linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vignesh Raghavendra <vigneshr@ti.com>
To: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Kishon Vijay Abraham I <kishon@ti.com>,
	Andrew Murray <andrew.murray@arm.com>,
	Bjorn Helgaas <bhelgaas@google.com>, <linux-omap@vger.kernel.org>,
	<linux-pci@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] PCI: dwc: pci-dra7xx: Fix MSI IRQ handling
Date: Thu, 26 Mar 2020 20:58:46 +0530	[thread overview]
Message-ID: <42024104-deb0-42e1-5e77-6ca7df822963@ti.com> (raw)
In-Reply-To: <20200324150520.GA1174@e121166-lin.cambridge.arm.com>



On 24/03/20 8:35 pm, Lorenzo Pieralisi wrote:
[...]
>> -static irqreturn_t dra7xx_pcie_msi_irq_handler(int irq, void *arg)
>> +static void dra7xx_pcie_msi_irq_handler(struct irq_desc *desc)
>>  {
>> -	struct dra7xx_pcie *dra7xx = arg;
>> -	struct dw_pcie *pci = dra7xx->pci;
>> -	struct pcie_port *pp = &pci->pp;
>> +	struct irq_chip *chip = irq_desc_get_chip(desc);
>> +	struct dra7xx_pcie *dra7xx;
>> +	struct dw_pcie *pci;
>> +	struct pcie_port *pp;
>>  	unsigned long reg;
>>  	u32 virq, bit;
>> +	int count = 0;
>> +
>> +	chained_irq_enter(chip, desc);
>> +
>> +	pp = irq_desc_get_handler_data(desc);
>> +	pci = to_dw_pcie_from_pp(pp);
>> +	dra7xx = to_dra7xx_pcie(pci);
>>  
>>  	reg = dra7xx_pcie_readl(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI);
>> +	dra7xx_pcie_writel(dra7xx, PCIECTRL_DRA7XX_CONF_IRQSTATUS_MSI, reg);
>>  
>>  	switch (reg) {
>>  	case MSI:
>> -		dw_handle_msi_irq(pp);
>> +		/**
>> +		 * Need to make sure all MSI status bits read 0 before
>> +		 * exiting. Else, new MSI IRQs are not registered by the
>> +		 * wrapper. Have an upperbound for the loop and exit the
>> +		 * IRQ in case of IRQ flood to avoid locking up system
>> +		 * in interrupt context.
>> +		 */
>> +		while (dra7xx_pcie_handle_msi_irq(pp) && count < 1000)
>> +			count++;
> 
> Apologies for the delay in replying.
> 
> Do you really need to call the function in a loop ? Can't the loop
> be written inside the function ? It is not going to be any nicer
> but I think it would make code easier to follow. Also, don't know
> if you want to print a warning to signal a count overrun.
> 
> I don't like this code at all but at least it is self-contained
> so we may get it in this cycle.
> 

I have posted v3 with loop moved inside dra7xx_pcie_handle_msi_irq() and
also added dev_warn on overrun. Thanks!

Regard
Vignesh

[...]


      reply	other threads:[~2020-03-26 15:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24 16:36 [PATCH] PCI: dwc: pci-dra7xx: Fix MSI IRQ handling Vignesh Raghavendra
2020-02-21 11:43 ` Kishon Vijay Abraham I
2020-03-24  9:31 ` Vignesh Raghavendra
2020-03-24 15:05 ` Lorenzo Pieralisi
2020-03-26 15:28   ` Vignesh Raghavendra [this message]

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=42024104-deb0-42e1-5e77-6ca7df822963@ti.com \
    --to=vigneshr@ti.com \
    --cc=andrew.murray@arm.com \
    --cc=bhelgaas@google.com \
    --cc=kishon@ti.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=lorenzo.pieralisi@arm.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).