From patchwork Thu Jan 28 11:37:55 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 75580 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.3/8.14.3) with ESMTP id o0SBg3oY008976 for ; Thu, 28 Jan 2010 11:42:03 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755807Ab0A1Llb (ORCPT ); Thu, 28 Jan 2010 06:41:31 -0500 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1754817Ab0A1Lie (ORCPT ); Thu, 28 Jan 2010 06:38:34 -0500 Received: from tx2ehsobe005.messaging.microsoft.com ([65.55.88.15]:28625 "EHLO TX2EHSOBE010.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754696Ab0A1Lic (ORCPT ); Thu, 28 Jan 2010 06:38:32 -0500 Received: from mail144-tx2-R.bigfish.com (10.9.14.250) by TX2EHSOBE010.bigfish.com (10.9.40.30) with Microsoft SMTP Server id 8.1.240.5; Thu, 28 Jan 2010 11:38:31 +0000 Received: from mail144-tx2 (localhost [127.0.0.1]) by mail144-tx2-R.bigfish.com (Postfix) with ESMTP id 86508B70D78; Thu, 28 Jan 2010 11:38:31 +0000 (UTC) X-SpamScore: 3 X-BigFish: VPS3(z2d9bozab9bh936eMzz1202hzzz32i6bh87h62h) X-Spam-TCS-SCL: 1:0 X-FB-DOMAIN-IP-MATCH: fail Received: from mail144-tx2 (localhost.localdomain [127.0.0.1]) by mail144-tx2 (MessageSwitch) id 126467871180335_758; Thu, 28 Jan 2010 11:38:31 +0000 (UTC) Received: from TX2EHSMHS023.bigfish.com (unknown [10.9.14.236]) by mail144-tx2.bigfish.com (Postfix) with ESMTP id 0062812F02C5; Thu, 28 Jan 2010 11:38:30 +0000 (UTC) Received: from ausb3extmailp02.amd.com (163.181.251.22) by TX2EHSMHS023.bigfish.com (10.9.99.123) with Microsoft SMTP Server (TLS) id 14.0.482.39; Thu, 28 Jan 2010 11:38:30 +0000 Received: from ausb3twp02.amd.com ([163.181.250.38]) by ausb3extmailp02.amd.com (Switch-3.2.7/Switch-3.2.7) with ESMTP id o0SBdo0I014266; Thu, 28 Jan 2010 05:39:53 -0600 X-WSS-ID: 0KWYGBW-02-6ZZ-02 X-M-MSG: Received: from sausexbh1.amd.com (sausexbh1.amd.com [163.181.22.101]) by ausb3twp02.amd.com (Tumbleweed MailGate 3.7.2) with ESMTP id 24AB5C84D7; Thu, 28 Jan 2010 05:38:19 -0600 (CST) Received: from sausexmb6.amd.com ([163.181.49.140]) by sausexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 28 Jan 2010 05:38:23 -0600 Received: from seurexmb1.amd.com ([165.204.9.130]) by sausexmb6.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 28 Jan 2010 05:38:22 -0600 Received: from lemmy.osrc.amd.com ([165.204.15.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 28 Jan 2010 12:38:20 +0100 Received: by lemmy.osrc.amd.com (Postfix, from userid 41430) id 98801C9B08; Thu, 28 Jan 2010 12:38:20 +0100 (CET) From: Joerg Roedel To: Avi Kivity , Marcelo Tosatti , David Woodhouse CC: kvm@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, Joerg Roedel Subject: [PATCH 04/11] VT-d: Change {un}map_range functions to implement {un}map interface Date: Thu, 28 Jan 2010 12:37:55 +0100 Message-ID: <1264678682-30655-5-git-send-email-joerg.roedel@amd.com> X-Mailer: git-send-email 1.6.6 In-Reply-To: <1264678682-30655-1-git-send-email-joerg.roedel@amd.com> References: <1264678682-30655-1-git-send-email-joerg.roedel@amd.com> X-OriginalArrivalTime: 28 Jan 2010 11:38:20.0742 (UTC) FILETIME=[645F1660:01CAA00E] MIME-Version: 1.0 X-Reverse-DNS: ausb3extmailp02.amd.com Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Thu, 28 Jan 2010 11:42:03 +0000 (UTC) diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index a714e3d..f1d3b85 100644 --- a/drivers/pci/intel-iommu.c +++ b/drivers/pci/intel-iommu.c @@ -3626,14 +3626,15 @@ static void intel_iommu_detach_device(struct iommu_domain *domain, domain_remove_one_dev_info(dmar_domain, pdev); } -static int intel_iommu_map_range(struct iommu_domain *domain, - unsigned long iova, phys_addr_t hpa, - size_t size, int iommu_prot) +static int intel_iommu_map(struct iommu_domain *domain, + unsigned long iova, phys_addr_t hpa, + int gfp_order, int iommu_prot) { struct dmar_domain *dmar_domain = domain->priv; u64 max_addr; int addr_width; int prot = 0; + size_t size; int ret; if (iommu_prot & IOMMU_READ) @@ -3643,6 +3644,7 @@ static int intel_iommu_map_range(struct iommu_domain *domain, if ((iommu_prot & IOMMU_CACHE) && dmar_domain->iommu_snooping) prot |= DMA_PTE_SNP; + size = 0x1000UL << gfp_order; max_addr = iova + size; if (dmar_domain->max_addr < max_addr) { int min_agaw; @@ -3669,19 +3671,19 @@ static int intel_iommu_map_range(struct iommu_domain *domain, return ret; } -static void intel_iommu_unmap_range(struct iommu_domain *domain, - unsigned long iova, size_t size) +static int intel_iommu_unmap(struct iommu_domain *domain, + unsigned long iova, int gfp_order) { struct dmar_domain *dmar_domain = domain->priv; - - if (!size) - return; + size_t size = 0x1000UL << gfp_order; dma_pte_clear_range(dmar_domain, iova >> VTD_PAGE_SHIFT, (iova + size - 1) >> VTD_PAGE_SHIFT); if (dmar_domain->max_addr == iova + size) dmar_domain->max_addr = iova; + + return gfp_order; } static phys_addr_t intel_iommu_iova_to_phys(struct iommu_domain *domain, @@ -3714,8 +3716,8 @@ static struct iommu_ops intel_iommu_ops = { .domain_destroy = intel_iommu_domain_destroy, .attach_dev = intel_iommu_attach_device, .detach_dev = intel_iommu_detach_device, - .map_range = intel_iommu_map_range, - .unmap_range = intel_iommu_unmap_range, + .map = intel_iommu_map, + .unmap = intel_iommu_unmap, .iova_to_phys = intel_iommu_iova_to_phys, .domain_has_cap = intel_iommu_domain_has_cap, };