Message ID | 20221111122015.691357406@linutronix.de |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753917wru; Fri, 11 Nov 2022 05:59:39 -0800 (PST) X-Google-Smtp-Source: AA0mqf4XJ1JN75rKlyOxtkOkRP9SdTwcIHsX0Mrx6BoBu3W7VZ10HUnl+yBrhw9ZZBhXdALsDF7b X-Received: by 2002:a17:906:ae98:b0:7ad:d7a5:6c2a with SMTP id md24-20020a170906ae9800b007add7a56c2amr1924756ejb.138.1668175179222; Fri, 11 Nov 2022 05:59:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175179; cv=none; d=google.com; s=arc-20160816; b=mbo/KWCeYowtYL6SXI6ijXcBdvEqNPIp/B8LSqESODmON814y51B01+gMgXzV2fgTh QTmjuF7u7GHNiS27Q6Oii0k5iNaNj1IDAU+CDJuiZY9IefU+pWrN4/RVdTQej+ueTbZN uwMZ69m7cFI7fiPi1r9Qci4Ucct6iRv84F1YhD59NCaFt/FsoAVpds50GLR8j7vaoO21 9mRrgNlpzzzNMBnzgGvHvjkMSGgz0P1JjlPBSXwm9Fzsih323tANCpsv6a8bmukex5nu 8sxVCzPUIH+20rX1pTimoNzaYP2sI67NVUzra3pSrMLWCANR2TeQr+Mk7OwlQ3VhiL2I 5mFQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:mime-version:references:subject:cc:to:from :dkim-signature:dkim-signature:message-id; bh=ZT2wqZQe1H/I6Zbp9NC+LKW2/0gzRDmAQRTFrKQsKJ4=; b=jvzIR1QvRat4eQZ+Y4kOSfyt3AwATgGwj4ZeYLwc/ecjrPzQkkuWULxlf0OKKujpIU IjneUQBvA2a/pvvJiyRXDEal0gvs2w0aHc/c4MKCl5gQIzC90rFZUIdTGhQDEewNVCHQ 64R7u4s0DuA7sNLGcL+IDC5hWe3BJQQsGMBrdp0RIUjJpHow7Z+vJsK4zaF5ci7QugXM 1nvF4oFmn9X1UqxJxTuckrj4bgo+kEDZNVADk+7fHn14TXUAk8FLVS3vhtl8z89XphU4 P2Zjxs4SbJpPqYH206nifHJIPOrU8vMkaf3YyfOOfjnxRSWyg6UUq+NH1Gk05T2bGir+ KTWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pZhlEC8H; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dm4-20020a170907948400b007835897050esi2344025ejc.404.2022.11.11.05.59.14; Fri, 11 Nov 2022 05:59:39 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pZhlEC8H; dkim=neutral (no key) header.i=@linutronix.de; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234102AbiKKN5y (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Fri, 11 Nov 2022 08:57:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234050AbiKKN5A (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 11 Nov 2022 08:57:00 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FB607F572; Fri, 11 Nov 2022 05:55:14 -0800 (PST) Message-ID: <20221111122015.691357406@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174913; 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=ZT2wqZQe1H/I6Zbp9NC+LKW2/0gzRDmAQRTFrKQsKJ4=; b=pZhlEC8HQoltxfUbzgMXHkDfB0GRlxnLvSjN1dc3PiVBo8WSLYIF9ktMwc0XjNYb4kLS8+ FqTCjJWZeq1j8WqGwul0V0shm019qcC15aTTmWrBmibPa4iyBaHln17GO+B7a+FZ7HzxkG 0nigWZfumb9aUEbIyEZcIeoXLpiQyjkTbnipeH21yJ5xwmTxonq864TxZUl+LihVftel2x Ph1PWWqEcs7OLda5Ee6GdGF+KAXyt4i9XvX9Y9f9J76I48MVaA77REkSGiMVd5hEo8Wn9s 7pMPZ0LZKwuqpeWH/NkpM1YFXBbaazZjlZyRkesNTxkBHo+2AUSp+C++9BSUwA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174913; 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=ZT2wqZQe1H/I6Zbp9NC+LKW2/0gzRDmAQRTFrKQsKJ4=; b=XzyeTFE4zXDDmgsFpNdLl62MN8+2pdKYw4Ip6qUuQqqfIw4P9A9EW8A7NpauZTzTWtO0LS F5TDeOWU93205LDg== From: Thomas Gleixner <tglx@linutronix.de> To: LKML <linux-kernel@vger.kernel.org> Cc: x86@kernel.org, Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>, linux-pci@vger.kernel.org, Bjorn Helgaas <bhelgaas@google.com>, Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>, Marc Zyngier <maz@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Jason Gunthorpe <jgg@mellanox.com>, Dave Jiang <dave.jiang@intel.com>, Alex Williamson <alex.williamson@redhat.com>, Kevin Tian <kevin.tian@intel.com>, Dan Williams <dan.j.williams@intel.com>, Logan Gunthorpe <logang@deltatee.com>, Ashok Raj <ashok.raj@intel.com>, Jon Mason <jdmason@kudzu.us>, Allen Hubbe <allenbh@gmail.com>, Michael Ellerman <mpe@ellerman.id.au>, Christophe Leroy <christophe.leroy@csgroup.eu>, linuxppc-dev@lists.ozlabs.org, "Ahmed S. Darwish" <darwi@linutronix.de>, Reinette Chatre <reinette.chatre@intel.com> Subject: [patch 36/39] PCI/MSI: Validate MSIX contiguous restriction early References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Fri, 11 Nov 2022 14:55:12 +0100 (CET) X-Spam-Status: No, score=-4.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208456253206530?= X-GMAIL-MSGID: =?utf-8?q?1749208456253206530?= |
Series |
genirq, PCI/MSI: Support for per device MSI and PCI/IMS - Part 1 cleanups
|
|
Commit Message
Thomas Gleixner
Nov. 11, 2022, 1:55 p.m. UTC
With interrupt domains the sanity check for MSI-X vector validation can be
done _before_ any allocation happens. The sanity check only applies to the
allocation functions which have an 'entries' array argument. The entries
array is filled by the caller with the requested MSI-X indicies. Some drivers
have gaps in the index space which is not supported on all architectures.
The PCI/MSI irqdomain has a 'feature' bit to enforce this validation late
during the allocation phase.
Just do it right away before doing any other work along with the other
sanity checks on that array.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
drivers/pci/msi/msi.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
Comments
On Fri, Nov 11, 2022 at 02:55:12PM +0100, Thomas Gleixner wrote: > With interrupt domains the sanity check for MSI-X vector validation can be > done _before_ any allocation happens. The sanity check only applies to the > allocation functions which have an 'entries' array argument. The entries > array is filled by the caller with the requested MSI-X indicies. Some drivers > have gaps in the index space which is not supported on all architectures. > > The PCI/MSI irqdomain has a 'feature' bit to enforce this validation late > during the allocation phase. > > Just do it right away before doing any other work along with the other > sanity checks on that array. > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Bjorn Helgaas <bhelgaas@google.com> s/indicies/indices/ (commit log) s/irqdomain/irq domain/? IIRC previous logs used "irq domain" s/MSIX/MSI-X/ (subject line) > --- > drivers/pci/msi/msi.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > --- a/drivers/pci/msi/msi.c > +++ b/drivers/pci/msi/msi.c > @@ -725,13 +725,17 @@ static int msix_capability_init(struct p > return ret; > } > > -static bool pci_msix_validate_entries(struct msix_entry *entries, int nvec, int hwsize) > +static bool pci_msix_validate_entries(struct pci_dev *dev, struct msix_entry *entries, > + int nvec, int hwsize) > { > + bool nogap; > int i, j; > > if (!entries) > return true; > > + nogap = pci_msi_domain_supports(dev, MSI_FLAG_MSIX_CONTIGUOUS, DENY_LEGACY); > + > for (i = 0; i < nvec; i++) { > /* Entry within hardware limit? */ > if (entries[i].entry >= hwsize) > @@ -742,6 +746,9 @@ static bool pci_msix_validate_entries(st > if (entries[i].entry == entries[j].entry) > return false; > } > + /* Check for unsupported gaps */ > + if (nogap && entries[i].entry != i) > + return false; > } > return true; > } > @@ -773,7 +780,7 @@ int __pci_enable_msix_range(struct pci_d > if (hwsize < 0) > return hwsize; > > - if (!pci_msix_validate_entries(entries, nvec, hwsize)) > + if (!pci_msix_validate_entries(dev, entries, nvec, hwsize)) > return -EINVAL; > > /* PCI_IRQ_VIRTUAL is a horrible hack! */ >
On Fri, Nov 11, 2022 at 02:55:12PM +0100, Thomas Gleixner wrote: > With interrupt domains the sanity check for MSI-X vector validation can be > done _before_ any allocation happens. The sanity check only applies to the > allocation functions which have an 'entries' array argument. The entries > array is filled by the caller with the requested MSI-X indicies. Some drivers > have gaps in the index space which is not supported on all architectures. > > The PCI/MSI irqdomain has a 'feature' bit to enforce this validation late > during the allocation phase. > > Just do it right away before doing any other work along with the other > sanity checks on that array. > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> > --- > drivers/pci/msi/msi.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Jason
--- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -725,13 +725,17 @@ static int msix_capability_init(struct p return ret; } -static bool pci_msix_validate_entries(struct msix_entry *entries, int nvec, int hwsize) +static bool pci_msix_validate_entries(struct pci_dev *dev, struct msix_entry *entries, + int nvec, int hwsize) { + bool nogap; int i, j; if (!entries) return true; + nogap = pci_msi_domain_supports(dev, MSI_FLAG_MSIX_CONTIGUOUS, DENY_LEGACY); + for (i = 0; i < nvec; i++) { /* Entry within hardware limit? */ if (entries[i].entry >= hwsize) @@ -742,6 +746,9 @@ static bool pci_msix_validate_entries(st if (entries[i].entry == entries[j].entry) return false; } + /* Check for unsupported gaps */ + if (nogap && entries[i].entry != i) + return false; } return true; } @@ -773,7 +780,7 @@ int __pci_enable_msix_range(struct pci_d if (hwsize < 0) return hwsize; - if (!pci_msix_validate_entries(entries, nvec, hwsize)) + if (!pci_msix_validate_entries(dev, entries, nvec, hwsize)) return -EINVAL; /* PCI_IRQ_VIRTUAL is a horrible hack! */