linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Niklas Schnelle <schnelle@linux.ibm.com>
To: Bjorn Helgaas <helgaas@kernel.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
	Jan Kiszka <jan.kiszka@siemens.com>,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	Pierre Morel <pmorel@linux.ibm.com>,
	linux-kernel@vger.kernel.org,
	virtualization@lists.linux-foundation.org,
	linux-s390@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH RESEND v5 1/4] PCI: Clean up pci_scan_slot()
Date: Mon, 23 May 2022 10:40:53 +0200	[thread overview]
Message-ID: <26e53653b06e6045ef94f2c5f9c10e333821f186.camel@linux.ibm.com> (raw)
In-Reply-To: <20220513140723.GA947754@bhelgaas>

On Fri, 2022-05-13 at 09:07 -0500, Bjorn Helgaas wrote:
> On Thu, May 12, 2022 at 04:56:42PM +0200, Niklas Schnelle wrote:
> > On Thu, 2022-05-05 at 10:38 +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>
> > > ---
> > 
> > Friendly ping :-)
> 
> Thanks and sorry for the delay.  I'm off today for my daughter's
> wedding reception but will get back to it next week.  Just to expose
> some of my thought process (and not to request more work from you!)
> I've been wondering whether b1bd58e448f2 ("PCI: Consolidate
> "next-function" functions") is really causing us more trouble than
> it's worth.  In some ways that makes the single next-function harder
> to read.  But I guess the hypervisor special case is not exactly a
> "next-function" thing -- it's a "keep scanning even if there's no fn
> 0" thing.
> 
> Bjorn

I've thought again about your comment. Personally what I like about
b1bd58e448f2 ("PCI: Consolidate "next-function" functions") is that it got rid of the next_fn function pointer complication. I agree though that on the other hand it removed a nice separation between the ARI and traditional cases. So I'm thinking maybe we should bring that part back. I think my patch as is makes it easier to see the equivalence to the existing code but then we could add a patch on top and turn it into the below, it's a bit more verbose but very easy to follow.

static int next_ari_fn(struct pci_bus *bus, struct pci_dev *dev, int fn)
{
…
}

static int next_trad_fn(struct pci_bus *bus, struct pci_dev *dev, int fn)
{
	if (fn >= 7)
		return -ENODEV;

	/* only multifunction devices may have more functions */
	if (dev && !dev->multifunction)
		return -ENODEV;

	return fn + 1;
}

static int next_fn(struct pci_bus *bus, struct pci_dev *dev, int fn)
{
	if (pci_ari_enabled(bus)) {
		return next_ari_fn(bus, dev, fn);
	}
	return next_trad_fn(bus, dev, fn);
}



  parent reply	other threads:[~2022-05-23  8:41 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-05  8:38 [PATCH RESEND v5 0/4] PCI: Rework pci_scan_slot() and isolated PCI functions Niklas Schnelle
2022-05-05  8:38 ` [PATCH RESEND v5 1/4] PCI: Clean up pci_scan_slot() Niklas Schnelle
2022-05-12 14:56   ` Niklas Schnelle
2022-05-13 14:07     ` Bjorn Helgaas
2022-05-13 14:47       ` Niklas Schnelle
2022-05-23  8:40       ` Niklas Schnelle [this message]
2022-05-05  8:38 ` [PATCH RESEND v5 2/4] PCI: Move jailhouse's isolated function handling to pci_scan_slot() Niklas Schnelle
2022-05-05  8:38 ` [PATCH RESEND v5 3/4] PCI: Extend isolated function probing to s390 Niklas Schnelle
2022-05-05  8:38 ` [PATCH RESEND v5 4/4] s390/pci: allow zPCI zbus without a function zero Niklas Schnelle
2022-06-02 10:30 [PATCH RESEND v5 0/4] PCI: Rework pci_scan_slot() and isolated PCI functions Niklas Schnelle
2022-06-02 10:30 ` [PATCH RESEND v5 1/4] PCI: Clean up pci_scan_slot() Niklas Schnelle
2022-06-15 11:09   ` 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=26e53653b06e6045ef94f2c5f9c10e333821f186.camel@linux.ibm.com \
    --to=schnelle@linux.ibm.com \
    --cc=bhelgaas@google.com \
    --cc=helgaas@kernel.org \
    --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).