Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp405260ybg; Tue, 9 Jun 2020 03:48:00 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzM6TRDzGere4CrGF+ziBM75m/Mr/1D+6gXG6OwMQ9sEHdahz01t/LtCzPyMXXwRzusulTA X-Received: by 2002:a17:906:2584:: with SMTP id m4mr25377222ejb.328.1591699680064; Tue, 09 Jun 2020 03:48:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591699680; cv=none; d=google.com; s=arc-20160816; b=PLy0fxo/j+GLnQkEMJtZja6Jk5CejUlG8Ak4v4gQdOf5WuMCAtJ993imEQ5BUKfNpu 4ebQPkxdFzZWcYq3jVR2nzg0fNmGLnelLTvaSVBpO1dM0R75Yfy7S3oM5dxsy2OIJytn ec5EJhiy7OC6DsFV8Es/92BgZQ++ZatikdK0U24w3JxF8BkZKqKX5/dMwKlh08RLDE9v zqp+ufWnma304s3fSGh2Az8FIJd2Lfq/qSlkeqAUrX6bBRxvKpiIZbquEq/kyMUB/HaM bGf6Yle0UQiNc4Rf6+ed48FtfhQyg43EX8V1LdaGJKKkjttPJ7Vw4F3TN75Ur3QoclVM xOfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:ironport-sdr:ironport-sdr; bh=DGGI2msys+d1z424HjhVYXtzeKKhQexSpN9s+tLh+vk=; b=DFZrjda5FrW91WOKqxJzNzMVSLDRJ2/5nNbBWRpGKV0+hU0OQv51YG2PHI8zUv2tkO TckEgQWIxlvKgBB/BbExKk4BdY0MqMrd8OU0wm72LRpqUsUWfBwFxCCvTbgUI7qKxloc 5y/67mD0JPdGo84Nb558Y07gtlkO7Y8A8BgC8LOk5XX15JfMxKKh+vWxM7mFBf1dpuhL xPdBiTq1mQkt8wVWRqdGP4PvtJKekJdUW8KpKdIl7IC8HB7jfkfy07UnDvVX/RdTxK/W fKvi3AzX3GCSwVJMeblPoqCxCe5enhwIXLyLXoVxGVV5GclZqSjzz2H7u3dFVqoza+fV hqEA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id dt16si14126122ejc.525.2020.06.09.03.47.37; Tue, 09 Jun 2020 03:48:00 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728330AbgFIJPc (ORCPT + 99 others); Tue, 9 Jun 2020 05:15:32 -0400 Received: from mga01.intel.com ([192.55.52.88]:19611 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726187AbgFIJP3 (ORCPT ); Tue, 9 Jun 2020 05:15:29 -0400 IronPort-SDR: wDxBlxE1goElNLjzWI1owja+MkbhW0cN60lmx0+C7yBJqmUt459E+XyY0H59np+nTtSk9kVX5M idzBKddX6JSw== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Jun 2020 02:15:27 -0700 IronPort-SDR: zuVF1mpKEINGAUTfFgnW32ujP1+dFBFdKRMr5TZil/7TzHAJ8widMg9onu+E1zBPM7s1hY41vc yQpBURsN6aiA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,491,1583222400"; d="scan'208";a="259739056" Received: from gklab-125-110.igk.intel.com ([10.91.125.110]) by orsmga007.jf.intel.com with ESMTP; 09 Jun 2020 02:15:25 -0700 From: Piotr Stankiewicz To: Bjorn Helgaas , linux-pci@vger.kernel.org Cc: Andy Shevchenko , Piotr Stankiewicz , "Rafael J. Wysocki" , Randy Dunlap , Jian-Hong Pan , Arnd Bergmann , Greg Kroah-Hartman , Logan Gunthorpe , linux-kernel@vger.kernel.org Subject: [PATCH v3 01/15] PCI/MSI: Forward MSI-X vector enable error code in pci_alloc_irq_vectors_affinity() Date: Tue, 9 Jun 2020 11:14:39 +0200 Message-Id: <20200609091440.497-1-piotr.stankiewicz@intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20200609091148.32749-1-piotr.stankiewicz@intel.com> References: <20200609091148.32749-1-piotr.stankiewicz@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When debugging an issue where I was asking the PCI machinery to enable a set of MSI-X vectors, without falling back on MSI, I ran across a behaviour which seems odd. The pci_alloc_irq_vectors_affinity() will always return -ENOSPC on failure, when allocating MSI-X vectors only, whereas with MSI fallback it will forward any error returned by __pci_enable_msi_range(). This is a confusing behaviour, so have the pci_alloc_irq_vectors_affinity() forward the error code from __pci_enable_msix_range() when appropriate. Signed-off-by: Piotr Stankiewicz --- drivers/pci/msi.c | 22 +++++++++------------- 1 file changed, 9 insertions(+), 13 deletions(-) diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index 6b43a5455c7a..cade9be68b09 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c @@ -1191,8 +1191,7 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, struct irq_affinity *affd) { struct irq_affinity msi_default_affd = {0}; - int msix_vecs = -ENOSPC; - int msi_vecs = -ENOSPC; + int nvecs = -ENOSPC; if (flags & PCI_IRQ_AFFINITY) { if (!affd) @@ -1203,17 +1202,16 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, } if (flags & PCI_IRQ_MSIX) { - msix_vecs = __pci_enable_msix_range(dev, NULL, min_vecs, - max_vecs, affd, flags); - if (msix_vecs > 0) - return msix_vecs; + nvecs = __pci_enable_msix_range(dev, NULL, min_vecs, max_vecs, + affd, flags); + if (nvecs > 0) + return nvecs; } if (flags & PCI_IRQ_MSI) { - msi_vecs = __pci_enable_msi_range(dev, min_vecs, max_vecs, - affd); - if (msi_vecs > 0) - return msi_vecs; + nvecs = __pci_enable_msi_range(dev, min_vecs, max_vecs, affd); + if (nvecs > 0) + return nvecs; } /* use legacy IRQ if allowed */ @@ -1231,9 +1229,7 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, } } - if (msix_vecs == -ENOSPC) - return -ENOSPC; - return msi_vecs; + return nvecs; } EXPORT_SYMBOL(pci_alloc_irq_vectors_affinity); -- 2.17.2