Message ID | 20221111122013.653556720@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 l7csp752416wru; Fri, 11 Nov 2022 05:56:01 -0800 (PST) X-Google-Smtp-Source: AA0mqf5M/o6oOIfLuwSyzaDQw+yNklwE1cdJy0HQRbh7qqML29w/VuwmwNpj6VmDyyVuMGAZDByl X-Received: by 2002:a17:906:9453:b0:78d:88c7:c1bf with SMTP id z19-20020a170906945300b0078d88c7c1bfmr1892117ejx.299.1668174961211; Fri, 11 Nov 2022 05:56:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668174961; cv=none; d=google.com; s=arc-20160816; b=gMf602TXtYXkOtYKJ6JuR1HnzuHwWCJf8CUEt0TYIpwA85DtHgLZXkEkRHTdaNmhD0 FV9pWJ0NdwXAGAjKuj0SxEYUsJTy/qXkIU/W4zh+SmxfvHVt1oE/KKUbxO2IbdkUzFur 3KMYvFo4yMC3H1HSdtlDp52uy6yvu9dXcDxKvuZGHhiPtlmxW7wmOqFzG6/iQPihsgse AWb+L6E3GyfTnN9EvlyeyFXy9210kqtk7H5gzQ37EcYzi7IY7u5/0yjnRJjnk06ezcgh XNAiwIcPem4WLP1sqd3kexRv9gYoONI5mSUvxrpwQhsuRdfXuHdzM1qWZsINsROIy9tr pmwg== 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=coIIhyuiXnYLFo01pBIKB6JYTvWHpv/omCaoVJDpJVg=; b=MEBdeIxU14mqafDkfPt26uKjL2Xjzy6E6/IizRe1jNxrHSti65Wzm/yNoFPuywHJ8T nRmD89Ybnsbmyr7azEqHAbd4zOY7H6dv75m88OPChgqqmwBDzo5zpaxgzwxlbgbEE9et KhsBYUtVKdOJyKguSgd2tbT8bsBbch7K5XdlIS7y848ohOjJKK/hDz9wVERvDrdzqM7a znjDT8CvViNCun25AXTllabEt+E+8t+YBPa9GwQ6VsAlCf0IOdFDDm5u2KaY57B1wfRR snm6Pn38QDGGBHUDLprfbAb6m86sUGkZtBZOkiCub2jz3ZkWFaXi22LN5tQ/ILJFvE5y P5Qg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="s/U6Zaar"; dkim=neutral (no key) header.i=@linutronix.de header.b=dp0qPLUF; 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 m15-20020a056402510f00b00467631dfc0esi609920edd.145.2022.11.11.05.55.24; Fri, 11 Nov 2022 05:56:01 -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="s/U6Zaar"; dkim=neutral (no key) header.i=@linutronix.de header.b=dp0qPLUF; 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 S233456AbiKKNyU (ORCPT <rfc822;winker.wchi@gmail.com> + 99 others); Fri, 11 Nov 2022 08:54:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231300AbiKKNyS (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 11 Nov 2022 08:54:18 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 328F8450A0; Fri, 11 Nov 2022 05:54:18 -0800 (PST) Message-ID: <20221111122013.653556720@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174856; 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=coIIhyuiXnYLFo01pBIKB6JYTvWHpv/omCaoVJDpJVg=; b=s/U6Zaar7ls0H2qsLwsr8aiLFHuaVuhBicdGJQADmCq0O1hvJG7u/w86lF2pDffDWPTkcK gh8pG+58CQS0JvliEiWZUIO1OP4VoMfKp7GIDpkbtmTydLSos0uJJgDnN/82RrN+m008Kt pcwRsAEtTCkDN13TliZ7P5bqc8kQ5lCR1U2UuWXy9DlSHjPbnsBlUUYlCt04j2jwTsqa3m 9GphyvrVWAYxNrMF8zid+S1JgBioKKpAd0OFleA65Swb5lIVMH3c8mMR4C+u/t0s9BUSSG xoJAFwa/EQettO0NoV+mbrN0EtHCiVpqcGAhEt6tg8oZ6PY6ayrjDrl4po72Xg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174856; 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=coIIhyuiXnYLFo01pBIKB6JYTvWHpv/omCaoVJDpJVg=; b=dp0qPLUFHHtY136HpcXF3x8yJlJhKmtWn4q1Z9ZhO7otN+4+TDH5MHXbJ5zxxaIjm2DPmE huK/q0vb/nufNPDA== 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 01/39] PCI/MSI: Check for MSI enabled in __pci_msix_enable() References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Date: Fri, 11 Nov 2022 14:54:15 +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?1749208228234037004?= X-GMAIL-MSGID: =?utf-8?q?1749208228234037004?= |
Series |
genirq, PCI/MSI: Support for per device MSI and PCI/IMS - Part 1 cleanups
|
|
Commit Message
Thomas Gleixner
Nov. 11, 2022, 1:54 p.m. UTC
PCI/MSI and PCI/MSI-X are mutually exclusive, but the MSI-X enable code
lacks a check for already enabled MSI.
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
---
drivers/pci/msi/msi.c | 5 +++++
1 file changed, 5 insertions(+)
Comments
On Fri, Nov 11, 2022 at 02:54:15PM +0100, Thomas Gleixner wrote: > PCI/MSI and PCI/MSI-X are mutually exclusive, but the MSI-X enable code > lacks a check for already enabled MSI. > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> > --- > drivers/pci/msi/msi.c | 5 +++++ > 1 file changed, 5 insertions(+) > > --- a/drivers/pci/msi/msi.c > +++ b/drivers/pci/msi/msi.c > @@ -935,6 +935,11 @@ static int __pci_enable_msix_range(struc > if (maxvec < minvec) > return -ERANGE; > > + if (dev->msi_enabled) { > + pci_info(dev, "can't enable MSI-X (MSI already enabled)\n"); > + return -EINVAL; > + } > + nit: Can the pre-enabled checks for msi and msix be moved up before any vector range check? not that it matters for how it fails, does EBUSY sound better? looks good. Reviewed-by: Ashok Raj <ashok.raj@intel.com> > if (WARN_ON_ONCE(dev->msix_enabled)) > return -EINVAL;
On Fri, Nov 11, 2022 at 02:54:15PM +0100, Thomas Gleixner wrote: > PCI/MSI and PCI/MSI-X are mutually exclusive, but the MSI-X enable code > lacks a check for already enabled MSI. > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Acked-by: Bjorn Helgaas <bhelgaas@google.com> > --- > drivers/pci/msi/msi.c | 5 +++++ > 1 file changed, 5 insertions(+) > > --- a/drivers/pci/msi/msi.c > +++ b/drivers/pci/msi/msi.c > @@ -935,6 +935,11 @@ static int __pci_enable_msix_range(struc > if (maxvec < minvec) > return -ERANGE; > > + if (dev->msi_enabled) { > + pci_info(dev, "can't enable MSI-X (MSI already enabled)\n"); > + return -EINVAL; > + } > + > if (WARN_ON_ONCE(dev->msix_enabled)) > return -EINVAL; > >
On Fri, Nov 11, 2022 at 02:54:15PM +0100, Thomas Gleixner wrote: > PCI/MSI and PCI/MSI-X are mutually exclusive, but the MSI-X enable code > lacks a check for already enabled MSI. > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> > --- > drivers/pci/msi/msi.c | 5 +++++ > 1 file changed, 5 insertions(+) Reviewed-by: Jason Gunthorpe <jgg@nvidia.com> Jason
On Wed, Nov 16 2022 at 07:39, Ashok Raj wrote: > On Fri, Nov 11, 2022 at 02:54:15PM +0100, Thomas Gleixner wrote: > > Can the pre-enabled checks for msi and msix be moved up before any vector > range check? > > not that it matters for how it fails, does EBUSY sound better? Does any caller care about the error code or about the ordering in which the caller stupity is detected?
On Thu, Nov 17, 2022 at 02:07:33PM +0100, Thomas Gleixner wrote: > On Wed, Nov 16 2022 at 07:39, Ashok Raj wrote: > > On Fri, Nov 11, 2022 at 02:54:15PM +0100, Thomas Gleixner wrote: > > > > Can the pre-enabled checks for msi and msix be moved up before any vector > > range check? > > > > not that it matters for how it fails, does EBUSY sound better? > > Does any caller care about the error code or about the ordering in which > the caller stupity is detected? No, I don't think so. That's why I prefixed it with "not that it matters" :-) Just thought it would be good hygiene, but doesn't change anything functionally.
> From: Thomas Gleixner <tglx@linutronix.de> > Sent: Friday, November 11, 2022 9:54 PM > > PCI/MSI and PCI/MSI-X are mutually exclusive, but the MSI-X enable code > lacks a check for already enabled MSI. > > Signed-off-by: Thomas Gleixner <tglx@linutronix.de> > --- > drivers/pci/msi/msi.c | 5 +++++ > 1 file changed, 5 insertions(+) > > --- a/drivers/pci/msi/msi.c > +++ b/drivers/pci/msi/msi.c > @@ -935,6 +935,11 @@ static int __pci_enable_msix_range(struc > if (maxvec < minvec) > return -ERANGE; > > + if (dev->msi_enabled) { > + pci_info(dev, "can't enable MSI-X (MSI already enabled)\n"); > + return -EINVAL; > + } > + > if (WARN_ON_ONCE(dev->msix_enabled)) > return -EINVAL; > a same check remains in __pci_enable_msix(): /* Check whether driver already requested for MSI IRQ */ if (dev->msi_enabled) { pci_info(dev, "can't enable MSI-X (MSI IRQ already assigned)\n"); return -EINVAL; } return msix_capability_init(dev, entries, nvec, affd); It's removed later in patch33 when sanitizing MSI-X checks. But logically the removal can come with this patch.
--- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -935,6 +935,11 @@ static int __pci_enable_msix_range(struc if (maxvec < minvec) return -ERANGE; + if (dev->msi_enabled) { + pci_info(dev, "can't enable MSI-X (MSI already enabled)\n"); + return -EINVAL; + } + if (WARN_ON_ONCE(dev->msix_enabled)) return -EINVAL;