linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tejun Heo <tj@kernel.org>
To: Robert Richter <rric@kernel.org>
Cc: Catalin Marinas <catalin.marinas@arm.com>,
	Will Deacon <will.deacon@arm.com>,
	Sunil Goutham <sgoutham@cavium.com>,
	Jiang Liu <jiang.liu@linux.intel.com>,
	Robert Richter <rrichter@cavium.com>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org,
	Alexander Gordeev <agordeev@redhat.com>
Subject: Re: [PATCH v2] AHCI: Add generic MSI-X interrupt support to SATA PCI driver
Date: Mon, 4 May 2015 12:06:52 -0400	[thread overview]
Message-ID: <20150504160652.GB1971@htj.duckdns.org> (raw)
In-Reply-To: <1430725538-22162-1-git-send-email-rric@kernel.org>

Hello, Robert. (cc'ing Alexander for ahci msi)

On Mon, May 04, 2015 at 09:45:37AM +0200, Robert Richter wrote:
> From: Robert Richter <rrichter@cavium.com>
> 
> This patch adds generic support for MSI-X interrupts to the SATA PCI
> driver. Only single interrupt support is implemented. Thus, per-port
> interrupts can not yet be enabled.
> 
> The driver now checks the device for the existence of MSI-X and tries
> to enable the interrupt. Otherwise, if a device is not MSI-X capable,
> the initialization is skipped and MSI or intx interrupts are
> configured.
> 
> This patch also enables AHCI for Cavium Thunder SoCs that uses MSI-X.

Please don't mix these two changes in the same patch.

> @@ -1202,11 +1207,41 @@ static inline void ahci_gtf_filter_workaround(struct ata_host *host)
>  {}
>  #endif
>  
> -static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
> -				struct ahci_host_priv *hpriv)
> +static int ahci_init_msix(struct pci_dev *pdev, unsigned int n_ports,
> +			  struct ahci_host_priv *hpriv)
> +{
> +	int rc, nvec;
> +	struct msix_entry entry = {};
> +
> +	/* check if msix is supported */
> +	nvec = pci_msix_vec_count(pdev);
> +	if (nvec <= 0)
> +		return 0;
> +
> +	/* per-port msix interrupts are not supported */
> +	if (n_ports > 1 && nvec >= n_ports)
> +		return -ENOSYS;

Hmm... can you please elaborate why the condition isn't nvec > 1?
Also, shouldn't we be printing a warning message here explaining why
probing is failing?

> +
> +	/* only enable the first entry (entry.entry = 0) */
> +	rc = pci_enable_msix_exact(pdev, &entry, 1);

So, enabling the first msix works if nvec > 1 && nvec < n_ports but
not if nvec >= n_ports?

> +	if (rc < 0)
> +		return rc;
> +
> +	return 1;
> +}
> +
> +static int __ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
> +				  struct ahci_host_priv *hpriv)
>  {
>  	int rc, nvec;
>  
> +	nvec = ahci_init_msix(pdev, n_ports, hpriv);
> +	if (nvec > 0)
> +		return nvec;
> +
> +	if (nvec && nvec != -ENOSYS)
> +		dev_err(&pdev->dev, "failed to enable MSI-X: %d", nvec);
> +
>  	if (hpriv->flags & AHCI_HFLAG_NO_MSI)
>  		goto intx;
>  
> @@ -1250,6 +1285,35 @@ static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
>  	return 0;
>  }
>  
> +static struct msi_desc *msix_get_desc(struct pci_dev *dev, u16 entry)
> +{
> +	struct msi_desc *desc;
> +
> +	list_for_each_entry(desc, &dev->msi_list, list) {
> +		if (desc->msi_attrib.entry_nr == entry)
> +			return desc;
> +	}
> +
> +	return NULL;
> +}
> +
> +static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
> +				struct ahci_host_priv *hpriv)
> +{
> +	struct msi_desc *desc;
> +
> +	__ahci_init_interrupts(pdev, n_ports, hpriv);
> +
> +	if (!pdev->msix_enabled)
> +		return pdev->irq;
> +
> +	desc = msix_get_desc(pdev, 0);	/* first entry */
> +	if (!desc)
> +		return -ENODEV;
> +
> +	return desc->irq;
> +}

Can we please do this properly?  We should be able to move port priv
allocation to host allocaotion time and add and use pp->irq instead,
right?

Thanks.

-- 
tejun

  reply	other threads:[~2015-05-04 16:06 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-04  7:45 [PATCH v2] AHCI: Add generic MSI-X interrupt support to SATA PCI driver Robert Richter
2015-05-04 16:06 ` Tejun Heo [this message]
2015-05-11 17:18   ` Robert Richter
2015-05-12 11:46     ` Robert Richter
2015-05-13 14:39       ` Tejun Heo
2015-05-13 17:28         ` Robert Richter
2015-05-13 17:46           ` Tejun Heo
2015-05-13 18:07             ` Robert Richter
2015-05-13 18:10               ` Tejun Heo
2015-05-13 14:33     ` Tejun Heo
2015-05-17  7:33 ` Alexander Gordeev
2015-05-18  8:06   ` Robert Richter

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=20150504160652.GB1971@htj.duckdns.org \
    --to=tj@kernel.org \
    --cc=agordeev@redhat.com \
    --cc=catalin.marinas@arm.com \
    --cc=jiang.liu@linux.intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-ide@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rric@kernel.org \
    --cc=rrichter@cavium.com \
    --cc=sgoutham@cavium.com \
    --cc=will.deacon@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).