Skip to content

Commit f7f15fc

Browse files
floatiousbjorn-helgaas
authored andcommitted
PCI: endpoint: Align pci_epc_get_msi(), pci_epc_ops::get_msi() return value encoding
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 <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Signed-off-by: Bjorn Helgaas <[email protected]> Reviewed-by: Damien Le Moal <[email protected]> Cc: [email protected] # this is simply a cleanup Link: https://patch.msgid.link/[email protected]
1 parent c8bcb01 commit f7f15fc

File tree

5 files changed

+5
-7
lines changed

5 files changed

+5
-7
lines changed

drivers/pci/controller/cadence/pcie-cadence-ep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ static int cdns_pcie_ep_get_msi(struct pci_epc *epc, u8 fn, u8 vfn)
262262
*/
263263
mme = FIELD_GET(PCI_MSI_FLAGS_QSIZE, flags);
264264

265-
return mme;
265+
return 1 << mme;
266266
}
267267

268268
static int cdns_pcie_ep_get_msix(struct pci_epc *epc, u8 func_no, u8 vfunc_no)

drivers/pci/controller/dwc/pcie-designware-ep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ static int dw_pcie_ep_get_msi(struct pci_epc *epc, u8 func_no, u8 vfunc_no)
532532

533533
val = FIELD_GET(PCI_MSI_FLAGS_QSIZE, val);
534534

535-
return val;
535+
return 1 << val;
536536
}
537537

538538
static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 func_no, u8 vfunc_no,

drivers/pci/controller/pcie-rcar-ep.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ static int rcar_pcie_ep_get_msi(struct pci_epc *epc, u8 fn, u8 vfn)
280280
if (!(flags & MSICAP0_MSIE))
281281
return -EINVAL;
282282

283-
return ((flags & MSICAP0_MMESE_MASK) >> MSICAP0_MMESE_OFFSET);
283+
return 1 << ((flags & MSICAP0_MMESE_MASK) >> MSICAP0_MMESE_OFFSET);
284284
}
285285

286286
static int rcar_pcie_ep_map_addr(struct pci_epc *epc, u8 fn, u8 vfn,

drivers/pci/controller/pcie-rockchip-ep.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,8 +340,8 @@ static int rockchip_pcie_ep_get_msi(struct pci_epc *epc, u8 fn, u8 vfn)
340340
if (!(flags & ROCKCHIP_PCIE_EP_MSI_CTRL_ME))
341341
return -EINVAL;
342342

343-
return ((flags & ROCKCHIP_PCIE_EP_MSI_CTRL_MME_MASK) >>
344-
ROCKCHIP_PCIE_EP_MSI_CTRL_MME_OFFSET);
343+
return 1 << ((flags & ROCKCHIP_PCIE_EP_MSI_CTRL_MME_MASK) >>
344+
ROCKCHIP_PCIE_EP_MSI_CTRL_MME_OFFSET);
345345
}
346346

347347
static void rockchip_pcie_ep_assert_intx(struct rockchip_pcie_ep *ep, u8 fn,

drivers/pci/endpoint/pci-epc-core.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,8 +293,6 @@ int pci_epc_get_msi(struct pci_epc *epc, u8 func_no, u8 vfunc_no)
293293
if (interrupt < 0)
294294
return 0;
295295

296-
interrupt = 1 << interrupt;
297-
298296
return interrupt;
299297
}
300298
EXPORT_SYMBOL_GPL(pci_epc_get_msi);

0 commit comments

Comments
 (0)