PCI: qcom: Fix higher MSI vectors handling
Subsystems (7)
v7 cover PCI: qcom: Fix higher MSI vectors handling
I have replied with my Tested-by to the patch at [2], which has landed in the linux-next as the commit 20f1bfb8dd62 ("PCI: qcom:
Add support for handling MSIs from 8 endpoints"). However lately I noticed that during the tests I still had 'pcie_pme=nomsi', so the device was not forced to use higher MSI vectors.
After removing this option I noticed that hight MSI vectors are not delivered on tested platforms. After additional research I stumbled upon a patch in msm-4.14 ([1]), which describes that each group of MSI vectors is mapped to the separate interrupt. Implement corresponding mapping.
Since we can not expect that other platforms will use multi-IRQ scheme for MSI mapping (e.g. iMX and Tegra map all 256 MSI interrupts to single IRQ), it's support is implemented directly in pcie-qcom rather than in the core driver.
The first patch in the series is a revert of [2] (landed in pci-next). Either both patches should be applied or both should be dropped.
Patchseries dependecies: [3] (for the schema change).
Changes since v6:
- Fix indentation of the arguments as requested by Stanimir
Changes since v5:
- Fixed commit subject and in-comment code according to Bjorn's suggestion,
- Changed variable idx to i to follow dw_handle_msi_irq() style.
Changes since v4:
- Fix the minItems/maxItems properties in the YAML schema.
Changes since v3:
- Reimplement MSI handling scheme in the Qualcomm host controller driver.
Changes since v2:
- Fix and rephrase commit message for patch 2.
Changes since v1:
- Split a huge patch into three patches as suggested by Bjorn Helgaas
- snps,dw-pcie removal is now part of [3]
[1] https://git.codelinaro.org/clo/la/kernel/msm-4.14/-/commit/671a3d5f129f4bfe477152292ada2194c8440d22
[2] https://lore.kernel.org/linux-arm-msm/[email protected]/
[3] https://lore.kernel.org/linux-arm-msm/[email protected]/
Dmitry Baryshkov (7):
PCI: qcom: Revert "PCI: qcom: Add support for handling MSIs from 8
endpoints"
PCI: dwc: Correct msi_irq condition in dw_pcie_free_msi()
PCI: dwc: Add msi_host_deinit callback
PCI: dwc: Export several functions useful for MSI implentations
PCI: qcom: Handle MSIs routed to multiple GIC interrupts
dt-bindings: PCI: qcom: Support additional MSI interrupts
arm64: dts: qcom: sm8250: provide additional MSI interrupts
.../devicetree/bindings/pci/qcom,pcie.yaml | 45 +++++- arch/arm64/boot/dts/qcom/sm8250.dtsi | 11 +- .../pci/controller/dwc/pcie-designware-host.c | 72 +++++---- drivers/pci/controller/dwc/pcie-designware.h | 12 ++ drivers/pci/controller/dwc/pcie-qcom.c | 138 +++++++++++++++++- 5 files changed, 246 insertions(+), 32 deletions(-)
Signature · 1 line
2.35.1
PATCH v7 1/7 PCI: qcom: Revert "PCI: qcom: Add support for handling MSIs from 8 endpoints"
I have replied with my Tested-by to the patch at [2], which has landed in the linux-next as the commit 20f1bfb8dd62 ("PCI: qcom:
Add support for handling MSIs from 8 endpoints"). However lately I noticed that during the tests I still had 'pcie_pme=nomsi', so the device was not forced to use higher MSI vectors.
After removing this option I noticed that hight MSI vectors are not delivered on tested platforms. Additional research pointed to a patch in msm-4.14 ([1]), which describes that each group of MSI vectors is mapped to the separate interrupt.
Without these changes specifying num_verctors can lead to missing MSI interrupts and thus to devices malfunction.
--- drivers/pci/controller/dwc/pcie-qcom.c | 1 - 1 file changed, 1 deletion(-)
drivers/pci/controller/dwc/pcie-qcom.c +0 -1
@@ -1593,7 +1593,6 @@ static int qcom_pcie_probe(struct platform_device *pdev) pci->dev = dev; pci->ops = &dw_pcie_ops; pp = &pci->pp; - pp->num_vectors =MAX_MSI_IRQS ; pcie->pci = pci;
Signature · 1 line
2.35.1
Re: [PATCH v7 1/7] PCI: qcom: Revert "PCI: qcom: Add support for handling MSIs from 8 endpoints"
Quoted 7 lines · Dmitry Baryshkov
I have replied with my Tested-by to the patch at [2], which has landed in the linux-next as the commit
20f1bfb8dd62("PCI: qcom:
Add support for handling MSIs from 8 endpoints"). However lately I noticed that during the tests I still had 'pcie_pme=nomsi', so the device was not forced to use higher MSI vectors.After removing this option I noticed that hight MSI vectors are not
s/hight/high/
Quoted 5 lines
delivered on tested platforms. Additional research pointed to a patch in msm-4.14 ([1]), which describes that each group of MSI vectors is mapped to the separate interrupt.
Without these changes specifying
num_verctorscan lead to missing MSI
s/num_verctors/num_vectors/
Quoted 7 lines
interrupts and thus to devices malfunction.
Fixes 20f1bfb8dd62 ("PCI: qcom: Add support for handling MSIs from 8 endpoints")Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/pci/controller/dwc/pcie-qcom.c | 1 - 1 file changed, 1 deletion(-)
PATCH v7 2/7 PCI: dwc: Correct msi_irq condition in dw_pcie_free_msi()
In reply to Dmitry BaryshkovThe subdrivers pass -ESOMETHING if they do not want the core to touch MSI IRQ. dw_pcie_host_init() also checks if (msi_irq > 0) rather than just if (msi_irq). So let's make dw_pcie_free_msi() also check that msi_irq is greater than zero.
--- drivers/pci/controller/dwc/pcie-designware-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-designware-host.c +1 -1
@@ -257,7 +257,7 @@ int dw_pcie_allocate_domains(struct pcie_port *pp)static void dw_pcie_free_msi (struct pcie_port *pp) { -if (pp->msi_irq) +if (pp->msi_irq >0 )irq_set_chained_handler_and_data (pp->msi_irq,NULL ,NULL );irq_domain_remove (pp->msi_domain);
Signature · 1 line
2.35.1
Re: [PATCH v7 2/7] PCI: dwc: Correct msi_irq condition in dw_pcie_free_msi()
Quoted 9 lines · Dmitry Baryshkov
The subdrivers pass
-ESOMETHINGif they do not want the core to touch MSI IRQ.dw_pcie_host_init()also checks if (msi_irq> 0) rather than just if (msi_irq). So let's makedw_pcie_free_msi()also check thatmsi_irqis greater than zero.Signed-off-by Dmitry Baryshkov <[email protected]>--- drivers/pci/controller/dwc/pcie-designware-host.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
PATCH v7 3/7 PCI: dwc: Add msi_host_deinit callback
In reply to Dmitry BaryshkovAdd msi_host_deinit() callback as a counterpart to msi_host_init(). It will tear down MSI support in case host has to run host-specific ops.
--- drivers/pci/controller/dwc/pcie-designware-host.c | 8 ++++++-- drivers/pci/controller/dwc/pcie-designware.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +6 -2
@@ -424,7 +424,9 @@ int dw_pcie_host_init(struct pcie_port *pp)return 0 ; err_free_msi: -if (pp->has_msi_ctrl) +if (pp->ops->msi_host_deinit) + pp->ops->msi_host_deinit (pp); +else if (pp->has_msi_ctrl)dw_pcie_free_msi (pp);return ret; }
@@ -434,7 +436,9 @@ void dw_pcie_host_deinit(struct pcie_port *pp) {pci_stop_root_bus (pp->bridge->bus);pci_remove_root_bus (pp->bridge->bus); -if (pp->has_msi_ctrl) +if (pp->ops->msi_host_deinit) + pp->ops->msi_host_deinit (pp); +else if (pp->has_msi_ctrl)dw_pcie_free_msi (pp); }EXPORT_SYMBOL_GPL (dw_pcie_host_deinit);
drivers/pci/controller/dwc/pcie-designware.h +1 -0
@@ -175,6 +175,7 @@ enum dw_pcie_device_mode {struct dw_pcie_host_ops {int (*host_init)(struct pcie_port *pp);int (*msi_host_init)(struct pcie_port *pp); +void (*msi_host_deinit)(struct pcie_port *pp); };struct pcie_port {
Signature · 1 line
2.35.1
PATCH v7 4/7 PCI: dwc: Export several functions useful for MSI implentations
In reply to Dmitry BaryshkovSupporting multiple MSI interrupts on Qualcomm hardware would benefit from having these functions being exported rather than static. Note that both designware and qcom driver can not be built as modules, so no need to use EXPORT_SYMBOL here.
--- .../pci/controller/dwc/pcie-designware-host.c | 62 ++++++++++++------- drivers/pci/controller/dwc/pcie-designware.h | 11 ++++ 2 files changed, 49 insertions(+), 24 deletions(-)
drivers/pci/controller/dwc/pcie-designware-host.c +38 -24
@@ -255,7 +255,39 @@ int dw_pcie_allocate_domains(struct pcie_port *pp)return 0 ; } -static void dw_pcie_free_msi (struct pcie_port *pp) +int dw_pcie_allocate_msi (struct pcie_port *pp) +{ +struct dw_pcie *pci =to_dw_pcie_from_pp (pp); +int ret; + + ret =dw_pcie_allocate_domains (pp); +if (ret) +return ret; + +if (pp->msi_irq >0 ) +irq_set_chained_handler_and_data (pp->msi_irq, + dw_chained_msi_isr, + pp); + + ret =dma_set_mask (pci->dev,DMA_BIT_MASK (32 )); +if (ret) +dev_warn (pci->dev,"Failed to set DMA mask to 32-bit. Devices with only 32-bit MSI support may not work properly\n" ); + + pp->msi_data =dma_map_single_attrs (pci->dev, &pp->msi_msg, +sizeof (pp->msi_msg), +DMA_FROM_DEVICE , +DMA_ATTR_SKIP_CPU_SYNC ); + ret =dma_mapping_error (pci->dev, pp->msi_data); +if (ret) { +dev_err (pci->dev,"Failed to map MSI data\n" ); + pp->msi_data =0 ; +return ret; + } + +return 0 ; +} + +void dw_pcie_free_msi (struct pcie_port *pp) {if (pp->msi_irq >0 )irq_set_chained_handler_and_data (pp->msi_irq,NULL ,NULL );
@@ -357,6 +389,9 @@ int dw_pcie_host_init(struct pcie_port *pp)return -EINVAL ; } +/* this can be overridden by msi_host_init() if necessary */ + pp->msi_irq_chip = &dw_pci_msi_bottom_irq_chip; +if (pp->ops->msi_host_init) { ret = pp->ops->msi_host_init (pp);if (ret <0 )
@@ -377,30 +412,9 @@ int dw_pcie_host_init(struct pcie_port *pp) } } - pp->msi_irq_chip = &dw_pci_msi_bottom_irq_chip; - - ret =dw_pcie_allocate_domains (pp); -if (ret) + ret =dw_pcie_allocate_msi (pp); +if (ret <0 )return ret; - -if (pp->msi_irq >0 ) -irq_set_chained_handler_and_data (pp->msi_irq, - dw_chained_msi_isr, - pp); - - ret =dma_set_mask (pci->dev,DMA_BIT_MASK (32 )); -if (ret) -dev_warn (pci->dev,"Failed to set DMA mask to 32-bit. Devices with only 32-bit MSI support may not work properly\n" ); - - pp->msi_data =dma_map_single_attrs (pci->dev, &pp->msi_msg, -sizeof (pp->msi_msg), -DMA_FROM_DEVICE , -DMA_ATTR_SKIP_CPU_SYNC ); -if (dma_mapping_error (pci->dev, pp->msi_data)) { -dev_err (pci->dev,"Failed to map MSI data\n" ); - pp->msi_data =0 ; - goto err_free_msi; - } } }
drivers/pci/controller/dwc/pcie-designware.h +11 -0
@@ -374,6 +374,8 @@ void dw_pcie_host_deinit(struct pcie_port *pp);int dw_pcie_allocate_domains (struct pcie_port *pp);void __iomem *dw_pcie_own_conf_map_bus (struct pci_bus *bus,unsigned int devfn,int where); +int dw_pcie_allocate_msi (struct pcie_port *pp); +void dw_pcie_free_msi (struct pcie_port *pp);#else static inline irqreturn_t dw_handle_msi_irq (struct pcie_port *pp) {
@@ -403,6 +405,15 @@ static inline void __iomem *dw_pcie_own_conf_map_bus(struct pci_bus *bus, {return NULL ; } + +static int dw_pcie_allocate_msi (struct pcie_port *pp) +{ +return -EINVAL ; +} + +static void dw_pcie_free_msi (struct pcie_port *pp) +{ +}#endif #ifdef CONFIG_PCIE_DW_EP
Signature · 1 line
2.35.1
PATCH v7 5/7 PCI: qcom: Handle MSIs routed to multiple GIC interrupts
In reply to Dmitry BaryshkovOn some of Qualcomm platforms each group of 32 MSI vectors is routed to the separate GIC interrupt. Thus to receive higher MSI vectors properly, add separate msi_host_init()/msi_host_deinit() handling additional host IRQs.
Note, that if DT doesn't list extra MSI interrupts, the driver will limit the amount of supported MSI vectors accordingly (to 32).
--- drivers/pci/controller/dwc/pcie-qcom.c | 137 ++++++++++++++++++++++++- 1 file changed, 136 insertions(+), 1 deletion(-)
drivers/pci/controller/dwc/pcie-qcom.c +136 -1
@@ -194,6 +194,7 @@ struct qcom_pcie_ops {struct qcom_pcie_cfg {const struct qcom_pcie_ops *ops; +unsigned int has_split_msi_irqs:1 ;unsigned int pipe_clk_need_muxing:1 ;unsigned int has_tbu_clk:1 ;unsigned int has_ddrss_sf_tbu_clk:1 ;
@@ -209,6 +210,7 @@ struct qcom_pcie {struct phy *phy;struct gpio_desc *reset;const struct qcom_pcie_cfg *cfg; +int msi_irqs[MAX_MSI_CTRLS ]; };#define to_qcom_pcie (x) dev_get_drvdata((x)->dev)
@@ -1387,6 +1389,124 @@ static int qcom_pcie_config_sid_sm8250(struct qcom_pcie *pcie)return 0 ; } +static void qcom_chained_msi_isr (struct irq_desc *desc) +{ +struct irq_chip *chip =irq_desc_get_chip (desc); +int irq =irq_desc_get_irq (desc); +struct pcie_port *pp; +int i, pos; +unsigned long val; +u32 status, num_ctrls; +struct dw_pcie *pci; +struct qcom_pcie *pcie; + +chained_irq_enter (chip, desc); + + pp =irq_desc_get_handler_data (desc); + pci =to_dw_pcie_from_pp (pp); + pcie =to_qcom_pcie (pci); + +/* +* Unlike generic dw_handle_msi_irq(), we can determine which group of +* MSIs triggered the IRQ, so process just that group. +*/ + num_ctrls = pp->num_vectors /MAX_MSI_IRQS_PER_CTRL ; + +for (i =0 ; i < num_ctrls; i++) { +if (pcie->msi_irqs[i] == irq) +break ; + } + +if (WARN_ON_ONCE (unlikely (i == num_ctrls))) + goto out; + + status =dw_pcie_readl_dbi (pci,PCIE_MSI_INTR0_STATUS + + (i *MSI_REG_CTRL_BLOCK_SIZE )); +if (!status) + goto out; + + val = status; + pos =0 ; +while ((pos =find_next_bit (&val,MAX_MSI_IRQS_PER_CTRL , + pos)) !=MAX_MSI_IRQS_PER_CTRL ) { +generic_handle_domain_irq (pp->irq_domain, + (i *MAX_MSI_IRQS_PER_CTRL ) + + pos); + pos++; + } + +out: +chained_irq_exit (chip, desc); +} + +static int qcom_pcie_msi_host_init (struct pcie_port *pp) +{ +struct dw_pcie *pci =to_dw_pcie_from_pp (pp); +struct qcom_pcie *pcie =to_qcom_pcie (pci); +struct platform_device *pdev =to_platform_device (pci->dev); +char irq_name[] ="msiXXX" ; +unsigned int ctrl, num_ctrls; +int msi_irq, ret; + + pp->msi_irq = -EINVAL ; + +/* +* We provide our own implementation of MSI init/deinit, but rely on +* using the rest of DWC MSI functionality. +*/ + pp->has_msi_ctrl = true; + + msi_irq =platform_get_irq_byname_optional (pdev,"msi" ); +if (msi_irq <0 ) { + msi_irq =platform_get_irq (pdev,0 ); +if (msi_irq <0 ) +return msi_irq; + } + + pcie->msi_irqs[0 ] = msi_irq; + +for (num_ctrls =1 ; num_ctrls <MAX_MSI_CTRLS ; num_ctrls++) { +snprintf (irq_name,sizeof (irq_name),"msi%d" , num_ctrls +1 ); + msi_irq =platform_get_irq_byname_optional (pdev, irq_name); +if (msi_irq == -ENXIO ) +break ; + + pcie->msi_irqs[num_ctrls] = msi_irq; + } + + pp->num_vectors = num_ctrls *MAX_MSI_IRQS_PER_CTRL ; +dev_info (&pdev->dev,"Using %d MSI vectors\n" , pp->num_vectors); +for (ctrl =0 ; ctrl < num_ctrls; ctrl++) + pp->irq_mask[ctrl] = ~0 ; + + ret =dw_pcie_allocate_msi (pp); +if (ret) +return ret; + +for (ctrl =0 ; ctrl < num_ctrls; ctrl++) +irq_set_chained_handler_and_data (pcie->msi_irqs[ctrl], + qcom_chained_msi_isr, + pp); + +return 0 ; +} + +static void qcom_pcie_msi_host_deinit (struct pcie_port *pp) +{ +struct dw_pcie *pci =to_dw_pcie_from_pp (pp); +struct qcom_pcie *pcie =to_qcom_pcie (pci); +unsigned int ctrl, num_ctrls; + + num_ctrls = pp->num_vectors /MAX_MSI_IRQS_PER_CTRL ; + +for (ctrl =0 ; ctrl < num_ctrls; ctrl++) +irq_set_chained_handler_and_data (pcie->msi_irqs[ctrl], +NULL , +NULL ); + +dw_pcie_free_msi (pp); +} +static int qcom_pcie_host_init (struct pcie_port *pp) {struct dw_pcie *pci =to_dw_pcie_from_pp (pp);
@@ -1435,6 +1555,12 @@ static const struct dw_pcie_host_ops qcom_pcie_dw_ops = { .host_init = qcom_pcie_host_init, }; +static const struct dw_pcie_host_ops qcom_pcie_msi_dw_ops = { + .host_init = qcom_pcie_host_init, + .msi_host_init = qcom_pcie_msi_host_init, + .msi_host_deinit = qcom_pcie_msi_host_deinit, +}; +/* Qcom IP rev.: 2.1.0 Synopsys IP rev.: 4.01a */ static const struct qcom_pcie_ops ops_2_1_0 = { .get_resources = qcom_pcie_get_resources_2_1_0,
@@ -1508,6 +1634,7 @@ static const struct qcom_pcie_cfg ipq8064_cfg = {static const struct qcom_pcie_cfg msm8996_cfg = { .ops = &ops_2_3_2, + .has_split_msi_irqs = true, };static const struct qcom_pcie_cfg ipq8074_cfg = {
@@ -1520,6 +1647,7 @@ static const struct qcom_pcie_cfg ipq4019_cfg = {static const struct qcom_pcie_cfg sdm845_cfg = { .ops = &ops_2_7_0, + .has_split_msi_irqs = true, .has_tbu_clk = true, };
@@ -1532,12 +1660,14 @@ static const struct qcom_pcie_cfg sm8150_cfg = {static const struct qcom_pcie_cfg sm8250_cfg = { .ops = &ops_1_9_0, + .has_split_msi_irqs = true, .has_tbu_clk = true, .has_ddrss_sf_tbu_clk = true, };static const struct qcom_pcie_cfg sm8450_pcie0_cfg = { .ops = &ops_1_9_0, + .has_split_msi_irqs = true, .has_ddrss_sf_tbu_clk = true, .pipe_clk_need_muxing = true, .has_aggre0_clk = true,
@@ -1546,6 +1676,7 @@ static const struct qcom_pcie_cfg sm8450_pcie0_cfg = {static const struct qcom_pcie_cfg sm8450_pcie1_cfg = { .ops = &ops_1_9_0, + .has_split_msi_irqs = true, .has_ddrss_sf_tbu_clk = true, .pipe_clk_need_muxing = true, .has_aggre1_clk = true,
@@ -1553,6 +1684,7 @@ static const struct qcom_pcie_cfg sm8450_pcie1_cfg = {static const struct qcom_pcie_cfg sc7280_cfg = { .ops = &ops_1_9_0, + .has_split_msi_irqs = true, .has_tbu_clk = true, .pipe_clk_need_muxing = true, };
@@ -1626,7 +1758,10 @@ static int qcom_pcie_probe(struct platform_device *pdev)if (ret) goto err_pm_runtime_put; - pp->ops = &qcom_pcie_dw_ops; +if (pcie->cfg->has_split_msi_irqs) + pp->ops = &qcom_pcie_msi_dw_ops; +else + pp->ops = &qcom_pcie_dw_ops; ret =phy_init (pcie->phy);if (ret) {
Signature · 1 line
2.35.1
Rob Herring
maintainerRe: [PATCH v7 5/7] PCI: qcom: Handle MSIs routed to multiple GIC interrupts
Quoted 4 lines · Dmitry Baryshkov
On some of Qualcomm platforms each group of 32 MSI vectors is routed to the separate GIC interrupt. Thus to receive higher MSI vectors properly, add separate msi_host_init()/msi_host_deinit() handling additional host IRQs.
msi_host_init() has 1 user (keystone) as it doesn't use the DWC MSI controller. But QCom does given the access to PCIE_MSI_INTR0_STATUS, so mutiple MSI IRQ outputs must have been added in newer versions of the DWC IP. If so, it's only a matter of time for another platform to do the same thing. Maybe someone from Synopsys could confirm?
Therefore this should all be handled in the DWC core. In general, I don't want to see more users nor more ops if we don't have to. Let's not create ops for what can be handled as data. AFAICT, this is just number of MSIs and # of MSIs per IRQ. It seems plausible another platform could do something similar and supporting it in the core code wouldn't negatively impact other platforms.
Rob
Re: [PATCH v7 5/7] PCI: qcom: Handle MSIs routed to multiple GIC interrupts
Quoted 11 lines · Rob Herring
Quoted 4 lines · Dmitry Baryshkov
On some of Qualcomm platforms each group of 32 MSI vectors is routed to the separate GIC interrupt. Thus to receive higher MSI vectors properly, add separate msi_host_init()/msi_host_deinit() handling additional host IRQs.
msi_host_init()has 1 user (keystone) as it doesn't use the DWC MSI controller. But QCom does given the access toPCIE_MSI_INTR0_STATUS, so mutiple MSI IRQ outputs must have been added in newer versions of the DWC IP. If so, it's only a matter of time for another platform to do the same thing. Maybe someone from Synopsys could confirm?
This is a valid question, and if you check, first iterations of this patchset had this in the dwc core ([1], [2]). Exactly for the reason this might be usable for other platforms.
Then I did some research for other platforms using DWC PCIe IP core. For example, both Tegra Xavier and iMX6 support up to 256 MSI vectors, they use DWC MSI IRQ controller. The iMX6 TRM explicitly describes using different MSI groups for different endpoints. The diagram shows 8 MSI IRQ signal lines. However in the end the signals from all groups are OR'ed to form a single host msi_ctrl_int. Thus currently I suppose that using multiple MSI IRQs is a peculiarity of Qualcomm platform.
Quoted 7 lines
Therefore this should all be handled in the DWC core. In general, I don't want to see more users nor more ops if we don't have to. Let's not create ops for what can be handled as data. AFAICT, this is just number of MSIs and # of MSIs per IRQ. It seems plausible another platform could do something similar and supporting it in the core code wouldn't negatively impact other platforms.
I wanted to balance adding additional ops vs complicating the core for other platforms. And I still suppose that platform specifics should go to the platform driver. However if you prefer [1] and [2], we can go back to that implementation.
[1]: https://lore.kernel.org/linux-arm-msm/[email protected]/[2]: https://lore.kernel.org/linux-arm-msm/[email protected]/
Signature · 2 lines
With best wishes Dmitry
Rob Herring
maintainerRe: [PATCH v7 5/7] PCI: qcom: Handle MSIs routed to multiple GIC interrupts
Quoted 17 lines · Dmitry Baryshkov
Quoted 11 lines · Rob Herring
Quoted 4 lines · Dmitry Baryshkov
On some of Qualcomm platforms each group of 32 MSI vectors is routed to the separate GIC interrupt. Thus to receive higher MSI vectors properly, add separate msi_host_init()/msi_host_deinit() handling additional host IRQs.
msi_host_init()has 1 user (keystone) as it doesn't use the DWC MSI controller. But QCom does given the access toPCIE_MSI_INTR0_STATUS, so mutiple MSI IRQ outputs must have been added in newer versions of the DWC IP. If so, it's only a matter of time for another platform to do the same thing. Maybe someone from Synopsys could confirm?This is a valid question, and if you check, first iterations of this patchset had this in the dwc core ([1], [2]). Exactly for the reason this might be usable for other platforms.
Quoted 7 lines
Then I did some research for other platforms using DWC PCIe IP core. For example, both Tegra Xavier and iMX6 support up to 256 MSI vectors, they use DWC MSI IRQ controller. The iMX6 TRM explicitly describes using different MSI groups for different endpoints. The diagram shows 8 MSI IRQ signal lines. However in the end the signals from all groups are OR'ed to form a single host
msi_ctrl_int. Thus currently I suppose that using multiple MSI IRQs is a peculiarity of Qualcomm platform.
Chip integration very often will just OR together interrupts or not. It's completely at the whim of the SoC design, so I'd say both cases are very likely. Seems to be a feature in newer versions of the IP. Probably requested by some misguided h/w person thinking split interrupts would be 'faster'. (Sorry, too many past discussions with h/w designers on this topic.)
Quoted 11 lines
Quoted 6 lines
Therefore this should all be handled in the DWC core. In general, I don't want to see more users nor more ops if we don't have to. Let's not create ops for what can be handled as data. AFAICT, this is just number of MSIs and # of MSIs per IRQ. It seems plausible another platform could do something similar and supporting it in the core code wouldn't negatively impact other platforms.
I wanted to balance adding additional ops vs complicating the core for other platforms. And I still suppose that platform specifics should go to the platform driver. However if you prefer [1] and [2], we can go back to that implementation.
Yes, I prefer that implementation.
Rob
PATCH v7 6/7 dt-bindings: PCI: qcom: Support additional MSI interrupts
In reply to Dmitry BaryshkovOn Qualcomm platforms each group of 32 MSI vectors is routed to the separate GIC interrupt. Document mapping of additional interrupts.
--- .../devicetree/bindings/pci/qcom,pcie.yaml | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/pci/qcom,pcie.yaml +44 -1
@@ -43,11 +43,20 @@ properties: maxItems: 5 interrupts: - maxItems: 1 + minItems: 1 + maxItems: 8 interrupt-names: + minItems: 1 items: - const: msi + - const: msi2 + - const: msi3 + - const: msi4 + - const: msi5 + - const: msi6 + - const: msi7 + - const: msi8 # Common definitions for clocks, clock-names and reset. # Platform constraints are described later.
@@ -623,6 +632,40 @@ allOf: - resets - reset-names + # On newer chipsets support either 1 or 8 msi interrupts + # On older chipsets it's always 1 msi interrupt + - if: + properties: + compatibles: + contains: + enum: + - qcom,pcie-msm8996 + - qcom,pcie-sc7280 + - qcom,pcie-sc8180x + - qcom,pcie-sdm845 + - qcom,pcie-sm8150 + - qcom,pcie-sm8250 + - qcom,pcie-sm8450-pcie0 + - qcom,pcie-sm8450-pcie1 + then: + oneOf: + - properties: + interrupts: + maxItems: 1 + interrupt-names: + maxItems: 1 + - properties: + interrupts: + minItems: 8 + interrupt-names: + minItems: 8 + else: + properties: + interrupts: + maxItems: 1 + interrupt-names: + maxItems: 1 + unevaluatedProperties: false examples:
Signature · 1 line
2.35.1
Rob Herring
maintainerRe: [PATCH v7 6/7] dt-bindings: PCI: qcom: Support additional MSI interrupts
Quoted 16 lines · Dmitry Baryshkov
On Qualcomm platforms each group of 32 MSI vectors is routed to the separate GIC interrupt. Document mapping of additional interrupts.
Reviewed-by Krzysztof Kozlowski <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- .../devicetree/bindings/pci/qcom,pcie.yaml | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/pci/qcom,pcie.yaml +0
-0@@ -43,11 +43,20 @@ properties: maxItems: 5
Documentation/devicetree/bindings/pci/qcom,pcie.yaml properties: · line 53
Quoted 10 lines
Documentation/devicetree/bindings/pci/qcom,pcie.yaml +4
-1interrupts: - maxItems: 1 + minItems: 1 + maxItems: 8 interrupt-names: + minItems: 1 items: - const: msi + - const: msi2
Is 2 from some documentation or you made up. If the latter, software folks start numbering at 0, not 1. :) I wouldn't care, but I think this may become common.
Quoted 6 lines
Documentation/devicetree/bindings/pci/qcom,pcie.yaml +6
-0+ - const: msi3 + - const: msi4 + - const: msi5 + - const: msi6 + - const: msi7 + - const: msi8
Re: [PATCH v7 6/7] dt-bindings: PCI: qcom: Support additional MSI interrupts
Quoted 22 lines · Rob Herring
Quoted 21 lines · Dmitry Baryshkov
On Qualcomm platforms each group of 32 MSI vectors is routed to the separate GIC interrupt. Document mapping of additional interrupts.
Reviewed-by Krzysztof Kozlowski <[email protected]>Signed-off-by Dmitry Baryshkov <[email protected]>--- .../devicetree/bindings/pci/qcom,pcie.yaml | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/pci/qcom,pcie.yaml +2
-1@@ -43,11 +43,20 @@ properties: maxItems: 5 interrupts: - maxItems: 1 + minItems: 1 + maxItems: 8
Quoted 9 lines
Documentation/devicetree/bindings/pci/qcom,pcie.yaml properties: · line 53
Quoted 5 lines
Documentation/devicetree/bindings/pci/qcom,pcie.yaml +2
-0interrupt-names: + minItems: 1 items: - const: msi + - const: msi2Is 2 from some documentation or you made up. If the latter, software folks start numbering at 0, not 1. :) I wouldn't care, but I think this may become common.
It has been made up, so I will update this.
Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/pci/qcom,pcie.yaml +6
-0+ - const: msi3 + - const: msi4 + - const: msi5 + - const: msi6 + - const: msi7 + - const: msi8
Signature · 2 lines
With best wishes Dmitry
PATCH v7 7/7 arm64: dts: qcom: sm8250: provide additional MSI interrupts
In reply to Dmitry BaryshkovOn SM8250 each group of MSI interrupts is mapped to the separate host interrupt. Describe each of interrupts in the device tree for PCIe0 host.
Tested on Qualcomm RB5 platform with first group of MSI interrupts being used by the PME and attached ath11k WiFi chip using second group of MSI interrupts.
--- arch/arm64/boot/dts/qcom/sm8250.dtsi | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-)
arch/arm64/boot/dts/qcom/sm8250.dtsi +9 -2
@@ -1807,8 +1807,15 @@ pcie0: pci@1c00000 { ranges = <0x01000000 0x0 0x60200000 0 0x60200000 0x0 0x100000>, <0x02000000 0x0 0x60300000 0 0x60300000 0x0 0x3d00000>; - interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>; - interrupt-names = "msi"; + interrupts = <GIC_SPI 141 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 142 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 143 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 144 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 145 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 146 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>; + interrupt-names = "msi", "msi2", "msi3", "msi4", "msi5", "msi6", "msi7", "msi8"; #interrupt-cells = <1>; interrupt-map-mask = <0 0 0 0x7>; interrupt-map = <0 0 0 1 &intc 0 149 IRQ_TYPE_LEVEL_HIGH>, /* int_a */
Signature · 1 line
2.35.1
Thanks Dmitry!
Quoted 24 lines · Dmitry Baryshkov
I have replied with my Tested-by to the patch at [2], which has landed in the linux-next as the commit
20f1bfb8dd62("PCI: qcom:
Add support for handling MSIs from 8 endpoints"). However lately I noticed that during the tests I still had 'pcie_pme=nomsi', so the device was not forced to use higher MSI vectors.After removing this option I noticed that hight MSI vectors are not delivered on tested platforms. After additional research I stumbled upon a patch in msm-4.14 ([1]), which describes that each group of MSI vectors is mapped to the separate interrupt. Implement corresponding mapping.
Since we can not expect that other platforms will use multi-IRQ scheme for MSI mapping (e.g. iMX and Tegra map all 256 MSI interrupts to single IRQ), it's support is implemented directly in pcie-qcom rather than in the core driver.
The first patch in the series is a revert of [2] (landed in pci-next). Either both patches should be applied or both should be dropped.
Patchseries dependecies: [3] (for the schema change).
Changes since v6:
- Fix indentation of the arguments as requested by Stanimir
<cut>
Quoted 10 lines
Dmitry Baryshkov (7):
PCI: qcom: Revert "PCI: qcom: Add support for handling MSIs from 8
endpoints"
PCI: dwc: Correctmsi_irqcondition indw_pcie_free_msi()
PCI: dwc: Addmsi_host_deinitcallback
PCI: dwc: Export several functions useful for MSI implentations
PCI: qcom: Handle MSIs routed to multiple GIC interrupts
dt-bindings: PCI: qcom: Support additional MSI interrupts
arm64: dts: qcom: sm8250: provide additional MSI interrupts
For PCI qcom driver:
Quoted 8 lines
.../devicetree/bindings/pci/qcom,pcie.yaml | 45 +++++- arch/arm64/boot/dts/qcom/sm8250.dtsi | 11 +- .../pci/controller/dwc/pcie-designware-host.c | 72 +++++---- drivers/pci/controller/dwc/pcie-designware.h | 12 ++ drivers/pci/controller/dwc/pcie-qcom.c | 138 +++++++++++++++++- 5 files changed, 246 insertions(+), 32 deletions(-)
Signature · 2 lines
regards, Stan