Path: csiph.com!news.mixmin.net!news.unit0.net!news.panservice.it!bofh.it!news.nic.it!robomod From: Joerg Roedel Newsgroups: linux.kernel Subject: [PATCH 18/20] iommu/amd: Handle IOMMU_DOMAIN_DMA in ops->domain_free call-back Date: Fri, 08 Jul 2016 13:50:03 +0200 Message-ID: References: Dkim-Signature: v=1; a=rsa-sha256; c=simple/simple; d=8bytes.org; s=mail-1; t=1467978329; bh=s6DDIj1m61ZtGNOInm77exuDF52idbxQDKRPzjzNjUo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Winy3w6+Qw/8xuRs0c5OcSbnggbrRjwKY2SUwnCwIZAeE7EAUmpYsTWFjwAhCQPKK M1UgulpIzGalSHxvTTV/xF5OmamQ4y1rF2sj775O19EIrnq9sE1Exk8Q48keIvSJzm f9lGr83VtlLSsD4DhtiNctOweYsKjbjBm8FXNTK7U7NIc+h5Er7Lb/c+y7UW/3RIhS LaQvJlYmPS4ONYA4vETK7yfAJ/LfGF8bUukRIOmZduLrBX+fUXnhutAXbW2YjsUaF+ tfWSegTweew/qVHW4uDvW0FuLuAirYnXfK5NQkG8qCsIfaaxymeEeUsV2ySpCm/wiU h/z6kYx+cQV9g== X-Mailer: git-send-email 1.9.1 Sender: robomod@news.nic.it List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Approved: robomod@news.nic.it Lines: 59 Organization: linux.* mail to news gateway X-Original-Cc: linux-kernel@vger.kernel.org, Suravee Suthikulpanit , Vincent.Wan@amd.com, Joerg Roedel X-Original-Date: Fri, 8 Jul 2016 13:45:09 +0200 X-Original-Message-ID: <1467978311-28322-19-git-send-email-joro@8bytes.org> X-Original-References: <1467978311-28322-1-git-send-email-joro@8bytes.org> X-Original-Sender: linux-kernel-owner@vger.kernel.org Xref: csiph.com linux.kernel:1439357 From: Joerg Roedel This domain type is not yet handled in the iommu_ops->domain_free() call-back. Fix that. Fixes: 0bb6e243d7fb ('iommu/amd: Support IOMMU_DOMAIN_DMA type allocation') Cc: stable@vger.kernel.org # v4.2+ Signed-off-by: Joerg Roedel --- drivers/iommu/amd_iommu.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/drivers/iommu/amd_iommu.c b/drivers/iommu/amd_iommu.c index 4b17148..dc3dbb4 100644 --- a/drivers/iommu/amd_iommu.c +++ b/drivers/iommu/amd_iommu.c @@ -2836,9 +2836,7 @@ static struct iommu_domain *amd_iommu_domain_alloc(unsigned type) static void amd_iommu_domain_free(struct iommu_domain *dom) { struct protection_domain *domain; - - if (!dom) - return; + struct dma_ops_domain *dma_dom; domain = to_pdomain(dom); @@ -2847,13 +2845,24 @@ static void amd_iommu_domain_free(struct iommu_domain *dom) BUG_ON(domain->dev_cnt != 0); - if (domain->mode != PAGE_MODE_NONE) - free_pagetable(domain); + if (!dom) + return; - if (domain->flags & PD_IOMMUV2_MASK) - free_gcr3_table(domain); + switch (dom->type) { + case IOMMU_DOMAIN_DMA: + dma_dom = domain->priv; + dma_ops_domain_free(dma_dom); + break; + default: + if (domain->mode != PAGE_MODE_NONE) + free_pagetable(domain); - protection_domain_free(domain); + if (domain->flags & PD_IOMMUV2_MASK) + free_gcr3_table(domain); + + protection_domain_free(domain); + break; + } } static void amd_iommu_detach_device(struct iommu_domain *dom, -- 1.9.1