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

drm/amd/display: Convert memory from cpu to fw endianness correctly

[Why]
Current code does not guarantee the correct endianness of memory being
copied to fw, specifically in the case where cpu isn't little endian.

[How]
Windows and Diags are always little endian, so we define a macro that
does nothing. Linux already defines this macro and will do the correct
endianness conversion.

Signed-off-by: Wyatt Wood <wyatt.wood@amd.com>
Reviewed-by: Harry Wentland <Harry.Wentland@amd.com>
Acked-by: Anthony Koo <Anthony.Koo@amd.com>
Acked-by: Rodrigo Siqueira <Rodrigo.Siqueira@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Wyatt Wood and committed by
Alex Deucher
a42c1ed5 af031f07

+31 -27
+31 -27
drivers/gpu/drm/amd/display/modules/power/power_helpers.c
··· 265 265 ASSERT(lut_index < params.backlight_lut_array_size); 266 266 267 267 table->backlight_thresholds[i] = (big_endian) ? 268 - cpu_to_be16(DIV_ROUNDUP((i * 65536), num_entries)) : DIV_ROUNDUP((i * 65536), num_entries); 268 + cpu_to_be16(DIV_ROUNDUP((i * 65536), num_entries)) : 269 + cpu_to_le16(DIV_ROUNDUP((i * 65536), num_entries)); 269 270 table->backlight_offsets[i] = (big_endian) ? 270 - cpu_to_be16(params.backlight_lut_array[lut_index]) : params.backlight_lut_array[lut_index]; 271 + cpu_to_be16(params.backlight_lut_array[lut_index]) : 272 + cpu_to_le16(params.backlight_lut_array[lut_index]); 271 273 } 272 274 } 273 275 ··· 598 596 unsigned int set = params.set; 599 597 600 598 ram_table->flags = 0x0; 601 - ram_table->min_abm_backlight = (big_endian) ? cpu_to_be16(params.min_abm_backlight) : params.min_abm_backlight; 599 + ram_table->min_abm_backlight = (big_endian) ? 600 + cpu_to_be16(params.min_abm_backlight) : 601 + cpu_to_le16(params.min_abm_backlight); 602 602 603 603 for (i = 0; i < NUM_AGGR_LEVEL; i++) { 604 604 ram_table->hybrid_factor[i] = abm_settings[set][i].brightness_gain; ··· 624 620 ram_table->iir_curve[4] = 0x65; 625 621 626 622 //Gamma 2.2 627 - ram_table->crgb_thresh[0] = (big_endian) ? cpu_to_be16(0x127c) : 0x127c; 628 - ram_table->crgb_thresh[1] = (big_endian) ? cpu_to_be16(0x151b) : 0x151b; 629 - ram_table->crgb_thresh[2] = (big_endian) ? cpu_to_be16(0x17d5) : 0x17d5; 630 - ram_table->crgb_thresh[3] = (big_endian) ? cpu_to_be16(0x1a56) : 0x1a56; 631 - ram_table->crgb_thresh[4] = (big_endian) ? cpu_to_be16(0x1c83) : 0x1c83; 632 - ram_table->crgb_thresh[5] = (big_endian) ? cpu_to_be16(0x1e72) : 0x1e72; 633 - ram_table->crgb_thresh[6] = (big_endian) ? cpu_to_be16(0x20f0) : 0x20f0; 634 - ram_table->crgb_thresh[7] = (big_endian) ? cpu_to_be16(0x232b) : 0x232b; 635 - ram_table->crgb_offset[0] = (big_endian) ? cpu_to_be16(0x2999) : 0x2999; 636 - ram_table->crgb_offset[1] = (big_endian) ? cpu_to_be16(0x3999) : 0x3999; 637 - ram_table->crgb_offset[2] = (big_endian) ? cpu_to_be16(0x4666) : 0x4666; 638 - ram_table->crgb_offset[3] = (big_endian) ? cpu_to_be16(0x5999) : 0x5999; 639 - ram_table->crgb_offset[4] = (big_endian) ? cpu_to_be16(0x6333) : 0x6333; 640 - ram_table->crgb_offset[5] = (big_endian) ? cpu_to_be16(0x7800) : 0x7800; 641 - ram_table->crgb_offset[6] = (big_endian) ? cpu_to_be16(0x8c00) : 0x8c00; 642 - ram_table->crgb_offset[7] = (big_endian) ? cpu_to_be16(0xa000) : 0xa000; 643 - ram_table->crgb_slope[0] = (big_endian) ? cpu_to_be16(0x3609) : 0x3609; 644 - ram_table->crgb_slope[1] = (big_endian) ? cpu_to_be16(0x2dfa) : 0x2dfa; 645 - ram_table->crgb_slope[2] = (big_endian) ? cpu_to_be16(0x27ea) : 0x27ea; 646 - ram_table->crgb_slope[3] = (big_endian) ? cpu_to_be16(0x235d) : 0x235d; 647 - ram_table->crgb_slope[4] = (big_endian) ? cpu_to_be16(0x2042) : 0x2042; 648 - ram_table->crgb_slope[5] = (big_endian) ? cpu_to_be16(0x1dc3) : 0x1dc3; 649 - ram_table->crgb_slope[6] = (big_endian) ? cpu_to_be16(0x1b1a) : 0x1b1a; 650 - ram_table->crgb_slope[7] = (big_endian) ? cpu_to_be16(0x1910) : 0x1910; 623 + ram_table->crgb_thresh[0] = (big_endian) ? cpu_to_be16(0x127c) : cpu_to_le16(0x127c); 624 + ram_table->crgb_thresh[1] = (big_endian) ? cpu_to_be16(0x151b) : cpu_to_le16(0x151b); 625 + ram_table->crgb_thresh[2] = (big_endian) ? cpu_to_be16(0x17d5) : cpu_to_le16(0x17d5); 626 + ram_table->crgb_thresh[3] = (big_endian) ? cpu_to_be16(0x1a56) : cpu_to_le16(0x1a56); 627 + ram_table->crgb_thresh[4] = (big_endian) ? cpu_to_be16(0x1c83) : cpu_to_le16(0x1c83); 628 + ram_table->crgb_thresh[5] = (big_endian) ? cpu_to_be16(0x1e72) : cpu_to_le16(0x1e72); 629 + ram_table->crgb_thresh[6] = (big_endian) ? cpu_to_be16(0x20f0) : cpu_to_le16(0x20f0); 630 + ram_table->crgb_thresh[7] = (big_endian) ? cpu_to_be16(0x232b) : cpu_to_le16(0x232b); 631 + ram_table->crgb_offset[0] = (big_endian) ? cpu_to_be16(0x2999) : cpu_to_le16(0x2999); 632 + ram_table->crgb_offset[1] = (big_endian) ? cpu_to_be16(0x3999) : cpu_to_le16(0x3999); 633 + ram_table->crgb_offset[2] = (big_endian) ? cpu_to_be16(0x4666) : cpu_to_le16(0x4666); 634 + ram_table->crgb_offset[3] = (big_endian) ? cpu_to_be16(0x5999) : cpu_to_le16(0x5999); 635 + ram_table->crgb_offset[4] = (big_endian) ? cpu_to_be16(0x6333) : cpu_to_le16(0x6333); 636 + ram_table->crgb_offset[5] = (big_endian) ? cpu_to_be16(0x7800) : cpu_to_le16(0x7800); 637 + ram_table->crgb_offset[6] = (big_endian) ? cpu_to_be16(0x8c00) : cpu_to_le16(0x8c00); 638 + ram_table->crgb_offset[7] = (big_endian) ? cpu_to_be16(0xa000) : cpu_to_le16(0xa000); 639 + ram_table->crgb_slope[0] = (big_endian) ? cpu_to_be16(0x3609) : cpu_to_le16(0x3609); 640 + ram_table->crgb_slope[1] = (big_endian) ? cpu_to_be16(0x2dfa) : cpu_to_le16(0x2dfa); 641 + ram_table->crgb_slope[2] = (big_endian) ? cpu_to_be16(0x27ea) : cpu_to_le16(0x27ea); 642 + ram_table->crgb_slope[3] = (big_endian) ? cpu_to_be16(0x235d) : cpu_to_le16(0x235d); 643 + ram_table->crgb_slope[4] = (big_endian) ? cpu_to_be16(0x2042) : cpu_to_le16(0x2042); 644 + ram_table->crgb_slope[5] = (big_endian) ? cpu_to_be16(0x1dc3) : cpu_to_le16(0x1dc3); 645 + ram_table->crgb_slope[6] = (big_endian) ? cpu_to_be16(0x1b1a) : cpu_to_le16(0x1b1a); 646 + ram_table->crgb_slope[7] = (big_endian) ? cpu_to_be16(0x1910) : cpu_to_le16(0x1910); 651 647 652 648 fill_backlight_transform_table_v_2_2( 653 649 params, ram_table, big_endian);