Add MSI-X support on pcitest tool
Subsystems (8)
v4 cover Add MSI-X support on pcitest tool
Patch series made against Lorenzo's master branch.
Add MSI-X support on pcitest tool.
Add new callbacks methods and handlers to trigger the MSI-X interrupts on the EP DesignWare IP driver.
Allow to set/get MSI-X EP maximum capability number.
Rework on set/get and triggering MSI methods on EP DesignWare IP driver.
Add a new input parameter (msix) to pcitest tool to test MSI-X feature.
Update the pcitest.sh script to support MSI-X feature tests.
Gustavo Pimentel (10):
PCI: endpoint: Add MSI-X interfaces
PCI: dwc: Add MSI-X callbacks handler
PCI: Update xxx_pcie_ep_raise_irq() and pci_epc_raise_irq() signatures
PCI: dwc: Rework MSI callbacks handler
PCI: dwc: Add legacy interrupt callback handler pci-epf-test/pci_endpoint_test: Cleanup PCI_ENDPOINT_TEST memspace pci-epf-test/pci_endpoint_test: Use irq_type module parameter pci-epf-test/pci_endpoint_test: Add MSI-X support
pci_endpoint_test: Add 2 ioctl commands
tools: PCI: Add MSI-X support
Documentation/misc-devices/pci-endpoint-test.txt | 6 + drivers/misc/pci_endpoint_test.c | 261 ++++++++++++++++------ drivers/pci/controller/dwc/pci-dra7xx.c | 2 +- drivers/pci/controller/dwc/pcie-artpec6.c | 2 +- drivers/pci/controller/dwc/pcie-designware-ep.c | 205 +++++++++++++++-- drivers/pci/controller/dwc/pcie-designware-plat.c | 7 +- drivers/pci/controller/dwc/pcie-designware.h | 31 ++- drivers/pci/controller/pcie-cadence-ep.c | 3 +- drivers/pci/endpoint/functions/pci-epf-test.c | 81 +++++-- drivers/pci/endpoint/pci-ep-cfs.c | 24 ++ drivers/pci/endpoint/pci-epc-core.c | 68 +++++- include/linux/pci-epc.h | 15 +- include/linux/pci-epf.h | 1 + include/uapi/linux/pcitest.h | 3 + tools/pci/pcitest.c | 51 ++++- tools/pci/pcitest.sh | 15 ++ 16 files changed, 643 insertions(+), 132 deletions(-)
Signature · 1 line
2.7.4
PATCH v4 1/10 PCI: endpoint: Add MSI-X interfaces
Add PCI_EPC_IRQ_MSIX type.
Add MSI-X callbacks signatures to the ops structure.
Add sysfs interface for set/get MSI-X capability maximum number.
---
Change v1->v2:
- Nothing changed, just to follow the patch set version.
Change v2->v3:
- Moved pci_epc_raise_irq() signature changes to patch file #3.
Change v3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.
drivers/pci/endpoint/pci-ep-cfs.c | 24 ++++++++++++++++ drivers/pci/endpoint/pci-epc-core.c | 57 +++++++++++++++++++++++++++++++++++++ include/linux/pci-epc.h | 9 ++++++ include/linux/pci-epf.h | 1 + 4 files changed, 91 insertions(+)
drivers/pci/endpoint/pci-ep-cfs.c +24 -0
@@ -286,6 +286,28 @@ static ssize_t pci_epf_msi_interrupts_show(struct config_item *item, to_pci_epf_group(item)->epf->msi_interrupts); } +static ssize_t pci_epf_msix_interrupts_store (struct config_item *item, +const char *page,size_t len) +{ +u16 val; +int ret; + + ret =kstrtou16 (page,0 , &val); +if (ret) +return ret; + +to_pci_epf_group (item)->epf->msix_interrupts = val; + +return len; +} + +static ssize_t pci_epf_msix_interrupts_show (struct config_item *item, +char *page) +{ +return sprintf (page,"%d\n" , +to_pci_epf_group (item)->epf->msix_interrupts); +} +PCI_EPF_HEADER_R (vendorid)PCI_EPF_HEADER_W_u16 (vendorid)
@@ -327,6 +349,7 @@ CONFIGFS_ATTR(pci_epf_, subsys_vendor_id);CONFIGFS_ATTR (pci_epf_, subsys_id);CONFIGFS_ATTR (pci_epf_, interrupt_pin);CONFIGFS_ATTR (pci_epf_, msi_interrupts); +CONFIGFS_ATTR (pci_epf_, msix_interrupts);static struct configfs_attribute *pci_epf_attrs[] = { &pci_epf_attr_vendorid,
@@ -340,6 +363,7 @@ static struct configfs_attribute *pci_epf_attrs[] = { &pci_epf_attr_subsys_id, &pci_epf_attr_interrupt_pin, &pci_epf_attr_msi_interrupts, + &pci_epf_attr_msix_interrupts, NULL, };
drivers/pci/endpoint/pci-epc-core.c +57 -0
63 lines not on this page · raw message
include/linux/pci-epc.h +9 -0
@@ -17,6 +17,7 @@ enum pci_epc_irq_type {PCI_EPC_IRQ_UNKNOWN ,PCI_EPC_IRQ_LEGACY ,PCI_EPC_IRQ_MSI , + PCI_EPC_IRQ_MSIX, };/**
@@ -30,6 +31,10 @@ enum pci_epc_irq_type {* capability register * @get_msi: ops to get the number of MSI interrupts allocated by the RC from * the MSI capability register +* @set_msix: ops to set the requested number of MSI-X interrupts in the +* MSI-X capability register +* @get_msix: ops to get the number of MSI-X interrupts allocated by the RC +* from the MSI-X capability register * @raise_irq: ops to raise a legacy or MSI interrupt * @start: ops to start the PCI link * @stop: ops to stop the PCI link
@@ -48,6 +53,8 @@ struct pci_epc_ops { phys_addr_t addr);int (*set_msi)(struct pci_epc *epc,u8 func_no,u8 interrupts);int (*get_msi)(struct pci_epc *epc,u8 func_no); +int (*set_msix)(struct pci_epc *epc,u8 func_no,u16 interrupts); +int (*get_msix)(struct pci_epc *epc,u8 func_no);int (*raise_irq)(struct pci_epc *epc,u8 func_no,enum pci_epc_irq_type type,u8 interrupt_num);int (*start)(struct pci_epc *epc);
@@ -144,6 +151,8 @@ void pci_epc_unmap_addr(struct pci_epc *epc, u8 func_no, phys_addr_t phys_addr);int pci_epc_set_msi (struct pci_epc *epc,u8 func_no,u8 interrupts);int pci_epc_get_msi (struct pci_epc *epc,u8 func_no); +int pci_epc_set_msix (struct pci_epc *epc,u8 func_no,u16 interrupts); +int pci_epc_get_msix (struct pci_epc *epc,u8 func_no);int pci_epc_raise_irq (struct pci_epc *epc,u8 func_no,enum pci_epc_irq_type type,u8 interrupt_num);int pci_epc_start (struct pci_epc *epc);
include/linux/pci-epf.h +1 -0
@@ -119,6 +119,7 @@ struct pci_epf {struct pci_epf_header *header;struct pci_epf_bar bar[6 ];u8 msi_interrupts; +u16 msix_interrupts;u8 func_no;struct pci_epc *epc;
Signature · 1 line
2.7.4
PATCH v4 2/10 PCI: dwc: Add MSI-X callbacks handler
In reply to Gustavo PimentelAdd PCIe config space capability search function.
Add sysfs set/get interface to allow the change of EP MSI-X maximum number.
Add EP MSI-X callback for triggering interruptions.
---
Change v1->v2:
- Nothing changed, just to follow the patch set version.
Change v2->v3:
- Moved dra7xx_pcie_raise_irq() signature change to patch file #3.
- Moved artpec6_pcie_raise_irq() signature change to patch file #3.
- Replaced wrong return value 0 to -EINVAL.
- Removed an else if by code refactoring.
- Reduced the size of ioremap_nocache mapping from ep->addr_size toPCI_MSIX_ENTRY_SIZE.
- Fixed a small bug. If the MSI-X vector bit has been set, the function
would return without executing the proper unmap.
Change v3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.
- Added static prefix to __dw_pcie_ep_find_next_cap function.
drivers/pci/controller/dwc/pcie-designware-ep.c | 146 +++++++++++++++++++++- drivers/pci/controller/dwc/pcie-designware-plat.c | 4 +- drivers/pci/controller/dwc/pcie-designware.h | 14 ++- 3 files changed, 161 insertions(+), 3 deletions(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +145 -1
@@ -40,6 +40,39 @@ void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar)__dw_pcie_ep_reset_bar (pci, bar,0 ); } +static u8 __dw_pcie_ep_find_next_cap (struct dw_pcie *pci,u8 cap_ptr, +u8 cap) +{ +u8 cap_id, next_cap_ptr; +u16 reg; + + reg =dw_pcie_readw_dbi (pci, cap_ptr); + next_cap_ptr = (reg &0xff00 ) >>8 ; + cap_id = (reg &0x00ff ); + +if (!next_cap_ptr || cap_id >PCI_CAP_ID_MAX ) +return 0 ; + +if (cap_id == cap) +return cap_ptr; + +return __dw_pcie_ep_find_next_cap (pci, next_cap_ptr, cap); +} + +u8 dw_pcie_ep_find_capability (struct dw_pcie *pci,u8 cap) +{ +u8 next_cap_ptr; +u16 reg; + + reg =dw_pcie_readw_dbi (pci,PCI_CAPABILITY_LIST ); + next_cap_ptr = (reg &0x00ff ); + +if (!next_cap_ptr) +return 0 ; + +return __dw_pcie_ep_find_next_cap (pci, next_cap_ptr, cap); +} +static int dw_pcie_ep_write_header (struct pci_epc *epc,u8 func_no,struct pci_epf_header *hdr) {
@@ -241,8 +274,47 @@ static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 func_no, u8 encode_int)return 0 ; } +static int dw_pcie_ep_get_msix (struct pci_epc *epc,u8 func_no) +{ +struct dw_pcie_ep *ep =epc_get_drvdata (epc); +struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +u32 val, reg; + +if (!ep->msix_cap) +return -EINVAL ; + + reg = ep->msix_cap +PCI_MSIX_FLAGS ; + val =dw_pcie_readw_dbi (pci, reg); +if (!(val &PCI_MSIX_FLAGS_ENABLE )) +return -EINVAL ; + + val &=PCI_MSIX_FLAGS_QSIZE ; + +return val; +} + +static int dw_pcie_ep_set_msix (struct pci_epc *epc,u8 func_no,u16 interrupts) +{ +struct dw_pcie_ep *ep =epc_get_drvdata (epc); +struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +u32 val, reg; + +if (!ep->msix_cap) +return -EINVAL ; + + reg = ep->msix_cap +PCI_MSIX_FLAGS ; + val =dw_pcie_readw_dbi (pci, reg); + val &= ~PCI_MSIX_FLAGS_QSIZE ; + val |= interrupts; +dw_pcie_dbi_ro_wr_en (pci); +dw_pcie_writew_dbi (pci, reg, val); +dw_pcie_dbi_ro_wr_dis (pci); + +return 0 ; +} +static int dw_pcie_ep_raise_irq (struct pci_epc *epc,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type,u16 interrupt_num) {struct dw_pcie_ep *ep =epc_get_drvdata (epc);
@@ -282,6 +354,8 @@ static const struct pci_epc_ops epc_ops = { .unmap_addr = dw_pcie_ep_unmap_addr, .set_msi = dw_pcie_ep_set_msi, .get_msi = dw_pcie_ep_get_msi, + .set_msix = dw_pcie_ep_set_msix, + .get_msix = dw_pcie_ep_get_msix, .raise_irq = dw_pcie_ep_raise_irq, .start = dw_pcie_ep_start, .stop = dw_pcie_ep_stop,
@@ -322,6 +396,64 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,return 0 ; } +int dw_pcie_ep_raise_msix_irq (struct dw_pcie_ep *ep,u8 func_no, +u16 interrupt_num) +{ +struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +struct pci_epc *epc = ep->epc; +u16 tbl_offset, bir; +u32 bar_addr_upper, bar_addr_lower; +u32 msg_addr_upper, msg_addr_lower; +u32 reg, msg_data, vec_ctrl; +u64 tbl_addr, msg_addr, reg_u64; +void __iomem *msix_tbl; +int ret; + + reg = ep->msix_cap +PCI_MSIX_TABLE ; + tbl_offset =dw_pcie_readl_dbi (pci, reg); + bir = (tbl_offset &PCI_MSIX_TABLE_BIR ); + tbl_offset &=PCI_MSIX_TABLE_OFFSET ; + tbl_offset >>=3 ; + + reg =PCI_BASE_ADDRESS_0 + (4 * bir); + bar_addr_upper =0 ; + bar_addr_lower =dw_pcie_readl_dbi (pci, reg); + reg_u64 = (bar_addr_lower &PCI_BASE_ADDRESS_MEM_TYPE_MASK ); +if (reg_u64 ==PCI_BASE_ADDRESS_MEM_TYPE_64 ) + bar_addr_upper =dw_pcie_readl_dbi (pci, reg +4 ); + + tbl_addr = ((u64 ) bar_addr_upper) <<32 | bar_addr_lower; + tbl_addr += (tbl_offset + ((interrupt_num -1 ) *PCI_MSIX_ENTRY_SIZE )); + tbl_addr &=PCI_BASE_ADDRESS_MEM_MASK ; + + msix_tbl =ioremap_nocache (ep->phys_base + tbl_addr, +PCI_MSIX_ENTRY_SIZE ); +if (!msix_tbl) +return -EINVAL ; + + msg_addr_lower =readl (msix_tbl +PCI_MSIX_ENTRY_LOWER_ADDR ); + msg_addr_upper =readl (msix_tbl +PCI_MSIX_ENTRY_UPPER_ADDR ); + msg_addr = ((u64 ) msg_addr_upper) <<32 | msg_addr_lower; + msg_data =readl (msix_tbl +PCI_MSIX_ENTRY_DATA ); + vec_ctrl =readl (msix_tbl +PCI_MSIX_ENTRY_VECTOR_CTRL ); + +iounmap (msix_tbl); + +if (vec_ctrl &PCI_MSIX_ENTRY_CTRL_MASKBIT ) +return -EPERM ; + + ret =dw_pcie_ep_map_addr (epc, func_no, ep->msix_mem_phys, msg_addr, + epc->mem->page_size); +if (ret) +return ret; + +writel (msg_data, ep->msix_mem); + +dw_pcie_ep_unmap_addr (epc, func_no, ep->msix_mem_phys); + +return 0 ; +} +void dw_pcie_ep_exit (struct dw_pcie_ep *ep) {struct pci_epc *epc = ep->epc;
@@ -329,6 +461,9 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep)pci_epc_mem_free_addr (epc, ep->msi_mem_phys, ep->msi_mem, epc->mem->page_size); +pci_epc_mem_free_addr (epc, ep->msix_mem_phys, ep->msix_mem, + epc->mem->page_size); +pci_epc_mem_exit (epc); }
@@ -412,6 +547,15 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)dev_err (dev,"Failed to reserve memory for MSI\n" );return -ENOMEM ; } + ep->msi_cap =dw_pcie_ep_find_capability (pci,PCI_CAP_ID_MSI ); + + ep->msix_mem =pci_epc_mem_alloc_addr (epc, &ep->msix_mem_phys, + epc->mem->page_size); +if (!ep->msix_mem) { +dev_err (dev,"Failed to reserve memory for MSI-X\n" ); +return -ENOMEM ; + } + ep->msix_cap =dw_pcie_ep_find_capability (pci,PCI_CAP_ID_MSIX ); epc->features =EPC_FEATURE_NO_LINKUP_NOTIFIER ;EPC_FEATURE_SET_BAR (epc->features,BAR_0 );
drivers/pci/controller/dwc/pcie-designware-plat.c +3 -1
@@ -78,7 +78,7 @@ static void dw_plat_pcie_ep_init(struct dw_pcie_ep *ep)static int dw_plat_pcie_ep_raise_irq (struct dw_pcie_ep *ep,u8 func_no,enum pci_epc_irq_type type, -u8 interrupt_num) +u16 interrupt_num) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep);
@@ -88,6 +88,8 @@ static int dw_plat_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no,return -EINVAL ;case PCI_EPC_IRQ_MSI :return dw_pcie_ep_raise_msi_irq (ep, func_no, interrupt_num); +case PCI_EPC_IRQ_MSIX : +return dw_pcie_ep_raise_msix_irq (ep, func_no, interrupt_num);default :dev_err (pci->dev,"UNKNOWN IRQ type\n" ); }
drivers/pci/controller/dwc/pcie-designware.h +13 -1
@@ -191,7 +191,7 @@ enum dw_pcie_as_type {struct dw_pcie_ep_ops {void (*ep_init)(struct dw_pcie_ep *ep);int (*raise_irq)(struct dw_pcie_ep *ep,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num); +enum pci_epc_irq_type type,u16 interrupt_num); };struct dw_pcie_ep {
@@ -208,6 +208,10 @@ struct dw_pcie_ep {u32 num_ob_windows;void __iomem *msi_mem;phys_addr_t msi_mem_phys; +void __iomem *msix_mem; +phys_addr_t msix_mem_phys; +u8 msi_cap;/* MSI capability offset */ +u8 msix_cap;/* MSI-X capability offset */ };struct dw_pcie_ops {
@@ -359,6 +363,8 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep);void dw_pcie_ep_exit (struct dw_pcie_ep *ep);int dw_pcie_ep_raise_msi_irq (struct dw_pcie_ep *ep,u8 func_no,u8 interrupt_num); +int dw_pcie_ep_raise_msix_irq (struct dw_pcie_ep *ep,u8 func_no, +u16 interrupt_num);void dw_pcie_ep_reset_bar (struct dw_pcie *pci,enum pci_barno bar);#else static inline void dw_pcie_ep_linkup (struct dw_pcie_ep *ep)
@@ -380,6 +386,12 @@ static inline int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,return 0 ; } +static inline int dw_pcie_ep_raise_msix_irq (struct dw_pcie_ep *ep,u8 func_no, +u16 interrupt_num) +{ +return 0 ; +} +static inline void dw_pcie_ep_reset_bar (struct dw_pcie *pci,enum pci_barno bar) { }
Signature · 1 line
2.7.4
kbuild test robot
build bot[RFC PATCH] PCI: dwc: dw_pcie_ep_find_capability() can be static
Fixes: 43f8cf4686e0 ("PCI: dwc: Add MSI-X callbacks handler")
--- pcie-designware-ep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +1 -1
@@ -59,7 +59,7 @@ static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie *pci, u8 cap_ptr,return __dw_pcie_ep_find_next_cap (pci, next_cap_ptr, cap); } -u8 dw_pcie_ep_find_capability (struct dw_pcie *pci,u8 cap) +static u8 dw_pcie_ep_find_capability (struct dw_pcie *pci,u8 cap) {u8 next_cap_ptr;u16 reg;
Re: [RFC PATCH] PCI: dwc: dw_pcie_ep_find_capability() can be static
Hi,
Thanks for the suggestion.
Regards,
Gustavo
Quoted 21 lines · kbuild test robot
Fixes 43f8cf4686e0 ("PCI: dwc: Add MSI-X callbacks handler")Signed-off-by kbuild test robot <[email protected]>--- pcie-designware-ep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/pci/controller/dwc/pcie-designware-ep.c +1
-1@@ -59,7 +59,7 @@ static u8 __dw_pcie_ep_find_next_cap(struct dw_pcie *pci, u8 cap_ptr,return __dw_pcie_ep_find_next_cap (pci, next_cap_ptr, cap); } -u8 dw_pcie_ep_find_capability (struct dw_pcie *pci,u8 cap) +static u8 dw_pcie_ep_find_capability (struct dw_pcie *pci,u8 cap) {u8 next_cap_ptr;u16 reg;
Re: [PATCH v4 02/10] PCI: dwc: Add MSI-X callbacks handler
In reply to Gustavo PimentelHi,
Quoted 46 lines · Gustavo Pimentel
Add PCIe config space capability search function.
Add sysfs set/get interface to allow the change of EP MSI-X maximum number.
Add EP MSI-X callback for triggering interruptions.
Signed-off-by Gustavo Pimentel <[email protected]>---
Changev1->v2:
- Nothing changed, just to follow the patch set version.
Changev2->v3:
- Moveddra7xx_pcie_raise_irq()signature change to patch file #3.
- Movedartpec6_pcie_raise_irq()signature change to patch file #3.
- Replaced wrong return value 0 to-EINVAL.
- Removed an else if by code refactoring.
- Reduced the size ofioremap_nocachemapping fromep->addr_sizetoPCI_MSIX_ENTRY_SIZE.
- Fixed a small bug. If the MSI-X vector bit has been set, the function
would return without executing the proper unmap.
Changev3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.
- Added static prefix to__dw_pcie_ep_find_next_capfunction.drivers/pci/controller/dwc/pcie-designware-ep.c | 146 +++++++++++++++++++++- drivers/pci/controller/dwc/pcie-designware-plat.c | 4 +- drivers/pci/controller/dwc/pcie-designware.h | 14 ++- 3 files changed, 161 insertions(+), 3 deletions(-)drivers/pci/controller/dwc/pcie-designware-ep.c +10
-0@@ -40,6 +40,39 @@ void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar)__dw_pcie_ep_reset_bar (pci, bar,0 ); } +static u8 __dw_pcie_ep_find_next_cap (struct dw_pcie *pci,u8 cap_ptr, +u8 cap) +{ +u8 cap_id, next_cap_ptr; +u16 reg; + + reg =dw_pcie_readw_dbi (pci, cap_ptr); + next_cap_ptr = (reg &0xff00 ) >>8 ; + cap_id = (reg &0x00ff ); +
drivers/pci/controller/dwc/pcie-designware-ep.c void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) · line 62
Quoted 10 lines
drivers/pci/controller/dwc/pcie-designware-ep.c +10
-0+if (!next_cap_ptr || cap_id >PCI_CAP_ID_MAX ) +return 0 ; + +if (cap_id == cap) +return cap_ptr; + +return __dw_pcie_ep_find_next_cap (pci, next_cap_ptr, cap); +} + +u8 dw_pcie_ep_find_capability (struct dw_pcie *pci,u8 cap)
This should be static?
Thanks
Kishon
Quoted 234 lines
drivers/pci/controller/dwc/pcie-designware-ep.c +125
-1+{ +u8 next_cap_ptr; +u16 reg; + + reg =dw_pcie_readw_dbi (pci,PCI_CAPABILITY_LIST ); + next_cap_ptr = (reg &0x00ff ); + +if (!next_cap_ptr) +return 0 ; + +return __dw_pcie_ep_find_next_cap (pci, next_cap_ptr, cap); +} +static int dw_pcie_ep_write_header (struct pci_epc *epc,u8 func_no,struct pci_epf_header *hdr) {@@ -241,8 +274,47 @@ static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 func_no, u8 encode_int)return 0 ; } +static int dw_pcie_ep_get_msix (struct pci_epc *epc,u8 func_no) +{ +struct dw_pcie_ep *ep =epc_get_drvdata (epc); +struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +u32 val, reg; + +if (!ep->msix_cap) +return -EINVAL ; + + reg = ep->msix_cap +PCI_MSIX_FLAGS ; + val =dw_pcie_readw_dbi (pci, reg); +if (!(val &PCI_MSIX_FLAGS_ENABLE )) +return -EINVAL ; + + val &=PCI_MSIX_FLAGS_QSIZE ; + +return val; +} + +static int dw_pcie_ep_set_msix (struct pci_epc *epc,u8 func_no,u16 interrupts) +{ +struct dw_pcie_ep *ep =epc_get_drvdata (epc); +struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +u32 val, reg; + +if (!ep->msix_cap) +return -EINVAL ; + + reg = ep->msix_cap +PCI_MSIX_FLAGS ; + val =dw_pcie_readw_dbi (pci, reg); + val &= ~PCI_MSIX_FLAGS_QSIZE ; + val |= interrupts; +dw_pcie_dbi_ro_wr_en (pci); +dw_pcie_writew_dbi (pci, reg, val); +dw_pcie_dbi_ro_wr_dis (pci); + +return 0 ; +} +static int dw_pcie_ep_raise_irq (struct pci_epc *epc,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type,u16 interrupt_num) {struct dw_pcie_ep *ep =epc_get_drvdata (epc);@@ -282,6 +354,8 @@ static const struct pci_epc_ops epc_ops = { .unmap_addr = dw_pcie_ep_unmap_addr, .set_msi = dw_pcie_ep_set_msi, .get_msi = dw_pcie_ep_get_msi, + .set_msix = dw_pcie_ep_set_msix, + .get_msix = dw_pcie_ep_get_msix, .raise_irq = dw_pcie_ep_raise_irq, .start = dw_pcie_ep_start, .stop = dw_pcie_ep_stop,@@ -322,6 +396,64 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,return 0 ; } +int dw_pcie_ep_raise_msix_irq (struct dw_pcie_ep *ep,u8 func_no, +u16 interrupt_num) +{ +struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +struct pci_epc *epc = ep->epc; +u16 tbl_offset, bir; +u32 bar_addr_upper, bar_addr_lower; +u32 msg_addr_upper, msg_addr_lower; +u32 reg, msg_data, vec_ctrl; +u64 tbl_addr, msg_addr, reg_u64; +void __iomem *msix_tbl; +int ret; + + reg = ep->msix_cap +PCI_MSIX_TABLE ; + tbl_offset =dw_pcie_readl_dbi (pci, reg); + bir = (tbl_offset &PCI_MSIX_TABLE_BIR ); + tbl_offset &=PCI_MSIX_TABLE_OFFSET ; + tbl_offset >>=3 ; + + reg =PCI_BASE_ADDRESS_0 + (4 * bir); + bar_addr_upper =0 ; + bar_addr_lower =dw_pcie_readl_dbi (pci, reg); + reg_u64 = (bar_addr_lower &PCI_BASE_ADDRESS_MEM_TYPE_MASK ); +if (reg_u64 ==PCI_BASE_ADDRESS_MEM_TYPE_64 ) + bar_addr_upper =dw_pcie_readl_dbi (pci, reg +4 ); + + tbl_addr = ((u64 ) bar_addr_upper) <<32 | bar_addr_lower; + tbl_addr += (tbl_offset + ((interrupt_num -1 ) *PCI_MSIX_ENTRY_SIZE )); + tbl_addr &=PCI_BASE_ADDRESS_MEM_MASK ; + + msix_tbl =ioremap_nocache (ep->phys_base + tbl_addr, +PCI_MSIX_ENTRY_SIZE ); +if (!msix_tbl) +return -EINVAL ; + + msg_addr_lower =readl (msix_tbl +PCI_MSIX_ENTRY_LOWER_ADDR ); + msg_addr_upper =readl (msix_tbl +PCI_MSIX_ENTRY_UPPER_ADDR ); + msg_addr = ((u64 ) msg_addr_upper) <<32 | msg_addr_lower; + msg_data =readl (msix_tbl +PCI_MSIX_ENTRY_DATA ); + vec_ctrl =readl (msix_tbl +PCI_MSIX_ENTRY_VECTOR_CTRL ); + +iounmap (msix_tbl); + +if (vec_ctrl &PCI_MSIX_ENTRY_CTRL_MASKBIT ) +return -EPERM ; + + ret =dw_pcie_ep_map_addr (epc, func_no, ep->msix_mem_phys, msg_addr, + epc->mem->page_size); +if (ret) +return ret; + +writel (msg_data, ep->msix_mem); + +dw_pcie_ep_unmap_addr (epc, func_no, ep->msix_mem_phys); + +return 0 ; +} +void dw_pcie_ep_exit (struct dw_pcie_ep *ep) {struct pci_epc *epc = ep->epc;@@ -329,6 +461,9 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep)pci_epc_mem_free_addr (epc, ep->msi_mem_phys, ep->msi_mem, epc->mem->page_size); +pci_epc_mem_free_addr (epc, ep->msix_mem_phys, ep->msix_mem, + epc->mem->page_size); +pci_epc_mem_exit (epc); }@@ -412,6 +547,15 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)dev_err (dev,"Failed to reserve memory for MSI\n" );return -ENOMEM ; } + ep->msi_cap =dw_pcie_ep_find_capability (pci,PCI_CAP_ID_MSI ); + + ep->msix_mem =pci_epc_mem_alloc_addr (epc, &ep->msix_mem_phys, + epc->mem->page_size); +if (!ep->msix_mem) { +dev_err (dev,"Failed to reserve memory for MSI-X\n" ); +return -ENOMEM ; + } + ep->msix_cap =dw_pcie_ep_find_capability (pci,PCI_CAP_ID_MSIX ); epc->features =EPC_FEATURE_NO_LINKUP_NOTIFIER ;EPC_FEATURE_SET_BAR (epc->features,BAR_0 );drivers/pci/controller/dwc/pcie-designware-plat.c +3
-1@@ -78,7 +78,7 @@ static void dw_plat_pcie_ep_init(struct dw_pcie_ep *ep)static int dw_plat_pcie_ep_raise_irq (struct dw_pcie_ep *ep,u8 func_no,enum pci_epc_irq_type type, -u8 interrupt_num) +u16 interrupt_num) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep);@@ -88,6 +88,8 @@ static int dw_plat_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no,return -EINVAL ;case PCI_EPC_IRQ_MSI :return dw_pcie_ep_raise_msi_irq (ep, func_no, interrupt_num); +case PCI_EPC_IRQ_MSIX : +return dw_pcie_ep_raise_msix_irq (ep, func_no, interrupt_num);default :dev_err (pci->dev,"UNKNOWN IRQ type\n" ); }drivers/pci/controller/dwc/pcie-designware.h +13
-1@@ -191,7 +191,7 @@ enum dw_pcie_as_type {struct dw_pcie_ep_ops {void (*ep_init)(struct dw_pcie_ep *ep);int (*raise_irq)(struct dw_pcie_ep *ep,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num); +enum pci_epc_irq_type type,u16 interrupt_num); };struct dw_pcie_ep {@@ -208,6 +208,10 @@ struct dw_pcie_ep {u32 num_ob_windows;void __iomem *msi_mem;phys_addr_t msi_mem_phys; +void __iomem *msix_mem; +phys_addr_t msix_mem_phys; +u8 msi_cap;/* MSI capability offset */ +u8 msix_cap;/* MSI-X capability offset */ };struct dw_pcie_ops {@@ -359,6 +363,8 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep);void dw_pcie_ep_exit (struct dw_pcie_ep *ep);int dw_pcie_ep_raise_msi_irq (struct dw_pcie_ep *ep,u8 func_no,u8 interrupt_num); +int dw_pcie_ep_raise_msix_irq (struct dw_pcie_ep *ep,u8 func_no, +u16 interrupt_num);void dw_pcie_ep_reset_bar (struct dw_pcie *pci,enum pci_barno bar);#else static inline void dw_pcie_ep_linkup (struct dw_pcie_ep *ep)@@ -380,6 +386,12 @@ static inline int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,return 0 ; } +static inline int dw_pcie_ep_raise_msix_irq (struct dw_pcie_ep *ep,u8 func_no, +u16 interrupt_num) +{ +return 0 ; +} +static inline void dw_pcie_ep_reset_bar (struct dw_pcie *pci,enum pci_barno bar) { }
Re: [PATCH v4 02/10] PCI: dwc: Add MSI-X callbacks handler
Hi Kishon,
Quoted 53 lines · Kishon Vijay Abraham I
Hi,
Quoted 50 lines · Gustavo Pimentel
Add PCIe config space capability search function.
Add sysfs set/get interface to allow the change of EP MSI-X maximum number.
Add EP MSI-X callback for triggering interruptions.
Signed-off-by Gustavo Pimentel <[email protected]>---
Changev1->v2:
- Nothing changed, just to follow the patch set version.
Changev2->v3:
- Moveddra7xx_pcie_raise_irq()signature change to patch file #3.
- Movedartpec6_pcie_raise_irq()signature change to patch file #3.
- Replaced wrong return value 0 to-EINVAL.
- Removed an else if by code refactoring.
- Reduced the size ofioremap_nocachemapping fromep->addr_sizetoPCI_MSIX_ENTRY_SIZE.
- Fixed a small bug. If the MSI-X vector bit has been set, the function
would return without executing the proper unmap.
Changev3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.
- Added static prefix to__dw_pcie_ep_find_next_capfunction.drivers/pci/controller/dwc/pcie-designware-ep.c | 146 +++++++++++++++++++++- drivers/pci/controller/dwc/pcie-designware-plat.c | 4 +- drivers/pci/controller/dwc/pcie-designware.h | 14 ++- 3 files changed, 161 insertions(+), 3 deletions(-)drivers/pci/controller/dwc/pcie-designware-ep.c +14
-0@@ -40,6 +40,39 @@ void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar)__dw_pcie_ep_reset_bar (pci, bar,0 ); } +static u8 __dw_pcie_ep_find_next_cap (struct dw_pcie *pci,u8 cap_ptr, +u8 cap) +{ +u8 cap_id, next_cap_ptr; +u16 reg; + + reg =dw_pcie_readw_dbi (pci, cap_ptr); + next_cap_ptr = (reg &0xff00 ) >>8 ; + cap_id = (reg &0x00ff ); + +if (!next_cap_ptr || cap_id >PCI_CAP_ID_MAX ) +return 0 ; + +if (cap_id == cap)
Quoted 8 lines
drivers/pci/controller/dwc/pcie-designware-ep.c void dw_pcie_ep_reset_bar(struct dw_pcie *pci, enum pci_barno bar) · line 62
Quoted 6 lines
drivers/pci/controller/dwc/pcie-designware-ep.c +6
-0+return cap_ptr; + +return __dw_pcie_ep_find_next_cap (pci, next_cap_ptr, cap); +} + +u8 dw_pcie_ep_find_capability (struct dw_pcie *pci,u8 cap)This should be static?
Yes, kbuild also point that out. It'll be fixed.
Thanks
Gustavo
Quoted 237 lines
Thanks
KishonQuoted 234 lines
drivers/pci/controller/dwc/pcie-designware-ep.c +125
-1+{ +u8 next_cap_ptr; +u16 reg; + + reg =dw_pcie_readw_dbi (pci,PCI_CAPABILITY_LIST ); + next_cap_ptr = (reg &0x00ff ); + +if (!next_cap_ptr) +return 0 ; + +return __dw_pcie_ep_find_next_cap (pci, next_cap_ptr, cap); +} +static int dw_pcie_ep_write_header (struct pci_epc *epc,u8 func_no,struct pci_epf_header *hdr) {@@ -241,8 +274,47 @@ static int dw_pcie_ep_set_msi(struct pci_epc *epc, u8 func_no, u8 encode_int)return 0 ; } +static int dw_pcie_ep_get_msix (struct pci_epc *epc,u8 func_no) +{ +struct dw_pcie_ep *ep =epc_get_drvdata (epc); +struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +u32 val, reg; + +if (!ep->msix_cap) +return -EINVAL ; + + reg = ep->msix_cap +PCI_MSIX_FLAGS ; + val =dw_pcie_readw_dbi (pci, reg); +if (!(val &PCI_MSIX_FLAGS_ENABLE )) +return -EINVAL ; + + val &=PCI_MSIX_FLAGS_QSIZE ; + +return val; +} + +static int dw_pcie_ep_set_msix (struct pci_epc *epc,u8 func_no,u16 interrupts) +{ +struct dw_pcie_ep *ep =epc_get_drvdata (epc); +struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +u32 val, reg; + +if (!ep->msix_cap) +return -EINVAL ; + + reg = ep->msix_cap +PCI_MSIX_FLAGS ; + val =dw_pcie_readw_dbi (pci, reg); + val &= ~PCI_MSIX_FLAGS_QSIZE ; + val |= interrupts; +dw_pcie_dbi_ro_wr_en (pci); +dw_pcie_writew_dbi (pci, reg, val); +dw_pcie_dbi_ro_wr_dis (pci); + +return 0 ; +} +static int dw_pcie_ep_raise_irq (struct pci_epc *epc,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type,u16 interrupt_num) {struct dw_pcie_ep *ep =epc_get_drvdata (epc);@@ -282,6 +354,8 @@ static const struct pci_epc_ops epc_ops = { .unmap_addr = dw_pcie_ep_unmap_addr, .set_msi = dw_pcie_ep_set_msi, .get_msi = dw_pcie_ep_get_msi, + .set_msix = dw_pcie_ep_set_msix, + .get_msix = dw_pcie_ep_get_msix, .raise_irq = dw_pcie_ep_raise_irq, .start = dw_pcie_ep_start, .stop = dw_pcie_ep_stop,@@ -322,6 +396,64 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,return 0 ; } +int dw_pcie_ep_raise_msix_irq (struct dw_pcie_ep *ep,u8 func_no, +u16 interrupt_num) +{ +struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +struct pci_epc *epc = ep->epc; +u16 tbl_offset, bir; +u32 bar_addr_upper, bar_addr_lower; +u32 msg_addr_upper, msg_addr_lower; +u32 reg, msg_data, vec_ctrl; +u64 tbl_addr, msg_addr, reg_u64; +void __iomem *msix_tbl; +int ret; + + reg = ep->msix_cap +PCI_MSIX_TABLE ; + tbl_offset =dw_pcie_readl_dbi (pci, reg); + bir = (tbl_offset &PCI_MSIX_TABLE_BIR ); + tbl_offset &=PCI_MSIX_TABLE_OFFSET ; + tbl_offset >>=3 ; + + reg =PCI_BASE_ADDRESS_0 + (4 * bir); + bar_addr_upper =0 ; + bar_addr_lower =dw_pcie_readl_dbi (pci, reg); + reg_u64 = (bar_addr_lower &PCI_BASE_ADDRESS_MEM_TYPE_MASK ); +if (reg_u64 ==PCI_BASE_ADDRESS_MEM_TYPE_64 ) + bar_addr_upper =dw_pcie_readl_dbi (pci, reg +4 ); + + tbl_addr = ((u64 ) bar_addr_upper) <<32 | bar_addr_lower; + tbl_addr += (tbl_offset + ((interrupt_num -1 ) *PCI_MSIX_ENTRY_SIZE )); + tbl_addr &=PCI_BASE_ADDRESS_MEM_MASK ; + + msix_tbl =ioremap_nocache (ep->phys_base + tbl_addr, +PCI_MSIX_ENTRY_SIZE ); +if (!msix_tbl) +return -EINVAL ; + + msg_addr_lower =readl (msix_tbl +PCI_MSIX_ENTRY_LOWER_ADDR ); + msg_addr_upper =readl (msix_tbl +PCI_MSIX_ENTRY_UPPER_ADDR ); + msg_addr = ((u64 ) msg_addr_upper) <<32 | msg_addr_lower; + msg_data =readl (msix_tbl +PCI_MSIX_ENTRY_DATA ); + vec_ctrl =readl (msix_tbl +PCI_MSIX_ENTRY_VECTOR_CTRL ); + +iounmap (msix_tbl); + +if (vec_ctrl &PCI_MSIX_ENTRY_CTRL_MASKBIT ) +return -EPERM ; + + ret =dw_pcie_ep_map_addr (epc, func_no, ep->msix_mem_phys, msg_addr, + epc->mem->page_size); +if (ret) +return ret; + +writel (msg_data, ep->msix_mem); + +dw_pcie_ep_unmap_addr (epc, func_no, ep->msix_mem_phys); + +return 0 ; +} +void dw_pcie_ep_exit (struct dw_pcie_ep *ep) {struct pci_epc *epc = ep->epc;@@ -329,6 +461,9 @@ void dw_pcie_ep_exit(struct dw_pcie_ep *ep)pci_epc_mem_free_addr (epc, ep->msi_mem_phys, ep->msi_mem, epc->mem->page_size); +pci_epc_mem_free_addr (epc, ep->msix_mem_phys, ep->msix_mem, + epc->mem->page_size); +pci_epc_mem_exit (epc); }@@ -412,6 +547,15 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep)dev_err (dev,"Failed to reserve memory for MSI\n" );return -ENOMEM ; } + ep->msi_cap =dw_pcie_ep_find_capability (pci,PCI_CAP_ID_MSI ); + + ep->msix_mem =pci_epc_mem_alloc_addr (epc, &ep->msix_mem_phys, + epc->mem->page_size); +if (!ep->msix_mem) { +dev_err (dev,"Failed to reserve memory for MSI-X\n" ); +return -ENOMEM ; + } + ep->msix_cap =dw_pcie_ep_find_capability (pci,PCI_CAP_ID_MSIX ); epc->features =EPC_FEATURE_NO_LINKUP_NOTIFIER ;EPC_FEATURE_SET_BAR (epc->features,BAR_0 );drivers/pci/controller/dwc/pcie-designware-plat.c +3
-1@@ -78,7 +78,7 @@ static void dw_plat_pcie_ep_init(struct dw_pcie_ep *ep)static int dw_plat_pcie_ep_raise_irq (struct dw_pcie_ep *ep,u8 func_no,enum pci_epc_irq_type type, -u8 interrupt_num) +u16 interrupt_num) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep);@@ -88,6 +88,8 @@ static int dw_plat_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no,return -EINVAL ;case PCI_EPC_IRQ_MSI :return dw_pcie_ep_raise_msi_irq (ep, func_no, interrupt_num); +case PCI_EPC_IRQ_MSIX : +return dw_pcie_ep_raise_msix_irq (ep, func_no, interrupt_num);default :dev_err (pci->dev,"UNKNOWN IRQ type\n" ); }drivers/pci/controller/dwc/pcie-designware.h +13
-1@@ -191,7 +191,7 @@ enum dw_pcie_as_type {struct dw_pcie_ep_ops {void (*ep_init)(struct dw_pcie_ep *ep);int (*raise_irq)(struct dw_pcie_ep *ep,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num); +enum pci_epc_irq_type type,u16 interrupt_num); };struct dw_pcie_ep {@@ -208,6 +208,10 @@ struct dw_pcie_ep {u32 num_ob_windows;void __iomem *msi_mem;phys_addr_t msi_mem_phys; +void __iomem *msix_mem; +phys_addr_t msix_mem_phys; +u8 msi_cap;/* MSI capability offset */ +u8 msix_cap;/* MSI-X capability offset */ };struct dw_pcie_ops {@@ -359,6 +363,8 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep);void dw_pcie_ep_exit (struct dw_pcie_ep *ep);int dw_pcie_ep_raise_msi_irq (struct dw_pcie_ep *ep,u8 func_no,u8 interrupt_num); +int dw_pcie_ep_raise_msix_irq (struct dw_pcie_ep *ep,u8 func_no, +u16 interrupt_num);void dw_pcie_ep_reset_bar (struct dw_pcie *pci,enum pci_barno bar);#else static inline void dw_pcie_ep_linkup (struct dw_pcie_ep *ep)@@ -380,6 +386,12 @@ static inline int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,return 0 ; } +static inline int dw_pcie_ep_raise_msix_irq (struct dw_pcie_ep *ep,u8 func_no, +u16 interrupt_num) +{ +return 0 ; +} +static inline void dw_pcie_ep_reset_bar (struct dw_pcie *pci,enum pci_barno bar) { }
PATCH v4 3/10 PCI: Update xxx_pcie_ep_raise_irq() and pci_epc_raise_irq() signatures
In reply to Gustavo PimentelChange {cdns, dra7xx, artpec6}_pcie_ep_raise_irq() and pci_epc_raise_irq() signature, namely the interrupt_num variable type from u8 to u16 to accommodate 2048 maximum MSI-X interrupts.
---
Change v1->v2:
- Nothing changed, just to follow the patch set version.
Change v2->v3:
- Move into here the pci_epc_raise_irq() signature change from patch
file #1.
- Move into here the {dra7xx, artpec6}_pcie_ep_raise_irq() signature
changes from patch file #2.
Change v3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.
drivers/pci/controller/dwc/pci-dra7xx.c | 2 +- drivers/pci/controller/dwc/pcie-artpec6.c | 2 +- drivers/pci/controller/pcie-cadence-ep.c | 3 ++- drivers/pci/endpoint/pci-epc-core.c | 8 ++++---- include/linux/pci-epc.h | 6 +++--- 5 files changed, 11 insertions(+), 10 deletions(-)
drivers/pci/controller/dwc/pci-dra7xx.c +1 -1
@@ -370,7 +370,7 @@ static void dra7xx_pcie_raise_msi_irq(struct dra7xx_pcie *dra7xx, }static int dra7xx_pcie_raise_irq (struct dw_pcie_ep *ep,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type,u16 interrupt_num) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep);struct dra7xx_pcie *dra7xx =to_dra7xx_pcie (pci);
drivers/pci/controller/dwc/pcie-artpec6.c +1 -1
@@ -428,7 +428,7 @@ static void artpec6_pcie_ep_init(struct dw_pcie_ep *ep) }static int artpec6_pcie_raise_irq (struct dw_pcie_ep *ep,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type,u16 interrupt_num) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep);
drivers/pci/controller/pcie-cadence-ep.c +2 -1
@@ -363,7 +363,8 @@ static int cdns_pcie_ep_send_msi_irq(struct cdns_pcie_ep *ep, u8 fn, }static int cdns_pcie_ep_raise_irq (struct pci_epc *epc,u8 fn, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type, +u16 interrupt_num) {struct cdns_pcie_ep *ep =epc_get_drvdata (epc);
drivers/pci/endpoint/pci-epc-core.c +4 -4
@@ -131,13 +131,13 @@ EXPORT_SYMBOL_GPL(pci_epc_start);* pci_epc_raise_irq() - interrupt the host system * @epc: the EPC device which has to interrupt the host * @func_no: the endpoint function number in the EPC device -* @type: specify the type of interrupt; legacy or MSI -* @interrupt_num: the MSI interrupt number +* @type: specify the type of interrupt; legacy, MSI or MSI-X +* @interrupt_num: the MSI or MSI-X interrupt number * -* Invoke to raise an MSI or legacy interrupt +* Invoke to raise an legacy, MSI or MSI-X interrupt */ int pci_epc_raise_irq (struct pci_epc *epc,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type,u16 interrupt_num) {int ret;unsigned long flags;
include/linux/pci-epc.h +3 -3
@@ -35,7 +35,7 @@ enum pci_epc_irq_type {* MSI-X capability register * @get_msix: ops to get the number of MSI-X interrupts allocated by the RC * from the MSI-X capability register -* @raise_irq: ops to raise a legacy or MSI interrupt +* @raise_irq: ops to raise a legacy, MSI or MSI-X interrupt * @start: ops to start the PCI link * @stop: ops to stop the PCI link * @owner: the module owner containing the ops
@@ -56,7 +56,7 @@ struct pci_epc_ops {int (*set_msix)(struct pci_epc *epc,u8 func_no,u16 interrupts);int (*get_msix)(struct pci_epc *epc,u8 func_no);int (*raise_irq)(struct pci_epc *epc,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num); +enum pci_epc_irq_type type,u16 interrupt_num);int (*start)(struct pci_epc *epc);void (*stop)(struct pci_epc *epc);struct module *owner;
@@ -154,7 +154,7 @@ int pci_epc_get_msi(struct pci_epc *epc, u8 func_no);int pci_epc_set_msix (struct pci_epc *epc,u8 func_no,u16 interrupts);int pci_epc_get_msix (struct pci_epc *epc,u8 func_no);int pci_epc_raise_irq (struct pci_epc *epc,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num); +enum pci_epc_irq_type type,u16 interrupt_num);int pci_epc_start (struct pci_epc *epc);void pci_epc_stop (struct pci_epc *epc);struct pci_epc *pci_epc_get (const char *epc_name);
Signature · 1 line
2.7.4
kbuild test robot
build botRe: [PATCH v4 03/10] PCI: Update xxx_pcie_ep_raise_irq() and pci_epc_raise_irq() signatures
Thank you for the patch! Yet something to improve:
Hi Gustavo,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on pci/next]
[also build test ERROR on v4.18-rc1 next-20180618]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Gustavo-Pimentel/Add-MSI-X-support-on-pcitest-tool/20180619-004625 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next config: ia64-allmodconfig (attached as .config) compiler: ia64-linux-gcc (GCC) 8.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=8.1.0 make.cross ARCH=ia64
All errors (new ones prefixed by >>):
>> drivers/pci/controller/pcie-rockchip-ep.c:516:15: error: initialization of 'int (*)(struct pci_epc *, u8, enum pci_epc_irq_type, u16)' {aka 'int (*)(struct pci_epc *, unsigned char, enum pci_epc_irq_type, short unsigned int)'} from incompatible pointer type 'int (*)(struct pci_epc *, u8, enum pci_epc_irq_type, u8)' {aka 'int (*)(struct pci_epc *, unsigned char, enum pci_epc_irq_type, unsigned char)'} [-Werror=incompatible-pointer-types] .raise_irq = rockchip_pcie_ep_raise_irq,
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/pci/controller/pcie-rockchip-ep.c:516:15: note: (near initialization for 'rockchip_pcie_epc_ops.raise_irq')
cc1: some warnings being treated as errors
vim +516 drivers/pci/controller/pcie-rockchip-ep.c
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 507
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 508 static const struct pci_epc_ops rockchip_pcie_epc_ops = {
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 509 .write_header = rockchip_pcie_ep_write_header,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 510 .set_bar = rockchip_pcie_ep_set_bar,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 511 .clear_bar = rockchip_pcie_ep_clear_bar,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 512 .map_addr = rockchip_pcie_ep_map_addr,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 513 .unmap_addr = rockchip_pcie_ep_unmap_addr,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 514 .set_msi = rockchip_pcie_ep_set_msi,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 515 .get_msi = rockchip_pcie_ep_get_msi,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 @516 .raise_irq = rockchip_pcie_ep_raise_irq,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 517 .start = rockchip_pcie_ep_start,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 518 };cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 519
:::::: The code at line 516 was first introduced by commit
:::::: cf590b07839133146842d2d3d9a68f804c2edc4b PCI: rockchip: Add EP driver for Rockchip PCIe controller
:::::: TO: Shawn Lin <[email protected]> :::::: CC: Lorenzo Pieralisi <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botRe: [PATCH v4 03/10] PCI: Update xxx_pcie_ep_raise_irq() and pci_epc_raise_irq() signatures
In reply to Gustavo PimentelThank you for the patch! Yet something to improve:
Hi Gustavo,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on pci/next]
[also build test ERROR on v4.18-rc1 next-20180618]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Gustavo-Pimentel/Add-MSI-X-support-on-pcitest-tool/20180619-004625 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next config: arm-allmodconfig (attached as .config) compiler: arm-linux-gnueabi-gcc (Debian 7.2.0-11) 7.2.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.2.0 make.cross ARCH=arm
All errors (new ones prefixed by >>):
>> drivers/pci/controller/pcie-rockchip-ep.c:516:15: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.raise_irq = rockchip_pcie_ep_raise_irq,
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/pci/controller/pcie-rockchip-ep.c:516:15: note: (near initialization for 'rockchip_pcie_epc_ops.raise_irq')
cc1: some warnings being treated as errors
vim +516 drivers/pci/controller/pcie-rockchip-ep.c
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 507
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 508 static const struct pci_epc_ops rockchip_pcie_epc_ops = {
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 509 .write_header = rockchip_pcie_ep_write_header,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 510 .set_bar = rockchip_pcie_ep_set_bar,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 511 .clear_bar = rockchip_pcie_ep_clear_bar,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 512 .map_addr = rockchip_pcie_ep_map_addr,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 513 .unmap_addr = rockchip_pcie_ep_unmap_addr,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 514 .set_msi = rockchip_pcie_ep_set_msi,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 515 .get_msi = rockchip_pcie_ep_get_msi,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 @516 .raise_irq = rockchip_pcie_ep_raise_irq,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 517 .start = rockchip_pcie_ep_start,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 518 };cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 519
:::::: The code at line 516 was first introduced by commit
:::::: cf590b07839133146842d2d3d9a68f804c2edc4b PCI: rockchip: Add EP driver for Rockchip PCIe controller
:::::: TO: Shawn Lin <[email protected]> :::::: CC: Lorenzo Pieralisi <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
kbuild test robot
build botRe: [PATCH v4 03/10] PCI: Update xxx_pcie_ep_raise_irq() and pci_epc_raise_irq() signatures
In reply to Gustavo PimentelThank you for the patch! Perhaps something to improve:
Hi Gustavo,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on pci/next]
[also build test WARNING on v4.18-rc1 next-20180618]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]
url: https://github.com/0day-ci/linux/commits/Gustavo-Pimentel/Add-MSI-X-support-on-pcitest-tool/20180619-004625 base: https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git next reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__
sparse warnings: (new ones prefixed by >>)
drivers/pci/controller/pcie-rockchip-ep.c:173:14: sparse: expression using sizeof(void)
>> drivers/pci/controller/pcie-rockchip-ep.c:516:27: sparse: incorrect type in initializer (incompatible argument 4 (different type sizes)) @@ expected int ( *raise_irq )( ... ) @@ got int ( *raise_irq )( ... ) @@
drivers/pci/controller/pcie-rockchip-ep.c:516:27: expected int ( *raise_irq )( ... )
drivers/pci/controller/pcie-rockchip-ep.c:516:27: got int ( *<noident> )( ... )
drivers/pci/controller/pcie-rockchip-ep.c:516:15: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.raise_irq = rockchip_pcie_ep_raise_irq,
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/pci/controller/pcie-rockchip-ep.c:516:15: note: (near initialization for 'rockchip_pcie_epc_ops.raise_irq')
cc1: some warnings being treated as errors
vim +516 drivers/pci/controller/pcie-rockchip-ep.c
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 507
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 508 static const struct pci_epc_ops rockchip_pcie_epc_ops = {
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 509 .write_header = rockchip_pcie_ep_write_header,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 510 .set_bar = rockchip_pcie_ep_set_bar,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 511 .clear_bar = rockchip_pcie_ep_clear_bar,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 512 .map_addr = rockchip_pcie_ep_map_addr,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 513 .unmap_addr = rockchip_pcie_ep_unmap_addr,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 514 .set_msi = rockchip_pcie_ep_set_msi,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 515 .get_msi = rockchip_pcie_ep_get_msi,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 @516 .raise_irq = rockchip_pcie_ep_raise_irq,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 517 .start = rockchip_pcie_ep_start,
cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 518 };cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 519
:::::: The code at line 516 was first introduced by commit
:::::: cf590b07839133146842d2d3d9a68f804c2edc4b PCI: rockchip: Add EP driver for Rockchip PCIe controller
:::::: TO: Shawn Lin <[email protected]> :::::: CC: Lorenzo Pieralisi <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH v4 03/10] PCI: Update xxx_pcie_ep_raise_irq() and pci_epc_raise_irq() signatures
Hi,
Thanks for the suggestion.
Regards,
Gustavo
Quoted 54 lines · kbuild test robot
Hi Gustavo,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on pci/next]
[also build test WARNING on v4.18-rc1 next-20180618]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]url: https://urldefense.proofpoint.com/v2/url?u=https-3A__github.com_0day-2Dci_linux_commits_Gustavo-2DPimentel_Add-2DMSI-2DX-2Dsupport-2Don-2Dpcitest-2Dtool_20180619-2D004625&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-f-E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=IFx9JKJsE2KvE7siiXs4GRW2a3OkFpE8BFO41SbTjJA&s=vuOhITY-_4Y-jxzyQ1ddb6M8E9-OELpKXzcJZqgWqvE&e= base: https://urldefense.proofpoint.com/v2/url?u=https-3A__git.kernel.org_pub_scm_linux_kernel_git_helgaas_pci.git&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-f-E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=IFx9JKJsE2KvE7siiXs4GRW2a3OkFpE8BFO41SbTjJA&s=7xs_oUDvo5HRxpqsZAqdybMJcJDO6K3hooyy-CmXwkM&e= next reproduce: # apt-get install sparse make ARCH=x86_64 allmodconfig make C=1 CF=-D__CHECK_ENDIAN__sparse warnings: (new ones prefixed by >>)
drivers/pci/controller/pcie-rockchip-ep.c:173:14: sparse: expression using sizeof(void)Quoted 1 line
Quoted 1 line
drivers/pci/controller/pcie-rockchip-ep.c:516:27: sparse: incorrect type in initializer (incompatible argument 4 (different type sizes)) @@ expected int (*raise_irq)( ... ) @@ got int (*raise_irq)( ... ) @@
drivers/pci/controller/pcie-rockchip-ep.c:516:27: expected int (*raise_irq)( ... )
drivers/pci/controller/pcie-rockchip-ep.c:516:27: got int ( *<noident> )( ... )
drivers/pci/controller/pcie-rockchip-ep.c:516:15: error: initialization from incompatible pointer type [-Werror=incompatible-pointer-types]
.raise_irq =rockchip_pcie_ep_raise_irq,
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/pci/controller/pcie-rockchip-ep.c:516:15: note: (near initialization for 'rockchip_pcie_epc_ops.raise_irq')
cc1: some warnings being treated as errorsvim +516
drivers/pci/controller/pcie-rockchip-ep.ccf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 507 cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 508 static const struct pci_epc_ops rockchip_pcie_epc_ops = { cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 509 .write_header = rockchip_pcie_ep_write_header, cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 510 .set_bar = rockchip_pcie_ep_set_bar, cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 511 .clear_bar = rockchip_pcie_ep_clear_bar, cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 512 .map_addr = rockchip_pcie_ep_map_addr, cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 513 .unmap_addr = rockchip_pcie_ep_unmap_addr, cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 514 .set_msi = rockchip_pcie_ep_set_msi, cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 515 .get_msi = rockchip_pcie_ep_get_msi, cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 @516 .raise_irq = rockchip_pcie_ep_raise_irq, cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 517 .start = rockchip_pcie_ep_start, cf590b07 drivers/pci/host/pcie-rockchip-ep.c Shawn Lin 2018-05-09 518 };
cf590b07drivers/pci/host/pcie-rockchip-ep.cShawn Lin 2018-05-09 519:::::: The code at line 516 was first introduced by commit
::::::cf590b07839133146842d2d3d9a68f804c2edc4bPCI: rockchip: Add EP driver for Rockchip PCIe controller:::::: TO: Shawn Lin <[email protected]> :::::: CC: Lorenzo Pieralisi <[email protected]>
---
0-DAY kernel test infrastructure Open Source Technology Center
https://urldefense.proofpoint.com/v2/url?u=https-3A__lists.01.org_pipermail_kbuild-2Dall&d=DwIBAg&c=DPL6_X_6JkXFx7AXWqB0tg&r=bkWxpLoW-f-E3EdiDCCa0_h0PicsViasSlvIpzZvPxs&m=IFx9JKJsE2KvE7siiXs4GRW2a3OkFpE8BFO41SbTjJA&s=Mf1d7cz8MbsSZPkgXFwnxZJY1579nwc7-mpjeQBdweY&e= Intel Corporation
Re: [PATCH v4 03/10] PCI: Update xxx_pcie_ep_raise_irq() and pci_epc_raise_irq() signatures
In reply to Gustavo PimentelHi,
Quoted 6 lines · Gustavo Pimentel
Change {cdns, dra7xx, artpec6}_pcie_ep_raise_irq() and
pci_epc_raise_irq()signature, namely theinterrupt_numvariable type from u8 to u16 to accommodate 2048 maximum MSI-X interrupts.Signed-off-by Gustavo Pimentel <[email protected]>Acked-by Alan Douglas <[email protected]>
This patch should precede patch #2 and the following hunk from patch #2 should be added here.
drivers/pci/controller/dwc/pcie-designware.h +1 -1
@@ -191,7 +191,7 @@ enum dw_pcie_as_type {struct dw_pcie_ep_ops {void (*ep_init)(struct dw_pcie_ep *ep);int (*raise_irq)(struct dw_pcie_ep *ep,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num); +enum pci_epc_irq_type type,u16 interrupt_num); };
Thanks
Kishon
Quoted 112 lines
---
Changev1->v2:
- Nothing changed, just to follow the patch set version.
Changev2->v3:
- Move into here thepci_epc_raise_irq()signature change from patch
file #1.
- Move into here the {dra7xx, artpec6}_pcie_ep_raise_irq() signature
changes from patch file #2.
Changev3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.drivers/pci/controller/dwc/pci-dra7xx.c | 2 +- drivers/pci/controller/dwc/pcie-artpec6.c | 2 +- drivers/pci/controller/pcie-cadence-ep.c | 3 ++- drivers/pci/endpoint/pci-epc-core.c | 8 ++++---- include/linux/pci-epc.h | 6 +++--- 5 files changed, 11 insertions(+), 10 deletions(-)drivers/pci/controller/dwc/pci-dra7xx.c +1
-1@@ -370,7 +370,7 @@ static void dra7xx_pcie_raise_msi_irq(struct dra7xx_pcie *dra7xx, }static int dra7xx_pcie_raise_irq (struct dw_pcie_ep *ep,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type,u16 interrupt_num) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep);struct dra7xx_pcie *dra7xx =to_dra7xx_pcie (pci);drivers/pci/controller/dwc/pcie-artpec6.c +1
-1@@ -428,7 +428,7 @@ static void artpec6_pcie_ep_init(struct dw_pcie_ep *ep) }static int artpec6_pcie_raise_irq (struct dw_pcie_ep *ep,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type,u16 interrupt_num) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep);drivers/pci/controller/pcie-cadence-ep.c +2
-1@@ -363,7 +363,8 @@ static int cdns_pcie_ep_send_msi_irq(struct cdns_pcie_ep *ep, u8 fn, }static int cdns_pcie_ep_raise_irq (struct pci_epc *epc,u8 fn, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type, +u16 interrupt_num) {struct cdns_pcie_ep *ep =epc_get_drvdata (epc);drivers/pci/endpoint/pci-epc-core.c +4
-4@@ -131,13 +131,13 @@ EXPORT_SYMBOL_GPL(pci_epc_start);* pci_epc_raise_irq() - interrupt the host system * @epc: the EPC device which has to interrupt the host * @func_no: the endpoint function number in the EPC device -* @type: specify the type of interrupt; legacy or MSI -* @interrupt_num: the MSI interrupt number +* @type: specify the type of interrupt; legacy, MSI or MSI-X +* @interrupt_num: the MSI or MSI-X interrupt number * -* Invoke to raise an MSI or legacy interrupt +* Invoke to raise an legacy, MSI or MSI-X interrupt */ int pci_epc_raise_irq (struct pci_epc *epc,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type,u16 interrupt_num) {int ret;unsigned long flags;include/linux/pci-epc.h +3
-3@@ -35,7 +35,7 @@ enum pci_epc_irq_type {* MSI-X capability register * @get_msix: ops to get the number of MSI-X interrupts allocated by the RC * from the MSI-X capability register -* @raise_irq: ops to raise a legacy or MSI interrupt +* @raise_irq: ops to raise a legacy, MSI or MSI-X interrupt * @start: ops to start the PCI link * @stop: ops to stop the PCI link * @owner: the module owner containing the ops @@ -56,7 +56,7 @@ struct pci_epc_ops {int (*set_msix)(struct pci_epc *epc,u8 func_no,u16 interrupts);int (*get_msix)(struct pci_epc *epc,u8 func_no);int (*raise_irq)(struct pci_epc *epc,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num); +enum pci_epc_irq_type type,u16 interrupt_num);int (*start)(struct pci_epc *epc);void (*stop)(struct pci_epc *epc);struct module *owner;@@ -154,7 +154,7 @@ int pci_epc_get_msi(struct pci_epc *epc, u8 func_no);int pci_epc_set_msix (struct pci_epc *epc,u8 func_no,u16 interrupts);int pci_epc_get_msix (struct pci_epc *epc,u8 func_no);int pci_epc_raise_irq (struct pci_epc *epc,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num); +enum pci_epc_irq_type type,u16 interrupt_num);int pci_epc_start (struct pci_epc *epc);void pci_epc_stop (struct pci_epc *epc);struct pci_epc *pci_epc_get (const char *epc_name);
Re: [PATCH v4 03/10] PCI: Update xxx_pcie_ep_raise_irq() and pci_epc_raise_irq() signatures
Hi,
Quoted 16 lines · Kishon Vijay Abraham I
Hi,
Quoted 6 lines · Gustavo Pimentel
Change {cdns, dra7xx, artpec6}_pcie_ep_raise_irq() and
pci_epc_raise_irq()signature, namely theinterrupt_numvariable type from u8 to u16 to accommodate 2048 maximum MSI-X interrupts.Signed-off-by Gustavo Pimentel <[email protected]>Acked-by Alan Douglas <[email protected]>This patch should precede patch #2 and the following hunk from patch #2 should be added here.
drivers/pci/controller/dwc/pcie-designware.h enum dw_pcie_as_type { · line 195
Quoted 6 lines
drivers/pci/controller/dwc/pcie-designware.h +1
-1@@ -191,7 +191,7 @@ enum dw_pcie_as_type {struct dw_pcie_ep_ops {void (*ep_init)(struct dw_pcie_ep *ep);int (*raise_irq)(struct dw_pcie_ep *ep,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num); +enum pci_epc_irq_type type,u16 interrupt_num); };
Yes, it it makes a lot more sense in the other patch file.
Thanks.
Gustavo
Quoted 116 lines
Thanks
KishonQuoted 112 lines
---
Changev1->v2:
- Nothing changed, just to follow the patch set version.
Changev2->v3:
- Move into here thepci_epc_raise_irq()signature change from patch
file #1.
- Move into here the {dra7xx, artpec6}_pcie_ep_raise_irq() signature
changes from patch file #2.
Changev3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.drivers/pci/controller/dwc/pci-dra7xx.c | 2 +- drivers/pci/controller/dwc/pcie-artpec6.c | 2 +- drivers/pci/controller/pcie-cadence-ep.c | 3 ++- drivers/pci/endpoint/pci-epc-core.c | 8 ++++---- include/linux/pci-epc.h | 6 +++--- 5 files changed, 11 insertions(+), 10 deletions(-)drivers/pci/controller/dwc/pci-dra7xx.c +1
-1@@ -370,7 +370,7 @@ static void dra7xx_pcie_raise_msi_irq(struct dra7xx_pcie *dra7xx, }static int dra7xx_pcie_raise_irq (struct dw_pcie_ep *ep,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type,u16 interrupt_num) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep);struct dra7xx_pcie *dra7xx =to_dra7xx_pcie (pci);drivers/pci/controller/dwc/pcie-artpec6.c +1
-1@@ -428,7 +428,7 @@ static void artpec6_pcie_ep_init(struct dw_pcie_ep *ep) }static int artpec6_pcie_raise_irq (struct dw_pcie_ep *ep,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type,u16 interrupt_num) {struct dw_pcie *pci =to_dw_pcie_from_ep (ep);drivers/pci/controller/pcie-cadence-ep.c +2
-1@@ -363,7 +363,8 @@ static int cdns_pcie_ep_send_msi_irq(struct cdns_pcie_ep *ep, u8 fn, }static int cdns_pcie_ep_raise_irq (struct pci_epc *epc,u8 fn, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type, +u16 interrupt_num) {struct cdns_pcie_ep *ep =epc_get_drvdata (epc);drivers/pci/endpoint/pci-epc-core.c +4
-4@@ -131,13 +131,13 @@ EXPORT_SYMBOL_GPL(pci_epc_start);* pci_epc_raise_irq() - interrupt the host system * @epc: the EPC device which has to interrupt the host * @func_no: the endpoint function number in the EPC device -* @type: specify the type of interrupt; legacy or MSI -* @interrupt_num: the MSI interrupt number +* @type: specify the type of interrupt; legacy, MSI or MSI-X +* @interrupt_num: the MSI or MSI-X interrupt number * -* Invoke to raise an MSI or legacy interrupt +* Invoke to raise an legacy, MSI or MSI-X interrupt */ int pci_epc_raise_irq (struct pci_epc *epc,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num) +enum pci_epc_irq_type type,u16 interrupt_num) {int ret;unsigned long flags;include/linux/pci-epc.h +3
-3@@ -35,7 +35,7 @@ enum pci_epc_irq_type {* MSI-X capability register * @get_msix: ops to get the number of MSI-X interrupts allocated by the RC * from the MSI-X capability register -* @raise_irq: ops to raise a legacy or MSI interrupt +* @raise_irq: ops to raise a legacy, MSI or MSI-X interrupt * @start: ops to start the PCI link * @stop: ops to stop the PCI link * @owner: the module owner containing the ops @@ -56,7 +56,7 @@ struct pci_epc_ops {int (*set_msix)(struct pci_epc *epc,u8 func_no,u16 interrupts);int (*get_msix)(struct pci_epc *epc,u8 func_no);int (*raise_irq)(struct pci_epc *epc,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num); +enum pci_epc_irq_type type,u16 interrupt_num);int (*start)(struct pci_epc *epc);void (*stop)(struct pci_epc *epc);struct module *owner;@@ -154,7 +154,7 @@ int pci_epc_get_msi(struct pci_epc *epc, u8 func_no);int pci_epc_set_msix (struct pci_epc *epc,u8 func_no,u16 interrupts);int pci_epc_get_msix (struct pci_epc *epc,u8 func_no);int pci_epc_raise_irq (struct pci_epc *epc,u8 func_no, -enum pci_epc_irq_type type,u8 interrupt_num); +enum pci_epc_irq_type type,u16 interrupt_num);int pci_epc_start (struct pci_epc *epc);void pci_epc_stop (struct pci_epc *epc);struct pci_epc *pci_epc_get (const char *epc_name);
PATCH v4 4/10 PCI: dwc: Rework MSI callbacks handler
In reply to Gustavo PimentelRemove duplicate defines located on pcie-designware.h file already available on /include/uapi/linux/pci-regs.h file.
Add pci_epc_set_msi() maximum 32 interrupts validation.
---
Change v1->v2:
- Nothing changed, just to follow the patch set version.
Change v2->v3:
- Replaced wrong return value 0 to -EINVAL.
Change v3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.
drivers/pci/controller/dwc/pcie-designware-ep.c | 49 +++++++++++++++++-------- drivers/pci/controller/dwc/pcie-designware.h | 11 ------ drivers/pci/endpoint/pci-epc-core.c | 3 +- 3 files changed, 35 insertions(+), 28 deletions(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +33 -16
@@ -246,29 +246,38 @@ static int dw_pcie_ep_map_addr(struct pci_epc *epc, u8 func_no,static int dw_pcie_ep_get_msi (struct pci_epc *epc,u8 func_no) { -int val;struct dw_pcie_ep *ep =epc_get_drvdata (epc);struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +u32 val, reg; + +if (!ep->msi_cap) +return -EINVAL ; - val =dw_pcie_readw_dbi (pci,MSI_MESSAGE_CONTROL ); -if (!(val &MSI_CAP_MSI_EN_MASK )) + reg = ep->msi_cap +PCI_MSI_FLAGS ; + val =dw_pcie_readw_dbi (pci, reg); +if (!(val &PCI_MSI_FLAGS_ENABLE ))return -EINVAL ; - val = (val &MSI_CAP_MME_MASK ) >>MSI_CAP_MME_SHIFT ; + val = (val &PCI_MSI_FLAGS_QSIZE ) >>4 ; +return val; } -static int dw_pcie_ep_set_msi (struct pci_epc *epc,u8 func_no,u8 encode_int) +static int dw_pcie_ep_set_msi (struct pci_epc *epc,u8 func_no,u8 interrupts) { -int val;struct dw_pcie_ep *ep =epc_get_drvdata (epc);struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +u32 val, reg; - val =dw_pcie_readw_dbi (pci,MSI_MESSAGE_CONTROL ); - val &= ~MSI_CAP_MMC_MASK ; - val |= (encode_int <<MSI_CAP_MMC_SHIFT ) &MSI_CAP_MMC_MASK ; +if (!ep->msi_cap) +return -EINVAL ; + + reg = ep->msi_cap +PCI_MSI_FLAGS ; + val =dw_pcie_readw_dbi (pci, reg); + val &= ~PCI_MSI_FLAGS_QMASK ; + val |= (interrupts <<1 ) &PCI_MSI_FLAGS_QMASK ;dw_pcie_dbi_ro_wr_en (pci); -dw_pcie_writew_dbi (pci,MSI_MESSAGE_CONTROL , val); +dw_pcie_writew_dbi (pci, reg, val);dw_pcie_dbi_ro_wr_dis (pci);return 0 ;
@@ -367,21 +376,29 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,struct dw_pcie *pci =to_dw_pcie_from_ep (ep);struct pci_epc *epc = ep->epc;u16 msg_ctrl, msg_data; -u32 msg_addr_lower, msg_addr_upper; +u32 msg_addr_lower, msg_addr_upper, reg;u64 msg_addr;bool has_upper;int ret; +if (!ep->msi_cap) +return -EINVAL ; +/* Raise MSI per the PCI Local Bus Specification Revision 3.0, 6.8.1. */ - msg_ctrl =dw_pcie_readw_dbi (pci,MSI_MESSAGE_CONTROL ); + reg = ep->msi_cap +PCI_MSI_FLAGS ; + msg_ctrl =dw_pcie_readw_dbi (pci, reg); has_upper = !!(msg_ctrl &PCI_MSI_FLAGS_64BIT ); - msg_addr_lower =dw_pcie_readl_dbi (pci,MSI_MESSAGE_ADDR_L32 ); + reg = ep->msi_cap +PCI_MSI_ADDRESS_LO ; + msg_addr_lower =dw_pcie_readl_dbi (pci, reg);if (has_upper) { - msg_addr_upper =dw_pcie_readl_dbi (pci,MSI_MESSAGE_ADDR_U32 ); - msg_data =dw_pcie_readw_dbi (pci,MSI_MESSAGE_DATA_64 ); + reg = ep->msi_cap +PCI_MSI_ADDRESS_HI ; + msg_addr_upper =dw_pcie_readl_dbi (pci, reg); + reg = ep->msi_cap +PCI_MSI_DATA_64 ; + msg_data =dw_pcie_readw_dbi (pci, reg); }else { msg_addr_upper =0 ; - msg_data =dw_pcie_readw_dbi (pci,MSI_MESSAGE_DATA_32 ); + reg = ep->msi_cap +PCI_MSI_DATA_32 ; + msg_data =dw_pcie_readw_dbi (pci, reg); } msg_addr = ((u64 ) msg_addr_upper) <<32 | msg_addr_lower; ret = dw_pcie_ep_map_addr(epc, func_no, ep->msi_mem_phys, msg_addr,
drivers/pci/controller/dwc/pcie-designware.h +0 -11
@@ -96,17 +96,6 @@#define PCIE_GET_ATU_INB_UNR_REG_OFFSET (region) \ ((0x3 << 20) | ((region) << 9) | (0x1 << 8)) -#define MSI_MESSAGE_CONTROL 0x52 -#define MSI_CAP_MMC_SHIFT 1 -#define MSI_CAP_MMC_MASK (7 << MSI_CAP_MMC_SHIFT) -#define MSI_CAP_MME_SHIFT 4 -#define MSI_CAP_MSI_EN_MASK 0x1 -#define MSI_CAP_MME_MASK (7 << MSI_CAP_MME_SHIFT) -#define MSI_MESSAGE_ADDR_L32 0x54 -#define MSI_MESSAGE_ADDR_U32 0x58 -#define MSI_MESSAGE_DATA_32 0x58 -#define MSI_MESSAGE_DATA_64 0x5C -#define MAX_MSI_IRQS 256#define MAX_MSI_IRQS_PER_CTRL 32#define MAX_MSI_CTRLS (MAX_MSI_IRQS / MAX_MSI_IRQS_PER_CTRL)
drivers/pci/endpoint/pci-epc-core.c +2 -1
@@ -201,7 +201,8 @@ int pci_epc_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts)u8 encode_int;unsigned long flags; -if (IS_ERR_OR_NULL (epc) || func_no >= epc->max_functions) +if (IS_ERR_OR_NULL (epc) || func_no >= epc->max_functions || + interrupts >32 )return -EINVAL ;if (!epc->ops->set_msi)
Signature · 1 line
2.7.4
Re: [PATCH v4 04/10] PCI: dwc: Rework MSI callbacks handler
Hi,
Quoted 135 lines · Gustavo Pimentel
Remove duplicate defines located on
pcie-designware.hfile already available on /include/uapi/linux/pci-regs.h file.Add
pci_epc_set_msi()maximum 32 interrupts validation.Signed-off-by Gustavo Pimentel <[email protected]>---
Changev1->v2:
- Nothing changed, just to follow the patch set version.
Changev2->v3:
- Replaced wrong return value 0 to-EINVAL.
Changev3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.drivers/pci/controller/dwc/pcie-designware-ep.c | 49 +++++++++++++++++-------- drivers/pci/controller/dwc/pcie-designware.h | 11 ------ drivers/pci/endpoint/pci-epc-core.c | 3 +- 3 files changed, 35 insertions(+), 28 deletions(-)drivers/pci/controller/dwc/pcie-designware-ep.c +33
-16@@ -246,29 +246,38 @@ static int dw_pcie_ep_map_addr(struct pci_epc *epc, u8 func_no,static int dw_pcie_ep_get_msi (struct pci_epc *epc,u8 func_no) { -int val;struct dw_pcie_ep *ep =epc_get_drvdata (epc);struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +u32 val, reg; + +if (!ep->msi_cap) +return -EINVAL ; - val =dw_pcie_readw_dbi (pci,MSI_MESSAGE_CONTROL ); -if (!(val &MSI_CAP_MSI_EN_MASK )) + reg = ep->msi_cap +PCI_MSI_FLAGS ; + val =dw_pcie_readw_dbi (pci, reg); +if (!(val &PCI_MSI_FLAGS_ENABLE ))return -EINVAL ; - val = (val &MSI_CAP_MME_MASK ) >>MSI_CAP_MME_SHIFT ; + val = (val &PCI_MSI_FLAGS_QSIZE ) >>4 ; +return val; } -static int dw_pcie_ep_set_msi (struct pci_epc *epc,u8 func_no,u8 encode_int) +static int dw_pcie_ep_set_msi (struct pci_epc *epc,u8 func_no,u8 interrupts) { -int val;struct dw_pcie_ep *ep =epc_get_drvdata (epc);struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +u32 val, reg; - val =dw_pcie_readw_dbi (pci,MSI_MESSAGE_CONTROL ); - val &= ~MSI_CAP_MMC_MASK ; - val |= (encode_int <<MSI_CAP_MMC_SHIFT ) &MSI_CAP_MMC_MASK ; +if (!ep->msi_cap) +return -EINVAL ; + + reg = ep->msi_cap +PCI_MSI_FLAGS ; + val =dw_pcie_readw_dbi (pci, reg); + val &= ~PCI_MSI_FLAGS_QMASK ; + val |= (interrupts <<1 ) &PCI_MSI_FLAGS_QMASK ;dw_pcie_dbi_ro_wr_en (pci); -dw_pcie_writew_dbi (pci,MSI_MESSAGE_CONTROL , val); +dw_pcie_writew_dbi (pci, reg, val);dw_pcie_dbi_ro_wr_dis (pci);return 0 ;@@ -367,21 +376,29 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,struct dw_pcie *pci =to_dw_pcie_from_ep (ep);struct pci_epc *epc = ep->epc;u16 msg_ctrl, msg_data; -u32 msg_addr_lower, msg_addr_upper; +u32 msg_addr_lower, msg_addr_upper, reg;u64 msg_addr;bool has_upper;int ret; +if (!ep->msi_cap) +return -EINVAL ; +/* Raise MSI per the PCI Local Bus Specification Revision 3.0, 6.8.1. */ - msg_ctrl =dw_pcie_readw_dbi (pci,MSI_MESSAGE_CONTROL ); + reg = ep->msi_cap +PCI_MSI_FLAGS ; + msg_ctrl =dw_pcie_readw_dbi (pci, reg); has_upper = !!(msg_ctrl &PCI_MSI_FLAGS_64BIT ); - msg_addr_lower =dw_pcie_readl_dbi (pci,MSI_MESSAGE_ADDR_L32 ); + reg = ep->msi_cap +PCI_MSI_ADDRESS_LO ; + msg_addr_lower =dw_pcie_readl_dbi (pci, reg);if (has_upper) { - msg_addr_upper =dw_pcie_readl_dbi (pci,MSI_MESSAGE_ADDR_U32 ); - msg_data =dw_pcie_readw_dbi (pci,MSI_MESSAGE_DATA_64 ); + reg = ep->msi_cap +PCI_MSI_ADDRESS_HI ; + msg_addr_upper =dw_pcie_readl_dbi (pci, reg); + reg = ep->msi_cap +PCI_MSI_DATA_64 ; + msg_data =dw_pcie_readw_dbi (pci, reg); }else { msg_addr_upper =0 ; - msg_data =dw_pcie_readw_dbi (pci,MSI_MESSAGE_DATA_32 ); + reg = ep->msi_cap +PCI_MSI_DATA_32 ; + msg_data =dw_pcie_readw_dbi (pci, reg); } msg_addr = ((u64 ) msg_addr_upper) <<32 | msg_addr_lower; ret = dw_pcie_ep_map_addr(epc, func_no, ep->msi_mem_phys, msg_addr,drivers/pci/controller/dwc/pcie-designware.h +0
-11@@ -96,17 +96,6 @@#define PCIE_GET_ATU_INB_UNR_REG_OFFSET (region) \ ((0x3 << 20) | ((region) << 9) | (0x1 << 8)) -#define MSI_MESSAGE_CONTROL 0x52 -#define MSI_CAP_MMC_SHIFT 1 -#define MSI_CAP_MMC_MASK (7 << MSI_CAP_MMC_SHIFT) -#define MSI_CAP_MME_SHIFT 4 -#define MSI_CAP_MSI_EN_MASK 0x1 -#define MSI_CAP_MME_MASK (7 << MSI_CAP_MME_SHIFT) -#define MSI_MESSAGE_ADDR_L32 0x54 -#define MSI_MESSAGE_ADDR_U32 0x58 -#define MSI_MESSAGE_DATA_32 0x58 -#define MSI_MESSAGE_DATA_64 0x5C -#define MAX_MSI_IRQS 256#define MAX_MSI_IRQS_PER_CTRL 32#define MAX_MSI_CTRLS (MAX_MSI_IRQS / MAX_MSI_IRQS_PER_CTRL)drivers/pci/endpoint/pci-epc-core.c +0
-0
drivers/pci/endpoint/pci-epc-core.c int pci_epc_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts) · line 206
Quoted 7 lines
drivers/pci/endpoint/pci-epc-core.c +2
-1@@ -201,7 +201,8 @@ int pci_epc_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts)u8 encode_int;unsigned long flags; -if (IS_ERR_OR_NULL (epc) || func_no >= epc->max_functions) +if (IS_ERR_OR_NULL (epc) || func_no >= epc->max_functions || + interrupts >32 )return -EINVAL ;
This is not related to $patch->subject
Thanks
Kishon
Re: [PATCH v4 04/10] PCI: dwc: Rework MSI callbacks handler
Hi,
Quoted 141 lines · Kishon Vijay Abraham I
Hi,
Quoted 138 lines · Gustavo Pimentel
Remove duplicate defines located on
pcie-designware.hfile already available on /include/uapi/linux/pci-regs.h file.Add
pci_epc_set_msi()maximum 32 interrupts validation.Signed-off-by Gustavo Pimentel <[email protected]>---
Changev1->v2:
- Nothing changed, just to follow the patch set version.
Changev2->v3:
- Replaced wrong return value 0 to-EINVAL.
Changev3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.drivers/pci/controller/dwc/pcie-designware-ep.c | 49 +++++++++++++++++-------- drivers/pci/controller/dwc/pcie-designware.h | 11 ------ drivers/pci/endpoint/pci-epc-core.c | 3 +- 3 files changed, 35 insertions(+), 28 deletions(-)drivers/pci/controller/dwc/pcie-designware-ep.c +33
-16@@ -246,29 +246,38 @@ static int dw_pcie_ep_map_addr(struct pci_epc *epc, u8 func_no,static int dw_pcie_ep_get_msi (struct pci_epc *epc,u8 func_no) { -int val;struct dw_pcie_ep *ep =epc_get_drvdata (epc);struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +u32 val, reg; + +if (!ep->msi_cap) +return -EINVAL ; - val =dw_pcie_readw_dbi (pci,MSI_MESSAGE_CONTROL ); -if (!(val &MSI_CAP_MSI_EN_MASK )) + reg = ep->msi_cap +PCI_MSI_FLAGS ; + val =dw_pcie_readw_dbi (pci, reg); +if (!(val &PCI_MSI_FLAGS_ENABLE ))return -EINVAL ; - val = (val &MSI_CAP_MME_MASK ) >>MSI_CAP_MME_SHIFT ; + val = (val &PCI_MSI_FLAGS_QSIZE ) >>4 ; +return val; } -static int dw_pcie_ep_set_msi (struct pci_epc *epc,u8 func_no,u8 encode_int) +static int dw_pcie_ep_set_msi (struct pci_epc *epc,u8 func_no,u8 interrupts) { -int val;struct dw_pcie_ep *ep =epc_get_drvdata (epc);struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +u32 val, reg; - val =dw_pcie_readw_dbi (pci,MSI_MESSAGE_CONTROL ); - val &= ~MSI_CAP_MMC_MASK ; - val |= (encode_int <<MSI_CAP_MMC_SHIFT ) &MSI_CAP_MMC_MASK ; +if (!ep->msi_cap) +return -EINVAL ; + + reg = ep->msi_cap +PCI_MSI_FLAGS ; + val =dw_pcie_readw_dbi (pci, reg); + val &= ~PCI_MSI_FLAGS_QMASK ; + val |= (interrupts <<1 ) &PCI_MSI_FLAGS_QMASK ;dw_pcie_dbi_ro_wr_en (pci); -dw_pcie_writew_dbi (pci,MSI_MESSAGE_CONTROL , val); +dw_pcie_writew_dbi (pci, reg, val);dw_pcie_dbi_ro_wr_dis (pci);return 0 ;@@ -367,21 +376,29 @@ int dw_pcie_ep_raise_msi_irq(struct dw_pcie_ep *ep, u8 func_no,struct dw_pcie *pci =to_dw_pcie_from_ep (ep);struct pci_epc *epc = ep->epc;u16 msg_ctrl, msg_data; -u32 msg_addr_lower, msg_addr_upper; +u32 msg_addr_lower, msg_addr_upper, reg;u64 msg_addr;bool has_upper;int ret; +if (!ep->msi_cap) +return -EINVAL ; +/* Raise MSI per the PCI Local Bus Specification Revision 3.0, 6.8.1. */ - msg_ctrl =dw_pcie_readw_dbi (pci,MSI_MESSAGE_CONTROL ); + reg = ep->msi_cap +PCI_MSI_FLAGS ; + msg_ctrl =dw_pcie_readw_dbi (pci, reg); has_upper = !!(msg_ctrl &PCI_MSI_FLAGS_64BIT ); - msg_addr_lower =dw_pcie_readl_dbi (pci,MSI_MESSAGE_ADDR_L32 ); + reg = ep->msi_cap +PCI_MSI_ADDRESS_LO ; + msg_addr_lower =dw_pcie_readl_dbi (pci, reg);if (has_upper) { - msg_addr_upper =dw_pcie_readl_dbi (pci,MSI_MESSAGE_ADDR_U32 ); - msg_data =dw_pcie_readw_dbi (pci,MSI_MESSAGE_DATA_64 ); + reg = ep->msi_cap +PCI_MSI_ADDRESS_HI ; + msg_addr_upper =dw_pcie_readl_dbi (pci, reg); + reg = ep->msi_cap +PCI_MSI_DATA_64 ; + msg_data =dw_pcie_readw_dbi (pci, reg); }else { msg_addr_upper =0 ; - msg_data =dw_pcie_readw_dbi (pci,MSI_MESSAGE_DATA_32 ); + reg = ep->msi_cap +PCI_MSI_DATA_32 ; + msg_data =dw_pcie_readw_dbi (pci, reg); } msg_addr = ((u64 ) msg_addr_upper) <<32 | msg_addr_lower; ret = dw_pcie_ep_map_addr(epc, func_no, ep->msi_mem_phys, msg_addr,drivers/pci/controller/dwc/pcie-designware.h +0
-11@@ -96,17 +96,6 @@#define PCIE_GET_ATU_INB_UNR_REG_OFFSET (region) \ ((0x3 << 20) | ((region) << 9) | (0x1 << 8)) -#define MSI_MESSAGE_CONTROL 0x52 -#define MSI_CAP_MMC_SHIFT 1 -#define MSI_CAP_MMC_MASK (7 << MSI_CAP_MMC_SHIFT) -#define MSI_CAP_MME_SHIFT 4 -#define MSI_CAP_MSI_EN_MASK 0x1 -#define MSI_CAP_MME_MASK (7 << MSI_CAP_MME_SHIFT) -#define MSI_MESSAGE_ADDR_L32 0x54 -#define MSI_MESSAGE_ADDR_U32 0x58 -#define MSI_MESSAGE_DATA_32 0x58 -#define MSI_MESSAGE_DATA_64 0x5C -#define MAX_MSI_IRQS 256#define MAX_MSI_IRQS_PER_CTRL 32#define MAX_MSI_CTRLS (MAX_MSI_IRQS / MAX_MSI_IRQS_PER_CTRL)drivers/pci/endpoint/pci-epc-core.c +0
-0@@ -201,7 +201,8 @@ int pci_epc_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts)u8 encode_int;unsigned long flags;
Quoted 6 lines
drivers/pci/endpoint/pci-epc-core.c int pci_epc_set_msi(struct pci_epc *epc, u8 func_no, u8 interrupts) · line 206
Quoted 4 lines
drivers/pci/endpoint/pci-epc-core.c +2
-1-if (IS_ERR_OR_NULL (epc) || func_no >= epc->max_functions) +if (IS_ERR_OR_NULL (epc) || func_no >= epc->max_functions || + interrupts >32 )return -EINVAL ;This is not related to $patch->subject
A new patch file will be created for this.
Thanks,
Gustavo
Quoted 4 lines
Thanks
Kishon
PATCH v4 5/10 PCI: dwc: Add legacy interrupt callback handler
In reply to Gustavo PimentelAdd a legacy interrupt callback handler. Currently DesignWare IP don't allow trigger legacy interrupts.
---
Change v1->v2:
- Nothing changed, just to follow the patch set version.
Change v2->v3:
- Nothing changed, just to follow the patch set version.
Change v3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.
drivers/pci/controller/dwc/pcie-designware-ep.c | 10 ++++++++++ drivers/pci/controller/dwc/pcie-designware-plat.c | 3 +-- drivers/pci/controller/dwc/pcie-designware.h | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-designware-ep.c +10 -0
@@ -370,6 +370,16 @@ static const struct pci_epc_ops epc_ops = { .stop = dw_pcie_ep_stop, }; +int dw_pcie_ep_raise_legacy_irq (struct dw_pcie_ep *ep,u8 func_no) +{ +struct dw_pcie *pci =to_dw_pcie_from_ep (ep); +struct device *dev = pci->dev; + +dev_err (dev,"EP cannot trigger legacy IRQs\n" ); + +return -EINVAL ; +} +int dw_pcie_ep_raise_msi_irq (struct dw_pcie_ep *ep,u8 func_no,u8 interrupt_num) {
drivers/pci/controller/dwc/pcie-designware-plat.c +1 -2
@@ -84,8 +84,7 @@ static int dw_plat_pcie_ep_raise_irq(struct dw_pcie_ep *ep, u8 func_no,switch (type) {case PCI_EPC_IRQ_LEGACY : -dev_err (pci->dev,"EP cannot trigger legacy IRQs\n" ); -return -EINVAL ; +return dw_pcie_ep_raise_legacy_irq (ep, func_no);case PCI_EPC_IRQ_MSI :return dw_pcie_ep_raise_msi_irq (ep, func_no, interrupt_num);case PCI_EPC_IRQ_MSIX :
drivers/pci/controller/dwc/pcie-designware.h +6 -0
@@ -350,6 +350,7 @@ static inline int dw_pcie_allocate_domains(struct pcie_port *pp)void dw_pcie_ep_linkup (struct dw_pcie_ep *ep);int dw_pcie_ep_init (struct dw_pcie_ep *ep);void dw_pcie_ep_exit (struct dw_pcie_ep *ep); +int dw_pcie_ep_raise_legacy_irq (struct dw_pcie_ep *ep,u8 func_no);int dw_pcie_ep_raise_msi_irq (struct dw_pcie_ep *ep,u8 func_no,u8 interrupt_num); int dw_pcie_ep_raise_msix_irq(struct dw_pcie_ep *ep, u8 func_no,
@@ -369,6 +370,11 @@ static inline void dw_pcie_ep_exit(struct dw_pcie_ep *ep) { } +static inline int dw_pcie_ep_raise_legacy_irq (struct dw_pcie_ep *ep,u8 func_no) +{ +return 0 ; +} +static inline int dw_pcie_ep_raise_msi_irq (struct dw_pcie_ep *ep,u8 func_no,u8 interrupt_num) {
Signature · 1 line
2.7.4
PATCH v4 6/10 pci-epf-test/pci_endpoint_test: Cleanup PCI_ENDPOINT_TEST memspace
In reply to Gustavo PimentelCleanup PCI_ENDPOINT_TEST memspace (by moving the interrupt number away from command section).
---
Change v2->v3:
- New patch file created base on the previous patch
"misc: pci_endpoint_test: Add MSI-X support" patch file following Kishon's suggestion.
Change v3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.
drivers/misc/pci_endpoint_test.c | 84 ++++++++++++++++----------- drivers/pci/endpoint/functions/pci-epf-test.c | 60 ++++++++++++------- 2 files changed, 91 insertions(+), 53 deletions(-)
drivers/misc/pci_endpoint_test.c +51 -33
@@ -35,38 +35,42 @@#include <uapi/linux/pcitest.h> -#define DRV_MODULE_NAME "pci-endpoint-test" - -#define PCI_ENDPOINT_TEST_MAGIC 0x0 - -#define PCI_ENDPOINT_TEST_COMMAND 0x4 -#define COMMAND_RAISE_LEGACY_IRQ BIT(0) -#define COMMAND_RAISE_MSI_IRQ BIT(1) -#define MSI_NUMBER_SHIFT 2 -/* 6 bits for MSI number */ -#define COMMAND_READ BIT(8) -#define COMMAND_WRITE BIT(9) -#define COMMAND_COPY BIT(10) - -#define PCI_ENDPOINT_TEST_STATUS 0x8 -#define STATUS_READ_SUCCESS BIT(0) -#define STATUS_READ_FAIL BIT(1) -#define STATUS_WRITE_SUCCESS BIT(2) -#define STATUS_WRITE_FAIL BIT(3) -#define STATUS_COPY_SUCCESS BIT(4) -#define STATUS_COPY_FAIL BIT(5) -#define STATUS_IRQ_RAISED BIT(6) -#define STATUS_SRC_ADDR_INVALID BIT(7) -#define STATUS_DST_ADDR_INVALID BIT(8) - -#define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0xc +#define DRV_MODULE_NAME "pci-endpoint-test" + +#define IRQ_TYPE_LEGACY 0 +#define IRQ_TYPE_MSI 1 + +#define PCI_ENDPOINT_TEST_MAGIC 0x0 + +#define PCI_ENDPOINT_TEST_COMMAND 0x4 +#define COMMAND_RAISE_LEGACY_IRQ BIT(0) +#define COMMAND_RAISE_MSI_IRQ BIT(1) +#define COMMAND_READ BIT(3) +#define COMMAND_WRITE BIT(4) +#define COMMAND_COPY BIT(5) + +#define PCI_ENDPOINT_TEST_STATUS 0x8 +#define STATUS_READ_SUCCESS BIT(0) +#define STATUS_READ_FAIL BIT(1) +#define STATUS_WRITE_SUCCESS BIT(2) +#define STATUS_WRITE_FAIL BIT(3) +#define STATUS_COPY_SUCCESS BIT(4) +#define STATUS_COPY_FAIL BIT(5) +#define STATUS_IRQ_RAISED BIT(6) +#define STATUS_SRC_ADDR_INVALID BIT(7) +#define STATUS_DST_ADDR_INVALID BIT(8) + +#define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0x0c#define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR 0x10#define PCI_ENDPOINT_TEST_LOWER_DST_ADDR 0x14#define PCI_ENDPOINT_TEST_UPPER_DST_ADDR 0x18 -#define PCI_ENDPOINT_TEST_SIZE 0x1c -#define PCI_ENDPOINT_TEST_CHECKSUM 0x20 +#define PCI_ENDPOINT_TEST_SIZE 0x1c +#define PCI_ENDPOINT_TEST_CHECKSUM 0x20 + +#define PCI_ENDPOINT_TEST_IRQ_TYPE 0x24 +#define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28static DEFINE_IDA (pci_endpoint_test_ida);
@@ -179,6 +183,9 @@ static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) {u32 val; +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , +IRQ_TYPE_LEGACY ); +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_NUMBER ,0 );pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_COMMAND ,COMMAND_RAISE_LEGACY_IRQ ); val = wait_for_completion_timeout(&test->irq_raised,
@@ -190,20 +197,22 @@ static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) }static bool pci_endpoint_test_msi_irq (struct pci_endpoint_test *test, -u8 msi_num) +u8 irq_num) {u32 val;struct pci_dev *pdev = test->pdev; +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , +IRQ_TYPE_MSI ); +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_NUMBER , irq_num);pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_COMMAND , - msi_num <<MSI_NUMBER_SHIFT |COMMAND_RAISE_MSI_IRQ ); val =wait_for_completion_timeout (&test->irq_raised,msecs_to_jiffies (1000 ));if (!val)return false; -if (pci_irq_vector (pdev, msi_num -1 ) == test->last_irq) +if (pci_irq_vector (pdev, irq_num -1 ) == test->last_irq)return true;return false;
@@ -281,8 +290,11 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, size_t size)pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_SIZE , size); +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , + no_msi ?IRQ_TYPE_LEGACY :IRQ_TYPE_MSI ); +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_NUMBER ,1 );pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_COMMAND , -1 <<MSI_NUMBER_SHIFT |COMMAND_COPY ); +COMMAND_COPY );wait_for_completion (&test->irq_raised);
@@ -348,8 +360,11 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test, size_t size)pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_SIZE , size); +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , + no_msi ?IRQ_TYPE_LEGACY :IRQ_TYPE_MSI ); +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_NUMBER ,1 );pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_COMMAND , -1 <<MSI_NUMBER_SHIFT |COMMAND_READ ); +COMMAND_READ );wait_for_completion (&test->irq_raised);
@@ -403,8 +418,11 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test, size_t size)pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_SIZE , size); +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , + no_msi ?IRQ_TYPE_LEGACY :IRQ_TYPE_MSI ); +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_NUMBER ,1 );pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_COMMAND , -1 <<MSI_NUMBER_SHIFT |COMMAND_WRITE ); +COMMAND_WRITE );wait_for_completion (&test->irq_raised);
drivers/pci/endpoint/functions/pci-epf-test.c +40 -20
135 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v4 06/10] pci-epf-test/pci_endpoint_test: Cleanup PCI_ENDPOINT_TEST memspace
Hi,
Quoted 49 lines · Gustavo Pimentel
Cleanup
PCI_ENDPOINT_TESTmemspace (by moving the interrupt number away from command section).Signed-off-by Gustavo Pimentel <[email protected]>---
Changev2->v3:
- New patch file created base on the previous patch
"misc:pci_endpoint_test: Add MSI-X support" patch file following Kishon's suggestion.
Changev3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.drivers/misc/pci_endpoint_test.c | 84 ++++++++++++++++----------- drivers/pci/endpoint/functions/pci-epf-test.c | 60 ++++++++++++------- 2 files changed, 91 insertions(+), 53 deletions(-)drivers/misc/pci_endpoint_test.c +0
-25@@ -35,38 +35,42 @@#include <uapi/linux/pcitest.h> -#define DRV_MODULE_NAME "pci-endpoint-test" - -#define PCI_ENDPOINT_TEST_MAGIC 0x0 - -#define PCI_ENDPOINT_TEST_COMMAND 0x4 -#define COMMAND_RAISE_LEGACY_IRQ BIT(0) -#define COMMAND_RAISE_MSI_IRQ BIT(1) -#define MSI_NUMBER_SHIFT 2 -/* 6 bits for MSI number */ -#define COMMAND_READ BIT(8) -#define COMMAND_WRITE BIT(9) -#define COMMAND_COPY BIT(10) - -#define PCI_ENDPOINT_TEST_STATUS 0x8 -#define STATUS_READ_SUCCESS BIT(0) -#define STATUS_READ_FAIL BIT(1) -#define STATUS_WRITE_SUCCESS BIT(2) -#define STATUS_WRITE_FAIL BIT(3) -#define STATUS_COPY_SUCCESS BIT(4) -#define STATUS_COPY_FAIL BIT(5) -#define STATUS_IRQ_RAISED BIT(6) -#define STATUS_SRC_ADDR_INVALID BIT(7) -#define STATUS_DST_ADDR_INVALID BIT(8) - -#define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0xc
drivers/misc/pci_endpoint_test.c line 47
Quoted 10 lines
drivers/misc/pci_endpoint_test.c +10
-0+#define DRV_MODULE_NAME "pci-endpoint-test" + +#define IRQ_TYPE_LEGACY 0 +#define IRQ_TYPE_MSI 1 + +#define PCI_ENDPOINT_TEST_MAGIC 0x0 + +#define PCI_ENDPOINT_TEST_COMMAND 0x4 +#define COMMAND_RAISE_LEGACY_IRQ BIT(0) +#define COMMAND_RAISE_MSI_IRQ BIT(1)
Maybe you can add a comment here that BIT(2) is reserved for MSIX support
Quoted 17 lines
drivers/misc/pci_endpoint_test.c +16
-0+#define COMMAND_READ BIT(3) +#define COMMAND_WRITE BIT(4) +#define COMMAND_COPY BIT(5) + +#define PCI_ENDPOINT_TEST_STATUS 0x8 +#define STATUS_READ_SUCCESS BIT(0) +#define STATUS_READ_FAIL BIT(1) +#define STATUS_WRITE_SUCCESS BIT(2) +#define STATUS_WRITE_FAIL BIT(3) +#define STATUS_COPY_SUCCESS BIT(4) +#define STATUS_COPY_FAIL BIT(5) +#define STATUS_IRQ_RAISED BIT(6) +#define STATUS_SRC_ADDR_INVALID BIT(7) +#define STATUS_DST_ADDR_INVALID BIT(8) + +#define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0x0c#define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR 0x10
drivers/misc/pci_endpoint_test.c line 72
Quoted 10 lines
drivers/misc/pci_endpoint_test.c +4
-2#define PCI_ENDPOINT_TEST_LOWER_DST_ADDR 0x14#define PCI_ENDPOINT_TEST_UPPER_DST_ADDR 0x18 -#define PCI_ENDPOINT_TEST_SIZE 0x1c -#define PCI_ENDPOINT_TEST_CHECKSUM 0x20 +#define PCI_ENDPOINT_TEST_SIZE 0x1c +#define PCI_ENDPOINT_TEST_CHECKSUM 0x20 + +#define PCI_ENDPOINT_TEST_IRQ_TYPE 0x24
Is this not redundant? COMMAND_RAISE_LEGACY_IRQ, COMMAND_RAISE_MSI_IRQ already indicates the irq type to be used.
drivers/misc/pci_endpoint_test.c static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) · line 188
Quoted 11 lines
drivers/misc/pci_endpoint_test.c +4
-0+#define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28static DEFINE_IDA (pci_endpoint_test_ida);@@ -179,6 +183,9 @@ static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) {u32 val; +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , +IRQ_TYPE_LEGACY ); +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_NUMBER ,0 );
Not sure if the above writes are really required.
drivers/misc/pci_endpoint_test.c static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) · line 200
Quoted 9 lines
drivers/misc/pci_endpoint_test.c +1
-1pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_COMMAND ,COMMAND_RAISE_LEGACY_IRQ ); val = wait_for_completion_timeout(&test->irq_raised,@@ -190,20 +197,22 @@ static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) }static bool pci_endpoint_test_msi_irq (struct pci_endpoint_test *test, -u8 msi_num) +u8 irq_num)
why do you want to rename this?
Thanks
Kishon
Re: [PATCH v4 06/10] pci-epf-test/pci_endpoint_test: Cleanup PCI_ENDPOINT_TEST memspace
Hi,
Quoted 56 lines · Kishon Vijay Abraham I
Hi,
Quoted 53 lines · Gustavo Pimentel
Cleanup
PCI_ENDPOINT_TESTmemspace (by moving the interrupt number away from command section).Signed-off-by Gustavo Pimentel <[email protected]>---
Changev2->v3:
- New patch file created base on the previous patch
"misc:pci_endpoint_test: Add MSI-X support" patch file following Kishon's suggestion.
Changev3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.drivers/misc/pci_endpoint_test.c | 84 ++++++++++++++++----------- drivers/pci/endpoint/functions/pci-epf-test.c | 60 ++++++++++++------- 2 files changed, 91 insertions(+), 53 deletions(-)drivers/misc/pci_endpoint_test.c +4
-25@@ -35,38 +35,42 @@#include <uapi/linux/pcitest.h> -#define DRV_MODULE_NAME "pci-endpoint-test" - -#define PCI_ENDPOINT_TEST_MAGIC 0x0 - -#define PCI_ENDPOINT_TEST_COMMAND 0x4 -#define COMMAND_RAISE_LEGACY_IRQ BIT(0) -#define COMMAND_RAISE_MSI_IRQ BIT(1) -#define MSI_NUMBER_SHIFT 2 -/* 6 bits for MSI number */ -#define COMMAND_READ BIT(8) -#define COMMAND_WRITE BIT(9) -#define COMMAND_COPY BIT(10) - -#define PCI_ENDPOINT_TEST_STATUS 0x8 -#define STATUS_READ_SUCCESS BIT(0) -#define STATUS_READ_FAIL BIT(1) -#define STATUS_WRITE_SUCCESS BIT(2) -#define STATUS_WRITE_FAIL BIT(3) -#define STATUS_COPY_SUCCESS BIT(4) -#define STATUS_COPY_FAIL BIT(5) -#define STATUS_IRQ_RAISED BIT(6) -#define STATUS_SRC_ADDR_INVALID BIT(7) -#define STATUS_DST_ADDR_INVALID BIT(8) - -#define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0xc +#define DRV_MODULE_NAME "pci-endpoint-test" + +#define IRQ_TYPE_LEGACY 0 +#define IRQ_TYPE_MSI 1
Quoted 8 lines
drivers/misc/pci_endpoint_test.c line 47
Quoted 6 lines
drivers/misc/pci_endpoint_test.c +6
-0+ +#define PCI_ENDPOINT_TEST_MAGIC 0x0 + +#define PCI_ENDPOINT_TEST_COMMAND 0x4 +#define COMMAND_RAISE_LEGACY_IRQ BIT(0) +#define COMMAND_RAISE_MSI_IRQ BIT(1)Maybe you can add a comment here that BIT(2) is reserved for MSIX support
Sure.
Quoted 21 lines
Quoted 21 lines
drivers/misc/pci_endpoint_test.c +16
-0+#define COMMAND_READ BIT(3) +#define COMMAND_WRITE BIT(4) +#define COMMAND_COPY BIT(5) + +#define PCI_ENDPOINT_TEST_STATUS 0x8 +#define STATUS_READ_SUCCESS BIT(0) +#define STATUS_READ_FAIL BIT(1) +#define STATUS_WRITE_SUCCESS BIT(2) +#define STATUS_WRITE_FAIL BIT(3) +#define STATUS_COPY_SUCCESS BIT(4) +#define STATUS_COPY_FAIL BIT(5) +#define STATUS_IRQ_RAISED BIT(6) +#define STATUS_SRC_ADDR_INVALID BIT(7) +#define STATUS_DST_ADDR_INVALID BIT(8) + +#define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0x0c#define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR 0x10#define PCI_ENDPOINT_TEST_LOWER_DST_ADDR 0x14#define PCI_ENDPOINT_TEST_UPPER_DST_ADDR 0x18
Quoted 9 lines
drivers/misc/pci_endpoint_test.c line 72
Quoted 6 lines
drivers/misc/pci_endpoint_test.c +4
-2-#define PCI_ENDPOINT_TEST_SIZE 0x1c -#define PCI_ENDPOINT_TEST_CHECKSUM 0x20 +#define PCI_ENDPOINT_TEST_SIZE 0x1c +#define PCI_ENDPOINT_TEST_CHECKSUM 0x20 + +#define PCI_ENDPOINT_TEST_IRQ_TYPE 0x24Is this not redundant?
COMMAND_RAISE_LEGACY_IRQ,COMMAND_RAISE_MSI_IRQalready indicates the irq type to be used.
In previous implementation the distinction between interrupt types was simpler, basically legacy *number* always set as zero and the MSI *number* always non-zero. However by introducing the MSI-X this simple mechanism is no longer valid, because the MSI-X *number* is also always non-zero like as MSI. Therefore is necessary to distinguish which interrupt type was been triggered (MSI or MSI-X) especially for the Write/Read/Copy tests.
Quoted 8 lines
Quoted 8 lines
drivers/misc/pci_endpoint_test.c +1
-0+#define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28static DEFINE_IDA (pci_endpoint_test_ida);@@ -179,6 +183,9 @@ static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) {u32 val;
Quoted 5 lines
drivers/misc/pci_endpoint_test.c static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) · line 188
Quoted 3 lines
drivers/misc/pci_endpoint_test.c +3
-0+pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , +IRQ_TYPE_LEGACY ); +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_NUMBER ,0 );Not sure if the above writes are really required.
Is not required, but I added those write for keeping the code coherency between pci_endpoint_test_legacy_irq() and pci_endpoint_test_msi_irq(), basically both functions write on the same registers. I think it doesn't cause any harm.
Quoted 11 lines
drivers/misc/pci_endpoint_test.c static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) · line 200
Quoted 9 lines
drivers/misc/pci_endpoint_test.c +1
-1pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_COMMAND ,COMMAND_RAISE_LEGACY_IRQ ); val = wait_for_completion_timeout(&test->irq_raised,@@ -190,20 +197,22 @@ static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) }static bool pci_endpoint_test_msi_irq (struct pci_endpoint_test *test, -u8 msi_num) +u8 irq_num)why do you want to rename this?
Initially this patch file contained the changes related to MSI-X support and by that time I had changed the name of this variable so that its name had a broader meaning that contemplated these two types. Now that I see this, I think the original name may also be valid, I will revert this name change.
Regards,
Gustavo
Quoted 4 lines
Thanks
Kishon
PATCH v4 7/10 pci-epf-test/pci_endpoint_test: Use irq_type module parameter
In reply to Gustavo PimentelAdd new driver parameter to allow interruption type selection.
---
Change v2->v3:
- New patch file created base on the previous patch
"misc: pci_endpoint_test: Add MSI-X support" patch file following Kishon's suggestion.
Change v3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.
drivers/misc/pci_endpoint_test.c | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-)
drivers/misc/pci_endpoint_test.c +21 -9
@@ -81,6 +81,10 @@ static bool no_msi;module_param (no_msi, bool,0444 );MODULE_PARM_DESC (no_msi,"Disable MSI interrupt in pci_endpoint_test" ); +static int irq_type =IRQ_TYPE_MSI ; +module_param (irq_type, int,0444 ); +MODULE_PARM_DESC (irq_type,"IRQ mode selection in pci_endpoint_test (0 - Legacy, 1 - MSI)" ); +enum pci_barno {BAR_0 ,BAR_1 ,
@@ -107,7 +111,7 @@ struct pci_endpoint_test {struct pci_endpoint_test_data {enum pci_barno test_reg_bar;size_t alignment; -bool no_msi; +int irq_type; }; static inline u32 pci_endpoint_test_readl(struct pci_endpoint_test *test,
@@ -290,8 +294,7 @@ static bool pci_endpoint_test_copy(struct pci_endpoint_test *test, size_t size)pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_SIZE , size); -pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , - no_msi ?IRQ_TYPE_LEGACY :IRQ_TYPE_MSI ); +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , irq_type);pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_NUMBER ,1 );pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_COMMAND ,COMMAND_COPY );
@@ -360,8 +363,7 @@ static bool pci_endpoint_test_write(struct pci_endpoint_test *test, size_t size)pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_SIZE , size); -pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , - no_msi ?IRQ_TYPE_LEGACY :IRQ_TYPE_MSI ); +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , irq_type);pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_NUMBER ,1 );pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_COMMAND ,COMMAND_READ );
@@ -418,8 +420,7 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test, size_t size)pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_SIZE , size); -pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , - no_msi ?IRQ_TYPE_LEGACY :IRQ_TYPE_MSI ); +pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , irq_type);pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_NUMBER ,1 );pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_COMMAND ,COMMAND_WRITE );
@@ -504,11 +505,14 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, test->alignment =0 ; test->pdev = pdev; +if (no_msi) + irq_type =IRQ_TYPE_LEGACY ; + data = (struct pci_endpoint_test_data *)ent->driver_data;if (data) { test_reg_bar = data->test_reg_bar; test->alignment = data->alignment; - no_msi = data->no_msi; + irq_type = data->irq_type; }init_completion (&test->irq_raised);
@@ -528,13 +532,21 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,pci_set_master (pdev); -if (!no_msi) { +switch (irq_type) { +case IRQ_TYPE_LEGACY : + irq =0 ; +break ; +case IRQ_TYPE_MSI : irq =pci_alloc_irq_vectors (pdev,1 ,32 ,PCI_IRQ_MSI );if (irq <0 )dev_err (dev,"Failed to get MSI interrupts\n" ); test->num_irqs = irq; +break ; +default : +dev_err (dev,"Invalid IRQ type selected\n" ); } + err =devm_request_irq (dev, pdev->irq, pci_endpoint_test_irqhandler,IRQF_SHARED ,DRV_MODULE_NAME , test);if (err) {
Signature · 1 line
2.7.4
PATCH v4 8/10 pci-epf-test/pci_endpoint_test: Add MSI-X support
In reply to Gustavo PimentelAdd MSI-X support and update driver documentation accordingly.
---
Change v2->v3:
- New patch file created base on the previous patch
"misc: pci_endpoint_test: Add MSI-X support" patch file following Kishon's suggestion.
Change v3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.
Documentation/misc-devices/pci-endpoint-test.txt | 3 +++ drivers/misc/pci_endpoint_test.c | 28 ++++++++++++++++++------ drivers/pci/endpoint/functions/pci-epf-test.c | 23 ++++++++++++++++++- 3 files changed, 46 insertions(+), 8 deletions(-)
Documentation/misc-devices/pci-endpoint-test.txt +3 -0
@@ -10,6 +10,7 @@ The PCI driver for the test device performs the following tests *) verifying addresses programmed in BAR *) raise legacy IRQ *) raise MSI IRQ + *) raise MSI-X IRQ *) read data *) write data *) copy data
@@ -25,6 +26,8 @@ ioctl PCITEST_LEGACY_IRQ: Tests legacy IRQ PCITEST_MSI: Tests message signalled interrupts. The MSI number to be tested should be passed as argument. + PCITEST_MSIX: Tests message signalled interrupts. The MSI-X number + to be tested should be passed as argument. PCITEST_WRITE: Perform write tests. The size of the buffer should be passed as argument. PCITEST_READ: Perform read tests. The size of the buffer should be passed
drivers/misc/pci_endpoint_test.c +21 -7
@@ -39,12 +39,14 @@#define IRQ_TYPE_LEGACY 0#define IRQ_TYPE_MSI 1 +#define IRQ_TYPE_MSIX 2#define PCI_ENDPOINT_TEST_MAGIC 0x0#define PCI_ENDPOINT_TEST_COMMAND 0x4#define COMMAND_RAISE_LEGACY_IRQ BIT(0)#define COMMAND_RAISE_MSI_IRQ BIT(1) +#define COMMAND_RAISE_MSIX_IRQ BIT(2)#define COMMAND_READ BIT(3)#define COMMAND_WRITE BIT(4)#define COMMAND_COPY BIT(5)
@@ -83,7 +85,7 @@ MODULE_PARM_DESC(no_msi, "Disable MSI interrupt in pci_endpoint_test");static int irq_type =IRQ_TYPE_MSI ;module_param (irq_type, int,0444 ); -MODULE_PARM_DESC (irq_type,"IRQ mode selection in pci_endpoint_test (0 - Legacy, 1 - MSI)" ); +MODULE_PARM_DESC (irq_type,"IRQ mode selection in pci_endpoint_test (0 - Legacy, 1 - MSI, 2 - MSI-X)" );enum pci_barno {BAR_0 ,
@@ -201,16 +203,18 @@ static bool pci_endpoint_test_legacy_irq(struct pci_endpoint_test *test) }static bool pci_endpoint_test_msi_irq (struct pci_endpoint_test *test, -u8 irq_num) +u16 irq_num,bool msix) {u32 val;struct pci_dev *pdev = test->pdev;pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_TYPE , -IRQ_TYPE_MSI ); + msix == false ?IRQ_TYPE_MSI : +IRQ_TYPE_MSIX );pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_IRQ_NUMBER , irq_num);pci_endpoint_test_writel (test,PCI_ENDPOINT_TEST_COMMAND , -COMMAND_RAISE_MSI_IRQ ); + msix == false ?COMMAND_RAISE_MSI_IRQ : +COMMAND_RAISE_MSIX_IRQ ); val =wait_for_completion_timeout (&test->irq_raised,msecs_to_jiffies (1000 ));if (!val)
@@ -455,7 +459,8 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, ret =pci_endpoint_test_legacy_irq (test);break ;case PCITEST_MSI : - ret =pci_endpoint_test_msi_irq (test, arg); +case PCITEST_MSIX : + ret =pci_endpoint_test_msi_irq (test, arg, cmd ==PCITEST_MSIX );break ;case PCITEST_WRITE : ret =pci_endpoint_test_write (test, arg);
@@ -542,6 +547,12 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev,dev_err (dev,"Failed to get MSI interrupts\n" ); test->num_irqs = irq;break ; +case IRQ_TYPE_MSIX : + irq =pci_alloc_irq_vectors (pdev,1 ,2048 ,PCI_IRQ_MSIX ); +if (irq <0 ) +dev_err (dev,"Failed to get MSI-X interrupts\n" ); + test->num_irqs = irq; +break ;default :dev_err (dev,"Invalid IRQ type selected\n" ); }
@@ -559,8 +570,9 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, pci_endpoint_test_irqhandler, IRQF_SHARED, DRV_MODULE_NAME, test);if (err) -dev_err (dev,"failed to request IRQ %d for MSI %d\n" , -pci_irq_vector (pdev, i), i +1 ); +dev_err (dev,"Failed to request IRQ %d for MSI%s %d\n" , +pci_irq_vector (pdev, i), + irq_type ==IRQ_TYPE_MSIX ?"-X" :"" , i +1 ); }for (bar =BAR_0 ; bar <=BAR_5 ; bar++) {
@@ -626,6 +638,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, err_disable_msi:pci_disable_msi (pdev); +pci_disable_msix (pdev);pci_release_regions (pdev); err_disable_pdev:
@@ -657,6 +670,7 @@ static void pci_endpoint_test_remove(struct pci_dev *pdev)for (i =0 ; i < test->num_irqs; i++)devm_free_irq (&pdev->dev,pci_irq_vector (pdev, i), test);pci_disable_msi (pdev); +pci_disable_msix (pdev);pci_release_regions (pdev);pci_disable_device (pdev); }
drivers/pci/endpoint/functions/pci-epf-test.c +22 -1
@@ -20,9 +20,11 @@#define IRQ_TYPE_LEGACY 0#define IRQ_TYPE_MSI 1 +#define IRQ_TYPE_MSIX 2#define COMMAND_RAISE_LEGACY_IRQ BIT(0)#define COMMAND_RAISE_MSI_IRQ BIT(1) +#define COMMAND_RAISE_MSIX_IRQ BIT(2)#define COMMAND_READ BIT(3)#define COMMAND_WRITE BIT(4)#define COMMAND_COPY BIT(5)
@@ -265,6 +267,9 @@ static void pci_epf_test_raise_irq(struct pci_epf_test *epf_test, u8 irq_type,case IRQ_TYPE_MSI :pci_epc_raise_irq (epc, epf->func_no,PCI_EPC_IRQ_MSI , irq);break ; +case IRQ_TYPE_MSIX : +pci_epc_raise_irq (epc, epf->func_no,PCI_EPC_IRQ_MSIX , irq); +break ;default :dev_err (dev,"Failed to raise IRQ, unknown type\n" );break ;
@@ -291,7 +296,7 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) reg->command =0 ; reg->status =0 ; -if (reg->irq_type >IRQ_TYPE_MSI ) { +if (reg->irq_type >IRQ_TYPE_MSIX ) {dev_err (dev,"Failed to detect IRQ type\n" ); goto reset_handler; }
@@ -345,6 +350,16 @@ static void pci_epf_test_cmd_handler(struct work_struct *work) goto reset_handler; } +if (command &COMMAND_RAISE_MSIX_IRQ ) { + count =pci_epc_get_msix (epc, epf->func_no); +if (reg->irq_number > count || count <=0 ) + goto reset_handler; + reg->status =STATUS_IRQ_RAISED ; +pci_epc_raise_irq (epc, epf->func_no,PCI_EPC_IRQ_MSIX , + reg->irq_number); + goto reset_handler; + } + reset_handler:queue_delayed_work (kpcitest_workqueue, &epf_test->cmd_handler,msecs_to_jiffies (1 ));
@@ -480,6 +495,12 @@ static int pci_epf_test_bind(struct pci_epf *epf)return ret; } + ret =pci_epc_set_msix (epc, epf->func_no, epf->msix_interrupts); +if (ret) { +dev_err (dev,"MSI-X configuration failed\n" ); +return ret; + } +if (!epf_test->linkup_notifier)queue_work (kpcitest_workqueue, &epf_test->cmd_handler.work);
Signature · 1 line
2.7.4
PATCH v4 9/10 pci_endpoint_test: Add 2 ioctl commands
In reply to Gustavo PimentelAdd MSI-X support and update driver documentation accordingly.
Add 2 new IOCTL commands:
- Allow to reconfigure driver IRQ type in runtime.
- Allow to retrieve current driver IRQ type configured.
---
Change v2->v3:
- New patch file created base on the previous patch
"misc: pci_endpoint_test: Add MSI-X support" patch file following Kishon's suggestion.
Change v3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.
Documentation/misc-devices/pci-endpoint-test.txt | 3 + drivers/misc/pci_endpoint_test.c | 177 +++++++++++++++++------ 2 files changed, 132 insertions(+), 48 deletions(-)
Documentation/misc-devices/pci-endpoint-test.txt +3 -0
@@ -28,6 +28,9 @@ ioctl to be tested should be passed as argument. PCITEST_MSIX: Tests message signalled interrupts. The MSI-X number to be tested should be passed as argument. + PCITEST_SET_IRQTYPE: Changes driver IRQ type configuration. The IRQ type + should be passed as argument (0: Legacy, 1:MSI, 2:MSI-X). + PCITEST_GET_IRQTYPE: Gets driver IRQ type configuration. PCITEST_WRITE: Perform write tests. The size of the buffer should be passed as argument. PCITEST_READ: Perform read tests. The size of the buffer should be passed
drivers/misc/pci_endpoint_test.c +129 -48
228 lines not on this page · raw message
Signature · 1 line
2.7.4
Re: [PATCH v4 09/10] pci_endpoint_test: Add 2 ioctl commands
Hi,
Quoted 165 lines · Gustavo Pimentel
Add MSI-X support and update driver documentation accordingly.
Add 2 new IOCTL commands:
- Allow to reconfigure driver IRQ type in runtime.
- Allow to retrieve current driver IRQ type configured.Signed-off-by Gustavo Pimentel <[email protected]>---
Changev2->v3:
- New patch file created base on the previous patch
"misc:pci_endpoint_test: Add MSI-X support" patch file following Kishon's suggestion.
Changev3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.Documentation/misc-devices/pci-endpoint-test.txt | 3 + drivers/misc/pci_endpoint_test.c | 177 +++++++++++++++++------ 2 files changed, 132 insertions(+), 48 deletions(-)Documentation/misc-devices/pci-endpoint-test.txt +3
-0@@ -28,6 +28,9 @@ ioctl to be tested should be passed as argument. PCITEST_MSIX: Tests message signalled interrupts. The MSI-X number to be tested should be passed as argument. + PCITEST_SET_IRQTYPE: Changes driver IRQ type configuration. The IRQ type + should be passed as argument (0: Legacy, 1:MSI, 2:MSI-X). + PCITEST_GET_IRQTYPE: Gets driver IRQ type configuration. PCITEST_WRITE: Perform write tests. The size of the buffer should be passed as argument. PCITEST_READ: Perform read tests. The size of the buffer should be passeddrivers/misc/pci_endpoint_test.c +113
-0@@ -157,6 +157,87 @@ static irqreturn_t pci_endpoint_test_irqhandler(int irq, void *dev_id)return IRQ_HANDLED ; } +static void pci_endpoint_test_free_irq_vectors (struct pci_endpoint_test *test) +{ +int i; +struct pci_dev *pdev = test->pdev; +struct device *dev = &pdev->dev; + +for (i =0 ; i < test->num_irqs; i++) +devm_free_irq (dev,pci_irq_vector (pdev, i), test); + + test->num_irqs =0 ; +} + +static bool pci_endpoint_test_alloc_irq_vectors (struct pci_endpoint_test *test) +{ +int irq =-1 ; +struct pci_dev *pdev = test->pdev; +struct device *dev = &pdev->dev; +bool res = true; + +switch (irq_type) { +case IRQ_TYPE_LEGACY : + irq =0 ; +break ; +case IRQ_TYPE_MSI : + irq =pci_alloc_irq_vectors (pdev,1 ,32 ,PCI_IRQ_MSI ); +if (irq <0 ) +dev_err (dev,"Failed to get MSI interrupts\n" ); +break ; +case IRQ_TYPE_MSIX : + irq =pci_alloc_irq_vectors (pdev,1 ,2048 ,PCI_IRQ_MSIX ); +if (irq <0 ) +dev_err (dev,"Failed to get MSI-X interrupts\n" ); +break ; +default : +dev_err (dev,"Invalid IRQ type selected\n" ); + } + +if (irq <0 ) { + irq =0 ; + res = false; + } + test->num_irqs = irq; + +return res; +} + +static void pci_endpoint_test_release_irq (struct pci_endpoint_test *test) +{ +struct pci_dev *pdev = test->pdev; + +pci_disable_msi (pdev); +pci_disable_msix (pdev); +} + +static bool pci_endpoint_test_request_irq (struct pci_endpoint_test *test) +{ +int i; +int err; +struct pci_dev *pdev = test->pdev; +struct device *dev = &pdev->dev; + + err =devm_request_irq (dev, pdev->irq, pci_endpoint_test_irqhandler, +IRQF_SHARED ,DRV_MODULE_NAME , test); +if (err) { +dev_err (dev,"Failed to request IRQ %d\n" , pdev->irq); +return false; + } + +for (i =1 ; i < test->num_irqs; i++) { + err =devm_request_irq (dev,pci_irq_vector (pdev, i), + pci_endpoint_test_irqhandler, +IRQF_SHARED ,DRV_MODULE_NAME , test); +if (err) +dev_err (dev,"Failed to request IRQ %d for MSI%s %d\n" , +pci_irq_vector (pdev, i), + irq_type ==IRQ_TYPE_MSIX ?"-X" :"" , i +1 ); + } + +return true; +} +static bool pci_endpoint_test_bar (struct pci_endpoint_test *test,enum pci_barno barno) {@@ -440,6 +521,38 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test, size_t size)return ret; } +static bool pci_endpoint_test_set_irq (struct pci_endpoint_test *test, +int req_irq_type) +{ +struct pci_dev *pdev = test->pdev; +struct device *dev = &pdev->dev; + +if (req_irq_type <IRQ_TYPE_LEGACY || req_irq_type >IRQ_TYPE_MSIX ) { +dev_err (dev,"Invalid IRQ type option\n" ); +return false; + } + +if (irq_type == req_irq_type) +return true; + + irq_type = req_irq_type; + +pci_endpoint_test_free_irq_vectors (test); +pci_endpoint_test_release_irq (test); + +if (!pci_endpoint_test_alloc_irq_vectors (test)) { +pci_endpoint_test_release_irq (test); +return false; + } + +if (!pci_endpoint_test_request_irq (test)) { +pci_endpoint_test_release_irq (test); +return false; + } + +return true; +} +static long pci_endpoint_test_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {
drivers/misc/pci_endpoint_test.c static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, · line 591
Quoted 8 lines
drivers/misc/pci_endpoint_test.c +5
-0@@ -471,6 +584,12 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,case PCITEST_COPY : ret =pci_endpoint_test_copy (test, arg);break ; +case PCITEST_SET_IRQTYPE : + ret =pci_endpoint_test_set_irq (test, arg); +break ; +case PCITEST_GET_IRQTYPE : + ret = irq_type;
Can't the set_irq be done as part of raise irq itself?
Thanks
Kishon
Re: [PATCH v4 09/10] pci_endpoint_test: Add 2 ioctl commands
Hi,
Quoted 170 lines · Kishon Vijay Abraham I
Hi,
Quoted 167 lines · Gustavo Pimentel
Add MSI-X support and update driver documentation accordingly.
Add 2 new IOCTL commands:
- Allow to reconfigure driver IRQ type in runtime.
- Allow to retrieve current driver IRQ type configured.Signed-off-by Gustavo Pimentel <[email protected]>---
Changev2->v3:
- New patch file created base on the previous patch
"misc:pci_endpoint_test: Add MSI-X support" patch file following Kishon's suggestion.
Changev3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.Documentation/misc-devices/pci-endpoint-test.txt | 3 + drivers/misc/pci_endpoint_test.c | 177 +++++++++++++++++------ 2 files changed, 132 insertions(+), 48 deletions(-)Documentation/misc-devices/pci-endpoint-test.txt +3
-0@@ -28,6 +28,9 @@ ioctl to be tested should be passed as argument. PCITEST_MSIX: Tests message signalled interrupts. The MSI-X number to be tested should be passed as argument. + PCITEST_SET_IRQTYPE: Changes driver IRQ type configuration. The IRQ type + should be passed as argument (0: Legacy, 1:MSI, 2:MSI-X). + PCITEST_GET_IRQTYPE: Gets driver IRQ type configuration. PCITEST_WRITE: Perform write tests. The size of the buffer should be passed as argument. PCITEST_READ: Perform read tests. The size of the buffer should be passeddrivers/misc/pci_endpoint_test.c +113
-0@@ -157,6 +157,87 @@ static irqreturn_t pci_endpoint_test_irqhandler(int irq, void *dev_id)return IRQ_HANDLED ; } +static void pci_endpoint_test_free_irq_vectors (struct pci_endpoint_test *test) +{ +int i; +struct pci_dev *pdev = test->pdev; +struct device *dev = &pdev->dev; + +for (i =0 ; i < test->num_irqs; i++) +devm_free_irq (dev,pci_irq_vector (pdev, i), test); + + test->num_irqs =0 ; +} + +static bool pci_endpoint_test_alloc_irq_vectors (struct pci_endpoint_test *test) +{ +int irq =-1 ; +struct pci_dev *pdev = test->pdev; +struct device *dev = &pdev->dev; +bool res = true; + +switch (irq_type) { +case IRQ_TYPE_LEGACY : + irq =0 ; +break ; +case IRQ_TYPE_MSI : + irq =pci_alloc_irq_vectors (pdev,1 ,32 ,PCI_IRQ_MSI ); +if (irq <0 ) +dev_err (dev,"Failed to get MSI interrupts\n" ); +break ; +case IRQ_TYPE_MSIX : + irq =pci_alloc_irq_vectors (pdev,1 ,2048 ,PCI_IRQ_MSIX ); +if (irq <0 ) +dev_err (dev,"Failed to get MSI-X interrupts\n" ); +break ; +default : +dev_err (dev,"Invalid IRQ type selected\n" ); + } + +if (irq <0 ) { + irq =0 ; + res = false; + } + test->num_irqs = irq; + +return res; +} + +static void pci_endpoint_test_release_irq (struct pci_endpoint_test *test) +{ +struct pci_dev *pdev = test->pdev; + +pci_disable_msi (pdev); +pci_disable_msix (pdev); +} + +static bool pci_endpoint_test_request_irq (struct pci_endpoint_test *test) +{ +int i; +int err; +struct pci_dev *pdev = test->pdev; +struct device *dev = &pdev->dev; + + err =devm_request_irq (dev, pdev->irq, pci_endpoint_test_irqhandler, +IRQF_SHARED ,DRV_MODULE_NAME , test); +if (err) { +dev_err (dev,"Failed to request IRQ %d\n" , pdev->irq); +return false; + } + +for (i =1 ; i < test->num_irqs; i++) { + err =devm_request_irq (dev,pci_irq_vector (pdev, i), + pci_endpoint_test_irqhandler, +IRQF_SHARED ,DRV_MODULE_NAME , test); +if (err) +dev_err (dev,"Failed to request IRQ %d for MSI%s %d\n" , +pci_irq_vector (pdev, i), + irq_type ==IRQ_TYPE_MSIX ?"-X" :"" , i +1 ); + } + +return true; +} +static bool pci_endpoint_test_bar (struct pci_endpoint_test *test,enum pci_barno barno) {@@ -440,6 +521,38 @@ static bool pci_endpoint_test_read(struct pci_endpoint_test *test, size_t size)return ret; } +static bool pci_endpoint_test_set_irq (struct pci_endpoint_test *test, +int req_irq_type) +{ +struct pci_dev *pdev = test->pdev; +struct device *dev = &pdev->dev; + +if (req_irq_type <IRQ_TYPE_LEGACY || req_irq_type >IRQ_TYPE_MSIX ) { +dev_err (dev,"Invalid IRQ type option\n" ); +return false; + } + +if (irq_type == req_irq_type) +return true; + + irq_type = req_irq_type; + +pci_endpoint_test_free_irq_vectors (test); +pci_endpoint_test_release_irq (test); + +if (!pci_endpoint_test_alloc_irq_vectors (test)) { +pci_endpoint_test_release_irq (test); +return false; + } + +if (!pci_endpoint_test_request_irq (test)) { +pci_endpoint_test_release_irq (test); +return false; + } + +return true; +} +static long pci_endpoint_test_ioctl (struct file *file,unsigned int cmd,unsigned long arg) {@@ -471,6 +584,12 @@ static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd,case PCITEST_COPY : ret =pci_endpoint_test_copy (test, arg);
Quoted 8 lines
drivers/misc/pci_endpoint_test.c static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, · line 591
Quoted 6 lines
drivers/misc/pci_endpoint_test.c +5
-0break ; +case PCITEST_SET_IRQTYPE : + ret =pci_endpoint_test_set_irq (test, arg); +break ; +case PCITEST_GET_IRQTYPE : + ret = irq_type;Can't the
set_irqbe done as part of raise irq itself?
That could work for the legacy/MSI/MSI-X tests, but not for the Write/Read/Copy tests... From what I saw, it was possible to perform Write/Read/Copy tests with either legacy or MSI on the previous version. I'm assuming that you don't wanna to lose that functionalities, right?
Regards,
Gustavo
Quoted 4 lines
Thanks
Kishon
PATCH v4 10/10 tools: PCI: Add MSI-X support
In reply to Gustavo PimentelAdd MSI-X support to pcitest tool.
Add 2 new IOCTL commands:
- Allow to reconfigure driver IRQ type in runtime.
- Allow to retrieve current driver IRQ type configured.
Modify pcitest.sh script to accommodate MSI-X interrupt tests.
---
Change v1->v2:
- Allow IRQ type driver reconfiguring in runtime, follwing Kishon's
suggestion.
Change v2->v3:
- Nothing changed, just to follow the patch set version.
Change v3->v4:
- Rebased to Lorenzo's master branch v4.18-rc1.
include/uapi/linux/pcitest.h | 3 +++ tools/pci/pcitest.c | 51 +++++++++++++++++++++++++++++++++++++++++++- tools/pci/pcitest.sh | 15 +++++++++++++ 3 files changed, 68 insertions(+), 1 deletion(-)
include/uapi/linux/pcitest.h +3 -0
@@ -16,5 +16,8 @@#define PCITEST_WRITE _IOW('P', 0x4, unsigned long)#define PCITEST_READ _IOW('P', 0x5, unsigned long)#define PCITEST_COPY _IOW('P', 0x6, unsigned long) +#define PCITEST_MSIX _IOW('P', 0x7, int) +#define PCITEST_SET_IRQTYPE _IOW('P', 0x8, int) +#define PCITEST_GET_IRQTYPE _IO('P', 0x9)#endif /* __UAPI_LINUX_PCITEST_H */
tools/pci/pcitest.c +50 -1
93 lines not on this page · raw message
tools/pci/pcitest.sh +15 -0
@@ -16,7 +16,10 @@ echo echo "Interrupt tests" echo +pcitest -i 0 pcitest -l + +pcitest -i 1 msi=1 while [ $msi -lt 33 ]
@@ -26,9 +29,21 @@ do done echo +pcitest -i 2 +msix=1 + +while [ $msix -lt 2049 ] +do + pcitest -x $msix + msix=`expr $msix + 1` +done +echo + echo "Read Tests" echo +pcitest -i 1 + pcitest -r -s 1 pcitest -r -s 1024 pcitest -r -s 1025
Signature · 1 line
2.7.4