[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1291677875-30493-12-git-send-email-konrad.wilk@oracle.com>
Date: Mon, 6 Dec 2010 18:24:23 -0500
From: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
To: airlied@...ux.ie, tglx@...utronix.de, hpa@...or.com,
airlied@...hat.com, linux-kernel@...r.kernel.org, konrad@...nel.org
Cc: Jeremy Fitzhardinge <jeremy@...p.org>,
Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
Subject: [PATCH 11/23] agp/serverworks: Utilize the PCI API for allocating/inserting pages.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>
---
drivers/char/agp/sworks-agp.c | 18 ++++++++++++------
1 files changed, 12 insertions(+), 6 deletions(-)
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c
index 13acaaf..494cc65 100644
--- a/drivers/char/agp/sworks-agp.c
+++ b/drivers/char/agp/sworks-agp.c
@@ -31,6 +31,7 @@
struct serverworks_page_map {
unsigned long *real;
unsigned long __iomem *remapped;
+ dma_addr_t dma_addr;
};
static struct _serverworks_private {
@@ -48,7 +49,10 @@ static int serverworks_create_page_map(struct serverworks_page_map *page_map)
{
int i;
- page_map->real = (unsigned long *) __get_free_page(GFP_KERNEL);
+ page_map->real = (unsigned long *)pci_alloc_consistent(serverworks_private.svrwrks_dev,
+ PAGE_SIZE,
+ &page_map->dma_addr);
+
if (page_map->real == NULL) {
return -ENOMEM;
}
@@ -66,7 +70,9 @@ static int serverworks_create_page_map(struct serverworks_page_map *page_map)
static void serverworks_free_page_map(struct serverworks_page_map *page_map)
{
set_memory_wb((unsigned long)page_map->real, 1);
- free_page((unsigned long) page_map->real);
+ pci_free_consistent(serverworks_private.svrwrks_dev, PAGE_SIZE,
+ (void *) page_map->real, page_map->dma_addr);
+ page_map->dma_addr = DMA_ERROR_CODE;
}
static void serverworks_free_gatt_pages(void)
@@ -155,7 +161,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
/* Create a fake scratch directory */
for (i = 0; i < 1024; i++) {
writel(agp_bridge->scratch_page, serverworks_private.scratch_dir.remapped+i);
- writel(virt_to_phys(serverworks_private.scratch_dir.real) | 1, page_dir.remapped+i);
+ writel(serverworks_private.scratch_dir.dma_addr | 1, page_dir.remapped+i);
}
retval = serverworks_create_gatt_pages(value->num_entries / 1024);
@@ -167,7 +173,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
agp_bridge->gatt_table_real = (u32 *)page_dir.real;
agp_bridge->gatt_table = (u32 __iomem *)page_dir.remapped;
- agp_bridge->gatt_bus_addr = virt_to_phys(page_dir.real);
+ agp_bridge->gatt_bus_addr = page_dir.dma_addr;
/* Get the address for the gart region.
* This is a bus address even on the alpha, b/c its
@@ -179,7 +185,7 @@ static int serverworks_create_gatt_table(struct agp_bridge_data *bridge)
/* Calculate the agp offset */
for (i = 0; i < value->num_entries / 1024; i++)
- writel(virt_to_phys(serverworks_private.gatt_pages[i]->real)|1, page_dir.remapped+i);
+ writel(serverworks_private.gatt_pages[i]->dma_addr|1, page_dir.remapped+i);
return 0;
}
@@ -350,7 +356,7 @@ static int serverworks_insert_memory(struct agp_memory *mem,
addr = (j * PAGE_SIZE) + agp_bridge->gart_bus_addr;
cur_gatt = SVRWRKS_GET_GATT(addr);
writel(agp_bridge->driver->mask_memory(agp_bridge,
- page_to_phys(mem->pages[i]), mem->type),
+ mem->dma_addr[i], mem->type),
cur_gatt+GET_GATT_OFF(addr));
}
serverworks_tlbflush(mem);
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists