From: "Dixit, Ashutosh" <ashutosh.dixit@intel.com>
To: "Iddamsetty, Aravind" <aravind.iddamsetty@intel.com>
Cc: Bommu Krishnaiah <krishnaiah.bommu@intel.com>,
Tvrtko Ursulin <tvrtko.ursulin@intel.com>,
intel-xe@lists.freedesktop.org,
Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [Intel-xe] [PATCH v3 2/2] drm/xe/pmu: Enable PMU interface
Date: Fri, 11 Aug 2023 12:17:17 -0700 [thread overview]
Message-ID: <87wmy1z8w2.wl-ashutosh.dixit@intel.com> (raw)
In-Reply-To: <890d81c9-f617-f77d-848c-de92cb9396c3@intel.com>
On Thu, 10 Aug 2023 23:17:47 -0700, Iddamsetty, Aravind wrote:
>
Hi Aravind,
> On 11-08-2023 09:08, Dixit, Ashutosh wrote:
>
> > On Thu, 10 Aug 2023 14:55:41 -0700, Rodrigo Vivi wrote:
> >
> >> On Thu, Aug 10, 2023 at 01:40:16PM +0530, Iddamsetty, Aravind wrote:
> >>> On 10-08-2023 08:10, Dixit, Ashutosh wrote:
> >>>
> >>>> On Wed, 09 Aug 2023 06:11:48 -0700, Iddamsetty, Aravind wrote:
> >>>>
> >>>>> On 09-08-2023 17:27, Iddamsetty, Aravind wrote:
> >>>>>> On 09-08-2023 15:25, Iddamsetty, Aravind wrote:
> >>>>>>> On 09-08-2023 12:58, Dixit, Ashutosh wrote:
> >>>>>>>> On Tue, 08 Aug 2023 04:54:36 -0700, Aravind Iddamsetty wrote:
> >>>>>>>>
> >>>>>>>> Spotted a few remaining things. See if it's possible to fix these up and
> >>>>>>>> send another version.
> >>>>>>>>
> >>>>>>>>> diff --git a/drivers/gpu/drm/xe/xe_pmu.c b/drivers/gpu/drm/xe/xe_pmu.c
> >>>>>>>>> new file mode 100644
> >>>>>>>>> index 000000000000..9637f8283641
> >>>>>>>>> --- /dev/null
> >>>>>>>>> +++ b/drivers/gpu/drm/xe/xe_pmu.c
> >>>>>>>>> @@ -0,0 +1,673 @@
> >>>>>>>
> >>>>>>> <snip>
> >>>>>>>>> +static u64 __engine_group_busyness_read(struct xe_gt *gt, int sample_type)
> >>>>>>>>> +{
> >>>>>>>>> + u64 val = 0;
> >>>>>>>>> +
> >>>>>>>>
> >>>>>>>> What is the forcewake domain for these registers? Don't we need to get
> >>>>>>>> forcewake before reading these. Something like:
> >>>>>>>>
> >>>>>>>> XE_WARN_ON(xe_force_wake_get(gt_to_fw(gt), XE_FORCEWAKE_ALL));
> >>>>>>>
> >>>>>>> based on BSPEC:67609 these belong to GT power domain, so acquiring that
> >>>>>>> should be sufficient.
> >>>>>>
> >>>>>> But if i understand correctly taking forcewake is not allowed here as it
> >>>>>> is an atomic context and forcewake can sleep and that is what I'm seeing
> >>>>>> as well, might also be the reason why i915 didn't do that as well.
> >>>>>>
> >>>>>> [ 899.114316] BUG: sleeping function called from invalid context at
> >>>>>> kernel/locking/mutex.c:580
> >>>>>> [ 899.115768] in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid:
> >>>>>> 290, name: kworker/27:1
> >>>>>
> >>>>> that is the reason why in i915 we were doing similar thing of storing
> >>>>> the counter as we enter rc6, not sure how do we do that in xe.
> >>>>
> >>>> Just to check, which code path(s) is/are aotmic context:
> >>>>
> >>>> a. xe_pm_suspend
> >>>> b. xe_pm_runtime_suspend
> >>>> c. xe_pmu_event_read
> >>>
> >>> pmu_event_read and runtime_suspend are atomic contexts.
> >>
> >> what about doing this at xe_pci_runtime_idle() ?
> >>
> >> This will run after the autosuspend time elapses,
> >> but before calling any suspend. Also, there's no requirement of
> >> that function to be in atomic context. So you could forcewake_get/put
> >> and stash your registers before we go runtime_suspend.
> >
> > Thanks for the suggestion. Though Anshuman was saying that rpm_suspend
> > callback itself is not called in atomic context, Aravind seems to have made
> > a mistake. Aravind could you please confirm?
>
> Yup i made a mistake runtime_suspend is not an atomic context, in actual
> we are taking the forcewake in gt_suspend which calls the xe_pmu_suspend.
OK, great, thanks for confirming.
> >
> > In any case there seems to be a way out here, we should work to save off
> > the registers while suspending in either the idle or suspend callbacks.
> >
> >>>> Now I am wondering if GuC should provide these counters too along with
> >>>> other busyness values it provides, since GuC is what control RC6
> >>>> entry/exit. But let's try to understand the issue some more first.
> >>>
> >>> do you mean GuC reading these registers and presenting us in a way, will
> >>> need to think over how does it fit in the PMU.
> >
> > I think better to leave GuC out since it's a long process to modify the GuC
> > API. So let's cancel that.
> >
> > About xe_pmu_event_read being atomic context, since the registers might be
> > getting updated while xe_pmu_event_read calls are happening, the only way
> > out I am seeing is to run a kthread (specifically a delayed work item)
> > while PMU is active. The work item will run every 10 ms or so and save off
> > the registers (since we cannot take forcewake in xe_pmu_event_read and read
> > the registers). So this way we should be able to report register values
> > which are at most 10 ms old.
>
> there are two cases here:
Correct.
> 1. similar to suspend, we shall capture the register state before GT goes
> to rc6 and that shall cover suspend case as well
>
> 2. in xe_pmu_event_read, we shall check if device is not in rc6 rather
> than awake and read register but might have to take forcewake
>
> for first I do not think we have a way to know in Xe if GT is entering
> rc6 (like gt_park in i915).
But we can take forcewake here to either prevent GT from entering RC6 or
bring it out of RC6 to read the registers.
> even in kthread/timer we shall take forcewake only when GT is out of
Timer is interrupt/atomic context so it cannot be used, it will have to be
a kthread/workqueue.
> rc6, but there is a problem our devices default autosuspend is in 1sec
> so if we have a timer or kthread at msec the user shall also adjust the
> autosuspend to ms or else device will never go to suspend as we take the
> pm reference in mem_access_get.
The kthread will only try to get forcewake (to read the registers) if the
device is awake, so it will use xe_device_mem_access_get_if_ongoing. If
device is not awake use previous stored values.
Thanks.
--
Ashutosh
> > Any other ideas here?
> >
> > Thanks.
> > --
> > Ashutosh
> >
> >>>>>>>>
> >>>>>>>>> + switch (sample_type) {
> >>>>>>>>> + case __XE_SAMPLE_RENDER_GROUP_BUSY:
> >>>>>>>>> + val = xe_mmio_read32(gt, XE_OAG_RENDER_BUSY_FREE);
> >>>>>>>>> + break;
> >>>>>>>>> + case __XE_SAMPLE_COPY_GROUP_BUSY:
> >>>>>>>>> + val = xe_mmio_read32(gt, XE_OAG_BLT_BUSY_FREE);
> >>>>>>>>> + break;
> >>>>>>>>> + case __XE_SAMPLE_MEDIA_GROUP_BUSY:
> >>>>>>>>> + val = xe_mmio_read32(gt, XE_OAG_ANY_MEDIA_FF_BUSY_FREE);
> >>>>>>>>> + break;
> >>>>>>>>> + case __XE_SAMPLE_ANY_ENGINE_GROUP_BUSY:
> >>>>>>>>> + val = xe_mmio_read32(gt, XE_OAG_RC0_ANY_ENGINE_BUSY_FREE);
> >>>>>>>>> + break;
> >>>>>>>>> + default:
> >>>>>>>>> + drm_warn(>->tile->xe->drm, "unknown pmu event\n");
> >>>>>>>>> + }
> >>>>>>>>
> >>>>>>>> And similarly here:
> >>>>>>>>
> >>>>>>>> XE_WARN_ON(xe_force_wake_put(gt_to_fw(gt), XE_FORCEWAKE_ALL));
next prev parent reply other threads:[~2023-08-11 19:18 UTC|newest]
Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-08-08 11:54 [Intel-xe] [PATCH v3 0/2] drm/xe/pmu: Enable PMU interface Aravind Iddamsetty
2023-08-08 11:54 ` [Intel-xe] [PATCH v3 1/2] drm/xe: Get GT clock to nanosecs Aravind Iddamsetty
2023-08-09 5:08 ` Dixit, Ashutosh
2023-08-09 11:07 ` Iddamsetty, Aravind
2023-08-08 11:54 ` [Intel-xe] [PATCH v3 2/2] drm/xe/pmu: Enable PMU interface Aravind Iddamsetty
2023-08-09 7:28 ` Dixit, Ashutosh
2023-08-09 7:46 ` Iddamsetty, Aravind
2023-08-09 11:39 ` Iddamsetty, Aravind
2023-08-10 2:17 ` Dixit, Ashutosh
2023-08-10 2:06 ` Dixit, Ashutosh
2023-08-09 9:55 ` Iddamsetty, Aravind
2023-08-09 11:57 ` Iddamsetty, Aravind
2023-08-09 13:11 ` Iddamsetty, Aravind
2023-08-10 2:40 ` Dixit, Ashutosh
2023-08-10 8:10 ` Iddamsetty, Aravind
2023-08-10 21:55 ` Rodrigo Vivi
2023-08-11 3:38 ` Dixit, Ashutosh
2023-08-11 6:17 ` Iddamsetty, Aravind
2023-08-11 19:17 ` Dixit, Ashutosh [this message]
2023-08-14 2:02 ` Dixit, Ashutosh
2023-08-14 4:19 ` Iddamsetty, Aravind
2023-08-08 12:08 ` [Intel-xe] ✓ CI.Patch_applied: success for drm/xe/pmu: Enable PMU interface (rev3) Patchwork
2023-08-08 12:09 ` [Intel-xe] ✗ CI.checkpatch: warning " Patchwork
2023-08-08 12:10 ` [Intel-xe] ✓ CI.KUnit: success " Patchwork
2023-08-08 12:14 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-08-08 12:14 ` [Intel-xe] ✓ CI.Hooks: " Patchwork
2023-08-08 12:14 ` [Intel-xe] ✗ CI.checksparse: warning " Patchwork
2023-08-08 12:51 ` [Intel-xe] ✗ CI.BAT: 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=87wmy1z8w2.wl-ashutosh.dixit@intel.com \
--to=ashutosh.dixit@intel.com \
--cc=aravind.iddamsetty@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=krishnaiah.bommu@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=tvrtko.ursulin@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