Commit 2145199c4f0db7c517dd788abec301dc84b91bd0
Exists in
master
and in
38 other branches
Merge branch 'drm-fixes' of git://people.freedesktop.org/~airlied/linux
* 'drm-fixes' of git://people.freedesktop.org/~airlied/linux: dma-buf: Documentation update for Kconfig select nouveau: Support Optimus models for vga_switcheroo nouveau: properly check for _DSM function support dma-buf: drop option text so users don't select it. radeon: Call pci_clear_master() instead of open-coding it. gma500: Discard modes that don't fit in stolen memory drm: bump DRM_CONNECTOR_MAX_ENCODER from 2 to 3 drm/radeon/kms: Fix module parameter description format drm/radeon/kms/ni: fix packet2 handling for VM IB parser ttm/dma: Remove the WARN() which is not useful.
Showing 15 changed files Side-by-side Diff
- Documentation/dma-buf-sharing.txt
- drivers/base/Kconfig
- drivers/gpu/drm/gma500/cdv_intel_crt.c
- drivers/gpu/drm/gma500/cdv_intel_hdmi.c
- drivers/gpu/drm/gma500/oaktrail_hdmi.c
- drivers/gpu/drm/gma500/psb_intel_sdvo.c
- drivers/gpu/drm/nouveau/nouveau_acpi.c
- drivers/gpu/drm/nouveau/nouveau_drv.h
- drivers/gpu/drm/nouveau/nouveau_state.c
- drivers/gpu/drm/radeon/evergreen_cs.c
- drivers/gpu/drm/radeon/r100.c
- drivers/gpu/drm/radeon/radeon_drv.c
- drivers/gpu/drm/radeon/rs600.c
- drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
- include/drm/drm_crtc.h
Documentation/dma-buf-sharing.txt
... | ... | @@ -219,6 +219,10 @@ |
219 | 219 | If the exporter chooses not to allow an attach() operation once a |
220 | 220 | map_dma_buf() API has been called, it simply returns an error. |
221 | 221 | |
222 | +Miscellaneous notes: | |
223 | +- Any exporters or users of the dma-buf buffer sharing framework must have | |
224 | + a 'select DMA_SHARED_BUFFER' in their respective Kconfigs. | |
225 | + | |
222 | 226 | References: |
223 | 227 | [1] struct dma_buf_ops in include/linux/dma-buf.h |
224 | 228 | [2] All interfaces mentioned above defined in include/linux/dma-buf.h |
drivers/base/Kconfig
drivers/gpu/drm/gma500/cdv_intel_crt.c
... | ... | @@ -66,6 +66,7 @@ |
66 | 66 | static int cdv_intel_crt_mode_valid(struct drm_connector *connector, |
67 | 67 | struct drm_display_mode *mode) |
68 | 68 | { |
69 | + struct drm_psb_private *dev_priv = connector->dev->dev_private; | |
69 | 70 | int max_clock = 0; |
70 | 71 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
71 | 72 | return MODE_NO_DBLESCAN; |
... | ... | @@ -81,6 +82,11 @@ |
81 | 82 | |
82 | 83 | if (mode->hdisplay > 1680 || mode->vdisplay > 1050) |
83 | 84 | return MODE_PANEL; |
85 | + | |
86 | + /* We assume worst case scenario of 32 bpp here, since we don't know */ | |
87 | + if ((ALIGN(mode->hdisplay * 4, 64) * mode->vdisplay) > | |
88 | + dev_priv->vram_stolen_size) | |
89 | + return MODE_MEM; | |
84 | 90 | |
85 | 91 | return MODE_OK; |
86 | 92 | } |
drivers/gpu/drm/gma500/cdv_intel_hdmi.c
... | ... | @@ -241,6 +241,7 @@ |
241 | 241 | static int cdv_hdmi_mode_valid(struct drm_connector *connector, |
242 | 242 | struct drm_display_mode *mode) |
243 | 243 | { |
244 | + struct drm_psb_private *dev_priv = connector->dev->dev_private; | |
244 | 245 | |
245 | 246 | if (mode->clock > 165000) |
246 | 247 | return MODE_CLOCK_HIGH; |
... | ... | @@ -255,14 +256,11 @@ |
255 | 256 | if (mode->flags & DRM_MODE_FLAG_INTERLACE) |
256 | 257 | return MODE_NO_INTERLACE; |
257 | 258 | |
258 | - /* | |
259 | - * FIXME: for now we limit the size to 1680x1050 on CDV, otherwise it | |
260 | - * will go beyond the stolen memory size allocated to the framebuffer | |
261 | - */ | |
262 | - if (mode->hdisplay > 1680) | |
263 | - return MODE_PANEL; | |
264 | - if (mode->vdisplay > 1050) | |
265 | - return MODE_PANEL; | |
259 | + /* We assume worst case scenario of 32 bpp here, since we don't know */ | |
260 | + if ((ALIGN(mode->hdisplay * 4, 64) * mode->vdisplay) > | |
261 | + dev_priv->vram_stolen_size) | |
262 | + return MODE_MEM; | |
263 | + | |
266 | 264 | return MODE_OK; |
267 | 265 | } |
268 | 266 |
drivers/gpu/drm/gma500/oaktrail_hdmi.c
... | ... | @@ -506,6 +506,7 @@ |
506 | 506 | static int oaktrail_hdmi_mode_valid(struct drm_connector *connector, |
507 | 507 | struct drm_display_mode *mode) |
508 | 508 | { |
509 | + struct drm_psb_private *dev_priv = connector->dev->dev_private; | |
509 | 510 | if (mode->clock > 165000) |
510 | 511 | return MODE_CLOCK_HIGH; |
511 | 512 | if (mode->clock < 20000) |
... | ... | @@ -513,6 +514,11 @@ |
513 | 514 | |
514 | 515 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
515 | 516 | return MODE_NO_DBLESCAN; |
517 | + | |
518 | + /* We assume worst case scenario of 32 bpp here, since we don't know */ | |
519 | + if ((ALIGN(mode->hdisplay * 4, 64) * mode->vdisplay) > | |
520 | + dev_priv->vram_stolen_size) | |
521 | + return MODE_MEM; | |
516 | 522 | |
517 | 523 | return MODE_OK; |
518 | 524 | } |
drivers/gpu/drm/gma500/psb_intel_sdvo.c
... | ... | @@ -1141,6 +1141,7 @@ |
1141 | 1141 | static int psb_intel_sdvo_mode_valid(struct drm_connector *connector, |
1142 | 1142 | struct drm_display_mode *mode) |
1143 | 1143 | { |
1144 | + struct drm_psb_private *dev_priv = connector->dev->dev_private; | |
1144 | 1145 | struct psb_intel_sdvo *psb_intel_sdvo = intel_attached_sdvo(connector); |
1145 | 1146 | |
1146 | 1147 | if (mode->flags & DRM_MODE_FLAG_DBLSCAN) |
... | ... | @@ -1159,6 +1160,11 @@ |
1159 | 1160 | if (mode->vdisplay > psb_intel_sdvo->sdvo_lvds_fixed_mode->vdisplay) |
1160 | 1161 | return MODE_PANEL; |
1161 | 1162 | } |
1163 | + | |
1164 | + /* We assume worst case scenario of 32 bpp here, since we don't know */ | |
1165 | + if ((ALIGN(mode->hdisplay * 4, 64) * mode->vdisplay) > | |
1166 | + dev_priv->vram_stolen_size) | |
1167 | + return MODE_MEM; | |
1162 | 1168 | |
1163 | 1169 | return MODE_OK; |
1164 | 1170 | } |
drivers/gpu/drm/nouveau/nouveau_acpi.c
... | ... | @@ -18,12 +18,6 @@ |
18 | 18 | |
19 | 19 | #include <linux/vga_switcheroo.h> |
20 | 20 | |
21 | -#define NOUVEAU_DSM_SUPPORTED 0x00 | |
22 | -#define NOUVEAU_DSM_SUPPORTED_FUNCTIONS 0x00 | |
23 | - | |
24 | -#define NOUVEAU_DSM_ACTIVE 0x01 | |
25 | -#define NOUVEAU_DSM_ACTIVE_QUERY 0x00 | |
26 | - | |
27 | 21 | #define NOUVEAU_DSM_LED 0x02 |
28 | 22 | #define NOUVEAU_DSM_LED_STATE 0x00 |
29 | 23 | #define NOUVEAU_DSM_LED_OFF 0x10 |
... | ... | @@ -35,6 +29,9 @@ |
35 | 29 | #define NOUVEAU_DSM_POWER_SPEED 0x01 |
36 | 30 | #define NOUVEAU_DSM_POWER_STAMINA 0x02 |
37 | 31 | |
32 | +#define NOUVEAU_DSM_OPTIMUS_FN 0x1A | |
33 | +#define NOUVEAU_DSM_OPTIMUS_ARGS 0x03000001 | |
34 | + | |
38 | 35 | static struct nouveau_dsm_priv { |
39 | 36 | bool dsm_detected; |
40 | 37 | bool optimus_detected; |
... | ... | @@ -61,7 +58,8 @@ |
61 | 58 | struct acpi_object_list input; |
62 | 59 | union acpi_object params[4]; |
63 | 60 | union acpi_object *obj; |
64 | - int err; | |
61 | + int i, err; | |
62 | + char args_buff[4]; | |
65 | 63 | |
66 | 64 | input.count = 4; |
67 | 65 | input.pointer = params; |
... | ... | @@ -73,7 +71,11 @@ |
73 | 71 | params[2].type = ACPI_TYPE_INTEGER; |
74 | 72 | params[2].integer.value = func; |
75 | 73 | params[3].type = ACPI_TYPE_BUFFER; |
76 | - params[3].buffer.length = 0; | |
74 | + params[3].buffer.length = 4; | |
75 | + /* ACPI is little endian, AABBCCDD becomes {DD,CC,BB,AA} */ | |
76 | + for (i = 0; i < 4; i++) | |
77 | + args_buff[i] = (arg >> i * 8) & 0xFF; | |
78 | + params[3].buffer.pointer = args_buff; | |
77 | 79 | |
78 | 80 | err = acpi_evaluate_object(handle, "_DSM", &input, &output); |
79 | 81 | if (err) { |
... | ... | @@ -148,6 +150,23 @@ |
148 | 150 | return 0; |
149 | 151 | } |
150 | 152 | |
153 | +/* Returns 1 if a DSM function is usable and 0 otherwise */ | |
154 | +static int nouveau_test_dsm(acpi_handle test_handle, | |
155 | + int (*dsm_func)(acpi_handle, int, int, uint32_t *), | |
156 | + int sfnc) | |
157 | +{ | |
158 | + u32 result = 0; | |
159 | + | |
160 | + /* Function 0 returns a Buffer containing available functions. The args | |
161 | + * parameter is ignored for function 0, so just put 0 in it */ | |
162 | + if (dsm_func(test_handle, 0, 0, &result)) | |
163 | + return 0; | |
164 | + | |
165 | + /* ACPI Spec v4 9.14.1: if bit 0 is zero, no function is supported. If | |
166 | + * the n-th bit is enabled, function n is supported */ | |
167 | + return result & 1 && result & (1 << sfnc); | |
168 | +} | |
169 | + | |
151 | 170 | static int nouveau_dsm_switch_mux(acpi_handle handle, int mux_id) |
152 | 171 | { |
153 | 172 | mxm_wmi_call_mxmx(mux_id == NOUVEAU_DSM_LED_STAMINA ? MXM_MXDS_ADAPTER_IGD : MXM_MXDS_ADAPTER_0); |
... | ... | @@ -168,6 +187,10 @@ |
168 | 187 | |
169 | 188 | static int nouveau_dsm_switchto(enum vga_switcheroo_client_id id) |
170 | 189 | { |
190 | + /* perhaps the _DSM functions are mutually exclusive, but prepare for | |
191 | + * the future */ | |
192 | + if (!nouveau_dsm_priv.dsm_detected && nouveau_dsm_priv.optimus_detected) | |
193 | + return 0; | |
171 | 194 | if (id == VGA_SWITCHEROO_IGD) |
172 | 195 | return nouveau_dsm_switch_mux(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_LED_STAMINA); |
173 | 196 | else |
... | ... | @@ -180,6 +203,11 @@ |
180 | 203 | if (id == VGA_SWITCHEROO_IGD) |
181 | 204 | return 0; |
182 | 205 | |
206 | + /* Optimus laptops have the card already disabled in | |
207 | + * nouveau_switcheroo_set_state */ | |
208 | + if (!nouveau_dsm_priv.dsm_detected && nouveau_dsm_priv.optimus_detected) | |
209 | + return 0; | |
210 | + | |
183 | 211 | return nouveau_dsm_set_discrete_state(nouveau_dsm_priv.dhandle, state); |
184 | 212 | } |
185 | 213 | |
... | ... | @@ -212,8 +240,7 @@ |
212 | 240 | { |
213 | 241 | acpi_handle dhandle, nvidia_handle; |
214 | 242 | acpi_status status; |
215 | - int ret, retval = 0; | |
216 | - uint32_t result; | |
243 | + int retval = 0; | |
217 | 244 | |
218 | 245 | dhandle = DEVICE_ACPI_HANDLE(&pdev->dev); |
219 | 246 | if (!dhandle) |
220 | 247 | |
... | ... | @@ -224,13 +251,11 @@ |
224 | 251 | return false; |
225 | 252 | } |
226 | 253 | |
227 | - ret = nouveau_dsm(dhandle, NOUVEAU_DSM_SUPPORTED, | |
228 | - NOUVEAU_DSM_SUPPORTED_FUNCTIONS, &result); | |
229 | - if (ret == 0) | |
254 | + if (nouveau_test_dsm(dhandle, nouveau_dsm, NOUVEAU_DSM_POWER)) | |
230 | 255 | retval |= NOUVEAU_DSM_HAS_MUX; |
231 | 256 | |
232 | - ret = nouveau_optimus_dsm(dhandle, 0, 0, &result); | |
233 | - if (ret == 0) | |
257 | + if (nouveau_test_dsm(dhandle, nouveau_optimus_dsm, | |
258 | + NOUVEAU_DSM_OPTIMUS_FN)) | |
234 | 259 | retval |= NOUVEAU_DSM_HAS_OPT; |
235 | 260 | |
236 | 261 | if (retval) |
237 | 262 | |
238 | 263 | |
239 | 264 | |
... | ... | @@ -269,15 +294,22 @@ |
269 | 294 | } |
270 | 295 | |
271 | 296 | if (vga_count == 2 && has_dsm && guid_valid) { |
272 | - acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME, &buffer); | |
297 | + acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME, | |
298 | + &buffer); | |
273 | 299 | printk(KERN_INFO "VGA switcheroo: detected DSM switching method %s handle\n", |
274 | - acpi_method_name); | |
300 | + acpi_method_name); | |
275 | 301 | nouveau_dsm_priv.dsm_detected = true; |
276 | 302 | ret = true; |
277 | 303 | } |
278 | 304 | |
279 | - if (has_optimus == 1) | |
305 | + if (has_optimus == 1) { | |
306 | + acpi_get_name(nouveau_dsm_priv.dhandle, ACPI_FULL_PATHNAME, | |
307 | + &buffer); | |
308 | + printk(KERN_INFO "VGA switcheroo: detected Optimus DSM method %s handle\n", | |
309 | + acpi_method_name); | |
280 | 310 | nouveau_dsm_priv.optimus_detected = true; |
311 | + ret = true; | |
312 | + } | |
281 | 313 | |
282 | 314 | return ret; |
283 | 315 | } |
... | ... | @@ -291,6 +323,17 @@ |
291 | 323 | return; |
292 | 324 | |
293 | 325 | vga_switcheroo_register_handler(&nouveau_dsm_handler); |
326 | +} | |
327 | + | |
328 | +/* Must be called for Optimus models before the card can be turned off */ | |
329 | +void nouveau_switcheroo_optimus_dsm(void) | |
330 | +{ | |
331 | + u32 result = 0; | |
332 | + if (!nouveau_dsm_priv.optimus_detected) | |
333 | + return; | |
334 | + | |
335 | + nouveau_optimus_dsm(nouveau_dsm_priv.dhandle, NOUVEAU_DSM_OPTIMUS_FN, | |
336 | + NOUVEAU_DSM_OPTIMUS_ARGS, &result); | |
294 | 337 | } |
295 | 338 | |
296 | 339 | void nouveau_unregister_dsm_handler(void) |
drivers/gpu/drm/nouveau/nouveau_drv.h
... | ... | @@ -1055,12 +1055,14 @@ |
1055 | 1055 | #if defined(CONFIG_ACPI) |
1056 | 1056 | void nouveau_register_dsm_handler(void); |
1057 | 1057 | void nouveau_unregister_dsm_handler(void); |
1058 | +void nouveau_switcheroo_optimus_dsm(void); | |
1058 | 1059 | int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len); |
1059 | 1060 | bool nouveau_acpi_rom_supported(struct pci_dev *pdev); |
1060 | 1061 | int nouveau_acpi_edid(struct drm_device *, struct drm_connector *); |
1061 | 1062 | #else |
1062 | 1063 | static inline void nouveau_register_dsm_handler(void) {} |
1063 | 1064 | static inline void nouveau_unregister_dsm_handler(void) {} |
1065 | +static inline void nouveau_switcheroo_optimus_dsm(void) {} | |
1064 | 1066 | static inline bool nouveau_acpi_rom_supported(struct pci_dev *pdev) { return false; } |
1065 | 1067 | static inline int nouveau_acpi_get_bios_chunk(uint8_t *bios, int offset, int len) { return -EINVAL; } |
1066 | 1068 | static inline int nouveau_acpi_edid(struct drm_device *dev, struct drm_connector *connector) { return -EINVAL; } |
drivers/gpu/drm/nouveau/nouveau_state.c
... | ... | @@ -525,6 +525,7 @@ |
525 | 525 | printk(KERN_ERR "VGA switcheroo: switched nouveau off\n"); |
526 | 526 | dev->switch_power_state = DRM_SWITCH_POWER_CHANGING; |
527 | 527 | drm_kms_helper_poll_disable(dev); |
528 | + nouveau_switcheroo_optimus_dsm(); | |
528 | 529 | nouveau_pci_suspend(pdev, pmm); |
529 | 530 | dev->switch_power_state = DRM_SWITCH_POWER_OFF; |
530 | 531 | } |
drivers/gpu/drm/radeon/evergreen_cs.c
... | ... | @@ -1793,10 +1793,12 @@ |
1793 | 1793 | ret = -EINVAL; |
1794 | 1794 | break; |
1795 | 1795 | case PACKET_TYPE2: |
1796 | + idx += 1; | |
1796 | 1797 | break; |
1797 | 1798 | case PACKET_TYPE3: |
1798 | 1799 | pkt.opcode = CP_PACKET3_GET_OPCODE(ib->ptr[idx]); |
1799 | 1800 | ret = evergreen_vm_packet3_check(rdev, ib->ptr, &pkt); |
1801 | + idx += pkt.count + 2; | |
1800 | 1802 | break; |
1801 | 1803 | default: |
1802 | 1804 | dev_err(rdev->dev, "Unknown packet type %d !\n", pkt.type); |
... | ... | @@ -1805,7 +1807,6 @@ |
1805 | 1807 | } |
1806 | 1808 | if (ret) |
1807 | 1809 | break; |
1808 | - idx += pkt.count + 2; | |
1809 | 1810 | } while (idx < ib->length_dw); |
1810 | 1811 | |
1811 | 1812 | return ret; |
drivers/gpu/drm/radeon/r100.c
... | ... | @@ -2186,7 +2186,6 @@ |
2186 | 2186 | void r100_bm_disable(struct radeon_device *rdev) |
2187 | 2187 | { |
2188 | 2188 | u32 tmp; |
2189 | - u16 tmp16; | |
2190 | 2189 | |
2191 | 2190 | /* disable bus mastering */ |
2192 | 2191 | tmp = RREG32(R_000030_BUS_CNTL); |
... | ... | @@ -2197,8 +2196,7 @@ |
2197 | 2196 | WREG32(R_000030_BUS_CNTL, (tmp & 0xFFFFFFFF) | 0x00000040); |
2198 | 2197 | tmp = RREG32(RADEON_BUS_CNTL); |
2199 | 2198 | mdelay(1); |
2200 | - pci_read_config_word(rdev->pdev, 0x4, &tmp16); | |
2201 | - pci_write_config_word(rdev->pdev, 0x4, tmp16 & 0xFFFB); | |
2199 | + pci_clear_master(rdev->pdev); | |
2202 | 2200 | mdelay(1); |
2203 | 2201 | } |
2204 | 2202 |
drivers/gpu/drm/radeon/radeon_drv.c
... | ... | @@ -145,7 +145,7 @@ |
145 | 145 | MODULE_PARM_DESC(agpmode, "AGP Mode (-1 == PCI)"); |
146 | 146 | module_param_named(agpmode, radeon_agpmode, int, 0444); |
147 | 147 | |
148 | -MODULE_PARM_DESC(gartsize, "Size of PCIE/IGP gart to setup in megabytes (32,64, etc)\n"); | |
148 | +MODULE_PARM_DESC(gartsize, "Size of PCIE/IGP gart to setup in megabytes (32, 64, etc)"); | |
149 | 149 | module_param_named(gartsize, radeon_gart_size, int, 0600); |
150 | 150 | |
151 | 151 | MODULE_PARM_DESC(benchmark, "Run benchmark"); |
drivers/gpu/drm/radeon/rs600.c
... | ... | @@ -322,16 +322,6 @@ |
322 | 322 | } |
323 | 323 | } |
324 | 324 | |
325 | -void rs600_bm_disable(struct radeon_device *rdev) | |
326 | -{ | |
327 | - u16 tmp; | |
328 | - | |
329 | - /* disable bus mastering */ | |
330 | - pci_read_config_word(rdev->pdev, 0x4, &tmp); | |
331 | - pci_write_config_word(rdev->pdev, 0x4, tmp & 0xFFFB); | |
332 | - mdelay(1); | |
333 | -} | |
334 | - | |
335 | 325 | int rs600_asic_reset(struct radeon_device *rdev) |
336 | 326 | { |
337 | 327 | struct rv515_mc_save save; |
... | ... | @@ -355,7 +345,8 @@ |
355 | 345 | WREG32(RADEON_CP_RB_CNTL, tmp); |
356 | 346 | pci_save_state(rdev->pdev); |
357 | 347 | /* disable bus mastering */ |
358 | - rs600_bm_disable(rdev); | |
348 | + pci_clear_master(rdev->pdev); | |
349 | + mdelay(1); | |
359 | 350 | /* reset GA+VAP */ |
360 | 351 | WREG32(R_0000F0_RBBM_SOFT_RESET, S_0000F0_SOFT_RESET_VAP(1) | |
361 | 352 | S_0000F0_SOFT_RESET_GA(1)); |
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
... | ... | @@ -952,10 +952,9 @@ |
952 | 952 | |
953 | 953 | type = ttm_to_type(ttm->page_flags, ttm->caching_state); |
954 | 954 | pool = ttm_dma_find_pool(dev, type); |
955 | - if (!pool) { | |
956 | - WARN_ON(!pool); | |
955 | + if (!pool) | |
957 | 956 | return; |
958 | - } | |
957 | + | |
959 | 958 | is_cached = (ttm_dma_find_pool(pool->dev, |
960 | 959 | ttm_to_type(ttm->page_flags, tt_cached)) == pool); |
961 | 960 |
include/drm/drm_crtc.h
... | ... | @@ -453,7 +453,7 @@ |
453 | 453 | #define DRM_CONNECTOR_MAX_UMODES 16 |
454 | 454 | #define DRM_CONNECTOR_MAX_PROPERTY 16 |
455 | 455 | #define DRM_CONNECTOR_LEN 32 |
456 | -#define DRM_CONNECTOR_MAX_ENCODER 2 | |
456 | +#define DRM_CONNECTOR_MAX_ENCODER 3 | |
457 | 457 | |
458 | 458 | /** |
459 | 459 | * drm_encoder - central DRM encoder structure |