PCI: Remove unused PCI_SUBTRACTIVE_DECODE
PATCH 1/3 PCI: Remove unused PCI_SUBTRACTIVE_DECODE
The commit 2fe2abf896c1 ("PCI: augment bus resource table with a list") added PCI_SUBTRACTIVE_DECODE which is put into the struct pci_bus_resource flags field but is never read. There seems to never have been users for it. Remove both PCI_SUBTRACTIVE_DECODE and the flags field from the struct pci_bus_resource.
--- arch/s390/pci/pci_bus.c | 2 +- arch/x86/pci/fixup.c | 2 +- drivers/pci/bus.c | 4 +--- drivers/pci/probe.c | 5 ++--- include/linux/pci.h | 12 +----------- 5 files changed, 6 insertions(+), 19 deletions(-)
arch/s390/pci/pci_bus.c +1 -1
@@ -53,7 +53,7 @@ static int zpci_bus_prepare_device(struct zpci_dev *zdev)zpci_setup_bus_resources (zdev);for (i =0 ; i <PCI_STD_NUM_BARS ; i++) {if (zdev->bars[i].res) -pci_bus_add_resource (zdev->zbus->bus, zdev->bars[i].res,0 ); +pci_bus_add_resource (zdev->zbus->bus, zdev->bars[i].res); } }
arch/x86/pci/fixup.c +1 -1
@@ -757,7 +757,7 @@ static void pci_amd_enable_64bit_bar(struct pci_dev *dev)dev_info (&dev->dev,"adding root bus resource %pR (tainting kernel)\n" , res);add_taint (TAINT_FIRMWARE_WORKAROUND ,LOCKDEP_STILL_OK ); -pci_bus_add_resource (dev->bus, res,0 ); +pci_bus_add_resource (dev->bus, res); } base = ((res->start >> 8) & AMD_141b_MMIO_BASE_MMIOBASE_MASK) |
drivers/pci/bus.c +1 -3
@@ -46,8 +46,7 @@ void pci_free_resource_list(struct list_head *resources) }EXPORT_SYMBOL (pci_free_resource_list); -void pci_bus_add_resource (struct pci_bus *bus,struct resource *res, -unsigned int flags) +void pci_bus_add_resource (struct pci_bus *bus,struct resource *res) {struct pci_bus_resource *bus_res;
@@ -58,7 +57,6 @@ void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, } bus_res->res = res; - bus_res->flags = flags;list_add_tail (&bus_res->list, &bus->resources); }
drivers/pci/probe.c +2 -3
@@ -546,8 +546,7 @@ void pci_read_bridge_bases(struct pci_bus *child)if (dev->transparent) {pci_bus_for_each_resource (child->parent, res) {if (res && res->flags) { -pci_bus_add_resource (child, res, -PCI_SUBTRACTIVE_DECODE ); +pci_bus_add_resource (child, res);pci_info (dev," bridge window %pR (subtractive decode)\n" , res); }
@@ -1032,7 +1031,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)if (res->flags &IORESOURCE_BUS )pci_bus_insert_busn_res (bus, bus->number, res->end);else -pci_bus_add_resource (bus, res,0 ); +pci_bus_add_resource (bus, res);if (offset) {if (resource_type (res) ==IORESOURCE_IO )
include/linux/pci.h +1 -11
@@ -633,18 +633,9 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);* Use pci_bus_for_each_resource() to iterate through all the resources. */ -/* -* PCI_SUBTRACTIVE_DECODE means the bridge forwards the window implicitly -* and there's no way to program the bridge with the details of the window. -* This does not apply to ACPI _CRS windows, even with the _DEC subtractive- -* decode bit set, because they are explicit and can be programmed with _SRS. -*/ -#define PCI_SUBTRACTIVE_DECODE 0x1 -struct pci_bus_resource {struct list_head list;struct resource *res; -unsigned int flags; };#define PCI_REGION_FLAG_MASK 0x0fU/* These bits of resource flags tell us the PCI region flags */
@@ -1498,8 +1489,7 @@ void pci_add_resource(struct list_head *resources, struct resource *res);void pci_add_resource_offset (struct list_head *resources,struct resource *res,resource_size_t offset);void pci_free_resource_list (struct list_head *resources); -void pci_bus_add_resource (struct pci_bus *bus,struct resource *res, -unsigned int flags); +void pci_bus_add_resource (struct pci_bus *bus,struct resource *res);struct resource *pci_bus_resource_n (const struct pci_bus *bus,int n);void pci_bus_remove_resources (struct pci_bus *bus);void pci_bus_remove_resource (struct pci_bus *bus,struct resource *res);
Signature · 1 line
2.39.5
PATCH 2/3 PCI: Move struct pci_bus_resource into bus.c
The struct pci_bus_resource is only used in bus.c so move it there.
--- drivers/pci/bus.c | 12 ++++++++++++ include/linux/pci.h | 12 ------------ 2 files changed, 12 insertions(+), 12 deletions(-)
drivers/pci/bus.c +12 -0
@@ -18,6 +18,18 @@#include "pci.h" +/* +* The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond +* to P2P or CardBus bridge windows) go in a table. Additional ones (for +* buses below host bridges or subtractive decode bridges) go in the list. +* Use pci_bus_for_each_resource() to iterate through all the resources. +*/ + +struct pci_bus_resource { +struct list_head list; +struct resource *res; +}; +void pci_add_resource_offset (struct list_head *resources,struct resource *res,resource_size_t offset) {
include/linux/pci.h +0 -12
@@ -626,18 +626,6 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge,int pcibios_root_bridge_prepare (struct pci_host_bridge *bridge); -/* -* The first PCI_BRIDGE_RESOURCE_NUM PCI bus resources (those that correspond -* to P2P or CardBus bridge windows) go in a table. Additional ones (for -* buses below host bridges or subtractive decode bridges) go in the list. -* Use pci_bus_for_each_resource() to iterate through all the resources. -*/ - -struct pci_bus_resource { -struct list_head list; -struct resource *res; -}; -#define PCI_REGION_FLAG_MASK 0x0fU/* These bits of resource flags tell us the PCI region flags */ struct pci_bus {
Signature · 1 line
2.39.5
Re: [PATCH 2/3] PCI: Move struct pci_bus_resource into bus.c
Quoted 3 lines · On Thu, 17 Oct 2024 17:11:09 +0300 Ilpo Järvinen…
The struct
pci_bus_resourceis only used inbus.cso move it there.Signed-off-by Ilpo Järvinen <[email protected]>
LGTM
PATCH 3/3 PCI: Use reverse logic in pci_read_bridge_bases()
In reply to Ilpo JärvinenUse reverse logic combined with return and continue to allow significant reduction in indentation level in pci_read_bridge_bases().
--- drivers/pci/probe.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/pci/probe.c +9 -8
@@ -543,14 +543,15 @@ void pci_read_bridge_bases(struct pci_bus *child)pci_read_bridge_mmio (child->self, child->resource[1 ], false);pci_read_bridge_mmio_pref (child->self, child->resource[2 ], false); -if (dev->transparent) { -pci_bus_for_each_resource (child->parent, res) { -if (res && res->flags) { -pci_bus_add_resource (child, res); -pci_info (dev," bridge window %pR (subtractive decode)\n" , - res); - } - } +if (!dev->transparent) +return ; + +pci_bus_for_each_resource (child->parent, res) { +if (!res || !res->flags) +continue ; + +pci_bus_add_resource (child, res); +pci_info (dev," bridge window %pR (subtractive decode)\n" , res); } }
Signature · 1 line
2.39.5
Re: [PATCH 3/3] PCI: Use reverse logic in pci_read_bridge_bases()
Quoted 4 lines · On Thu, 17 Oct 2024 17:11:10 +0300 Ilpo Järvinen…
Use reverse logic combined with return and continue to allow significant reduction in indentation level in
pci_read_bridge_bases().Signed-off-by Ilpo Järvinen <[email protected]>
Quoted 32 lines
--- drivers/pci/probe.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)drivers/pci/probe.c +9
-8@@ -543,14 +543,15 @@ void pci_read_bridge_bases(struct pci_bus *child)pci_read_bridge_mmio (child->self, child->resource[1 ], false);pci_read_bridge_mmio_pref (child->self, child->resource[2 ], false); -if (dev->transparent) { -pci_bus_for_each_resource (child->parent, res) { -if (res && res->flags) { -pci_bus_add_resource (child, res); -pci_info (dev," bridge window %pR (subtractive decode)\n" , - res); - } - } +if (!dev->transparent) +return ; + +pci_bus_for_each_resource (child->parent, res) { +if (!res || !res->flags) +continue ; + +pci_bus_add_resource (child, res); +pci_info (dev," bridge window %pR (subtractive decode)\n" , res); } }
Quoted 7 lines · On Thu, 17 Oct 2024 17:11:08 +0300 Ilpo Järvinen…
The commit
2fe2abf896c1("PCI: augment bus resource table with a list") addedPCI_SUBTRACTIVE_DECODEwhich is put into the structpci_bus_resourceflags field but is never read. There seems to never have been users for it. Remove bothPCI_SUBTRACTIVE_DECODEand the flags field from the structpci_bus_resource.Signed-off-by Ilpo Järvinen <[email protected]>
Nice cleanup.
Quoted 7 lines
--- arch/s390/pci/pci_bus.c | 2 +- arch/x86/pci/fixup.c | 2 +- drivers/pci/bus.c | 4 +--- drivers/pci/probe.c | 5 ++--- include/linux/pci.h | 12 +----------- 5 files changed, 6 insertions(+), 19 deletions(-)
Quoted 7 lines · Ilpo Järvinen
The commit
2fe2abf896c1("PCI: augment bus resource table with a list") addedPCI_SUBTRACTIVE_DECODEwhich is put into the structpci_bus_resourceflags field but is never read. There seems to never have been users for it. Remove bothPCI_SUBTRACTIVE_DECODEand the flags field from the structpci_bus_resource.Signed-off-by Ilpo Järvinen <[email protected]>
All three applied with Jonathan's reviewed-by to pci/enumeration for v6.13, thanks, Ilpo!
Quoted 115 lines
--- arch/s390/pci/pci_bus.c | 2 +- arch/x86/pci/fixup.c | 2 +- drivers/pci/bus.c | 4 +--- drivers/pci/probe.c | 5 ++--- include/linux/pci.h | 12 +----------- 5 files changed, 6 insertions(+), 19 deletions(-)arch/s390/pci/pci_bus.c +1
-1@@ -53,7 +53,7 @@ static int zpci_bus_prepare_device(struct zpci_dev *zdev)zpci_setup_bus_resources (zdev);for (i =0 ; i <PCI_STD_NUM_BARS ; i++) {if (zdev->bars[i].res) -pci_bus_add_resource (zdev->zbus->bus, zdev->bars[i].res,0 ); +pci_bus_add_resource (zdev->zbus->bus, zdev->bars[i].res); } }arch/x86/pci/fixup.c +1
-1@@ -757,7 +757,7 @@ static void pci_amd_enable_64bit_bar(struct pci_dev *dev)dev_info (&dev->dev,"adding root bus resource %pR (tainting kernel)\n" , res);add_taint (TAINT_FIRMWARE_WORKAROUND ,LOCKDEP_STILL_OK ); -pci_bus_add_resource (dev->bus, res,0 ); +pci_bus_add_resource (dev->bus, res); } base = ((res->start >> 8) & AMD_141b_MMIO_BASE_MMIOBASE_MASK) |drivers/pci/bus.c +1
-3@@ -46,8 +46,7 @@ void pci_free_resource_list(struct list_head *resources) }EXPORT_SYMBOL (pci_free_resource_list); -void pci_bus_add_resource (struct pci_bus *bus,struct resource *res, -unsigned int flags) +void pci_bus_add_resource (struct pci_bus *bus,struct resource *res) {struct pci_bus_resource *bus_res;@@ -58,7 +57,6 @@ void pci_bus_add_resource(struct pci_bus *bus, struct resource *res, } bus_res->res = res; - bus_res->flags = flags;list_add_tail (&bus_res->list, &bus->resources); }drivers/pci/probe.c +2
-3@@ -546,8 +546,7 @@ void pci_read_bridge_bases(struct pci_bus *child)if (dev->transparent) {pci_bus_for_each_resource (child->parent, res) {if (res && res->flags) { -pci_bus_add_resource (child, res, -PCI_SUBTRACTIVE_DECODE ); +pci_bus_add_resource (child, res);pci_info (dev," bridge window %pR (subtractive decode)\n" , res); }@@ -1032,7 +1031,7 @@ static int pci_register_host_bridge(struct pci_host_bridge *bridge)if (res->flags &IORESOURCE_BUS )pci_bus_insert_busn_res (bus, bus->number, res->end);else -pci_bus_add_resource (bus, res,0 ); +pci_bus_add_resource (bus, res);if (offset) {if (resource_type (res) ==IORESOURCE_IO )include/linux/pci.h +1
-11@@ -633,18 +633,9 @@ int pcibios_root_bridge_prepare(struct pci_host_bridge *bridge);* Use pci_bus_for_each_resource() to iterate through all the resources. */ -/* -* PCI_SUBTRACTIVE_DECODE means the bridge forwards the window implicitly -* and there's no way to program the bridge with the details of the window. -* This does not apply to ACPI _CRS windows, even with the _DEC subtractive- -* decode bit set, because they are explicit and can be programmed with _SRS. -*/ -#define PCI_SUBTRACTIVE_DECODE 0x1 -struct pci_bus_resource {struct list_head list;struct resource *res; -unsigned int flags; };#define PCI_REGION_FLAG_MASK 0x0fU/* These bits of resource flags tell us the PCI region flags */ @@ -1498,8 +1489,7 @@ void pci_add_resource(struct list_head *resources, struct resource *res);void pci_add_resource_offset (struct list_head *resources,struct resource *res,resource_size_t offset);void pci_free_resource_list (struct list_head *resources); -void pci_bus_add_resource (struct pci_bus *bus,struct resource *res, -unsigned int flags); +void pci_bus_add_resource (struct pci_bus *bus,struct resource *res);struct resource *pci_bus_resource_n (const struct pci_bus *bus,int n);void pci_bus_remove_resources (struct pci_bus *bus);void pci_bus_remove_resource (struct pci_bus *bus,struct resource *res);Signature · 1 line
2.39.5