Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync Panthor with drm-tip #301

Merged
merged 31 commits into from
Dec 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
c8ca3e9
drm/sched: add optional errno to drm_sched_start()
Aug 26, 2024
049d0bb
drm/scheduler: Improve documentation
ShuichengLin Sep 17, 2024
5e8f1d3
drm/sched: Optimise drm_sched_entity_push_job
Oct 16, 2024
63d336b
drm/sched: Stop setting current entity in FIFO mode
Oct 16, 2024
ebdb66c
drm/sched: Re-group and rename the entity run-queue lock
Oct 16, 2024
4fa255f
drm/sched: Further optimise drm_sched_entity_push_job
Oct 16, 2024
75a1ffd
drm/sched: memset() 'job' in drm_sched_job_init()
Oct 21, 2024
48a8510
drm/sched: warn about drm_sched_job_init()'s partial init
Oct 23, 2024
c8fd92c
drm/sched: Mark scheduler work queues with WQ_MEM_RECLAIM
mbrost05 Oct 23, 2024
9c7f3d8
drm/sched: Document purpose of drm_sched_{start,stop}
Oct 29, 2024
3af756a
drm/sched: Improve teardown documentation
Nov 5, 2024
0e2c18d
drm/panthor: Use the BITS_PER_LONG macro
Sep 2, 2024
609397a
drm/panthor: Add DEV_QUERY_TIMESTAMP_INFO dev query
marysaka Aug 30, 2024
d5dead0
drm/panthor: Display FW version information
Sep 6, 2024
a379dad
drm/panthor: Add PANTHOR_GROUP_PRIORITY_REALTIME group priority
marysaka Sep 9, 2024
d3f5674
drm/panthor: Add DEV_QUERY_GROUP_PRIORITIES_INFO dev query
marysaka Sep 9, 2024
55c06d3
drm/panthor: introduce job cycle and timestamp accounting
larunbe Sep 23, 2024
613367e
drm/panthor: record current and maximum device clock frequencies
larunbe Sep 23, 2024
4acff6d
drm/panthor: add sysfs knob for enabling job profiling
larunbe Sep 23, 2024
7920423
drm/panthor: Fix firmware initialization on systems with a page size …
bbrezillon Oct 30, 2024
8d7ea27
drm/panthor: Fail job creation when the group is dead
bbrezillon Oct 29, 2024
6494e61
drm/panthor: Report group as timedout when we fail to properly suspend
bbrezillon Oct 29, 2024
afc057f
drm/panthor: Fix OPP refcnt leaks in devfreq initialisation
larunbe Nov 5, 2024
629af85
drm/panthor: Lock XArray when getting entries for the VM
dliviu Nov 6, 2024
bba563a
drm/panthor: Be stricter about IO mapping flags
thejh Nov 4, 2024
4941839
drm/panthor: Fix handling of partial GPU mapping of BOs
akagoe01 Nov 11, 2024
d9f2eae
drm/panthor: Update memattr programing to align with GPU spec
akagoe01 Oct 30, 2024
6907585
drm/panthor: Explicitly set the coherency mode
akagoe01 Oct 30, 2024
3972500
drm/panthor: Simplify FW fast reset path
Nov 19, 2024
c1322e7
drm/panthor: Fix compilation failure on panthor_fw.c
dliviu Nov 19, 2024
6e73d82
drm/panthor: Fix a typo in the FW iface flag definitions
bbrezillon Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions Documentation/ABI/testing/sysfs-driver-panthor-profiling
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
What: /sys/bus/platform/drivers/panthor/.../profiling
Date: September 2024
KernelVersion: 6.11.0
Contact: Adrian Larumbe <[email protected]>
Description:
Bitmask to enable drm fdinfo's job profiling measurements.
Valid values are:
0: Don't enable fdinfo job profiling sources.
1: Enable GPU cycle measurements for running jobs.
2: Enable GPU timestamp sampling for running jobs.
46 changes: 46 additions & 0 deletions Documentation/gpu/panthor.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
.. SPDX-License-Identifier: GPL-2.0+

=========================
drm/Panthor CSF driver
=========================

.. _panfrost-usage-stats:

Panthor DRM client usage stats implementation
==============================================

The drm/Panthor driver implements the DRM client usage stats specification as
documented in :ref:`drm-client-usage-stats`.

Example of the output showing the implemented key value pairs and entirety of
the currently possible format options:

::
pos: 0
flags: 02400002
mnt_id: 29
ino: 491
drm-driver: panthor
drm-client-id: 10
drm-engine-panthor: 111110952750 ns
drm-cycles-panthor: 94439687187
drm-maxfreq-panthor: 1000000000 Hz
drm-curfreq-panthor: 1000000000 Hz
drm-total-memory: 16480 KiB
drm-shared-memory: 0
drm-active-memory: 16200 KiB
drm-resident-memory: 16480 KiB
drm-purgeable-memory: 0

