From: Lukas Zapolskas <lukas.zapolskas@arm.com>
To: Boris Brezillon <boris.brezillon@collabora.com>,
Steven Price <steven.price@arm.com>,
Liviu Dudau <liviu.dudau@arm.com>,
Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
Maxime Ripard <mripard@kernel.org>,
Thomas Zimmermann <tzimmermann@suse.de>,
David Airlie <airlied@gmail.com>, Simona Vetter <simona@ffwll.ch>,
dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org
Cc: "Adrián Larumbe" <adrian.larumbe@collabora.com>,
"Lukas Zapolskas" <lukas.zapolskas@arm.com>
Subject: [PATCH v4 0/7] Performance counter implementation with single manual client support
Date: Fri, 16 May 2025 16:49:34 +0100 [thread overview]
Message-ID: <cover.1747148172.git.lukas.zapolskas@arm.com> (raw)
Hello,
This patch set implements initial support for performance counter
sampling in Panthor, as a follow-up for Adrián Larumbe's patch
set [1]. This version of the patch series fixes a number of issues,
including FW ring buffer wrapping and IRQ handling for the
performance counter IRQs. The size of the sample is also added
to the uAPI, allowing for the PERF_INFO DEV_QUERY to be sufficient
to handle backwards and forwards compatibility of the interface.
The Mesa implementation is also now available [3].
Existing performance counter workflows, such as those in game
engines, and user-space power models/governor implementations
require the ability to simultaneously obtain counter data. The
hardware and firmware interfaces support a single global
configuration, meaning the kernel must allow for the multiplexing.
It is also in the best position to supplement the counter data
with contextual information about elapsed sampling periods,
information on the power state transitions undergone during
the sampling period, and cycles elapsed on specific clocks chosen
by the integrator.
Each userspace client creates a session, providing an enable
mask of counter values it requires, a BO for a ring buffer,
and a separate BO for the insert and extract indices, along with
an eventfd to signal counter capture, all of which are kept fixed
for the lifetime of the session. When emitting a sample for a
session, counters that were not requested are stripped out,
and non-counter information needed to interpret counter values
is added to either the sample header, or the block header,
which are stored in-line with the counter values in the sample.
The proposed uAPI specifies two major sources of supplemental
information:
- coarse-grained block state transitions are provided on newer
FW versions which support the metadata block, a FW-provided
counter block which indicates the reason a sample was taken
when entering or exiting a non-counting region, or when a
shader core has powered down.
- the clock assignments to individual blocks is done by
integrators, and in order to normalize counter values
which count cycles, userspace must know both the clock
cycles elapsed over the sampling period, and which
of the clocks that particular block is associated
with.
All of the sessions are then aggregated by the sampler, which
handles the programming of the FW interface and subsequent
handling of the samples coming from FW.
v2:
- Fixed offset issues into FW ring buffer
- Fixed sparse shader core handling
- Added pre- and post- reset handlers
- Added module param to control size of FW ring buffer
- Clarified naming on sampler functions
- Added error logging for PERF_SETUP
v3:
- Added sample size to the uAPI.
- Clarified the bit-to-counter mapping for enable masks.
- Fixed IRQ handling: the PERFCNT_THRESHOLD and PERFCNT_OVERFLOW
interrupts can be handled by checking the difference between the
REQ and ACK bits, whereas PERFCNT_SAMPLE needs external data to
validate.
- FW ring buffer indices are now only wrapped when reading the buffer
and are otherwise left in their pre-wrapped form.
- Accumulation index is now bumped after the first copy.
- All insert and extract index reads now use the proper, full-width
type.
- L2 slices are now computed via a macro to extract the relevant
bits from the MEM_FEATURES register. This macro was moved from
the uAPI due to changes in the register making it unstable.
- Consistently take the sampler lock to check if a sample has been
requested.
[1]: https://lore.kernel.org/lkml/20240305165820.585245-1-adrian.larumbe@collabora.com/T/#m67d1f89614fe35dc0560e8304d6731eb1a6942b6
[2]: https://lore.kernel.org/lkml/20241211165024.490748-1-lukas.zapolskas@arm.com/
[3]: https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/35024
Adrián Larumbe (1):
drm/panthor: Implement the counter sampler and sample handling
Lukas Zapolskas (6):
drm/panthor: Add performance counter uAPI
drm/panthor: Add DEV_QUERY.PERF_INFO handling for Gx10
drm/panthor: Add panthor perf initialization and termination
drm/panthor: Introduce sampling sessions to handle userspace clients
drm/panthor: Add suspend, resume and reset handling
drm/panthor: Expose the panthor perf ioctls
base-commit: 96c85e428ebaeacd2c640eba075479ab92072ccd
Adrián Larumbe (1):
drm/panthor: Implement the counter sampler and sample handling
Lukas Zapolskas (6):
drm/panthor: Add performance counter uAPI
drm/panthor: Add DEV_QUERY.PERF_INFO handling for Gx10
drm/panthor: Add panthor perf initialization and termination
drm/panthor: Introduce sampling sessions to handle userspace clients
drm/panthor: Add suspend, resume and reset handling
drm/panthor: Expose the panthor perf ioctls
drivers/gpu/drm/panthor/Makefile | 1 +
drivers/gpu/drm/panthor/panthor_device.c | 14 +-
drivers/gpu/drm/panthor/panthor_device.h | 11 +-
drivers/gpu/drm/panthor/panthor_drv.c | 150 +-
drivers/gpu/drm/panthor/panthor_fw.c | 6 +
drivers/gpu/drm/panthor/panthor_fw.h | 9 +-
drivers/gpu/drm/panthor/panthor_perf.c | 1982 ++++++++++++++++++++++
drivers/gpu/drm/panthor/panthor_perf.h | 40 +
drivers/gpu/drm/panthor/panthor_regs.h | 1 +
include/uapi/drm/panthor_drm.h | 565 ++++++
10 files changed, 2774 insertions(+), 5 deletions(-)
create mode 100644 drivers/gpu/drm/panthor/panthor_perf.c
create mode 100644 drivers/gpu/drm/panthor/panthor_perf.h
base-commit: 96c85e428ebaeacd2c640eba075479ab92072ccd
--
2.33.0.dirty
next reply other threads:[~2025-05-16 15:58 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-05-16 15:49 Lukas Zapolskas [this message]
2025-05-16 15:49 ` [PATCH v4 1/7] drm/panthor: Add performance counter uAPI Lukas Zapolskas
2025-07-18 2:43 ` Adrián Larumbe
2025-07-21 8:46 ` Lukas Zapolskas
2025-05-16 15:49 ` [PATCH v4 2/7] drm/panthor: Add DEV_QUERY.PERF_INFO handling for Gx10 Lukas Zapolskas
2025-07-18 2:52 ` Adrián Larumbe
2025-07-21 9:04 ` Lukas Zapolskas
2025-07-18 15:11 ` Adrián Larumbe
2025-07-21 9:06 ` Lukas Zapolskas
2025-05-16 15:49 ` [PATCH v4 3/7] drm/panthor: Add panthor perf initialization and termination Lukas Zapolskas
2025-07-18 3:10 ` Adrián Larumbe
2025-07-21 9:10 ` Lukas Zapolskas
2025-05-16 15:49 ` [PATCH v4 4/7] drm/panthor: Introduce sampling sessions to handle userspace clients Lukas Zapolskas
2025-05-17 7:53 ` kernel test robot
2025-06-20 15:28 ` Steven Price
2025-07-21 9:58 ` Lukas Zapolskas
2025-07-18 3:34 ` Adrián Larumbe
2025-07-21 9:53 ` Lukas Zapolskas
2025-05-16 15:49 ` [PATCH v4 5/7] drm/panthor: Implement the counter sampler and sample handling Lukas Zapolskas
2025-05-17 8:56 ` kernel test robot
2025-07-18 14:49 ` Adrián Larumbe
2025-07-25 10:29 ` Lukas Zapolskas
2025-05-16 15:49 ` [PATCH v4 6/7] drm/panthor: Add suspend, resume and reset handling Lukas Zapolskas
2025-07-18 15:01 ` Adrián Larumbe
2025-07-25 9:26 ` Lukas Zapolskas
2025-05-16 15:49 ` [PATCH v4 7/7] drm/panthor: Expose the panthor perf ioctls Lukas Zapolskas
2025-07-18 15:05 ` Adrián Larumbe
2025-07-18 15:19 ` Adrián Larumbe
2025-07-25 9:09 ` Lukas Zapolskas
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=cover.1747148172.git.lukas.zapolskas@arm.com \
--to=lukas.zapolskas@arm.com \
--cc=adrian.larumbe@collabora.com \
--cc=airlied@gmail.com \
--cc=boris.brezillon@collabora.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-kernel@vger.kernel.org \
--cc=liviu.dudau@arm.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=mripard@kernel.org \
--cc=simona@ffwll.ch \
--cc=steven.price@arm.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).