From patchwork Mon Dec 5 18:25:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: tip-bot2 for Thomas Gleixner X-Patchwork-Id: 29841 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp2409168wrr; Mon, 5 Dec 2022 10:27:43 -0800 (PST) X-Google-Smtp-Source: AA0mqf6+7JUto2Cxxe/9avrw7ZNj+thLM18TU91YMfD7aPSakuzMIcCEopnOJFKJKvKhRlcEtwII X-Received: by 2002:a17:906:cc8f:b0:78b:8ce7:fe3c with SMTP id oq15-20020a170906cc8f00b0078b8ce7fe3cmr70550978ejb.557.1670264863298; Mon, 05 Dec 2022 10:27:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670264863; cv=none; d=google.com; s=arc-20160816; b=MrLGreldFvg9mQOI9HbTLyipb6x+uvrkwkWYzHcdREY3D2vmgR/3naPSAls9o4u3Fq HrYsVtvqM3bgzF0/Alh+6cSnHWqQMBiCqmS4c6b0eSLSffKYYVI8Fe4JYUJLGozEYOXT q9FPXL86bObdHmh8wUZxvjG+0ClXm2xrRvQN9I/hPKJcD1J6qCv9dZzJmXc37NpfYjie ITMwcUO6gKdIyAc3UvldknGjhma4mrchxwheY1NBmr6AkPkzhgYJZPcgqAftz68kFmxl KkByJsNNZfo0oJ3/O5N1HtWvy8Jg90WNJkEqxXYNSR0TuUZezJ5T/tL73KzyAVSm8RY4 BQKA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:robot-unsubscribe :robot-id:message-id:mime-version:references:in-reply-to:cc:subject :to:reply-to:sender:from:dkim-signature:dkim-signature:date; bh=Il/CbdHu9pPpiZtWniggttxXh3zGtyvoQhyMRC2LCcw=; b=Z6Y2mSKsQs3s647je/SVTErECzkmXK7qq91z2zMXqZmX5RMAt1lmW0biojGm35GDC5 LoNvDjeQvfkwIEB7ep+OoqCJOu3jQUJM+DM8TcpCXCUQEr8md8yB84L4Ue/jL5q3S3zh 14rlxmz9jqcVzEM7QUsoxL9viPRVc/FS2Gb3vxFwhweZ3pQGj+mtkATYsvyZCEQJZlVn VVs1P7+tbiwM7vOxNgm/zB9sX+++UA56tCTXPIQ5nbQwyTo+NQu5hHTv3aPXDMS4ZnRy nRiS9G3Km0aA8XA4ObWvYjLDtNQjqzz+VKbN1PqTV2ZatL+J28utbAQjrxQLFQi3G1GE NemA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linutronix.de header.s=2020 header.b=Nlo4ZNv2; 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 di10-20020a170906730a00b007aea0bbe2e2si14336921ejc.394.2022.12.05.10.27.20; Mon, 05 Dec 2022 10:27:43 -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=Nlo4ZNv2; 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 S233350AbiLES0s (ORCPT + 99 others); Mon, 5 Dec 2022 13:26:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232410AbiLESZS (ORCPT ); Mon, 5 Dec 2022 13:25:18 -0500 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 368D920BCA; Mon, 5 Dec 2022 10:25:17 -0800 (PST) Date: Mon, 05 Dec 2022 18:25:13 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1670264714; h=from:from:sender:sender:reply-to: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: in-reply-to:in-reply-to:references:references; bh=Il/CbdHu9pPpiZtWniggttxXh3zGtyvoQhyMRC2LCcw=; b=Nlo4ZNv2J8ClcIlmPHx8DWGX5kIKwdu0LmFBxGI49kps2Kur32WyIHu00xdfMtqI4nrt6W 8QBAb6fVQPxj7LyMtxRCZqNpgdmnqjqb3jsjS2DxVjaDtt//SWCbCih2peTz76JhTtZEAU uqjLXYBiBR3aZTdmVUqvx3SJIfnJmA9MPb8iJEIu36Kc++uvtUS3N6oQiktgd4nDhMigyv MwugoVpnioezZSWCcn+tNkY57RPP0pnKosYvI9CAEkauVMaz+AF2OCuTcaB/8HtcYCYddt VJsRGRxNKEkbXhFnPWeACCOajmNe1wJJ6+Z+FVdJgMPqBX9PVFWUxl8CYB6wcA== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1670264714; h=from:from:sender:sender:reply-to: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: in-reply-to:in-reply-to:references:references; bh=Il/CbdHu9pPpiZtWniggttxXh3zGtyvoQhyMRC2LCcw=; b=6puPcduO6SzC+Vl1KbloSzQssnzHX6TlevYWm0eIReo5elLB/VI6WLH/rwGszJDcTfmQef 2hFGtYYrkBA68yAQ== From: "tip-bot2 for Thomas Gleixner" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: irq/core] iommu/amd: Switch to MSI base domains Cc: Thomas Gleixner , Kevin Tian , Marc Zyngier , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20221124232326.209212272@linutronix.de> References: <20221124232326.209212272@linutronix.de> MIME-Version: 1.0 Message-ID: <167026471384.4906.14147282485402173941.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails 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?1750422204605415396?= X-GMAIL-MSGID: =?utf-8?q?1751399649680450097?= The following commit has been merged into the irq/core branch of tip: Commit-ID: eb7395d58b1c2c8d5ff76bc2b102d4300a68a67b Gitweb: https://git.kernel.org/tip/eb7395d58b1c2c8d5ff76bc2b102d4300a68a67b Author: Thomas Gleixner AuthorDate: Fri, 25 Nov 2022 00:26:10 +01:00 Committer: Thomas Gleixner CommitterDate: Mon, 05 Dec 2022 19:21:02 +01:00 iommu/amd: Switch to MSI base domains Remove the global PCI/MSI irqdomain implementation and provide the required MSI parent ops so the PCI/MSI code can detect the new parent and setup per device domains. Signed-off-by: Thomas Gleixner Reviewed-by: Kevin Tian Acked-by: Marc Zyngier Link: https://lore.kernel.org/r/20221124232326.209212272@linutronix.de --- arch/x86/kernel/apic/msi.c | 1 + drivers/iommu/amd/amd_iommu_types.h | 1 - drivers/iommu/amd/iommu.c | 19 +++++++++++++------ include/linux/irqdomain_defs.h | 1 + 4 files changed, 15 insertions(+), 7 deletions(-) diff --git a/arch/x86/kernel/apic/msi.c b/arch/x86/kernel/apic/msi.c index a8dccb0..d198da3 100644 --- a/arch/x86/kernel/apic/msi.c +++ b/arch/x86/kernel/apic/msi.c @@ -218,6 +218,7 @@ static bool x86_init_dev_msi_info(struct device *dev, struct irq_domain *domain, info->flags |= MSI_FLAG_NOMASK_QUIRK; break; case DOMAIN_BUS_DMAR: + case DOMAIN_BUS_AMDVI: break; default: WARN_ON_ONCE(1); diff --git a/drivers/iommu/amd/amd_iommu_types.h b/drivers/iommu/amd/amd_iommu_types.h index 1d0a70c..3d68419 100644 --- a/drivers/iommu/amd/amd_iommu_types.h +++ b/drivers/iommu/amd/amd_iommu_types.h @@ -734,7 +734,6 @@ struct amd_iommu { u8 max_counters; #ifdef CONFIG_IRQ_REMAP struct irq_domain *ir_domain; - struct irq_domain *msi_domain; struct amd_irte_ops *irte_ops; #endif diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 67e209c..7caccd8 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -815,7 +815,7 @@ amd_iommu_set_pci_msi_domain(struct device *dev, struct amd_iommu *iommu) !pci_dev_has_default_msi_parent_domain(to_pci_dev(dev))) return; - dev_set_msi_domain(dev, iommu->msi_domain); + dev_set_msi_domain(dev, iommu->ir_domain); } #else /* CONFIG_IRQ_REMAP */ @@ -3648,6 +3648,12 @@ static struct irq_chip amd_ir_chip = { .irq_compose_msi_msg = ir_compose_msi_msg, }; +static const struct msi_parent_ops amdvi_msi_parent_ops = { + .supported_flags = X86_VECTOR_MSI_FLAGS_SUPPORTED | MSI_FLAG_MULTI_PCI_MSI, + .prefix = "IR-", + .init_dev_msi_info = msi_parent_init_dev_msi_info, +}; + int amd_iommu_create_irq_domain(struct amd_iommu *iommu) { struct fwnode_handle *fn; @@ -3655,16 +3661,17 @@ int amd_iommu_create_irq_domain(struct amd_iommu *iommu) fn = irq_domain_alloc_named_id_fwnode("AMD-IR", iommu->index); if (!fn) return -ENOMEM; - iommu->ir_domain = irq_domain_create_tree(fn, &amd_ir_domain_ops, iommu); + iommu->ir_domain = irq_domain_create_hierarchy(arch_get_ir_parent_domain(), 0, 0, + fn, &amd_ir_domain_ops, iommu); if (!iommu->ir_domain) { irq_domain_free_fwnode(fn); return -ENOMEM; } - iommu->ir_domain->parent = arch_get_ir_parent_domain(); - iommu->msi_domain = arch_create_remap_msi_irq_domain(iommu->ir_domain, - "AMD-IR-MSI", - iommu->index); + irq_domain_update_bus_token(iommu->ir_domain, DOMAIN_BUS_AMDVI); + iommu->ir_domain->flags |= IRQ_DOMAIN_FLAG_MSI_PARENT; + iommu->ir_domain->msi_parent_ops = &amdvi_msi_parent_ops; + return 0; } diff --git a/include/linux/irqdomain_defs.h b/include/linux/irqdomain_defs.h index 3a09396..0b2d8a8 100644 --- a/include/linux/irqdomain_defs.h +++ b/include/linux/irqdomain_defs.h @@ -24,6 +24,7 @@ enum irq_domain_bus_token { DOMAIN_BUS_PCI_DEVICE_MSI, DOMAIN_BUS_PCI_DEVICE_MSIX, DOMAIN_BUS_DMAR, + DOMAIN_BUS_AMDVI, }; #endif /* _LINUX_IRQDOMAIN_DEFS_H */