From patchwork Thu Jun 13 13:24:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jan Beulich X-Patchwork-Id: 10991773 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 1C2B313AF for ; Thu, 13 Jun 2019 13:26:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0A51B2886C for ; Thu, 13 Jun 2019 13:26:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F235528BF3; Thu, 13 Jun 2019 13:26:05 +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 A770F2896F for ; Thu, 13 Jun 2019 13:26:05 +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 1hbPik-0001UW-O1; Thu, 13 Jun 2019 13:24:50 +0000 Received: from us1-rack-dfw2.inumbo.com ([104.130.134.6]) by lists.xenproject.org with esmtp (Exim 4.89) (envelope-from ) id 1hbPii-0001UE-V2 for xen-devel@lists.xenproject.org; Thu, 13 Jun 2019 13:24:48 +0000 X-Inumbo-ID: 9d77f425-8dde-11e9-8980-bc764e045a96 Received: from prv1-mh.provo.novell.com (unknown [137.65.248.33]) by us1-rack-dfw2.inumbo.com (Halon) with ESMTPS id 9d77f425-8dde-11e9-8980-bc764e045a96; Thu, 13 Jun 2019 13:24:47 +0000 (UTC) Received: from INET-PRV1-MTA by prv1-mh.provo.novell.com with Novell_GroupWise; Thu, 13 Jun 2019 07:24:47 -0600 Message-Id: <5D024E9C0200007800237E28@prv1-mh.provo.novell.com> X-Mailer: Novell GroupWise Internet Agent 18.1.1 Date: Thu, 13 Jun 2019 07:24:44 -0600 From: "Jan Beulich" To: "xen-devel" References: <5D024C500200007800237DD8@prv1-mh.provo.novell.com> In-Reply-To: <5D024C500200007800237DD8@prv1-mh.provo.novell.com> Mime-Version: 1.0 Content-Disposition: inline Subject: [Xen-devel] [PATCH 5/9] AMD/IOMMU: split amd_iommu_init_one() 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 , Suravee Suthikulpanit Errors-To: xen-devel-bounces@lists.xenproject.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP Mapping the MMIO space and obtaining feature information needs to happen slightly earlier, such that for x2APIC support we can set XTEn prior to calling amd_iommu_update_ivrs_mapping_acpi() and amd_iommu_setup_ioapic_remapping(). Signed-off-by: Jan Beulich Reviewed-by: Andrew Cooper --- a/xen/drivers/passthrough/amd/iommu_init.c +++ b/xen/drivers/passthrough/amd/iommu_init.c @@ -970,14 +970,6 @@ static void * __init allocate_ppr_log(st static int __init amd_iommu_init_one(struct amd_iommu *iommu) { - if ( map_iommu_mmio_region(iommu) != 0 ) - goto error_out; - - get_iommu_features(iommu); - - if ( iommu->features.raw ) - iommuv2_enabled = 1; - if ( allocate_cmd_buffer(iommu) == NULL ) goto error_out; @@ -1197,6 +1189,23 @@ static bool_t __init amd_sp5100_erratum2 return 0; } +static int __init amd_iommu_prepare_one(struct amd_iommu *iommu) +{ + int rc = alloc_ivrs_mappings(iommu->seg); + + if ( !rc ) + rc = map_iommu_mmio_region(iommu); + if ( rc ) + return rc; + + get_iommu_features(iommu); + + if ( iommu->features.raw ) + iommuv2_enabled = true; + + return 0; +} + int __init amd_iommu_init(void) { struct amd_iommu *iommu; @@ -1227,7 +1236,7 @@ int __init amd_iommu_init(void) radix_tree_init(&ivrs_maps); for_each_amd_iommu ( iommu ) { - rc = alloc_ivrs_mappings(iommu->seg); + rc = amd_iommu_prepare_one(iommu); if ( rc ) goto error_out; }