Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com>
Subject: [PATCH 0/2] Fix crash due to open pmu events during unbind
Date: Tue, 13 Feb 2024 10:03:00 -0800	[thread overview]
Message-ID: <20240213180302.47266-1-umesh.nerlige.ramappa@intel.com> (raw)

Once a user opens an fd for a perf event, if the driver undergoes a
function level reset (FLR), the resources are not cleaned up as
expected. For this discussion FLR is defined as a PCI unbind followed by
a bind. perf_pmu_unregister() would cleanup everything, but when the
user closes the perf fd much later, perf_release() is called and we
encounter null pointer dereferences and/or list corruption in that path
which require a reboot to recover.

The only approach that worked to resolve this was to close the file
associated with the event such that the relevant cleanup happens w.r.t.
the open file. To do so, use the event->owner task and find the file
relevant to the event and close it. This relies on the
file->private_data matching the event object.

Test-with: 20240213062948.32735-1-umesh.nerlige.ramappa@intel.com
Signed-off-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com>

Umesh Nerlige Ramappa (2):
  i915/pmu: Add pmu_teardown helper
  i915/pmu: Cleanup pending events on unbind

 drivers/gpu/drm/i915/i915_pmu.c | 192 ++++++++++++++++++++++++--------
 drivers/gpu/drm/i915/i915_pmu.h |  15 +++
 2 files changed, 161 insertions(+), 46 deletions(-)

-- 
2.34.1


             reply	other threads:[~2024-02-13 18:03 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 18:03 Umesh Nerlige Ramappa [this message]
2024-02-13 18:03 ` [PATCH 1/2] i915/pmu: Add pmu_teardown helper Umesh Nerlige Ramappa
2024-02-13 18:03 ` [PATCH 2/2] i915/pmu: Cleanup pending events on unbind Umesh Nerlige Ramappa
2024-02-13 18:36   ` Jani Nikula
2024-02-13 19:44     ` Umesh Nerlige Ramappa
2024-02-14  8:21   ` Tvrtko Ursulin
2024-02-14 19:16     ` Umesh Nerlige Ramappa
2024-02-15  2:48   ` kernel test robot
2024-02-15 21:41   ` kernel test robot
2024-02-13 21:35 ` ✗ Fi.CI.CHECKPATCH: warning for Fix crash due to open pmu events during unbind Patchwork
2024-02-13 21:35 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-02-13 21:54 ` ✓ Fi.CI.BAT: success " Patchwork
2024-02-14  4:34 ` ✗ Fi.CI.IGT: failure " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2024-02-13  6:46 [PATCH 0/2] " Umesh Nerlige Ramappa
2024-02-13 18:04 ` Umesh Nerlige Ramappa

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=20240213180302.47266-1-umesh.nerlige.ramappa@intel.com \
    --to=umesh.nerlige.ramappa@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