Rev 2327 | Rev 2332 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 2327 | Rev 2330 | ||
---|---|---|---|
Line 29... | Line 29... | ||
29 | #include "drmP.h" |
29 | #include "drmP.h" |
30 | #include "drm.h" |
30 | #include "drm.h" |
31 | #include "drm_crtc_helper.h" |
31 | #include "drm_crtc_helper.h" |
32 | #include "drm_fb_helper.h" |
32 | #include "drm_fb_helper.h" |
33 | #include "intel_drv.h" |
33 | #include "intel_drv.h" |
34 | //#include "i915_drm.h" |
34 | #include "i915_drm.h" |
35 | #include "i915_drv.h" |
35 | #include "i915_drv.h" |
36 | #include |
36 | #include |
37 | //#include "i915_trace.h" |
37 | //#include "i915_trace.h" |
38 | //#include "../../../platform/x86/intel_ips.h" |
38 | //#include "../../../platform/x86/intel_ips.h" |
39 | #include |
39 | #include |
40 | //#include |
40 | //#include |
41 | //#include |
41 | //#include |
42 | //#include |
42 | //#include |
43 | //#include |
43 | //#include |
44 | //#include |
44 | #include |
45 | //#include |
45 | //#include |
Line 46... | Line 46... | ||
46 | 46 | ||
Line -... | Line 47... | ||
- | 47 | void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen); |
|
- | 48 | ||
- | 49 | static inline int pci_read_config_dword(struct pci_dev *dev, int where, |
|
- | 50 | u32 *val) |
|
- | 51 | { |
|
- | 52 | *val = PciRead32(dev->busnr, dev->devfn, where); |
|
- | 53 | return 1; |
|
- | 54 | } |
|
- | 55 | ||
47 | void __iomem *pci_iomap(struct pci_dev *dev, int bar, unsigned long maxlen); |
56 | |
48 | 57 | ||
49 | static void i915_write_hws_pga(struct drm_device *dev) |
58 | static void i915_write_hws_pga(struct drm_device *dev) |
50 | { |
59 | { |
Line 55... | Line 64... | ||
55 | if (INTEL_INFO(dev)->gen >= 4) |
64 | if (INTEL_INFO(dev)->gen >= 4) |
56 | addr |= (dev_priv->status_page_dmah->busaddr >> 28) & 0xf0; |
65 | addr |= (dev_priv->status_page_dmah->busaddr >> 28) & 0xf0; |
57 | I915_WRITE(HWS_PGA, addr); |
66 | I915_WRITE(HWS_PGA, addr); |
58 | } |
67 | } |
Line 59... | Line -... | ||
59 | - | ||
60 | 68 | ||
61 | /** |
69 | /** |
62 | * Sets up the hardware status page for devices that need a physical address |
70 | * Sets up the hardware status page for devices that need a physical address |
63 | * in the register. |
71 | * in the register. |
64 | */ |
72 | */ |
Line 79... | Line 87... | ||
79 | 87 | ||
80 | dbgprintf("Enabled hardware status page\n"); |
88 | dbgprintf("Enabled hardware status page\n"); |
81 | return 0; |
89 | return 0; |
Line -... | Line 90... | ||
- | 90 | } |
|
- | 91 | ||
- | 92 | ||
- | 93 | ||
- | 94 | ||
- | 95 | ||
- | 96 | ||
- | 97 | ||
- | 98 | ||
- | 99 | ||
- | 100 | ||
- | 101 | #define MCHBAR_I915 0x44 |
|
- | 102 | #define MCHBAR_I965 0x48 |
|
- | 103 | #define MCHBAR_SIZE (4*4096) |
|
- | 104 | ||
- | 105 | #define DEVEN_REG 0x54 |
|
- | 106 | #define DEVEN_MCHBAR_EN (1 << 28) |
|
- | 107 | ||
- | 108 | ||
- | 109 | ||
- | 110 | ||
- | 111 | /* Setup MCHBAR if possible, return true if we should disable it again */ |
|
- | 112 | static void |
|
- | 113 | intel_setup_mchbar(struct drm_device *dev) |
|
- | 114 | { |
|
- | 115 | drm_i915_private_t *dev_priv = dev->dev_private; |
|
- | 116 | int mchbar_reg = INTEL_INFO(dev)->gen >= 4 ? MCHBAR_I965 : MCHBAR_I915; |
|
- | 117 | u32 temp; |
|
- | 118 | bool enabled; |
|
- | 119 | ||
- | 120 | dev_priv->mchbar_need_disable = false; |
|
- | 121 | ||
- | 122 | if (IS_I915G(dev) || IS_I915GM(dev)) { |
|
- | 123 | pci_read_config_dword(dev_priv->bridge_dev, DEVEN_REG, &temp); |
|
- | 124 | enabled = !!(temp & DEVEN_MCHBAR_EN); |
|
- | 125 | } else { |
|
- | 126 | pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp); |
|
- | 127 | enabled = temp & 1; |
|
- | 128 | } |
|
- | 129 | ||
- | 130 | /* If it's already enabled, don't have to do anything */ |
|
- | 131 | if (enabled) |
|
- | 132 | return; |
|
- | 133 | ||
- | 134 | dbgprintf("Epic fail\n"); |
|
- | 135 | ||
- | 136 | #if 0 |
|
- | 137 | if (intel_alloc_mchbar_resource(dev)) |
|
- | 138 | return; |
|
- | 139 | ||
- | 140 | dev_priv->mchbar_need_disable = true; |
|
- | 141 | ||
- | 142 | /* Space is allocated or reserved, so enable it. */ |
|
- | 143 | if (IS_I915G(dev) || IS_I915GM(dev)) { |
|
- | 144 | pci_write_config_dword(dev_priv->bridge_dev, DEVEN_REG, |
|
- | 145 | temp | DEVEN_MCHBAR_EN); |
|
- | 146 | } else { |
|
- | 147 | pci_read_config_dword(dev_priv->bridge_dev, mchbar_reg, &temp); |
|
- | 148 | pci_write_config_dword(dev_priv->bridge_dev, mchbar_reg, temp | 1); |
|
- | 149 | } |
|
- | 150 | #endif |
|
- | 151 | } |
|
- | 152 | ||
- | 153 | ||
- | 154 | ||
- | 155 | ||
- | 156 | ||
- | 157 | ||
- | 158 | ||
- | 159 | ||
- | 160 | ||
- | 161 | ||
- | 162 | ||
- | 163 | ||
- | 164 | ||
- | 165 | ||
- | 166 | ||
- | 167 | ||
- | 168 | static int i915_load_gem_init(struct drm_device *dev) |
|
- | 169 | { |
|
- | 170 | struct drm_i915_private *dev_priv = dev->dev_private; |
|
- | 171 | unsigned long prealloc_size, gtt_size, mappable_size; |
|
- | 172 | int ret; |
|
- | 173 | ||
- | 174 | prealloc_size = dev_priv->mm.gtt->stolen_size; |
|
- | 175 | gtt_size = dev_priv->mm.gtt->gtt_total_entries << PAGE_SHIFT; |
|
- | 176 | mappable_size = dev_priv->mm.gtt->gtt_mappable_entries << PAGE_SHIFT; |
|
- | 177 | ||
- | 178 | dbgprintf("%s prealloc: %x gtt: %x mappable: %x\n",__FUNCTION__, |
|
- | 179 | prealloc_size, gtt_size, mappable_size); |
|
- | 180 | ||
- | 181 | /* Basic memrange allocator for stolen space */ |
|
- | 182 | drm_mm_init(&dev_priv->mm.stolen, 0, prealloc_size); |
|
- | 183 | ||
- | 184 | //0xC00000 >> PAGE_SHIFT |
|
- | 185 | ||
- | 186 | /* Let GEM Manage all of the aperture. |
|
- | 187 | * |
|
- | 188 | * However, leave one page at the end still bound to the scratch page. |
|
- | 189 | * There are a number of places where the hardware apparently |
|
- | 190 | * prefetches past the end of the object, and we've seen multiple |
|
- | 191 | * hangs with the GPU head pointer stuck in a batchbuffer bound |
|
- | 192 | * at the last page of the aperture. One page should be enough to |
|
- | 193 | * keep any prefetching inside of the aperture. |
|
- | 194 | */ |
|
- | 195 | // i915_gem_do_init(dev, 0, mappable_size, gtt_size - PAGE_SIZE); |
|
- | 196 | ||
- | 197 | // mutex_lock(&dev->struct_mutex); |
|
- | 198 | // ret = i915_gem_init_ringbuffer(dev); |
|
- | 199 | // mutex_unlock(&dev->struct_mutex); |
|
- | 200 | // if (ret) |
|
- | 201 | // return ret; |
|
- | 202 | ||
- | 203 | /* Try to set up FBC with a reasonable compressed buffer size */ |
|
- | 204 | // if (I915_HAS_FBC(dev) && i915_powersave) { |
|
- | 205 | // int cfb_size; |
|
- | 206 | ||
- | 207 | /* Leave 1M for line length buffer & misc. */ |
|
- | 208 | ||
- | 209 | /* Try to get a 32M buffer... */ |
|
- | 210 | // if (prealloc_size > (36*1024*1024)) |
|
- | 211 | // cfb_size = 32*1024*1024; |
|
- | 212 | // else /* fall back to 7/8 of the stolen space */ |
|
- | 213 | // cfb_size = prealloc_size * 7 / 8; |
|
- | 214 | // i915_setup_compression(dev, cfb_size); |
|
- | 215 | // } |
|
- | 216 | ||
- | 217 | /* Allow hardware batchbuffers unless told otherwise. */ |
|
- | 218 | dev_priv->allow_batchbuffer = 1; |
|
- | 219 | return 0; |
|
82 | } |
220 | } |
83 | 221 | ||
84 | static int i915_load_modeset_init(struct drm_device *dev) |
222 | static int i915_load_modeset_init(struct drm_device *dev) |
85 | { |
223 | { |
Line 96... | Line 234... | ||
96 | if (IS_GEN3(dev) && (I915_READ(ECOSKPD) & ECO_FLIP_DONE)) |
234 | if (IS_GEN3(dev) && (I915_READ(ECOSKPD) & ECO_FLIP_DONE)) |
97 | dev_priv->flip_pending_is_done = true; |
235 | dev_priv->flip_pending_is_done = true; |
Line 98... | Line 236... | ||
98 | 236 | ||
Line 99... | Line -... | ||
99 | intel_modeset_init(dev); |
- | |
100 | - | ||
101 | #if 0 |
237 | intel_modeset_init(dev); |
102 | 238 | ||
103 | ret = i915_load_gem_init(dev); |
239 | ret = i915_load_gem_init(dev); |
Line -... | Line 240... | ||
- | 240 | if (ret) |
|
- | 241 | goto cleanup_vga_switcheroo; |
|
104 | if (ret) |
242 | |
Line 105... | Line 243... | ||
105 | goto cleanup_vga_switcheroo; |
243 | #if 0 |
106 | 244 | ||
107 | intel_modeset_gem_init(dev); |
245 | intel_modeset_gem_init(dev); |
Line 390... | Line 528... | ||
390 | 528 | ||
Line 391... | Line 529... | ||
391 | 529 | ||
392 | // intel_irq_init(dev); |
530 | // intel_irq_init(dev); |
393 | 531 | ||
394 | /* Try to make sure MCHBAR is enabled before poking at it */ |
- | |
395 | // intel_setup_mchbar(dev); |
532 | /* Try to make sure MCHBAR is enabled before poking at it */ |
Line 396... | Line 533... | ||
396 | intel_setup_gmbus(dev); |
533 | intel_setup_mchbar(dev); |
397 | 534 | intel_setup_gmbus(dev); |
|
Line 398... | Line 535... | ||
398 | intel_opregion_setup(dev); |
535 | intel_opregion_setup(dev); |
Line 399... | Line 536... | ||
399 | 536 | ||
400 | /* Make sure the bios did its job and set up vital registers */ |
537 | /* Make sure the bios did its job and set up vital registers */ |