Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751768AbbEKRSc (ORCPT ); Mon, 11 May 2015 13:18:32 -0400 Received: from mail-bn1on0062.outbound.protection.outlook.com ([157.56.110.62]:4016 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751013AbbEKRSa (ORCPT ); Mon, 11 May 2015 13:18:30 -0400 X-Greylist: delayed 29012 seconds by postgrey-1.27 at vger.kernel.org; Mon, 11 May 2015 13:18:29 EDT Authentication-Results: kernel.org; dkim=none (message not signed) header.d=none; Date: Mon, 11 May 2015 19:18:10 +0200 From: Robert Richter To: Tejun Heo CC: Robert Richter , Catalin Marinas , Will Deacon , Sunil Goutham , Jiang Liu , , , , Alexander Gordeev Subject: Re: [PATCH v2] AHCI: Add generic MSI-X interrupt support to SATA PCI driver Message-ID: <20150511171810.GB29499@rric.localhost> References: <1430725538-22162-1-git-send-email-rric@kernel.org> <20150504160652.GB1971@htj.duckdns.org> MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Disposition: inline In-Reply-To: <20150504160652.GB1971@htj.duckdns.org> User-Agent: Mutt/1.5.23 (2014-03-12) X-Originating-IP: [92.224.193.75] X-ClientProxiedBy: VI1PR05CA0035.eurprd05.prod.outlook.com (25.162.33.173) To SN2PR0701MB814.namprd07.prod.outlook.com (25.160.16.148) X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN2PR0701MB814;UriScan:;BCL:0;PCL:0;RULEID:;SRVR:SN2PR0701MB1024; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(5005006)(3002001);SRVR:SN2PR0701MB814;BCL:0;PCL:0;RULEID:;SRVR:SN2PR0701MB814; X-Forefront-PRVS: 05739BA1B5 X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6069001)(6009001)(164054003)(24454002)(47776003)(92566002)(46406003)(77156002)(33656002)(62966003)(66066001)(87976001)(76506005)(97756001)(42186005)(2950100001)(50466002)(23726002)(54356999)(76176999)(50986999)(40100003)(86362001)(5001960100002)(4001350100001)(110136002)(46102003)(122386002)(83506001)(189998001)(41533002)(217873001);DIR:OUT;SFP:1101;SCL:1;SRVR:SN2PR0701MB814;H:rric.localhost;FPR:;SPF:None;MLV:sfv;LANG:; X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 May 2015 17:18:24.1322 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR0701MB814 X-OriginatorOrg: caviumnetworks.com Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 4066 Lines: 148 Tejun, thanks for your review and answer. On 04.05.15 12:06:52, Tejun Heo wrote: > > This patch also enables AHCI for Cavium Thunder SoCs that uses MSI-X. > > Please don't mix these two changes in the same patch. I will split the patch. > > + /* 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? I slightly changed the check and added a comment that explains that's going on in the function. This is the new version: 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. Assume single * port interrupts for: * * n_ports == 1, or * nvec < n_ports. * * We also need to check for n_ports != 0 which is implicitly * covered here since nvec > 0. */ if (n_ports != 1 && nvec >= n_ports) return -ENOSYS; /* * There can exist more than one vector (e.g. for error * detection or hdd hotplug). Then the first vector is used, * all others are ignored. Only enable the first entry here * (entry.entry = 0). */ rc = pci_enable_msix_exact(pdev, &entry, 1); if (rc < 0) return rc; return 1; } Note that the check changed to n_ports != 1 to also cover the case n_ports == 0 which should return -ENOSYS. > Also, shouldn't we be printing a warning message here explaining why > probing is failing? I didn't want to print a warning in case -ENOSYS for backward compatability. Only if msi-x code fails there is a message, see __ahci_init_interrupts(). In any other case the behaviour is as before, thus no message is printed. > > + > > + /* 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? For n_ports > 1 && nvec >= n_ports we need to assume per-port interrupts. There are enough vectors for all ports then. > > + 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? I started working implementing this. Will send an updated patch set once finished. Thanks, -Robert -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/