Linux ATA/IDE development
 help / color / mirror / Atom feed
From: Marek Vasut <marex@denx.de>
To: Richard Zhu <richard.zhuhongxing@gmail.com>
Cc: jbe@pengutronix.de, hrhaan@gmail.com, shawn.guo@linaro.org,
	jgarzik@pobox.com, tj@kernel.org, linux-ide@vger.kernel.org,
	Richard Zhu <r65037@freescale.com>
Subject: Re: [PATCH] pci: imx: enable pcie msi support
Date: Mon, 9 Dec 2013 12:16:23 +0100	[thread overview]
Message-ID: <201312091216.23906.marex@denx.de> (raw)
In-Reply-To: <1386581119-2962-2-git-send-email-richard.zhuhongxing@gmail.com>

On Monday, December 09, 2013 at 10:25:19 AM, Richard Zhu wrote:
> From: Richard Zhu <r65037@freescale.com>
> 
> eanble pcie msi support on imx6 platforms
> * add check_device api in the msi chip.
> * add the quirks into pcie_port struct for the deviation
> from standard routines.
> 
> Signed-off-by: Richard Zhu <richard.zhuhongxing@gmail.com>
[...]

> diff --git a/drivers/pci/host/pcie-designware.c
> b/drivers/pci/host/pcie-designware.c index e33b68b..96d2b78 100644
> --- a/drivers/pci/host/pcie-designware.c
> +++ b/drivers/pci/host/pcie-designware.c
> @@ -308,23 +308,28 @@ static int dw_msi_setup_irq(struct msi_chip *chip,
> struct pci_dev *pdev, return -EINVAL;
>  	}
> 
> -	pci_read_config_word(pdev, desc->msi_attrib.pos+PCI_MSI_FLAGS,
> -				&msg_ctr);
> -	msgvec = (msg_ctr&PCI_MSI_FLAGS_QSIZE) >> 4;
> -	if (msgvec == 0)
> -		msgvec = (msg_ctr & PCI_MSI_FLAGS_QMASK) >> 1;
> -	if (msgvec > 5)
> -		msgvec = 0;
> -
> -	irq = assign_irq((1 << msgvec), desc, &pos);
> -	if (irq < 0)
> -		return irq;
> -
> -	msg_ctr &= ~PCI_MSI_FLAGS_QSIZE;
> -	msg_ctr |= msgvec << 4;
> -	pci_write_config_word(pdev, desc->msi_attrib.pos + PCI_MSI_FLAGS,
> -				msg_ctr);
> -	desc->msi_attrib.multiple = msgvec;
> +	if (pp->quirks & DW_PCIE_QUIRK_NO_MSI_VEC) {
> +		irq = assign_irq(1, desc, &pos);
> +		set_irq_flags(irq, IRQF_VALID);

What does this do exactly please ? I don't quite understand how this code works. 
A beefy comment how this works and why it's needed would really help.

> +	} else {
> +		pci_read_config_word(pdev, desc->msi_attrib.pos+PCI_MSI_FLAGS,
> +					&msg_ctr);
> +		msgvec = (msg_ctr&PCI_MSI_FLAGS_QSIZE) >> 4;
> +		if (msgvec == 0)
> +			msgvec = (msg_ctr & PCI_MSI_FLAGS_QMASK) >> 1;
> +		if (msgvec > 5)
> +			msgvec = 0;
> +
> +		irq = assign_irq((1 << msgvec), desc, &pos);
> +		if (irq < 0)
> +			return irq;
> +
> +		msg_ctr &= ~PCI_MSI_FLAGS_QSIZE;
> +		msg_ctr |= msgvec << 4;
> +		pci_write_config_word(pdev, desc->msi_attrib.pos + 
PCI_MSI_FLAGS,
> +					msg_ctr);
> +		desc->msi_attrib.multiple = msgvec;
> +	}
> 
>  	msg.address_lo = virt_to_phys((void *)pp->msi_data);
>  	msg.address_hi = 0x0;
> @@ -339,9 +344,30 @@ static void dw_msi_teardown_irq(struct msi_chip *chip,
> unsigned int irq) clear_irq(irq);
>  }
> 
> +static int dw_msi_check_device(struct msi_chip *chip, struct pci_dev
> *pdev, +		int nvec, int type)
> +{
> +	struct pcie_port *pp = sys_to_pcie(pdev->bus->sysdata);
> +	u32 val;

Can we not have a callback here into the MX6 PCIe driver instead of having this 
code here? Then we would likely not need these quirk flags at all.

> +	if (pp->quirks & DW_PCIE_QUIRK_MSI_SELF_EN) {
> +		if ((type == PCI_CAP_ID_MSI) || (type == PCI_CAP_ID_MSIX)) {
> +			/* Set MSI enable of RC here */
> +			val = readl(pp->dbi_base + 0x50);
> +			if ((val & (PCI_MSI_FLAGS_ENABLE << 16)) == 0) {
> +				val |= PCI_MSI_FLAGS_ENABLE << 16;
> +				writel(val, pp->dbi_base + 0x50);
> +			}
> +		}
> +	}
> +
> +	return 0;
> +}
> +
>  static struct msi_chip dw_pcie_msi_chip = {
>  	.setup_irq = dw_msi_setup_irq,
>  	.teardown_irq = dw_msi_teardown_irq,
> +	.check_device = dw_msi_check_device,
>  };
> 
>  int dw_pcie_link_up(struct pcie_port *pp)
[...]

  parent reply	other threads:[~2013-12-09 12:37 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-09  9:25 [discussion] pci: imx: enable pcie msi support Richard Zhu
2013-12-09  9:25 ` [PATCH] " Richard Zhu
2013-12-09 11:00   ` Jürgen Beisert
2013-12-16  5:44     ` Hong-Xing.Zhu
2013-12-09 11:16   ` Marek Vasut [this message]
2013-12-12 18:57   ` Harro Haan

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=201312091216.23906.marex@denx.de \
    --to=marex@denx.de \
    --cc=hrhaan@gmail.com \
    --cc=jbe@pengutronix.de \
    --cc=jgarzik@pobox.com \
    --cc=linux-ide@vger.kernel.org \
    --cc=r65037@freescale.com \
    --cc=richard.zhuhongxing@gmail.com \
    --cc=shawn.guo@linaro.org \
    --cc=tj@kernel.org \
    /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