Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'drm-next-2020-04-08' of git://anongit.freedesktop.org/drm/drm

Pull drm fixes from Dave Airlie:
"This is a set of fixes that have queued up, I think I might have
another pull with some more before rc1 but I'd like to dequeue what I
have now just in case Easter is more eggciting that expected.

The main thing in here is a fix for a longstanding nouveau power
management issues on certain laptops, it should help runtime
suspend/resume for a lot of people.

There is also a reverted patch for some drm_mm behaviour in atomic
contexts.

Summary:

core:
- revert drm_mm atomic patch
- dt binding fixes

fbcon:
- null ptr error fix

i915:
- GVT fixes

nouveau:
- runpm fix
- svm fixes

amdgpu:
- HDCP fixes
- gfx10 fix
- Misc display fixes
- BACO fixes

amdkfd:
- Fix memory leak

vboxvideo:
- remove conflicting fbs

vc4:
- mode validation fix

xen:
- fix PTR_ERR usage"

* tag 'drm-next-2020-04-08' of git://anongit.freedesktop.org/drm/drm: (41 commits)
drm/nouveau/kms/nv50-: wait for FIFO space on PIO channels
drm/nouveau/nvif: protect waits against GPU falling off the bus
drm/nouveau/nvif: access PTIMER through usermode class, if available
drm/nouveau/gr/gp107,gp108: implement workaround for HW hanging during init
drm/nouveau: workaround runpm fail by disabling PCI power management on certain intel bridges
drm/nouveau/svm: remove useless SVM range check
drm/nouveau/svm: check for SVM initialized before migrating
drm/nouveau/svm: fix vma range check for migration
drm/nouveau: remove checks for return value of debugfs functions
drm/nouveau/ttm: evict other IO mappings when running out of BAR1 space
drm/amdkfd: kfree the wrong pointer
drm/amd/display: increase HDCP authentication delay
drm/amd/display: Correctly cancel future watchdog and callback events
drm/amd/display: Don't try hdcp1.4 when content_type is set to type1
drm/amd/powerplay: move the ASIC specific nbio operation out of smu_v11_0.c
drm/amd/powerplay: drop redundant BIF doorbell interrupt operations
drm/amd/display: Fix dcn21 num_states
drm/amd/display: Enable BT2020 in COLOR_ENCODING property
drm/amd/display: LFC not working on 2.0x range monitors (v2)
drm/amd/display: Support plane level CTM
...

