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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 C3A2FC433F5 for ; Sun, 28 Nov 2021 21:01:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=3APuNF0M50HVPiF7WnfdWwy8YwhQm5rBjxppJZVi718=; b=MXI57ulPBnF5w1 3K65IkfLr7NN2a4wqp4faaz/8wUzP/Oq9Y+SSXz8vgrFLS3bbrXMS+6xGoXyYAi72YC+Uo/KN34lm HDyds4VGu7/EVsoiD6Do31mY9JOVoLF8ivH0wecACW5B/nT++BWxj3xhELMRpTM2PtUIYXedSysft MjEla09D/7dPPKYVsSsaouvWqG7pzLJgq8L33IObNHE06EEm7mUOqluBmIAvCAWm5u8x8OiQSqs1P nJS4FtUhrSHh5phrqHL0wPvW5XGM29tJmDvJUTAxZjERoflDudDdj7CNBpXzHFBf74u0/pOb2Bvvq nN1Hh8MSOBTQerE56tlQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrRHl-00GfoP-6S; Sun, 28 Nov 2021 21:00:33 +0000 Received: from galois.linutronix.de ([2a0a:51c0:0:12e:550::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mrRHh-00GfnU-9b for linux-arm-kernel@lists.infradead.org; Sun, 28 Nov 2021 21:00:31 +0000 From: Thomas Gleixner DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1638133227; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=oVxt6RB3wq6HozhBc+E1hXItThUGltcJ9ju6gKUja04=; b=ovQrQWgMUuCiS2J0TbehvfgGdvNDScGgbL+6hWiymu/4hk9yeorrjvjwv2A9ri4fiF4TL3 DSfT6C8e0bmVDuHDUQCzJRqttusZrTW5XX4wCU7Yj9sLULu1x4kK66+AlBBbjIUAjG9B8b 64XqhOhWkg/ctdSQbKmE8BPcVfZbk2k2cR6inZtwbnSoC1F0IYB1MxGUeqWra/EysyM5Ez qxt0eKskFmSTQ/tAboszZk03QHU7P8ZOyTxd+7hAvKgMMi3vTl00SxM61TgYLUB2M3NMJS AYqARRb1pH+8qjed7HIPkZ/WNgRcJfB3t7oIWocwmnlKWlG53ZmKHDR/Q2zjcg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1638133227; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=oVxt6RB3wq6HozhBc+E1hXItThUGltcJ9ju6gKUja04=; b=NUA/BtE19KWnZCRSqlc8MZDe4YbQjIYarpAE6lp/GjIsHlXDmVpRZHIvnhigXdHIcoaHek On6pzReK20LEQhBw== To: Marc Zyngier Cc: LKML , Bjorn Helgaas , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , linux-pci@vger.kernel.org, Greg Kroah-Hartman , Santosh Shilimkar , iommu@lists.linux-foundation.org, dmaengine@vger.kernel.org, Stuart Yoder , Laurentiu Tudor , Nishanth Menon , Tero Kristo , linux-arm-kernel@lists.infradead.org, x86@kernel.org, Vinod Koul , Mark Rutland , Will Deacon , Sinan Kaya Subject: Re: [patch 29/37] PCI/MSI: Use __msi_get_virq() in pci_get_vector() In-Reply-To: <871r30rrzq.wl-maz@kernel.org> References: <20211126224100.303046749@linutronix.de> <20211126230525.660206325@linutronix.de> <871r30rrzq.wl-maz@kernel.org> Date: Sun, 28 Nov 2021 22:00:26 +0100 Message-ID: <87tufwdmhh.ffs@tglx> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211128_130029_650404_E427C10A X-CRM114-Status: GOOD ( 18.00 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Sun, Nov 28 2021 at 19:37, Marc Zyngier wrote: > On Sat, 27 Nov 2021 01:22:03 +0000, > Thomas Gleixner wrote: > > 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; Hrm. ENODEV is returned when dev->msi.data == NULL, ENOENT when there is no MSI entry. But yes, that goes south when the device tried to enable MSI[X} and then ended up with INTx. It still has dev->msi.data, which causes it to return -ENOENT, which makes the above go belly up. Moo, what was I thinking? Thanks, tglx --- --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -1032,13 +1032,13 @@ EXPORT_SYMBOL(pci_free_irq_vectors); */ int pci_irq_vector(struct pci_dev *dev, unsigned int nr) { - int irq = __msi_get_virq(&dev->dev, nr); + unsigned int irq; - switch (irq) { - case -ENODEV: return !nr ? dev->irq : -EINVAL; - case -ENOENT: return -EINVAL; - } - return irq; + if (!dev->msi_enabled && !dev->msix_enabled) + return !nr ? dev->irq : -EINVAL; + + irq = msi_get_virq(&dev->dev, nr); + return irq ? irq : -EINVAL; } EXPORT_SYMBOL(pci_irq_vector); --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -169,21 +169,7 @@ static inline bool msi_device_has_proper } #endif -int __msi_get_virq(struct device *dev, unsigned int index); - -/** - * msi_get_virq - Return Linux interrupt number of a MSI interrupt - * @dev: Device to operate on - * @index: MSI interrupt index to look for (0-based) - * - * Return: The Linux interrupt number on success (> 0), 0 if not found - */ -static inline unsigned int msi_get_virq(struct device *dev, unsigned int index) -{ - int ret = __msi_get_virq(dev, index); - - return ret < 0 ? 0 : ret; -} +unsigned int msi_get_virq(struct device *dev, unsigned int index); /* Helpers to hide struct msi_desc implementation details */ #define msi_desc_to_dev(desc) ((desc)->dev) --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -119,21 +119,19 @@ int msi_setup_device_data(struct device } /** - * __msi_get_virq - Return Linux interrupt number of a MSI interrupt + * msi_get_virq - Return Linux interrupt number of a MSI interrupt * @dev: Device to operate on * @index: MSI interrupt index to look for (0-based) * - * Return: The Linux interrupt number on success (> 0) - * -ENODEV when the device is not using MSI - * -ENOENT if no such entry exists + * Return: The Linux interrupt number on success (> 0), 0 if not found */ -int __msi_get_virq(struct device *dev, unsigned int index) +unsigned int msi_get_virq(struct device *dev, unsigned int index) { struct msi_desc *desc; bool pcimsi; if (!dev->msi.data) - return -ENODEV; + return 0; pcimsi = msi_device_has_property(dev, MSI_PROP_PCI_MSI); @@ -152,9 +150,9 @@ int __msi_get_virq(struct device *dev, u if (desc->msi_index == index) return desc->irq; } - return -ENOENT; + return 0; } -EXPORT_SYMBOL_GPL(__msi_get_virq); +EXPORT_SYMBOL_GPL(msi_get_virq); #ifdef CONFIG_SYSFS static ssize_t msi_mode_show(struct device *dev, struct device_attribute *attr, _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel