PCI: endpoint: Align pci_epc_get_msi(), pci_epc_ops::get_msi() return value encoding
authorNiklas Cassel <cassel@kernel.org>
Wed, 14 May 2025 07:43:16 +0000 (09:43 +0200)
committerBjorn Helgaas <bhelgaas@google.com>
Wed, 28 May 2025 21:47:56 +0000 (16:47 -0500)
The kdoc for API pci_epc_get_msi() says:
"Invoke to get the number of MSI interrupts allocated by the RC"

The kdoc for the callback pci_epc_ops::get_msi() says:
"ops to get the number of MSI interrupts allocated by the RC from
the MSI capability register"

pci_epc_ops::get_msi() does however return the number of interrupts in the
encoding as defined by the Multiple Message Enable (MME) field of the MSI
Capability structure.

Nowhere in the kdoc does it say that the returned number of interrupts is
in MME encoding. It is very confusing that the API pci_epc_get_msi() and
the callback function pci_epc_ops::get_msi() don't return the same value.

Clean up the API and the callback function to have the same semantics,
i.e. return the number of interrupts, regardless of the internal encoding
of that value.

[bhelgaas: more specific subject]

Signed-off-by: Niklas Cassel <cassel@kernel.org>
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@linaro.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
Cc: stable+noautosel@kernel.org # this is simply a cleanup
Link: https://patch.msgid.link/20250514074313.283156-11-cassel@kernel.org
drivers/pci/controller/cadence/pcie-cadence-ep.c
drivers/pci/controller/dwc/pcie-designware-ep.c
drivers/pci/controller/pcie-rcar-ep.c
drivers/pci/controller/pcie-rockchip-ep.c
drivers/pci/endpoint/pci-epc-core.c

index 112ae200b393a66ac3d5cb3780016354a88cd275..78b4d009cd04808e8e74a4ba916cc5c4271eef8b 100644 (file)
@@ -262,7 +262,7 @@ static int cdns_pcie_ep_get_msi(struct pci_epc *epc, u8 fn, u8 vfn)
         */
        mme = FIELD_GET(PCI_MSI_FLAGS_QSIZE, flags);
 
-       return mme;
+       return 1 << mme;
 }
 
 static int cdns_pcie_ep_get_msix(struct pci_epc *epc, u8 func_no, u8 vfunc_no)
index 24026f3f34133bf70be7d5bfb7337c3d0d3447e8..03597551f4cda611cea11428bd0d81a891bc35b3 100644 (file)
@@ -532,7 +532,7 @@ static int dw_pcie_ep_get_msi(struct pci_epc *epc, u8 func_no, u8 vfunc_no)
 
        val = FIELD_GET(PCI_MSI_FLAGS_QSIZE, val);
 
-       return val;
+       return 1 << val;
 }
 
 static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 func_no, u8 vfunc_no,
index c5e0d025bc4359ce26b5527dc8825bef27050383..9da39a4617b6d3575fbac64397df03a802a66093 100644 (file)
@@ -280,7 +280,7 @@ static int rcar_pcie_ep_get_msi(struct pci_epc *epc, u8 fn, u8 vfn)
        if (!(flags & MSICAP0_MSIE))
                return -EINVAL;
 
-       return ((flags & MSICAP0_MMESE_MASK) >> MSICAP0_MMESE_OFFSET);
+       return 1 << ((flags & MSICAP0_MMESE_MASK) >> MSICAP0_MMESE_OFFSET);
 }
 
 static int rcar_pcie_ep_map_addr(struct pci_epc *epc, u8 fn, u8 vfn,
index 85ea36df2f59ab6f7d41f38b55bcc21fc8658d7b..85ca7d9b4c77c653a14e33d7be9aa3fe5ad48308 100644 (file)
@@ -340,8 +340,8 @@ static int rockchip_pcie_ep_get_msi(struct pci_epc *epc, u8 fn, u8 vfn)
        if (!(flags & ROCKCHIP_PCIE_EP_MSI_CTRL_ME))
                return -EINVAL;
 
-       return ((flags & ROCKCHIP_PCIE_EP_MSI_CTRL_MME_MASK) >>
-                       ROCKCHIP_PCIE_EP_MSI_CTRL_MME_OFFSET);
+       return 1 << ((flags & ROCKCHIP_PCIE_EP_MSI_CTRL_MME_MASK) >>
+                    ROCKCHIP_PCIE_EP_MSI_CTRL_MME_OFFSET);
 }
 
 static void rockchip_pcie_ep_assert_intx(struct rockchip_pcie_ep *ep, u8 fn,
index beabea00af915cf551dde139096459b0f7ec260c..cc1456bd188e340c96a4b7f85cad2785c1c73d43 100644 (file)
@@ -293,8 +293,6 @@ int pci_epc_get_msi(struct pci_epc *epc, u8 func_no, u8 vfunc_no)
        if (interrupt < 0)
                return 0;
 
-       interrupt = 1 << interrupt;
-
        return interrupt;
 }
 EXPORT_SYMBOL_GPL(pci_epc_get_msi);