From: Matthew Brost <matthew.brost@intel.com>
To: Rodrigo Vivi <rodrigo.vivi@kernel.org>
Cc: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
Rodrigo Vivi <rodrigo.vivi@intel.com>
Subject: Re: [Intel-xe] [PATCH 03/14] drm/xe: Do not take any action if our device was removed.
Date: Tue, 2 May 2023 23:06:02 +0000 [thread overview]
Message-ID: <ZFGXWiozW+stGJF3@DUT025-TGLU.fm.intel.com> (raw)
In-Reply-To: <ZFFGp1XD5Nfum0H7@rdvivi-mobl4>
On Tue, May 02, 2023 at 01:21:43PM -0400, Rodrigo Vivi wrote:
> On Tue, May 02, 2023 at 03:40:50PM +0000, Matthew Brost wrote:
> > On Wed, Apr 26, 2023 at 04:57:02PM -0400, Rodrigo Vivi wrote:
> > > Unfortunately devcoredump infrastructure does not provide and
> > > interface for us to force the device removal upon the pci_remove
> > > time of our device.
> > >
> > > The devcoredump is linked at the device level, so when in use
> > > it will prevent the module removal, but it doesn't prevent the
> > > call of the pci_remove callback. This callback cannot fail
> > > anyway and we end up clearing and freeing the entire pci device.
> > >
> > > Hence, after we removed the pci device, we shouldn't allow any
> > > read or free operations to avoid segmentation fault.
> > >
> > > Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> > > ---
> > > drivers/gpu/drm/xe/xe_devcoredump.c | 19 ++++++++++++++++---
> > > 1 file changed, 16 insertions(+), 3 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c
> > > index d9531183f03a..a08929c01b75 100644
> > > --- a/drivers/gpu/drm/xe/xe_devcoredump.c
> > > +++ b/drivers/gpu/drm/xe/xe_devcoredump.c
> > > @@ -42,6 +42,11 @@
> > > * hang capture.
> > > */
> > >
> > > +static struct xe_device *coredump_to_xe(const struct xe_devcoredump *coredump)
> > > +{
> > > + return container_of(coredump, struct xe_device, devcoredump);
> >
> > Confused how still would ever return NULL, can you explain?
>
> Very good question! I'm honestly still confused myself.
>
> There's something not quite right with the device relationship that
> is getting created with the failling_device and the virtual coredump device.
>
> Once failing_device is removed, the devcoredump should be removed as well,
> or both removals blocked. However this is not what happens.
>
> On rmmod xe, the device removal is called and we free all xe structs.
> The pci device removal is a void function. We cannot fail. The module
> removal ends up blocked because the relationship, but that doesn't
> saves the day since the device itself is already gone, by the pci
> removal function.
>
> But the devcoredump device is there and active. There's no callback on
> devcoredump infra that we could call to force the device removal. Then
> any read function will hit a NULL xe device and BOOM!
>
> This is one of the things I planned to tackle on the devcoredump side
> after we get this basic infra in use in our driver. This patch allows
> us to be protected from this scenario while we don't fix this at the
> devcoredump side.
>
> It's worth saying that the devcoredump virtual device is auto removed
> after a time elapsed... couple minutes? (I can't remember by heart now).
>
After some serious thought, I think I get this. With that:
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
But agree this goofy and try to fix this properly after this is merged.
> >
> > Matt
> >
> > > +}
> > > +
> > > static ssize_t xe_devcoredump_read(char *buffer, loff_t offset,
> > > size_t count, void *data, size_t datalen)
> > > {
> > > @@ -51,6 +56,10 @@ static ssize_t xe_devcoredump_read(char *buffer, loff_t offset,
> > > struct drm_print_iterator iter;
> > > struct timespec64 ts;
> > >
> > > + /* Our device is gone already... */
> > > + if (!data || !coredump_to_xe(coredump))
> > > + return -ENODEV;
> > > +
> > > iter.data = buffer;
> > > iter.offset = 0;
> > > iter.start = offset;
> > > @@ -80,12 +89,16 @@ static ssize_t xe_devcoredump_read(char *buffer, loff_t offset,
> > > static void xe_devcoredump_free(void *data)
> > > {
> > > struct xe_devcoredump *coredump = data;
> > > - struct xe_device *xe = container_of(coredump, struct xe_device,
> > > - devcoredump);
> > > +
> > > + /* Our device is gone. Nothing to do... */
> > > + if (!data || !coredump_to_xe(coredump))
> > > + return;
> > > +
> > > mutex_lock(&coredump->lock);
> > >
> > > coredump->faulty_engine = NULL;
> > > - drm_info(&xe->drm, "Xe device coredump has been deleted.\n");
> > > + drm_info(&coredump_to_xe(coredump)->drm,
> > > + "Xe device coredump has been deleted.\n");
> > >
> > > mutex_unlock(&coredump->lock);
> > > }
> > > --
> > > 2.39.2
> > >
next prev parent reply other threads:[~2023-05-02 23:06 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-26 20:56 [Intel-xe] [PATCH 00/14] Introduce xe_devcoredump Rodrigo Vivi
2023-04-26 20:57 ` [Intel-xe] [PATCH 01/14] drm/xe: Fix print of RING_EXECLIST_SQ_CONTENTS_HI Rodrigo Vivi
2023-04-26 21:40 ` Lucas De Marchi
2023-04-26 21:59 ` Rodrigo Vivi
2023-04-26 20:57 ` [Intel-xe] [PATCH 02/14] drm/xe: Introduce the dev_coredump infrastructure Rodrigo Vivi
2023-04-27 8:28 ` Thomas Hellström
2023-05-02 7:57 ` Matthew Brost
2023-05-02 18:06 ` Rodrigo Vivi
2023-05-02 20:29 ` Matthew Brost
2023-05-02 7:55 ` Jani Nikula
2023-05-02 17:25 ` Rodrigo Vivi
2023-04-26 20:57 ` [Intel-xe] [PATCH 03/14] drm/xe: Do not take any action if our device was removed Rodrigo Vivi
2023-05-02 15:40 ` Matthew Brost
2023-05-02 17:21 ` Rodrigo Vivi
2023-05-02 23:06 ` Matthew Brost [this message]
2023-04-26 20:57 ` [Intel-xe] [PATCH 04/14] drm/xe: Extract non mapped regions out of GuC CTB into its own struct Rodrigo Vivi
2023-05-02 5:12 ` Matthew Brost
2023-04-26 20:57 ` [Intel-xe] [PATCH 05/14] drm/xe: Convert GuC CT print to snapshot capture and print Rodrigo Vivi
2023-05-02 5:27 ` Matthew Brost
2023-04-26 20:57 ` [Intel-xe] [PATCH 06/14] drm/xe: Add GuC CT snapshot to xe_devcoredump Rodrigo Vivi
2023-05-02 14:55 ` Matthew Brost
2023-04-26 20:57 ` [Intel-xe] [PATCH 07/14] drm/xe: Introduce guc_submit_types.h with relevant structs Rodrigo Vivi
2023-05-02 7:44 ` Matthew Brost
2023-04-26 20:57 ` [Intel-xe] [PATCH 08/14] drm/xe: Convert GuC Engine print to snapshot capture and print Rodrigo Vivi
2023-05-02 15:01 ` Matthew Brost
2023-04-26 20:57 ` [Intel-xe] [PATCH 09/14] drm/xe: Add GuC Submit Engine snapshot to xe_devcoredump Rodrigo Vivi
2023-05-02 15:03 ` Matthew Brost
2023-04-26 20:57 ` [Intel-xe] [PATCH 10/14] drm/xe: Convert Xe HW Engine print to snapshot capture and print Rodrigo Vivi
2023-05-02 15:20 ` Matthew Brost
2023-04-26 20:57 ` [Intel-xe] [PATCH 11/14] drm/xe: Add HW Engine snapshot to xe_devcoredump Rodrigo Vivi
2023-05-02 15:30 ` Matthew Brost
2023-04-26 20:57 ` [Intel-xe] [PATCH 12/14] drm/xe: Limit CONFIG_DRM_XE_SIMPLE_ERROR_CAPTURE to itself Rodrigo Vivi
2023-05-02 15:35 ` Matthew Brost
2023-04-26 20:57 ` [Intel-xe] [PATCH 13/14] drm/xe: Convert VM print to snapshot capture and print Rodrigo Vivi
2023-05-02 7:50 ` Matthew Brost
2023-05-02 8:07 ` Matthew Brost
2023-04-26 20:57 ` [Intel-xe] [PATCH 14/14] drm/xe: Add VM snapshot to xe_devcoredump Rodrigo Vivi
2023-05-02 15:38 ` Matthew Brost
2023-04-26 21:01 ` [Intel-xe] ✓ CI.Patch_applied: success for Introduce xe_devcoredump Patchwork
2023-04-26 21:02 ` [Intel-xe] ✓ CI.KUnit: " Patchwork
2023-04-26 21:06 ` [Intel-xe] ✓ CI.Build: " Patchwork
2023-04-26 21:29 ` [Intel-xe] ○ CI.BAT: info " Patchwork
2023-05-02 8:11 ` [Intel-xe] [PATCH 00/14] " Matthew Brost
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=ZFGXWiozW+stGJF3@DUT025-TGLU.fm.intel.com \
--to=matthew.brost@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=rodrigo.vivi@intel.com \
--cc=rodrigo.vivi@kernel.org \
/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).