powerpc/rtas_pci: rename and properly expose config access APIs
authorNathan Lynch <nathanl@linux.ibm.com>
Tue, 28 Nov 2023 00:40:09 +0000 (18:40 -0600)
committerMichael Ellerman <mpe@ellerman.id.au>
Tue, 28 Nov 2023 10:49:45 +0000 (21:49 +1100)
The rtas_read_config() and rtas_write_config() functions in
kernel/rtas_pci.c have external linkage and two users in arch/powerpc:
the rtas_pci code itself and the pseries platform's "enhanced error
handling" (EEH) support code.

The prototypes for these functions in asm/ppc-pci.h have until now
been guarded by CONFIG_EEH since the only external caller is the
pseries EEH code. However, this presumably has always generated
warnings when built with !CONFIG_EEH and -Wmissing-prototypes:

  arch/powerpc/kernel/rtas_pci.c:46:5: error: no previous prototype for
  function 'rtas_read_config' [-Werror,-Wmissing-prototypes]
     46 | int rtas_read_config(struct pci_dn *pdn, int where,
                               int size, u32 *val)

  arch/powerpc/kernel/rtas_pci.c:98:5: error: no previous prototype for
  function 'rtas_write_config' [-Werror,-Wmissing-prototypes]
     98 | int rtas_write_config(struct pci_dn *pdn, int where,
                                int size, u32 val)

The introduction of commit c6345dfa6e3e ("Makefile.extrawarn: turn on
missing-prototypes globally") forces the issue.

The efika and chrp platform code have (static) functions with the same
names but different signatures. We may as well eliminate the potential
for conflicts and confusion by renaming the globally visible versions
as their prototypes get moved out of the CONFIG_EEH-guarded region;
their current names are too generic anyway. Since they operate on
objects of the type 'struct pci_dn *', give them the slightly more
verbose prefix "rtas_pci_dn_" and fix up all the call sites.

Fixes: c6345dfa6e3e ("Makefile.extrawarn: turn on missing-prototypes globally")
Reported-by: Linux Kernel Functional Testing <lkft@linaro.org>
Closes: https://lore.kernel.org/linuxppc-dev/CA+G9fYt0LLXtjSz+Hkf3Fhm-kf0ZQanrhUS+zVZGa3O+Wt2+vg@mail.gmail.com/
Signed-off-by: Nathan Lynch <nathanl@linux.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231127-rtas-pci-rw-config-v1-1-385d29ace3df@linux.ibm.com
arch/powerpc/include/asm/ppc-pci.h
arch/powerpc/kernel/rtas_pci.c
arch/powerpc/platforms/pseries/eeh_pseries.c

index d9fcff5750271d066b74b3fdb8e321de37121aeb..ce2b1b5eebddcf5eb2e84b5e8853f89cf06501a6 100644 (file)
@@ -35,6 +35,9 @@ extern void init_pci_config_tokens (void);
 extern unsigned long get_phb_buid (struct device_node *);
 extern int rtas_setup_phb(struct pci_controller *phb);
 
+int rtas_pci_dn_read_config(struct pci_dn *pdn, int where, int size, u32 *val);
+int rtas_pci_dn_write_config(struct pci_dn *pdn, int where, int size, u32 val);
+
 #ifdef CONFIG_EEH
 
 void eeh_addr_cache_insert_dev(struct pci_dev *dev);
@@ -44,8 +47,6 @@ void eeh_slot_error_detail(struct eeh_pe *pe, int severity);
 int eeh_pci_enable(struct eeh_pe *pe, int function);
 int eeh_pe_reset_full(struct eeh_pe *pe, bool include_passed);
 void eeh_save_bars(struct eeh_dev *edev);
-int rtas_write_config(struct pci_dn *, int where, int size, u32 val);
-int rtas_read_config(struct pci_dn *, int where, int size, u32 *val);
 void eeh_pe_state_mark(struct eeh_pe *pe, int state);
 void eeh_pe_mark_isolated(struct eeh_pe *pe);
 void eeh_pe_state_clear(struct eeh_pe *pe, int state, bool include_passed);
index e1fdc7473b72c1da37d88d5af6f5c0afa7335f82..fccf96e897f6a7b6f092f38b20c4d18142f650e7 100644 (file)
@@ -43,7 +43,7 @@ static inline int config_access_valid(struct pci_dn *dn, int where)
        return 0;
 }
 
