linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joerg Roedel <joerg.roedel@amd.com>
To: Joerg Roedel <joro@8bytes.org>
Cc: David Woodhouse <dwmw2@infradead.org>,
	iommu@lists.linux-foundation.org,
	Marcelo Tosatti <mtosatti@redhat.com>,
	Avi Kivity <avi@redhat.com>,
	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
Date: Mon, 1 Feb 2010 15:16:46 +0100	[thread overview]
Message-ID: <20100201141646.GC16236@amd.com> (raw)
In-Reply-To: <20100129090526.GT17809@8bytes.org>

On Fri, Jan 29, 2010 at 10:05:26AM +0100, Joerg Roedel wrote:
> > Um, that's not a page-size based interface. Page size isn't always 4KiB;
> > this code runs on IA64 too.
> > 
> > We have enough fun with CPU vs. DMA page size on IA64 already :)
> 
> Ah right. So this should be
> 
> 	size     = PAGE_SIZE << gfp_order;
> 
> Right? The interface is meant to map the same amount of memory which
> alloc_pages(gfp_order) would return. Same for the return value of the
> unmap function.

Ok, here is an updated patch (also updated in the iommu/largepage
branch). Does it look ok to you David?

>From a3ef8393d8027c795709e11b2f57c6013d2474a6 Mon Sep 17 00:00:00 2001
From: Joerg Roedel <joerg.roedel@amd.com>
Date: Wed, 20 Jan 2010 17:17:37 +0100
Subject: [PATCH 04/11] VT-d: Change {un}map_range functions to implement {un}map interface

This patch changes the iommu-api functions for mapping and
unmapping page ranges to use the new page-size based
interface. This allows to remove the range based functions
later.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 drivers/pci/intel-iommu.c |   22 ++++++++++++----------
 1 files changed, 12 insertions(+), 10 deletions(-)

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,
 };
-- 
1.6.6



  reply	other threads:[~2010-02-01 14:17 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-01-28 11:37 [PATCH 0/11] Large Page Support for IOMMU-API and KVM Joerg Roedel
2010-01-28 11:37 ` [PATCH 01/11] iommu-api: Rename ->{un}map function pointers to ->{un}map_range Joerg Roedel
2010-01-28 11:37 ` [PATCH 02/11] iommu-api: Add iommu_map and iommu_unmap functions Joerg Roedel
2010-02-07  9:38   ` Avi Kivity
2010-02-07 10:50     ` Joerg Roedel
2010-02-07 10:52       ` Avi Kivity
2010-01-28 11:37 ` [PATCH 03/11] iommu-api: Add ->{un}map callbacks to iommu_ops Joerg Roedel
2010-01-28 11:37 ` [PATCH 04/11] VT-d: Change {un}map_range functions to implement {un}map interface Joerg Roedel
2010-01-28 20:59   ` David Woodhouse
2010-01-29  9:05     ` Joerg Roedel
2010-02-01 14:16       ` Joerg Roedel [this message]
2010-02-05 11:00         ` [PATCH 04/11 v2] " Joerg Roedel
2010-01-28 11:37 ` [PATCH 05/11] kvm: Introduce kvm_host_page_size Joerg Roedel
2010-02-07 12:09   ` Avi Kivity
2010-02-07 14:13     ` Joerg Roedel
2010-01-28 11:37 ` [PATCH 06/11] kvm: Change kvm_iommu_map_pages to map large pages Joerg Roedel
2010-01-28 22:24   ` Marcelo Tosatti
2010-01-29  9:32     ` Joerg Roedel
2010-02-01 14:18       ` Joerg Roedel
2010-02-01 19:30         ` Marcelo Tosatti
2010-02-05 11:01           ` Joerg Roedel
2010-02-07 12:22             ` Avi Kivity
2010-02-07 12:41               ` Joerg Roedel
2010-02-07 12:18     ` Avi Kivity
2010-02-07 18:41       ` Marcelo Tosatti
2010-02-08  9:24         ` Avi Kivity
2010-01-28 11:37 ` [PATCH 07/11] x86/amd-iommu: Make iommu_map_page and alloc_pte aware of page sizes Joerg Roedel
2010-01-28 11:37 ` [PATCH 08/11] x86/amd-iommu: Make iommu_unmap_page and fetch_pte " Joerg Roedel
2010-01-28 11:38 ` [PATCH 09/11] x86/amd-iommu: Make amd_iommu_iova_to_phys aware of multiple " Joerg Roedel
2010-01-28 11:38 ` [PATCH 10/11] x86/amd-iommu: Implement ->{un}map callbacks for iommu-api Joerg Roedel
2010-01-28 11:38 ` [PATCH 11/11] iommu-api: Remove iommu_{un}map_range functions Joerg Roedel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100201141646.GC16236@amd.com \
    --to=joerg.roedel@amd.com \
    --cc=avi@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mtosatti@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).