2 * Intel GTT (Graphics Translation Table) routines
4 * Caveat: This driver implements the linux agp interface, but this is far from
5 * a agp driver! GTT support ended up here for purely historical reasons: The
6 * old userspace intel graphics drivers needed an interface to map memory into
7 * the GTT. And the drm provides a default interface for graphic devices sitting
8 * on an agp port. So it made sense to fake the GTT support as an agp port to
9 * avoid having to create a new api.
11 * With gem this does not make much sense anymore, just needlessly complicates
12 * the code. But as long as the old graphics stack is still support, it's stuck
15 * /fairy-tale-mode off
18 #include <linux/module.h>
19 #include <linux/pci.h>
20 #include <linux/init.h>
21 #include <linux/kernel.h>
22 #include <linux/pagemap.h>
23 #include <linux/agp_backend.h>
24 #include <linux/delay.h>
27 #include "intel-agp.h"
28 #include <drm/intel-gtt.h>
31 * If we have Intel graphics, we're not going to have anything other than
32 * an Intel IOMMU. So make the correct use of the PCI DMA API contingent
33 * on the Intel IOMMU support (CONFIG_INTEL_IOMMU).
34 * Only newer chipsets need to bother with this, of course.
36 #ifdef CONFIG_INTEL_IOMMU
37 #define USE_PCI_DMA_API 1
39 #define USE_PCI_DMA_API 0
42 struct intel_gtt_driver {
44 unsigned int is_g33 : 1;
45 unsigned int is_pineview : 1;
46 unsigned int is_ironlake : 1;
47 unsigned int has_pgtbl_enable : 1;
48 unsigned int dma_mask_size : 8;
49 /* Chipset specific GTT setup */
51 /* This should undo anything done in ->setup() save the unmapping
52 * of the mmio register file, that's done in the generic code. */
53 void (*cleanup)(void);
54 void (*write_entry)(dma_addr_t addr, unsigned int entry, unsigned int flags);
55 /* Flags is a more or less chipset specific opaque value.
56 * For chipsets that need to support old ums (non-gem) code, this
57 * needs to be identical to the various supported agp memory types! */
58 bool (*check_flags)(unsigned int flags);
59 void (*chipset_flush)(void);
62 static struct _intel_private {
63 struct intel_gtt base;
64 const struct intel_gtt_driver *driver;
65 struct pci_dev *pcidev; /* device one */
66 struct pci_dev *bridge_dev;
67 u8 __iomem *registers;
68 phys_addr_t gtt_bus_addr;
70 u32 __iomem *gtt; /* I915G */
71 bool clear_fake_agp; /* on first access via agp, fill with scratch */
72 int num_dcache_entries;
73 void __iomem *i9xx_flush_page;
75 struct resource ifp_resource;
77 struct page *scratch_page;
80 #define INTEL_GTT_GEN intel_private.driver->gen
81 #define IS_G33 intel_private.driver->is_g33
82 #define IS_PINEVIEW intel_private.driver->is_pineview
83 #define IS_IRONLAKE intel_private.driver->is_ironlake
84 #define HAS_PGTBL_EN intel_private.driver->has_pgtbl_enable
86 int intel_gtt_map_memory(struct page **pages, unsigned int num_entries,
87 struct scatterlist **sg_list, int *num_sg)
90 struct scatterlist *sg;
94 return 0; /* already mapped (for e.g. resume */
96 DBG("try mapping %lu pages\n", (unsigned long)num_entries);
98 if (sg_alloc_table(&st, num_entries, GFP_KERNEL))
101 *sg_list = sg = st.sgl;
103 for (i = 0 ; i < num_entries; i++, sg = sg_next(sg))
104 sg_set_page(sg, pages[i], PAGE_SIZE, 0);
106 *num_sg = pci_map_sg(intel_private.pcidev, *sg_list,
107 num_entries, PCI_DMA_BIDIRECTIONAL);
108 if (unlikely(!*num_sg))
117 EXPORT_SYMBOL(intel_gtt_map_memory);
119 void intel_gtt_unmap_memory(struct scatterlist *sg_list, int num_sg)
122 DBG("try unmapping %lu pages\n", (unsigned long)mem->page_count);
124 pci_unmap_sg(intel_private.pcidev, sg_list,
125 num_sg, PCI_DMA_BIDIRECTIONAL);
128 st.orig_nents = st.nents = num_sg;
132 EXPORT_SYMBOL(intel_gtt_unmap_memory);
134 static void intel_fake_agp_enable(struct agp_bridge_data *bridge, u32 mode)
139 /* Exists to support ARGB cursors */
140 static struct page *i8xx_alloc_pages(void)
144 page = alloc_pages(GFP_KERNEL | GFP_DMA32, 2);
148 if (set_pages_uc(page, 4) < 0) {
149 set_pages_wb(page, 4);
150 __free_pages(page, 2);
154 atomic_inc(&agp_bridge->current_memory_agp);
158 static void i8xx_destroy_pages(struct page *page)
163 set_pages_wb(page, 4);
165 __free_pages(page, 2);
166 atomic_dec(&agp_bridge->current_memory_agp);
169 #define I810_GTT_ORDER 4
170 static int i810_setup(void)
175 /* i81x does not preallocate the gtt. It's always 64kb in size. */
176 gtt_table = alloc_gatt_pages(I810_GTT_ORDER);
177 if (gtt_table == NULL)
179 intel_private.i81x_gtt_table = gtt_table;
181 pci_read_config_dword(intel_private.pcidev, I810_MMADDR, ®_addr);
182 reg_addr &= 0xfff80000;
184 intel_private.registers = ioremap(reg_addr, KB(64));
185 if (!intel_private.registers)
188 writel(virt_to_phys(gtt_table) | I810_PGETBL_ENABLED,
189 intel_private.registers+I810_PGETBL_CTL);
191 intel_private.gtt_bus_addr = reg_addr + I810_PTE_BASE;
193 if ((readl(intel_private.registers+I810_DRAM_CTL)
194 & I810_DRAM_ROW_0) == I810_DRAM_ROW_0_SDRAM) {
195 dev_info(&intel_private.pcidev->dev,
196 "detected 4MB dedicated video ram\n");
197 intel_private.num_dcache_entries = 1024;
203 static void i810_cleanup(void)
205 writel(0, intel_private.registers+I810_PGETBL_CTL);
206 free_gatt_pages(intel_private.i81x_gtt_table, I810_GTT_ORDER);
209 static int i810_insert_dcache_entries(struct agp_memory *mem, off_t pg_start,
214 if ((pg_start + mem->page_count)
215 > intel_private.num_dcache_entries)
218 if (!mem->is_flushed)
219 global_cache_flush();
221 for (i = pg_start; i < (pg_start + mem->page_count); i++) {
222 dma_addr_t addr = i << PAGE_SHIFT;
223 intel_private.driver->write_entry(addr,
226 readl(intel_private.gtt+i-1);
232 * The i810/i830 requires a physical address to program its mouse
233 * pointer into hardware.
234 * However the Xserver still writes to it through the agp aperture.
236 static struct agp_memory *alloc_agpphysmem_i8xx(size_t pg_count, int type)
238 struct agp_memory *new;
242 case 1: page = agp_bridge->driver->agp_alloc_page(agp_bridge);
245 /* kludge to get 4 physical pages for ARGB cursor */
246 page = i8xx_alloc_pages();
255 new = agp_create_memory(pg_count);
259 new->pages[0] = page;
261 /* kludge to get 4 physical pages for ARGB cursor */
262 new->pages[1] = new->pages[0] + 1;
263 new->pages[2] = new->pages[1] + 1;
264 new->pages[3] = new->pages[2] + 1;
266 new->page_count = pg_count;
267 new->num_scratch_pages = pg_count;
268 new->type = AGP_PHYS_MEMORY;
269 new->physical = page_to_phys(new->pages[0]);
273 static void intel_i810_free_by_type(struct agp_memory *curr)
275 agp_free_key(curr->key);
276 if (curr->type == AGP_PHYS_MEMORY) {
277 if (curr->page_count == 4)
278 i8xx_destroy_pages(curr->pages[0]);
280 agp_bridge->driver->agp_destroy_page(curr->pages[0],
281 AGP_PAGE_DESTROY_UNMAP);
282 agp_bridge->driver->agp_destroy_page(curr->pages[0],
283 AGP_PAGE_DESTROY_FREE);
285 agp_free_page_array(curr);
290 static int intel_gtt_setup_scratch_page(void)
295 page = alloc_page(GFP_KERNEL | GFP_DMA32 | __GFP_ZERO);
299 set_pages_uc(page, 1);
301 if (intel_private.base.needs_dmar) {
302 dma_addr = pci_map_page(intel_private.pcidev, page, 0,
303 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
304 if (pci_dma_mapping_error(intel_private.pcidev, dma_addr))
307 intel_private.base.scratch_page_dma = dma_addr;
309 intel_private.base.scratch_page_dma = page_to_phys(page);
311 intel_private.scratch_page = page;
316 static void i810_write_entry(dma_addr_t addr, unsigned int entry,
319 u32 pte_flags = I810_PTE_VALID;
322 case AGP_DCACHE_MEMORY:
323 pte_flags |= I810_PTE_LOCAL;
325 case AGP_USER_CACHED_MEMORY:
326 pte_flags |= I830_PTE_SYSTEM_CACHED;
330 writel(addr | pte_flags, intel_private.gtt + entry);
333 static const struct aper_size_info_fixed intel_fake_agp_sizes[] = {
341 static unsigned int intel_gtt_stolen_size(void)
346 static const int ddt[4] = { 0, 16, 32, 64 };
347 unsigned int stolen_size = 0;
349 if (INTEL_GTT_GEN == 1)
350 return 0; /* no stolen mem on i81x */
352 pci_read_config_word(intel_private.bridge_dev,
353 I830_GMCH_CTRL, &gmch_ctrl);
355 if (intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82830_HB ||
356 intel_private.bridge_dev->device == PCI_DEVICE_ID_INTEL_82845G_HB) {
357 switch (gmch_ctrl & I830_GMCH_GMS_MASK) {
358 case I830_GMCH_GMS_STOLEN_512:
359 stolen_size = KB(512);
361 case I830_GMCH_GMS_STOLEN_1024:
364 case I830_GMCH_GMS_STOLEN_8192:
367 case I830_GMCH_GMS_LOCAL:
368 rdct = readb(intel_private.registers+I830_RDRAM_CHANNEL_TYPE);
369 stolen_size = (I830_RDRAM_ND(rdct) + 1) *
370 MB(ddt[I830_RDRAM_DDT(rdct)]);
377 } else if (INTEL_GTT_GEN == 6) {
379 * SandyBridge has new memory control reg at 0x50.w
382 pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl);
383 switch (snb_gmch_ctl & SNB_GMCH_GMS_STOLEN_MASK) {
384 case SNB_GMCH_GMS_STOLEN_32M:
385 stolen_size = MB(32);
387 case SNB_GMCH_GMS_STOLEN_64M:
388 stolen_size = MB(64);
390 case SNB_GMCH_GMS_STOLEN_96M:
391 stolen_size = MB(96);
393 case SNB_GMCH_GMS_STOLEN_128M:
394 stolen_size = MB(128);
396 case SNB_GMCH_GMS_STOLEN_160M:
397 stolen_size = MB(160);
399 case SNB_GMCH_GMS_STOLEN_192M:
400 stolen_size = MB(192);
402 case SNB_GMCH_GMS_STOLEN_224M:
403 stolen_size = MB(224);
405 case SNB_GMCH_GMS_STOLEN_256M:
406 stolen_size = MB(256);
408 case SNB_GMCH_GMS_STOLEN_288M:
409 stolen_size = MB(288);
411 case SNB_GMCH_GMS_STOLEN_320M:
412 stolen_size = MB(320);
414 case SNB_GMCH_GMS_STOLEN_352M:
415 stolen_size = MB(352);
417 case SNB_GMCH_GMS_STOLEN_384M:
418 stolen_size = MB(384);
420 case SNB_GMCH_GMS_STOLEN_416M:
421 stolen_size = MB(416);
423 case SNB_GMCH_GMS_STOLEN_448M:
424 stolen_size = MB(448);
426 case SNB_GMCH_GMS_STOLEN_480M:
427 stolen_size = MB(480);
429 case SNB_GMCH_GMS_STOLEN_512M:
430 stolen_size = MB(512);
434 switch (gmch_ctrl & I855_GMCH_GMS_MASK) {
435 case I855_GMCH_GMS_STOLEN_1M:
438 case I855_GMCH_GMS_STOLEN_4M:
441 case I855_GMCH_GMS_STOLEN_8M:
444 case I855_GMCH_GMS_STOLEN_16M:
445 stolen_size = MB(16);
447 case I855_GMCH_GMS_STOLEN_32M:
448 stolen_size = MB(32);
450 case I915_GMCH_GMS_STOLEN_48M:
451 stolen_size = MB(48);
453 case I915_GMCH_GMS_STOLEN_64M:
454 stolen_size = MB(64);
456 case G33_GMCH_GMS_STOLEN_128M:
457 stolen_size = MB(128);
459 case G33_GMCH_GMS_STOLEN_256M:
460 stolen_size = MB(256);
462 case INTEL_GMCH_GMS_STOLEN_96M:
463 stolen_size = MB(96);
465 case INTEL_GMCH_GMS_STOLEN_160M:
466 stolen_size = MB(160);
468 case INTEL_GMCH_GMS_STOLEN_224M:
469 stolen_size = MB(224);
471 case INTEL_GMCH_GMS_STOLEN_352M:
472 stolen_size = MB(352);
480 if (stolen_size > 0) {
481 dev_info(&intel_private.bridge_dev->dev, "detected %dK %s memory\n",
482 stolen_size / KB(1), local ? "local" : "stolen");
484 dev_info(&intel_private.bridge_dev->dev,
485 "no pre-allocated video memory detected\n");
492 static void i965_adjust_pgetbl_size(unsigned int size_flag)
494 u32 pgetbl_ctl, pgetbl_ctl2;
496 /* ensure that ppgtt is disabled */
497 pgetbl_ctl2 = readl(intel_private.registers+I965_PGETBL_CTL2);
498 pgetbl_ctl2 &= ~I810_PGETBL_ENABLED;
499 writel(pgetbl_ctl2, intel_private.registers+I965_PGETBL_CTL2);
501 /* write the new ggtt size */
502 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL);
503 pgetbl_ctl &= ~I965_PGETBL_SIZE_MASK;
504 pgetbl_ctl |= size_flag;
505 writel(pgetbl_ctl, intel_private.registers+I810_PGETBL_CTL);
508 static unsigned int i965_gtt_total_entries(void)
514 pci_read_config_word(intel_private.bridge_dev,
515 I830_GMCH_CTRL, &gmch_ctl);
517 if (INTEL_GTT_GEN == 5) {
518 switch (gmch_ctl & G4x_GMCH_SIZE_MASK) {
519 case G4x_GMCH_SIZE_1M:
520 case G4x_GMCH_SIZE_VT_1M:
521 i965_adjust_pgetbl_size(I965_PGETBL_SIZE_1MB);
523 case G4x_GMCH_SIZE_VT_1_5M:
524 i965_adjust_pgetbl_size(I965_PGETBL_SIZE_1_5MB);
526 case G4x_GMCH_SIZE_2M:
527 case G4x_GMCH_SIZE_VT_2M:
528 i965_adjust_pgetbl_size(I965_PGETBL_SIZE_2MB);
533 pgetbl_ctl = readl(intel_private.registers+I810_PGETBL_CTL);
535 switch (pgetbl_ctl & I965_PGETBL_SIZE_MASK) {
536 case I965_PGETBL_SIZE_128KB:
539 case I965_PGETBL_SIZE_256KB:
542 case I965_PGETBL_SIZE_512KB:
545 /* GTT pagetable sizes bigger than 512KB are not possible on G33! */
546 case I965_PGETBL_SIZE_1MB:
549 case I965_PGETBL_SIZE_2MB:
552 case I965_PGETBL_SIZE_1_5MB:
553 size = KB(1024 + 512);
556 dev_info(&intel_private.pcidev->dev,
557 "unknown page table size, assuming 512KB\n");
564 static unsigned int intel_gtt_total_entries(void)
568 if (IS_G33 || INTEL_GTT_GEN == 4 || INTEL_GTT_GEN == 5)
569 return i965_gtt_total_entries();
570 else if (INTEL_GTT_GEN == 6) {
573 pci_read_config_word(intel_private.pcidev, SNB_GMCH_CTRL, &snb_gmch_ctl);
574 switch (snb_gmch_ctl & SNB_GTT_SIZE_MASK) {
576 case SNB_GTT_SIZE_0M:
577 printk(KERN_ERR "Bad GTT size mask: 0x%04x.\n", snb_gmch_ctl);
580 case SNB_GTT_SIZE_1M:
583 case SNB_GTT_SIZE_2M:
589 /* On previous hardware, the GTT size was just what was
590 * required to map the aperture.
592 return intel_private.base.gtt_mappable_entries;
596 static unsigned int intel_gtt_mappable_entries(void)
598 unsigned int aperture_size;
600 if (INTEL_GTT_GEN == 1) {
603 pci_read_config_dword(intel_private.bridge_dev,
604 I810_SMRAM_MISCC, &smram_miscc);
606 if ((smram_miscc & I810_GFX_MEM_WIN_SIZE)
607 == I810_GFX_MEM_WIN_32M)
608 aperture_size = MB(32);
610 aperture_size = MB(64);
611 } else if (INTEL_GTT_GEN == 2) {
614 pci_read_config_word(intel_private.bridge_dev,
615 I830_GMCH_CTRL, &gmch_ctrl);
617 if ((gmch_ctrl & I830_GMCH_MEM_MASK) == I830_GMCH_MEM_64M)
618 aperture_size = MB(64);
620 aperture_size = MB(128);
622 /* 9xx supports large sizes, just look at the length */
623 aperture_size = pci_resource_len(intel_private.pcidev, 2);
626 return aperture_size >> PAGE_SHIFT;
629 static void intel_gtt_teardown_scratch_page(void)
631 set_pages_wb(intel_private.scratch_page, 1);
632 pci_unmap_page(intel_private.pcidev, intel_private.base.scratch_page_dma,
633 PAGE_SIZE, PCI_DMA_BIDIRECTIONAL);
634 put_page(intel_private.scratch_page);
635 __free_page(intel_private.scratch_page);
638 static void intel_gtt_cleanup(void)
640 intel_private.driver->cleanup();
642 iounmap(intel_private.gtt);
643 iounmap(intel_private.registers);
645 intel_gtt_teardown_scratch_page();
648 static int intel_gtt_init(void)
653 ret = intel_private.driver->setup();
657 intel_private.base.gtt_mappable_entries = intel_gtt_mappable_entries();
658 intel_private.base.gtt_total_entries = intel_gtt_total_entries();
660 /* save the PGETBL reg for resume */
661 intel_private.PGETBL_save =
662 readl(intel_private.registers+I810_PGETBL_CTL)
663 & ~I810_PGETBL_ENABLED;
664 /* we only ever restore the register when enabling the PGTBL... */
666 intel_private.PGETBL_save |= I810_PGETBL_ENABLED;
668 dev_info(&intel_private.bridge_dev->dev,
669 "detected gtt size: %dK total, %dK mappable\n",
670 intel_private.base.gtt_total_entries * 4,
671 intel_private.base.gtt_mappable_entries * 4);
673 gtt_map_size = intel_private.base.gtt_total_entries * 4;
675 intel_private.gtt = ioremap(intel_private.gtt_bus_addr,
677 if (!intel_private.gtt) {
678 intel_private.driver->cleanup();
679 iounmap(intel_private.registers);
682 intel_private.base.gtt = intel_private.gtt;
684 global_cache_flush(); /* FIXME: ? */
686 intel_private.base.stolen_size = intel_gtt_stolen_size();
688 intel_private.base.needs_dmar = USE_PCI_DMA_API && INTEL_GTT_GEN > 2;
690 ret = intel_gtt_setup_scratch_page();
699 static int intel_fake_agp_fetch_size(void)
701 int num_sizes = ARRAY_SIZE(intel_fake_agp_sizes);
702 unsigned int aper_size;
705 aper_size = (intel_private.base.gtt_mappable_entries << PAGE_SHIFT)
708 for (i = 0; i < num_sizes; i++) {
709 if (aper_size == intel_fake_agp_sizes[i].size) {
710 agp_bridge->current_size =
711 (void *) (intel_fake_agp_sizes + i);
719 static void i830_cleanup(void)
723 /* The chipset_flush interface needs to get data that has already been
724 * flushed out of the CPU all the way out to main memory, because the GPU
725 * doesn't snoop those buffers.
727 * The 8xx series doesn't have the same lovely interface for flushing the
728 * chipset write buffers that the later chips do. According to the 865
729 * specs, it's 64 octwords, or 1KB. So, to get those previous things in
730 * that buffer out, we just fill 1KB and clflush it out, on the assumption
731 * that it'll push whatever was in there out. It appears to work.
733 static void i830_chipset_flush(void)
735 unsigned long timeout = jiffies + msecs_to_jiffies(1000);
737 /* Forcibly evict everything from the CPU write buffers.
738 * clflush appears to be insufficient.
740 wbinvd_on_all_cpus();
742 /* Now we've only seen documents for this magic bit on 855GM,
743 * we hope it exists for the other gen2 chipsets...
745 * Also works as advertised on my 845G.
747 writel(readl(intel_private.registers+I830_HIC) | (1<<31),
748 intel_private.registers+I830_HIC);
750 while (readl(intel_private.registers+I830_HIC) & (1<<31)) {
751 if (time_after(jiffies, timeout))
758 static void i830_write_entry(dma_addr_t addr, unsigned int entry,
761 u32 pte_flags = I810_PTE_VALID;
763 if (flags == AGP_USER_CACHED_MEMORY)
764 pte_flags |= I830_PTE_SYSTEM_CACHED;
766 writel(addr | pte_flags, intel_private.gtt + entry);
769 static bool intel_enable_gtt(void)
774 if (INTEL_GTT_GEN <= 2)
775 pci_read_config_dword(intel_private.pcidev, I810_GMADDR,
778 pci_read_config_dword(intel_private.pcidev, I915_GMADDR,
781 intel_private.base.gma_bus_addr = (gma_addr & PCI_BASE_ADDRESS_MEM_MASK);
783 if (INTEL_GTT_GEN >= 6)
786 if (INTEL_GTT_GEN == 2) {
789 pci_read_config_word(intel_private.bridge_dev,
790 I830_GMCH_CTRL, &gmch_ctrl);
791 gmch_ctrl |= I830_GMCH_ENABLED;
792 pci_write_config_word(intel_private.bridge_dev,
793 I830_GMCH_CTRL, gmch_ctrl);
795 pci_read_config_word(intel_private.bridge_dev,
796 I830_GMCH_CTRL, &gmch_ctrl);
797 if ((gmch_ctrl & I830_GMCH_ENABLED) == 0) {
798 dev_err(&intel_private.pcidev->dev,
799 "failed to enable the GTT: GMCH_CTRL=%x\n",
805 /* On the resume path we may be adjusting the PGTBL value, so
806 * be paranoid and flush all chipset write buffers...
808 if (INTEL_GTT_GEN >= 3)
809 writel(0, intel_private.registers+GFX_FLSH_CNTL);
811 reg = intel_private.registers+I810_PGETBL_CTL;
812 writel(intel_private.PGETBL_save, reg);
813 if (HAS_PGTBL_EN && (readl(reg) & I810_PGETBL_ENABLED) == 0) {
814 dev_err(&intel_private.pcidev->dev,
815 "failed to enable the GTT: PGETBL=%x [expected %x]\n",
816 readl(reg), intel_private.PGETBL_save);
820 if (INTEL_GTT_GEN >= 3)
821 writel(0, intel_private.registers+GFX_FLSH_CNTL);
826 static int i830_setup(void)
830 pci_read_config_dword(intel_private.pcidev, I810_MMADDR, ®_addr);
831 reg_addr &= 0xfff80000;
833 intel_private.registers = ioremap(reg_addr, KB(64));
834 if (!intel_private.registers)
837 intel_private.gtt_bus_addr = reg_addr + I810_PTE_BASE;
842 static int intel_fake_agp_create_gatt_table(struct agp_bridge_data *bridge)
844 agp_bridge->gatt_table_real = NULL;
845 agp_bridge->gatt_table = NULL;
846 agp_bridge->gatt_bus_addr = 0;
851 static int intel_fake_agp_free_gatt_table(struct agp_bridge_data *bridge)
856 static int intel_fake_agp_configure(void)
858 if (!intel_enable_gtt())
861 intel_private.clear_fake_agp = true;
862 agp_bridge->gart_bus_addr = intel_private.base.gma_bus_addr;
867 static bool i830_check_flags(unsigned int flags)
871 case AGP_PHYS_MEMORY:
872 case AGP_USER_CACHED_MEMORY:
873 case AGP_USER_MEMORY:
880 void intel_gtt_insert_sg_entries(struct scatterlist *sg_list,
882 unsigned int pg_start,
885 struct scatterlist *sg;
891 /* sg may merge pages, but we have to separate
892 * per-page addr for GTT */
893 for_each_sg(sg_list, sg, sg_len, i) {
894 len = sg_dma_len(sg) >> PAGE_SHIFT;
895 for (m = 0; m < len; m++) {
896 dma_addr_t addr = sg_dma_address(sg) + (m << PAGE_SHIFT);
897 intel_private.driver->write_entry(addr,
902 readl(intel_private.gtt+j-1);
904 EXPORT_SYMBOL(intel_gtt_insert_sg_entries);
906 void intel_gtt_insert_pages(unsigned int first_entry, unsigned int num_entries,
907 struct page **pages, unsigned int flags)
911 for (i = 0, j = first_entry; i < num_entries; i++, j++) {
912 dma_addr_t addr = page_to_phys(pages[i]);
913 intel_private.driver->write_entry(addr,
916 readl(intel_private.gtt+j-1);
918 EXPORT_SYMBOL(intel_gtt_insert_pages);
920 static int intel_fake_agp_insert_entries(struct agp_memory *mem,
921 off_t pg_start, int type)
925 if (intel_private.base.do_idle_maps)
928 if (intel_private.clear_fake_agp) {
929 int start = intel_private.base.stolen_size / PAGE_SIZE;
930 int end = intel_private.base.gtt_mappable_entries;
931 intel_gtt_clear_range(start, end - start);
932 intel_private.clear_fake_agp = false;
935 if (INTEL_GTT_GEN == 1 && type == AGP_DCACHE_MEMORY)
936 return i810_insert_dcache_entries(mem, pg_start, type);
938 if (mem->page_count == 0)
941 if (pg_start + mem->page_count > intel_private.base.gtt_total_entries)
944 if (type != mem->type)
947 if (!intel_private.driver->check_flags(type))
950 if (!mem->is_flushed)
951 global_cache_flush();
953 if (intel_private.base.needs_dmar) {
954 ret = intel_gtt_map_memory(mem->pages, mem->page_count,
955 &mem->sg_list, &mem->num_sg);
959 intel_gtt_insert_sg_entries(mem->sg_list, mem->num_sg,
962 intel_gtt_insert_pages(pg_start, mem->page_count, mem->pages,
968 mem->is_flushed = true;
972 void intel_gtt_clear_range(unsigned int first_entry, unsigned int num_entries)
976 for (i = first_entry; i < (first_entry + num_entries); i++) {
977 intel_private.driver->write_entry(intel_private.base.scratch_page_dma,
980 readl(intel_private.gtt+i-1);
982 EXPORT_SYMBOL(intel_gtt_clear_range);
984 static int intel_fake_agp_remove_entries(struct agp_memory *mem,
985 off_t pg_start, int type)
987 if (mem->page_count == 0)
990 if (intel_private.base.do_idle_maps)
993 intel_gtt_clear_range(pg_start, mem->page_count);
995 if (intel_private.base.needs_dmar) {
996 intel_gtt_unmap_memory(mem->sg_list, mem->num_sg);
1004 static struct agp_memory *intel_fake_agp_alloc_by_type(size_t pg_count,
1007 struct agp_memory *new;
1009 if (type == AGP_DCACHE_MEMORY && INTEL_GTT_GEN == 1) {
1010 if (pg_count != intel_private.num_dcache_entries)
1013 new = agp_create_memory(1);
1017 new->type = AGP_DCACHE_MEMORY;
1018 new->page_count = pg_count;
1019 new->num_scratch_pages = 0;
1020 agp_free_page_array(new);
1023 if (type == AGP_PHYS_MEMORY)
1024 return alloc_agpphysmem_i8xx(pg_count, type);
1025 /* always return NULL for other allocation types for now */
1029 static int intel_alloc_chipset_flush_resource(void)
1032 ret = pci_bus_alloc_resource(intel_private.bridge_dev->bus, &intel_private.ifp_resource, PAGE_SIZE,
1033 PAGE_SIZE, PCIBIOS_MIN_MEM, 0,
1034 pcibios_align_resource, intel_private.bridge_dev);
1039 static void intel_i915_setup_chipset_flush(void)
1044 pci_read_config_dword(intel_private.bridge_dev, I915_IFPADDR, &temp);
1045 if (!(temp & 0x1)) {
1046 intel_alloc_chipset_flush_resource();
1047 intel_private.resource_valid = 1;
1048 pci_write_config_dword(intel_private.bridge_dev, I915_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1);
1052 intel_private.resource_valid = 1;
1053 intel_private.ifp_resource.start = temp;
1054 intel_private.ifp_resource.end = temp + PAGE_SIZE;
1055 ret = request_resource(&iomem_resource, &intel_private.ifp_resource);
1056 /* some BIOSes reserve this area in a pnp some don't */
1058 intel_private.resource_valid = 0;
1062 static void intel_i965_g33_setup_chipset_flush(void)
1064 u32 temp_hi, temp_lo;
1067 pci_read_config_dword(intel_private.bridge_dev, I965_IFPADDR + 4, &temp_hi);
1068 pci_read_config_dword(intel_private.bridge_dev, I965_IFPADDR, &temp_lo);
1070 if (!(temp_lo & 0x1)) {
1072 intel_alloc_chipset_flush_resource();
1074 intel_private.resource_valid = 1;
1075 pci_write_config_dword(intel_private.bridge_dev, I965_IFPADDR + 4,
1076 upper_32_bits(intel_private.ifp_resource.start));
1077 pci_write_config_dword(intel_private.bridge_dev, I965_IFPADDR, (intel_private.ifp_resource.start & 0xffffffff) | 0x1);
1082 l64 = ((u64)temp_hi << 32) | temp_lo;
1084 intel_private.resource_valid = 1;
1085 intel_private.ifp_resource.start = l64;
1086 intel_private.ifp_resource.end = l64 + PAGE_SIZE;
1087 ret = request_resource(&iomem_resource, &intel_private.ifp_resource);
1088 /* some BIOSes reserve this area in a pnp some don't */
1090 intel_private.resource_valid = 0;
1094 static void intel_i9xx_setup_flush(void)
1096 /* return if already configured */
1097 if (intel_private.ifp_resource.start)
1100 if (INTEL_GTT_GEN == 6)
1103 /* setup a resource for this object */
1104 intel_private.ifp_resource.name = "Intel Flush Page";
1105 intel_private.ifp_resource.flags = IORESOURCE_MEM;
1107 /* Setup chipset flush for 915 */
1108 if (IS_G33 || INTEL_GTT_GEN >= 4) {
1109 intel_i965_g33_setup_chipset_flush();
1111 intel_i915_setup_chipset_flush();
1114 if (intel_private.ifp_resource.start)
1115 intel_private.i9xx_flush_page = ioremap_nocache(intel_private.ifp_resource.start, PAGE_SIZE);
1116 if (!intel_private.i9xx_flush_page)
1117 dev_err(&intel_private.pcidev->dev,
1118 "can't ioremap flush page - no chipset flushing\n");
1121 static void i9xx_cleanup(void)
1123 if (intel_private.i9xx_flush_page)
1124 iounmap(intel_private.i9xx_flush_page);
1125 if (intel_private.resource_valid)
1126 release_resource(&intel_private.ifp_resource);
1127 intel_private.ifp_resource.start = 0;
1128 intel_private.resource_valid = 0;
1131 static void i9xx_chipset_flush(void)
1133 if (intel_private.i9xx_flush_page)
1134 writel(1, intel_private.i9xx_flush_page);
1137 static void i965_write_entry(dma_addr_t addr,
1143 pte_flags = I810_PTE_VALID;
1144 if (flags == AGP_USER_CACHED_MEMORY)
1145 pte_flags |= I830_PTE_SYSTEM_CACHED;
1147 /* Shift high bits down */
1148 addr |= (addr >> 28) & 0xf0;
1149 writel(addr | pte_flags, intel_private.gtt + entry);
1152 static bool gen6_check_flags(unsigned int flags)
1157 static void gen6_write_entry(dma_addr_t addr, unsigned int entry,
1160 unsigned int type_mask = flags & ~AGP_USER_CACHED_MEMORY_GFDT;
1161 unsigned int gfdt = flags & AGP_USER_CACHED_MEMORY_GFDT;
1164 if (type_mask == AGP_USER_MEMORY)
1165 pte_flags = GEN6_PTE_UNCACHED | I810_PTE_VALID;
1166 else if (type_mask == AGP_USER_CACHED_MEMORY_LLC_MLC) {
1167 pte_flags = GEN6_PTE_LLC_MLC | I810_PTE_VALID;
1169 pte_flags |= GEN6_PTE_GFDT;
1170 } else { /* set 'normal'/'cached' to LLC by default */
1171 pte_flags = GEN6_PTE_LLC | I810_PTE_VALID;
1173 pte_flags |= GEN6_PTE_GFDT;
1176 /* gen6 has bit11-4 for physical addr bit39-32 */
1177 addr |= (addr >> 28) & 0xff0;
1178 writel(addr | pte_flags, intel_private.gtt + entry);
1181 static void valleyview_write_entry(dma_addr_t addr, unsigned int entry,
1186 pte_flags = GEN6_PTE_UNCACHED | I810_PTE_VALID;
1188 /* gen6 has bit11-4 for physical addr bit39-32 */
1189 addr |= (addr >> 28) & 0xff0;
1190 writel(addr | pte_flags, intel_private.gtt + entry);
1192 writel(1, intel_private.registers + GFX_FLSH_CNTL_VLV);
1195 static void gen6_cleanup(void)
1199 /* Certain Gen5 chipsets require require idling the GPU before
1200 * unmapping anything from the GTT when VT-d is enabled.
1202 static inline int needs_idle_maps(void)
1204 #ifdef CONFIG_INTEL_IOMMU
1205 const unsigned short gpu_devid = intel_private.pcidev->device;
1207 /* Query intel_iommu to see if we need the workaround. Presumably that
1210 if ((gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_HB ||
1211 gpu_devid == PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG) &&
1212 intel_iommu_gfx_mapped)
1218 static int i9xx_setup(void)
1223 pci_read_config_dword(intel_private.pcidev, I915_MMADDR, ®_addr);
1225 reg_addr &= 0xfff80000;
1227 if (INTEL_GTT_GEN >= 7)
1230 intel_private.registers = ioremap(reg_addr, size);
1231 if (!intel_private.registers)
1234 if (INTEL_GTT_GEN == 3) {
1237 pci_read_config_dword(intel_private.pcidev,
1238 I915_PTEADDR, >t_addr);
1239 intel_private.gtt_bus_addr = gtt_addr;
1243 switch (INTEL_GTT_GEN) {
1250 gtt_offset = KB(512);
1253 intel_private.gtt_bus_addr = reg_addr + gtt_offset;
1256 if (needs_idle_maps())
1257 intel_private.base.do_idle_maps = 1;
1259 intel_i9xx_setup_flush();
1264 static const struct agp_bridge_driver intel_fake_agp_driver = {
1265 .owner = THIS_MODULE,
1266 .size_type = FIXED_APER_SIZE,
1267 .aperture_sizes = intel_fake_agp_sizes,
1268 .num_aperture_sizes = ARRAY_SIZE(intel_fake_agp_sizes),
1269 .configure = intel_fake_agp_configure,
1270 .fetch_size = intel_fake_agp_fetch_size,
1271 .cleanup = intel_gtt_cleanup,
1272 .agp_enable = intel_fake_agp_enable,
1273 .cache_flush = global_cache_flush,
1274 .create_gatt_table = intel_fake_agp_create_gatt_table,
1275 .free_gatt_table = intel_fake_agp_free_gatt_table,
1276 .insert_memory = intel_fake_agp_insert_entries,
1277 .remove_memory = intel_fake_agp_remove_entries,
1278 .alloc_by_type = intel_fake_agp_alloc_by_type,
1279 .free_by_type = intel_i810_free_by_type,
1280 .agp_alloc_page = agp_generic_alloc_page,
1281 .agp_alloc_pages = agp_generic_alloc_pages,
1282 .agp_destroy_page = agp_generic_destroy_page,
1283 .agp_destroy_pages = agp_generic_destroy_pages,
1286 static const struct intel_gtt_driver i81x_gtt_driver = {
1288 .has_pgtbl_enable = 1,
1289 .dma_mask_size = 32,
1290 .setup = i810_setup,
1291 .cleanup = i810_cleanup,
1292 .check_flags = i830_check_flags,
1293 .write_entry = i810_write_entry,
1295 static const struct intel_gtt_driver i8xx_gtt_driver = {
1297 .has_pgtbl_enable = 1,
1298 .setup = i830_setup,
1299 .cleanup = i830_cleanup,
1300 .write_entry = i830_write_entry,
1301 .dma_mask_size = 32,
1302 .check_flags = i830_check_flags,
1303 .chipset_flush = i830_chipset_flush,
1305 static const struct intel_gtt_driver i915_gtt_driver = {
1307 .has_pgtbl_enable = 1,
1308 .setup = i9xx_setup,
1309 .cleanup = i9xx_cleanup,
1310 /* i945 is the last gpu to need phys mem (for overlay and cursors). */
1311 .write_entry = i830_write_entry,
1312 .dma_mask_size = 32,
1313 .check_flags = i830_check_flags,
1314 .chipset_flush = i9xx_chipset_flush,
1316 static const struct intel_gtt_driver g33_gtt_driver = {
1319 .setup = i9xx_setup,
1320 .cleanup = i9xx_cleanup,
1321 .write_entry = i965_write_entry,
1322 .dma_mask_size = 36,
1323 .check_flags = i830_check_flags,
1324 .chipset_flush = i9xx_chipset_flush,
1326 static const struct intel_gtt_driver pineview_gtt_driver = {
1328 .is_pineview = 1, .is_g33 = 1,
1329 .setup = i9xx_setup,
1330 .cleanup = i9xx_cleanup,
1331 .write_entry = i965_write_entry,
1332 .dma_mask_size = 36,
1333 .check_flags = i830_check_flags,
1334 .chipset_flush = i9xx_chipset_flush,
1336 static const struct intel_gtt_driver i965_gtt_driver = {
1338 .has_pgtbl_enable = 1,
1339 .setup = i9xx_setup,
1340 .cleanup = i9xx_cleanup,
1341 .write_entry = i965_write_entry,
1342 .dma_mask_size = 36,
1343 .check_flags = i830_check_flags,
1344 .chipset_flush = i9xx_chipset_flush,
1346 static const struct intel_gtt_driver g4x_gtt_driver = {
1348 .setup = i9xx_setup,
1349 .cleanup = i9xx_cleanup,
1350 .write_entry = i965_write_entry,
1351 .dma_mask_size = 36,
1352 .check_flags = i830_check_flags,
1353 .chipset_flush = i9xx_chipset_flush,
1355 static const struct intel_gtt_driver ironlake_gtt_driver = {
1358 .setup = i9xx_setup,
1359 .cleanup = i9xx_cleanup,
1360 .write_entry = i965_write_entry,
1361 .dma_mask_size = 36,
1362 .check_flags = i830_check_flags,
1363 .chipset_flush = i9xx_chipset_flush,
1365 static const struct intel_gtt_driver sandybridge_gtt_driver = {
1367 .setup = i9xx_setup,
1368 .cleanup = gen6_cleanup,
1369 .write_entry = gen6_write_entry,
1370 .dma_mask_size = 40,
1371 .check_flags = gen6_check_flags,
1372 .chipset_flush = i9xx_chipset_flush,
1374 static const struct intel_gtt_driver valleyview_gtt_driver = {
1376 .setup = i9xx_setup,
1377 .cleanup = gen6_cleanup,
1378 .write_entry = valleyview_write_entry,
1379 .dma_mask_size = 40,
1380 .check_flags = gen6_check_flags,
1381 .chipset_flush = i9xx_chipset_flush,
1384 /* Table to describe Intel GMCH and AGP/PCIE GART drivers. At least one of
1385 * driver and gmch_driver must be non-null, and find_gmch will determine
1386 * which one should be used if a gmch_chip_id is present.
1388 static const struct intel_gtt_driver_description {
1389 unsigned int gmch_chip_id;
1391 const struct intel_gtt_driver *gtt_driver;
1392 } intel_gtt_chipsets[] = {
1393 { PCI_DEVICE_ID_INTEL_82810_IG1, "i810",
1395 { PCI_DEVICE_ID_INTEL_82810_IG3, "i810",
1397 { PCI_DEVICE_ID_INTEL_82810E_IG, "i810",
1399 { PCI_DEVICE_ID_INTEL_82815_CGC, "i815",
1401 { PCI_DEVICE_ID_INTEL_82830_CGC, "830M",
1403 { PCI_DEVICE_ID_INTEL_82845G_IG, "845G",
1405 { PCI_DEVICE_ID_INTEL_82854_IG, "854",
1407 { PCI_DEVICE_ID_INTEL_82855GM_IG, "855GM",
1409 { PCI_DEVICE_ID_INTEL_82865_IG, "865",
1411 { PCI_DEVICE_ID_INTEL_E7221_IG, "E7221 (i915)",
1413 { PCI_DEVICE_ID_INTEL_82915G_IG, "915G",
1415 { PCI_DEVICE_ID_INTEL_82915GM_IG, "915GM",
1417 { PCI_DEVICE_ID_INTEL_82945G_IG, "945G",
1419 { PCI_DEVICE_ID_INTEL_82945GM_IG, "945GM",
1421 { PCI_DEVICE_ID_INTEL_82945GME_IG, "945GME",
1423 { PCI_DEVICE_ID_INTEL_82946GZ_IG, "946GZ",
1425 { PCI_DEVICE_ID_INTEL_82G35_IG, "G35",
1427 { PCI_DEVICE_ID_INTEL_82965Q_IG, "965Q",
1429 { PCI_DEVICE_ID_INTEL_82965G_IG, "965G",
1431 { PCI_DEVICE_ID_INTEL_82965GM_IG, "965GM",
1433 { PCI_DEVICE_ID_INTEL_82965GME_IG, "965GME/GLE",
1435 { PCI_DEVICE_ID_INTEL_G33_IG, "G33",
1437 { PCI_DEVICE_ID_INTEL_Q35_IG, "Q35",
1439 { PCI_DEVICE_ID_INTEL_Q33_IG, "Q33",
1441 { PCI_DEVICE_ID_INTEL_PINEVIEW_M_IG, "GMA3150",
1442 &pineview_gtt_driver },
1443 { PCI_DEVICE_ID_INTEL_PINEVIEW_IG, "GMA3150",
1444 &pineview_gtt_driver },
1445 { PCI_DEVICE_ID_INTEL_GM45_IG, "GM45",
1447 { PCI_DEVICE_ID_INTEL_EAGLELAKE_IG, "Eaglelake",
1449 { PCI_DEVICE_ID_INTEL_Q45_IG, "Q45/Q43",
1451 { PCI_DEVICE_ID_INTEL_G45_IG, "G45/G43",
1453 { PCI_DEVICE_ID_INTEL_B43_IG, "B43",
1455 { PCI_DEVICE_ID_INTEL_B43_1_IG, "B43",
1457 { PCI_DEVICE_ID_INTEL_G41_IG, "G41",
1459 { PCI_DEVICE_ID_INTEL_IRONLAKE_D_IG,
1460 "HD Graphics", &ironlake_gtt_driver },
1461 { PCI_DEVICE_ID_INTEL_IRONLAKE_M_IG,
1462 "HD Graphics", &ironlake_gtt_driver },
1463 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT1_IG,
1464 "Sandybridge", &sandybridge_gtt_driver },
1465 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_IG,
1466 "Sandybridge", &sandybridge_gtt_driver },
1467 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_GT2_PLUS_IG,
1468 "Sandybridge", &sandybridge_gtt_driver },
1469 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT1_IG,
1470 "Sandybridge", &sandybridge_gtt_driver },
1471 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_IG,
1472 "Sandybridge", &sandybridge_gtt_driver },
1473 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_M_GT2_PLUS_IG,
1474 "Sandybridge", &sandybridge_gtt_driver },
1475 { PCI_DEVICE_ID_INTEL_SANDYBRIDGE_S_IG,
1476 "Sandybridge", &sandybridge_gtt_driver },
1477 { PCI_DEVICE_ID_INTEL_IVYBRIDGE_GT1_IG,
1478 "Ivybridge", &sandybridge_gtt_driver },
1479 { PCI_DEVICE_ID_INTEL_IVYBRIDGE_GT2_IG,
1480 "Ivybridge", &sandybridge_gtt_driver },
1481 { PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_GT1_IG,
1482 "Ivybridge", &sandybridge_gtt_driver },
1483 { PCI_DEVICE_ID_INTEL_IVYBRIDGE_M_GT2_IG,
1484 "Ivybridge", &sandybridge_gtt_driver },
1485 { PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT1_IG,
1486 "Ivybridge", &sandybridge_gtt_driver },
1487 { PCI_DEVICE_ID_INTEL_IVYBRIDGE_S_GT2_IG,
1488 "Ivybridge", &sandybridge_gtt_driver },
1489 { PCI_DEVICE_ID_INTEL_VALLEYVIEW_IG,
1490 "ValleyView", &valleyview_gtt_driver },
1491 { PCI_DEVICE_ID_INTEL_HASWELL_D_GT1_IG,
1492 "Haswell", &sandybridge_gtt_driver },
1493 { PCI_DEVICE_ID_INTEL_HASWELL_D_GT2_IG,
1494 "Haswell", &sandybridge_gtt_driver },
1495 { PCI_DEVICE_ID_INTEL_HASWELL_M_GT1_IG,
1496 "Haswell", &sandybridge_gtt_driver },
1497 { PCI_DEVICE_ID_INTEL_HASWELL_M_GT2_IG,
1498 "Haswell", &sandybridge_gtt_driver },
1499 { PCI_DEVICE_ID_INTEL_HASWELL_S_GT1_IG,
1500 "Haswell", &sandybridge_gtt_driver },
1501 { PCI_DEVICE_ID_INTEL_HASWELL_S_GT2_IG,
1502 "Haswell", &sandybridge_gtt_driver },
1503 { PCI_DEVICE_ID_INTEL_HASWELL_SDV,
1504 "Haswell", &sandybridge_gtt_driver },
1508 static int find_gmch(u16 device)
1510 struct pci_dev *gmch_device;
1512 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL, device, NULL);
1513 if (gmch_device && PCI_FUNC(gmch_device->devfn) != 0) {
1514 gmch_device = pci_get_device(PCI_VENDOR_ID_INTEL,
1515 device, gmch_device);
1521 intel_private.pcidev = gmch_device;
1525 int intel_gmch_probe(struct pci_dev *pdev,
1526 struct agp_bridge_data *bridge)
1529 intel_private.driver = NULL;
1531 for (i = 0; intel_gtt_chipsets[i].name != NULL; i++) {
1532 if (find_gmch(intel_gtt_chipsets[i].gmch_chip_id)) {
1533 intel_private.driver =
1534 intel_gtt_chipsets[i].gtt_driver;
1539 if (!intel_private.driver)
1542 bridge->driver = &intel_fake_agp_driver;
1543 bridge->dev_private_data = &intel_private;
1546 intel_private.bridge_dev = pci_dev_get(pdev);
1548 dev_info(&pdev->dev, "Intel %s Chipset\n", intel_gtt_chipsets[i].name);
1550 mask = intel_private.driver->dma_mask_size;
1551 if (pci_set_dma_mask(intel_private.pcidev, DMA_BIT_MASK(mask)))
1552 dev_err(&intel_private.pcidev->dev,
1553 "set gfx device dma mask %d-bit failed!\n", mask);
1555 pci_set_consistent_dma_mask(intel_private.pcidev,
1556 DMA_BIT_MASK(mask));
1558 if (intel_gtt_init() != 0)
1563 EXPORT_SYMBOL(intel_gmch_probe);
1565 const struct intel_gtt *intel_gtt_get(void)
1567 return &intel_private.base;
1569 EXPORT_SYMBOL(intel_gtt_get);
1571 void intel_gtt_chipset_flush(void)
1573 if (intel_private.driver->chipset_flush)
1574 intel_private.driver->chipset_flush();
1576 EXPORT_SYMBOL(intel_gtt_chipset_flush);
1578 void intel_gmch_remove(struct pci_dev *pdev)
1580 if (intel_private.pcidev)
1581 pci_dev_put(intel_private.pcidev);
1582 if (intel_private.bridge_dev)
1583 pci_dev_put(intel_private.bridge_dev);
1585 EXPORT_SYMBOL(intel_gmch_remove);
1587 MODULE_AUTHOR("Dave Jones <davej@redhat.com>");
1588 MODULE_LICENSE("GPL and additional rights");