Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: Dmitry Safonov <dima@arista.com>
Cc: Daniel Stodden <dns@arista.com>,
	Kurt Schwemmer <kurt.schwemmer@microsemi.com>,
	Logan Gunthorpe <logang@deltatee.com>,
	linux-pci@vger.kernel.org
Subject: Re: [PATCH v3] switchtec: Fix stdev_release crash after suprise device loss.
Date: Tue, 21 Nov 2023 18:41:25 -0600	[thread overview]
Message-ID: <20231122004125.GA265607@bhelgaas> (raw)
In-Reply-To: <7058922e-9a55-47a2-b6fa-ea1cdade937a@arista.com>

On Wed, Nov 22, 2023 at 12:37:33AM +0000, Dmitry Safonov wrote:
> On 11/13/23 21:21, Daniel Stodden wrote:
> > A pci device hot removal may occur while stdev->cdev is held open. The
> > call to stdev_release is then delivered during close or exit, at a
> > point way past switchtec_pci_remove. Otherwise the last ref would
> > vanish with the trailing put_device, just before return.
> > 
> > At that later point in time, the device layer has alreay removed
> > stdev->mrpc_mmio map. Also, the stdev->pdev reference was not a
> > counted one. Therefore, in dma mode, the iowrite32 in stdev_release
> > will cause a fatal page fault, and the subsequent dma_free_coherent,
> > if reached, would pass a stale &stdev->pdev->dev pointer.
> > 
> > Fixed by moving mrpc dma shutdown into switchtec_pci_remove, after
> > stdev_kill. Counting the stdev->pdev ref is now optional, but may
> > prevent future accidents.
> > 
> > Signed-off-by: Daniel Stodden <dns@arista.com>
> > Reviewed-by: Logan Gunthorpe <logang@deltatee.com>
> 
> Just in case, duplicating on the patch.
> With pci_dev_put(stdev->pdev) on stdev_create() err-path,
> 
> Reviewed-by: Dmitry Safonov <dima@arista.com>

OK, I'm totally lost.  Please post a v4 with the content you want.

Bjorn

  reply	other threads:[~2023-11-22  0:41 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-13 21:21 [PATCH v3 0/1] switchtec: Fix stdev_release crash after suprise device loss Daniel Stodden
2023-11-13 21:21 ` [PATCH v3] " Daniel Stodden
2023-11-20 21:25   ` Bjorn Helgaas
2023-11-21 18:23     ` Daniel Stodden
2023-11-21 18:40       ` Bjorn Helgaas
2023-11-21 23:58         ` Daniel Stodden
2023-11-22  0:02           ` Daniel Stodden
2023-11-22  0:39             ` Bjorn Helgaas
2023-11-22  0:19           ` Bjorn Helgaas
2023-11-22  0:25             ` Dmitry Safonov
2023-11-22  0:37               ` Bjorn Helgaas
2023-11-22  0:37   ` Dmitry Safonov
2023-11-22  0:41     ` Bjorn Helgaas [this message]
2023-11-22  1:02       ` Daniel Stodden
2023-11-22  3:16         ` Bjorn Helgaas

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=20231122004125.GA265607@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=dima@arista.com \
    --cc=dns@arista.com \
    --cc=kurt.schwemmer@microsemi.com \
    --cc=linux-pci@vger.kernel.org \
    --cc=logang@deltatee.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