[PATCH v2 06/10] PCI: keystone: Add ks_pcie_free_intx_irq() helper for cleanup

Siddharth Vadapalli posted 10 patches 2 weeks, 6 days ago
There is a newer version of this series
[PATCH v2 06/10] PCI: keystone: Add ks_pcie_free_intx_irq() helper for cleanup
Posted by Siddharth Vadapalli 2 weeks, 6 days ago
Introduce the helper function ks_pcie_free_intx_irq() which will undo the
configuration performed by the ks_pcie_config_intx_irq() function. This
will be required for implementing a future helper function to undo the
configuration performed by the ks_pcie_host_init() function.

Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>
---

v1: https://lore.kernel.org/r/20250903124505.365913-7-s-vadapalli@ti.com/
No changes since v1.

 drivers/pci/controller/dwc/pci-keystone.c | 29 +++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
index 81c3686688c0..074566fb1d74 100644
--- a/drivers/pci/controller/dwc/pci-keystone.c
+++ b/drivers/pci/controller/dwc/pci-keystone.c
@@ -745,6 +745,35 @@ static int ks_pcie_config_msi_irq(struct keystone_pcie *ks_pcie)
 	return ret;
 }
 
+static void ks_pcie_free_intx_irq(struct keystone_pcie *ks_pcie)
+{
+	struct device_node *np = ks_pcie->np;
+	struct device_node *intc_np;
+	int irq_count, i;
+	u32 val;
+
+	/* Nothing to do if INTx Interrupt Controller does not exist */
+	intc_np = of_get_child_by_name(np, "legacy-interrupt-controller");
+	if (!intc_np)
+		return;
+
+	/* irq_count should be non-zero. Else, ks_pcie_host_init would have failed. */
+	irq_count = of_irq_count(intc_np);
+
+	/* Disable all legacy interrupts */
+	for (i = 0; i < PCI_NUM_INTX; i++) {
+		val = ks_pcie_app_readl(ks_pcie, IRQ_ENABLE_SET(i));
+		val &= ~INTx_EN;
+		ks_pcie_app_writel(ks_pcie, IRQ_ENABLE_SET(i), val);
+	}
+
+	irq_domain_remove(ks_pcie->intx_irq_domain);
+	for (i = 0; i < irq_count; i++)
+		irq_set_chained_handler(ks_pcie->intx_host_irqs[i], NULL);
+
+	of_node_put(intc_np);
+}
+
 static int ks_pcie_config_intx_irq(struct keystone_pcie *ks_pcie)
 {
 	struct device *dev = ks_pcie->pci->dev;
-- 
2.43.0
Re: [PATCH v2 06/10] PCI: keystone: Add ks_pcie_free_intx_irq() helper for cleanup
Posted by Manivannan Sadhasivam 1 week, 5 days ago
On Fri, Sep 12, 2025 at 05:46:17PM +0530, Siddharth Vadapalli wrote:
> Introduce the helper function ks_pcie_free_intx_irq() which will undo the
> configuration performed by the ks_pcie_config_intx_irq() function. This
> will be required for implementing a future helper function to undo the
> configuration performed by the ks_pcie_host_init() function.
> 
> Signed-off-by: Siddharth Vadapalli <s-vadapalli@ti.com>

Please squash all patches introducing new helpers.

- Mani

> ---
> 
> v1: https://lore.kernel.org/r/20250903124505.365913-7-s-vadapalli@ti.com/
> No changes since v1.
> 
>  drivers/pci/controller/dwc/pci-keystone.c | 29 +++++++++++++++++++++++
>  1 file changed, 29 insertions(+)
> 
> diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
> index 81c3686688c0..074566fb1d74 100644
> --- a/drivers/pci/controller/dwc/pci-keystone.c
> +++ b/drivers/pci/controller/dwc/pci-keystone.c
> @@ -745,6 +745,35 @@ static int ks_pcie_config_msi_irq(struct keystone_pcie *ks_pcie)
>  	return ret;
>  }
>  
> +static void ks_pcie_free_intx_irq(struct keystone_pcie *ks_pcie)
> +{
> +	struct device_node *np = ks_pcie->np;
> +	struct device_node *intc_np;
> +	int irq_count, i;
> +	u32 val;
> +
> +	/* Nothing to do if INTx Interrupt Controller does not exist */
> +	intc_np = of_get_child_by_name(np, "legacy-interrupt-controller");
> +	if (!intc_np)
> +		return;
> +
> +	/* irq_count should be non-zero. Else, ks_pcie_host_init would have failed. */
> +	irq_count = of_irq_count(intc_np);
> +
> +	/* Disable all legacy interrupts */
> +	for (i = 0; i < PCI_NUM_INTX; i++) {
> +		val = ks_pcie_app_readl(ks_pcie, IRQ_ENABLE_SET(i));
> +		val &= ~INTx_EN;
> +		ks_pcie_app_writel(ks_pcie, IRQ_ENABLE_SET(i), val);
> +	}
> +
> +	irq_domain_remove(ks_pcie->intx_irq_domain);
> +	for (i = 0; i < irq_count; i++)
> +		irq_set_chained_handler(ks_pcie->intx_host_irqs[i], NULL);
> +
> +	of_node_put(intc_np);
> +}
> +
>  static int ks_pcie_config_intx_irq(struct keystone_pcie *ks_pcie)
>  {
>  	struct device *dev = ks_pcie->pci->dev;
> -- 
> 2.43.0
> 

-- 
மணிவண்ணன் சதாசிவம்