mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Joerg Roedel <joerg.roedel@amd.com>
To: mingo@redhat.com, tglx@linutronix.de
Cc: linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org,
	bhavna.sarathy@amd.com, robert.richter@amd.com,
	Joerg Roedel <joerg.roedel@amd.com>
Subject: [PATCH] x86 gart: replace to_pages macro with iommu_num_pages
Date: Fri, 25 Jul 2008 14:58:00 +0200	[thread overview]
Message-ID: <1216990680-1227-4-git-send-email-joerg.roedel@amd.com> (raw)
In-Reply-To: <1216990680-1227-1-git-send-email-joerg.roedel@amd.com>

This patch removes the to_pages macro from x86 GART code and calls the generic
iommu_num_pages function instead.

Signed-off-by: Joerg Roedel <joerg.roedel@amd.com>
---
 arch/x86/kernel/pci-gart_64.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/pci-gart_64.c b/arch/x86/kernel/pci-gart_64.c
index 1062dc1..31bc068 100644
--- a/arch/x86/kernel/pci-gart_64.c
+++ b/arch/x86/kernel/pci-gart_64.c
@@ -67,9 +67,6 @@ static u32 gart_unmapped_entry;
 	(((x) & 0xfffff000) | (((x) >> 32) << 4) | GPTE_VALID | GPTE_COHERENT)
 #define GPTE_DECODE(x) (((x) & 0xfffff000) | (((u64)(x) & 0xff0) << 28))
 
-#define to_pages(addr, size) \
-	(round_up(((addr) & ~PAGE_MASK) + (size), PAGE_SIZE) >> PAGE_SHIFT)
-
 #define EMERGENCY_PAGES 32 /* = 128KB */
 
 #ifdef CONFIG_AGP
@@ -241,7 +238,7 @@ nonforced_iommu(struct device *dev, unsigned long addr, size_t size)
 static dma_addr_t dma_map_area(struct device *dev, dma_addr_t phys_mem,
 				size_t size, int dir)
 {
-	unsigned long npages = to_pages(phys_mem, size);
+	unsigned long npages = iommu_num_pages(phys_mem, size);
 	unsigned long iommu_page = alloc_iommu(dev, npages);
 	int i;
 
@@ -304,7 +301,7 @@ static void gart_unmap_single(struct device *dev, dma_addr_t dma_addr,
 		return;
 
 	iommu_page = (dma_addr - iommu_bus_base)>>PAGE_SHIFT;
-	npages = to_pages(dma_addr, size);
+	npages = iommu_num_pages(dma_addr, size);
 	for (i = 0; i < npages; i++) {
 		iommu_gatt_base[iommu_page + i] = gart_unmapped_entry;
 		CLEAR_LEAK(iommu_page + i);
@@ -387,7 +384,7 @@ static int __dma_map_cont(struct device *dev, struct scatterlist *start,
 		}
 
 		addr = phys_addr;
-		pages = to_pages(s->offset, s->length);
+		pages = iommu_num_pages(s->offset, s->length);
 		while (pages--) {
 			iommu_gatt_base[iommu_page] = GPTE_ENCODE(addr);
 			SET_LEAK(iommu_page);
@@ -470,7 +467,7 @@ gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, int dir)
 
 		seg_size += s->length;
 		need = nextneed;
-		pages += to_pages(s->offset, s->length);
+		pages += iommu_num_pages(s->offset, s->length);
 		ps = s;
 	}
 	if (dma_map_cont(dev, start_sg, i - start, sgmap, pages, need) < 0)
-- 
1.5.3.7



  parent reply	other threads:[~2008-07-25 12:59 UTC|newest]

Thread overview: 40+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-25 12:57 [PATCH 0/3] IOMMU: move page number calculation to generic code Joerg Roedel
2008-07-25 12:57 ` [PATCH] add iommu_num_pages helper function Joerg Roedel
2008-07-25 13:15   ` FUJITA Tomonori
2008-07-25 13:21     ` Joerg Roedel
2008-07-25 13:34       ` FUJITA Tomonori
2008-07-25 13:41         ` Joerg Roedel
2008-07-25 13:57           ` FUJITA Tomonori
2008-07-25 14:14             ` Joerg Roedel
2008-07-25 14:32               ` FUJITA Tomonori
2008-07-26 13:41                 ` Ingo Molnar
2008-07-29  1:07                   ` Stephen Rothwell
2008-07-29  1:46                     ` FUJITA Tomonori
2008-07-29  3:56                       ` Stephen Rothwell
2008-07-29  4:38                         ` FUJITA Tomonori
2008-07-29  5:26                           ` David Miller
2008-07-29  5:42                             ` FUJITA Tomonori
2008-07-29  5:24                         ` David Miller
2008-07-29  5:42                           ` FUJITA Tomonori
2008-07-29  6:45                           ` Stephen Rothwell
2008-07-29  9:50                             ` Joerg Roedel
2008-07-29  9:58                               ` FUJITA Tomonori
2008-07-29 10:02                                 ` Joerg Roedel
2008-07-30 22:44                                   ` Benjamin Herrenschmidt
2008-07-31  2:07                                     ` FUJITA Tomonori
2008-07-29 10:10                               ` David Miller
2008-07-29 10:26                                 ` Joerg Roedel
2008-07-29 10:27                                 ` FUJITA Tomonori
2008-07-29 10:31                                   ` Ingo Molnar
2008-07-29 10:33                                     ` David Miller
2008-07-29 12:45                                       ` Stephen Rothwell
2008-07-30 12:18                                 ` Joerg Roedel
2008-07-30 13:16                                   ` FUJITA Tomonori
2008-07-30 14:03                                     ` Joerg Roedel
2008-07-30 18:52                                     ` Joerg Roedel
2008-07-30 22:44                                 ` Benjamin Herrenschmidt
2008-07-29 11:27                     ` Ingo Molnar
2008-07-29 15:45                       ` Jesse Barnes
2008-07-25 12:57 ` [PATCH] AMD IOMMU: replace to_pages macro with iommu_num_pages Joerg Roedel
2008-07-25 12:58 ` Joerg Roedel [this message]
2008-07-26 13:44 ` [PATCH 0/3] IOMMU: move page number calculation to generic code Ingo Molnar

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=1216990680-1227-4-git-send-email-joerg.roedel@amd.com \
    --to=joerg.roedel@amd.com \
    --cc=bhavna.sarathy@amd.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=robert.richter@amd.com \
    --cc=tglx@linutronix.de \
    /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

Powered by JetHome