[PATCH 15/23] agp: Make agp_generic_insert_memory use the mem->dma_addr[i].

From: Konrad Rzeszutek Wilk
Date: Mon Dec 06 2010 - 18:26:37 EST


For platforms that are not using the PCI API the value
of dma_addr[i] is page_to_phys(mem->page[i]), which was
obtained by using the _agp_alloc_page macro.

This does mean that drivers that have their own .agp_create_page
functions and don't populate dma_addr[i] and use this
agp_generic_insert_memory need to have this right. Fortunatly,
all of the previous patches have done so. Just in case we have
a warning and end use the old mechanism to get the DMA address.

Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@xxxxxxxxxx>
---
drivers/char/agp/generic.c | 7 ++++++-
1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/drivers/char/agp/generic.c b/drivers/char/agp/generic.c
index 65fd7c7..4cf3f94 100644
--- a/drivers/char/agp/generic.c
+++ b/drivers/char/agp/generic.c
@@ -1142,8 +1142,13 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type)
}

for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
+ dma_addr_t dma_addr = mem->dma_addr[i];
+ if (dma_addr == DMA_ERROR_CODE) {
+ WARN_ONCE(1, "Caller hasn't converted to DMA API!\n");
+ dma_addr = page_to_phys(mem->pages[i]);
+ }
writel(bridge->driver->mask_memory(bridge,
- page_to_phys(mem->pages[i]),
+ dma_addr,
mask_type),
bridge->gatt_table+j);
}
--
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/