From patchwork Mon Dec 6 22:51:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thomas Gleixner X-Patchwork-Id: 12660323 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 3B1EFC433FE for ; Mon, 6 Dec 2021 22:51:28 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.240133.416618 (Exim 4.92) (envelope-from ) id 1muMpM-0002ln-SZ; Mon, 06 Dec 2021 22:51:20 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 240133.416618; Mon, 06 Dec 2021 22:51:20 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1muMpM-0002j4-E8; Mon, 06 Dec 2021 22:51:20 +0000 Received: by outflank-mailman (input) for mailman id 240133; Mon, 06 Dec 2021 22:51:18 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1muMpK-0000Tb-AF for xen-devel@lists.xenproject.org; Mon, 06 Dec 2021 22:51:18 +0000 Received: from galois.linutronix.de (galois.linutronix.de [2a0a:51c0:0:12e:550::1]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 05cb285d-56e7-11ec-8a4d-196798b21f7b; Mon, 06 Dec 2021 23:51:17 +0100 (CET) X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 05cb285d-56e7-11ec-8a4d-196798b21f7b Message-ID: <20211206210748.089085131@linutronix.de> DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1638831077; 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=O192gTv7DVMCmoiFcAQ4tyGbPvViDQQz5Lq/A3dCGdU=; b=yAGXeCWb/MLSFOWdyqn+f3X7iRs0IbPpmDQ2LDClgWe2kyw40xFdfg87fcMA3GSkbXdpRp P4jKMgelmsbNP+ajv6QuUI/YvPD46YfxdK/tIkaJKr7oJKF88KyOGJA/Eg9ozHpz5UyDs+ X2UpRnC2ETnBVHswRo5ju3uaspL1Hr8L2VEKC/WMii0ILQ1aJmADFWDY+tKFUqX+W5sS7+ JLHMYFCndpVQwB1ty7SXBw0CRNc3HOmjKE1mpn3ehsl0bA/07CL8htyJb/5ZrAZjVo5nf7 BWLZh62Sv60QedOoRKVKKhpCTkQF6rUQzyYh2zRmZFcoScESSB7zYoCJNupn4Q== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1638831077; 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=O192gTv7DVMCmoiFcAQ4tyGbPvViDQQz5Lq/A3dCGdU=; b=LOPeM1wwdBLryYGVoFatNH/lCkc91JRDEBARe01ZXRbr1hoNxRJB3rT3CyT0HQcyqz5EUa dcAfNimcrSAi4SCA== From: Thomas Gleixner To: LKML Cc: Bjorn Helgaas , Marc Zygnier , Alex Williamson , Kevin Tian , Jason Gunthorpe , Megha Dey , Ashok Raj , linux-pci@vger.kernel.org, Cedric Le Goater , xen-devel@lists.xenproject.org, Juergen Gross , Greg Kroah-Hartman , Niklas Schnelle , linux-s390@vger.kernel.org, Heiko Carstens , Christian Borntraeger , Logan Gunthorpe , Jon Mason , Dave Jiang , Allen Hubbe , linux-ntb@googlegroups.com Subject: [patch V2 09/31] PCI/MSI: Let core code free MSI descriptors References: <20211206210600.123171746@linutronix.de> MIME-Version: 1.0 Date: Mon, 6 Dec 2021 23:51:16 +0100 (CET) Set the domain info flag which tells the core code to free the MSI descriptors from msi_domain_free_irqs() and add an explicit call to the core function into the legacy code. Signed-off-by: Thomas Gleixner Acked-by: Bjorn Helgaas --- drivers/pci/msi/irqdomain.c | 3 ++- drivers/pci/msi/legacy.c | 1 + drivers/pci/msi/msi.c | 14 -------------- 3 files changed, 3 insertions(+), 15 deletions(-) --- a/drivers/pci/msi/irqdomain.c +++ b/drivers/pci/msi/irqdomain.c @@ -171,7 +171,8 @@ struct irq_domain *pci_msi_create_irq_do if (info->flags & MSI_FLAG_USE_DEF_CHIP_OPS) pci_msi_domain_update_chip_ops(info); - info->flags |= MSI_FLAG_ACTIVATE_EARLY | MSI_FLAG_DEV_SYSFS; + info->flags |= MSI_FLAG_ACTIVATE_EARLY | MSI_FLAG_DEV_SYSFS | + MSI_FLAG_FREE_MSI_DESCS; if (IS_ENABLED(CONFIG_GENERIC_IRQ_RESERVATION_MODE)) info->flags |= MSI_FLAG_MUST_REACTIVATE; --- a/drivers/pci/msi/legacy.c +++ b/drivers/pci/msi/legacy.c @@ -80,4 +80,5 @@ void pci_msi_legacy_teardown_msi_irqs(st { msi_device_destroy_sysfs(&dev->dev); arch_teardown_msi_irqs(dev); + msi_free_msi_descs(&dev->dev); } --- a/drivers/pci/msi/msi.c +++ b/drivers/pci/msi/msi.c @@ -224,22 +224,8 @@ EXPORT_SYMBOL_GPL(pci_write_msi_msg); static void free_msi_irqs(struct pci_dev *dev) { - struct list_head *msi_list = dev_to_msi_list(&dev->dev); - struct msi_desc *entry, *tmp; - int i; - - for_each_pci_msi_entry(entry, dev) - if (entry->irq) - for (i = 0; i < entry->nvec_used; i++) - BUG_ON(irq_has_action(entry->irq + i)); - pci_msi_teardown_msi_irqs(dev); - list_for_each_entry_safe(entry, tmp, msi_list, list) { - list_del(&entry->list); - free_msi_entry(entry); - } - if (dev->msix_base) { iounmap(dev->msix_base); dev->msix_base = NULL;