[PATCH 01/14] drm/amd/display: Add PSP block to verify HDCP2.2 steps

2019-11-07 Thread Bhawanpreet Lakha
[Why]
All the HDCP transactions should be verified using PSP

[How]
This patch adds the psp calls we need to verify the steps

Signed-off-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/modules/hdcp/hdcp.h   |  44 ++
 .../drm/amd/display/modules/hdcp/hdcp_psp.c   | 502 +-
 .../drm/amd/display/modules/hdcp/hdcp_psp.h   | 194 +++
 3 files changed, 739 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h
index 5664bc0b5bd0..d83f0ab1cadb 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h
@@ -111,8 +111,33 @@ struct mod_hdcp_message_hdcp1 {
uint16_tbinfo_dp;
 };
 
+struct mod_hdcp_message_hdcp2 {
+   uint8_t hdcp2version_hdmi;
+   uint8_t rxcaps_dp[3];
+   uint16_trxstatus;
+
+   uint8_t ake_init[12];
+   uint8_t ake_cert[534];
+   uint8_t ake_no_stored_km[129];
+   uint8_t ake_stored_km[33];
+   uint8_t ake_h_prime[33];
+   uint8_t ake_pairing_info[17];
+   uint8_t lc_init[9];
+   uint8_t lc_l_prime[33];
+   uint8_t ske_eks[25];
+   uint8_t rx_id_list[177]; // 22 + 5 * 31
+   uint16_trx_id_list_size;
+   uint8_t repeater_auth_ack[17];
+   uint8_t repeater_auth_stream_manage[68]; // 6 + 2 * 31
+   uint16_tstream_manage_size;
+   uint8_t repeater_auth_stream_ready[33];
+
+   uint8_t content_stream_type_dp[2];
+};
+
 union mod_hdcp_message {
struct mod_hdcp_message_hdcp1 hdcp1;
+   struct mod_hdcp_message_hdcp2 hdcp2;
 };
 
 struct mod_hdcp_auth_counters {
@@ -234,6 +259,25 @@ enum mod_hdcp_status 
mod_hdcp_hdcp1_enable_dp_stream_encryption(
 enum mod_hdcp_status mod_hdcp_hdcp1_link_maintenance(struct mod_hdcp *hdcp);
 enum mod_hdcp_status mod_hdcp_hdcp1_get_link_encryption_status(struct mod_hdcp 
*hdcp,
   enum 
mod_hdcp_encryption_status *encryption_status);
+enum mod_hdcp_status mod_hdcp_hdcp2_create_session(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_destroy_session(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_prepare_ake_init(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_validate_ake_cert(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_validate_h_prime(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_prepare_lc_init(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_validate_l_prime(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_prepare_eks(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_enable_encryption(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_validate_rx_id_list(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(
+   struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_prepare_stream_management(
+   struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_validate_stream_ready(
+   struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_get_link_encryption_status(struct mod_hdcp 
*hdcp,
+  enum 
mod_hdcp_encryption_status *encryption_status);
+
 /* ddc functions */
 enum mod_hdcp_status mod_hdcp_read_bksv(struct mod_hdcp *hdcp);
 enum mod_hdcp_status mod_hdcp_read_bcaps(struct mod_hdcp *hdcp);
diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
index 646d909bbc37..ddba0cfa5722 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
@@ -31,6 +31,19 @@
 #include "amdgpu.h"
 #include "hdcp_psp.h"
 
+static void hdcp2_message_init(struct mod_hdcp *hdcp,
+  struct 
ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *in)
+{
+   in->session_handle = hdcp->auth.id;
+   in->prepare.msg1_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE;
+   in->prepare.msg2_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE;
+   in->process.msg1_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE;
+   in->process.msg1_desc.msg_size = 0;
+   in->process.msg2_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE;
+   in->process.msg2_desc.msg_size = 0;
+   in->process.msg3_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE;
+   in->process.msg3_desc.msg_id = 0;
+}
 enum mod_hdcp_status mod_hdcp_remove_display_topology(struct mod_hdcp *hdcp)
 {
 
@@ -42,7 +55,7 @@ enum mod_hdcp_status mod_hdcp_remove_display_topology(struct 
mod_hdcp *hdcp)
dtm_cmd = (struct ta_dtm_shared_memory 
*)psp->dtm_context.dtm_shared_

[PATCH 2/3] drm/amd/display: Drop CONFIG_DRM_AMD_DC_DCN2_1 flag

2019-11-01 Thread Bhawanpreet Lakha
[Why]

DCN21 is stable enough to be build by default. So drop the flags.

[How]

Remove them using the unifdef tool. The following commands were executed
in sequence:

$ find -name '*.c' -exec unifdef -m -DCONFIG_DRM_AMD_DC_DCN2_1 
-UCONFIG_TRIM_DRM_AMD_DC_DCN2_1 '{}' ';'
$ find -name '*.h' -exec unifdef -m -DCONFIG_DRM_AMD_DC_DCN2_1 
-UCONFIG_TRIM_DRM_AMD_DC_DCN2_1 '{}' ';'

In addition:

* Remove from kconfig, and replace any dependencies with DCN1_0.
* Remove from any makefiles.
* Fix and cleanup Renoir definitions in dal_asic_id.h
* Expand DCN1 ifdef to include DCN21 code in the following files:
* clk_mgr/clk_mgr.c: dc_clk_mgr_create()
* core/dc_resources.c: dc_create_resource_pool()
* gpio/hw_factory.c: dal_hw_factory_init()
* gpio/hw_translate.c: dal_hw_translate_init()

Signed-off-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/Kconfig| 18 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  |  6 --
 .../amd/display/amdgpu_dm/amdgpu_dm_pp_smu.c   |  4 
 drivers/gpu/drm/amd/display/dc/Makefile|  3 ---
 .../display/dc/bios/command_table_helper2.c|  2 --
 .../gpu/drm/amd/display/dc/clk_mgr/Makefile|  2 --
 .../gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c   |  4 
 drivers/gpu/drm/amd/display/dc/core/dc.c   |  2 --
 .../gpu/drm/amd/display/dc/core/dc_resource.c  |  6 --
 drivers/gpu/drm/amd/display/dc/dc.h|  2 --
 .../drm/amd/display/dc/dce/dce_clock_source.h  |  2 --
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c  |  6 --
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h  |  2 --
 drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h |  4 
 .../drm/amd/display/dc/dcn10/dcn10_hubbub.h|  8 
 .../amd/display/dc/dcn10/dcn10_hw_sequencer.c  |  2 --
 .../gpu/drm/amd/display/dc/dcn20/dcn20_hubp.h  | 16 
 .../drm/amd/display/dc/dcn20/dcn20_resource.c  |  8 
 .../drm/amd/display/dc/dcn21/dcn21_resource.c  |  2 --
 drivers/gpu/drm/amd/display/dc/dm_pp_smu.h |  4 
 drivers/gpu/drm/amd/display/dc/dml/Makefile|  4 
 .../drm/amd/display/dc/dml/display_mode_lib.c  |  6 --
 .../drm/amd/display/dc/dml/display_mode_lib.h  |  2 --
 drivers/gpu/drm/amd/display/dc/gpio/Makefile   |  5 +++--
 .../display/dc/gpio/dcn21/hw_factory_dcn21.h   |  2 --
 .../display/dc/gpio/dcn21/hw_translate_dcn21.h |  2 --
 .../gpu/drm/amd/display/dc/gpio/hw_factory.c   |  4 
 .../gpu/drm/amd/display/dc/gpio/hw_translate.c |  4 
 .../gpu/drm/amd/display/dc/inc/core_types.h|  4 
 .../gpu/drm/amd/display/dc/inc/hw/clk_mgr.h|  6 --
 .../gpu/drm/amd/display/dc/inc/hw/mem_input.h  |  2 --
 .../gpu/drm/amd/display/dc/inc/hw_sequencer.h  |  2 --
 drivers/gpu/drm/amd/display/dc/irq/Makefile|  2 --
 .../gpu/drm/amd/display/include/dal_asic_id.h  |  2 --
 .../gpu/drm/amd/display/include/dal_types.h|  2 --
 35 files changed, 4 insertions(+), 148 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/Kconfig 
b/drivers/gpu/drm/amd/display/Kconfig
index 0b4c71dc0447..b5a9bfe8998c 100644
--- a/drivers/gpu/drm/amd/display/Kconfig
+++ b/drivers/gpu/drm/amd/display/Kconfig
@@ -15,23 +15,7 @@ config DRM_AMD_DC
 config DRM_AMD_DC_DCN1_0
def_bool n
help
- RV and NV family support for display engine
-
-config DRM_AMD_DC_DCN2_1
-   bool "DCN 2.1 family"
-   depends on DRM_AMD_DC && X86
-   help
- Choose this option if you want to have
- Renoir support for display engine
-
-config DRM_AMD_DC_DSC_SUPPORT
-   bool "DSC support"
-   default y
-   depends on DRM_AMD_DC && X86
-   depends on DRM_AMD_DC_DCN1_0
-   help
- Choose this option if you want to have
- Dynamic Stream Compression support
+ Raven, Navi and Renoir family support for display engine
 
 config DRM_AMD_DC_HDCP
bool "Enable HDCP support in DC"
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index b0005313e9a9..441ad43ce9a9 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -2460,9 +2460,7 @@ static int amdgpu_dm_initialize_drm_device(struct 
amdgpu_device *adev)
case CHIP_NAVI12:
case CHIP_NAVI10:
case CHIP_NAVI14:
-#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
case CHIP_RENOIR:
-#endif
if (dcn10_register_irq_handlers(dm->adev)) {
DRM_ERROR("DM: Failed to initialize IRQ\n");
goto fail;
@@ -2699,13 +2697,11 @@ static int dm_early_init(void *handle)
adev->mode_info.num_hpd = 5;
adev->mode_info.num_dig = 5;
break;
-#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
case CHIP_RENOIR:
adev->mode_info.num_crtc = 4;
adev->mode_info.num_hpd = 4;
adev

[PATCH 3/3] drm/amd/display: rename DCN1_0 kconfig to DCN

2019-11-01 Thread Bhawanpreet Lakha
Since dcn20 and dcn21 are under dcn1 it doesnt make sense to
have it named dcn1.

Change it to "dcn" to make it generic

Signed-off-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/Kconfig   |  4 ++--
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  8 
 drivers/gpu/drm/amd/display/dc/Makefile   |  4 ++--
 .../display/dc/bios/command_table_helper2.c   |  2 +-
 drivers/gpu/drm/amd/display/dc/calcs/Makefile |  2 +-
 .../gpu/drm/amd/display/dc/clk_mgr/Makefile   |  2 +-
 .../gpu/drm/amd/display/dc/clk_mgr/clk_mgr.c  |  2 +-
 drivers/gpu/drm/amd/display/dc/core/dc.c  |  8 
 .../gpu/drm/amd/display/dc/core/dc_debug.c|  2 +-
 drivers/gpu/drm/amd/display/dc/core/dc_link.c |  2 +-
 .../gpu/drm/amd/display/dc/core/dc_resource.c | 12 +--
 .../gpu/drm/amd/display/dc/core/dc_stream.c   |  4 ++--
 drivers/gpu/drm/amd/display/dc/dc.h   |  2 +-
 .../drm/amd/display/dc/dce/dce_clock_source.c |  2 +-
 .../drm/amd/display/dc/dce/dce_clock_source.h |  2 +-
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c | 10 +-
 .../amd/display/dc/dce/dce_stream_encoder.c   | 20 +--
 .../display/dc/dce110/dce110_hw_sequencer.c   |  2 +-
 .../gpu/drm/amd/display/dc/dcn10/dcn10_dwb.c  |  2 +-
 .../gpu/drm/amd/display/dc/dcn10/dcn10_dwb.h  |  2 +-
 drivers/gpu/drm/amd/display/dc/dml/Makefile   |  4 ++--
 drivers/gpu/drm/amd/display/dc/gpio/Makefile  |  2 +-
 .../gpu/drm/amd/display/dc/gpio/hw_factory.c  |  4 ++--
 .../drm/amd/display/dc/gpio/hw_translate.c|  4 ++--
 .../gpu/drm/amd/display/dc/inc/core_types.h   |  6 +++---
 drivers/gpu/drm/amd/display/dc/inc/hw/dwb.h   |  2 +-
 drivers/gpu/drm/amd/display/dc/irq/Makefile   |  2 +-
 .../gpu/drm/amd/display/dc/irq/irq_service.c  |  2 +-
 drivers/gpu/drm/amd/display/dc/os_types.h |  2 +-
 29 files changed, 61 insertions(+), 61 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/Kconfig 
b/drivers/gpu/drm/amd/display/Kconfig
index b5a9bfe8998c..78f40690a109 100644
--- a/drivers/gpu/drm/amd/display/Kconfig
+++ b/drivers/gpu/drm/amd/display/Kconfig
@@ -6,13 +6,13 @@ config DRM_AMD_DC
bool "AMD DC - Enable new display engine"
default y
select SND_HDA_COMPONENT if SND_HDA_CORE
-   select DRM_AMD_DC_DCN1_0 if X86 && !(KCOV_INSTRUMENT_ALL && 
KCOV_ENABLE_COMPARISONS)
+   select DRM_AMD_DC_DCN if X86 && !(KCOV_INSTRUMENT_ALL && 
KCOV_ENABLE_COMPARISONS)
help
  Choose this option if you want to use the new display engine
  support for AMDGPU. This adds required support for Vega and
  Raven ASICs.
 
-config DRM_AMD_DC_DCN1_0
+config DRM_AMD_DC_DCN
def_bool n
help
  Raven, Navi and Renoir family support for display engine
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 441ad43ce9a9..72e7a1245bd8 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -72,7 +72,7 @@
 #include 
 #include 
 
-#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
+#if defined(CONFIG_DRM_AMD_DC_DCN)
 #include "ivsrcid/dcn/irqsrcs_dcn_1_0.h"
 
 #include "dcn/dcn_1_0_offset.h"
@@ -1866,7 +1866,7 @@ static int dce110_register_irq_handlers(struct 
amdgpu_device *adev)
return 0;
 }
 
-#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
+#if defined(CONFIG_DRM_AMD_DC_DCN)
 /* Register IRQ sources and initialize IRQ callbacks */
 static int dcn10_register_irq_handlers(struct amdgpu_device *adev)
 {
@@ -2455,7 +2455,7 @@ static int amdgpu_dm_initialize_drm_device(struct 
amdgpu_device *adev)
goto fail;
}
break;
-#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
+#if defined(CONFIG_DRM_AMD_DC_DCN)
case CHIP_RAVEN:
case CHIP_NAVI12:
case CHIP_NAVI10:
@@ -2679,7 +2679,7 @@ static int dm_early_init(void *handle)
adev->mode_info.num_hpd = 6;
adev->mode_info.num_dig = 6;
break;
-#if defined(CONFIG_DRM_AMD_DC_DCN1_0)
+#if defined(CONFIG_DRM_AMD_DC_DCN)
case CHIP_RAVEN:
adev->mode_info.num_crtc = 4;
adev->mode_info.num_hpd = 4;
diff --git a/drivers/gpu/drm/amd/display/dc/Makefile 
b/drivers/gpu/drm/amd/display/dc/Makefile
index 1feba4190284..ee9b83e5c51a 100644
--- a/drivers/gpu/drm/amd/display/dc/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/Makefile
@@ -25,7 +25,7 @@
 
 DC_LIBS = basics bios calcs clk_mgr dce gpio irq virtual
 
-ifdef CONFIG_DRM_AMD_DC_DCN1_0
+ifdef CONFIG_DRM_AMD_DC_DCN
 DC_LIBS += dcn20
 DC_LIBS += dsc
 DC_LIBS += dcn10 dml
@@ -50,7 +50,7 @@ include $(AMD_DC)
 DISPLAY_CORE = dc.o dc_link.o dc_resource.o dc_hw_sequencer.o dc_sink.o \
 dc_surface.o dc_link_hwss.o dc_link_dp.o dc_link_ddc.o dc_debug.o dc_stream.o
 
-ifdef CONFIG_DRM_AMD_DC_DCN1_0
+ifdef CONFIG_DRM_AMD_DC_DCN
 DISP

[PATCH 19/20] drm/amd/display: use previous aux timeout val if no repeater.

2019-10-31 Thread Bhawanpreet Lakha
From: abdoulaye berthe 

[Why]
The aux timeout value is not default before reading link cap.
Setting it to default when lttpr is not enabled causes some monitor
not to light up.

[How]
Read the aux engine timeout value before setting it to extended.
Set the aux engine timeout to its previous value if no lttpr.

Signed-off-by: abdoulaye berthe 
Reviewed-by: Aric Cyr 
---
 .../gpu/drm/amd/display/dc/core/dc_link_ddc.c | 13 +++---
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  |  9 ++--
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c  | 46 +++
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.h  |  2 +-
 .../gpu/drm/amd/display/dc/inc/dc_link_ddc.h  |  2 +-
 .../gpu/drm/amd/display/dc/inc/dc_link_dp.h   |  2 +-
 6 files changed, 52 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
index a2e6adacaff6..c8037af93e0a 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
@@ -650,17 +650,16 @@ bool dc_link_aux_transfer_with_retries(struct ddc_service 
*ddc,
 }
 
 
-enum dc_status dc_link_aux_configure_timeout(struct ddc_service *ddc,
+uint32_t dc_link_aux_configure_timeout(struct ddc_service *ddc,
uint32_t timeout)
 {
-   enum dc_status status = DC_OK;
+   uint32_t prev_timeout = 0;
struct ddc *ddc_pin = ddc->ddc_pin;
 
-   if 
(ddc->ctx->dc->res_pool->engines[ddc_pin->pin_data->en]->funcs->configure_timeout
 == NULL)
-   return DC_ERROR_UNEXPECTED;
-   if 
(!ddc->ctx->dc->res_pool->engines[ddc_pin->pin_data->en]->funcs->configure_timeout(ddc,
 timeout))
-   status = DC_ERROR_UNEXPECTED;
-   return status;
+   if 
(ddc->ctx->dc->res_pool->engines[ddc_pin->pin_data->en]->funcs->configure_timeout)
+   prev_timeout =
+   
ddc->ctx->dc->res_pool->engines[ddc_pin->pin_data->en]->funcs->configure_timeout(ddc,
 timeout);
+   return prev_timeout;
 }
 
 /*test only function*/
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index 11b6e14b345e..6e1f00ab6646 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -2977,6 +2977,7 @@ static bool retrieve_link_cap(struct dc_link *link)
union dp_downstream_port_present ds_port = { 0 };
enum dc_status status = DC_ERROR_UNEXPECTED;
uint32_t read_dpcd_retry_cnt = 3;
+   uint32_t prev_timeout_val;
int i;
struct dp_sink_hw_fw_revision dp_hw_fw_revision;
 
@@ -2987,7 +2988,9 @@ static bool retrieve_link_cap(struct dc_link *link)
link->is_lttpr_mode_transparent = true;
 
if (ext_timeout_support) {
-   status = dc_link_aux_configure_timeout(link->ddc, 
LINK_AUX_DEFAULT_EXTENDED_TIMEOUT_PERIOD);
+   prev_timeout_val =
+   dc_link_aux_configure_timeout(link->ddc,
+   
LINK_AUX_DEFAULT_EXTENDED_TIMEOUT_PERIOD);
}
 
memset(dpcd_data, '\0', sizeof(dpcd_data));
@@ -3022,7 +3025,7 @@ static bool retrieve_link_cap(struct dc_link *link)
return false;
}
 
-   if (ext_timeout_support && link->dpcd_caps.dpcd_rev.raw >= 0x14) {
+   if (ext_timeout_support) {
status = core_link_read_dpcd(
link,
DP_PHY_REPEATER_CNT,
@@ -3063,7 +3066,7 @@ static bool retrieve_link_cap(struct dc_link *link)

>dpcd_caps.lttpr_caps.max_ext_timeout,

sizeof(link->dpcd_caps.lttpr_caps.max_ext_timeout));
} else {
-   dc_link_aux_configure_timeout(link->ddc, 
LINK_AUX_DEFAULT_TIMEOUT_PERIOD);
+   dc_link_aux_configure_timeout(link->ddc, 
prev_timeout_val);
}
}
 
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c 
b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
index e472608faf33..f7626cd70ec8 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
@@ -60,12 +60,14 @@ enum {
AUX_DEFER_RETRY_COUNTER = 6
 };
 
-#define TIME_OUT_INCREMENT  1016
-#define TIME_OUT_MULTIPLIER_8  8
-#define TIME_OUT_MULTIPLIER_16  16
-#define TIME_OUT_MULTIPLIER_32  32
-#define TIME_OUT_MULTIPLIER_64  64
-#define MAX_TIMEOUT_LENGTH  127
+#define TIME_OUT_INCREMENT1016
+#define TIME_OUT_MULTIPLIER_8 8
+#define TIME_OUT_MULTIPLIER_1616
+#define TIME_OUT_MULTIPLIER_3232
+#define TIME_OUT_MULTIPLIER_6464
+#define MAX_TIMEOUT_LENGTH127
+#define DEFAULT_AUX_ENGINE_MULT   0
+#define DEFAULT_AUX_ENGINE_LENGTH 69
 
 static void release_engine(
struct dce_aux *engine)
@@ -427,11 +429,14 @@ void 

[PATCH 13/20] drm/amd/display: Add PSP FW version mask.

2019-10-31 Thread Bhawanpreet Lakha
From: Yongqiang Sun 

[Why]
PSP version format is AB.CD.EF.GH, where CD and GH is the main version.
current psp version check for dmcub loading dmcu check 0x00110029, in
case of some psp version eg: 0x00110227 which main version should be
0x00110027, will result in unexpeceted dmcub loading dmcu FW.

[How]
Add psp version mask 0x00FF00FF for checking version.

Signed-off-by: Yongqiang Sun 
Reviewed-by: Tony Cheng 
Acked-by: Bhawanpreet Lakha 
Acked-by: Nicholas Kazlauskas 
---
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c 
b/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c
index 3417100d51e4..3276944e6997 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c
@@ -886,7 +886,7 @@ static void dcn21_dmcu_construct(
 
if (!IS_FPGA_MAXIMUS_DC(ctx->dce_environment)) {
psp_version = dm_read_reg(ctx, mmMP0_SMN_C2PMSG_58);
-   dmcu_dce->base.auto_load_dmcu = (psp_version > 0x00110029);
+   dmcu_dce->base.auto_load_dmcu = ((psp_version & 0x00FF00FF) > 
0x00110029);
dmcu_dce->base.psp_version = psp_version;
}
 }
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 03/20] drm/amd/display: Fix assert observed when performing dummy p-state check

2019-10-31 Thread Bhawanpreet Lakha
From: David Galiffi 

[WHY]
V.Active dram clock change workaround need a small modification for DMLv2
to ensure that the dummy p-state check doesn't fail.

Signed-off-by: David Galiffi 
Reviewed-by: Jun Lei 
Acked-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c  | 4 
 drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.c | 2 ++
 drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.h | 1 +
 3 files changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c
index 3c70dd577292..d63ca4ccf7cf 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c
@@ -2611,9 +2611,13 @@ static void 
dml20v2_DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndP
mode_lib->vba.MinActiveDRAMClockChangeMargin
+ mode_lib->vba.DRAMClockChangeLatency;
 
+
if (mode_lib->vba.MinActiveDRAMClockChangeMargin > 50) {
mode_lib->vba.DRAMClockChangeWatermark += 25;
mode_lib->vba.DRAMClockChangeSupport[0][0] = 
dm_dram_clock_change_vactive;
+   } else if (mode_lib->vba.DummyPStateCheck &&
+   mode_lib->vba.MinActiveDRAMClockChangeMargin > 
0) {
+   mode_lib->vba.DRAMClockChangeSupport[0][0] = 
dm_dram_clock_change_vactive;
} else {
if (mode_lib->vba.SynchronizedVBlank || 
mode_lib->vba.NumberOfActivePlanes == 1) {
mode_lib->vba.DRAMClockChangeSupport[0][0] = 
dm_dram_clock_change_vblank;
diff --git a/drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.c 
b/drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.c
index 7f9a5621922f..81db8517a690 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.c
@@ -222,6 +222,8 @@ static void fetch_socbb_params(struct display_mode_lib 
*mode_lib)
mode_lib->vba.SRExitTime = soc->sr_exit_time_us;
mode_lib->vba.SREnterPlusExitTime = soc->sr_enter_plus_exit_time_us;
mode_lib->vba.DRAMClockChangeLatency = 
soc->dram_clock_change_latency_us;
+   mode_lib->vba.DummyPStateCheck = soc->dram_clock_change_latency_us == 
soc->dummy_pstate_latency_us;
+
mode_lib->vba.Downspreading = soc->downspread_percent;
mode_lib->vba.DRAMChannelWidth = soc->dram_channel_width_bytes;   // 
new!
mode_lib->vba.FabricDatapathToDCNDataReturn = 
soc->fabric_datapath_to_dcn_data_return_bytes; // new!
diff --git a/drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.h 
b/drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.h
index 1540ffbe3979..6c59a332093a 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.h
+++ b/drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.h
@@ -155,6 +155,7 @@ struct vba_vars_st {
double UrgentLatencySupportUsChroma;
unsigned int DSCFormatFactor;
 
+   bool DummyPStateCheck;
bool PrefetchModeSupported;
enum self_refresh_affinity 
AllowDRAMSelfRefreshOrDRAMClockChangeInVblank; // Mode Support only
double XFCRemoteSurfaceFlipDelay;
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 01/20] drm/amd/display: 3.2.57

2019-10-31 Thread Bhawanpreet Lakha
From: Aric Cyr 

Signed-off-by: Aric Cyr 
Reviewed-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 0416a17b0897..d931e5878b4c 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -39,7 +39,7 @@
 #include "inc/hw/dmcu.h"
 #include "dml/display_mode_lib.h"
 
-#define DC_VER "3.2.56"
+#define DC_VER "3.2.57"
 
 #define MAX_SURFACES 3
 #define MAX_PLANES 6
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 02/20] drm/amd/display: Change dmcu init sequence for dmcub loading dmcu FW.

2019-10-31 Thread Bhawanpreet Lakha
From: Yongqiang Sun 

[Why]
DMCU isn't intiliazed properly by dmcub loading due to dmcub initialize
sequence.

[How]
Change dmcu init sequece to meet dmcub initilize.

Signed-off-by: Yongqiang Sun 
Reviewed-by: Tony Cheng 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c | 79 +++
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h | 13 +++
 .../amd/display/dc/dcn10/dcn10_hw_sequencer.c |  2 +-
 .../drm/amd/display/dc/dcn21/dcn21_resource.c |  4 +-
 drivers/gpu/drm/amd/display/dc/inc/hw/dmcu.h  |  2 +
 5 files changed, 97 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c 
b/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c
index ba995d3f2318..3417100d51e4 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c
@@ -59,6 +59,12 @@
 #define MCP_BL_SET_PWM_FRAC 0x6A  /* Enable or disable Fractional PWM */
 #define MASTER_COMM_CNTL_REG__MASTER_COMM_INTERRUPT_MASK   0x0001L
 
+// PSP FW version
+#define mmMP0_SMN_C2PMSG_580x1607A
+
+//Register access policy version
+#define mmMP0_SMN_C2PMSG_910x1609B
+
 static bool dce_dmcu_init(struct dmcu *dmcu)
 {
// Do nothing
@@ -373,6 +379,7 @@ static bool dcn10_dmcu_init(struct dmcu *dmcu)
const struct dc_config *config = >ctx->dc->config;
bool status = false;
 
+   PERF_TRACE();
/*  Definition of DC_DMCU_SCRATCH
 *  0 : firmare not loaded
 *  1 : PSP load DMCU FW but not initialized
@@ -429,9 +436,23 @@ static bool dcn10_dmcu_init(struct dmcu *dmcu)
break;
}
 
+   PERF_TRACE();
return status;
 }
 
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+static bool dcn21_dmcu_init(struct dmcu *dmcu)
+{
+   struct dce_dmcu *dmcu_dce = TO_DCE_DMCU(dmcu);
+   uint32_t dmcub_psp_version = REG_READ(DMCUB_SCRATCH15);
+
+   if (dmcu->auto_load_dmcu && dmcub_psp_version == 0) {
+   return false;
+   }
+
+   return dcn10_dmcu_init(dmcu);
+}
+#endif
 
 static bool dcn10_dmcu_load_iram(struct dmcu *dmcu,
unsigned int start_offset,
@@ -818,6 +839,21 @@ static const struct dmcu_funcs dcn20_funcs = {
 };
 #endif
 
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+static const struct dmcu_funcs dcn21_funcs = {
+   .dmcu_init = dcn21_dmcu_init,
+   .load_iram = dcn10_dmcu_load_iram,
+   .set_psr_enable = dcn10_dmcu_set_psr_enable,
+   .setup_psr = dcn10_dmcu_setup_psr,
+   .get_psr_state = dcn10_get_dmcu_psr_state,
+   .set_psr_wait_loop = dcn10_psr_wait_loop,
+   .get_psr_wait_loop = dcn10_get_psr_wait_loop,
+   .is_dmcu_initialized = dcn10_is_dmcu_initialized,
+   .lock_phy = dcn20_lock_phy,
+   .unlock_phy = dcn20_unlock_phy
+};
+#endif
+
 static void dce_dmcu_construct(
struct dce_dmcu *dmcu_dce,
struct dc_context *ctx,
@@ -836,6 +872,26 @@ static void dce_dmcu_construct(
dmcu_dce->dmcu_mask = dmcu_mask;
 }
 
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+static void dcn21_dmcu_construct(
+   struct dce_dmcu *dmcu_dce,
+   struct dc_context *ctx,
+   const struct dce_dmcu_registers *regs,
+   const struct dce_dmcu_shift *dmcu_shift,
+   const struct dce_dmcu_mask *dmcu_mask)
+{
+   uint32_t psp_version = 0;
+
+   dce_dmcu_construct(dmcu_dce, ctx, regs, dmcu_shift, dmcu_mask);
+
+   if (!IS_FPGA_MAXIMUS_DC(ctx->dce_environment)) {
+   psp_version = dm_read_reg(ctx, mmMP0_SMN_C2PMSG_58);
+   dmcu_dce->base.auto_load_dmcu = (psp_version > 0x00110029);
+   dmcu_dce->base.psp_version = psp_version;
+   }
+}
+#endif
+
 struct dmcu *dce_dmcu_create(
struct dc_context *ctx,
const struct dce_dmcu_registers *regs,
@@ -903,6 +959,29 @@ struct dmcu *dcn20_dmcu_create(
 }
 #endif
 
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+struct dmcu *dcn21_dmcu_create(
+   struct dc_context *ctx,
+   const struct dce_dmcu_registers *regs,
+   const struct dce_dmcu_shift *dmcu_shift,
+   const struct dce_dmcu_mask *dmcu_mask)
+{
+   struct dce_dmcu *dmcu_dce = kzalloc(sizeof(*dmcu_dce), GFP_KERNEL);
+
+   if (dmcu_dce == NULL) {
+   BREAK_TO_DEBUGGER();
+   return NULL;
+   }
+
+   dcn21_dmcu_construct(
+   dmcu_dce, ctx, regs, dmcu_shift, dmcu_mask);
+
+   dmcu_dce->base.funcs = _funcs;
+
+   return _dce->base;
+}
+#endif
+
 void dce_dmcu_destroy(struct dmcu **dmcu)
 {
struct dce_dmcu *dmcu_dce = TO_DCE_DMCU(*dmcu);
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h 
b/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h
index cc8587683b4b..1a42b2cbb21b 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h
@@ -71,6 +71,10 @@
DMCU_COMMON_REG_LIST_

[PATCH 09/20] drm/amd/display: optimize bandwidth after commit streams.

2019-10-31 Thread Bhawanpreet Lakha
From: Yongqiang Sun 

[Why]
System is unable to enter S0i3 due to DISPLAY_OFF_MASK not asserted
in SMU.

[How]
Optimized bandwidth should be called paired and to resolve unplug
display underflow issue, optimize bandwidth after commit streams is
moved to next page flip, in case of S0i3, there is a change for no
flip coming causing display count is 1 in SMU side.
Add optimize bandwidth after commit stream.

Signed-off-by: Yongqiang Sun 
Reviewed-by: Tony Cheng 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 32f31bf91915..b26ed07c2d2c 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1245,6 +1245,10 @@ static enum dc_status dc_commit_state_no_check(struct dc 
*dc, struct dc_state *c
 
dc_enable_stereo(dc, context, dc_streams, context->stream_count);
 
+   if (!dc->optimize_seamless_boot)
+   /* pplib is notified if disp_num changed */
+   dc->hwss.optimize_bandwidth(dc, context);
+
for (i = 0; i < context->stream_count; i++)
context->streams[i]->mode_changed = false;
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 18/20] drm/amd/display: implement lttpr logic

2019-10-31 Thread Bhawanpreet Lakha
From: abdoulaye berthe 

1-If at least one repeater is present in the link and we are in non
transparent mode, perform clock recovery then channel equalization
with all repeaters one by one before training DPRX.

2-Mark the end of LT with a repeater by setting training pattern 0
at the end of channel equalization with each repeater.

Signed-off-by: abdoulaye berthe 
Reviewed-by: Aric Cyr 
---
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  | 319 ++
 .../drm/amd/display/dc/core/dc_link_hwss.c|  39 ++-
 .../gpu/drm/amd/display/dc/inc/link_hwss.h|   6 +-
 3 files changed, 292 insertions(+), 72 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index 94d5a0ac308f..11b6e14b345e 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -22,7 +22,7 @@
link->ctx->logger
 
 
-#define DP_REPEATER_CONFIGURATION_AND_STATUS_OFFSET   0x50
+#define DP_REPEATER_CONFIGURATION_AND_STATUS_SIZE   0x50
 
 /* maximum pre emphasis level allowed for each voltage swing level*/
 static const enum dc_pre_emphasis voltage_swing_to_pre_emphasis[] = {
@@ -224,19 +224,31 @@ static enum dpcd_training_patterns
return dpcd_tr_pattern;
 }
 
+static inline bool is_repeater(struct dc_link *link, uint32_t offset)
+{
+   return (!link->is_lttpr_mode_transparent && offset != 0);
+}
+
 static void dpcd_set_lt_pattern_and_lane_settings(
struct dc_link *link,
const struct link_training_settings *lt_settings,
-   enum dc_dp_training_pattern pattern)
+   enum dc_dp_training_pattern pattern,
+   uint32_t offset)
 {
union dpcd_training_lane dpcd_lane[LANE_COUNT_DP_MAX] = { { {0} } };
-   const uint32_t dpcd_base_lt_offset =
-   DP_TRAINING_PATTERN_SET;
+
+   uint32_t dpcd_base_lt_offset;
+
uint8_t dpcd_lt_buffer[5] = {0};
union dpcd_training_pattern dpcd_pattern = { {0} };
uint32_t lane;
uint32_t size_in_bytes;
bool edp_workaround = false; /* TODO link_prop.INTERNAL */
+   dpcd_base_lt_offset = DP_TRAINING_PATTERN_SET;
+
+   if (is_repeater(link, offset))
+   dpcd_base_lt_offset = DP_TRAINING_PATTERN_SET_PHY_REPEATER1 +
+   ((DP_REPEATER_CONFIGURATION_AND_STATUS_SIZE) * (offset 
- 1));
 
/*
* DpcdAddress_TrainingPatternSet
@@ -244,12 +256,12 @@ static void dpcd_set_lt_pattern_and_lane_settings(
dpcd_pattern.v1_4.TRAINING_PATTERN_SET =
dc_dp_training_pattern_to_dpcd_training_pattern(link, pattern);
 
-   dpcd_lt_buffer[DP_TRAINING_PATTERN_SET - dpcd_base_lt_offset]
+   dpcd_lt_buffer[DP_TRAINING_PATTERN_SET - DP_TRAINING_PATTERN_SET]
= dpcd_pattern.raw;
 
-   DC_LOG_HW_LINK_TRAINING("%s\n %x pattern = %x\n",
+   DC_LOG_HW_LINK_TRAINING("%s\n 0x%X pattern = %x\n",
__func__,
-   DP_TRAINING_PATTERN_SET,
+   dpcd_base_lt_offset,
dpcd_pattern.v1_4.TRAINING_PATTERN_SET);
 
/*
@@ -271,19 +283,19 @@ static void dpcd_set_lt_pattern_and_lane_settings(
PRE_EMPHASIS_MAX_LEVEL ? 1 : 0);
}
 
-   /* concatinate everything into one buffer*/
+   /* concatenate everything into one buffer*/
 
size_in_bytes = lt_settings->link_settings.lane_count * 
sizeof(dpcd_lane[0]);
 
 // 0x00103 - 0x00102
memmove(
-   _lt_buffer[DP_TRAINING_LANE0_SET - dpcd_base_lt_offset],
+   _lt_buffer[DP_TRAINING_LANE0_SET - 
DP_TRAINING_PATTERN_SET],
dpcd_lane,
size_in_bytes);
 
-   DC_LOG_HW_LINK_TRAINING("%s:\n %x VS set = %x  PE set = %x max VS 
Reached = %x  max PE Reached = %x\n",
+   DC_LOG_HW_LINK_TRAINING("%s:\n 0x%X VS set = %x  PE set = %x max VS 
Reached = %x  max PE Reached = %x\n",
__func__,
-   DP_TRAINING_LANE0_SET,
+   dpcd_base_lt_offset,
dpcd_lane[0].bits.VOLTAGE_SWING_SET,
dpcd_lane[0].bits.PRE_EMPHASIS_SET,
dpcd_lane[0].bits.MAX_SWING_REACHED,
@@ -498,8 +510,12 @@ static void get_lane_status_and_drive_settings(
const struct link_training_settings *link_training_setting,
union lane_status *ln_status,
union lane_align_status_updated *ln_status_updated,
-   struct link_training_settings *req_settings)
+   struct link_training_settings *req_settings,
+   uint32_t offset)
 {
+   unsigned int lane01_status_address = DP_LANE0_1_STATUS;
+   uint8_t lane_adjust_offset = 4;
+   unsigned int lane01_adjust_address;
uint8_t dpcd_buf[6] = {0};
union lane_adjust dpcd_lane_adjust[LANE_COUNT_DP_MAX] = { { {0} } };
struct link_training_settings 

[PATCH 14/20] drm/amd/display: Unify all scaling when Integer Scaling enabled

2019-10-31 Thread Bhawanpreet Lakha
From: Reza Amini 

[why]
We want to guarantee integer ratio scaling for all scaling modes.

[how]
Treat centered, fullscreen, preserve aspect ratio the same: scale
the view as many times as possible, and fill in the rest with a black
border.

Signed-off-by: Reza Amini 
Reviewed-by: Aric Cyr 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c  |  8 +--
 .../gpu/drm/amd/display/dc/core/dc_resource.c | 21 ---
 drivers/gpu/drm/amd/display/dc/dc_stream.h|  1 +
 3 files changed, 11 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index b3366ccc29c3..6d650a0ecbb9 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1551,7 +1551,10 @@ static enum surface_update_type 
get_scaling_info_update_type(
if (u->scaling_info->clip_rect.width != u->surface->clip_rect.width
|| u->scaling_info->clip_rect.height != 
u->surface->clip_rect.height
|| u->scaling_info->dst_rect.width != 
u->surface->dst_rect.width
-   || u->scaling_info->dst_rect.height != 
u->surface->dst_rect.height) {
+   || u->scaling_info->dst_rect.height != 
u->surface->dst_rect.height
+   || u->scaling_info->scaling_quality.integer_scaling !=
+   u->surface->scaling_quality.integer_scaling
+   ) {
update_flags->bits.scaling_change = 1;
 
if ((u->scaling_info->dst_rect.width < 
u->surface->dst_rect.width
@@ -1672,7 +1675,8 @@ static enum surface_update_type 
check_update_surfaces_for_stream(
union stream_update_flags *su_flags = 
_update->stream->update_flags;
 
if ((stream_update->src.height != 0 && stream_update->src.width 
!= 0) ||
-   (stream_update->dst.height != 0 && 
stream_update->dst.width != 0))
+   (stream_update->dst.height != 0 && 
stream_update->dst.width != 0) ||
+   stream_update->integer_scaling_update)
su_flags->bits.scaling = 1;
 
if (stream_update->out_transfer_func)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
index 37698305a2dc..30f5434fa8e9 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -951,25 +951,14 @@ static void calculate_inits_and_adj_vp(struct pipe_ctx 
*pipe_ctx)
data->inits.v_c_bot = dc_fixpt_add(data->inits.v_c, 
data->ratios.vert_c);
 
 }
-static bool are_rects_integer_multiples(struct rect src, struct rect dest)
-{
-   if (dest.width  >= src.width  && dest.width  % src.width  == 0 &&
-   dest.height >= src.height && dest.height % src.height == 0)
-   return true;
-
-   return false;
-}
 
 static void calculate_integer_scaling(struct pipe_ctx *pipe_ctx)
 {
-   if (!pipe_ctx->plane_state->scaling_quality.integer_scaling)
-   return;
+   unsigned int integer_multiple = 1;
 
-   //for Centered Mode
-   if (pipe_ctx->stream->dst.width  == pipe_ctx->stream->src.width &&
-   pipe_ctx->stream->dst.height == pipe_ctx->stream->src.height) {
+   if (pipe_ctx->plane_state->scaling_quality.integer_scaling) {
// calculate maximum # of replication of src onto addressable
-   unsigned int integer_multiple = min(
+   integer_multiple = min(
pipe_ctx->stream->timing.h_addressable / 
pipe_ctx->stream->src.width,
pipe_ctx->stream->timing.v_addressable  / 
pipe_ctx->stream->src.height);
 
@@ -980,10 +969,8 @@ static void calculate_integer_scaling(struct pipe_ctx 
*pipe_ctx)
//center dst onto addressable
pipe_ctx->stream->dst.x = 
(pipe_ctx->stream->timing.h_addressable - pipe_ctx->stream->dst.width)/2;
pipe_ctx->stream->dst.y = 
(pipe_ctx->stream->timing.v_addressable - pipe_ctx->stream->dst.height)/2;
-   }
 
-   //disable taps if src & dst are integer ratio
-   if (are_rects_integer_multiples(pipe_ctx->stream->src, 
pipe_ctx->stream->dst)) {
+   //We are guaranteed that we are scaling in integer ratio
pipe_ctx->plane_state->scaling_quality.v_taps = 1;
pipe_ctx->plane_state->scaling_quality.h_taps = 1;
pipe_ctx->plane_state->scaling_quality.v_taps_c = 1;
diff --

[PATCH 17/20] drm/amd/display: configure lttpr mode

2019-10-31 Thread Bhawanpreet Lakha
From: abdoulaye berthe 

[Description]
1-Grant extended timeout request. Done once after detection
2-Configure lttpr mode based on lttpr support before LT
3-Account for lttpr cap when determining max link settings

Signed-off-by: abdoulaye berthe 
Reviewed-by: Aric Cyr 
---
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  | 42 +++
 1 file changed, 42 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index 1e4480f3bd3c..94d5a0ac308f 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -1057,6 +1057,26 @@ static void initialize_training_settings(
lt_settings->enhanced_framing = 1;
 }
 
+static void configure_lttpr_mode(struct dc_link *link)
+{
+   /* aux timeout is already set to extended */
+   /* RESET/SET lttpr mode to enable non transparent mode */
+   enum lttpr_mode repeater_mode = phy_repeater_mode_transparent;
+
+   core_link_write_dpcd(link,
+   DP_PHY_REPEATER_MODE,
+   (uint8_t *)_mode,
+   sizeof(repeater_mode));
+
+   if (!link->is_lttpr_mode_transparent) {
+   repeater_mode = phy_repeater_mode_non_transparent;
+   core_link_write_dpcd(link,
+   DP_PHY_REPEATER_MODE,
+   (uint8_t *)_mode,
+   sizeof(repeater_mode));
+   }
+}
+
 static void print_status_message(
struct dc_link *link,
const struct link_training_settings *lt_settings,
@@ -1210,6 +1230,9 @@ enum link_training_result 
dc_link_dp_perform_link_training(
dp_set_fec_ready(link, fec_enable);
 #endif
 
+   /* Configure lttpr mode */
+   if (!link->is_lttpr_mode_transparent)
+   configure_lttpr_mode(link);
 
/* 2. perform link training (set link training done
 *  to false is done as well)
@@ -1426,6 +1449,17 @@ static struct dc_link_settings get_max_link_cap(struct 
dc_link *link)
max_link_cap.link_spread)
max_link_cap.link_spread =
link->reported_link_cap.link_spread;
+   /*
+* account for lttpr repeaters cap
+* notes: repeaters do not snoop in the DPRX Capabilities addresses 
(3.6.3).
+*/
+   if (!link->is_lttpr_mode_transparent) {
+   if (link->dpcd_caps.lttpr_caps.max_lane_count < 
max_link_cap.lane_count)
+   max_link_cap.lane_count = 
link->dpcd_caps.lttpr_caps.max_lane_count;
+
+   if (link->dpcd_caps.lttpr_caps.max_link_rate < 
max_link_cap.link_rate)
+   max_link_cap.link_rate = 
link->dpcd_caps.lttpr_caps.max_link_rate;
+   }
return max_link_cap;
 }
 
@@ -1571,6 +1605,13 @@ bool dp_verify_link_cap(
 
max_link_cap = get_max_link_cap(link);
 
+   /* Grant extended timeout request */
+   if (!link->is_lttpr_mode_transparent && 
link->dpcd_caps.lttpr_caps.max_ext_timeout > 0) {
+   uint8_t grant = link->dpcd_caps.lttpr_caps.max_ext_timeout & 
0x80;
+
+   core_link_write_dpcd(link, 
DP_PHY_REPEATER_EXTENDED_WAIT_TIMEOUT, , sizeof(grant));
+   }
+
/* TODO implement override and monitor patch later */
 
/* try to train the link from high to low to
@@ -2759,6 +2800,7 @@ static bool retrieve_link_cap(struct dc_link *link)
/* Set default timeout to 3.2ms and read LTTPR capabilities */
bool ext_timeout_support = link->dc->caps.extended_aux_timeout_support 
&&
!link->dc->config.disable_extended_timeout_support;
+
link->is_lttpr_mode_transparent = true;
 
if (ext_timeout_support) {
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 00/20] DC Patches 31 Oct 2019

2019-10-31 Thread Bhawanpreet Lakha
Summary Of Changes
*configure and init lttpr
*DSC sanity check
*Bandwidth optimization
*Some assert fixes

Anthony Koo (1):
  drm/amd/display: set MSA MISC1 bit 6 while sending colorimetry in VSC
SDP

Aric Cyr (2):
  drm/amd/display: 3.2.57
  drm/amd/display: 3.2.58

David Galiffi (2):
  drm/amd/display: Fix assert observed when performing dummy p-state
check
  drm/amd/display: Create debug option to disable v.active clock change
policy.

Eric Yang (1):
  drm/amd/display: Renoir chroma viewport WA

Jun Lei (1):
  drm/amd/display: add oem i2c implemenation in dc

Leo (Hanghong) Ma (1):
  drm/amd/display: Add some hardware status in DTN log debugfs

Nikola Cornij (1):
  drm/amd/display: Add a sanity check for DSC already enabled/disabled

Reza Amini (1):
  drm/amd/display: Unify all scaling when Integer Scaling enabled

Sung Lee (1):
  drm/amd/display: Use SIGNAL_TYPE_NONE in disable_output unless eDP

Yongqiang Sun (3):
  drm/amd/display: Change dmcu init sequence for dmcub loading dmcu FW.
  drm/amd/display: optimize bandwidth after commit streams.
  drm/amd/display: Add PSP FW version mask.

abdoulaye berthe (6):
  drm/amd/display: initialize lttpr
  drm/amd/display: check for dp rev before reading lttpr regs
  drm/amd/display: configure lttpr mode
  drm/amd/display: implement lttpr logic
  drm/amd/display: use previous aux timeout val if no repeater.
  drm/amd/display: disable lttpr for invalid lttpr caps.

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |   4 +-
 .../drm/amd/display/dc/bios/bios_parser2.c|  63 ++-
 drivers/gpu/drm/amd/display/dc/core/dc.c  |  23 +-
 drivers/gpu/drm/amd/display/dc/core/dc_link.c |   1 +
 .../gpu/drm/amd/display/dc/core/dc_link_ddc.c |  18 +-
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  | 419 +++---
 .../drm/amd/display/dc/core/dc_link_hwss.c|  39 +-
 .../gpu/drm/amd/display/dc/core/dc_resource.c |  21 +-
 drivers/gpu/drm/amd/display/dc/dc.h   |   7 +-
 drivers/gpu/drm/amd/display/dc/dc_link.h  |   5 +
 drivers/gpu/drm/amd/display/dc/dc_stream.h|   2 +
 drivers/gpu/drm/amd/display/dc/dc_types.h |  25 ++
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c  |  46 +-
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.h  |   2 +-
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.c |  79 
 drivers/gpu/drm/amd/display/dc/dce/dce_dmcu.h |  13 +
 drivers/gpu/drm/amd/display/dc/dce/dce_i2c.c  |  19 +-
 .../gpu/drm/amd/display/dc/dce/dce_i2c_sw.c   |  43 --
 .../gpu/drm/amd/display/dc/dce/dce_i2c_sw.h   |   6 +-
 .../amd/display/dc/dce/dce_stream_encoder.c   |   1 +
 .../display/dc/dce110/dce110_hw_sequencer.c   |   3 +
 .../gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c |   3 +
 .../gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h |   1 +
 .../amd/display/dc/dcn10/dcn10_hw_sequencer.c |  45 +-
 .../gpu/drm/amd/display/dc/dcn10/dcn10_opp.c  |   1 +
 .../gpu/drm/amd/display/dc/dcn10/dcn10_optc.h |   1 +
 .../display/dc/dcn10/dcn10_stream_encoder.c   |   6 +-
 .../display/dc/dcn10/dcn10_stream_encoder.h   |   1 +
 .../gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c  |  25 +-
 .../amd/display/dc/dcn20/dcn20_link_encoder.c |   1 +
 .../drm/amd/display/dc/dcn20/dcn20_resource.c |  16 +
 .../display/dc/dcn20/dcn20_stream_encoder.c   |   7 +-
 .../display/dc/dcn20/dcn20_stream_encoder.h   |   1 +
 .../gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c |  65 ++-
 .../drm/amd/display/dc/dcn21/dcn21_resource.c |   5 +-
 .../dc/dml/dcn20/display_mode_vba_20.c|   3 +-
 .../dc/dml/dcn20/display_mode_vba_20v2.c  |   6 +-
 .../amd/display/dc/dml/display_mode_structs.h |   1 +
 .../drm/amd/display/dc/dml/display_mode_vba.c |   4 +
 .../drm/amd/display/dc/dml/display_mode_vba.h |   2 +
 .../display/dc/gpio/dcn20/hw_factory_dcn20.c  |  12 +
 .../gpu/drm/amd/display/dc/inc/core_types.h   |   2 +
 .../gpu/drm/amd/display/dc/inc/dc_link_ddc.h  |   2 +-
 .../gpu/drm/amd/display/dc/inc/dc_link_dp.h   |   4 +-
 drivers/gpu/drm/amd/display/dc/inc/hw/dmcu.h  |   2 +
 .../drm/amd/display/dc/inc/hw/link_encoder.h  |   1 +
 .../amd/display/dc/inc/hw/stream_encoder.h|   1 +
 .../gpu/drm/amd/display/dc/inc/link_hwss.h|   6 +-
 .../dc/virtual/virtual_stream_encoder.c   |   1 +
 .../display/include/grph_object_ctrl_defs.h   |   3 +-
 .../amd/display/modules/inc/mod_info_packet.h |   4 +-
 .../display/modules/info_packet/info_packet.c |  46 +-
 52 files changed, 884 insertions(+), 233 deletions(-)

-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 10/20] drm/amd/display: 3.2.58

2019-10-31 Thread Bhawanpreet Lakha
From: Aric Cyr 

Signed-off-by: Aric Cyr 
Reviewed-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 7bf0241999c7..32eafff6b043 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -39,7 +39,7 @@
 #include "inc/hw/dmcu.h"
 #include "dml/display_mode_lib.h"
 
-#define DC_VER "3.2.57"
+#define DC_VER "3.2.58"
 
 #define MAX_SURFACES 3
 #define MAX_PLANES 6
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 11/20] drm/amd/display: Add some hardware status in DTN log debugfs

2019-10-31 Thread Bhawanpreet Lakha
From: "Leo (Hanghong) Ma" 

[Why]
For debug purpose, we need to check the following hardware status
in DTN log debugfs:
1.dpp & hubp clock enable;
2.crtc blank enable;
3.link phy status;

[How]
Add the upper information in the amdgpu_dm_dtn_log debugfs.

For CRTC blanked status, since DCN2 and greater reports it on the OPP
instead of OTG, we patch it in after calling optc1_read_otg_states.
Ideally, this should be done in the DCN version specific function hooks.
It has been left as a TODO item.

Signed-off-by: Leo (Hanghong) Ma 
Reviewed-by: Mikita Lipski 
Acked-by: Bhawanpreet Lakha 
Acked-by: Harry Wentland 
---
 .../gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c |  3 ++
 .../gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h |  1 +
 .../amd/display/dc/dcn10/dcn10_hw_sequencer.c | 43 +--
 .../gpu/drm/amd/display/dc/dcn10/dcn10_opp.c  |  1 +
 .../gpu/drm/amd/display/dc/dcn10/dcn10_optc.h |  1 +
 .../amd/display/dc/dcn20/dcn20_link_encoder.c |  1 +
 .../drm/amd/display/dc/inc/hw/link_encoder.h  |  1 +
 7 files changed, 37 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c
index 14d1be6c66e6..5aeee938605a 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.c
@@ -1014,6 +1014,9 @@ void hubp1_read_state_common(struct hubp *hubp)
HUBP_TTU_DISABLE, >ttu_disable,
HUBP_UNDERFLOW_STATUS, >underflow_status);
 
+   REG_GET(HUBP_CLK_CNTL,
+   HUBP_CLOCK_ENABLE, >clock_en);
+
REG_GET(DCN_GLOBAL_TTU_CNTL,
MIN_TTU_VBLANK, >min_ttu_vblank);
 
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h
index ae70d9c0aa1d..e65e76f018e4 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hubp.h
@@ -670,6 +670,7 @@ struct dcn_hubp_state {
uint32_t sw_mode;
uint32_t dcc_en;
uint32_t blank_en;
+   uint32_t clock_en;
uint32_t underflow_status;
uint32_t ttu_disable;
uint32_t min_ttu_vblank;
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
index 32844cd50d09..0a30d97b2656 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
@@ -129,9 +129,8 @@ static void dcn10_log_hubp_states(struct dc *dc, void 
*log_ctx)
struct resource_pool *pool = dc->res_pool;
int i;
 
-   DTN_INFO("HUBP:  format  addr_hi  width  height"
-   "  rot  mir  sw_mode  dcc_en  blank_en  ttu_dis  
underflow"
-   "   min_ttu_vblank   qos_low_wm  
qos_high_wm\n");
+   DTN_INFO(
+   "HUBP:  format  addr_hi  width  height  rot  mir  sw_mode  
dcc_en  blank_en  clock_en  ttu_dis  underflow   min_ttu_vblank   
qos_low_wm  qos_high_wm\n");
for (i = 0; i < pool->pipe_count; i++) {
struct hubp *hubp = pool->hubps[i];
struct dcn_hubp_state *s = &(TO_DCN10_HUBP(hubp)->state);
@@ -139,8 +138,7 @@ static void dcn10_log_hubp_states(struct dc *dc, void 
*log_ctx)
hubp->funcs->hubp_read_state(hubp);
 
if (!s->blank_en) {
-   DTN_INFO("[%2d]:  %5xh  %6xh  %5d  %6d  %2xh  %2xh  
%6xh"
-   "  %6d  %8d  %7d  %8xh",
+   DTN_INFO("[%2d]:  %5xh  %6xh  %5d  %6d  %2xh  %2xh  
%6xh  %6d  %8d  %8d  %7d  %8xh",
hubp->inst,
s->pixel_format,
s->inuse_addr_hi,
@@ -151,6 +149,7 @@ static void dcn10_log_hubp_states(struct dc *dc, void 
*log_ctx)
s->sw_mode,
s->dcc_en,
s->blank_en,
+   s->clock_en,
s->ttu_disable,
s->underflow_status);
DTN_INFO_MICRO_SEC(s->min_ttu_vblank);
@@ -308,21 +307,35 @@ void dcn10_log_hw_state(struct dc *dc,
}
DTN_INFO("\n");
 
-   DTN_INFO("OTG:  v_bs  v_be  v_ss  v_se  vpol  vmax  vmin  vmax_sel  
vmin_sel"
-   "  h_bs  h_be  h_ss  h_se  hpol  htot  vtot  
underflow\n");
+   DTN_INFO("OTG:  v_bs  v_be  v_ss  v_se  vpol  vmax  vmin  vmax_sel  
vmin_sel  h_bs  h_be  h_ss  h_se  hpol  htot  vtot  underflow blank_en\n");
 
for (i = 0;

[PATCH 12/20] drm/amd/display: add oem i2c implemenation in dc

2019-10-31 Thread Bhawanpreet Lakha
From: Jun Lei 

[why]
Need it for some OEM I2C devices in Nv10

[how]
Link up code to parse OEM table and expose DC interface
to access the pins

Signed-off-by: Jun Lei 
Reviewed-by: Aric Cyr 
Acked-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/bios/bios_parser2.c| 63 ---
 drivers/gpu/drm/amd/display/dc/core/dc.c  | 11 
 .../gpu/drm/amd/display/dc/core/dc_link_ddc.c |  5 +-
 drivers/gpu/drm/amd/display/dc/dc_link.h  |  4 ++
 drivers/gpu/drm/amd/display/dc/dce/dce_i2c.c  | 19 +++---
 .../gpu/drm/amd/display/dc/dce/dce_i2c_sw.c   | 43 -
 .../gpu/drm/amd/display/dc/dce/dce_i2c_sw.h   |  6 +-
 .../drm/amd/display/dc/dcn20/dcn20_resource.c | 15 +
 .../display/dc/gpio/dcn20/hw_factory_dcn20.c  | 12 
 .../gpu/drm/amd/display/dc/inc/core_types.h   |  2 +
 .../display/include/grph_object_ctrl_defs.h   |  3 +-
 11 files changed, 100 insertions(+), 83 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c 
b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
index 7873abea4112..05be2c0c25d1 100644
--- a/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
+++ b/drivers/gpu/drm/amd/display/dc/bios/bios_parser2.c
@@ -294,11 +294,21 @@ static enum bp_result bios_parser_get_i2c_info(struct 
dc_bios *dcb,
struct atom_display_object_path_v2 *object;
struct atom_common_record_header *header;
struct atom_i2c_record *record;
+   struct atom_i2c_record dummy_record = {0};
struct bios_parser *bp = BP_FROM_DCB(dcb);
 
if (!info)
return BP_RESULT_BADINPUT;
 
+   if (id.type == OBJECT_TYPE_GENERIC) {
+   dummy_record.i2c_id = id.id;
+
+   if (get_gpio_i2c_info(bp, _record, info) == BP_RESULT_OK)
+   return BP_RESULT_OK;
+   else
+   return BP_RESULT_NORECORD;
+   }
+
object = get_bios_object(bp, id);
 
if (!object)
@@ -341,6 +351,7 @@ static enum bp_result get_gpio_i2c_info(
struct atom_gpio_pin_lut_v2_1 *header;
uint32_t count = 0;
unsigned int table_index = 0;
+   bool find_valid = false;
 
if (!info)
return BP_RESULT_BADINPUT;
@@ -368,33 +379,28 @@ static enum bp_result get_gpio_i2c_info(
- sizeof(struct atom_common_table_header))
/ sizeof(struct atom_gpio_pin_assignment);
 
-   table_index = record->i2c_id  & I2C_HW_LANE_MUX;
-
-   if (count < table_index) {
-   bool find_valid = false;
-
-   for (table_index = 0; table_index < count; table_index++) {
-   if (((record->i2c_id & I2C_HW_CAP) == (
-   header->gpio_pin[table_index].gpio_id &
-   I2C_HW_CAP)) &&
-   ((record->i2c_id & I2C_HW_ENGINE_ID_MASK)  ==
-   (header->gpio_pin[table_index].gpio_id &
-   I2C_HW_ENGINE_ID_MASK)) &&
-   ((record->i2c_id & I2C_HW_LANE_MUX) ==
-   (header->gpio_pin[table_index].gpio_id &
-   I2C_HW_LANE_MUX))) {
-   /* still valid */
-   find_valid = true;
-   break;
-   }
+   for (table_index = 0; table_index < count; table_index++) {
+   if (((record->i2c_id & I2C_HW_CAP) == (
+   header->gpio_pin[table_index].gpio_id &
+   I2C_HW_CAP)) &&
+   ((record->i2c_id & I2C_HW_ENGINE_ID_MASK)  ==
+   (header->gpio_pin[table_index].gpio_id &
+   I2C_HW_ENGINE_ID_MASK)) &&
+   ((record->i2c_id & I2C_HW_LANE_MUX) ==
+   (header->gpio_pin[table_index].gpio_id &
+   I2C_HW_LANE_MUX))) {
+   /* still valid */
+   find_valid = true;
+   break;
}
-   /* If we don't find the entry that we are looking for then
-*  we will return BP_Result_BadBiosTable.
-*/
-   if (find_valid == false)
-   return BP_RESULT_BADBIOSTABLE;
}
 
+   /* If we don't find the entry that we are looking for then
+*  we will return BP_Result_BadBiosTable.
+*/
+   if (find_valid == false)
+   return BP_RESULT_BADBIOSTABLE;
+
/* get the GPIO_I2C_INFO */
info->i2c_hw_assist = (record->i2c_id & I2C_HW_CAP) ? true : false;
info->i2c_line = record->i2c_id & I2C_HW_LANE_MUX;
@@ -1

[PATCH 04/20] drm/amd/display: Renoir chroma viewport WA

2019-10-31 Thread Bhawanpreet Lakha
From: Eric Yang 

[Why]
For unknown reason, immediate flip with host VM translation on NV12
surface will underflow on last row of PTE.

[How]
Hack chroma viewport height to make fetch one more row of PTE.
Note that this will cause hubp underflow on all video underlay
cases, but the underflow is not user visible since it is in
blank region.

Signed-off-by: Eric Yang 
Reviewed-by: Tony Cheng 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dc.h   |  2 +
 .../gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c | 65 ++-
 .../drm/amd/display/dc/dcn21/dcn21_resource.c |  1 +
 3 files changed, 67 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index d931e5878b4c..5db4477cc4b7 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -417,6 +417,8 @@ struct dc_debug_options {
bool cm_in_bypass;
 #endif
int force_clock_mode;/*every mode change.*/
+
+   bool nv12_iflip_vm_wa;
 };
 
 struct dc_debug_data {
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
index 2f5a5867e674..1ddd6ae22155 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
@@ -164,6 +164,69 @@ static void hubp21_setup(
 
 }
 
+void hubp21_set_viewport(
+   struct hubp *hubp,
+   const struct rect *viewport,
+   const struct rect *viewport_c)
+{
+   struct dcn21_hubp *hubp21 = TO_DCN21_HUBP(hubp);
+   int patched_viewport_height = 0;
+   struct dc_debug_options *debug = >ctx->dc->debug;
+
+   REG_SET_2(DCSURF_PRI_VIEWPORT_DIMENSION, 0,
+ PRI_VIEWPORT_WIDTH, viewport->width,
+ PRI_VIEWPORT_HEIGHT, viewport->height);
+
+   REG_SET_2(DCSURF_PRI_VIEWPORT_START, 0,
+ PRI_VIEWPORT_X_START, viewport->x,
+ PRI_VIEWPORT_Y_START, viewport->y);
+
+   /*for stereo*/
+   REG_SET_2(DCSURF_SEC_VIEWPORT_DIMENSION, 0,
+ SEC_VIEWPORT_WIDTH, viewport->width,
+ SEC_VIEWPORT_HEIGHT, viewport->height);
+
+   REG_SET_2(DCSURF_SEC_VIEWPORT_START, 0,
+ SEC_VIEWPORT_X_START, viewport->x,
+ SEC_VIEWPORT_Y_START, viewport->y);
+
+   /*
+*  Work around for underflow issue with NV12 + rIOMMU translation
+*  + immediate flip. This will cause hubp underflow, but will not
+*  be user visible since underflow is in blank region
+*/
+   patched_viewport_height = viewport_c->height;
+   if (viewport_c->height != 0 && debug->nv12_iflip_vm_wa) {
+   int pte_row_height = 0;
+   int pte_rows = 0;
+
+   REG_GET(DCHUBP_REQ_SIZE_CONFIG,
+   PTE_ROW_HEIGHT_LINEAR, _row_height);
+
+   pte_row_height = 1 << (pte_row_height + 3);
+   pte_rows = (viewport_c->height + pte_row_height - 1) / 
pte_row_height;
+   patched_viewport_height = pte_rows * pte_row_height + 3;
+   }
+
+
+   /* DC supports NV12 only at the moment */
+   REG_SET_2(DCSURF_PRI_VIEWPORT_DIMENSION_C, 0,
+ PRI_VIEWPORT_WIDTH_C, viewport_c->width,
+ PRI_VIEWPORT_HEIGHT_C, patched_viewport_height);
+
+   REG_SET_2(DCSURF_PRI_VIEWPORT_START_C, 0,
+ PRI_VIEWPORT_X_START_C, viewport_c->x,
+ PRI_VIEWPORT_Y_START_C, viewport_c->y);
+
+   REG_SET_2(DCSURF_SEC_VIEWPORT_DIMENSION_C, 0,
+ SEC_VIEWPORT_WIDTH_C, viewport_c->width,
+ SEC_VIEWPORT_HEIGHT_C, patched_viewport_height);
+
+   REG_SET_2(DCSURF_SEC_VIEWPORT_START_C, 0,
+ SEC_VIEWPORT_X_START_C, viewport_c->x,
+ SEC_VIEWPORT_Y_START_C, viewport_c->y);
+}
+
 void hubp21_set_vm_system_aperture_settings(struct hubp *hubp,
struct vm_system_aperture_param *apt)
 {
@@ -211,7 +274,7 @@ static struct hubp_funcs dcn21_hubp_funcs = {
.hubp_set_vm_system_aperture_settings = 
hubp21_set_vm_system_aperture_settings,
.set_blank = hubp1_set_blank,
.dcc_control = hubp1_dcc_control,
-   .mem_program_viewport = min_set_viewport,
+   .mem_program_viewport = hubp21_set_viewport,
.set_cursor_attributes  = hubp2_cursor_set_attributes,
.set_cursor_position= hubp1_cursor_set_position,
.hubp_clk_cntl = hubp1_clk_cntl,
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
index da4aadf72a7d..01caffec91e5 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
@@ -845,6 +845,7 @@ static const struct dc_debug_options debug_defaults_drv = {

[PATCH 06/20] drm/amd/display: Add a sanity check for DSC already enabled/disabled

2019-10-31 Thread Bhawanpreet Lakha
From: Nikola Cornij 

[why]
If acquire/release DSC resource sequence is affected by a regression,
it can happen that the already-in-use DSC HW block is being wrongly
re-used for a different pipe. The reverse is also possible, i.e.
already-disabled DSC HW block could be disabled from other context.

[how]
Read back the enable state of DSC HW and report an error if duplicate
enable or disable was attempted.

Signed-off-by: Nikola Cornij 
Reviewed-by: Dmytro Laktyushkin 
Acked-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c  | 25 ---
 1 file changed, 22 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c
index 63eb377ed9c0..dc9944427d2f 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dsc.c
@@ -222,9 +222,18 @@ static bool dsc2_get_packed_pps(struct 
display_stream_compressor *dsc, const str
 static void dsc2_enable(struct display_stream_compressor *dsc, int opp_pipe)
 {
struct dcn20_dsc *dsc20 = TO_DCN20_DSC(dsc);
+   int dsc_clock_en;
+   int dsc_fw_config;
+   int enabled_opp_pipe;
 
-   /* TODO Check if DSC alreay in use? */
-   DC_LOG_DSC("enable DSC at opp pipe %d", opp_pipe);
+   DC_LOG_DSC("enable DSC %d at opp pipe %d", dsc->inst, opp_pipe);
+
+   REG_GET(DSC_TOP_CONTROL, DSC_CLOCK_EN, _clock_en);
+   REG_GET_2(DSCRM_DSC_FORWARD_CONFIG, DSCRM_DSC_FORWARD_EN, 
_fw_config, DSCRM_DSC_OPP_PIPE_SOURCE, _opp_pipe);
+   if ((dsc_clock_en || dsc_fw_config) && enabled_opp_pipe != opp_pipe) {
+   DC_LOG_DSC("ERROR: DSC %d at opp pipe %d already enabled!", 
dsc->inst, enabled_opp_pipe);
+   ASSERT(0);
+   }
 
REG_UPDATE(DSC_TOP_CONTROL,
DSC_CLOCK_EN, 1);
@@ -238,8 +247,18 @@ static void dsc2_enable(struct display_stream_compressor 
*dsc, int opp_pipe)
 static void dsc2_disable(struct display_stream_compressor *dsc)
 {
struct dcn20_dsc *dsc20 = TO_DCN20_DSC(dsc);
+   int dsc_clock_en;
+   int dsc_fw_config;
+   int enabled_opp_pipe;
 
-   DC_LOG_DSC("disable DSC");
+   DC_LOG_DSC("disable DSC %d", dsc->inst);
+
+   REG_GET(DSC_TOP_CONTROL, DSC_CLOCK_EN, _clock_en);
+   REG_GET_2(DSCRM_DSC_FORWARD_CONFIG, DSCRM_DSC_FORWARD_EN, 
_fw_config, DSCRM_DSC_OPP_PIPE_SOURCE, _opp_pipe);
+   if (!dsc_clock_en || !dsc_fw_config) {
+   DC_LOG_DSC("ERROR: DSC %d at opp pipe %d already disabled!", 
dsc->inst, enabled_opp_pipe);
+   ASSERT(0);
+   }
 
REG_UPDATE(DSCRM_DSC_FORWARD_CONFIG,
DSCRM_DSC_FORWARD_EN, 0);
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 20/20] drm/amd/display: disable lttpr for invalid lttpr caps.

2019-10-31 Thread Bhawanpreet Lakha
From: abdoulaye berthe 

1-Read lttpr caps in 5-bytes
2-Parse caps
3-Validate caps and set lttpr_mode
4-Use hw default timeout when lttpr is disabled.

Signed-off-by: abdoulaye berthe 
Reviewed-by: Wenjing Liu 
---
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  | 90 ++-
 drivers/gpu/drm/amd/display/dc/dc_types.h | 15 +---
 .../gpu/drm/amd/display/dc/inc/dc_link_dp.h   |  2 +-
 3 files changed, 49 insertions(+), 58 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index 6e1f00ab6646..7d18fc1e68c6 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -1172,7 +1172,7 @@ static void configure_lttpr_mode(struct dc_link *link)
uint8_t repeater_cnt;
uint32_t aux_interval_address;
uint8_t repeater_id;
-   enum lttpr_mode repeater_mode = phy_repeater_mode_transparent;
+   uint8_t repeater_mode = DP_PHY_REPEATER_MODE_TRANSPARENT;
 
core_link_write_dpcd(link,
DP_PHY_REPEATER_MODE,
@@ -1180,7 +1180,7 @@ static void configure_lttpr_mode(struct dc_link *link)
sizeof(repeater_mode));
 
if (!link->is_lttpr_mode_transparent) {
-   repeater_mode = phy_repeater_mode_non_transparent;
+   repeater_mode = DP_PHY_REPEATER_MODE_NON_TRANSPARENT;
core_link_write_dpcd(link,
DP_PHY_REPEATER_MODE,
(uint8_t *)_mode,
@@ -2964,7 +2964,11 @@ static void dp_wa_power_up_0010FA(struct dc_link *link, 
uint8_t *dpcd_data,
 
 static bool retrieve_link_cap(struct dc_link *link)
 {
-   uint8_t dpcd_data[DP_ADAPTER_CAP - DP_DPCD_REV + 1];
+   /* DP_ADAPTER_CAP - DP_DPCD_REV + 1 == 16 and also 
DP_DSC_BITS_PER_PIXEL_INC - DP_DSC_SUPPORT + 1 == 16,
+* which means size 16 will be good for both of those DPCD register 
block reads
+*/
+   uint8_t dpcd_data[16];
+   uint8_t lttpr_dpcd_data[6];
 
/*Only need to read 1 byte starting from 
DP_DPRX_FEATURE_ENUMERATION_LIST.
 */
@@ -2977,7 +2981,6 @@ static bool retrieve_link_cap(struct dc_link *link)
union dp_downstream_port_present ds_port = { 0 };
enum dc_status status = DC_ERROR_UNEXPECTED;
uint32_t read_dpcd_retry_cnt = 3;
-   uint32_t prev_timeout_val;
int i;
struct dp_sink_hw_fw_revision dp_hw_fw_revision;
 
@@ -2988,12 +2991,12 @@ static bool retrieve_link_cap(struct dc_link *link)
link->is_lttpr_mode_transparent = true;
 
if (ext_timeout_support) {
-   prev_timeout_val =
-   dc_link_aux_configure_timeout(link->ddc,
-   
LINK_AUX_DEFAULT_EXTENDED_TIMEOUT_PERIOD);
+   dc_link_aux_configure_timeout(link->ddc,
+   
LINK_AUX_DEFAULT_EXTENDED_TIMEOUT_PERIOD);
}
 
memset(dpcd_data, '\0', sizeof(dpcd_data));
+   memset(lttpr_dpcd_data, '\0', sizeof(lttpr_dpcd_data));
memset(_strm_port_count,
'\0', sizeof(union down_stream_port_count));
memset(_config_cap, '\0',
@@ -3026,47 +3029,46 @@ static bool retrieve_link_cap(struct dc_link *link)
}
 
if (ext_timeout_support) {
+
status = core_link_read_dpcd(
link,
-   DP_PHY_REPEATER_CNT,
-   >dpcd_caps.lttpr_caps.phy_repeater_cnt,
-   
sizeof(link->dpcd_caps.lttpr_caps.phy_repeater_cnt));
-
-   if (link->dpcd_caps.lttpr_caps.phy_repeater_cnt > 0) {
-
+   
DP_LT_TUNABLE_PHY_REPEATER_FIELD_DATA_STRUCTURE_REV,
+   lttpr_dpcd_data,
+   sizeof(lttpr_dpcd_data));
+
+   link->dpcd_caps.lttpr_caps.revision.raw =
+   
lttpr_dpcd_data[DP_LT_TUNABLE_PHY_REPEATER_FIELD_DATA_STRUCTURE_REV -
+   
DP_LT_TUNABLE_PHY_REPEATER_FIELD_DATA_STRUCTURE_REV];
+
+   link->dpcd_caps.lttpr_caps.max_link_rate =
+   lttpr_dpcd_data[DP_MAX_LINK_RATE_PHY_REPEATER -
+   
DP_LT_TUNABLE_PHY_REPEATER_FIELD_DATA_STRUCTURE_REV];
+
+   link->dpcd_caps.lttpr_caps.phy_repeater_cnt =
+   lttpr_dpcd_data[DP_PHY_REPEATER_CNT -
+   
DP_LT_TUNABLE_PHY_REPEATER_FIELD_DATA_STRUCTURE_REV];
+
+   link->dpcd_caps.lttpr_caps.max_lane_count =
+   lttpr_dpcd_data[DP_MAX_LANE_COUNT_PHY_REPEATER -
+   

[PATCH 16/20] drm/amd/display: check for dp rev before reading lttpr regs

2019-10-31 Thread Bhawanpreet Lakha
From: abdoulaye berthe 

[Why]
LTTPR was introduced after DP1.2. Reading LTTPR registers 0xF
on some DP 1.2 display is causing an unexpected behavior.

[How]
Make sure that we don't read any lttpr registers on 1.2 displays.

Signed-off-by: abdoulaye berthe 
Reviewed-by: Aric Cyr 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index 2a89f90ef7a7..1e4480f3bd3c 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -2759,9 +2759,10 @@ static bool retrieve_link_cap(struct dc_link *link)
/* Set default timeout to 3.2ms and read LTTPR capabilities */
bool ext_timeout_support = link->dc->caps.extended_aux_timeout_support 
&&
!link->dc->config.disable_extended_timeout_support;
+   link->is_lttpr_mode_transparent = true;
+
if (ext_timeout_support) {
status = dc_link_aux_configure_timeout(link->ddc, 
LINK_AUX_DEFAULT_EXTENDED_TIMEOUT_PERIOD);
-   link->is_lttpr_mode_transparent = true;
}
 
memset(dpcd_data, '\0', sizeof(dpcd_data));
@@ -2796,7 +2797,7 @@ static bool retrieve_link_cap(struct dc_link *link)
return false;
}
 
-   if (ext_timeout_support) {
+   if (ext_timeout_support && link->dpcd_caps.dpcd_rev.raw >= 0x14) {
status = core_link_read_dpcd(
link,
DP_PHY_REPEATER_CNT,
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 15/20] drm/amd/display: initialize lttpr

2019-10-31 Thread Bhawanpreet Lakha
From: abdoulaye berthe 

[Description]
When reading link, update the procedure as follows:
1-Set aux timeout to extended: 3.2ms
2-Start with reading lttpr caps
3-Determine if lttpr support should be enabled. Reset aux timeout to
400us if no repeater is found.

Signed-off-by: abdoulaye berthe 
Reviewed-by: Aric Cyr 
---
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  | 56 +++
 drivers/gpu/drm/amd/display/dc/dc.h   |  2 +
 drivers/gpu/drm/amd/display/dc/dc_link.h  |  1 +
 drivers/gpu/drm/amd/display/dc/dc_types.h | 36 
 4 files changed, 95 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index 0f59b68aa4c2..2a89f90ef7a7 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -21,6 +21,9 @@
 #define DC_LOGGER \
link->ctx->logger
 
+
+#define DP_REPEATER_CONFIGURATION_AND_STATUS_OFFSET   0x50
+
 /* maximum pre emphasis level allowed for each voltage swing level*/
 static const enum dc_pre_emphasis voltage_swing_to_pre_emphasis[] = {
PRE_EMPHASIS_LEVEL3,
@@ -2753,6 +2756,14 @@ static bool retrieve_link_cap(struct dc_link *link)
int i;
struct dp_sink_hw_fw_revision dp_hw_fw_revision;
 
+   /* Set default timeout to 3.2ms and read LTTPR capabilities */
+   bool ext_timeout_support = link->dc->caps.extended_aux_timeout_support 
&&
+   !link->dc->config.disable_extended_timeout_support;
+   if (ext_timeout_support) {
+   status = dc_link_aux_configure_timeout(link->ddc, 
LINK_AUX_DEFAULT_EXTENDED_TIMEOUT_PERIOD);
+   link->is_lttpr_mode_transparent = true;
+   }
+
memset(dpcd_data, '\0', sizeof(dpcd_data));
memset(_strm_port_count,
'\0', sizeof(union down_stream_port_count));
@@ -2785,6 +2796,51 @@ static bool retrieve_link_cap(struct dc_link *link)
return false;
}
 
+   if (ext_timeout_support) {
+   status = core_link_read_dpcd(
+   link,
+   DP_PHY_REPEATER_CNT,
+   >dpcd_caps.lttpr_caps.phy_repeater_cnt,
+   
sizeof(link->dpcd_caps.lttpr_caps.phy_repeater_cnt));
+
+   if (link->dpcd_caps.lttpr_caps.phy_repeater_cnt > 0) {
+
+   link->is_lttpr_mode_transparent = false;
+
+   status = core_link_read_dpcd(
+   link,
+   
DP_LT_TUNABLE_PHY_REPEATER_FIELD_DATA_STRUCTURE_REV,
+   (uint8_t 
*)>dpcd_caps.lttpr_caps.revision,
+   
sizeof(link->dpcd_caps.lttpr_caps.revision));
+
+   status = core_link_read_dpcd(
+   link,
+   DP_MAX_LINK_RATE_PHY_REPEATER,
+   
>dpcd_caps.lttpr_caps.max_link_rate,
+   
sizeof(link->dpcd_caps.lttpr_caps.max_link_rate));
+
+   status = core_link_read_dpcd(
+   link,
+   DP_PHY_REPEATER_MODE,
+   (uint8_t 
*)>dpcd_caps.lttpr_caps.mode,
+   
sizeof(link->dpcd_caps.lttpr_caps.mode));
+
+   status = core_link_read_dpcd(
+   link,
+   DP_MAX_LANE_COUNT_PHY_REPEATER,
+   
>dpcd_caps.lttpr_caps.max_lane_count,
+   
sizeof(link->dpcd_caps.lttpr_caps.max_lane_count));
+
+   status = core_link_read_dpcd(
+   link,
+   DP_PHY_REPEATER_EXTENDED_WAIT_TIMEOUT,
+   
>dpcd_caps.lttpr_caps.max_ext_timeout,
+   
sizeof(link->dpcd_caps.lttpr_caps.max_ext_timeout));
+   } else {
+   dc_link_aux_configure_timeout(link->ddc, 
LINK_AUX_DEFAULT_TIMEOUT_PERIOD);
+   }
+   }
+
{
union training_aux_rd_interval aux_rd_interval;
 
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 32eafff6b043..3fad17d96feb 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -987,6 +987,8 @@ struct dpcd_caps {
union dpcd_fec_capability fec_cap;
struct dpcd_dsc_capabilities dsc_caps;
 #endif
+   struct dc_lttpr_caps lttpr_caps;
+
 };
 
 #include "dc_link.h"
diff --git a/drivers/gpu/drm/amd/display/dc/dc_link.h 
b/drivers/gpu/drm/amd/display/dc/dc_link.h
index 

[PATCH 08/20] drm/amd/display: Create debug option to disable v.active clock change policy.

2019-10-31 Thread Bhawanpreet Lakha
From: David Galiffi 

[WHY]
It has been a useful option in debugging GFXOFF and P.State Change issues.
May be required as for platform specific workaround.

[HOW]
Create option in enum dc_debug_options, "disable_vactive_clock_change".
When it is set, dm_dram_clock_change_vactive, will translate into
p_state_change_support: false.

Signed-off-by: David Galiffi 
Reviewed-by: Jun Lei 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dc.h | 1 +
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c   | 1 +
 .../gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c  | 3 ++-
 .../drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c| 6 +++---
 drivers/gpu/drm/amd/display/dc/dml/display_mode_structs.h   | 1 +
 drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.c   | 2 ++
 drivers/gpu/drm/amd/display/dc/dml/display_mode_vba.h   | 1 +
 7 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 5db4477cc4b7..7bf0241999c7 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -419,6 +419,7 @@ struct dc_debug_options {
int force_clock_mode;/*every mode change.*/
 
bool nv12_iflip_vm_wa;
+   bool disable_dram_clock_change_vactive_support;
 };
 
 struct dc_debug_data {
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
index 924c2e303588..1862d8a192bc 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
@@ -2845,6 +2845,7 @@ bool dcn20_validate_bandwidth(struct dc *dc, struct 
dc_state *context,
bool full_pstate_supported = false;
bool dummy_pstate_supported = false;
double p_state_latency_us = 
context->bw_ctx.dml.soc.dram_clock_change_latency_us;
+   context->bw_ctx.dml.soc.disable_dram_clock_change_vactive_support = 
dc->debug.disable_dram_clock_change_vactive_support;
 
if (fast_validate)
return dcn20_validate_bandwidth_internal(dc, context, true);
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c
index 6c6c486b774a..77b7574c63cb 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20.c
@@ -2577,7 +2577,8 @@ static void 
dml20_DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPer
mode_lib->vba.MinActiveDRAMClockChangeMargin
+ mode_lib->vba.DRAMClockChangeLatency;
 
-   if (mode_lib->vba.MinActiveDRAMClockChangeMargin > 50) {
+   if (mode_lib->vba.DRAMClockChangeSupportsVActive &&
+   mode_lib->vba.MinActiveDRAMClockChangeMargin > 50) {
mode_lib->vba.DRAMClockChangeWatermark += 25;
mode_lib->vba.DRAMClockChangeSupport[0][0] = 
dm_dram_clock_change_vactive;
} else {
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c
index d63ca4ccf7cf..62dfd36d830a 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn20/display_mode_vba_20v2.c
@@ -2611,12 +2611,12 @@ static void 
dml20v2_DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndP
mode_lib->vba.MinActiveDRAMClockChangeMargin
+ mode_lib->vba.DRAMClockChangeLatency;
 
-
-   if (mode_lib->vba.MinActiveDRAMClockChangeMargin > 50) {
+   if (mode_lib->vba.DRAMClockChangeSupportsVActive &&
+   mode_lib->vba.MinActiveDRAMClockChangeMargin > 50) {
mode_lib->vba.DRAMClockChangeWatermark += 25;
mode_lib->vba.DRAMClockChangeSupport[0][0] = 
dm_dram_clock_change_vactive;
} else if (mode_lib->vba.DummyPStateCheck &&
-   mode_lib->vba.MinActiveDRAMClockChangeMargin > 
0) {
+   mode_lib->vba.MinActiveDRAMClockChangeMargin > 0) {
mode_lib->vba.DRAMClockChangeSupport[0][0] = 
dm_dram_clock_change_vactive;
} else {
if (mode_lib->vba.SynchronizedVBlank || 
mode_lib->vba.NumberOfActivePlanes == 1) {
diff --git a/drivers/gpu/drm/amd/display/dc/dml/display_mode_structs.h 
b/drivers/gpu/drm/amd/display/dc/dml/display_mode_structs.h
index cfacd6027467..19356180cbb6 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/display_mode_structs.h
+++ b/drivers/gpu/drm/amd/display/dc/dml/display_mode_structs.h
@@ -112,6 +112,7 @@ struct _vcs_dpi_soc_bounding_box_st {

[PATCH 07/20] drm/amd/display: set MSA MISC1 bit 6 while sending colorimetry in VSC SDP

2019-10-31 Thread Bhawanpreet Lakha
From: Anthony Koo 

[Why]
It is confusing to sinks if we send VSC SDP only on some format. Today we
signal colorimetry format using MSA while in formats like sRGB.
But when we switch to BT2020 we set the bit to ignore MSA  colorimetry and
instead use the colorimetry information in the VSC SDP.

But if sink supports signaling of colorimetry via VSC SDP we should always
set the MSA MISC1 bit 6, instead of doing so selectively.

[How]
If sink supports signaling of colorimetry via VSC SDP, and we are sending
the colorimetry info via VSC SDP with packet revision 05h, then always
set MSA MISC1 bit 6.

Signed-off-by: Anthony Koo 
Reviewed-by: Aric Cyr 
Acked-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  4 +-
 drivers/gpu/drm/amd/display/dc/core/dc_link.c |  1 +
 drivers/gpu/drm/amd/display/dc/dc_stream.h|  1 +
 .../amd/display/dc/dce/dce_stream_encoder.c   |  1 +
 .../display/dc/dcn10/dcn10_stream_encoder.c   |  6 +--
 .../display/dc/dcn10/dcn10_stream_encoder.h   |  1 +
 .../display/dc/dcn20/dcn20_stream_encoder.c   |  7 ++-
 .../display/dc/dcn20/dcn20_stream_encoder.h   |  1 +
 .../amd/display/dc/inc/hw/stream_encoder.h|  1 +
 .../dc/virtual/virtual_stream_encoder.c   |  1 +
 .../amd/display/modules/inc/mod_info_packet.h |  4 +-
 .../display/modules/info_packet/info_packet.c | 46 +++
 12 files changed, 57 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 48f5b43e2698..6f0216ce4d4e 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3834,7 +3834,9 @@ create_stream_for_sink(struct amdgpu_dm_connector 
*aconnector,
struct dmcu *dmcu = core_dc->res_pool->dmcu;
 
stream->psr_version = dmcu->dmcu_version.psr_version;
-   mod_build_vsc_infopacket(stream, 
>vsc_infopacket);
+   mod_build_vsc_infopacket(stream,
+   >vsc_infopacket,
+   >use_vsc_sdp_for_colorimetry);
}
}
 finish:
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index cc94c1a73daa..cdd9850ea3ca 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -2946,6 +2946,7 @@ void core_link_enable_stream(
pipe_ctx->stream_res.stream_enc,
>timing,
stream->output_color_space,
+   stream->use_vsc_sdp_for_colorimetry,

stream->link->dpcd_caps.dprx_feature.bits.SST_SPLIT_SDP_CAP);
 
if (dc_is_hdmi_tmds_signal(pipe_ctx->stream->signal))
diff --git a/drivers/gpu/drm/amd/display/dc/dc_stream.h 
b/drivers/gpu/drm/amd/display/dc/dc_stream.h
index fdb6adc37857..f8c07d5a4054 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_stream.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_stream.h
@@ -164,6 +164,7 @@ struct dc_stream_state {
 
enum view_3d_format view_format;
 
+   bool use_vsc_sdp_for_colorimetry;
bool ignore_msa_timing_param;
bool converter_disable_audio;
uint8_t qs_bit;
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c 
b/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c
index 6ed922a3c1cd..2baaac1e5156 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_stream_encoder.c
@@ -275,6 +275,7 @@ static void dce110_stream_encoder_dp_set_stream_attribute(
struct stream_encoder *enc,
struct dc_crtc_timing *crtc_timing,
enum dc_color_space output_color_space,
+   bool use_vsc_sdp_for_colorimetry,
uint32_t enable_sdp_splitting)
 {
 #if defined(CONFIG_DRM_AMD_DC_DCN1_0)
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c
index 06e5bbb4545c..376c4264d295 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c
@@ -247,6 +247,7 @@ void enc1_stream_encoder_dp_set_stream_attribute(
struct stream_encoder *enc,
struct dc_crtc_timing *crtc_timing,
enum dc_color_space output_color_space,
+   bool use_vsc_sdp_for_colorimetry,
uint32_t enable_sdp_splitting)
 {
uint32_t h_active_start;
@@ -312,10 +313,7 @@ void enc1_stream_encoder_dp_set_stream_attribute(
 * Pixel Encoding/Colorimetry Format and that a Sink device shall 
ignore MISC1, bit 7,
 * and MISC0, bits 7:1 (MISC1, bit 7, and MISC0, bits 7:1, become 
"don't care").
 */
-   if ((hw_crtc_timing.pixel_encoding == PIXEL_ENCODING_Y

[PATCH 05/20] drm/amd/display: Use SIGNAL_TYPE_NONE in disable_output unless eDP

2019-10-31 Thread Bhawanpreet Lakha
From: Sung Lee 

[WHY]
Currently made a change where disable_output is called using signal_type.
Using actual signal_type when calilng disable_output in power_down_encoders
would make DP to HDMI dongle not light up on boot. As it would have signal_type
SIGNAL_TYPE_DISPLAY_PORT.

[HOW]
Set signal_type to SIGNAL_TYPE_NONE unless it is eDP.

Signed-off-by: Sung Lee 
Reviewed-by: Yongqiang Sun 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c 
b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
index f0e837d14000..37f5bbcba155 100644
--- a/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dce110/dce110_hw_sequencer.c
@@ -1438,6 +1438,9 @@ static void power_down_encoders(struct dc *dc)
if (!dc->links[i]->wa_flags.dp_keep_receiver_powered)
dp_receiver_power_ctrl(dc->links[i], false);
 
+   if (signal != SIGNAL_TYPE_EDP)
+   signal = SIGNAL_TYPE_NONE;
+
dc->links[i]->link_enc->funcs->disable_output(
dc->links[i]->link_enc, signal);
}
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 18/29] drm/amd/display: update renoir bounding box and res_caps

2019-10-11 Thread Bhawanpreet Lakha
The values for bounding box and res_caps were incorrect. So
Fix them

Signed-off-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/dcn21/dcn21_resource.c | 24 ++-
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
index 5e15f800a9f1..002e7fb67068 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
@@ -82,6 +82,7 @@
 
 
 struct _vcs_dpi_ip_params_st dcn2_1_ip = {
+   .odm_capable = 1,
.gpuvm_enable = 0,
.hostvm_enable = 0,
.gpuvm_max_page_table_levels = 1,
@@ -203,11 +204,11 @@ struct _vcs_dpi_soc_bounding_box_st dcn2_1_soc = {
.state = 4,
.dcfclk_mhz = 810.0,
.fabricclk_mhz = 1600.0,
-   .dispclk_mhz = 1015.0,
-   .dppclk_mhz = 1015.0,
-   .phyclk_mhz = 810.0,
+   .dispclk_mhz = 1395.0,
+   .dppclk_mhz = 1285.0,
+   .phyclk_mhz = 1325.0,
.socclk_mhz = 953.0,
-   .dscclk_mhz = 318.334,
+   .dscclk_mhz = 489.0,
.dram_speed_mts = 4266.0,
},
/*Extra state, no dispclk ramping*/
@@ -215,18 +216,18 @@ struct _vcs_dpi_soc_bounding_box_st dcn2_1_soc = {
.state = 5,
.dcfclk_mhz = 810.0,
.fabricclk_mhz = 1600.0,
-   .dispclk_mhz = 1015.0,
-   .dppclk_mhz = 1015.0,
-   .phyclk_mhz = 810.0,
+   .dispclk_mhz = 1395.0,
+   .dppclk_mhz = 1285.0,
+   .phyclk_mhz = 1325.0,
.socclk_mhz = 953.0,
-   .dscclk_mhz = 318.334,
+   .dscclk_mhz = 489.0,
.dram_speed_mts = 4266.0,
},
 
},
 
-   .sr_exit_time_us = 9.0,
-   .sr_enter_plus_exit_time_us = 11.0,
+   .sr_exit_time_us = 12.5,
+   .sr_enter_plus_exit_time_us = 17.0,
.urgent_latency_us = 4.0,
.urgent_latency_pixel_data_only_us = 4.0,
.urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
@@ -764,6 +765,7 @@ static const struct resource_caps res_cap_rn = {
.num_pll = 5,  // maybe 3 because the last two used for USB-c
.num_dwb = 1,
.num_ddc = 5,
+   .num_vmid = 1,
 #ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
.num_dsc = 3,
 #endif
@@ -833,7 +835,7 @@ static const struct dc_debug_options debug_defaults_drv = {
.disable_dcc = DCC_ENABLE,
.vsr_support = true,
.performance_trace = false,
-   .max_downscale_src_width = 5120,/*upto 5K*/
+   .max_downscale_src_width = 3840,
.disable_pplib_wm_range = false,
.scl_reset_length10 = true,
.sanity_checks = true,
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 14/29] drm/amd/display: use dcn10 version of program tiling on Renoir

2019-10-11 Thread Bhawanpreet Lakha
From: Eric Yang 

[Why]
Renoir is gfx9, same as dcn10, not dcn20.

Signed-off-by: Eric Yang 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
index a00af513aa2b..2f5a5867e674 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
@@ -22,6 +22,8 @@
  * Authors: AMD
  *
  */
+
+#include "dcn10/dcn10_hubp.h"
 #include "dcn21_hubp.h"
 
 #include "dm_services.h"
@@ -202,7 +204,7 @@ static struct hubp_funcs dcn21_hubp_funcs = {
.hubp_enable_tripleBuffer = hubp2_enable_triplebuffer,
.hubp_is_triplebuffer_enabled = hubp2_is_triplebuffer_enabled,
.hubp_program_surface_flip_and_addr = 
hubp2_program_surface_flip_and_addr,
-   .hubp_program_surface_config = hubp2_program_surface_config,
+   .hubp_program_surface_config = hubp1_program_surface_config,
.hubp_is_flip_pending = hubp1_is_flip_pending,
.hubp_setup = hubp21_setup,
.hubp_setup_interdependent = hubp2_setup_interdependent,
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 25/29] drm/amd/display: fix header for RN clk mgr

2019-10-11 Thread Bhawanpreet Lakha
From: joseph gravenor 

[why]
Should always MP0_BASE for any register definition from MP per-IP header files.
I belive the reason the linux version of MP1_BASE works is The 0th element of 
the 0th table
of that is identical to the corrisponding value of MP0_BASE in the renoir 
offset header file.
The reason we should only use MP0_BASE is There is only one set of per-IP 
headers MP
that includes all register definitions related to SMU IP block. This IP 
includes MP0, MP1, MP2
and  an ecryption engine that can be used only by MP0. As a result all register 
definitions from
MP file should be based only on MP0_BASE data.

[How]
Change MP1_BASE to MP0_BASE

Signed-off-by: joseph gravenor 
Acked-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
index 8e860f567d5c..db28e91adb3d 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
@@ -33,7 +33,7 @@
 #include "mp/mp_12_0_0_sh_mask.h"
 
 #define REG(reg_name) \
-   (MP1_BASE.instance[0].segment[mm ## reg_name ## _BASE_IDX] + mm ## 
reg_name)
+   (MP0_BASE.instance[0].segment[mm ## reg_name ## _BASE_IDX] + mm ## 
reg_name)
 
 #define FN(reg_name, field) \
FD(reg_name##__##field)
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 04/29] drm/amd/display: Add DP_DPHY_INTERNAL_CTR regs

2019-10-11 Thread Bhawanpreet Lakha
Signed-off-by: Bhawanpreet Lakha 
---
 .../drm/amd/include/asic_reg/dcn/dcn_2_1_0_offset.h| 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/amd/include/asic_reg/dcn/dcn_2_1_0_offset.h 
b/drivers/gpu/drm/amd/include/asic_reg/dcn/dcn_2_1_0_offset.h
index be4249adb356..eddf83ec1c39 100644
--- a/drivers/gpu/drm/amd/include/asic_reg/dcn/dcn_2_1_0_offset.h
+++ b/drivers/gpu/drm/amd/include/asic_reg/dcn/dcn_2_1_0_offset.h
@@ -9859,6 +9859,8 @@
 #define mmDP0_DP_STEER_FIFO_BASE_IDX   
2
 #define mmDP0_DP_MSA_MISC  
0x210e
 #define mmDP0_DP_MSA_MISC_BASE_IDX 
2
+#define mmDP0_DP_DPHY_INTERNAL_CTRL
0x210f
+#define mmDP0_DP_DPHY_INTERNAL_CTRL_BASE_IDX   
2
 #define mmDP0_DP_VID_TIMING
0x2110
 #define mmDP0_DP_VID_TIMING_BASE_IDX   
2
 #define mmDP0_DP_VID_N 
0x2111
@@ -10187,6 +10189,8 @@
 #define mmDP1_DP_STEER_FIFO_BASE_IDX   
2
 #define mmDP1_DP_MSA_MISC  
0x220e
 #define mmDP1_DP_MSA_MISC_BASE_IDX 
2
+#define mmDP1_DP_DPHY_INTERNAL_CTRL
0x220f
+#define mmDP1_DP_DPHY_INTERNAL_CTRL_BASE_IDX   
2
 #define mmDP1_DP_VID_TIMING
0x2210
 #define mmDP1_DP_VID_TIMING_BASE_IDX   
2
 #define mmDP1_DP_VID_N 
0x2211
@@ -10515,6 +10519,8 @@
 #define mmDP2_DP_STEER_FIFO_BASE_IDX   
2
 #define mmDP2_DP_MSA_MISC  
0x230e
 #define mmDP2_DP_MSA_MISC_BASE_IDX 
2
+#define mmDP2_DP_DPHY_INTERNAL_CTRL
0x230f
+#define mmDP2_DP_DPHY_INTERNAL_CTRL_BASE_IDX   
2
 #define mmDP2_DP_VID_TIMING
0x2310
 #define mmDP2_DP_VID_TIMING_BASE_IDX   
2
 #define mmDP2_DP_VID_N 
0x2311
@@ -10843,6 +10849,8 @@
 #define mmDP3_DP_STEER_FIFO_BASE_IDX   
2
 #define mmDP3_DP_MSA_MISC  
0x240e
 #define mmDP3_DP_MSA_MISC_BASE_IDX 
2
+#define mmDP3_DP_DPHY_INTERNAL_CTRL
0x240f
+#define mmDP3_DP_DPHY_INTERNAL_CTRL_BASE_IDX   
2
 #define mmDP3_DP_VID_TIMING
0x2410
 #define mmDP3_DP_VID_TIMING_BASE_IDX   
2
 #define mmDP3_DP_VID_N 
0x2411
@@ -11171,6 +11179,8 @@
 #define mmDP4_DP_STEER_FIFO_BASE_IDX   
2
 #define mmDP4_DP_MSA_MISC  
0x250e
 #define mmDP4_DP_MSA_MISC_BASE_IDX 
2
+#define mmDP4_DP_DPHY_INTERNAL_CTRL
0x250f
+#define mmDP4_DP_DPHY_INTERNAL_CTRL_BASE_IDX   
2
 #define mmDP4_DP_VID_TIMING
0x2510
 #define mmDP4_DP_VID_TIMING_BASE_IDX   
2
 #define mmDP4_DP_VID_N 
0x2511
-- 
2.17.1

[PATCH 27/29] drm/amd/display: use requested_dispclk_khz instead of clk

2019-10-11 Thread Bhawanpreet Lakha
Use requested_dispclk_khz / 1000 directly

Signed-off-by: Bhawanpreet Lakha 
---
 .../display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git 
a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
index 2650776acbc3..5647fcf10717 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
@@ -84,16 +84,12 @@ int rn_vbios_smu_set_dispclk(struct clk_mgr_internal 
*clk_mgr, int requested_dis
int actual_dispclk_set_mhz = -1;
struct dc *core_dc = clk_mgr->base.ctx->dc;
struct dmcu *dmcu = core_dc->res_pool->dmcu;
-   uint32_t clk = requested_dispclk_khz / 1000;
-
-   if (clk <= 100)
-   clk = 101;
 
/*  Unit of SMU msg parameter is Mhz */
actual_dispclk_set_mhz = rn_vbios_smu_send_msg_with_param(
clk_mgr,
VBIOSSMC_MSG_SetDispclkFreq,
-   clk);
+   requested_dispclk_khz / 1000);
 
if (!IS_FPGA_MAXIMUS_DC(core_dc->ctx->dce_environment)) {
if (dmcu && dmcu->funcs->is_dmcu_initialized(dmcu)) {
@@ -162,15 +158,10 @@ int rn_vbios_smu_set_dppclk(struct clk_mgr_internal 
*clk_mgr, int requested_dpp_
 {
int actual_dppclk_set_mhz = -1;
 
-   uint32_t clk = requested_dpp_khz / 1000;
-
-   if (clk <= 100)
-   clk = 101;
-
actual_dppclk_set_mhz = rn_vbios_smu_send_msg_with_param(
clk_mgr,
VBIOSSMC_MSG_SetDppclkFreq,
-   clk);
+   requested_dpp_khz / 1000);
 
return actual_dppclk_set_mhz * 1000;
 }
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 21/29] drm/amd/display: update odm mode validation to be in line with policy

2019-10-11 Thread Bhawanpreet Lakha
From: Dmytro Laktyushkin 

Previously 8k30 worked with dsc and odm combine due to a workaround that ran
the formula a second time with dsc support enable should dsc validation fail.
This worked when clocks were low enough for formula to enable odm to lower
voltage, however now broke due to increased clocks.

This change updates the ODM combine policy within the formula to properly
reflect our current policy within DC, only enabling ODM when we have to, as
well as adding a check for viewport width when dsc is enabled.

As a side effect the redundant call to dml when odm is required is now
unnecessary.

Signed-off-by: Dmytro Laktyushkin 
Acked-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c   | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
index 3b6ed60dcd35..fd707e7459b5 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
@@ -65,6 +65,7 @@ typedef struct {
 
 #define BPP_INVALID 0
 #define BPP_BLENDED_PIPE 0x
+#define DCN21_MAX_DSC_IMAGE_WIDTH 5184
 
 static void DisplayPipeConfiguration(struct display_mode_lib *mode_lib);
 static void 
DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation(
@@ -3936,6 +3937,10 @@ void dml21_ModeSupportAndSystemConfigurationFull(struct 
display_mode_lib *mode_l
mode_lib->vba.MaximumSwathWidthInLineBuffer);
}
for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
+   double MaxMaxDispclkRoundedDown = RoundToDFSGranularityDown(
+   mode_lib->vba.MaxDispclk[mode_lib->vba.soc.num_states],
+   mode_lib->vba.DISPCLKDPPCLKVCOSpeed);
+
for (j = 0; j < 2; j++) {
mode_lib->vba.MaxDispclkRoundedDownToDFSGranularity = 
RoundToDFSGranularityDown(
mode_lib->vba.MaxDispclk[i],
@@ -3965,7 +3970,9 @@ void dml21_ModeSupportAndSystemConfigurationFull(struct 
display_mode_lib *mode_l
&& i == 
mode_lib->vba.soc.num_states)

mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine = mode_lib->vba.PixelClock[k] 
/ 2
* (1 + 
mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0);
-   if (mode_lib->vba.ODMCapability == false || 
mode_lib->vba.PlaneRequiredDISPCLKWithoutODMCombine <= 
mode_lib->vba.MaxDispclkRoundedDownToDFSGranularity) {
+   if (mode_lib->vba.ODMCapability == false ||
+   
(locals->PlaneRequiredDISPCLKWithoutODMCombine <= MaxMaxDispclkRoundedDown
+   && 
(!locals->DSCEnabled[k] || locals->HActive[k] <= DCN21_MAX_DSC_IMAGE_WIDTH))) {
locals->ODMCombineEnablePerState[i][k] 
= false;
mode_lib->vba.PlaneRequiredDISPCLK = 
mode_lib->vba.PlaneRequiredDISPCLKWithoutODMCombine;
} else {
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 22/29] drm/amd/display: handle "18" case in TruncToValidBPP

2019-10-11 Thread Bhawanpreet Lakha
Handle 18 DecimalBPP like other cases

Signed-off-by: Bhawanpreet Lakha 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
index fd707e7459b5..ba77957aefe3 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
@@ -3380,6 +3380,8 @@ static unsigned int TruncToValidBPP(
return 30;
else if (DecimalBPP >= 24 && (DesiredBPP == 0 || 
DesiredBPP == 24))
return 24;
+   else if (DecimalBPP >= 18 && (DesiredBPP == 0 || 
DesiredBPP == 18))
+   return 18;
else
return BPP_INVALID;
}
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 08/29] drm/amd/display: add REFCYC_PER_TRIP_TO_MEMORY programming

2019-10-11 Thread Bhawanpreet Lakha
it allows us to do urgent latency programming

Signed-off-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/dcn20/dcn20_resource.c | 16 
 .../drm/amd/display/dc/dcn21/dcn21_hubbub.c   | 39 +--
 .../drm/amd/display/dc/dcn21/dcn21_hubbub.h   | 17 
 .../gpu/drm/amd/display/dc/inc/hw/mem_input.h |  1 +
 4 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
index 9cc6797e3860..086d1bc0d0a5 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
@@ -2573,6 +2573,10 @@ void dcn20_calculate_wm(
context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_exit_ns = 
get_wm_stutter_exit(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.pstate_change_ns = 
get_wm_dram_clock_change(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.b.pte_meta_urgent_ns = 
get_wm_memory_trip(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+   context->bw_ctx.bw.dcn.watermarks.b.frac_urg_bw_nom = 
get_fraction_of_urgent_bandwidth(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+   context->bw_ctx.bw.dcn.watermarks.b.frac_urg_bw_flip = 
get_fraction_of_urgent_bandwidth_imm_flip(>bw_ctx.dml, pipes, 
pipe_cnt) * 1000;
+#endif
 
if (vlevel < 2) {
pipes[0].clks_cfg.voltage = 2;
@@ -2584,6 +2588,10 @@ void dcn20_calculate_wm(
context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_exit_ns = 
get_wm_stutter_exit(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.pstate_change_ns = 
get_wm_dram_clock_change(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.c.pte_meta_urgent_ns = 
get_wm_memory_trip(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+   context->bw_ctx.bw.dcn.watermarks.c.frac_urg_bw_nom = 
get_fraction_of_urgent_bandwidth(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+   context->bw_ctx.bw.dcn.watermarks.c.frac_urg_bw_flip = 
get_fraction_of_urgent_bandwidth_imm_flip(>bw_ctx.dml, pipes, 
pipe_cnt) * 1000;
+#endif
 
if (vlevel < 3) {
pipes[0].clks_cfg.voltage = 3;
@@ -2595,6 +2603,10 @@ void dcn20_calculate_wm(
context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_exit_ns = 
get_wm_stutter_exit(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.pstate_change_ns = 
get_wm_dram_clock_change(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.d.pte_meta_urgent_ns = 
get_wm_memory_trip(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+   context->bw_ctx.bw.dcn.watermarks.d.frac_urg_bw_nom = 
get_fraction_of_urgent_bandwidth(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+   context->bw_ctx.bw.dcn.watermarks.d.frac_urg_bw_flip = 
get_fraction_of_urgent_bandwidth_imm_flip(>bw_ctx.dml, pipes, 
pipe_cnt) * 1000;
+#endif
 
pipes[0].clks_cfg.voltage = vlevel;
pipes[0].clks_cfg.dcfclk_mhz = 
context->bw_ctx.dml.soc.clock_limits[vlevel].dcfclk_mhz;
@@ -2604,6 +2616,10 @@ void dcn20_calculate_wm(
context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_exit_ns = 
get_wm_stutter_exit(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns = 
get_wm_dram_clock_change(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.a.pte_meta_urgent_ns = 
get_wm_memory_trip(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+   context->bw_ctx.bw.dcn.watermarks.a.frac_urg_bw_nom = 
get_fraction_of_urgent_bandwidth(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+   context->bw_ctx.bw.dcn.watermarks.a.frac_urg_bw_flip = 
get_fraction_of_urgent_bandwidth_imm_flip(>bw_ctx.dml, pipes, 
pipe_cnt) * 1000;
+#endif
 }
 
 void dcn20_calculate_dlg_params(
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index d1266741763b..8e7e79f44272 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -97,7 +97,7 @@ void dcn21_dchvm_init(struct hubbub *hubbub)
REG_WAIT(DCHVM_RIOMMU_STAT0, HOSTVM_PREFETCH_DONE, 1, 5, 100);
 }
 
-static int hubbub21_init_dchub(struct hubbub *hubbub,
+int hubbub21_init_dchub(struct hubbub *hubbub,
struct dcn_hubbub_phys_addr_config *pa_config)
 {
struct dcn20_hubbub *hubbub1 = TO_DCN20_HUBBUB(hubbub);
@@ -120,7 +120,7 @@ static int hubbub21_init_dchub(struct hubbub *hubbub,
return NUM_VMID;
 }
 
-static void hubbub21_p

[PATCH 13/29] drm/amd/display: initialize RN gpuvm context programming function

2019-10-11 Thread Bhawanpreet Lakha
From: Dmytro Laktyushkin 

Renoir can use vm contexes as long as HOSTVM is off so
this should be initialized.

Signed-off-by: Dmytro Laktyushkin 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index 2232ccf14bdd..44f64a8e33f1 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -628,7 +628,7 @@ void hubbub21_apply_DEDCN21_147_wa(struct hubbub *hubbub)
 static const struct hubbub_funcs hubbub21_funcs = {
.update_dchub = hubbub2_update_dchub,
.init_dchub_sys_ctx = hubbub21_init_dchub,
-   .init_vm_ctx = NULL,
+   .init_vm_ctx = hubbub2_init_vm_ctx,
.dcc_support_swizzle = hubbub2_dcc_support_swizzle,
.dcc_support_pixel_format = hubbub2_dcc_support_pixel_format,
.get_dcc_compression_cap = hubbub2_get_dcc_compression_cap,
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 00/29] Renoir DC Patches v2

2019-10-11 Thread Bhawanpreet Lakha
Hi all,

There was a delta betwwen internal dcn21 code and upstream dcn21 code.
These changes bring them inline.


Summary of Changes
*Add RN registors
*Add dcn12 hwseq and link_encoder
*RN specific fixes
*aux timeout support
*bounding box changes

v2:
*add usb-c functions
*compile fix and check lightup on renoir
*fix aux timeout regression

new patches
  drm/amd/display: handle dp is usb-c
  drm/amd/display: null check pp_smu clock table before using it
  drm/amd/display: disable ext aux support for vega



Bhawanpreet Lakha (14):
  drm/amd/display: Add DP_DPHY_INTERNAL_CTR regs
  drm/amd/display: Add DCN_BASE regs
  drm/amd/display: Add renoir hw_seq
  drm/amd/display: create dcn21_link_encoder files
  drm/amd/display: add REFCYC_PER_TRIP_TO_MEMORY programming
  drm/amd/display: fix incorrect page table address for renoir
  drm/amd/display: add detile buffer size for renoir
  drm/amd/display: update dcn21 hubbub registers
  drm/amd/display: update renoir bounding box and res_caps
  drm/amd/display: change PP_SM defs to 8
  drm/amd/display: handle "18" case in TruncToValidBPP
  drm/amd/display: use requested_dispclk_khz instead of clk
  drm/amd/display: handle dp is usb-c
  drm/amd/display: null check pp_smu clock table before using it

Dmytro Laktyushkin (4):
  drm/amd/display: enable hostvm based on roimmu active for dcn2.1
  drm/amd/display: initialize RN gpuvm context programming function
  drm/amd/display: correct dcn21 NUM_VMID to 16
  drm/amd/display: update odm mode validation to be in line with policy

Eric Yang (2):
  drm/amd/display: use dcn10 version of program tiling on Renoir
  drm/amd/display: add sanity check for clk table from smu

Lewis Huang (3):
  drm/amd/display: move the bounding box patch before calculate wm
  drm/amd/display: Temporary workaround to toggle watermark setting
  drm/amd/display: enable smu set dcfclk

Michael Strauss (1):
  drm/amd/display: Fix rn audio playback and video playback speed

Roman Li (1):
  drm/amd/display: disable ext aux support for vega

Sung Lee (1):
  drm/amd/display: add dummy functions to smu for Renoir Silicon Diags

abdoulaye berthe (2):
  drm/amd/display: update register field access mechanism
  drm/amd/display: configurable aux timeout support

joseph gravenor (1):
  drm/amd/display: fix header for RN clk mgr

 .../amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c |  25 +-
 .../dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c   |  19 +-
 .../gpu/drm/amd/display/dc/core/dc_link_ddc.c |  14 +
 drivers/gpu/drm/amd/display/dc/dc.h   |   2 +
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c  |  82 ++-
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.h  | 187 ++-
 .../gpu/drm/amd/display/dc/dce/dce_hwseq.h|   1 +
 .../amd/display/dc/dce100/dce100_resource.c   |  15 +-
 .../amd/display/dc/dce110/dce110_resource.c   |  14 +-
 .../amd/display/dc/dce112/dce112_resource.c   |  15 +-
 .../amd/display/dc/dce120/dce120_resource.c   |  15 +-
 .../drm/amd/display/dc/dce80/dce80_resource.c |  14 +-
 .../amd/display/dc/dcn10/dcn10_hw_sequencer.c |   4 +
 .../amd/display/dc/dcn10/dcn10_link_encoder.h |  49 +-
 .../drm/amd/display/dc/dcn10/dcn10_resource.c |  15 +-
 .../drm/amd/display/dc/dcn20/dcn20_hwseq.c|   4 +
 .../amd/display/dc/dcn20/dcn20_link_encoder.h |   7 +
 .../drm/amd/display/dc/dcn20/dcn20_resource.c |  31 +-
 drivers/gpu/drm/amd/display/dc/dcn21/Makefile |   2 +-
 .../drm/amd/display/dc/dcn21/dcn21_hubbub.c   | 116 -
 .../drm/amd/display/dc/dcn21/dcn21_hubbub.h   |  34 +-
 .../gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c |   4 +-
 .../drm/amd/display/dc/dcn21/dcn21_hwseq.c| 122 +
 .../drm/amd/display/dc/dcn21/dcn21_hwseq.h|  33 ++
 .../amd/display/dc/dcn21/dcn21_link_encoder.c | 470 ++
 .../amd/display/dc/dcn21/dcn21_link_encoder.h |  61 +++
 .../drm/amd/display/dc/dcn21/dcn21_resource.c | 269 --
 drivers/gpu/drm/amd/display/dc/dm_pp_smu.h|   6 +-
 .../dc/dml/dcn21/display_mode_vba_21.c|  11 +-
 .../gpu/drm/amd/display/dc/inc/dc_link_ddc.h  |   3 +
 .../gpu/drm/amd/display/dc/inc/dc_link_dp.h   |   2 +
 .../drm/amd/display/dc/inc/hw/aux_engine.h|   3 +
 .../gpu/drm/amd/display/dc/inc/hw/dchubbub.h  |   1 +
 .../gpu/drm/amd/display/dc/inc/hw/mem_input.h |   1 +
 .../gpu/drm/amd/display/dc/inc/hw_sequencer.h |   3 +
 .../include/asic_reg/dcn/dcn_2_1_0_offset.h   |  10 +
 .../gpu/drm/amd/include/renoir_ip_offset.h|  34 ++
 37 files changed, 1572 insertions(+), 126 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.h
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.h

-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 09/29] drm/amd/display: move the bounding box patch before calculate wm

2019-10-11 Thread Bhawanpreet Lakha
From: Lewis Huang 

[why]
driver updateis the dcn2_1_soc into dml before call update_bw_bounding_box

[How]
Move the patch function before calculate wm.

Signed-off-by: Lewis Huang 
Signed-off-by: joseph graveno 
Acked-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/dcn21/dcn21_resource.c | 25 +++
 1 file changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
index ddf52e260ed6..e39961d0f24e 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
@@ -1007,6 +1007,29 @@ static void calculate_wm_set_for_vlevel(
 
 }
 
+static void patch_bounding_box(struct dc *dc, struct 
_vcs_dpi_soc_bounding_box_st *bb)
+{
+   kernel_fpu_begin();
+   if (dc->bb_overrides.sr_exit_time_ns) {
+   bb->sr_exit_time_us = dc->bb_overrides.sr_exit_time_ns / 1000.0;
+   }
+
+   if (dc->bb_overrides.sr_enter_plus_exit_time_ns) {
+   bb->sr_enter_plus_exit_time_us =
+   dc->bb_overrides.sr_enter_plus_exit_time_ns / 
1000.0;
+   }
+
+   if (dc->bb_overrides.urgent_latency_ns) {
+   bb->urgent_latency_us = dc->bb_overrides.urgent_latency_ns / 
1000.0;
+   }
+
+   if (dc->bb_overrides.dram_clock_change_latency_ns) {
+   bb->dram_clock_change_latency_us =
+   dc->bb_overrides.dram_clock_change_latency_ns / 
1000.0;
+   }
+   kernel_fpu_end();
+}
+
 void dcn21_calculate_wm(
struct dc *dc, struct dc_state *context,
display_e2e_pipe_params_st *pipes,
@@ -1021,6 +1044,8 @@ void dcn21_calculate_wm(
 
ASSERT(bw_params);
 
+   patch_bounding_box(dc, >bw_ctx.dml.soc);
+
for (i = 0, pipe_idx = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; 
i++) {
if (!context->res_ctx.pipe_ctx[i].stream)
continue;
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 15/29] drm/amd/display: correct dcn21 NUM_VMID to 16

2019-10-11 Thread Bhawanpreet Lakha
From: Dmytro Laktyushkin 

1 vmid limitation only exists for HOSTVM which is a custom
use case anyway.

Signed-off-by: Dmytro Laktyushkin 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index 44f64a8e33f1..aeb5de6f4530 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -52,7 +52,7 @@
 #ifdef NUM_VMID
 #undef NUM_VMID
 #endif
-#define NUM_VMID 1
+#define NUM_VMID 16
 
 static uint32_t convert_and_clamp(
uint32_t wm_ns,
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 02/29] drm/amd/display: configurable aux timeout support

2019-10-11 Thread Bhawanpreet Lakha
From: abdoulaye berthe 

[Description]
1-add configurable timeout support to aux engine.
2-add timeout support field to dc_caps
3-add reg_key to override extended timeout support

Signed-off-by: abdoulaye berthe 
Acked-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/dc/core/dc_link_ddc.c | 14 
 drivers/gpu/drm/amd/display/dc/dc.h   |  2 +
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c  | 73 ++-
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.h  | 16 +++-
 .../amd/display/dc/dce100/dce100_resource.c   |  5 +-
 .../amd/display/dc/dce110/dce110_resource.c   |  4 +-
 .../amd/display/dc/dce112/dce112_resource.c   |  5 +-
 .../amd/display/dc/dce120/dce120_resource.c   |  5 +-
 .../drm/amd/display/dc/dce80/dce80_resource.c |  4 +-
 .../drm/amd/display/dc/dcn10/dcn10_resource.c |  5 +-
 .../drm/amd/display/dc/dcn20/dcn20_resource.c |  4 +-
 .../drm/amd/display/dc/dcn21/dcn21_resource.c |  4 +-
 .../gpu/drm/amd/display/dc/inc/dc_link_ddc.h  |  3 +
 .../gpu/drm/amd/display/dc/inc/dc_link_dp.h   |  2 +
 .../drm/amd/display/dc/inc/hw/aux_engine.h|  3 +
 15 files changed, 132 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
index 57fb0574f198..9a56f110bbd1 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
@@ -634,6 +634,20 @@ bool dc_link_aux_transfer_with_retries(struct ddc_service 
*ddc,
return dce_aux_transfer_with_retries(ddc, payload);
 }
 
+
+enum dc_status dc_link_aux_configure_timeout(struct ddc_service *ddc,
+   uint32_t timeout)
+{
+   enum dc_status status = DC_OK;
+   struct ddc *ddc_pin = ddc->ddc_pin;
+
+   if 
(ddc->ctx->dc->res_pool->engines[ddc_pin->pin_data->en]->funcs->configure_timeout
 == NULL)
+   return DC_ERROR_UNEXPECTED;
+   if 
(!ddc->ctx->dc->res_pool->engines[ddc_pin->pin_data->en]->funcs->configure_timeout(ddc,
 timeout))
+   status = DC_ERROR_UNEXPECTED;
+   return status;
+}
+
 /*test only function*/
 void dal_ddc_service_set_ddc_pin(
struct ddc_service *ddc_service,
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 41e366f59f10..5967106826ca 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -111,6 +111,7 @@ struct dc_caps {
bool force_dp_tps4_for_cp2520;
bool disable_dp_clk_share;
bool psp_setup_panel_mode;
+   bool extended_aux_timeout_support;
 #ifdef CONFIG_DRM_AMD_DC_DCN2_0
bool hw_3d_lut;
 #endif
@@ -220,6 +221,7 @@ struct dc_config {
bool power_down_display_on_boot;
bool edp_not_connected;
bool forced_clocks;
+   bool disable_extended_timeout_support; // Used to disable extended 
timeout and lttpr feature as well
bool multi_mon_pp_mclk_switch;
 };
 
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c 
b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
index de233270e3d5..976bd4987a28 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
@@ -59,6 +59,14 @@ enum {
AUX_TIMED_OUT_RETRY_COUNTER = 2,
AUX_DEFER_RETRY_COUNTER = 6
 };
+
+#define TIME_OUT_INCREMENT  1016
+#define TIME_OUT_MULTIPLIER_8  8
+#define TIME_OUT_MULTIPLIER_16  16
+#define TIME_OUT_MULTIPLIER_32  32
+#define TIME_OUT_MULTIPLIER_64  64
+#define MAX_TIMEOUT_LENGTH  127
+
 static void release_engine(
struct dce_aux *engine)
 {
@@ -202,7 +210,7 @@ static void submit_channel_request(
REG_UPDATE(AUX_INTERRUPT_CONTROL, AUX_SW_DONE_ACK, 1);
 
REG_WAIT(AUX_SW_STATUS, AUX_SW_DONE, 0,
-   10, aux110->timeout_period/10);
+   10, aux110->polling_timeout_period/10);
 
/* set the delay and the number of bytes to write */
 
@@ -331,7 +339,7 @@ static enum aux_channel_operation_result get_channel_status(
 
/* poll to make sure that SW_DONE is asserted */
REG_WAIT(AUX_SW_STATUS, AUX_SW_DONE, 1,
-   10, aux110->timeout_period/10);
+   10, aux110->polling_timeout_period/10);
 
value = REG_READ(AUX_SW_STATUS);
/* in case HPD is LOW, exit AUX transaction */
@@ -419,24 +427,81 @@ void dce110_engine_destroy(struct dce_aux **engine)
 
 }
 
+static bool dce_aux_configure_timeout(struct ddc_service *ddc,
+   uint32_t timeout_in_us)
+{
+   uint32_t multiplier = 0;
+   uint32_t length = 0;
+   uint32_t timeout = 0;
+   struct ddc *ddc_pin = ddc->ddc_pin;
+   struct dce_aux *aux_engine = 
ddc->ctx->dc->res_pool->engines[ddc_pin->pin_data->en];
+   struct aux_engine_dce110 *aux110 = FROM_AUX_ENGINE(aux_engine);
+
+   /* 1-Upd

[PATCH 12/29] drm/amd/display: Temporary workaround to toggle watermark setting

2019-10-11 Thread Bhawanpreet Lakha
From: Lewis Huang 

[Why]
Watermarks not propagated to DCHUBP after it is powered on

[How]
Add temoprary function apply_DEDCN21_147_wa to apply wm settings for Renoir

Signed-off-by: Lewis Huang 
Reviewed-by: Tony Cheng 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c| 4 
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c   | 9 +
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c | 1 +
 drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h  | 1 +
 4 files changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
index ce2530509e12..6229a8ca0013 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
@@ -1533,6 +1533,10 @@ static void dcn20_program_front_end_for_ctx(
msleep(1);
}
}
+
+   /* WA to apply WM setting*/
+   if (dc->hwseq->wa.DEGVIDCN21)
+   
dc->res_pool->hubbub->funcs->apply_DEDCN21_147_wa(dc->res_pool->hubbub);
 }
 
 
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index fdfbdeb32459..2232ccf14bdd 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -616,6 +616,14 @@ void hubbub21_wm_read_state(struct hubbub *hubbub,
DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_D, 
>dram_clk_chanage);
 }
 
+void hubbub21_apply_DEDCN21_147_wa(struct hubbub *hubbub)
+{
+   struct dcn20_hubbub *hubbub1 = TO_DCN20_HUBBUB(hubbub);
+   uint32_t prog_wm_value;
+
+   prog_wm_value = REG_READ(DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_A);
+   REG_WRITE(DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_A, prog_wm_value);
+}
 
 static const struct hubbub_funcs hubbub21_funcs = {
.update_dchub = hubbub2_update_dchub,
@@ -627,6 +635,7 @@ static const struct hubbub_funcs hubbub21_funcs = {
.wm_read_state = hubbub21_wm_read_state,
.get_dchub_ref_freq = hubbub2_get_dchub_ref_freq,
.program_watermarks = hubbub21_program_watermarks,
+   .apply_DEDCN21_147_wa = hubbub21_apply_DEDCN21_147_wa,
 };
 
 void hubbub21_construct(struct dcn20_hubbub *hubbub,
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
index e39961d0f24e..5e15f800a9f1 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
@@ -1468,6 +1468,7 @@ static struct dce_hwseq *dcn21_hwseq_create(
hws->regs = _reg;
hws->shifts = _shift;
hws->masks = _mask;
+   hws->wa.DEGVIDCN21 = true;
}
return hws;
 }
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h 
b/drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h
index a6297219d7fc..c81a17aeaa25 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h
@@ -147,6 +147,7 @@ struct hubbub_funcs {
bool (*is_allow_self_refresh_enabled)(struct hubbub *hubbub);
void (*allow_self_refresh_control)(struct hubbub *hubbub, bool allow);
 
+   void (*apply_DEDCN21_147_wa)(struct hubbub *hubbub);
 };
 
 struct hubbub {
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 07/29] drm/amd/display: create dcn21_link_encoder files

2019-10-11 Thread Bhawanpreet Lakha
[Why]
DCN20 and DCN21 have different phy programming sequences.

[How]
Create a separate dcn21_link_encoder for Renoir

Signed-off-by: Bhawanpreet Lakha 
---
 .../amd/display/dc/dcn10/dcn10_link_encoder.h |  35 +-
 .../amd/display/dc/dcn20/dcn20_link_encoder.h |   7 +
 drivers/gpu/drm/amd/display/dc/dcn21/Makefile |   2 +-
 .../amd/display/dc/dcn21/dcn21_link_encoder.c | 379 ++
 .../amd/display/dc/dcn21/dcn21_link_encoder.h |  51 +++
 .../drm/amd/display/dc/dcn21/dcn21_resource.c |  85 +++-
 6 files changed, 555 insertions(+), 4 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.h

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h
index 0c12395cfa36..239a6c90ffb9 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h
@@ -250,6 +250,10 @@ struct dcn10_link_enc_registers {
type RDPCS_EXT_REFCLK_EN;\
type RDPCS_TX_FIFO_EN;\
type UNIPHY_LINK_ENABLE;\
+   type UNIPHY_CHANNEL0_XBAR_SOURCE;\
+   type UNIPHY_CHANNEL1_XBAR_SOURCE;\
+   type UNIPHY_CHANNEL2_XBAR_SOURCE;\
+   type UNIPHY_CHANNEL3_XBAR_SOURCE;\
type UNIPHY_CHANNEL0_INVERT;\
type UNIPHY_CHANNEL1_INVERT;\
type UNIPHY_CHANNEL2_INVERT;\
@@ -342,12 +346,41 @@ struct dcn10_link_enc_registers {
type RDPCS_PHY_DPALT_DISABLE_ACK;\
type RDPCS_PHY_DP_MPLLB_V2I;\
type RDPCS_PHY_DP_MPLLB_FREQ_VCO;\
+   type RDPCS_PHY_DP_MPLLB_CP_INT_GS;\
+   type RDPCS_PHY_RX_VREF_CTRL;\
type RDPCS_PHY_DP_MPLLB_CP_INT;\
type RDPCS_PHY_DP_MPLLB_CP_PROP;\
type RDPCS_PHY_RX_REF_LD_VAL;\
type RDPCS_PHY_RX_VCO_LD_VAL;\
type DPCSTX_DEBUG_CONFIG; \
-   type RDPCSTX_DEBUG_CONFIG
+   type RDPCSTX_DEBUG_CONFIG; \
+   type RDPCS_PHY_DP_TX0_EQ_MAIN;\
+   type RDPCS_PHY_DP_TX0_EQ_PRE;\
+   type RDPCS_PHY_DP_TX0_EQ_POST;\
+   type RDPCS_PHY_DP_TX1_EQ_MAIN;\
+   type RDPCS_PHY_DP_TX1_EQ_PRE;\
+   type RDPCS_PHY_DP_TX1_EQ_POST;\
+   type RDPCS_PHY_DP_TX2_EQ_MAIN;\
+   type RDPCS_PHY_DP_MPLLB_CP_PROP_GS;\
+   type RDPCS_PHY_DP_TX2_EQ_PRE;\
+   type RDPCS_PHY_DP_TX2_EQ_POST;\
+   type RDPCS_PHY_DP_TX3_EQ_MAIN;\
+   type RDPCS_PHY_DCO_RANGE;\
+   type RDPCS_PHY_DCO_FINETUNE;\
+   type RDPCS_PHY_DP_TX3_EQ_PRE;\
+   type RDPCS_PHY_DP_TX3_EQ_POST;\
+   type RDPCS_PHY_SUP_PRE_HP;\
+   type RDPCS_PHY_DP_TX0_VREGDRV_BYP;\
+   type RDPCS_PHY_DP_TX1_VREGDRV_BYP;\
+   type RDPCS_PHY_DP_TX2_VREGDRV_BYP;\
+   type RDPCS_PHY_DP_TX3_VREGDRV_BYP;\
+   type RDPCS_DMCU_DPALT_DIS_BLOCK_REG;\
+   type UNIPHYA_SOFT_RESET;\
+   type UNIPHYB_SOFT_RESET;\
+   type UNIPHYC_SOFT_RESET;\
+   type UNIPHYD_SOFT_RESET;\
+   type UNIPHYE_SOFT_RESET;\
+   type UNIPHYF_SOFT_RESET
 
 #define DCN20_LINK_ENCODER_REG_FIELD_LIST(type) \
type DIG_LANE0EN;\
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_link_encoder.h 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_link_encoder.h
index 3736b5548a25..0c98a0bbbd14 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_link_encoder.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_link_encoder.h
@@ -91,6 +91,13 @@ struct mpll_cfg {
uint32_t ref_range;
uint32_t ref_clk;
bool hdmimode_enable;
+   bool sup_pre_hp;
+   bool dp_tx0_vergdrv_byp;
+   bool dp_tx1_vergdrv_byp;
+   bool dp_tx2_vergdrv_byp;
+   bool dp_tx3_vergdrv_byp;
+
+
 };
 
 struct dpcssys_phy_seq_cfg {
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile 
b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
index 5b8f42ae2334..b7a9285348fb 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
@@ -1,7 +1,7 @@
 #
 # Makefile for DCN21.
 
-DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o dcn21_hwseq.o
+DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o dcn21_hwseq.o 
dcn21_link_encoder.o
 
 CFLAGS_dcn21_resource.o := -mhard-float -msse -mpreferred-stack-boundary=4
 
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c
new file mode 100644
index ..526865c43b48
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c
@@ -0,0 +1,379 @@
+/*
+ * Copyright 2012-15 Advanced Micro

[PATCH 16/29] drm/amd/display: add detile buffer size for renoir

2019-10-11 Thread Bhawanpreet Lakha
Detile buffer size affects dcc caps, it was already added for
dcn2. Now add it for dcn21

Signed-off-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index aeb5de6f4530..f546260c15b7 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -653,4 +653,5 @@ void hubbub21_construct(struct dcn20_hubbub *hubbub,
hubbub->masks = hubbub_mask;
 
hubbub->debug_test_index_pstate = 0xB;
+   hubbub->detile_buf_size = 164 * 1024; /* 164KB for DCN2.0 */
 }
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 19/29] drm/amd/display: change PP_SM defs to 8

2019-10-11 Thread Bhawanpreet Lakha
DPM level is 8 these were incorrect before. Fix them

Signed-off-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dm_pp_smu.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dm_pp_smu.h 
b/drivers/gpu/drm/amd/display/dc/dm_pp_smu.h
index c03a441ee638..de3c83c8f6c3 100644
--- a/drivers/gpu/drm/amd/display/dc/dm_pp_smu.h
+++ b/drivers/gpu/drm/amd/display/dc/dm_pp_smu.h
@@ -252,9 +252,9 @@ struct pp_smu_funcs_nv {
 #if defined(CONFIG_DRM_AMD_DC_DCN2_1)
 
 #define PP_SMU_NUM_SOCCLK_DPM_LEVELS  8
-#define PP_SMU_NUM_DCFCLK_DPM_LEVELS  4
-#define PP_SMU_NUM_FCLK_DPM_LEVELS4
-#define PP_SMU_NUM_MEMCLK_DPM_LEVELS  4
+#define PP_SMU_NUM_DCFCLK_DPM_LEVELS  8
+#define PP_SMU_NUM_FCLK_DPM_LEVELS8
+#define PP_SMU_NUM_MEMCLK_DPM_LEVELS  8
 
 struct dpm_clock {
   uint32_t  Freq;// In MHz
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 28/29] drm/amd/display: handle dp is usb-c

2019-10-11 Thread Bhawanpreet Lakha
This patch adds handling of dp is usb-c, it is not tested but is
needed to support dp over usb-c

Signed-off-by: Bhawanpreet Lakha 
---
 .../amd/display/dc/dcn10/dcn10_link_encoder.h | 14 +++
 .../amd/display/dc/dcn21/dcn21_link_encoder.c | 93 ++-
 .../amd/display/dc/dcn21/dcn21_link_encoder.h | 10 ++
 3 files changed, 116 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h
index 239a6c90ffb9..88fcc395adf5 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h
@@ -113,6 +113,20 @@ struct dcn10_link_enc_registers {
uint32_t DIG_LANE_ENABLE;
/* UNIPHY */
uint32_t CHANNEL_XBAR_CNTL;
+   /* DPCS */
+   uint32_t RDPCSTX_PHY_CNTL3;
+   uint32_t RDPCSTX_PHY_CNTL4;
+   uint32_t RDPCSTX_PHY_CNTL5;
+   uint32_t RDPCSTX_PHY_CNTL6;
+   uint32_t RDPCSTX_PHY_CNTL7;
+   uint32_t RDPCSTX_PHY_CNTL8;
+   uint32_t RDPCSTX_PHY_CNTL9;
+   uint32_t RDPCSTX_PHY_CNTL10;
+   uint32_t RDPCSTX_PHY_CNTL11;
+   uint32_t RDPCSTX_PHY_CNTL12;
+   uint32_t RDPCSTX_PHY_CNTL13;
+   uint32_t RDPCSTX_PHY_CNTL14;
+   uint32_t RDPCSTX_PHY_CNTL15;
/* indirect registers */
uint32_t RAWLANE0_DIG_PCS_XF_RX_OVRD_IN_2;
uint32_t RAWLANE0_DIG_PCS_XF_RX_OVRD_IN_3;
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c
index 526865c43b48..e8a504ca5890 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c
@@ -203,6 +203,77 @@ static bool update_cfg_data(
return true;
 }
 
+void dcn21_link_encoder_get_max_link_cap(struct link_encoder *enc,
+   struct dc_link_settings *link_settings)
+{
+   struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc);
+   uint32_t value;
+
+   REG_GET(RDPCSTX_PHY_CNTL6, RDPCS_PHY_DPALT_DP4, );
+
+   if (!value && link_settings->lane_count > LANE_COUNT_TWO)
+   link_settings->lane_count = LANE_COUNT_TWO;
+}
+
+bool dcn21_link_encoder_is_in_alt_mode(struct link_encoder *enc)
+{
+   struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc);
+   uint32_t value;
+
+   REG_GET(RDPCSTX_PHY_CNTL6, RDPCS_PHY_DPALT_DISABLE, );
+
+   // if value == 1 alt mode is disabled, otherwise it is enabled
+   return !value;
+}
+
+bool dcn21_link_encoder_acquire_phy(struct link_encoder *enc)
+{
+   struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc);
+   int value;
+
+   if (enc->features.flags.bits.DP_IS_USB_C) {
+   REG_GET(RDPCSTX_PHY_CNTL6,
+   RDPCS_PHY_DPALT_DISABLE, );
+
+   if (value == 1) {
+   ASSERT(0);
+   return false;
+   }
+   REG_UPDATE(RDPCSTX_PHY_CNTL6,
+   RDPCS_PHY_DPALT_DISABLE_ACK, 0);
+
+   udelay(40);
+
+   REG_GET(RDPCSTX_PHY_CNTL6,
+   RDPCS_PHY_DPALT_DISABLE, 
);
+   if (value == 1) {
+   ASSERT(0);
+   REG_UPDATE(RDPCSTX_PHY_CNTL6,
+   RDPCS_PHY_DPALT_DISABLE_ACK, 1);
+   return false;
+   }
+   }
+
+   REG_UPDATE(RDPCSTX_PHY_CNTL6, RDPCS_PHY_DP_REF_CLK_EN, 1);
+
+   return true;
+}
+
+
+
+static void dcn21_link_encoder_release_phy(struct link_encoder *enc)
+{
+   struct dcn10_link_encoder *enc10 = TO_DCN10_LINK_ENC(enc);
+
+   if (enc->features.flags.bits.DP_IS_USB_C) {
+   REG_UPDATE(RDPCSTX_PHY_CNTL6,
+   RDPCS_PHY_DPALT_DISABLE_ACK, 1);
+   }
+
+   REG_UPDATE(RDPCSTX_PHY_CNTL6, RDPCS_PHY_DP_REF_CLK_EN, 0);
+
+}
+
 void dcn21_link_encoder_enable_dp_output(
struct link_encoder *enc,
const struct dc_link_settings *link_settings,
@@ -212,6 +283,9 @@ void dcn21_link_encoder_enable_dp_output(
struct dcn21_link_encoder *enc21 = (struct dcn21_link_encoder *) enc10;
struct dpcssys_phy_seq_cfg *cfg = >phy_seq_cfg;
 
+   if (!dcn21_link_encoder_acquire_phy(enc))
+   return;
+
if (!enc->ctx->dc->debug.avoid_vbios_exec_table) {
dcn10_link_encoder_enable_dp_output(enc, link_settings, 
clock_source);
return;
@@ -226,13 +300,28 @@ void dcn21_link_encoder_enable_dp_output(
 
 }
 
+void dcn21_link_encoder_enable_dp_mst_output(
+   struct link_encoder *enc,
+   const struct dc_link_settings *link_settings,
+   enum clock_source_id clock_source)
+{
+   if (!dcn21_link_encoder_acquire_phy(enc))
+   return;
+
+   dcn10_link_encoder_enable_dp_mst_outpu

[PATCH 24/29] drm/amd/display: add sanity check for clk table from smu

2019-10-11 Thread Bhawanpreet Lakha
From: Eric Yang 

[Why]
Handle the case where we don't get a valid table. Also fixes compiler
warning for variable potentially used before assignment.

[How]
If the entire table has no valid fclk, reject the table and use our own
hard code.

Signed-off-by: Eric Yang 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
index fb8aa9436bf0..0e712df87109 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
@@ -546,6 +546,8 @@ void rn_clk_mgr_helper_populate_bw_params(struct 
clk_bw_params *bw_params, struc
 {
int i, j = 0;
 
+   j = -1;
+
ASSERT(PP_SMU_NUM_FCLK_DPM_LEVELS <= MAX_NUM_DPM_LVL);
 
/* Find lowest DPM, FCLK is filled in reverse order*/
@@ -557,6 +559,12 @@ void rn_clk_mgr_helper_populate_bw_params(struct 
clk_bw_params *bw_params, struc
}
}
 
+   if (j == -1) {
+   /* clock table is all 0s, just use our own hardcode */
+   ASSERT(0);
+   return;
+   }
+
bw_params->clk_table.num_entries = j + 1;
 
for (i = 0; i < bw_params->clk_table.num_entries; i++, j--) {
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 05/29] drm/amd/display: Add DCN_BASE regs

2019-10-11 Thread Bhawanpreet Lakha
Signed-off-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/include/renoir_ip_offset.h| 34 +++
 1 file changed, 34 insertions(+)

diff --git a/drivers/gpu/drm/amd/include/renoir_ip_offset.h 
b/drivers/gpu/drm/amd/include/renoir_ip_offset.h
index 094648cac392..07633e22e99a 100644
--- a/drivers/gpu/drm/amd/include/renoir_ip_offset.h
+++ b/drivers/gpu/drm/amd/include/renoir_ip_offset.h
@@ -169,6 +169,11 @@ static const struct IP_BASE NBIF0_BASE ={ { { { 
0x, 0x0014, 0x0D
 { { 0, 0, 0, 0, 0 } },
 { { 0, 0, 0, 0, 0 } },
 { { 0, 0, 0, 0, 0 } } } };
+static const struct IP_BASE DCN_BASE   ={ { { { 0x0012, 0x00C0, 
0x34C0, 0, 0 } },
+{ { 0, 0, 0, 0, 0 } },
+{ { 0, 0, 0, 0, 0 } },
+{ { 0, 0, 0, 0, 0 } },
+{ { 0, 0, 0, 0, 0 } } } };
 static const struct IP_BASE OSSSYS_BASE ={ { { { 0x10A0, 0x0240A000, 0, 0, 
0 } },
 { { 0, 0, 0, 0, 0 } },
 { { 0, 0, 0, 0, 0 } },
@@ -1361,4 +1366,33 @@ static const struct IP_BASE UVD0_BASE ={ { { { 
0x7800, 0x7E00, 0x0240300
 #define UVD0_BASE__INST6_SEG3  0
 #define UVD0_BASE__INST6_SEG4  0
 
+#define DCN_BASE__INST0_SEG0  0x0012
+#define DCN_BASE__INST0_SEG1  0x00C0
+#define DCN_BASE__INST0_SEG2  0x34C0
+#define DCN_BASE__INST0_SEG3  0
+#define DCN_BASE__INST0_SEG4  0
+
+#define DCN_BASE__INST1_SEG0  0
+#define DCN_BASE__INST1_SEG1  0
+#define DCN_BASE__INST1_SEG2  0
+#define DCN_BASE__INST1_SEG3  0
+#define DCN_BASE__INST1_SEG4  0
+
+#define DCN_BASE__INST2_SEG0  0
+#define DCN_BASE__INST2_SEG1  0
+#define DCN_BASE__INST2_SEG2  0
+#define DCN_BASE__INST2_SEG3  0
+#define DCN_BASE__INST2_SEG4  0
+
+#define DCN_BASE__INST3_SEG0  0
+#define DCN_BASE__INST3_SEG1  0
+#define DCN_BASE__INST3_SEG2  0
+#define DCN_BASE__INST3_SEG3  0
+#define DCN_BASE__INST3_SEG4  0
+
+#define DCN_BASE__INST4_SEG0  0
+#define DCN_BASE__INST4_SEG1  0
+#define DCN_BASE__INST4_SEG2  0
+#define DCN_BASE__INST4_SEG3  0
+#define DCN_BASE__INST4_SEG4  0
 #endif
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 23/29] drm/amd/display: Fix rn audio playback and video playback speed

2019-10-11 Thread Bhawanpreet Lakha
From: Michael Strauss 

[WHY]
dprefclk is improperly read due to incorrect units used.
Causes an audio clock to be improperly set, making audio
non-functional and videos play back too fast

[HOW]
Scale dprefclk value from MHz to KHz (multiply by 1000)
to ensure that dprefclk_khz is in correct units

Signed-off-by: Michael Strauss 
Acked-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
index 93e46e376bb1..fb8aa9436bf0 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
@@ -377,7 +377,7 @@ void rn_get_clk_states(struct clk_mgr *clk_mgr_base, struct 
clk_states *s)
 
rn_dump_clk_registers(, clk_mgr_base, _info);
 
-   s->dprefclk_khz = sb.dprefclk;
+   s->dprefclk_khz = sb.dprefclk * 1000;
 }
 
 void rn_enable_pme_wa(struct clk_mgr *clk_mgr_base)
@@ -633,16 +633,15 @@ void rn_clk_mgr_construct(
clk_mgr->dentist_vco_freq_khz = 360;
 
rn_dump_clk_registers(, _mgr->base, _info);
-   clk_mgr->base.dprefclk_khz = s.dprefclk;
-
-   if (clk_mgr->base.dprefclk_khz != 60) {
-   clk_mgr->base.dprefclk_khz = 60;
-   ASSERT(1); //TODO: Renoir follow up.
-   }
+   /* Convert dprefclk units from MHz to KHz */
+   /* Value already divided by 10, some resolution lost */
+   clk_mgr->base.dprefclk_khz = s.dprefclk * 1000;
 
/* in case we don't get a value from the register, use default 
*/
-   if (clk_mgr->base.dprefclk_khz == 0)
+   if (clk_mgr->base.dprefclk_khz == 0) {
+   ASSERT(clk_mgr->base.dprefclk_khz == 60);
clk_mgr->base.dprefclk_khz = 60;
+   }
}
 
dce_clock_read_ss_info(clk_mgr);
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 17/29] drm/amd/display: update dcn21 hubbub registers

2019-10-11 Thread Bhawanpreet Lakha
use dcn20 common regs define to share some regs with dcn20

Signed-off-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.h | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.h 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.h
index 698c470cc0f6..c4840dfb1fa5 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.h
@@ -36,6 +36,10 @@
SR(DCHUBBUB_ARB_FRAC_URG_BW_FLIP_B),\
SR(DCHUBBUB_ARB_FRAC_URG_BW_FLIP_C),\
SR(DCHUBBUB_ARB_FRAC_URG_BW_FLIP_D),\
+   SR(DCHUBBUB_ARB_REFCYC_PER_TRIP_TO_MEMORY_A),\
+   SR(DCHUBBUB_ARB_REFCYC_PER_TRIP_TO_MEMORY_B),\
+   SR(DCHUBBUB_ARB_REFCYC_PER_TRIP_TO_MEMORY_C),\
+   SR(DCHUBBUB_ARB_REFCYC_PER_TRIP_TO_MEMORY_D),\
SR(DCHUBBUB_ARB_HOSTVM_CNTL), \
SR(DCHVM_CTRL0), \
SR(DCHVM_MEM_CTRL), \
@@ -44,16 +48,9 @@
SR(DCHVM_RIOMMU_STAT0)
 
 #define HUBBUB_REG_LIST_DCN21()\
-   HUBBUB_REG_LIST_DCN_COMMON(), \
+   HUBBUB_REG_LIST_DCN20_COMMON(), \
HUBBUB_SR_WATERMARK_REG_LIST(), \
-   HUBBUB_HVM_REG_LIST(), \
-   SR(DCHUBBUB_CRC_CTRL), \
-   SR(DCN_VM_FB_LOCATION_BASE),\
-   SR(DCN_VM_FB_LOCATION_TOP),\
-   SR(DCN_VM_FB_OFFSET),\
-   SR(DCN_VM_AGP_BOT),\
-   SR(DCN_VM_AGP_TOP),\
-   SR(DCN_VM_AGP_BASE)
+   HUBBUB_HVM_REG_LIST()
 
 #define HUBBUB_MASK_SH_LIST_HVM(mask_sh) \
HUBBUB_SF(DCHUBBUB_ARB_DF_REQ_OUTSTAND, 
DCHUBBUB_ARB_MIN_REQ_OUTSTAND_COMMIT_THRESHOLD, mask_sh), \
@@ -102,7 +99,7 @@
HUBBUB_SF(DCHUBBUB_ARB_REFCYC_PER_TRIP_TO_MEMORY_D, 
DCHUBBUB_ARB_REFCYC_PER_TRIP_TO_MEMORY_D, mask_sh)
 
 #define HUBBUB_MASK_SH_LIST_DCN21(mask_sh)\
-   HUBBUB_MASK_SH_LIST_HVM(mask_sh),\
+   HUBBUB_MASK_SH_LIST_HVM(mask_sh), \
HUBBUB_MASK_SH_LIST_DCN_COMMON(mask_sh), \
HUBBUB_MASK_SH_LIST_STUTTER(mask_sh), \
HUBBUB_SF(DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_REFDIV, 
mask_sh), \
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 11/29] drm/amd/display: fix incorrect page table address for renoir

2019-10-11 Thread Bhawanpreet Lakha
Incorrect page table address and programming sys aperture for
stutter gather, so fix it.

Signed-off-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/dcn21/dcn21_hubbub.c   | 23 ++-
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index bd247e5e753e..fdfbdeb32459 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -111,19 +111,30 @@ int hubbub21_init_dchub(struct hubbub *hubbub,
struct dcn_hubbub_phys_addr_config *pa_config)
 {
struct dcn20_hubbub *hubbub1 = TO_DCN20_HUBBUB(hubbub);
+   struct dcn_vmid_page_table_config phys_config;
 
REG_SET(DCN_VM_FB_LOCATION_BASE, 0,
-   FB_BASE, pa_config->system_aperture.fb_base);
+   FB_BASE, pa_config->system_aperture.fb_base >> 24);
REG_SET(DCN_VM_FB_LOCATION_TOP, 0,
-   FB_TOP, pa_config->system_aperture.fb_top);
+   FB_TOP, pa_config->system_aperture.fb_top >> 24);
REG_SET(DCN_VM_FB_OFFSET, 0,
-   FB_OFFSET, pa_config->system_aperture.fb_offset);
+   FB_OFFSET, pa_config->system_aperture.fb_offset >> 24);
REG_SET(DCN_VM_AGP_BOT, 0,
-   AGP_BOT, pa_config->system_aperture.agp_bot);
+   AGP_BOT, pa_config->system_aperture.agp_bot >> 24);
REG_SET(DCN_VM_AGP_TOP, 0,
-   AGP_TOP, pa_config->system_aperture.agp_top);
+   AGP_TOP, pa_config->system_aperture.agp_top >> 24);
REG_SET(DCN_VM_AGP_BASE, 0,
-   AGP_BASE, pa_config->system_aperture.agp_base);
+   AGP_BASE, pa_config->system_aperture.agp_base >> 24);
+
+   if (pa_config->gart_config.page_table_start_addr != 
pa_config->gart_config.page_table_end_addr) {
+   phys_config.page_table_start_addr = 
pa_config->gart_config.page_table_start_addr >> 12;
+   phys_config.page_table_end_addr = 
pa_config->gart_config.page_table_end_addr >> 12;
+   phys_config.page_table_base_addr = 
pa_config->gart_config.page_table_base_addr | 1; //Note: hack
+   phys_config.depth = 0;
+   phys_config.block_size = 0;
+   // Init VMID 0 based on PA config
+   dcn20_vmid_setup(>vmid[0], _config);
+   }
 
dcn21_dchvm_init(hubbub);
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 20/29] drm/amd/display: add dummy functions to smu for Renoir Silicon Diags

2019-10-11 Thread Bhawanpreet Lakha
From: Sung Lee 

[Why]
Previously only dummy functions were added in Diags for FPGA.
On silicon, this would lead to a segmentation fault on silicon diags.

[How]
Check if diags silicon and if so, add dummy functions.

Signed-off-by: Sung Lee 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
index 002e7fb67068..25f62a3f2ffc 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
@@ -1397,7 +1397,7 @@ static struct pp_smu_funcs *dcn21_pp_smu_create(struct 
dc_context *ctx)
if (!pp_smu)
return pp_smu;
 
-   if (IS_FPGA_MAXIMUS_DC(ctx->dce_environment)) {
+   if (IS_FPGA_MAXIMUS_DC(ctx->dce_environment) || 
IS_DIAG_DC(ctx->dce_environment)) {
pp_smu->ctx.ver = PP_SMU_VER_RN;
pp_smu->rn_funcs.get_dpm_clock_table = 
dummy_get_dpm_clock_table;
pp_smu->rn_funcs.set_wm_ranges = dummy_set_wm_ranges;
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 03/29] drm/amd/display: disable ext aux support for vega

2019-10-11 Thread Bhawanpreet Lakha
From: Roman Li 

[Why]
Earlier changes to support configurable aux timeout
caused dc init failure on vega due to missing reg defs.
Needs to be disabled until implemented for vega.

[How]
Set extended aux timeout cap for vega to false.

fixes: drm/amd/display: configurable aux timeout support

Signed-off-by: Roman Li 
Reviewed-By: abdoulaye berthe 
---
 drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c 
b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
index 75dd9457cc2d..c30faa05fd27 100644
--- a/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dce120/dce120_resource.c
@@ -1017,7 +1017,7 @@ static bool construct(
dc->caps.max_cursor_size = 128;
dc->caps.dual_link_dvi = true;
dc->caps.psp_setup_panel_mode = true;
-   dc->caps.extended_aux_timeout_support = true;
+   dc->caps.extended_aux_timeout_support = false;
dc->debug = debug_defaults;
 
/*
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 10/29] drm/amd/display: enable hostvm based on roimmu active for dcn2.1

2019-10-11 Thread Bhawanpreet Lakha
From: Dmytro Laktyushkin 

Enabling hostvm when ROIMMU is not active seems to break GPUVM.
This fixes the issue by not enabling hostvm if ROIMMU is not
activated.

Signed-off-by: Dmytro Laktyushkin 
Acked-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/dcn21/dcn21_hubbub.c   | 40 ---
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index 8e7e79f44272..bd247e5e753e 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -22,6 +22,7 @@
  * Authors: AMD
  *
  */
+#include 
 #include "dm_services.h"
 #include "dcn20/dcn20_hubbub.h"
 #include "dcn21_hubbub.h"
@@ -71,30 +72,39 @@ static uint32_t convert_and_clamp(
 void dcn21_dchvm_init(struct hubbub *hubbub)
 {
struct dcn20_hubbub *hubbub1 = TO_DCN20_HUBBUB(hubbub);
+   uint32_t riommu_active;
+   int i;
 
//Init DCHVM block
REG_UPDATE(DCHVM_CTRL0, HOSTVM_INIT_REQ, 1);
 
//Poll until RIOMMU_ACTIVE = 1
-   //TODO: Figure out interval us and retry count
-   REG_WAIT(DCHVM_RIOMMU_STAT0, RIOMMU_ACTIVE, 1, 5, 100);
+   for (i = 0; i < 100; i++) {
+   REG_GET(DCHVM_RIOMMU_STAT0, RIOMMU_ACTIVE, _active);
 
-   //Reflect the power status of DCHUBBUB
-   REG_UPDATE(DCHVM_RIOMMU_CTRL0, HOSTVM_POWERSTATUS, 1);
+   if (riommu_active)
+   break;
+   else
+   udelay(5);
+   }
+
+   if (riommu_active) {
+   //Reflect the power status of DCHUBBUB
+   REG_UPDATE(DCHVM_RIOMMU_CTRL0, HOSTVM_POWERSTATUS, 1);
 
-   //Start rIOMMU prefetching
-   REG_UPDATE(DCHVM_RIOMMU_CTRL0, HOSTVM_PREFETCH_REQ, 1);
+   //Start rIOMMU prefetching
+   REG_UPDATE(DCHVM_RIOMMU_CTRL0, HOSTVM_PREFETCH_REQ, 1);
 
-   // Enable dynamic clock gating
-   REG_UPDATE_4(DCHVM_CLK_CTRL,
-   HVM_DISPCLK_R_GATE_DIS, 0,
-   HVM_DISPCLK_G_GATE_DIS, 0,
-   HVM_DCFCLK_R_GATE_DIS, 0,
-   HVM_DCFCLK_G_GATE_DIS, 0);
+   // Enable dynamic clock gating
+   REG_UPDATE_4(DCHVM_CLK_CTRL,
+   HVM_DISPCLK_R_GATE_DIS, 0,
+   HVM_DISPCLK_G_GATE_DIS, 0,
+   HVM_DCFCLK_R_GATE_DIS, 0,
+   HVM_DCFCLK_G_GATE_DIS, 0);
 
-   //Poll until HOSTVM_PREFETCH_DONE = 1
-   //TODO: Figure out interval us and retry count
-   REG_WAIT(DCHVM_RIOMMU_STAT0, HOSTVM_PREFETCH_DONE, 1, 5, 100);
+   //Poll until HOSTVM_PREFETCH_DONE = 1
+   REG_WAIT(DCHVM_RIOMMU_STAT0, HOSTVM_PREFETCH_DONE, 1, 5, 100);
+   }
 }
 
 int hubbub21_init_dchub(struct hubbub *hubbub,
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 01/29] drm/amd/display: update register field access mechanism

2019-10-11 Thread Bhawanpreet Lakha
From: abdoulaye berthe 

1-add timeout length and multiplier fields to aux_control1 register
2-update access mechanism from macro constructed name to uint32_t
defined addresses.
3-define registers and field per asic family

Signed-off-by: abdoulaye berthe 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c  |  11 +-
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.h  | 175 +-
 .../amd/display/dc/dce100/dce100_resource.c   |  12 +-
 .../amd/display/dc/dce110/dce110_resource.c   |  12 +-
 .../amd/display/dc/dce112/dce112_resource.c   |  12 +-
 .../amd/display/dc/dce120/dce120_resource.c   |  12 +-
 .../drm/amd/display/dc/dce80/dce80_resource.c |  12 +-
 .../drm/amd/display/dc/dcn10/dcn10_resource.c |  12 +-
 .../drm/amd/display/dc/dcn20/dcn20_resource.c |  13 +-
 .../drm/amd/display/dc/dcn21/dcn21_resource.c |  12 +-
 10 files changed, 271 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c 
b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
index 48a0e4ae80c2..de233270e3d5 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
@@ -42,6 +42,10 @@
 
 #include "reg_helper.h"
 
+#undef FN
+#define FN(reg_name, field_name) \
+   aux110->shift->field_name, aux110->mask->field_name
+
 #define FROM_AUX_ENGINE(ptr) \
container_of((ptr), struct aux_engine_dce110, base)
 
@@ -414,11 +418,14 @@ void dce110_engine_destroy(struct dce_aux **engine)
*engine = NULL;
 
 }
+
 struct dce_aux *dce110_aux_engine_construct(struct aux_engine_dce110 
*aux_engine110,
struct dc_context *ctx,
uint32_t inst,
uint32_t timeout_period,
-   const struct dce110_aux_registers *regs)
+   const struct dce110_aux_registers *regs,
+   const struct dce110_aux_registers_mask *mask,
+   const struct dce110_aux_registers_shift *shift)
 {
aux_engine110->base.ddc = NULL;
aux_engine110->base.ctx = ctx;
@@ -428,6 +435,8 @@ struct dce_aux *dce110_aux_engine_construct(struct 
aux_engine_dce110 *aux_engine
aux_engine110->timeout_period = timeout_period;
aux_engine110->regs = regs;
 
+   aux_engine110->mask = mask;
+   aux_engine110->shift = shift;
return _engine110->base;
 }
 
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.h 
b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.h
index ed7fec8fe253..717378502e9d 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.h
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.h
@@ -29,6 +29,7 @@
 #include "i2caux_interface.h"
 #include "inc/hw/aux_engine.h"
 
+
 #ifdef CONFIG_DRM_AMD_DC_DCN2_0
 #define AUX_COMMON_REG_LIST0(id)\
SRI(AUX_CONTROL, DP_AUX, id), \
@@ -36,6 +37,7 @@
SRI(AUX_SW_DATA, DP_AUX, id), \
SRI(AUX_SW_CONTROL, DP_AUX, id), \
SRI(AUX_INTERRUPT_CONTROL, DP_AUX, id), \
+   SRI(AUX_DPHY_RX_CONTROL1, DP_AUX, id), \
SRI(AUX_SW_STATUS, DP_AUX, id)
 #endif
 
@@ -55,6 +57,7 @@ struct dce110_aux_registers {
uint32_t AUX_SW_DATA;
uint32_t AUX_SW_CONTROL;
uint32_t AUX_INTERRUPT_CONTROL;
+   uint32_t AUX_DPHY_RX_CONTROL1;
uint32_t AUX_SW_STATUS;
uint32_t AUXN_IMPCAL;
uint32_t AUXP_IMPCAL;
@@ -62,6 +65,156 @@ struct dce110_aux_registers {
uint32_t AUX_RESET_MASK;
 };
 
+#define DCE_AUX_REG_FIELD_LIST(type)\
+   type AUX_EN;\
+   type AUX_RESET;\
+   type AUX_RESET_DONE;\
+   type AUX_REG_RW_CNTL_STATUS;\
+   type AUX_SW_USE_AUX_REG_REQ;\
+   type AUX_SW_DONE_USING_AUX_REG;\
+   type AUX_SW_AUTOINCREMENT_DISABLE;\
+   type AUX_SW_DATA_RW;\
+   type AUX_SW_INDEX;\
+   type AUX_SW_GO;\
+   type AUX_SW_DATA;\
+   type AUX_SW_REPLY_BYTE_COUNT;\
+   type AUX_SW_DONE;\
+   type AUX_SW_DONE_ACK;\
+   type AUXN_IMPCAL_ENABLE;\
+   type AUXP_IMPCAL_ENABLE;\
+   type AUXN_IMPCAL_OVERRIDE_ENABLE;\
+   type AUXP_IMPCAL_OVERRIDE_ENABLE;\
+   type AUX_RX_TIMEOUT_LEN;\
+   type AUX_RX_TIMEOUT_LEN_MUL;\
+   type AUXN_CALOUT_ERROR_AK;\
+   type AUXP_CALOUT_ERROR_AK;\
+   type AUX_SW_START_DELAY;\
+   type AUX_SW_WR_BYTES
+
+#define DCE10_AUX_MASK_SH_LIST(mask_sh)\
+   AUX_SF(AUX_CONTROL, AUX_EN, mask_sh),\
+   AUX_SF(AUX_ARB_CONTROL, AUX_REG_RW_CNTL_STATUS, mask_sh),\
+   AUX_SF(AUX_ARB_CONTROL, AUX_SW_USE_AUX_REG_REQ, mask_sh),\
+   AUX_SF(AUX_ARB_CONTROL, AUX_SW_DONE_USING_AUX_REG, mask_sh),\
+   AUX_SF(AUX_SW_CONTROL, AUX_SW_START_DELAY, mask_sh),\
+   AUX_SF(AUX_SW_CONTROL, AUX_SW_WR_BYTES, mask_sh),\
+   AUX_SF(AUX_SW_CONTROL, AUX_SW_GO, mask_sh),\
+   AUX_SF(AUX_SW_DATA, AUX_SW_AUTOINCREMENT_DISABLE, mask_sh),\
+   AUX_SF(AUX_SW_DATA, AUX_SW_DATA_RW, mask_sh),\
+   AUX_SF(AUX_SW_DATA, AUX_SW_AUTOINCREMENT_DISABLE, mask_sh),\
+   

[PATCH 29/29] drm/amd/display: null check pp_smu clock table before using it

2019-10-11 Thread Bhawanpreet Lakha
Signed-off-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
index 0e712df87109..b647e0320e4b 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
@@ -656,7 +656,7 @@ void rn_clk_mgr_construct(
 
clk_mgr->base.bw_params = _bw_params;
 
-   if (pp_smu) {
+   if (pp_smu && pp_smu->rn_funcs.get_dpm_clock_table) {
pp_smu->rn_funcs.get_dpm_clock_table(_smu->rn_funcs.pp_smu, 
_table);
rn_clk_mgr_helper_populate_bw_params(clk_mgr->base.bw_params, 
_table, >asic_id);
}
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 06/29] drm/amd/display: Add renoir hw_seq

2019-10-11 Thread Bhawanpreet Lakha
This change adds renoir hw_seq, needed to do renoir
specific hw programing

Signed-off-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/dc/dce/dce_hwseq.h|   1 +
 .../amd/display/dc/dcn10/dcn10_hw_sequencer.c |   4 +
 drivers/gpu/drm/amd/display/dc/dcn21/Makefile |   2 +-
 .../drm/amd/display/dc/dcn21/dcn21_hwseq.c| 122 ++
 .../drm/amd/display/dc/dcn21/dcn21_hwseq.h|  33 +
 .../drm/amd/display/dc/dcn21/dcn21_resource.c | 118 +
 .../gpu/drm/amd/display/dc/inc/hw_sequencer.h |   3 +
 7 files changed, 255 insertions(+), 28 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.h

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h 
b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h
index ac04d77058f0..32d145a0d6fc 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h
@@ -679,6 +679,7 @@ struct dce_hwseq_registers {
HWS_SF(, DOMAIN17_PG_STATUS, DOMAIN17_PGFSM_PWR_STATUS, mask_sh), \
HWS_SF(, DOMAIN18_PG_STATUS, DOMAIN18_PGFSM_PWR_STATUS, mask_sh), \
HWS_SF(, DC_IP_REQUEST_CNTL, IP_REQUEST_EN, mask_sh), \
+   HWSEQ_LVTMA_MASK_SH_LIST(mask_sh), \
HWS_SF(, LVTMA_PWRSEQ_CNTL, LVTMA_BLON, mask_sh), \
HWS_SF(, LVTMA_PWRSEQ_STATE, LVTMA_PWRSEQ_TARGET_STATE_R, mask_sh)
 #endif
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
index 32bf6cf09677..df1be8ada66d 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
@@ -670,6 +670,10 @@ static void dcn10_bios_golden_init(struct dc *dc)
int i;
bool allow_self_fresh_force_enable = true;
 
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+   if (dc->hwss.s0i3_golden_init_wa && dc->hwss.s0i3_golden_init_wa(dc))
+   return;
+#endif
if (dc->res_pool->hubbub->funcs->is_allow_self_refresh_enabled)
allow_self_fresh_force_enable =

dc->res_pool->hubbub->funcs->is_allow_self_refresh_enabled(dc->res_pool->hubbub);
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile 
b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
index b2b39090fb57..5b8f42ae2334 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
@@ -1,7 +1,7 @@
 #
 # Makefile for DCN21.
 
-DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o
+DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o dcn21_hwseq.o
 
 CFLAGS_dcn21_resource.o := -mhard-float -msse -mpreferred-stack-boundary=4
 
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c
new file mode 100644
index ..b25215cadf85
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2016 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#include "dm_services.h"
+#include "dm_helpers.h"
+#include "core_types.h"
+#include "resource.h"
+#include "dce/dce_hwseq.h"
+#include "dcn20/dcn20_hwseq.h"
+#include "vmid.h"
+#include "reg_helper.h"
+#include "hw/clk_mgr.h"
+
+
+#define DC_LOGGER_INIT(logger)
+
+#define CTX \
+   hws->ctx
+#define REG(reg)\
+   hws->regs->reg
+
+#undef FN
+#define FN(reg_name, field_name) \
+   hws->shifts->field_name, hws->masks->field_name
+
+/* Temporary read settings, future will get values from kmd directly */
+static void mmhub_update_page_table_config(struct dcn_hubbub_phys_addr_config 
*conf

[PATCH 26/29] drm/amd/display: enable smu set dcfclk

2019-10-11 Thread Bhawanpreet Lakha
From: Lewis Huang 

[Why]
SMU fixed this issue after version 0x370c00

[How]
enable smu send message to set dcfclk after smu version 0x370c00

Signed-off-by: Lewis Huang 
Acked-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
index db28e91adb3d..2650776acbc3 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
@@ -124,7 +124,7 @@ int rn_vbios_smu_set_hard_min_dcfclk(struct 
clk_mgr_internal *clk_mgr, int reque
 {
int actual_dcfclk_set_mhz = -1;
 
-   if (clk_mgr->smu_ver < 0x)
+   if (clk_mgr->smu_ver < 0x370c00)
return actual_dcfclk_set_mhz;
 
actual_dcfclk_set_mhz = rn_vbios_smu_send_msg_with_param(
@@ -139,7 +139,7 @@ int rn_vbios_smu_set_min_deep_sleep_dcfclk(struct 
clk_mgr_internal *clk_mgr, int
 {
int actual_min_ds_dcfclk_mhz = -1;
 
-   if (clk_mgr->smu_ver < 0x)
+   if (clk_mgr->smu_ver < 0x370c00)
return actual_min_ds_dcfclk_mhz;
 
actual_min_ds_dcfclk_mhz = rn_vbios_smu_send_msg_with_param(
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 23/26] drm/amd/display: add sanity check for clk table from smu

2019-10-09 Thread Bhawanpreet Lakha
From: Eric Yang 

[Why]
Handle the case where we don't get a valid table. Also fixes compiler
warning for variable potentially used before assignment.

[How]
If the entire table has no valid fclk, reject the table and use our own
hard code.

Signed-off-by: Eric Yang 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
index fb8aa9436bf0..0e712df87109 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
@@ -546,6 +546,8 @@ void rn_clk_mgr_helper_populate_bw_params(struct 
clk_bw_params *bw_params, struc
 {
int i, j = 0;
 
+   j = -1;
+
ASSERT(PP_SMU_NUM_FCLK_DPM_LEVELS <= MAX_NUM_DPM_LVL);
 
/* Find lowest DPM, FCLK is filled in reverse order*/
@@ -557,6 +559,12 @@ void rn_clk_mgr_helper_populate_bw_params(struct 
clk_bw_params *bw_params, struc
}
}
 
+   if (j == -1) {
+   /* clock table is all 0s, just use our own hardcode */
+   ASSERT(0);
+   return;
+   }
+
bw_params->clk_table.num_entries = j + 1;
 
for (i = 0; i < bw_params->clk_table.num_entries; i++, j--) {
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 24/26] drm/amd/display: fix header for RN clk mgr

2019-10-09 Thread Bhawanpreet Lakha
From: joseph gravenor 

[why]
Should always MP0_BASE for any register definition from MP per-IP header files.
I belive the reason the linux version of MP1_BASE works is The 0th element of 
the 0th table
of that is identical to the corrisponding value of MP0_BASE in the renoir 
offset header file.
The reason we should only use MP0_BASE is There is only one set of per-IP 
headers MP
that includes all register definitions related to SMU IP block. This IP 
includes MP0, MP1, MP2
and  an ecryption engine that can be used only by MP0. As a result all register 
definitions from
MP file should be based only on MP0_BASE data.

[How]
Change MP1_BASE to MP0_BASE

Signed-off-by: joseph gravenor 
Acked-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git 
a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
index 8e860f567d5c..db28e91adb3d 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
@@ -33,7 +33,7 @@
 #include "mp/mp_12_0_0_sh_mask.h"
 
 #define REG(reg_name) \
-   (MP1_BASE.instance[0].segment[mm ## reg_name ## _BASE_IDX] + mm ## 
reg_name)
+   (MP0_BASE.instance[0].segment[mm ## reg_name ## _BASE_IDX] + mm ## 
reg_name)
 
 #define FN(reg_name, field) \
FD(reg_name##__##field)
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 00/26] Renoir DC Patches

2019-10-09 Thread Bhawanpreet Lakha
Hi all,

There was a delta betwwen internal dcn21 code and upstream dcn21 code.
These changes bring them inline.


Summary of Changes
*Add RN registors
*Add dcn12 hwseq and link_encoder
*RN specific fixes
*aux timeout support
*bounding box changes

Bhawanpreet Lakha (12):
  drm/amd/display: Add DP_DPHY_INTERNAL_CTR regs
  drm/amd/display: Add DCN_BASE regs
  drm/amd/display: Add renoir hw_seq
  drm/amd/display: create dcn21_link_encoder files
  drm/amd/display: add REFCYC_PER_TRIP_TO_MEMORY programming
  drm/amd/display: fix incorrect page table address for renoir
  drm/amd/display: add detile buffer size for renoir
  drm/amd/display: update dcn21 hubbub registers
  drm/amd/display: update renoir bounding box and res_caps
  drm/amd/display: change PP_SM defs to 8
  drm/amd/display: handle "18" case in TruncToValidBPP
  drm/amd/display: use requested_dispclk_khz instead of clk

Dmytro Laktyushkin (4):
  drm/amd/display: enable hostvm based on roimmu active for dcn2.1
  drm/amd/display: initialize RN gpuvm context programming function
  drm/amd/display: correct dcn21 NUM_VMID to 16
  drm/amd/display: update odm mode validation to be in line with policy

Eric Yang (2):
  drm/amd/display: use dcn10 version of program tiling on Renoir
  drm/amd/display: add sanity check for clk table from smu

Lewis Huang (3):
  drm/amd/display: move the bounding box patch before calculate wm
  drm/amd/display: Temporary workaround to toggle watermark setting
  drm/amd/display: enable smu set dcfclk

Michael Strauss (1):
  drm/amd/display: Fix rn audio playback and video playback speed

Sung Lee (1):
  drm/amd/display: add dummy functions to smu for Renoir Silicon Diags

abdoulaye berthe (2):
  drm/amd/display: update register field access mechanism
  drm/amd/display: configurable aux timeout support

joseph gravenor (1):
  drm/amd/display: fix header for RN clk mgr

 .../amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c |  23 +-
 .../dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c   |  19 +-
 .../gpu/drm/amd/display/dc/core/dc_link_ddc.c |  14 +
 drivers/gpu/drm/amd/display/dc/dc.h   |   2 +
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c  |  82 +++-
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.h  | 187 -
 .../gpu/drm/amd/display/dc/dce/dce_hwseq.h|   1 +
 .../amd/display/dc/dce100/dce100_resource.c   |  15 +-
 .../amd/display/dc/dce110/dce110_resource.c   |  14 +-
 .../amd/display/dc/dce112/dce112_resource.c   |  15 +-
 .../amd/display/dc/dce120/dce120_resource.c   |  15 +-
 .../drm/amd/display/dc/dce80/dce80_resource.c |  14 +-
 .../amd/display/dc/dcn10/dcn10_hw_sequencer.c |   4 +
 .../amd/display/dc/dcn10/dcn10_link_encoder.h |  35 +-
 .../drm/amd/display/dc/dcn10/dcn10_resource.c |  15 +-
 .../drm/amd/display/dc/dcn20/dcn20_hwseq.c|   4 +
 .../amd/display/dc/dcn20/dcn20_link_encoder.h |   7 +
 .../drm/amd/display/dc/dcn20/dcn20_resource.c |  31 +-
 drivers/gpu/drm/amd/display/dc/dcn21/Makefile |   2 +-
 .../drm/amd/display/dc/dcn21/dcn21_hubbub.c   | 116 --
 .../drm/amd/display/dc/dcn21/dcn21_hubbub.h   |  34 +-
 .../gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c |   4 +-
 .../drm/amd/display/dc/dcn21/dcn21_hwseq.c| 122 ++
 .../drm/amd/display/dc/dcn21/dcn21_hwseq.h|  33 ++
 .../amd/display/dc/dcn21/dcn21_link_encoder.c | 384 ++
 .../amd/display/dc/dcn21/dcn21_link_encoder.h |  51 +++
 .../drm/amd/display/dc/dcn21/dcn21_resource.c | 269 ++--
 drivers/gpu/drm/amd/display/dc/dm_pp_smu.h|   6 +-
 .../dc/dml/dcn21/display_mode_vba_21.c|  11 +-
 .../gpu/drm/amd/display/dc/inc/dc_link_ddc.h  |   3 +
 .../gpu/drm/amd/display/dc/inc/dc_link_dp.h   |   2 +
 .../drm/amd/display/dc/inc/hw/aux_engine.h|   3 +
 .../gpu/drm/amd/display/dc/inc/hw/dchubbub.h  |   1 +
 .../gpu/drm/amd/display/dc/inc/hw/mem_input.h |   1 +
 .../gpu/drm/amd/display/dc/inc/hw_sequencer.h |   3 +
 .../include/asic_reg/dcn/dcn_2_1_0_offset.h   |  10 +
 .../gpu/drm/amd/include/renoir_ip_offset.h|  34 ++
 37 files changed, 1461 insertions(+), 125 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.h
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.h

-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 11/26] drm/amd/display: Temporary workaround to toggle watermark setting

2019-10-09 Thread Bhawanpreet Lakha
From: Lewis Huang 

[Why]
Watermarks not propagated to DCHUBP after it is powered on

[How]
Add temoprary function apply_DEDCN21_147_wa to apply wm settings for Renoir

Signed-off-by: Lewis Huang 
Reviewed-by: Tony Cheng 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c| 4 
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c   | 9 +
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c | 1 +
 drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h  | 1 +
 4 files changed, 15 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
index ce2530509e12..6229a8ca0013 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
@@ -1533,6 +1533,10 @@ static void dcn20_program_front_end_for_ctx(
msleep(1);
}
}
+
+   /* WA to apply WM setting*/
+   if (dc->hwseq->wa.DEGVIDCN21)
+   
dc->res_pool->hubbub->funcs->apply_DEDCN21_147_wa(dc->res_pool->hubbub);
 }
 
 
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index fdfbdeb32459..2232ccf14bdd 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -616,6 +616,14 @@ void hubbub21_wm_read_state(struct hubbub *hubbub,
DCHUBBUB_ARB_ALLOW_DRAM_CLK_CHANGE_WATERMARK_D, 
>dram_clk_chanage);
 }
 
+void hubbub21_apply_DEDCN21_147_wa(struct hubbub *hubbub)
+{
+   struct dcn20_hubbub *hubbub1 = TO_DCN20_HUBBUB(hubbub);
+   uint32_t prog_wm_value;
+
+   prog_wm_value = REG_READ(DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_A);
+   REG_WRITE(DCHUBBUB_ARB_DATA_URGENCY_WATERMARK_A, prog_wm_value);
+}
 
 static const struct hubbub_funcs hubbub21_funcs = {
.update_dchub = hubbub2_update_dchub,
@@ -627,6 +635,7 @@ static const struct hubbub_funcs hubbub21_funcs = {
.wm_read_state = hubbub21_wm_read_state,
.get_dchub_ref_freq = hubbub2_get_dchub_ref_freq,
.program_watermarks = hubbub21_program_watermarks,
+   .apply_DEDCN21_147_wa = hubbub21_apply_DEDCN21_147_wa,
 };
 
 void hubbub21_construct(struct dcn20_hubbub *hubbub,
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
index e39961d0f24e..5e15f800a9f1 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
@@ -1468,6 +1468,7 @@ static struct dce_hwseq *dcn21_hwseq_create(
hws->regs = _reg;
hws->shifts = _shift;
hws->masks = _mask;
+   hws->wa.DEGVIDCN21 = true;
}
return hws;
 }
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h 
b/drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h
index a6297219d7fc..c81a17aeaa25 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/hw/dchubbub.h
@@ -147,6 +147,7 @@ struct hubbub_funcs {
bool (*is_allow_self_refresh_enabled)(struct hubbub *hubbub);
void (*allow_self_refresh_control)(struct hubbub *hubbub, bool allow);
 
+   void (*apply_DEDCN21_147_wa)(struct hubbub *hubbub);
 };
 
 struct hubbub {
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 05/26] drm/amd/display: Add renoir hw_seq

2019-10-09 Thread Bhawanpreet Lakha
This change adds renoir hw_seq, needed to do renoir
specific hw programing

Signed-off-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/dc/dce/dce_hwseq.h|   1 +
 .../amd/display/dc/dcn10/dcn10_hw_sequencer.c |   4 +
 drivers/gpu/drm/amd/display/dc/dcn21/Makefile |   2 +-
 .../drm/amd/display/dc/dcn21/dcn21_hwseq.c| 122 ++
 .../drm/amd/display/dc/dcn21/dcn21_hwseq.h|  33 +
 .../drm/amd/display/dc/dcn21/dcn21_resource.c | 118 +
 .../gpu/drm/amd/display/dc/inc/hw_sequencer.h |   3 +
 7 files changed, 255 insertions(+), 28 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.h

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h 
b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h
index ac04d77058f0..32d145a0d6fc 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_hwseq.h
@@ -679,6 +679,7 @@ struct dce_hwseq_registers {
HWS_SF(, DOMAIN17_PG_STATUS, DOMAIN17_PGFSM_PWR_STATUS, mask_sh), \
HWS_SF(, DOMAIN18_PG_STATUS, DOMAIN18_PGFSM_PWR_STATUS, mask_sh), \
HWS_SF(, DC_IP_REQUEST_CNTL, IP_REQUEST_EN, mask_sh), \
+   HWSEQ_LVTMA_MASK_SH_LIST(mask_sh), \
HWS_SF(, LVTMA_PWRSEQ_CNTL, LVTMA_BLON, mask_sh), \
HWS_SF(, LVTMA_PWRSEQ_STATE, LVTMA_PWRSEQ_TARGET_STATE_R, mask_sh)
 #endif
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
index 32bf6cf09677..df1be8ada66d 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_hw_sequencer.c
@@ -670,6 +670,10 @@ static void dcn10_bios_golden_init(struct dc *dc)
int i;
bool allow_self_fresh_force_enable = true;
 
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+   if (dc->hwss.s0i3_golden_init_wa && dc->hwss.s0i3_golden_init_wa(dc))
+   return;
+#endif
if (dc->res_pool->hubbub->funcs->is_allow_self_refresh_enabled)
allow_self_fresh_force_enable =

dc->res_pool->hubbub->funcs->is_allow_self_refresh_enabled(dc->res_pool->hubbub);
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile 
b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
index b2b39090fb57..5b8f42ae2334 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
@@ -1,7 +1,7 @@
 #
 # Makefile for DCN21.
 
-DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o
+DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o dcn21_hwseq.o
 
 CFLAGS_dcn21_resource.o := -mhard-float -msse -mpreferred-stack-boundary=4
 
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c
new file mode 100644
index ..b25215cadf85
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hwseq.c
@@ -0,0 +1,122 @@
+/*
+ * Copyright 2016 Advanced Micro Devices, Inc.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a
+ * copy of this software and associated documentation files (the "Software"),
+ * to deal in the Software without restriction, including without limitation
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,
+ * and/or sell copies of the Software, and to permit persons to whom the
+ * Software is furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
+ *
+ * Authors: AMD
+ *
+ */
+
+#include "dm_services.h"
+#include "dm_helpers.h"
+#include "core_types.h"
+#include "resource.h"
+#include "dce/dce_hwseq.h"
+#include "dcn20/dcn20_hwseq.h"
+#include "vmid.h"
+#include "reg_helper.h"
+#include "hw/clk_mgr.h"
+
+
+#define DC_LOGGER_INIT(logger)
+
+#define CTX \
+   hws->ctx
+#define REG(reg)\
+   hws->regs->reg
+
+#undef FN
+#define FN(reg_name, field_name) \
+   hws->shifts->field_name, hws->masks->field_name
+
+/* Temporary read settings, future will get values from kmd directly */
+static void mmhub_update_page_table_config(struct dcn_hubbub_phys_addr_config 
*conf

[PATCH 14/26] drm/amd/display: correct dcn21 NUM_VMID to 16

2019-10-09 Thread Bhawanpreet Lakha
From: Dmytro Laktyushkin 

1 vmid limitation only exists for HOSTVM which is a custom
use case anyway.

Signed-off-by: Dmytro Laktyushkin 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index 44f64a8e33f1..aeb5de6f4530 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -52,7 +52,7 @@
 #ifdef NUM_VMID
 #undef NUM_VMID
 #endif
-#define NUM_VMID 1
+#define NUM_VMID 16
 
 static uint32_t convert_and_clamp(
uint32_t wm_ns,
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 20/26] drm/amd/display: update odm mode validation to be in line with policy

2019-10-09 Thread Bhawanpreet Lakha
From: Dmytro Laktyushkin 

Previously 8k30 worked with dsc and odm combine due to a workaround that ran
the formula a second time with dsc support enable should dsc validation fail.
This worked when clocks were low enough for formula to enable odm to lower
voltage, however now broke due to increased clocks.

This change updates the ODM combine policy within the formula to properly
reflect our current policy within DC, only enabling ODM when we have to, as
well as adding a check for viewport width when dsc is enabled.

As a side effect the redundant call to dml when odm is required is now
unnecessary.

Signed-off-by: Dmytro Laktyushkin 
Acked-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c   | 9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
index 3b6ed60dcd35..fd707e7459b5 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
@@ -65,6 +65,7 @@ typedef struct {
 
 #define BPP_INVALID 0
 #define BPP_BLENDED_PIPE 0x
+#define DCN21_MAX_DSC_IMAGE_WIDTH 5184
 
 static void DisplayPipeConfiguration(struct display_mode_lib *mode_lib);
 static void 
DISPCLKDPPCLKDCFCLKDeepSleepPrefetchParametersWatermarksAndPerformanceCalculation(
@@ -3936,6 +3937,10 @@ void dml21_ModeSupportAndSystemConfigurationFull(struct 
display_mode_lib *mode_l
mode_lib->vba.MaximumSwathWidthInLineBuffer);
}
for (i = 0; i <= mode_lib->vba.soc.num_states; i++) {
+   double MaxMaxDispclkRoundedDown = RoundToDFSGranularityDown(
+   mode_lib->vba.MaxDispclk[mode_lib->vba.soc.num_states],
+   mode_lib->vba.DISPCLKDPPCLKVCOSpeed);
+
for (j = 0; j < 2; j++) {
mode_lib->vba.MaxDispclkRoundedDownToDFSGranularity = 
RoundToDFSGranularityDown(
mode_lib->vba.MaxDispclk[i],
@@ -3965,7 +3970,9 @@ void dml21_ModeSupportAndSystemConfigurationFull(struct 
display_mode_lib *mode_l
&& i == 
mode_lib->vba.soc.num_states)

mode_lib->vba.PlaneRequiredDISPCLKWithODMCombine = mode_lib->vba.PixelClock[k] 
/ 2
* (1 + 
mode_lib->vba.DISPCLKDPPCLKDSCCLKDownSpreading / 100.0);
-   if (mode_lib->vba.ODMCapability == false || 
mode_lib->vba.PlaneRequiredDISPCLKWithoutODMCombine <= 
mode_lib->vba.MaxDispclkRoundedDownToDFSGranularity) {
+   if (mode_lib->vba.ODMCapability == false ||
+   
(locals->PlaneRequiredDISPCLKWithoutODMCombine <= MaxMaxDispclkRoundedDown
+   && 
(!locals->DSCEnabled[k] || locals->HActive[k] <= DCN21_MAX_DSC_IMAGE_WIDTH))) {
locals->ODMCombineEnablePerState[i][k] 
= false;
mode_lib->vba.PlaneRequiredDISPCLK = 
mode_lib->vba.PlaneRequiredDISPCLKWithoutODMCombine;
} else {
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 08/26] drm/amd/display: move the bounding box patch before calculate wm

2019-10-09 Thread Bhawanpreet Lakha
From: Lewis Huang 

[why]
driver updateis the dcn2_1_soc into dml before call update_bw_bounding_box

[How]
Move the patch function before calculate wm.

Signed-off-by: Lewis Huang 
Signed-off-by: joseph graveno 
Acked-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/dcn21/dcn21_resource.c | 25 +++
 1 file changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
index ddf52e260ed6..e39961d0f24e 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
@@ -1007,6 +1007,29 @@ static void calculate_wm_set_for_vlevel(
 
 }
 
+static void patch_bounding_box(struct dc *dc, struct 
_vcs_dpi_soc_bounding_box_st *bb)
+{
+   kernel_fpu_begin();
+   if (dc->bb_overrides.sr_exit_time_ns) {
+   bb->sr_exit_time_us = dc->bb_overrides.sr_exit_time_ns / 1000.0;
+   }
+
+   if (dc->bb_overrides.sr_enter_plus_exit_time_ns) {
+   bb->sr_enter_plus_exit_time_us =
+   dc->bb_overrides.sr_enter_plus_exit_time_ns / 
1000.0;
+   }
+
+   if (dc->bb_overrides.urgent_latency_ns) {
+   bb->urgent_latency_us = dc->bb_overrides.urgent_latency_ns / 
1000.0;
+   }
+
+   if (dc->bb_overrides.dram_clock_change_latency_ns) {
+   bb->dram_clock_change_latency_us =
+   dc->bb_overrides.dram_clock_change_latency_ns / 
1000.0;
+   }
+   kernel_fpu_end();
+}
+
 void dcn21_calculate_wm(
struct dc *dc, struct dc_state *context,
display_e2e_pipe_params_st *pipes,
@@ -1021,6 +1044,8 @@ void dcn21_calculate_wm(
 
ASSERT(bw_params);
 
+   patch_bounding_box(dc, >bw_ctx.dml.soc);
+
for (i = 0, pipe_idx = 0, pipe_cnt = 0; i < dc->res_pool->pipe_count; 
i++) {
if (!context->res_ctx.pipe_ctx[i].stream)
continue;
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 12/26] drm/amd/display: initialize RN gpuvm context programming function

2019-10-09 Thread Bhawanpreet Lakha
From: Dmytro Laktyushkin 

Renoir can use vm contexes as long as HOSTVM is off so
this should be initialized.

Signed-off-by: Dmytro Laktyushkin 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index 2232ccf14bdd..44f64a8e33f1 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -628,7 +628,7 @@ void hubbub21_apply_DEDCN21_147_wa(struct hubbub *hubbub)
 static const struct hubbub_funcs hubbub21_funcs = {
.update_dchub = hubbub2_update_dchub,
.init_dchub_sys_ctx = hubbub21_init_dchub,
-   .init_vm_ctx = NULL,
+   .init_vm_ctx = hubbub2_init_vm_ctx,
.dcc_support_swizzle = hubbub2_dcc_support_swizzle,
.dcc_support_pixel_format = hubbub2_dcc_support_pixel_format,
.get_dcc_compression_cap = hubbub2_get_dcc_compression_cap,
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 07/26] drm/amd/display: add REFCYC_PER_TRIP_TO_MEMORY programming

2019-10-09 Thread Bhawanpreet Lakha
it allows us to do urgent latency programming

Signed-off-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/dcn20/dcn20_resource.c | 16 
 .../drm/amd/display/dc/dcn21/dcn21_hubbub.c   | 39 +--
 .../drm/amd/display/dc/dcn21/dcn21_hubbub.h   | 17 
 .../gpu/drm/amd/display/dc/inc/hw/mem_input.h |  1 +
 4 files changed, 69 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
index 9cc6797e3860..086d1bc0d0a5 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
@@ -2573,6 +2573,10 @@ void dcn20_calculate_wm(
context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.cstate_exit_ns = 
get_wm_stutter_exit(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.b.cstate_pstate.pstate_change_ns = 
get_wm_dram_clock_change(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.b.pte_meta_urgent_ns = 
get_wm_memory_trip(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+   context->bw_ctx.bw.dcn.watermarks.b.frac_urg_bw_nom = 
get_fraction_of_urgent_bandwidth(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+   context->bw_ctx.bw.dcn.watermarks.b.frac_urg_bw_flip = 
get_fraction_of_urgent_bandwidth_imm_flip(>bw_ctx.dml, pipes, 
pipe_cnt) * 1000;
+#endif
 
if (vlevel < 2) {
pipes[0].clks_cfg.voltage = 2;
@@ -2584,6 +2588,10 @@ void dcn20_calculate_wm(
context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.cstate_exit_ns = 
get_wm_stutter_exit(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.c.cstate_pstate.pstate_change_ns = 
get_wm_dram_clock_change(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.c.pte_meta_urgent_ns = 
get_wm_memory_trip(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+   context->bw_ctx.bw.dcn.watermarks.c.frac_urg_bw_nom = 
get_fraction_of_urgent_bandwidth(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+   context->bw_ctx.bw.dcn.watermarks.c.frac_urg_bw_flip = 
get_fraction_of_urgent_bandwidth_imm_flip(>bw_ctx.dml, pipes, 
pipe_cnt) * 1000;
+#endif
 
if (vlevel < 3) {
pipes[0].clks_cfg.voltage = 3;
@@ -2595,6 +2603,10 @@ void dcn20_calculate_wm(
context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.cstate_exit_ns = 
get_wm_stutter_exit(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.d.cstate_pstate.pstate_change_ns = 
get_wm_dram_clock_change(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.d.pte_meta_urgent_ns = 
get_wm_memory_trip(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+   context->bw_ctx.bw.dcn.watermarks.d.frac_urg_bw_nom = 
get_fraction_of_urgent_bandwidth(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+   context->bw_ctx.bw.dcn.watermarks.d.frac_urg_bw_flip = 
get_fraction_of_urgent_bandwidth_imm_flip(>bw_ctx.dml, pipes, 
pipe_cnt) * 1000;
+#endif
 
pipes[0].clks_cfg.voltage = vlevel;
pipes[0].clks_cfg.dcfclk_mhz = 
context->bw_ctx.dml.soc.clock_limits[vlevel].dcfclk_mhz;
@@ -2604,6 +2616,10 @@ void dcn20_calculate_wm(
context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.cstate_exit_ns = 
get_wm_stutter_exit(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.a.cstate_pstate.pstate_change_ns = 
get_wm_dram_clock_change(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
context->bw_ctx.bw.dcn.watermarks.a.pte_meta_urgent_ns = 
get_wm_memory_trip(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+#if defined(CONFIG_DRM_AMD_DC_DCN2_1)
+   context->bw_ctx.bw.dcn.watermarks.a.frac_urg_bw_nom = 
get_fraction_of_urgent_bandwidth(>bw_ctx.dml, pipes, pipe_cnt) * 1000;
+   context->bw_ctx.bw.dcn.watermarks.a.frac_urg_bw_flip = 
get_fraction_of_urgent_bandwidth_imm_flip(>bw_ctx.dml, pipes, 
pipe_cnt) * 1000;
+#endif
 }
 
 void dcn20_calculate_dlg_params(
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index d1266741763b..8e7e79f44272 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -97,7 +97,7 @@ void dcn21_dchvm_init(struct hubbub *hubbub)
REG_WAIT(DCHVM_RIOMMU_STAT0, HOSTVM_PREFETCH_DONE, 1, 5, 100);
 }
 
-static int hubbub21_init_dchub(struct hubbub *hubbub,
+int hubbub21_init_dchub(struct hubbub *hubbub,
struct dcn_hubbub_phys_addr_config *pa_config)
 {
struct dcn20_hubbub *hubbub1 = TO_DCN20_HUBBUB(hubbub);
@@ -120,7 +120,7 @@ static int hubbub21_init_dchub(struct hubbub *hubbub,
return NUM_VMID;
 }
 
-static void hubbub21_p

[PATCH 13/26] drm/amd/display: use dcn10 version of program tiling on Renoir

2019-10-09 Thread Bhawanpreet Lakha
From: Eric Yang 

[Why]
Renoir is gfx9, same as dcn10, not dcn20.

Signed-off-by: Eric Yang 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
index a00af513aa2b..2f5a5867e674 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubp.c
@@ -22,6 +22,8 @@
  * Authors: AMD
  *
  */
+
+#include "dcn10/dcn10_hubp.h"
 #include "dcn21_hubp.h"
 
 #include "dm_services.h"
@@ -202,7 +204,7 @@ static struct hubp_funcs dcn21_hubp_funcs = {
.hubp_enable_tripleBuffer = hubp2_enable_triplebuffer,
.hubp_is_triplebuffer_enabled = hubp2_is_triplebuffer_enabled,
.hubp_program_surface_flip_and_addr = 
hubp2_program_surface_flip_and_addr,
-   .hubp_program_surface_config = hubp2_program_surface_config,
+   .hubp_program_surface_config = hubp1_program_surface_config,
.hubp_is_flip_pending = hubp1_is_flip_pending,
.hubp_setup = hubp21_setup,
.hubp_setup_interdependent = hubp2_setup_interdependent,
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 04/26] drm/amd/display: Add DCN_BASE regs

2019-10-09 Thread Bhawanpreet Lakha
Signed-off-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/include/renoir_ip_offset.h| 34 +++
 1 file changed, 34 insertions(+)

diff --git a/drivers/gpu/drm/amd/include/renoir_ip_offset.h 
b/drivers/gpu/drm/amd/include/renoir_ip_offset.h
index 094648cac392..07633e22e99a 100644
--- a/drivers/gpu/drm/amd/include/renoir_ip_offset.h
+++ b/drivers/gpu/drm/amd/include/renoir_ip_offset.h
@@ -169,6 +169,11 @@ static const struct IP_BASE NBIF0_BASE ={ { { { 
0x, 0x0014, 0x0D
 { { 0, 0, 0, 0, 0 } },
 { { 0, 0, 0, 0, 0 } },
 { { 0, 0, 0, 0, 0 } } } };
+static const struct IP_BASE DCN_BASE   ={ { { { 0x0012, 0x00C0, 
0x34C0, 0, 0 } },
+{ { 0, 0, 0, 0, 0 } },
+{ { 0, 0, 0, 0, 0 } },
+{ { 0, 0, 0, 0, 0 } },
+{ { 0, 0, 0, 0, 0 } } } };
 static const struct IP_BASE OSSSYS_BASE ={ { { { 0x10A0, 0x0240A000, 0, 0, 
0 } },
 { { 0, 0, 0, 0, 0 } },
 { { 0, 0, 0, 0, 0 } },
@@ -1361,4 +1366,33 @@ static const struct IP_BASE UVD0_BASE ={ { { { 
0x7800, 0x7E00, 0x0240300
 #define UVD0_BASE__INST6_SEG3  0
 #define UVD0_BASE__INST6_SEG4  0
 
+#define DCN_BASE__INST0_SEG0  0x0012
+#define DCN_BASE__INST0_SEG1  0x00C0
+#define DCN_BASE__INST0_SEG2  0x34C0
+#define DCN_BASE__INST0_SEG3  0
+#define DCN_BASE__INST0_SEG4  0
+
+#define DCN_BASE__INST1_SEG0  0
+#define DCN_BASE__INST1_SEG1  0
+#define DCN_BASE__INST1_SEG2  0
+#define DCN_BASE__INST1_SEG3  0
+#define DCN_BASE__INST1_SEG4  0
+
+#define DCN_BASE__INST2_SEG0  0
+#define DCN_BASE__INST2_SEG1  0
+#define DCN_BASE__INST2_SEG2  0
+#define DCN_BASE__INST2_SEG3  0
+#define DCN_BASE__INST2_SEG4  0
+
+#define DCN_BASE__INST3_SEG0  0
+#define DCN_BASE__INST3_SEG1  0
+#define DCN_BASE__INST3_SEG2  0
+#define DCN_BASE__INST3_SEG3  0
+#define DCN_BASE__INST3_SEG4  0
+
+#define DCN_BASE__INST4_SEG0  0
+#define DCN_BASE__INST4_SEG1  0
+#define DCN_BASE__INST4_SEG2  0
+#define DCN_BASE__INST4_SEG3  0
+#define DCN_BASE__INST4_SEG4  0
 #endif
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 01/26] drm/amd/display: update register field access mechanism

2019-10-09 Thread Bhawanpreet Lakha
From: abdoulaye berthe 

1-add timeout length and multiplier fields to aux_control1 register
2-update access mechanism from macro constructed name to uint32_t
defined addresses.
3-define registers and field per asic family

Signed-off-by: abdoulaye berthe 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c  |  11 +-
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.h  | 175 +-
 .../amd/display/dc/dce100/dce100_resource.c   |  12 +-
 .../amd/display/dc/dce110/dce110_resource.c   |  12 +-
 .../amd/display/dc/dce112/dce112_resource.c   |  12 +-
 .../amd/display/dc/dce120/dce120_resource.c   |  12 +-
 .../drm/amd/display/dc/dce80/dce80_resource.c |  12 +-
 .../drm/amd/display/dc/dcn10/dcn10_resource.c |  12 +-
 .../drm/amd/display/dc/dcn20/dcn20_resource.c |  13 +-
 .../drm/amd/display/dc/dcn21/dcn21_resource.c |  12 +-
 10 files changed, 271 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c 
b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
index 48a0e4ae80c2..de233270e3d5 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
@@ -42,6 +42,10 @@
 
 #include "reg_helper.h"
 
+#undef FN
+#define FN(reg_name, field_name) \
+   aux110->shift->field_name, aux110->mask->field_name
+
 #define FROM_AUX_ENGINE(ptr) \
container_of((ptr), struct aux_engine_dce110, base)
 
@@ -414,11 +418,14 @@ void dce110_engine_destroy(struct dce_aux **engine)
*engine = NULL;
 
 }
+
 struct dce_aux *dce110_aux_engine_construct(struct aux_engine_dce110 
*aux_engine110,
struct dc_context *ctx,
uint32_t inst,
uint32_t timeout_period,
-   const struct dce110_aux_registers *regs)
+   const struct dce110_aux_registers *regs,
+   const struct dce110_aux_registers_mask *mask,
+   const struct dce110_aux_registers_shift *shift)
 {
aux_engine110->base.ddc = NULL;
aux_engine110->base.ctx = ctx;
@@ -428,6 +435,8 @@ struct dce_aux *dce110_aux_engine_construct(struct 
aux_engine_dce110 *aux_engine
aux_engine110->timeout_period = timeout_period;
aux_engine110->regs = regs;
 
+   aux_engine110->mask = mask;
+   aux_engine110->shift = shift;
return _engine110->base;
 }
 
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.h 
b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.h
index ed7fec8fe253..717378502e9d 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.h
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.h
@@ -29,6 +29,7 @@
 #include "i2caux_interface.h"
 #include "inc/hw/aux_engine.h"
 
+
 #ifdef CONFIG_DRM_AMD_DC_DCN2_0
 #define AUX_COMMON_REG_LIST0(id)\
SRI(AUX_CONTROL, DP_AUX, id), \
@@ -36,6 +37,7 @@
SRI(AUX_SW_DATA, DP_AUX, id), \
SRI(AUX_SW_CONTROL, DP_AUX, id), \
SRI(AUX_INTERRUPT_CONTROL, DP_AUX, id), \
+   SRI(AUX_DPHY_RX_CONTROL1, DP_AUX, id), \
SRI(AUX_SW_STATUS, DP_AUX, id)
 #endif
 
@@ -55,6 +57,7 @@ struct dce110_aux_registers {
uint32_t AUX_SW_DATA;
uint32_t AUX_SW_CONTROL;
uint32_t AUX_INTERRUPT_CONTROL;
+   uint32_t AUX_DPHY_RX_CONTROL1;
uint32_t AUX_SW_STATUS;
uint32_t AUXN_IMPCAL;
uint32_t AUXP_IMPCAL;
@@ -62,6 +65,156 @@ struct dce110_aux_registers {
uint32_t AUX_RESET_MASK;
 };
 
+#define DCE_AUX_REG_FIELD_LIST(type)\
+   type AUX_EN;\
+   type AUX_RESET;\
+   type AUX_RESET_DONE;\
+   type AUX_REG_RW_CNTL_STATUS;\
+   type AUX_SW_USE_AUX_REG_REQ;\
+   type AUX_SW_DONE_USING_AUX_REG;\
+   type AUX_SW_AUTOINCREMENT_DISABLE;\
+   type AUX_SW_DATA_RW;\
+   type AUX_SW_INDEX;\
+   type AUX_SW_GO;\
+   type AUX_SW_DATA;\
+   type AUX_SW_REPLY_BYTE_COUNT;\
+   type AUX_SW_DONE;\
+   type AUX_SW_DONE_ACK;\
+   type AUXN_IMPCAL_ENABLE;\
+   type AUXP_IMPCAL_ENABLE;\
+   type AUXN_IMPCAL_OVERRIDE_ENABLE;\
+   type AUXP_IMPCAL_OVERRIDE_ENABLE;\
+   type AUX_RX_TIMEOUT_LEN;\
+   type AUX_RX_TIMEOUT_LEN_MUL;\
+   type AUXN_CALOUT_ERROR_AK;\
+   type AUXP_CALOUT_ERROR_AK;\
+   type AUX_SW_START_DELAY;\
+   type AUX_SW_WR_BYTES
+
+#define DCE10_AUX_MASK_SH_LIST(mask_sh)\
+   AUX_SF(AUX_CONTROL, AUX_EN, mask_sh),\
+   AUX_SF(AUX_ARB_CONTROL, AUX_REG_RW_CNTL_STATUS, mask_sh),\
+   AUX_SF(AUX_ARB_CONTROL, AUX_SW_USE_AUX_REG_REQ, mask_sh),\
+   AUX_SF(AUX_ARB_CONTROL, AUX_SW_DONE_USING_AUX_REG, mask_sh),\
+   AUX_SF(AUX_SW_CONTROL, AUX_SW_START_DELAY, mask_sh),\
+   AUX_SF(AUX_SW_CONTROL, AUX_SW_WR_BYTES, mask_sh),\
+   AUX_SF(AUX_SW_CONTROL, AUX_SW_GO, mask_sh),\
+   AUX_SF(AUX_SW_DATA, AUX_SW_AUTOINCREMENT_DISABLE, mask_sh),\
+   AUX_SF(AUX_SW_DATA, AUX_SW_DATA_RW, mask_sh),\
+   AUX_SF(AUX_SW_DATA, AUX_SW_AUTOINCREMENT_DISABLE, mask_sh),\
+   

[PATCH 17/26] drm/amd/display: update renoir bounding box and res_caps

2019-10-09 Thread Bhawanpreet Lakha
The values for bounding box and res_caps were incorrect. So
Fix them

Signed-off-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/dcn21/dcn21_resource.c | 24 ++-
 1 file changed, 13 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
index 5e15f800a9f1..002e7fb67068 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
@@ -82,6 +82,7 @@
 
 
 struct _vcs_dpi_ip_params_st dcn2_1_ip = {
+   .odm_capable = 1,
.gpuvm_enable = 0,
.hostvm_enable = 0,
.gpuvm_max_page_table_levels = 1,
@@ -203,11 +204,11 @@ struct _vcs_dpi_soc_bounding_box_st dcn2_1_soc = {
.state = 4,
.dcfclk_mhz = 810.0,
.fabricclk_mhz = 1600.0,
-   .dispclk_mhz = 1015.0,
-   .dppclk_mhz = 1015.0,
-   .phyclk_mhz = 810.0,
+   .dispclk_mhz = 1395.0,
+   .dppclk_mhz = 1285.0,
+   .phyclk_mhz = 1325.0,
.socclk_mhz = 953.0,
-   .dscclk_mhz = 318.334,
+   .dscclk_mhz = 489.0,
.dram_speed_mts = 4266.0,
},
/*Extra state, no dispclk ramping*/
@@ -215,18 +216,18 @@ struct _vcs_dpi_soc_bounding_box_st dcn2_1_soc = {
.state = 5,
.dcfclk_mhz = 810.0,
.fabricclk_mhz = 1600.0,
-   .dispclk_mhz = 1015.0,
-   .dppclk_mhz = 1015.0,
-   .phyclk_mhz = 810.0,
+   .dispclk_mhz = 1395.0,
+   .dppclk_mhz = 1285.0,
+   .phyclk_mhz = 1325.0,
.socclk_mhz = 953.0,
-   .dscclk_mhz = 318.334,
+   .dscclk_mhz = 489.0,
.dram_speed_mts = 4266.0,
},
 
},
 
-   .sr_exit_time_us = 9.0,
-   .sr_enter_plus_exit_time_us = 11.0,
+   .sr_exit_time_us = 12.5,
+   .sr_enter_plus_exit_time_us = 17.0,
.urgent_latency_us = 4.0,
.urgent_latency_pixel_data_only_us = 4.0,
.urgent_latency_pixel_mixed_with_vm_data_us = 4.0,
@@ -764,6 +765,7 @@ static const struct resource_caps res_cap_rn = {
.num_pll = 5,  // maybe 3 because the last two used for USB-c
.num_dwb = 1,
.num_ddc = 5,
+   .num_vmid = 1,
 #ifdef CONFIG_DRM_AMD_DC_DSC_SUPPORT
.num_dsc = 3,
 #endif
@@ -833,7 +835,7 @@ static const struct dc_debug_options debug_defaults_drv = {
.disable_dcc = DCC_ENABLE,
.vsr_support = true,
.performance_trace = false,
-   .max_downscale_src_width = 5120,/*upto 5K*/
+   .max_downscale_src_width = 3840,
.disable_pplib_wm_range = false,
.scl_reset_length10 = true,
.sanity_checks = true,
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 03/26] drm/amd/display: Add DP_DPHY_INTERNAL_CTR regs

2019-10-09 Thread Bhawanpreet Lakha
Signed-off-by: Bhawanpreet Lakha 
---
 .../drm/amd/include/asic_reg/dcn/dcn_2_1_0_offset.h| 10 ++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpu/drm/amd/include/asic_reg/dcn/dcn_2_1_0_offset.h 
b/drivers/gpu/drm/amd/include/asic_reg/dcn/dcn_2_1_0_offset.h
index be4249adb356..eddf83ec1c39 100644
--- a/drivers/gpu/drm/amd/include/asic_reg/dcn/dcn_2_1_0_offset.h
+++ b/drivers/gpu/drm/amd/include/asic_reg/dcn/dcn_2_1_0_offset.h
@@ -9859,6 +9859,8 @@
 #define mmDP0_DP_STEER_FIFO_BASE_IDX   
2
 #define mmDP0_DP_MSA_MISC  
0x210e
 #define mmDP0_DP_MSA_MISC_BASE_IDX 
2
+#define mmDP0_DP_DPHY_INTERNAL_CTRL
0x210f
+#define mmDP0_DP_DPHY_INTERNAL_CTRL_BASE_IDX   
2
 #define mmDP0_DP_VID_TIMING
0x2110
 #define mmDP0_DP_VID_TIMING_BASE_IDX   
2
 #define mmDP0_DP_VID_N 
0x2111
@@ -10187,6 +10189,8 @@
 #define mmDP1_DP_STEER_FIFO_BASE_IDX   
2
 #define mmDP1_DP_MSA_MISC  
0x220e
 #define mmDP1_DP_MSA_MISC_BASE_IDX 
2
+#define mmDP1_DP_DPHY_INTERNAL_CTRL
0x220f
+#define mmDP1_DP_DPHY_INTERNAL_CTRL_BASE_IDX   
2
 #define mmDP1_DP_VID_TIMING
0x2210
 #define mmDP1_DP_VID_TIMING_BASE_IDX   
2
 #define mmDP1_DP_VID_N 
0x2211
@@ -10515,6 +10519,8 @@
 #define mmDP2_DP_STEER_FIFO_BASE_IDX   
2
 #define mmDP2_DP_MSA_MISC  
0x230e
 #define mmDP2_DP_MSA_MISC_BASE_IDX 
2
+#define mmDP2_DP_DPHY_INTERNAL_CTRL
0x230f
+#define mmDP2_DP_DPHY_INTERNAL_CTRL_BASE_IDX   
2
 #define mmDP2_DP_VID_TIMING
0x2310
 #define mmDP2_DP_VID_TIMING_BASE_IDX   
2
 #define mmDP2_DP_VID_N 
0x2311
@@ -10843,6 +10849,8 @@
 #define mmDP3_DP_STEER_FIFO_BASE_IDX   
2
 #define mmDP3_DP_MSA_MISC  
0x240e
 #define mmDP3_DP_MSA_MISC_BASE_IDX 
2
+#define mmDP3_DP_DPHY_INTERNAL_CTRL
0x240f
+#define mmDP3_DP_DPHY_INTERNAL_CTRL_BASE_IDX   
2
 #define mmDP3_DP_VID_TIMING
0x2410
 #define mmDP3_DP_VID_TIMING_BASE_IDX   
2
 #define mmDP3_DP_VID_N 
0x2411
@@ -11171,6 +11179,8 @@
 #define mmDP4_DP_STEER_FIFO_BASE_IDX   
2
 #define mmDP4_DP_MSA_MISC  
0x250e
 #define mmDP4_DP_MSA_MISC_BASE_IDX 
2
+#define mmDP4_DP_DPHY_INTERNAL_CTRL
0x250f
+#define mmDP4_DP_DPHY_INTERNAL_CTRL_BASE_IDX   
2
 #define mmDP4_DP_VID_TIMING
0x2510
 #define mmDP4_DP_VID_TIMING_BASE_IDX   
2
 #define mmDP4_DP_VID_N 
0x2511
-- 
2.17.1

[PATCH 06/26] drm/amd/display: create dcn21_link_encoder files

2019-10-09 Thread Bhawanpreet Lakha
[Why]
DCN20 and DCN21 have different phy programming sequences.

[How]
Create a separate dcn21_link_encoder for Renoir

Signed-off-by: Bhawanpreet Lakha 
---
 .../amd/display/dc/dcn10/dcn10_link_encoder.h |  35 +-
 .../amd/display/dc/dcn20/dcn20_link_encoder.h |   7 +
 drivers/gpu/drm/amd/display/dc/dcn21/Makefile |   2 +-
 .../amd/display/dc/dcn21/dcn21_link_encoder.c | 384 ++
 .../amd/display/dc/dcn21/dcn21_link_encoder.h |  51 +++
 .../drm/amd/display/dc/dcn21/dcn21_resource.c |  85 +++-
 6 files changed, 560 insertions(+), 4 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c
 create mode 100644 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.h

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h
index 0c12395cfa36..239a6c90ffb9 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_link_encoder.h
@@ -250,6 +250,10 @@ struct dcn10_link_enc_registers {
type RDPCS_EXT_REFCLK_EN;\
type RDPCS_TX_FIFO_EN;\
type UNIPHY_LINK_ENABLE;\
+   type UNIPHY_CHANNEL0_XBAR_SOURCE;\
+   type UNIPHY_CHANNEL1_XBAR_SOURCE;\
+   type UNIPHY_CHANNEL2_XBAR_SOURCE;\
+   type UNIPHY_CHANNEL3_XBAR_SOURCE;\
type UNIPHY_CHANNEL0_INVERT;\
type UNIPHY_CHANNEL1_INVERT;\
type UNIPHY_CHANNEL2_INVERT;\
@@ -342,12 +346,41 @@ struct dcn10_link_enc_registers {
type RDPCS_PHY_DPALT_DISABLE_ACK;\
type RDPCS_PHY_DP_MPLLB_V2I;\
type RDPCS_PHY_DP_MPLLB_FREQ_VCO;\
+   type RDPCS_PHY_DP_MPLLB_CP_INT_GS;\
+   type RDPCS_PHY_RX_VREF_CTRL;\
type RDPCS_PHY_DP_MPLLB_CP_INT;\
type RDPCS_PHY_DP_MPLLB_CP_PROP;\
type RDPCS_PHY_RX_REF_LD_VAL;\
type RDPCS_PHY_RX_VCO_LD_VAL;\
type DPCSTX_DEBUG_CONFIG; \
-   type RDPCSTX_DEBUG_CONFIG
+   type RDPCSTX_DEBUG_CONFIG; \
+   type RDPCS_PHY_DP_TX0_EQ_MAIN;\
+   type RDPCS_PHY_DP_TX0_EQ_PRE;\
+   type RDPCS_PHY_DP_TX0_EQ_POST;\
+   type RDPCS_PHY_DP_TX1_EQ_MAIN;\
+   type RDPCS_PHY_DP_TX1_EQ_PRE;\
+   type RDPCS_PHY_DP_TX1_EQ_POST;\
+   type RDPCS_PHY_DP_TX2_EQ_MAIN;\
+   type RDPCS_PHY_DP_MPLLB_CP_PROP_GS;\
+   type RDPCS_PHY_DP_TX2_EQ_PRE;\
+   type RDPCS_PHY_DP_TX2_EQ_POST;\
+   type RDPCS_PHY_DP_TX3_EQ_MAIN;\
+   type RDPCS_PHY_DCO_RANGE;\
+   type RDPCS_PHY_DCO_FINETUNE;\
+   type RDPCS_PHY_DP_TX3_EQ_PRE;\
+   type RDPCS_PHY_DP_TX3_EQ_POST;\
+   type RDPCS_PHY_SUP_PRE_HP;\
+   type RDPCS_PHY_DP_TX0_VREGDRV_BYP;\
+   type RDPCS_PHY_DP_TX1_VREGDRV_BYP;\
+   type RDPCS_PHY_DP_TX2_VREGDRV_BYP;\
+   type RDPCS_PHY_DP_TX3_VREGDRV_BYP;\
+   type RDPCS_DMCU_DPALT_DIS_BLOCK_REG;\
+   type UNIPHYA_SOFT_RESET;\
+   type UNIPHYB_SOFT_RESET;\
+   type UNIPHYC_SOFT_RESET;\
+   type UNIPHYD_SOFT_RESET;\
+   type UNIPHYE_SOFT_RESET;\
+   type UNIPHYF_SOFT_RESET
 
 #define DCN20_LINK_ENCODER_REG_FIELD_LIST(type) \
type DIG_LANE0EN;\
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_link_encoder.h 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_link_encoder.h
index 3736b5548a25..0c98a0bbbd14 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_link_encoder.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_link_encoder.h
@@ -91,6 +91,13 @@ struct mpll_cfg {
uint32_t ref_range;
uint32_t ref_clk;
bool hdmimode_enable;
+   bool sup_pre_hp;
+   bool dp_tx0_vergdrv_byp;
+   bool dp_tx1_vergdrv_byp;
+   bool dp_tx2_vergdrv_byp;
+   bool dp_tx3_vergdrv_byp;
+
+
 };
 
 struct dpcssys_phy_seq_cfg {
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile 
b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
index 5b8f42ae2334..b7a9285348fb 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/Makefile
@@ -1,7 +1,7 @@
 #
 # Makefile for DCN21.
 
-DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o dcn21_hwseq.o
+DCN21 = dcn21_hubp.o dcn21_hubbub.o dcn21_resource.o dcn21_hwseq.o 
dcn21_link_encoder.o
 
 CFLAGS_dcn21_resource.o := -mhard-float -msse -mpreferred-stack-boundary=4
 
diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c
new file mode 100644
index ..b835f5fcbe52
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_link_encoder.c
@@ -0,0 +1,384 @@
+/*
+ * Copyright 2012-15 Advanced Micro

[PATCH 18/26] drm/amd/display: change PP_SM defs to 8

2019-10-09 Thread Bhawanpreet Lakha
DPM level is 8 these were incorrect before. Fix them

Signed-off-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dm_pp_smu.h | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dm_pp_smu.h 
b/drivers/gpu/drm/amd/display/dc/dm_pp_smu.h
index c03a441ee638..de3c83c8f6c3 100644
--- a/drivers/gpu/drm/amd/display/dc/dm_pp_smu.h
+++ b/drivers/gpu/drm/amd/display/dc/dm_pp_smu.h
@@ -252,9 +252,9 @@ struct pp_smu_funcs_nv {
 #if defined(CONFIG_DRM_AMD_DC_DCN2_1)
 
 #define PP_SMU_NUM_SOCCLK_DPM_LEVELS  8
-#define PP_SMU_NUM_DCFCLK_DPM_LEVELS  4
-#define PP_SMU_NUM_FCLK_DPM_LEVELS4
-#define PP_SMU_NUM_MEMCLK_DPM_LEVELS  4
+#define PP_SMU_NUM_DCFCLK_DPM_LEVELS  8
+#define PP_SMU_NUM_FCLK_DPM_LEVELS8
+#define PP_SMU_NUM_MEMCLK_DPM_LEVELS  8
 
 struct dpm_clock {
   uint32_t  Freq;// In MHz
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 22/26] drm/amd/display: Fix rn audio playback and video playback speed

2019-10-09 Thread Bhawanpreet Lakha
From: Michael Strauss 

[WHY]
dprefclk is improperly read due to incorrect units used.
Causes an audio clock to be improperly set, making audio
non-functional and videos play back too fast

[HOW]
Scale dprefclk value from MHz to KHz (multiply by 1000)
to ensure that dprefclk_khz is in correct units

Signed-off-by: Michael Strauss 
Acked-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c | 15 +++
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
index 93e46e376bb1..fb8aa9436bf0 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
@@ -377,7 +377,7 @@ void rn_get_clk_states(struct clk_mgr *clk_mgr_base, struct 
clk_states *s)
 
rn_dump_clk_registers(, clk_mgr_base, _info);
 
-   s->dprefclk_khz = sb.dprefclk;
+   s->dprefclk_khz = sb.dprefclk * 1000;
 }
 
 void rn_enable_pme_wa(struct clk_mgr *clk_mgr_base)
@@ -633,16 +633,15 @@ void rn_clk_mgr_construct(
clk_mgr->dentist_vco_freq_khz = 360;
 
rn_dump_clk_registers(, _mgr->base, _info);
-   clk_mgr->base.dprefclk_khz = s.dprefclk;
-
-   if (clk_mgr->base.dprefclk_khz != 60) {
-   clk_mgr->base.dprefclk_khz = 60;
-   ASSERT(1); //TODO: Renoir follow up.
-   }
+   /* Convert dprefclk units from MHz to KHz */
+   /* Value already divided by 10, some resolution lost */
+   clk_mgr->base.dprefclk_khz = s.dprefclk * 1000;
 
/* in case we don't get a value from the register, use default 
*/
-   if (clk_mgr->base.dprefclk_khz == 0)
+   if (clk_mgr->base.dprefclk_khz == 0) {
+   ASSERT(clk_mgr->base.dprefclk_khz == 60);
clk_mgr->base.dprefclk_khz = 60;
+   }
}
 
dce_clock_read_ss_info(clk_mgr);
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 25/26] drm/amd/display: enable smu set dcfclk

2019-10-09 Thread Bhawanpreet Lakha
From: Lewis Huang 

[Why]
SMU fixed this issue after version 0x370c00

[How]
enable smu send message to set dcfclk after smu version 0x370c00

Signed-off-by: Lewis Huang 
Acked-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c   | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git 
a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
index db28e91adb3d..2650776acbc3 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
@@ -124,7 +124,7 @@ int rn_vbios_smu_set_hard_min_dcfclk(struct 
clk_mgr_internal *clk_mgr, int reque
 {
int actual_dcfclk_set_mhz = -1;
 
-   if (clk_mgr->smu_ver < 0x)
+   if (clk_mgr->smu_ver < 0x370c00)
return actual_dcfclk_set_mhz;
 
actual_dcfclk_set_mhz = rn_vbios_smu_send_msg_with_param(
@@ -139,7 +139,7 @@ int rn_vbios_smu_set_min_deep_sleep_dcfclk(struct 
clk_mgr_internal *clk_mgr, int
 {
int actual_min_ds_dcfclk_mhz = -1;
 
-   if (clk_mgr->smu_ver < 0x)
+   if (clk_mgr->smu_ver < 0x370c00)
return actual_min_ds_dcfclk_mhz;
 
actual_min_ds_dcfclk_mhz = rn_vbios_smu_send_msg_with_param(
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 21/26] drm/amd/display: handle "18" case in TruncToValidBPP

2019-10-09 Thread Bhawanpreet Lakha
Handle 18 DecimalBPP like other cases

Signed-off-by: Bhawanpreet Lakha 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c 
b/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
index fd707e7459b5..ba77957aefe3 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
+++ b/drivers/gpu/drm/amd/display/dc/dml/dcn21/display_mode_vba_21.c
@@ -3380,6 +3380,8 @@ static unsigned int TruncToValidBPP(
return 30;
else if (DecimalBPP >= 24 && (DesiredBPP == 0 || 
DesiredBPP == 24))
return 24;
+   else if (DecimalBPP >= 18 && (DesiredBPP == 0 || 
DesiredBPP == 18))
+   return 18;
else
return BPP_INVALID;
}
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 19/26] drm/amd/display: add dummy functions to smu for Renoir Silicon Diags

2019-10-09 Thread Bhawanpreet Lakha
From: Sung Lee 

[Why]
Previously only dummy functions were added in Diags for FPGA.
On silicon, this would lead to a segmentation fault on silicon diags.

[How]
Check if diags silicon and if so, add dummy functions.

Signed-off-by: Sung Lee 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
index 002e7fb67068..25f62a3f2ffc 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_resource.c
@@ -1397,7 +1397,7 @@ static struct pp_smu_funcs *dcn21_pp_smu_create(struct 
dc_context *ctx)
if (!pp_smu)
return pp_smu;
 
-   if (IS_FPGA_MAXIMUS_DC(ctx->dce_environment)) {
+   if (IS_FPGA_MAXIMUS_DC(ctx->dce_environment) || 
IS_DIAG_DC(ctx->dce_environment)) {
pp_smu->ctx.ver = PP_SMU_VER_RN;
pp_smu->rn_funcs.get_dpm_clock_table = 
dummy_get_dpm_clock_table;
pp_smu->rn_funcs.set_wm_ranges = dummy_set_wm_ranges;
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 10/26] drm/amd/display: fix incorrect page table address for renoir

2019-10-09 Thread Bhawanpreet Lakha
Incorrect page table address and programming sys aperture for
stutter gather, so fix it.

Signed-off-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/dcn21/dcn21_hubbub.c   | 23 ++-
 1 file changed, 17 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index bd247e5e753e..fdfbdeb32459 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -111,19 +111,30 @@ int hubbub21_init_dchub(struct hubbub *hubbub,
struct dcn_hubbub_phys_addr_config *pa_config)
 {
struct dcn20_hubbub *hubbub1 = TO_DCN20_HUBBUB(hubbub);
+   struct dcn_vmid_page_table_config phys_config;
 
REG_SET(DCN_VM_FB_LOCATION_BASE, 0,
-   FB_BASE, pa_config->system_aperture.fb_base);
+   FB_BASE, pa_config->system_aperture.fb_base >> 24);
REG_SET(DCN_VM_FB_LOCATION_TOP, 0,
-   FB_TOP, pa_config->system_aperture.fb_top);
+   FB_TOP, pa_config->system_aperture.fb_top >> 24);
REG_SET(DCN_VM_FB_OFFSET, 0,
-   FB_OFFSET, pa_config->system_aperture.fb_offset);
+   FB_OFFSET, pa_config->system_aperture.fb_offset >> 24);
REG_SET(DCN_VM_AGP_BOT, 0,
-   AGP_BOT, pa_config->system_aperture.agp_bot);
+   AGP_BOT, pa_config->system_aperture.agp_bot >> 24);
REG_SET(DCN_VM_AGP_TOP, 0,
-   AGP_TOP, pa_config->system_aperture.agp_top);
+   AGP_TOP, pa_config->system_aperture.agp_top >> 24);
REG_SET(DCN_VM_AGP_BASE, 0,
-   AGP_BASE, pa_config->system_aperture.agp_base);
+   AGP_BASE, pa_config->system_aperture.agp_base >> 24);
+
+   if (pa_config->gart_config.page_table_start_addr != 
pa_config->gart_config.page_table_end_addr) {
+   phys_config.page_table_start_addr = 
pa_config->gart_config.page_table_start_addr >> 12;
+   phys_config.page_table_end_addr = 
pa_config->gart_config.page_table_end_addr >> 12;
+   phys_config.page_table_base_addr = 
pa_config->gart_config.page_table_base_addr | 1; //Note: hack
+   phys_config.depth = 0;
+   phys_config.block_size = 0;
+   // Init VMID 0 based on PA config
+   dcn20_vmid_setup(>vmid[0], _config);
+   }
 
dcn21_dchvm_init(hubbub);
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 02/26] drm/amd/display: configurable aux timeout support

2019-10-09 Thread Bhawanpreet Lakha
From: abdoulaye berthe 

[Description]
1-add configurable timeout support to aux engine.
2-add timeout support field to dc_caps
3-add reg_key to override extended timeout support

Signed-off-by: abdoulaye berthe 
Acked-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/dc/core/dc_link_ddc.c | 14 
 drivers/gpu/drm/amd/display/dc/dc.h   |  2 +
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c  | 73 ++-
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.h  | 16 +++-
 .../amd/display/dc/dce100/dce100_resource.c   |  5 +-
 .../amd/display/dc/dce110/dce110_resource.c   |  4 +-
 .../amd/display/dc/dce112/dce112_resource.c   |  5 +-
 .../amd/display/dc/dce120/dce120_resource.c   |  5 +-
 .../drm/amd/display/dc/dce80/dce80_resource.c |  4 +-
 .../drm/amd/display/dc/dcn10/dcn10_resource.c |  5 +-
 .../drm/amd/display/dc/dcn20/dcn20_resource.c |  4 +-
 .../drm/amd/display/dc/dcn21/dcn21_resource.c |  4 +-
 .../gpu/drm/amd/display/dc/inc/dc_link_ddc.h  |  3 +
 .../gpu/drm/amd/display/dc/inc/dc_link_dp.h   |  2 +
 .../drm/amd/display/dc/inc/hw/aux_engine.h|  3 +
 15 files changed, 132 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
index 57fb0574f198..9a56f110bbd1 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_ddc.c
@@ -634,6 +634,20 @@ bool dc_link_aux_transfer_with_retries(struct ddc_service 
*ddc,
return dce_aux_transfer_with_retries(ddc, payload);
 }
 
+
+enum dc_status dc_link_aux_configure_timeout(struct ddc_service *ddc,
+   uint32_t timeout)
+{
+   enum dc_status status = DC_OK;
+   struct ddc *ddc_pin = ddc->ddc_pin;
+
+   if 
(ddc->ctx->dc->res_pool->engines[ddc_pin->pin_data->en]->funcs->configure_timeout
 == NULL)
+   return DC_ERROR_UNEXPECTED;
+   if 
(!ddc->ctx->dc->res_pool->engines[ddc_pin->pin_data->en]->funcs->configure_timeout(ddc,
 timeout))
+   status = DC_ERROR_UNEXPECTED;
+   return status;
+}
+
 /*test only function*/
 void dal_ddc_service_set_ddc_pin(
struct ddc_service *ddc_service,
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 41e366f59f10..5967106826ca 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -111,6 +111,7 @@ struct dc_caps {
bool force_dp_tps4_for_cp2520;
bool disable_dp_clk_share;
bool psp_setup_panel_mode;
+   bool extended_aux_timeout_support;
 #ifdef CONFIG_DRM_AMD_DC_DCN2_0
bool hw_3d_lut;
 #endif
@@ -220,6 +221,7 @@ struct dc_config {
bool power_down_display_on_boot;
bool edp_not_connected;
bool forced_clocks;
+   bool disable_extended_timeout_support; // Used to disable extended 
timeout and lttpr feature as well
bool multi_mon_pp_mclk_switch;
 };
 
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c 
b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
index de233270e3d5..976bd4987a28 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
@@ -59,6 +59,14 @@ enum {
AUX_TIMED_OUT_RETRY_COUNTER = 2,
AUX_DEFER_RETRY_COUNTER = 6
 };
+
+#define TIME_OUT_INCREMENT  1016
+#define TIME_OUT_MULTIPLIER_8  8
+#define TIME_OUT_MULTIPLIER_16  16
+#define TIME_OUT_MULTIPLIER_32  32
+#define TIME_OUT_MULTIPLIER_64  64
+#define MAX_TIMEOUT_LENGTH  127
+
 static void release_engine(
struct dce_aux *engine)
 {
@@ -202,7 +210,7 @@ static void submit_channel_request(
REG_UPDATE(AUX_INTERRUPT_CONTROL, AUX_SW_DONE_ACK, 1);
 
REG_WAIT(AUX_SW_STATUS, AUX_SW_DONE, 0,
-   10, aux110->timeout_period/10);
+   10, aux110->polling_timeout_period/10);
 
/* set the delay and the number of bytes to write */
 
@@ -331,7 +339,7 @@ static enum aux_channel_operation_result get_channel_status(
 
/* poll to make sure that SW_DONE is asserted */
REG_WAIT(AUX_SW_STATUS, AUX_SW_DONE, 1,
-   10, aux110->timeout_period/10);
+   10, aux110->polling_timeout_period/10);
 
value = REG_READ(AUX_SW_STATUS);
/* in case HPD is LOW, exit AUX transaction */
@@ -419,24 +427,81 @@ void dce110_engine_destroy(struct dce_aux **engine)
 
 }
 
+static bool dce_aux_configure_timeout(struct ddc_service *ddc,
+   uint32_t timeout_in_us)
+{
+   uint32_t multiplier = 0;
+   uint32_t length = 0;
+   uint32_t timeout = 0;
+   struct ddc *ddc_pin = ddc->ddc_pin;
+   struct dce_aux *aux_engine = 
ddc->ctx->dc->res_pool->engines[ddc_pin->pin_data->en];
+   struct aux_engine_dce110 *aux110 = FROM_AUX_ENGINE(aux_engine);
+
+   /* 1-Upd

[PATCH 16/26] drm/amd/display: update dcn21 hubbub registers

2019-10-09 Thread Bhawanpreet Lakha
use dcn20 common regs define to share some regs with dcn20

Signed-off-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.h | 17 +++--
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.h 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.h
index 698c470cc0f6..c4840dfb1fa5 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.h
@@ -36,6 +36,10 @@
SR(DCHUBBUB_ARB_FRAC_URG_BW_FLIP_B),\
SR(DCHUBBUB_ARB_FRAC_URG_BW_FLIP_C),\
SR(DCHUBBUB_ARB_FRAC_URG_BW_FLIP_D),\
+   SR(DCHUBBUB_ARB_REFCYC_PER_TRIP_TO_MEMORY_A),\
+   SR(DCHUBBUB_ARB_REFCYC_PER_TRIP_TO_MEMORY_B),\
+   SR(DCHUBBUB_ARB_REFCYC_PER_TRIP_TO_MEMORY_C),\
+   SR(DCHUBBUB_ARB_REFCYC_PER_TRIP_TO_MEMORY_D),\
SR(DCHUBBUB_ARB_HOSTVM_CNTL), \
SR(DCHVM_CTRL0), \
SR(DCHVM_MEM_CTRL), \
@@ -44,16 +48,9 @@
SR(DCHVM_RIOMMU_STAT0)
 
 #define HUBBUB_REG_LIST_DCN21()\
-   HUBBUB_REG_LIST_DCN_COMMON(), \
+   HUBBUB_REG_LIST_DCN20_COMMON(), \
HUBBUB_SR_WATERMARK_REG_LIST(), \
-   HUBBUB_HVM_REG_LIST(), \
-   SR(DCHUBBUB_CRC_CTRL), \
-   SR(DCN_VM_FB_LOCATION_BASE),\
-   SR(DCN_VM_FB_LOCATION_TOP),\
-   SR(DCN_VM_FB_OFFSET),\
-   SR(DCN_VM_AGP_BOT),\
-   SR(DCN_VM_AGP_TOP),\
-   SR(DCN_VM_AGP_BASE)
+   HUBBUB_HVM_REG_LIST()
 
 #define HUBBUB_MASK_SH_LIST_HVM(mask_sh) \
HUBBUB_SF(DCHUBBUB_ARB_DF_REQ_OUTSTAND, 
DCHUBBUB_ARB_MIN_REQ_OUTSTAND_COMMIT_THRESHOLD, mask_sh), \
@@ -102,7 +99,7 @@
HUBBUB_SF(DCHUBBUB_ARB_REFCYC_PER_TRIP_TO_MEMORY_D, 
DCHUBBUB_ARB_REFCYC_PER_TRIP_TO_MEMORY_D, mask_sh)
 
 #define HUBBUB_MASK_SH_LIST_DCN21(mask_sh)\
-   HUBBUB_MASK_SH_LIST_HVM(mask_sh),\
+   HUBBUB_MASK_SH_LIST_HVM(mask_sh), \
HUBBUB_MASK_SH_LIST_DCN_COMMON(mask_sh), \
HUBBUB_MASK_SH_LIST_STUTTER(mask_sh), \
HUBBUB_SF(DCHUBBUB_GLOBAL_TIMER_CNTL, DCHUBBUB_GLOBAL_TIMER_REFDIV, 
mask_sh), \
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 15/26] drm/amd/display: add detile buffer size for renoir

2019-10-09 Thread Bhawanpreet Lakha
Detile buffer size affects dcc caps, it was already added for
dcn2. Now add it for dcn21

Signed-off-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index aeb5de6f4530..f546260c15b7 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -653,4 +653,5 @@ void hubbub21_construct(struct dcn20_hubbub *hubbub,
hubbub->masks = hubbub_mask;
 
hubbub->debug_test_index_pstate = 0xB;
+   hubbub->detile_buf_size = 164 * 1024; /* 164KB for DCN2.0 */
 }
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 26/26] drm/amd/display: use requested_dispclk_khz instead of clk

2019-10-09 Thread Bhawanpreet Lakha
Use requested_dispclk_khz / 1000 directly

Signed-off-by: Bhawanpreet Lakha 
---
 .../display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c | 13 ++---
 1 file changed, 2 insertions(+), 11 deletions(-)

diff --git 
a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
index 2650776acbc3..5647fcf10717 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr_vbios_smu.c
@@ -84,16 +84,12 @@ int rn_vbios_smu_set_dispclk(struct clk_mgr_internal 
*clk_mgr, int requested_dis
int actual_dispclk_set_mhz = -1;
struct dc *core_dc = clk_mgr->base.ctx->dc;
struct dmcu *dmcu = core_dc->res_pool->dmcu;
-   uint32_t clk = requested_dispclk_khz / 1000;
-
-   if (clk <= 100)
-   clk = 101;
 
/*  Unit of SMU msg parameter is Mhz */
actual_dispclk_set_mhz = rn_vbios_smu_send_msg_with_param(
clk_mgr,
VBIOSSMC_MSG_SetDispclkFreq,
-   clk);
+   requested_dispclk_khz / 1000);
 
if (!IS_FPGA_MAXIMUS_DC(core_dc->ctx->dce_environment)) {
if (dmcu && dmcu->funcs->is_dmcu_initialized(dmcu)) {
@@ -162,15 +158,10 @@ int rn_vbios_smu_set_dppclk(struct clk_mgr_internal 
*clk_mgr, int requested_dpp_
 {
int actual_dppclk_set_mhz = -1;
 
-   uint32_t clk = requested_dpp_khz / 1000;
-
-   if (clk <= 100)
-   clk = 101;
-
actual_dppclk_set_mhz = rn_vbios_smu_send_msg_with_param(
clk_mgr,
VBIOSSMC_MSG_SetDppclkFreq,
-   clk);
+   requested_dpp_khz / 1000);
 
return actual_dppclk_set_mhz * 1000;
 }
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 09/26] drm/amd/display: enable hostvm based on roimmu active for dcn2.1

2019-10-09 Thread Bhawanpreet Lakha
From: Dmytro Laktyushkin 

Enabling hostvm when ROIMMU is not active seems to break GPUVM.
This fixes the issue by not enabling hostvm if ROIMMU is not
activated.

Signed-off-by: Dmytro Laktyushkin 
Acked-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/dc/dcn21/dcn21_hubbub.c   | 40 ---
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c 
b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
index 8e7e79f44272..bd247e5e753e 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn21/dcn21_hubbub.c
@@ -22,6 +22,7 @@
  * Authors: AMD
  *
  */
+#include 
 #include "dm_services.h"
 #include "dcn20/dcn20_hubbub.h"
 #include "dcn21_hubbub.h"
@@ -71,30 +72,39 @@ static uint32_t convert_and_clamp(
 void dcn21_dchvm_init(struct hubbub *hubbub)
 {
struct dcn20_hubbub *hubbub1 = TO_DCN20_HUBBUB(hubbub);
+   uint32_t riommu_active;
+   int i;
 
//Init DCHVM block
REG_UPDATE(DCHVM_CTRL0, HOSTVM_INIT_REQ, 1);
 
//Poll until RIOMMU_ACTIVE = 1
-   //TODO: Figure out interval us and retry count
-   REG_WAIT(DCHVM_RIOMMU_STAT0, RIOMMU_ACTIVE, 1, 5, 100);
+   for (i = 0; i < 100; i++) {
+   REG_GET(DCHVM_RIOMMU_STAT0, RIOMMU_ACTIVE, _active);
 
-   //Reflect the power status of DCHUBBUB
-   REG_UPDATE(DCHVM_RIOMMU_CTRL0, HOSTVM_POWERSTATUS, 1);
+   if (riommu_active)
+   break;
+   else
+   udelay(5);
+   }
+
+   if (riommu_active) {
+   //Reflect the power status of DCHUBBUB
+   REG_UPDATE(DCHVM_RIOMMU_CTRL0, HOSTVM_POWERSTATUS, 1);
 
-   //Start rIOMMU prefetching
-   REG_UPDATE(DCHVM_RIOMMU_CTRL0, HOSTVM_PREFETCH_REQ, 1);
+   //Start rIOMMU prefetching
+   REG_UPDATE(DCHVM_RIOMMU_CTRL0, HOSTVM_PREFETCH_REQ, 1);
 
-   // Enable dynamic clock gating
-   REG_UPDATE_4(DCHVM_CLK_CTRL,
-   HVM_DISPCLK_R_GATE_DIS, 0,
-   HVM_DISPCLK_G_GATE_DIS, 0,
-   HVM_DCFCLK_R_GATE_DIS, 0,
-   HVM_DCFCLK_G_GATE_DIS, 0);
+   // Enable dynamic clock gating
+   REG_UPDATE_4(DCHVM_CLK_CTRL,
+   HVM_DISPCLK_R_GATE_DIS, 0,
+   HVM_DISPCLK_G_GATE_DIS, 0,
+   HVM_DCFCLK_R_GATE_DIS, 0,
+   HVM_DCFCLK_G_GATE_DIS, 0);
 
-   //Poll until HOSTVM_PREFETCH_DONE = 1
-   //TODO: Figure out interval us and retry count
-   REG_WAIT(DCHVM_RIOMMU_STAT0, HOSTVM_PREFETCH_DONE, 1, 5, 100);
+   //Poll until HOSTVM_PREFETCH_DONE = 1
+   REG_WAIT(DCHVM_RIOMMU_STAT0, HOSTVM_PREFETCH_DONE, 1, 5, 100);
+   }
 }
 
 int hubbub21_init_dchub(struct hubbub *hubbub,
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 10/11] drm/amd/display: Refactor HDCP encryption status update

2019-10-03 Thread Bhawanpreet Lakha
[Why]
The old way was to poll PSP and update the properties. But due to a
limitation in the PSP interface this doesn't work for MST.

[How]
According to PSP if set_encryption return success, the link is encrypted
and the only way it will not be is if we get a link loss(which we handle
already).

So this method should be good enough to report HDCP status.

Signed-off-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c |  3 +--
 .../gpu/drm/amd/display/modules/hdcp/hdcp.c| 18 ++
 .../gpu/drm/amd/display/modules/inc/mod_hdcp.h |  4 ++--
 3 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
index 6c4b3134e786..603909416398 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
@@ -81,6 +81,7 @@ static void process_output(struct hdcp_workqueue *hdcp_work)
schedule_delayed_work(_work->watchdog_timer_dwork,
  
msecs_to_jiffies(output.watchdog_timer_delay));
 
+   schedule_delayed_work(_work->property_validate_dwork, 
msecs_to_jiffies(0));
 }
 
 void hdcp_update_display(struct hdcp_workqueue *hdcp_work,
@@ -233,8 +234,6 @@ static void event_property_validate(struct work_struct 
*work)
schedule_work(_work->property_update_work);
}
 
-   schedule_delayed_work(_work->property_validate_dwork, 
msecs_to_jiffies(DRM_HDCP_CHECK_PERIOD_MS));
-
mutex_unlock(_work->mutex);
 }
 
diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c
index 0f2f242710b3..cbb5e9c063ec 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c
@@ -417,10 +417,20 @@ enum mod_hdcp_status mod_hdcp_query_display(struct 
mod_hdcp *hdcp,
query->trace = >connection.trace;
query->encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF;
 
-   if (is_hdcp1(hdcp))
-   mod_hdcp_hdcp1_get_link_encryption_status(hdcp, 
>encryption_status);
-   else if (is_hdcp2(hdcp))
-   mod_hdcp_hdcp2_get_link_encryption_status(hdcp, 
>encryption_status);
+   if (is_display_encryption_enabled(display)) {
+   if (is_hdcp1(hdcp)) {
+   query->encryption_status = 
MOD_HDCP_ENCRYPTION_STATUS_HDCP1_ON;
+   } else if (is_hdcp2(hdcp)) {
+   if (query->link->adjust.hdcp2.force_type == 
MOD_HDCP_FORCE_TYPE_0)
+   query->encryption_status = 
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE0_ON;
+   else if (query->link->adjust.hdcp2.force_type == 
MOD_HDCP_FORCE_TYPE_1)
+   query->encryption_status = 
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON;
+   else
+   query->encryption_status = 
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_ON;
+   }
+   } else {
+   query->encryption_status = MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF;
+   }
 
 out:
return status;
diff --git a/drivers/gpu/drm/amd/display/modules/inc/mod_hdcp.h 
b/drivers/gpu/drm/amd/display/modules/inc/mod_hdcp.h
index ff2bb2bfbb53..f2a0e1a064da 100644
--- a/drivers/gpu/drm/amd/display/modules/inc/mod_hdcp.h
+++ b/drivers/gpu/drm/amd/display/modules/inc/mod_hdcp.h
@@ -191,9 +191,9 @@ struct mod_hdcp_trace {
 enum mod_hdcp_encryption_status {
MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF = 0,
MOD_HDCP_ENCRYPTION_STATUS_HDCP1_ON,
-   MOD_HDCP_ENCRYPTION_STATUS_HDCP2_ON,
MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE0_ON,
-   MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON
+   MOD_HDCP_ENCRYPTION_STATUS_HDCP2_TYPE1_ON,
+   MOD_HDCP_ENCRYPTION_STATUS_HDCP2_ON
 };
 
 /* per link events dm has to notify to hdcp module */
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 11/11] drm/amd/display: fix events handling for hdcp

2019-10-03 Thread Bhawanpreet Lakha
[Why]
When we execute a event, pending events should be canceled. This leads
to cases where we execute the same event twice,if the new event is
scheduled to run before the old event.

Also watchdog event was being canceled inside callback event. This is
incorrect.

[How]
Cancel pending events before executing the current and fix watchdog
event being canceled by callback event

Change-Id: I3c595901d63f3393c83d898cdb2d7dfc1a769142
Signed-off-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
index 603909416398..715f650715b3 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
@@ -169,7 +169,7 @@ static void event_callback(struct work_struct *work)
 
mutex_lock(_work->mutex);
 
-   cancel_delayed_work(_work->watchdog_timer_dwork);
+   cancel_delayed_work(_work->callback_dwork);
 
mod_hdcp_process_event(_work->hdcp, MOD_HDCP_EVENT_CALLBACK,
   _work->output);
@@ -247,6 +247,8 @@ static void event_watchdog_timer(struct work_struct *work)
 
mutex_lock(_work->mutex);
 
+   cancel_delayed_work(_work->watchdog_timer_dwork);
+
mod_hdcp_process_event(_work->hdcp,
   MOD_HDCP_EVENT_WATCHDOG_TIMEOUT,
   _work->output);
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 04/11] drm/amd/display: Add logging for HDCP2.2

2019-10-03 Thread Bhawanpreet Lakha
[Why]
We need to log the state changes for 2.2
This patch extends the existing logging functions to handle
HDCP2.2.

[How]
We do this by adding if/else in the defines, and output the log
 based on the hdcp version

Signed-off-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/modules/hdcp/hdcp_log.c   | 118 ++
 .../drm/amd/display/modules/hdcp/hdcp_log.h   |  94 +++---
 .../drm/amd/display/modules/hdcp/hdcp_psp.c   |   4 +
 3 files changed, 196 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.c 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.c
index d868f556d180..a1d640e485da 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.c
@@ -116,6 +116,58 @@ char *mod_hdcp_status_to_str(int32_t status)
return "MOD_HDCP_STATUS_DDC_FAILURE";
case MOD_HDCP_STATUS_INVALID_OPERATION:
return "MOD_HDCP_STATUS_INVALID_OPERATION";
+   case MOD_HDCP_STATUS_HDCP2_NOT_CAPABLE:
+   return "MOD_HDCP_STATUS_HDCP2_NOT_CAPABLE";
+   case MOD_HDCP_STATUS_HDCP2_CREATE_SESSION_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_CREATE_SESSION_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_DESTROY_SESSION_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_DESTROY_SESSION_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_PREP_AKE_INIT_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_PREP_AKE_INIT_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_AKE_CERT_PENDING:
+   return "MOD_HDCP_STATUS_HDCP2_AKE_CERT_PENDING";
+   case MOD_HDCP_STATUS_HDCP2_H_PRIME_PENDING:
+   return "MOD_HDCP_STATUS_HDCP2_H_PRIME_PENDING";
+   case MOD_HDCP_STATUS_HDCP2_PAIRING_INFO_PENDING:
+   return "MOD_HDCP_STATUS_HDCP2_PAIRING_INFO_PENDING";
+   case MOD_HDCP_STATUS_HDCP2_VALIDATE_AKE_CERT_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_VALIDATE_AKE_CERT_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_AKE_CERT_REVOKED:
+   return "MOD_HDCP_STATUS_HDCP2_AKE_CERT_REVOKED";
+   case MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_VALIDATE_H_PRIME_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_VALIDATE_PAIRING_INFO_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_VALIDATE_PAIRING_INFO_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_PREP_LC_INIT_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_PREP_LC_INIT_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_L_PRIME_PENDING:
+   return "MOD_HDCP_STATUS_HDCP2_L_PRIME_PENDING";
+   case MOD_HDCP_STATUS_HDCP2_VALIDATE_L_PRIME_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_VALIDATE_L_PRIME_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_PREP_EKS_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_PREP_EKS_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_ENABLE_ENCRYPTION_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_ENABLE_ENCRYPTION_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_VALIDATE_RX_ID_LIST_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_REVOKED:
+   return "MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_REVOKED";
+   case MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_NOT_READY:
+   return "MOD_HDCP_STATUS_HDCP2_RX_ID_LIST_NOT_READY";
+   case MOD_HDCP_STATUS_HDCP2_ENABLE_STREAM_ENCRYPTION:
+   return "MOD_HDCP_STATUS_HDCP2_ENABLE_STREAM_ENCRYPTION";
+   case MOD_HDCP_STATUS_HDCP2_STREAM_READY_PENDING:
+   return "MOD_HDCP_STATUS_HDCP2_STREAM_READY_PENDING";
+   case MOD_HDCP_STATUS_HDCP2_VALIDATE_STREAM_READY_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_VALIDATE_STREAM_READY_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_PREPARE_STREAM_MANAGEMENT_FAILURE:
+   return 
"MOD_HDCP_STATUS_HDCP2_PREPARE_STREAM_MANAGEMENT_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_REAUTH_REQUEST:
+   return "MOD_HDCP_STATUS_HDCP2_REAUTH_REQUEST";
+   case MOD_HDCP_STATUS_HDCP2_REAUTH_LINK_INTEGRITY_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_REAUTH_LINK_INTEGRITY_FAILURE";
+   case MOD_HDCP_STATUS_HDCP2_DEVICE_COUNT_MISMATCH_FAILURE:
+   return "MOD_HDCP_STATUS_HDCP2_DEVICE_COUNT_MISMATCH_FAILURE";
default:
return "MOD_HDCP_STATUS_UNKNOWN";
}
@@ -156,6 +208,72 @@ char *mod_hdcp_state_id_to_str(int32_t id)
return "D1_A6_WAIT_FOR_READY";
case D1_A7_READ_KSV_LIST:
return "D1_A7_READ_KSV_LIST";
+   case H2_A0_KNOWN_HDCP2_CAPABLE_RX

[PATCH 07/11] drm/amd/display: Handle hdcp2.2 type0/1 in dm

2019-10-03 Thread Bhawanpreet Lakha
[Why]
HDCP 2.2 uses type0 and type1 content type. This is passed to the receiver
to stream the proper content.

For example, in a MST case if the main
device is HDCP2.2 capable but the secondary device is only 1.4 capabale
we can use Type0

Type0 content: use HDCP 1.4 or HDCP2.2 type0
Type1 content: Only use HDCP 2.2 type1

[How]
We use the "hdcp content type" property in drm. We use the
disable_type1 flag in hdcp module to select the type based on the
properties.

For updating the property we use the same logic as 1.4, but now we
consider content_type as well and update the property if the
requirements are met

Signed-off-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c  | 18 ++
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c | 17 +
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h |  4 ++--
 .../gpu/drm/amd/display/modules/hdcp/hdcp.c|  5 -
 4 files changed, 33 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 7b0ca2e1ed8b..e9a9edac6ea7 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -39,6 +39,7 @@
 #include "amdgpu_dm.h"
 #ifdef CONFIG_DRM_AMD_DC_HDCP
 #include "amdgpu_dm_hdcp.h"
+#include 
 #endif
 #include "amdgpu_pm.h"
 
@@ -5118,7 +5119,7 @@ void amdgpu_dm_connector_init_helper(struct 
amdgpu_display_manager *dm,
adev->mode_info.freesync_capable_property, 0);
 #ifdef CONFIG_DRM_AMD_DC_HDCP
if (adev->asic_type >= CHIP_RAVEN)
-   
drm_connector_attach_content_protection_property(>base, false);
+   
drm_connector_attach_content_protection_property(>base, true);
 #endif
}
 }
@@ -5369,6 +5370,12 @@ static bool is_content_protection_different(struct 
drm_connector_state *state,
 {
struct amdgpu_dm_connector *aconnector = 
to_amdgpu_dm_connector(connector);
 
+   if (old_state->hdcp_content_type != state->hdcp_content_type &&
+   state->content_protection != DRM_MODE_CONTENT_PROTECTION_UNDESIRED) 
{
+   state->content_protection = DRM_MODE_CONTENT_PROTECTION_DESIRED;
+   return true;
+   }
+
/* CP is being re enabled, ignore this */
if (old_state->content_protection == 
DRM_MODE_CONTENT_PROTECTION_ENABLED &&
state->content_protection == DRM_MODE_CONTENT_PROTECTION_DESIRED) {
@@ -5401,11 +5408,14 @@ static void update_content_protection(struct 
drm_connector_state *state, const s
  struct hdcp_workqueue *hdcp_w)
 {
struct amdgpu_dm_connector *aconnector = 
to_amdgpu_dm_connector(connector);
+   bool disable_type1 = state->hdcp_content_type == 
DRM_MODE_HDCP_CONTENT_TYPE0 ? true : false;
 
-   if (state->content_protection == DRM_MODE_CONTENT_PROTECTION_DESIRED)
-   hdcp_add_display(hdcp_w, aconnector->dc_link->link_index, 
aconnector);
-   else if (state->content_protection == 
DRM_MODE_CONTENT_PROTECTION_UNDESIRED)
+   if (state->content_protection == DRM_MODE_CONTENT_PROTECTION_DESIRED) {
+   hdcp_reset_display(hdcp_w, aconnector->dc_link->link_index);
+   hdcp_add_display(hdcp_w, aconnector->dc_link->link_index, 
aconnector, disable_type1);
+   } else if (state->content_protection == 
DRM_MODE_CONTENT_PROTECTION_UNDESIRED) {
hdcp_remove_display(hdcp_w, aconnector->dc_link->link_index, 
aconnector->base.index);
+   }
 
 }
 #endif
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
index fc775c0795d8..75f7045f04dd 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
@@ -83,7 +83,8 @@ static void process_output(struct hdcp_workqueue *hdcp_work)
 
 }
 
-void hdcp_add_display(struct hdcp_workqueue *hdcp_work, unsigned int 
link_index, struct amdgpu_dm_connector *aconnector)
+void hdcp_add_display(struct hdcp_workqueue *hdcp_work, unsigned int 
link_index, struct amdgpu_dm_connector *aconnector,
+ bool disable_type1)
 {
struct hdcp_workqueue *hdcp_w = _work[link_index];
struct mod_hdcp_display *display = _work[link_index].display;
@@ -92,6 +93,8 @@ void hdcp_add_display(struct hdcp_workqueue *hdcp_work, 
unsigned int link_index,
mutex_lock(_w->mutex);
hdcp_w->aconnector = aconnector;
 
+   hdcp_w->link.adjust.hdcp2.disable_type1 = disable_type1;
+
mod_hdcp_add_display(_w->hdcp, link, display, _w->output);
 
schedule_delayed_work(_w->property_validate_dwork, 
msecs_to_jiffies(DRM_HDCP_CHECK_PERIOD_MS));
@@ -

[PATCH 08/11] drm/amd/display: Refactor HDCP to handle multiple displays per link

2019-10-03 Thread Bhawanpreet Lakha
[Why]
We need to do this to support HDCP over MST

Currently we save a display per link, in a MST case we need to save
multiple displays per link.

[How]
We can create an array per link to cache the displays, but it
complicates the design. Instead we can use the module to cache the
displays.

Now we will always add all the displays to the module, but we use the
adjustment flag to disable hdcp on all of them before they are added.

When we want to enable hdcp we just query the display(cache), remove
it then add it back with different adjustments. Its the similar for
disable.

Signed-off-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 20 ++-
 .../amd/display/amdgpu_dm/amdgpu_dm_hdcp.c| 53 ++-
 .../amd/display/amdgpu_dm/amdgpu_dm_hdcp.h|  9 ++--
 3 files changed, 40 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index e9a9edac6ea7..0bb212e47766 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -5404,20 +5404,6 @@ static bool is_content_protection_different(struct 
drm_connector_state *state,
return false;
 }
 
-static void update_content_protection(struct drm_connector_state *state, const 
struct drm_connector *connector,
- struct hdcp_workqueue *hdcp_w)
-{
-   struct amdgpu_dm_connector *aconnector = 
to_amdgpu_dm_connector(connector);
-   bool disable_type1 = state->hdcp_content_type == 
DRM_MODE_HDCP_CONTENT_TYPE0 ? true : false;
-
-   if (state->content_protection == DRM_MODE_CONTENT_PROTECTION_DESIRED) {
-   hdcp_reset_display(hdcp_w, aconnector->dc_link->link_index);
-   hdcp_add_display(hdcp_w, aconnector->dc_link->link_index, 
aconnector, disable_type1);
-   } else if (state->content_protection == 
DRM_MODE_CONTENT_PROTECTION_UNDESIRED) {
-   hdcp_remove_display(hdcp_w, aconnector->dc_link->link_index, 
aconnector->base.index);
-   }
-
-}
 #endif
 static void remove_stream(struct amdgpu_device *adev,
  struct amdgpu_crtc *acrtc,
@@ -6364,7 +6350,11 @@ static void amdgpu_dm_atomic_commit_tail(struct 
drm_atomic_state *state)
}
 
if (is_content_protection_different(new_con_state, 
old_con_state, connector, adev->dm.hdcp_workqueue))
-   update_content_protection(new_con_state, connector, 
adev->dm.hdcp_workqueue);
+   hdcp_update_display(
+   adev->dm.hdcp_workqueue, 
aconnector->dc_link->link_index, aconnector,
+   new_con_state->hdcp_content_type == 
DRM_MODE_HDCP_CONTENT_TYPE0 ? true : false,
+   new_con_state->content_protection == 
DRM_MODE_CONTENT_PROTECTION_DESIRED ? true
+   
 : false);
}
 #endif
 
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
index 75f7045f04dd..ca12362e799a 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
@@ -83,43 +83,45 @@ static void process_output(struct hdcp_workqueue *hdcp_work)
 
 }
 
-void hdcp_add_display(struct hdcp_workqueue *hdcp_work, unsigned int 
link_index, struct amdgpu_dm_connector *aconnector,
- bool disable_type1)
+void hdcp_update_display(struct hdcp_workqueue *hdcp_work,
+unsigned int link_index,
+struct amdgpu_dm_connector *aconnector,
+bool disable_type1,
+bool enable_encryption)
 {
struct hdcp_workqueue *hdcp_w = _work[link_index];
struct mod_hdcp_display *display = _work[link_index].display;
struct mod_hdcp_link *link = _work[link_index].link;
+   struct mod_hdcp_display_query query;
 
mutex_lock(_w->mutex);
hdcp_w->aconnector = aconnector;
 
-   hdcp_w->link.adjust.hdcp2.disable_type1 = disable_type1;
-
-   mod_hdcp_add_display(_w->hdcp, link, display, _w->output);
-
-   schedule_delayed_work(_w->property_validate_dwork, 
msecs_to_jiffies(DRM_HDCP_CHECK_PERIOD_MS));
-
-   process_output(hdcp_w);
-
-   mutex_unlock(_w->mutex);
-
-}
-
-void hdcp_remove_display(struct hdcp_workqueue *hdcp_work, unsigned int 
link_index,  unsigned int display_index)
-{
-   struct hdcp_workqueue *hdcp_w = _work[link_index];
-
-   mutex_lock(_w->mutex);
+   query.display = NULL;
+   mod_hdcp_query_display(_w->hdcp, aconnector->base.index, );
+
+   if (query.display != NULL) {
+   memcpy(display, query.display, sizeof(struct

[PATCH 06/11] drm/amd/display: Enable HDCP 2.2

2019-10-03 Thread Bhawanpreet Lakha
[Why]
HDCP 2.2 was disabled, we need to enable it

[How]
-Update display topology to support 2.2
-Unset hdcp2.disable in update_config
-Change logic of event_update_property, now we set the property to be
ENABLED for any level of encryption (2.2 or 1.4).

Signed-off-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c | 3 +--
 drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c| 2 +-
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
index 2443c238c188..fc775c0795d8 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
@@ -186,7 +186,7 @@ static void event_property_update(struct work_struct *work)
}
}
 
-   if (hdcp_work->encryption_status == MOD_HDCP_ENCRYPTION_STATUS_HDCP1_ON)
+   if (hdcp_work->encryption_status != MOD_HDCP_ENCRYPTION_STATUS_HDCP_OFF)
drm_hdcp_update_content_protection(>base, 
DRM_MODE_CONTENT_PROTECTION_ENABLED);
else
drm_hdcp_update_content_protection(>base, 
DRM_MODE_CONTENT_PROTECTION_DESIRED);
@@ -290,7 +290,6 @@ static void update_config(void *handle, struct 
cp_psp_stream_config *config)
link->dig_be = config->link_enc_inst;
link->ddc_line = aconnector->dc_link->ddc_hw_inst + 1;
link->dp.rev = aconnector->dc_link->dpcd_caps.dpcd_rev.raw;
-   link->adjust.hdcp2.disable = 1;
 
 }
 
diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
index 82283c3804df..4a6b95d7b44e 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
@@ -109,7 +109,7 @@ enum mod_hdcp_status mod_hdcp_add_display_topology(struct 
mod_hdcp *hdcp)
dtm_cmd->dtm_in_message.topology_update_v2.dig_fe = 
display->dig_fe;
dtm_cmd->dtm_in_message.topology_update_v2.dp_mst_vcid 
= display->vc_id;

dtm_cmd->dtm_in_message.topology_update_v2.max_hdcp_supported_version =
-   TA_DTM_HDCP_VERSION_MAX_SUPPORTED__1_x;
+   TA_DTM_HDCP_VERSION_MAX_SUPPORTED__2_2;
dtm_cmd->dtm_status = TA_DTM_STATUS__GENERIC_FAILURE;
 
psp_dtm_invoke(psp, dtm_cmd->cmd_id);
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 09/11] drm/amd/display: add force Type0/1 flag

2019-10-03 Thread Bhawanpreet Lakha
[Why]
Before we had a disable_type1 flag, this forced HDCP 2.2 to type0
There was no way to force type1.

[How]
Remove disable_type1 flag and instead add a flag to force type0/1.

Signed-off-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  2 +-
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c| 15 ---
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h|  2 +-
 .../amd/display/modules/hdcp/hdcp2_transition.c   |  2 +-
 .../gpu/drm/amd/display/modules/hdcp/hdcp_psp.c   |  7 +--
 .../gpu/drm/amd/display/modules/inc/mod_hdcp.h| 11 +--
 6 files changed, 29 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 0bb212e47766..482cde62b555 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -6352,7 +6352,7 @@ static void amdgpu_dm_atomic_commit_tail(struct 
drm_atomic_state *state)
if (is_content_protection_different(new_con_state, 
old_con_state, connector, adev->dm.hdcp_workqueue))
hdcp_update_display(
adev->dm.hdcp_workqueue, 
aconnector->dc_link->link_index, aconnector,
-   new_con_state->hdcp_content_type == 
DRM_MODE_HDCP_CONTENT_TYPE0 ? true : false,
+   new_con_state->hdcp_content_type,
new_con_state->content_protection == 
DRM_MODE_CONTENT_PROTECTION_DESIRED ? true

 : false);
}
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
index ca12362e799a..6c4b3134e786 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.c
@@ -86,7 +86,7 @@ static void process_output(struct hdcp_workqueue *hdcp_work)
 void hdcp_update_display(struct hdcp_workqueue *hdcp_work,
 unsigned int link_index,
 struct amdgpu_dm_connector *aconnector,
-bool disable_type1,
+uint8_t content_type,
 bool enable_encryption)
 {
struct hdcp_workqueue *hdcp_w = _work[link_index];
@@ -104,9 +104,18 @@ void hdcp_update_display(struct hdcp_workqueue *hdcp_work,
memcpy(display, query.display, sizeof(struct mod_hdcp_display));
mod_hdcp_remove_display(_w->hdcp, aconnector->base.index, 
_w->output);
 
+   hdcp_w->link.adjust.hdcp2.force_type = MOD_HDCP_FORCE_TYPE_0;
+
if (enable_encryption) {
display->adjust.disable = 0;
-   hdcp_w->link.adjust.hdcp2.disable_type1 = disable_type1;
+   if (content_type == DRM_MODE_HDCP_CONTENT_TYPE0) {
+   hdcp_w->link.adjust.hdcp1.disable = 0;
+   hdcp_w->link.adjust.hdcp2.force_type = 
MOD_HDCP_FORCE_TYPE_0;
+   } else if (content_type == DRM_MODE_HDCP_CONTENT_TYPE1) 
{
+   hdcp_w->link.adjust.hdcp1.disable = 1;
+   hdcp_w->link.adjust.hdcp2.force_type = 
MOD_HDCP_FORCE_TYPE_1;
+   }
+
schedule_delayed_work(_w->property_validate_dwork,
  
msecs_to_jiffies(DRM_HDCP_CHECK_PERIOD_MS));
} else {
@@ -304,7 +313,7 @@ static void update_config(void *handle, struct 
cp_psp_stream_config *config)
display->adjust.disable = 1;
link->adjust.auth_delay = 2;
 
-   hdcp_update_display(hdcp_work, link_index, aconnector, false, false);
+   hdcp_update_display(hdcp_work, link_index, aconnector, 
DRM_MODE_HDCP_CONTENT_TYPE0, false);
 }
 
 struct hdcp_workqueue *hdcp_create_workqueue(void *psp_context, struct cp_psp 
*cp_psp, struct dc *dc)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h
index 71e121f037cb..6abde86bce4a 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_hdcp.h
@@ -57,7 +57,7 @@ struct hdcp_workqueue {
 void hdcp_update_display(struct hdcp_workqueue *hdcp_work,
 unsigned int link_index,
 struct amdgpu_dm_connector *aconnector,
-bool disable_type1,
+uint8_t content_type,
 bool enable_encryption);
 
 void hdcp_reset_display(struct hdcp_workqueue *work, unsigned int link_index);
diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_transition.c 
b/drive

[PATCH 03/11] drm/amd/display: Add execution and transition states for HDCP2.2

2019-10-03 Thread Bhawanpreet Lakha
The module works like a state machine

+-+
--> | Execution.c | --
|   +-+   |
| V
++  ++ +--+
| DM |->| Hdcp.c |  <  | Transition.c |
++<-++ +--+

This patch adds the execution and transition files for 2.2

Extension to "40a702d427 drm/amd/display: Add HDCP module" for 2.2

Signed-off-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/modules/hdcp/Makefile |   3 +-
 .../gpu/drm/amd/display/modules/hdcp/hdcp.c   |  86 +-
 .../gpu/drm/amd/display/modules/hdcp/hdcp.h   | 127 +++
 .../display/modules/hdcp/hdcp2_execution.c| 881 ++
 .../display/modules/hdcp/hdcp2_transition.c   | 674 ++
 .../drm/amd/display/modules/inc/mod_hdcp.h|   2 +
 6 files changed, 1764 insertions(+), 9 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_execution.c
 create mode 100644 drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_transition.c

diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/Makefile 
b/drivers/gpu/drm/amd/display/modules/hdcp/Makefile
index 1c3c6d47973a..904424da01b5 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/Makefile
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/Makefile
@@ -24,7 +24,8 @@
 #
 
 HDCP = hdcp_ddc.o hdcp_log.o hdcp_psp.o hdcp.o \
-   hdcp1_execution.o hdcp1_transition.o
+   hdcp1_execution.o hdcp1_transition.o \
+   hdcp2_execution.o hdcp2_transition.o
 
 AMD_DAL_HDCP = $(addprefix $(AMDDALPATH)/modules/hdcp/,$(HDCP))
 #$(info   DAL-HDCP_MAKEFILE )
diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c
index d7ac445dec6f..a74812977963 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c
@@ -37,24 +37,52 @@ static void push_error_status(struct mod_hdcp *hdcp,
HDCP_ERROR_TRACE(hdcp, status);
}
 
-   hdcp->connection.hdcp1_retry_count++;
+   if (is_hdcp1(hdcp)) {
+   hdcp->connection.hdcp1_retry_count++;
+   } else if (is_hdcp2(hdcp)) {
+   hdcp->connection.hdcp2_retry_count++;
+   }
 }
 
 static uint8_t is_cp_desired_hdcp1(struct mod_hdcp *hdcp)
 {
-   int i, display_enabled = 0;
+   int i, is_auth_needed = 0;
 
-   /* if all displays on the link are disabled, hdcp is not desired */
+   /* if all displays on the link don't need authentication,
+* hdcp is not desired
+*/
for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) {
if (hdcp->connection.displays[i].state != 
MOD_HDCP_DISPLAY_INACTIVE &&
!hdcp->connection.displays[i].adjust.disable) {
-   display_enabled = 1;
+   is_auth_needed = 1;
break;
}
}
 
return (hdcp->connection.hdcp1_retry_count < MAX_NUM_OF_ATTEMPTS) &&
-   display_enabled && 
!hdcp->connection.link.adjust.hdcp1.disable;
+   is_auth_needed &&
+   !hdcp->connection.link.adjust.hdcp1.disable;
+}
+
+static uint8_t is_cp_desired_hdcp2(struct mod_hdcp *hdcp)
+{
+   int i, is_auth_needed = 0;
+
+   /* if all displays on the link don't need authentication,
+* hdcp is not desired
+*/
+   for (i = 0; i < MAX_NUM_OF_DISPLAYS; i++) {
+   if (hdcp->connection.displays[i].state != 
MOD_HDCP_DISPLAY_INACTIVE &&
+   !hdcp->connection.displays[i].adjust.disable) {
+   is_auth_needed = 1;
+   break;
+   }
+   }
+
+   return (hdcp->connection.hdcp2_retry_count < MAX_NUM_OF_ATTEMPTS) &&
+   is_auth_needed &&
+   !hdcp->connection.link.adjust.hdcp2.disable &&
+   !hdcp->connection.is_hdcp2_revoked;
 }
 
 static enum mod_hdcp_status execution(struct mod_hdcp *hdcp,
@@ -82,6 +110,11 @@ static enum mod_hdcp_status execution(struct mod_hdcp *hdcp,
} else if (is_in_hdcp1_dp_states(hdcp)) {
status = mod_hdcp_hdcp1_dp_execution(hdcp,
event_ctx, >hdcp1);
+   } else if (is_in_hdcp2_states(hdcp)) {
+   status = mod_hdcp_hdcp2_execution(hdcp, event_ctx, 
>hdcp2);
+   } else if (is_in_hdcp2_dp_states(hdcp)) {
+   status = mod_hdcp_hdcp2_dp_execution(hdcp,
+   event_ctx, >hdcp2);
}
 out:
  

[PATCH 00/11] HDCP 2 Content Protection

2019-10-03 Thread Bhawanpreet Lakha
Just like with the 1.4 series of patches This only introduces the
ability to authenticate and encrypt the link. These patches by
themselves don't constitute a complete and compliant HDCP content
protection solution but are a requirement for such a solution.

Summary of the changes
*Adds 2.2 code to the module
*Enabled HDCP 2.2 authentication/encryption
*Add type0/1 selection for 2.2
*Add MST support (Only tested single daisy chain usecase)

Bhawanpreet Lakha (11):
  drm/amd/display: Add PSP block to verify HDCP2.2 steps
  drm/amd/display: Add DDC handles for HDCP2.2
  drm/amd/display: Add execution and transition states for HDCP2.2
  drm/amd/display: Add logging for HDCP2.2
  drm/amd/display: Change ERROR to WARN for HDCP module
  drm/amd/display: Enable HDCP 2.2
  drm/amd/display: Handle hdcp2.2 type0/1 in dm
  drm/amd/display: Refactor HDCP to handle multiple displays per link
  drm/amd/display: add force Type0/1 flag
  drm/amd/display: Refactor HDCP encryption status update
  drm/amd/display: fix events handling for hdcp

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  26 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_hdcp.c|  79 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_hdcp.h|   9 +-
 .../gpu/drm/amd/display/modules/hdcp/Makefile |   3 +-
 .../gpu/drm/amd/display/modules/hdcp/hdcp.c   | 101 +-
 .../gpu/drm/amd/display/modules/hdcp/hdcp.h   | 171 
 .../display/modules/hdcp/hdcp2_execution.c| 881 ++
 .../display/modules/hdcp/hdcp2_transition.c   | 674 ++
 .../drm/amd/display/modules/hdcp/hdcp_ddc.c   | 326 +++
 .../drm/amd/display/modules/hdcp/hdcp_log.c   | 118 +++
 .../drm/amd/display/modules/hdcp/hdcp_log.h   |  98 +-
 .../drm/amd/display/modules/hdcp/hdcp_psp.c   | 511 +-
 .../drm/amd/display/modules/hdcp/hdcp_psp.h   | 194 
 .../drm/amd/display/modules/inc/mod_hdcp.h|  15 +-
 14 files changed, 3125 insertions(+), 81 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_execution.c
 create mode 100644 drivers/gpu/drm/amd/display/modules/hdcp/hdcp2_transition.c

-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 01/11] drm/amd/display: Add PSP block to verify HDCP2.2 steps

2019-10-03 Thread Bhawanpreet Lakha
[Why]
All the HDCP transactions should be verified using PSP

[How]
This patch adds the psp calls we need to verify the steps

Signed-off-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/modules/hdcp/hdcp.h   |  44 ++
 .../drm/amd/display/modules/hdcp/hdcp_psp.c   | 502 +-
 .../drm/amd/display/modules/hdcp/hdcp_psp.h   | 194 +++
 3 files changed, 739 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h
index 402bb7999093..596a0192784c 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h
@@ -111,8 +111,33 @@ struct mod_hdcp_message_hdcp1 {
uint16_tbinfo_dp;
 };
 
+struct mod_hdcp_message_hdcp2 {
+   uint8_t hdcp2version_hdmi;
+   uint8_t rxcaps_dp[3];
+   uint16_trxstatus;
+
+   uint8_t ake_init[12];
+   uint8_t ake_cert[534];
+   uint8_t ake_no_stored_km[129];
+   uint8_t ake_stored_km[33];
+   uint8_t ake_h_prime[33];
+   uint8_t ake_pairing_info[17];
+   uint8_t lc_init[9];
+   uint8_t lc_l_prime[33];
+   uint8_t ske_eks[25];
+   uint8_t rx_id_list[177]; // 22 + 5 * 31
+   uint16_trx_id_list_size;
+   uint8_t repeater_auth_ack[17];
+   uint8_t repeater_auth_stream_manage[68]; // 6 + 2 * 31
+   uint16_tstream_manage_size;
+   uint8_t repeater_auth_stream_ready[33];
+
+   uint8_t content_stream_type_dp[2];
+};
+
 union mod_hdcp_message {
struct mod_hdcp_message_hdcp1 hdcp1;
+   struct mod_hdcp_message_hdcp2 hdcp2;
 };
 
 struct mod_hdcp_auth_counters {
@@ -234,6 +259,25 @@ enum mod_hdcp_status 
mod_hdcp_hdcp1_enable_dp_stream_encryption(
 enum mod_hdcp_status mod_hdcp_hdcp1_link_maintenance(struct mod_hdcp *hdcp);
 enum mod_hdcp_status mod_hdcp_hdcp1_get_link_encryption_status(struct mod_hdcp 
*hdcp,
   enum 
mod_hdcp_encryption_status *encryption_status);
+enum mod_hdcp_status mod_hdcp_hdcp2_create_session(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_destroy_session(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_prepare_ake_init(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_validate_ake_cert(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_validate_h_prime(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_prepare_lc_init(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_validate_l_prime(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_prepare_eks(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_enable_encryption(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_validate_rx_id_list(struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_enable_dp_stream_encryption(
+   struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_prepare_stream_management(
+   struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_validate_stream_ready(
+   struct mod_hdcp *hdcp);
+enum mod_hdcp_status mod_hdcp_hdcp2_get_link_encryption_status(struct mod_hdcp 
*hdcp,
+  enum 
mod_hdcp_encryption_status *encryption_status);
+
 /* ddc functions */
 enum mod_hdcp_status mod_hdcp_read_bksv(struct mod_hdcp *hdcp);
 enum mod_hdcp_status mod_hdcp_read_bcaps(struct mod_hdcp *hdcp);
diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
index 646d909bbc37..8187cae5f5ca 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_psp.c
@@ -31,6 +31,19 @@
 #include "amdgpu.h"
 #include "hdcp_psp.h"
 
+static void hdcp2_message_init(struct mod_hdcp *hdcp,
+  struct 
ta_hdcp_cmd_hdcp2_process_prepare_authentication_message_input_v2 *in)
+{
+   in->session_handle = hdcp->auth.id;
+   in->prepare.msg1_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE;
+   in->prepare.msg2_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE;
+   in->process.msg1_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE;
+   in->process.msg1_desc.msg_size = 0;
+   in->process.msg2_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE;
+   in->process.msg2_desc.msg_size = 0;
+   in->process.msg3_desc.msg_id = TA_HDCP_HDCP2_MSG_ID__NULL_MESSAGE;
+   in->process.msg3_desc.msg_id = 0;
+}
 enum mod_hdcp_status mod_hdcp_remove_display_topology(struct mod_hdcp *hdcp)
 {
 
@@ -42,7 +55,7 @@ enum mod_hdcp_status mod_hdcp_remove_display_topology(struct 
mod_hdcp *hdcp)
dtm_cmd = (struct ta_dtm_shared_memory 
*)psp->dtm_context.dtm_shared_

[PATCH 05/11] drm/amd/display: Change ERROR to WARN for HDCP module

2019-10-03 Thread Bhawanpreet Lakha
[Why]
HDCP is a bit finicky so we try it 3 times, this leads to a case where
if we fail the first time and pass the second time the error is still
shown in dmesg for the first failed attempt.

This leads to false positive errors.

[How]
Change the logging from ERROR to WARNING. Warnings are still shown in dmesg
to know what went wrong.

Signed-off-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.h 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.h
index b29322e7d5fe..ff91373ebada 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.h
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_log.h
@@ -27,7 +27,7 @@
 #define MOD_HDCP_LOG_H_
 
 #ifdef CONFIG_DRM_AMD_DC_HDCP
-#define HDCP_LOG_ERR(hdcp, ...) DRM_ERROR(__VA_ARGS__)
+#define HDCP_LOG_ERR(hdcp, ...) DRM_WARN(__VA_ARGS__)
 #define HDCP_LOG_VER(hdcp, ...) DRM_DEBUG_KMS(__VA_ARGS__)
 #define HDCP_LOG_FSM(hdcp, ...) DRM_DEBUG_KMS(__VA_ARGS__)
 #define HDCP_LOG_TOP(hdcp, ...) pr_debug("[HDCP_TOP]:"__VA_ARGS__)
@@ -37,7 +37,7 @@
 /* default logs */
 #define HDCP_ERROR_TRACE(hdcp, status) \
HDCP_LOG_ERR(hdcp, \
-   "[Link %d] ERROR %s IN STATE %s", \
+   "[Link %d] WARNING %s IN STATE %s", \
hdcp->config.index, \
mod_hdcp_status_to_str(status), \
mod_hdcp_state_id_to_str(hdcp->state.id))
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 02/11] drm/amd/display: Add DDC handles for HDCP2.2

2019-10-03 Thread Bhawanpreet Lakha
[Why]
We need these to read and write to aux/i2c, during
authentication

[How]
Create read/write functions for all the steps
(Eg, h_prime, paring_info etc)

Signed-off-by: Bhawanpreet Lakha 
---
 .../drm/amd/display/modules/hdcp/hdcp_ddc.c   | 326 ++
 1 file changed, 326 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c
index e7baae059b85..8059aff9911f 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp_ddc.c
@@ -51,6 +51,26 @@ enum mod_hdcp_ddc_message_id {
MOD_HDCP_MESSAGE_ID_READ_KSV_FIFO,
MOD_HDCP_MESSAGE_ID_READ_BINFO,
 
+   /* HDCP 2.2 */
+
+   MOD_HDCP_MESSAGE_ID_HDCP2VERSION,
+   MOD_HDCP_MESSAGE_ID_RX_CAPS,
+   MOD_HDCP_MESSAGE_ID_WRITE_AKE_INIT,
+   MOD_HDCP_MESSAGE_ID_READ_AKE_SEND_CERT,
+   MOD_HDCP_MESSAGE_ID_WRITE_AKE_NO_STORED_KM,
+   MOD_HDCP_MESSAGE_ID_WRITE_AKE_STORED_KM,
+   MOD_HDCP_MESSAGE_ID_READ_AKE_SEND_H_PRIME,
+   MOD_HDCP_MESSAGE_ID_READ_AKE_SEND_PAIRING_INFO,
+   MOD_HDCP_MESSAGE_ID_WRITE_LC_INIT,
+   MOD_HDCP_MESSAGE_ID_READ_LC_SEND_L_PRIME,
+   MOD_HDCP_MESSAGE_ID_WRITE_SKE_SEND_EKS,
+   MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_SEND_RECEIVERID_LIST,
+   MOD_HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_SEND_ACK,
+   MOD_HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_STREAM_MANAGE,
+   MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_STREAM_READY,
+   MOD_HDCP_MESSAGE_ID_READ_RXSTATUS,
+   MOD_HDCP_MESSAGE_ID_WRITE_CONTENT_STREAM_TYPE,
+
MOD_HDCP_MESSAGE_ID_MAX
 };
 
@@ -70,6 +90,22 @@ static const uint8_t hdcp_i2c_offsets[] = {
[MOD_HDCP_MESSAGE_ID_READ_BSTATUS] = 0x41,
[MOD_HDCP_MESSAGE_ID_READ_KSV_FIFO] = 0x43,
[MOD_HDCP_MESSAGE_ID_READ_BINFO] = 0xFF,
+   [MOD_HDCP_MESSAGE_ID_HDCP2VERSION] = 0x50,
+   [MOD_HDCP_MESSAGE_ID_WRITE_AKE_INIT] = 0x60,
+   [MOD_HDCP_MESSAGE_ID_READ_AKE_SEND_CERT] = 0x80,
+   [MOD_HDCP_MESSAGE_ID_WRITE_AKE_NO_STORED_KM] = 0x60,
+   [MOD_HDCP_MESSAGE_ID_WRITE_AKE_STORED_KM] = 0x60,
+   [MOD_HDCP_MESSAGE_ID_READ_AKE_SEND_H_PRIME] = 0x80,
+   [MOD_HDCP_MESSAGE_ID_READ_AKE_SEND_PAIRING_INFO] = 0x80,
+   [MOD_HDCP_MESSAGE_ID_WRITE_LC_INIT] = 0x60,
+   [MOD_HDCP_MESSAGE_ID_READ_LC_SEND_L_PRIME] = 0x80,
+   [MOD_HDCP_MESSAGE_ID_WRITE_SKE_SEND_EKS] = 0x60,
+   [MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_SEND_RECEIVERID_LIST] = 0x80,
+   [MOD_HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_SEND_ACK] = 0x60,
+   [MOD_HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_STREAM_MANAGE] = 0x60,
+   [MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_STREAM_READY] = 0x80,
+   [MOD_HDCP_MESSAGE_ID_READ_RXSTATUS] = 0x70,
+   [MOD_HDCP_MESSAGE_ID_WRITE_CONTENT_STREAM_TYPE] = 0x0
 };
 
 static const uint32_t hdcp_dpcd_addrs[] = {
@@ -88,6 +124,22 @@ static const uint32_t hdcp_dpcd_addrs[] = {
[MOD_HDCP_MESSAGE_ID_READ_BSTATUS] = 0x68029,
[MOD_HDCP_MESSAGE_ID_READ_KSV_FIFO] = 0x6802c,
[MOD_HDCP_MESSAGE_ID_READ_BINFO] = 0x6802a,
+   [MOD_HDCP_MESSAGE_ID_RX_CAPS] = 0x6921d,
+   [MOD_HDCP_MESSAGE_ID_WRITE_AKE_INIT] = 0x69000,
+   [MOD_HDCP_MESSAGE_ID_READ_AKE_SEND_CERT] = 0x6900b,
+   [MOD_HDCP_MESSAGE_ID_WRITE_AKE_NO_STORED_KM] = 0x69220,
+   [MOD_HDCP_MESSAGE_ID_WRITE_AKE_STORED_KM] = 0x692a0,
+   [MOD_HDCP_MESSAGE_ID_READ_AKE_SEND_H_PRIME] = 0x692c0,
+   [MOD_HDCP_MESSAGE_ID_READ_AKE_SEND_PAIRING_INFO] = 0x692e0,
+   [MOD_HDCP_MESSAGE_ID_WRITE_LC_INIT] = 0x692f0,
+   [MOD_HDCP_MESSAGE_ID_READ_LC_SEND_L_PRIME] = 0x692f8,
+   [MOD_HDCP_MESSAGE_ID_WRITE_SKE_SEND_EKS] = 0x69318,
+   [MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_SEND_RECEIVERID_LIST] = 0x69330,
+   [MOD_HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_SEND_ACK] = 0x693e0,
+   [MOD_HDCP_MESSAGE_ID_WRITE_REPEATER_AUTH_STREAM_MANAGE] = 0x693f0,
+   [MOD_HDCP_MESSAGE_ID_READ_REPEATER_AUTH_STREAM_READY] = 0x69473,
+   [MOD_HDCP_MESSAGE_ID_READ_RXSTATUS] = 0x69493,
+   [MOD_HDCP_MESSAGE_ID_WRITE_CONTENT_STREAM_TYPE] = 0x69494
 };
 
 static enum mod_hdcp_status read(struct mod_hdcp *hdcp,
@@ -303,3 +355,277 @@ enum mod_hdcp_status mod_hdcp_write_an(struct mod_hdcp 
*hdcp)
hdcp->auth.msg.hdcp1.an,
sizeof(hdcp->auth.msg.hdcp1.an));
 }
+
+enum mod_hdcp_status mod_hdcp_read_hdcp2version(struct mod_hdcp *hdcp)
+{
+   enum mod_hdcp_status status;
+
+   if (is_dp_hdcp(hdcp))
+   status = MOD_HDCP_STATUS_INVALID_OPERATION;
+   else
+   status = read(hdcp, MOD_HDCP_MESSAGE_ID_HDCP2VERSION,
+   >auth.msg.hdcp2.hdcp2version_hdmi,
+   sizeof(hdcp->auth.msg.hdcp2.hdcp2version_hdmi));
+
+   return status;
+}
+
+enum mod_hdcp_status mod_hdcp_read_rxcaps(struct mod_hdcp *hdcp)
+{
+   enum mod_hdcp_status status;
+
+   if (!is_

[PATCH 19/38] drm/amd/display: fix bug with check for HPD Low in verify link cap

2019-10-02 Thread Bhawanpreet Lakha
From: Sivapiriyan Kumarasamy 

[Why]
There is a bug when determining if link training should be retried when
HPD is low in dp_verify_link_cap_with_retries.

[How]
Correctly, fail dp_verify_link_cap_with_retries without retry when
HPD is low.

Change-Id: I6fbf64c28f0aac96252a508715a806927fb86d63
Signed-off-by: Sivapiriyan Kumarasamy 
Reviewed-by: Wenjing Liu 
Acked-by: Abdoulaye Berthe 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index 701b73926616..5a0c3384c16b 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -1656,11 +1656,14 @@ bool dp_verify_link_cap_with_retries(
 
for (i = 0; i < attempts; i++) {
int fail_count = 0;
-   enum dc_connection_type type;
+   enum dc_connection_type type = dc_connection_none;
 
memset(>verified_link_cap, 0,
sizeof(struct dc_link_settings));
-   if (!dc_link_detect_sink(link, )) {
+   if (!dc_link_detect_sink(link, ) || type == 
dc_connection_none) {
+   link->verified_link_cap.lane_count = LANE_COUNT_ONE;
+   link->verified_link_cap.link_rate = LINK_RATE_LOW;
+   link->verified_link_cap.link_spread = 
LINK_SPREAD_DISABLED;
break;
} else if (dp_verify_link_cap(link,
>reported_link_cap,
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 20/38] drm/amd/display: Use dcn1 Optimal Taps Get

2019-10-02 Thread Bhawanpreet Lakha
From: Wesley Chalmers 

[WHY]
dpp2_get_optimal_number_of_taps is incorrect, and dcn2 should be using
dpp1_get_optimal_number_of_taps instead

Change-Id: I421c9b8d9dc244d37f2bd9f99027ce2cca2b8817
Signed-off-by: Wesley Chalmers 
Reviewed-by: Dmytro Laktyushkin 
Acked-by: Bhawanpreet Lakha 
---
 .../gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c  |  4 +-
 .../gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h  |  5 ++
 .../gpu/drm/amd/display/dc/dcn20/dcn20_dpp.c  | 86 +--
 .../gpu/drm/amd/display/dc/dcn20/dcn20_dpp.h  |  5 --
 4 files changed, 8 insertions(+), 92 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c
index d8b2da18db39..997e9582edc7 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.c
@@ -129,7 +129,7 @@ void dpp_set_gamut_remap_bypass(struct dcn10_dpp *dpp)
 
 #define IDENTITY_RATIO(ratio) (dc_fixpt_u2d19(ratio) == (1 << 19))
 
-static bool dpp_get_optimal_number_of_taps(
+bool dpp1_get_optimal_number_of_taps(
struct dpp *dpp,
struct scaler_data *scl_data,
const struct scaling_taps *in_taps)
@@ -521,7 +521,7 @@ static const struct dpp_funcs dcn10_dpp_funcs = {
.dpp_read_state = dpp_read_state,
.dpp_reset = dpp_reset,
.dpp_set_scaler = dpp1_dscl_set_scaler_manual_scale,
-   .dpp_get_optimal_number_of_taps = 
dpp_get_optimal_number_of_taps,
+   .dpp_get_optimal_number_of_taps = 
dpp1_get_optimal_number_of_taps,
.dpp_set_gamut_remap = dpp1_cm_set_gamut_remap,
.dpp_set_csc_adjustment = dpp1_cm_set_output_csc_adjustment,
.dpp_set_csc_default = dpp1_cm_set_output_csc_default,
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h
index e2c613611ac9..1d4a7d640334 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_dpp.h
@@ -1504,6 +1504,11 @@ void dpp1_set_hdr_multiplier(
struct dpp *dpp_base,
uint32_t multiplier);
 
+bool dpp1_get_optimal_number_of_taps(
+   struct dpp *dpp,
+   struct scaler_data *scl_data,
+   const struct scaling_taps *in_taps);
+
 void dpp1_construct(struct dcn10_dpp *dpp1,
struct dc_context *ctx,
uint32_t inst,
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dpp.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dpp.c
index 2f5aade1e882..e991acafeedf 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dpp.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_dpp.c
@@ -369,90 +369,6 @@ void dpp2_set_cursor_attributes(
}
 }
 
-#define IDENTITY_RATIO(ratio) (dc_fixpt_u3d19(ratio) == (1 << 19))
-
-bool dpp2_get_optimal_number_of_taps(
-   struct dpp *dpp,
-   struct scaler_data *scl_data,
-   const struct scaling_taps *in_taps)
-{
-   uint32_t pixel_width;
-
-   if (scl_data->viewport.width > scl_data->recout.width)
-   pixel_width = scl_data->recout.width;
-   else
-   pixel_width = scl_data->viewport.width;
-
-   /* Some ASICs does not support  FP16 scaling, so we reject modes 
require this*/
-   if (scl_data->viewport.width  != scl_data->h_active &&
-   scl_data->viewport.height != scl_data->v_active &&
-   dpp->caps->dscl_data_proc_format == 
DSCL_DATA_PRCESSING_FIXED_FORMAT &&
-   scl_data->format == PIXEL_FORMAT_FP16)
-   return false;
-
-   if (scl_data->viewport.width > scl_data->h_active &&
-   dpp->ctx->dc->debug.max_downscale_src_width != 0 &&
-   scl_data->viewport.width > 
dpp->ctx->dc->debug.max_downscale_src_width)
-   return false;
-
-   /* TODO: add lb check */
-
-   /* No support for programming ratio of 8, drop to 7.9.. */
-   if (scl_data->ratios.horz.value == (8ll << 32))
-   scl_data->ratios.horz.value--;
-   if (scl_data->ratios.vert.value == (8ll << 32))
-   scl_data->ratios.vert.value--;
-   if (scl_data->ratios.horz_c.value == (8ll << 32))
-   scl_data->ratios.horz_c.value--;
-   if (scl_data->ratios.vert_c.value == (8ll << 32))
-   scl_data->ratios.vert_c.value--;
-
-   /* Set default taps if none are provided */
-   if (in_taps->h_taps == 0) {
-   if (dc_fixpt_ceil(scl_data->ratios.horz) > 4)
-   scl_data->taps.h_taps = 8;
-   else
-   scl_data->taps.h_taps = 4;
-   } else
-   scl_data->taps.h_taps =

[PATCH 34/38] drm/amd/display: Fix dongle_caps containing stale information.

2019-10-02 Thread Bhawanpreet Lakha
From: David Galiffi 

[WHY]

During detection:
function: get_active_converter_info populates link->dpcd_caps.dongle_caps
only when dpcd_rev >= DPCD_REV_11 and DWN_STRM_PORTX_TYPE is
DOWN_STREAM_DETAILED_HDMI or DOWN_STREAM_DETAILED_DP_PLUS_PLUS.
Otherwise, it is not cleared, and stale information remains.

During mode validation:
function: dp_active_dongle_validate_timing reads
link->dpcd_caps.dongle_caps->dongle_type to determine the maximum
pixel clock to support. This information is now stale and no longer
valid.

[HOW]
dp_active_dongle_validate_timing should be using
link->dpcd_caps->dongle_type instead.

Change-Id: Ie93769353ccf209b4af0b87c1a143422c88df92d
Signed-off-by: David Galiffi 
Reviewed-by: Jun Lei 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c| 2 +-
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 1 +
 2 files changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
index f41f1706c05f..149b15aeffb4 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -2256,7 +2256,7 @@ static bool dp_active_dongle_validate_timing(
break;
}
 
-   if (dongle_caps->dongle_type != DISPLAY_DONGLE_DP_HDMI_CONVERTER ||
+   if (dpcd_caps->dongle_type != DISPLAY_DONGLE_DP_HDMI_CONVERTER ||
dongle_caps->extendedCapValid == false)
return true;
 
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
index aae204141c60..0f59b68aa4c2 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c
@@ -2575,6 +2575,7 @@ static void get_active_converter_info(
uint8_t data, struct dc_link *link)
 {
union dp_downstream_port_present ds_port = { .byte = data };
+   memset(>dpcd_caps.dongle_caps, 0, 
sizeof(link->dpcd_caps.dongle_caps));
 
/* decode converter info*/
if (!ds_port.fields.PORT_PRESENT) {
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 36/38] drm/amd/display: Skip DIG Check if Link is Virtual for Display Count

2019-10-02 Thread Bhawanpreet Lakha
From: Sung Lee 

[WHY]
Without a check for virtual links, every link's DIG was getting
checked for enabled or disabled. If link was virtual, since it
did not have a DIG, this would cause issues.

[HOW]
Skip DIG Enable check if link is virtual and add virtual link to
to display count.

Change-Id: Iccbc64335628247e92814bdebcd8c78439e4814c
Signed-off-by: Sung Lee 
Reviewed-by: Yongqiang Sun 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
index 68d38239304c..cae6a6f5405d 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c
@@ -79,7 +79,8 @@ int rn_get_active_display_cnt_wa(
 * S0i2.
 */
/* abusing the fact that the dig and phy are coupled to see if 
the phy is enabled */
-   if (link->link_enc->funcs->is_dig_enabled(link->link_enc))
+   if (link->connector_signal == SIGNAL_TYPE_VIRTUAL ||
+   
link->link_enc->funcs->is_dig_enabled(link->link_enc))
display_count++;
}
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 30/38] drm/amd/display: use vbios message to call smu for dpm level

2019-10-02 Thread Bhawanpreet Lakha
From: Charlene Liu 

[Description]
use vbios message to call smu for dpm level
also only program dmdata in vsyncflip as HW requirement.

Change-Id: Iaad00db1a5f8e203b708d2605ff16e8b3b323b2b
Signed-off-by: Charlene Liu 
Reviewed-by: Dmytro Laktyushkin 
Acked-by: Bhawanpreet Lakha 
---
 .../amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.h  |  1 +
 drivers/gpu/drm/amd/display/dc/dc.h   |  8 
 .../gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c|  6 --
 .../drm/amd/display/dc/inc/hw/clk_mgr_internal.h  | 15 +++
 4 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.h 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.h
index ac31a9787305..c9fd824f3c23 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.h
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.h
@@ -50,4 +50,5 @@ void dcn2_get_clock(struct clk_mgr *clk_mgr,
enum dc_clock_type clock_type,
struct dc_clock_config *clock_cfg);
 
+void dcn20_update_clocks_update_dentist(struct clk_mgr_internal *clk_mgr);
 #endif //__DCN20_CLK_MGR_H__
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index 6c50d5c24658..c04a1f40e0be 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -245,6 +245,13 @@ enum wm_report_mode {
WM_REPORT_DEFAULT = 0,
WM_REPORT_OVERRIDE = 1,
 };
+enum dtm_pstate{
+   dtm_level_p0 = 0,/*highest voltage*/
+   dtm_level_p1,
+   dtm_level_p2,
+   dtm_level_p3,
+   dtm_level_p4,/*when active_display_count = 0*/
+};
 
 enum dcn_pwr_state {
DCN_PWR_STATE_OPTIMIZED = 0,
@@ -271,6 +278,7 @@ struct dc_clocks {
 * optimization required
 */
bool prev_p_state_change_support;
+   enum dtm_pstate dtm_level;
int max_supported_dppclk_khz;
int max_supported_dispclk_khz;
int bw_dppclk_khz; /*a copy of dppclk_khz*/
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
index 2dce3e4b5e51..ce2530509e12 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
@@ -2209,8 +2209,10 @@ static void dcn20_enable_stream(struct pipe_ctx 
*pipe_ctx)
link->link_enc->funcs->connect_dig_be_to_fe(link->link_enc,

pipe_ctx->stream_res.stream_enc->id, true);
 
-   if (link->dc->hwss.program_dmdata_engine)
-   link->dc->hwss.program_dmdata_engine(pipe_ctx);
+   if (pipe_ctx->plane_state && pipe_ctx->plane_state->flip_immediate != 
1) {
+   if (link->dc->hwss.program_dmdata_engine)
+   link->dc->hwss.program_dmdata_engine(pipe_ctx);
+   }
 
link->dc->hwss.update_info_frame(pipe_ctx);
 
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/clk_mgr_internal.h 
b/drivers/gpu/drm/amd/display/dc/inc/hw/clk_mgr_internal.h
index 7dd46eb96d67..2e8cd7956a17 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/hw/clk_mgr_internal.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/hw/clk_mgr_internal.h
@@ -184,6 +184,21 @@ struct clk_mgr_registers {
uint32_t MP1_SMN_C2PMSG_91;
 };
 
+enum clock_type {
+   clock_type_dispclk = 1,
+   clock_type_dcfclk,
+   clock_type_socclk,
+   clock_type_pixelclk,
+   clock_type_phyclk,
+   clock_type_dppclk,
+   clock_type_fclk,
+   clock_type_dcfdsclk,
+   clock_type_dscclk,
+   clock_type_uclk,
+   clock_type_dramclk,
+};
+
+
 struct state_dependent_clocks {
int display_clk_khz;
int pixel_clk_khz;
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 29/38] drm/amd/display: Fix maybe-uninitialized warning

2019-10-02 Thread Bhawanpreet Lakha
From: Leo Li 

[Why]

Compiling with GCC 9.1.0 gives the following warning (I have
warnings-as-errors enabled):

drivers/gpu/drm/amd/amdgpu/../dal-dev/dc/core/dc.c: In function 
'dc_validate_seamless_boot_timing':
drivers/gpu/drm/amd/amdgpu/../dal-dev/dc/core/dc.c:1180:8: error: 'se' may be 
used uninitialized in this function [-Werror=maybe-uninitialized]
 1180 |   if (!se->funcs->dp_get_pixel_format(
  |^~~
 1181 |se,
  |~~~
 1182 |_crtc_timing.pixel_encoding,
  |~~~
 1183 |_crtc_timing.display_color_depth))

[How]

Initialize se to NULL.

Change-Id: I79d89ea518f862a9479581529dbbe8977e224ce2
Signed-off-by: Leo Li 
Reviewed-by: Harry Wentland 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 3416c8bd09ae..824c0d3b2100 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1004,7 +1004,7 @@ bool dc_validate_seamless_boot_timing(const struct dc *dc,
struct dc_crtc_timing *crtc_timing)
 {
struct timing_generator *tg;
-   struct stream_encoder *se;
+   struct stream_encoder *se = NULL;
 
struct dc_crtc_timing hw_crtc_timing = {0};
 
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

[PATCH 32/38] drm/amd/display: 3.2.54

2019-10-02 Thread Bhawanpreet Lakha
From: Aric Cyr 

Change-Id: I8ccb02411c552f679cb08ace8652f5c9d4fe3b4f
Signed-off-by: Aric Cyr 
Reviewed-by: Aric Cyr 
Acked-by: Bhawanpreet Lakha 
---
 drivers/gpu/drm/amd/display/dc/dc.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index c04a1f40e0be..41e366f59f10 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -39,7 +39,7 @@
 #include "inc/hw/dmcu.h"
 #include "dml/display_mode_lib.h"
 
-#define DC_VER "3.2.53"
+#define DC_VER "3.2.54"
 
 #define MAX_SURFACES 3
 #define MAX_PLANES 6
-- 
2.17.1

___
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

<    1   2   3   4   5   6   7   8   >