-int rtas_read_config(struct pci_dn *pdn, int where, int size, u32 *val)
+int rtas_pci_dn_read_config(struct pci_dn *pdn, int where, int size, u32 *val)
 {
        int returnval = -1;
        unsigned long buid, addr;
@@ -87,7 +87,7 @@ static int rtas_pci_read_config(struct pci_bus *bus,
        pdn = pci_get_pdn_by_devfn(bus, devfn);
 
        /* Validity of pdn is checked in here */
-       ret = rtas_read_config(pdn, where, size, val);
+       ret = rtas_pci_dn_read_config(pdn, where, size, val);
        if (*val == EEH_IO_ERROR_VALUE(size) &&
            eeh_dev_check_failure(pdn_to_eeh_dev(pdn)))
                return PCIBIOS_DEVICE_NOT_FOUND;
@@ -95,7 +95,7 @@ static int rtas_pci_read_config(struct pci_bus *bus,
        return ret;
 }
 
-int rtas_write_config(struct pci_dn *pdn, int where, int size, u32 val)
+int rtas_pci_dn_write_config(struct pci_dn *pdn, int where, int size, u32 val)
 {
        unsigned long buid, addr;
        int ret;
@@ -134,7 +134,7 @@ static int rtas_pci_write_config(struct pci_bus *bus,
        pdn = pci_get_pdn_by_devfn(bus, devfn);
 
        /* Validity of pdn is checked in here. */
-       return rtas_write_config(pdn, where, size, val);
+       return rtas_pci_dn_write_config(pdn, where, size, val);
 }
 
 static struct pci_ops rtas_pci_ops = {
index def184da51cf0e719441a9ad586fea7b36dae818..b1ae0c0d1187825cd490c95e5b4d1174fa056928 100644 (file)
@@ -252,7 +252,7 @@ static int pseries_eeh_cap_start(struct pci_dn *pdn)
        if (!pdn)
                return 0;
 
-       rtas_read_config(pdn, PCI_STATUS, 2, &status);
+       rtas_pci_dn_read_config(pdn, PCI_STATUS, 2, &status);
        if (!(status & PCI_STATUS_CAP_LIST))
                return 0;
 
@@ -270,11 +270,11 @@ static int pseries_eeh_find_cap(struct pci_dn *pdn, int cap)
                return 0;
 
         while (cnt--) {
-               rtas_read_config(pdn, pos, 1, &pos);
+               rtas_pci_dn_read_config(pdn, pos, 1, &pos);
                if (pos < 0x40)
                        break;
                pos &= ~3;
-               rtas_read_config(pdn, pos + PCI_CAP_LIST_ID, 1, &id);
+               rtas_pci_dn_read_config(pdn, pos + PCI_CAP_LIST_ID, 1, &id);
                if (id == 0xff)
                        break;
                if (id == cap)
@@ -294,7 +294,7 @@ static int pseries_eeh_find_ecap(struct pci_dn *pdn, int cap)
 
        if (!edev || !edev->pcie_cap)
                return 0;
-       if (rtas_read_config(pdn, pos, 4, &header) != PCIBIOS_SUCCESSFUL)
+       if (rtas_pci_dn_read_config(pdn, pos, 4, &header) != PCIBIOS_SUCCESSFUL)
                return 0;
        else if (!header)
                return 0;
@@ -307,7 +307,7 @@ static int pseries_eeh_find_ecap(struct pci_dn *pdn, int cap)
                if (pos < 256)
                        break;
 
-               if (rtas_read_config(pdn, pos, 4, &header) != PCIBIOS_SUCCESSFUL)
+               if (rtas_pci_dn_read_config(pdn, pos, 4, &header) != PCIBIOS_SUCCESSFUL)
                        break;
        }
 
@@ -412,8 +412,8 @@ static void pseries_eeh_init_edev(struct pci_dn *pdn)
        if ((pdn->class_code >> 8) == PCI_CLASS_BRIDGE_PCI) {
                edev->mode |= EEH_DEV_BRIDGE;
                if (edev->pcie_cap) {
-                       rtas_read_config(pdn, edev->pcie_cap + PCI_EXP_FLAGS,
-                                        2, &pcie_flags);
+                       rtas_pci_dn_read_config(pdn, edev->pcie_cap + PCI_EXP_FLAGS,
+                                               2, &pcie_flags);
                        pcie_flags = (pcie_flags & PCI_EXP_FLAGS_TYPE) >> 4;
                        if (pcie_flags == PCI_EXP_TYPE_ROOT_PORT)
                                edev->mode |= EEH_DEV_ROOT_PORT;
@@ -676,7 +676,7 @@ static int pseries_eeh_read_config(struct eeh_dev *edev, int where, int size, u3
 {
        struct pci_dn *pdn = eeh_dev_to_pdn(edev);
 
-       return rtas_read_config(pdn, where, size, val);
+       return rtas_pci_dn_read_config(pdn, where, size, val);
 }
 
 /**
@@ -692,7 +692,7 @@ static int pseries_eeh_write_config(struct eeh_dev *edev, int where, int size, u
 {
        struct pci_dn *pdn = eeh_dev_to_pdn(edev);
 
-       return rtas_write_config(pdn, where, size, val);
+       return rtas_pci_dn_write_config(pdn, where, size, val);
 }
 
 #ifdef CONFIG_PCI_IOV