mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: airlied@linux.ie, tglx@linutronix.de, hpa@zytor.com,
	airlied@redhat.com, linux-kernel@vger.kernel.org,
	konrad@kernel.org
Cc: Jeremy Fitzhardinge <jeremy@goop.org>,
	Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH 03/23] agp: Introduce two new macros: _agp_[alloc|free]_page.
Date: Mon,  6 Dec 2010 18:24:15 -0500	[thread overview]
Message-ID: <1291677875-30493-4-git-send-email-konrad.wilk@oracle.com> (raw)
In-Reply-To: <1291677875-30493-1-git-send-email-konrad.wilk@oracle.com>

This macro will be used in the agp_generic_[alloc|destroy]_page[s|]
functions. Currently it does exactly what it replaces and also
saves the DMA address in dma_addr[] using the page_to_phys() macro.

These two macros can be at any time replaced with an implementation that
can utilize the PCI API.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 arch/alpha/include/asm/agp.h   |   14 ++++++++++++++
 arch/ia64/include/asm/agp.h    |   15 +++++++++++++++
 arch/parisc/include/asm/agp.h  |   15 +++++++++++++++
 arch/powerpc/include/asm/agp.h |   15 +++++++++++++++
 arch/sparc/include/asm/agp.h   |   14 ++++++++++++++
 arch/x86/include/asm/agp.h     |   14 ++++++++++++++
 6 files changed, 87 insertions(+), 0 deletions(-)

diff --git a/arch/alpha/include/asm/agp.h b/arch/alpha/include/asm/agp.h
index 0ee274c..41547e3 100644
--- a/arch/alpha/include/asm/agp.h
+++ b/arch/alpha/include/asm/agp.h
@@ -15,4 +15,18 @@
 #define free_gatt_pages(bridge, order)	\
 	free_pages((unsigned long)(bridge->gatt_table_real), (order))
 
+/* pages allocation. */
+#define _agp_alloc_page(bridge, dma_addr) \
+	({ \
+		struct page *_page = NULL; \
+		_page = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); \
+		if (_page) \
+			*dma_addr = page_to_phys(_page); \
+		_page; \
+	})
+#define _agp_free_page(bridge, page, dma_addr) \
+	({ \
+		__free_page(page); \
+		*dma_addr = DMA_ERROR_CODE; \
+	})
 #endif
diff --git a/arch/ia64/include/asm/agp.h b/arch/ia64/include/asm/agp.h
index 4e12b72..9107e97 100644
--- a/arch/ia64/include/asm/agp.h
+++ b/arch/ia64/include/asm/agp.h
@@ -23,4 +23,19 @@
 #define free_gatt_pages(bridge, order)	\
 	free_pages((unsigned long)(bridge->gatt_table_real), (order))
 
+/* pages allocation. */
+#define _agp_alloc_page(bridge, dma_addr) \
+	({ \
+		struct page *_page = NULL; \
+		_page = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); \
+		if (_page) \
+			*dma_addr = page_to_phys(_page); \
+		_page; \
+	})
+#define _agp_free_page(bridge, page, dma_addr) \
+	({ \
+		__free_page(page); \
+		*dma_addr = DMA_ERROR_CODE; \
+	})
+
 #endif /* _ASM_IA64_AGP_H */
diff --git a/arch/parisc/include/asm/agp.h b/arch/parisc/include/asm/agp.h
index 6e8fd98..1de4174 100644
--- a/arch/parisc/include/asm/agp.h
+++ b/arch/parisc/include/asm/agp.h
@@ -17,4 +17,19 @@
 #define free_gatt_pages(bridge, order)	\
 	free_pages((unsigned long)(bridge->gatt_table_real), (order))
 
+/* pages allocation. */
+#define _agp_alloc_page(bridge, dma_addr) \
+	({ \
+		struct page *_page = NULL; \
+		_page = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); \
+		if (_page) \
+			*dma_addr = page_to_phys(_page); \
+		_page; \
+	})
+#define _agp_free_page(bridge, page, dma_addr) \
+	({ \
+		__free_page(page); \
+		*dma_addr = DMA_ERROR_CODE; \
+	})
+
 #endif /* _ASM_PARISC_AGP_H */
diff --git a/arch/powerpc/include/asm/agp.h b/arch/powerpc/include/asm/agp.h
index 0996a43..cdfa8e7 100644
--- a/arch/powerpc/include/asm/agp.h
+++ b/arch/powerpc/include/asm/agp.h
@@ -14,5 +14,20 @@
 #define free_gatt_pages(bridge, order)	\
 	free_pages((unsigned long)(bridge->gatt_table_real), (order))
 
+/* pages allocation. */
+#define _agp_alloc_page(bridge, dma_addr) \
+	({ \
+		struct page *_page = NULL; \
+		_page = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); \
+		if (_page) \
+			*dma_addr = page_to_phys(_page); \
+		_page; \
+	})
+#define _agp_free_page(bridge, page, dma_addr) \
+	({ \
+		__free_page(page); \
+		*dma_addr = DMA_ERROR_CODE; \
+	})
+
 #endif /* __KERNEL__ */
 #endif	/* _ASM_POWERPC_AGP_H */
