From patchwork Fri Nov 11 13:54:15 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 13040334 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id ADC1AC4332F for ; Fri, 11 Nov 2022 13:54:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233237AbiKKNyT (ORCPT ); Fri, 11 Nov 2022 08:54:19 -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 ); 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 To: LKML Cc: x86@kernel.org, Joerg Roedel , Will Deacon , linux-pci@vger.kernel.org, Bjorn Helgaas , Lorenzo Pieralisi , Marc Zyngier , Greg Kroah-Hartman , Jason Gunthorpe , Dave Jiang , Alex Williamson , Kevin Tian , Dan Williams , Logan Gunthorpe , Ashok Raj , Jon Mason , Allen Hubbe , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org, "Ahmed S. Darwish" , Reinette Chatre Subject: [patch 01/39] PCI/MSI: Check for MSI enabled in __pci_msix_enable() References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:15 +0100 (CET) Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org 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 Reviewed-by: Ashok Raj Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe --- 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;