Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Summers, Stuart" <stuart.summers@intel.com>
To: "tvrtko.ursulin@linux.intel.com" <tvrtko.ursulin@linux.intel.com>
Cc: "intel-gfx@lists.freedesktop.org" <intel-gfx@lists.freedesktop.org>
Subject: Re: [Intel-gfx] [PATCH 1/2] drm/i915: Fix NPD in PMU during driver teardown
Date: Thu, 4 Aug 2022 18:56:02 +0000	[thread overview]
Message-ID: <9f8bc74b5f0de4ca2803caba4c99a7bdea0c1953.camel@intel.com> (raw)
In-Reply-To: <a3920919-26c0-fde9-7954-cf44539d223d@linux.intel.com>

On Thu, 2022-08-04 at 09:42 +0100, Tvrtko Ursulin wrote:
> On 04/08/2022 00:03, Stuart Summers wrote:
> > In the driver teardown, we are unregistering the gt prior
> > to unregistering the PMU. This means there is a small window
> > of time in which the application can request metrics from the
> > PMU, some of which are calling into the uapi engines list,
> > while the engines are not available. In this case we can
> > see null pointer dereferences.
> > 
> > Fix this ordering in both the driver load and unload sequences.
> > 
> > v1: Actually address the driver load/unload ordering issue
> > v2: Remove the NULL checks since they shouldn't be necessary
> >      now with the proper ordering
> > 
> > Fixes: 42014f69bb235 ("drm/i915: Hook up GT power management")
> 
> What happened in this commit to break it?

Hm.. well this was the patch that added the abstraction ordering issue,
i.e. gt_register/unregister. There isn't anything specifically broken
here since we don't actually access the gt structure underneath. My
assertion is that this patch should have taken the expansion of the gt
structure into consideration and added the correct ordering with
respect to the pmu.

Are you asking for the specific patch where things stopped working
functionally?

Thanks,
Stuart

> 
> > Signed-off-by: Stuart Summers <stuart.summers@intel.com>
> > ---
> >   drivers/gpu/drm/i915/i915_driver.c | 11 ++++++-----
> >   1 file changed, 6 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/i915_driver.c
> > b/drivers/gpu/drm/i915/i915_driver.c
> > index deb8a8b76965a..ee4dcb85d2060 100644
> > --- a/drivers/gpu/drm/i915/i915_driver.c
> > +++ b/drivers/gpu/drm/i915/i915_driver.c
> > @@ -717,7 +717,6 @@ static void i915_driver_register(struct
> > drm_i915_private *dev_priv)
> >   	struct drm_device *dev = &dev_priv->drm;
> >   
> >   	i915_gem_driver_register(dev_priv);
> > -	i915_pmu_register(dev_priv);
> >   
> >   	intel_vgpu_register(dev_priv);
> >   
> > @@ -731,11 +730,12 @@ static void i915_driver_register(struct
> > drm_i915_private *dev_priv)
> >   	i915_debugfs_register(dev_priv);
> >   	i915_setup_sysfs(dev_priv);
> >   
> > +	intel_gt_driver_register(to_gt(dev_priv));
> > +
> >   	/* Depends on sysfs having been initialized */
> > +	i915_pmu_register(dev_priv);
> >   	i915_perf_register(dev_priv);
> >   
> > -	intel_gt_driver_register(to_gt(dev_priv));
> > -
> 
> There was a bit of a time distance since we originally discussed this
> so 
> things kind of evaporated from my head. Or at least it feels like
> that. 
>   Today when I look at the code I don't understand why is this
> shuffle 
> relevant.
> 
> The sysfs comment does not really apply to pmu, but also if I look
> into 
> intel_gt_driver_(un)register I did not spot what is the relevant
> part 
> which interacts with the PMU.
> 
> On register it is engine list first then PMU.
> 
> On unregister it is PMU first, then engine list:
> 
>    i915_driver_remove
>      i915_driver_unregister
>        i915_pmu_unregister
>      i915_gem_driver_remove
>        clears uabi engines list
> 
> Help please? :)
> 
> Regards,
> 
> Tvrtko
> 
> >   	intel_display_driver_register(dev_priv);
> >   
> >   	intel_power_domains_enable(dev_priv);
> > @@ -762,11 +762,12 @@ static void i915_driver_unregister(struct
> > drm_i915_private *dev_priv)
> >   
> >   	intel_display_driver_unregister(dev_priv);
> >   
> > -	intel_gt_driver_unregister(to_gt(dev_priv));
> > -
> >   	i915_perf_unregister(dev_priv);
> > +	/* GT should be available until PMU is gone */
> >   	i915_pmu_unregister(dev_priv);
> >   
> > +	intel_gt_driver_unregister(to_gt(dev_priv));
> > +
> >   	i915_teardown_sysfs(dev_priv);
> >   	drm_dev_unplug(&dev_priv->drm);
> >   

  reply	other threads:[~2022-08-04 18:56 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-08-03 23:03 [Intel-gfx] [PATCH 1/2] drm/i915: Fix NPD in PMU during driver teardown Stuart Summers
2022-08-03 23:03 ` [Intel-gfx] [PATCH 2/2] drm/i915: Only disable PMU on stop if not already closed Stuart Summers
2022-08-04  8:46   ` Tvrtko Ursulin
2022-08-04 18:56     ` Summers, Stuart
2022-08-04 23:26   ` Umesh Nerlige Ramappa
2022-08-03 23:50 ` [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [1/2] drm/i915: Fix NPD in PMU during driver teardown Patchwork
2022-08-04  6:29 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2022-08-04  8:42 ` [Intel-gfx] [PATCH 1/2] " Tvrtko Ursulin
2022-08-04 18:56   ` Summers, Stuart [this message]
2022-08-05  9:26     ` Tvrtko Ursulin

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=9f8bc74b5f0de4ca2803caba4c99a7bdea0c1953.camel@intel.com \
    --to=stuart.summers@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tvrtko.ursulin@linux.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