All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: Phil Edworthy <phil.edworthy@renesas.com>
Cc: linux-pci@vger.kernel.org, linux-sh@vger.kernel.org,
	LAKML <linux-arm-kernel@lists.infradead.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Valentine Barshak <valentine.barshak@cogentembedded.com>,
	Simon Horman <horms@verge.net.au>,
	Magnus Damm <magnus.damm@gmail.com>
Subject: Re: [PATCH v5 2/9] PCI: host: rcar: Add MSI support
Date: Tue, 25 Mar 2014 17:04:51 +0000	[thread overview]
Message-ID: <5331B733.8090802@codethink.co.uk> (raw)
In-Reply-To: <1395766604-30926-3-git-send-email-phil.edworthy@renesas.com>

On 25/03/14 16:56, Phil Edworthy wrote:
> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> ---
> v5:
>   - Return IRQ_NONE from MSI isr when there is no pending MSI
>   - Add additional interrupt bindings
> +
> +static void rcar_msi_free(struct rcar_msi *chip, unsigned long irq)
> +{
> +	struct device *dev = chip->chip.dev;
> +
> +	mutex_lock(&chip->lock);
> +
> +	if (!test_bit(irq, chip->used))
> +		dev_err(dev, "trying to free unused MSI#%lu\n", irq);

Does the upper level not check for this?

> +	else
> +		clear_bit(irq, chip->used);
> +
> +	mutex_unlock(&chip->lock);


> +}
> +
> +static irqreturn_t rcar_pcie_msi_irq(int irq, void *data)
> +{
> +	struct rcar_pcie *pcie = data;
> +	struct rcar_msi *msi = &pcie->msi;
> +	unsigned long reg;
> +
> +	reg = pci_read_reg(pcie, PCIEMSIFR);
> +
> +	/* MSI & INTx share an interrupt - we only handle MSI here */
> +	if (!reg)
> +		return IRQ_NONE;
> +
> +	while (reg) {
> +		unsigned int index = find_first_bit(&reg, 32);
> +		unsigned int irq;
> +
> +		/* clear the interrupt */
> +		pci_write_reg(pcie, 1 << index, PCIEMSIFR);
> +
> +		irq = irq_find_mapping(msi->domain, index);
> +		if (irq) {
> +			if (test_bit(index, msi->used))
> +				generic_handle_irq(irq);
> +			else
> +				dev_info(pcie->dev, "unhandled MSI\n");
> +		} else {
> +			/*
> +			 * that's weird who triggered this?
> +			 * just clear it
> +			 */
> +			dev_info(pcie->dev, "unexpected MSI\n");
> +		}

You may want to change this to something that is either rate-limited
or is say debug level so it does not spam the console if something
does go wrong.

Also the comment could easily be made one line
	/* Weird, unknown MSI IRQ, just clear it */


-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

WARNING: multiple messages have this Message-ID (diff)
From: Ben Dooks <ben.dooks@codethink.co.uk>
To: linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v5 2/9] PCI: host: rcar: Add MSI support
Date: Tue, 25 Mar 2014 17:04:51 +0000	[thread overview]
Message-ID: <5331B733.8090802@codethink.co.uk> (raw)
In-Reply-To: <1395766604-30926-3-git-send-email-phil.edworthy@renesas.com>

On 25/03/14 16:56, Phil Edworthy wrote:
> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> ---
> v5:
>   - Return IRQ_NONE from MSI isr when there is no pending MSI
>   - Add additional interrupt bindings
> +
> +static void rcar_msi_free(struct rcar_msi *chip, unsigned long irq)
> +{
> +	struct device *dev = chip->chip.dev;
> +
> +	mutex_lock(&chip->lock);
> +
> +	if (!test_bit(irq, chip->used))
> +		dev_err(dev, "trying to free unused MSI#%lu\n", irq);

Does the upper level not check for this?

> +	else
> +		clear_bit(irq, chip->used);
> +
> +	mutex_unlock(&chip->lock);


> +}
> +
> +static irqreturn_t rcar_pcie_msi_irq(int irq, void *data)
> +{
> +	struct rcar_pcie *pcie = data;
> +	struct rcar_msi *msi = &pcie->msi;
> +	unsigned long reg;
> +
> +	reg = pci_read_reg(pcie, PCIEMSIFR);
> +
> +	/* MSI & INTx share an interrupt - we only handle MSI here */
> +	if (!reg)
> +		return IRQ_NONE;
> +
> +	while (reg) {
> +		unsigned int index = find_first_bit(&reg, 32);
> +		unsigned int irq;
> +
> +		/* clear the interrupt */
> +		pci_write_reg(pcie, 1 << index, PCIEMSIFR);
> +
> +		irq = irq_find_mapping(msi->domain, index);
> +		if (irq) {
> +			if (test_bit(index, msi->used))
> +				generic_handle_irq(irq);
> +			else
> +				dev_info(pcie->dev, "unhandled MSI\n");
> +		} else {
> +			/*
> +			 * that's weird who triggered this?
> +			 * just clear it
> +			 */
> +			dev_info(pcie->dev, "unexpected MSI\n");
> +		}

You may want to change this to something that is either rate-limited
or is say debug level so it does not spam the console if something
does go wrong.

Also the comment could easily be made one line
	/* Weird, unknown MSI IRQ, just clear it */


-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

WARNING: multiple messages have this Message-ID (diff)
From: ben.dooks@codethink.co.uk (Ben Dooks)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH v5 2/9] PCI: host: rcar: Add MSI support
Date: Tue, 25 Mar 2014 17:04:51 +0000	[thread overview]
Message-ID: <5331B733.8090802@codethink.co.uk> (raw)
In-Reply-To: <1395766604-30926-3-git-send-email-phil.edworthy@renesas.com>

On 25/03/14 16:56, Phil Edworthy wrote:
> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> ---
> v5:
>   - Return IRQ_NONE from MSI isr when there is no pending MSI
>   - Add additional interrupt bindings
> +
> +static void rcar_msi_free(struct rcar_msi *chip, unsigned long irq)
> +{
> +	struct device *dev = chip->chip.dev;
> +
> +	mutex_lock(&chip->lock);
> +
> +	if (!test_bit(irq, chip->used))
> +		dev_err(dev, "trying to free unused MSI#%lu\n", irq);

Does the upper level not check for this?

> +	else
> +		clear_bit(irq, chip->used);
> +
> +	mutex_unlock(&chip->lock);


> +}
> +
> +static irqreturn_t rcar_pcie_msi_irq(int irq, void *data)
> +{
> +	struct rcar_pcie *pcie = data;
> +	struct rcar_msi *msi = &pcie->msi;
> +	unsigned long reg;
> +
> +	reg = pci_read_reg(pcie, PCIEMSIFR);
> +
> +	/* MSI & INTx share an interrupt - we only handle MSI here */
> +	if (!reg)
> +		return IRQ_NONE;
> +
> +	while (reg) {
> +		unsigned int index = find_first_bit(&reg, 32);
> +		unsigned int irq;
> +
> +		/* clear the interrupt */
> +		pci_write_reg(pcie, 1 << index, PCIEMSIFR);
> +
> +		irq = irq_find_mapping(msi->domain, index);
> +		if (irq) {
> +			if (test_bit(index, msi->used))
> +				generic_handle_irq(irq);
> +			else
> +				dev_info(pcie->dev, "unhandled MSI\n");
> +		} else {
> +			/*
> +			 * that's weird who triggered this?
> +			 * just clear it
> +			 */
> +			dev_info(pcie->dev, "unexpected MSI\n");
> +		}

You may want to change this to something that is either rate-limited
or is say debug level so it does not spam the console if something
does go wrong.

Also the comment could easily be made one line
	/* Weird, unknown MSI IRQ, just clear it */


-- 
Ben Dooks				http://www.codethink.co.uk/
Senior Engineer				Codethink - Providing Genius

  reply	other threads:[~2014-03-25 17:04 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-25 16:56 [PATCH v5 0/9] R-Car Gen2 PCIe host driver Phil Edworthy
2014-03-25 16:56 ` Phil Edworthy
2014-03-25 16:56 ` Phil Edworthy
2014-03-25 16:56 ` [PATCH v5 1/9] PCI: host: rcar: Add Renesas R-Car PCIe driver Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 16:56 ` [PATCH v5 2/9] PCI: host: rcar: Add MSI support Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 17:04   ` Ben Dooks [this message]
2014-03-25 17:04     ` Ben Dooks
2014-03-25 17:04     ` Ben Dooks
2014-03-26 10:12     ` Phil.Edworthy
2014-03-26 10:12       ` Phil.Edworthy at renesas.com
2014-03-26 10:12       ` Phil.Edworthy
2014-03-25 16:56 ` [PATCH v5 3/9] ARM: shmobile: r8a7790: Add PCIe clock device tree nodes Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 16:56 ` [PATCH v5 4/9] ARM: shmobile: r8a7791: " Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 16:56 ` [PATCH v5 5/9] dt-bindings: pci: rcar pcie device tree bindings Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 19:22   ` Sergei Shtylyov
2014-03-25 20:22     ` Sergei Shtylyov
2014-03-25 20:22     ` Sergei Shtylyov
2014-03-26  9:12     ` Phil.Edworthy
2014-03-26  9:12       ` Phil.Edworthy at renesas.com
2014-03-26  9:12       ` Phil.Edworthy
2014-03-25 16:56 ` [PATCH v5 6/9] ARM: shmobile: Add PCIe device tree nodes for R8A7790 Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 18:42   ` Arnd Bergmann
2014-03-25 18:42     ` Arnd Bergmann
2014-03-25 18:42     ` Arnd Bergmann
2014-03-26  9:55     ` Phil.Edworthy
2014-03-26  9:55       ` Phil.Edworthy at renesas.com
2014-03-26  9:55       ` Phil.Edworthy
2014-03-26 10:34       ` Arnd Bergmann
2014-03-26 10:34         ` Arnd Bergmann
2014-03-26 10:34         ` Arnd Bergmann
2014-03-26 11:01         ` Phil.Edworthy
2014-03-26 11:01           ` Phil.Edworthy at renesas.com
2014-03-26 11:01           ` Phil.Edworthy
2014-03-26 11:14           ` Arnd Bergmann
2014-03-26 11:14             ` Arnd Bergmann
2014-03-26 11:14             ` Arnd Bergmann
2014-03-26 11:34             ` Phil.Edworthy
2014-03-26 11:34               ` Phil.Edworthy at renesas.com
2014-03-26 11:34               ` Phil.Edworthy
2014-03-26 11:52               ` Arnd Bergmann
2014-03-26 11:52                 ` Arnd Bergmann
2014-03-26 11:52                 ` Arnd Bergmann
2014-03-26 11:56                 ` Phil.Edworthy
2014-03-26 11:56                   ` Phil.Edworthy at renesas.com
2014-03-26 11:56                   ` Phil.Edworthy
2014-03-25 21:03   ` Simon Horman
2014-03-25 21:03     ` Simon Horman
2014-03-25 21:03     ` Simon Horman
2014-03-26  8:54     ` Phil.Edworthy
2014-03-26  8:54       ` Phil.Edworthy at renesas.com
2014-03-26  8:54       ` Phil.Edworthy
2014-03-25 16:56 ` [PATCH v5 7/9] ARM: shmobile: Add PCIe device tree nodes for R8A7791 Koelsch board Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 21:00   ` Simon Horman
2014-03-25 21:00     ` Simon Horman
2014-03-25 21:00     ` Simon Horman
2014-03-25 16:56 ` [PATCH v5 8/9] ARM: koelsch: Add PCIe to defconfig Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 20:57   ` Simon Horman
2014-03-25 20:57     ` Simon Horman
2014-03-25 20:57     ` Simon Horman
2014-03-25 16:56 ` [PATCH v5 9/9] ARM: koelsch: Add HAVE_ARM_ARCH_TIMER " Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 16:56   ` Phil Edworthy
2014-03-25 21:02   ` Simon Horman
2014-03-25 21:02     ` Simon Horman
2014-03-25 21:02     ` Simon Horman
2014-03-26  5:39   ` Magnus Damm
2014-03-26  5:39     ` Magnus Damm
2014-03-26  5:39     ` Magnus Damm
2014-03-26  8:50     ` Phil.Edworthy
2014-03-26  8:50       ` Phil.Edworthy at renesas.com
2014-03-26  8:50       ` Phil.Edworthy

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=5331B733.8090802@codethink.co.uk \
    --to=ben.dooks@codethink.co.uk \
    --cc=bhelgaas@google.com \
    --cc=horms@verge.net.au \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-sh@vger.kernel.org \
    --cc=magnus.damm@gmail.com \
    --cc=phil.edworthy@renesas.com \
    --cc=valentine.barshak@cogentembedded.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.