From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 5B2C5C433E0 for ; Wed, 3 Jun 2020 16:22:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 346E920738 for ; Wed, 3 Jun 2020 16:22:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (2048-bit key) header.d=deltatee.com header.i=@deltatee.com header.b="Ua29264L" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726188AbgFCQWV (ORCPT ); Wed, 3 Jun 2020 12:22:21 -0400 Received: from ts18-13.vcr.istar.ca ([204.191.154.188]:49702 "EHLO ale.deltatee.com" rhost-flags-OK-FAIL-OK-OK) by vger.kernel.org with ESMTP id S1725995AbgFCQWV (ORCPT ); Wed, 3 Jun 2020 12:22:21 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=deltatee.com; s=20200525; h=Subject:Content-Transfer-Encoding:Content-Type: In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To:Sender: Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From:Resent-Sender :Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help:List-Unsubscribe: List-Subscribe:List-Post:List-Owner:List-Archive; bh=LBoBxoGsBmzyCez6mYzhh8bje58137/Gvmb4lxqwSsw=; b=Ua29264LU/U8Ko49gYOZ0iXTxY +3BagQlHopT9NJC0Yn/3wXl1/mzjn9iYrphf0ArYNCH6g58dS2WIxtPYJLQtHnh0K1VUM7xKWSqYE 1VzACgJJUBz6nPHrx/3wtHmQsYu/6xYLpbr49HisbUyyxxIqcJhX7WJ0X/fjsKf7ohqJPsbLRxVzi 0muXXp33BZwWGhZjZX05QEEhFMjQ7BfQ602mkWqBikvF1u6PWWV7TxoDun1qSngjxbIRjWRi/VTbf OcwktivNVX8EBUgFCJtp0Iq0JDuLe5p99rWrDfB/23/ddaAu7yE/6IBtoC4++XwtXqkjezn4vg+OV WSlJfomg==; Received: from s0106602ad0811846.cg.shawcable.net ([68.147.191.165] helo=[192.168.0.12]) by ale.deltatee.com with esmtpsa (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1jgW9i-0002hs-N5; Wed, 03 Jun 2020 10:22:19 -0600 To: "Stankiewicz, Piotr" , Bjorn Helgaas , "linux-pci@vger.kernel.org" Cc: "Shevchenko, Andriy" , "Wysocki, Rafael J" , Jian-Hong Pan , Greg Kroah-Hartman , "linux-kernel@vger.kernel.org" References: <20200603114212.12525-1-piotr.stankiewicz@intel.com> <20200603114425.12734-1-piotr.stankiewicz@intel.com> <3bc1522b-33ba-04ee-4d8e-e4a31ec50756@deltatee.com> From: Logan Gunthorpe Message-ID: <6bfeb14e-b2b7-3843-f417-1a2858859869@deltatee.com> Date: Wed, 3 Jun 2020 10:22:16 -0600 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 68.147.191.165 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, jian-hong@endlessm.com, rafael.j.wysocki@intel.com, andriy.shevchenko@intel.com, linux-pci@vger.kernel.org, bhelgaas@google.com, piotr.stankiewicz@intel.com X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH v2 01/15] PCI/MSI: Forward MSI-X vector enable error code in pci_alloc_irq_vectors_affinity() X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-06-03 10:04 a.m., Stankiewicz, Piotr wrote: >> -----Original Message----- >> From: Logan Gunthorpe >> Sent: Wednesday, June 3, 2020 5:48 PM >> >> >> >> On 2020-06-03 5:44 a.m., Piotr Stankiewicz wrote: >>> 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 >>> Reviewed-by: Andy Shevchenko >>> --- >>> drivers/pci/msi.c | 5 +++-- >>> 1 file changed, 3 insertions(+), 2 deletions(-) >>> >>> diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c >>> index 6b43a5455c7a..443cc324b196 100644 >>> --- a/drivers/pci/msi.c >>> +++ b/drivers/pci/msi.c >>> @@ -1231,8 +1231,9 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev >> *dev, unsigned int min_vecs, >>> } >>> } >>> >>> - if (msix_vecs == -ENOSPC) >>> - return -ENOSPC; >>> + if (msix_vecs == -ENOSPC || >>> + (flags & (PCI_IRQ_MSI | PCI_IRQ_MSIX)) == PCI_IRQ_MSIX) >>> + return msix_vecs; >>> return msi_vecs; >>> } >>> EXPORT_SYMBOL(pci_alloc_irq_vectors_affinity); >>> >> >> It occurs to me that we could clean this function up a bit more... I >> don't see any need to have two variables for msi_vecs and msix_vecs and >> then have a complicated bit of logic at the end to decide which to return. >> >> Why not instead just have one variable which is set by >> __pci_enable_msix_range(), then __pci_enable_msi_range(), then returned >> if they both fail? >> > > That wouldn't preserve the original bit of logic where -ENOSPC is returned > any time __pci_enable_msix_range() fails with -ENOSPC, irrespective of whether > MSI fallback was requested. Though I don't know if that is desired behaviour. That does look very odd, but ok... Then, couldn't we just set msi_vecs to msix_vecs after calling __pci_enable_msix_range() such that if __pci_enable_msi_range() doesn't get called we will return the same error without needing the messy second conditional? Logan