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 Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0EE73C433FE for ; Sun, 28 Nov 2021 19:46:49 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 945A382EF0; Sun, 28 Nov 2021 19:46:49 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id dKIIpJBFEJg8; Sun, 28 Nov 2021 19:46:48 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp1.osuosl.org (Postfix) with ESMTPS id 4F32D82EE1; Sun, 28 Nov 2021 19:46:48 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 23CE5C001C; Sun, 28 Nov 2021 19:46:48 +0000 (UTC) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by lists.linuxfoundation.org (Postfix) with ESMTP id 2630CC000A for ; Sun, 28 Nov 2021 19:46:47 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 0E73582EE1 for ; Sun, 28 Nov 2021 19:46:47 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id XmdzY1-IOZEK for ; Sun, 28 Nov 2021 19:46:46 +0000 (UTC) X-Greylist: delayed 00:08:52 by SQLgrey-1.8.0 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by smtp1.osuosl.org (Postfix) with ESMTPS id 2C40282EB5 for ; Sun, 28 Nov 2021 19:46:46 +0000 (UTC) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id D24BCB80D57; Sun, 28 Nov 2021 19:37:50 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 3E7BAC004E1; Sun, 28 Nov 2021 19:37:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1638128269; bh=9kshVg9cWpie2kn2nDFxTot3kBs7ISxnybYkG4sh8SM=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=nZest/lJT4X+8M592uWupGcZA3K/bqpTbWXeabbvC0ZxQ9e7NFcweRsLi7hPITUxi cv3N1cQ4AvwAkP/8BbG8U4/eNiDUwizouClthzINE6Z02aJay9QfGBzvB3o5zRpY0t A7u6aKdfeU7rzeujANQP3gXKyhtm7f45fn8Vx11KlK2MUAuEC3uHEX680Tb6AayILE IK/Ufbe3Hdy9YtKCoMnccCSllNGTkg36pvnE3PXBdSW2gwDFjmBDIbhUmOCuHLkcMG ctIZ0c1oxyCwilUk8uaY0b04ik5js9T60W6ssAhdZleFp0cihB1hYaWxYe/eqGc93f OwcqHzbhqKY6A== Received: from sofa.misterjones.org ([185.219.108.64] helo=wait-a-minute.misterjones.org) by disco-boy.misterjones.org with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mrPze-008TDJ-Q8; Sun, 28 Nov 2021 19:37:47 +0000 Date: Sun, 28 Nov 2021 19:37:45 +0000 Message-ID: <871r30rrzq.wl-maz@kernel.org> From: Marc Zyngier To: Thomas Gleixner Subject: Re: [patch 29/37] PCI/MSI: Use __msi_get_virq() in pci_get_vector() In-Reply-To: <20211126230525.660206325@linutronix.de> References: <20211126224100.303046749@linutronix.de> <20211126230525.660206325@linutronix.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) SEMI-EPG/1.14.7 (Harue) FLIM-LB/1.14.9 (=?UTF-8?B?R29qxY0=?=) APEL-LB/10.8 EasyPG/1.0.0 Emacs/27.1 (x86_64-pc-linux-gnu) MULE/6.0 (HANACHIRUSATO) MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") X-SA-Exim-Connect-IP: 185.219.108.64 X-SA-Exim-Rcpt-To: tglx@linutronix.de, linux-kernel@vger.kernel.org, helgaas@kernel.org, alex.williamson@redhat.com, kevin.tian@intel.com, jgg@nvidia.com, megha.dey@intel.com, ashok.raj@intel.com, linux-pci@vger.kernel.org, gregkh@linuxfoundation.org, ssantosh@kernel.org, iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, stuyoder@gmail.com, laurentiu.tudor@nxp.com, nm@ti.com, kristo@kernel.org, linux-arm-kernel@lists.infradead.org, x86@kernel.org, vkoul@kernel.org, mark.rutland@arm.com, will@kernel.org, okaya@kernel.org X-SA-Exim-Mail-From: maz@kernel.org X-SA-Exim-Scanned: No (on disco-boy.misterjones.org); SAEximRunCond expanded to false Cc: Nishanth Menon , Mark Rutland , Stuart Yoder , linux-pci@vger.kernel.org, Will Deacon , Ashok Raj , x86@kernel.org, Sinan Kaya , iommu@lists.linux-foundation.org, Bjorn Helgaas , Megha Dey , Jason Gunthorpe , Kevin Tian , Alex Williamson , Santosh Shilimkar , linux-arm-kernel@lists.infradead.org, Tero Kristo , Greg Kroah-Hartman , LKML , Vinod Koul , dmaengine@vger.kernel.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Sat, 27 Nov 2021 01:22:03 +0000, Thomas Gleixner wrote: > > Use __msi_get_vector() and handle the return values to be compatible. > > No functional change intended. You wish ;-). [ 15.779540] pcieport 0001:00:01.0: AER: request AER IRQ -22 failed Notice how amusing the IRQ number is? > > Signed-off-by: Thomas Gleixner > --- > drivers/pci/msi/msi.c | 25 +++++-------------------- > 1 file changed, 5 insertions(+), 20 deletions(-) > > --- a/drivers/pci/msi/msi.c > +++ b/drivers/pci/msi/msi.c > @@ -1023,28 +1023,13 @@ EXPORT_SYMBOL(pci_free_irq_vectors); > */ > int pci_irq_vector(struct pci_dev *dev, unsigned int nr) > { > - if (dev->msix_enabled) { > - struct msi_desc *entry; > + int irq = __msi_get_virq(&dev->dev, nr); > > - for_each_pci_msi_entry(entry, dev) { > - if (entry->msi_index == nr) > - return entry->irq; > - } > - WARN_ON_ONCE(1); > - return -EINVAL; > + switch (irq) { > + case -ENODEV: return !nr ? dev->irq : -EINVAL; > + case -ENOENT: return -EINVAL; > } > - > - if (dev->msi_enabled) { > - struct msi_desc *entry = first_pci_msi_entry(dev); > - > - if (WARN_ON_ONCE(nr >= entry->nvec_used)) > - return -EINVAL; > - } else { > - if (WARN_ON_ONCE(nr > 0)) > - return -EINVAL; > - } > - > - return dev->irq + nr; > + return irq; > } > EXPORT_SYMBOL(pci_irq_vector); I worked around it with the hack below, but I doubt this is the real thing. portdrv_core.c does complicated things, and I don't completely understand its logic. M. diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 1f72bc734226..b15278a5fb4b 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -1092,8 +1092,9 @@ int pci_irq_vector(struct pci_dev *dev, unsigned int nr) int irq = __msi_get_virq(&dev->dev, nr); switch (irq) { - case -ENODEV: return !nr ? dev->irq : -EINVAL; - case -ENOENT: return -EINVAL; + case -ENOENT: + case -ENODEV: + return !nr ? dev->irq : -EINVAL; } return irq; } -- Without deviation from the norm, progress is not possible. _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu