* [PATCH v2 0/2] PCI fixes for s390
@ 2025-10-22 21:24 Farhan Ali
2025-10-22 21:24 ` [PATCH v2 1/2] PCI: Allow per function PCI slots Farhan Ali
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Farhan Ali @ 2025-10-22 21:24 UTC (permalink / raw)
To: linux-s390, linux-pci, linux-kernel
Cc: helgaas, alifm, schnelle, mjrosato, bblock, agordeev, gor, hca
Hi,
I came across some issues in PCI code for s390 while working on VFIO error
recovery for s390 PCI devices [1]. These patches can be indepedently applied and
has no depedency on error recovery patch series. We would like to get these
patches merged as they do fix some existing issues.
[1] https://lore.kernel.org/all/20250924171628.826-1-alifm@linux.ibm.com/
ChangeLog
---------
v1 -> v2
- Re-work patch 1 on setting per_func_slot flag. The flag is set if platform
enables per function pci slots (currently only enabled for s390).
- Drop R-b tags for patch 1.
Thanks
Farhan
Farhan Ali (2):
PCI: Allow per function PCI slots
s390/pci: Add architecture specific resource/bus address translation
arch/s390/pci/pci.c | 74 +++++++++++++++++++++++++++++++++++++++
drivers/pci/host-bridge.c | 4 +--
drivers/pci/pci.c | 5 +--
drivers/pci/slot.c | 25 +++++++++++--
include/linux/pci.h | 1 +
5 files changed, 102 insertions(+), 7 deletions(-)
--
2.43.0
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH v2 1/2] PCI: Allow per function PCI slots
2025-10-22 21:24 [PATCH v2 0/2] PCI fixes for s390 Farhan Ali
@ 2025-10-22 21:24 ` Farhan Ali
2025-10-27 12:29 ` Niklas Schnelle
2025-10-22 21:24 ` [PATCH v2 2/2] s390/pci: Add architecture specific resource/bus address translation Farhan Ali
2025-11-03 20:06 ` [PATCH v2 0/2] PCI fixes for s390 Farhan Ali
2 siblings, 1 reply; 7+ messages in thread
From: Farhan Ali @ 2025-10-22 21:24 UTC (permalink / raw)
To: linux-s390, linux-pci, linux-kernel
Cc: helgaas, alifm, schnelle, mjrosato, bblock, agordeev, gor, hca,
stable
On s390 systems, which use a machine level hypervisor, PCI devices are
always accessed through a form of PCI pass-through which fundamentally
operates on a per PCI function granularity. This is also reflected in the
s390 PCI hotplug driver which creates hotplug slots for individual PCI
functions. Its reset_slot() function, which is a wrapper for
zpci_hot_reset_device(), thus also resets individual functions.
Currently, the kernel's PCI_SLOT() macro assigns the same pci_slot object
to multifunction devices. This approach worked fine on s390 systems that
only exposed virtual functions as individual PCI domains to the operating
system. Since commit 44510d6fa0c0 ("s390/pci: Handling multifunctions")
s390 supports exposing the topology of multifunction PCI devices by
grouping them in a shared PCI domain. When attempting to reset a function
through the hotplug driver, the shared slot assignment causes the wrong
function to be reset instead of the intended one. It also leaks memory as
we do create a pci_slot object for the function, but don't correctly free
it in pci_slot_release().
Add a flag for struct pci_slot to allow per function PCI slots for
functions managed through a hypervisor, which exposes individual PCI
functions while retaining the topology.
Fixes: 44510d6fa0c0 ("s390/pci: Handling multifunctions")
Cc: stable@vger.kernel.org
Suggested-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
---
drivers/pci/pci.c | 5 +++--
drivers/pci/slot.c | 25 ++++++++++++++++++++++---
include/linux/pci.h | 1 +
3 files changed, 26 insertions(+), 5 deletions(-)
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index b14dd064006c..36ee38e0d817 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -4980,8 +4980,9 @@ static int pci_reset_hotplug_slot(struct hotplug_slot *hotplug, bool probe)
static int pci_dev_reset_slot_function(struct pci_dev *dev, bool probe)
{
- if (dev->multifunction || dev->subordinate || !dev->slot ||
- dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)
+ if (dev->subordinate || !dev->slot ||
+ dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET ||
+ (dev->multifunction && !dev->slot->per_func_slot))
return -ENOTTY;
return pci_reset_hotplug_slot(dev->slot->hotplug, probe);
diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
index 50fb3eb595fe..ed10fa3ae727 100644
--- a/drivers/pci/slot.c
+++ b/drivers/pci/slot.c
@@ -63,6 +63,22 @@ static ssize_t cur_speed_read_file(struct pci_slot *slot, char *buf)
return bus_speed_read(slot->bus->cur_bus_speed, buf);
}
+static bool pci_dev_matches_slot(struct pci_dev *dev, struct pci_slot *slot)
+{
+ if (slot->per_func_slot)
+ return dev->devfn == slot->number;
+
+ return PCI_SLOT(dev->devfn) == slot->number;
+}
+
+static bool pci_slot_enabled_per_func(void)
+{
+ if (IS_ENABLED(CONFIG_S390))
+ return true;
+
+ return false;
+}
+
static void pci_slot_release(struct kobject *kobj)
{
struct pci_dev *dev;
@@ -73,7 +89,7 @@ static void pci_slot_release(struct kobject *kobj)
down_read(&pci_bus_sem);
list_for_each_entry(dev, &slot->bus->devices, bus_list)
- if (PCI_SLOT(dev->devfn) == slot->number)
+ if (pci_dev_matches_slot(dev, slot))
dev->slot = NULL;
up_read(&pci_bus_sem);
@@ -166,7 +182,7 @@ void pci_dev_assign_slot(struct pci_dev *dev)
mutex_lock(&pci_slot_mutex);
list_for_each_entry(slot, &dev->bus->slots, list)
- if (PCI_SLOT(dev->devfn) == slot->number)
+ if (pci_dev_matches_slot(dev, slot))
dev->slot = slot;
mutex_unlock(&pci_slot_mutex);
}
@@ -265,6 +281,9 @@ struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
slot->bus = pci_bus_get(parent);
slot->number = slot_nr;
+ if (pci_slot_enabled_per_func())
+ slot->per_func_slot = 1;
+
slot->kobj.kset = pci_slots_kset;
slot_name = make_slot_name(name);
@@ -285,7 +304,7 @@ struct pci_slot *pci_create_slot(struct pci_bus *parent, int slot_nr,
down_read(&pci_bus_sem);
list_for_each_entry(dev, &parent->devices, bus_list)
- if (PCI_SLOT(dev->devfn) == slot_nr)
+ if (pci_dev_matches_slot(dev, slot))
dev->slot = slot;
up_read(&pci_bus_sem);
diff --git a/include/linux/pci.h b/include/linux/pci.h
index d1fdf81fbe1e..6ad194597ab5 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -78,6 +78,7 @@ struct pci_slot {
struct list_head list; /* Node in list of slots */
struct hotplug_slot *hotplug; /* Hotplug info (move here) */
unsigned char number; /* PCI_SLOT(pci_dev->devfn) */
+ unsigned int per_func_slot:1; /* Allow per function slot */
struct kobject kobj;
};
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/2] s390/pci: Add architecture specific resource/bus address translation
2025-10-22 21:24 [PATCH v2 0/2] PCI fixes for s390 Farhan Ali
2025-10-22 21:24 ` [PATCH v2 1/2] PCI: Allow per function PCI slots Farhan Ali
@ 2025-10-22 21:24 ` Farhan Ali
2025-11-03 20:06 ` [PATCH v2 0/2] PCI fixes for s390 Farhan Ali
2 siblings, 0 replies; 7+ messages in thread
From: Farhan Ali @ 2025-10-22 21:24 UTC (permalink / raw)
To: linux-s390, linux-pci, linux-kernel
Cc: helgaas, alifm, schnelle, mjrosato, bblock, agordeev, gor, hca
On s390 today we overwrite the PCI BAR resource address to either an
artificial cookie address or MIO address. However this address is different
from the bus address of the BARs programmed by firmware. The artificial
cookie address was created to index into an array of function handles
(zpci_iomap_start). The MIO (mapped I/O) addresses are provided by firmware
but maybe different from the bus addresses. This creates an issue when trying
to convert the BAR resource address to bus address using the generic
pcibios_resource_to_bus().
Implement an architecture specific pcibios_resource_to_bus() function to
correctly translate PCI BAR resource addresses to bus addresses for s390.
Similarly add architecture specific pcibios_bus_to_resource function to do
the reverse translation.
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
---
arch/s390/pci/pci.c | 74 +++++++++++++++++++++++++++++++++++++++
drivers/pci/host-bridge.c | 4 +--
2 files changed, 76 insertions(+), 2 deletions(-)
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
index c82c577db2bc..cacad02b2b7f 100644
--- a/arch/s390/pci/pci.c
+++ b/arch/s390/pci/pci.c
@@ -264,6 +264,80 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
return 0;
}
+void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
+ struct resource *res)
+{
+ struct zpci_bus *zbus = bus->sysdata;
+ struct zpci_bar_struct *zbar;
+ struct zpci_dev *zdev;
+
+ region->start = res->start;
+ region->end = res->end;
+
+ for (int i = 0; i < ZPCI_FUNCTIONS_PER_BUS; i++) {
+ int j = 0;
+
+ zbar = NULL;
+ zdev = zbus->function[i];
+ if (!zdev)
+ continue;
+
+ for (j = 0; j < PCI_STD_NUM_BARS; j++) {
+ if (zdev->bars[j].res->start == res->start &&
+ zdev->bars[j].res->end == res->end &&
+ res->flags & IORESOURCE_MEM) {
+ zbar = &zdev->bars[j];
+ break;
+ }
+ }
+
+ if (zbar) {
+ /* only MMIO is supported */
+ region->start = zbar->val & PCI_BASE_ADDRESS_MEM_MASK;
+ if (zbar->val & PCI_BASE_ADDRESS_MEM_TYPE_64)
+ region->start |= (u64)zdev->bars[j + 1].val << 32;
+
+ region->end = region->start + (1UL << zbar->size) - 1;
+ return;
+ }
+ }
+}
+
+void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
+ struct pci_bus_region *region)
+{
+ struct zpci_bus *zbus = bus->sysdata;
+ struct zpci_dev *zdev;
+ resource_size_t start, end;
+
+ res->start = region->start;
+ res->end = region->end;
+
+ for (int i = 0; i < ZPCI_FUNCTIONS_PER_BUS; i++) {
+ zdev = zbus->function[i];
+ if (!zdev || !zdev->has_resources)
+ continue;
+
+ for (int j = 0; j < PCI_STD_NUM_BARS; j++) {
+ if (!zdev->bars[j].size)
+ continue;
+
+ /* only MMIO is supported */
+ start = zdev->bars[j].val & PCI_BASE_ADDRESS_MEM_MASK;
+ if (zdev->bars[j].val & PCI_BASE_ADDRESS_MEM_TYPE_64)
+ start |= (u64)zdev->bars[j + 1].val << 32;
+
+ end = start + (1UL << zdev->bars[j].size) - 1;
+
+ if (start == region->start && end == region->end) {
+ res->start = zdev->bars[j].res->start;
+ res->end = zdev->bars[j].res->end;
+ return;
+ }
+ }
+ }
+}
+
void __iomem *ioremap_prot(phys_addr_t phys_addr, size_t size,
pgprot_t prot)
{
diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c
index afa50b446567..56d62afb3afe 100644
--- a/drivers/pci/host-bridge.c
+++ b/drivers/pci/host-bridge.c
@@ -48,7 +48,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,
}
EXPORT_SYMBOL_GPL(pci_set_host_bridge_release);
-void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
+void __weak pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
struct resource *res)
{
struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
@@ -73,7 +73,7 @@ static bool region_contains(struct pci_bus_region *region1,
return region1->start <= region2->start && region1->end >= region2->end;
}
-void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
+void __weak pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res,
struct pci_bus_region *region)
{
struct pci_host_bridge *bridge = pci_find_host_bridge(bus);
--
2.43.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] PCI: Allow per function PCI slots
2025-10-22 21:24 ` [PATCH v2 1/2] PCI: Allow per function PCI slots Farhan Ali
@ 2025-10-27 12:29 ` Niklas Schnelle
2025-10-28 1:11 ` Bibo Mao
0 siblings, 1 reply; 7+ messages in thread
From: Niklas Schnelle @ 2025-10-27 12:29 UTC (permalink / raw)
To: Farhan Ali, linux-s390, linux-pci, linux-kernel
Cc: helgaas, mjrosato, bblock, agordeev, gor, hca, stable,
Tianrui Zhao, Bibo Mao, Huacai Chen
On Wed, 2025-10-22 at 14:24 -0700, Farhan Ali wrote:
> On s390 systems, which use a machine level hypervisor, PCI devices are
> always accessed through a form of PCI pass-through which fundamentally
> operates on a per PCI function granularity. This is also reflected in the
> s390 PCI hotplug driver which creates hotplug slots for individual PCI
> functions. Its reset_slot() function, which is a wrapper for
> zpci_hot_reset_device(), thus also resets individual functions.
>
> Currently, the kernel's PCI_SLOT() macro assigns the same pci_slot object
> to multifunction devices. This approach worked fine on s390 systems that
> only exposed virtual functions as individual PCI domains to the operating
> system. Since commit 44510d6fa0c0 ("s390/pci: Handling multifunctions")
> s390 supports exposing the topology of multifunction PCI devices by
> grouping them in a shared PCI domain. When attempting to reset a function
> through the hotplug driver, the shared slot assignment causes the wrong
> function to be reset instead of the intended one. It also leaks memory as
> we do create a pci_slot object for the function, but don't correctly free
> it in pci_slot_release().
>
> Add a flag for struct pci_slot to allow per function PCI slots for
> functions managed through a hypervisor, which exposes individual PCI
> functions while retaining the topology.
I wonder if LoongArch which now also does per PCI function pass-through
might need this too. Adding their KVM maintainers.
>
> Fixes: 44510d6fa0c0 ("s390/pci: Handling multifunctions")
> Cc: stable@vger.kernel.org
> Suggested-by: Niklas Schnelle <schnelle@linux.ibm.com>
> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
> ---
> drivers/pci/pci.c | 5 +++--
> drivers/pci/slot.c | 25 ++++++++++++++++++++++---
> include/linux/pci.h | 1 +
> 3 files changed, 26 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index b14dd064006c..36ee38e0d817 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -4980,8 +4980,9 @@ static int pci_reset_hotplug_slot(struct hotplug_slot *hotplug, bool probe)
>
> static int pci_dev_reset_slot_function(struct pci_dev *dev, bool probe)
> {
> - if (dev->multifunction || dev->subordinate || !dev->slot ||
> - dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)
> + if (dev->subordinate || !dev->slot ||
> + dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET ||
> + (dev->multifunction && !dev->slot->per_func_slot))
> return -ENOTTY;
>
> return pci_reset_hotplug_slot(dev->slot->hotplug, probe);
> diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
> index 50fb3eb595fe..ed10fa3ae727 100644
> --- a/drivers/pci/slot.c
> +++ b/drivers/pci/slot.c
> @@ -63,6 +63,22 @@ static ssize_t cur_speed_read_file(struct pci_slot *slot, char *buf)
> return bus_speed_read(slot->bus->cur_bus_speed, buf);
> }
>
> +static bool pci_dev_matches_slot(struct pci_dev *dev, struct pci_slot *slot)
> +{
> + if (slot->per_func_slot)
> + return dev->devfn == slot->number;
> +
> + return PCI_SLOT(dev->devfn) == slot->number;
> +}
> +
> +static bool pci_slot_enabled_per_func(void)
> +{
> + if (IS_ENABLED(CONFIG_S390))
> + return true;
> +
> + return false;
> +}
> +
--- snip ---
>
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index d1fdf81fbe1e..6ad194597ab5 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -78,6 +78,7 @@ struct pci_slot {
> struct list_head list; /* Node in list of slots */
> struct hotplug_slot *hotplug; /* Hotplug info (move here) */
> unsigned char number; /* PCI_SLOT(pci_dev->devfn) */
> + unsigned int per_func_slot:1; /* Allow per function slot */
> struct kobject kobj;
> };
>
Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] PCI: Allow per function PCI slots
2025-10-27 12:29 ` Niklas Schnelle
@ 2025-10-28 1:11 ` Bibo Mao
2025-10-29 8:37 ` Niklas Schnelle
0 siblings, 1 reply; 7+ messages in thread
From: Bibo Mao @ 2025-10-28 1:11 UTC (permalink / raw)
To: Niklas Schnelle, Farhan Ali, linux-s390, linux-pci, linux-kernel
Cc: helgaas, mjrosato, bblock, agordeev, gor, hca, stable,
Tianrui Zhao, Huacai Chen
On 2025/10/27 下午8:29, Niklas Schnelle wrote:
> On Wed, 2025-10-22 at 14:24 -0700, Farhan Ali wrote:
>> On s390 systems, which use a machine level hypervisor, PCI devices are
>> always accessed through a form of PCI pass-through which fundamentally
>> operates on a per PCI function granularity. This is also reflected in the
>> s390 PCI hotplug driver which creates hotplug slots for individual PCI
>> functions. Its reset_slot() function, which is a wrapper for
>> zpci_hot_reset_device(), thus also resets individual functions.
>>
>> Currently, the kernel's PCI_SLOT() macro assigns the same pci_slot object
>> to multifunction devices. This approach worked fine on s390 systems that
>> only exposed virtual functions as individual PCI domains to the operating
>> system. Since commit 44510d6fa0c0 ("s390/pci: Handling multifunctions")
>> s390 supports exposing the topology of multifunction PCI devices by
>> grouping them in a shared PCI domain. When attempting to reset a function
>> through the hotplug driver, the shared slot assignment causes the wrong
>> function to be reset instead of the intended one. It also leaks memory as
>> we do create a pci_slot object for the function, but don't correctly free
>> it in pci_slot_release().
>>
>> Add a flag for struct pci_slot to allow per function PCI slots for
>> functions managed through a hypervisor, which exposes individual PCI
>> functions while retaining the topology.
>
> I wonder if LoongArch which now also does per PCI function pass-through
> might need this too. Adding their KVM maintainers.
Hi Niklas,
Thanks for your reminder. Yes, LoongArch do per PCI function
pass-throught. In theory, function pci_slot_enabled_per_func() should
return true on LoongArch also. Only that now IOMMU driver is not merged,
there is no way to test it, however we will write down this as a note
inside about this issue and verify it once IOMMU driver is merged.
Regards
Bibo Mao
>
>>
>> Fixes: 44510d6fa0c0 ("s390/pci: Handling multifunctions")
>> Cc: stable@vger.kernel.org
>> Suggested-by: Niklas Schnelle <schnelle@linux.ibm.com>
>> Signed-off-by: Farhan Ali <alifm@linux.ibm.com>
>> ---
>> drivers/pci/pci.c | 5 +++--
>> drivers/pci/slot.c | 25 ++++++++++++++++++++++---
>> include/linux/pci.h | 1 +
>> 3 files changed, 26 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
>> index b14dd064006c..36ee38e0d817 100644
>> --- a/drivers/pci/pci.c
>> +++ b/drivers/pci/pci.c
>> @@ -4980,8 +4980,9 @@ static int pci_reset_hotplug_slot(struct hotplug_slot *hotplug, bool probe)
>>
>> static int pci_dev_reset_slot_function(struct pci_dev *dev, bool probe)
>> {
>> - if (dev->multifunction || dev->subordinate || !dev->slot ||
>> - dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET)
>> + if (dev->subordinate || !dev->slot ||
>> + dev->dev_flags & PCI_DEV_FLAGS_NO_BUS_RESET ||
>> + (dev->multifunction && !dev->slot->per_func_slot))
>> return -ENOTTY;
>>
>> return pci_reset_hotplug_slot(dev->slot->hotplug, probe);
>> diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c
>> index 50fb3eb595fe..ed10fa3ae727 100644
>> --- a/drivers/pci/slot.c
>> +++ b/drivers/pci/slot.c
>> @@ -63,6 +63,22 @@ static ssize_t cur_speed_read_file(struct pci_slot *slot, char *buf)
>> return bus_speed_read(slot->bus->cur_bus_speed, buf);
>> }
>>
>> +static bool pci_dev_matches_slot(struct pci_dev *dev, struct pci_slot *slot)
>> +{
>> + if (slot->per_func_slot)
>> + return dev->devfn == slot->number;
>> +
>> + return PCI_SLOT(dev->devfn) == slot->number;
>> +}
>> +
>> +static bool pci_slot_enabled_per_func(void)
>> +{
>> + if (IS_ENABLED(CONFIG_S390))
>> + return true;
>> +
>> + return false;
>> +}
>> +
> --- snip ---
>>
>> diff --git a/include/linux/pci.h b/include/linux/pci.h
>> index d1fdf81fbe1e..6ad194597ab5 100644
>> --- a/include/linux/pci.h
>> +++ b/include/linux/pci.h
>> @@ -78,6 +78,7 @@ struct pci_slot {
>> struct list_head list; /* Node in list of slots */
>> struct hotplug_slot *hotplug; /* Hotplug info (move here) */
>> unsigned char number; /* PCI_SLOT(pci_dev->devfn) */
>> + unsigned int per_func_slot:1; /* Allow per function slot */
>> struct kobject kobj;
>> };
>>
>
> Reviewed-by: Niklas Schnelle <schnelle@linux.ibm.com>
>
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 1/2] PCI: Allow per function PCI slots
2025-10-28 1:11 ` Bibo Mao
@ 2025-10-29 8:37 ` Niklas Schnelle
0 siblings, 0 replies; 7+ messages in thread
From: Niklas Schnelle @ 2025-10-29 8:37 UTC (permalink / raw)
To: Bibo Mao, Farhan Ali, linux-s390, linux-pci, linux-kernel
Cc: helgaas, mjrosato, bblock, agordeev, gor, hca, stable,
Tianrui Zhao, Huacai Chen
On Tue, 2025-10-28 at 09:11 +0800, Bibo Mao wrote:
>
> On 2025/10/27 下午8:29, Niklas Schnelle wrote:
> > On Wed, 2025-10-22 at 14:24 -0700, Farhan Ali wrote:
> > > On s390 systems, which use a machine level hypervisor, PCI devices are
> > > always accessed through a form of PCI pass-through which fundamentally
> > > operates on a per PCI function granularity. This is also reflected in the
> > > s390 PCI hotplug driver which creates hotplug slots for individual PCI
> > > functions. Its reset_slot() function, which is a wrapper for
> > > zpci_hot_reset_device(), thus also resets individual functions.
> > >
> > > Currently, the kernel's PCI_SLOT() macro assigns the same pci_slot object
> > > to multifunction devices. This approach worked fine on s390 systems that
> > > only exposed virtual functions as individual PCI domains to the operating
> > > system. Since commit 44510d6fa0c0 ("s390/pci: Handling multifunctions")
> > > s390 supports exposing the topology of multifunction PCI devices by
> > > grouping them in a shared PCI domain. When attempting to reset a function
> > > through the hotplug driver, the shared slot assignment causes the wrong
> > > function to be reset instead of the intended one. It also leaks memory as
> > > we do create a pci_slot object for the function, but don't correctly free
> > > it in pci_slot_release().
> > >
> > > Add a flag for struct pci_slot to allow per function PCI slots for
> > > functions managed through a hypervisor, which exposes individual PCI
> > > functions while retaining the topology.
> >
> > I wonder if LoongArch which now also does per PCI function pass-through
> > might need this too. Adding their KVM maintainers.
>
> Hi Niklas,
>
> Thanks for your reminder. Yes, LoongArch do per PCI function
> pass-throught. In theory, function pci_slot_enabled_per_func() should
> return true on LoongArch also. Only that now IOMMU driver is not merged,
> there is no way to test it, however we will write down this as a note
> inside about this issue and verify it once IOMMU driver is merged.
>
>
> Regards
> Bibo Mao
>
Hi Bibo,
Is your ability to test if it works for you also hindered for my other
patch touching pci_scan_slot()? It sounded like Huacai was looking into
testing that.
Thanks,
Niklas
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/2] PCI fixes for s390
2025-10-22 21:24 [PATCH v2 0/2] PCI fixes for s390 Farhan Ali
2025-10-22 21:24 ` [PATCH v2 1/2] PCI: Allow per function PCI slots Farhan Ali
2025-10-22 21:24 ` [PATCH v2 2/2] s390/pci: Add architecture specific resource/bus address translation Farhan Ali
@ 2025-11-03 20:06 ` Farhan Ali
2 siblings, 0 replies; 7+ messages in thread
From: Farhan Ali @ 2025-11-03 20:06 UTC (permalink / raw)
To: linux-s390, linux-pci, linux-kernel, Bjorn Helgaas
Cc: schnelle, mjrosato, bblock, agordeev, gor, hca
Hi Bjorn,
Polite ping. I would like to get these patches merged as they fix some
existing issues for PCI devices on s390. Please let me know if there are
any concerns with the patches or anything needs to be changed.
Thanks
Farhan
On 10/22/2025 2:24 PM, Farhan Ali wrote:
> Hi,
>
> I came across some issues in PCI code for s390 while working on VFIO error
> recovery for s390 PCI devices [1]. These patches can be indepedently applied and
> has no depedency on error recovery patch series. We would like to get these
> patches merged as they do fix some existing issues.
>
> [1] https://lore.kernel.org/all/20250924171628.826-1-alifm@linux.ibm.com/
>
> ChangeLog
> ---------
> v1 -> v2
> - Re-work patch 1 on setting per_func_slot flag. The flag is set if platform
> enables per function pci slots (currently only enabled for s390).
> - Drop R-b tags for patch 1.
>
> Thanks
> Farhan
>
>
> Farhan Ali (2):
> PCI: Allow per function PCI slots
> s390/pci: Add architecture specific resource/bus address translation
>
> arch/s390/pci/pci.c | 74 +++++++++++++++++++++++++++++++++++++++
> drivers/pci/host-bridge.c | 4 +--
> drivers/pci/pci.c | 5 +--
> drivers/pci/slot.c | 25 +++++++++++--
> include/linux/pci.h | 1 +
> 5 files changed, 102 insertions(+), 7 deletions(-)
>
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2025-11-03 20:06 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-22 21:24 [PATCH v2 0/2] PCI fixes for s390 Farhan Ali
2025-10-22 21:24 ` [PATCH v2 1/2] PCI: Allow per function PCI slots Farhan Ali
2025-10-27 12:29 ` Niklas Schnelle
2025-10-28 1:11 ` Bibo Mao
2025-10-29 8:37 ` Niklas Schnelle
2025-10-22 21:24 ` [PATCH v2 2/2] s390/pci: Add architecture specific resource/bus address translation Farhan Ali
2025-11-03 20:06 ` [PATCH v2 0/2] PCI fixes for s390 Farhan Ali
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox