aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/agp/nvidia-agp.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/char/agp/nvidia-agp.c')
-rw-r--r--drivers/char/agp/nvidia-agp.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/drivers/char/agp/nvidia-agp.c b/drivers/char/agp/nvidia-agp.c
index 80dafa3030bd..4c67135c12d8 100644
--- a/drivers/char/agp/nvidia-agp.c
+++ b/drivers/char/agp/nvidia-agp.c
@@ -11,6 +11,7 @@
11#include <linux/gfp.h> 11#include <linux/gfp.h>
12#include <linux/page-flags.h> 12#include <linux/page-flags.h>
13#include <linux/mm.h> 13#include <linux/mm.h>
14#include <linux/jiffies.h>
14#include "agp.h" 15#include "agp.h"
15 16
16/* NVIDIA registers */ 17/* NVIDIA registers */
@@ -72,7 +73,7 @@ static int nvidia_init_iorr(u32 base, u32 size)
72 /* Find the iorr that is already used for the base */ 73 /* Find the iorr that is already used for the base */
73 /* If not found, determine the uppermost available iorr */ 74 /* If not found, determine the uppermost available iorr */
74 free_iorr_addr = AMD_K7_NUM_IORR; 75 free_iorr_addr = AMD_K7_NUM_IORR;
75 for(iorr_addr = 0; iorr_addr < AMD_K7_NUM_IORR; iorr_addr++) { 76 for (iorr_addr = 0; iorr_addr < AMD_K7_NUM_IORR; iorr_addr++) {
76 rdmsr(IORR_BASE0 + 2 * iorr_addr, base_lo, base_hi); 77 rdmsr(IORR_BASE0 + 2 * iorr_addr, base_lo, base_hi);
77 rdmsr(IORR_MASK0 + 2 * iorr_addr, mask_lo, mask_hi); 78 rdmsr(IORR_MASK0 + 2 * iorr_addr, mask_lo, mask_hi);
78 79
@@ -82,7 +83,7 @@ static int nvidia_init_iorr(u32 base, u32 size)
82 if ((mask_lo & 0x00000800) == 0) 83 if ((mask_lo & 0x00000800) == 0)
83 free_iorr_addr = iorr_addr; 84 free_iorr_addr = iorr_addr;
84 } 85 }
85 86
86 if (iorr_addr >= AMD_K7_NUM_IORR) { 87 if (iorr_addr >= AMD_K7_NUM_IORR) {
87 iorr_addr = free_iorr_addr; 88 iorr_addr = free_iorr_addr;
88 if (iorr_addr >= AMD_K7_NUM_IORR) 89 if (iorr_addr >= AMD_K7_NUM_IORR)
@@ -139,7 +140,7 @@ static int nvidia_configure(void)
139 } 140 }
140 141
141 /* attbase */ 142 /* attbase */
142 for(i = 0; i < 8; i++) { 143 for (i = 0; i < 8; i++) {
143 pci_write_config_dword(nvidia_private.dev_2, NVIDIA_2_ATTBASE(i), 144 pci_write_config_dword(nvidia_private.dev_2, NVIDIA_2_ATTBASE(i),
144 (agp_bridge->gatt_bus_addr + (i % num_dirs) * 64 * 1024) | 1); 145 (agp_bridge->gatt_bus_addr + (i % num_dirs) * 64 * 1024) | 1);
145 } 146 }
@@ -197,15 +198,15 @@ extern int agp_memory_reserved;
197static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type) 198static int nvidia_insert_memory(struct agp_memory *mem, off_t pg_start, int type)
198{ 199{
199 int i, j; 200 int i, j;
200 201
201 if ((type != 0) || (mem->type != 0)) 202 if ((type != 0) || (mem->type != 0))
202 return -EINVAL; 203 return -EINVAL;
203 204
204 if ((pg_start + mem->page_count) > 205 if ((pg_start + mem->page_count) >
205 (nvidia_private.num_active_entries - agp_memory_reserved/PAGE_SIZE)) 206 (nvidia_private.num_active_entries - agp_memory_reserved/PAGE_SIZE))
206 return -EINVAL; 207 return -EINVAL;
207 208
208 for(j = pg_start; j < (pg_start + mem->page_count); j++) { 209 for (j = pg_start; j < (pg_start + mem->page_count); j++) {
209 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+nvidia_private.pg_offset+j))) 210 if (!PGE_EMPTY(agp_bridge, readl(agp_bridge->gatt_table+nvidia_private.pg_offset+j)))
210 return -EBUSY; 211 return -EBUSY;
211 } 212 }
@@ -256,7 +257,7 @@ static void nvidia_tlbflush(struct agp_memory *mem)
256 do { 257 do {
257 pci_read_config_dword(nvidia_private.dev_1, 258 pci_read_config_dword(nvidia_private.dev_1,
258 NVIDIA_1_WBC, &wbc_reg); 259 NVIDIA_1_WBC, &wbc_reg);
259 if ((signed)(end - jiffies) <= 0) { 260 if (time_before_eq(end, jiffies)) {
260 printk(KERN_ERR PFX 261 printk(KERN_ERR PFX
261 "TLB flush took more than 3 seconds.\n"); 262 "TLB flush took more than 3 seconds.\n");
262 } 263 }
@@ -264,9 +265,9 @@ static void nvidia_tlbflush(struct agp_memory *mem)
264 } 265 }
265 266
266 /* flush TLB entries */ 267 /* flush TLB entries */
267 for(i = 0; i < 32 + 1; i++) 268 for (i = 0; i < 32 + 1; i++)
268 temp = readl(nvidia_private.aperture+(i * PAGE_SIZE / sizeof(u32))); 269 temp = readl(nvidia_private.aperture+(i * PAGE_SIZE / sizeof(u32)));
269 for(i = 0; i < 32 + 1; i++) 270 for (i = 0; i < 32 + 1; i++)
270 temp = readl(nvidia_private.aperture+(i * PAGE_SIZE / sizeof(u32))); 271 temp = readl(nvidia_private.aperture+(i * PAGE_SIZE / sizeof(u32)));
271} 272}
272 273
@@ -323,7 +324,7 @@ static int __devinit agp_nvidia_probe(struct pci_dev *pdev,
323 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2)); 324 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(0, 2));
324 nvidia_private.dev_3 = 325 nvidia_private.dev_3 =
325 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0)); 326 pci_find_slot((unsigned int)pdev->bus->number, PCI_DEVFN(30, 0));
326 327
327 if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) { 328 if (!nvidia_private.dev_1 || !nvidia_private.dev_2 || !nvidia_private.dev_3) {
328 printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 " 329 printk(KERN_INFO PFX "Detected an NVIDIA nForce/nForce2 "
329 "chipset, but could not find the secondary devices.\n"); 330 "chipset, but could not find the secondary devices.\n");