diff options
| author | Michel Dänzer <daenzer@vmware.com> | 2009-12-05 21:15:56 -0500 |
|---|---|---|
| committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2009-12-09 01:09:30 -0500 |
| commit | 37580f3f229fa72f2ef73ea7df0a1d28a9dab36d (patch) | |
| tree | 8d9204cfe66717ec685eee5fcff807e645f52274 | |
| parent | 3fc3a6b476581d9b47b33fc1349817ce7b66433e (diff) | |
agp/uninorth: Unify U3 and pre-U3 insert_memory and remove_memory hooks.
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 | 64 |
1 files changed, 11 insertions, 53 deletions
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c index 4e05021f3f18..d89da4ac061f 100644 --- a/drivers/char/agp/uninorth-agp.c +++ b/drivers/char/agp/uninorth-agp.c | |||
| @@ -144,53 +144,7 @@ static int uninorth_configure(void) | |||
| 144 | return 0; | 144 | return 0; |
| 145 | } | 145 | } |
| 146 | 146 | ||
| 147 | static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start, | 147 | static int uninorth_insert_memory(struct agp_memory *mem, off_t pg_start, int type) |
| 148 | int type) | ||
| 149 | { | ||
| 150 | int i, j, num_entries; | ||
| 151 | void *temp; | ||
| 152 | int mask_type; | ||
| 153 | |||
| 154 | if (type != mem->type) | ||
| 155 | return -EINVAL; | ||
| 156 | |||
| 157 | mask_type = agp_bridge->driver->agp_type_to_mask_type(agp_bridge, type); | ||
| 158 | if (mask_type != 0) { | ||
| 159 | /* We know nothing of memory types */ | ||
| 160 | return -EINVAL; | ||
| 161 | } | ||
| 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 | |||
| 169 | if ((pg_start + mem->page_count) > num_entries) | ||
| 170 | return -EINVAL; | ||
| 171 | |||
| 172 | j = pg_start; | ||
| 173 | |||
| 174 | while (j < (pg_start + mem->page_count)) { | ||
| 175 | if (agp_bridge->gatt_table[j]) | ||
| 176 | return -EBUSY; | ||
| 177 | j++; | ||
| 178 | } | ||
| 179 | |||
| 180 | for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { | ||
| 181 | agp_bridge->gatt_table[j] = | ||
| 182 | cpu_to_le32((page_to_phys(mem->pages[i]) & 0xFFFFF000UL) | 0x1UL); | ||
| 183 | flush_dcache_range((unsigned long)__va(page_to_phys(mem->pages[i])), | ||
| 184 | (unsigned long)__va(page_to_phys(mem->pages[i]))+0x1000); | ||
| 185 | } | ||
| 186 | (void)in_le32((volatile u32*)&agp_bridge->gatt_table[pg_start]); | ||
| 187 | mb(); | ||
| 188 | |||
| 189 | uninorth_tlbflush(mem); | ||
| 190 | return 0; | ||
| 191 | } | ||
| 192 | |||
| 193 | static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type) | ||
| 194 | { | 148 | { |
| 195 | int i, num_entries; | 149 | int i, num_entries; |
| 196 | void *temp; | 150 | void *temp; |
| @@ -219,14 +173,18 @@ static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
| 219 | for (i = 0; i < mem->page_count; ++i) { | 173 | for (i = 0; i < mem->page_count; ++i) { |
| 220 | if (gp[i]) { | 174 | if (gp[i]) { |
| 221 | dev_info(&agp_bridge->dev->dev, | 175 | dev_info(&agp_bridge->dev->dev, |
| 222 | "u3_insert_memory: entry 0x%x occupied (%x)\n", | 176 | "uninorth_insert_memory: entry 0x%x occupied (%x)\n", |
| 223 | i, gp[i]); | 177 | i, gp[i]); |
| 224 | return -EBUSY; | 178 | return -EBUSY; |
| 225 | } | 179 | } |
| 226 | } | 180 | } |
| 227 | 181 | ||
| 228 | for (i = 0; i < mem->page_count; i++) { | 182 | for (i = 0; i < mem->page_count; i++) { |
| 229 | gp[i] = (page_to_phys(mem->pages[i]) >> PAGE_SHIFT) | 0x80000000UL; | 183 | if (is_u3) |
| 184 | gp[i] = (page_to_phys(mem->pages[i]) >> PAGE_SHIFT) | 0x80000000UL; | ||
| 185 | else | ||
| 186 | gp[i] = cpu_to_le32((page_to_phys(mem->pages[i]) & 0xFFFFF000UL) | | ||
| 187 | 0x1UL); | ||
| 230 | flush_dcache_range((unsigned long)__va(page_to_phys(mem->pages[i])), | 188 | flush_dcache_range((unsigned long)__va(page_to_phys(mem->pages[i])), |
| 231 | (unsigned long)__va(page_to_phys(mem->pages[i]))+0x1000); | 189 | (unsigned long)__va(page_to_phys(mem->pages[i]))+0x1000); |
| 232 | } | 190 | } |
| @@ -236,7 +194,7 @@ static int u3_insert_memory(struct agp_memory *mem, off_t pg_start, int type) | |||
| 236 | return 0; | 194 | return 0; |
| 237 | } | 195 | } |
| 238 | 196 | ||
| 239 | int u3_remove_memory(struct agp_memory *mem, off_t pg_start, int type) | 197 | int uninorth_remove_memory(struct agp_memory *mem, off_t pg_start, int type) |
| 240 | { | 198 | { |
| 241 | size_t i; | 199 | size_t i; |
| 242 | u32 *gp; | 200 | u32 *gp; |
| @@ -551,7 +509,7 @@ const struct agp_bridge_driver uninorth_agp_driver = { | |||
| 551 | .create_gatt_table = uninorth_create_gatt_table, | 509 | .create_gatt_table = uninorth_create_gatt_table, |
| 552 | .free_gatt_table = uninorth_free_gatt_table, | 510 | .free_gatt_table = uninorth_free_gatt_table, |
| 553 | .insert_memory = uninorth_insert_memory, | 511 | .insert_memory = uninorth_insert_memory, |
| 554 | .remove_memory = agp_generic_remove_memory, | 512 | .remove_memory = uninorth_remove_memory, |
| 555 | .alloc_by_type = agp_generic_alloc_by_type, | 513 | .alloc_by_type = agp_generic_alloc_by_type, |
| 556 | .free_by_type = agp_generic_free_by_type, | 514 | .free_by_type = agp_generic_free_by_type, |
| 557 | .agp_alloc_page = agp_generic_alloc_page, | 515 | .agp_alloc_page = agp_generic_alloc_page, |
| @@ -577,8 +535,8 @@ const struct agp_bridge_driver u3_agp_driver = { | |||
| 577 | .agp_enable = uninorth_agp_enable, | 535 | .agp_enable = uninorth_agp_enable, |
| 578 | .create_gatt_table = uninorth_create_gatt_table, | 536 | .create_gatt_table = uninorth_create_gatt_table, |
| 579 | .free_gatt_table = uninorth_free_gatt_table, | 537 | .free_gatt_table = uninorth_free_gatt_table, |
| 580 | .insert_memory = u3_insert_memory, | 538 | .insert_memory = uninorth_insert_memory, |
| 581 | .remove_memory = u3_remove_memory, | 539 | .remove_memory = uninorth_remove_memory, |
| 582 | .alloc_by_type = agp_generic_alloc_by_type, | 540 | .alloc_by_type = agp_generic_alloc_by_type, |
| 583 | .free_by_type = agp_generic_free_by_type, | 541 | .free_by_type = agp_generic_free_by_type, |
| 584 | .agp_alloc_page = agp_generic_alloc_page, | 542 | .agp_alloc_page = agp_generic_alloc_page, |
