From patchwork Mon Apr 8 11:16:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 10889325 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7806317E0 for ; Mon, 8 Apr 2019 11:18:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5407E2863C for ; Mon, 8 Apr 2019 11:18:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4720328650; Mon, 8 Apr 2019 11:18:59 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-5.2 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D59A02863C for ; Mon, 8 Apr 2019 11:18:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hDSGu-0001jr-Us; Mon, 08 Apr 2019 11:17:04 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hDSGt-0001jm-AM for xen-devel@lists.xenproject.org; Mon, 08 Apr 2019 11:17:03 +0000 X-Inumbo-ID: d4f12040-59ef-11e9-92d7-bc764e045a96 Received: from prv1-mh.provo.novell.com (unknown [137.65.248.33]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id d4f12040-59ef-11e9-92d7-bc764e045a96; Mon, 08 Apr 2019 11:17:02 +0000 (UTC) Received: from INET-PRV1-MTA by prv1-mh.provo.novell.com with Novell_GroupWise; Mon, 08 Apr 2019 05:17:01 -0600 Message-Id: <5CAB2DAA02000078002254F3@prv1-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 18.1.0 Date: Mon, 08 Apr 2019 05:16:58 -0600 From: "Jan Beulich" To: "xen-devel" Mime-Version: 1.0 Content-Disposition: inline Subject: [Xen-devel] [PATCH] x86/IOMMU: abstract Intel-specific adjust_vtd_irq_affinities() X-BeenThere: xen-devel@lists.xenproject.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Cc: Andrew Cooper , Kevin Tian , Wei Liu , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP This can't be folded into the resume hook, as that runs before bringin back up APs, but the affinity adjustment wants to happen with all CPUs back online. Hence a separate hook is needed such that AMD can then leverage it as well. Signed-off-by: Jan Beulich Reviewed-by: Kevin Tian Reviewed-by: Andrew Cooper --- a/xen/arch/x86/acpi/power.c +++ b/xen/arch/x86/acpi/power.c @@ -275,7 +275,7 @@ static int enter_state(u32 state) mtrr_aps_sync_begin(); enable_nonboot_cpus(); mtrr_aps_sync_end(); - adjust_vtd_irq_affinities(); + iommu_adjust_irq_affinities(); acpi_dmar_zap(); thaw_domains(); system_state = SYS_STATE_active; --- a/xen/drivers/passthrough/vtd/iommu.c +++ b/xen/drivers/passthrough/vtd/iommu.c @@ -2141,7 +2141,7 @@ static void adjust_irq_affinity(struct a dma_msi_set_affinity(irq_to_desc(drhd->iommu->msi.irq), cpumask); } -int adjust_vtd_irq_affinities(void) +static int adjust_vtd_irq_affinities(void) { struct acpi_drhd_unit *drhd; @@ -2725,6 +2725,7 @@ const struct iommu_ops __initconstrel in .read_apic_from_ire = io_apic_read_remap_rte, .read_msi_from_ire = msi_msg_read_remap_rte, .setup_hpet_msi = intel_setup_hpet_msi, + .adjust_irq_affinities = adjust_vtd_irq_affinities, .suspend = vtd_suspend, .resume = vtd_resume, .share_p2m = iommu_set_pgd, --- a/xen/include/asm-x86/iommu.h +++ b/xen/include/asm-x86/iommu.h @@ -81,8 +81,14 @@ void iommu_update_ire_from_apic(unsigned unsigned int iommu_read_apic_from_ire(unsigned int apic, unsigned int reg); int iommu_setup_hpet_msi(struct msi_desc *); +static inline int iommu_adjust_irq_affinities(void) +{ + return iommu_ops.adjust_irq_affinities + ? iommu_ops.adjust_irq_affinities() + : 0; +} + /* While VT-d specific, this must get declared in a generic header. */ -int adjust_vtd_irq_affinities(void); int __must_check iommu_pte_flush(struct domain *d, u64 gfn, u64 *pte, int order, int present); --- a/xen/include/xen/iommu.h +++ b/xen/include/xen/iommu.h @@ -224,7 +224,10 @@ struct iommu_ops { void (*update_ire_from_apic)(unsigned int apic, unsigned int reg, unsigned int value); unsigned int (*read_apic_from_ire)(unsigned int apic, unsigned int reg); + int (*setup_hpet_msi)(struct msi_desc *); + + int (*adjust_irq_affinities)(void); #endif /* CONFIG_X86 */ int __must_check (*suspend)(void);