aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char
diff options
context:
space:
mode:
authorThomas Hellstrom <thomas-at-tungstengraphics-dot-com>2008-09-10 08:13:33 -0400
committerDave Airlie <airlied@redhat.com>2008-10-16 02:37:18 -0400
commita64d2b37c2259e169759c1701ac565f0a11dc0ea (patch)
tree02d86a00f6a4617722c5d7f55da81056e5ca3bce /drivers/char
parent2a32c3c894bcd3b3f8cc7e23f5ecbebca4a9f8e8 (diff)
agp/nvidia: Support agp user-memory on nvidia agp.
This adds user memory support required for TTM to the nvidia AGP driver. Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/char')
-rw-r--r--drivers/char/agp/nvidia-agp.c22
1 files changed, 18 insertions, 4 deletions
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index eaceb61ba2dc..0cc1c5baced5 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -201,10 +201,15 @@ extern int agp_memory_reserved;
201static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type) 201static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
202{ 202{
203 int i, j; 203 int i, j;
204 int mask_type;
204 205
205 if ((type != 0) || (mem->type != 0)) 206 mask_type = agp_generic_type_to_mask_type(mem->bridge, type);
207 if (mask_type != 0 || type != mem->type)
206 return -EINVAL; 208 return -EINVAL;
207 209
210 if (mem->page_count == 0)
211 return 0;
212
208 if ((pg_start + mem->page_count) > 213 if ((pg_start + mem->page_count) >
209 (nvidia_private.num_active_entries - agp_memory_reserved/PAGE_SIZE)) 214 (nvidia_private.num_active_entries - agp_memory_reserved/PAGE_SIZE))
210 return -EINVAL; 215 return -EINVAL;
@@ -220,10 +225,13 @@ static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type
220 } 225 }
221 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) { 226 for (i = 0, j = pg_start; i < mem->page_count; i++, j++) {
222 writel(agp_bridge->driver->mask_memory(agp_bridge, 227 writel(agp_bridge->driver->mask_memory(agp_bridge,
223 mem->memory[i], mem->type), 228 mem->memory[i], mask_type),
224 agp_bridge->gatt_table+nvidia_private.pg_offset+j); 229 agp_bridge->gatt_table+nvidia_private.pg_offset+j);
225 readl(agp_bridge->gatt_table+nvidia_private.pg_offset+j); /* PCI Posting. */
226 } 230 }
231
232 /* PCI Posting. */
233 readl(agp_bridge->gatt_table+nvidia_private.pg_offset+j - 1);
234
227 agp_bridge->driver->tlb_flush(mem); 235 agp_bridge->driver->tlb_flush(mem);
228 return 0; 236 return 0;
229} 237}
@@ -233,9 +241,15 @@ static int nvidia_remove_memory(struct agp_memory *mem, off_t pg_start, int type
233{ 241{
234 int i; 242 int i;
235 243
236 if ((type != 0) || (mem->type != 0)) 244 int mask_type;
245
246 mask_type = agp_generic_type_to_mask_type(mem->bridge, type);
247 if (mask_type != 0 || type != mem->type)
237 return -EINVAL; 248 return -EINVAL;
238 249
250 if (mem->page_count == 0)
251 return 0;
252
239 for (i = pg_start; i < (mem->page_count + pg_start); i++) 253 for (i = pg_start; i < (mem->page_count + pg_start); i++)
240 writel(agp_bridge->scratch_page, agp_bridge->gatt_table+nvidia_private.pg_offset+i); 254 writel(agp_bridge->scratch_page, agp_bridge->gatt_table+nvidia_private.pg_offset+i);
241 255