Possible `drm-engine-` key names are: `panthor`.
`drm-curfreq-` values convey the current operating frequency for that engine.

Users must bear in mind that engine and cycle sampling are disabled by default,
because of power saving concerns. `fdinfo` users and benchmark applications which
query the fdinfo file must make sure to toggle the job profiling status of the
driver by writing into the appropriate sysfs node::

echo <N> > /sys/bus/platform/drivers/panthor/[a-f0-9]*.gpu/profiling

Where `N` is a bit mask where cycle and timestamp sampling are respectively
enabled by the first and second bits.
4 changes: 2 additions & 2 deletions drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -5399,7 +5399,7 @@ int amdgpu_device_gpu_recover(struct amdgpu_device *adev,
if (!tmp_adev->asic_reset_res && !job_signaled)
drm_sched_resubmit_jobs(&ring->sched);

drm_sched_start(&ring->sched);
drm_sched_start(&ring->sched, 0);
}

if (adev->enable_mes && adev->ip_versions[GC_HWIP][0] != IP_VERSION(11, 0, 3))
Expand Down Expand Up @@ -5854,7 +5854,7 @@ void amdgpu_pci_resume(struct pci_dev *pdev)


drm_sched_resubmit_jobs(&ring->sched);
drm_sched_start(&ring->sched);
drm_sched_start(&ring->sched, 0);
}

