From: Pierre Morel <pmorel@linux.ibm.com>
To: Niklas Schnelle <schnelle@linux.ibm.com>,
Bjorn Helgaas <bhelgaas@google.com>
Cc: Jan Kiszka <jan.kiszka@siemens.com>,
Matthew Rosato <mjrosato@linux.ibm.com>,
linux-s390@vger.kernel.org, linux-pci@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v6 5/5] s390/pci: allow zPCI zbus without a function zero
Date: Thu, 30 Jun 2022 14:53:37 +0200 [thread overview]
Message-ID: <54426ccd-8c1d-c4e5-6fec-07c77c0f3d59@linux.ibm.com> (raw)
In-Reply-To: <20220628143100.3228092-6-schnelle@linux.ibm.com>
On 6/28/22 16:31, Niklas Schnelle wrote:
> Currently the zPCI code block PCI bus creation and probing of a zPCI
> zbus unless there is a PCI function with devfn 0. This is always the
> case for the PCI functions with hidden RID but may keep PCI functions
> from a multi-function PCI device with RID information invisible until
> the function 0 becomes visible. Worse as a PCI bus is necessary to even
> present a PCI hotplug slot even that remains invisible.
>
> With the probing of these so called isolated PCI functions enabled for
> s390 in common code this restriction is no longer necessary. On network
> cards with multiple ports and a PF per port this also allows using each
> port on its own while still providing the physical PCI topology
> information in the devfn needed to associate VFs with their parent PF.
>
> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com>
> ---
> arch/s390/pci/pci_bus.c | 82 ++++++++++-------------------------------
> 1 file changed, 20 insertions(+), 62 deletions(-)
>
> diff --git a/arch/s390/pci/pci_bus.c b/arch/s390/pci/pci_bus.c
> index 5d77acbd1c87..6a8da1b742ae 100644
> --- a/arch/s390/pci/pci_bus.c
> +++ b/arch/s390/pci/pci_bus.c
> @@ -145,9 +145,6 @@ int zpci_bus_scan_bus(struct zpci_bus *zbus)
> struct zpci_dev *zdev;
> int devfn, rc, ret = 0;
>
> - if (!zbus->function[0])
> - return 0;
> -
> for (devfn = 0; devfn < ZPCI_FUNCTIONS_PER_BUS; devfn++) {
> zdev = zbus->function[devfn];
> if (zdev && zdev->state == ZPCI_FN_STATE_CONFIGURED) {
> @@ -184,26 +181,26 @@ void zpci_bus_scan_busses(void)
>
> /* zpci_bus_create_pci_bus - Create the PCI bus associated with this zbus
> * @zbus: the zbus holding the zdevices
> - * @f0: function 0 of the bus
> + * @fr: PCI root function that will determine the bus's domain, and bus speeed
> * @ops: the pci operations
> *
> - * Function zero is taken as a parameter as this is used to determine the
> - * domain, multifunction property and maximum bus speed of the entire bus.
> + * The PCI function @fr determines the domain (its UID), multifunction property
> + * and maximum bus speed of the entire bus.
> *
> * Return: 0 on success, an error code otherwise
> */
> -static int zpci_bus_create_pci_bus(struct zpci_bus *zbus, struct zpci_dev *f0, struct pci_ops *ops)
> +static int zpci_bus_create_pci_bus(struct zpci_bus *zbus, struct zpci_dev *fr, struct pci_ops *ops)
> {
> struct pci_bus *bus;
> int domain;
>
> - domain = zpci_alloc_domain((u16)f0->uid);
> + domain = zpci_alloc_domain((u16)fr->uid);
> if (domain < 0)
> return domain;
>
> zbus->domain_nr = domain;
> - zbus->multifunction = f0->rid_available;
> - zbus->max_bus_speed = f0->max_bus_speed;
> + zbus->multifunction = fr->rid_available;
> + zbus->max_bus_speed = fr->max_bus_speed;
>
> /*
> * Note that the zbus->resources are taken over and zbus->resources
> @@ -303,47 +300,6 @@ void pcibios_bus_add_device(struct pci_dev *pdev)
> }
> }
>
> -/* zpci_bus_create_hotplug_slots - Add hotplug slot(s) for device added to bus
> - * @zdev: the zPCI device that was newly added
> - *
> - * Add the hotplug slot(s) for the newly added PCI function. Normally this is
> - * simply the slot for the function itself. If however we are adding the
> - * function 0 on a zbus, it might be that we already registered functions on
> - * that zbus but could not create their hotplug slots yet so add those now too.
> - *
> - * Return: 0 on success, an error code otherwise
> - */
> -static int zpci_bus_create_hotplug_slots(struct zpci_dev *zdev)
> -{
> - struct zpci_bus *zbus = zdev->zbus;
> - int devfn, rc = 0;
> -
> - rc = zpci_init_slot(zdev);
> - if (rc)
> - return rc;
> - zdev->has_hp_slot = 1;
> -
> - if (zdev->devfn == 0 && zbus->multifunction) {
> - /* Now that function 0 is there we can finally create the
> - * hotplug slots for those functions with devfn != 0 that have
> - * been parked in zbus->function[] waiting for us to be able to
> - * create the PCI bus.
> - */
> - for (devfn = 1; devfn < ZPCI_FUNCTIONS_PER_BUS; devfn++) {
> - zdev = zbus->function[devfn];
> - if (zdev && !zdev->has_hp_slot) {
> - rc = zpci_init_slot(zdev);
> - if (rc)
> - return rc;
> - zdev->has_hp_slot = 1;
> - }
> - }
> -
> - }
> -
> - return rc;
> -}
> -
> static int zpci_bus_add_device(struct zpci_bus *zbus, struct zpci_dev *zdev)
> {
> int rc = -EINVAL;
> @@ -352,21 +308,19 @@ static int zpci_bus_add_device(struct zpci_bus *zbus, struct zpci_dev *zdev)
> pr_err("devfn %04x is already assigned\n", zdev->devfn);
> return rc;
> }
> +
Unnecessary CR
> zdev->zbus = zbus;
> zbus->function[zdev->devfn] = zdev;
> zpci_nb_devices++;
>
> - if (zbus->bus) {
> - if (zbus->multifunction && !zdev->rid_available) {
> - WARN_ONCE(1, "rid_available not set for multifunction\n");
> - goto error;
> - }
> -
> - zpci_bus_create_hotplug_slots(zdev);
> - } else {
> - /* Hotplug slot will be created once function 0 appears */
> - zbus->multifunction = 1;
> + if (zbus->multifunction && !zdev->rid_available) {
> + WARN_ONCE(1, "rid_available not set for multifunction\n");
> + goto error;
> }
> + rc = zpci_init_slot(zdev);
> + if (rc)
> + goto error;
> + zdev->has_hp_slot = 1;
>
> return 0;
>
> @@ -400,7 +354,11 @@ int zpci_bus_device_register(struct zpci_dev *zdev, struct pci_ops *ops)
> return -ENOMEM;
> }
>
> - if (zdev->devfn == 0) {
> + if (!zbus->bus) {
> + /* The UID of the first PCI function registered with a zpci_bus
> + * is used as the domain number for that bus. Currently there
> + * is exactly one zpci_bus per domain.
> + */
> rc = zpci_bus_create_pci_bus(zbus, zdev, ops);
> if (rc)
> goto error;
>
Reviewed-by: Pierre Morel <pmorel@linux.ibm.com>
--
Pierre Morel
IBM Lab Boeblingen
next prev parent reply other threads:[~2022-06-30 12:49 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-06-28 14:30 [PATCH v6 0/5] PCI: Rework pci_scan_slot() and isolated PCI functions Niklas Schnelle
2022-06-28 14:30 ` [PATCH v6 1/5] PCI: Clean up pci_scan_slot() Niklas Schnelle
2022-06-30 12:40 ` Pierre Morel
2022-06-30 13:48 ` Niklas Schnelle
2022-06-30 14:50 ` Pierre Morel
2022-07-11 8:52 ` Niklas Schnelle
2022-06-28 14:30 ` [PATCH v6 2/5] PCI: Split out next_ari_fn() from next_fn() Niklas Schnelle
2022-06-30 12:44 ` Pierre Morel
2022-06-28 14:30 ` [PATCH v6 3/5] PCI: Move jailhouse's isolated function handling to pci_scan_slot() Niklas Schnelle
2022-06-30 12:47 ` Pierre Morel
2022-06-28 14:30 ` [PATCH v6 4/5] PCI: Extend isolated function probing to s390 Niklas Schnelle
2022-06-30 12:45 ` Pierre Morel
2022-07-01 14:42 ` Niklas Schnelle
2022-07-22 21:13 ` Bjorn Helgaas
2022-06-28 14:31 ` [PATCH v6 5/5] s390/pci: allow zPCI zbus without a function zero Niklas Schnelle
2022-06-30 12:53 ` Pierre Morel [this message]
2022-07-22 21:07 ` [PATCH v6 0/5] PCI: Rework pci_scan_slot() and isolated PCI functions 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=54426ccd-8c1d-c4e5-6fec-07c77c0f3d59@linux.ibm.com \
--to=pmorel@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=schnelle@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;
as well as URLs for NNTP newsgroup(s).