[PATCH 02/23] agp: Add dma_addr array in struct agp_memory.

From: Konrad Rzeszutek Wilk
Date: Mon Dec 06 2010 - 18:28:00 EST


We are expanding the 'struct agp_memory' with an extra array
of dma_addr_t values. They correspond 1-to-1 to the page* array.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
drivers/char/agp/generic.c | 9 +++++++--
include/linux/agp_backend.h | 4 +++-
2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 09332ba..bcefc66 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -97,11 +97,14 @@ EXPORT_SYMBOL(agp_flush_chipset);
void agp_alloc_page_array(size_t size, struct agp_memory *mem)
{
mem->pages = NULL;
-
- if (size <= 2*PAGE_SIZE)
+ mem->dma_addr = NULL;
+ if (size <= 2*PAGE_SIZE) {
mem->pages = kmalloc(size, GFP_KERNEL | __GFP_NOWARN);
+ mem->dma_addr = kmalloc(size, GFP_KERNEL | __GFP_NOWARN);
+ }
if (mem->pages == NULL) {
mem->pages = vmalloc(size);
+ mem->dma_addr = vmalloc(size);
}
}
EXPORT_SYMBOL(agp_alloc_page_array);
@@ -110,8 +113,10 @@ void agp_free_page_array(struct agp_memory *mem)
{
if (is_vmalloc_addr(mem->pages)) {
vfree(mem->pages);
+ vfree(mem->dma_addr);
} else {
kfree(mem->pages);
+ kfree(mem->dma_addr);
}
}
EXPORT_SYMBOL(agp_free_page_array);
diff --git a/include/linux/agp_backend.h b/include/linux/agp_backend.h
index 09ea4a1..1d0d73f 100644
--- a/include/linux/agp_backend.h
+++ b/include/linux/agp_backend.h
@@ -81,9 +81,11 @@ struct agp_memory {
bool is_flushed;
/* list of agp_memory mapped to the aperture */
struct list_head mapped_list;
- /* DMA-mapped addresses */
+ /* DMA-mapped addresses (exclusivly used by intel-gtt) */
struct scatterlist *sg_list;
int num_sg;
+ /* DMA address for pages. */
+ dma_addr_t *dma_addr;
};

#define AGP_NORMAL_MEMORY 0
--
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/