amdgpu_device_unset_mp1_state(adev);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/etnaviv/etnaviv_sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static enum drm_gpu_sched_stat etnaviv_sched_timedout_job(struct drm_sched_job

drm_sched_resubmit_jobs(&gpu->sched);

drm_sched_start(&gpu->sched);
drm_sched_start(&gpu->sched, 0);
return DRM_GPU_SCHED_STAT_NOMINAL;

out_no_timeout:
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/lima/lima_sched.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ static enum drm_gpu_sched_stat lima_sched_timedout_job(struct drm_sched_job *job
lima_pm_idle(ldev);

drm_sched_resubmit_jobs(&pipe->base);
drm_sched_start(&pipe->base);
drm_sched_start(&pipe->base, 0);

return DRM_GPU_SCHED_STAT_NOMINAL;
}
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/panfrost/panfrost_job.c
Original file line number Diff line number Diff line change
Expand Up @@ -696,7 +696,7 @@ panfrost_reset(struct panfrost_device *pfdev,

/* Restart the schedulers */
for (i = 0; i < NUM_JOB_SLOTS; i++)
drm_sched_start(&pfdev->js->queue[i].sched);
drm_sched_start(&pfdev->js->queue[i].sched, 0);

/* Re-enable job interrupts now that everything has been restarted. */
job_write(pfdev, JOB_INT_MASK,
Expand Down
29 changes: 22 additions & 7 deletions drivers/gpu/drm/panthor/panthor_devfreq.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,14 +62,20 @@ static void panthor_devfreq_update_utilization(struct panthor_devfreq *pdevfreq)
static int panthor_devfreq_target(struct device *dev, unsigned long *freq,
u32 flags)
{
struct panthor_device *ptdev = dev_get_drvdata(dev);
struct dev_pm_opp *opp;
int err;

opp = devfreq_recommended_opp(dev, freq, flags);
if (IS_ERR(opp))
return PTR_ERR(opp);
dev_pm_opp_put(opp);

return dev_pm_opp_set_rate(dev, *freq);
err = dev_pm_opp_set_rate(dev, *freq);
if (!err)
ptdev->current_frequency = *freq;

return err;
}

static void panthor_devfreq_reset(struct panthor_devfreq *pdevfreq)
Expand Down Expand Up @@ -130,6 +136,7 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
struct panthor_devfreq *pdevfreq;
struct dev_pm_opp *opp;
unsigned long cur_freq;
unsigned long freq = ULONG_MAX;
int ret;

pdevfreq = drmm_kzalloc(&ptdev->base, sizeof(*ptdev->devfreq), GFP_KERNEL);
Expand All @@ -156,12 +163,6 @@ int panthor_devfreq_init(struct panthor_device *ptdev)

cur_freq = clk_get_rate(ptdev->clks.core);

opp = devfreq_recommended_opp(dev, &cur_freq, 0);
if (IS_ERR(opp))
return PTR_ERR(opp);

panthor_devfreq_profile.initial_freq = cur_freq;

/* Regulator coupling only takes care of synchronizing/balancing voltage
* updates, but the coupled regulator needs to be enabled manually.
*
Expand Down Expand Up @@ -192,16 +193,30 @@ int panthor_devfreq_init(struct panthor_device *ptdev)
return ret;
}

opp = devfreq_recommended_opp(dev, &cur_freq, 0);
if (IS_ERR(opp))
return PTR_ERR(opp);

panthor_devfreq_profile.initial_freq = cur_freq;
ptdev->current_frequency = cur_freq;

/*
* Set the recommend OPP this will enable and configure the regulator
* if any and will avoid a switch off by regulator_late_cleanup()
*/
ret = dev_pm_opp_set_opp(dev, opp);
dev_pm_opp_put(opp);
if (ret) {
DRM_DEV_ERROR(dev, "Couldn't set recommended OPP\n");
return ret;
}

/* Find the fastest defined rate */
opp = dev_pm_opp_find_freq_floor(dev, &freq);
if (IS_ERR(opp))
return PTR_ERR(opp);
ptdev->fast_rate = freq;

dev_pm_opp_put(opp);

/*
Expand Down
26 changes: 25 additions & 1 deletion drivers/gpu/drm/panthor/panthor_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@
#include "panthor_regs.h"
#include "panthor_sched.h"

static int panthor_gpu_coherency_init(struct panthor_device *ptdev)
{
ptdev->coherent = device_get_dma_attr(ptdev->base.dev) == DEV_DMA_COHERENT;

if (!ptdev->coherent)
return 0;

/* Check if the ACE-Lite coherency protocol is actually supported by the GPU.
* ACE protocol has never been supported for command stream frontend GPUs.
*/
if ((gpu_read(ptdev, GPU_COHERENCY_FEATURES) &
GPU_COHERENCY_PROT_BIT(ACE_LITE)))
return 0;

drm_err(&ptdev->base, "Coherency not supported by the device");
return -ENOTSUPP;
}

static int panthor_clk_init(struct panthor_device *ptdev)
{
ptdev->clks.core = devm_clk_get(ptdev->base.dev, NULL);
Expand Down Expand Up @@ -156,7 +174,9 @@ int panthor_device_init(struct panthor_device *ptdev)
struct page *p;
int ret;

ptdev->coherent = device_get_dma_attr(ptdev->base.dev) == DEV_DMA_COHERENT;
ret = panthor_gpu_coherency_init(ptdev);
if (ret)
return ret;

init_completion(&ptdev->unplug.done);
ret = drmm_mutex_init(&ptdev->base, &ptdev->unplug.lock);
Expand Down Expand Up @@ -390,11 +410,15 @@ int panthor_device_mmap_io(struct panthor_device *ptdev, struct vm_area_struct *
{
u64 offset = (u64)vma->vm_pgoff << PAGE_SHIFT;

if ((vma->vm_flags & VM_SHARED) == 0)
return -EINVAL;

switch (offset) {
case DRM_PANTHOR_USER_FLUSH_ID_MMIO_OFFSET:
if (vma->vm_end - vma->vm_start != PAGE_SIZE ||
(vma->vm_flags & (VM_WRITE | VM_EXEC)))
return -EINVAL;
vma->vm_flags &= ~VM_MAYWRITE;

break;

Expand Down
28 changes: 28 additions & 0 deletions drivers/gpu/drm/panthor/panthor_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,25 @@ struct panthor_irq {
atomic_t suspended;
};

/**
* enum panthor_device_profiling_mode - Profiling state
*/
enum panthor_device_profiling_flags {
/** @PANTHOR_DEVICE_PROFILING_DISABLED: Profiling is disabled. */
PANTHOR_DEVICE_PROFILING_DISABLED = 0,

/** @PANTHOR_DEVICE_PROFILING_CYCLES: Sampling job cycles. */
PANTHOR_DEVICE_PROFILING_CYCLES = BIT(0),

/** @PANTHOR_DEVICE_PROFILING_TIMESTAMP: Sampling job timestamp. */
PANTHOR_DEVICE_PROFILING_TIMESTAMP = BIT(1),

/** @PANTHOR_DEVICE_PROFILING_ALL: Sampling everything. */
PANTHOR_DEVICE_PROFILING_ALL =
PANTHOR_DEVICE_PROFILING_CYCLES |
PANTHOR_DEVICE_PROFILING_TIMESTAMP,
};

/**
* struct panthor_device - Panthor device
*/
Expand Down Expand Up @@ -162,6 +181,15 @@ struct panthor_device {
*/
struct page *dummy_latest_flush;
} pm;

/** @profile_mask: User-set profiling flags for job accounting. */
u32 profile_mask;

/** @current_frequency: Device clock frequency at present. Set by DVFS*/
unsigned long current_frequency;

/** @fast_rate: Maximum device clock frequency. Set by DVFS */
unsigned long fast_rate;
};

/**
Expand Down
Loading
Loading