mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/
synced 2026-04-18 06:33:43 -04:00
Merge tag 'amd-drm-next-5.7-2020-02-26' of git://people.freedesktop.org/~agd5f/linux into drm-next
amd-drm-next-5.7-2020-02-26: amdgpu: - Rework VM update handling in preparation for HMM support - HDCP srm support - PSR fixes - DC watermark fixes - OLED panel support - SR-IOV fixes - BACO fixes - Optimize debugging vram access - RAS fixes - Use BACO for runtime pm - HDCP fixes - XGMI fixes - DDC fixes - DC clock programming optimizations and fixes - PSP fw loading sequence updates - Drop DRIVER_USE_AGP - Remove legacy drm load and unload callbacks amdkfd: - Add runtime pm support radeon: - Drop DRIVER_USE_AGP Signed-off-by: Dave Airlie <airlied@redhat.com> From: Alex Deucher <alexdeucher@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200227043142.4075-1-alexander.deucher@amd.com
This commit is contained in:
@@ -98,6 +98,9 @@ MODULE_FIRMWARE(FIRMWARE_RENOIR_DMUB);
|
||||
#define FIRMWARE_RAVEN_DMCU "amdgpu/raven_dmcu.bin"
|
||||
MODULE_FIRMWARE(FIRMWARE_RAVEN_DMCU);
|
||||
|
||||
#define FIRMWARE_NAVI12_DMCU "amdgpu/navi12_dmcu.bin"
|
||||
MODULE_FIRMWARE(FIRMWARE_NAVI12_DMCU);
|
||||
|
||||
/* Number of bytes in PSP header for firmware. */
|
||||
#define PSP_HEADER_BYTES 0x100
|
||||
|
||||
@@ -801,10 +804,20 @@ static int dm_dmub_hw_init(struct amdgpu_device *adev)
|
||||
|
||||
fw_bss_data_size = le32_to_cpu(hdr->bss_data_bytes);
|
||||
|
||||
memcpy(fb_info->fb[DMUB_WINDOW_0_INST_CONST].cpu_addr, fw_inst_const,
|
||||
fw_inst_const_size);
|
||||
/* if adev->firmware.load_type == AMDGPU_FW_LOAD_PSP,
|
||||
* amdgpu_ucode_init_single_fw will load dmub firmware
|
||||
* fw_inst_const part to cw0; otherwise, the firmware back door load
|
||||
* will be done by dm_dmub_hw_init
|
||||
*/
|
||||
if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) {
|
||||
memcpy(fb_info->fb[DMUB_WINDOW_0_INST_CONST].cpu_addr, fw_inst_const,
|
||||
fw_inst_const_size);
|
||||
}
|
||||
|
||||
memcpy(fb_info->fb[DMUB_WINDOW_2_BSS_DATA].cpu_addr, fw_bss_data,
|
||||
fw_bss_data_size);
|
||||
|
||||
/* Copy firmware bios info into FB memory. */
|
||||
memcpy(fb_info->fb[DMUB_WINDOW_3_VBIOS].cpu_addr, adev->bios,
|
||||
adev->bios_size);
|
||||
|
||||
@@ -823,6 +836,10 @@ static int dm_dmub_hw_init(struct amdgpu_device *adev)
|
||||
hw_params.fb_base = adev->gmc.fb_start;
|
||||
hw_params.fb_offset = adev->gmc.aper_base;
|
||||
|
||||
/* backdoor load firmware and trigger dmub running */
|
||||
if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP)
|
||||
hw_params.load_inst_const = true;
|
||||
|
||||
if (dmcu)
|
||||
hw_params.psp_version = dmcu->psp_version;
|
||||
|
||||
@@ -960,7 +977,7 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
|
||||
|
||||
#ifdef CONFIG_DRM_AMD_DC_HDCP
|
||||
if (adev->asic_type >= CHIP_RAVEN) {
|
||||
adev->dm.hdcp_workqueue = hdcp_create_workqueue(&adev->psp, &init_params.cp_psp, adev->dm.dc);
|
||||
adev->dm.hdcp_workqueue = hdcp_create_workqueue(adev, &init_params.cp_psp, adev->dm.dc);
|
||||
|
||||
if (!adev->dm.hdcp_workqueue)
|
||||
DRM_ERROR("amdgpu: failed to initialize hdcp_workqueue.\n");
|
||||
@@ -991,11 +1008,6 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
|
||||
goto error;
|
||||
}
|
||||
|
||||
#if defined(CONFIG_DEBUG_FS)
|
||||
if (dtn_debugfs_init(adev))
|
||||
DRM_ERROR("amdgpu: failed initialize dtn debugfs support.\n");
|
||||
#endif
|
||||
|
||||
DRM_DEBUG_DRIVER("KMS initialized.\n");
|
||||
|
||||
return 0;
|
||||
@@ -1079,9 +1091,11 @@ static int load_dmcu_fw(struct amdgpu_device *adev)
|
||||
case CHIP_VEGA20:
|
||||
case CHIP_NAVI10:
|
||||
case CHIP_NAVI14:
|
||||
case CHIP_NAVI12:
|
||||
case CHIP_RENOIR:
|
||||
return 0;
|
||||
case CHIP_NAVI12:
|
||||
fw_name_dmcu = FIRMWARE_NAVI12_DMCU;
|
||||
break;
|
||||
case CHIP_RAVEN:
|
||||
if (ASICREV_IS_PICASSO(adev->external_rev_id))
|
||||
fw_name_dmcu = FIRMWARE_RAVEN_DMCU;
|
||||
@@ -1192,23 +1206,22 @@ static int dm_dmub_sw_init(struct amdgpu_device *adev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (adev->firmware.load_type != AMDGPU_FW_LOAD_PSP) {
|
||||
DRM_WARN("Only PSP firmware loading is supported for DMUB\n");
|
||||
return 0;
|
||||
hdr = (const struct dmcub_firmware_header_v1_0 *)adev->dm.dmub_fw->data;
|
||||
|
||||
if (adev->firmware.load_type == AMDGPU_FW_LOAD_PSP) {
|
||||
adev->firmware.ucode[AMDGPU_UCODE_ID_DMCUB].ucode_id =
|
||||
AMDGPU_UCODE_ID_DMCUB;
|
||||
adev->firmware.ucode[AMDGPU_UCODE_ID_DMCUB].fw =
|
||||
adev->dm.dmub_fw;
|
||||
adev->firmware.fw_size +=
|
||||
ALIGN(le32_to_cpu(hdr->inst_const_bytes), PAGE_SIZE);
|
||||
|
||||
DRM_INFO("Loading DMUB firmware via PSP: version=0x%08X\n",
|
||||
adev->dm.dmcub_fw_version);
|
||||
}
|
||||
|
||||
hdr = (const struct dmcub_firmware_header_v1_0 *)adev->dm.dmub_fw->data;
|
||||
adev->firmware.ucode[AMDGPU_UCODE_ID_DMCUB].ucode_id =
|
||||
AMDGPU_UCODE_ID_DMCUB;
|
||||
adev->firmware.ucode[AMDGPU_UCODE_ID_DMCUB].fw = adev->dm.dmub_fw;
|
||||
adev->firmware.fw_size +=
|
||||
ALIGN(le32_to_cpu(hdr->inst_const_bytes), PAGE_SIZE);
|
||||
|
||||
adev->dm.dmcub_fw_version = le32_to_cpu(hdr->header.ucode_version);
|
||||
|
||||
DRM_INFO("Loading DMUB firmware via PSP: version=0x%08X\n",
|
||||
adev->dm.dmcub_fw_version);
|
||||
|
||||
adev->dm.dmub_srv = kzalloc(sizeof(*adev->dm.dmub_srv), GFP_KERNEL);
|
||||
dmub_srv = adev->dm.dmub_srv;
|
||||
|
||||
@@ -1758,6 +1771,61 @@ static struct drm_mode_config_helper_funcs amdgpu_dm_mode_config_helperfuncs = {
|
||||
.atomic_commit_tail = amdgpu_dm_atomic_commit_tail
|
||||
};
|
||||
|
||||
static void update_connector_ext_caps(struct amdgpu_dm_connector *aconnector)
|
||||
{
|
||||
u32 max_cll, min_cll, max, min, q, r;
|
||||
struct amdgpu_dm_backlight_caps *caps;
|
||||
struct amdgpu_display_manager *dm;
|
||||
struct drm_connector *conn_base;
|
||||
struct amdgpu_device *adev;
|
||||
static const u8 pre_computed_values[] = {
|
||||
50, 51, 52, 53, 55, 56, 57, 58, 59, 61, 62, 63, 65, 66, 68, 69,
|
||||
71, 72, 74, 75, 77, 79, 81, 82, 84, 86, 88, 90, 92, 94, 96, 98};
|
||||
|
||||
if (!aconnector || !aconnector->dc_link)
|
||||
return;
|
||||
|
||||
conn_base = &aconnector->base;
|
||||
adev = conn_base->dev->dev_private;
|
||||
dm = &adev->dm;
|
||||
caps = &dm->backlight_caps;
|
||||
caps->ext_caps = &aconnector->dc_link->dpcd_sink_ext_caps;
|
||||
caps->aux_support = false;
|
||||
max_cll = conn_base->hdr_sink_metadata.hdmi_type1.max_cll;
|
||||
min_cll = conn_base->hdr_sink_metadata.hdmi_type1.min_cll;
|
||||
|
||||
if (caps->ext_caps->bits.oled == 1 ||
|
||||
caps->ext_caps->bits.sdr_aux_backlight_control == 1 ||
|
||||
caps->ext_caps->bits.hdr_aux_backlight_control == 1)
|
||||
caps->aux_support = true;
|
||||
|
||||
/* From the specification (CTA-861-G), for calculating the maximum
|
||||
* luminance we need to use:
|
||||
* Luminance = 50*2**(CV/32)
|
||||
* Where CV is a one-byte value.
|
||||
* For calculating this expression we may need float point precision;
|
||||
* to avoid this complexity level, we take advantage that CV is divided
|
||||
* by a constant. From the Euclids division algorithm, we know that CV
|
||||
* can be written as: CV = 32*q + r. Next, we replace CV in the
|
||||
* Luminance expression and get 50*(2**q)*(2**(r/32)), hence we just
|
||||
* need to pre-compute the value of r/32. For pre-computing the values
|
||||
* We just used the following Ruby line:
|
||||
* (0...32).each {|cv| puts (50*2**(cv/32.0)).round}
|
||||
* The results of the above expressions can be verified at
|
||||
* pre_computed_values.
|
||||
*/
|
||||
q = max_cll >> 5;
|
||||
r = max_cll % 32;
|
||||
max = (1 << q) * pre_computed_values[r];
|
||||
|
||||
// min luminance: maxLum * (CV/255)^2 / 100
|
||||
q = DIV_ROUND_CLOSEST(min_cll, 255);
|
||||
min = max * DIV_ROUND_CLOSEST((q * q), 100);
|
||||
|
||||
caps->aux_max_input_signal = max;
|
||||
caps->aux_min_input_signal = min;
|
||||
}
|
||||
|
||||
static void
|
||||
amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
|
||||
{
|
||||
@@ -1872,7 +1940,7 @@ amdgpu_dm_update_connector_after_detect(struct amdgpu_dm_connector *aconnector)
|
||||
aconnector->edid);
|
||||
}
|
||||
amdgpu_dm_update_freesync_caps(connector, aconnector->edid);
|
||||
|
||||
update_connector_ext_caps(aconnector);
|
||||
} else {
|
||||
drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux);
|
||||
amdgpu_dm_update_freesync_caps(connector, NULL);
|
||||
@@ -1911,7 +1979,7 @@ static void handle_hpd_irq(void *param)
|
||||
mutex_lock(&aconnector->hpd_lock);
|
||||
|
||||
#ifdef CONFIG_DRM_AMD_DC_HDCP
|
||||
if (adev->asic_type >= CHIP_RAVEN)
|
||||
if (adev->dm.hdcp_workqueue)
|
||||
hdcp_reset_display(adev->dm.hdcp_workqueue, aconnector->dc_link->link_index);
|
||||
#endif
|
||||
if (aconnector->fake_enable)
|
||||
@@ -2088,8 +2156,10 @@ static void handle_hpd_rx_irq(void *param)
|
||||
}
|
||||
}
|
||||
#ifdef CONFIG_DRM_AMD_DC_HDCP
|
||||
if (hpd_irq_data.bytes.device_service_irq.bits.CP_IRQ)
|
||||
hdcp_handle_cpirq(adev->dm.hdcp_workqueue, aconnector->base.index);
|
||||
if (hpd_irq_data.bytes.device_service_irq.bits.CP_IRQ) {
|
||||
if (adev->dm.hdcp_workqueue)
|
||||
hdcp_handle_cpirq(adev->dm.hdcp_workqueue, aconnector->base.index);
|
||||
}
|
||||
#endif
|
||||
if ((dc_link->cur_link_settings.lane_count != LANE_COUNT_UNKNOWN) ||
|
||||
(dc_link->type == dc_connection_mst_branch))
|
||||
@@ -2484,6 +2554,7 @@ static int amdgpu_dm_mode_config_init(struct amdgpu_device *adev)
|
||||
|
||||
#define AMDGPU_DM_DEFAULT_MIN_BACKLIGHT 12
|
||||
#define AMDGPU_DM_DEFAULT_MAX_BACKLIGHT 255
|
||||
#define AUX_BL_DEFAULT_TRANSITION_TIME_MS 50
|
||||
|
||||
#if defined(CONFIG_BACKLIGHT_CLASS_DEVICE) ||\
|
||||
defined(CONFIG_BACKLIGHT_CLASS_DEVICE_MODULE)
|
||||
@@ -2498,9 +2569,11 @@ static void amdgpu_dm_update_backlight_caps(struct amdgpu_display_manager *dm)
|
||||
|
||||
amdgpu_acpi_get_backlight_caps(dm->adev, &caps);
|
||||
if (caps.caps_valid) {
|
||||
dm->backlight_caps.caps_valid = true;
|
||||
if (caps.aux_support)
|
||||
return;
|
||||
dm->backlight_caps.min_input_signal = caps.min_input_signal;
|
||||
dm->backlight_caps.max_input_signal = caps.max_input_signal;
|
||||
dm->backlight_caps.caps_valid = true;
|
||||
} else {
|
||||
dm->backlight_caps.min_input_signal =
|
||||
AMDGPU_DM_DEFAULT_MIN_BACKLIGHT;
|
||||
@@ -2508,40 +2581,95 @@ static void amdgpu_dm_update_backlight_caps(struct amdgpu_display_manager *dm)
|
||||
AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
|
||||
}
|
||||
#else
|
||||
if (dm->backlight_caps.aux_support)
|
||||
return;
|
||||
|
||||
dm->backlight_caps.min_input_signal = AMDGPU_DM_DEFAULT_MIN_BACKLIGHT;
|
||||
dm->backlight_caps.max_input_signal = AMDGPU_DM_DEFAULT_MAX_BACKLIGHT;
|
||||
#endif
|
||||
}
|
||||
|
||||
static int set_backlight_via_aux(struct dc_link *link, uint32_t brightness)
|
||||
{
|
||||
bool rc;
|
||||
|
||||
if (!link)
|
||||
return 1;
|
||||
|
||||
rc = dc_link_set_backlight_level_nits(link, true, brightness,
|
||||
AUX_BL_DEFAULT_TRANSITION_TIME_MS);
|
||||
|
||||
return rc ? 0 : 1;
|
||||
}
|
||||
|
||||
static u32 convert_brightness(const struct amdgpu_dm_backlight_caps *caps,
|
||||
const uint32_t user_brightness)
|
||||
{
|
||||
u32 min, max, conversion_pace;
|
||||
u32 brightness = user_brightness;
|
||||
|
||||
if (!caps)
|
||||
goto out;
|
||||
|
||||
if (!caps->aux_support) {
|
||||
max = caps->max_input_signal;
|
||||
min = caps->min_input_signal;
|
||||
/*
|
||||
* The brightness input is in the range 0-255
|
||||
* It needs to be rescaled to be between the
|
||||
* requested min and max input signal
|
||||
* It also needs to be scaled up by 0x101 to
|
||||
* match the DC interface which has a range of
|
||||
* 0 to 0xffff
|
||||
*/
|
||||
conversion_pace = 0x101;
|
||||
brightness =
|
||||
user_brightness
|
||||
* conversion_pace
|
||||
* (max - min)
|
||||
/ AMDGPU_MAX_BL_LEVEL
|
||||
+ min * conversion_pace;
|
||||
} else {
|
||||
/* TODO
|
||||
* We are doing a linear interpolation here, which is OK but
|
||||
* does not provide the optimal result. We probably want
|
||||
* something close to the Perceptual Quantizer (PQ) curve.
|
||||
*/
|
||||
max = caps->aux_max_input_signal;
|
||||
min = caps->aux_min_input_signal;
|
||||
|
||||
brightness = (AMDGPU_MAX_BL_LEVEL - user_brightness) * min
|
||||
+ user_brightness * max;
|
||||
// Multiple the value by 1000 since we use millinits
|
||||
brightness *= 1000;
|
||||
brightness = DIV_ROUND_CLOSEST(brightness, AMDGPU_MAX_BL_LEVEL);
|
||||
}
|
||||
|
||||
out:
|
||||
return brightness;
|
||||
}
|
||||
|
||||
static int amdgpu_dm_backlight_update_status(struct backlight_device *bd)
|
||||
{
|
||||
struct amdgpu_display_manager *dm = bl_get_data(bd);
|
||||
struct amdgpu_dm_backlight_caps caps;
|
||||
uint32_t brightness = bd->props.brightness;
|
||||
struct dc_link *link = NULL;
|
||||
u32 brightness;
|
||||
bool rc;
|
||||
|
||||
amdgpu_dm_update_backlight_caps(dm);
|
||||
caps = dm->backlight_caps;
|
||||
/*
|
||||
* The brightness input is in the range 0-255
|
||||
* It needs to be rescaled to be between the
|
||||
* requested min and max input signal
|
||||
*
|
||||
* It also needs to be scaled up by 0x101 to
|
||||
* match the DC interface which has a range of
|
||||
* 0 to 0xffff
|
||||
*/
|
||||
brightness =
|
||||
brightness
|
||||
* 0x101
|
||||
* (caps.max_input_signal - caps.min_input_signal)
|
||||
/ AMDGPU_MAX_BL_LEVEL
|
||||
+ caps.min_input_signal * 0x101;
|
||||
|
||||
if (dc_link_set_backlight_level(dm->backlight_link,
|
||||
brightness, 0))
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
link = (struct dc_link *)dm->backlight_link;
|
||||
|
||||
brightness = convert_brightness(&caps, bd->props.brightness);
|
||||
// Change brightness based on AUX property
|
||||
if (caps.aux_support)
|
||||
return set_backlight_via_aux(link, brightness);
|
||||
|
||||
rc = dc_link_set_backlight_level(dm->backlight_link, brightness, 0);
|
||||
|
||||
return rc ? 0 : 1;
|
||||
}
|
||||
|
||||
static int amdgpu_dm_backlight_get_brightness(struct backlight_device *bd)
|
||||
@@ -4493,6 +4621,19 @@ amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector)
|
||||
return &new_state->base;
|
||||
}
|
||||
|
||||
static int
|
||||
amdgpu_dm_connector_late_register(struct drm_connector *connector)
|
||||
{
|
||||
struct amdgpu_dm_connector *amdgpu_dm_connector =
|
||||
to_amdgpu_dm_connector(connector);
|
||||
|
||||
#if defined(CONFIG_DEBUG_FS)
|
||||
connector_debugfs_init(amdgpu_dm_connector);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct drm_connector_funcs amdgpu_dm_connector_funcs = {
|
||||
.reset = amdgpu_dm_connector_funcs_reset,
|
||||
.detect = amdgpu_dm_connector_detect,
|
||||
@@ -4502,6 +4643,7 @@ static const struct drm_connector_funcs amdgpu_dm_connector_funcs = {
|
||||
.atomic_destroy_state = drm_atomic_helper_connector_destroy_state,
|
||||
.atomic_set_property = amdgpu_dm_connector_atomic_set_property,
|
||||
.atomic_get_property = amdgpu_dm_connector_atomic_get_property,
|
||||
.late_register = amdgpu_dm_connector_late_register,
|
||||
.early_unregister = amdgpu_dm_connector_unregister
|
||||
};
|
||||
|
||||
@@ -5705,7 +5847,7 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
|
||||
drm_connector_attach_vrr_capable_property(
|
||||
&aconnector->base);
|
||||
#ifdef CONFIG_DRM_AMD_DC_HDCP
|
||||
if (adev->asic_type >= CHIP_RAVEN)
|
||||
if (adev->dm.hdcp_workqueue)
|
||||
drm_connector_attach_content_protection_property(&aconnector->base, true);
|
||||
#endif
|
||||
}
|
||||
@@ -5842,13 +5984,6 @@ static int amdgpu_dm_connector_init(struct amdgpu_display_manager *dm,
|
||||
drm_connector_attach_encoder(
|
||||
&aconnector->base, &aencoder->base);
|
||||
|
||||
drm_connector_register(&aconnector->base);
|
||||
#if defined(CONFIG_DEBUG_FS)
|
||||
connector_debugfs_init(aconnector);
|
||||
aconnector->debugfs_dpcd_address = 0;
|
||||
aconnector->debugfs_dpcd_size = 0;
|
||||
#endif
|
||||
|
||||
if (connector_type == DRM_MODE_CONNECTOR_DisplayPort
|
||||
|| connector_type == DRM_MODE_CONNECTOR_eDP)
|
||||
amdgpu_dm_initialize_dp_connector(dm, aconnector);
|
||||
|
||||
Reference in New Issue
Block a user