From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Bjorn Helgaas <bhelgaas@google.com>,
Jan Kiszka <jan.kiszka@siemens.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
Pierre Morel <pmorel@linux.ibm.com>
Cc: linux-kernel@vger.kernel.org,
virtualization@lists.linux-foundation.org,
linux-s390@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH v4 1/4] PCI: Clean up pci_scan_slot()
Date: Fri, 22 Apr 2022 15:35:07 +0200 [thread overview]
Message-ID: <19ea2a8ff04c24708a6504924f7a91c1045308d0.camel@linux.ibm.com> (raw)
In-Reply-To: <20220422132858.1213022-2-schnelle@linux.ibm.com>
[-- Attachment #1: Type: text/plain, Size: 2054 bytes --]
On Fri, 2022-04-22 at 15:28 +0200, Niklas Schnelle wrote:
> While determining the next PCI function is factored out of
> pci_scan_slot() into next_fn() the former still handles the first
> function as a special case. This duplicates the code from the scan loop.
>
> Furthermore the non ARI branch of next_fn() is generally hard to
> understand and especially the check for multifunction devices is hidden
> in the handling of NULL devices for non-contiguous multifunction. It
> also signals that no further functions need to be scanned by returning
> 0 via wraparound and this is a valid function number.
>
> Improve upon this by transforming the conditions in next_fn() to be
> easier to understand.
>
> By changing next_fn() to return -ENODEV instead of 0 when there is no
> next function we can then handle the initial function inside the loop
> and deduplicate the shared handling. This also makes it more explicit
> that only function 0 must exist.
>
> No functional change is intended.
>
> Cc: Jan Kiszka <jan.kiszka@siemens.com>
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
> ---
> drivers/pci/probe.c | 39 ++++++++++++++++++++-------------------
> 1 file changed, 20 insertions(+), 19 deletions(-)
>
> diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
> index 17a969942d37..2000e9858f12 100644
> --- a/drivers/pci/probe.c
> +++ b/drivers/pci/probe.c
> @@ -2579,8 +2579,7 @@ struct pci_dev *pci_scan_single_device(struct pci_bus *bus, int devfn)
> }
> EXPORT_SYMBOL(pci_scan_single_device);
>
> -static unsigned int next_fn(struct pci_bus *bus, struct pci_dev *dev,
> - unsigned int fn)
> +static int next_fn(struct pci_bus *bus, struct pci_dev *dev, int fn)
> {
> int pos;
> u16 cap = 0;
> @@ -2588,24 +2587,27 @@ static unsigned int next_fn(struct pci_bus *bus, struct pci_dev *dev,
>
> if (pci_ari_enabled(bus)) {
> if (!dev)
> - return 0;
> + return -ENODEV;
> +
>
Sorry the whitespace damage was of course not intended, fixed locally.
[-- Attachment #2: This is a digitally signed message part --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
next prev parent reply other threads:[~2022-04-22 13:35 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-22 13:28 [PATCH v4 0/4] PCI: Rework pci_scan_slot() and isolated PCI functions Niklas Schnelle
2022-04-22 13:28 ` [PATCH v4 1/4] PCI: Clean up pci_scan_slot() Niklas Schnelle
2022-04-22 13:35 ` Niklas Schnelle [this message]
2022-04-22 13:28 ` [PATCH v4 2/4] PCI: Move jailhouse's isolated function handling to pci_scan_slot() Niklas Schnelle
2022-04-22 13:28 ` [PATCH v4 3/4] PCI: Extend isolated function probing to s390 Niklas Schnelle
2022-04-22 13:28 ` [PATCH v4 4/4] s390/pci: allow zPCI zbus without a function zero Niklas Schnelle
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=19ea2a8ff04c24708a6504924f7a91c1045308d0.camel@linux.ibm.com \
--to=schnelle@linux.ibm.com \
--cc=bhelgaas@google.com \
--cc=jan.kiszka@siemens.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=mjrosato@linux.ibm.com \
--cc=pmorel@linux.ibm.com \
--cc=virtualization@lists.linux-foundation.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).