Magellan Linux

Contents of /trunk/nvidia/1.0.6629/NVIDIA_kernel-1.0-6629-1201042.diff

Parent Directory Parent Directory | Revision Log Revision Log


Revision 153 - (show annotations) (download)
Tue May 8 20:52:56 2007 UTC (17 years ago) by niro
File size: 9445 byte(s)
-import

1 diff -ru usr/src/nv/nv-linux.h usr/src/nv.1201042/nv-linux.h
2 --- usr/src/nv/nv-linux.h 2004-11-03 22:53:00.000000000 +0100
3 +++ usr/src/nv.1201042/nv-linux.h 2005-01-26 01:56:26.000000000 +0100
4 @@ -565,11 +565,6 @@
5 #define PCI_CAP_ID_EXP 0x10
6 #endif
7
8 -#if defined(KERNEL_2_6) && defined(AGPGART)
9 -typedef struct agp_kern_info agp_kern_info;
10 -typedef struct agp_memory agp_memory;
11 -#endif
12 -
13 #if defined(CONFIG_DEVFS_FS)
14 # if defined(KERNEL_2_6)
15 typedef void* devfs_handle_t;
16 diff -ru usr/src/nv/nv.c usr/src/nv.1201042/nv.c
17 --- usr/src/nv/nv.c 2004-11-03 22:53:00.000000000 +0100
18 +++ usr/src/nv.1201042/nv.c 2005-01-26 01:56:28.000000000 +0100
19 @@ -2987,32 +2987,47 @@
20 */
21 if ( (!NV_AGP_ENABLED(nv)) && (config & NVOS_AGP_CONFIG_NVAGP) )
22 {
23 - /* make sure the user does not have agpgart loaded */
24 - if (inter_module_get("drm_agp")) {
25 +#if defined(KERNEL_2_4)
26 + if (inter_module_get("drm_agp"))
27 + {
28 inter_module_put("drm_agp");
29 - nv_printf(NV_DBG_WARNINGS, "NVRM: not using NVAGP, AGPGART is loaded!!\n");
30 - } else {
31 -#if defined(CONFIG_X86_64) && defined(CONFIG_GART_IOMMU)
32 + nv_printf(NV_DBG_WARNINGS, "NVRM: not using NVAGP, AGPGART is loaded!\n");
33 + return status;
34 + }
35 +#elif defined(AGPGART)
36 + int error;
37 + /*
38 + * We can only safely use NvAGP when no backend has been
39 + * registered with the AGPGART frontend. This condition
40 + * is only met when the acquire function returns -EINVAL.
41 + *
42 + * Other return codes indicate that a backend is present
43 + * and was either acquired, busy or else unavailable.
44 + */
45 + if ((error = agp_backend_acquire()) != -EINVAL)
46 + {
47 + if (!error) agp_backend_release();
48 nv_printf(NV_DBG_WARNINGS,
49 - "NVRM: not using NVAGP, kernel was compiled with GART_IOMMU support!!\n");
50 -#else
51 - status = rm_init_agp(nv);
52 - if (status == RM_OK)
53 - {
54 - nv->agp_config = NVOS_AGP_CONFIG_NVAGP;
55 - nv->agp_status = NV_AGP_STATUS_ENABLED;
56 - }
57 + "NVRM: not using NVAGP, an AGPGART backend is loaded!\n");
58 + return status;
59 + }
60 #endif
61 +#if defined(CONFIG_X86_64) && defined(CONFIG_GART_IOMMU)
62 + nv_printf(NV_DBG_WARNINGS,
63 + "NVRM: not using NVAGP, kernel was compiled with GART_IOMMU support!\n");
64 +#else
65 + status = rm_init_agp(nv);
66 + if (status == RM_OK)
67 + {
68 + nv->agp_config = NVOS_AGP_CONFIG_NVAGP;
69 + nv->agp_status = NV_AGP_STATUS_ENABLED;
70 }
71 +#endif
72 }
73
74 if (NV_AGP_ENABLED(nv))
75 old_error = 0; /* report new errors */
76
77 - nv_printf(NV_DBG_SETUP,
78 - "NVRM: agp_init finished with status 0x%x and config %d\n",
79 - status, nv->agp_config);
80 -
81 return status;
82 }
83
84 @@ -3036,9 +3051,6 @@
85 nv->agp_config = NVOS_AGP_CONFIG_DISABLE_AGP;
86 nv->agp_status = NV_AGP_STATUS_DISABLED;
87
88 - nv_printf(NV_DBG_SETUP, "NVRM: teardown finished with status 0x%x\n",
89 - status);
90 -
91 return status;
92 }
93
94 diff -ru usr/src/nv/os-agp.c usr/src/nv.1201042/os-agp.c
95 --- usr/src/nv/os-agp.c 2004-11-03 22:53:00.000000000 +0100
96 +++ usr/src/nv.1201042/os-agp.c 2005-01-26 01:56:30.000000000 +0100
97 @@ -25,6 +25,13 @@
98
99 #ifdef AGPGART
100
101 +#if defined(KERNEL_2_6)
102 +typedef struct agp_kern_info agp_kern_info;
103 +typedef struct agp_memory agp_memory;
104 +#elif defined(KERNEL_2_4)
105 +const drm_agp_t *drm_agp_p; /* functions */
106 +#endif
107 +
108 typedef struct {
109 agp_memory *ptr;
110 int num_pages;
111 @@ -45,7 +52,6 @@
112
113 agp_kern_info agpinfo;
114 agp_gart gart;
115 -const drm_agp_t *drm_agp_p;
116
117 #if defined(CONFIG_MTRR)
118 #define MTRR_DEL(gart) if ((gart).mtrr > 0) mtrr_del((gart).mtrr, 0, 0);
119 @@ -53,6 +59,26 @@
120 #define MTRR_DEL(gart)
121 #endif
122
123 +#if defined(KERNEL_2_6)
124 +#define NV_AGPGART_BACKEND_ACQUIRE(o) agp_backend_acquire()
125 +#define NV_AGPGART_BACKEND_ENABLE(o,mode) agp_enable(mode)
126 +#define NV_AGPGART_BACKEND_RELEASE(o) agp_backend_release()
127 +#define NV_AGPGART_COPY_INFO(o,p) agp_copy_info(p)
128 +#define NV_AGPGART_ALLOCATE_MEMORY(o,count,type) agp_allocate_memory(count,type)
129 +#define NV_AGPGART_FREE_MEMORY(o,p) agp_free_memory(p)
130 +#define NV_AGPGART_BIND_MEMORY(o,p,offset) agp_bind_memory(p,offset)
131 +#define NV_AGPGART_UNBIND_MEMORY(o,p) agp_unbind_memory(p)
132 +#elif defined(KERNEL_2_4)
133 +#define NV_AGPGART_BACKEND_ACQUIRE(o) ({ (o)->acquire(); 0; })
134 +#define NV_AGPGART_BACKEND_ENABLE(o,mode) (o)->enable(mode)
135 +#define NV_AGPGART_BACKEND_RELEASE(o) ((o)->release())
136 +#define NV_AGPGART_COPY_INFO(o,p) ({ (o)->copy_info(p); 0; })
137 +#define NV_AGPGART_ALLOCATE_MEMORY(o,count,type) (o)->allocate_memory(count,type)
138 +#define NV_AGPGART_FREE_MEMORY(o,p) (o)->free_memory(p)
139 +#define NV_AGPGART_BIND_MEMORY(o,p,offset) (o)->bind_memory(p,offset)
140 +#define NV_AGPGART_UNBIND_MEMORY(o,p) (o)->unbind_memory(p)
141 +#endif
142 +
143 #endif /* AGPGART */
144
145 BOOL KernInitAGP(
146 @@ -73,8 +99,10 @@
147
148 memset( (void *) &gart, 0, sizeof(agp_gart));
149
150 +#if defined(KERNEL_2_4)
151 if (!(drm_agp_p = inter_module_get_request("drm_agp", "agpgart")))
152 return 1;
153 +#endif
154
155 /* NOTE: from here down, return an error code of '-1'
156 * that indicates that agpgart is loaded, but we failed to use it
157 @@ -82,11 +110,10 @@
158 * the memory controller.
159 */
160
161 - if (drm_agp_p->acquire())
162 + if (NV_AGPGART_BACKEND_ACQUIRE(drm_agp_p))
163 {
164 - nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: backend in use\n");
165 - inter_module_put("drm_agp");
166 - return -1;
167 + nv_printf(NV_DBG_INFO, "NVRM: AGPGART: no backend available\n");
168 + goto bailout;
169 }
170
171 if (rm_read_registry_dword(nv, "NVreg", "ReqAGPRate", &agp_rate) == RM_ERROR)
172 @@ -101,21 +128,12 @@
173 agp_fw = 1;
174 agp_fw &= 0x00000001;
175
176 -#if defined(KERNEL_2_4)
177 - /*
178 - * The original Linux 2.4 AGP GART driver interface declared copy_info to
179 - * return nothing. This changed in Linux 2.5, which reports unsupported
180 - * chipsets via this function. If this Linux 2.4 kernels behaves the same
181 - * way, we have no way to know.
182 - */
183 - drm_agp_p->copy_info(&agpinfo);
184 -#else
185 - if (drm_agp_p->copy_info(&agpinfo)) {
186 + if (NV_AGPGART_COPY_INFO(drm_agp_p, &agpinfo))
187 + {
188 nv_printf(NV_DBG_ERRORS,
189 "NVRM: AGPGART: kernel reports chipset as unsupported\n");
190 goto failed;
191 }
192 -#endif
193
194 #ifdef CONFIG_MTRR
195 /*
196 @@ -170,7 +188,7 @@
197 if (!(agp_rate & 0x00000004)) agpinfo.mode &= ~0x00000004;
198 if (!(agp_rate & 0x00000002)) agpinfo.mode &= ~0x00000002;
199
200 - drm_agp_p->enable(agpinfo.mode);
201 + NV_AGPGART_BACKEND_ENABLE(drm_agp_p, agpinfo.mode);
202
203 *ap_phys_base = (void*) agpinfo.aper_base;
204 *ap_mapped_base = (void*) gart.aperture;
205 @@ -182,8 +200,11 @@
206
207 failed:
208 MTRR_DEL(gart); /* checks gart.mtrr */
209 - drm_agp_p->release();
210 + NV_AGPGART_BACKEND_RELEASE(drm_agp_p);
211 +bailout:
212 +#if defined(KERNEL_2_4)
213 inter_module_put("drm_agp");
214 +#endif
215
216 return -1;
217
218 @@ -213,9 +234,10 @@
219 NV_IOUNMAP(gart.aperture, RM_PAGE_SIZE);
220 }
221
222 - drm_agp_p->release();
223 -
224 + NV_AGPGART_BACKEND_RELEASE(drm_agp_p);
225 +#if defined(KERNEL_2_4)
226 inter_module_put("drm_agp");
227 +#endif
228
229 if (rm_clear_agp_bitmap(nv, &bitmap))
230 {
231 @@ -244,7 +266,6 @@
232 return RM_ERROR;
233 #else
234 agp_memory *ptr;
235 - int err;
236 agp_priv_data *data;
237 RM_STATUS status;
238
239 @@ -262,7 +283,7 @@
240 return RM_ERROR;
241 }
242
243 - ptr = drm_agp_p->allocate_memory(PageCount, AGP_NORMAL_MEMORY);
244 + ptr = NV_AGPGART_ALLOCATE_MEMORY(drm_agp_p, PageCount, AGP_NORMAL_MEMORY);
245 if (ptr == NULL)
246 {
247 *pAddress = (void*) 0;
248 @@ -270,8 +291,7 @@
249 return RM_ERR_NO_FREE_MEM;
250 }
251
252 - err = drm_agp_p->bind_memory(ptr, *Offset);
253 - if (err)
254 + if (NV_AGPGART_BIND_MEMORY(drm_agp_p, ptr, *Offset))
255 {
256 // this happens a lot when the aperture itself fills up..
257 // not a big deal, so don't alarm people with an error message
258 @@ -280,14 +300,11 @@
259 goto fail;
260 }
261
262 - /* return the agp aperture address */
263 - *pAddress = (void *) (agpinfo.aper_base + (*Offset << PAGE_SHIFT));
264 -
265 status = os_alloc_mem((void **)&data, sizeof(agp_priv_data));
266 if (status != RM_OK)
267 {
268 nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: memory allocation failed\n");
269 - drm_agp_p->unbind_memory(ptr);
270 + NV_AGPGART_UNBIND_MEMORY(drm_agp_p, ptr);
271 goto fail;
272 }
273
274 @@ -302,7 +319,7 @@
275 return RM_OK;
276
277 fail:
278 - drm_agp_p->free_memory(ptr);
279 + NV_AGPGART_FREE_MEMORY(drm_agp_p, ptr);
280 *pAddress = (void*) 0;
281
282 return RM_ERROR;
283 @@ -342,7 +359,7 @@
284 {
285 nv_printf(NV_DBG_ERRORS, "NVRM: AGPGART: unable to remap %lu pages\n",
286 (unsigned long)agp_data->num_pages);
287 - drm_agp_p->unbind_memory(agp_data->ptr);
288 + NV_AGPGART_UNBIND_MEMORY(drm_agp_p, agp_data->ptr);
289 goto fail;
290 }
291
292 @@ -441,8 +458,8 @@
293 {
294 size_t pages = ptr->page_count;
295
296 - drm_agp_p->unbind_memory(ptr);
297 - drm_agp_p->free_memory(ptr);
298 + NV_AGPGART_UNBIND_MEMORY(drm_agp_p, ptr);
299 + NV_AGPGART_FREE_MEMORY(drm_agp_p, ptr);
300
301 nv_printf(NV_DBG_INFO, "NVRM: AGPGART: freed %ld pages\n",
302 (unsigned long)pages);

Properties

Name Value
svn:executable *