MIPS: Cleanups to PCI related code
cover MIPS: Cleanups to PCI related code
While auditing PCI config space read/write callbacks, I came across a few places which were asking for cleanup. Thus, this cleanup series came to be.
Ilpo Järvinen (4):
MIPS: lantiq: Remove unused function pointer variables
MIPS: ath79: Don't return PCIBIOS_* code from pcibios_enable_device()
MIPS: PCI: Return PCIBIOS_* from tx4927_pci_config_read/write()
MIPS: TXx9: Use PCI_SET_ERROR_RESPONSE()
arch/mips/pci/fixup-ath79.c | 2 +- arch/mips/pci/fixup-lantiq.c | 9 --------- arch/mips/pci/ops-tx4927.c | 16 ++++++++++------ 3 files changed, 11 insertions(+), 16 deletions(-)
Signature · 1 line
2.39.2
PATCH 1/4 MIPS: lantiq: Remove unused function pointer variables
Ever since introduction in the commit e47d488935ed ("MIPS: Lantiq: Add PCI controller support.") ltqpci_plat_dev_init has been unused. In 57c8cb8f2429 ("MIPS: pci: convert lantiq driver to OF") also ltq_pci_plat_arch_init was introduced.
With those commit being more than 10 years ago, it seem neither is going to get used anytime soon. Thus, remove both unused function pointer variables.
--- arch/mips/pci/fixup-lantiq.c | 9 --------- 1 file changed, 9 deletions(-)
arch/mips/pci/fixup-lantiq.c +0 -9
@@ -7,17 +7,8 @@#include <linux/of_pci.h> #include <linux/pci.h> -int (*ltq_pci_plat_arch_init)(struct pci_dev *dev) =NULL ; -int (*ltq_pci_plat_dev_init)(struct pci_dev *dev) =NULL ; -int pcibios_plat_dev_init (struct pci_dev *dev) { -if (ltq_pci_plat_arch_init) -return ltq_pci_plat_arch_init (dev); - -if (ltq_pci_plat_dev_init) -return ltq_pci_plat_dev_init (dev); -return 0 ; }
Signature · 1 line
2.39.2
PATCH 2/4 MIPS: ath79: Don't return PCIBIOS_* code from pcibios_enable_device()
In reply to Ilpo Järvinenpcibios_plat_dev_init() is called from pcibios_enable_device() that should return normal errnos, not PCIBIOS return codes. In this case the impact is only cosmetic because PCIBIOS_SUCCESSFUL equals 0 that is success code with errnos as well. Nonetheless, remove the inconsistency by replacing the PCIBIOS_SUCCESSFUL with 0.
--- arch/mips/pci/fixup-ath79.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/pci/fixup-ath79.c +1 -1
@@ -9,7 +9,7 @@int pcibios_plat_dev_init (struct pci_dev *dev) { -return PCIBIOS_SUCCESSFUL ; +return 0 ; }int pcibios_map_irq (const struct pci_dev *dev,u8 slot,u8 pin)
Signature · 1 line
2.39.2
PATCH 3/4 MIPS: PCI: Return PCIBIOS_* from tx4927_pci_config_read/write()
In reply to Ilpo Järvinenpci_ops .read/.write must return PCIBIOS_* codes but tx4927_pci_config_read/write() return -1 when mkaddr() cannot find devfn from the root bus. Return PCIBIOS_DEVICE_NOT_FOUND instead and pass that onward in the call chain instead of overwriting the return value.
--- arch/mips/pci/ops-tx4927.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
arch/mips/pci/ops-tx4927.c +9 -5
@@ -60,7 +60,7 @@ static int mkaddr(struct pci_bus *bus, unsigned int devfn, int where, {if (bus->parent ==NULL && devfn >=PCI_DEVFN (TX4927_PCIC_MAX_DEVNU ,0 )) -return -1 ; +return PCIBIOS_DEVICE_NOT_FOUND ; __raw_writel(((bus->number & 0xff) << 0x10) | ((devfn & 0xff) << 0x08) | (where & 0xfc) | (bus->parent ? 1 : 0),
@@ -140,10 +140,12 @@ static int tx4927_pci_config_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val) { struct tx4927_pcic_reg __iomem *pcicptr = pci_bus_to_pcicptr(bus); +int ret; -if (mkaddr (bus, devfn, where, pcicptr)) { + ret =mkaddr (bus, devfn, where, pcicptr); +if (ret !=PCIBIOS_SUCCESSFUL ) { *val =0xffffffff ; -return -1 ; +return ret; }switch (size) {case 1 :
@@ -162,9 +164,11 @@ static int tx4927_pci_config_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val) { struct tx4927_pcic_reg __iomem *pcicptr = pci_bus_to_pcicptr(bus); +int ret; -if (mkaddr (bus, devfn, where, pcicptr)) -return -1 ; + ret =mkaddr (bus, devfn, where, pcicptr); +if (ret !=PCIBIOS_SUCCESSFUL ) +return ret;switch (size) {case 1 :icd_writeb (val, where &3 , pcicptr);
Signature · 1 line
2.39.2
Re: [PATCH 3/4] MIPS: PCI: Return PCIBIOS_* from tx4927_pci_config_read/write()
Hi,
Quoted 17 lines · Ilpo Järvinen
pci_ops.read/.write must return PCIBIOS_* codes but tx4927_pci_config_read/write() return -1 whenmkaddr()cannot find devfn from the root bus. ReturnPCIBIOS_DEVICE_NOT_FOUNDinstead and pass that onward in the call chain instead of overwriting the return value.Signed-off-by Ilpo Järvinen <[email protected]>--- arch/mips/pci/ops-tx4927.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)arch/mips/pci/ops-tx4927.c +0
-0
arch/mips/pci/ops-tx4927.c static int mkaddr(struct pci_bus *bus, unsigned int devfn, int where, · line 66
Quoted 8 lines
arch/mips/pci/ops-tx4927.c +1
-1@@ -60,7 +60,7 @@ static int mkaddr(struct pci_bus *bus, unsigned int devfn, int where, {if (bus->parent ==NULL && devfn >=PCI_DEVFN (TX4927_PCIC_MAX_DEVNU ,0 )) -return -1 ; +return PCIBIOS_DEVICE_NOT_FOUND ; __raw_writel(((bus->number & 0xff) << 0x10) | ((devfn & 0xff) << 0x08) | (where & 0xfc) | (bus->parent ? 1 : 0),
Should we also return PCIBIOS_SUCCESSFUL instead of 'return 0' in 'mkaddr' for coherency?
Other than that, changes look good to me.
Thanks,
Sergio Paracuellos
Quoted 33 lines
arch/mips/pci/ops-tx4927.c +8
-5@@ -140,10 +140,12 @@ static int tx4927_pci_config_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val) { struct tx4927_pcic_reg __iomem *pcicptr = pci_bus_to_pcicptr(bus); +int ret; -if (mkaddr (bus, devfn, where, pcicptr)) { + ret =mkaddr (bus, devfn, where, pcicptr); +if (ret !=PCIBIOS_SUCCESSFUL ) { *val =0xffffffff ; -return -1 ; +return ret; }switch (size) {case 1 :@@ -162,9 +164,11 @@ static int tx4927_pci_config_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val) { struct tx4927_pcic_reg __iomem *pcicptr = pci_bus_to_pcicptr(bus); +int ret; -if (mkaddr (bus, devfn, where, pcicptr)) -return -1 ; + ret =mkaddr (bus, devfn, where, pcicptr); +if (ret !=PCIBIOS_SUCCESSFUL ) +return ret;switch (size) {case 1 :icd_writeb (val, where &3 , pcicptr); --2.39.2
Re: [PATCH 3/4] MIPS: PCI: Return PCIBIOS_* from tx4927_pci_config_read/write()
Quoted 14 lines · Sergio Paracuellos
Quoted 12 lines · Ilpo Järvinen
pci_ops.read/.write must return PCIBIOS_* codes but tx4927_pci_config_read/write() return -1 whenmkaddr()cannot find devfn from the root bus. ReturnPCIBIOS_DEVICE_NOT_FOUNDinstead and pass that onward in the call chain instead of overwriting the return value.Signed-off-by Ilpo Järvinen <[email protected]>--- arch/mips/pci/ops-tx4927.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-)
Quoted 16 lines
arch/mips/pci/ops-tx4927.c static int mkaddr(struct pci_bus *bus, unsigned int devfn, int where, · line 66
Quoted 13 lines
arch/mips/pci/ops-tx4927.c +1
-1@@ -60,7 +60,7 @@ static int mkaddr(struct pci_bus *bus, unsigned int devfn, int where, {if (bus->parent ==NULL && devfn >=PCI_DEVFN (TX4927_PCIC_MAX_DEVNU ,0 )) -return -1 ; +return PCIBIOS_DEVICE_NOT_FOUND ; __raw_writel(((bus->number & 0xff) << 0x10) | ((devfn & 0xff) << 0x08) | (where & 0xfc) | (bus->parent ? 1 : 0),Should we also return
PCIBIOS_SUCCESSFULinstead of 'return 0' in 'mkaddr' for coherency?
Yeah right, I'll change it too.
I didn't take notice of that because the reason for all this is that I intend to convert these functions to return generic errno and push the PCIBIOS error code -> errno conversion into where it's really needed (real PCIBIOS access functions in arch/x86/pci/pcbios.c). Returning 0 as literal is very common cosmetic "error" in these functions. While calculating the error rate in return values of these functions (I'm able to do that because of the audit), those were not even included to 15% returning -Esomething instead of PCIBIOS_*. It would be way above that if I'd count return 0 also as an error.
Quoted 3 lines
Other than that, changes look good to me.
Reviewed-by Sergio Paracuellos <[email protected]>
Thanks for the review.
Signature · 1 line
i.
PATCH 4/4 MIPS: TXx9: Use PCI_SET_ERROR_RESPONSE()
In reply to Ilpo JärvinenInstead of literal, PCI error value should be set with PCI_SET_ERROR_RESPONSE(). Use it in tx4927_pci_config_read().
--- arch/mips/pci/ops-tx4927.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
arch/mips/pci/ops-tx4927.c +1 -1
@@ -144,7 +144,7 @@ static int tx4927_pci_config_read(struct pci_bus *bus, unsigned int devfn, ret =mkaddr (bus, devfn, where, pcicptr);if (ret !=PCIBIOS_SUCCESSFUL ) { - *val =0xffffffff ; +PCI_SET_ERROR_RESPONSE (val);return ret; }switch (size) {
Signature · 1 line
2.39.2