summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2006-10-18 16:33:48 +0200
committerThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2006-10-18 16:33:48 +0200
commitfcb3895a69516d0b3c93319fb8755097be81e5a9 (patch)
treec2649ef0b481f2f60755ba1af88f0c7738173ae8
parente8b1faef7798d6dee88c16e7b9949c45792560bf (diff)
Bugfixes and cleanups.
-rw-r--r--agp.h32
-rw-r--r--frontend.c3
-rw-r--r--generic.c276
-rw-r--r--intel-agp.c274
4 files changed, 243 insertions, 342 deletions
diff --git a/agp.h b/agp.h
index 4a72018..4636f10 100644
--- a/agp.h
+++ b/agp.h
@@ -29,6 +29,17 @@
#ifndef _AGP_BACKEND_PRIV_H
#define _AGP_BACKEND_PRIV_H 1
+/*
+ * Remove this for kernel update.
+ */
+
+
+#ifndef AGP_USER_TYPES
+#define AGP_USER_TYPES (1 << 16)
+#define AGP_USER_MEMORY (AGP_USER_TYPES)
+#define AGP_USER_CACHED_MEMORY (AGP_USER_TYPES + 1)
+#endif
+
#include <asm/agp.h> /* for flush_agp_cache() */
#include <linux/version.h>
@@ -116,6 +127,7 @@ struct agp_bridge_driver {
void (*free_by_type)(struct agp_memory *);
void *(*agp_alloc_page)(struct agp_bridge_data *);
void (*agp_destroy_page)(void *);
+ int (*agp_type_to_mask_type) (struct agp_bridge_data *, int);
};
struct agp_bridge_data {
@@ -265,8 +277,8 @@ u32 agp_collect_device_status(struct agp_bridge_data *bridge,
unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge,
unsigned long addr, int type);
-
-
+int agp_generic_type_to_mask_type(struct agp_bridge_data *bridge,
+ int type);
struct agp_memory *agp_create_memory(int scratch_pages);
int agp_generic_insert_memory(struct agp_memory *mem, off_t pg_start, int type);
int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type);
@@ -352,4 +364,20 @@ extern int agp_try_unsupported_boot;
#define AGP_ERRATA_SBA 1<<1
#define AGP_ERRATA_1X 1<<2
+static inline struct agp_bridge_data *agp_get_bridge(struct agp_memory *curr)
+{
+ struct agp_bridge_data *bridge;
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
+ bridge = agp_bridge;
+ if (bridge->type == NOT_SUPPORTED)
+ return NULL;
+#else
+ if (!curr)
+ return NULL;
+
+ bridge = curr->bridge;
+#endif
+ return bridge;
+}
#endif /* _AGP_BACKEND_PRIV_H */
diff --git a/frontend.c b/frontend.c
index 6dd7acb..ae09880 100644
--- a/frontend.c
+++ b/frontend.c
@@ -968,6 +968,9 @@ static int agpioc_allocate_wrap(struct agp_file_private *priv, void __user *arg)
if (copy_from_user(&alloc, arg, sizeof(struct agp_allocate)))
return -EFAULT;
+ if (alloc.type >= AGP_USER_TYPES)
+ return -EINVAL;
+
memory = agp_allocate_memory_wrap(alloc.pg_count, alloc.type);
if (memory == NULL)
diff --git a/generic.c b/generic.c
index cc389b2..616ce25 100644
--- a/generic.c
+++ b/generic.c
@@ -100,6 +100,45 @@ static int agp_get_key(void)
return -1;
}
+/*
+ * Use kmalloc if possible for the page list. Otherwise fall back to
+ * vmalloc. This speeds things up and also saves memory for small AGP
+ * regions.
+ */
+
+static struct agp_memory *agp_create_user_memory(unsigned long num_agp_pages)
+{
+ struct agp_memory *new;
+ unsigned long alloc_size = num_agp_pages*sizeof(struct page *);
+
+ new = kmalloc(sizeof(struct agp_memory), GFP_KERNEL);
+
+ if (new == NULL)
+ return NULL;
+
+ memset(new, 0, sizeof(struct agp_memory));
+ new->key = agp_get_key();
+
+ if (new->key < 0) {
+ kfree(new);
+ return NULL;
+ }
+
+ if (alloc_size <= 4*PAGE_SIZE) {
+ new->memory = kmalloc(alloc_size, GFP_KERNEL);
+ }
+ if (new->memory == NULL) {
+ new->memory = vmalloc(alloc_size);
+ }
+ if (new->memory == NULL) {
+ agp_free_key(new->key);
+ kfree(new);
+ return NULL;
+ }
+ new->num_scratch_pages = 0;
+ return new;
+}
+
struct agp_memory *agp_create_memory(int scratch_pages)
{
@@ -140,31 +179,26 @@ EXPORT_SYMBOL(agp_create_memory);
void agp_free_memory(struct agp_memory *curr)
{
size_t i;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- if (agp_bridge->type == NOT_SUPPORTED)
- return;
-#endif
- if (curr == NULL)
+ struct agp_bridge_data *bridge = agp_get_bridge(curr);
+
+ if (bridge == NULL)
return;
if (curr->is_bound == TRUE)
agp_unbind_memory(curr);
+ if (curr->type >= AGP_USER_TYPES) {
+ agp_generic_free_user(curr);
+ return;
+ }
+
if (curr->type != 0) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- agp_bridge->driver->free_by_type(curr);
-#else
- curr->bridge->driver->free_by_type(curr);
-#endif
+ bridge->driver->free_by_type(curr);
return;
}
if (curr->page_count != 0) {
for (i = 0; i < curr->page_count; i++) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- agp_bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[i]));
-#else
- curr->bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[i]));
-#endif
+ bridge->driver->agp_destroy_page(gart_to_virt(curr->memory[i]));
}
}
agp_free_key(curr->key);
@@ -211,6 +245,15 @@ struct agp_memory *agp_allocate_memory(struct agp_bridge_data *bridge,
if ((atomic_read(&bridge->current_memory_agp) + page_count) > bridge->max_memory_agp)
return NULL;
+ if (type >= AGP_USER_TYPES) {
+ new = agp_generic_alloc_user(page_count, type);
+#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
+ if (new)
+ new->bridge = bridge;
+#endif
+ return new;
+ }
+
if (type != 0) {
new = bridge->driver->alloc_by_type(page_count, type);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,12)
@@ -228,11 +271,8 @@ struct agp_memory *agp_allocate_memory(struct agp_bridge_data *bridge,
return NULL;
for (i = 0; i < page_count; i++) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- void *addr = bridge->driver->agp_alloc_page();
-#else
void *addr = bridge->driver->agp_alloc_page(bridge);
-#endif
+
if (addr == NULL) {
agp_free_memory(new);
return NULL;
@@ -392,14 +432,9 @@ EXPORT_SYMBOL(agp_copy_info);
int agp_bind_memory(struct agp_memory *curr, off_t pg_start)
{
int ret_val;
- struct agp_bridge_data *bridge;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- if (agp_bridge->type == NOT_SUPPORTED)
- return -EINVAL;
-#endif
+ struct agp_bridge_data *bridge = agp_get_bridge(curr);
- if (curr == NULL)
+ if (bridge == NULL)
return -EINVAL;
if (curr->is_bound == TRUE) {
@@ -407,11 +442,6 @@ int agp_bind_memory(struct agp_memory *curr, off_t pg_start)
return -EINVAL;
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- bridge = agp_bridge;
-#else
- bridge = curr->bridge;
-#endif
if (curr->is_flushed == FALSE) {
bridge->driver->cache_flush();
curr->is_flushed = TRUE;
@@ -439,14 +469,9 @@ EXPORT_SYMBOL(agp_bind_memory);
int agp_unbind_memory(struct agp_memory *curr)
{
int ret_val;
- struct agp_bridge_data *bridge;
+ struct agp_bridge_data *bridge = agp_get_bridge(curr);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- if (agp_bridge->type == NOT_SUPPORTED)
- return -EINVAL;
-#endif
-
- if (curr == NULL)
+ if (bridge == NULL)
return -EINVAL;
if (curr->is_bound != TRUE) {
@@ -454,12 +479,6 @@ int agp_unbind_memory(struct agp_memory *curr)
return -EINVAL;
}
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- bridge = agp_bridge;
-#else
- bridge = curr->bridge;
-#endif
-
ret_val = bridge->driver->remove_memory(curr, curr->pg_start, curr->type);
if (ret_val != 0)
@@ -798,7 +817,7 @@ done:
*/
#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
-u32 agp_collect_device_status(u32 mode, u32 cmd)
+u32 agp_collect_device_status(struct agp_bridge_data *bridge, u32 mode, u32 cmd)
{
struct pci_dev *device = NULL;
u8 cap_ptr;
@@ -944,11 +963,7 @@ void agp_generic_enable(struct agp_bridge_data *bridge, u32 requested_mode)
pci_read_config_dword(agp_bridge->dev,
agp_bridge->capndx + PCI_AGP_STATUS, &bridge_agpstat);
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- bridge_agpstat = agp_collect_device_status(requested_mode, bridge_agpstat);
-#else
- bridge_agpstat = agp_collect_device_status(agp_bridge, requested_mode, bridge_agpstat);
-#endif
+ bridge_agpstat = agp_collect_device_status(bridge, requested_mode, bridge_agpstat);
if (bridge_agpstat == 0)
/* Something bad happened. FIXME: Return error code? */
return;
@@ -1177,12 +1192,8 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type)
size_t i;
off_t j;
void *temp;
- struct agp_bridge_data *bridge;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- bridge = agp_bridge;
-#else
- bridge = mem->bridge;
-#endif
+ struct agp_bridge_data *bridge = agp_get_bridge(mem);
+ int mask_type;
if (!bridge)
return -EINVAL;
@@ -1214,7 +1225,12 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type)
num_entries -= agp_memory_reserved/PAGE_SIZE;
if (num_entries < 0) num_entries = 0;
- if (type != 0 || mem->type != 0) {
+ if (type != mem->type) {
+ return -EINVAL;
+ }
+
+ mask_type = bridge->driver->agp_type_to_mask_type(bridge, type);
+ if (mask_type != 0) {
/* The generic routines know nothing of memory types */
return -EINVAL;
}
@@ -1223,6 +1239,9 @@ int agp_generic_insert_memory(struct agp_memory * mem, off_t pg_start, int type)
if ((pg_start + mem->page_count) > num_entries)
return -EINVAL;
+ if (mem->page_count == 0)
+ return 0;
+
j = pg_start;
while (j < (pg_start + mem->page_count)) {
@@ -1237,15 +1256,12 @@ 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++) {
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- writel(bridge->driver->mask_memory(mem->memory[i], mem->type), bridge->gatt_table+j);
-#else
writel(bridge->driver->mask_memory(bridge, mem->memory[i], mem->type), bridge->gatt_table+j);
-#endif
- readl(bridge->gatt_table+j); /* PCI Posting. */
}
+ readl(bridge->gatt_table+j-1); /* PCI Posting. */
bridge->driver->tlb_flush(mem);
+ mem->is_flushed = FALSE;
return 0;
}
EXPORT_SYMBOL(agp_generic_insert_memory);
@@ -1254,17 +1270,21 @@ EXPORT_SYMBOL(agp_generic_insert_memory);
int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
{
size_t i;
- struct agp_bridge_data *bridge;
+ struct agp_bridge_data *bridge = agp_get_bridge(mem);
+ int mask_type;
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- bridge = agp_bridge;
-#else
- bridge = mem->bridge;
-#endif
if (!bridge)
return -EINVAL;
- if (type != 0 || mem->type != 0) {
+ if (type != mem->type) {
+ return -EINVAL;
+ }
+
+ if (mem->page_count == 0)
+ return 0;
+
+ mask_type = bridge->driver->agp_type_to_mask_type(bridge, type);
+ if (mask_type != 0) {
/* The generic routines know nothing of memory types */
return -EINVAL;
}
@@ -1272,10 +1292,9 @@ int agp_generic_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
/* AK: bogus, should encode addresses > 4GB */
for (i = pg_start; i < (mem->page_count + pg_start); i++) {
writel(bridge->scratch_page, bridge->gatt_table+i);
- readl(bridge->gatt_table+i); /* PCI Posting. */
}
+ readl(bridge->gatt_table+i-1); /* PCI Posting. */
- global_cache_flush();
bridge->driver->tlb_flush(mem);
return 0;
}
@@ -1297,6 +1316,42 @@ void agp_generic_free_by_type(struct agp_memory *curr)
}
EXPORT_SYMBOL(agp_generic_free_by_type);
+struct agp_memory *agp_generic_alloc_user(size_t page_count, int type)
+{
+ struct agp_memory *new;
+ int i;
+ int pages;
+
+ pages = (page_count + ENTRIES_PER_PAGE - 1) / ENTRIES_PER_PAGE;
+ new = agp_create_user_memory(page_count);
+ if (new == NULL)
+ return NULL;
+
+ for (i = 0; i < page_count; i++) {
+ new->memory[i] = 0;
+ }
+ new->page_count = 0;
+ new->type = type;
+ new->num_scratch_pages = pages;
+
+ return new;
+}
+EXPORT_SYMBOL(agp_generic_alloc_user);
+
+
+void agp_generic_free_user(struct agp_memory *curr)
+{
+ if ((unsigned long) curr->memory >= VMALLOC_START
+ && (unsigned long) curr->memory < VMALLOC_END) {
+ vfree(curr->memory);
+ } else {
+ kfree(curr->memory);
+ }
+ agp_free_key(curr->key);
+ kfree(curr);
+}
+EXPORT_SYMBOL(agp_generic_free_user);
+
/*
* Basic Page Allocation Routines -
@@ -1402,81 +1457,14 @@ unsigned long agp_generic_mask_memory(struct agp_bridge_data *bridge,
}
EXPORT_SYMBOL(agp_generic_mask_memory);
-/*
- * Use kmalloc if possible for the page list. Otherwise fall back to
- * vmalloc. This speeds things up and also saves memory for small AGP
- * regions.
- */
-
-static struct agp_memory *agp_create_drm_memory(unsigned long num_agp_pages)
+int agp_generic_type_to_mask_type(struct agp_bridge_data *bridge,
+ int type)
{
- struct agp_memory *new;
- unsigned long alloc_size = num_agp_pages*sizeof(struct page *);
-
- new = kmalloc(sizeof(struct agp_memory), GFP_KERNEL);
-
- if (new == NULL)
- return NULL;
-
- memset(new, 0, sizeof(struct agp_memory));
- new->key = agp_get_key();
-
- if (new->key < 0) {
- kfree(new);
- return NULL;
- }
-
- if (alloc_size <= 4*PAGE_SIZE) {
- new->memory = kmalloc(alloc_size, GFP_KERNEL);
- }
- if (new->memory == NULL) {
- new->memory = vmalloc(alloc_size);
- }
- if (new->memory == NULL) {
- agp_free_key(new->key);
- kfree(new);
- return NULL;
- }
- new->num_scratch_pages = 0;
- return new;
-}
-
-struct agp_memory *agp_generic_alloc_user(size_t page_count, int type)
-{
- struct agp_memory *new;
- int i;
- int pages;
-
- pages = (page_count + ENTRIES_PER_PAGE - 1) / ENTRIES_PER_PAGE;
- new = agp_create_drm_memory(page_count);
- if (new == NULL)
- return NULL;
-
- for (i = 0; i < page_count; i++) {
- new->memory[i] = 0;
- }
- new->page_count = 0;
- new->type = type;
- new->num_scratch_pages = pages;
-
- return new;
+ if (type >= AGP_USER_TYPES)
+ return 0;
+ return type;
}
-EXPORT_SYMBOL(agp_generic_alloc_user);
-
-
-
-void agp_generic_free_user(struct agp_memory *curr)
-{
- if ((unsigned long) curr->memory >= VMALLOC_START
- && (unsigned long) curr->memory < VMALLOC_END) {
- vfree(curr->memory);
- } else {
- kfree(curr->memory);
- }
- agp_free_key(curr->key);
- kfree(curr);
-}
-EXPORT_SYMBOL(agp_generic_free_user);
+EXPORT_SYMBOL(agp_generic_type_to_mask_type);
/*
* These functions are implemented according to the AGPv3 spec,
diff --git a/intel-agp.c b/intel-agp.c
index 4ac5cb9..5a2b78c 100644
--- a/intel-agp.c
+++ b/intel-agp.c
@@ -96,15 +96,13 @@ static struct aper_size_info_fixed intel_i810_sizes[] =
#define AGP_DCACHE_MEMORY 1
#define AGP_PHYS_MEMORY 2
-#define INTEL_AGP_USER_MEMORY 3
-#define INTEL_AGP_CACHED_MEMORY 4
+#define INTEL_AGP_CACHED_MEMORY 3
static struct gatt_mask intel_i810_masks[] =
{
{.mask = I810_PTE_VALID, .type = 0},
{.mask = (I810_PTE_VALID | I810_PTE_LOCAL), .type = AGP_DCACHE_MEMORY},
{.mask = I810_PTE_VALID, .type = 0},
- {.mask = I810_PTE_VALID, .type = 0},
{.mask = I810_PTE_VALID | I830_PTE_SYSTEM_CACHED,
.type = INTEL_AGP_CACHED_MEMORY}
};
@@ -118,142 +116,6 @@ static struct _intel_i810_private {
} intel_i810_private;
-/*
- * Note that agp_generic_mask_memory always defaults to memory type 0,
- * so we don't need to provide a specialization for that function to support
- * INTEL_AGP_USER_MEMORY.
- */
-
-static int intel_generic_insert_memory(struct agp_memory * mem,
- off_t pg_start, int type)
-{
- int num_entries;
- size_t i;
- off_t j;
- void *temp;
- struct agp_bridge_data *bridge;
- int ret = -EINVAL;
-
- if (mem->page_count == 0)
- goto out;
-
-#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,12)
- bridge = agp_bridge;
-#else
- bridge = mem->bridge;
-#endif
-
- if (!bridge)
- goto out_err;
-
- temp = bridge->current_size;
-
- switch (bridge->driver->size_type) {
- case U8_APER_SIZE:
- num_entries = A_SIZE_8(temp)->num_entries;
- break;
- case U16_APER_SIZE:
- num_entries = A_SIZE_16(temp)->num_entries;
- break;
- case U32_APER_SIZE:
- num_entries = A_SIZE_32(temp)->num_entries;
- break;
- case FIXED_APER_SIZE:
- num_entries = A_SIZE_FIX(temp)->num_entries;
- break;
- case LVL2_APER_SIZE:
- /* The generic routines can't deal with 2 level gatt's */
- goto out_err;
- break;
- default:
- num_entries = 0;
- break;
- }
-
- num_entries -= agp_memory_reserved/PAGE_SIZE;
- if (num_entries < 0) num_entries = 0;
-
- if (type != mem->type)
- goto out_err;
-
- if (type != 0 &&
- type != INTEL_AGP_USER_MEMORY)
- goto out_err;
-
- if ((pg_start + mem->page_count) > num_entries)
- goto out_err;
-
- j = pg_start;
-
- while (j < (pg_start + mem->page_count)) {
- if (!PGE_EMPTY(bridge, readl(bridge->gatt_table+j))) {
- ret = -EBUSY;
- goto out_err;
- }
- j++;
- }
-
- if (!mem->is_flushed)
- global_cache_flush();
-
- for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
- writel(bridge->driver->mask_memory(bridge,
- mem->memory[i], mem->type),
- bridge->gatt_table+j);
- }
- readl(bridge->gatt_table+mem->page_count-1);
- bridge->driver->tlb_flush(mem);
- out:
- ret = 0;
- out_err:
- mem->is_flushed = 0;
- return ret;
-}
-
-
-static int intel_generic_remove_memory(struct agp_memory *mem,
- off_t pg_start, int type)
-{
- size_t i;
- struct agp_bridge_data *bridge;
-
- bridge = mem->bridge;
- if (!bridge)
- return -EINVAL;
-
- if (type != mem->type)
- return -EINVAL;
-
- if (type != 0 && type != INTEL_AGP_USER_MEMORY)
- return -EINVAL;
-
- if (mem->page_count == 0)
- return 0;
-
- for (i = pg_start; i < (mem->page_count + pg_start); i++) {
- writel(bridge->scratch_page, bridge->gatt_table+i);
- }
- readl(bridge->gatt_table+mem->page_count - 1);
-
- bridge->driver->tlb_flush(mem);
- return 0;
-}
-
-static struct agp_memory *intel_generic_alloc_by_type(size_t pg_count, int type)
-{
- if (type == INTEL_AGP_USER_MEMORY)
- return agp_generic_alloc_user(pg_count, type);
- return NULL;
-}
-
-static void intel_generic_free_by_type(struct agp_memory *curr)
-{
- agp_free_key(curr->key);
- if (curr->type == INTEL_AGP_USER_MEMORY) {
- agp_generic_free_user(curr);
- }
-}
-
static int intel_i810_fetch_size(void)
{
u32 smram_miscc;
@@ -373,6 +235,18 @@ static void i8xx_destroy_pages(void *addr)
atomic_dec(&agp_bridge->current_memory_agp);
}
+static int intel_i830_type_to_mask_type(struct agp_bridge_data *bridge,
+ int type)
+{
+ if (type < AGP_USER_TYPES)
+ return type;
+ else if (type == AGP_USER_CACHED_MEMORY)
+ return INTEL_AGP_CACHED_MEMORY;
+ else
+ return 0;
+}
+
+
static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
int type)
{
@@ -380,6 +254,7 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
void *temp;
struct agp_bridge_data *bridge;
int ret = -EINVAL;
+ int mask_type;
if (mem->page_count == 0)
goto out;
@@ -410,7 +285,9 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
if (type != mem->type)
goto out_err;
- switch (type) {
+ mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
+
+ switch (mask_type) {
case AGP_DCACHE_MEMORY:
if (!mem->is_flushed)
global_cache_flush();
@@ -421,13 +298,12 @@ static int intel_i810_insert_entries(struct agp_memory *mem, off_t pg_start,
readl(intel_i810_private.registers+I810_PTE_BASE+((i-1)*4));
break;
case AGP_PHYS_MEMORY:
- case INTEL_AGP_USER_MEMORY:
if (!mem->is_flushed)
global_cache_flush();
for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
writel(bridge->driver->mask_memory(bridge,
mem->memory[i],
- mem->type),
+ mask_type),
intel_i810_private.registers+I810_PTE_BASE+(j*4));
}
readl(intel_i810_private.registers+I810_PTE_BASE+((j-1)*4));
@@ -527,8 +403,6 @@ static struct agp_memory *intel_i810_alloc_by_type(size_t pg_count, int type)
}
if (type == AGP_PHYS_MEMORY)
return alloc_agpphysmem_i8xx(pg_count, type);
- else if (type == INTEL_AGP_USER_MEMORY)
- return agp_generic_alloc_user(pg_count, type);
return NULL;
}
@@ -544,10 +418,6 @@ static void intel_i810_free_by_type(struct agp_memory *curr)
flush_agp_mappings();
}
vfree(curr->memory);
- } else if (curr->type == INTEL_AGP_USER_MEMORY ||
- curr->type == INTEL_AGP_CACHED_MEMORY) {
- agp_generic_free_user(curr);
- return;
}
kfree(curr);
}
@@ -786,6 +656,7 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int
void *temp;
struct agp_bridge_data *bridge;
int ret = -EINVAL;
+ int mask_type;
if (mem->page_count == 0)
goto out;
@@ -820,9 +691,10 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int
if (type != mem->type)
goto out_err;
- if (type != 0 && type != AGP_PHYS_MEMORY &&
- type != INTEL_AGP_USER_MEMORY &&
- type != INTEL_AGP_CACHED_MEMORY)
+ mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
+
+ if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY &&
+ mask_type != INTEL_AGP_CACHED_MEMORY)
goto out_err;
if (!mem->is_flushed)
@@ -830,7 +702,7 @@ static int intel_i830_insert_entries(struct agp_memory *mem,off_t pg_start, int
for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
writel(bridge->driver->mask_memory(bridge,
- mem->memory[i], mem->type),
+ mem->memory[i], mask_type),
intel_i830_private.registers+I810_PTE_BASE+(j*4));
}
readl(intel_i830_private.registers+I810_PTE_BASE+((j-1)*4));
@@ -897,10 +769,6 @@ static struct agp_memory *intel_i830_alloc_by_type(size_t pg_count,int type)
{
if (type == AGP_PHYS_MEMORY)
return alloc_agpphysmem_i8xx(pg_count, type);
- else if (type == INTEL_AGP_USER_MEMORY ||
- type == INTEL_AGP_CACHED_MEMORY)
- return agp_generic_alloc_user(pg_count, type);
-
/* always return NULL for other allocation types for now */
return NULL;
}
@@ -964,6 +832,7 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
void *temp;
struct agp_bridge_data *bridge;
int ret = -EINVAL;
+ int mask_type;
if (mem->page_count == 0)
goto out;
@@ -998,9 +867,9 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
if (type != mem->type)
goto out_err;
- if (type != 0 && type != AGP_PHYS_MEMORY &&
- type != INTEL_AGP_USER_MEMORY &&
- type != INTEL_AGP_CACHED_MEMORY)
+ mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
+ if (mask_type != 0 && mask_type != AGP_PHYS_MEMORY &&
+ mask_type != INTEL_AGP_CACHED_MEMORY)
goto out_err;
if (!mem->is_flushed)
@@ -1008,7 +877,7 @@ static int intel_i915_insert_entries(struct agp_memory *mem,off_t pg_start,
for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
writel(bridge->driver->mask_memory(bridge, mem->memory[i],
- mem->type),
+ mask_type),
intel_i830_private.gtt+j);
}
readl(intel_i830_private.gtt+j-1);
@@ -1620,12 +1489,13 @@ static struct agp_bridge_driver intel_generic_driver = {
.cache_flush = global_cache_flush,
.create_gatt_table = agp_generic_create_gatt_table,
.free_gatt_table = agp_generic_free_gatt_table,
- .insert_memory = intel_generic_insert_memory,
- .remove_memory = intel_generic_remove_memory,
- .alloc_by_type = intel_generic_alloc_by_type,
- .free_by_type = intel_generic_free_by_type,
+ .insert_memory = agp_generic_insert_memory,
+ .remove_memory = agp_generic_remove_memory,
+ .alloc_by_type = agp_generic_alloc_by_type,
+ .free_by_type = agp_generic_free_by_type,
.agp_alloc_page = agp_generic_alloc_page,
.agp_destroy_page = agp_generic_destroy_page,
+ .agp_type_to_mask_type = agp_generic_type_to_mask_type,
};
static struct agp_bridge_driver intel_810_driver = {
@@ -1650,6 +1520,7 @@ static struct agp_bridge_driver intel_810_driver = {
.free_by_type = intel_i810_free_by_type,
.agp_alloc_page = agp_generic_alloc_page,
.agp_destroy_page = agp_generic_destroy_page,
+ .agp_type_to_mask_type = agp_generic_type_to_mask_type,
};
static struct agp_bridge_driver intel_815_driver = {
@@ -1667,12 +1538,13 @@ static struct agp_bridge_driver intel_815_driver = {
.cache_flush = global_cache_flush,
.create_gatt_table = agp_generic_create_gatt_table,
.free_gatt_table = agp_generic_free_gatt_table,
- .insert_memory = intel_generic_insert_memory,
- .remove_memory = intel_generic_remove_memory,
- .alloc_by_type = intel_generic_alloc_by_type,
- .free_by_type = intel_generic_free_by_type,
+ .insert_memory = agp_generic_insert_memory,
+ .remove_memory = agp_generic_remove_memory,
+ .alloc_by_type = agp_generic_alloc_by_type,
+ .free_by_type = agp_generic_free_by_type,
.agp_alloc_page = agp_generic_alloc_page,
.agp_destroy_page = agp_generic_destroy_page,
+ .agp_type_to_mask_type = agp_generic_type_to_mask_type,
};
static struct agp_bridge_driver intel_830_driver = {
@@ -1697,6 +1569,7 @@ static struct agp_bridge_driver intel_830_driver = {
.free_by_type = intel_i810_free_by_type,
.agp_alloc_page = agp_generic_alloc_page,
.agp_destroy_page = agp_generic_destroy_page,
+ .agp_type_to_mask_type = intel_i830_type_to_mask_type,
};
static struct agp_bridge_driver intel_820_driver = {
@@ -1714,12 +1587,13 @@ static struct agp_bridge_driver intel_820_driver = {
.cache_flush = global_cache_flush,
.create_gatt_table = agp_generic_create_gatt_table,
.free_gatt_table = agp_generic_free_gatt_table,
- .insert_memory = intel_generic_insert_memory,
- .remove_memory = intel_generic_remove_memory,
- .alloc_by_type = intel_generic_alloc_by_type,
- .free_by_type = intel_generic_free_by_type,
+ .insert_memory = agp_generic_insert_memory,
+ .remove_memory = agp_generic_remove_memory,
+ .alloc_by_type = agp_generic_alloc_by_type,
+ .free_by_type = agp_generic_free_by_type,
.agp_alloc_page = agp_generic_alloc_page,
.agp_destroy_page = agp_generic_destroy_page,
+ .agp_type_to_mask_type = agp_generic_type_to_mask_type,
};
static struct agp_bridge_driver intel_830mp_driver = {
@@ -1737,12 +1611,13 @@ static struct agp_bridge_driver intel_830mp_driver = {
.cache_flush = global_cache_flush,
.create_gatt_table = agp_generic_create_gatt_table,
.free_gatt_table = agp_generic_free_gatt_table,
- .insert_memory = intel_generic_insert_memory,
- .remove_memory = intel_generic_remove_memory,
- .alloc_by_type = intel_generic_alloc_by_type,
- .free_by_type = intel_generic_free_by_type,
+ .insert_memory = agp_generic_insert_memory,
+ .remove_memory = agp_generic_remove_memory,
+ .alloc_by_type = agp_generic_alloc_by_type,
+ .free_by_type = agp_generic_free_by_type,
.agp_alloc_page = agp_generic_alloc_page,
.agp_destroy_page = agp_generic_destroy_page,
+ .agp_type_to_mask_type = agp_generic_type_to_mask_type,
};
static struct agp_bridge_driver intel_840_driver = {
@@ -1760,12 +1635,13 @@ static struct agp_bridge_driver intel_840_driver = {
.cache_flush = global_cache_flush,
.create_gatt_table = agp_generic_create_gatt_table,
.free_gatt_table = agp_generic_free_gatt_table,
- .insert_memory = intel_generic_insert_memory,
- .remove_memory = intel_generic_remove_memory,
- .alloc_by_type = intel_generic_alloc_by_type,
- .free_by_type = intel_generic_free_by_type,
+ .insert_memory = agp_generic_insert_memory,
+ .remove_memory = agp_generic_remove_memory,
+ .alloc_by_type = agp_generic_alloc_by_type,
+ .free_by_type = agp_generic_free_by_type,
.agp_alloc_page = agp_generic_alloc_page,
.agp_destroy_page = agp_generic_destroy_page,
+ .agp_type_to_mask_type = agp_generic_type_to_mask_type,
};
static struct agp_bridge_driver intel_845_driver = {
@@ -1783,12 +1659,13 @@ static struct agp_bridge_driver intel_845_driver = {
.cache_flush = global_cache_flush,
.create_gatt_table = agp_generic_create_gatt_table,
.free_gatt_table = agp_generic_free_gatt_table,
- .insert_memory = intel_generic_insert_memory,
- .remove_memory = intel_generic_remove_memory,
- .alloc_by_type = intel_generic_alloc_by_type,
- .free_by_type = intel_generic_free_by_type,
+ .insert_memory = agp_generic_insert_memory,
+ .remove_memory = agp_generic_remove_memory,
+ .alloc_by_type = agp_generic_alloc_by_type,
+ .free_by_type = agp_generic_free_by_type,
.agp_alloc_page = agp_generic_alloc_page,
.agp_destroy_page = agp_generic_destroy_page,
+ .agp_type_to_mask_type = agp_generic_type_to_mask_type,
};
static struct agp_bridge_driver intel_850_driver = {
@@ -1806,12 +1683,13 @@ static struct agp_bridge_driver intel_850_driver = {
.cache_flush = global_cache_flush,
.create_gatt_table = agp_generic_create_gatt_table,
.free_gatt_table = agp_generic_free_gatt_table,
- .insert_memory = intel_generic_insert_memory,
- .remove_memory = intel_generic_remove_memory,
- .alloc_by_type = intel_generic_alloc_by_type,
- .free_by_type = intel_generic_free_by_type,
+ .insert_memory = agp_generic_insert_memory,
+ .remove_memory = agp_generic_remove_memory,
+ .alloc_by_type = agp_generic_alloc_by_type,
+ .free_by_type = agp_generic_free_by_type,
.agp_alloc_page = agp_generic_alloc_page,
.agp_destroy_page = agp_generic_destroy_page,
+ .agp_type_to_mask_type = agp_generic_type_to_mask_type,
};
static struct agp_bridge_driver intel_860_driver = {
@@ -1829,12 +1707,13 @@ static struct agp_bridge_driver intel_860_driver = {
.cache_flush = global_cache_flush,
.create_gatt_table = agp_generic_create_gatt_table,
.free_gatt_table = agp_generic_free_gatt_table,
- .insert_memory = intel_generic_insert_memory,
- .remove_memory = intel_generic_remove_memory,
- .alloc_by_type = intel_generic_alloc_by_type,
- .free_by_type = intel_generic_free_by_type,
+ .insert_memory = agp_generic_insert_memory,
+ .remove_memory = agp_generic_remove_memory,
+ .alloc_by_type = agp_generic_alloc_by_type,
+ .free_by_type = agp_generic_free_by_type,
.agp_alloc_page = agp_generic_alloc_page,
.agp_destroy_page = agp_generic_destroy_page,
+ .agp_type_to_mask_type = agp_generic_type_to_mask_type,
};
static struct agp_bridge_driver intel_915_driver = {
@@ -1859,6 +1738,7 @@ static struct agp_bridge_driver intel_915_driver = {
.free_by_type = intel_i830_free_by_type,
.agp_alloc_page = intel_alloc_page,
.agp_destroy_page = intel_destroy_page,
+ .agp_type_to_mask_type = intel_i830_type_to_mask_type,
};
static struct agp_bridge_driver intel_i965_driver = {
@@ -1883,6 +1763,7 @@ static struct agp_bridge_driver intel_i965_driver = {
.free_by_type = intel_i830_free_by_type,
.agp_alloc_page = intel_alloc_page,
.agp_destroy_page = intel_destroy_page,
+ .agp_type_to_mask_type = intel_i830_type_to_mask_type,
};
static struct agp_bridge_driver intel_7505_driver = {
@@ -1900,12 +1781,13 @@ static struct agp_bridge_driver intel_7505_driver = {
.cache_flush = global_cache_flush,
.create_gatt_table = agp_generic_create_gatt_table,
.free_gatt_table = agp_generic_free_gatt_table,
- .insert_memory = intel_generic_insert_memory,
- .remove_memory = intel_generic_remove_memory,
- .alloc_by_type = intel_generic_alloc_by_type,
- .free_by_type = intel_generic_free_by_type,
+ .insert_memory = agp_generic_insert_memory,
+ .remove_memory = agp_generic_remove_memory,
+ .alloc_by_type = agp_generic_alloc_by_type,
+ .free_by_type = agp_generic_free_by_type,
.agp_alloc_page = agp_generic_alloc_page,
.agp_destroy_page = agp_generic_destroy_page,
+ .agp_type_to_mask_type = agp_generic_type_to_mask_type,
};
static int find_i810(u16 device)