diff options
| author | Michel Dänzer <daenzer@vmware.com> | 2009-12-05 21:15:55 -0500 |
|---|---|---|
| committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-12-09 01:09:30 -0500 |
| commit | 3fc3a6b476581d9b47b33fc1349817ce7b66433e (patch) | |
| tree | 34aa3e5c6fbc9ae3161479f56b88af0b77c9c301 | |
| parent | ceae8cbe94f3127253110e2d01b9334069e93177 (diff) | |
agp/uninorth: Also handle user memory types in u3_remove_memory().
Also short-circuit empty updates.
Signed-off-by: Michel Dänzer <daenzer@vmware.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
| -rw-r--r-- | drivers/char/agp/uninorth-agp.c | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c index 703959eba45a..4e05021f3f18 100644 --- a/drivers/char/agp/uninorth-agp.c +++ b/drivers/char/agp/uninorth-agp.c | |||
| @@ -151,9 +151,6 @@ static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start, | |||
| 151 | void *temp; | 151 | void *temp; |
| 152 | int mask_type; | 152 | int mask_type; |
| 153 | 153 | ||
| 154 | temp = agp_bridge->current_size; | ||
| 155 | num_entries = A_SIZE_32(temp)->num_entries; | ||
| 156 | |||
| 157 | if (type != mem->type) | 154 | if (type != mem->type) |
| 158 | return -EINVAL; | 155 | return -EINVAL; |
| 159 | 156 | ||
| @@ -163,6 +160,12 @@ static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start, | |||
| 163 | return -EINVAL; | 160 | return -EINVAL; |
| 164 | } | 161 | } |
| 165 | 162 | ||
| 163 | if (mem->page_count == 0) | ||
| 164 | return 0; | ||
| 165 | |||
| 166 | temp = agp_bridge->current_size; | ||
| 167 | num_entries = A_SIZE_32(temp)->num_entries; | ||
| 168 | |||
| 166 | if ((pg_start + mem->page_count) > num_entries) | 169 | if ((pg_start + mem->page_count) > num_entries) |
| 167 | return -EINVAL; | 170 | return -EINVAL; |
| 168 | 171 | ||
| @@ -194,9 +197,6 @@ static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
| 194 | u32 *gp; | 197 | u32 *gp; |
| 195 | int mask_type; | 198 | int mask_type; |
| 196 | 199 | ||
| 197 | temp = agp_bridge->current_size; | ||
| 198 | num_entries = A_SIZE_32(temp)->num_entries; | ||
| 199 | |||
| 200 | if (type != mem->type) | 200 | if (type != mem->type) |
| 201 | return -EINVAL; | 201 | return -EINVAL; |
| 202 | 202 | ||
| @@ -206,6 +206,12 @@ static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
| 206 | return -EINVAL; | 206 | return -EINVAL; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | if (mem->page_count == 0) | ||
| 210 | return 0; | ||
| 211 | |||
| 212 | temp = agp_bridge->current_size; | ||
| 213 | num_entries = A_SIZE_32(temp)->num_entries; | ||
| 214 | |||
| 209 | if ((pg_start + mem->page_count) > num_entries) | 215 | if ((pg_start + mem->page_count) > num_entries) |
| 210 | return -EINVAL; | 216 | return -EINVAL; |
| 211 | 217 | ||
| @@ -234,10 +240,19 @@ int u3_remove_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
| 234 | { | 240 | { |
| 235 | size_t i; | 241 | size_t i; |
| 236 | u32 *gp; | 242 | u32 *gp; |
| 243 | int mask_type; | ||
| 244 | |||
| 245 | if (type != mem->type) | ||
| 246 | return -EINVAL; | ||
| 237 | 247 | ||
| 238 | if (type != 0 || mem->type != 0) | 248 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); |
| 249 | if (mask_type != 0) { | ||
| 239 | /* We know nothing of memory types */ | 250 | /* We know nothing of memory types */ |
| 240 | return -EINVAL; | 251 | return -EINVAL; |
| 252 | } | ||
| 253 | |||
| 254 | if (mem->page_count == 0) | ||
| 255 | return 0; | ||
| 241 | 256 | ||
| 242 | gp = (u32 *) &agp_bridge->gatt_table[pg_start]; | 257 | gp = (u32 *) &agp_bridge->gatt_table[pg_start]; |
| 243 | for (i = 0; i < mem->page_count; ++i) | 258 | for (i = 0; i < mem->page_count; ++i) |
