Re: [PATCH v4 04/10] s390/pci: Add architecture specific resource/bus address translation

From: Farhan Ali
Date: Wed Oct 01 2025 - 14:02:12 EST



On 10/1/2025 9:04 AM, Benjamin Block wrote:
On Thu, Sep 25, 2025 at 12:54:07PM +0200, Niklas Schnelle wrote:
On Wed, 2025-09-24 at 10:16 -0700, Farhan Ali wrote:
+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;
When we don't find a BAR matching the resource this would become the
region used. I'm not sure what a better value would be if we don't find
a match though and that should hopefully not happen in sensible uses.
Also this would keep the existing behavior so seems fine.
I was wondering the same things, but I guess it matches what happens elsewhere
as well, if no match is found

void __weak pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region,
struct resource *res)
{
...
resource_size_t offset = 0;

resource_list_for_each_entry(window, &bridge->windows) {
if (resource_contains(window->res, res)) {
offset = window->offset;
break;
}
}

region->start = res->start - offset;
region->end = res->end - offset;
}

So I guess that is fine.

The thing I'm also unclear on is whether it is OK to "throw out" this whole
logic about `resource_contains(window->res, res)` here and
`region_contains(&bus_region, region)` in the other original function?
I mean, the original function don't search for perfect matches, but also
matches where are contained in a given resource/region, which is different
from what we do here. Are we OK with not doing that at all?

I had thought about doing the range check, similar to resource_contains/region_contains rather than doing exact checks. But I think the way we expose the topology of the devices, the offset in our (s390x) case is zero. So I thought it should be safe to just doing exact match and might help us catch any issues if its not exact.

Thanks

Farhan