From: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
To: Riana Tauro <riana.tauro@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <anshuman.gupta@intel.com>,
<lucas.demarchi@intel.com>, <vinay.belgaumkar@intel.com>,
<soham.purkait@intel.com>, Rodrigo Vivi <rodrigo.vivi@intel.com>,
"Himal Prasad Ghimiray" <himal.prasad.ghimiray@intel.com>
Subject: Re: [PATCH v6 5/8] drm/xe/xe_pmu: Acquire forcewake on event init for engine events
Date: Wed, 12 Feb 2025 15:49:50 -0800 [thread overview]
Message-ID: <Z60zngGCAOpITKGN@orsosgc001> (raw)
In-Reply-To: <20250211100952.322303-6-riana.tauro@intel.com>
On Tue, Feb 11, 2025 at 03:39:47PM +0530, Riana Tauro wrote:
>When the engine events are created, acquire GT forcewake to read gpm
>timestamp required for the events and release on event destroy. This
>cannot be done during read due to the raw spinlock held my pmu.
>
>v2: remove forcewake counting (Umesh)
>
>Cc: Rodrigo Vivi <rodrigo.vivi@intel.com>
>Cc: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
>Signed-off-by: Riana Tauro <riana.tauro@intel.com>
>---
> drivers/gpu/drm/xe/xe_pmu.c | 52 +++++++++++++++++++++++++++++--
> drivers/gpu/drm/xe/xe_pmu_types.h | 4 +++
> 2 files changed, 54 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_pmu.c b/drivers/gpu/drm/xe/xe_pmu.c
>index dc89fa6d0ec5..0539dd61ddc3 100644
>--- a/drivers/gpu/drm/xe/xe_pmu.c
>+++ b/drivers/gpu/drm/xe/xe_pmu.c
>@@ -7,6 +7,7 @@
> #include <linux/device.h>
>
> #include "xe_device.h"
>+#include "xe_force_wake.h"
> #include "xe_gt_idle.h"
> #include "xe_guc_engine_activity.h"
> #include "xe_hw_engine.h"
>@@ -102,6 +103,37 @@ static struct xe_hw_engine *event_to_hwe(struct perf_event *event)
> return hwe;
> }
>
>+static bool is_engine_event(u64 config)
>+{
>+ unsigned int event_id = config_to_event_id(config);
>+
>+ return (event_id == XE_PMU_EVENT_ENGINE_TOTAL_TICKS ||
>+ event_id == XE_PMU_EVENT_ENGINE_ACTIVE_TICKS);
>+}
>+
>+static bool event_gt_forcewake(struct perf_event *event)
>+{
>+ struct xe_device *xe = container_of(event->pmu, typeof(*xe), pmu.base);
>+ u64 config = event->attr.config;
>+ struct xe_pmu *pmu = &xe->pmu;
>+ struct xe_gt *gt;
>+ unsigned int fw_ref;
>+
>+ if (!is_engine_event(config))
>+ return true;
>+
>+ gt = xe_device_get_gt(xe, config_to_gt_id(config));
>+
>+ fw_ref = xe_force_wake_get(gt_to_fw(gt), XE_FW_GT);
>+ if (!fw_ref)
>+ return false;
>+
>+ if (!pmu->fw_ref)
>+ pmu->fw_ref = fw_ref;
>+
>+ return true;
>+}
>+
> static bool event_supported(struct xe_pmu *pmu, unsigned int gt,
> unsigned int id)
> {
>@@ -144,6 +176,13 @@ static bool event_param_valid(struct perf_event *event)
> static void xe_pmu_event_destroy(struct perf_event *event)
> {
> struct xe_device *xe = container_of(event->pmu, typeof(*xe), pmu.base);
>+ struct xe_pmu *pmu = &xe->pmu;
>+ struct xe_gt *gt;
>+
>+ if (pmu->fw_ref) {
>+ gt = xe_device_get_gt(xe, config_to_gt_id(event->attr.config));
>+ xe_force_wake_put(gt_to_fw(gt), pmu->fw_ref);
>+ }
>
> drm_WARN_ON(&xe->drm, event->parent);
> xe_pm_runtime_put(xe);
>@@ -183,18 +222,27 @@ static int xe_pmu_event_init(struct perf_event *event)
> if (!event->parent) {
> drm_dev_get(&xe->drm);
> xe_pm_runtime_get(xe);
>+ if (!event_gt_forcewake(event)) {
>+ xe_pm_runtime_put(xe);
>+ drm_dev_put(&xe->drm);
>+ return -EINVAL;
>+ }
> event->destroy = xe_pmu_event_destroy;
> }
>
> return 0;
> }
>
>-static u64 read_engine_events(struct xe_gt *gt, struct perf_event *event)
>+static u64 read_engine_events(struct xe_gt *gt, struct perf_event *event, u64 prev)
extra space before u64 prev. Strangely checkpatch does not complain!
Rest LGTM,
Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
Thanks,
Umesh
next prev parent reply other threads:[~2025-02-12 23:49 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-11 10:09 [PATCH v6 0/8] PMU support for engine activity Riana Tauro
2025-02-11 10:09 ` [PATCH v6 1/8] drm/xe: Add engine activity support Riana Tauro
2025-02-11 10:09 ` [PATCH v6 2/8] drm/xe/trace: Add trace for engine activity Riana Tauro
2025-02-11 10:09 ` [PATCH v6 3/8] drm/xe/guc: Expose engine activity only for supported GuC version Riana Tauro
2025-02-13 18:08 ` Umesh Nerlige Ramappa
2025-02-11 10:09 ` [PATCH v6 4/8] drm/xe/xe_pmu: Add PMU support for engine activity Riana Tauro
2025-02-11 10:09 ` [PATCH v6 5/8] drm/xe/xe_pmu: Acquire forcewake on event init for engine events Riana Tauro
2025-02-12 23:49 ` Umesh Nerlige Ramappa [this message]
2025-02-11 10:09 ` [PATCH v6 6/8] drm/xe: Add support for per-function engine activity Riana Tauro
2025-02-11 10:09 ` [PATCH v6 7/8] drm/xe/xe_pmu: Add PMU support for per-function engine activity stats Riana Tauro
2025-02-11 10:09 ` [PATCH v6 8/8] drm/xe/pf: Enable " Riana Tauro
2025-02-11 10:48 ` ✓ CI.Patch_applied: success for PMU support for engine activity (rev2) Patchwork
2025-02-11 10:49 ` ✗ CI.checkpatch: warning " Patchwork
2025-02-11 10:50 ` ✓ CI.KUnit: success " Patchwork
2025-02-11 11:19 ` ✓ CI.Build: " Patchwork
2025-02-11 11:21 ` ✗ CI.Hooks: failure " Patchwork
2025-02-11 11:22 ` ✗ CI.checksparse: warning " Patchwork
2025-02-11 11:42 ` ✓ Xe.CI.BAT: success " Patchwork
2025-02-11 19:01 ` ✗ Xe.CI.Full: failure " Patchwork
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=Z60zngGCAOpITKGN@orsosgc001 \
--to=umesh.nerlige.ramappa@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=lucas.demarchi@intel.com \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=soham.purkait@intel.com \
--cc=vinay.belgaumkar@intel.com \
/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