+538 -227
-10
Documentation/devicetree/bindings/display/panel/panel-dpi.yaml
··· 21 21 - {} 22 22 - const: panel-dpi 23 23 24 - data-mapping: 25 - enum: 26 - - rgb24 27 - - rgb565 28 - - bgr666 29 - description: | 30 - Describes the media format, how the display panel is connected 31 - to the display interface. 32 - 33 24 backlight: true 34 25 enable-gpios: true 35 26 height-mm: true ··· 43 52 compatible = "osddisplays,osd057T0559-34ts", "panel-dpi"; 44 53 label = "osddisplay"; 45 54 power-supply = <&vcc_supply>; 46 - data-mapping = "rgb565"; 47 55 backlight = <&backlight>; 48 56 49 57 port {
+2 -2
Documentation/devicetree/bindings/display/ti/ti,am65x-dss.yaml
··· 65 65 ports: 66 66 type: object 67 67 description: 68 - Ports as described in Documentation/devictree/bindings/graph.txt 68 + Ports as described in Documentation/devicetree/bindings/graph.txt 69 69 properties: 70 70 "#address-cells": 71 71 const: 1 ··· 121 121 #include <dt-bindings/interrupt-controller/irq.h> 122 122 #include <dt-bindings/soc/ti,sci_pm_domain.h> 123 123 124 - dss: dss@04a00000 { 124 + dss: dss@4a00000 { 125 125 compatible = "ti,am65x-dss"; 126 126 reg = <0x0 0x04a00000 0x0 0x1000>, /* common */ 127 127 <0x0 0x04a02000 0x0 0x1000>, /* vidl1 */
+2 -2
Documentation/devicetree/bindings/display/ti/ti,j721e-dss.yaml
··· 98 98 ports: 99 99 type: object 100 100 description: 101 - Ports as described in Documentation/devictree/bindings/graph.txt 101 + Ports as described in Documentation/devicetree/bindings/graph.txt 102 102 properties: 103 103 "#address-cells": 104 104 const: 1 ··· 154 154 #include <dt-bindings/interrupt-controller/irq.h> 155 155 #include <dt-bindings/soc/ti,sci_pm_domain.h> 156 156 157 - dss: dss@04a00000 { 157 + dss: dss@4a00000 { 158 158 compatible = "ti,j721e-dss"; 159 159 reg = <0x00 0x04a00000 0x00 0x10000>, /* common_m */ 160 160 <0x00 0x04a10000 0x00 0x10000>, /* common_s0*/
+2 -2
Documentation/devicetree/bindings/display/ti/ti,k2g-dss.yaml
··· 56 56 port: 57 57 type: object 58 58 description: 59 - Port as described in Documentation/devictree/bindings/graph.txt. 59 + Port as described in Documentation/devicetree/bindings/graph.txt. 60 60 The DSS DPI output port node 61 61 62 62 max-memory-bandwidth: ··· 81 81 #include <dt-bindings/interrupt-controller/arm-gic.h> 82 82 #include <dt-bindings/interrupt-controller/irq.h> 83 83 84 - dss: dss@02540000 { 84 + dss: dss@2540000 { 85 85 compatible = "ti,k2g-dss"; 86 86 reg = <0x02540000 0x400>, 87 87 <0x02550000 0x1000>,
+6 -5
drivers/dma-buf/Kconfig
··· 43 43 bool "Move notify between drivers (EXPERIMENTAL)" 44 44 default n 45 45 help 46 - Don''t pin buffers if the dynamic DMA-buf interface is available on both the 47 - exporter as well as the importer. This fixes a security problem where 48 - userspace is able to pin unrestricted amounts of memory through DMA-buf. 49 - But marked experimental because we don''t jet have a consistent execution 50 - context and memory management between drivers. 46 + Don't pin buffers if the dynamic DMA-buf interface is available on 47 + both the exporter as well as the importer. This fixes a security 48 + problem where userspace is able to pin unrestricted amounts of memory 49 + through DMA-buf. 50 + This is marked experimental because we don't yet have a consistent 51 + execution context and memory management between drivers. 51 52 52 53 config DMABUF_SELFTESTS 53 54 tristate "Selftests for the dma-buf interfaces"
+1 -1
drivers/gpu/drm/amd/amdgpu/gfx_v10_0.c
··· 1113 1113 return r; 1114 1114 } 1115 1115 1116 - memset(hpd, 0, adev->gfx.mec.hpd_eop_obj->tbo.mem.size); 1116 + memset(hpd, 0, mec_hpd_size); 1117 1117 1118 1118 amdgpu_bo_kunmap(adev->gfx.mec.hpd_eop_obj); 1119 1119 amdgpu_bo_unreserve(adev->gfx.mec.hpd_eop_obj);
+1 -1
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c
··· 1946 1946 return r; 1947 1947 } 1948 1948 1949 - memset(hpd, 0, adev->gfx.mec.hpd_eop_obj->tbo.mem.size); 1949 + memset(hpd, 0, mec_hpd_size); 1950 1950 1951 1951 amdgpu_bo_kunmap(adev->gfx.mec.hpd_eop_obj); 1952 1952 amdgpu_bo_unreserve(adev->gfx.mec.hpd_eop_obj);
+2 -2
drivers/gpu/drm/amd/amdkfd/kfd_device.c
··· 1112 1112 return 0; 1113 1113 1114 1114 kfd_gtt_no_free_chunk: 1115 - pr_debug("Allocation failed with mem_obj = %p\n", mem_obj); 1115 + pr_debug("Allocation failed with mem_obj = %p\n", *mem_obj); 1116 1116 mutex_unlock(&kfd->gtt_sa_lock); 1117 - kfree(mem_obj); 1117 + kfree(*mem_obj); 1118 1118 return -ENOMEM; 1119 1119 } 1120 1120
+10 -2
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
··· 3639 3639 case DRM_FORMAT_NV12: 3640 3640 plane_info->format = SURFACE_PIXEL_FORMAT_VIDEO_420_YCrCb; 3641 3641 break; 3642 + case DRM_FORMAT_P010: 3643 + plane_info->format = SURFACE_PIXEL_FORMAT_VIDEO_420_10bpc_YCrCb; 3644 + break; 3642 3645 default: 3643 3646 DRM_ERROR( 3644 3647 "Unsupported screen format %s\n", ··· 5538 5535 5539 5536 if (plane_cap && plane_cap->pixel_format_support.nv12) 5540 5537 formats[num_formats++] = DRM_FORMAT_NV12; 5538 + if (plane_cap && plane_cap->pixel_format_support.p010) 5539 + formats[num_formats++] = DRM_FORMAT_P010; 5541 5540 break; 5542 5541 5543 5542 case DRM_PLANE_TYPE_OVERLAY: ··· 5592 5587 } 5593 5588 5594 5589 if (plane->type == DRM_PLANE_TYPE_PRIMARY && 5595 - plane_cap && plane_cap->pixel_format_support.nv12) { 5590 + plane_cap && 5591 + (plane_cap->pixel_format_support.nv12 || 5592 + plane_cap->pixel_format_support.p010)) { 5596 5593 /* This only affects YUV formats. */ 5597 5594 drm_plane_create_color_properties( 5598 5595 plane, 5599 5596 BIT(DRM_COLOR_YCBCR_BT601) | 5600 - BIT(DRM_COLOR_YCBCR_BT709), 5597 + BIT(DRM_COLOR_YCBCR_BT709) | 5598 + BIT(DRM_COLOR_YCBCR_BT2020), 5601 5599 BIT(DRM_COLOR_YCBCR_LIMITED_RANGE) | 5602 5600 BIT(DRM_COLOR_YCBCR_FULL_RANGE), 5603 5601 DRM_COLOR_YCBCR_BT709, DRM_COLOR_YCBCR_LIMITED_RANGE);
+10 -4
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
··· 192 192 &hdcp_work->srm_version); 193 193 194 194 display->adjust.disable = 0; 195 - if (content_type == DRM_MODE_HDCP_CONTENT_TYPE0) 195 + if (content_type == DRM_MODE_HDCP_CONTENT_TYPE0) { 196 + hdcp_w->link.adjust.hdcp1.disable = 0; 196 197 hdcp_w->link.adjust.hdcp2.force_type = MOD_HDCP_FORCE_TYPE_0; 197 - else if (content_type == DRM_MODE_HDCP_CONTENT_TYPE1) 198 + } else if (content_type == DRM_MODE_HDCP_CONTENT_TYPE1) { 199 + hdcp_w->link.adjust.hdcp1.disable = 1; 198 200 hdcp_w->link.adjust.hdcp2.force_type = MOD_HDCP_FORCE_TYPE_1; 201 + } 199 202 200 203 schedule_delayed_work(&hdcp_w->property_validate_dwork, 201 204 msecs_to_jiffies(DRM_HDCP_CHECK_PERIOD_MS)); ··· 266 263 267 264 mutex_lock(&hdcp_work->mutex); 268 265 269 - cancel_delayed_work(&hdcp_work->watchdog_timer_dwork); 266 + cancel_delayed_work(&hdcp_work->callback_dwork); 270 267 271 268 mod_hdcp_process_event(&hdcp_work->hdcp, MOD_HDCP_EVENT_CALLBACK, 272 269 &hdcp_work->output); ··· 347 344 348 345 mutex_lock(&hdcp_work->mutex); 349 346 347 + cancel_delayed_work(&hdcp_work->watchdog_timer_dwork); 348 + 350 349 mod_hdcp_process_event(&hdcp_work->hdcp, 351 350 MOD_HDCP_EVENT_WATCHDOG_TIMEOUT, 352 351 &hdcp_work->output); ··· 419 414 link->dp.rev = aconnector->dc_link->dpcd_caps.dpcd_rev.raw; 420 415 link->dp.mst_supported = config->mst_supported; 421 416 display->adjust.disable = 1; 422 - link->adjust.auth_delay = 2; 417 + link->adjust.auth_delay = 3; 418 + link->adjust.hdcp1.disable = 0; 423 419 424 420 hdcp_update_display(hdcp_work, link_index, aconnector, DRM_MODE_HDCP_CONTENT_TYPE0, false); 425 421 }
+32 -1
drivers/gpu/drm/amd/display/dc/core/dc.c
··· 1360 1360 return (result == DC_OK); 1361 1361 } 1362 1362 1363 + static bool is_flip_pending_in_pipes(struct dc *dc, struct dc_state *context) 1364 + { 1365 + int i; 1366 + struct pipe_ctx *pipe; 1367 + 1368 + for (i = 0; i < MAX_PIPES; i++) { 1369 + pipe = &context->res_ctx.pipe_ctx[i]; 1370 + 1371 + if (!pipe->plane_state) 1372 + continue; 1373 + 1374 + /* Must set to false to start with, due to OR in update function */ 1375 + pipe->plane_state->status.is_flip_pending = false; 1376 + dc->hwss.update_pending_status(pipe); 1377 + if (pipe->plane_state->status.is_flip_pending) 1378 + return true; 1379 + } 1380 + return false; 1381 + } 1382 + 1363 1383 bool dc_post_update_surfaces_to_stream(struct dc *dc) 1364 1384 { 1365 1385 int i; ··· 1389 1369 return true; 1390 1370 1391 1371 post_surface_trace(dc); 1372 + 1373 + if (is_flip_pending_in_pipes(dc, context)) 1374 + return true; 1392 1375 1393 1376 for (i = 0; i < dc->res_pool->pipe_count; i++) 1394 1377 if (context->res_ctx.pipe_ctx[i].stream == NULL || ··· 1726 1703 if (u->coeff_reduction_factor) 1727 1704 update_flags->bits.coeff_reduction_change = 1; 1728 1705 1706 + if (u->gamut_remap_matrix) 1707 + update_flags->bits.gamut_remap_change = 1; 1708 + 1729 1709 if (u->gamma) { 1730 1710 enum surface_pixel_format format = SURFACE_PIXEL_FORMAT_GRPH_BEGIN; 1731 1711 ··· 1754 1728 1755 1729 if (update_flags->bits.input_csc_change 1756 1730 || update_flags->bits.coeff_reduction_change 1757 - || update_flags->bits.gamma_change) { 1731 + || update_flags->bits.gamma_change 1732 + || update_flags->bits.gamut_remap_change) { 1758 1733 type = UPDATE_TYPE_FULL; 1759 1734 elevate_update_type(&overall_type, type); 1760 1735 } ··· 2000 1973 if (srf_update->coeff_reduction_factor) 2001 1974 surface->coeff_reduction_factor = 2002 1975 *srf_update->coeff_reduction_factor; 1976 + 1977 + if (srf_update->gamut_remap_matrix) 1978 + surface->gamut_remap_matrix = 1979 + *srf_update->gamut_remap_matrix; 2003 1980 } 2004 1981 2005 1982 static void copy_stream_update_to_stream(struct dc *dc,
+1
drivers/gpu/drm/amd/display/dc/core/dc_resource.c
··· 1077 1077 * on certain displays, such as the Sharp 4k 1078 1078 */ 1079 1079 pipe_ctx->plane_res.scl_data.lb_params.depth = LB_PIXEL_DEPTH_30BPP; 1080 + pipe_ctx->plane_res.scl_data.lb_params.alpha_en = plane_state->per_pixel_alpha; 1080 1081 1081 1082 pipe_ctx->plane_res.scl_data.recout.x += timing->h_border_left; 1082 1083 pipe_ctx->plane_res.scl_data.recout.y += timing->v_border_top;
+3
drivers/gpu/drm/amd/display/dc/dc.h
··· 726 726 uint32_t output_tf_change:1; 727 727 uint32_t pixel_format_change:1; 728 728 uint32_t plane_size_change:1; 729 + uint32_t gamut_remap_change:1; 729 730 730 731 /* Full updates */ 731 732 uint32_t new_plane:1; ··· 761 760 struct dc_csc_transform input_csc_color_matrix; 762 761 struct fixed31_32 coeff_reduction_factor; 763 762 struct fixed31_32 hdr_mult; 763 + struct colorspace_transform gamut_remap_matrix; 764 764 765 765 // TODO: No longer used, remove 766 766 struct dc_hdr_static_metadata hdr_static_ctx; ··· 841 839 const struct dc_transfer_func *func_shaper; 842 840 const struct dc_3dlut *lut3d_func; 843 841 const struct dc_transfer_func *blend_tf; 842 + const struct colorspace_transform *gamut_remap_matrix; 844 843 }; 845 844 846 845 /*
+6
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
··· 2004 2004 for (i = 0; i < CSC_TEMPERATURE_MATRIX_SIZE; i++) 2005 2005 adjust.temperature_matrix[i] = 2006 2006 pipe_ctx->stream->gamut_remap_matrix.matrix[i]; 2007 + } else if (pipe_ctx->plane_state && 2008 + pipe_ctx->plane_state->gamut_remap_matrix.enable_remap == true) { 2009 + adjust.gamut_adjust_type = GRAPHICS_GAMUT_ADJUST_TYPE_SW; 2010 + for (i = 0; i < CSC_TEMPERATURE_MATRIX_SIZE; i++) 2011 + adjust.temperature_matrix[i] = 2012 + pipe_ctx->plane_state->gamut_remap_matrix.matrix[i]; 2007 2013 } 2008 2014 2009 2015 pipe_ctx->plane_res.dpp->funcs->dpp_set_gamut_remap(pipe_ctx->plane_res.dpp, &adjust);
+18
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c
··· 343 343 } 344 344 345 345 /** 346 + * optc1_set_timing_double_buffer() - DRR double buffering control 347 + * 348 + * Sets double buffer point for V_TOTAL, H_TOTAL, VTOTAL_MIN, 349 + * VTOTAL_MAX, VTOTAL_MIN_SEL and VTOTAL_MAX_SEL registers. 350 + * 351 + * Options: any time, start of frame, dp start of frame (range timing) 352 + */ 353 + void optc1_set_timing_double_buffer(struct timing_generator *optc, bool enable) 354 + { 355 + struct optc *optc1 = DCN10TG_FROM_TG(optc); 356 + uint32_t mode = enable ? 2 : 0; 357 + 358 + REG_UPDATE(OTG_DOUBLE_BUFFER_CONTROL, 359 + OTG_RANGE_TIMING_DBUF_UPDATE_MODE, mode); 360 + } 361 + 362 + /** 346 363 * unblank_crtc 347 364 * Call ASIC Control Object to UnBlank CRTC. 348 365 */ ··· 1370 1353 void optc1_tg_init(struct timing_generator *optc) 1371 1354 { 1372 1355 optc1_set_blank_data_double_buffer(optc, true); 1356 + optc1_set_timing_double_buffer(optc, true); 1373 1357 optc1_clear_optc_underflow(optc); 1374 1358 } 1375 1359
+3
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.h
··· 185 185 SF(OTG0_OTG_GLOBAL_CONTROL0, OTG_MASTER_UPDATE_LOCK_SEL, mask_sh),\ 186 186 SF(OTG0_OTG_DOUBLE_BUFFER_CONTROL, OTG_UPDATE_PENDING, mask_sh),\ 187 187 SF(OTG0_OTG_DOUBLE_BUFFER_CONTROL, OTG_BLANK_DATA_DOUBLE_BUFFER_EN, mask_sh),\ 188 + SF(OTG0_OTG_DOUBLE_BUFFER_CONTROL, OTG_RANGE_TIMING_DBUF_UPDATE_MODE, mask_sh),\ 188 189 SF(OTG0_OTG_H_TOTAL, OTG_H_TOTAL, mask_sh),\ 189 190 SF(OTG0_OTG_H_BLANK_START_END, OTG_H_BLANK_START, mask_sh),\ 190 191 SF(OTG0_OTG_H_BLANK_START_END, OTG_H_BLANK_END, mask_sh),\ ··· 643 642 bool optc1_is_optc_underflow_occurred(struct timing_generator *optc); 644 643 645 644 void optc1_set_blank_data_double_buffer(struct timing_generator *optc, bool enable); 645 + 646 + void optc1_set_timing_double_buffer(struct timing_generator *optc, bool enable); 646 647 647 648 bool optc1_get_otg_active_size(struct timing_generator *optc, 648 649 uint32_t *otg_active_width,
+2 -1
drivers/gpu/drm/amd/display/dc/dcn10/dcn10_resource.c
··· 552 552 .pixel_format_support = { 553 553 .argb8888 = true, 554 554 .nv12 = true, 555 - .fp16 = true 555 + .fp16 = true, 556 + .p010 = true 556 557 }, 557 558 558 559 .max_upscale_factor = {
+3 -2
drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
··· 1012 1012 .pixel_format_support = { 1013 1013 .argb8888 = true, 1014 1014 .nv12 = true, 1015 - .fp16 = true 1015 + .fp16 = true, 1016 + .p010 = true 1016 1017 }, 1017 1018 1018 1019 .max_upscale_factor = { ··· 3343 3342 void dcn20_update_bounding_box(struct dc *dc, struct _vcs_dpi_soc_bounding_box_st *bb, 3344 3343 struct pp_smu_nv_clock_table *max_clocks, unsigned int *uclk_states, unsigned int num_states) 3345 3344 { 3346 - struct _vcs_dpi_voltage_scaling_st calculated_states[MAX_CLOCK_LIMIT_STATES]; 3345 + struct _vcs_dpi_voltage_scaling_st calculated_states[DC__VOLTAGE_STATES]; 3347 3346 int i; 3348 3347 int num_calculated_states = 0; 3349 3348 int min_dcfclk = 0;
+14 -26
drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
··· 300 300 .xfc_bus_transport_time_us = 4, 301 301 .xfc_xbuf_latency_tolerance_us = 4, 302 302 .use_urgent_burst_bw = 1, 303 - .num_states = 9 303 + .num_states = 8 304 304 }; 305 305 306 306 #ifndef MAX ··· 838 838 .pixel_format_support = { 839 839 .argb8888 = true, 840 840 .nv12 = true, 841 - .fp16 = true 841 + .fp16 = true, 842 + .p010 = true 842 843 }, 843 844 844 845 .max_upscale_factor = { ··· 1377 1376 unsigned int i, j, k; 1378 1377 int closest_clk_lvl; 1379 1378 1380 - // diags does not retrieve proper values from SMU 1381 - // cap states to 5 and make state 5 the max state 1382 - if (IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment) || IS_DIAG_DC(dc->ctx->dce_environment)) { 1383 - dcn2_1_soc.num_states = 5; 1384 - 1385 - dcn2_1_soc.clock_limits[5].state = 5; 1386 - dcn2_1_soc.clock_limits[5].dcfclk_mhz = 810.0; 1387 - dcn2_1_soc.clock_limits[5].fabricclk_mhz = 1600.0; 1388 - dcn2_1_soc.clock_limits[5].dispclk_mhz = 1395.0; 1389 - dcn2_1_soc.clock_limits[5].dppclk_mhz = 1285.0; 1390 - dcn2_1_soc.clock_limits[5].phyclk_mhz = 1325.0; 1391 - dcn2_1_soc.clock_limits[5].socclk_mhz = 953.0; 1392 - dcn2_1_soc.clock_limits[5].dscclk_mhz = 489.0; 1393 - dcn2_1_soc.clock_limits[5].dram_speed_mts = 4266.0; 1394 - } else { 1379 + // Default clock levels are used for diags, which may lead to overclocking. 1380 + if (!IS_FPGA_MAXIMUS_DC(dc->ctx->dce_environment) && !IS_DIAG_DC(dc->ctx->dce_environment)) { 1395 1381 dcn2_1_ip.max_num_otg = pool->base.res_cap->num_timing_generator; 1396 1382 dcn2_1_ip.max_num_dpp = pool->base.pipe_count; 1397 1383 dcn2_1_soc.num_chans = bw_params->num_channels; ··· 1391 1403 dcn2_1_soc.clock_limits[0].dram_speed_mts = clk_table->entries[0].memclk_mhz * 2; 1392 1404 1393 1405 /* 1394 - * Other levels: find cloest DCN clocks that fit the given clock limit using dcfclk 1395 - * as indicater 1406 + * Other levels: find closest DCN clocks that fit the given clock limit using dcfclk 1407 + * as indicator 1396 1408 */ 1397 1409 1398 1410 closest_clk_lvl = -1; 1399 1411 /* index currently being filled */ 1400 1412 k = 1; 1401 1413 for (i = 1; i < clk_table->num_entries; i++) { 1402 - /* loop backwards, skip duplicate state, +1 because SMU has precision issue */ 1403 - for (j = dcn2_1_soc.num_states - 2; j >= k; j--) { 1414 + /* loop backwards, skip duplicate state*/ 1415 + for (j = dcn2_1_soc.num_states - 1; j >= k; j--) { 1404 1416 if ((unsigned int) dcn2_1_soc.clock_limits[j].dcfclk_mhz <= clk_table->entries[i].dcfclk_mhz) { 1405 1417 closest_clk_lvl = j; 1406 1418 break; ··· 1425 1437 k++; 1426 1438 } 1427 1439 } 1428 - 1429 - /* duplicate last level */ 1430 - dcn2_1_soc.clock_limits[k] = dcn2_1_soc.clock_limits[k - 1]; 1431 - dcn2_1_soc.clock_limits[k].state = k; 1432 - dcn2_1_soc.num_states = k + 1; 1440 + dcn2_1_soc.num_states = k; 1433 1441 } 1442 + 1443 + /* duplicate last level */ 1444 + dcn2_1_soc.clock_limits[dcn2_1_soc.num_states] = dcn2_1_soc.clock_limits[dcn2_1_soc.num_states - 1]; 1445 + dcn2_1_soc.clock_limits[dcn2_1_soc.num_states].state = dcn2_1_soc.num_states; 1434 1446 1435 1447 dml_init_instance(&dc->dml, &dcn2_1_soc, &dcn2_1_ip, DML_PROJECT_DCN21); 1436 1448 }
+1 -1
drivers/gpu/drm/amd/display/dc/dml/dc_features.h
··· 29 29 #define DC__PRESENT 1 30 30 #define DC__PRESENT__1 1 31 31 #define DC__NUM_DPP 4 32 - #define DC__VOLTAGE_STATES 7 32 + #define DC__VOLTAGE_STATES 9 33 33 #define DC__NUM_DPP__4 1 34 34 #define DC__NUM_DPP__0_PRESENT 1 35 35 #define DC__NUM_DPP__1_PRESENT 1
+4 -3
drivers/gpu/drm/amd/display/dc/dml/display_mode_structs.h
··· 22 22 * Authors: AMD 23 23 * 24 24 */ 25 + 26 + #include "dc_features.h" 27 + 25 28 #ifndef __DISPLAY_MODE_STRUCTS_H__ 26 29 #define __DISPLAY_MODE_STRUCTS_H__ 27 - 28 - #define MAX_CLOCK_LIMIT_STATES 9 29 30 30 31 typedef struct _vcs_dpi_voltage_scaling_st voltage_scaling_st; 31 32 typedef struct _vcs_dpi_soc_bounding_box_st soc_bounding_box_st; ··· 69 68 }; 70 69 71 70 struct _vcs_dpi_soc_bounding_box_st { 72 - struct _vcs_dpi_voltage_scaling_st clock_limits[MAX_CLOCK_LIMIT_STATES]; 71 + struct _vcs_dpi_voltage_scaling_st clock_limits[DC__VOLTAGE_STATES]; 73 72 unsigned int num_states; 74 73 double sr_exit_time_us; 75 74 double sr_enter_plus_exit_time_us;
+19 -15
drivers/gpu/drm/amd/display/modules/freesync/freesync.c
··· 734 734 { 735 735 struct core_freesync *core_freesync = NULL; 736 736 unsigned long long nominal_field_rate_in_uhz = 0; 737 + unsigned long long rounded_nominal_in_uhz = 0; 737 738 unsigned int refresh_range = 0; 738 739 unsigned long long min_refresh_in_uhz = 0; 739 740 unsigned long long max_refresh_in_uhz = 0; ··· 751 750 min_refresh_in_uhz = in_config->min_refresh_in_uhz; 752 751 max_refresh_in_uhz = in_config->max_refresh_in_uhz; 753 752 754 - // Don't allow min > max 755 - if (min_refresh_in_uhz > max_refresh_in_uhz) 756 - min_refresh_in_uhz = max_refresh_in_uhz; 757 - 758 753 // Full range may be larger than current video timing, so cap at nominal 759 754 if (max_refresh_in_uhz > nominal_field_rate_in_uhz) 760 755 max_refresh_in_uhz = nominal_field_rate_in_uhz; 761 756 762 757 // Full range may be larger than current video timing, so cap at nominal 763 - if (min_refresh_in_uhz > nominal_field_rate_in_uhz) 764 - min_refresh_in_uhz = nominal_field_rate_in_uhz; 758 + if (min_refresh_in_uhz > max_refresh_in_uhz) 759 + min_refresh_in_uhz = max_refresh_in_uhz; 760 + 761 + // If a monitor reports exactly max refresh of 2x of min, enforce it on nominal 762 + rounded_nominal_in_uhz = 763 + div_u64(nominal_field_rate_in_uhz + 50000, 100000) * 100000; 764 + if (in_config->max_refresh_in_uhz == (2 * in_config->min_refresh_in_uhz) && 765 + in_config->max_refresh_in_uhz == rounded_nominal_in_uhz) 766 + min_refresh_in_uhz = div_u64(nominal_field_rate_in_uhz, 2); 765 767 766 768 if (!vrr_settings_require_update(core_freesync, 767 769 in_config, (unsigned int)min_refresh_in_uhz, (unsigned int)max_refresh_in_uhz, ··· 796 792 refresh_range = in_out_vrr->max_refresh_in_uhz - 797 793 in_out_vrr->min_refresh_in_uhz; 798 794 799 - in_out_vrr->btr.margin_in_us = in_out_vrr->max_duration_in_us - 800 - 2 * in_out_vrr->min_duration_in_us; 801 - if (in_out_vrr->btr.margin_in_us > BTR_MAX_MARGIN) 802 - in_out_vrr->btr.margin_in_us = BTR_MAX_MARGIN; 803 - 804 795 in_out_vrr->supported = true; 805 796 } 806 797 ··· 803 804 804 805 in_out_vrr->btr.btr_enabled = in_config->btr; 805 806 806 - if (in_out_vrr->max_refresh_in_uhz < 807 - 2 * in_out_vrr->min_refresh_in_uhz) 807 + if (in_out_vrr->max_refresh_in_uhz < (2 * in_out_vrr->min_refresh_in_uhz)) 808 808 in_out_vrr->btr.btr_enabled = false; 809 + else { 810 + in_out_vrr->btr.margin_in_us = in_out_vrr->max_duration_in_us - 811 + 2 * in_out_vrr->min_duration_in_us; 812 + if (in_out_vrr->btr.margin_in_us > BTR_MAX_MARGIN) 813 + in_out_vrr->btr.margin_in_us = BTR_MAX_MARGIN; 814 + } 809 815 810 816 in_out_vrr->btr.btr_active = false; 811 817 in_out_vrr->btr.inserted_duration_in_us = 0; ··· 1012 1008 unsigned int total = stream->timing.h_total * stream->timing.v_total; 1013 1009 1014 1010 /* Calculate nominal field rate for stream, rounded up to nearest integer */ 1015 - nominal_field_rate_in_uhz = stream->timing.pix_clk_100hz / 10; 1016 - nominal_field_rate_in_uhz *= 1000ULL * 1000ULL * 1000ULL; 1011 + nominal_field_rate_in_uhz = stream->timing.pix_clk_100hz; 1012 + nominal_field_rate_in_uhz *= 100000000ULL; 1017 1013 1018 1014 nominal_field_rate_in_uhz = div_u64(nominal_field_rate_in_uhz, total); 1019 1015
+2 -3
drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c
··· 328 328 /* add display to connection */ 329 329 hdcp->connection.link = *link; 330 330 *display_container = *display; 331 - status = mod_hdcp_add_display_to_topology(hdcp, display_container); 332 - 331 + status = mod_hdcp_add_display_to_topology(hdcp, display->index); 333 332 if (status != MOD_HDCP_STATUS_SUCCESS) 334 333 goto out; 335 334 ··· 374 375 status = mod_hdcp_remove_display_from_topology(hdcp, index); 375 376 if (status != MOD_HDCP_STATUS_SUCCESS) 376 377 goto out; 377 - memset(display, 0, sizeof(struct mod_hdcp_display)); 378 + display->state = MOD_HDCP_DISPLAY_INACTIVE; 378 379 379 380 /* request authentication when connection is not reset */ 380 381 if (current_state(hdcp) != HDCP_UNINITIALIZED)
+22 -6
drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h
··· 328 328 329 329 /* psp functions */ 330 330 enum mod_hdcp_status mod_hdcp_add_display_to_topology( 331 - struct mod_hdcp *hdcp, struct mod_hdcp_display *display); 331 + struct mod_hdcp *hdcp, uint8_t index); 332 332 enum mod_hdcp_status mod_hdcp_remove_display_from_topology( 333 333 struct mod_hdcp *hdcp, uint8_t index); 334 334 enum mod_hdcp_status mod_hdcp_hdcp1_create_session(struct mod_hdcp *hdcp); ··· 503 503 return display->state >= MOD_HDCP_DISPLAY_ACTIVE; 504 504 } 505 505 506 + static inline uint8_t is_display_added(struct mod_hdcp_display *display) 507 + { 508 + return display->state >= MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED; 509 + } 510 + 506 511 static inline uint8_t is_display_encryption_enabled(struct mod_hdcp_display *display) 507 512 { 508 513 return display->state >= MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED; ··· 515 510 516 511 static inline uint8_t get_active_display_count(struct mod_hdcp *hdcp) 517 512 { 518 - uint8_t active_count = 0; 513 + uint8_t added_count = 0; 519 514 uint8_t i; 520 515 521 516 for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) 522 517 if (is_display_active(&hdcp->displays[i])) 523 - active_count++; 524 - return active_count; 518 + added_count++; 519 + return added_count; 525 520 } 526 521 527 - static inline struct mod_hdcp_display *get_first_active_display( 522 + static inline uint8_t get_added_display_count(struct mod_hdcp *hdcp) 523 + { 524 + uint8_t added_count = 0; 525 + uint8_t i; 526 + 527 + for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) 528 + if (is_display_added(&hdcp->displays[i])) 529 + added_count++; 530 + return added_count; 531 + } 532 + 533 + static inline struct mod_hdcp_display *get_first_added_display( 528 534 struct mod_hdcp *hdcp) 529 535 { 530 536 uint8_t i; 531 537 struct mod_hdcp_display *display = NULL; 532 538 533 539 for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) 534 - if (is_display_active(&hdcp->displays[i])) { 540 + if (is_display_added(&hdcp->displays[i])) { 535 541 display = &hdcp->displays[i]; 536 542 break; 537 543 }
+1 -1
drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_execution.c
··· 129 129 static inline enum mod_hdcp_status check_device_count(struct mod_hdcp *hdcp) 130 130 { 131 131 /* device count must be greater than or equal to tracked hdcp displays */ 132 - return (get_device_count(hdcp) < get_active_display_count(hdcp)) ? 132 + return (get_device_count(hdcp) < get_added_display_count(hdcp)) ? 133 133 MOD_HDCP_STATUS_HDCP1_DEVICE_COUNT_MISMATCH_FAILURE : 134 134 MOD_HDCP_STATUS_SUCCESS; 135 135 }
+1 -1
drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_execution.c
··· 208 208 static enum mod_hdcp_status check_device_count(struct mod_hdcp *hdcp) 209 209 { 210 210 /* device count must be greater than or equal to tracked hdcp displays */ 211 - return (get_device_count(hdcp) < get_active_display_count(hdcp)) ? 211 + return (get_device_count(hdcp) < get_added_display_count(hdcp)) ? 212 212 MOD_HDCP_STATUS_HDCP2_DEVICE_COUNT_MISMATCH_FAILURE : 213 213 MOD_HDCP_STATUS_SUCCESS; 214 214 }
+22 -17
drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
··· 54 54 55 55 dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf; 56 56 57 - if (!display || !is_display_active(display)) 57 + if (!display || !is_display_added(display)) 58 58 return MOD_HDCP_STATUS_DISPLAY_NOT_FOUND; 59 59 60 60 memset(dtm_cmd, 0, sizeof(struct ta_dtm_shared_memory)); ··· 73 73 HDCP_TOP_REMOVE_DISPLAY_TRACE(hdcp, display->index); 74 74 75 75 return MOD_HDCP_STATUS_SUCCESS; 76 - } 77 - 78 - enum mod_hdcp_status mod_hdcp_add_display_to_topology( 79 - struct mod_hdcp *hdcp, struct mod_hdcp_display *display) 76 + 77 + } 78 + enum mod_hdcp_status mod_hdcp_add_display_to_topology(struct mod_hdcp *hdcp, 79 + uint8_t index) 80 80 { 81 81 struct psp_context *psp = hdcp->config.psp.handle; 82 82 struct ta_dtm_shared_memory *dtm_cmd; 83 + struct mod_hdcp_display *display = 84 + get_active_display_at_index(hdcp, index); 83 85 struct mod_hdcp_link *link = &hdcp->connection.link; 84 86 85 87 if (!psp->dtm_context.dtm_initialized) { 86 88 DRM_ERROR("Failed to add display topology, DTM TA is not initialized."); 87 - display->state = MOD_HDCP_DISPLAY_INACTIVE; 88 89 return MOD_HDCP_STATUS_FAILURE; 89 90 } 91 + 92 + if (!display || is_display_added(display)) 93 + return MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE; 90 94 91 95 dtm_cmd = (struct ta_dtm_shared_memory *)psp->dtm_context.dtm_shared_buf; 92 96 ··· 113 109 114 110 psp_dtm_invoke(psp, dtm_cmd->cmd_id); 115 111 116 - if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS) { 117 - display->state = MOD_HDCP_DISPLAY_INACTIVE; 112 + if (dtm_cmd->dtm_status != TA_DTM_STATUS__SUCCESS) 118 113 return MOD_HDCP_STATUS_UPDATE_TOPOLOGY_FAILURE; 119 - } 120 114 115 + display->state = MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED; 121 116 HDCP_TOP_ADD_DISPLAY_TRACE(hdcp, display->index); 122 117 123 118 return MOD_HDCP_STATUS_SUCCESS; ··· 126 123 { 127 124 128 125 struct psp_context *psp = hdcp->config.psp.handle; 129 - struct mod_hdcp_display *display = get_first_active_display(hdcp); 126 + struct mod_hdcp_display *display = get_first_added_display(hdcp); 130 127 struct ta_hdcp_shared_memory *hdcp_cmd; 131 128 132 129 if (!psp->hdcp_context.hdcp_initialized) { ··· 179 176 if (is_display_encryption_enabled( 180 177 &hdcp->displays[i])) { 181 178 hdcp->displays[i].state = 182 - MOD_HDCP_DISPLAY_ACTIVE; 179 + MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED; 183 180 HDCP_HDCP1_DISABLED_TRACE(hdcp, 184 181 hdcp->displays[i].index); 185 182 } ··· 231 228 { 232 229 struct psp_context *psp = hdcp->config.psp.handle; 233 230 struct ta_hdcp_shared_memory *hdcp_cmd; 234 - struct mod_hdcp_display *display = get_first_active_display(hdcp); 231 + struct mod_hdcp_display *display = get_first_added_display(hdcp); 235 232 236 233 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 237 234 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); ··· 301 298 302 299 for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) { 303 300 304 - if (hdcp->displays[i].adjust.disable) 301 + if (hdcp->displays[i].state != MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED || 302 + hdcp->displays[i].adjust.disable) 305 303 continue; 306 304 307 305 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); ··· 364 360 { 365 361 struct psp_context *psp = hdcp->config.psp.handle; 366 362 struct ta_hdcp_shared_memory *hdcp_cmd; 367 - struct mod_hdcp_display *display = get_first_active_display(hdcp); 363 + struct mod_hdcp_display *display = get_first_added_display(hdcp); 368 364 369 365 if (!psp->hdcp_context.hdcp_initialized) { 370 366 DRM_ERROR("Failed to create hdcp session, HDCP TA is not initialized"); ··· 423 419 if (is_display_encryption_enabled( 424 420 &hdcp->displays[i])) { 425 421 hdcp->displays[i].state = 426 - MOD_HDCP_DISPLAY_ACTIVE; 422 + MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED; 427 423 HDCP_HDCP2_DISABLED_TRACE(hdcp, 428 424 hdcp->displays[i].index); 429 425 } ··· 662 658 { 663 659 struct psp_context *psp = hdcp->config.psp.handle; 664 660 struct ta_hdcp_shared_memory *hdcp_cmd; 665 - struct mod_hdcp_display *display = get_first_active_display(hdcp); 661 + struct mod_hdcp_display *display = get_first_added_display(hdcp); 666 662 667 663 hdcp_cmd = (struct ta_hdcp_shared_memory *)psp->hdcp_context.hdcp_shared_buf; 668 664 memset(hdcp_cmd, 0, sizeof(struct ta_hdcp_shared_memory)); ··· 747 743 748 744 749 745 for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) { 750 - if (hdcp->displays[i].adjust.disable) 746 + if (hdcp->displays[i].state != MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED || 747 + hdcp->displays[i].adjust.disable) 751 748 continue; 752 749 hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.display_handle = hdcp->displays[i].index; 753 750 hdcp_cmd->in_msg.hdcp2_enable_dp_stream_encryption.session_handle = hdcp->auth.id;
+1
drivers/gpu/drm/amd/display/modules/inc/mod_hdcp.h
··· 117 117 enum mod_hdcp_display_state { 118 118 MOD_HDCP_DISPLAY_INACTIVE = 0, 119 119 MOD_HDCP_DISPLAY_ACTIVE, 120 + MOD_HDCP_DISPLAY_ACTIVE_AND_ADDED, 120 121 MOD_HDCP_DISPLAY_ENCRYPTION_ENABLED 121 122 }; 122 123
+14 -1
drivers/gpu/drm/amd/powerplay/arcturus_ppt.c
··· 35 35 #include "arcturus_ppt.h" 36 36 #include "smu_v11_0_pptable.h" 37 37 #include "arcturus_ppsmc.h" 38 + #include "nbio/nbio_7_4_offset.h" 38 39 #include "nbio/nbio_7_4_sh_mask.h" 39 40 #include "amdgpu_xgmi.h" 40 41 #include <linux/i2c.h> ··· 2211 2210 i2c_del_adapter(control); 2212 2211 } 2213 2212 2213 + static bool arcturus_is_baco_supported(struct smu_context *smu) 2214 + { 2215 + struct amdgpu_device *adev = smu->adev; 2216 + uint32_t val; 2217 + 2218 + if (!smu_v11_0_baco_is_support(smu)) 2219 + return false; 2220 + 2221 + val = RREG32_SOC15(NBIO, 0, mmRCC_BIF_STRAP0); 2222 + return (val & RCC_BIF_STRAP0__STRAP_PX_CAPABLE_MASK) ? true : false; 2223 + } 2224 + 2214 2225 static uint32_t arcturus_get_pptable_power_limit(struct smu_context *smu) 2215 2226 { 2216 2227 PPTable_t *pptable = smu->smu_table.driver_pptable; ··· 2334 2321 .register_irq_handler = smu_v11_0_register_irq_handler, 2335 2322 .set_azalia_d3_pme = smu_v11_0_set_azalia_d3_pme, 2336 2323 .get_max_sustainable_clocks_by_dc = smu_v11_0_get_max_sustainable_clocks_by_dc, 2337 - .baco_is_support= smu_v11_0_baco_is_support, 2324 + .baco_is_support= arcturus_is_baco_supported, 2338 2325 .baco_get_state = smu_v11_0_baco_get_state, 2339 2326 .baco_set_state = smu_v11_0_baco_set_state, 2340 2327 .baco_enter = smu_v11_0_baco_enter,
+16 -2
drivers/gpu/drm/amd/powerplay/navi10_ppt.c
··· 28 28 #include "smu_internal.h" 29 29 #include "atomfirmware.h" 30 30 #include "amdgpu_atomfirmware.h" 31 + #include "soc15_common.h" 31 32 #include "smu_v11_0.h" 32 33 #include "smu11_driver_if_navi10.h" 33 34 #include "atom.h" 34 35 #include "navi10_ppt.h" 35 36 #include "smu_v11_0_pptable.h" 36 37 #include "smu_v11_0_ppsmc.h" 37 - #include "nbio/nbio_7_4_sh_mask.h" 38 + #include "nbio/nbio_2_3_offset.h" 39 + #include "nbio/nbio_2_3_sh_mask.h" 38 40 39 41 #include "asic_reg/mp/mp_11_0_sh_mask.h" 40 42 ··· 1987 1985 return 0; 1988 1986 } 1989 1987 1988 + static bool navi10_is_baco_supported(struct smu_context *smu) 1989 + { 1990 + struct amdgpu_device *adev = smu->adev; 1991 + uint32_t val; 1992 + 1993 + if (!smu_v11_0_baco_is_support(smu)) 1994 + return false; 1995 + 1996 + val = RREG32_SOC15(NBIO, 0, mmRCC_BIF_STRAP0); 1997 + return (val & RCC_BIF_STRAP0__STRAP_PX_CAPABLE_MASK) ? true : false; 1998 + } 1999 + 1990 2000 static int navi10_set_default_od_settings(struct smu_context *smu, bool initialize) { 1991 2001 OverDriveTable_t *od_table, *boot_od_table; 1992 2002 int ret = 0; ··· 2375 2361 .register_irq_handler = smu_v11_0_register_irq_handler, 2376 2362 .set_azalia_d3_pme = smu_v11_0_set_azalia_d3_pme, 2377 2363 .get_max_sustainable_clocks_by_dc = smu_v11_0_get_max_sustainable_clocks_by_dc, 2378 - .baco_is_support= smu_v11_0_baco_is_support, 2364 + .baco_is_support= navi10_is_baco_supported, 2379 2365 .baco_get_state = smu_v11_0_baco_get_state, 2380 2366 .baco_set_state = smu_v11_0_baco_set_state, 2381 2367 .baco_enter = smu_v11_0_baco_enter,
+1 -23
drivers/gpu/drm/amd/powerplay/smu_v11_0.c
··· 42 42 #include "asic_reg/thm/thm_11_0_2_sh_mask.h" 43 43 #include "asic_reg/mp/mp_11_0_offset.h" 44 44 #include "asic_reg/mp/mp_11_0_sh_mask.h" 45 - #include "asic_reg/nbio/nbio_7_4_offset.h" 46 - #include "asic_reg/nbio/nbio_7_4_sh_mask.h" 47 45 #include "asic_reg/smuio/smuio_11_0_0_offset.h" 48 46 #include "asic_reg/smuio/smuio_11_0_0_sh_mask.h" 49 47 ··· 1660 1662 1661 1663 bool smu_v11_0_baco_is_support(struct smu_context *smu) 1662 1664 { 1663 - struct amdgpu_device *adev = smu->adev; 1664 1665 struct smu_baco_context *smu_baco = &smu->smu_baco; 1665 - uint32_t val; 1666 1666 bool baco_support; 1667 1667 1668 1668 mutex_lock(&smu_baco->mutex); ··· 1675 1679 !smu_feature_is_enabled(smu, SMU_FEATURE_BACO_BIT)) 1676 1680 return false; 1677 1681 1678 - val = RREG32_SOC15(NBIO, 0, mmRCC_BIF_STRAP0); 1679 - if (val & RCC_BIF_STRAP0__STRAP_PX_CAPABLE_MASK) 1680 - return true; 1681 - 1682 - return false; 1682 + return true; 1683 1683 } 1684 1684 1685 1685 enum smu_baco_state smu_v11_0_baco_get_state(struct smu_context *smu) ··· 1692 1700 1693 1701 int smu_v11_0_baco_set_state(struct smu_context *smu, enum smu_baco_state state) 1694 1702 { 1695 - 1696 1703 struct smu_baco_context *smu_baco = &smu->smu_baco; 1697 1704 struct amdgpu_device *adev = smu->adev; 1698 1705 struct amdgpu_ras *ras = amdgpu_ras_get_context(adev); 1699 - uint32_t bif_doorbell_intr_cntl; 1700 1706 uint32_t data; 1701 1707 int ret = 0; 1702 1708 ··· 1703 1713 1704 1714 mutex_lock(&smu_baco->mutex); 1705 1715 1706 - bif_doorbell_intr_cntl = RREG32_SOC15(NBIO, 0, mmBIF_DOORBELL_INT_CNTL); 1707 - 1708 1716 if (state == SMU_BACO_STATE_ENTER) { 1709 - bif_doorbell_intr_cntl = REG_SET_FIELD(bif_doorbell_intr_cntl, 1710 - BIF_DOORBELL_INT_CNTL, 1711 - DOORBELL_INTERRUPT_DISABLE, 1); 1712 - WREG32_SOC15(NBIO, 0, mmBIF_DOORBELL_INT_CNTL, bif_doorbell_intr_cntl); 1713 - 1714 1717 if (!ras || !ras->supported) { 1715 1718 data = RREG32_SOC15(THM, 0, mmTHM_BACO_CNTL); 1716 1719 data |= 0x80000000; ··· 1717 1734 ret = smu_send_smc_msg(smu, SMU_MSG_ExitBaco, NULL); 1718 1735 if (ret) 1719 1736 goto out; 1720 - 1721 - bif_doorbell_intr_cntl = REG_SET_FIELD(bif_doorbell_intr_cntl, 1722 - BIF_DOORBELL_INT_CNTL, 1723 - DOORBELL_INTERRUPT_DISABLE, 0); 1724 - WREG32_SOC15(NBIO, 0, mmBIF_DOORBELL_INT_CNTL, bif_doorbell_intr_cntl); 1725 1737 1726 1738 /* clear vbios scratch 6 and 7 for coming asic reinit */ 1727 1739 WREG32(adev->bios_scratch_reg_offset + 6, 0);
+13 -1
drivers/gpu/drm/amd/powerplay/vega20_ppt.c
··· 35 35 #include "vega20_ppt.h" 36 36 #include "vega20_pptable.h" 37 37 #include "vega20_ppsmc.h" 38 + #include "nbio/nbio_7_4_offset.h" 38 39 #include "nbio/nbio_7_4_sh_mask.h" 39 40 #include "asic_reg/thm/thm_11_0_2_offset.h" 40 41 #include "asic_reg/thm/thm_11_0_2_sh_mask.h" ··· 3175 3174 return ret; 3176 3175 } 3177 3176 3177 + static bool vega20_is_baco_supported(struct smu_context *smu) 3178 + { 3179 + struct amdgpu_device *adev = smu->adev; 3180 + uint32_t val; 3181 + 3182 + if (!smu_v11_0_baco_is_support(smu)) 3183 + return false; 3184 + 3185 + val = RREG32_SOC15(NBIO, 0, mmRCC_BIF_STRAP0); 3186 + return (val & RCC_BIF_STRAP0__STRAP_PX_CAPABLE_MASK) ? true : false; 3187 + } 3178 3188 3179 3189 static const struct pptable_funcs vega20_ppt_funcs = { 3180 3190 .tables_init = vega20_tables_init, ··· 3274 3262 .register_irq_handler = smu_v11_0_register_irq_handler, 3275 3263 .set_azalia_d3_pme = smu_v11_0_set_azalia_d3_pme, 3276 3264 .get_max_sustainable_clocks_by_dc = smu_v11_0_get_max_sustainable_clocks_by_dc, 3277 - .baco_is_support= smu_v11_0_baco_is_support, 3265 + .baco_is_support= vega20_is_baco_supported, 3278 3266 .baco_get_state = smu_v11_0_baco_get_state, 3279 3267 .baco_set_state = smu_v11_0_baco_set_state, 3280 3268 .baco_enter = smu_v11_0_baco_enter,
+1 -7
drivers/gpu/drm/drm_mm.c
··· 45 45 #include <linux/export.h> 46 46 #include <linux/interval_tree_generic.h> 47 47 #include <linux/seq_file.h> 48 - #include <linux/sched/signal.h> 49 48 #include <linux/slab.h> 50 49 #include <linux/stacktrace.h> 51 50 ··· 366 367 struct drm_mm_node *node, 367 368 enum drm_mm_insert_mode mode) 368 369 { 369 - /* Searching is slow; check if we ran out of time/patience */ 370 - cond_resched(); 371 - if (fatal_signal_pending(current)) 372 - return NULL; 373 - 374 370 switch (mode) { 375 371 default: 376 372 case DRM_MM_INSERT_BEST: ··· 557 563 return 0; 558 564 } 559 565 560 - return signal_pending(current) ? -ERESTARTSYS : -ENOSPC; 566 + return -ENOSPC; 561 567 } 562 568 EXPORT_SYMBOL(drm_mm_insert_node_in_range); 563 569
+4 -12
drivers/gpu/drm/i915/gvt/cmd_parser.c
··· 164 164 #define OP_STATE_BASE_ADDRESS OP_3D_MEDIA(0x0, 0x1, 0x01) 165 165 #define OP_STATE_SIP OP_3D_MEDIA(0x0, 0x1, 0x02) 166 166 #define OP_3D_MEDIA_0_1_4 OP_3D_MEDIA(0x0, 0x1, 0x04) 167 + #define OP_SWTESS_BASE_ADDRESS OP_3D_MEDIA(0x0, 0x1, 0x03) 167 168 168 169 #define OP_3DSTATE_VF_STATISTICS_GM45 OP_3D_MEDIA(0x1, 0x0, 0x0B) 169 170 ··· 968 967 { 969 968 int i, ret = 0; 970 969 int cmd_len = cmd_length(s); 971 - u32 valid_len = CMD_LEN(1); 972 - 973 - /* 974 - * Official intel docs are somewhat sloppy , check the definition of 975 - * MI_LOAD_REGISTER_IMM. 976 - */ 977 - #define MAX_VALID_LEN 127 978 - if ((cmd_len < valid_len) || (cmd_len > MAX_VALID_LEN)) { 979 - gvt_err("len is not valid: len=%u valid_len=%u\n", 980 - cmd_len, valid_len); 981 - return -EFAULT; 982 - } 983 970 984 971 for (i = 1; i < cmd_len; i += 2) { 985 972 if (IS_BROADWELL(s->engine->i915) && s->engine->id != RCS0) { ··· 2473 2484 2474 2485 {"OP_3D_MEDIA_0_1_4", OP_3D_MEDIA_0_1_4, F_LEN_VAR, R_RCS, D_ALL, 2475 2486 ADDR_FIX_1(1), 8, NULL}, 2487 + 2488 + {"OP_SWTESS_BASE_ADDRESS", OP_SWTESS_BASE_ADDRESS, 2489 + F_LEN_VAR, R_RCS, D_ALL, ADDR_FIX_2(1, 2), 3, NULL}, 2476 2490 2477 2491 {"3DSTATE_VS", OP_3DSTATE_VS, F_LEN_VAR, R_RCS, D_ALL, 0, 8, NULL}, 2478 2492
+3 -3
drivers/gpu/drm/i915/gvt/display.c
··· 221 221 ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK | 222 222 TRANS_DDI_PORT_MASK); 223 223 vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) |= 224 - (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DVI | 224 + (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST | 225 225 (PORT_B << TRANS_DDI_PORT_SHIFT) | 226 226 TRANS_DDI_FUNC_ENABLE); 227 227 if (IS_BROADWELL(dev_priv)) { ··· 241 241 ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK | 242 242 TRANS_DDI_PORT_MASK); 243 243 vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) |= 244 - (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DVI | 244 + (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST | 245 245 (PORT_C << TRANS_DDI_PORT_SHIFT) | 246 246 TRANS_DDI_FUNC_ENABLE); 247 247 if (IS_BROADWELL(dev_priv)) { ··· 261 261 ~(TRANS_DDI_BPC_MASK | TRANS_DDI_MODE_SELECT_MASK | 262 262 TRANS_DDI_PORT_MASK); 263 263 vgpu_vreg_t(vgpu, TRANS_DDI_FUNC_CTL(TRANSCODER_A)) |= 264 - (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DVI | 264 + (TRANS_DDI_BPC_8 | TRANS_DDI_MODE_SELECT_DP_SST | 265 265 (PORT_D << TRANS_DDI_PORT_SHIFT) | 266 266 TRANS_DDI_FUNC_ENABLE); 267 267 if (IS_BROADWELL(dev_priv)) {
+6 -2
drivers/gpu/drm/i915/gvt/handlers.c
··· 462 462 return 0; 463 463 } 464 464 465 - /* ascendingly sorted */ 465 + /* sorted in ascending order */ 466 466 static i915_reg_t force_nonpriv_white_list[] = { 467 + _MMIO(0xd80), 467 468 GEN9_CS_DEBUG_MODE1, //_MMIO(0x20ec) 468 469 GEN9_CTX_PREEMPT_REG,//_MMIO(0x2248) 469 - PS_INVOCATION_COUNT,//_MMIO(0x2348) 470 + CL_PRIMITIVES_COUNT, //_MMIO(0x2340) 471 + PS_INVOCATION_COUNT, //_MMIO(0x2348) 472 + PS_DEPTH_COUNT, //_MMIO(0x2350) 470 473 GEN8_CS_CHICKEN1,//_MMIO(0x2580) 471 474 _MMIO(0x2690), 472 475 _MMIO(0x2694), ··· 494 491 _MMIO(0xe18c), 495 492 _MMIO(0xe48c), 496 493 _MMIO(0xe5f4), 494 + _MMIO(0x64844), 497 495 }; 498 496 499 497 /* a simple bsearch */
+2 -2
drivers/gpu/drm/i915/gvt/scheduler.c
··· 296 296 * Update bits 0-11 of the context descriptor which includes flags 297 297 * like GEN8_CTX_* cached in desc_template 298 298 */ 299 - desc &= ~(0x3 << GEN8_CTX_ADDRESSING_MODE_SHIFT); 300 - desc |= workload->ctx_desc.addressing_mode << 299 + desc &= ~(0x3ull << GEN8_CTX_ADDRESSING_MODE_SHIFT); 300 + desc |= (u64)workload->ctx_desc.addressing_mode << 301 301 GEN8_CTX_ADDRESSING_MODE_SHIFT; 302 302 303 303 ce->lrc_desc = desc;
+2 -1
drivers/gpu/drm/nouveau/dispnv04/dac.c
··· 35 35 36 36 #include <subdev/bios/gpio.h> 37 37 #include <subdev/gpio.h> 38 - #include <subdev/timer.h> 38 + 39 + #include <nvif/timer.h> 39 40 40 41 int nv04_dac_output_offset(struct drm_encoder *encoder) 41 42 {
+1
drivers/gpu/drm/nouveau/dispnv04/hw.c
··· 26 26 #include "hw.h" 27 27 28 28 #include <subdev/bios/pll.h> 29 + #include <nvif/timer.h> 29 30 30 31 #define CHIPSET_NFORCE 0x01a0 31 32 #define CHIPSET_NFORCE2 0x01f0
+1
drivers/gpu/drm/nouveau/dispnv50/base507c.c
··· 23 23 24 24 #include <nvif/cl507c.h> 25 25 #include <nvif/event.h> 26 + #include <nvif/timer.h> 26 27 27 28 #include <drm/drm_atomic_helper.h> 28 29 #include <drm/drm_fourcc.h>
+1
drivers/gpu/drm/nouveau/dispnv50/core507d.c
··· 23 23 #include "head.h" 24 24 25 25 #include <nvif/cl507d.h> 26 + #include <nvif/timer.h> 26 27 27 28 #include "nouveau_bo.h" 28 29
+2
drivers/gpu/drm/nouveau/dispnv50/corec37d.c
··· 24 24 25 25 #include <nouveau_bo.h> 26 26 27 + #include <nvif/timer.h> 28 + 27 29 void 28 30 corec37d_wndw_owner(struct nv50_core *core) 29 31 {
+18 -3
drivers/gpu/drm/nouveau/dispnv50/curs507a.c
··· 24 24 #include "head.h" 25 25 26 26 #include <nvif/cl507a.h> 27 + #include <nvif/timer.h> 27 28 28 29 #include <drm/drm_atomic_helper.h> 29 30 #include <drm/drm_plane_helper.h> 30 31 32 + bool 33 + curs507a_space(struct nv50_wndw *wndw) 34 + { 35 + nvif_msec(&nouveau_drm(wndw->plane.dev)->client.device, 2, 36 + if (nvif_rd32(&wndw->wimm.base.user, 0x0008) >= 4) 37 + return true; 38 + ); 39 + WARN_ON(1); 40 + return false; 41 + } 42 + 31 43 static void 32 44 curs507a_update(struct nv50_wndw *wndw, u32 *interlock) 33 45 { 34 - nvif_wr32(&wndw->wimm.base.user, 0x0080, 0x00000000); 46 + if (curs507a_space(wndw)) 47 + nvif_wr32(&wndw->wimm.base.user, 0x0080, 0x00000000); 35 48 } 36 49 37 50 static void 38 51 curs507a_point(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) 39 52 { 40 - nvif_wr32(&wndw->wimm.base.user, 0x0084, asyw->point.y << 16 | 41 - asyw->point.x); 53 + if (curs507a_space(wndw)) { 54 + nvif_wr32(&wndw->wimm.base.user, 0x0084, asyw->point.y << 16 | 55 + asyw->point.x); 56 + } 42 57 } 43 58 44 59 const struct nv50_wimm_func
+6 -3
drivers/gpu/drm/nouveau/dispnv50/cursc37a.c
··· 25 25 static void 26 26 cursc37a_update(struct nv50_wndw *wndw, u32 *interlock) 27 27 { 28 - nvif_wr32(&wndw->wimm.base.user, 0x0200, 0x00000001); 28 + if (curs507a_space(wndw)) 29 + nvif_wr32(&wndw->wimm.base.user, 0x0200, 0x00000001); 29 30 } 30 31 31 32 static void 32 33 cursc37a_point(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) 33 34 { 34 - nvif_wr32(&wndw->wimm.base.user, 0x0208, asyw->point.y << 16 | 35 - asyw->point.x); 35 + if (curs507a_space(wndw)) { 36 + nvif_wr32(&wndw->wimm.base.user, 0x0208, asyw->point.y << 16 | 37 + asyw->point.x); 38 + } 36 39 } 37 40 38 41 static const struct nv50_wimm_func
+1
drivers/gpu/drm/nouveau/dispnv50/disp.c
··· 45 45 #include <nvif/cl5070.h> 46 46 #include <nvif/cl507d.h> 47 47 #include <nvif/event.h> 48 + #include <nvif/timer.h> 48 49 49 50 #include "nouveau_drv.h" 50 51 #include "nouveau_dma.h"
+2
drivers/gpu/drm/nouveau/dispnv50/ovly827e.c
··· 24 24 25 25 #include <nouveau_bo.h> 26 26 27 + #include <nvif/timer.h> 28 + 27 29 static void 28 30 ovly827e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw) 29 31 {
+1
drivers/gpu/drm/nouveau/dispnv50/wndw.h
··· 97 97 }; 98 98 99 99 extern const struct nv50_wimm_func curs507a; 100 + bool curs507a_space(struct nv50_wndw *); 100 101 101 102 int wndwc37e_new(struct nouveau_drm *, enum drm_plane_type, int, s32, 102 103 struct nv50_wndw **);
-21
drivers/gpu/drm/nouveau/include/nvif/device.h
··· 23 23 void nvif_device_fini(struct nvif_device *); 24 24 u64 nvif_device_time(struct nvif_device *); 25 25 26 - /* Delay based on GPU time (ie. PTIMER). 27 - * 28 - * Will return -ETIMEDOUT unless the loop was terminated with 'break', 29 - * where it will return the number of nanoseconds taken instead. 30 - */ 31 - #define nvif_nsec(d,n,cond...) ({ \ 32 - struct nvif_device *_device = (d); \ 33 - u64 _nsecs = (n), _time0 = nvif_device_time(_device); \ 34 - s64 _taken = 0; \ 35 - \ 36 - do { \ 37 - cond \ 38 - } while (_taken = nvif_device_time(_device) - _time0, _taken < _nsecs);\ 39 - \ 40 - if (_taken >= _nsecs) \ 41 - _taken = -ETIMEDOUT; \ 42 - _taken; \ 43 - }) 44 - #define nvif_usec(d,u,cond...) nvif_nsec((d), (u) * 1000, ##cond) 45 - #define nvif_msec(d,m,cond...) nvif_usec((d), (m) * 1000, ##cond) 46 - 47 26 /*XXX*/ 48 27 #include <subdev/bios.h> 49 28 #include <subdev/fb.h>
+35
drivers/gpu/drm/nouveau/include/nvif/timer.h
··· 1 + #ifndef __NVIF_TIMER_H__ 2 + #define __NVIF_TIMER_H__ 3 + #include <nvif/os.h> 4 + 5 + struct nvif_timer_wait { 6 + struct nvif_device *device; 7 + u64 limit; 8 + u64 time0; 9 + u64 time1; 10 + int reads; 11 + }; 12 + 13 + void nvif_timer_wait_init(struct nvif_device *, u64 nsec, 14 + struct nvif_timer_wait *); 15 + s64 nvif_timer_wait_test(struct nvif_timer_wait *); 16 + 17 + /* Delay based on GPU time (ie. PTIMER). 18 + * 19 + * Will return -ETIMEDOUT unless the loop was terminated with 'break', 20 + * where it will return the number of nanoseconds taken instead. 21 + */ 22 + #define nvif_nsec(d,n,cond...) ({ \ 23 + struct nvif_timer_wait _wait; \ 24 + s64 _taken = 0; \ 25 + \ 26 + nvif_timer_wait_init((d), (n), &_wait); \ 27 + do { \ 28 + cond \ 29 + } while ((_taken = nvif_timer_wait_test(&_wait)) >= 0); \ 30 + \ 31 + _taken; \ 32 + }) 33 + #define nvif_usec(d,u,cond...) nvif_nsec((d), (u) * 1000, ##cond) 34 + #define nvif_msec(d,m,cond...) nvif_usec((d), (m) * 1000, ##cond) 35 + #endif
+1
drivers/gpu/drm/nouveau/include/nvif/user.h
··· 10 10 11 11 struct nvif_user_func { 12 12 void (*doorbell)(struct nvif_user *, u32 token); 13 + u64 (*time)(struct nvif_user *); 13 14 }; 14 15 15 16 int nvif_user_init(struct nvif_device *);
+7 -2
drivers/gpu/drm/nouveau/nouveau_bo.c
··· 1494 1494 ret = nvif_object_map_handle(&mem->mem.object, 1495 1495 &args, argc, 1496 1496 &handle, &length); 1497 - if (ret != 1) 1498 - return ret ? ret : -EINVAL; 1497 + if (ret != 1) { 1498 + if (WARN_ON(ret == 0)) 1499 + return -EINVAL; 1500 + if (ret == -ENOSPC) 1501 + return -EAGAIN; 1502 + return ret; 1503 + } 1499 1504 1500 1505 reg->bus.base = 0; 1501 1506 reg->bus.offset = handle;
+8 -12
drivers/gpu/drm/nouveau/nouveau_debugfs.c
··· 222 222 { 223 223 struct nouveau_drm *drm = nouveau_drm(minor->dev); 224 224 struct dentry *dentry; 225 - int i, ret; 225 + int i; 226 226 227 227 for (i = 0; i < ARRAY_SIZE(nouveau_debugfs_files); i++) { 228 - dentry = debugfs_create_file(nouveau_debugfs_files[i].name, 229 - S_IRUGO | S_IWUSR, 230 - minor->debugfs_root, minor->dev, 231 - nouveau_debugfs_files[i].fops); 232 - if (!dentry) 233 - return -ENOMEM; 228 + debugfs_create_file(nouveau_debugfs_files[i].name, 229 + S_IRUGO | S_IWUSR, 230 + minor->debugfs_root, minor->dev, 231 + nouveau_debugfs_files[i].fops); 234 232 } 235 233 236 - ret = drm_debugfs_create_files(nouveau_debugfs_list, 237 - NOUVEAU_DEBUGFS_ENTRIES, 238 - minor->debugfs_root, minor); 239 - if (ret) 240 - return ret; 234 + drm_debugfs_create_files(nouveau_debugfs_list, 235 + NOUVEAU_DEBUGFS_ENTRIES, 236 + minor->debugfs_root, minor); 241 237 242 238 /* Set the size of the vbios since we know it, and it's confusing to 243 239 * userspace if it wants to seek() but the file has a length of 0
+63
drivers/gpu/drm/nouveau/nouveau_drm.c
··· 618 618 kfree(drm); 619 619 } 620 620 621 + /* 622 + * On some Intel PCIe bridge controllers doing a 623 + * D0 -> D3hot -> D3cold -> D0 sequence causes Nvidia GPUs to not reappear. 624 + * Skipping the intermediate D3hot step seems to make it work again. This is 625 + * probably caused by not meeting the expectation the involved AML code has 626 + * when the GPU is put into D3hot state before invoking it. 627 + * 628 + * This leads to various manifestations of this issue: 629 + * - AML code execution to power on the GPU hits an infinite loop (as the 630 + * code waits on device memory to change). 631 + * - kernel crashes, as all PCI reads return -1, which most code isn't able 632 + * to handle well enough. 633 + * 634 + * In all cases dmesg will contain at least one line like this: 635 + * 'nouveau 0000:01:00.0: Refused to change power state, currently in D3' 636 + * followed by a lot of nouveau timeouts. 637 + * 638 + * In the \_SB.PCI0.PEG0.PG00._OFF code deeper down writes bit 0x80 to the not 639 + * documented PCI config space register 0x248 of the Intel PCIe bridge 640 + * controller (0x1901) in order to change the state of the PCIe link between 641 + * the PCIe port and the GPU. There are alternative code paths using other 642 + * registers, which seem to work fine (executed pre Windows 8): 643 + * - 0xbc bit 0x20 (publicly available documentation claims 'reserved') 644 + * - 0xb0 bit 0x10 (link disable) 645 + * Changing the conditions inside the firmware by poking into the relevant 646 + * addresses does resolve the issue, but it seemed to be ACPI private memory 647 + * and not any device accessible memory at all, so there is no portable way of 648 + * changing the conditions. 649 + * On a XPS 9560 that means bits [0,3] on \CPEX need to be cleared. 650 + * 651 + * The only systems where this behavior can be seen are hybrid graphics laptops 652 + * with a secondary Nvidia Maxwell, Pascal or Turing GPU. It's unclear whether 653 + * this issue only occurs in combination with listed Intel PCIe bridge 654 + * controllers and the mentioned GPUs or other devices as well. 655 + * 656 + * documentation on the PCIe bridge controller can be found in the 657 + * "7th Generation Intel® Processor Families for H Platforms Datasheet Volume 2" 658 + * Section "12 PCI Express* Controller (x16) Registers" 659 + */ 660 + 661 + static void quirk_broken_nv_runpm(struct pci_dev *pdev) 662 + { 663 + struct drm_device *dev = pci_get_drvdata(pdev); 664 + struct nouveau_drm *drm = nouveau_drm(dev); 665 + struct pci_dev *bridge = pci_upstream_bridge(pdev); 666 + 667 + if (!bridge || bridge->vendor != PCI_VENDOR_ID_INTEL) 668 + return; 669 + 670 + switch (bridge->device) { 671 + case 0x1901: 672 + drm->old_pm_cap = pdev->pm_cap; 673 + pdev->pm_cap = 0; 674 + NV_INFO(drm, "Disabling PCI power management to avoid bug\n"); 675 + break; 676 + } 677 + } 678 + 621 679 static int nouveau_drm_probe(struct pci_dev *pdev, 622 680 const struct pci_device_id *pent) 623 681 { ··· 757 699 if (ret) 758 700 goto fail_drm_dev_init; 759 701 702 + quirk_broken_nv_runpm(pdev); 760 703 return 0; 761 704 762 705 fail_drm_dev_init: ··· 793 734 nouveau_drm_remove(struct pci_dev *pdev) 794 735 { 795 736 struct drm_device *dev = pci_get_drvdata(pdev); 737 + struct nouveau_drm *drm = nouveau_drm(dev); 796 738 739 + /* revert our workaround */ 740 + if (drm->old_pm_cap) 741 + pdev->pm_cap = drm->old_pm_cap; 797 742 nouveau_drm_device_remove(dev); 798 743 pci_disable_device(pdev); 799 744 }
+2
drivers/gpu/drm/nouveau/nouveau_drv.h
··· 140 140 141 141 struct list_head clients; 142 142 143 + u8 old_pm_cap; 144 + 143 145 struct { 144 146 struct agp_bridge_data *bridge; 145 147 u32 base;
+6 -3
drivers/gpu/drm/nouveau/nouveau_svm.c
··· 171 171 mm = get_task_mm(current); 172 172 down_read(&mm->mmap_sem); 173 173 174 + if (!cli->svm.svmm) { 175 + up_read(&mm->mmap_sem); 176 + return -EINVAL; 177 + } 178 + 174 179 for (addr = args->va_start, end = args->va_start + size; addr < end;) { 175 180 struct vm_area_struct *vma; 176 181 unsigned long next; ··· 184 179 if (!vma) 185 180 break; 186 181 182 + addr = max(addr, vma->vm_start); 187 183 next = min(vma->vm_end, end); 188 184 /* This is a best effort so we ignore errors */ 189 185 nouveau_dmem_migrate_vma(cli->drm, vma, addr, next); ··· 662 656 limit = start + (ARRAY_SIZE(args.phys) << PAGE_SHIFT); 663 657 if (start < svmm->unmanaged.limit) 664 658 limit = min_t(u64, limit, svmm->unmanaged.start); 665 - else 666 - if (limit > svmm->unmanaged.start) 667 - start = max_t(u64, start, svmm->unmanaged.limit); 668 659 SVMM_DBG(svmm, "wndw %016llx-%016llx", start, limit); 669 660 670 661 mm = svmm->notifier.mm;
+1
drivers/gpu/drm/nouveau/nvif/Kbuild
··· 8 8 nvif-y += nvif/mem.o 9 9 nvif-y += nvif/mmu.o 10 10 nvif-y += nvif/notify.o 11 + nvif-y += nvif/timer.o 11 12 nvif-y += nvif/vmm.o 12 13 13 14 # Usermode classes
+9 -5
drivers/gpu/drm/nouveau/nvif/device.c
··· 27 27 u64 28 28 nvif_device_time(struct nvif_device *device) 29 29 { 30 - struct nv_device_time_v0 args = {}; 31 - int ret = nvif_object_mthd(&device->object, NV_DEVICE_V0_TIME, 32 - &args, sizeof(args)); 33 - WARN_ON_ONCE(ret != 0); 34 - return args.time; 30 + if (!device->user.func) { 31 + struct nv_device_time_v0 args = {}; 32 + int ret = nvif_object_mthd(&device->object, NV_DEVICE_V0_TIME, 33 + &args, sizeof(args)); 34 + WARN_ON_ONCE(ret != 0); 35 + return args.time; 36 + } 37 + 38 + return device->user.func->time(&device->user); 35 39 } 36 40 37 41 void
+56
drivers/gpu/drm/nouveau/nvif/timer.c
··· 1 + /* 2 + * Copyright 2020 Red Hat Inc. 3 + * 4 + * Permission is hereby granted, free of charge, to any person obtaining a 5 + * copy of this software and associated documentation files (the "Software"), 6 + * to deal in the Software without restriction, including without limitation 7 + * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 + * and/or sell copies of the Software, and to permit persons to whom the 9 + * Software is furnished to do so, subject to the following conditions: 10 + * 11 + * The above copyright notice and this permission notice shall be included in 12 + * all copies or substantial portions of the Software. 13 + * 14 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 15 + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 16 + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 17 + * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR 18 + * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 19 + * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 20 + * OTHER DEALINGS IN THE SOFTWARE. 21 + */ 22 + #include <nvif/timer.h> 23 + #include <nvif/device.h> 24 + 25 + s64 26 + nvif_timer_wait_test(struct nvif_timer_wait *wait) 27 + { 28 + u64 time = nvif_device_time(wait->device); 29 + 30 + if (wait->reads == 0) { 31 + wait->time0 = time; 32 + wait->time1 = time; 33 + } 34 + 35 + if (wait->time1 == time) { 36 + if (WARN_ON(wait->reads++ == 16)) 37 + return -ETIMEDOUT; 38 + } else { 39 + wait->time1 = time; 40 + wait->reads = 1; 41 + } 42 + 43 + if (wait->time1 - wait->time0 > wait->limit) 44 + return -ETIMEDOUT; 45 + 46 + return wait->time1 - wait->time0; 47 + } 48 + 49 + void 50 + nvif_timer_wait_init(struct nvif_device *device, u64 nsec, 51 + struct nvif_timer_wait *wait) 52 + { 53 + wait->device = device; 54 + wait->limit = nsec; 55 + wait->reads = 0; 56 + }
+14
drivers/gpu/drm/nouveau/nvif/userc361.c
··· 21 21 */ 22 22 #include <nvif/user.h> 23 23 24 + static u64 25 + nvif_userc361_time(struct nvif_user *user) 26 + { 27 + u32 hi, lo; 28 + 29 + do { 30 + hi = nvif_rd32(&user->object, 0x084); 31 + lo = nvif_rd32(&user->object, 0x080); 32 + } while (hi != nvif_rd32(&user->object, 0x084)); 33 + 34 + return ((u64)hi << 32 | lo); 35 + } 36 + 24 37 static void 25 38 nvif_userc361_doorbell(struct nvif_user *user, u32 token) 26 39 { ··· 43 30 const struct nvif_user_func 44 31 nvif_userc361 = { 45 32 .doorbell = nvif_userc361_doorbell, 33 + .time = nvif_userc361_time, 46 34 };
+26
drivers/gpu/drm/nouveau/nvkm/engine/gr/gf100.c
··· 1981 1981 { 1982 1982 struct gf100_gr *gr = gf100_gr(base); 1983 1983 struct nvkm_subdev *subdev = &base->engine.subdev; 1984 + struct nvkm_device *device = subdev->device; 1985 + bool reset = device->chipset == 0x137 || device->chipset == 0x138; 1984 1986 u32 ret; 1987 + 1988 + /* On certain GP107/GP108 boards, we trigger a weird issue where 1989 + * GR will stop responding to PRI accesses after we've asked the 1990 + * SEC2 RTOS to boot the GR falcons. This happens with far more 1991 + * frequency when cold-booting a board (ie. returning from D3). 1992 + * 1993 + * The root cause for this is not known and has proven difficult 1994 + * to isolate, with many avenues being dead-ends. 1995 + * 1996 + * A workaround was discovered by Karol, whereby putting GR into 1997 + * reset for an extended period right before initialisation 1998 + * prevents the problem from occuring. 1999 + * 2000 + * XXX: As RM does not require any such workaround, this is more 2001 + * of a hack than a true fix. 2002 + */ 2003 + reset = nvkm_boolopt(device->cfgopt, "NvGrResetWar", reset); 2004 + if (reset) { 2005 + nvkm_mask(device, 0x000200, 0x00001000, 0x00000000); 2006 + nvkm_rd32(device, 0x000200); 2007 + msleep(50); 2008 + nvkm_mask(device, 0x000200, 0x00001000, 0x00001000); 2009 + nvkm_rd32(device, 0x000200); 2010 + } 1985 2011 1986 2012 nvkm_pmu_pgob(gr->base.engine.subdev.device->pmu, false); 1987 2013
-11
drivers/gpu/drm/panel/panel-simple.c
··· 361 361 struct panel_desc *desc; 362 362 unsigned int bus_flags; 363 363 struct videomode vm; 364 - const char *mapping; 365 364 int ret; 366 365 367 366 np = dev->of_node; ··· 384 385 385 386 of_property_read_u32(np, "width-mm", &desc->size.width); 386 387 of_property_read_u32(np, "height-mm", &desc->size.height); 387 - 388 - of_property_read_string(np, "data-mapping", &mapping); 389 - if (!strcmp(mapping, "rgb24")) 390 - desc->bus_format = MEDIA_BUS_FMT_RGB888_1X24; 391 - else if (!strcmp(mapping, "rgb565")) 392 - desc->bus_format = MEDIA_BUS_FMT_RGB565_1X16; 393 - else if (!strcmp(mapping, "bgr666")) 394 - desc->bus_format = MEDIA_BUS_FMT_RGB666_1X18; 395 - else if (!strcmp(mapping, "lvds666")) 396 - desc->bus_format = MEDIA_BUS_FMT_RGB666_1X24_CPADHI; 397 388 398 389 /* Extract bus_flags from display_timing */ 399 390 bus_flags = 0;
+4
drivers/gpu/drm/vboxvideo/vbox_drv.c
··· 41 41 if (!vbox_check_supported(VBE_DISPI_ID_HGSMI)) 42 42 return -ENODEV; 43 43 44 + ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, "vboxvideodrmfb"); 45 + if (ret) 46 + return ret; 47 + 44 48 vbox = kzalloc(sizeof(*vbox), GFP_KERNEL); 45 49 if (!vbox) 46 50 return -ENOMEM;
+16 -4
drivers/gpu/drm/vc4/vc4_hdmi.c
··· 681 681 vc4_hdmi_encoder_mode_valid(struct drm_encoder *crtc, 682 682 const struct drm_display_mode *mode) 683 683 { 684 - /* HSM clock must be 108% of the pixel clock. Additionally, 685 - * the AXI clock needs to be at least 25% of pixel clock, but 686 - * HSM ends up being the limiting factor. 684 + /* 685 + * As stated in RPi's vc4 firmware "HDMI state machine (HSM) clock must 686 + * be faster than pixel clock, infinitesimally faster, tested in 687 + * simulation. Otherwise, exact value is unimportant for HDMI 688 + * operation." This conflicts with bcm2835's vc4 documentation, which 689 + * states HSM's clock has to be at least 108% of the pixel clock. 690 + * 691 + * Real life tests reveal that vc4's firmware statement holds up, and 692 + * users are able to use pixel clocks closer to HSM's, namely for 693 + * 1920x1200@60Hz. So it was decided to have leave a 1% margin between 694 + * both clocks. Which, for RPi0-3 implies a maximum pixel clock of 695 + * 162MHz. 696 + * 697 + * Additionally, the AXI clock needs to be at least 25% of 698 + * pixel clock, but HSM ends up being the limiting factor. 687 699 */ 688 - if (mode->clock > HSM_CLOCK_FREQ / (1000 * 108 / 100)) 700 + if (mode->clock > HSM_CLOCK_FREQ / (1000 * 101 / 100)) 689 701 return MODE_CLOCK_HIGH; 690 702 691 703 return MODE_OK;
+1 -1
drivers/gpu/drm/xen/xen_drm_front.c
··· 401 401 402 402 obj = xen_drm_front_gem_create(dev, args->size); 403 403 if (IS_ERR_OR_NULL(obj)) { 404 - ret = PTR_ERR(obj); 404 + ret = PTR_ERR_OR_ZERO(obj); 405 405 goto fail; 406 406 } 407 407
+3
drivers/video/fbdev/core/fbcon.c
··· 1282 1282 if (!con_is_bound(&fb_con)) 1283 1283 fbcon_exit(); 1284 1284 1285 + if (vc->vc_num == logo_shown) 1286 + logo_shown = FBCON_LOGO_CANSHOW; 1287 + 1285 1288 return; 1286 1289 } 1287 1290