Commit 3fc3a6b4 authored by Michel Dänzer's avatar Michel Dänzer Committed by Benjamin Herrenschmidt

agp/uninorth: Also handle user memory types in u3_remove_memory().

Also short-circuit empty updates.
Signed-off-by: default avatarMichel Dänzer <daenzer@vmware.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent ceae8cbe
...@@ -151,9 +151,6 @@ static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start, ...@@ -151,9 +151,6 @@ static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start,
void *temp; void *temp;
int mask_type; int mask_type;
temp = agp_bridge->current_size;
num_entries = A_SIZE_32(temp)->num_entries;
if (type != mem->type) if (type != mem->type)
return -EINVAL; return -EINVAL;
...@@ -163,6 +160,12 @@ static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start, ...@@ -163,6 +160,12 @@ static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start,
return -EINVAL; return -EINVAL;
} }
if (mem->page_count == 0)
return 0;
temp = agp_bridge->current_size;
num_entries = A_SIZE_32(temp)->num_entries;
if ((pg_start + mem->page_count) > num_entries) if ((pg_start + mem->page_count) > num_entries)
return -EINVAL; return -EINVAL;
...@@ -194,9 +197,6 @@ static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type) ...@@ -194,9 +197,6 @@ static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
u32 *gp; u32 *gp;
int mask_type; int mask_type;
temp = agp_bridge->current_size;
num_entries = A_SIZE_32(temp)->num_entries;
if (type != mem->type) if (type != mem->type)
return -EINVAL; return -EINVAL;
...@@ -206,6 +206,12 @@ static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type) ...@@ -206,6 +206,12 @@ static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
return -EINVAL; return -EINVAL;
} }
if (mem->page_count == 0)
return 0;
temp = agp_bridge->current_size;
num_entries = A_SIZE_32(temp)->num_entries;
if ((pg_start + mem->page_count) > num_entries) if ((pg_start + mem->page_count) > num_entries)
return -EINVAL; return -EINVAL;
...@@ -234,10 +240,19 @@ int u3_remove_memory(struct agp_memory *mem, off_t pg_start, int type) ...@@ -234,10 +240,19 @@ int u3_remove_memory(struct agp_memory *mem, off_t pg_start, int type)
{ {
size_t i; size_t i;
u32 *gp; u32 *gp;
int mask_type;
if (type != mem->type)
return -EINVAL;
if (type != 0 || mem->type != 0) mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type);
if (mask_type != 0) {
/* We know nothing of memory types */ /* We know nothing of memory types */
return -EINVAL; return -EINVAL;
}
if (mem->page_count == 0)
return 0;
gp = (u32 *) &agp_bridge->gatt_table[pg_start]; gp = (u32 *) &agp_bridge->gatt_table[pg_start];
for (i = 0; i < mem->page_count; ++i) for (i = 0; i < mem->page_count; ++i)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment