From patchwork Thu Mar 28 14:49:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 10875077 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 5793E186D for ; Thu, 28 Mar 2019 14:51:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3B37528D6F for ; Thu, 28 Mar 2019 14:51:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 36F3428DB8; Thu, 28 Mar 2019 14:51:53 +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 D92AE28DF9 for ; Thu, 28 Mar 2019 14:51:51 +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 1h9WM2-0008GF-UA; Thu, 28 Mar 2019 14:50:06 +0000 Received: from all-amaz-eas1.inumbo.com ([34.197.232.57] helo=us1-amaz-eas2.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1h9WM1-00088p-Hp for xen-devel@lists.xenproject.org; Thu, 28 Mar 2019 14:50:05 +0000 X-Inumbo-ID: c4122596-5168-11e9-b8d3-6f5cfe7c30e2 Received: from prv1-mh.provo.novell.com (unknown [137.65.248.33]) by us1-amaz-eas2.inumbo.com (Halon) with ESMTPS id c4122596-5168-11e9-b8d3-6f5cfe7c30e2; Thu, 28 Mar 2019 14:50:02 +0000 (UTC) Received: from INET-PRV1-MTA by prv1-mh.provo.novell.com with Novell_GroupWise; Thu, 28 Mar 2019 08:50:01 -0600 Message-Id: <5C9CDF140200007800222844@prv1-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 18.1.0 Date: Thu, 28 Mar 2019 08:49:56 -0600 From: "Jan Beulich" To: "xen-devel" References: <5C9CDDAF020000780022282A@prv1-mh.provo.novell.com> In-Reply-To: <5C9CDDAF020000780022282A@prv1-mh.provo.novell.com> Mime-Version: 1.0 Content-Disposition: inline Subject: [Xen-devel] [PATCH 3/7] x86/ACPI: also parse AMD IOMMU tables early 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 , Brian Woods , Wei Liu , Suravee Suthikulpanit , Roger Pau Monne Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP In order to be able to initialize x2APIC mode we need to parse respective ACPI tables early. Split amd_iov_detect() into two parts for this purpose, and call the initial part earlier on. Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper Acked-by: Brian Woods --- a/xen/arch/x86/acpi/boot.c +++ b/xen/arch/x86/acpi/boot.c @@ -733,7 +733,7 @@ int __init acpi_boot_init(void) acpi_mmcfg_init(); - acpi_dmar_init(); + acpi_iommu_init(); erst_init(); --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include #include "../ats.h" @@ -170,7 +171,7 @@ static void amd_iommu_setup_domain_devic } } -int __init amd_iov_detect(void) +int __init acpi_ivrs_init(void) { INIT_LIST_HEAD(&amd_iommu_head); @@ -184,6 +185,14 @@ int __init amd_iov_detect(void) return -ENODEV; } + return 0; +} + +int __init amd_iov_detect(void) +{ + if ( !iommu_enable && !iommu_intremap ) + return 0; + iommu_ops = amd_iommu_ops; if ( amd_iommu_init() != 0 ) --- a/xen/include/asm-x86/acpi.h +++ b/xen/include/asm-x86/acpi.h @@ -26,6 +26,7 @@ #include #include #include +#include #define COMPILER_DEPENDENT_INT64 long long #define COMPILER_DEPENDENT_UINT64 unsigned long long @@ -145,6 +146,15 @@ extern u32 pmtmr_ioport; extern unsigned int pmtmr_width; int acpi_dmar_init(void); +int acpi_ivrs_init(void); + +static inline int acpi_iommu_init(void) +{ + int ret = acpi_dmar_init(); + + return ret == -ENODEV ? acpi_ivrs_init() : ret; +} + void acpi_mmcfg_init(void); /* Incremented whenever we transition through S3. Value is 1 during boot. */