diff --git a/arch/sparc/include/asm/agp.h b/arch/sparc/include/asm/agp.h
index 2a83241..b0cd187 100644
--- a/arch/sparc/include/asm/agp.h
+++ b/arch/sparc/include/asm/agp.h
@@ -13,4 +13,18 @@
 #define free_gatt_pages(bridge, order)	\
 	free_pages((unsigned long)(bridge->gatt_table_real), (order))
 
+/* pages allocation. */
+#define _agp_alloc_page(bridge, dma_addr) \
+	({ \
+		struct page *_page = NULL; \
+		_page = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); \
+		if (_page) \
+			*dma_addr = page_to_phys(_page); \
+		_page; \
+	})
+#define _agp_free_page(bridge, page, dma_addr) \
+	({ \
+		__free_page(page); \
+		*dma_addr = DMA_ERROR_CODE; \
+	})
 #endif
diff --git a/arch/x86/include/asm/agp.h b/arch/x86/include/asm/agp.h
index cbc996d..72e7179 100644
--- a/arch/x86/include/asm/agp.h
+++ b/arch/x86/include/asm/agp.h
@@ -28,4 +28,18 @@
 #define free_gatt_pages(bridge, order)	\
 	free_pages((unsigned long)(bridge->gatt_table_real), (order))
 
+/* pages allocation. */
+#define _agp_alloc_page(bridge, dma_addr) \
+	({ \
+		struct page *_page = NULL; \
+		_page = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO); \
+		if (_page) \
+			*dma_addr = page_to_phys(_page); \
+		_page; \
+	})
+#define _agp_free_page(bridge, page, dma_addr) \
+	({ \
+		__free_page(page); \
+		*dma_addr = DMA_ERROR_CODE; \
+	})
 #endif /* _ASM_X86_AGP_H */
-- 
1.7.1


  parent reply	other threads:[~2010-12-06 23:27 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-12-06 23:24 [RFC PATCH] Utilize the PCI API in the AGP framework Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 01/23] agp: Add bridge argument to [free|alloc]_gatt_pages macro Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 02/23] agp: Add dma_addr array in struct agp_memory Konrad Rzeszutek Wilk
2010-12-06 23:24 ` Konrad Rzeszutek Wilk [this message]
2010-12-06 23:24 ` [PATCH 04/23] agp: Make agp_generic_[alloc|destroy]_pages use the _agp_[alloc|free]_page macro Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 05/23] agp: Make agp_generic_[alloc|destroy]_page use " Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 06/23] agp/ali: Use the dma_addr instead of page_to_phys for m1541_[alloc|destroy]_page Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 07/23] agp/nvidia: Use the dma_addr[] instead of page_to_phys when inserting Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 08/23] agp/amd64: Use the dma_addr[] and gatt_bus_addr instead of [page|virt]_to_phys respectivly Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 09/23] agp/amd-k7: Utilize the PCI API for creating/inserting pages Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 10/23] ati/agp: " Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 11/23] agp/serverworks: Utilize the PCI API for allocating/inserting pages Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 12/23] agp/intel-gtt: Utilize the PCI DMA for i8xxx, Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 13/23] ia64/agp/zx1: Use PCI API for inserting pages in HP's ZX1 AGP device Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 14/23] ia64/agp/i460: Use PCI API for inserting pages in DIG (non-VT-d) platforms Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 15/23] agp: Make agp_generic_insert_memory use the mem->dma_addr[i] Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 16/23] agp: save the size of GATT table Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 17/23] agp: Make agp_generic_[create|free]_gatt_table be aware of PCI API Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 18/23] agp/x86: Make agp_generic_* use " Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 19/23] ia64/sgi: fix compile error Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 20/23] ia64: Add DMA_ERROR_CODE define Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 21/23] agp/sgi: Use PCI API for inserting/creating pages on SGI Altix Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 22/23] ia64/agp: Make agp_generic_* use PCI API Konrad Rzeszutek Wilk
2010-12-06 23:24 ` [PATCH 23/23] agp/generic: Set the dma_addr[i] to DMA_ERROR_CODE Konrad Rzeszutek Wilk
2010-12-07  0:02 ` [RFC PATCH] Utilize the PCI API in the AGP framework Dave Airlie
2010-12-07  0:48   ` Konrad Rzeszutek Wilk
2010-12-07  1:16     ` Dave Airlie
2010-12-07  2:12       ` Konrad Rzeszutek Wilk
2010-12-08 16:45         ` Konrad Rzeszutek Wilk

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=1291677875-30493-4-git-send-email-konrad.wilk@oracle.com \
    --to=konrad.wilk@oracle.com \
    --cc=airlied@linux.ie \
    --cc=airlied@redhat.com \
    --cc=hpa@zytor.com \
    --cc=jeremy@goop.org \
    --cc=konrad@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --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

all inboxes | Powered by JetHome®