From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Benjamin Block <bblock@linux.ibm.com>, Farhan Ali <alifm@linux.ibm.com>
Cc: Gerd Bayer <gbayer@linux.ibm.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Julian Ruess <julianr@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Vasily Gorbik <gor@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Sven Schnelle <svens@linux.ibm.com>,
Ramesh Errabolu <ramesh@linux.ibm.com>,
Tobias Schumacher <ts@linux.ibm.com>,
Halil Pasic <pasic@linux.ibm.com>,
Peter Oberparleiter <oberpar@linux.ibm.com>,
Gerald Schaefer <gerald.schaefer@linux.ibm.com>,
Christian Borntraeger <borntraeger@linux.ibm.com>,
linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2 2/2] s390/pci: Extend device lock to cover zpci_report_status()
Date: Fri, 21 Aug 2026 15:14:32 +0200 [thread overview]
Message-ID: <6dff883412d6a8fc55b55cec8f58f4e27afc429f.camel@linux.ibm.com> (raw)
In-Reply-To: <20260821125944.GB171473@p14sgen6-pf6akexs.ehn-de.ibm.com>
On Fri, 2026-08-21 at 14:59 +0200, Benjamin Block wrote:
> On Wed, Aug 19, 2026 at 02:30:18PM -0700, Farhan Ali wrote:
> >
> > On 8/19/2026 2:58 AM, Niklas Schnelle wrote:
> > > As zpci_report_status() accesses the device's driver the device lock
> > > needs to be held. Extend the critical section to cover the
> > > zpci_report_status() call.
> > >
> > > Cc: stable@vger.kernel.org
> > > Fixes: 4ec6054e7321 ("s390/pci: Report PCI error recovery results via SCLP")
> > > Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
> > > ---
> > > arch/s390/pci/pci_event.c | 2 +-
> > > 1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/arch/s390/pci/pci_event.c b/arch/s390/pci/pci_event.c
> > > index 839bd91c056e..48c150d6ba81 100644
> > > --- a/arch/s390/pci/pci_event.c
> > > +++ b/arch/s390/pci/pci_event.c
> > > @@ -256,8 +256,8 @@ static pci_ers_result_t zpci_event_attempt_error_recovery(struct pci_dev *pdev)
> > > driver->err_handler->resume(pdev);
> > > pci_uevent_ers(pdev, PCI_ERS_RESULT_RECOVERED);
> > > out_unlock:
> > > - device_unlock(&pdev->dev);
> > > zpci_report_status(zdev, "recovery", status_str);
> > > + device_unlock(&pdev->dev);
> > >
> > > return ers_res;
> > > }
> >
> > AFAICT this change is correct, but should we also add a lockdep_assert
>
> Andy maybe the context one `__must_hold()` or something as function attribute.
>
> > in zpci_report_status()? Since this is the only placed its called, it
> > maybe fine as is. I just fear that we could miss on getting the lock if
> > we were to re-use zpci_report_status().
>
> Yeah, I agree. It's not obvious.
>
> I guess the critical point here why we need the lock is this line:
>
> driver = to_pci_driver(pdev->dev.driver);
>
> right? Because we assume the relation between driver and device stays intact
> after we get that assignment.
>
> Because otherwise I don't see why we must get the lock, if we get a valid
> reference in zpci_report_status().
Yes exactly, we need to make sure the driver isn't unbound or worse
unloaded in the middle of it. It's quite subtle which is why I forgot
it in the first place I guess.
Also note that the function may be called, and does handle, both an
unbound device (driver == NULL) and/or a zdev prior to probing the
associated pdev (pdev == NULL). This means the device_lock_assert()
needs to be inside the !pdev block. I'd think this also means we can't
really use __must_hold(), right?
Thanks,
Niklas
next prev parent reply other threads:[~2026-08-21 13:15 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-19 9:58 [PATCH v2 0/2] s390/pci: Fix missing pci_dev_put() in zpci_report_status() Niklas Schnelle
2026-08-19 9:58 ` [PATCH v2 1/2] " Niklas Schnelle
2026-08-19 10:08 ` sashiko-bot
2026-08-20 7:50 ` Niklas Schnelle
2026-08-21 12:48 ` Benjamin Block
2026-08-19 9:58 ` [PATCH v2 2/2] s390/pci: Extend device lock to cover zpci_report_status() Niklas Schnelle
2026-08-19 10:19 ` sashiko-bot
2026-08-19 14:08 ` Matthew Rosato
2026-08-19 21:30 ` Farhan Ali
2026-08-21 12:50 ` Niklas Schnelle
2026-08-21 12:59 ` Benjamin Block
2026-08-21 13:14 ` Niklas Schnelle [this message]
2026-08-21 13:58 ` Benjamin Block
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=6dff883412d6a8fc55b55cec8f58f4e27afc429f.camel@linux.ibm.com \
--to=schnelle@linux.ibm.com \
--cc=agordeev@linux.ibm.com \
--cc=alifm@linux.ibm.com \
--cc=bblock@linux.ibm.com \
--cc=borntraeger@linux.ibm.com \
--cc=gbayer@linux.ibm.com \
--cc=gerald.schaefer@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=julianr@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=oberpar@linux.ibm.com \
--cc=pasic@linux.ibm.com \
--cc=ramesh@linux.ibm.com \
--cc=svens@linux.ibm.com \
--cc=ts@linux.ibm.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