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: 18747 Return-Path: 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 + 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 ); 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) 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: 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?= 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; From patchwork Fri Nov 11 13:54:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18754 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp752663wru; Fri, 11 Nov 2022 05:56:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf4KiUhMYs9+F/oFiAetmXk+lLZf+7wUo5iY53RzjdRSlN+drJNOeOU7G/aZoRZ+OumTpY5z X-Received: by 2002:a50:fd15:0:b0:458:fc30:f1ff with SMTP id i21-20020a50fd15000000b00458fc30f1ffmr1538792eds.132.1668174993680; Fri, 11 Nov 2022 05:56:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668174993; cv=none; d=google.com; s=arc-20160816; b=P0SNSRkgXU3RacIs9P//1TGS6iyEERxvHsJGU48pVMj23tl1TyC+JFI3Q8C2BKRDfH lvUp8450xj6M9mYtWZ1MBWeB884fRf7R2Z+nRWCb75fmhQI0bVqPTwGQ8kjOW5d72lVu n7zJOR2jBOf95AjE0MNRX+QB+Su8kgoE9RgNXp3KHvQXEI2gdK2nkIwjos4UBPCzTe1d wxAGBi3GLF44IW4dtEAwihU52StRNmgbuzNi2IkOM0nQe/DzQVpdO0WHAXsWmlmugyav BiVESsW+lpPEmNUChC9ebUVGw2uLh1Jpw1553zC+jd9EEvB3RZG4XQeg/6tCHOaTj8N7 vbAQ== 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=lEZvgy6HHUzbXINFeZhEm07cTVI+tuFx6PeXgAOnbxo=; b=WusGcamzaNreYkzs+SHxGU0UmjG21AOCiEEswJB1exRSb4FFisIPKT2zWuXzl9bUJi G9UqI+kqf4oTn/EhJseSa3hYkltz4vMWFueHlsZwNKE4AciQ9YvWpnMovsI95G9Nn5nG bjky0inJswMEXGPxC3Kb4HhLaTHif+rrkYWTBf762BZDLW/E6Ib5FYsLPqlXSRDx2KmD ntRN0cDnq/dSP3D4tyh5gtLlguZUuo8eL5aaCAM0hwAsQaJYxraQGD5q7mmeK2H8Ls2e 1eYJ2hm1VhgfRXPMsq9ssQ0KGVfC/fIsTcFhDF+1k9muH5s580UENXXivXo3pFYnEfEK yQLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="d/SC/+T3"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 d15-20020a1709063ecf00b007ad8bc64c89si1448549ejj.701.2022.11.11.05.55.34; Fri, 11 Nov 2022 05:56:33 -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="d/SC/+T3"; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S233308AbiKKNy1 (ORCPT + 99 others); Fri, 11 Nov 2022 08:54:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233395AbiKKNyT (ORCPT ); Fri, 11 Nov 2022 08:54:19 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B35849B45; Fri, 11 Nov 2022 05:54:19 -0800 (PST) Message-ID: <20221111122013.713848846@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174857; 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=lEZvgy6HHUzbXINFeZhEm07cTVI+tuFx6PeXgAOnbxo=; b=d/SC/+T3CdcHrZ8MbLToM6SSgF7cmkTyPqkaOcSGfaaP5mtPj0fjgr8rnBLbwbwdHmYuYk 7SKAOEcT6nKblCt9++hnKZvd+jnkTl1ZCW97zgckpAOxOBJmCDcHjFZupqhfm+PjbkhQpC Ckkz+Hj5GFVPZ1huA0zuyZ4hM4+gKcRlEFFA6OkAyaW7XRBfOils813Wxb61S8hx7uF8YS FPIL8fs5LmFd8YyN/0q1ix84xHIH4WCefuDCyBQmTAKbmEhRdRl4r/t8EE8uoiDCjoenXT EZBdsG29ygGfSFeQEzfgGUkF5RfcjPEM2Ne/1LcpX0GDjhCM/BBOezUEg+g0jQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174857; 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=lEZvgy6HHUzbXINFeZhEm07cTVI+tuFx6PeXgAOnbxo=; b=eImqZwzolHHQM3N4D4bpfBwXxwGdxDtOGKetRv0eo1dAL0/gfurg2TqhJroXzqv0ZskPkU k56t5cHRVmzfcUCQ== 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 02/39] iommu/vt-d: Remove bogus check for multi MSI-X References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:17 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208262382472286?= X-GMAIL-MSGID: =?utf-8?q?1749208262382472286?= PCI/Multi-MSI is MSI specific and not supported for MSI-X. Signed-off-by: Thomas Gleixner Reviewed-by: Ashok Raj --- drivers/iommu/intel/irq_remapping.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/iommu/intel/irq_remapping.c +++ b/drivers/iommu/intel/irq_remapping.c @@ -1334,8 +1334,7 @@ static int intel_irq_remapping_alloc(str if (!info || !iommu) return -EINVAL; - if (nr_irqs > 1 && info->type != X86_IRQ_ALLOC_TYPE_PCI_MSI && - info->type != X86_IRQ_ALLOC_TYPE_PCI_MSIX) + if (nr_irqs > 1 && info->type != X86_IRQ_ALLOC_TYPE_PCI_MSI) return -EINVAL; /* From patchwork Fri Nov 11 13:54:19 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18749 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp752466wru; Fri, 11 Nov 2022 05:56:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf6i1Ch+wB3fOIlGpraujdPFzKYAybNuLnjyTievfM53ejm+EVfEtK+ZkU9w2PSfEd2ZaH9w X-Received: by 2002:a17:907:110d:b0:7a9:6107:572a with SMTP id qu13-20020a170907110d00b007a96107572amr1887317ejb.729.1668174967120; Fri, 11 Nov 2022 05:56:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668174967; cv=none; d=google.com; s=arc-20160816; b=ZfF1o4Dudj+W7uEluc0QpZojFZ8ERSX4hSTLcldowADOtm6HLsX660mXJFcw+RQZuG kR9ONChxcUvPCAktgUmnLPiPC/2yCxz9Ob4XTkqG3BGekOPyiNF3dvmMdcWQamBTP/7R SkPIlYsbq1uRDTQArNNlBpck+9B4W8w28EIM7wBXkqbHq6Li7QOUOaj3eNxZQYAXj6MI OiPRctqzHhsiWLIlGo45MDPqrF/5nLe42AlUa0gXU2uXTqtjie05LJRDzBAFj7flbvvr aH0D+DJuTn78JvhNLrKB7ouv/qx8aSALsaXUMocOwJhR3k8J5YGo1DHUvvJYn0NnQQpT J2vg== 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=A5gxwhjOfYDDe9pKor0TACcvTNvwKPr4BmNEQMHYUXM=; b=HPFB7prqIazBQ8Ii4HjcC+JuuGzqirUdtNqPOfWmPjXQ1MFTkDjR2xzsKEe4EMeG77 0iKUnTJkMEuN4d5Q36IYSQr00AFMYjnhRcrzLakwCGn7EQNKTTX5+YloTysfCvHPJYCa sJ89IKNZCZT1GkyKP9gMqMrq8cbJm3LSakvUU5nKrUhQCsz8pChP4FepTq4kxS7CeRst W1tNNicgofdGkZ38NuD6ZvatXbYLFM1/PEAwCLn3ThVZ7N1kk0wEfmCos6vY1IDcpAL9 lQ8nkgt6ady5j8V+9Xm3KLVEVhJ46ZDfqgaLTSYmkFOE1u6i4dh3bqOsLdTAUeUbc43E 7m5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=2Fw81I21; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=nfZOapQu; 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 i3-20020a05640242c300b0045c7611d8ddsi1500257edc.179.2022.11.11.05.55.43; Fri, 11 Nov 2022 05:56:07 -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=2Fw81I21; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=nfZOapQu; 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 S233553AbiKKNyg (ORCPT + 99 others); Fri, 11 Nov 2022 08:54:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57746 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233466AbiKKNyV (ORCPT ); Fri, 11 Nov 2022 08:54:21 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E1EFF657E6; Fri, 11 Nov 2022 05:54:20 -0800 (PST) Message-ID: <20221111122013.772447165@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174859; 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=A5gxwhjOfYDDe9pKor0TACcvTNvwKPr4BmNEQMHYUXM=; b=2Fw81I21MoAKaeHMvY8ErYps4l1IO750NK6h0Rw5RZWIkRe1THjaR3X9HOgWaw0l0mTY3s Ll/dD746mdb0yAlQ0ov5sWM+AUpitCcs3HH2sgJgDOjn4vJMHJ7fU7zVpfvS6ftBxmpMqN 3lNkZB4zUY5dQCXSdvJRx9miYjQo5pscOVVZiUT43KjB5ToV7Gf6LBOoyJeBaDHV34hPBt Kov5aUw/Nj5pOGw+zbQh01L3MNB9F/dqZYgM8k0EV9pZZdCg7t9WZLyUA2eNreUXI3U/Xg YGxOHz7tgOcX14fftMFVLmC0ys4b/FRIRn7D0mnNGwj+0dhV8PWJeucTy3fKZg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174859; 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=A5gxwhjOfYDDe9pKor0TACcvTNvwKPr4BmNEQMHYUXM=; b=nfZOapQueWw+bWDWb8DtO7mx9RdWBuPX7UZNwtQUy7EXN7HJhuDTmRaao/o2kWTcYU4fDr 5a1Y5VotFiqrI7Bg== 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 03/39] iommu/amd: Remove bogus check for multi MSI-X References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:19 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208234392125048?= X-GMAIL-MSGID: =?utf-8?q?1749208234392125048?= PCI/Multi-MSI is MSI specific and not supported for MSI-X Signed-off-by: Thomas Gleixner --- drivers/iommu/amd/iommu.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -3294,8 +3294,7 @@ static int irq_remapping_alloc(struct ir if (!info) return -EINVAL; - if (nr_irqs > 1 && info->type != X86_IRQ_ALLOC_TYPE_PCI_MSI && - info->type != X86_IRQ_ALLOC_TYPE_PCI_MSIX) + if (nr_irqs > 1 && info->type != X86_IRQ_ALLOC_TYPE_PCI_MSI) return -EINVAL; /* From patchwork Fri Nov 11 13:54:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18750 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp752515wru; Fri, 11 Nov 2022 05:56:13 -0800 (PST) X-Google-Smtp-Source: AA0mqf52WaPfzjtS0OAYxD67Uf23P0C4XQ71fcPXAvl8qFEwN8ZnMAvtl9mQkMAFov51MxoH7AC9 X-Received: by 2002:a17:906:1613:b0:7a2:fa90:924 with SMTP id m19-20020a170906161300b007a2fa900924mr1885480ejd.674.1668174973282; Fri, 11 Nov 2022 05:56:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668174973; cv=none; d=google.com; s=arc-20160816; b=g69ubUtGBdJrfud3Or3nOsaQSwh7Ou2muY6hyxLjtny+CgAI//fPrpgwNmkkv36Q1K 6Mj4mpDze3Or5AD1brXPq0Ta7jlJpBzGea7Cfl4DlRh09H12FLUaCFFRuAEyHF3JbTTd MuUUXMbXB/vS2NdnZDKaU3pfcxy5+fApzTyjxamMkXwhszaVrQHYMrnQHr4XpE81P/D/ L23otOZ27quQjcWRlEBSTzKbOOAatda4CZmp2fxSAXyYGa/XmGfW7cvsQwmSLZx+bv32 0h2DiD3y6e/LGy/BlO6ma3XK9WGC9YSchVsG0MHFtR3TW2RFZj7Sw/ttVT+ojwQuRitY J4gQ== 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=hXGyAAuT/IU9qjkYv54P57CF8Kg9D2gsGu3taE3+4kw=; b=rtHXZ2Ct1ATFNH3Jk8dQrCdF1L/Jj03U+9nqaplf3qywU8sWPVao+qvKQQUJWHf4OV Q2DF+ABSU2QtDmUg6xKX5y//1wROf2AmeTqSpgUUaWpSWlPTUmmMGAhAgY5LIOrtDKvN FLGUHy6089/ywYv+idpC70SQW7u6E4fYYmfivnhvtABguTqRPGqT6VELExHKjNVwhnny 4MFU//K9ouFzCTIPGGbs/s/VEmaeidOOJzlcL2Bx2CMif5Pj8nRblZVrv50lWgAhj8xC 4vWo3VcL40pirI+vSZ3J9v3n3dTxoGJmGIOuiB4Ingpio7PSTqPi7c9KM3LrtVCnuO+2 8pQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Q+w7rfhi; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 qb24-20020a1709077e9800b0078db5170767si2397297ejc.18.2022.11.11.05.55.49; Fri, 11 Nov 2022 05:56:13 -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=Q+w7rfhi; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S233552AbiKKNyl (ORCPT + 99 others); Fri, 11 Nov 2022 08:54:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233483AbiKKNyX (ORCPT ); Fri, 11 Nov 2022 08:54:23 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 849DD6B380; Fri, 11 Nov 2022 05:54:22 -0800 (PST) Message-ID: <20221111122013.831151822@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174861; 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=hXGyAAuT/IU9qjkYv54P57CF8Kg9D2gsGu3taE3+4kw=; b=Q+w7rfhi1CD/id8ozBrg2Q21W5nVKor55fq9WBt8lCSQOVHcaMdncE2KL8ROw5Fn3DJ9Wy C6Gq/MFoG/TdPdL4180NCcfok/4hREfFzaUBJ2BmjZ4CE+WN7WxTwWtSOLaJ3+LD9kYY1j TeMFKUGxFAbHhfzCAwnA3C119hea+KSW+lcpY1H4pdCjjM97PrlqTIGom3CT1l9I0ocFXD G10ovxb7yJ25ZsdRupfmuMU0Sra+dE3GF4bYWQ/7cPGDS+UTUyJkHMxazfENu7wjY2KpoV n9hEYT+9jQQ5Lr1oLQSUrUgQfs9mO1k5gyzHqyjF8kOdb1h0q7MIXG+o1lSBMA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174861; 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=hXGyAAuT/IU9qjkYv54P57CF8Kg9D2gsGu3taE3+4kw=; b=cdP8Z8xVU6B5EEH8jHzk7TfeiPxnZMmWed+TgxJS3tdmgdVHc4X28EdbDT2icsz8tJCHaq CTp0kZmpTRg7YJAA== 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 04/39] genirq/msi: Use MSI_DESC_ALL in msi_add_simple_msi_descs() References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:20 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208240541448530?= X-GMAIL-MSGID: =?utf-8?q?1749208240541448530?= There are no associated MSI descriptors in the requested range when the MSI descriptor allocation fails. Use MSI_DESC_ALL as the filter which prepares the next step to get rid of the filter for freeing. Signed-off-by: Thomas Gleixner Reviewed-by: Ashok Raj Reviewed-by: Jason Gunthorpe --- kernel/irq/msi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -120,7 +120,7 @@ static int msi_add_simple_msi_descs(stru fail_mem: ret = -ENOMEM; fail: - msi_free_msi_descs_range(dev, MSI_DESC_NOTASSOCIATED, index, last); + msi_free_msi_descs_range(dev, MSI_DESC_ALL, index, last); return ret; } From patchwork Fri Nov 11 13:54:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18752 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp752561wru; Fri, 11 Nov 2022 05:56:20 -0800 (PST) X-Google-Smtp-Source: AA0mqf4XPStNRa0FxwV7HDtXfYcFWoB8KVRuD4vDgoO6idF+T3TrBMeEU6wisjAws82esOCzU/q3 X-Received: by 2002:a17:907:2904:b0:78d:8b9b:de8c with SMTP id eq4-20020a170907290400b0078d8b9bde8cmr1868563ejc.436.1668174980184; Fri, 11 Nov 2022 05:56:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668174980; cv=none; d=google.com; s=arc-20160816; b=jiv0Zr0U35QRJ4ceWXGgp74G1wBvpS1cbyEHOykryvCKEp1SkZ8XbNErQFmxakfijT jmQbkqwGgNjmIjFIVXZA+ATKEDTVT1rfAvLPRGzn/8Zet+THXCUdzNpOXVMRiGGVnogZ bGkHfcDAN12GsMxzr2D37+rluMaXs0ToGSqQj2eXs1XVVuuagYx2iAdIuPXtA83YGoBH bgJAXnvg/bwlz7N907ALYQO6Ezgf5fkcU+AhOJ52/bowIinyxZZRDaUFtGy9dTjEw53/ eLGHvbEIY+q4Fz01Wd5V+Il7/y3Yp8H4cTdcA3bq2mF+jY5gBKpQU5h/l9v+pC2/wpMB OKkA== 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=efOtDMgGZtrOq2C93xDB3bkE3dnMFMUi6PhL2K3F+Xc=; b=IYp+gMtMuqzuyi8rIAxCrr6iPi8FDsb3HJEOzxbJWyWwTfXLY2eY4Crm1bqSYLzZKy DW7RGeippZZXb0/mc2/Kd5a8QjLZrprLKBPRcHaYftpYzZUtgkOk1UKO0L+41w8mXGva S6WeGq+U6Q0jdbhscrcfnWntsvVNfKdU/0cvdhTDtLdiPs4SQkPztrEXC+6CQYDz0oLu 1+JWS59ZhjAa9iZ5XaZD7BMgp4ZrhNmgla3L1b4Hmnx7hrtL1NQVev8DQ4yu3yTaRNnl T3xXf/5z1brkj+8wrQrvK3+bF0IXD6qeiizrJAJjw/jgNJP8YqbyjPSMLBNsn+Kgfn7j D3Sg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OGgspOZe; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 cs15-20020a170906dc8f00b007ad2d85d753si1989777ejc.495.2022.11.11.05.55.55; Fri, 11 Nov 2022 05:56:20 -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=OGgspOZe; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S233690AbiKKNyy (ORCPT + 99 others); Fri, 11 Nov 2022 08:54:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233518AbiKKNyY (ORCPT ); Fri, 11 Nov 2022 08:54:24 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2220F654F6; Fri, 11 Nov 2022 05:54:24 -0800 (PST) Message-ID: <20221111122013.888850936@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174862; 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=efOtDMgGZtrOq2C93xDB3bkE3dnMFMUi6PhL2K3F+Xc=; b=OGgspOZeBC55SSE4L/03t3Yj8kEAUvaCDyesgMfIQ/8qhXJLoIiwTqSD0usnmt+jNWsGxe jJQIhOK2glpk+B7OSR+bSxnJRrGYjm7l6+v8O35MDAj8CaLu4GeF+phCjLDtbCTxh5572M +ZpPJAvMXeUjr0mPgIt+9+snp1r51HIvN8aPT4w0auBrP/NkfAAUYZzp759bwdCn1Kq78A lb32ySTfELSWx1/+L0w3PdN47RZdW50J4E5gvQQfzie7ob1/CZlWpi2e3Wn5ebKYWS0ZtB zSBgFrBCzs8wHVGv86iPTFC38nFfQbhWVVsDO/a8gXoX8MLGY2aFp0qzQ9nWRA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174862; 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=efOtDMgGZtrOq2C93xDB3bkE3dnMFMUi6PhL2K3F+Xc=; b=sIAyS0gBMPiZE7rx+h8POgBoJq70Rx877SA8g16n791fowonYh2meMpqEAwdbzM0ajaQbK ljBVTKfudKOlfWCg== 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 05/39] genirq/msi: Remove filter from msi_free_descs_free_range() References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:22 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208248353951191?= X-GMAIL-MSGID: =?utf-8?q?1749208248353951191?= When a range of descriptors is freed then all of them are not associated to a linux interrupt. Remove the filter and add a warning to the free function. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe Tested-by: Miquel Raynal --- drivers/base/platform-msi.c | 2 +- include/linux/msi.h | 5 ++--- kernel/irq/msi.c | 19 ++++++++++--------- 3 files changed, 13 insertions(+), 13 deletions(-) --- a/drivers/base/platform-msi.c +++ b/drivers/base/platform-msi.c @@ -325,7 +325,7 @@ void platform_msi_device_domain_free(str msi_lock_descs(data->dev); irq_domain_free_irqs_common(domain, virq, nr_irqs); - msi_free_msi_descs_range(data->dev, MSI_DESC_ALL, virq, virq + nr_irqs - 1); + msi_free_msi_descs_range(data->dev, virq, virq + nr_irqs - 1); msi_unlock_descs(data->dev); } --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -247,8 +247,7 @@ static inline void pci_write_msi_msg(uns #endif /* CONFIG_PCI_MSI */ int msi_add_msi_desc(struct device *dev, struct msi_desc *init_desc); -void msi_free_msi_descs_range(struct device *dev, enum msi_desc_filter filter, - unsigned int first_index, unsigned int last_index); +void msi_free_msi_descs_range(struct device *dev, unsigned int first_index, unsigned int last_index); /** * msi_free_msi_descs - Free MSI descriptors of a device @@ -256,7 +255,7 @@ void msi_free_msi_descs_range(struct dev */ static inline void msi_free_msi_descs(struct device *dev) { - msi_free_msi_descs_range(dev, MSI_DESC_ALL, 0, MSI_MAX_INDEX); + msi_free_msi_descs_range(dev, 0, MSI_MAX_INDEX); } void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg); --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -120,7 +120,7 @@ static int msi_add_simple_msi_descs(stru fail_mem: ret = -ENOMEM; fail: - msi_free_msi_descs_range(dev, MSI_DESC_ALL, index, last); + msi_free_msi_descs_range(dev, index, last); return ret; } @@ -141,12 +141,11 @@ static bool msi_desc_match(struct msi_de /** * msi_free_msi_descs_range - Free MSI descriptors of a device * @dev: Device to free the descriptors - * @filter: Descriptor state filter * @first_index: Index to start freeing from * @last_index: Last index to be freed */ -void msi_free_msi_descs_range(struct device *dev, enum msi_desc_filter filter, - unsigned int first_index, unsigned int last_index) +void msi_free_msi_descs_range(struct device *dev, unsigned int first_index, + unsigned int last_index) { struct xarray *xa = &dev->msi.data->__store; struct msi_desc *desc; @@ -155,10 +154,12 @@ void msi_free_msi_descs_range(struct dev lockdep_assert_held(&dev->msi.data->mutex); xa_for_each_range(xa, idx, desc, first_index, last_index) { - if (msi_desc_match(desc, filter)) { - xa_erase(xa, idx); - msi_free_desc(desc); - } + xa_erase(xa, idx); + + /* Leak the descriptor when it is still referenced */ + if (WARN_ON_ONCE(msi_desc_match(desc, MSI_DESC_ASSOCIATED))) + continue; + msi_free_desc(desc); } } @@ -739,7 +740,7 @@ int msi_domain_populate_irqs(struct irq_ fail: for (--virq; virq >= virq_base; virq--) irq_domain_free_irqs_common(domain, virq, 1); - msi_free_msi_descs_range(dev, MSI_DESC_ALL, virq_base, virq_base + nvec - 1); + msi_free_msi_descs_range(dev, virq_base, virq_base + nvec - 1); unlock: msi_unlock_descs(dev); return ret; From patchwork Fri Nov 11 13:54:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18753 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp752647wru; Fri, 11 Nov 2022 05:56:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf4KgmNIkXCX4F8FJksDYI4SiBIvhB/hUC7xBZYxVcBtRVeEE9JsZIlmpAzcIWmr/MxApmcN X-Received: by 2002:a17:906:141b:b0:78d:5176:c4d2 with SMTP id p27-20020a170906141b00b0078d5176c4d2mr1842321ejc.532.1668174989977; Fri, 11 Nov 2022 05:56:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668174989; cv=none; d=google.com; s=arc-20160816; b=A7NL568PMnzA5QUOiFZNRudm01SXuIJmafXovLeIjRExrp0qEqzSomEHwXE1AuXYnK xm/TIUUoytlimW9tlibRf02tpslOXBP5Kur1xfg6/MWB6LwjWyI9H7obmCvyJu6GMMfV JKIEGtMLEfhxV/0XDkG3v7LVssrdV6uVH75ED8cRMuKthxamnqCAiiVkJYeYr/DBm1HI z3SyrgCBw/ZYjIkJKqWFoZpeyc2JTKvY2mQhSC2jmK0EnwY1aKILX+BmSuzwLXPXyoPE aNdU3GzgLqPOLd+JOfJ7cAtOANGAjctjl/ESswxJNLdsAtrHmZI8rVx4lQXLoZzRQM/R jH/w== 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=DzwMVitVEwpsnJRYX1GqcWllvAqc3k0vBxAI8Er+FBs=; b=MvTqvh1UM1lvLXzP4teowOwSox9NCroqDqt1nEHy5rWMTECe3Be7yC8vI+naz4HaSk eeedDh1cDUgCaDWR5kVclz51dGm7z7SjEwp0UxUVxiQcnStYiQl6xBYAPwdluJkGNoNX U65gLztDFC91dqf4flFbpilgC85mWE1AUujrw+F3z3yiZ+TX07UIwXz9cp9a557vkgQJ h04+nxEhjN8y6jmp0ie7BOyDeGJVUAUZGYyaonROtRvinjWp71h8t73e7Jxl5vWQwHET QTVFhBsa19pCPOFcQvlCdFGDT8XCSXbiLr3jqdj4kWnQ9+7IW2yg9xa2V9IiNaC8litv Lmug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=rM3Hvm2A; 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 w21-20020a170907271500b00781b66e7065si1473456ejk.240.2022.11.11.05.56.04; Fri, 11 Nov 2022 05:56:29 -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=rM3Hvm2A; 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 S233641AbiKKNy6 (ORCPT + 99 others); Fri, 11 Nov 2022 08:54:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233564AbiKKNym (ORCPT ); Fri, 11 Nov 2022 08:54:42 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BA1575CD10; Fri, 11 Nov 2022 05:54:25 -0800 (PST) Message-ID: <20221111122013.947071142@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174864; 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=DzwMVitVEwpsnJRYX1GqcWllvAqc3k0vBxAI8Er+FBs=; b=rM3Hvm2A/73BTlgf/cJ63LRmKDRdAAwY5hxOMDRVqxPwJ3lk7tngBwLUDRQqeuz3V9+rh2 UK742ef9qcpZt85XVhtCPr67bCbu6J8HmHF9/OXUHWpBeASoZHKjXY5LPgDIXkVvpfcUrh 0Fy4d5HpPhKpH8TTLrDqDqP9eJUC4nLW6rPv1G/xbxvW0jE9wO+lR5tz8qZ51i7kz2/WdY HNOhZ6XfV5J0TFdNls9y7zjvYcuIerly6Q1R1KkISjg1mNrIwlh4L7Xc9RsSXApFGVviKb +27SOaCWk/l8xdmgBcHsAANAKPHRSa11nAfqQyh5L2hBCPUHmS6cP+bbtIJm3A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174864; 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=DzwMVitVEwpsnJRYX1GqcWllvAqc3k0vBxAI8Er+FBs=; b=61OFjcySwk55/wM8ZG3QX632+240BfUAoDJeeBKxzaHUj49wFuflEH1l5zdnt0rEJuHj6f WudG4TZAewxnW2BQ== 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 06/39] genirq/msi: Add missing kernel doc to msi_next_desc() References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:23 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208258342966110?= X-GMAIL-MSGID: =?utf-8?q?1749208258342966110?= W=1 complains about this. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe --- kernel/irq/msi.c | 1 + 1 file changed, 1 insertion(+) --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -282,6 +282,7 @@ EXPORT_SYMBOL_GPL(msi_first_desc); /** * msi_next_desc - Get the next MSI descriptor of a device * @dev: Device to operate on + * @filter: Descriptor state filter * * The first invocation of msi_next_desc() has to be preceeded by a * successful invocation of __msi_first_desc(). Consecutive invocations are From patchwork Fri Nov 11 13:54:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18774 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753533wru; Fri, 11 Nov 2022 05:58:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf4s0jzo7ifmvpOlv5471jki+vms71s/4zBV7h1wgwBAyul6T5WFxoo2cUDfUwHsxvnJHdNU X-Received: by 2002:a17:906:e094:b0:78d:48fa:8038 with SMTP id gh20-20020a170906e09400b0078d48fa8038mr1928796ejb.309.1668175120471; Fri, 11 Nov 2022 05:58:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175120; cv=none; d=google.com; s=arc-20160816; b=vb5vgPIBX4uETxAfaniKEVp4DEM5tm8jx4LFw4WNAwS1wkyU1xVi8g00pEGiZDXypA lRFO/8CBiugxbyoDOM0q8frQrCBrE1JN3PJxJi5PBDpa6CaDBRjjGT0w6Ig1ehrLLJMK CGjYevYpbgE8gGBhI7OnYTbB8EqQkLWq8x+TuEqOPM2SGWe3mJZGmH3m5FDTvQlWDoyb dK4mIaNtZyDRajchiaA96uvn2/ybkyCwrze+nNmNUJvXRz1K6p55hdVv84KDZR9NHohT RIXeCaKmp2BONapfBtB0Lmm0dggSMSv3N8jZpMvuA+n4hgRAZT7cTHND0CDK8nW2IK9+ 0Fvg== 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=GAKiePxBwA26UOzSRlo0ofGhAo2Fb7Jw45XwvXqJzKU=; b=MZP4O1uuU45vOLjb93L8oHd/mPU0WMXu0jBR4LynaFjbYVDJOUWYYAzAJhaSz83nFY bGHDVqFc31OB6k/xzWqdhWsAqOt+drXTIaQeYFwohi2KcmStCPPokJ5NUsHlBV8tdBGL A25/GnVS8G18lbZL381vvonHrHR2Ud64bw672hBlHbr/o7B+ifRHfLQ6EzJk58p29YJo ajRdLwHlbTmAsA+Bpq0ZZBT7eVDJanEjMbdS/EwWX/CWkKIsIDQ8JBDQkojzSvP9136b Wem68nXXu+R4PHoJD40xZm6pY34wY6f1BQw52SxlG5Asb7lftLWCbugNN8K/E2UHeCik G6vw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Yu6U84ia; 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 u11-20020a170906780b00b007820f00167fsi1564680ejm.260.2022.11.11.05.58.16; Fri, 11 Nov 2022 05:58:40 -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=Yu6U84ia; 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 S233654AbiKKNzC (ORCPT + 99 others); Fri, 11 Nov 2022 08:55:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233593AbiKKNyv (ORCPT ); Fri, 11 Nov 2022 08:54:51 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4FC8C6F366; Fri, 11 Nov 2022 05:54:27 -0800 (PST) Message-ID: <20221111122014.004725919@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174866; 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=GAKiePxBwA26UOzSRlo0ofGhAo2Fb7Jw45XwvXqJzKU=; b=Yu6U84ia9FLugctorieny+7ozdDKY9K4yqqmT77rPtFmjIsYVb+xbI+H5owKByCTwabGFi XSUP3+twnj3K2LOXu5MGeCAk5Fqc95LTtwvoNYzKrFPOlHQMT38RZvffj79o/PUIffICyR Jw4JMo25Fr0VI6ucEf2SRxIGXBk5fNUjPRXoubLhcl+2CXsZWT11nLZF51xi1yvuNx3JzV vLMM+vvz4a8LfnKYX3C/JE+uy3X/nEjWc4GtcwLcypC9JiCo0kd0nnPqlNus4OEuGchKBA /pQVvyBdbBupRB6uqKjHCKGo5tVWIdNOeHLUIvsxZS9dpIQyB+6Of8k52fhTUg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174866; 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=GAKiePxBwA26UOzSRlo0ofGhAo2Fb7Jw45XwvXqJzKU=; b=oM7mFTR/BDMFIdSFauwnokPDjh6lKKffIIiPbVtB8cy6c9N5UGO9yua+3dqGd7aiCGwFmW BpQKABGh9Jg8x2DA== 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 07/39] genirq/msi: Make __msi_domain_alloc_irqs() static References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:25 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208395139332618?= X-GMAIL-MSGID: =?utf-8?q?1749208395139332618?= Nothing outside of the core code requires this. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe --- include/linux/msi.h | 7 ++----- kernel/irq/msi.c | 6 ++++-- 2 files changed, 6 insertions(+), 7 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -334,9 +334,8 @@ struct msi_domain_info; * MSI_FLAG_USE_DEF_DOM_OPS is not set to avoid breaking existing users and * because these callbacks are obviously mandatory. * - * This is NOT meant to be abused, but it can be useful to build wrappers - * for specialized MSI irq domains which need extra work before and after - * calling __msi_domain_alloc_irqs()/__msi_domain_free_irqs(). + * __msi_domain_free_irqs() is exposed for PPC pseries to handle extra + * work after all interrupts and descriptors have been freed. */ struct msi_domain_ops { irq_hw_number_t (*get_hwirq)(struct msi_domain_info *info, @@ -425,8 +424,6 @@ int msi_domain_set_affinity(struct irq_d struct irq_domain *msi_create_irq_domain(struct fwnode_handle *fwnode, struct msi_domain_info *info, struct irq_domain *parent); -int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, - int nvec); int msi_domain_alloc_irqs_descs_locked(struct irq_domain *domain, struct device *dev, int nvec); int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -462,6 +462,8 @@ static inline void msi_sysfs_remove_desc #endif /* !CONFIG_SYSFS */ #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN +static int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, int nvec); + static inline void irq_chip_write_msi_msg(struct irq_data *data, struct msi_msg *msg) { @@ -852,8 +854,8 @@ static int msi_init_virq(struct irq_doma return 0; } -int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, - int nvec) +static int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, + int nvec) { struct msi_domain_info *info = domain->host_data; struct msi_domain_ops *ops = info->ops; From patchwork Fri Nov 11 13:54:27 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18755 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp752679wru; Fri, 11 Nov 2022 05:56:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf76GZOvnqcRBQ1f7eb/AnPTE4EWdZB37A/QuY+wDOKv36M8SOgSp9xiYRHkkuBUEM8pWFGQ X-Received: by 2002:a17:906:b181:b0:7ad:69eb:90c3 with SMTP id w1-20020a170906b18100b007ad69eb90c3mr1966473ejy.285.1668174997279; Fri, 11 Nov 2022 05:56:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668174997; cv=none; d=google.com; s=arc-20160816; b=OOEsdxEF/omHTTjVTc+gJAzAtOPHO/ZAZWfwhEurgZghztVTBccAxYiUS8kQZVJUUt ZTQQozSA/Z85XHEtcOtSihC9AAHYaaXDzyAvzbhwz8N3tYVyDNEENgq0eDKoMsVOjCtB eN/deSbv7AXSAfMiSxc6PWRrgiEPSjbfIt6Jf4HRx6ynn+FF/pV9sMF5Q2jGzJlVtn4p C/nlkKZOAGjRXIal/n1Za/+UvBvMf2BW7dUj8FCaxbF8MhG3I2tN33cGG+BmMdIYwT1b nei++4wgDWFXCnd9k9JiaGleE+7YpfXgzCjP6DL9LXD8SGRVPz7AqiHzz45vdME+mmfY oUGA== 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=pIvr9Rr0WHVjkSJi7bxH/bI9Rim62Flb8AM+4v5YvL4=; b=EnQabYETFnShpZ20AyU6WVsQiPrHuBJgbsvJyyqMXj8cshojeMc6I6PiubXYSrLgrB dUolYmq0rZb4ciHiCBvWVZh623lZYPuF3sPEuJriAsvF6qPOI4KHM51pKTMRncssl+nx 279+apuALAvnz6VDuGaVkgIpPS2DRveGcaRS1EX4mHFZp9FKygCNTcdAKtdvdTj2gRxO /sRO1+iz75+s2N8dP77prH3OL8nIAcj7uRAhRUtJxPt1Hk9+f6sb1bhpv0u9FNJEftQZ nPg6Ja3q/lHQeQExTyp/4NnWhgMtzUB6BL2KJISmxNpgI2heClRUD48NOcQ5VijsgQbP eFoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=whjvZ1hG; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=wxPrtb03; 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 sh32-20020a1709076ea000b007adbe7695a5si2235268ejc.935.2022.11.11.05.56.12; Fri, 11 Nov 2022 05:56:37 -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=whjvZ1hG; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=wxPrtb03; 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 S233674AbiKKNzJ (ORCPT + 99 others); Fri, 11 Nov 2022 08:55:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57846 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233655AbiKKNyx (ORCPT ); Fri, 11 Nov 2022 08:54:53 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D4C167018C; Fri, 11 Nov 2022 05:54:28 -0800 (PST) Message-ID: <20221111122014.063153448@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174867; 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=pIvr9Rr0WHVjkSJi7bxH/bI9Rim62Flb8AM+4v5YvL4=; b=whjvZ1hGnpGUhhkqm9I0JMcNO4qtQO27s2DQH8Oz9beyGWo7DUQsr+41f0+cZiGoF9CSwx vy50S9pzw9A2kbFhsoMOktYg78PizaWs9IR3KZshscuyc2m56wjLCpqJFSZBll2eH6V8nU MFd9D8/wAHhHSsTq9hOhTwRl6vK+7OlKxNjL0jjqxx5Jpk/xWBNusgl4nofXeNU4sGa2Jp 4xxBlfu+GgVENgM2JLDzwXreETXKAUYT3oNe/e3Yp7Pby/icgOzh/0FpdMoIZobV0qz8X0 +eNahDWVvyqLmTEvfdcUV0DxSloKi+SoF3/VjpwVitY04LcMpyXhGyF/Qz4d6A== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174867; 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=pIvr9Rr0WHVjkSJi7bxH/bI9Rim62Flb8AM+4v5YvL4=; b=wxPrtb03zedDnlK+TXh2gy6+0tXIlW3ThKc+ATDQcqkU5payjRpOO+xzL6leSmWxWqt9sy poWzdm2Y5IW7krDQ== 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 08/39] genirq/msi: Provide msi_domain_ops::post_free() References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:27 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208266057488564?= X-GMAIL-MSGID: =?utf-8?q?1749208266057488564?= To prepare for removing the exposure of __msi_domain_free_irqs() provide a post_free() callback in the MSI domain ops which can be used to solve the problem of the only user of __msi_domain_free_irqs() in arch/powerpc. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe --- include/linux/msi.h | 4 ++++ kernel/irq/msi.c | 2 ++ 2 files changed, 6 insertions(+) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -315,6 +315,8 @@ struct msi_domain_info; * function. * @domain_free_irqs: Optional function to override the default free * function. + * @msi_post_free: Optional function which is invoked after freeing + * all interrupts. * * @get_hwirq, @msi_init and @msi_free are callbacks used by the underlying * irqdomain. @@ -359,6 +361,8 @@ struct msi_domain_ops { struct device *dev, int nvec); void (*domain_free_irqs)(struct irq_domain *domain, struct device *dev); + void (*msi_post_free)(struct irq_domain *domain, + struct device *dev); }; /** --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -1026,6 +1026,8 @@ void msi_domain_free_irqs_descs_locked(s lockdep_assert_held(&dev->msi.data->mutex); ops->domain_free_irqs(domain, dev); + if (ops->msi_post_free) + ops->msi_post_free(domain, dev); msi_domain_free_msi_descs(info, dev); } From patchwork Fri Nov 11 13:54:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18756 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp752724wru; Fri, 11 Nov 2022 05:56:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf7rvbjCC17wLF6vsdRexGQVFKfHdMCUZawJdquG2WbV5c63Lxj8zGlo9whMMyBzyJAUqrD1 X-Received: by 2002:a17:906:54cf:b0:78a:d075:98d8 with SMTP id c15-20020a17090654cf00b0078ad07598d8mr1930980ejp.324.1668175005827; Fri, 11 Nov 2022 05:56:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175005; cv=none; d=google.com; s=arc-20160816; b=Qp/SudHRhUKmeiNmEHTkIf/gT+agVmYFVDBEzm+IqwD2mnL3gbyi6Jy+L8AG0HsJG7 P7EWrgPZUFWduXJ5BihibheNaGfkR60CWJ1iqUTXm3E8OHxagMemCekRy5kwkzOJY2NG 3RPwIRuwsSURJ3PsrtqK3wXx1xqvxMjjYPcIDIY05qCZeMbOBF5V6Ik1YiNnw8vi/UjK fgGPq9hBdHuwOlBn0yWBHocSWcfZu4FL0NA/AsvNjy5AX3zDMGL7tzV3qx7lUWDzru/j mtXwf3Zxo4zdXCYY0SNhD1mkBA9KWcQBwiYYrakcle/U0HhFNQdE8liWvSTG6eJ/a91p w4Ug== 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=uAK7e6YKYfE3NKk9044qCaJfhx6qFWH6i8PscALcCkU=; b=fUetarD9Nnk05HGCIr//HW3d7GWUJRNFHb4Nasw3OTPBb4zasR/q3NIUM9bq5lRolx cK2u+UJC2UrNGuurctx6/R3pXUr5KpghPwY5ZFrvD1tQU3hvB5t4oBExc6STkD1VpdZG G4d5sNOQJQm/XOVv4dCOUqecAbWO3zXNTCnwhMUehPT73P4UDqAYLUdLir90eX+bUDUB OpHZ2VRjqlKbTz+EPzD4RtiNpoJv+f+QEXGgGYqWI/MV52oqCtFw0VorVu/XuMDGjWjZ p8rUikfvzpSQ6trZZ762FNQiZlg66OHuIgi2AYs4En5sB/i49+DVCxMBbXZ/B9gsHwj8 gTnA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bhdG0eo2; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=CdnfXWBv; 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 he12-20020a1709073d8c00b007acf3aed493si2237415ejc.910.2022.11.11.05.56.19; Fri, 11 Nov 2022 05:56:45 -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=bhdG0eo2; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=CdnfXWBv; 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 S233852AbiKKNzX (ORCPT + 99 others); Fri, 11 Nov 2022 08:55:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233592AbiKKNyy (ORCPT ); Fri, 11 Nov 2022 08:54:54 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6610270183; Fri, 11 Nov 2022 05:54:30 -0800 (PST) Message-ID: <20221111122014.120489922@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174869; 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=uAK7e6YKYfE3NKk9044qCaJfhx6qFWH6i8PscALcCkU=; b=bhdG0eo2d5cR5NUOFj3Ienrsw5VPaTNHp3Q9tmXe+N2uBx5Zp/1epSUs7hD/C0G7eLrHaV +C8SctVO+X4BrGfCIZMTE0ojXzDO8B42XGVZas3NbDPd0Q/HPETWT9XKnO9F2VmwX6OV9S V668vy8p1CUipfcobFboZ4vTtAxDWK63IStDKwrOKRaBdhZFOak3Blp+nwAEE7pjT3xpcw ZLBLGCh74g5FftekR3u7YTxhlQ16TIYo++JJjAD0y7eaEOF/5GUbQq9RCpuQSBLyXzaAzV C/+4MDauiberZ+DV2mcdIIvqMMOnfOqSzRFvFsw2nuyv9tz7FHZ0r4CKPbYqkA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174869; 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=uAK7e6YKYfE3NKk9044qCaJfhx6qFWH6i8PscALcCkU=; b=CdnfXWBvUOFJUQvenC/sG/RoCl0EBsTovXNlHbcYl5w55OTi8OHqj96pgDXVqDNddziMC5 Q0FyhLFGFQVlnUCw== 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 09/39] powerpc/pseries/msi: Use msi_domain_ops::msi_post_free() References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:28 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208274794391553?= X-GMAIL-MSGID: =?utf-8?q?1749208274794391553?= Use the new msi_post_free() callback which is invoked after the interrupts have been freed to tell the hypervisor about the shutdown. This allows to remove the exposure of __msi_domain_free_irqs(). Signed-off-by: Thomas Gleixner Cc: Michael Ellerman Cc: Christophe Leroy Cc: linuxppc-dev@lists.ozlabs.org Reviewed-by: Jason Gunthorpe --- arch/powerpc/platforms/pseries/msi.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) --- a/arch/powerpc/platforms/pseries/msi.c +++ b/arch/powerpc/platforms/pseries/msi.c @@ -447,21 +447,18 @@ static void pseries_msi_ops_msi_free(str * RTAS can not disable one MSI at a time. It's all or nothing. Do it * at the end after all IRQs have been freed. */ -static void pseries_msi_domain_free_irqs(struct irq_domain *domain, - struct device *dev) +static void pseries_msi_post_free(struct irq_domain *domain, struct device *dev) { if (WARN_ON_ONCE(!dev_is_pci(dev))) return; - __msi_domain_free_irqs(domain, dev); - rtas_disable_msi(to_pci_dev(dev)); } static struct msi_domain_ops pseries_pci_msi_domain_ops = { .msi_prepare = pseries_msi_ops_prepare, .msi_free = pseries_msi_ops_msi_free, - .domain_free_irqs = pseries_msi_domain_free_irqs, + .msi_post_free = pseries_msi_post_free, }; static void pseries_msi_shutdown(struct irq_data *d) From patchwork Fri Nov 11 13:54:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18757 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp752768wru; Fri, 11 Nov 2022 05:56:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf5/XZPBKbd2yHGkFfsdpfjdiN4cPnlVSk1dt+vr2+I/W0zFWosGy4ZHXoLHcCcBnOCVVxXE X-Received: by 2002:a05:6402:1004:b0:461:53b0:2ac0 with SMTP id c4-20020a056402100400b0046153b02ac0mr1509087edu.153.1668175012085; Fri, 11 Nov 2022 05:56:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175012; cv=none; d=google.com; s=arc-20160816; b=0DS0qQuTN9P0XqMvBONocWo2EIGsoq6YcGRiaEqoBu/xjKMGZnl37OZU9V6oUujTtE nPNsrteU8zNigz+vuM6wNhayl7T3qxeZypDtVdoa31P9S2RpAyDE41v8vemQC2gwGznh heOlCijm6NP/fLKl7tHQ7waP8H5gD3n+HkMI3Rto20pe0CxPloDGB927X9kQ2wo33mug /DIoj/87E6q28Q53x8ByIDCA7mKxJdJQjNAJqkgH6R3yasowDe5Le2XHLRSaZmg9knEe 2O5TiBehHwJXnRjvQcSgbKPe/KryGlUVGLmO37IoTtrdhe/5VvlbjoN5GIYlfdmuaARw SzEQ== 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=oY+wTD07UJdZe/4apbDgNNcex5cwO56TFt4SFwForIc=; b=vdNVwfTazmkUO/4/DVpblLBVQZ1kiiKdsOqlpIITkaab4U+lmXBX+e+2H7MCWfV3jc A1YnBpQ7ly19DXoqoifw3xt/H//QS9ukiI9Q6cW8TIQz33L5nUWD9QgiE5S9oS/ED/fK R566hC4gndMKMmi/5qBQ8xeJn96KVwViXgAq8CoHxFtNtOCNHzL9EAYUfgSzAQ83sXav FpzT7LrwhjEQxRErGcX208YX76YoOSMgecw9p6WFymwHwIqsyMxwoz1L0rQDYBAGXloU aqqo+qB2TMpmP1OgQqjUSaJ2DkSMPBmSqHusdOsEfJxfmqW6SLZOadsue+kPIfDW1mHQ b0cw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XKH6NEiB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 hu8-20020a170907a08800b007ad69eba328si2082520ejc.539.2022.11.11.05.56.28; Fri, 11 Nov 2022 05:56:52 -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=XKH6NEiB; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S233743AbiKKNz0 (ORCPT + 99 others); Fri, 11 Nov 2022 08:55:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58950 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233204AbiKKNy4 (ORCPT ); Fri, 11 Nov 2022 08:54:56 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D19165863; Fri, 11 Nov 2022 05:54:32 -0800 (PST) Message-ID: <20221111122014.179595843@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174871; 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=oY+wTD07UJdZe/4apbDgNNcex5cwO56TFt4SFwForIc=; b=XKH6NEiB67Xn3bODoK1UFNxfG2Caz8t/SVVKnrvUY4TysvhYRo1CTn8qB9QRn9RXgGnOUn ZlbsPVdXWbPeRr+WmykWCafK8bLI9q2+VQe4v5gBp0//TxvsSvxCpPxquAuRMxNEgtM/2N FxObd8tB3rxUW6wBz7mLBiKynGG5OmxeXo5buw0kruHyiYCT7q3lsatjITlV+OIRMqapgo /ZgLE9xBM91qCV2tv5mSnn5R76PdySctgB00+MO+fIVUWs9O5o7hYp6u+FWK6+yL40MA1E eIxjf8p9VQYpJPcp119zLp2e+qHu7Ls8pywkEyFDGq1LVZW6sAQAPyCaxlhp7w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174871; 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=oY+wTD07UJdZe/4apbDgNNcex5cwO56TFt4SFwForIc=; b=DEHoveL7w/ktG5ghiwXKDZHBT8EPqXrrOFE5Ik9fSJifrawkey+Jqom1hnjX29gXiW58gk NcPL/Y06TjJtq6Cg== 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 10/39] genirq/msi: Make __msi_domain_free_irqs() static References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:30 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208281547726358?= X-GMAIL-MSGID: =?utf-8?q?1749208281547726358?= Now that the last user is gone, confine it to the core code. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe --- include/linux/msi.h | 4 ---- kernel/irq/msi.c | 3 ++- 2 files changed, 2 insertions(+), 5 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -335,9 +335,6 @@ struct msi_domain_info; * are set to the default implementation if NULL and even when * MSI_FLAG_USE_DEF_DOM_OPS is not set to avoid breaking existing users and * because these callbacks are obviously mandatory. - * - * __msi_domain_free_irqs() is exposed for PPC pseries to handle extra - * work after all interrupts and descriptors have been freed. */ struct msi_domain_ops { irq_hw_number_t (*get_hwirq)(struct msi_domain_info *info, @@ -432,7 +429,6 @@ int msi_domain_alloc_irqs_descs_locked(s int nvec); int msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, int nvec); -void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev); void msi_domain_free_irqs_descs_locked(struct irq_domain *domain, struct device *dev); void msi_domain_free_irqs(struct irq_domain *domain, struct device *dev); struct msi_domain_info *msi_get_domain_info(struct irq_domain *domain); --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -463,6 +463,7 @@ static inline void msi_sysfs_remove_desc #ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN static int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, int nvec); +static void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev); static inline void irq_chip_write_msi_msg(struct irq_data *data, struct msi_msg *msg) @@ -978,7 +979,7 @@ int msi_domain_alloc_irqs(struct irq_dom return ret; } -void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev) +static void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev) { struct msi_domain_info *info = domain->host_data; struct irq_data *irqd; From patchwork Fri Nov 11 13:54:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18758 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp752813wru; Fri, 11 Nov 2022 05:56:58 -0800 (PST) X-Google-Smtp-Source: AA0mqf7RbMcX/NqPy2PKbIwSXCRnIKIsmGVc6g0Vxxx6N+RwkOOJcA8Ii2q2VtJicNDbjX7ahnHt X-Received: by 2002:a17:906:4e0d:b0:7ad:b822:d2e4 with SMTP id z13-20020a1709064e0d00b007adb822d2e4mr1938168eju.35.1668175018400; Fri, 11 Nov 2022 05:56:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175018; cv=none; d=google.com; s=arc-20160816; b=CUvlilBzrwz9KWDCDivEmPMswEnM2q7jYlP5zwse89cQsA+GkVpKYX1ok9WFhzzd2b 8+l/WBWhu/OFIOp6RcWNiHpZx7A7DVR8ViSLMtSYoS/2sm52E3/NJPCB4b0vLkjAMTSo UblT1bxq47v7+uCEYpSYtMyaEUNd+JdniOEuDJwlK1WHquvRa3blaGTZ5xvVy1/oRn+J CCoB7T5SqaUd0RFN+17gdViMtUYlbnwTxWUXL+Cbn+2ToJJcwCVz5c7SBFCtxkI9hqCF nVXd5+DfRBTpo6XVHdxf5wkcQrk3jRoKXriLiyiPkxpEc4ZiQc23ieUApLYsmFXIkbeD DQNw== 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=i6lv85ZNUn8jbTiqiaOVEezDOQ2OYDxW2lkZxbSQfPs=; b=pWiEYKZKSI+f0KWWoz+faQzduALYsin4fduIvYPWuktzKGB6D0RxXiSSs+VP7RHyk8 WKNHPRnsfDnKgulC65/vIhyVH3m8bW/RvgDkhD9RfWG/d2haDD47a9FoPXuId1+2pSmT 1P5Rz0MJe5NHOjg84eI23ZO0HW5uRN45Kaz+D4uD/LogwC3O2mzjqhD+/GMPJphylH72 GF51DhHL9Tvjls8BxM/9Srd6ePBbP8O1UNlV+5sxb85U4vWVNrKL/ruqSrfm7eOLcSHi f2rlLfVfCSGvYfLPOkbLxWx5tzoXa+s89qdPVV+Ra/rCfh+ljNWUL2PZ2/F4DbNCCmut 9fKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=43XNu7V6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="r6FLcQ/X"; 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 nd27-20020a170907629b00b0078e27f2ef4bsi2307330ejc.956.2022.11.11.05.56.35; Fri, 11 Nov 2022 05:56:58 -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=43XNu7V6; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b="r6FLcQ/X"; 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 S233655AbiKKNzb (ORCPT + 99 others); Fri, 11 Nov 2022 08:55:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233678AbiKKNzN (ORCPT ); Fri, 11 Nov 2022 08:55:13 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4B03A7299D; Fri, 11 Nov 2022 05:54:34 -0800 (PST) Message-ID: <20221111122014.237221143@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174872; 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=i6lv85ZNUn8jbTiqiaOVEezDOQ2OYDxW2lkZxbSQfPs=; b=43XNu7V6lxNjeSplgzaxAS44tgV1Hxus/MQ0Rod85yoWEU9uzoUV0/Gvo4MbkhRTwi9Tzn K+wX7sK78xcXVDD899/v4pK5j+RLz0Ao3nSp2UCpEepJa70aoQnMHmpP19VhP2+pwR4qww 0tGVylR7vtiM38R3uV3EvetHi2nC3skf1+FL3cNo1DnnGoJtSoTvvwyivArsgTeJicRErs l1UHy/+fO39St2quL4Q1Hy4tm4W1uszLlCgDZRMWKSkBfgmRsWXid7/6U9QZn+s1br0VHF drP8Q36KtsFNrJNa9PZHRRkcIy1K7rYVmLVVutyERWy8ViXgAtWWWRTnnNlHgA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174872; 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=i6lv85ZNUn8jbTiqiaOVEezDOQ2OYDxW2lkZxbSQfPs=; b=r6FLcQ/XkDdVENpg6jrJnxOUENgvyAqRux+b2LWEAUoE54RxJtQQhVavaj2vznzl/JqrCy KnNE4MphZHlzBvCQ== 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 11/39] genirq/irqdomain: Move bus token enum into a seperate header References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:32 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208287666910946?= X-GMAIL-MSGID: =?utf-8?q?1749208287666910946?= Split the bus token defines out into a seperate header file to avoid inclusion of irqdomain.h in msi.h. Signed-off-by: Thomas Gleixner Reviewed-by: Ashok Raj Reviewed-by: Jason Gunthorpe --- include/linux/irqdomain.h | 22 +--------------------- include/linux/irqdomain_defs.h | 26 ++++++++++++++++++++++++++ 2 files changed, 27 insertions(+), 21 deletions(-) --- a/include/linux/irqdomain.h +++ b/include/linux/irqdomain.h @@ -31,6 +31,7 @@ #define _LINUX_IRQDOMAIN_H #include +#include #include #include #include @@ -68,27 +69,6 @@ struct irq_fwspec { void of_phandle_args_to_fwspec(struct device_node *np, const u32 *args, unsigned int count, struct irq_fwspec *fwspec); -/* - * Should several domains have the same device node, but serve - * different purposes (for example one domain is for PCI/MSI, and the - * other for wired IRQs), they can be distinguished using a - * bus-specific token. Most domains are expected to only carry - * DOMAIN_BUS_ANY. - */ -enum irq_domain_bus_token { - DOMAIN_BUS_ANY = 0, - DOMAIN_BUS_WIRED, - DOMAIN_BUS_GENERIC_MSI, - DOMAIN_BUS_PCI_MSI, - DOMAIN_BUS_PLATFORM_MSI, - DOMAIN_BUS_NEXUS, - DOMAIN_BUS_IPI, - DOMAIN_BUS_FSL_MC_MSI, - DOMAIN_BUS_TI_SCI_INTA_MSI, - DOMAIN_BUS_WAKEUP, - DOMAIN_BUS_VMD_MSI, -}; - /** * struct irq_domain_ops - Methods for irq_domain objects * @match: Match an interrupt controller device node to a host, returns --- /dev/null +++ b/include/linux/irqdomain_defs.h @@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_IRQDOMAIN_DEFS_H +#define _LINUX_IRQDOMAIN_DEFS_H + +/* + * Should several domains have the same device node, but serve + * different purposes (for example one domain is for PCI/MSI, and the + * other for wired IRQs), they can be distinguished using a + * bus-specific token. Most domains are expected to only carry + * DOMAIN_BUS_ANY. + */ +enum irq_domain_bus_token { + DOMAIN_BUS_ANY = 0, + DOMAIN_BUS_WIRED, + DOMAIN_BUS_GENERIC_MSI, + DOMAIN_BUS_PCI_MSI, + DOMAIN_BUS_PLATFORM_MSI, + DOMAIN_BUS_NEXUS, + DOMAIN_BUS_IPI, + DOMAIN_BUS_FSL_MC_MSI, + DOMAIN_BUS_TI_SCI_INTA_MSI, + DOMAIN_BUS_WAKEUP, + DOMAIN_BUS_VMD_MSI, +}; + +#endif /* _LINUX_IRQDOMAIN_DEFS_H */ From patchwork Fri Nov 11 13:54:33 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18759 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp752822wru; Fri, 11 Nov 2022 05:57:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf7+FlnaombAx/zuD/Vo7azeStTJLW4Tl1BARf2sqKWFWlzM+FLZ2lh8VP20ZrsLp0oOptrl X-Received: by 2002:aa7:c6d0:0:b0:461:ee90:3d77 with SMTP id b16-20020aa7c6d0000000b00461ee903d77mr1500873eds.322.1668175020787; Fri, 11 Nov 2022 05:57:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175020; cv=none; d=google.com; s=arc-20160816; b=SAMOW9CAP0uPBEIWpWUr2fO3a6DPQ9rqQU673qJ9HmgMALIb8VZMs2mpYe60VRPudX A0LgpEUCzJ1JPN5Yv45CMCnd84qzUKQMVZaBfy8WG3GmeBdGsKYKfnitY3zOzhRSI1Wd GQNn/CjGwoip+Vpy8X2mAWFyvxxFjQNFtj9pHtOooXHMUBTGQxAaC4JZffvYHAV2Jb/f fnn+CRuC8rDjOdTzSYn6pl+cAKRgU64tG/V9N0lWCcfcwGTiHjAsAX4foQVCx7uJpdSl cFztxMX6r+u+H9cwx5jsKaMygEcjC5D06PQAdqQw/LVaUI5e5lWmGPeP+45wm1HymrwG wb+g== 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=bJxkwerKAjiWe6cHbEqN33xS2DP9tmAemXhkKdu0gyY=; b=pG7AjpnZ3UuCfDbSd1KoIAF/wqidgvjz+b0ofDOY+2Tz11jdtG/8N9TCpKMjU8N5ij EhNcwNa86NvEFYvRNdx6OaRoXDBWAR3CqKveHl48FuNnG54jGkmSNiZBIqHKQILjm22B Vu108Kgt+oGlhy42nHYnuai4JCIGoYBX4YmbwN56mVupapOKXrJ+5c4/678ARauTPFm3 ytodclkI/zzzpBKww8NBrPV3RZtOB/Wn2saKrEVoCfIKwhP4TJmWP6WiNiT3NuPUnLlZ ENAfjbLU2FxL8N/tbEhGDK1zIRgzxAyH9y2HB5TPJVv0kDou7gEnOF1YFOBy8iUc+ZZz KJfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=QLffNtOU; 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 bj10-20020a170906b04a00b0078dc5c888f1si1790190ejb.135.2022.11.11.05.56.36; Fri, 11 Nov 2022 05:57:00 -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=QLffNtOU; 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 S233692AbiKKNzo (ORCPT + 99 others); Fri, 11 Nov 2022 08:55:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58804 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233688AbiKKNzT (ORCPT ); Fri, 11 Nov 2022 08:55:19 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A4414742D2; Fri, 11 Nov 2022 05:54:35 -0800 (PST) Message-ID: <20221111122014.294554462@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174874; 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=bJxkwerKAjiWe6cHbEqN33xS2DP9tmAemXhkKdu0gyY=; b=QLffNtOU+BM9Q6v/Z8H95R6LwiMPRmhfbmoj75MKEHMyuvoWkxB4RbZv0LOe8zConFdPn3 FoUFDUYVoPhjPiUz6C+xwY6wbZBS5lKJg3/Gsu3284EwPDC+c//3QKxn3kDkoOFde3hYQC +pd/Xgm/h8dGs8OjV+shpssdUDGjerTJOwD/8mC4GG/L0S4ZPt/7rL+PeupLgtvUpTDE1N Un9QztBWeePvOOGEhy8v40+sFh0e4oCbUYoSJSn1XhDvUlTbCyxiOgkrR743ROQ9a0ADqn +HbdIbRhYeOip7Q6YM6FLWMKuOVt6JtuB76/8dQyT2nLcE1Cab8xY9yYhSPJGw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174874; 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=bJxkwerKAjiWe6cHbEqN33xS2DP9tmAemXhkKdu0gyY=; b=REJ8yjGkmRMaCMvX4cw1m2qo8vf54uF9WaXNDdGlD7gTrIZa0CONrZEpNhXpv0sciserxB AcKM8IQKL5Qmr3BQ== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 12/39] genirq/msi: Add bus token to struct msi_domain_info References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:33 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208290717554140?= X-GMAIL-MSGID: =?utf-8?q?1749208290717554140?= From: Ahmed S. Darwish Add a bus token member to struct msi_domain_info and let msi_create_irq_domain() set the bus token. That allows to remove the bus token updates at the call sites. Suggested-by: Thomas Gleixner Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe --- include/linux/msi.h | 19 +++++++++++-------- kernel/irq/msi.c | 7 +++++-- 2 files changed, 16 insertions(+), 10 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -16,6 +16,7 @@ * abuse. The only function which is relevant for drivers is msi_get_virq(). */ +#include #include #include #include @@ -365,6 +366,7 @@ struct msi_domain_ops { /** * struct msi_domain_info - MSI interrupt domain data * @flags: Flags to decribe features and capabilities + * @bus_token: The domain bus token * @ops: The callback data structure * @chip: Optional: associated interrupt chip * @chip_data: Optional: associated interrupt chip data @@ -374,14 +376,15 @@ struct msi_domain_ops { * @data: Optional: domain specific data */ struct msi_domain_info { - u32 flags; - struct msi_domain_ops *ops; - struct irq_chip *chip; - void *chip_data; - irq_flow_handler_t handler; - void *handler_data; - const char *handler_name; - void *data; + u32 flags; + enum irq_domain_bus_token bus_token; + struct msi_domain_ops *ops; + struct irq_chip *chip; + void *chip_data; + irq_flow_handler_t handler; + void *handler_data; + const char *handler_name; + void *data; }; /* Flags for msi_domain_info */ --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -694,8 +694,11 @@ struct irq_domain *msi_create_irq_domain domain = irq_domain_create_hierarchy(parent, IRQ_DOMAIN_FLAG_MSI, 0, fwnode, &msi_domain_ops, info); - if (domain && !domain->name && info->chip) - domain->name = info->chip->name; + if (domain) { + if (!domain->name && info->chip) + domain->name = info->chip->name; + irq_domain_update_bus_token(domain, info->bus_token); + } return domain; } From patchwork Fri Nov 11 13:54:35 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18760 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp752848wru; Fri, 11 Nov 2022 05:57:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf6M2tQur3JTIIhRbz+Qggmyiys9cRkYsT5/UxGkNX2iawbbyE2/J7Mb6Qt6Spn6CzJssQZA X-Received: by 2002:a05:6402:4447:b0:461:9f41:2960 with SMTP id o7-20020a056402444700b004619f412960mr1497178edb.242.1668175023794; Fri, 11 Nov 2022 05:57:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175023; cv=none; d=google.com; s=arc-20160816; b=GoWey0T+eJy+28zHf1Kjpxt5F08QcVzE62GI5WhWN2fhBf2pH8GFzaX76xLC4INHfp Vpj9LmTTRn8S+szFnnsSaq1I8kE95HvjGaRPEz4gI260aWN1jxD3J6U35PWUJokHKEQC FFfuKcxnvrmUuz9ic0aiTT+fprTYiZaPQex874ZdMksHZykNNRlXTNQzoGX23mVteSXQ JDHMFgaF21la4czlVDLL1T8QGTWGeiwDWHejlYosg4+51Je2QuM856m+XMVXTR8xbWry lUEhPx3YMuzltVO6+wdv76ZrxWfUlfnYYH8Ng/LXISO6Sgg5CCXdukUL4J/wTJfG+p7c RmjA== 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=SR+JTKB3rKiZ73e/G+mgOLVXr9oQkVaEjTjLGttb2Gk=; b=u3CYWJNhKSHBSS85g8RHFOWuQkYtvJeaqYOIqJH2+w+m0kM4bLcAXrWc7y/EHq1Q2r R8NjrJezB9C4ZjdECuZMGh7J97gcBPESMj/Kp5+CH7tkbCAQcYHKES64SNX8iyxbuI7P 70GzbV+sdg+V58sC8WvV2gqCUCWoCtExZvP09EYcic/kKKSNqBTbn6Qjh/gauvZXrJKh x3mK88dhsbdH1uiaGhQVsmT+Lq7p0nUAeBtRVTbEeoa219pbU0prt6C1xrYRgx2rqKAQ 6WE97fJTNF9gx+38pK2Cqj2hXJHgxla+Y1rjoauSoxdXiaLHCiEKuU5T+tVsJcXj+nNs IMmg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=cquks9wv; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=upJdg7cK; 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 f9-20020a056402354900b0045beaf03ddesi2457839edd.411.2022.11.11.05.56.39; Fri, 11 Nov 2022 05:57:03 -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=cquks9wv; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=upJdg7cK; 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 S231615AbiKKNzt (ORCPT + 99 others); Fri, 11 Nov 2022 08:55:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233702AbiKKNzU (ORCPT ); Fri, 11 Nov 2022 08:55:20 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 521B1748CE; Fri, 11 Nov 2022 05:54:37 -0800 (PST) Message-ID: <20221111122014.352437595@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174875; 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=SR+JTKB3rKiZ73e/G+mgOLVXr9oQkVaEjTjLGttb2Gk=; b=cquks9wvdwGZvfTVGMseDqonmMru5Jvd1Wp80d+QA7r+OPUBjVQ33nkUC2zM/Xj1+O8fPG vtb671Sgwa26sjZk08mR0d6Khag9L+dcgpdaaiX3gijScukZ+VHAfliD2IMtv3iaBOUF0H z/MslAY6PXFpX332pOy1ThF73fCI+4dA58/e9E/htDuO/wELj5pOCP8hkEbevCn9g05Q6e Dc8lugCbNGIQGIngKhOUPod5JqprevnRQk8hF+mBQQn/l8M/1bzTmQzN7g8pOmzecptGGk /UJmMPp34YQm20YaIUWb6Ef0Mc9mjvia3FKyyNDWpMCxHg3It/xaV2cgV2oHEA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174875; 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=SR+JTKB3rKiZ73e/G+mgOLVXr9oQkVaEjTjLGttb2Gk=; b=upJdg7cKT2Y7T72CwaobIKCBWj/eDCRfZapw31fhp5ESPdWoHIOrAME2ohvtTWo1VMweL7 27ljumxd1t7PlDBA== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 13/39] PCI/MSI: Use msi_domain_info::bus_token References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:35 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208293874684700?= X-GMAIL-MSGID: =?utf-8?q?1749208293874684700?= From: Ahmed S. Darwish Set the bus token in the msi_domain_info structure and let the core code handle the update. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe --- drivers/pci/msi/irqdomain.c | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -162,8 +162,6 @@ struct irq_domain *pci_msi_create_irq_do struct msi_domain_info *info, struct irq_domain *parent) { - struct irq_domain *domain; - if (WARN_ON(info->flags & MSI_FLAG_LEVEL_CAPABLE)) info->flags &= ~MSI_FLAG_LEVEL_CAPABLE; @@ -178,13 +176,10 @@ struct irq_domain *pci_msi_create_irq_do /* PCI-MSI is oneshot-safe */ info->chip->flags |= IRQCHIP_ONESHOT_SAFE; + /* Let the core update the bus token */ + info->bus_token = DOMAIN_BUS_PCI_MSI; - domain = msi_create_irq_domain(fwnode, info, parent); - if (!domain) - return NULL; - - irq_domain_update_bus_token(domain, DOMAIN_BUS_PCI_MSI); - return domain; + return msi_create_irq_domain(fwnode, info, parent); } EXPORT_SYMBOL_GPL(pci_msi_create_irq_domain); From patchwork Fri Nov 11 13:54:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18776 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753572wru; Fri, 11 Nov 2022 05:58:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf53AwTTOFk6Nyg133X6LKIBYiNV6m15JumEPSQC7PMla+z9mCfR3eHh91D2g6RV3v6xCvzm X-Received: by 2002:a17:906:f2c3:b0:78d:d762:5457 with SMTP id gz3-20020a170906f2c300b0078dd7625457mr2072270ejb.67.1668175128273; Fri, 11 Nov 2022 05:58:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175128; cv=none; d=google.com; s=arc-20160816; b=pEFFVAa2DfBQUMitcO/3Wr2EaVo0E74f9ymW9MfVu4tTGv3tiNop4qAD/KAQSPRl4v mE/A+oGqcphKtjMq8xEwUAxmxLZGnA17H4v43S6ZPe7PoR6UTfXVaZ5wTFWe7YK8G9bS WtA3/76I9VVp+kZwM0iCvexSm5vVRh3vlgFooXkEkXYpX0EOndUYQt2BHyxdqfBDlnrn XpQpoeizhI5xdMk3cSzUcx2AzWKdo6KUudL0tZbYZYzMweGT6FDNL2WGVNTFmxQ27RtO 57m8mLa0fCMN1CPLQ5ohUs8twlWsVrdZ+F/E9zetkpm7o+GOG3VQQbMoaQYCL/bR4fqZ BFnQ== 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=ihQb1Hr2tFB57KaqSJ6TMuVbBaKbPYZLQeHvg5ugyrc=; b=E1+/ULAFQK3o7rJUOvIFolFFwBGd29NKZCM+Ef0wRnV48aAenovww4yKmJ9xaQuGDU 6LoRQ98+vZVJubuNFfENDvyf8Guk3jtRQdbcMGGOO/3QD6rl2MhBDhK3dYNir+2LKCYb ug6qKh11A0bejKdzdbRNiB8/FRvD1ggXaS9ysfMmrRq0aU7rmZKdy/DN5KaemFmLHuF9 WXLH8Y6WPMPCgR5SzU8/eBIhvBm14b9Ul6stQSAuIXauR1xyY9ukONAekf7JvPK0yIrd yHuZbsuB62LPXKhkE6QU1S47qkGyNnfpy8fyoxEhuoRz+UKna05FL5UVGJakxSe/eJgi yx0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KIxoGLm3; 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 m19-20020a056402511300b0045d46f28533si2714920edd.377.2022.11.11.05.58.25; Fri, 11 Nov 2022 05:58:48 -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=KIxoGLm3; 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 S233829AbiKKNzx (ORCPT + 99 others); Fri, 11 Nov 2022 08:55:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59638 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233817AbiKKNzU (ORCPT ); Fri, 11 Nov 2022 08:55:20 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E48C077E4A; Fri, 11 Nov 2022 05:54:38 -0800 (PST) Message-ID: <20221111122014.409654736@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174877; 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=ihQb1Hr2tFB57KaqSJ6TMuVbBaKbPYZLQeHvg5ugyrc=; b=KIxoGLm3fdgX8mVYTA3gqrUlF6RwTtW90vYGHTzR9LA4zR9jAvDQ3Mz275nIl+k1FsCVo8 BDasSMGgRPumnK+XCfXPGjj7fbt46WHiGID8auAQfUb2Fb1FPhMqiq4S5Vfu8sZEu1C9Y8 MQnr0/wDyfTzrL68KxmtWwLyR/P+t79hViR57xRScUXMobFg6K+I2h8IV+wgT+yxvAvOM7 7uVe7yokIXo/LjW9ONZit1EjWi5RuhSl2zMdJxNHQ3BUemd1RxyK5J0d706hKkPPOlSxn2 x/CvdueaKYFaZ+eSmgX5gR3aO6NPOicaxHiLhYOGfhjwy5k+jQQsoBWV8i2oLA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174877; 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=ihQb1Hr2tFB57KaqSJ6TMuVbBaKbPYZLQeHvg5ugyrc=; b=uMHNBoXC2VwEdIAQL/VEAVQGgdOqIQAKBY94YN3/zPMpA2g+0keRMDIAeVH1iiSVA9XOms zwnFBQCZgvigUJCQ== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 14/39] PCI/MSI: Let the MSI core free descriptors References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:37 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208403171002781?= X-GMAIL-MSGID: =?utf-8?q?1749208403171002781?= From: Ahmed S. Darwish Let the core do the freeing of descriptors and just keep it around for the legacy case. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe --- drivers/pci/msi/irqdomain.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -24,11 +24,12 @@ void pci_msi_teardown_msi_irqs(struct pc struct irq_domain *domain; domain = dev_get_msi_domain(&dev->dev); - if (domain && irq_domain_is_hierarchy(domain)) + if (domain && irq_domain_is_hierarchy(domain)) { msi_domain_free_irqs_descs_locked(domain, &dev->dev); - else + } else { pci_msi_legacy_teardown_msi_irqs(dev); - msi_free_msi_descs(&dev->dev); + msi_free_msi_descs(&dev->dev); + } } /** @@ -170,6 +171,9 @@ struct irq_domain *pci_msi_create_irq_do if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS) pci_msi_domain_update_chip_ops(info); + /* Let the core code free MSI descriptors when freeing interrupts */ + info->flags |= MSI_FLAG_FREE_MSI_DESCS; + info->flags |= MSI_FLAG_ACTIVATE_EARLY | MSI_FLAG_DEV_SYSFS; if (IS_ENABLED(CONFIG_GENERIC_IRQ_RESERVATION_MODE)) info->flags |= MSI_FLAG_MUST_REACTIVATE; From patchwork Fri Nov 11 13:54:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18761 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp752907wru; Fri, 11 Nov 2022 05:57:14 -0800 (PST) X-Google-Smtp-Source: AA0mqf7kAwFKGm8g2oDBH/46plhzNOlLQ/G0eutCN/Cnu5K2djzLj4+7Cv0GG8Ot99UklLoQx/BC X-Received: by 2002:a17:906:8316:b0:77f:9082:73c7 with SMTP id j22-20020a170906831600b0077f908273c7mr1797230ejx.517.1668175034740; Fri, 11 Nov 2022 05:57:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175034; cv=none; d=google.com; s=arc-20160816; b=wBmtkB4RyhPORvUikdKL5BgCk5SKxKugjP7pyFeptF/lxhjrHlvTEPufa3fTEzCub1 X4fPOZ7La8W8OXNLjDzgKCEQWyjI9NgN0PxFdUDs0Qp2k7BmceRtpvJnRAhGHdgqf9wd RVd5MFYqXjkpwIk4OIsCo/BDr0dvul0vvJA8UEgT6vZqVXBevp5phZ8e/O7XhGxGWR9U 0iN1uZuRC3JsHLnqRDljzw4CUpzki9S4V3miGmEx4w/NLsIKyjGyhJf07btdmSWaqmE3 rlIGER2fTrpoH0jiVFE5+1o0/5PsmFPrGn4sfWqcoa/crGHPdUJ4VahqoJiCIQtf8lCt pxiw== 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=5A7Hp3XooT8XFfSy8bD+z0GIWEX9YLOligSHPn52djI=; b=JHxjX+qACYunczUpLG/gckZSyzUALm4u01v2AG/1Tq6Jc18ybyJZvRxAtLm9hwejAu vc+wezVS/B9mEeOyEo4B1AMjPp+NVseX6d/Gf3t4DtzvLQYWNGl2KbBqsMX0M4fGnmwV 0HNmqADNBSFYBBwLyQ2AXNBcReGe8EAb3cAqMRaVKeDUSRAt807nCk+jknbR0GGfCs4F jWbLMM2MtXF+VB7iTtmzIxSMQl38TChX2P8+uFsDoMPWCnern+HO+Tw4eqHMMqz1Qqka 29SHOtIwW3m6p6bdz5og8vnNYvA05mrPKUHtsiUbozxXSK3NQAaYbMrAA792aD5dN52X qacg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=iWL4l2Ov; 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 la26-20020a170907781a00b007aa493b067asi1526573ejc.396.2022.11.11.05.56.49; Fri, 11 Nov 2022 05:57:14 -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=iWL4l2Ov; 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 S233932AbiKKN4E (ORCPT + 99 others); Fri, 11 Nov 2022 08:56:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58976 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233856AbiKKNzX (ORCPT ); Fri, 11 Nov 2022 08:55:23 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92F5777E7D; Fri, 11 Nov 2022 05:54:40 -0800 (PST) Message-ID: <20221111122014.467556921@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174879; 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=5A7Hp3XooT8XFfSy8bD+z0GIWEX9YLOligSHPn52djI=; b=iWL4l2OvhkPUWALd1814ZNr/gBhu0qEaVl9fSSzsJZIcWUG2YXvbdIoclzl8rW6a6FgMWE eh0qylJadkJaTWW+uqDyv5XnRmsA1j1VbxqHAJyLNVaAIkKv+y5BiX+lI2WKQ9p4+tJ9HE P9kKEWR/XqgF5zZ1KA26AjGgkDpVApxwsl40T7f/yp4z8fQIpv3qXKb+6F5BPO2lgDFrRC m/3U7mPfEtw5HDLGpTUEUZgbSVh62PYg6NLnVEcYRXDnvkOrBxcM1z41RkcVbXb6Bzp8bn j0rtJzOMSZ5BIvGIDGRVsJjN/DomHYf+7QVslyZwYopRLbo5u928E5HbQocehA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174879; 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=5A7Hp3XooT8XFfSy8bD+z0GIWEX9YLOligSHPn52djI=; b=rit8bAKYvhVCKVUhHQidI0ex1MExnTBgg5dic01XJKyhNARkljhCWg4Wvu7CwvCUz84tta NK5ou3RdG3d7Z2DA== 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 15/39] PCI/MSI: Get rid of PCI_MSI_IRQ_DOMAIN References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:38 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208305298740604?= X-GMAIL-MSGID: =?utf-8?q?1749208305298740604?= What a zoo: PCI_MSI select GENERIC_MSI_IRQ PCI_MSI_IRQ_DOMAIN def_bool y depends on PCI_MSI select GENERIC_MSI_IRQ_DOMAIN Ergo PCI_MSI enables PCI_MSI_IRQ_DOMAIN which in turn selects GENERIC_MSI_IRQ_DOMAIN. So all the dependencies on PCI_MSI_IRQ_DOMAIN are just an indirection to PCI_MSI. Match the reality and just admit that PCI_MSI requires GENERIC_MSI_IRQ_DOMAIN. Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe --- arch/um/drivers/Kconfig | 1 arch/um/include/asm/pci.h | 2 - arch/x86/Kconfig | 1 arch/x86/include/asm/pci.h | 4 +- drivers/pci/Kconfig | 8 +---- drivers/pci/controller/Kconfig | 30 +++++++++----------- drivers/pci/controller/dwc/Kconfig | 48 ++++++++++++++++---------------- drivers/pci/controller/mobiveil/Kconfig | 6 ++-- drivers/pci/msi/Makefile | 2 - drivers/pci/probe.c | 2 - include/linux/msi.h | 32 ++++++--------------- 11 files changed, 56 insertions(+), 80 deletions(-) --- a/arch/um/drivers/Kconfig +++ b/arch/um/drivers/Kconfig @@ -381,7 +381,6 @@ config UML_PCI_OVER_VIRTIO select UML_IOMEM_EMULATION select UML_DMA_EMULATION select PCI_MSI - select PCI_MSI_IRQ_DOMAIN select PCI_LOCKLESS_CONFIG config UML_PCI_OVER_VIRTIO_DEVICE_ID --- a/arch/um/include/asm/pci.h +++ b/arch/um/include/asm/pci.h @@ -7,7 +7,7 @@ /* Generic PCI */ #include -#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN +#ifdef CONFIG_PCI_MSI /* * This is a bit of an annoying hack, and it assumes we only have * the virt-pci (if anything). Which is true, but still. --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -1109,7 +1109,6 @@ config X86_LOCAL_APIC def_bool y depends on X86_64 || SMP || X86_32_NON_STANDARD || X86_UP_APIC || PCI_MSI select IRQ_DOMAIN_HIERARCHY - select PCI_MSI_IRQ_DOMAIN if PCI_MSI config X86_IO_APIC def_bool y --- a/arch/x86/include/asm/pci.h +++ b/arch/x86/include/asm/pci.h @@ -21,7 +21,7 @@ struct pci_sysdata { #ifdef CONFIG_X86_64 void *iommu; /* IOMMU private data */ #endif -#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN +#ifdef CONFIG_PCI_MSI void *fwnode; /* IRQ domain for MSI assignment */ #endif #if IS_ENABLED(CONFIG_VMD) @@ -52,7 +52,7 @@ static inline int pci_proc_domain(struct } #endif -#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN +#ifdef CONFIG_PCI_MSI static inline void *_pci_root_bus_fwnode(struct pci_bus *bus) { return to_pci_sysdata(bus)->fwnode; --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -38,6 +38,7 @@ source "drivers/pci/pcie/Kconfig" config PCI_MSI bool "Message Signaled Interrupts (MSI and MSI-X)" + select GENERIC_MSI_IRQ_DOMAIN select GENERIC_MSI_IRQ help This allows device drivers to enable MSI (Message Signaled @@ -51,11 +52,6 @@ config PCI_MSI If you don't know what to do here, say Y. -config PCI_MSI_IRQ_DOMAIN - def_bool y - depends on PCI_MSI - select GENERIC_MSI_IRQ_DOMAIN - config PCI_MSI_ARCH_FALLBACKS bool @@ -192,7 +188,7 @@ config PCI_LABEL config PCI_HYPERV tristate "Hyper-V PCI Frontend" - depends on ((X86 && X86_64) || ARM64) && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN && SYSFS + depends on ((X86 && X86_64) || ARM64) && HYPERV && PCI_MSI && SYSFS select PCI_HYPERV_INTERFACE help The PCI device frontend driver allows the kernel to import arbitrary --- a/drivers/pci/controller/Kconfig +++ b/drivers/pci/controller/Kconfig @@ -19,7 +19,7 @@ config PCI_AARDVARK tristate "Aardvark PCIe controller" depends on (ARCH_MVEBU && ARM64) || COMPILE_TEST depends on OF - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCI_BRIDGE_EMUL help Add support for Aardvark 64bit PCIe Host Controller. This @@ -29,7 +29,7 @@ config PCI_AARDVARK config PCIE_XILINX_NWL bool "NWL PCIe Core" depends on ARCH_ZYNQMP || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI help Say 'Y' here if you want kernel support for Xilinx NWL PCIe controller. The controller can act as Root Port @@ -53,7 +53,7 @@ config PCI_IXP4XX config PCI_TEGRA bool "NVIDIA Tegra PCIe controller" depends on ARCH_TEGRA || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI help Say Y here if you want support for the PCIe host controller found on NVIDIA Tegra SoCs. @@ -70,7 +70,7 @@ config PCI_RCAR_GEN2 config PCIE_RCAR_HOST bool "Renesas R-Car PCIe host controller" depends on ARCH_RENESAS || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI help Say Y here if you want PCIe controller support on R-Car SoCs in host mode. @@ -99,7 +99,7 @@ config PCI_HOST_GENERIC config PCIE_XILINX bool "Xilinx AXI PCIe host bridge support" depends on OF || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI help Say 'Y' here if you want kernel to support the Xilinx AXI PCIe Host Bridge driver. @@ -124,7 +124,7 @@ config PCI_XGENE config PCI_XGENE_MSI bool "X-Gene v1 PCIe MSI feature" depends on PCI_XGENE - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI default y help Say Y here if you want PCIe MSI support for the APM X-Gene v1 SoC. @@ -170,7 +170,7 @@ config PCIE_IPROC_BCMA config PCIE_IPROC_MSI bool "Broadcom iProc PCIe MSI support" depends on PCIE_IPROC_PLATFORM || PCIE_IPROC_BCMA - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI default ARCH_BCM_IPROC help Say Y here if you want to enable MSI support for Broadcom's iProc @@ -186,7 +186,7 @@ config PCIE_ALTERA config PCIE_ALTERA_MSI tristate "Altera PCIe MSI feature" depends on PCIE_ALTERA - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI help Say Y here if you want PCIe MSI support for the Altera FPGA. This MSI driver supports Altera MSI to GIC controller IP. @@ -215,7 +215,7 @@ config PCIE_ROCKCHIP_HOST tristate "Rockchip PCIe host controller" depends on ARCH_ROCKCHIP || COMPILE_TEST depends on OF - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select MFD_SYSCON select PCIE_ROCKCHIP help @@ -239,7 +239,7 @@ config PCIE_MEDIATEK tristate "MediaTek PCIe controller" depends on ARCH_AIROHA || ARCH_MEDIATEK || COMPILE_TEST depends on OF - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI help Say Y here if you want to enable PCIe controller support on MediaTek SoCs. @@ -247,7 +247,7 @@ config PCIE_MEDIATEK config PCIE_MEDIATEK_GEN3 tristate "MediaTek Gen3 PCIe controller" depends on ARCH_MEDIATEK || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI help Adds support for PCIe Gen3 MAC controller for MediaTek SoCs. This PCIe controller is compatible with Gen3, Gen2 and Gen1 speed, @@ -277,7 +277,7 @@ config PCIE_BRCMSTB depends on ARCH_BRCMSTB || ARCH_BCM2835 || ARCH_BCMBCA || \ BMIPS_GENERIC || COMPILE_TEST depends on OF - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI default ARCH_BRCMSTB || BMIPS_GENERIC help Say Y here to enable PCIe host controller support for @@ -285,7 +285,7 @@ config PCIE_BRCMSTB config PCI_HYPERV_INTERFACE tristate "Hyper-V PCI Interface" - depends on ((X86 && X86_64) || ARM64) && HYPERV && PCI_MSI && PCI_MSI_IRQ_DOMAIN + depends on ((X86 && X86_64) || ARM64) && HYPERV && PCI_MSI && PCI_MSI help The Hyper-V PCI Interface is a helper driver allows other drivers to have a common interface with the Hyper-V PCI frontend driver. @@ -303,8 +303,6 @@ config PCI_LOONGSON config PCIE_MICROCHIP_HOST bool "Microchip AXI PCIe host bridge support" depends on PCI_MSI && OF - select PCI_MSI_IRQ_DOMAIN - select GENERIC_MSI_IRQ_DOMAIN select PCI_HOST_COMMON help Say Y here if you want kernel to support the Microchip AXI PCIe @@ -326,7 +324,7 @@ config PCIE_APPLE tristate "Apple PCIe controller" depends on ARCH_APPLE || COMPILE_TEST depends on OF - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCI_HOST_COMMON help Say Y here if you want to enable PCIe controller support on Apple --- a/drivers/pci/controller/dwc/Kconfig +++ b/drivers/pci/controller/dwc/Kconfig @@ -21,7 +21,7 @@ config PCI_DRA7XX_HOST tristate "TI DRA7xx PCIe controller Host Mode" depends on SOC_DRA7XX || COMPILE_TEST depends on OF && HAS_IOMEM && TI_PIPE3 - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST select PCI_DRA7XX default y if SOC_DRA7XX @@ -53,7 +53,7 @@ config PCIE_DW_PLAT config PCIE_DW_PLAT_HOST bool "Platform bus based DesignWare PCIe Controller - Host mode" - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST select PCIE_DW_PLAT help @@ -67,7 +67,7 @@ config PCIE_DW_PLAT_HOST config PCIE_DW_PLAT_EP bool "Platform bus based DesignWare PCIe Controller - Endpoint mode" - depends on PCI && PCI_MSI_IRQ_DOMAIN + depends on PCI && PCI_MSI depends on PCI_ENDPOINT select PCIE_DW_EP select PCIE_DW_PLAT @@ -83,7 +83,7 @@ config PCIE_DW_PLAT_EP config PCI_EXYNOS tristate "Samsung Exynos PCIe controller" depends on ARCH_EXYNOS || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST help Enables support for the PCIe controller in the Samsung Exynos SoCs @@ -94,13 +94,13 @@ config PCI_EXYNOS config PCI_IMX6 bool "Freescale i.MX6/7/8 PCIe controller" depends on ARCH_MXC || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST config PCIE_SPEAR13XX bool "STMicroelectronics SPEAr PCIe controller" depends on ARCH_SPEAR13XX || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST help Say Y here if you want PCIe support on SPEAr13XX SoCs. @@ -111,7 +111,7 @@ config PCI_KEYSTONE config PCI_KEYSTONE_HOST bool "PCI Keystone Host Mode" depends on ARCH_KEYSTONE || ARCH_K3 || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST select PCI_KEYSTONE help @@ -135,7 +135,7 @@ config PCI_KEYSTONE_EP config PCI_LAYERSCAPE bool "Freescale Layerscape PCIe controller - Host mode" depends on OF && (ARM || ARCH_LAYERSCAPE || COMPILE_TEST) - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST select MFD_SYSCON help @@ -160,7 +160,7 @@ config PCI_LAYERSCAPE_EP config PCI_HISI depends on OF && (ARM64 || COMPILE_TEST) bool "HiSilicon Hip05 and Hip06 SoCs PCIe controllers" - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST select PCI_HOST_COMMON help @@ -170,7 +170,7 @@ config PCI_HISI config PCIE_QCOM bool "Qualcomm PCIe controller" depends on OF && (ARCH_QCOM || COMPILE_TEST) - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST select CRC8 help @@ -191,7 +191,7 @@ config PCIE_QCOM_EP config PCIE_ARMADA_8K bool "Marvell Armada-8K PCIe controller" depends on ARCH_MVEBU || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST help Say Y here if you want to enable PCIe controller support on @@ -205,7 +205,7 @@ config PCIE_ARTPEC6 config PCIE_ARTPEC6_HOST bool "Axis ARTPEC-6 PCIe controller Host Mode" depends on MACH_ARTPEC6 || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST select PCIE_ARTPEC6 help @@ -226,7 +226,7 @@ config PCIE_ROCKCHIP_DW_HOST bool "Rockchip DesignWare PCIe controller" select PCIE_DW select PCIE_DW_HOST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI depends on ARCH_ROCKCHIP || COMPILE_TEST depends on OF help @@ -236,7 +236,7 @@ config PCIE_ROCKCHIP_DW_HOST config PCIE_INTEL_GW bool "Intel Gateway PCIe host controller support" depends on OF && (X86 || COMPILE_TEST) - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST help Say 'Y' here to enable PCIe Host controller support on Intel @@ -250,7 +250,7 @@ config PCIE_KEEMBAY config PCIE_KEEMBAY_HOST bool "Intel Keem Bay PCIe controller - Host mode" depends on ARCH_KEEMBAY || COMPILE_TEST - depends on PCI && PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST select PCIE_KEEMBAY help @@ -262,7 +262,7 @@ config PCIE_KEEMBAY_HOST config PCIE_KEEMBAY_EP bool "Intel Keem Bay PCIe controller - Endpoint mode" depends on ARCH_KEEMBAY || COMPILE_TEST - depends on PCI && PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI depends on PCI_ENDPOINT select PCIE_DW_EP select PCIE_KEEMBAY @@ -275,7 +275,7 @@ config PCIE_KEEMBAY_EP config PCIE_KIRIN depends on OF && (ARM64 || COMPILE_TEST) tristate "HiSilicon Kirin series SoCs PCIe controllers" - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST help Say Y here if you want PCIe controller support @@ -284,7 +284,7 @@ config PCIE_KIRIN config PCIE_HISI_STB bool "HiSilicon STB SoCs PCIe controllers" depends on ARCH_HISI || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST help Say Y here if you want PCIe controller support on HiSilicon STB SoCs @@ -292,7 +292,7 @@ config PCIE_HISI_STB config PCI_MESON tristate "MESON PCIe controller" default m if ARCH_MESON - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST help Say Y here if you want to enable PCI controller support on Amlogic @@ -306,7 +306,7 @@ config PCIE_TEGRA194 config PCIE_TEGRA194_HOST tristate "NVIDIA Tegra194 (and later) PCIe controller - Host Mode" depends on ARCH_TEGRA_194_SOC || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST select PHY_TEGRA194_P2U select PCIE_TEGRA194 @@ -336,7 +336,7 @@ config PCIE_TEGRA194_EP config PCIE_VISCONTI_HOST bool "Toshiba Visconti PCIe controllers" depends on ARCH_VISCONTI || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST help Say Y here if you want PCIe controller support on Toshiba Visconti SoC. @@ -346,7 +346,7 @@ config PCIE_UNIPHIER bool "Socionext UniPhier PCIe host controllers" depends on ARCH_UNIPHIER || COMPILE_TEST depends on OF && HAS_IOMEM - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST help Say Y here if you want PCIe host controller support on UniPhier SoCs. @@ -365,7 +365,7 @@ config PCIE_UNIPHIER_EP config PCIE_AL bool "Amazon Annapurna Labs PCIe controller" depends on OF && (ARM64 || COMPILE_TEST) - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_DW_HOST select PCI_ECAM help @@ -377,7 +377,7 @@ config PCIE_AL config PCIE_FU740 bool "SiFive FU740 PCIe host controller" - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI depends on SOC_SIFIVE || COMPILE_TEST select PCIE_DW_HOST help --- a/drivers/pci/controller/mobiveil/Kconfig +++ b/drivers/pci/controller/mobiveil/Kconfig @@ -8,14 +8,14 @@ config PCIE_MOBIVEIL config PCIE_MOBIVEIL_HOST bool - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_MOBIVEIL config PCIE_MOBIVEIL_PLAT bool "Mobiveil AXI PCIe controller" depends on ARCH_ZYNQMP || COMPILE_TEST depends on OF - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_MOBIVEIL_HOST help Say Y here if you want to enable support for the Mobiveil AXI PCIe @@ -25,7 +25,7 @@ config PCIE_MOBIVEIL_PLAT config PCIE_LAYERSCAPE_GEN4 bool "Freescale Layerscape PCIe Gen4 controller" depends on ARCH_LAYERSCAPE || COMPILE_TEST - depends on PCI_MSI_IRQ_DOMAIN + depends on PCI_MSI select PCIE_MOBIVEIL_HOST help Say Y here if you want PCIe Gen4 controller support on --- a/drivers/pci/msi/Makefile +++ b/drivers/pci/msi/Makefile @@ -3,5 +3,5 @@ # Makefile for the PCI/MSI obj-$(CONFIG_PCI) += pcidev_msi.o obj-$(CONFIG_PCI_MSI) += msi.o -obj-$(CONFIG_PCI_MSI_IRQ_DOMAIN) += irqdomain.o +obj-$(CONFIG_PCI_MSI) += irqdomain.o obj-$(CONFIG_PCI_MSI_ARCH_FALLBACKS) += legacy.o --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -842,7 +842,6 @@ static struct irq_domain *pci_host_bridg if (!d) d = pci_host_bridge_acpi_msi_domain(bus); -#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN /* * If no IRQ domain was found via the OF tree, try looking it up * directly through the fwnode_handle. @@ -854,7 +853,6 @@ static struct irq_domain *pci_host_bridg d = irq_find_matching_fwnode(fwnode, DOMAIN_BUS_PCI_MSI); } -#endif return d; } --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -238,15 +238,6 @@ static inline void msi_desc_set_iommu_co } #endif -#ifdef CONFIG_PCI_MSI -struct pci_dev *msi_desc_to_pci_dev(struct msi_desc *desc); -void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg); -#else /* CONFIG_PCI_MSI */ -static inline void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg) -{ -} -#endif /* CONFIG_PCI_MSI */ - int msi_add_msi_desc(struct device *dev, struct msi_desc *init_desc); void msi_free_msi_descs_range(struct device *dev, unsigned int first_index, unsigned int last_index); @@ -259,12 +250,6 @@ static inline void msi_free_msi_descs(st msi_free_msi_descs_range(dev, 0, MSI_MAX_INDEX); } -void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg); -void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg); - -void pci_msi_mask_irq(struct irq_data *data); -void pci_msi_unmask_irq(struct irq_data *data); - /* * The arch hooks to setup up msi irqs. Default functions are implemented * as weak symbols so that they /can/ be overriden by architecture specific @@ -466,20 +451,21 @@ int platform_msi_device_domain_alloc(str void platform_msi_device_domain_free(struct irq_domain *domain, unsigned int virq, unsigned int nvec); void *platform_msi_get_host_data(struct irq_domain *domain); -#endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */ -#ifdef CONFIG_PCI_MSI_IRQ_DOMAIN +/* PCI specific interfaces */ +struct pci_dev *msi_desc_to_pci_dev(struct msi_desc *desc); +void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg); +void __pci_read_msi_msg(struct msi_desc *entry, struct msi_msg *msg); +void __pci_write_msi_msg(struct msi_desc *entry, struct msi_msg *msg); +void pci_msi_mask_irq(struct irq_data *data); +void pci_msi_unmask_irq(struct irq_data *data); struct irq_domain *pci_msi_create_irq_domain(struct fwnode_handle *fwnode, struct msi_domain_info *info, struct irq_domain *parent); u32 pci_msi_domain_get_msi_rid(struct irq_domain *domain, struct pci_dev *pdev); struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev); bool pci_dev_has_special_msi_domain(struct pci_dev *pdev); -#else -static inline struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev) -{ - return NULL; -} -#endif /* CONFIG_PCI_MSI_IRQ_DOMAIN */ + +#endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */ #endif /* LINUX_MSI_H */ From patchwork Fri Nov 11 13:54:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18762 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753013wru; Fri, 11 Nov 2022 05:57:30 -0800 (PST) X-Google-Smtp-Source: AA0mqf5TqfoxXn6rPuyplAOIJJ/mmEOVVJxfwvk06cDhUo81NWaFNWw7PG1+hB6gYs3lx2Nvkr4N X-Received: by 2002:a17:906:7f92:b0:78d:4e5b:ffaa with SMTP id f18-20020a1709067f9200b0078d4e5bffaamr1816516ejr.455.1668175049986; Fri, 11 Nov 2022 05:57:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175049; cv=none; d=google.com; s=arc-20160816; b=kV9LRrBmpYDva1DcRmC5wBlNWL5b4lqAwkJ2I5EreAOWsQXKYOJc4YShniIgZxXIMC I/B8lV88Cy7GZUPsQKXOSm3xd0C0KYwTjHGXKE5F+YRJRFRMI0ckIVQhdjcClVLBliEw sVwg+bxkvYC4d0OmjzHRvV9Z7xT9IjZB67RfYJjnSNOSbWaa1CbYHdt1mfTN8k+whs83 wPCSDgzMwjgQqMdFn7D1FAu/QRfOJkvmxFSQxwcGTgWt6+8SyuOeZASl7P+ORyt74CwD hf2bExF3/kUBEidPLnXxs+CauLYx6CJGLzvWhALbMDnn+wtYdLF4EZbEnHq4kcKOI5Fo GZQw== 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=nX/kiLyWbr8sCZk981ReIZHgMoXYScRSLUvvPHFhr+I=; b=RWIFoJvf5bOZIHNs4+fzgdvrk46E6mH3sSv+DnBm2X2Hnl58bGBEV1+kktNBHaj/Ln ruzxNq6LqKci8jxbtF/iJT7F6feXthbPtPjJL0kTWi/MCdQcPZ2g+Ls1dIiVxCbifLsJ WcIAW2ddzyqQw/pYF/vSlTh/JFoGKl7ht4lcsOXu5NYL06RCy6nslTjPX0ZBeIqZffQd jTR7x2YajWb5q7Q01DsQe4wF0k+/X1WcFdPkiurkTRTilJ7UGdLVR5Mz9V3mOIVflC6Z 5yJdq6KEE9niHUpKvZjiKulNZr6ja2OAk9+MdnR5zwkL4y6YNQG5ny3Vct9R25Md6wYo CNlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=u+KdizKI; dkim=neutral (no key) header.i=@linutronix.de header.b="/gV9HPvt"; 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 f8-20020a056402354800b004612220a97fsi2465330edd.100.2022.11.11.05.57.06; Fri, 11 Nov 2022 05:57:29 -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=u+KdizKI; dkim=neutral (no key) header.i=@linutronix.de header.b="/gV9HPvt"; 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 S233943AbiKKN4H (ORCPT + 99 others); Fri, 11 Nov 2022 08:56:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59184 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233742AbiKKNz0 (ORCPT ); Fri, 11 Nov 2022 08:55:26 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E58478787; Fri, 11 Nov 2022 05:54:42 -0800 (PST) Message-ID: <20221111122014.524842979@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174881; 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=nX/kiLyWbr8sCZk981ReIZHgMoXYScRSLUvvPHFhr+I=; b=u+KdizKIt0qM9c1mNxNUainFe4cGSOxc3N7pjkIEmS03JsV/DWdst/DT7IplYSztLzsVzU UPERaAB4cQbJQN0rmoya/Mop8w5AUrc179VezSEsaHCbmr2wDiCy9wrleD1L5rUfGr0JPj n4CHbvKTkVKCfwHr7eGPRgT54TSzmsIAXAMYrs9K2Id69TQxBfRD6c0leeXX4bIDR8bOoJ NR1svsLag9E2s6kkeFuyi/FRh7yJeVXWUjGbLHzwm01HqZ4MCmDg3wkmFq0XxYP8ejzWhO ZXbyaI2SYu53F+1vf/U+PMA6gYfbS8P7uGDsYtnXhtiU3dQlg9LFaVUKSW8KsQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174881; 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=nX/kiLyWbr8sCZk981ReIZHgMoXYScRSLUvvPHFhr+I=; b=/gV9HPvtDrFTGv71bnYr6Mkzio2kV8KLKv7kYe2p3/RNpbT1YL7VYB6F+i6XmG4yWYIND2 57yVqfg7L8qDwiBQ== 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 16/39] genirq: Get rid of GENERIC_MSI_IRQ_DOMAIN References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:40 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208321300076984?= X-GMAIL-MSGID: =?utf-8?q?1749208321300076984?= Adjust to reality and remove another layer of pointless Kconfig indirection. CONFIG_GENERIC_MSI_IRQ is good enough to serve all purposes. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe --- drivers/base/Makefile | 2 +- drivers/bus/fsl-mc/Kconfig | 2 +- drivers/dma/Kconfig | 2 +- drivers/dma/qcom/hidma.c | 8 ++++---- drivers/iommu/Kconfig | 2 +- drivers/irqchip/Kconfig | 6 +++--- drivers/mailbox/Kconfig | 2 +- drivers/pci/Kconfig | 1 - drivers/perf/Kconfig | 2 +- drivers/soc/ti/Kconfig | 2 +- include/asm-generic/msi.h | 4 ++-- include/linux/device.h | 8 +++----- include/linux/gpio/driver.h | 2 +- include/linux/msi.h | 10 ++-------- kernel/irq/Kconfig | 7 +------ kernel/irq/msi.c | 3 --- 16 files changed, 23 insertions(+), 40 deletions(-) --- a/drivers/base/Makefile +++ b/drivers/base/Makefile @@ -22,7 +22,7 @@ obj-$(CONFIG_REGMAP) += regmap/ obj-$(CONFIG_SOC_BUS) += soc.o obj-$(CONFIG_PINCTRL) += pinctrl.o obj-$(CONFIG_DEV_COREDUMP) += devcoredump.o -obj-$(CONFIG_GENERIC_MSI_IRQ_DOMAIN) += platform-msi.o +obj-$(CONFIG_GENERIC_MSI_IRQ) += platform-msi.o obj-$(CONFIG_GENERIC_ARCH_TOPOLOGY) += arch_topology.o obj-$(CONFIG_GENERIC_ARCH_NUMA) += arch_numa.o obj-$(CONFIG_ACPI) += physical_location.o --- a/drivers/bus/fsl-mc/Kconfig +++ b/drivers/bus/fsl-mc/Kconfig @@ -8,7 +8,7 @@ config FSL_MC_BUS bool "QorIQ DPAA2 fsl-mc bus driver" depends on OF && (ARCH_LAYERSCAPE || (COMPILE_TEST && (ARM || ARM64 || X86_LOCAL_APIC || PPC))) - select GENERIC_MSI_IRQ_DOMAIN + select GENERIC_MSI_IRQ help Driver to enable the bus infrastructure for the QorIQ DPAA2 architecture. The fsl-mc bus driver handles discovery of --- a/drivers/dma/Kconfig +++ b/drivers/dma/Kconfig @@ -462,7 +462,7 @@ config MV_XOR_V2 select DMA_ENGINE select DMA_ENGINE_RAID select ASYNC_TX_ENABLE_CHANNEL_SWITCH - select GENERIC_MSI_IRQ_DOMAIN + select GENERIC_MSI_IRQ help Enable support for the Marvell version 2 XOR engine. --- a/drivers/dma/qcom/hidma.c +++ b/drivers/dma/qcom/hidma.c @@ -610,7 +610,7 @@ static irqreturn_t hidma_chirq_handler(i return hidma_ll_inthandler(chirq, lldev); } -#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN +#ifdef CONFIG_GENERIC_MSI_IRQ static irqreturn_t hidma_chirq_handler_msi(int chirq, void *arg) { struct hidma_lldev **lldevp = arg; @@ -671,7 +671,7 @@ static int hidma_sysfs_init(struct hidma return device_create_file(dev->ddev.dev, dev->chid_attrs); } -#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN +#ifdef CONFIG_GENERIC_MSI_IRQ static void hidma_write_msi_msg(struct msi_desc *desc, struct msi_msg *msg) { struct device *dev = msi_desc_to_dev(desc); @@ -687,7 +687,7 @@ static void hidma_write_msi_msg(struct m static void hidma_free_msis(struct hidma_dev *dmadev) { -#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN +#ifdef CONFIG_GENERIC_MSI_IRQ struct device *dev = dmadev->ddev.dev; int i, virq; @@ -704,7 +704,7 @@ static void hidma_free_msis(struct hidma static int hidma_request_msi(struct hidma_dev *dmadev, struct platform_device *pdev) { -#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN +#ifdef CONFIG_GENERIC_MSI_IRQ int rc, i, virq; rc = platform_msi_domain_alloc_irqs(&pdev->dev, HIDMA_MSI_INTS, --- a/drivers/iommu/Kconfig +++ b/drivers/iommu/Kconfig @@ -389,7 +389,7 @@ config ARM_SMMU_V3 depends on ARM64 select IOMMU_API select IOMMU_IO_PGTABLE_LPAE - select GENERIC_MSI_IRQ_DOMAIN + select GENERIC_MSI_IRQ help Support for implementations of the ARM System MMU architecture version 3 providing translation support to a PCIe root complex. --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -38,7 +38,7 @@ config ARM_GIC_V3 config ARM_GIC_V3_ITS bool - select GENERIC_MSI_IRQ_DOMAIN + select GENERIC_MSI_IRQ default ARM_GIC_V3 config ARM_GIC_V3_ITS_PCI @@ -375,7 +375,7 @@ config MVEBU_ICU config MVEBU_ODMI bool - select GENERIC_MSI_IRQ_DOMAIN + select GENERIC_MSI_IRQ config MVEBU_PIC bool @@ -488,7 +488,7 @@ config IMX_MU_MSI default m if ARCH_MXC select IRQ_DOMAIN select IRQ_DOMAIN_HIERARCHY - select GENERIC_MSI_IRQ_DOMAIN + select GENERIC_MSI_IRQ help Provide a driver for the i.MX Messaging Unit block used as a CPU-to-CPU MSI controller. This requires a specially crafted DT --- a/drivers/mailbox/Kconfig +++ b/drivers/mailbox/Kconfig @@ -223,7 +223,7 @@ config BCM_FLEXRM_MBOX tristate "Broadcom FlexRM Mailbox" depends on ARM64 depends on ARCH_BCM_IPROC || COMPILE_TEST - select GENERIC_MSI_IRQ_DOMAIN + select GENERIC_MSI_IRQ default m if ARCH_BCM_IPROC help Mailbox implementation of the Broadcom FlexRM ring manager, --- a/drivers/pci/Kconfig +++ b/drivers/pci/Kconfig @@ -38,7 +38,6 @@ source "drivers/pci/pcie/Kconfig" config PCI_MSI bool "Message Signaled Interrupts (MSI and MSI-X)" - select GENERIC_MSI_IRQ_DOMAIN select GENERIC_MSI_IRQ help This allows device drivers to enable MSI (Message Signaled --- a/drivers/perf/Kconfig +++ b/drivers/perf/Kconfig @@ -93,7 +93,7 @@ config ARM_PMU_ACPI config ARM_SMMU_V3_PMU tristate "ARM SMMUv3 Performance Monitors Extension" depends on (ARM64 && ACPI) || (COMPILE_TEST && 64BIT) - depends on GENERIC_MSI_IRQ_DOMAIN + depends on GENERIC_MSI_IRQ help Provides support for the ARM SMMUv3 Performance Monitor Counter Groups (PMCG), which provide monitoring of transactions passing --- a/drivers/soc/ti/Kconfig +++ b/drivers/soc/ti/Kconfig @@ -98,6 +98,6 @@ endif # SOC_TI config TI_SCI_INTA_MSI_DOMAIN bool - select GENERIC_MSI_IRQ_DOMAIN + select GENERIC_MSI_IRQ help Driver to enable Interrupt Aggregator specific MSI Domain. --- a/include/asm-generic/msi.h +++ b/include/asm-generic/msi.h @@ -4,7 +4,7 @@ #include -#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN +#ifdef CONFIG_GENERIC_MSI_IRQ #ifndef NUM_MSI_ALLOC_SCRATCHPAD_REGS # define NUM_MSI_ALLOC_SCRATCHPAD_REGS 2 @@ -36,6 +36,6 @@ typedef struct msi_alloc_info { #define GENERIC_MSI_DOMAIN_OPS 1 -#endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */ +#endif /* CONFIG_GENERIC_MSI_IRQ */ #endif --- a/include/linux/device.h +++ b/include/linux/device.h @@ -378,10 +378,8 @@ struct dev_links_info { * @data: Pointer to MSI device data */ struct dev_msi_info { -#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN - struct irq_domain *domain; -#endif #ifdef CONFIG_GENERIC_MSI_IRQ + struct irq_domain *domain; struct msi_device_data *data; #endif }; @@ -742,7 +740,7 @@ static inline void set_dev_node(struct d static inline struct irq_domain *dev_get_msi_domain(const struct device *dev) { -#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN +#ifdef CONFIG_GENERIC_MSI_IRQ return dev->msi.domain; #else return NULL; @@ -751,7 +749,7 @@ static inline struct irq_domain *dev_get static inline void dev_set_msi_domain(struct device *dev, struct irq_domain *d) { -#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN +#ifdef CONFIG_GENERIC_MSI_IRQ dev->msi.domain = d; #endif } --- a/include/linux/gpio/driver.h +++ b/include/linux/gpio/driver.h @@ -27,7 +27,7 @@ struct gpio_chip; union gpio_irq_fwspec { struct irq_fwspec fwspec; -#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN +#ifdef CONFIG_GENERIC_MSI_IRQ msi_alloc_info_t msiinfo; #endif }; --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -76,13 +76,7 @@ struct platform_msi_priv_data; struct device_attribute; void __get_cached_msi_msg(struct msi_desc *entry, struct msi_msg *msg); -#ifdef CONFIG_GENERIC_MSI_IRQ void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg); -#else -static inline void get_cached_msi_msg(unsigned int irq, struct msi_msg *msg) -{ -} -#endif typedef void (*irq_write_msi_msg_t)(struct msi_desc *desc, struct msi_msg *msg); @@ -278,7 +272,7 @@ static inline void msi_device_destroy_sy */ bool arch_restore_msi_irqs(struct pci_dev *dev); -#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN +#ifdef CONFIG_GENERIC_MSI_IRQ #include @@ -466,6 +460,6 @@ u32 pci_msi_domain_get_msi_rid(struct ir struct irq_domain *pci_msi_get_device_domain(struct pci_dev *pdev); bool pci_dev_has_special_msi_domain(struct pci_dev *pdev); -#endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */ +#endif /* CONFIG_GENERIC_MSI_IRQ */ #endif /* LINUX_MSI_H */ --- a/kernel/irq/Kconfig +++ b/kernel/irq/Kconfig @@ -86,15 +86,10 @@ config GENERIC_IRQ_IPI depends on SMP select IRQ_DOMAIN_HIERARCHY -# Generic MSI interrupt support -config GENERIC_MSI_IRQ - bool - # Generic MSI hierarchical interrupt domain support -config GENERIC_MSI_IRQ_DOMAIN +config GENERIC_MSI_IRQ bool select IRQ_DOMAIN_HIERARCHY - select GENERIC_MSI_IRQ config IRQ_MSI_IOMMU bool --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -461,7 +461,6 @@ static inline int msi_sysfs_populate_des static inline void msi_sysfs_remove_desc(struct device *dev, struct msi_desc *desc) { } #endif /* !CONFIG_SYSFS */ -#ifdef CONFIG_GENERIC_MSI_IRQ_DOMAIN static int __msi_domain_alloc_irqs(struct irq_domain *domain, struct device *dev, int nvec); static void __msi_domain_free_irqs(struct irq_domain *domain, struct device *dev); @@ -1058,5 +1057,3 @@ struct msi_domain_info *msi_get_domain_i { return (struct msi_domain_info *)domain->host_data; } - -#endif /* CONFIG_GENERIC_MSI_IRQ_DOMAIN */ From patchwork Fri Nov 11 13:54:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18763 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753028wru; Fri, 11 Nov 2022 05:57:32 -0800 (PST) X-Google-Smtp-Source: AA0mqf42HeDldvVHvw/MxFz0aS+B3pCPpcZNRaB55ed/9n7ckgRA+tNkeQaQbfLWJ0prTz31E7cU X-Received: by 2002:a17:906:9453:b0:78d:88c7:c1bf with SMTP id z19-20020a170906945300b0078d88c7c1bfmr1895813ejx.299.1668175051986; Fri, 11 Nov 2022 05:57:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175051; cv=none; d=google.com; s=arc-20160816; b=WvRfezVAlbsIw2OBiLwE+l0x7Crkbp6ec8YXH6D1+HqKp1ZAfBJwuoOvUoQt2n3T1g z/Z/aQ+4Ky4rMtGwcwMcPL3HDV1sBiPXKeqirJhzxBCCO8jw5P7AabW3Se4B9cx6XWbh 4s2bxZTfPmsbY/pbB6C+7nHdVxhhlgTph6OGP7+3bamm5e+325rhO4X904bAsc2tChS8 Q6tMo9+aVuHo2n+iug+FPccLCIMNjYCufEl8I3RhBozV7JJFixd6QA66VCk7gI3qx25v Y8pyMpJjewtn3HcyZ8kKtkjLjyobEZDH1JMhZqXaRn8xs3d8kCWlnPG+WLgxyobIoTV1 kUEg== 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=ZVOHAcQR6Ck8rZV367QnK3ufgoDh454h+k8+8chi22c=; b=C78RRkBmnl8TMVpTUreKyETuzrxab4obJKxV8K6eS76xRcRs6t9Q90wnCNFkBcpsx+ dheyCiAs1++cERfEBycfd3r8sgskBcIB+JvoYB4f5aj0e/xjVR2fiRtsxxH3YKhcNCep TdvfRvQhAVVPawKNAodYpJLgHm45fcj7ZECszGvw3Hyu5PG/c20shNG+lsXZAGBm7NZH haoFcSJ8rQVWF3Z2tLCW2yvXdBbXWIdiBz5DyELvtlncRiM068pPbI9JsL2YU+ityZHM F6AurSfvFOLNu1m38pOiCb9SLHj1vVyh3PdARzTOBQjko6KyVzpE7y/cNvDJVrcx/y2N qv8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=bh65FM3W; dkim=neutral (no key) header.i=@linutronix.de header.b=fjsDWHhh; 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 dm8-20020a170907948800b0078e063fc787si2162457ejc.433.2022.11.11.05.57.08; Fri, 11 Nov 2022 05:57:31 -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=bh65FM3W; dkim=neutral (no key) header.i=@linutronix.de header.b=fjsDWHhh; 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 S233742AbiKKN4L (ORCPT + 99 others); Fri, 11 Nov 2022 08:56:11 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57858 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233779AbiKKNzb (ORCPT ); Fri, 11 Nov 2022 08:55:31 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB3DF787B4; Fri, 11 Nov 2022 05:54:44 -0800 (PST) Message-ID: <20221111122014.582175082@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174882; 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=ZVOHAcQR6Ck8rZV367QnK3ufgoDh454h+k8+8chi22c=; b=bh65FM3Wv1jgNy8JX9L/1h1sGC4JvcUj61n/CAa1/GaCVxHMEPoCPnVUHAszASJJtm3aaS 3x6eK0/psnmrUrulQRoR5ceAXqPNIu5rg86zlhB9eMwtawFq4LqR95vhHRBEGkpP1ZUhLI nx+/v0r5xer11C1uLUi6/+zJz7nVSZOxDdgzI5tBPppvRovDqei+NkoMPwRggvR7n4XCqt 9qLbz9iXA2wI612maBZ+ywD0003Dp8VskJPB1CdTnzmeLisdjUb1V+0D+cbhpDSUo4BMF8 Ouy3gyMODMFyV9HGrxTx1HaFzMxnwY7YjVbWPP6ycv/4SosoyJug988nOd5IvQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174882; 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=ZVOHAcQR6Ck8rZV367QnK3ufgoDh454h+k8+8chi22c=; b=fjsDWHhhpyTkJ9A+o8h8oPspQFyMSpDqgwLBYxxiAcwxwbku+4D8UnAXoP0KekhsWD5xFC fd6YzUcVRwgcIGDg== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 17/39] PCI/MSI: Get rid of externs in msi.h References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:42 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208323168689357?= X-GMAIL-MSGID: =?utf-8?q?1749208323168689357?= From: Ahmed S. Darwish Follow the style of Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe --- drivers/pci/msi/msi.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/pci/msi/msi.h +++ b/drivers/pci/msi/msi.h @@ -5,12 +5,12 @@ #define msix_table_size(flags) ((flags & PCI_MSIX_FLAGS_QSIZE) + 1) -extern int pci_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); -extern void pci_msi_teardown_msi_irqs(struct pci_dev *dev); +int pci_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); +void pci_msi_teardown_msi_irqs(struct pci_dev *dev); #ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS -extern int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); -extern void pci_msi_legacy_teardown_msi_irqs(struct pci_dev *dev); +int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); +void pci_msi_legacy_teardown_msi_irqs(struct pci_dev *dev); #else static inline int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) { From patchwork Fri Nov 11 13:54:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18764 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753049wru; Fri, 11 Nov 2022 05:57:34 -0800 (PST) X-Google-Smtp-Source: AA0mqf7VR7MP+flAJghgGTClv6NNo3OWq6r/E1LgrgGJtEvOuYiDJBIjxDKVFbY+d1un+H1zeqaF X-Received: by 2002:a05:6402:5a:b0:45a:1bfa:98bf with SMTP id f26-20020a056402005a00b0045a1bfa98bfmr1509155edu.413.1668175054488; Fri, 11 Nov 2022 05:57:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175054; cv=none; d=google.com; s=arc-20160816; b=w745rCKAXFkrcwbQW7450clKOWhZTCk69h2IpdbjIzfvKJ43dhpx/qSD/g2WfyY+2v S0An5iZb/09SGwyeLvtgqJxq2z8qIUTO/pZ8zhsMfcMzJz90nLR/rEcfWaBPJq9XYCWz KlqHM2mouPQG4DF6NobNLJ7Fg4sqVMI1T+7Yb7Of66bnpZHNs2RksrQPeiLzXXVAtNsv 4vK1CFaoSAlf9A94FZz0JxCetit6WneQYf3xPLnoquAVnN9+4Puj1qpIWmP0RuglnbyG 6CnJi0nS5r3zzl6tyMeFJwrpg1VxpWXUUOXGh+hYknS7kLu2NsEu4gC5e8spiwTkXs8P 2byg== 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=kRlEyVKKnxgc8wl62QvRU5nn9b1AZrPtWorLrgk375w=; b=X8RnhLOcj/6Hpk6nKuWqQBUzBOU8hgs/oA2a1pigaiv17dDjlEW0gufpG5Kq6/WNhc 18SLyRkEJbjJKach4enPSV5KfTExJ3TX6IDnWjjftUYkz2TuxIulAFBlUBuoGBVC+01Q W1tpvv+V5FXEy9zJxweWqGsYs3Kg0ENFvTa2kGZ5ZPQnek+QAavpS4m4Dzs5IUStDjQx /VZ+fR7hXYXrLCfNQZJzmvxQ4x+J/U01o13V4VIJkkYMTuaDehKQE3yLcTCfLKm5UXHS Xk/8mstWv6L3rJfNXxjkGoItBMB7ALjtFhGo7keYjlUqT18vGVrzhnPuM0ca06IMteQe xdSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=ryg7ebz1; 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 x62-20020a50bac4000000b004621e2c473dsi2090460ede.354.2022.11.11.05.57.10; Fri, 11 Nov 2022 05:57:34 -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=ryg7ebz1; 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 S233965AbiKKN4Q (ORCPT + 99 others); Fri, 11 Nov 2022 08:56:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233801AbiKKNzl (ORCPT ); Fri, 11 Nov 2022 08:55:41 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1BF8778312; Fri, 11 Nov 2022 05:54:45 -0800 (PST) Message-ID: <20221111122014.640052354@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174884; 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=kRlEyVKKnxgc8wl62QvRU5nn9b1AZrPtWorLrgk375w=; b=ryg7ebz1ONkJp0BcF1tctqW/uo0TmYwk0M6DtUb4Qn1AD8mgQ8aFowTJsj/fYjtGqjKQ6Y 8pJ7TqZ5qm8LAYIPzt4XY2dea7aga7xIjPc/Gsr9KpqpHe2CjrS/7+ERr3KWCSzV/0A3+o cMavcFEzD5YtUPC6WgiK3TmqbNwhS4cWxO6S/w4fRL3w3GUHOtsmWyaoCGfI2kGsoW6Ebj f1zDZpAisWpCM5Vsxq+vr8maslsCRDHK1+2+7nG6eVFf93aDVuyNHvIdE5TNkzxEDun/Cc mU4CkGo/PQPzwlKHrGs9gY1ar04p8XRxdmoxmwkgEiyPWZeJekQ36NPz6A/4ug== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174884; 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=kRlEyVKKnxgc8wl62QvRU5nn9b1AZrPtWorLrgk375w=; b=ofJHjiRin0h7f5PMtU9l0xr54GINmGaThK/QZV+71VLlJINnxO9w97aT1aoGQ5bQKcTog+ aFDIPBRjC7itWZBw== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 18/39] PCI/MSI: Move mask and unmask helpers to msi.h References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:43 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208326215762906?= X-GMAIL-MSGID: =?utf-8?q?1749208326215762906?= From: Ahmed S. Darwish The upcoming support for per device MSI interrupt domains needs to share some of the inline helpers with the MSI implementation. Move them to the header file. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe --- drivers/pci/msi/msi.c | 61 +-------------------------------------- drivers/pci/msi/msi.h | 83 +++++++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 74 insertions(+), 70 deletions(-) --- diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 160af9f01669..5c310df55d0d 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -16,7 +16,7 @@ static int pci_msi_enable = 1; int pci_msi_ignore_mask; -static noinline void pci_msi_update_mask(struct msi_desc *desc, u32 clear, u32 set) +void pci_msi_update_mask(struct msi_desc *desc, u32 clear, u32 set) { raw_spinlock_t *lock = &to_pci_dev(desc->dev)->msi_lock; unsigned long flags; @@ -32,65 +32,6 @@ static noinline void pci_msi_update_mask(struct msi_desc *desc, u32 clear, u32 s raw_spin_unlock_irqrestore(lock, flags); } -static inline void pci_msi_mask(struct msi_desc *desc, u32 mask) -{ - pci_msi_update_mask(desc, 0, mask); -} - -static inline void pci_msi_unmask(struct msi_desc *desc, u32 mask) -{ - pci_msi_update_mask(desc, mask, 0); -} - -static inline void __iomem *pci_msix_desc_addr(struct msi_desc *desc) -{ - return desc->pci.mask_base + desc->msi_index * PCI_MSIX_ENTRY_SIZE; -} - -/* - * This internal function does not flush PCI writes to the device. All - * users must ensure that they read from the device before either assuming - * that the device state is up to date, or returning out of this file. - * It does not affect the msi_desc::msix_ctrl cache either. Use with care! - */ -static void pci_msix_write_vector_ctrl(struct msi_desc *desc, u32 ctrl) -{ - void __iomem *desc_addr = pci_msix_desc_addr(desc); - - if (desc->pci.msi_attrib.can_mask) - writel(ctrl, desc_addr + PCI_MSIX_ENTRY_VECTOR_CTRL); -} - -static inline void pci_msix_mask(struct msi_desc *desc) -{ - desc->pci.msix_ctrl |= PCI_MSIX_ENTRY_CTRL_MASKBIT; - pci_msix_write_vector_ctrl(desc, desc->pci.msix_ctrl); - /* Flush write to device */ - readl(desc->pci.mask_base); -} - -static inline void pci_msix_unmask(struct msi_desc *desc) -{ - desc->pci.msix_ctrl &= ~PCI_MSIX_ENTRY_CTRL_MASKBIT; - pci_msix_write_vector_ctrl(desc, desc->pci.msix_ctrl); -} - -static void __pci_msi_mask_desc(struct msi_desc *desc, u32 mask) -{ - if (desc->pci.msi_attrib.is_msix) - pci_msix_mask(desc); - else - pci_msi_mask(desc, mask); -} - -static void __pci_msi_unmask_desc(struct msi_desc *desc, u32 mask) -{ - if (desc->pci.msi_attrib.is_msix) - pci_msix_unmask(desc); - else - pci_msi_unmask(desc, mask); -} - /** * pci_msi_mask_irq - Generic IRQ chip callback to mask PCI/MSI interrupts * @data: pointer to irqdata associated to that interrupt diff --git a/drivers/pci/msi/msi.h b/drivers/pci/msi/msi.h index fc92603b33e1..d8f62d911f08 100644 --- a/drivers/pci/msi/msi.h +++ b/drivers/pci/msi/msi.h @@ -8,21 +8,67 @@ int pci_msi_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); void pci_msi_teardown_msi_irqs(struct pci_dev *dev); -#ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS -int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); -void pci_msi_legacy_teardown_msi_irqs(struct pci_dev *dev); -#else -static inline int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) +/* Mask/unmask helpers */ +void pci_msi_update_mask(struct msi_desc *desc, u32 clear, u32 set); + +static inline void pci_msi_mask(struct msi_desc *desc, u32 mask) { - WARN_ON_ONCE(1); - return -ENODEV; + pci_msi_update_mask(desc, 0, mask); } -static inline void pci_msi_legacy_teardown_msi_irqs(struct pci_dev *dev) +static inline void pci_msi_unmask(struct msi_desc *desc, u32 mask) { - WARN_ON_ONCE(1); + pci_msi_update_mask(desc, mask, 0); +} + +static inline void __iomem *pci_msix_desc_addr(struct msi_desc *desc) +{ + return desc->pci.mask_base + desc->msi_index * PCI_MSIX_ENTRY_SIZE; +} + +/* + * This internal function does not flush PCI writes to the device. All + * users must ensure that they read from the device before either assuming + * that the device state is up to date, or returning out of this file. + * It does not affect the msi_desc::msix_ctrl cache either. Use with care! + */ +static inline void pci_msix_write_vector_ctrl(struct msi_desc *desc, u32 ctrl) +{ + void __iomem *desc_addr = pci_msix_desc_addr(desc); + + if (desc->pci.msi_attrib.can_mask) + writel(ctrl, desc_addr + PCI_MSIX_ENTRY_VECTOR_CTRL); +} + +static inline void pci_msix_mask(struct msi_desc *desc) +{ + desc->pci.msix_ctrl |= PCI_MSIX_ENTRY_CTRL_MASKBIT; + pci_msix_write_vector_ctrl(desc, desc->pci.msix_ctrl); + /* Flush write to device */ + readl(desc->pci.mask_base); +} + +static inline void pci_msix_unmask(struct msi_desc *desc) +{ + desc->pci.msix_ctrl &= ~PCI_MSIX_ENTRY_CTRL_MASKBIT; + pci_msix_write_vector_ctrl(desc, desc->pci.msix_ctrl); +} + +static inline void __pci_msi_mask_desc(struct msi_desc *desc, u32 mask) +{ + if (desc->pci.msi_attrib.is_msix) + pci_msix_mask(desc); + else + pci_msi_mask(desc, mask); +} + +static inline void __pci_msi_unmask_desc(struct msi_desc *desc, u32 mask) +{ + if (desc->pci.msi_attrib.is_msix) + pci_msix_unmask(desc); + else + pci_msi_unmask(desc, mask); } -#endif /* * PCI 2.3 does not specify mask bits for each MSI interrupt. Attempting to @@ -37,3 +83,20 @@ static inline __attribute_const__ u32 msi_multi_mask(struct msi_desc *desc) return 0xffffffff; return (1 << (1 << desc->pci.msi_attrib.multi_cap)) - 1; } + +/* Legacy (!IRQDOMAIN) fallbacks */ +#ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS +int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); +void pci_msi_legacy_teardown_msi_irqs(struct pci_dev *dev); +#else +static inline int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) +{ + WARN_ON_ONCE(1); + return -ENODEV; +} + +static inline void pci_msi_legacy_teardown_msi_irqs(struct pci_dev *dev) +{ + WARN_ON_ONCE(1); +} +#endif From patchwork Fri Nov 11 13:54:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18765 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753106wru; Fri, 11 Nov 2022 05:57:41 -0800 (PST) X-Google-Smtp-Source: AA0mqf46dNvy98V/egVgVVbkbzprmNXcaCJiGm9sL498HvE2mPxamBjUuSu7141KV4gu5SQzj03Q X-Received: by 2002:a50:fd91:0:b0:463:ff10:4ff with SMTP id o17-20020a50fd91000000b00463ff1004ffmr1552677edt.290.1668175060903; Fri, 11 Nov 2022 05:57:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175060; cv=none; d=google.com; s=arc-20160816; b=L2tiLWFh6IIde3i9/nTv6abGDmCqxL6FpTgu9c/Xp6RwDdfoNLfYIyc1HxgrZ9amDg +tvJXPZ4169to0ICucXwp92zAxLe4f7Yuw5yssZMLouQ7NcCRfoTz1a8WNsicrIdOkxB cBM/LkolGYKWpSJOpBax7BeGXZ9QdqtZurQ+rg9R1bamdMdvyZMcPsxRErSUFMcZGEZb HPCO8UoicnMLeH0E/oYZfKG29O6PAp2EOEXa8jP/Vv1EcW9h4ivqEaPUUBaH79JEc+Zn ChaJCmloGQvQluCUlyVVwpRTixrt8nbrpRQKlYTRRuAC4He9CX6zjajcTWP5ka0Y+3yk 60IA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:content-transfer-encoding:mime-version :references:subject:cc:to:from:dkim-signature:dkim-signature :message-id; bh=5KmJKzZwAqMF//R5CEolBMOEBU8yD776C3UNuDuLpFo=; b=IeBOOjZW8BOI3fHFy5gO10oc64i3oqOUmQkcK2XvmiZlo1C2vCcVBXsrQpnZImcBXq sr5pHK95ITNoUW8UnLB9HOI18GC8ay/ZPqUACwW/HiWhEIFrehTtyUnUWeesZOSQnMNq bkwy5qOQL9dOf3ggsbtz2Fz2IWM072j4HKrhh1zz64WwAZs9gRlywcdsPQdIS1t5XWnK rR1uxBFONrXAjR14rV6ioKokTR2RW4Ti6eH2qjL9tsqu1ySSZHIIekl0WRQR5DzafoFx u3yMTg8tJKJsSM/snrJG0ftv9lzYspylesHvga4FlPZ5JVkqiDgEQmtr6WW2WgalYCE3 hzXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=aW9aT9GT; 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 nc33-20020a1709071c2100b0078d9db99f5esi2449901ejc.39.2022.11.11.05.57.16; Fri, 11 Nov 2022 05:57:40 -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=aW9aT9GT; 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 S233977AbiKKN4S (ORCPT + 99 others); Fri, 11 Nov 2022 08:56:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233803AbiKKNzn (ORCPT ); Fri, 11 Nov 2022 08:55:43 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1FF487BE68; Fri, 11 Nov 2022 05:54:47 -0800 (PST) Message-ID: <20221111122014.696798036@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174885; 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: content-transfer-encoding:content-transfer-encoding: references:references; bh=5KmJKzZwAqMF//R5CEolBMOEBU8yD776C3UNuDuLpFo=; b=aW9aT9GTxHiSQ01KmcKcVAR5Gtgm712AnUUjXcf/UAU+la1n84AAR2UKavCv+FV0EdOi0K GE+J5zNuoTimGlHv/TN11mzW0TcFOY96fSWBMrIxXfggJTwyt7FmyztYuREP2otV0Z2jLQ IelQtk6sZZ09STPmn+MIp6DLZcrUKcdLoJC25gD9iFwF8u9f1XqLIDyLpy7cr5fGjczJhJ T0cZWHq3/mtFCYeSlRoCya3GS0B8WNJMTYLwfLgvdnUTK1rPDUwOOh/5qYA5cT6J2+QM6v TVcpvC5MGQKsQcE/3PRdo4upSRBHB9Fu/+qY/awa/RURaoefAG4DEOKwiugMBQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174885; 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: content-transfer-encoding:content-transfer-encoding: references:references; bh=5KmJKzZwAqMF//R5CEolBMOEBU8yD776C3UNuDuLpFo=; b=JuaZZ0BRz9HXURKAI+Kmjfz/8OWWG3gRuOmSlo8r2Ql9shwrIORF/7ph03FmrEt4obqVVr pkNOSQC7YlHDVyCg== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 19/39] PCI/MSI: Move pci_disable_msi() to api.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:45 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208332295854448?= X-GMAIL-MSGID: =?utf-8?q?1749208332295854448?= From: Ahmed S. Darwish msi.c is a maze of randomly sorted functions which makes the code unreadable. As a first step split the driver visible API and the internal implementation which also allows proper API documentation via one file. Create drivers/pci/msi/api.c to group all exported device-driver PCI/MSI APIs in one C file. Begin by moving pci_disable_msi() there and add kernel-doc for the function as appropriate. Suggested-by: Thomas Gleixner Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/Makefile | 3 +-- drivers/pci/msi/api.c | 37 +++++++++++++++++++++++++++++++++++++ drivers/pci/msi/msi.c | 22 +++++----------------- drivers/pci/msi/msi.h | 4 ++++ 4 files changed, 47 insertions(+), 19 deletions(-) create mode 100644 drivers/pci/msi/api.c --- diff --git a/drivers/pci/msi/Makefile b/drivers/pci/msi/Makefile index 4e0a7e07965e..839ff72d72a8 100644 --- a/drivers/pci/msi/Makefile +++ b/drivers/pci/msi/Makefile @@ -2,6 +2,5 @@ # # Makefile for the PCI/MSI obj-$(CONFIG_PCI) += pcidev_msi.o -obj-$(CONFIG_PCI_MSI) += msi.o -obj-$(CONFIG_PCI_MSI) += irqdomain.o +obj-$(CONFIG_PCI_MSI) += api.o msi.o irqdomain.o obj-$(CONFIG_PCI_MSI_ARCH_FALLBACKS) += legacy.o diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c new file mode 100644 index 000000000000..7485942cbe5d --- /dev/null +++ b/drivers/pci/msi/api.c @@ -0,0 +1,37 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PCI MSI/MSI-X — Exported APIs for device drivers + * + * Copyright (C) 2003-2004 Intel + * Copyright (C) Tom Long Nguyen (tom.l.nguyen@intel.com) + * Copyright (C) 2016 Christoph Hellwig. + * Copyright (C) 2022 Linutronix GmbH + */ + +#include + +#include "msi.h" + +/** + * pci_disable_msi() - Disable MSI interrupt mode on device + * @dev: the PCI device to operate on + * + * Legacy device driver API to disable MSI interrupt mode on device, + * free earlier allocated interrupt vectors, and restore INTx emulation. + * The PCI device Linux IRQ (@dev->irq) is restored to its default + * pin-assertion IRQ. This is the cleanup pair of pci_enable_msi(). + * + * NOTE: The newer pci_alloc_irq_vectors() / pci_free_irq_vectors() API + * pair should, in general, be used instead. + */ +void pci_disable_msi(struct pci_dev *dev) +{ + if (!pci_msi_enabled() || !dev || !dev->msi_enabled) + return; + + msi_lock_descs(&dev->dev); + pci_msi_shutdown(dev); + pci_free_msi_irqs(dev); + msi_unlock_descs(&dev->dev); +} +EXPORT_SYMBOL(pci_disable_msi); diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 5c310df55d0d..4a1300b74518 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -163,7 +163,7 @@ void pci_write_msi_msg(unsigned int irq, struct msi_msg *msg) } EXPORT_SYMBOL_GPL(pci_write_msi_msg); -static void free_msi_irqs(struct pci_dev *dev) +void pci_free_msi_irqs(struct pci_dev *dev) { pci_msi_teardown_msi_irqs(dev); @@ -413,7 +413,7 @@ static int msi_capability_init(struct pci_dev *dev, int nvec, err: pci_msi_unmask(entry, msi_multi_mask(entry)); - free_msi_irqs(dev); + pci_free_msi_irqs(dev); fail: dev->msi_enabled = 0; unlock: @@ -531,7 +531,7 @@ static int msix_setup_interrupts(struct pci_dev *dev, void __iomem *base, goto out_unlock; out_free: - free_msi_irqs(dev); + pci_free_msi_irqs(dev); out_unlock: msi_unlock_descs(&dev->dev); kfree(masks); @@ -680,7 +680,7 @@ int pci_msi_vec_count(struct pci_dev *dev) } EXPORT_SYMBOL(pci_msi_vec_count); -static void pci_msi_shutdown(struct pci_dev *dev) +void pci_msi_shutdown(struct pci_dev *dev) { struct msi_desc *desc; @@ -701,18 +701,6 @@ static void pci_msi_shutdown(struct pci_dev *dev) pcibios_alloc_irq(dev); } -void pci_disable_msi(struct pci_dev *dev) -{ - if (!pci_msi_enable || !dev || !dev->msi_enabled) - return; - - msi_lock_descs(&dev->dev); - pci_msi_shutdown(dev); - free_msi_irqs(dev); - msi_unlock_descs(&dev->dev); -} -EXPORT_SYMBOL(pci_disable_msi); - /** * pci_msix_vec_count - return the number of device's MSI-X table entries * @dev: pointer to the pci_dev data structure of MSI-X device function @@ -797,7 +785,7 @@ void pci_disable_msix(struct pci_dev *dev) msi_lock_descs(&dev->dev); pci_msix_shutdown(dev); - free_msi_irqs(dev); + pci_free_msi_irqs(dev); msi_unlock_descs(&dev->dev); } EXPORT_SYMBOL(pci_disable_msix); diff --git a/drivers/pci/msi/msi.h b/drivers/pci/msi/msi.h index d8f62d911f08..634879277349 100644 --- a/drivers/pci/msi/msi.h +++ b/drivers/pci/msi/msi.h @@ -84,6 +84,10 @@ static inline __attribute_const__ u32 msi_multi_mask(struct msi_desc *desc) return (1 << (1 << desc->pci.msi_attrib.multi_cap)) - 1; } +/* MSI internal functions invoked from the public APIs */ +void pci_msi_shutdown(struct pci_dev *dev); +void pci_free_msi_irqs(struct pci_dev *dev); + /* Legacy (!IRQDOMAIN) fallbacks */ #ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); From patchwork Fri Nov 11 13:54:46 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18766 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753155wru; Fri, 11 Nov 2022 05:57:46 -0800 (PST) X-Google-Smtp-Source: AA0mqf7z9UlfROQeX39/EqRSuKxes0marSDOSP7HkV/jNFTKvMxyAy8WTaHeGiPVIw5gJ+kvHs28 X-Received: by 2002:a05:6402:1547:b0:461:5e99:a299 with SMTP id p7-20020a056402154700b004615e99a299mr1581846edx.40.1668175066460; Fri, 11 Nov 2022 05:57:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175066; cv=none; d=google.com; s=arc-20160816; b=rhE3DVjw6ONXOw4ZZE6DpdQRP+zuwE1BYllejz1hMm9gUOUFisRD0sc4fcWNHCd+tO O4B4ri8N6TRRB2pVdTHsdmQ6ve1V219qKIFGSUl7b3axhh0ed/LLk2abXOapca7OTdtn pVcGaW2I4E0qyXpeysnqKwvX92ONdcOOt43Fl6KLM6nZaxSvH8AC+CXlzDOpbvC2EqCY C6rbNWc5LfEp6DELV7WoFk0y/iFeHS2FFJh8kxnB/jn6F1DruezXUw8E7zVtSJJW9Ul8 ixLND+9AvDAIsK7ih8GKm6stnJQw3u7XtQMzPbQwvbBCkHjFTmlIYgNAT/cGvPI6QZ8C Aepg== 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=wQvlSyzCiWq4qPGjM0h6GVII+05+CelOP+QrbE9YOVQ=; b=AzAjTueItOUOoAyZS+BdDYo7zWZ/MNJGyCN6/o2T/3O+BLNAfpWkzR6cF/Fo3oJGe8 6rS1QmZnahKwVlv3IAPlcesxDK/MwJ3my8MEjGLdZTR9M64SSgZexYSSp9P20zyLG29A DgcD8UvAQbPImUpIgr6Kg94YhrP+zxiWpttOZi1PIUdj6UJKdlIiC2cRZzAa62yZVXn8 mWdhwVV9ThNlkXbEO71y1EqRYRxifoc4RilLOVecjiF91O5gE4tAoeA2L+qX3nBYap04 CH2v/T1U4+t6A393HsW3/X6kKxJ7cfW+ISu1xwNFwdVgB2wzLAKRcyiZtQ+R4CoYPcgJ ll8g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=fw5D8vTE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 s4-20020a17090699c400b0078df1c345dasi2368139ejn.534.2022.11.11.05.57.22; Fri, 11 Nov 2022 05:57:46 -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=fw5D8vTE; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S233898AbiKKN4f (ORCPT + 99 others); Fri, 11 Nov 2022 08:56:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58938 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233896AbiKKNzs (ORCPT ); Fri, 11 Nov 2022 08:55:48 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C2EFA79D3A; Fri, 11 Nov 2022 05:54:48 -0800 (PST) Message-ID: <20221111122014.755178149@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174887; 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=wQvlSyzCiWq4qPGjM0h6GVII+05+CelOP+QrbE9YOVQ=; b=fw5D8vTEf9OL/Hzxz50Ijd298/wbFchLIr8TMyRCskQnsWvuZwH85WDzYjyxa/PEEcm5S/ jq140H9dPnla1HZ3agqexHNFjhhzevUEVMXErO41h9kt9fao5vPKasGbCjKy9taJBY6hzv yXdu189B1M6hsC3msYMEU/SeaOuNFVdBoPjU9PO6ZGO+f4orB+1BmljW6SgW5O74Z3rM4b QSHAkL0lksdoznJyZ5kTjUKaP+JCdBYlcsUUx2Evza+ALkmP6L3ImXtuKlCJSPLOwLVok0 zz/njXuPPM0/spkdh7Z/3jQC9a2dfjIJeIQNNTOdDc1iR6SkzxFynpI0qJ0vhQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174887; 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=wQvlSyzCiWq4qPGjM0h6GVII+05+CelOP+QrbE9YOVQ=; b=ziGlwcK3Nj4s7gB/ueyqfSNSgD74IeHz55tHp/olK9uxKE7YDq5psk3BkZY1xDx4OMxWIZ CVYs5Yt0p+c5FYCw== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 20/39] PCI/MSI: Move pci_enable_msi() API to api.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:46 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208338166041756?= X-GMAIL-MSGID: =?utf-8?q?1749208338166041756?= From: Ahmed S. Darwish To distangle the maze in msi.c all exported device-driver MSI APIs are now to be grouped in one file, api.c. Move pci_enable_msi() and make its kernel-doc comprehensive. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/api.c | 23 +++++++++++++++++++++++ drivers/pci/msi/msi.c | 14 ++------------ drivers/pci/msi/msi.h | 1 + 3 files changed, 26 insertions(+), 12 deletions(-) --- diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index 7485942cbe5d..63d7f8f6a284 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -13,6 +13,29 @@ #include "msi.h" /** + * pci_enable_msi() - Enable MSI interrupt mode on device + * @dev: the PCI device to operate on + * + * Legacy device driver API to enable MSI interrupts mode on device and + * allocate a single interrupt vector. On success, the allocated vector + * Linux IRQ will be saved at @dev->irq. The driver must invoke + * pci_disable_msi() on cleanup. + * + * NOTE: The newer pci_alloc_irq_vectors() / pci_free_irq_vectors() API + * pair should, in general, be used instead. + * + * Return: 0 on success, errno otherwise + */ +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; +} +EXPORT_SYMBOL(pci_enable_msi); + +/** * pci_disable_msi() - Disable MSI interrupt mode on device * @dev: the PCI device to operate on * diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 4a1300b74518..98f07ad9af62 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -790,8 +790,8 @@ void pci_disable_msix(struct pci_dev *dev) } EXPORT_SYMBOL(pci_disable_msix); -static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, - struct irq_affinity *affd) +int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, + struct irq_affinity *affd) { int nvec; int rc; @@ -844,16 +844,6 @@ static int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, } } -/* 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; -} -EXPORT_SYMBOL(pci_enable_msi); - static int __pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int minvec, int maxvec, struct irq_affinity *affd, diff --git a/drivers/pci/msi/msi.h b/drivers/pci/msi/msi.h index 634879277349..00bb98d5bb0e 100644 --- a/drivers/pci/msi/msi.h +++ b/drivers/pci/msi/msi.h @@ -87,6 +87,7 @@ static inline __attribute_const__ u32 msi_multi_mask(struct msi_desc *desc) /* MSI internal functions invoked from the public APIs */ void pci_msi_shutdown(struct pci_dev *dev); void pci_free_msi_irqs(struct pci_dev *dev); +int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, struct irq_affinity *affd); /* Legacy (!IRQDOMAIN) fallbacks */ #ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS From patchwork Fri Nov 11 13:54:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18767 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753174wru; Fri, 11 Nov 2022 05:57:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf4chUbfYiQDKCPXaWYji6XJxqEQhz05z/9DoMWNNP6XVJZmbnTCBwFWXp86mc1TkNKipjUh X-Received: by 2002:a05:6402:747:b0:459:9dd3:2217 with SMTP id p7-20020a056402074700b004599dd32217mr1543971edy.163.1668175070487; Fri, 11 Nov 2022 05:57:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175070; cv=none; d=google.com; s=arc-20160816; b=Zhmw9Wm04i30eN8X71LBdzrjZixhn4IFLOuu5vZjL6eeepi1hVQNcU0INfnSFRQEM6 xW9Uc+y33XSrQ0YH3QQdcJcemjkjTdbfyUmC5D1nufeCEISZ7Ilbabiwxx5Dfs64Qob1 GsAw/TuNpFq8BDenrRaSBR8AKoOuIOJRZHwHd/wijs8qVKXfMNbpz2xBivP8vAT+P5J+ gfxblqgs/RUx/3tk59Yb8sRV8nh8GreWLp1ugOcf0CyvWzCI2JvkocdGPJBF66pS//nV P5vrC5ou7pThio1yIne6lLegAR8wsw78qvqyjyZQKKF/s4hwN2qDutLzKlEvkt1ZD/Rj w5xw== 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=+/SWQaPmmzQa3dI8BJSuUqTvToJtImL4OX5ekaSehDs=; b=GOyfZSn8AXcae8Nav3xWQh75zaeVeOcgMs8mUC4WKZvCCnuK4RNhaySFJIDJerTVLB gYSUATUwstM4lcPzV9AMNrdly3Yx5drSE0DkrG9u2uFNaVSRP5XYrwiA1vWxSSV6rjY7 9Palw2YUDPcwLgKyaKBNwkDtwMkjN7lvxtwfmkdBBQy43s6NaoLnd4h56l3SSwiGb2DU CRhmJUTCN4i3W3DG9iAbPYhR+FU5/v72XB/KNsoaaTFgNuJRSPQt39uDRNdiuXIzc5cL S6s3eBN8bwgmaddGKQt0jp2klToRk+L5iGlOLukv59r2QG6sMPoP66IWayOPkJXT2eCE mOrA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Er02kSdm; dkim=neutral (no key) header.i=@linutronix.de header.b=sZGbJ5v4; 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 xa6-20020a170906fd8600b00778d193ca81si2116101ejb.550.2022.11.11.05.57.26; Fri, 11 Nov 2022 05:57:50 -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=Er02kSdm; dkim=neutral (no key) header.i=@linutronix.de header.b=sZGbJ5v4; 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 S233608AbiKKN4h (ORCPT + 99 others); Fri, 11 Nov 2022 08:56:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59654 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233599AbiKKNzw (ORCPT ); Fri, 11 Nov 2022 08:55:52 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 549A37B229; Fri, 11 Nov 2022 05:54:50 -0800 (PST) Message-ID: <20221111122014.813792885@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174889; 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=+/SWQaPmmzQa3dI8BJSuUqTvToJtImL4OX5ekaSehDs=; b=Er02kSdmpSjpT/V3BnAH5gksYjlj5/BOkn1q9Xk0ByEwka7MmN00jjbggDtJ7CZn4JzwVE ER6d7eoeYN47fJi4hCN+Sok9ndfjzIKmFHUZu8xK7YQJ47q/TvEcVto6FzM6vIyHsnRgqs YgL6IDrUPtVRYLx8axV/P7RZ1srb/8C9YsnF4lxfzZyBgLgb+RhJZcNxQctOuwT0brjkvo VQDsYYqQscWHYak5X6s3xXhnNBK0x1opWlUPifFxluya48bGoRG9NqWQhRGYw04zGbfIJF I2et5ZGYIRLFpCoOT2KjezCk3ej3bKoSX7SQxaCNCf/G+6nDFBugigSPpvStew== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174889; 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=+/SWQaPmmzQa3dI8BJSuUqTvToJtImL4OX5ekaSehDs=; b=sZGbJ5v4ibSkVPeghlcKhY6RC7l93AZXEiSKmfJOLLjyOWr1rWHGxN49ajUHEOk1wCsitu 8ECbcklJiJTpKNDA== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 21/39] PCI/MSI: Move pci_enable_msix_range() to api.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:48 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208342570788301?= X-GMAIL-MSGID: =?utf-8?q?1749208342570788301?= From: Ahmed S. Darwish To distangle the maze in msi.c, all exported device-driver MSI APIs are now to be grouped in one file, api.c. Move pci_enable_msix_range() and make its kernel-doc comprehensive. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/api.c | 32 ++++++++++++++++++++++++++++++++ drivers/pci/msi/msi.c | 30 ++++-------------------------- drivers/pci/msi/msi.h | 3 +++ 3 files changed, 39 insertions(+), 26 deletions(-) --- diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index 63d7f8f6a284..d48050555d55 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -58,3 +58,35 @@ void pci_disable_msi(struct pci_dev *dev) msi_unlock_descs(&dev->dev); } EXPORT_SYMBOL(pci_disable_msi); + +/** + * pci_enable_msix_range() - Enable MSI-X interrupt mode on device + * @dev: the PCI device to operate on + * @entries: input/output parameter, array of MSI-X configuration entries + * @minvec: minimum required number of MSI-X vectors + * @maxvec: maximum desired number of MSI-X vectors + * + * Legacy device driver API to enable MSI-X interrupt mode on device and + * configure its MSI-X capability structure as appropriate. The passed + * @entries array must have each of its members "entry" field set to a + * desired (valid) MSI-X vector number, where the range of valid MSI-X + * vector numbers can be queried through pci_msix_vec_count(). If + * successful, the driver must invoke pci_disable_msix() on cleanup. + * + * NOTE: The newer pci_alloc_irq_vectors() / pci_free_irq_vectors() API + * pair should, in general, be used instead. + * + * Return: number of MSI-X vectors allocated (which might be smaller + * than @maxvecs), where Linux IRQ numbers for such allocated vectors + * are saved back in the @entries array elements' "vector" field. Return + * -ENOSPC if less than @minvecs interrupt vectors are available. + * Return -EINVAL if one of the passed @entries members "entry" field + * was invalid or a duplicate, or if plain MSI interrupts mode was + * earlier enabled on device. Return other errnos otherwise. + */ +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); +} +EXPORT_SYMBOL(pci_enable_msix_range); diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 98f07ad9af62..6700ef1c734e 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -844,10 +844,10 @@ int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, } } -static int __pci_enable_msix_range(struct pci_dev *dev, - struct msix_entry *entries, int minvec, - int maxvec, struct irq_affinity *affd, - int flags) +int __pci_enable_msix_range(struct pci_dev *dev, + struct msix_entry *entries, int minvec, + int maxvec, struct irq_affinity *affd, + int flags) { int rc, nvec = maxvec; @@ -887,28 +887,6 @@ static int __pci_enable_msix_range(struct pci_dev *dev, } /** - * pci_enable_msix_range - configure device's MSI-X capability structure - * @dev: pointer to the pci_dev data structure of MSI-X device function - * @entries: pointer to an array of MSI-X entries - * @minvec: minimum number of MSI-X IRQs requested - * @maxvec: maximum number of MSI-X IRQs requested - * - * Setup the MSI-X capability structure of device function with a maximum - * possible number of interrupts in the range between @minvec and @maxvec - * upon its software driver call to request for MSI-X mode enabled on its - * hardware device function. It returns a negative errno if an error occurs. - * If it succeeds, it returns the actual number of interrupts allocated and - * indicates the successful configuration of MSI-X capability structure - * with new allocated MSI-X interrupts. - **/ -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); -} -EXPORT_SYMBOL(pci_enable_msix_range); - -/** * pci_alloc_irq_vectors_affinity - allocate multiple IRQs for a device * @dev: PCI device to operate on * @min_vecs: minimum number of vectors required (must be >= 1) diff --git a/drivers/pci/msi/msi.h b/drivers/pci/msi/msi.h index 00bb98d5bb0e..8c4a5289432d 100644 --- a/drivers/pci/msi/msi.h +++ b/drivers/pci/msi/msi.h @@ -88,8 +88,11 @@ static inline __attribute_const__ u32 msi_multi_mask(struct msi_desc *desc) void pci_msi_shutdown(struct pci_dev *dev); void pci_free_msi_irqs(struct pci_dev *dev); int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, struct irq_affinity *affd); +int __pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int minvec, + int maxvec, struct irq_affinity *affd, int flags); /* Legacy (!IRQDOMAIN) fallbacks */ + #ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS int pci_msi_legacy_setup_msi_irqs(struct pci_dev *dev, int nvec, int type); void pci_msi_legacy_teardown_msi_irqs(struct pci_dev *dev); From patchwork Fri Nov 11 13:54:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18768 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753240wru; Fri, 11 Nov 2022 05:58:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Fmjtr6bMntuNso5Kx3jwZ86X4kGPRjs+VKt9/KX/VdaTnN2YSzAr/DHxV7PbCcd5W6NPY X-Received: by 2002:aa7:c64d:0:b0:45c:fca7:e094 with SMTP id z13-20020aa7c64d000000b0045cfca7e094mr1497925edr.314.1668175080238; Fri, 11 Nov 2022 05:58:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175080; cv=none; d=google.com; s=arc-20160816; b=C/BqEjs3XswDSZeyZl5BMwBmzAyR6kmY/JoGdXdXXivzbzsV+WhJHMSxJQXCbjfd07 BFw02sgd9ng8ro+kUTBEZ6LkVU8FSa6q0EeTaTqZEkx/b/G5U4RASbC6FeSySA2kkt+g oeJBOIm8roS6/6PyfWpx+ow5qKQTQ6B6RJG5ys0iHxsIaOTFgxsWsPKWvaS4RcUhFQ5O pUUWkxa4LnDORqN3ckuuIFVkX91e1iTR5IN/lya5CRj9JPPFGc/yi6bH4pR52wwCFTf+ ZvgR0TVtfYF8rYhY0Jk3FTPuzTQEsKB/yVNbIw3c9fsuYTYI5g9xdAbYQYy7o8oEVzYr zv9A== 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=r4FcKRBwb0S/6DX5J7gWRuaqhtaapFFj+24TyV6TJ3Q=; b=WJ4nNvS3mpSQI/JpQChIV8mgxTy8ysbpJi80LqaQZQvIQyBJg3w38fLVub+sZevTdV kgAoATU8dCoPjXIyeM2mcV2cS6kLBy+5PoqKR5LQOtXrayI5rQPwbXMqNIxHt9GOWZGX XFtt6KZs5AYnnl2AMFdOWGMkmQbOYAw8bPErjjfgjgjPuD8XjiKolj3ZYjbQHA5/5lRN vIlP51YHOSwa7ON9vsQr9175AxKxlY0Q7StdwJEb/2hmClcWZ+nW4fCXVCBrLkdl6uH8 0gYtIu/DN85gT6ToqohvPi9ev4yUzy+NxNLSPKfLTAWJUirgPCol5656tBcEZ+C6xEVU gooQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linutronix.de header.s=2020 header.b="oC1efg0/"; 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=fail (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 g18-20020a170906349200b007ad976163f4si1736437ejb.254.2022.11.11.05.57.35; Fri, 11 Nov 2022 05:58:00 -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=fail header.i=@linutronix.de header.s=2020 header.b="oC1efg0/"; 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=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=linutronix.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233911AbiKKN4n (ORCPT + 99 others); Fri, 11 Nov 2022 08:56:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233860AbiKKN4A (ORCPT ); Fri, 11 Nov 2022 08:56:00 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 05B6667101; Fri, 11 Nov 2022 05:54:52 -0800 (PST) Message-ID: <20221111122014.870888193@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174890; 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=r4FcKRBwb0S/6DX5J7gWRuaqhtaapFFj+24TyV6TJ3Q=; b=oC1efg0/7x7qL8AThd8flu4wRif16nNAbDPPmci8lhL2eADwgyBsYfEPHZSyI4yt8S+KJs Fly00rs/559MEIcgi9Gpww+9i6Iy4cQ3IWLL7y6p4eOn3TnfrtdrN2roLpKG6K+9zqLY4v g1KKU7xm4GzvZba1B8TViWnJhxeB7nJLyuymIW3Ni5ndgdwq/NUfrTUVt45sm3FKPWkwHK 3z1dwn6Fp7VjupcerdcMuAQAoVkB3fPh1EGTAU5atc2aHrIgDue3GqFMP23kj9jVwEFGY8 CIsWWqG23OelAGykN8OM25EcPbMu1aReKe9VPoRftrGjpfFHeLaNv3kuAzWvyA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174890; 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=r4FcKRBwb0S/6DX5J7gWRuaqhtaapFFj+24TyV6TJ3Q=; b=VBvji6CxYo3GJQJlKIkZ/fYFOTR9TrLHNIQBSnUKIR7abDARxG+AtzidhVRS0UQrQpqhJD 8rkdL7juWBEUqVBw== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 22/39] PCI/MSI: Move pci_alloc_irq_vectors() to api.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:50 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208352937799779?= X-GMAIL-MSGID: =?utf-8?q?1749208352937799779?= From: Ahmed S. Darwish To distangle the maze in msi.c, all exported device-driver MSI APIs are now to be grouped in one file, api.c. Make pci_alloc_irq_vectors() a real function instead of wrapper and add proper kernel doc to it. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/api.c | 33 +++++++++++++++++++++++++++++++++ include/linux/pci.h | 17 +++++++++-------- 2 files changed, 42 insertions(+), 8 deletions(-) --- diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index d48050555d55..1714905943fb 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -90,3 +90,36 @@ int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, return __pci_enable_msix_range(dev, entries, minvec, maxvec, NULL, 0); } EXPORT_SYMBOL(pci_enable_msix_range); + +/** + * pci_alloc_irq_vectors() - Allocate multiple device interrupt vectors + * @dev: the PCI device to operate on + * @min_vecs: minimum required number of vectors (must be >= 1) + * @max_vecs: maximum desired number of vectors + * @flags: One or more of: + * %PCI_IRQ_MSIX Allow trying MSI-X vector allocations + * %PCI_IRQ_MSI Allow trying MSI vector allocations + * %PCI_IRQ_LEGACY Allow trying legacy INTx interrupts, if + * and only if @min_vecs == 1 + * %PCI_IRQ_AFFINITY Auto-manage IRQs affinity by spreading + * the vectors around available CPUs + * + * Allocate up to @max_vecs interrupt vectors on device. MSI-X irq + * vector allocation has a higher precedence over plain MSI, which has a + * higher precedence over legacy INTx emulation. + * + * Upon a successful allocation, the caller should use pci_irq_vector() + * to get the Linux IRQ number to be passed to request_threaded_irq(). + * The driver must call pci_free_irq_vectors() on cleanup. + * + * Return: number of allocated vectors (which might be smaller than + * @max_vecs), -ENOSPC if less than @min_vecs interrupt vectors are + * available, other errnos otherwise. + */ +int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags) +{ + return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, + flags, NULL); +} +EXPORT_SYMBOL(pci_alloc_irq_vectors); diff --git a/include/linux/pci.h b/include/linux/pci.h index 2bda4a4e47e8..6a356a39ba94 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1553,6 +1553,8 @@ static inline int pci_enable_msix_exact(struct pci_dev *dev, return rc; return 0; } +int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags); int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, unsigned int max_vecs, unsigned int flags, struct irq_affinity *affd); @@ -1586,6 +1588,13 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, return 1; return -ENOSPC; } +static inline int +pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags) +{ + return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, + flags, NULL); +} static inline void pci_free_irq_vectors(struct pci_dev *dev) { @@ -1900,14 +1909,6 @@ pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, } #endif /* CONFIG_PCI */ -static inline int -pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, - unsigned int max_vecs, unsigned int flags) -{ - return pci_alloc_irq_vectors_affinity(dev, min_vecs, max_vecs, flags, - NULL); -} - /* Include architecture-dependent settings and functions */ #include From patchwork Fri Nov 11 13:54:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18769 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753243wru; Fri, 11 Nov 2022 05:58:00 -0800 (PST) X-Google-Smtp-Source: AA0mqf7Ug0jUoY9hzl4NNstqiOJ7/wIzRA9LDQHccUAE9DTRwOIBh1/MWDysFreqzXQAVvtMA9Sg X-Received: by 2002:a17:906:bc42:b0:78d:7a4c:13ea with SMTP id s2-20020a170906bc4200b0078d7a4c13eamr1903327ejv.471.1668175080476; Fri, 11 Nov 2022 05:58:00 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175080; cv=none; d=google.com; s=arc-20160816; b=pxSAoN/4oij39maxrVLzZ4ZItUPVIt6H47CH/7X0v0x49ikrTrwIAKBO6r3lcn+iIm RVv9XauTlPL7dregHDYrtCkmTwZP1zPXKXcsrW7LvrvjiselLcQLFBg94ZyJk8TezgQv qm1j5oj4wxTAQe9BZhojjbox/2O/DwKB2dL2+cCw/ekajpXQLnDob7nkWPITot5BTD4p zuLq4kSUibMGiOyJzWtoK8Tcdg7oLZOEryvmPzy6FK0j1EAG/sd1V3lKusXOGcxjMkOf BhSlVegdbPaspK0lmR0bv658okUc6l7Ukt57XheEMORXyrwHc86e2MbrwgmgecUVTI4A PKzg== 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=uefv1SQ/kFaCIoG5nEqNjtgMsMbRPxf/+/AfGMMS3ME=; b=yd44vkFEqMu2UyjcfK/pQaYoYi9Y7adwApGxc0EYE57fDQ3HeCJaM5E3NHCu/JkR1V WMiEI8UbZapiU7mfUEcKG/35Xz8k8OS5mwYEVhDBBOlJ15WgyNbiMkefURkEEd0aW9SQ EU5AgXNy2SerdHjMLEEYuj5kmT03qu3j3OjRxUnR2Js8nb9aVIWpRUzDq7/JA8ezSrXy QUH2NApdHSmqYhOrXHBeOSYnMqkGtn6bGNwNNQwnxuJ11/eQngCHLT7yOYAFNKq8/yNU 4FWBqz3ivNFmB94V+U+Nrp2LaSrxscqDw0q1XAHWXY/dB8inHl9mXYamv+55H8zUm4tv 1B6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=pRX56ARt; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=AJ1J3mtq; 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 gt40-20020a1709072da800b0078dce38525asi2402502ejc.896.2022.11.11.05.57.36; Fri, 11 Nov 2022 05:58:00 -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=pRX56ARt; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=AJ1J3mtq; 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 S233528AbiKKN4t (ORCPT + 99 others); Fri, 11 Nov 2022 08:56:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233613AbiKKN4B (ORCPT ); Fri, 11 Nov 2022 08:56:01 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F21F60698; Fri, 11 Nov 2022 05:54:53 -0800 (PST) Message-ID: <20221111122014.927531290@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174892; 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=uefv1SQ/kFaCIoG5nEqNjtgMsMbRPxf/+/AfGMMS3ME=; b=pRX56ARtPVj6OyQEIMCqiah6CjQfsbUUjLKE1htpO78jveI+lbUJsRZyFxv6ZjkAjUyoAN OmuwsBOTCOZcYbdo31sYBZJJ2JMMjsySbe+r7TtEcQbauOlB6obK1AaxPUm0xLZPC4vEfj fcveslvLUX0yyTCArZBpUr0GgvLaxk/Zt48uV76R6Xz6gsOtk073eqv6iPhtoDfylIPEcH 5WvyxYOkjFBFl2nOpoe9vzRcON0FKzSVhz9TXniJi/Fp6trJaG8/k4uD/ZGjZ0rqx/oUuu l8gSGVtbJBM/cwnAWhdq2WZdx3Vm6vpnKMcgPrP6Bm73HGnTvINn1tgoOm64CA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174892; 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=uefv1SQ/kFaCIoG5nEqNjtgMsMbRPxf/+/AfGMMS3ME=; b=AJ1J3mtq3gNBb0E5N58gtI7ISk9ECj7NVJw8fMFn44Fh4eLBVHxpY55lAGhoZtOWr1SC8R peJFrH/L1nyrdiAg== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 23/39] PCI/MSI: Move pci_alloc_irq_vectors_affinity() to api.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:51 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208353487196089?= X-GMAIL-MSGID: =?utf-8?q?1749208353487196089?= From: Ahmed S. Darwish To distangle the maze in msi.c, all exported device-driver MSI APIs are now to be grouped in one file, api.c. Move pci_alloc_irq_vectors_affinity() and let its kernel-doc reference pci_alloc_irq_vectors() documentation added in parent commit. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/api.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++- drivers/pci/msi/msi.c | 65 +---------------------------------------------------- 2 files changed, 59 insertions(+), 65 deletions(-) --- diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index 1714905943fb..8546749afa6e 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -123,3 +123,62 @@ int pci_alloc_irq_vectors(struct pci_dev *dev, unsigned int min_vecs, flags, NULL); } EXPORT_SYMBOL(pci_alloc_irq_vectors); + +/** + * pci_alloc_irq_vectors_affinity() - Allocate multiple device interrupt + * vectors with affinity requirements + * @dev: the PCI device to operate on + * @min_vecs: minimum required number of vectors (must be >= 1) + * @max_vecs: maximum desired number of vectors + * @flags: allocation flags, as in pci_alloc_irq_vectors() + * @affd: affinity requirements (can be %NULL). + * + * Same as pci_alloc_irq_vectors(), but with the extra @affd parameter. + * Check that function docs, and &struct irq_affinity, for more details. + */ +int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, + unsigned int max_vecs, unsigned int flags, + struct irq_affinity *affd) +{ + struct irq_affinity msi_default_affd = {0}; + int nvecs = -ENOSPC; + + if (flags & PCI_IRQ_AFFINITY) { + if (!affd) + affd = &msi_default_affd; + } else { + if (WARN_ON(affd)) + affd = NULL; + } + + if (flags & PCI_IRQ_MSIX) { + nvecs = __pci_enable_msix_range(dev, NULL, min_vecs, max_vecs, + affd, flags); + if (nvecs > 0) + return nvecs; + } + + if (flags & PCI_IRQ_MSI) { + nvecs = __pci_enable_msi_range(dev, min_vecs, max_vecs, affd); + if (nvecs > 0) + return nvecs; + } + + /* use legacy IRQ if allowed */ + if (flags & PCI_IRQ_LEGACY) { + if (min_vecs == 1 && dev->irq) { + /* + * Invoke the affinity spreading logic to ensure that + * the device driver can adjust queue configuration + * for the single interrupt case. + */ + if (affd) + irq_create_affinity_masks(1, affd); + pci_intx(dev, 1); + return 1; + } + } + + return nvecs; +} +EXPORT_SYMBOL(pci_alloc_irq_vectors_affinity); diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 6700ef1c734e..a028774f438d 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -887,71 +887,6 @@ int __pci_enable_msix_range(struct pci_dev *dev, } /** - * pci_alloc_irq_vectors_affinity - allocate multiple IRQs for a device - * @dev: PCI device to operate on - * @min_vecs: minimum number of vectors required (must be >= 1) - * @max_vecs: maximum (desired) number of vectors - * @flags: flags or quirks for the allocation - * @affd: optional description of the affinity requirements - * - * Allocate up to @max_vecs interrupt vectors for @dev, using MSI-X or MSI - * vectors if available, and fall back to a single legacy vector - * if neither is available. Return the number of vectors allocated, - * (which might be smaller than @max_vecs) if successful, or a negative - * error code on error. If less than @min_vecs interrupt vectors are - * available for @dev the function will fail with -ENOSPC. - * - * To get the Linux IRQ number used for a vector that can be passed to - * request_irq() use the pci_irq_vector() helper. - */ -int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, - unsigned int max_vecs, unsigned int flags, - struct irq_affinity *affd) -{ - struct irq_affinity msi_default_affd = {0}; - int nvecs = -ENOSPC; - - if (flags & PCI_IRQ_AFFINITY) { - if (!affd) - affd = &msi_default_affd; - } else { - if (WARN_ON(affd)) - affd = NULL; - } - - if (flags & PCI_IRQ_MSIX) { - nvecs = __pci_enable_msix_range(dev, NULL, min_vecs, max_vecs, - affd, flags); - if (nvecs > 0) - return nvecs; - } - - if (flags & PCI_IRQ_MSI) { - nvecs = __pci_enable_msi_range(dev, min_vecs, max_vecs, affd); - if (nvecs > 0) - return nvecs; - } - - /* use legacy IRQ if allowed */ - if (flags & PCI_IRQ_LEGACY) { - if (min_vecs == 1 && dev->irq) { - /* - * Invoke the affinity spreading logic to ensure that - * the device driver can adjust queue configuration - * for the single interrupt case. - */ - if (affd) - irq_create_affinity_masks(1, affd); - pci_intx(dev, 1); - return 1; - } - } - - return nvecs; -} -EXPORT_SYMBOL(pci_alloc_irq_vectors_affinity); - -/** * pci_free_irq_vectors - free previously allocated IRQs for a device * @dev: PCI device to operate on * From patchwork Fri Nov 11 13:54:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18770 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753261wru; Fri, 11 Nov 2022 05:58:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf4a1TfeSWJaWtHVnUVvtFxiOQImZVv8TP2EyOcPfqDAft8DA6RLJIt1/sjwMiytdHUkBPqH X-Received: by 2002:a17:906:793:b0:78c:ad86:d3 with SMTP id l19-20020a170906079300b0078cad8600d3mr1877419ejc.643.1668175082918; Fri, 11 Nov 2022 05:58:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175082; cv=none; d=google.com; s=arc-20160816; b=gLOGsdVY+UvcYOUbL0XUtYMFgEEXNIeFS9CBcIcB34rcBhtOmuWd6S4yBb0cXpT+eK wyxLqrCoLwJnF8pkUg288XzYi3yETzVrwdSLFr6N5uw4Vj8ZC0HSbeczeMNH5Sy+WIzI Um8TnbThW9i3M2bKkz99+Chht9PZoTgAN4XNcNYEZYYDLYjLBcPBngQTgmcLK5qVqhy8 Piz8A/EXqMTZXUdqFU8XyhSbkTQBDQKPMI6OCt7HMZ/fps3rHQmeyytkxdLjVg0l5BdY phUcUAjAqeNUfw6a/bG5OGCoJ1LmT0o89KsmjwSVRbNncl9FdTi5nT0k3mmREtJQrEcM oK0w== 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=bxe0AjpBaoDMg06CufdaCUWamwxhkdwl4bTBiQjCzNI=; b=W5FXLZm/CAkPbe6/BEyfoALjfpWdKi4HQk7WR+/RBuRKgqVWAoJmR/r/+41NfcJvtJ GSItKeD/2++eVeS72Sq8UyL9S3dXbaokwO0pDC4C3/K0LoNDHHGaHESuPzNFbCbI5Ybx VrwJJdgX9Cd5MCAF9bX4APFGTed3Sa85BecFiukvhTo2ei/fO/iAxSt+8ESp7FGDSgrQ xQlOTFiBBpMMIgMGpLgDMrezo6nqF7uS9s08hE2nkQZbpaiatZybs6X7LdTgxr4Gt6Ij sz+9TUyfUOKO3LfawmA1JFuia9anL4InN01beNYj4FRsH3JspnQc9tX6RtWTEg17juWW 5CYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=cMGjLzZL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=GqtozON3; 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 j18-20020a05640211d200b00462e628189asi2509729edw.304.2022.11.11.05.57.38; Fri, 11 Nov 2022 05:58:02 -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=cMGjLzZL; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=GqtozON3; 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 S233750AbiKKN5D (ORCPT + 99 others); Fri, 11 Nov 2022 08:57:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233592AbiKKN4D (ORCPT ); Fri, 11 Nov 2022 08:56:03 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E47295B5BF; Fri, 11 Nov 2022 05:54:55 -0800 (PST) Message-ID: <20221111122014.984490384@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174893; 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=bxe0AjpBaoDMg06CufdaCUWamwxhkdwl4bTBiQjCzNI=; b=cMGjLzZLtmJIj58oYr5P3Ok8YQZLmzLoqv8TcqjtDHGQGStfIwRRz5FAYENf+XUzKGvFfS U1HqMwbCGOu0ahCBvnP2LQuO4FVRfi6O6k8841mBDJLItntDNq2ICHJfGF8UOnvYlFZE1u MX98Yle05T3N1FhK+437CoOLSQfAyuWBThsr5H67RoLT46/GqCnJG2QP2J6tNr1wDFi7CZ uGECO372Vzpln/6RAnJjnLmcyJnBJYPQkkFr8QpGCUaz1gFD7VWXhMt+ebnZbvAhE0jFBC vOwD7a/CNm1eMI6JXWXXhXxMeCiz1a0yK3djJ5QxUfmSDOqc5eODC3QC3m22Cg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174893; 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=bxe0AjpBaoDMg06CufdaCUWamwxhkdwl4bTBiQjCzNI=; b=GqtozON3j5ddGqHse/b7ZFUeu9EaxdoXxaDKXGoeMNdAqhq3kEXBAFF/JTK28GaSU9IPnt NQvt0Gobxx0TOqBQ== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 24/39] PCI/MSI: Move pci_irq_vector() to api.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:53 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208355735757506?= X-GMAIL-MSGID: =?utf-8?q?1749208355735757506?= From: Ahmed S. Darwish To distangle the maze in msi.c, all exported device-driver MSI APIs are now to be grouped in one file, api.c. Move pci_irq_vector() and let its kernel-doc match the rest of the file. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/api.c | 23 +++++++++++++++++++++++ drivers/pci/msi/msi.c | 24 ------------------------ 2 files changed, 23 insertions(+), 24 deletions(-) --- diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index 8546749afa6e..0f1ec87e3f9f 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -182,3 +182,26 @@ int pci_alloc_irq_vectors_affinity(struct pci_dev *dev, unsigned int min_vecs, return nvecs; } EXPORT_SYMBOL(pci_alloc_irq_vectors_affinity); + +/** + * pci_irq_vector() - Get Linux IRQ number of a device interrupt vector + * @dev: the PCI device to operate on + * @nr: device-relative interrupt vector index (0-based); has different + * meanings, depending on interrupt mode + * MSI-X the index in the MSI-X vector table + * MSI the index of the enabled MSI vectors + * INTx must be 0 + * + * Return: the Linux IRQ number, or -EINVAL if @nr is out of range + */ +int pci_irq_vector(struct pci_dev *dev, unsigned int nr) +{ + unsigned int 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); diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index a028774f438d..38ad2fe4b85c 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -900,30 +900,6 @@ void pci_free_irq_vectors(struct pci_dev *dev) EXPORT_SYMBOL(pci_free_irq_vectors); /** - * pci_irq_vector - return Linux IRQ number of a device vector - * @dev: PCI device to operate on - * @nr: Interrupt vector index (0-based) - * - * @nr has the following meanings depending on the interrupt mode: - * MSI-X: The index in the MSI-X vector table - * MSI: The index of the enabled MSI vectors - * INTx: Must be 0 - * - * Return: The Linux interrupt number or -EINVAl if @nr is out of range. - */ -int pci_irq_vector(struct pci_dev *dev, unsigned int nr) -{ - unsigned int 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); - -/** * pci_irq_get_affinity - return the affinity of a particular MSI vector * @dev: PCI device to operate on * @nr: device-relative interrupt vector index (0-based). From patchwork Fri Nov 11 13:54:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18771 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753388wru; Fri, 11 Nov 2022 05:58:19 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Cy+BIrZ5sAq+hlOKUV278StR6djL9bg/xDajNKMFbsRbMFwy5aBFITur77Q8bTKstep6G X-Received: by 2002:a17:906:f196:b0:78d:6a9b:216c with SMTP id gs22-20020a170906f19600b0078d6a9b216cmr1880977ejb.602.1668175099388; Fri, 11 Nov 2022 05:58:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175099; cv=none; d=google.com; s=arc-20160816; b=MNNrd+JDJuY05xJ6oycdcepM5Ec7fFudNURd2zi2COsLw5miyRICcbu/0qmrZ958// RurBvSdiHjr3NpqZ66xFJ4zTdUveyS/TLbRqzE4JmLsg5wqD8z+A8PU1bf+wBW3Epukb UTCnWk3+iMXjHUpjFvYGr8P0vm6fogmEy37ifl5HMiYMxZP4nkrNunFco/1zIMT7tLWL Wn1r8LG0rH2BI+s0a2xnZhCLHzLUQ+os2v/kj5My8h2H/CY1mxrOCMnqAAu7vESh/V5O TzZXmh5yeI5jjmZjJNsEvdtWlf2/zdTkmMQMzqa+JgotxVyJ1h64PlCgY7M4h+oQW//T 7mJg== 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=P/dAsiB53NJ/9QiJ4hqH6W6Pskq4afAJG9tsk8AaX0Q=; b=RrtTOpTuIBB4wkBDOU+nAuDGtJ2gzOk87kNe5MOXmT6aUVQhseG3elVIxwA7sKqAi0 PRnMvTzQ4Iu4HVhUJA+nYbeYNWL/zVx6X2BThVs9SDWpUZAsrbAtJgy64Z+fKLL2C2U+ JkD/rBwki68cmvF+8XwhwQbWAoh8qjKGhqZsANT30i0UgxjG45DIV1mBPxoQSsKYEB85 zYtYQEpaH+W3ghNZ8nakgqtl75CVIbSk772sRRzCmVbn8TDVgHCEi57NlIxfUho0EL1C fbB1OxMyiTBUWMPamTkp4NwLw0uzdm6w1UGRQmejNw0gxoh5VXdsnfUPmGJZDrsEQwk5 ZTNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=OeXI2uBL; 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 t29-20020a056402241d00b004542c9947c1si2272728eda.217.2022.11.11.05.57.51; Fri, 11 Nov 2022 05:58:19 -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=OeXI2uBL; 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 S233859AbiKKN5K (ORCPT + 99 others); Fri, 11 Nov 2022 08:57:10 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58794 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233928AbiKKN4D (ORCPT ); Fri, 11 Nov 2022 08:56:03 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C14170196; Fri, 11 Nov 2022 05:54:57 -0800 (PST) Message-ID: <20221111122015.042870570@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174895; 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=P/dAsiB53NJ/9QiJ4hqH6W6Pskq4afAJG9tsk8AaX0Q=; b=OeXI2uBL1i4cCBWgCLDCjfWVrO+TGW/TKKoqPVlW6nRd7XuB0IylCLK2nnOS3JJqj3KGI3 woLnfcgLSwYHZfNTtZFOEzz/OUe8qmGOn1D/90O9/tMmcrTFbaxgcOkimW4wca31nX+6fC rNZqtK0XNoFRelFd/wWbFk4E84e8ezV7r/WBQN9qW/AlngbQicYTjPhvAEphKERN1UITqk j90JU0Ss2QQmTZzYyKyHXqECZWoRbVTbL4m6uUzQvH8hti+SyK0UoTlWAK8oD9ZKR1gLpM Rx1OR7SPtFM+tzdG9IJzLGeX4uVZOyPbm8AegMk+Ao7r2WOjtMa2HgjIieasKA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174895; 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=P/dAsiB53NJ/9QiJ4hqH6W6Pskq4afAJG9tsk8AaX0Q=; b=9etn11z13NPR3uOdAi/jxOseLod+YzmlXXfbgUMng69yMTgPSyiR5PWQM9MtTrhncoBb0J HEo73bvyvg7D2UBg== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 25/39] PCI/MSI: Move pci_free_irq_vectors() to api.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:54 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208372909429031?= X-GMAIL-MSGID: =?utf-8?q?1749208372909429031?= From: Ahmed S. Darwish To distangle the maze in msi.c, all exported device-driver MSI APIs are now to be grouped in one file, api.c. Move pci_free_irq_vectors() and make its kernel-doc comprehensive. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/api.c | 15 +++++++++++++++ drivers/pci/msi/msi.c | 13 ------------- 2 files changed, 15 insertions(+), 13 deletions(-) --- diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index 0f1ec87e3f9f..2ff2a9ccfc47 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -205,3 +205,18 @@ int pci_irq_vector(struct pci_dev *dev, unsigned int nr) return irq ? irq : -EINVAL; } EXPORT_SYMBOL(pci_irq_vector); + +/** + * pci_free_irq_vectors() - Free previously allocated IRQs for a device + * @dev: the PCI device to operate on + * + * Undo the interrupt vector allocations and possible device MSI/MSI-X + * enablement earlier done through pci_alloc_irq_vectors_affinity() or + * pci_alloc_irq_vectors(). + */ +void pci_free_irq_vectors(struct pci_dev *dev) +{ + pci_disable_msix(dev); + pci_disable_msi(dev); +} +EXPORT_SYMBOL(pci_free_irq_vectors); diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 38ad2fe4b85c..ed8caf5ac99f 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -887,19 +887,6 @@ int __pci_enable_msix_range(struct pci_dev *dev, } /** - * pci_free_irq_vectors - free previously allocated IRQs for a device - * @dev: PCI device to operate on - * - * Undoes the allocations and enabling in pci_alloc_irq_vectors(). - */ -void pci_free_irq_vectors(struct pci_dev *dev) -{ - pci_disable_msix(dev); - pci_disable_msi(dev); -} -EXPORT_SYMBOL(pci_free_irq_vectors); - -/** * pci_irq_get_affinity - return the affinity of a particular MSI vector * @dev: PCI device to operate on * @nr: device-relative interrupt vector index (0-based). From patchwork Fri Nov 11 13:54:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18772 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753426wru; Fri, 11 Nov 2022 05:58:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf7/IaQT9L/Lly3LnjnyB3wLyioYlWfz/9NAituciVERgVUQA6T+kqqa9VywdIMjxp55xWwr X-Received: by 2002:a17:906:960e:b0:781:aff3:c68d with SMTP id s14-20020a170906960e00b00781aff3c68dmr1977263ejx.36.1668175104389; Fri, 11 Nov 2022 05:58:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175104; cv=none; d=google.com; s=arc-20160816; b=wBWdFvILpSq1OI32OO+wfBqeTL8f523eSbIPnvPRiRQqVXUhWyLA/+V1OIos+39lSI +JoG/HDSVaUHXw7Ht7u9e2521BWzVmwx6cju5MWPjOM1HTFis7iUpMCfnDiTUH93SSUR OUFGsHPiTYGjir2qEsa55o/KfAfGTtqbkLLqM+0eALcvJ86eJxJd6MUIck9lhtGwOHxf hdKoXwYr98LBYrlI8Cs7L36GMuPI+Lhp51u0L6vU2T/71nrsvntFihQdKpKjPbqLeoR0 y2NrzVKFLvK9l05RAmHXeIjK2fVI1ie0tBqtsFewMCJUTCalwDHURkhuqQ2RfMi6eMmy n0eg== 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=CkhwWSdGdGLLdzERFUfoG3NG0AhBrHuNhPbAZeB+IvI=; b=oacU5+SuEx08oVcl4cvJMXIi9Mf7EBuGX8oi1O4n95QzqN8ULZbVmz9+hP+nJgVsjJ GVXlwZ0angU0YL09uRzVeWcQ6EPk2kmlaZWEwOGaD2XLoX953g8GE6ESNCX6ruCY/CCv SrpUc5fbIlhwtbHsc0Wn8MN/rApZvcgIasyIDM4P933d+2nXpFBQPmF9ECjp2trLUSfI 7qsYAWwTRcGwd7FnOY2Ibr983fD8bQyb6j8ctostM88swgp49m+SK6cFuVd3PWdZZMM+ diVB6O0MHf3kZW/jl7cxaP5/1aPEGOqzTR6qyw2tlx0Gs81EtOBKsajkqSFHs0YwN0Ev Bmeg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b="D/KO6ish"; 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 h1-20020a170906584100b007ae61d89b4bsi1483038ejs.283.2022.11.11.05.57.55; Fri, 11 Nov 2022 05:58:24 -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="D/KO6ish"; 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 S233923AbiKKN5Q (ORCPT + 99 others); Fri, 11 Nov 2022 08:57:16 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233933AbiKKN4E (ORCPT ); Fri, 11 Nov 2022 08:56:04 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9C8016EB4E; Fri, 11 Nov 2022 05:54:58 -0800 (PST) Message-ID: <20221111122015.099461602@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174897; 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=CkhwWSdGdGLLdzERFUfoG3NG0AhBrHuNhPbAZeB+IvI=; b=D/KO6ishfBlfCq11YH+Ofhy+P61hIKqceGKviXzQcvhX0F2xVoFUKMaucjWQOPHIBOtS0B /j/MU4IcPEAS0VdVZHkO+m3UpDZ7hTXF33/Ws3G36Ip5JRiX14aot8JnOG7L0U7Qq1Xlgj jjE4VymkIPiaEDau2j6yY/Sl8BqceSabP7pTCy9X4x6BTvRBxW/OT6bTntFuHWPwbPKT/V P1zatp5UOC1Uot6hhlrU4Qg82vOIZiBJdLZQcCmvdUdXk2TvgXRC20jIdiqB3/7836nSxW igL35SY8mpivrwl4VnRlxvfpssCjhZbbAJ3NJWotgixp4zcrki9BuKBYDFbLCg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174897; 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=CkhwWSdGdGLLdzERFUfoG3NG0AhBrHuNhPbAZeB+IvI=; b=agDEdkn3tqZvtSL/jqK2oB0oAy2H7vZ7hxPqegmfJc4ZGq2IGaAmYVus2CH/27QQDR0vBr OGs+tQD1dSzmRxCg== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 26/39] PCI/MSI: Move pci_msix_vec_count() to api.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:56 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208378296062517?= X-GMAIL-MSGID: =?utf-8?q?1749208378296062517?= From: Ahmed S. Darwish To distangle the maze in msi.c, all exported device-driver MSI APIs are now to be grouped in one file, api.c. Move pci_msix_vec_count() and make its kernel-doc comprehensive. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/api.c | 20 ++++++++++++++++++++ drivers/pci/msi/msi.c | 20 -------------------- 2 files changed, 20 insertions(+), 20 deletions(-) --- diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index 2ff2a9ccfc47..83ea38ffa116 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -60,6 +60,26 @@ void pci_disable_msi(struct pci_dev *dev) EXPORT_SYMBOL(pci_disable_msi); /** + * pci_msix_vec_count() - Get number of MSI-X interrupt vectors on device + * @dev: the PCI device to operate on + * + * Return: number of MSI-X interrupt vectors available on this device + * (i.e., the device's MSI-X capability structure "table size"), -EINVAL + * if the device is not MSI-X capable, other errnos otherwise. + */ +int pci_msix_vec_count(struct pci_dev *dev) +{ + u16 control; + + if (!dev->msix_cap) + return -EINVAL; + + pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &control); + return msix_table_size(control); +} +EXPORT_SYMBOL(pci_msix_vec_count); + +/** * pci_enable_msix_range() - Enable MSI-X interrupt mode on device * @dev: the PCI device to operate on * @entries: input/output parameter, array of MSI-X configuration entries diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index ed8caf5ac99f..1226d66da992 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -701,26 +701,6 @@ void pci_msi_shutdown(struct pci_dev *dev) pcibios_alloc_irq(dev); } -/** - * pci_msix_vec_count - return the number of device's MSI-X table entries - * @dev: pointer to the pci_dev data structure of MSI-X device function - * This function returns the number of device's MSI-X table entries and - * therefore the number of MSI-X vectors device is capable of sending. - * It returns a negative errno if the device is not capable of sending MSI-X - * interrupts. - **/ -int pci_msix_vec_count(struct pci_dev *dev) -{ - u16 control; - - if (!dev->msix_cap) - return -EINVAL; - - pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &control); - return msix_table_size(control); -} -EXPORT_SYMBOL(pci_msix_vec_count); - static int __pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec, struct irq_affinity *affd, int flags) { From patchwork Fri Nov 11 13:54:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18773 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753510wru; Fri, 11 Nov 2022 05:58:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf7tzaCasv/HmRnL5bz/+FOyh91keRav+xoqLQ+ZfMkq8Je9Prl0bwkAwWDhqIv1qCXqqUXA X-Received: by 2002:a17:906:51a:b0:78d:b3ef:656c with SMTP id j26-20020a170906051a00b0078db3ef656cmr1747327eja.627.1668175117087; Fri, 11 Nov 2022 05:58:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175117; cv=none; d=google.com; s=arc-20160816; b=OuQzS1SqDlNPeCaRdWcQUoAgY14zEGtFUXxCkuM9YeeBgYlVeGIHCrxqLGlr5Zq7ne L3c54HrpHmOr4vdJbZybokhbwucqDJAc21xgIZPY71znn6sgKtKSCpv7G9ePtxoiv2m6 z72UwKaJhoTHpGTOav6M0H5nI6qAoT8Awperg0eIfmOty0wSEv7wYCSutbTMUhpVNwCT 3oYZfXB41LDoS4P2mpzXTaCA5NQVIyH4YKBbSlWlXHlv8vorGqqUywd4Qg3QrIpUtcHV X9+gMqkEoeySt7Te6z9xOcfIIKnEu5wZP0cre8qrHqBlRUpqPas6ASR+eS1ERF98P4XM elUQ== 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=sTSauIHtQe8nkxj9vWG7an7hER/OZbQ0yiXscxhOHpY=; b=tE9qxaI1DOk4NQ95P0zi21fmtUGPXzAJZz7fQn0qVO3Em7MUNk98RYourN4MKCOW1y uafchtL1FiOR7bAYD1gtcN5cjmXCht/M07vs+y/lMaW2wy+cH7cFC6t35tzipj9UfjEQ c+aieMTmBLvFF46wDO67qNJv+g6qe5YNRqoDLlMBAWjUAzfh+aF7AAtYr5sfpkGRjZYV oG+hFcMXLXvq/6Lctj3MQvnEuzwhkdyI8IjONyw91zKxhCoNmVbLUlmLxXhjPJNvrsIu vg7iiovKDADf3X6KtI9/YfHOPCZ4ECzyNP/Kv/f/JADo32G6lWnrPQgmexdAPgcCBTBd qjFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GCdtHiG1; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 hp18-20020a1709073e1200b007ad95fdd21csi2055716ejc.761.2022.11.11.05.58.13; Fri, 11 Nov 2022 05:58:37 -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=GCdtHiG1; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S233980AbiKKN5T (ORCPT + 99 others); Fri, 11 Nov 2022 08:57:19 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233678AbiKKN4F (ORCPT ); Fri, 11 Nov 2022 08:56:05 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6FB7A2B25B; Fri, 11 Nov 2022 05:55:00 -0800 (PST) Message-ID: <20221111122015.156785224@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174898; 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=sTSauIHtQe8nkxj9vWG7an7hER/OZbQ0yiXscxhOHpY=; b=GCdtHiG1mb1fVSYh20ExvLEgwnR3bMna0MV/l5dzAxH4jfJF15HxOOhRez2F2sTkSkN2rE 3/uBzQAfXv8r/lDQ/bQ0HAgpcTfjq2J2UDjO3iwycl2Q+jrsyJr//OwbLU2VIZLpxn2NRN adFz/JEvDxevHKf15fZHh1DU3NcrOADkt9ul5zltTwQQyKC0f0k5XT9RW50IgaQfty3oc8 cLVj/5ydTRp0JAjS0IJeJ0iYQhdlGdk+zgCWfFHvaRjCbO4kQ+2PYWABD6ZZ/bNWOeJ1hF rJ9JtygHZ/oYVMg2RMhjmJlSJQwzKdf5qHoW7MyVyWQ09MLE5oq2DHddS4+qTQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174898; 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=sTSauIHtQe8nkxj9vWG7an7hER/OZbQ0yiXscxhOHpY=; b=eTjnEvqLANPRFPDzNmMJb0aixvOkBMzGLcVDG/D78BrlL+s4esd4umI5YvkWIFmjtWzfxv 1qpBSZvBZJ+hbBAg== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 27/39] PCI/MSI: Move pci_disable_msix() to api.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:58 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208391687361715?= X-GMAIL-MSGID: =?utf-8?q?1749208391687361715?= From: Ahmed S. Darwish To distangle the maze in msi.c, all exported device-driver MSI APIs are now to be grouped in one file, api.c. Move pci_disable_msix() and make its kernel-doc comprehensive. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/api.c | 24 ++++++++++++++++++++++++ drivers/pci/msi/msi.c | 14 +------------- drivers/pci/msi/msi.h | 1 + 3 files changed, 26 insertions(+), 13 deletions(-) --- diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index 83ea38ffa116..653a61868ae6 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -112,6 +112,30 @@ int pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, EXPORT_SYMBOL(pci_enable_msix_range); /** + * pci_disable_msix() - Disable MSI-X interrupt mode on device + * @dev: the PCI device to operate on + * + * Legacy device driver API to disable MSI-X interrupt mode on device, + * free earlier-allocated interrupt vectors, and restore INTx emulation. + * The PCI device Linux IRQ (@dev->irq) is restored to its default pin + * assertion IRQ. This is the cleanup pair of pci_enable_msix_range(). + * + * NOTE: The newer pci_alloc_irq_vectors() / pci_free_irq_vectors() API + * pair should, in general, be used instead. + */ +void pci_disable_msix(struct pci_dev *dev) +{ + if (!pci_msi_enabled() || !dev || !dev->msix_enabled) + return; + + msi_lock_descs(&dev->dev); + pci_msix_shutdown(dev); + pci_free_msi_irqs(dev); + msi_unlock_descs(&dev->dev); +} +EXPORT_SYMBOL(pci_disable_msix); + +/** * pci_alloc_irq_vectors() - Allocate multiple device interrupt vectors * @dev: the PCI device to operate on * @min_vecs: minimum required number of vectors (must be >= 1) diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 1226d66da992..6fa90d07d2e4 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -736,7 +736,7 @@ static int __pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, return msix_capability_init(dev, entries, nvec, affd); } -static void pci_msix_shutdown(struct pci_dev *dev) +void pci_msix_shutdown(struct pci_dev *dev) { struct msi_desc *desc; @@ -758,18 +758,6 @@ static void pci_msix_shutdown(struct pci_dev *dev) pcibios_alloc_irq(dev); } -void pci_disable_msix(struct pci_dev *dev) -{ - if (!pci_msi_enable || !dev || !dev->msix_enabled) - return; - - msi_lock_descs(&dev->dev); - pci_msix_shutdown(dev); - pci_free_msi_irqs(dev); - msi_unlock_descs(&dev->dev); -} -EXPORT_SYMBOL(pci_disable_msix); - int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, struct irq_affinity *affd) { diff --git a/drivers/pci/msi/msi.h b/drivers/pci/msi/msi.h index 8c4a5289432d..77e2587f7e4f 100644 --- a/drivers/pci/msi/msi.h +++ b/drivers/pci/msi/msi.h @@ -86,6 +86,7 @@ static inline __attribute_const__ u32 msi_multi_mask(struct msi_desc *desc) /* MSI internal functions invoked from the public APIs */ void pci_msi_shutdown(struct pci_dev *dev); +void pci_msix_shutdown(struct pci_dev *dev); void pci_free_msi_irqs(struct pci_dev *dev); int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, struct irq_affinity *affd); int __pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int minvec, From patchwork Fri Nov 11 13:54:59 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18788 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753984wru; Fri, 11 Nov 2022 05:59:50 -0800 (PST) X-Google-Smtp-Source: AA0mqf7gaxcKV1PgGPZCnSvmLlfGnJQKu/SqTs+DhycS3K2seWaqGEP7YehKSTw9QMoBg9AAnjAL X-Received: by 2002:a17:906:7707:b0:78d:9324:6f18 with SMTP id q7-20020a170906770700b0078d93246f18mr1967581ejm.664.1668175190492; Fri, 11 Nov 2022 05:59:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175190; cv=none; d=google.com; s=arc-20160816; b=iIP52yLsWwyWsyR/RFWBpPiWErXPlZFc0/imHYbUC7dlZj3b5K1C68DDBSUIRLGnpL TU6cLo0AadiOW9m80289cOLxa2qbdMz2fdWyxDntLqSOb88cIFRkAClQJn8jFF4p0we8 SkcD06MzlOpL0Hyy6DjoxYJ76z4SGqkCCVaBnQKhNNlDCslnDTcc6jVCNzL2dglweMl3 0XBFHz1WVwSpK1EITc6AvZFKjk7AKwIvgm7K0st8O+hDw6NxFi00xs04CMAcvNpX5RAM 11KJaMC3N1lDJE/4r8sESQEVc1n6x5yPKm+gV/YAP8Iuw5LdI+d9y52uNL4gnBz2b+2C qdJA== 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=gj8+JLvsSB7JkfjvtAibAPolzK16OEvGxNAST4u+PB8=; b=Jye2PTHQx+yCwvrPR+HJGEsMQTbstYEDxuzlAiDUvvC/V6sK7dqDF2DAgtTWRZJmOm WI4A6Jn8EbtZ0fD7+C/idco65p5Y+qnrfYh9GVWlwGbusMxpbPDYBTxbhttuYhf7MT5H 9LdFCm4QtoljhhuiRZaJtxxyHW2U7TtsDUi3bqG/8h53lCSykeS7IOJ4VcubxL77B3N1 Xl0hYKPML5IBnBWgEiLp2hwG0RCuuNfSEFSE445XOOwiZ5Qw/Mo4GauCDqSHCl75ZYn4 QhFMpmqp6T5n9F5SIO9b/DDQrxCaNWLgoRkXqq6gqeL3PYig8fZ8FzlaPx58vPoUcFEM CG5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XKPL2kgf; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=U39CZCre; 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 h5-20020a056402280500b00463ab1bf95bsi2816295ede.94.2022.11.11.05.59.26; Fri, 11 Nov 2022 05:59:50 -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=XKPL2kgf; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=U39CZCre; 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 S233886AbiKKN66 (ORCPT + 99 others); Fri, 11 Nov 2022 08:58:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58500 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233783AbiKKN4G (ORCPT ); Fri, 11 Nov 2022 08:56:06 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E6D7D657FF; Fri, 11 Nov 2022 05:55:01 -0800 (PST) Message-ID: <20221111122015.214792769@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174900; 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=gj8+JLvsSB7JkfjvtAibAPolzK16OEvGxNAST4u+PB8=; b=XKPL2kgfTpBrkdRq/Zqnr5TZtcoLiZS8HUTfm0kQkuYgegQYsqUwtY5csl9/CyJkrPrCEz A9uxOuIvrfntnY2DKbdKMXmf4ksC0QTVqS9OdMAlOAOQgCdzLXVMmX1JcCPAEBhdSB5mBf nhdD2+t2116iU5IqwotSXCD6AhM6aj2Y0RdnX73ut/xTahJDDpijcYHst0UpgmkbhE6eFJ UPSG4e0XWUziwhZY+cmfTYsgkNtc8sB9PEd/1aKnPYelYUCQtxFzSfMjWN7EeHPb0ht7Ss 04ZIAgydyt5L4gwlXCajkYRprDuhpS7NFJtkyRCbyY3urky7Pc8pU8t+6DhEDA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174900; 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=gj8+JLvsSB7JkfjvtAibAPolzK16OEvGxNAST4u+PB8=; b=U39CZCreXp6akmR3rKYVXRdbqs3XmuPdImd4hF/P0sSdCshaJKWtTXiiq6gHDDA3yj+rKA b2RkkjTtCy75QgDw== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 28/39] PCI/MSI: Move pci_irq_get_affinity() to api.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:54:59 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208468148514769?= X-GMAIL-MSGID: =?utf-8?q?1749208468148514769?= From: Ahmed S. Darwish To distangle the maze in msi.c, all exported device-driver MSI APIs are now to be grouped in one file, api.c. Move pci_irq_get_affinity() and let its kernel-doc match rest of the file. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/api.c | 43 +++++++++++++++++++++++++++++++++++++++++++ drivers/pci/msi/msi.c | 38 -------------------------------------- 2 files changed, 43 insertions(+), 38 deletions(-) --- diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index 653a61868ae6..473df7ba0584 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -9,6 +9,7 @@ */ #include +#include #include "msi.h" @@ -251,6 +252,48 @@ int pci_irq_vector(struct pci_dev *dev, unsigned int nr) EXPORT_SYMBOL(pci_irq_vector); /** + * pci_irq_get_affinity() - Get a device interrupt vector affinity + * @dev: the PCI device to operate on + * @nr: device-relative interrupt vector index (0-based); has different + * meanings, depending on interrupt mode + * MSI-X the index in the MSI-X vector table + * MSI the index of the enabled MSI vectors + * INTx must be 0 + * + * Return: MSI/MSI-X vector affinity, NULL if @nr is out of range or if + * the MSI(-X) vector was allocated without explicit affinity + * requirements (e.g., by pci_enable_msi(), pci_enable_msix_range(), or + * pci_alloc_irq_vectors() without the %PCI_IRQ_AFFINITY flag). Return a + * generic set of CPU ids representing all possible CPUs available + * during system boot if the device is in legacy INTx mode. + */ +const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr) +{ + int idx, irq = pci_irq_vector(dev, nr); + struct msi_desc *desc; + + if (WARN_ON_ONCE(irq <= 0)) + return NULL; + + desc = irq_get_msi_desc(irq); + /* Non-MSI does not have the information handy */ + if (!desc) + return cpu_possible_mask; + + /* MSI[X] interrupts can be allocated without affinity descriptor */ + if (!desc->affinity) + return NULL; + + /* + * MSI has a mask array in the descriptor. + * MSI-X has a single mask. + */ + idx = dev->msi_enabled ? nr : 0; + return &desc->affinity[idx].mask; +} +EXPORT_SYMBOL(pci_irq_get_affinity); + +/** * pci_free_irq_vectors() - Free previously allocated IRQs for a device * @dev: the PCI device to operate on * diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 6fa90d07d2e4..d78646d1c116 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -854,44 +854,6 @@ int __pci_enable_msix_range(struct pci_dev *dev, } } -/** - * pci_irq_get_affinity - return the affinity of a particular MSI vector - * @dev: PCI device to operate on - * @nr: device-relative interrupt vector index (0-based). - * - * @nr has the following meanings depending on the interrupt mode: - * MSI-X: The index in the MSI-X vector table - * MSI: The index of the enabled MSI vectors - * INTx: Must be 0 - * - * Return: A cpumask pointer or NULL if @nr is out of range - */ -const struct cpumask *pci_irq_get_affinity(struct pci_dev *dev, int nr) -{ - int idx, irq = pci_irq_vector(dev, nr); - struct msi_desc *desc; - - if (WARN_ON_ONCE(irq <= 0)) - return NULL; - - desc = irq_get_msi_desc(irq); - /* Non-MSI does not have the information handy */ - if (!desc) - return cpu_possible_mask; - - /* MSI[X] interrupts can be allocated without affinity descriptor */ - if (!desc->affinity) - return NULL; - - /* - * MSI has a mask array in the descriptor. - * MSI-X has a single mask. - */ - idx = dev->msi_enabled ? nr : 0; - return &desc->affinity[idx].mask; -} -EXPORT_SYMBOL(pci_irq_get_affinity); - struct pci_dev *msi_desc_to_pci_dev(struct msi_desc *desc) { return to_pci_dev(desc->dev); From patchwork Fri Nov 11 13:55:01 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18780 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753684wru; Fri, 11 Nov 2022 05:59:07 -0800 (PST) X-Google-Smtp-Source: AA0mqf7KBkR6FcWPBJpSlD9J1qwtMHYuMxdAOLaFJBuEA4Bw5GtO0rsxG/aO+AjbTdBLsGotxwxI X-Received: by 2002:a17:907:8a1b:b0:78d:9d0b:a9f6 with SMTP id sc27-20020a1709078a1b00b0078d9d0ba9f6mr1932542ejc.661.1668175146883; Fri, 11 Nov 2022 05:59:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175146; cv=none; d=google.com; s=arc-20160816; b=YTmUQnz5WcEczYk/0TloeVaDAOafpTbELmfr8+bgwNzGnSu5NU6skFi6XPime0dlM0 BrMJJ0Qg5RLtJ9BdHJf0I52i+Z5NN+4cfC2Z1udxOOGqolnSZESOfDKnPWF421tmkQSf K49Um+g/GTFogsaRNr3XkV1DjVLgxzzBk3qXQg+oRVruNxJiPMem8nwZXy6sKsVura7+ oa93JoT2K72iVR1w3dVXZL+6tCpsHUYeEdxqIw5XiNOHwoH/OO/YUMrBF3FBYPXZ1oDo ybsV0NGGWpZJVIvUAlS8ScRAonSfkIQcC6/hMxp9ADD1o4s8JybHsAwRI4T3C6Uru+GB Ox9Q== 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=uSFXy88Ws6eNkV/cYwDRULmA+6GRqcWIzt5ADLcbTDw=; b=Z/pkMpRoebm52+TsIoT+ft47g1iaeKKtxN+A9P//ZtPU6jnlcfxCvlPX+pWMkczPL4 +XB7QaR/5LN+TUpgnyfEorCeF4yeOrcYt0rBCD6VB79IBKT9On/L+ySCahlDxUA8YFnl vy0u77MuNU5tE7AI515OOBEzo/4idukTIi00dBqXsxpwtUcE1rqcX5TI6Z9uUnbUHpNk YfoWyEs7vcyw/wpn1V9K9+AeVCwgADxvu5Ch3rClvRlkmOB2OOY5Tz50Pj+KUe+lRBc5 qG8epNZh2Uz0Ljyhq5r79jRt9ng7PPz9rXvdYjVNE5N1wGSbgqyJ/4qvWtVTdpjd5Rns +ouA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=qtOLrPfL; 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 x9-20020a1709064a8900b007a31138203asi1634354eju.669.2022.11.11.05.58.43; Fri, 11 Nov 2022 05:59:06 -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=qtOLrPfL; 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 S234012AbiKKN5W (ORCPT + 99 others); Fri, 11 Nov 2022 08:57:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59596 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233799AbiKKN4H (ORCPT ); Fri, 11 Nov 2022 08:56:07 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5902D7F563; Fri, 11 Nov 2022 05:55:03 -0800 (PST) Message-ID: <20221111122015.271447896@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174902; 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=uSFXy88Ws6eNkV/cYwDRULmA+6GRqcWIzt5ADLcbTDw=; b=qtOLrPfLAgkAZVy6NU1Qu4bTgTB43Bj44kvSwwsRH2ZnPNV8dgX7HwnPsn22qu8w9m7yL2 A97svlVBbgwk1Kouj39B9/00uFrvjnNmfsSosW6KlZXHE8ipZjQ0zh2qu2h4JEOniktLvM DdJLcXVpW+4EUh71Wah1RWNgffLHTJmi70jycylYYTUnXe5mTgu11BanYjAsDqbjHjh5Cj jNVdIefLpB/Et84Tmy/wCrmUO2sDcrVo8lhj8nIcgrZW5QGFV0eKkEMimQbvvAjsRl/0w+ VdXkapfyi/PEEHMzxyAKo9mdYdwp3K4g/p7Prgjc0/kxGJjy/daFCUOg+YK/3w== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174902; 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=uSFXy88Ws6eNkV/cYwDRULmA+6GRqcWIzt5ADLcbTDw=; b=9t/bFWqCfq8f0C3vQmoP3/db8s/pcp6OGrpaut5YexKKU5gS1ZtJ1Y4TbyTmvAad70QZt8 pyB9AsmnH5FIAdCA== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 29/39] PCI/MSI: Move pci_msi_enabled() to api.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:55:01 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208422425165230?= X-GMAIL-MSGID: =?utf-8?q?1749208422425165230?= From: Ahmed S. Darwish To distangle the maze in msi.c, all exported device-driver MSI APIs are now to be grouped in one file, api.c. Move pci_msi_enabled() and make its kernel-doc comprehensive. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/api.c | 12 ++++++++++++ drivers/pci/msi/msi.c | 14 +------------- drivers/pci/msi/msi.h | 3 +++ 3 files changed, 16 insertions(+), 13 deletions(-) --- diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index 473df7ba0584..ee9ed5ccd94d 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -307,3 +307,15 @@ void pci_free_irq_vectors(struct pci_dev *dev) pci_disable_msi(dev); } EXPORT_SYMBOL(pci_free_irq_vectors); + +/** + * pci_msi_enabled() - Are MSI(-X) interrupts enabled system-wide? + * + * Return: true if MSI has not been globally disabled through ACPI FADT, + * PCI bridge quirks, or the "pci=nomsi" kernel command-line option. + */ +int pci_msi_enabled(void) +{ + return pci_msi_enable; +} +EXPORT_SYMBOL(pci_msi_enabled); diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index d78646d1c116..59c33bc7fe81 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -13,7 +13,7 @@ #include "../pci.h" #include "msi.h" -static int pci_msi_enable = 1; +int pci_msi_enable = 1; int pci_msi_ignore_mask; void pci_msi_update_mask(struct msi_desc *desc, u32 clear, u32 set) @@ -864,15 +864,3 @@ void pci_no_msi(void) { pci_msi_enable = 0; } - -/** - * pci_msi_enabled - is MSI enabled? - * - * Returns true if MSI has not been disabled by the command-line option - * pci=nomsi. - **/ -int pci_msi_enabled(void) -{ - return pci_msi_enable; -} -EXPORT_SYMBOL(pci_msi_enabled); diff --git a/drivers/pci/msi/msi.h b/drivers/pci/msi/msi.h index 77e2587f7e4f..f3f4ede53171 100644 --- a/drivers/pci/msi/msi.h +++ b/drivers/pci/msi/msi.h @@ -84,6 +84,9 @@ static inline __attribute_const__ u32 msi_multi_mask(struct msi_desc *desc) return (1 << (1 << desc->pci.msi_attrib.multi_cap)) - 1; } +/* Subsystem variables */ +extern int pci_msi_enable; + /* MSI internal functions invoked from the public APIs */ void pci_msi_shutdown(struct pci_dev *dev); void pci_msix_shutdown(struct pci_dev *dev); From patchwork Fri Nov 11 13:55:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18775 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753557wru; Fri, 11 Nov 2022 05:58:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf5rvq0eiWiZGaumktlACJHhfsKoiwJcYQa8bhZ23W498yyi9JEqVumZBmc/OUd5fF58hhQo X-Received: by 2002:a17:906:5fcd:b0:78d:4cb3:f65d with SMTP id k13-20020a1709065fcd00b0078d4cb3f65dmr1997372ejv.79.1668175125182; Fri, 11 Nov 2022 05:58:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175125; cv=none; d=google.com; s=arc-20160816; b=ldXwepyylAG4G5MyDR1LLF5qPcbsmq0NM0MrigmQZycblKwP/6rKfGOzZj3fEI69/s 6JNNSlGOWk7wkjsNUj97+89g2bUMOnFEvkMEAKVNjTNMLui86o/CLSMZnrAp7YnkADO7 iMxJXFSav0OiJPquNvoGkSpEVl5GjHuvcZZJHb1/Hd6MIME+R74Ag3oTvEZKQ7oGGFIU cTZ/86ha+7ysGmXEsbK/hFCL9IYsPe9MHi+4xLdlLy+R8/BLKfhopqVR95UtbHLR4T3x KYP21FyGYnzBYzULF/6KPoKU1V8luzM5icfrm1cG0RyFiyGvBoONy/M3vreQE3ij5Dab Susw== 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=17rQ88vsZDtlPmncoLd4F1WtMoDw5uG6QE6awHFzEIw=; b=YKPmrZF56bWCahi52NdTamuNHox9uMSkZPfd6ZyMwfFMBhhoYz+y+tRnxAtD+D6XqD l8grSco7AI9B8ZuA9OqCEy/qSc3GzrpaMTFPxQRgM/gEXQos0TeEJ4Up+oxdeZnufr+t e16SA4gI8AeBq6gvXvjv8IgHNIMHH4rkN7rJZvDLdRKGfeoX93RpJIfB8vKLwMqPzSXr 35uBeKyNwdYjg0yIm/oJHC6zswIbDgqnxpqet5LWtSA2gJXI7RwZxaJdP58Dwhs2goah XrgAZTvEXB+jT5uo/LlfRgnO5UHu7MWkOqJoH/JXepuWzStvXNfKtUiMv+tcxYK43Uoz Vt1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=u0MBwOKf; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 hc32-20020a17090716a000b007ae3958c7c9si2168784ejc.999.2022.11.11.05.58.21; Fri, 11 Nov 2022 05:58:45 -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=u0MBwOKf; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S234025AbiKKN5Z (ORCPT + 99 others); Fri, 11 Nov 2022 08:57:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59614 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233946AbiKKN4H (ORCPT ); Fri, 11 Nov 2022 08:56:07 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ECECC7F553; Fri, 11 Nov 2022 05:55:04 -0800 (PST) Message-ID: <20221111122015.331584998@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174903; 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=17rQ88vsZDtlPmncoLd4F1WtMoDw5uG6QE6awHFzEIw=; b=u0MBwOKfdKIjVYsMnyfBs1VTZDXJEX6DuRpL7pKRU7BC7LYQGVWXa3TmnszJmKSgH0051K OtzIlEYeXodSuQoLNocXCVjSNJ+SgKfEAeXuS+64VjLc4GPurIWeeRHa/RRkj7DvlLMz63 0E/LNoqZcMdHj7I03PLUzpPAk0nNuDtVGV0syPSnWCo1HSXjsr/Do7sHxw7mBxdBdzj41H zYliO7BNOl/ULvKU3DrQsE0n8X9U9rQ64Pi/Xy1uzv7lY0jO0j/y3V/2yvzS+fX30EUVaF iQ3hOSlA943JC+BvTCqBq/hIeuk9COv4UtayBK3AXOCrIBZBpde6Ui88XR3MVQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174903; 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=17rQ88vsZDtlPmncoLd4F1WtMoDw5uG6QE6awHFzEIw=; b=yM3dN0j6bNW9WtIT9LkNs9RYaMlN3S1D8j/YyTsQdLKC9l8Stsx3vyIB4R3Y33YnomF1gB ueyboCuUeHb+1ACQ== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 30/39] PCI/MSI: Move pci_msi_restore_state() to api.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:55:03 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208399899509930?= X-GMAIL-MSGID: =?utf-8?q?1749208399899509930?= From: Ahmed S. Darwish To distangle the maze in msi.c, all exported device-driver MSI APIs are now to be grouped in one file, api.c. Move pci_msi_enabled() and add kernel-doc for the function. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas diff --git a/drivers/pci/msi/api.c b/drivers/pci/msi/api.c index ee9ed5ccd94d..8d1cf6db9bd7 100644 --- a/drivers/pci/msi/api.c +++ b/drivers/pci/msi/api.c @@ -308,6 +308,21 @@ void pci_free_irq_vectors(struct pci_dev *dev) } EXPORT_SYMBOL(pci_free_irq_vectors); +/** + * pci_restore_msi_state() - Restore cached MSI(-X) state on device + * @dev: the PCI device to operate on + * + * Write the Linux-cached MSI(-X) state back on device. This is + * typically useful upon system resume, or after an error-recovery PCI + * adapter reset. + */ +void pci_restore_msi_state(struct pci_dev *dev) +{ + __pci_restore_msi_state(dev); + __pci_restore_msix_state(dev); +} +EXPORT_SYMBOL_GPL(pci_restore_msi_state); + /** * pci_msi_enabled() - Are MSI(-X) interrupts enabled system-wide? * diff --git a/drivers/pci/msi/msi.c b/drivers/pci/msi/msi.c index 59c33bc7fe81..a5d168c823ff 100644 --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -199,7 +199,7 @@ bool __weak arch_restore_msi_irqs(struct pci_dev *dev) return true; } -static void __pci_restore_msi_state(struct pci_dev *dev) +void __pci_restore_msi_state(struct pci_dev *dev) { struct msi_desc *entry; u16 control; @@ -231,7 +231,7 @@ static void pci_msix_clear_and_set_ctrl(struct pci_dev *dev, u16 clear, u16 set) pci_write_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, ctrl); } -static void __pci_restore_msix_state(struct pci_dev *dev) +void __pci_restore_msix_state(struct pci_dev *dev) { struct msi_desc *entry; bool write_msg; @@ -257,13 +257,6 @@ static void __pci_restore_msix_state(struct pci_dev *dev) pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0); } -void pci_restore_msi_state(struct pci_dev *dev) -{ - __pci_restore_msi_state(dev); - __pci_restore_msix_state(dev); -} -EXPORT_SYMBOL_GPL(pci_restore_msi_state); - static void pcim_msi_release(void *pcidev) { struct pci_dev *dev = pcidev; diff --git a/drivers/pci/msi/msi.h b/drivers/pci/msi/msi.h index f3f4ede53171..8170ef2c5ad0 100644 --- a/drivers/pci/msi/msi.h +++ b/drivers/pci/msi/msi.h @@ -94,6 +94,8 @@ void pci_free_msi_irqs(struct pci_dev *dev); int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, struct irq_affinity *affd); int __pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int minvec, int maxvec, struct irq_affinity *affd, int flags); +void __pci_restore_msi_state(struct pci_dev *dev); +void __pci_restore_msix_state(struct pci_dev *dev); /* Legacy (!IRQDOMAIN) fallbacks */ From patchwork Fri Nov 11 13:55:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18777 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753574wru; Fri, 11 Nov 2022 05:58:48 -0800 (PST) X-Google-Smtp-Source: AA0mqf5jB+5GdEb18QMvU9A2JPvWjoUcti4QZ8Phpp7XfrF080Pq3KtcCiJUztL7zvB5k18ZBGqS X-Received: by 2002:a05:6402:22e9:b0:464:1297:8412 with SMTP id dn9-20020a05640222e900b0046412978412mr1537088edb.50.1668175128574; Fri, 11 Nov 2022 05:58:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175128; cv=none; d=google.com; s=arc-20160816; b=Hr7EqKAXRxF2lGVmArOzl65w3tnrsmq35s4Hbdf5nHDZ16eExZDq+yBWYwvd1FJPRQ bgvFz3O+nisUZr+72AcdQU/BI3XfzQj77B4hbueyaDHXXuk5I8W/ilouiqQ1PzOpnn+K NDI14aVwXNhqRc3XpAg55VPKBg+erRzQo6se8PQg3F8iAifWi/wPt+ZQR5wJOBpjakuI 8aUlLnqDBdNkamSa4ZtuxtHGnSv1DIP891Z/kDfD8FNzewlA92k1Czb5g0B9svN0UQvz N8Q2XVfGxczryCClRBagQs4+987E/rId1pYR0WqYGm1J9Jzf7ZWyIqOisPUXB8ScizcY dOdA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:date:content-transfer-encoding:mime-version :references:subject:cc:to:from:dkim-signature:dkim-signature :message-id; bh=UuC1MepTqQIaLcqFkObf7DFyoADcBMPY/PEQtFoZlnk=; b=aK/HoeZSbXUVY8R9/ptSMaTf7A8mIRcp0mu1j8SfmzRbCHZke0I6n7gyx4Bq2sQQka nd/8kx7QhcVR6mj2fjf9cb080863BwF8WUJ6BwNRunnnoS9uNnYOMgich92oNh2xObuk JOe0Aud2e/9tWktCGW8bWl77KqQz/CC03voOCb2LHCrOvENl0ndrf8o3dnmW8p8iH54s XjVCVbaCEjfbocYacL24MO6q0+Z4/OFg1SrAnzt4/rGcpMJh7BRGGAjccjWhQUr76L2u GbmzurCKuv0soDllANmkZVXTYGZqbokpIOL8H7efhXe93WiJ2aNgWUOHGXWMcGg8RcJd Qhxw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=GthpV0+b; 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 m24-20020a056402051800b00458b752f449si1906482edv.91.2022.11.11.05.58.25; Fri, 11 Nov 2022 05:58:48 -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=GthpV0+b; 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 S234042AbiKKN53 (ORCPT + 99 others); Fri, 11 Nov 2022 08:57:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233887AbiKKN4b (ORCPT ); Fri, 11 Nov 2022 08:56:31 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8599B7F560; Fri, 11 Nov 2022 05:55:06 -0800 (PST) Message-ID: <20221111122015.397739421@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174905; 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: content-transfer-encoding:content-transfer-encoding: references:references; bh=UuC1MepTqQIaLcqFkObf7DFyoADcBMPY/PEQtFoZlnk=; b=GthpV0+bUwZ0On/zDcLYLzsswb8L1Lyf03t32FEBRxX4PnOlz+khlP72rDfyiJ1x9wRgx0 QZBHxxrL4JkPQLW7wxnFxQQP1C3bGSUtkFuYA7n7ImHn09T6nJKXmSRNq6GMcgez9zHcBr /sXuwxE+KMFFbdY6PdL0GaHWRYeq2JTEl73uUqyXZcW+aV/4sFTHIWAWRwSUxCox9LTE9G hYCMBp2pxhJCSf4Vrdt9VkoToU9NxPEz3oqd083h7hlHGv5jYqQ13ynW5aQ/L+OWRe7yr0 HZqb6OTN06vPLw7H/xCHtuHUesG4QYeE53KYO3lB8wsG9XL+fgCEqmcpWHMg5g== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174905; 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: content-transfer-encoding:content-transfer-encoding: references:references; bh=UuC1MepTqQIaLcqFkObf7DFyoADcBMPY/PEQtFoZlnk=; b=N5w5QY6eUkXGEGiXNQj1Q3SBpVNANVHkPj6Rf+UFoASB2T/i/8da2rW7Kz59cuUMxbBlwY 9I6yIp/HKRYP4CAQ== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 31/39] Documentation: PCI: Add reference to PCI/MSI device driver APIs References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:55:04 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208403354013744?= X-GMAIL-MSGID: =?utf-8?q?1749208403354013744?= From: Ahmed S. Darwish All exported device-driver MSI APIs are now grouped in one place at drivers/pci/msi/api.c with comprehensive kernel-docs added. Reference these kernel-docs in the official PCI/MSI howto. Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe --- Documentation/PCI/msi-howto.rst | 10 ++++++++++ 1 file changed, 10 insertions(+) --- --- a/Documentation/PCI/msi-howto.rst +++ b/Documentation/PCI/msi-howto.rst @@ -285,3 +285,13 @@ to bridges between the PCI root and the It is also worth checking the device driver to see whether it supports MSIs. For example, it may contain calls to pci_alloc_irq_vectors() with the PCI_IRQ_MSI or PCI_IRQ_MSIX flags. + + +List of device drivers MSI(-X) APIs +=================================== + +The PCI/MSI subystem has a dedicated C file for its exported device driver +APIs — `drivers/pci/msi/api.c`. The following functions are exported: + +.. kernel-doc:: drivers/pci/msi/api.c + :export: From patchwork Fri Nov 11 13:55:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18779 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753661wru; Fri, 11 Nov 2022 05:59:02 -0800 (PST) X-Google-Smtp-Source: AA0mqf7vxhtp8yT7L8V28bRAeWg5YOSezWrDcjfHQvIr7AOsHuakdgIf4eiRr+EnbmcsJnqe6HmB X-Received: by 2002:a17:906:b1c4:b0:7ad:d408:3a2b with SMTP id bv4-20020a170906b1c400b007add4083a2bmr1927948ejb.280.1668175142480; Fri, 11 Nov 2022 05:59:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175142; cv=none; d=google.com; s=arc-20160816; b=Eu3w6iFNz0rXxl8fOyeUrIAr4PcTifqaenuPbkLIdIuw2WHvwYfB8VSRkXom/VI8t7 CRDBnCluBe+GrOCUXF/PvPwBpnntxlvG9rtT/vfJYNThywRhJY9l3c+Kd6egw+n2ZIMS aGKHFV43YiaifoRnF/BUswEmLNjTnR7nyKQ8MEghxacqeRVkiH3DLoS1Wdhv8PhZ8CH8 pA1HYJWN0NelHCVMom+M/ISqk9R5ztbA2ZToKQo2orEET7lhcxIEsN/RBaRESSGihR38 bGmHHy0gxEZXuJAfZimT8pidz1KCFNf1NmKLIyvaR1q5mDI8Sl3tFz8/n8xC/c5ybo9y owCw== 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=4WpT4DxJx79msSHfiBpfy36+MpLWop9m91H3PwQHhsw=; b=jRseMaNnAzMbFSG4tVX3v6luTdq8IRAi3XGc+GeATDXpnbReB//n3yuwEFNWPwE2bd +piPv0lc0TxA4pAXwIMPOa9zbUnDPXN1SxE0T2l0QACo7UzhIuw2MKRds8CiJqfhiKs5 JX43mw0+xAExRdn8AQHsTtbsSjf2gN9o1xb+iuIm6FKMVpo6n0wsF5HUcBSqUS6TMs0L lhTgPhbnQhFyzbNc8L/7X/+12jZHiMTM3Q0wTgGgn3F9B462UpqSALxVbCfTRroUfVjX WJIrKggvVrORf7GkpH7rSfqSSWA8n73NxB5Z+a4kNh4vALlfPWfPv441K+MWDL7V4OQv jxTg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=XztcOFcD; dkim=neutral (no key) header.i=@linutronix.de header.b=0jC2qVnR; 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 o3-20020aa7c503000000b004488842d88esi832717edq.13.2022.11.11.05.58.36; Fri, 11 Nov 2022 05:59:02 -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=XztcOFcD; dkim=neutral (no key) header.i=@linutronix.de header.b=0jC2qVnR; 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 S234071AbiKKN5e (ORCPT + 99 others); Fri, 11 Nov 2022 08:57:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233990AbiKKN4f (ORCPT ); Fri, 11 Nov 2022 08:56:35 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6206C7F57C; Fri, 11 Nov 2022 05:55:08 -0800 (PST) Message-ID: <20221111122015.459089736@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174906; 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=4WpT4DxJx79msSHfiBpfy36+MpLWop9m91H3PwQHhsw=; b=XztcOFcDxM49M45k9PTE/1k36ZiA6VNV5dpHbBjf2uXg/ah5CPVotTwa6TV93P4O+2yemV Syo6FMVfzyYfQWirZCviQ/nLdzJkvNLuyGXAEvUO66w3RDDPl4jPjPcSbmxHFSR5z/uML/ y2caS967jflVd7HwOtwJN0ednEAU3jPpAwRoXWP4fYSnd/XwKn4thlMKZ/KtMiyr2wzRgA fcq5EIZ4CzzXGolnDwQyl84iWyypXfMxnDUqqx5UZiugUSI7QezYun3/RQKgyTfALjFXlj i9oICtLBfF9ecJLVQ9AawrF3OL6x99P/sR6CUhneHS/789Pi0nqvvZRzNAgtfA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174906; 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=4WpT4DxJx79msSHfiBpfy36+MpLWop9m91H3PwQHhsw=; b=0jC2qVnRRiQ+XBJLy3wiPxQeeG3vbJUU5q7NonBcd7vZGec3mNfgtHuoxczVY/LP4H1WTx giOEt7HPy8YFFHAA== 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 , "Ahmed S. Darwish" , Reinette Chatre , Michael Ellerman , Christophe Leroy , linuxppc-dev@lists.ozlabs.org Subject: [patch 32/39] PCI/MSI: Reorder functions in msi.c References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:55:06 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208418452232894?= X-GMAIL-MSGID: =?utf-8?q?1749208418452232894?= From: Ahmed S. Darwish There is no way to navigate msi.c without banging the head against the wall every now and then because MSI and MSI-X specific functions are intermingled and the code flow is completely non-obvious. Reorder everthing so common helpers, MSI and MSI-X specific functions are grouped together. Suggested-by: Thomas Gleixner Signed-off-by: Ahmed S. Darwish Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/msi.c | 577 +++++++++++++++++++++++++------------------------- 1 file changed, 295 insertions(+), 282 deletions(-) --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -16,6 +16,97 @@ int pci_msi_enable = 1; int pci_msi_ignore_mask; +/** + * pci_msi_supported - check whether MSI may be enabled on a device + * @dev: pointer to the pci_dev data structure of MSI device function + * @nvec: how many MSIs have been requested? + * + * Look at global flags, the device itself, and its parent buses + * to determine if MSI/-X are supported for the device. If MSI/-X is + * supported return 1, else return 0. + **/ +static int pci_msi_supported(struct pci_dev *dev, int nvec) +{ + struct pci_bus *bus; + + /* MSI must be globally enabled and supported by the device */ + if (!pci_msi_enable) + return 0; + + if (!dev || dev->no_msi) + return 0; + + /* + * You can't ask to have 0 or less MSIs configured. + * a) it's stupid .. + * b) the list manipulation code assumes nvec >= 1. + */ + if (nvec < 1) + return 0; + + /* + * Any bridge which does NOT route MSI transactions from its + * secondary bus to its primary bus must set NO_MSI flag on + * the secondary pci_bus. + * + * The NO_MSI flag can either be set directly by: + * - arch-specific PCI host bus controller drivers (deprecated) + * - quirks for specific PCI bridges + * + * or indirectly by platform-specific PCI host bridge drivers by + * advertising the 'msi_domain' property, which results in + * the NO_MSI flag when no MSI domain is found for this bridge + * at probe time. + */ + for (bus = dev->bus; bus; bus = bus->parent) + if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI) + return 0; + + return 1; +} + +static void pcim_msi_release(void *pcidev) +{ + struct pci_dev *dev = pcidev; + + dev->is_msi_managed = false; + pci_free_irq_vectors(dev); +} + +/* + * Needs to be separate from pcim_release to prevent an ordering problem + * vs. msi_device_data_release() in the MSI core code. + */ +static int pcim_setup_msi_release(struct pci_dev *dev) +{ + int ret; + + if (!pci_is_managed(dev) || dev->is_msi_managed) + return 0; + + ret = devm_add_action(&dev->dev, pcim_msi_release, dev); + if (!ret) + dev->is_msi_managed = true; + return ret; +} + +/* + * Ordering vs. devres: msi device data has to be installed first so that + * pcim_msi_release() is invoked before it on device release. + */ +static int pci_setup_msi_context(struct pci_dev *dev) +{ + int ret = msi_setup_device_data(&dev->dev); + + if (!ret) + ret = pcim_setup_msi_release(dev); + return ret; +} + +/* + * Helper functions for mask/unmask and MSI message handling + */ + void pci_msi_update_mask(struct msi_desc *desc, u32 clear, u32 set) { raw_spinlock_t *lock = &to_pci_dev(desc->dev)->msi_lock; @@ -163,15 +254,8 @@ void pci_write_msi_msg(unsigned int irq, } EXPORT_SYMBOL_GPL(pci_write_msi_msg); -void pci_free_msi_irqs(struct pci_dev *dev) -{ - pci_msi_teardown_msi_irqs(dev); - if (dev->msix_base) { - iounmap(dev->msix_base); - dev->msix_base = NULL; - } -} +/* PCI/MSI specific functionality */ static void pci_intx_for_msi(struct pci_dev *dev, int enable) { @@ -190,111 +274,6 @@ static void pci_msi_set_enable(struct pc pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control); } -/* - * Architecture override returns true when the PCI MSI message should be - * written by the generic restore function. - */ -bool __weak arch_restore_msi_irqs(struct pci_dev *dev) -{ - return true; -} - -void __pci_restore_msi_state(struct pci_dev *dev) -{ - struct msi_desc *entry; - u16 control; - - if (!dev->msi_enabled) - return; - - entry = irq_get_msi_desc(dev->irq); - - pci_intx_for_msi(dev, 0); - pci_msi_set_enable(dev, 0); - if (arch_restore_msi_irqs(dev)) - __pci_write_msi_msg(entry, &entry->msg); - - pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control); - pci_msi_update_mask(entry, 0, 0); - control &= ~PCI_MSI_FLAGS_QSIZE; - control |= (entry->pci.msi_attrib.multiple << 4) | PCI_MSI_FLAGS_ENABLE; - pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control); -} - -static void pci_msix_clear_and_set_ctrl(struct pci_dev *dev, u16 clear, u16 set) -{ - u16 ctrl; - - pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &ctrl); - ctrl &= ~clear; - ctrl |= set; - pci_write_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, ctrl); -} - -void __pci_restore_msix_state(struct pci_dev *dev) -{ - struct msi_desc *entry; - bool write_msg; - - if (!dev->msix_enabled) - return; - - /* route the table */ - pci_intx_for_msi(dev, 0); - pci_msix_clear_and_set_ctrl(dev, 0, - PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL); - - write_msg = arch_restore_msi_irqs(dev); - - msi_lock_descs(&dev->dev); - msi_for_each_desc(entry, &dev->dev, MSI_DESC_ALL) { - if (write_msg) - __pci_write_msi_msg(entry, &entry->msg); - pci_msix_write_vector_ctrl(entry, entry->pci.msix_ctrl); - } - msi_unlock_descs(&dev->dev); - - pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0); -} - -static void pcim_msi_release(void *pcidev) -{ - struct pci_dev *dev = pcidev; - - dev->is_msi_managed = false; - pci_free_irq_vectors(dev); -} - -/* - * Needs to be separate from pcim_release to prevent an ordering problem - * vs. msi_device_data_release() in the MSI core code. - */ -static int pcim_setup_msi_release(struct pci_dev *dev) -{ - int ret; - - if (!pci_is_managed(dev) || dev->is_msi_managed) - return 0; - - ret = devm_add_action(&dev->dev, pcim_msi_release, dev); - if (!ret) - dev->is_msi_managed = true; - return ret; -} - -/* - * Ordering vs. devres: msi device data has to be installed first so that - * pcim_msi_release() is invoked before it on device release. - */ -static int pci_setup_msi_context(struct pci_dev *dev) -{ - int ret = msi_setup_device_data(&dev->dev); - - if (!ret) - ret = pcim_setup_msi_release(dev); - return ret; -} - static int msi_setup_msi_desc(struct pci_dev *dev, int nvec, struct irq_affinity_desc *masks) { @@ -415,6 +394,149 @@ static int msi_capability_init(struct pc return ret; } +int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, + struct irq_affinity *affd) +{ + int nvec; + int rc; + + if (!pci_msi_supported(dev, minvec) || dev->current_state != PCI_D0) + return -EINVAL; + + /* Check whether driver already requested MSI-X IRQs */ + if (dev->msix_enabled) { + pci_info(dev, "can't enable MSI (MSI-X already enabled)\n"); + return -EINVAL; + } + + if (maxvec < minvec) + return -ERANGE; + + if (WARN_ON_ONCE(dev->msi_enabled)) + return -EINVAL; + + nvec = pci_msi_vec_count(dev); + if (nvec < 0) + return nvec; + if (nvec < minvec) + return -ENOSPC; + + if (nvec > maxvec) + nvec = maxvec; + + rc = pci_setup_msi_context(dev); + if (rc) + return rc; + + for (;;) { + if (affd) { + nvec = irq_calc_affinity_vectors(minvec, nvec, affd); + if (nvec < minvec) + return -ENOSPC; + } + + rc = msi_capability_init(dev, nvec, affd); + if (rc == 0) + return nvec; + + if (rc < 0) + return rc; + if (rc < minvec) + return -ENOSPC; + + nvec = rc; + } +} + +/** + * pci_msi_vec_count - Return the number of MSI vectors a device can send + * @dev: device to report about + * + * This function returns the number of MSI vectors a device requested via + * Multiple Message Capable register. It returns a negative errno if the + * device is not capable sending MSI interrupts. Otherwise, the call succeeds + * and returns a power of two, up to a maximum of 2^5 (32), according to the + * MSI specification. + **/ +int pci_msi_vec_count(struct pci_dev *dev) +{ + int ret; + u16 msgctl; + + if (!dev->msi_cap) + return -EINVAL; + + pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &msgctl); + ret = 1 << ((msgctl & PCI_MSI_FLAGS_QMASK) >> 1); + + return ret; +} +EXPORT_SYMBOL(pci_msi_vec_count); + +/* + * Architecture override returns true when the PCI MSI message should be + * written by the generic restore function. + */ +bool __weak arch_restore_msi_irqs(struct pci_dev *dev) +{ + return true; +} + +void __pci_restore_msi_state(struct pci_dev *dev) +{ + struct msi_desc *entry; + u16 control; + + if (!dev->msi_enabled) + return; + + entry = irq_get_msi_desc(dev->irq); + + pci_intx_for_msi(dev, 0); + pci_msi_set_enable(dev, 0); + if (arch_restore_msi_irqs(dev)) + __pci_write_msi_msg(entry, &entry->msg); + + pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &control); + pci_msi_update_mask(entry, 0, 0); + control &= ~PCI_MSI_FLAGS_QSIZE; + control |= (entry->pci.msi_attrib.multiple << 4) | PCI_MSI_FLAGS_ENABLE; + pci_write_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, control); +} + +void pci_msi_shutdown(struct pci_dev *dev) +{ + struct msi_desc *desc; + + if (!pci_msi_enable || !dev || !dev->msi_enabled) + return; + + pci_msi_set_enable(dev, 0); + pci_intx_for_msi(dev, 1); + dev->msi_enabled = 0; + + /* Return the device with MSI unmasked as initial states */ + desc = msi_first_desc(&dev->dev, MSI_DESC_ALL); + if (!WARN_ON_ONCE(!desc)) + pci_msi_unmask(desc, msi_multi_mask(desc)); + + /* Restore dev->irq to its default pin-assertion IRQ */ + dev->irq = desc->pci.msi_attrib.default_irq; + pcibios_alloc_irq(dev); +} + +/* PCI/MSI-X specific functionality */ + +static void pci_msix_clear_and_set_ctrl(struct pci_dev *dev, u16 clear, u16 set) +{ + u16 ctrl; + + pci_read_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, &ctrl); + ctrl &= ~clear; + ctrl |= set; + pci_write_config_word(dev, dev->msix_cap + PCI_MSIX_FLAGS, ctrl); +} + static void __iomem *msix_map_region(struct pci_dev *dev, unsigned int nr_entries) { @@ -599,101 +721,6 @@ static int msix_capability_init(struct p return ret; } -/** - * pci_msi_supported - check whether MSI may be enabled on a device - * @dev: pointer to the pci_dev data structure of MSI device function - * @nvec: how many MSIs have been requested? - * - * Look at global flags, the device itself, and its parent buses - * to determine if MSI/-X are supported for the device. If MSI/-X is - * supported return 1, else return 0. - **/ -static int pci_msi_supported(struct pci_dev *dev, int nvec) -{ - struct pci_bus *bus; - - /* MSI must be globally enabled and supported by the device */ - if (!pci_msi_enable) - return 0; - - if (!dev || dev->no_msi) - return 0; - - /* - * You can't ask to have 0 or less MSIs configured. - * a) it's stupid .. - * b) the list manipulation code assumes nvec >= 1. - */ - if (nvec < 1) - return 0; - - /* - * Any bridge which does NOT route MSI transactions from its - * secondary bus to its primary bus must set NO_MSI flag on - * the secondary pci_bus. - * - * The NO_MSI flag can either be set directly by: - * - arch-specific PCI host bus controller drivers (deprecated) - * - quirks for specific PCI bridges - * - * or indirectly by platform-specific PCI host bridge drivers by - * advertising the 'msi_domain' property, which results in - * the NO_MSI flag when no MSI domain is found for this bridge - * at probe time. - */ - for (bus = dev->bus; bus; bus = bus->parent) - if (bus->bus_flags & PCI_BUS_FLAGS_NO_MSI) - return 0; - - return 1; -} - -/** - * pci_msi_vec_count - Return the number of MSI vectors a device can send - * @dev: device to report about - * - * This function returns the number of MSI vectors a device requested via - * Multiple Message Capable register. It returns a negative errno if the - * device is not capable sending MSI interrupts. Otherwise, the call succeeds - * and returns a power of two, up to a maximum of 2^5 (32), according to the - * MSI specification. - **/ -int pci_msi_vec_count(struct pci_dev *dev) -{ - int ret; - u16 msgctl; - - if (!dev->msi_cap) - return -EINVAL; - - pci_read_config_word(dev, dev->msi_cap + PCI_MSI_FLAGS, &msgctl); - ret = 1 << ((msgctl & PCI_MSI_FLAGS_QMASK) >> 1); - - return ret; -} -EXPORT_SYMBOL(pci_msi_vec_count); - -void pci_msi_shutdown(struct pci_dev *dev) -{ - struct msi_desc *desc; - - if (!pci_msi_enable || !dev || !dev->msi_enabled) - return; - - pci_msi_set_enable(dev, 0); - pci_intx_for_msi(dev, 1); - dev->msi_enabled = 0; - - /* Return the device with MSI unmasked as initial states */ - desc = msi_first_desc(&dev->dev, MSI_DESC_ALL); - if (!WARN_ON_ONCE(!desc)) - pci_msi_unmask(desc, msi_multi_mask(desc)); - - /* Restore dev->irq to its default pin-assertion IRQ */ - dev->irq = desc->pci.msi_attrib.default_irq; - pcibios_alloc_irq(dev); -} - static int __pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, int nvec, struct irq_affinity *affd, int flags) { @@ -729,57 +756,23 @@ static int __pci_enable_msix(struct pci_ return msix_capability_init(dev, entries, nvec, affd); } -void pci_msix_shutdown(struct pci_dev *dev) -{ - struct msi_desc *desc; - - if (!pci_msi_enable || !dev || !dev->msix_enabled) - return; - - if (pci_dev_is_disconnected(dev)) { - dev->msix_enabled = 0; - return; - } - - /* Return the device with MSI-X masked as initial states */ - msi_for_each_desc(desc, &dev->dev, MSI_DESC_ALL) - pci_msix_mask(desc); - - pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0); - pci_intx_for_msi(dev, 1); - dev->msix_enabled = 0; - pcibios_alloc_irq(dev); -} - -int __pci_enable_msi_range(struct pci_dev *dev, int minvec, int maxvec, - struct irq_affinity *affd) +int __pci_enable_msix_range(struct pci_dev *dev, + struct msix_entry *entries, int minvec, + int maxvec, struct irq_affinity *affd, + int flags) { - int nvec; - int rc; - - if (!pci_msi_supported(dev, minvec) || dev->current_state != PCI_D0) - return -EINVAL; - - /* Check whether driver already requested MSI-X IRQs */ - if (dev->msix_enabled) { - pci_info(dev, "can't enable MSI (MSI-X already enabled)\n"); - return -EINVAL; - } + int rc, nvec = maxvec; if (maxvec < minvec) return -ERANGE; - if (WARN_ON_ONCE(dev->msi_enabled)) + if (dev->msi_enabled) { + pci_info(dev, "can't enable MSI-X (MSI already enabled)\n"); return -EINVAL; + } - nvec = pci_msi_vec_count(dev); - if (nvec < 0) - return nvec; - if (nvec < minvec) - return -ENOSPC; - - if (nvec > maxvec) - nvec = maxvec; + if (WARN_ON_ONCE(dev->msix_enabled)) + return -EINVAL; rc = pci_setup_msi_context(dev); if (rc) @@ -792,7 +785,7 @@ int __pci_enable_msi_range(struct pci_de return -ENOSPC; } - rc = msi_capability_init(dev, nvec, affd); + rc = __pci_enable_msix(dev, entries, nvec, affd, flags); if (rc == 0) return nvec; @@ -805,48 +798,68 @@ int __pci_enable_msi_range(struct pci_de } } -int __pci_enable_msix_range(struct pci_dev *dev, - struct msix_entry *entries, int minvec, - int maxvec, struct irq_affinity *affd, - int flags) +void __pci_restore_msix_state(struct pci_dev *dev) { - int rc, nvec = maxvec; + struct msi_desc *entry; + bool write_msg; - if (maxvec < minvec) - return -ERANGE; + if (!dev->msix_enabled) + return; - if (dev->msi_enabled) { - pci_info(dev, "can't enable MSI-X (MSI already enabled)\n"); - return -EINVAL; + /* route the table */ + pci_intx_for_msi(dev, 0); + pci_msix_clear_and_set_ctrl(dev, 0, + PCI_MSIX_FLAGS_ENABLE | PCI_MSIX_FLAGS_MASKALL); + + write_msg = arch_restore_msi_irqs(dev); + + msi_lock_descs(&dev->dev); + msi_for_each_desc(entry, &dev->dev, MSI_DESC_ALL) { + if (write_msg) + __pci_write_msi_msg(entry, &entry->msg); + pci_msix_write_vector_ctrl(entry, entry->pci.msix_ctrl); } + msi_unlock_descs(&dev->dev); - if (WARN_ON_ONCE(dev->msix_enabled)) - return -EINVAL; + pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_MASKALL, 0); +} - rc = pci_setup_msi_context(dev); - if (rc) - return rc; +void pci_msix_shutdown(struct pci_dev *dev) +{ + struct msi_desc *desc; - for (;;) { - if (affd) { - nvec = irq_calc_affinity_vectors(minvec, nvec, affd); - if (nvec < minvec) - return -ENOSPC; - } + if (!pci_msi_enable || !dev || !dev->msix_enabled) + return; - rc = __pci_enable_msix(dev, entries, nvec, affd, flags); - if (rc == 0) - return nvec; + if (pci_dev_is_disconnected(dev)) { + dev->msix_enabled = 0; + return; + } - if (rc < 0) - return rc; - if (rc < minvec) - return -ENOSPC; + /* Return the device with MSI-X masked as initial states */ + msi_for_each_desc(desc, &dev->dev, MSI_DESC_ALL) + pci_msix_mask(desc); - nvec = rc; + pci_msix_clear_and_set_ctrl(dev, PCI_MSIX_FLAGS_ENABLE, 0); + pci_intx_for_msi(dev, 1); + dev->msix_enabled = 0; + pcibios_alloc_irq(dev); +} + +/* Common interfaces */ + +void pci_free_msi_irqs(struct pci_dev *dev) +{ + pci_msi_teardown_msi_irqs(dev); + + if (dev->msix_base) { + iounmap(dev->msix_base); + dev->msix_base = NULL; } } +/* Misc. infrastructure */ + struct pci_dev *msi_desc_to_pci_dev(struct msi_desc *desc) { return to_pci_dev(desc->dev); From patchwork Fri Nov 11 13:55:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18781 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753776wru; Fri, 11 Nov 2022 05:59:23 -0800 (PST) X-Google-Smtp-Source: AA0mqf50UrQnQvjPwisEJbM7Awm3eQMxDZnhI8TcQfnMWkeag35ZGdj3sKy1cGTP40+fEQ+0WuMx X-Received: by 2002:a05:6402:2931:b0:463:ce05:c00e with SMTP id ee49-20020a056402293100b00463ce05c00emr1575551edb.46.1668175163080; Fri, 11 Nov 2022 05:59:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175163; cv=none; d=google.com; s=arc-20160816; b=lcokOltWU0E0lbNNUFuL/wM4xpevIZaD7NUb3JqRItSMfCt1kHfwzvYxzK/mY2KOZU xUi1J1Q6HXRndRCvjecelMSe8JhpnI3kuDHjbElsU2IagOp+a5uGULevCOCXZRIabaRA kgk9pIs81P5+EXA484bYnVmAEAdNCI1UwHGuSW/p+unItjU9P0mVVK2WQHIw6AxGd18+ 3nIXZfGc0i+DecQBQrnNb5VZDapqIENpMSLkhKyfcVIwpOeVItm7lpzPFctkk3wv25Uc SPbYvzDZhjv459HRVacMEgdCBUBGhF7WV124LcQBbPzLbg7jwFd4oN94x4ZvUc0+bgtY kymQ== 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=o9tkl2d2tC9egQPEBUifcDdfF9knjDTOjOdgLUksEhs=; b=Ub1CMbYqvtpIbtCyiyPlUVw9LWS8xpbRi4DXDhblbpgiCx8qtnyi3fY1Am2elrEBWf QquWQR2/4R8tFEl5rj17qm7+wC+6mjCDg+pUcN2AW4Ca940cEwGbZP9cHIxIZQ6E6kXk M9ox7LB9XChAfbNxfyecAWJmYDscvpRHYPeQ4i8590DC/7Jd77sehvz1Ce88CGkq0WkW qsLUJz3Ws4GFNighh4W38zZRiAMIpzIQnMtZZeAGpge7jfZj+4dsWnVS5mL3o1DEKdIH Tip8q9gZdQS5Ytc+M3Mj8GO+/tSxXNURL+gm2/6oaBlLoEsQNDIGgtn7OrwTtYMNwfmk e8bg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Su8Wkdkt; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=KIGuSY4S; 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 gt37-20020a1709072da500b007879e9a7451si2079270ejc.816.2022.11.11.05.58.58; Fri, 11 Nov 2022 05:59:23 -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=Su8Wkdkt; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=KIGuSY4S; 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 S234000AbiKKN5h (ORCPT + 99 others); Fri, 11 Nov 2022 08:57:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233995AbiKKN4g (ORCPT ); Fri, 11 Nov 2022 08:56:36 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C197E82C56; Fri, 11 Nov 2022 05:55:09 -0800 (PST) Message-ID: <20221111122015.516946468@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174908; 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=o9tkl2d2tC9egQPEBUifcDdfF9knjDTOjOdgLUksEhs=; b=Su8WkdktmaQZnQFe4G4U9ma1vOuBXXYDHeKzs+nJ4ypK8tbIDeDg8t6p/+iwp2yjUe4Ht2 /IZqPBRcKzvLSqBTBkToQ1mY4FdrLYKjU4mUPBPRZkmYWS7wxcklecLp+/LDx6I692inbi Pib/VAL+L1e3KDQHzOZDaZQh/oyZaQw7ZJnPjVjU/EA3ZFoLLwCEMCjYytL8YLpcWgzJTS t4HDKCTcEHB4VWAjNHDLvB05QuEGqQq0NPv2w1YnGFMqdqAC5n7pRdANlemgsj9cTxS0Pq 0NgymSBVP6eTSi+POjdh2sZLy0a//ARWXxQnrBVfmVehy/yDf52zIoCs24JUFQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174908; 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=o9tkl2d2tC9egQPEBUifcDdfF9knjDTOjOdgLUksEhs=; b=KIGuSY4SHqfY2xYt0UXwXFotUsRZ7MwILcY+hFirUyhfKVZQYvYuooVliEYPFYi0XbVRDs q/SAL05mXclgyDCw== 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 33/39] PCI/MSI: Sanitize MSI-X checks References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:55:07 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208439936809012?= X-GMAIL-MSGID: =?utf-8?q?1749208439936809012?= There is no point in doing the same sanity checks over and over in a loop during MSI-X enablement. Put them in front of the loop and return early when they fail. Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe --- drivers/pci/msi/msi.c | 67 +++++++++++++++++++++++++------------------------- 1 file changed, 34 insertions(+), 33 deletions(-) --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -721,47 +721,31 @@ static int msix_capability_init(struct p return ret; } -static int __pci_enable_msix(struct pci_dev *dev, struct msix_entry *entries, - int nvec, struct irq_affinity *affd, int flags) +static bool pci_msix_validate_entries(struct msix_entry *entries, int nvec, int hwsize) { - int nr_entries; int i, j; - if (!pci_msi_supported(dev, nvec) || dev->current_state != PCI_D0) - return -EINVAL; + if (!entries) + return true; - nr_entries = pci_msix_vec_count(dev); - if (nr_entries < 0) - return nr_entries; - if (nvec > nr_entries && !(flags & PCI_IRQ_VIRTUAL)) - return nr_entries; - - if (entries) { - /* Check for any invalid entries */ - for (i = 0; i < nvec; i++) { - if (entries[i].entry >= nr_entries) - return -EINVAL; /* invalid entry */ - for (j = i + 1; j < nvec; j++) { - if (entries[i].entry == entries[j].entry) - return -EINVAL; /* duplicate entry */ - } + for (i = 0; i < nvec; i++) { + /* Entry within hardware limit? */ + if (entries[i].entry >= hwsize) + return false; + + /* Check for duplicate entries */ + for (j = i + 1; j < nvec; j++) { + if (entries[i].entry == entries[j].entry) + return false; } } - - /* 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); + return true; } -int __pci_enable_msix_range(struct pci_dev *dev, - struct msix_entry *entries, int minvec, - int maxvec, struct irq_affinity *affd, - int flags) +int __pci_enable_msix_range(struct pci_dev *dev, struct msix_entry *entries, int minvec, + int maxvec, struct irq_affinity *affd, int flags) { - int rc, nvec = maxvec; + int hwsize, rc, nvec = maxvec; if (maxvec < minvec) return -ERANGE; @@ -774,6 +758,23 @@ int __pci_enable_msix_range(struct pci_d if (WARN_ON_ONCE(dev->msix_enabled)) return -EINVAL; + if (!pci_msi_supported(dev, nvec) || dev->current_state != PCI_D0) + return -EINVAL; + + hwsize = pci_msix_vec_count(dev); + if (hwsize < 0) + return hwsize; + + if (!pci_msix_validate_entries(entries, nvec, hwsize)) + return -EINVAL; + + /* PCI_IRQ_VIRTUAL is a horrible hack! */ + if (nvec > hwsize && !(flags & PCI_IRQ_VIRTUAL)) + nvec = hwsize; + + if (nvec < minvec) + return -ENOSPC; + rc = pci_setup_msi_context(dev); if (rc) return rc; @@ -785,7 +786,7 @@ int __pci_enable_msix_range(struct pci_d return -ENOSPC; } - rc = __pci_enable_msix(dev, entries, nvec, affd, flags); + rc = msix_capability_init(dev, entries, nvec, affd); if (rc == 0) return nvec; From patchwork Fri Nov 11 13:55:09 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18782 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753861wru; Fri, 11 Nov 2022 05:59:33 -0800 (PST) X-Google-Smtp-Source: AA0mqf5CY3nJG9gatIOEfv9VBvMYRluIiNYdMpidKHOXLTgxUGTQyNczaghUo2Nnrbj5HmNQjL4A X-Received: by 2002:a05:6402:2310:b0:462:735e:e34f with SMTP id l16-20020a056402231000b00462735ee34fmr1552045eda.213.1668175173280; Fri, 11 Nov 2022 05:59:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175173; cv=none; d=google.com; s=arc-20160816; b=NRzS2W10iwKc9E0yrdIo6L9G7PPXViDKCHazW43HkYXN/7+9XHheBahhOIWmjJsFVT QM0W0SqMatE3d2V3KVo8+ep1lL7iH8rs3xwc1X9PgyStflDqr/joOR2x8KV8CIK7tP5L m1BglSZlI3tNsSociVU39WS2fk8UIgyZsRuzGG8ohDng/VvNVPCr69qdbBHVTuqU0LeU /fF7mt9Kj9onnr9Toani+sVTq+hZaRbBsYE5moDUrB9+Xd9qJtaQdaXxlJnBMOVRW4dj sA0gFt3sICeRntz5HNGlwV4IZeIFW9EZc0QMsxTVimeE4ruoQ8hOh0daEHsdTrSmwydL ZDmA== 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=Msjel7aC5+Im+aQvsAthw2RuYInXdUWBTW//73XVYm0=; b=Lj0Bh4gVX82IEGKkt5QVCv2Xv4IPMdSJxJrn0IkQ1YdQYJB3uB66Jy/CeFFk6iHIct +EGmNv34lMtH1wITh7xwhSGMyFqNyb6ajJ1gnwscDiNcxAv2JVrarmRgLXA6130uJ/Nr vfynwlK+ckW6Sd5C9M3pDhsY0mQsFJj9Smt5yAIIil2FndHWpVjw6HGFYW3F7PyFCcd0 Ij8R2g/KwhxaGgZUIJwQwEn38Fk7NDi/JNUN585Vjl/Bn9z9IAV85CdVpaNiRp3AkWvL CVkIWP5JKL7CHzu4QP7wl81JtKKRj8+4+Vr70QazJnu7+OOJpZQEJq70Vx9BWAniEVlp QtWw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=KgXVLrX3; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=+iwkwvNE; 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 dr8-20020a170907720800b007ae9bc0b98asi1933382ejc.484.2022.11.11.05.59.09; Fri, 11 Nov 2022 05:59:33 -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=KgXVLrX3; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=+iwkwvNE; 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 S234088AbiKKN5q (ORCPT + 99 others); Fri, 11 Nov 2022 08:57:46 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59172 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234017AbiKKN4y (ORCPT ); Fri, 11 Nov 2022 08:56:54 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88FAC7F56F; Fri, 11 Nov 2022 05:55:11 -0800 (PST) Message-ID: <20221111122015.574339988@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174910; 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=Msjel7aC5+Im+aQvsAthw2RuYInXdUWBTW//73XVYm0=; b=KgXVLrX3pE/nIoqiS99qR5s9yOIMz/R1VaPvfyv2loIU5hDglv67gRX6pyou1DtK60H8cv 9GpmCDddO9kcF85adqjHiYF1bQ5d87zXTRgP0UgAlqGixa7Beb5iGb+pdp3Q4PG+f1toDz X83uOxv0BEfIdDiW+VJKmP5sHOk9JHA4UYsiIbRMhD1dFrLSv8FyNxH9l8a1jx+W7F1ES2 mgqX8q8gvQYFh0AjANuSBzI/kXzbuI16QPGuQiCAWc2j/5+ePYMfVnyMFOtmr8uagWYcXr mb6yiiUo1myYYM3ShslmbhVM3mpnldYVdu78xh8u5sdNukY35Vk1Ij8AFOxhaw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174910; 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=Msjel7aC5+Im+aQvsAthw2RuYInXdUWBTW//73XVYm0=; b=+iwkwvNEn54tR9xz7jcZGiqa+56HiFP8TiLT8JYtzPWGMO6Z8uVywQslTWiMPsVIVC4Jkm pdv9Nt05hulH8fCQ== 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 34/39] PCI/MSI: Reject multi-MSI early References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:55:09 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208450734092372?= X-GMAIL-MSGID: =?utf-8?q?1749208450734092372?= When hierarchical MSI interrupt domains are enabled then there is no point to do tons of work and detect the missing support for multi-MSI late in the allocation path. Just query the domain feature flags right away. The query function is going to be used for other purposes later and has a mode argument which influences the result: ALLOW_LEGACY returns true when: - there is no irq domain attached (legacy support) - there is a irq domain attached which has the feature flag set DENY_LEGACY returns only true when: - there is a irq domain attached which has the feature flag set This allows to use the function universally without ifdeffery in the calling code. Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe --- drivers/pci/msi/irqdomain.c | 22 ++++++++++++++++++++++ drivers/pci/msi/msi.c | 4 ++++ drivers/pci/msi/msi.h | 9 +++++++++ 3 files changed, 35 insertions(+) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -187,6 +187,28 @@ struct irq_domain *pci_msi_create_irq_do } EXPORT_SYMBOL_GPL(pci_msi_create_irq_domain); +/** + * pci_msi_domain_supports - Check for support of a particular feature flag + * @pdev: The PCI device to operate on + * @feature_mask: The feature mask to check for (full match) + * @mode: If ALLOW_LEGACY this grants the feature when there is no irq domain + * associated to the device. If DENY_LEGACY the lack of an irq domain + * makes the feature unsupported + */ +bool pci_msi_domain_supports(struct pci_dev *pdev, unsigned int feature_mask, + enum support_mode mode) +{ + struct msi_domain_info *info; + struct irq_domain *domain; + + domain = dev_get_msi_domain(&pdev->dev); + + if (!domain || !irq_domain_is_hierarchy(domain)) + return mode == ALLOW_LEGACY; + info = domain->host_data; + return (info->flags & feature_mask) == feature_mask; +} + /* * Users of the generic MSI infrastructure expect a device to have a single ID, * so with DMA aliases we have to pick the least-worst compromise. Devices with --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -347,6 +347,10 @@ static int msi_capability_init(struct pc struct msi_desc *entry; int ret; + /* Reject multi-MSI early on irq domain enabled architectures */ + if (nvec > 1 && !pci_msi_domain_supports(dev, MSI_FLAG_MULTI_PCI_MSI, ALLOW_LEGACY)) + return 1; + /* * Disable MSI during setup in the hardware, but mark it enabled * so that setup code can evaluate it. --- a/drivers/pci/msi/msi.h +++ b/drivers/pci/msi/msi.h @@ -97,6 +97,15 @@ int __pci_enable_msix_range(struct pci_d void __pci_restore_msi_state(struct pci_dev *dev); void __pci_restore_msix_state(struct pci_dev *dev); +/* irq_domain related functionality */ + +enum support_mode { + ALLOW_LEGACY, + DENY_LEGACY, +}; + +bool pci_msi_domain_supports(struct pci_dev *dev, unsigned int feature_mask, enum support_mode mode); + /* Legacy (!IRQDOMAIN) fallbacks */ #ifdef CONFIG_PCI_MSI_ARCH_FALLBACKS From patchwork Fri Nov 11 13:55:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753896wru; Fri, 11 Nov 2022 05:59:36 -0800 (PST) X-Google-Smtp-Source: AA0mqf5XAwysllyfScqhPMtTizu7lKd8zRhDYxeBjhJ+OsFHM+FK/YBUoHVBuSwKurzOjyVDROpV X-Received: by 2002:a17:906:2888:b0:78d:4b9f:c32 with SMTP id o8-20020a170906288800b0078d4b9f0c32mr1762195ejd.499.1668175176796; Fri, 11 Nov 2022 05:59:36 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175176; cv=none; d=google.com; s=arc-20160816; b=KZ4TRcIMocrHAz3CO1PUz6EcfWOgL/dIvHT//I0ayyGbsOwJkScASUemcOATTY+ctG RnGqYvcbRZaKs78V6+bKhqGCp86K9EOPXW919FooARV5wYQHEgBHlf4GvLVht2HVgxn9 5vFjVzQ81rjDjeCvxm7CHBz6kZqkBk5ecrD+b9ZXUkrw+su52NamJL6GlvB6V+BzlW9T cX8zPH4Rnz+z1Fk57gEMr+FRzmxA33vuup7AZj//jcDas71/qSH9G1q6jQf4W/vTO46Z ZAGEX10/FuN5lYCl/BPm6celkegMumtL/pK1qP4plLgtSj6znig2a1xAsz399JGIcwJS rBcA== 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=+6oBh3Odymqoh23rvdka2IMdSMoyZzzr0/UBN1qNnTk=; b=sKiKUFAlUF3d5I0B01JTf6U1+xqQOZoK+8pNEEpMF6BhdSnCtSsm4NlJfqR5LahSMD FwHEyj/L9ujvH4Fb5jezkZubiOIYwrADnXeqf/M0r9lssWjMz9v264PtWZehhKnKJvLR g5Xla9ablJkurf3gEdSXTLyisWf+hW4k1oUDVf8h7vbYSqhBejxckgiTZMjUIFRsr/Tj pCb4jhA9URFXlGAyCruZhzysMXv55nxgnWwtiI5vltpJH3zl2mo1P8xqSzGJNdOeayR0 iwOd6sr0U843sL04EP0Bo8RZwpHqZLH5Go5veMjZSBY6RBmuYDVAzVJGRmWAL4masySx HC3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=O3tsMqs0; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=RaGdX6Bh; 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 g2-20020a056402428200b00461d60a86casi2400884edc.135.2022.11.11.05.59.12; Fri, 11 Nov 2022 05:59:36 -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=O3tsMqs0; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=RaGdX6Bh; 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 S234098AbiKKN5t (ORCPT + 99 others); Fri, 11 Nov 2022 08:57:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234030AbiKKN46 (ORCPT ); Fri, 11 Nov 2022 08:56:58 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2F3F83BBD; Fri, 11 Nov 2022 05:55:12 -0800 (PST) Message-ID: <20221111122015.631728309@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174911; 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=+6oBh3Odymqoh23rvdka2IMdSMoyZzzr0/UBN1qNnTk=; b=O3tsMqs0BMeeR+sixFB4gZJapU/NxK4ghDKAVQPqDhnTZ1IBPbK56iDtMw7jiD/yvC0Vms vf+roT7vboCo/D68gqgyuCWbdKslCGJJlnagz5NYC84Fa+4muHYwvI8A/twTqrfeUBk4vq qOa5boM9ecDRIvlv/Ne3aj00R/KskvzhltFrU+g0Dwj09t1ZkfM5eE1QNWW8iR655FotRi SVw1neM3UJcaXYj5CYqZj6zgC6RP/mbHOygnVJyedVo6fh9IVUba5cbNVdgGznNBm/s8sV hI/fb/i3XF/r1foTj/UHFgkIBx8je8kZVkZCQzlLRfgqN9hBwDdlt7py4prVNw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174911; 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=+6oBh3Odymqoh23rvdka2IMdSMoyZzzr0/UBN1qNnTk=; b=RaGdX6Bhz2QV0LIWcWTdx/Y0fm6Co1H4cRb08fHDA9pCZ6wSQ+pfMSrQ7MxAFpkbWFifhD 9ql635EreUgGQKBA== 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 35/39] PCI/MSI: Reject MSI-X early References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:55:11 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208454418919210?= X-GMAIL-MSGID: =?utf-8?q?1749208454418919210?= Similar to PCI multi-MSI reject MSI-X enablement when a irq domain is attached to the device which does not support MSI-X. Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe --- drivers/pci/msi/msi.c | 4 ++++ 1 file changed, 4 insertions(+) --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -760,6 +760,10 @@ int __pci_enable_msix_range(struct pci_d if (WARN_ON_ONCE(dev->msix_enabled)) return -EINVAL; + /* Check MSI-X early on irq domain enabled architectures */ + if (!pci_msi_domain_supports(dev, MSI_FLAG_PCI_MSIX, ALLOW_LEGACY)) + return -ENOTSUPP; + if (!pci_msi_supported(dev, nvec) || dev->current_state != PCI_D0) return -EINVAL; From patchwork Fri Nov 11 13:55:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18784 Return-Path: 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 + 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 ); 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 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 36/39] PCI/MSI: Validate MSIX contiguous restriction early References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 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: 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?= 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 Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe --- 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! */ From patchwork Fri Nov 11 13:55:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18785 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753933wru; Fri, 11 Nov 2022 05:59:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf6U5WOGKY2gNzBqEXFWam32Qy7kZ1gEMu1frJtmriJwWNXI1NP+HDvoXZkDqCHnpVnsihF/ X-Received: by 2002:a17:906:a052:b0:7ad:a030:485c with SMTP id bg18-20020a170906a05200b007ada030485cmr1828727ejb.605.1668175182505; Fri, 11 Nov 2022 05:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175182; cv=none; d=google.com; s=arc-20160816; b=WHeKV/9+J5YnI2w9pFH8WIYNsQ7EatRkY4dL51j2puYqGaS5ptulYiJO9wXrrYRikv 8Il24XdXLkkTgHiAZ2DeUJKvbQ2byUpbghVzs3zGzsT3uOILsp97LIROxHkZ1a2IT4Jn iiVFWiTCdVceT8hrFz7bfS6nP6w+Nk5Fzyc9GQvR5hmOvP+ubhKHulppZUyWtmfhhOZt qEbcp9RJThpcpVWKHxXLqT1BA4X4IzGfrz3mLNTp5R+xCNpXVviaQ3xzFRiWk0iGewbC 33vgUa5uiRseeccoc0gbx9CCuzhPlIowsANHi1Lkj+ewGNhALc68WtsbGq5oKTdQGtJS 2VKg== 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=Ih0SYkcSYwketpyalRo87sRSG9j843DJDGdjQI9dFbE=; b=uvQdZtvM2bWiKcv1HvB1RoBDMUWhCK9FiQIM0AhcDUpWGPoBr3ayvsL6LDfGxgPWJi 8NH1AeZFPNNXi54w8m4QUdiVikygGR7A3kL0+aAgBxZ/zZFKLdMjvO/cx8GzgHWZ2EK1 fx1hJvyppBFU8NF8qatNGIqxJYC2ZVt69CLjMo3X5Tg9P5oHqh6HpYZ1gHkQcvdI8SD7 uqT1b09YRjiI+LyKRhxQb08NxKaw48QgudQfqOiK30UjMBoUtxG6hfQGAqAs337BSp8S rcMlokrpff8x1g6N9CnRnspUmMjjiX0btnNomsg0lJTk47r+g3gX4lsD4azidGr0PNaV uagg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=VRE7MeUl; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=3NdsAzuz; 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 hd42-20020a17090796aa00b007ae5fa9b603si2460966ejc.374.2022.11.11.05.59.15; Fri, 11 Nov 2022 05:59:42 -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=VRE7MeUl; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e header.b=3NdsAzuz; 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 S234067AbiKKN6M (ORCPT + 99 others); Fri, 11 Nov 2022 08:58:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234061AbiKKN5B (ORCPT ); Fri, 11 Nov 2022 08:57:01 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6172085460; Fri, 11 Nov 2022 05:55:16 -0800 (PST) Message-ID: <20221111122015.749446904@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174915; 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=Ih0SYkcSYwketpyalRo87sRSG9j843DJDGdjQI9dFbE=; b=VRE7MeUlB+cCM6U0cjMzbGN3WDIQa4HFZh7046HSLFSqzZZR+YCs/CdvdLqq6MWSGZekns H/dGx3if2rOBFQbosYmjXgs8H6R5QzfT4Wx9HUiK3bRvDeCd3Y2/aKwsZmLgcB2RLXpdOs oVkPfJgyTtJEli4A4Tu93d2MK7EdOeIEH+Y0BZTm7D17rn3qKvvsqjvAZrJgzd7vVJM1e9 1Z0lHU2nKsnKqYI3bqO1EqiYcRaa2k7iEq2ImYpiFsxIhbdqk1xQCU1UqPFsjb5fWestXq 04JcUcgHgsR+8pKz5h9KEtGpLzv4hoUBfbtq/MJ4c2jMIoOztbmH2Ysjx6MsoQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174915; 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=Ih0SYkcSYwketpyalRo87sRSG9j843DJDGdjQI9dFbE=; b=3NdsAzuzZxu0dT7r41E3zPAtIf/iHCijDpTpmlZOnjI92Lbu6pLEazC2N//W9XAeQ4XAqW 7LzccZ7efW9feDBw== 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 37/39] PCI/MSI: Remove redundant msi_check() callback References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:55:14 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208460194635266?= X-GMAIL-MSGID: =?utf-8?q?1749208460194635266?= All these sanity checks are now done _before_ any allocation work happens. No point in doing it twice. Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas Reviewed-by: Jason Gunthorpe --- drivers/pci/msi/irqdomain.c | 48 -------------------------------------------- 1 file changed, 48 deletions(-) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -64,51 +64,6 @@ static irq_hw_number_t pci_msi_domain_ca (pci_domain_nr(dev->bus) & 0xFFFFFFFF) << 27; } -static inline bool pci_msi_desc_is_multi_msi(struct msi_desc *desc) -{ - return !desc->pci.msi_attrib.is_msix && desc->nvec_used > 1; -} - -/** - * pci_msi_domain_check_cap - Verify that @domain supports the capabilities - * for @dev - * @domain: The interrupt domain to check - * @info: The domain info for verification - * @dev: The device to check - * - * Returns: - * 0 if the functionality is supported - * 1 if Multi MSI is requested, but the domain does not support it - * -ENOTSUPP otherwise - */ -static int pci_msi_domain_check_cap(struct irq_domain *domain, - struct msi_domain_info *info, - struct device *dev) -{ - struct msi_desc *desc = msi_first_desc(dev, MSI_DESC_ALL); - - /* Special handling to support __pci_enable_msi_range() */ - if (pci_msi_desc_is_multi_msi(desc) && - !(info->flags & MSI_FLAG_MULTI_PCI_MSI)) - return 1; - - if (desc->pci.msi_attrib.is_msix) { - if (!(info->flags & MSI_FLAG_PCI_MSIX)) - return -ENOTSUPP; - - if (info->flags & MSI_FLAG_MSIX_CONTIGUOUS) { - unsigned int idx = 0; - - /* Check for gaps in the entry indices */ - msi_for_each_desc(desc, dev, MSI_DESC_ALL) { - if (desc->msi_index != idx++) - return -ENOTSUPP; - } - } - } - return 0; -} - static void pci_msi_domain_set_desc(msi_alloc_info_t *arg, struct msi_desc *desc) { @@ -118,7 +73,6 @@ static void pci_msi_domain_set_desc(msi_ static struct msi_domain_ops pci_msi_domain_ops_default = { .set_desc = pci_msi_domain_set_desc, - .msi_check = pci_msi_domain_check_cap, }; static void pci_msi_domain_update_dom_ops(struct msi_domain_info *info) @@ -130,8 +84,6 @@ static void pci_msi_domain_update_dom_op } else { if (ops->set_desc == NULL) ops->set_desc = pci_msi_domain_set_desc; - if (ops->msi_check == NULL) - ops->msi_check = pci_msi_domain_check_cap; } } From patchwork Fri Nov 11 13:55: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: 18786 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753932wru; Fri, 11 Nov 2022 05:59:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf6BsLb7w+25h9WHvUZG8AvvxdeaQE+z2+2hXGgk6yCIHqy5CkaR+pnMUIE94DKSVFPC85qL X-Received: by 2002:a17:906:af14:b0:7ad:ba1e:1bac with SMTP id lx20-20020a170906af1400b007adba1e1bacmr1935306ejb.528.1668175182276; Fri, 11 Nov 2022 05:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175182; cv=none; d=google.com; s=arc-20160816; b=Nfxd0dR4UopkJy9S9qUUeLezUXRwNgtC/2rh/vlLjcHMkqplcmEyHZgCEjqOPgbaQ+ Pj40iYAtM4ipP10zjWJSyj6Otw1wLSQhDlUsIfzP+OwaNOuN+cWiIaT4mvb22WtCQGrR UjWv9oSjYaw0bZLHHoORXyHQ1I23DrprAlGeQvEKrdmN5DhQPVL9b5FNVreFhc/LDQKF 4xBEkGVqqMwdrvKhe3OGHjTIcNkj2F/V9RxcY8QHyZg5wjjqjL/+xN6ifRCiAkC3h4BY ZgnGIyJagGK1MJkuPt23v5nIWRBmgt7MZ6PHtGEy3Nv1VoG/pcF/Wb+MgzwKCuFGTbMA bKiQ== 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=643AGhyNZmR2aie2PCCrOjp31nEV6JyyeqqH5V3vLDo=; b=JEDYrmF+wD/6CoidfhkaMtOrttCRIV2vpi52gDKBQ/hPzEcTYIp+XGzjluAAwpLtJu rPRMd/7/th44oxaDusm2tkZPUjyb6OkBSwgEJs2QoYw3FQz4uFSmyqmJihldsjed4ZWP 1etvw4QehdOye9dYT2rXDby02wLnBgkBiSZ4HEMRn8EV8vg6QNqxB30Nyu7cyBT62Z8a OkMpBvBzd2TXz6Sg6T3DwC2nt2l91mEJNwgxlQyqMaullCRWuncmik2lRIe/fT96sZ/7 41JDW/nTUah1e1Ea4hlp4e0uyh4aV7RXV5iFaB0tFMWKIOvv3jMOuY1MRJ8DQjGj6jHd F0/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Sw1lJkOU; 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 q14-20020a170906144e00b0078e1d213812si1595195ejc.184.2022.11.11.05.59.17; Fri, 11 Nov 2022 05:59:42 -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=Sw1lJkOU; 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 S234123AbiKKN6R (ORCPT + 99 others); Fri, 11 Nov 2022 08:58:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58812 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234064AbiKKN5B (ORCPT ); Fri, 11 Nov 2022 08:57:01 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [IPv6:2a0a:51c0:0:12e:550::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DEA586EB6F; Fri, 11 Nov 2022 05:55:17 -0800 (PST) Message-ID: <20221111122015.807616900@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174916; 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=643AGhyNZmR2aie2PCCrOjp31nEV6JyyeqqH5V3vLDo=; b=Sw1lJkOUvkZ0DIAcRPl+ie495eVa6MbYCglERsRGFe8w0Y5OR00lTVkULAo3m3suKSbjrP 0ow0a6Nw5jI91aq9J3EGWRZoVNumWiEKlIlIXZxwTYrItsHWIo3QClO8S/4rXyABHAgyRd VLCJNs9QTCInxzPdTphoMGKQBBAQzQYXZZzvOmqqZ5Wydl5zhwLSMUpWma3gufRqtR7R7c Q7e/lmelPnuCPGVViHH7TrfQy0Chs28OJpRiQP92j/k5T4lQXPSjBLR5hGCMjSgcBdnQev 9JltwNMmtLP7XxpQGxTpy8LoCtAOCTdKp0RybLPEIGZ6vG3MULDpIUQfdcegHw== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174916; 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=643AGhyNZmR2aie2PCCrOjp31nEV6JyyeqqH5V3vLDo=; b=CEwbqwdLhlbEE3zKR1PyZBZm1Iv1k/zk7+gvTQLDniqqGqeEfGsMiJ+J0PDZl7Nx3yuYOM y3Rvy6Y7JuG7mMBQ== 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 38/39] genirq/msi: Remove msi_domain_ops::msi_check() References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:55: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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208459975906509?= X-GMAIL-MSGID: =?utf-8?q?1749208459975906509?= No more users. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe --- include/linux/msi.h | 4 ---- kernel/irq/msi.c | 17 +---------------- 2 files changed, 1 insertion(+), 20 deletions(-) --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -288,7 +288,6 @@ struct msi_domain_info; * @get_hwirq: Retrieve the resulting hw irq number * @msi_init: Domain specific init function for MSI interrupts * @msi_free: Domain specific function to free a MSI interrupts - * @msi_check: Callback for verification of the domain/info/dev data * @msi_prepare: Prepare the allocation of the interrupts in the domain * @set_desc: Set the msi descriptor for an interrupt * @domain_alloc_irqs: Optional function to override the default allocation @@ -326,9 +325,6 @@ struct msi_domain_ops { void (*msi_free)(struct irq_domain *domain, struct msi_domain_info *info, unsigned int virq); - int (*msi_check)(struct irq_domain *domain, - struct msi_domain_info *info, - struct device *dev); int (*msi_prepare)(struct irq_domain *domain, struct device *dev, int nvec, msi_alloc_info_t *arg); --- a/kernel/irq/msi.c +++ b/kernel/irq/msi.c @@ -617,17 +617,9 @@ static int msi_domain_ops_init(struct ir return 0; } -static int msi_domain_ops_check(struct irq_domain *domain, - struct msi_domain_info *info, - struct device *dev) -{ - return 0; -} - static struct msi_domain_ops msi_domain_ops_default = { .get_hwirq = msi_domain_ops_get_hwirq, .msi_init = msi_domain_ops_init, - .msi_check = msi_domain_ops_check, .msi_prepare = msi_domain_ops_prepare, .set_desc = msi_domain_ops_set_desc, .domain_alloc_irqs = __msi_domain_alloc_irqs, @@ -655,8 +647,6 @@ static void msi_domain_update_dom_ops(st ops->get_hwirq = msi_domain_ops_default.get_hwirq; if (ops->msi_init == NULL) ops->msi_init = msi_domain_ops_default.msi_init; - if (ops->msi_check == NULL) - ops->msi_check = msi_domain_ops_default.msi_check; if (ops->msi_prepare == NULL) ops->msi_prepare = msi_domain_ops_default.msi_prepare; if (ops->set_desc == NULL) @@ -707,13 +697,8 @@ int msi_domain_prepare_irqs(struct irq_d { struct msi_domain_info *info = domain->host_data; struct msi_domain_ops *ops = info->ops; - int ret; - - ret = ops->msi_check(domain, info, dev); - if (ret == 0) - ret = ops->msi_prepare(domain, dev, nvec, arg); - return ret; + return ops->msi_prepare(domain, dev, nvec, arg); } int msi_domain_populate_irqs(struct irq_domain *domain, struct device *dev, From patchwork Fri Nov 11 13:55:17 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 18787 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp753936wru; Fri, 11 Nov 2022 05:59:42 -0800 (PST) X-Google-Smtp-Source: AA0mqf76AZOaqGCv4DWP7WRvoYDfgaS7rZl3Z71d0A8K/g7ktD1z+cdV082HTLLPHTrc+rBLnQW8 X-Received: by 2002:a05:6402:e8a:b0:463:53c6:56a5 with SMTP id h10-20020a0564020e8a00b0046353c656a5mr1534480eda.223.1668175182768; Fri, 11 Nov 2022 05:59:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668175182; cv=none; d=google.com; s=arc-20160816; b=gUfFwWnfh3ntMPPww9pbHs7uT8RCR3Xf7WLNFCQ8ey3pUkYR0qB2jGvtj+RJua8P+3 D/tDEYcNUiNdJwxfNxpo6qq4A0G1AczDe6/pQS5WgX1pSzyNZBqcZlp+whN8gd+YyrF7 cDQESFPnVrB6NjsJshGXqWDcvDh1dEqMdpAYX7z1k4AHC4IgcLA5HKjqL40eg6alA1kt RGzjpHAezijqJj6V1B3v8vLc04fsFNq2D22RGqQU501dQ1WxQ2NYaUIV0gusEGCUE8ja YjJdC5+VJoa992t/qEBBdVGzeotbKzKIZlgRkvhhl9OAgZ4z+nqssMCIq16y6zQCmBw3 OB1g== 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=KlmWSrD822PE2zOCQUPKNeyY1BUX75wWYBCy1LY/Ddo=; b=aO/9smrWS3VfHvDkC0W8pw66xZmmIb60wIpKIaHnIaUTDsTjts4/Eti0eJbnyICRDB 3cxo+9k4paE6bqKc54o3/tvjZWg+B1hhb4wI6SvNymqnj8OtjXQUQVvDJaYnldulIs7N 9gi/sVd3oM5aPTJDnxtA7Ct1EpxVUHUsdtxu7I3RJVP4+5IOXANwp7iQ0IAb+/uu6haw aycHde9F7tGs5qREqQNAYAjVzY0C1anA2PTElroCxDAO3edXrdYuxL9bDIIOB7+p444H TNdEjmwHxWF0eWOCyJC/GhAJeiKDAHxDWX/j041YmbvDh/SxSOrTbACmjSZ/elGigZ9x Lq3Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=uOX0P7JY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 m5-20020a170906234500b0073d9f16e5b3si1653644eja.258.2022.11.11.05.59.18; Fri, 11 Nov 2022 05:59:42 -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=uOX0P7JY; dkim=neutral (no key) header.i=@linutronix.de header.s=2020e; 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 S233856AbiKKN6X (ORCPT + 99 others); Fri, 11 Nov 2022 08:58:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233581AbiKKN5C (ORCPT ); Fri, 11 Nov 2022 08:57:02 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F92D701AD; Fri, 11 Nov 2022 05:55:19 -0800 (PST) Message-ID: <20221111122015.865042356@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1668174918; 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=KlmWSrD822PE2zOCQUPKNeyY1BUX75wWYBCy1LY/Ddo=; b=uOX0P7JY4JDZrhpHSa4G1IGNcgMKKOEotn3WaD7e11QG/6dfy0hAWm6VlqdtkgWxscy2j2 vg8RZD2L7my03vFnseCP0zLzRVNFtmog03/OZWe8j+dCe3360GRdm7D7Ro+eFucXWe1cGt B1TbYs1Kn3thlD7fo2rbFIumODHXMAxjO1WybkfUU98oPmOGMfEeOcgke6duFUhpjCZKei OKjgabNkcGtNWaX2DdmfmLk843sFhP8s/1IrxWyfYUmW6Aek0x8nC5F0XV+DOF6doD4AUQ pelYpWuMy5qNR57TeK4q2muF+jZFU5A0mAMkigQCBXCSX0sc7psCpSz6yuOhBg== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1668174918; 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=KlmWSrD822PE2zOCQUPKNeyY1BUX75wWYBCy1LY/Ddo=; b=IbSEAj1FCCNGEuhGibqJgPyd7PCqcVB4JEhzyivG+QUYDdfm3d+uCQ5/9YQCI9bNGUKlUx zljP/0HV6LO8O0BA== 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 39/39] x86/apic: Remove X86_IRQ_ALLOC_CONTIGUOUS_VECTORS References: <20221111120501.026511281@linutronix.de> MIME-Version: 1.0 Date: Fri, 11 Nov 2022 14:55:17 +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: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749208460381136396?= X-GMAIL-MSGID: =?utf-8?q?1749208460381136396?= Now that the PCI/MSI core code does early checking for multi-MSI support X86_IRQ_ALLOC_CONTIGUOUS_VECTORS is not required anymore. Remove the flag and rely on MSI_FLAG_MULTI_PCI_MSI. Signed-off-by: Thomas Gleixner Reviewed-by: Jason Gunthorpe --- arch/x86/include/asm/irqdomain.h | 4 +--- arch/x86/kernel/apic/msi.c | 6 ++---- arch/x86/kernel/apic/vector.c | 4 ---- drivers/iommu/amd/iommu.c | 7 ------- drivers/iommu/intel/irq_remapping.c | 7 ------- drivers/pci/controller/pci-hyperv.c | 15 +-------------- 6 files changed, 4 insertions(+), 39 deletions(-) --- a/arch/x86/include/asm/irqdomain.h +++ b/arch/x86/include/asm/irqdomain.h @@ -7,9 +7,7 @@ #ifdef CONFIG_X86_LOCAL_APIC enum { - /* Allocate contiguous CPU vectors */ - X86_IRQ_ALLOC_CONTIGUOUS_VECTORS = 0x1, - X86_IRQ_ALLOC_LEGACY = 0x2, + X86_IRQ_ALLOC_LEGACY = 0x1, }; extern int x86_fwspec_is_ioapic(struct irq_fwspec *fwspec); --- a/arch/x86/kernel/apic/msi.c +++ b/arch/x86/kernel/apic/msi.c @@ -161,12 +161,10 @@ int pci_msi_prepare(struct irq_domain *d msi_alloc_info_t *arg) { init_irq_alloc_info(arg, NULL); - if (to_pci_dev(dev)->msix_enabled) { + if (to_pci_dev(dev)->msix_enabled) arg->type = X86_IRQ_ALLOC_TYPE_PCI_MSIX; - } else { + else arg->type = X86_IRQ_ALLOC_TYPE_PCI_MSI; - arg->flags |= X86_IRQ_ALLOC_CONTIGUOUS_VECTORS; - } return 0; } --- a/arch/x86/kernel/apic/vector.c +++ b/arch/x86/kernel/apic/vector.c @@ -539,10 +539,6 @@ static int x86_vector_alloc_irqs(struct if (disable_apic) return -ENXIO; - /* Currently vector allocator can't guarantee contiguous allocations */ - if ((info->flags & X86_IRQ_ALLOC_CONTIGUOUS_VECTORS) && nr_irqs > 1) - return -ENOSYS; - /* * Catch any attempt to touch the cascade interrupt on a PIC * equipped system. --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -3297,13 +3297,6 @@ static int irq_remapping_alloc(struct ir if (nr_irqs > 1 && info->type != X86_IRQ_ALLOC_TYPE_PCI_MSI) return -EINVAL; - /* - * With IRQ remapping enabled, don't need contiguous CPU vectors - * to support multiple MSI interrupts. - */ - if (info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI) - info->flags &= ~X86_IRQ_ALLOC_CONTIGUOUS_VECTORS; - sbdf = get_devid(info); if (sbdf < 0) return -EINVAL; --- a/drivers/iommu/intel/irq_remapping.c +++ b/drivers/iommu/intel/irq_remapping.c @@ -1337,13 +1337,6 @@ static int intel_irq_remapping_alloc(str if (nr_irqs > 1 && info->type != X86_IRQ_ALLOC_TYPE_PCI_MSI) return -EINVAL; - /* - * With IRQ remapping enabled, don't need contiguous CPU vectors - * to support multiple MSI interrupts. - */ - if (info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI) - info->flags &= ~X86_IRQ_ALLOC_CONTIGUOUS_VECTORS; - ret = irq_domain_alloc_irqs_parent(domain, virq, nr_irqs, arg); if (ret < 0) return ret; --- a/drivers/pci/controller/pci-hyperv.c +++ b/drivers/pci/controller/pci-hyperv.c @@ -611,20 +611,7 @@ static unsigned int hv_msi_get_int_vecto return cfg->vector; } -static int hv_msi_prepare(struct irq_domain *domain, struct device *dev, - int nvec, msi_alloc_info_t *info) -{ - int ret = pci_msi_prepare(domain, dev, nvec, info); - - /* - * By using the interrupt remapper in the hypervisor IOMMU, contiguous - * CPU vectors is not needed for multi-MSI - */ - if (info->type == X86_IRQ_ALLOC_TYPE_PCI_MSI) - info->flags &= ~X86_IRQ_ALLOC_CONTIGUOUS_VECTORS; - - return ret; -} +#define hv_msi_prepare pci_msi_prepare /** * hv_arch_irq_unmask() - "Unmask" the IRQ by setting its current