Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp889238ybm; Wed, 27 May 2020 10:24:28 -0700 (PDT) X-Google-Smtp-Source: ABdhPJywXZBpODJxHEIwFO+tbmUkA4bFLXjrqlLJoBIIhvhNGSLVuDbCis7K3CJu6xeoYusDrCsv X-Received: by 2002:a50:d7d1:: with SMTP id m17mr12583496edj.126.1590600268236; Wed, 27 May 2020 10:24:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590600268; cv=none; d=google.com; s=arc-20160816; b=AgimXaB36hHokSXD+ANCBBnB7QDhC3PA3utRq1LIrCkSfmzwabsvrc5Rw+7Fdcr29v KPbMi4cgyR4OJomzSKY61V1d1X1s3aoszhanIIjLFqwq7A+5WfkO1QsJWPeNmvk2HZ9h lKrhZMrn5Ur/bnhoseDC0apOGfYV3QFjDbv10bEcHMMiXcdajDM84cQwY1VtdqN6VVNl f+c35lzq8WGgZ0j/hfToInafRl+wmNzy0M7E5a6cH9Mn6xXvqvlSizTGn0hBBKiTAIg/ AtJIAqC4060WkK7OEjll754sLhj/H6blgQNCyHOtyiMdhSbSg212emriremSCEg//zwU 7+xQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=9aLu6hu5rcPjfhQC/hqG+LbKA8OXkGjMyuXZFiq448k=; b=BxhJZVGvJagDLCg90BGkXnS7dol11RwlpZEqD6zXGCMaDH3po0SMRnoz7AdEKSbmzn ErOMRu08Zr25C8M2sS1kr4E0wRpkpXjmolY1I7O7y5yWLwX/sr3J/Gp3j/DxKIhhzmYS oaTgcPmak0taSZvWzWdUm8ZH/bFDCaG/d/tTZAWBt4TXb9QJNu3cMxHXuuKZ1hlYk5X3 ri9ChAtlgUBtqChTpzKouMcqE1uUCRpDA2JTGqacL4RvbPE2XGW7zL17Kdfl9KgV1Pmj hJybUYkGfBuTPXnb+Ot94wny1HQ6Nv5eX5RnkG3O2SHEfg5aqIcnafHQbX6n858TtUri UlFw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j26si2428055ejk.3.2020.05.27.10.24.05; Wed, 27 May 2020 10:24:28 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728993AbgE0Lxc (ORCPT + 99 others); Wed, 27 May 2020 07:53:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48366 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728723AbgE0Lx2 (ORCPT ); Wed, 27 May 2020 07:53:28 -0400 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F0A24C08C5C1 for ; Wed, 27 May 2020 04:53:27 -0700 (PDT) Received: by theia.8bytes.org (Postfix, from userid 1000) id 0045E475; Wed, 27 May 2020 13:53:23 +0200 (CEST) From: Joerg Roedel To: Joerg Roedel Cc: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org, Suravee Suthikulpanit , jroedel@suse.de Subject: [PATCH 05/10] iommu/amd: Free page-table in protection_domain_free() Date: Wed, 27 May 2020 13:53:08 +0200 Message-Id: <20200527115313.7426-6-joro@8bytes.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200527115313.7426-1-joro@8bytes.org> References: <20200527115313.7426-1-joro@8bytes.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Joerg Roedel Align release of the page-table with the place where it is allocated. Signed-off-by: Joerg Roedel --- drivers/iommu/amd/iommu.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/iommu/amd/iommu.c b/drivers/iommu/amd/iommu.c index 0d5a5dbee9f3..5282ff6b8ea0 100644 --- a/drivers/iommu/amd/iommu.c +++ b/drivers/iommu/amd/iommu.c @@ -2387,12 +2387,18 @@ static void cleanup_domain(struct protection_domain *domain) static void protection_domain_free(struct protection_domain *domain) { + struct domain_pgtable pgtable; + if (!domain) return; if (domain->id) domain_id_free(domain->id); + amd_iommu_domain_get_pgtable(domain, &pgtable); + atomic64_set(&domain->pt_root, 0); + free_pagetable(&pgtable); + kfree(domain); } @@ -2476,7 +2482,6 @@ static struct iommu_domain *amd_iommu_domain_alloc(unsigned type) static void amd_iommu_domain_free(struct iommu_domain *dom) { struct protection_domain *domain; - struct domain_pgtable pgtable; domain = to_pdomain(dom); @@ -2494,10 +2499,6 @@ static void amd_iommu_domain_free(struct iommu_domain *dom) dma_ops_domain_free(domain); break; default: - amd_iommu_domain_get_pgtable(domain, &pgtable); - atomic64_set(&domain->pt_root, 0); - free_pagetable(&pgtable); - if (domain->flags & PD_IOMMUV2_MASK) free_gcr3_table(domain); -- 2.17.1