From patchwork Mon Feb 1 14:16:46 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joerg Roedel X-Patchwork-Id: 76080 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 o11EHWln018623 for ; Mon, 1 Feb 2010 14:17:32 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754731Ab0BAORG (ORCPT ); Mon, 1 Feb 2010 09:17:06 -0500 Received: from tx2ehsobe004.messaging.microsoft.com ([65.55.88.14]:14662 "EHLO TX2EHSOBE007.bigfish.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753297Ab0BAORE (ORCPT ); Mon, 1 Feb 2010 09:17:04 -0500 Received: from mail81-tx2-R.bigfish.com (10.9.14.244) by TX2EHSOBE007.bigfish.com (10.9.40.27) with Microsoft SMTP Server id 8.1.340.0; Mon, 1 Feb 2010 14:17:02 +0000 Received: from mail81-tx2 (localhost [127.0.0.1]) by mail81-tx2-R.bigfish.com (Postfix) with ESMTP id 9173413385B5; Mon, 1 Feb 2010 14:17:01 +0000 (UTC) X-SpamScore: -13 X-BigFish: VPS-13(z2d9bozab9bh1432R98dN936eMzz1202hzzz32i6bh87h61h) X-Spam-TCS-SCL: 0:0 X-FB-DOMAIN-IP-MATCH: fail Received: from mail81-tx2 (localhost.localdomain [127.0.0.1]) by mail81-tx2 (MessageSwitch) id 1265033820175434_26730; Mon, 1 Feb 2010 14:17:00 +0000 (UTC) Received: from TX2EHSMHS046.bigfish.com (unknown [10.9.14.240]) by mail81-tx2.bigfish.com (Postfix) with ESMTP id 222BC1910053; Mon, 1 Feb 2010 14:17:00 +0000 (UTC) Received: from ausb3extmailp02.amd.com (163.181.251.22) by TX2EHSMHS046.bigfish.com (10.9.99.146) with Microsoft SMTP Server (TLS) id 14.0.482.39; Mon, 1 Feb 2010 14:16:56 +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 o11EIWBe015438; Mon, 1 Feb 2010 08:18:35 -0600 X-WSS-ID: 0KX62BY-02-9XK-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 2CFFBC8702; Mon, 1 Feb 2010 08:16:46 -0600 (CST) Received: from sausexmb1.amd.com ([163.181.3.156]) by sausexbh1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 1 Feb 2010 08:16:50 -0600 Received: from seurexmb1.amd.com ([165.204.9.130]) by sausexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 1 Feb 2010 08:16:50 -0600 Received: from lemmy.osrc.amd.com ([165.204.15.93]) by seurexmb1.amd.com with Microsoft SMTPSVC(6.0.3790.3959); Mon, 1 Feb 2010 15:16:47 +0100 Received: by lemmy.osrc.amd.com (Postfix, from userid 41430) id ED23AC9AE6; Mon, 1 Feb 2010 15:16:46 +0100 (CET) Date: Mon, 1 Feb 2010 15:16:46 +0100 From: Joerg Roedel To: Joerg Roedel CC: David Woodhouse , iommu@lists.linux-foundation.org, Marcelo Tosatti , Avi Kivity , kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/11 v2] VT-d: Change {un}map_range functions to implement {un}map interface Message-ID: <20100201141646.GC16236@amd.com> References: <1264678682-30655-1-git-send-email-joerg.roedel@amd.com> <1264678682-30655-5-git-send-email-joerg.roedel@amd.com> <1264712382.9059.1109.camel@macbook.infradead.org> <20100129090526.GT17809@8bytes.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20100129090526.GT17809@8bytes.org> Organization: Advanced Micro Devices =?iso-8859-1?Q?GmbH?= =?iso-8859-1?Q?=2C_Karl-Hammerschmidt-Str=2E_34=2C_85609_Dornach_bei_M=FC?= =?iso-8859-1?Q?nchen=2C_Gesch=E4ftsf=FChrer=3A_Thomas_M=2E_McCoy=2C_Giuli?= =?iso-8859-1?Q?ano_Meroni=2C_Andrew_Bowd=2C_Sitz=3A_Dornach=2C_Gemeinde_A?= =?iso-8859-1?Q?schheim=2C_Landkreis_M=FCnchen=2C_Registergericht_M=FCnche?= =?iso-8859-1?Q?n=2C?= HRB Nr. 43632 User-Agent: Mutt/1.5.20 (2009-06-14) X-OriginalArrivalTime: 01 Feb 2010 14:16:47.0171 (UTC) FILETIME=[304C0930:01CAA349] 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]); Mon, 01 Feb 2010 14:17:32 +0000 (UTC) diff --git a/drivers/pci/intel-iommu.c b/drivers/pci/intel-iommu.c index a714e3d..371dc56 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 = PAGE_SIZE << 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 = PAGE_SIZE << 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, };