nouveau_mem.c 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563
  1. /*
  2. * Copyright (C) The Weather Channel, Inc. 2002. All Rights Reserved.
  3. * Copyright 2005 Stephane Marchesin
  4. *
  5. * The Weather Channel (TM) funded Tungsten Graphics to develop the
  6. * initial release of the Radeon 8500 driver under the XFree86 license.
  7. * This notice must be preserved.
  8. *
  9. * Permission is hereby granted, free of charge, to any person obtaining a
  10. * copy of this software and associated documentation files (the "Software"),
  11. * to deal in the Software without restriction, including without limitation
  12. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  13. * and/or sell copies of the Software, and to permit persons to whom the
  14. * Software is furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice (including the next
  17. * paragraph) shall be included in all copies or substantial portions of the
  18. * Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  23. * THE AUTHORS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
  24. * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
  25. * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  26. * DEALINGS IN THE SOFTWARE.
  27. *
  28. * Authors:
  29. * Keith Whitwell <keith@tungstengraphics.com>
  30. */
  31. #include "drmP.h"
  32. #include "drm.h"
  33. #include "drm_sarea.h"
  34. #include "nouveau_drv.h"
  35. /*
  36. * NV10-NV40 tiling helpers
  37. */
  38. static void
  39. nv10_mem_set_region_tiling(struct drm_device *dev, int i, uint32_t addr,
  40. uint32_t size, uint32_t pitch)
  41. {
  42. struct drm_nouveau_private *dev_priv = dev->dev_private;
  43. struct nouveau_fifo_engine *pfifo = &dev_priv->engine.fifo;
  44. struct nouveau_fb_engine *pfb = &dev_priv->engine.fb;
  45. struct nouveau_pgraph_engine *pgraph = &dev_priv->engine.graph;
  46. struct nouveau_tile_reg *tile = &dev_priv->tile.reg[i];
  47. tile->addr = addr;
  48. tile->size = size;
  49. tile->used = !!pitch;
  50. nouveau_fence_unref((void **)&tile->fence);
  51. if (!pfifo->cache_flush(dev))
  52. return;
  53. pfifo->reassign(dev, false);
  54. pfifo->cache_flush(dev);
  55. pfifo->cache_pull(dev, false);
  56. nouveau_wait_for_idle(dev);
  57. pgraph->set_region_tiling(dev, i, addr, size, pitch);
  58. pfb->set_region_tiling(dev, i, addr, size, pitch);
  59. pfifo->cache_pull(dev, true);
  60. pfifo->reassign(dev, true);
  61. }
  62. struct nouveau_tile_reg *
  63. nv10_mem_set_tiling(struct drm_device *dev, uint32_t addr, uint32_t size,
  64. uint32_t pitch)
  65. {
  66. struct drm_nouveau_private *dev_priv = dev->dev_private;
  67. struct nouveau_fb_engine *pfb = &dev_priv->engine.fb;
  68. struct nouveau_tile_reg *tile = dev_priv->tile.reg, *found = NULL;
  69. int i;
  70. spin_lock(&dev_priv->tile.lock);
  71. for (i = 0; i < pfb->num_tiles; i++) {
  72. if (tile[i].used)
  73. /* Tile region in use. */
  74. continue;
  75. if (tile[i].fence &&
  76. !nouveau_fence_signalled(tile[i].fence, NULL))
  77. /* Pending tile region. */
  78. continue;
  79. if (max(tile[i].addr, addr) <
  80. min(tile[i].addr + tile[i].size, addr + size))
  81. /* Kill an intersecting tile region. */
  82. nv10_mem_set_region_tiling(dev, i, 0, 0, 0);
  83. if (pitch && !found) {
  84. /* Free tile region. */
  85. nv10_mem_set_region_tiling(dev, i, addr, size, pitch);
  86. found = &tile[i];
  87. }
  88. }
  89. spin_unlock(&dev_priv->tile.lock);
  90. return found;
  91. }
  92. void
  93. nv10_mem_expire_tiling(struct drm_device *dev, struct nouveau_tile_reg *tile,
  94. struct nouveau_fence *fence)
  95. {
  96. if (fence) {
  97. /* Mark it as pending. */
  98. tile->fence = fence;
  99. nouveau_fence_ref(fence);
  100. }
  101. tile->used = false;
  102. }
  103. /*
  104. * NV50 VM helpers
  105. */
  106. int
  107. nv50_mem_vm_bind_linear(struct drm_device *dev, uint64_t virt, uint32_t size,
  108. uint32_t flags, uint64_t phys)
  109. {
  110. struct drm_nouveau_private *dev_priv = dev->dev_private;
  111. struct nouveau_gpuobj *pgt;
  112. unsigned block;
  113. int i;
  114. virt = ((virt - dev_priv->vm_vram_base) >> 16) << 1;
  115. size = (size >> 16) << 1;
  116. phys |= ((uint64_t)flags << 32);
  117. phys |= 1;
  118. if (dev_priv->vram_sys_base) {
  119. phys += dev_priv->vram_sys_base;
  120. phys |= 0x30;
  121. }
  122. dev_priv->engine.instmem.prepare_access(dev, true);
  123. while (size) {
  124. unsigned offset_h = upper_32_bits(phys);
  125. unsigned offset_l = lower_32_bits(phys);
  126. unsigned pte, end;
  127. for (i = 7; i >= 0; i--) {
  128. block = 1 << (i + 1);
  129. if (size >= block && !(virt & (block - 1)))
  130. break;
  131. }
  132. offset_l |= (i << 7);
  133. phys += block << 15;
  134. size -= block;
  135. while (block) {
  136. pgt = dev_priv->vm_vram_pt[virt >> 14];
  137. pte = virt & 0x3ffe;
  138. end = pte + block;
  139. if (end > 16384)
  140. end = 16384;
  141. block -= (end - pte);
  142. virt += (end - pte);
  143. while (pte < end) {
  144. nv_wo32(dev, pgt, pte++, offset_l);
  145. nv_wo32(dev, pgt, pte++, offset_h);
  146. }
  147. }
  148. }
  149. dev_priv->engine.instmem.finish_access(dev);
  150. nv_wr32(dev, 0x100c80, 0x00050001);
  151. if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
  152. NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
  153. NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80));
  154. return -EBUSY;
  155. }
  156. nv_wr32(dev, 0x100c80, 0x00000001);
  157. if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
  158. NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
  159. NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80));
  160. return -EBUSY;
  161. }
  162. nv_wr32(dev, 0x100c80, 0x00040001);
  163. if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
  164. NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
  165. NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80));
  166. return -EBUSY;
  167. }
  168. nv_wr32(dev, 0x100c80, 0x00060001);
  169. if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
  170. NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
  171. NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80));
  172. return -EBUSY;
  173. }
  174. return 0;
  175. }
  176. void
  177. nv50_mem_vm_unbind(struct drm_device *dev, uint64_t virt, uint32_t size)
  178. {
  179. struct drm_nouveau_private *dev_priv = dev->dev_private;
  180. struct nouveau_gpuobj *pgt;
  181. unsigned pages, pte, end;
  182. virt -= dev_priv->vm_vram_base;
  183. pages = (size >> 16) << 1;
  184. dev_priv->engine.instmem.prepare_access(dev, true);
  185. while (pages) {
  186. pgt = dev_priv->vm_vram_pt[virt >> 29];
  187. pte = (virt & 0x1ffe0000ULL) >> 15;
  188. end = pte + pages;
  189. if (end > 16384)
  190. end = 16384;
  191. pages -= (end - pte);
  192. virt += (end - pte) << 15;
  193. while (pte < end)
  194. nv_wo32(dev, pgt, pte++, 0);
  195. }
  196. dev_priv->engine.instmem.finish_access(dev);
  197. nv_wr32(dev, 0x100c80, 0x00050001);
  198. if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
  199. NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
  200. NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80));
  201. return;
  202. }
  203. nv_wr32(dev, 0x100c80, 0x00000001);
  204. if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
  205. NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
  206. NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80));
  207. return;
  208. }
  209. nv_wr32(dev, 0x100c80, 0x00040001);
  210. if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
  211. NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
  212. NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80));
  213. return;
  214. }
  215. nv_wr32(dev, 0x100c80, 0x00060001);
  216. if (!nv_wait(0x100c80, 0x00000001, 0x00000000)) {
  217. NV_ERROR(dev, "timeout: (0x100c80 & 1) == 0 (2)\n");
  218. NV_ERROR(dev, "0x100c80 = 0x%08x\n", nv_rd32(dev, 0x100c80));
  219. }
  220. }
  221. /*
  222. * Cleanup everything
  223. */
  224. void
  225. nouveau_mem_close(struct drm_device *dev)
  226. {
  227. struct drm_nouveau_private *dev_priv = dev->dev_private;
  228. nouveau_bo_unpin(dev_priv->vga_ram);
  229. nouveau_bo_ref(NULL, &dev_priv->vga_ram);
  230. ttm_bo_device_release(&dev_priv->ttm.bdev);
  231. nouveau_ttm_global_release(dev_priv);
  232. if (drm_core_has_AGP(dev) && dev->agp) {
  233. struct drm_agp_mem *entry, *tempe;
  234. /* Remove AGP resources, but leave dev->agp
  235. intact until drv_cleanup is called. */
  236. list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
  237. if (entry->bound)
  238. drm_unbind_agp(entry->memory);
  239. drm_free_agp(entry->memory, entry->pages);
  240. kfree(entry);
  241. }
  242. INIT_LIST_HEAD(&dev->agp->memory);
  243. if (dev->agp->acquired)
  244. drm_agp_release(dev);
  245. dev->agp->acquired = 0;
  246. dev->agp->enabled = 0;
  247. }
  248. if (dev_priv->fb_mtrr) {
  249. drm_mtrr_del(dev_priv->fb_mtrr,
  250. pci_resource_start(dev->pdev, 1),
  251. pci_resource_len(dev->pdev, 1), DRM_MTRR_WC);
  252. dev_priv->fb_mtrr = 0;
  253. }
  254. }
  255. static uint32_t
  256. nouveau_mem_detect_nv04(struct drm_device *dev)
  257. {
  258. uint32_t boot0 = nv_rd32(dev, NV03_BOOT_0);
  259. if (boot0 & 0x00000100)
  260. return (((boot0 >> 12) & 0xf) * 2 + 2) * 1024 * 1024;
  261. switch (boot0 & NV03_BOOT_0_RAM_AMOUNT) {
  262. case NV04_BOOT_0_RAM_AMOUNT_32MB:
  263. return 32 * 1024 * 1024;
  264. case NV04_BOOT_0_RAM_AMOUNT_16MB:
  265. return 16 * 1024 * 1024;
  266. case NV04_BOOT_0_RAM_AMOUNT_8MB:
  267. return 8 * 1024 * 1024;
  268. case NV04_BOOT_0_RAM_AMOUNT_4MB:
  269. return 4 * 1024 * 1024;
  270. }
  271. return 0;
  272. }
  273. static uint32_t
  274. nouveau_mem_detect_nforce(struct drm_device *dev)
  275. {
  276. struct drm_nouveau_private *dev_priv = dev->dev_private;
  277. struct pci_dev *bridge;
  278. uint32_t mem;
  279. bridge = pci_get_bus_and_slot(0, PCI_DEVFN(0, 1));
  280. if (!bridge) {
  281. NV_ERROR(dev, "no bridge device\n");
  282. return 0;
  283. }
  284. if (dev_priv->flags & NV_NFORCE) {
  285. pci_read_config_dword(bridge, 0x7C, &mem);
  286. return (uint64_t)(((mem >> 6) & 31) + 1)*1024*1024;
  287. } else
  288. if (dev_priv->flags & NV_NFORCE2) {
  289. pci_read_config_dword(bridge, 0x84, &mem);
  290. return (uint64_t)(((mem >> 4) & 127) + 1)*1024*1024;
  291. }
  292. NV_ERROR(dev, "impossible!\n");
  293. return 0;
  294. }
  295. /* returns the amount of FB ram in bytes */
  296. int
  297. nouveau_mem_detect(struct drm_device *dev)
  298. {
  299. struct drm_nouveau_private *dev_priv = dev->dev_private;
  300. if (dev_priv->card_type == NV_04) {
  301. dev_priv->vram_size = nouveau_mem_detect_nv04(dev);
  302. } else
  303. if (dev_priv->flags & (NV_NFORCE | NV_NFORCE2)) {
  304. dev_priv->vram_size = nouveau_mem_detect_nforce(dev);
  305. } else
  306. if (dev_priv->card_type < NV_50) {
  307. dev_priv->vram_size = nv_rd32(dev, NV04_FIFO_DATA);
  308. dev_priv->vram_size &= NV10_FIFO_DATA_RAM_AMOUNT_MB_MASK;
  309. } else {
  310. dev_priv->vram_size = nv_rd32(dev, NV04_FIFO_DATA);
  311. dev_priv->vram_size |= (dev_priv->vram_size & 0xff) << 32;
  312. dev_priv->vram_size &= 0xffffffff00;
  313. if (dev_priv->chipset == 0xaa || dev_priv->chipset == 0xac) {
  314. dev_priv->vram_sys_base = nv_rd32(dev, 0x100e10);
  315. dev_priv->vram_sys_base <<= 12;
  316. }
  317. }
  318. NV_INFO(dev, "Detected %dMiB VRAM\n", (int)(dev_priv->vram_size >> 20));
  319. if (dev_priv->vram_sys_base) {
  320. NV_INFO(dev, "Stolen system memory at: 0x%010llx\n",
  321. dev_priv->vram_sys_base);
  322. }
  323. if (dev_priv->vram_size)
  324. return 0;
  325. return -ENOMEM;
  326. }
  327. #if __OS_HAS_AGP
  328. static void nouveau_mem_reset_agp(struct drm_device *dev)
  329. {
  330. uint32_t saved_pci_nv_1, saved_pci_nv_19, pmc_enable;
  331. saved_pci_nv_1 = nv_rd32(dev, NV04_PBUS_PCI_NV_1);
  332. saved_pci_nv_19 = nv_rd32(dev, NV04_PBUS_PCI_NV_19);
  333. /* clear busmaster bit */
  334. nv_wr32(dev, NV04_PBUS_PCI_NV_1, saved_pci_nv_1 & ~0x4);
  335. /* clear SBA and AGP bits */
  336. nv_wr32(dev, NV04_PBUS_PCI_NV_19, saved_pci_nv_19 & 0xfffff0ff);
  337. /* power cycle pgraph, if enabled */
  338. pmc_enable = nv_rd32(dev, NV03_PMC_ENABLE);
  339. if (pmc_enable & NV_PMC_ENABLE_PGRAPH) {
  340. nv_wr32(dev, NV03_PMC_ENABLE,
  341. pmc_enable & ~NV_PMC_ENABLE_PGRAPH);
  342. nv_wr32(dev, NV03_PMC_ENABLE, nv_rd32(dev, NV03_PMC_ENABLE) |
  343. NV_PMC_ENABLE_PGRAPH);
  344. }
  345. /* and restore (gives effect of resetting AGP) */
  346. nv_wr32(dev, NV04_PBUS_PCI_NV_19, saved_pci_nv_19);
  347. nv_wr32(dev, NV04_PBUS_PCI_NV_1, saved_pci_nv_1);
  348. }
  349. #endif
  350. int
  351. nouveau_mem_init_agp(struct drm_device *dev)
  352. {
  353. #if __OS_HAS_AGP
  354. struct drm_nouveau_private *dev_priv = dev->dev_private;
  355. struct drm_agp_info info;
  356. struct drm_agp_mode mode;
  357. int ret;
  358. if (nouveau_noagp)
  359. return 0;
  360. nouveau_mem_reset_agp(dev);
  361. if (!dev->agp->acquired) {
  362. ret = drm_agp_acquire(dev);
  363. if (ret) {
  364. NV_ERROR(dev, "Unable to acquire AGP: %d\n", ret);
  365. return ret;
  366. }
  367. }
  368. ret = drm_agp_info(dev, &info);
  369. if (ret) {
  370. NV_ERROR(dev, "Unable to get AGP info: %d\n", ret);
  371. return ret;
  372. }
  373. /* see agp.h for the AGPSTAT_* modes available */
  374. mode.mode = info.mode;
  375. ret = drm_agp_enable(dev, mode);
  376. if (ret) {
  377. NV_ERROR(dev, "Unable to enable AGP: %d\n", ret);
  378. return ret;
  379. }
  380. dev_priv->gart_info.type = NOUVEAU_GART_AGP;
  381. dev_priv->gart_info.aper_base = info.aperture_base;
  382. dev_priv->gart_info.aper_size = info.aperture_size;
  383. #endif
  384. return 0;
  385. }
  386. int
  387. nouveau_mem_init(struct drm_device *dev)
  388. {
  389. struct drm_nouveau_private *dev_priv = dev->dev_private;
  390. struct ttm_bo_device *bdev = &dev_priv->ttm.bdev;
  391. int ret, dma_bits = 32;
  392. dev_priv->fb_phys = pci_resource_start(dev->pdev, 1);
  393. dev_priv->gart_info.type = NOUVEAU_GART_NONE;
  394. if (dev_priv->card_type >= NV_50 &&
  395. pci_dma_supported(dev->pdev, DMA_BIT_MASK(40)))
  396. dma_bits = 40;
  397. ret = pci_set_dma_mask(dev->pdev, DMA_BIT_MASK(dma_bits));
  398. if (ret) {
  399. NV_ERROR(dev, "Error setting DMA mask: %d\n", ret);
  400. return ret;
  401. }
  402. ret = nouveau_ttm_global_init(dev_priv);
  403. if (ret)
  404. return ret;
  405. ret = ttm_bo_device_init(&dev_priv->ttm.bdev,
  406. dev_priv->ttm.bo_global_ref.ref.object,
  407. &nouveau_bo_driver, DRM_FILE_PAGE_OFFSET,
  408. dma_bits <= 32 ? true : false);
  409. if (ret) {
  410. NV_ERROR(dev, "Error initialising bo driver: %d\n", ret);
  411. return ret;
  412. }
  413. INIT_LIST_HEAD(&dev_priv->ttm.bo_list);
  414. spin_lock_init(&dev_priv->ttm.bo_list_lock);
  415. spin_lock_init(&dev_priv->tile.lock);
  416. dev_priv->fb_available_size = dev_priv->vram_size;
  417. dev_priv->fb_mappable_pages = dev_priv->fb_available_size;
  418. if (dev_priv->fb_mappable_pages > pci_resource_len(dev->pdev, 1))
  419. dev_priv->fb_mappable_pages =
  420. pci_resource_len(dev->pdev, 1);
  421. dev_priv->fb_mappable_pages >>= PAGE_SHIFT;
  422. /* remove reserved space at end of vram from available amount */
  423. dev_priv->fb_available_size -= dev_priv->ramin_rsvd_vram;
  424. dev_priv->fb_aper_free = dev_priv->fb_available_size;
  425. /* mappable vram */
  426. ret = ttm_bo_init_mm(bdev, TTM_PL_VRAM,
  427. dev_priv->fb_available_size >> PAGE_SHIFT);
  428. if (ret) {
  429. NV_ERROR(dev, "Failed VRAM mm init: %d\n", ret);
  430. return ret;
  431. }
  432. ret = nouveau_bo_new(dev, NULL, 256*1024, 0, TTM_PL_FLAG_VRAM,
  433. 0, 0, true, true, &dev_priv->vga_ram);
  434. if (ret == 0)
  435. ret = nouveau_bo_pin(dev_priv->vga_ram, TTM_PL_FLAG_VRAM);
  436. if (ret) {
  437. NV_WARN(dev, "failed to reserve VGA memory\n");
  438. nouveau_bo_ref(NULL, &dev_priv->vga_ram);
  439. }
  440. /* GART */
  441. #if !defined(__powerpc__) && !defined(__ia64__)
  442. if (drm_device_is_agp(dev) && dev->agp) {
  443. ret = nouveau_mem_init_agp(dev);
  444. if (ret)
  445. NV_ERROR(dev, "Error initialising AGP: %d\n", ret);
  446. }
  447. #endif
  448. if (dev_priv->gart_info.type == NOUVEAU_GART_NONE) {
  449. ret = nouveau_sgdma_init(dev);
  450. if (ret) {
  451. NV_ERROR(dev, "Error initialising PCI(E): %d\n", ret);
  452. return ret;
  453. }
  454. }
  455. NV_INFO(dev, "%d MiB GART (aperture)\n",
  456. (int)(dev_priv->gart_info.aper_size >> 20));
  457. dev_priv->gart_info.aper_free = dev_priv->gart_info.aper_size;
  458. ret = ttm_bo_init_mm(bdev, TTM_PL_TT,
  459. dev_priv->gart_info.aper_size >> PAGE_SHIFT);
  460. if (ret) {
  461. NV_ERROR(dev, "Failed TT mm init: %d\n", ret);
  462. return ret;
  463. }
  464. dev_priv->fb_mtrr = drm_mtrr_add(pci_resource_start(dev->pdev, 1),
  465. pci_resource_len(dev->pdev, 1),
  466. DRM_MTRR_WC);
  467. return 0;
  468. }