All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Murali Karicheri <m-karicheri2@ti.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Jingoo Han <jingoohan1@gmail.com>,
	Gustavo Pimentel <gustavo.pimentel@synopsys.com>,
	linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3 3/9] PCI: keystone: Use hwirq to get the legacy IRQ number offset
Date: Wed, 13 Feb 2019 16:57:39 +0000	[thread overview]
Message-ID: <20190213165739.GE2280@e107981-ln.cambridge.arm.com> (raw)
In-Reply-To: <20190213132629.24790-4-kishon@ti.com>

On Wed, Feb 13, 2019 at 06:56:23PM +0530, Kishon Vijay Abraham I wrote:
> ks_pcie_legacy_irq_handler() uses 'virq' to get the IRQ number offset.
> This offset is used to get the correct IRQ_STATUS register
> corresponding to the IRQ line that raised the interrupt.
> There is no guarantee that 'virq' assigned for consecutive hardware
> IRQ will be contiguous. And this might get us an incorrect IRQ number
> offset.
> 
> Fix it here by using 'hwirq' to get the IRQ number offset.
> 
> Link: https://lkml.kernel.org/r/bb081d21-7c03-0357-4294-7e92d95d838c@arm.com
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  drivers/pci/controller/dwc/pci-keystone.c | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
> index e8b1d8eca78e..d35ac712a9f8 100644
> --- a/drivers/pci/controller/dwc/pci-keystone.c
> +++ b/drivers/pci/controller/dwc/pci-keystone.c
> @@ -87,7 +87,7 @@ struct keystone_pcie {
>  	struct dw_pcie		*pci;
>  	/* PCI Device ID */
>  	u32			device_id;
> -	int			legacy_host_irqs[PCI_NUM_INTX];
> +	int			legacy_host_irq;
>  	struct			device_node *legacy_intc_np;
>  
>  	int			msi_host_irqs[MAX_MSI_HOST_IRQS];
> @@ -582,11 +582,11 @@ static void ks_pcie_msi_irq_handler(struct irq_desc *desc)
>   */
>  static void ks_pcie_legacy_irq_handler(struct irq_desc *desc)
>  {
> -	unsigned int irq = irq_desc_get_irq(desc);
> +	unsigned int irq = desc->irq_data.hwirq;
>  	struct keystone_pcie *ks_pcie = irq_desc_get_handler_data(desc);
>  	struct dw_pcie *pci = ks_pcie->pci;
>  	struct device *dev = pci->dev;
> -	u32 irq_offset = irq - ks_pcie->legacy_host_irqs[0];
> +	u32 irq_offset = irq - ks_pcie->legacy_host_irq;

I think you should use the plain hwirq number (that if I understand
correctly range in [0,3]) and drop legacy_host_irq.

See below.

>  	struct irq_chip *chip = irq_desc_get_chip(desc);
>  
>  	dev_dbg(dev, ": Handling legacy irq %d\n", irq);
> @@ -657,6 +657,7 @@ static int ks_pcie_config_legacy_irq(struct keystone_pcie *ks_pcie)
>  	struct device_node *np = ks_pcie->np;
>  	struct device_node *intc_np;
>  	int irq_count, irq, ret, i;
> +	struct irq_data *irq_data;
>  
>  	intc_np = of_get_child_by_name(np, "legacy-interrupt-controller");
>  	if (!intc_np) {
> @@ -677,7 +678,15 @@ static int ks_pcie_config_legacy_irq(struct keystone_pcie *ks_pcie)
>  			ret = -EINVAL;
>  			goto err;
>  		}
> -		ks_pcie->legacy_host_irqs[i] = irq;
> +
> +		if (!ks_pcie->legacy_host_irq) {
> +			irq_data = irq_get_irq_data(irq);
> +			if (!irq_data) {
> +				ret = -EINVAL;
> +				goto err;
> +			}
> +			ks_pcie->legacy_host_irq = irq_data->hwirq;

This depends on DT property ordering and may well be wrong. On top
of that as I said above I do not think it is even needed.

Thanks,
Lorenzo

> +		}
>  
>  		irq_set_chained_handler_and_data(irq,
>  						 ks_pcie_legacy_irq_handler,
> -- 
> 2.17.1
> 

WARNING: multiple messages have this Message-ID (diff)
From: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
To: Kishon Vijay Abraham I <kishon@ti.com>
Cc: Jingoo Han <jingoohan1@gmail.com>,
	linux-kernel@vger.kernel.org,
	Murali Karicheri <m-karicheri2@ti.com>,
	linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>,
	Gustavo Pimentel <gustavo.pimentel@synopsys.com>,
	linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v3 3/9] PCI: keystone: Use hwirq to get the legacy IRQ number offset
Date: Wed, 13 Feb 2019 16:57:39 +0000	[thread overview]
Message-ID: <20190213165739.GE2280@e107981-ln.cambridge.arm.com> (raw)
In-Reply-To: <20190213132629.24790-4-kishon@ti.com>

On Wed, Feb 13, 2019 at 06:56:23PM +0530, Kishon Vijay Abraham I wrote:
> ks_pcie_legacy_irq_handler() uses 'virq' to get the IRQ number offset.
> This offset is used to get the correct IRQ_STATUS register
> corresponding to the IRQ line that raised the interrupt.
> There is no guarantee that 'virq' assigned for consecutive hardware
> IRQ will be contiguous. And this might get us an incorrect IRQ number
> offset.
> 
> Fix it here by using 'hwirq' to get the IRQ number offset.
> 
> Link: https://lkml.kernel.org/r/bb081d21-7c03-0357-4294-7e92d95d838c@arm.com
> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
> ---
>  drivers/pci/controller/dwc/pci-keystone.c | 17 +++++++++++++----
>  1 file changed, 13 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/pci/controller/dwc/pci-keystone.c b/drivers/pci/controller/dwc/pci-keystone.c
> index e8b1d8eca78e..d35ac712a9f8 100644
> --- a/drivers/pci/controller/dwc/pci-keystone.c
> +++ b/drivers/pci/controller/dwc/pci-keystone.c
> @@ -87,7 +87,7 @@ struct keystone_pcie {
>  	struct dw_pcie		*pci;
>  	/* PCI Device ID */
>  	u32			device_id;
> -	int			legacy_host_irqs[PCI_NUM_INTX];
> +	int			legacy_host_irq;
>  	struct			device_node *legacy_intc_np;
>  
>  	int			msi_host_irqs[MAX_MSI_HOST_IRQS];
> @@ -582,11 +582,11 @@ static void ks_pcie_msi_irq_handler(struct irq_desc *desc)
>   */
>  static void ks_pcie_legacy_irq_handler(struct irq_desc *desc)
>  {
> -	unsigned int irq = irq_desc_get_irq(desc);
> +	unsigned int irq = desc->irq_data.hwirq;
>  	struct keystone_pcie *ks_pcie = irq_desc_get_handler_data(desc);
>  	struct dw_pcie *pci = ks_pcie->pci;
>  	struct device *dev = pci->dev;
> -	u32 irq_offset = irq - ks_pcie->legacy_host_irqs[0];
> +	u32 irq_offset = irq - ks_pcie->legacy_host_irq;

I think you should use the plain hwirq number (that if I understand
correctly range in [0,3]) and drop legacy_host_irq.

See below.

>  	struct irq_chip *chip = irq_desc_get_chip(desc);
>  
>  	dev_dbg(dev, ": Handling legacy irq %d\n", irq);
> @@ -657,6 +657,7 @@ static int ks_pcie_config_legacy_irq(struct keystone_pcie *ks_pcie)
>  	struct device_node *np = ks_pcie->np;
>  	struct device_node *intc_np;
>  	int irq_count, irq, ret, i;
> +	struct irq_data *irq_data;
>  
>  	intc_np = of_get_child_by_name(np, "legacy-interrupt-controller");
>  	if (!intc_np) {
> @@ -677,7 +678,15 @@ static int ks_pcie_config_legacy_irq(struct keystone_pcie *ks_pcie)
>  			ret = -EINVAL;
>  			goto err;
>  		}
> -		ks_pcie->legacy_host_irqs[i] = irq;
> +
> +		if (!ks_pcie->legacy_host_irq) {
> +			irq_data = irq_get_irq_data(irq);
> +			if (!irq_data) {
> +				ret = -EINVAL;
> +				goto err;
> +			}
> +			ks_pcie->legacy_host_irq = irq_data->hwirq;

This depends on DT property ordering and may well be wrong. On top
of that as I said above I do not think it is even needed.

Thanks,
Lorenzo

> +		}
>  
>  		irq_set_chained_handler_and_data(irq,
>  						 ks_pcie_legacy_irq_handler,
> -- 
> 2.17.1
> 

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2019-02-13 16:57 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-13 13:26 [PATCH v3 0/9] PCI: DWC/Keystone: MSI configuration cleanup Kishon Vijay Abraham I
2019-02-13 13:26 ` Kishon Vijay Abraham I
2019-02-13 13:26 ` [PATCH v3 1/9] PCI: keystone: Cleanup interrupt related macros Kishon Vijay Abraham I
2019-02-13 13:26   ` Kishon Vijay Abraham I
2019-02-13 13:26 ` [PATCH v3 2/9] PCI: keystone: Add separate functions for configuring MSI and legacy interrupt Kishon Vijay Abraham I
2019-02-13 13:26   ` Kishon Vijay Abraham I
2019-02-13 13:26 ` [PATCH v3 3/9] PCI: keystone: Use hwirq to get the legacy IRQ number offset Kishon Vijay Abraham I
2019-02-13 13:26   ` Kishon Vijay Abraham I
2019-02-13 16:57   ` Lorenzo Pieralisi [this message]
2019-02-13 16:57     ` Lorenzo Pieralisi
2019-02-14  4:57     ` Kishon Vijay Abraham I
2019-02-14  4:57       ` Kishon Vijay Abraham I
2019-02-14 10:31       ` Lorenzo Pieralisi
2019-02-14 10:31         ` Lorenzo Pieralisi
2019-02-14 12:46         ` Marc Zyngier
2019-02-14 12:46           ` Marc Zyngier
2019-02-21  9:18         ` Kishon Vijay Abraham I
2019-02-21  9:18           ` Kishon Vijay Abraham I
2019-02-13 13:26 ` [PATCH v3 4/9] PCI: keystone: Use hwirq to get the MSI " Kishon Vijay Abraham I
2019-02-13 13:26   ` Kishon Vijay Abraham I
2019-02-13 13:26 ` [PATCH v3 5/9] PCI: keystone: Cleanup ks_pcie_msi_irq_handler and ks_pcie_legacy_irq_handler Kishon Vijay Abraham I
2019-02-13 13:26   ` Kishon Vijay Abraham I
2019-02-13 13:26 ` [PATCH v3 6/9] PCI: dwc: Add support to use non default msi_irq_chip Kishon Vijay Abraham I
2019-02-13 13:26   ` Kishon Vijay Abraham I
2019-02-13 13:26 ` [PATCH v3 7/9] PCI: keystone: Use Keystone specific msi_irq_chip Kishon Vijay Abraham I
2019-02-13 13:26   ` Kishon Vijay Abraham I
2019-02-13 13:26 ` [PATCH v3 8/9] PCI: dwc: Remove Keystone specific dw_pcie_host_ops Kishon Vijay Abraham I
2019-02-13 13:26   ` Kishon Vijay Abraham I
2019-02-13 13:26 ` [PATCH v3 9/9] PCI: dwc: Do not write to MSI control registers if the platform doesn't use it Kishon Vijay Abraham I
2019-02-13 13:26   ` Kishon Vijay Abraham I

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190213165739.GE2280@e107981-ln.cambridge.arm.com \
    --to=lorenzo.pieralisi@arm.com \
    --cc=bhelgaas@google.com \
    --cc=gustavo.pimentel@synopsys.com \
    --cc=jingoohan1@gmail.com \
    --cc=kishon@ti.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=m-karicheri2@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.