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 94667C433F5 for ; Sat, 27 Nov 2021 01:20:18 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id 412F282410; Sat, 27 Nov 2021 01:20:18 +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 tVWAI4UinO6c; Sat, 27 Nov 2021 01:20:17 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [IPv6:2605:bc80:3010:104::8cd3:938]) by smtp1.osuosl.org (Postfix) with ESMTPS id 268B58100D; Sat, 27 Nov 2021 01:20:17 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id D699FC001C; Sat, 27 Nov 2021 01:20:16 +0000 (UTC) Received: from smtp2.osuosl.org (smtp2.osuosl.org [140.211.166.133]) by lists.linuxfoundation.org (Postfix) with ESMTP id 443FCC000A for ; Sat, 27 Nov 2021 01:20:15 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id 1D664403B7 for ; Sat, 27 Nov 2021 01:20:15 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp2.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=linutronix.de header.b="01xVLTHM"; dkim=neutral reason="invalid (unsupported algorithm ed25519-sha256)" header.d=linutronix.de header.b="+xLyiosP" Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HA1IOM0_p3qN for ; Sat, 27 Nov 2021 01:20:14 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by smtp2.osuosl.org (Postfix) with ESMTPS id 5B09A4035C for ; Sat, 27 Nov 2021 01:20:14 +0000 (UTC) Message-ID: <20211126230524.112845775@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976012; 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: references:references; bh=PN3ExRN1k42hfHq1uj98iHzkfSIuhUpOYD8o8PLDemE=; b=01xVLTHMPuXuTeYCxg++1loVxFY22XwJw5EINvUVSLR8b6vSaVnJ4Eu3iDunii/+YGqLM6 1drlMi0SdMVbvjgfsBIj/PC0bDlRQRAjJbK5kv8969+ScHcA2xWUiPoos8LQZuh/d5d6jO D4ZE4rS/9iuO7f9eC1ny9luoPcBYIsrAVb7FPZeswFUjFFtIZXaqBBRhGMZLS9/8GAr3AR er7pPeOso93vK8TDq62PmgRQUj0m+taEbDUNcx8zjRG0i4QrPGMjYK76RagxwJyeeMhyiP I1tFT/vQYHZYOcsSJT14z3970ncLT74pAvEx8q/OQY2M3Dhgv2UuT9sGxMkwXw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976012; 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: references:references; bh=PN3ExRN1k42hfHq1uj98iHzkfSIuhUpOYD8o8PLDemE=; b=+xLyiosPdGZFZyXGwvjUBwEVY8q/I9iXLgSGR5i+pmeNwky76oEsuTtAiA8kT8N3t4LbfE qeYgv7hKS+NIrRAQ== From: Thomas Gleixner To: LKML Subject: [patch 03/37] PCI/MSI: Allocate MSI device data on first use References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:20:11 +0100 (CET) Cc: Nishanth Menon , Mark Rutland , Stuart Yoder , linux-pci@vger.kernel.org, Will Deacon , Ashok Raj , Marc Zygnier , 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 , 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" Allocate MSI device data on first use, i.e. when a PCI driver invokes one of the PCI/MSI enablement functions. Signed-off-by: Thomas Gleixner --- drivers/pci/msi/msi.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -889,10 +889,12 @@ static int __pci_enable_msi_range(struct /* deprecated, don't use */ int pci_enable_msi(struct pci_dev *dev) { - int rc = __pci_enable_msi_range(dev, 1, 1, NULL); - if (rc < 0) - return rc; - return 0; + int rc = msi_setup_device_data(&dev->dev); + + if (!rc) + rc = __pci_enable_msi_range(dev, 1, 1, NULL); + + return rc < 0 ? rc : 0; } EXPORT_SYMBOL(pci_enable_msi); @@ -947,7 +949,11 @@ static int __pci_enable_msix_range(struc int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int minvec, int maxvec) { - return __pci_enable_msix_range(dev, entries, minvec, maxvec, NULL, 0); + int ret = msi_setup_device_data(&dev->dev); + + if (!ret) + ret = __pci_enable_msix_range(dev, entries, minvec, maxvec, NULL, 0); + return ret; } EXPORT_SYMBOL(pci_enable_msix_range); @@ -974,8 +980,12 @@ int pci_alloc_irq_vectors_affinity(struc struct irq_affinity *affd) { struct irq_affinity msi_default_affd = {0}; + int ret = msi_setup_device_data(&dev->dev); int nvecs = -ENOSPC; + if (ret) + return ret; + if (flags & PCI_IRQ_AFFINITY) { if (!affd) affd = &msi_default_affd; _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu 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 smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (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 4B18AC433F5 for ; Sat, 27 Nov 2021 01:21:28 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 0263A61C15; Sat, 27 Nov 2021 01:21:28 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id uZ9-UENKqaLy; Sat, 27 Nov 2021 01:21:27 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by smtp3.osuosl.org (Postfix) with ESMTPS id C697061C08; Sat, 27 Nov 2021 01:21:26 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id A3543C0039; Sat, 27 Nov 2021 01:21:26 +0000 (UTC) Received: from smtp4.osuosl.org (smtp4.osuosl.org [IPv6:2605:bc80:3010::137]) by lists.linuxfoundation.org (Postfix) with ESMTP id A4D71C000A for ; Sat, 27 Nov 2021 01:21:25 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp4.osuosl.org (Postfix) with ESMTP id 865A44092D for ; Sat, 27 Nov 2021 01:21:25 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Authentication-Results: smtp4.osuosl.org (amavisd-new); dkim=pass (2048-bit key) header.d=linutronix.de header.b="CP7AHsOe"; dkim=neutral reason="invalid (unsupported algorithm ed25519-sha256)" header.d=linutronix.de header.b="MYTkd4Tw" Received: from smtp4.osuosl.org ([127.0.0.1]) by localhost (smtp4.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id Fozl8TehVZBv for ; Sat, 27 Nov 2021 01:21:25 +0000 (UTC) X-Greylist: domain auto-whitelisted by SQLgrey-1.8.0 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by smtp4.osuosl.org (Postfix) with ESMTPS id E664040962 for ; Sat, 27 Nov 2021 01:21:24 +0000 (UTC) Message-ID: <20211126230524.112845775@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1637976082; 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: references:references; bh=PN3ExRN1k42hfHq1uj98iHzkfSIuhUpOYD8o8PLDemE=; b=CP7AHsOeiCofaClIDYfrrlr4ZTfikHYL6L+ePsfOVaLzvytVt8rxY5MS2fPxkXF0pCPMSg BnYJd1fFxGCEvG6PkcG0aaC/fFYhs2iDYr85FcfFnW8XtwWWEERMEXzDiBETVkF5AZ/U16 3JVuF9tMf0N4ygmYCI2PA1ziqVEG6BzwXOYPkHIQuZSHwFxnwhVgL1RmeMnS4FT+Pe5XXU zaI0cY/XgwfdI5/QOvFWZctgE+QQxxMB6QQ0b5xbpqwpYQyf5V88D826ehqDVfoPAZOMm9 Oz2XWg7JmLe9HitCjTM7NdSqn03HqCSv02KSGxQ5w3MtFO0vccWWmdMKJepS7A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1637976082; 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: references:references; bh=PN3ExRN1k42hfHq1uj98iHzkfSIuhUpOYD8o8PLDemE=; b=MYTkd4TwNrAcWOX8VX/1sMslLnKJgzGhqYjt4CXqo1X6rPga6taXu0j+zxWW/MnHG6jTAA P7EBHuieujIYm2Ag== From: Thomas Gleixner To: LKML Subject: [patch 03/37] PCI/MSI: Allocate MSI device data on first use References: <20211126224100.303046749@linutronix.de> MIME-Version: 1.0 Date: Sat, 27 Nov 2021 02:21:22 +0100 (CET) Cc: Nishanth Menon , Mark Rutland , Stuart Yoder , linux-pci@vger.kernel.org, Will Deacon , Ashok Raj , Marc Zygnier , 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 , 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" Message-ID: <20211127012122.gIm5WKtQchSuFFURuPGjV0EdQp0bdMFHeUk7tDkLD_Y@z> Allocate MSI device data on first use, i.e. when a PCI driver invokes one of the PCI/MSI enablement functions. Signed-off-by: Thomas Gleixner --- drivers/pci/msi/msi.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -889,10 +889,12 @@ static int __pci_enable_msi_range(struct /* deprecated, don't use */ int pci_enable_msi(struct pci_dev *dev) { - int rc = __pci_enable_msi_range(dev, 1, 1, NULL); - if (rc < 0) - return rc; - return 0; + int rc = msi_setup_device_data(&dev->dev); + + if (!rc) + rc = __pci_enable_msi_range(dev, 1, 1, NULL); + + return rc < 0 ? rc : 0; } EXPORT_SYMBOL(pci_enable_msi); @@ -947,7 +949,11 @@ static int __pci_enable_msix_range(struc int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int minvec, int maxvec) { - return __pci_enable_msix_range(dev, entries, minvec, maxvec, NULL, 0); + int ret = msi_setup_device_data(&dev->dev); + + if (!ret) + ret = __pci_enable_msix_range(dev, entries, minvec, maxvec, NULL, 0); + return ret; } EXPORT_SYMBOL(pci_enable_msix_range); @@ -974,8 +980,12 @@ int pci_alloc_irq_vectors_affinity(struc struct irq_affinity *affd) { struct irq_affinity msi_default_affd = {0}; + int ret = msi_setup_device_data(&dev->dev); int nvecs = -ENOSPC; + if (ret) + return ret; + if (flags & PCI_IRQ_AFFINITY) { if (!affd) affd = &msi_default_affd; _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu