[PATCH 20/22] drm/amd/display: Query all entries in assignment table during updates.

2021-11-04 Thread Anson Jacob
From: Jimmy Kizito 

[Why]
Stream ordering and count can vary from one state to the next. Only
checking a subset of entries in the encoder assignment table can lead to
invalid encoder assignments.

[How]
Check all entries in encoder assignment table when querying it.

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Jimmy Kizito 
---
 .../gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c   | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
index b96e301f64f2..787aaa661a29 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
@@ -232,7 +232,7 @@ static struct link_encoder *get_link_enc_used_by_link(
.link_id = link->link_id,
.ep_type = link->ep_type};
 
-   for (i = 0; i < state->stream_count; i++) {
+   for (i = 0; i < MAX_PIPES; i++) {
struct link_enc_assignment assignment = 
state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i];
 
if (assignment.valid == true && 
are_ep_ids_equal(&assignment.ep_id, &ep_id))
@@ -538,6 +538,7 @@ bool link_enc_cfg_validate(struct dc *dc, struct dc_state 
*state)
uint8_t dig_stream_count = 0;
int matching_stream_ptrs = 0;
int eng_ids_per_ep_id[MAX_PIPES] = {0};
+   int valid_bitmap = 0;
 
/* (1) No. valid entries same as stream count. */
for (i = 0; i < MAX_PIPES; i++) {
@@ -619,5 +620,15 @@ bool link_enc_cfg_validate(struct dc *dc, struct dc_state 
*state)
is_valid = valid_entries && valid_stream_ptrs && valid_uniqueness && 
valid_avail && valid_streams;
ASSERT(is_valid);
 
+   if (is_valid == false) {
+   valid_bitmap =
+   (valid_entries & 0x1) |
+   ((valid_stream_ptrs & 0x1) << 1) |
+   ((valid_uniqueness & 0x1) << 2) |
+   ((valid_avail & 0x1) << 3) |
+   ((valid_streams & 0x1) << 4);
+   dm_error("Invalid link encoder assignments: 0x%x\n", 
valid_bitmap);
+   }
+
return is_valid;
 }
-- 
2.25.1



[PATCH 21/22] drm/amd/display: Initialise encoder assignment when initialising dc_state.

2021-11-04 Thread Anson Jacob
From: Jimmy Kizito 

[Why]
Link encoder assignment tracking variables need to be (re)initialised
whenever dc_state is (re)initialised. Otherwise variables used for
dynamic encoder assignment (especially the link encoder availability
pool) are out of sync with dc_state and future encoder assignments are
invalid.

[How]
Initialise encoder assignment variables when creating new dc_state
resource.

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Jimmy Kizito 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c  | 5 +
 drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c | 4 ++--
 drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 3 +++
 drivers/gpu/drm/amd/display/dc/inc/link_enc_cfg.h | 2 +-
 4 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index e76a2aa65a82..39ad3854bfe4 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1016,8 +1016,6 @@ static bool dc_construct(struct dc *dc,
goto fail;
}
 
-   dc_resource_state_construct(dc, dc->current_state);
-
if (!create_links(dc, init_params->num_virtual_links))
goto fail;
 
@@ -1027,8 +1025,7 @@ static bool dc_construct(struct dc *dc,
if (!create_link_encoders(dc))
goto fail;
 
-   /* Initialise DIG link encoder resource tracking variables. */
-   link_enc_cfg_init(dc, dc->current_state);
+   dc_resource_state_construct(dc, dc->current_state);
 
return true;
 
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
index 787aaa661a29..d3c789f26a02 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
@@ -242,7 +242,7 @@ static struct link_encoder *get_link_enc_used_by_link(
return link_enc;
 }
 /* Clear all link encoder assignments. */
-static void clear_enc_assignments(struct dc *dc, struct dc_state *state)
+static void clear_enc_assignments(const struct dc *dc, struct dc_state *state)
 {
int i;
 
@@ -261,7 +261,7 @@ static void clear_enc_assignments(struct dc *dc, struct 
dc_state *state)
 }
 
 void link_enc_cfg_init(
-   struct dc *dc,
+   const struct dc *dc,
struct dc_state *state)
 {
clear_enc_assignments(dc, state);
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 c32fdccd4d92..fabe1b83bd4f 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
@@ -2224,6 +2224,9 @@ void dc_resource_state_construct(
struct dc_state *dst_ctx)
 {
dst_ctx->clk_mgr = dc->clk_mgr;
+
+   /* Initialise DIG link encoder resource tracking variables. */
+   link_enc_cfg_init(dc, dst_ctx);
 }
 
 
diff --git a/drivers/gpu/drm/amd/display/dc/inc/link_enc_cfg.h 
b/drivers/gpu/drm/amd/display/dc/inc/link_enc_cfg.h
index 10dcf6a5e9b1..a4e43b4826e0 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/link_enc_cfg.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/link_enc_cfg.h
@@ -36,7 +36,7 @@
  * Initialise link encoder resource tracking.
  */
 void link_enc_cfg_init(
-   struct dc *dc,
+   const struct dc *dc,
struct dc_state *state);
 
 /*
-- 
2.25.1



[PATCH 18/22] drm/amd/display: 3.2.161

2021-11-04 Thread Anson Jacob
From: Aric Cyr 

This version brings along following fixes:
- Improvements to INBOX0 HW Lock
- Add support for sending TPS3 pattern
- Fix Coverity Issues
- Fixes for DMUB
- Fix RGB MPO underflow with multiple displays
- WS fixes and code restructure

Acked-by: Anson Jacob 
Signed-off-by: Aric Cyr 
---
 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 3aac3f4a2852..2bebc52c8ed9 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -47,7 +47,7 @@ struct aux_payload;
 struct set_config_cmd_payload;
 struct dmub_notification;
 
-#define DC_VER "3.2.160"
+#define DC_VER "3.2.161"
 
 #define MAX_SURFACES 3
 #define MAX_PLANES 6
-- 
2.25.1



[PATCH 16/22] drm/amd/display: Add hpd pending flag to indicate detection of new hpd.

2021-11-04 Thread Anson Jacob
From: Meenakshikumar Somasundaram 

[Why]
For dpia link, link->hpd_status indicates current state, but driver
fails to capture hpd transitions in certain scenarios such as during
link training.

[How]
Added link->hpd_pending flag that captures arrival of new hpd.

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Meenakshikumar Somasundaram 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c |  6 +++---
 .../drm/amd/display/dc/core/dc_link_dpia.c| 20 +--
 drivers/gpu/drm/amd/display/dc/dc_link.h  |  1 +
 3 files changed, 14 insertions(+), 13 deletions(-)

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 c4944ba59ec6..2e2dcd5518da 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -270,10 +270,10 @@ bool dc_link_detect_sink(struct dc_link *link, enum 
dc_connection_type *type)
 
/* Link may not have physical HPD pin. */
if (link->ep_type != DISPLAY_ENDPOINT_PHY) {
-   if (link->hpd_status)
-   *type = dc_connection_single;
-   else
+   if (link->is_hpd_pending || !link->hpd_status)
*type = dc_connection_none;
+   else
+   *type = dc_connection_single;
 
return true;
}
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dpia.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dpia.c
index b1c9f77d6bf4..d72122593959 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dpia.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dpia.c
@@ -94,17 +94,17 @@ static enum link_training_result dpia_configure_link(struct 
dc_link *link,
lt_settings);
 
status = dpcd_configure_channel_coding(link, lt_settings);
-   if (status != DC_OK && !link->hpd_status)
+   if (status != DC_OK && link->is_hpd_pending)
return LINK_TRAINING_ABORT;
 
/* Configure lttpr mode */
status = dpcd_configure_lttpr_mode(link, lt_settings);
-   if (status != DC_OK && !link->hpd_status)
+   if (status != DC_OK && link->is_hpd_pending)
return LINK_TRAINING_ABORT;
 
/* Set link rate, lane count and spread. */
status = dpcd_set_link_settings(link, lt_settings);
-   if (status != DC_OK && !link->hpd_status)
+   if (status != DC_OK && link->is_hpd_pending)
return LINK_TRAINING_ABORT;
 
if (link->preferred_training_settings.fec_enable)
@@ -112,7 +112,7 @@ static enum link_training_result dpia_configure_link(struct 
dc_link *link,
else
fec_enable = true;
status = dp_set_fec_ready(link, fec_enable);
-   if (status != DC_OK && !link->hpd_status)
+   if (status != DC_OK && link->is_hpd_pending)
return LINK_TRAINING_ABORT;
 
return LINK_TRAINING_SUCCESS;
@@ -388,7 +388,7 @@ static enum link_training_result 
dpia_training_cr_non_transparent(struct dc_link
}
 
/* Abort link training if clock recovery failed due to HPD unplug. */
-   if (!link->hpd_status)
+   if (link->is_hpd_pending)
result = LINK_TRAINING_ABORT;
 
DC_LOG_HW_LINK_TRAINING("%s\n DPIA(%d) clock recovery\n"
@@ -490,7 +490,7 @@ static enum link_training_result 
dpia_training_cr_transparent(struct dc_link *li
}
 
/* Abort link training if clock recovery failed due to HPD unplug. */
-   if (!link->hpd_status)
+   if (link->is_hpd_pending)
result = LINK_TRAINING_ABORT;
 
DC_LOG_HW_LINK_TRAINING("%s\n DPIA(%d) clock recovery\n"
@@ -675,7 +675,7 @@ static enum link_training_result 
dpia_training_eq_non_transparent(struct dc_link
}
 
/* Abort link training if equalization failed due to HPD unplug. */
-   if (!link->hpd_status)
+   if (link->is_hpd_pending)
result = LINK_TRAINING_ABORT;
 
DC_LOG_HW_LINK_TRAINING("%s\n DPIA(%d) equalization\n"
@@ -758,7 +758,7 @@ static enum link_training_result 
dpia_training_eq_transparent(struct dc_link *li
}
 
/* Abort link training if equalization failed due to HPD unplug. */
-   if (!link->hpd_status)
+   if (link->is_hpd_pending)
result = LINK_TRAINING_ABORT;
 
DC_LOG_HW_LINK_TRAINING("%s\n DPIA(%d) equalization\n"
@@ -892,10 +892,10 @@ static void dpia_training_abort(struct dc_link *link, 
uint32_t hop)
__func__,
link->link_id.enum_id - ENUM_ID_1,
link->lttpr_mode,
-   link->hpd_status);
+   link->is_hpd_pending);
 
/* Ab

[PATCH 22/22] drm/amd/display: Wait for ACK for INBOX0 HW Lock

2021-11-04 Thread Anson Jacob
From: Alvin Lee 

[Why]
In DC we want to wait for the INBOX0 HW Lock
command to ACK before continuing. This is to
ensure that the lock has been successfully acquired
before programming HW in DC.

[How]
Add interfaces to send messages on INBOX0,
poll for their completation and clear the ack.

Reviewed-by: Nicholas Kazlauskas 
Acked-by: Anson Jacob 
Signed-off-by: Alvin Lee 
---
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c  | 37 +++--
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h  |  2 +
 .../drm/amd/display/dc/dce/dmub_hw_lock_mgr.c |  3 ++
 drivers/gpu/drm/amd/display/dmub/dmub_srv.h   | 41 +++
 .../gpu/drm/amd/display/dmub/src/dmub_srv.c   | 35 
 5 files changed, 115 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c 
b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
index 360f3199ea6f..541376fabbef 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
+++ b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
@@ -115,13 +115,44 @@ void dc_dmub_srv_wait_idle(struct dc_dmub_srv 
*dc_dmub_srv)
}
 }
 
+void dc_dmub_srv_clear_inbox0_ack(struct dc_dmub_srv *dmub_srv)
+{
+   struct dmub_srv *dmub = dmub_srv->dmub;
+   struct dc_context *dc_ctx = dmub_srv->ctx;
+   enum dmub_status status = DMUB_STATUS_OK;
+
+   status = dmub_srv_clear_inbox0_ack(dmub);
+   if (status != DMUB_STATUS_OK) {
+   DC_ERROR("Error clearing INBOX0 ack: status=%d\n", status);
+   dc_dmub_srv_log_diagnostic_data(dmub_srv);
+   }
+}
+
+void dc_dmub_srv_wait_for_inbox0_ack(struct dc_dmub_srv *dmub_srv)
+{
+   struct dmub_srv *dmub = dmub_srv->dmub;
+   struct dc_context *dc_ctx = dmub_srv->ctx;
+   enum dmub_status status = DMUB_STATUS_OK;
+
+   status = dmub_srv_wait_for_inbox0_ack(dmub, 10);
+   if (status != DMUB_STATUS_OK) {
+   DC_ERROR("Error waiting for INBOX0 HW Lock Ack\n");
+   dc_dmub_srv_log_diagnostic_data(dmub_srv);
+   }
+}
+
 void dc_dmub_srv_send_inbox0_cmd(struct dc_dmub_srv *dmub_srv,
union dmub_inbox0_data_register data)
 {
struct dmub_srv *dmub = dmub_srv->dmub;
-   if (dmub->hw_funcs.send_inbox0_cmd)
-   dmub->hw_funcs.send_inbox0_cmd(dmub, data);
-   // TODO: Add wait command -- poll register for ACK
+   struct dc_context *dc_ctx = dmub_srv->ctx;
+   enum dmub_status status = DMUB_STATUS_OK;
+
+   status = dmub_srv_send_inbox0_cmd(dmub, data);
+   if (status != DMUB_STATUS_OK) {
+   DC_ERROR("Error sending INBOX0 cmd\n");
+   dc_dmub_srv_log_diagnostic_data(dmub_srv);
+   }
 }
 
 bool dc_dmub_srv_cmd_with_reply_data(struct dc_dmub_srv *dc_dmub_srv, union 
dmub_rb_cmd *cmd)
diff --git a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h 
b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h
index 3e35eee7188c..7e4e2ec5915d 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h
@@ -68,6 +68,8 @@ bool dc_dmub_srv_get_dmub_outbox0_msg(const struct dc *dc, 
struct dmcub_trace_bu
 
 void dc_dmub_trace_event_control(struct dc *dc, bool enable);
 
+void dc_dmub_srv_clear_inbox0_ack(struct dc_dmub_srv *dmub_srv);
+void dc_dmub_srv_wait_for_inbox0_ack(struct dc_dmub_srv *dmub_srv);
 void dc_dmub_srv_send_inbox0_cmd(struct dc_dmub_srv *dmub_srv, union 
dmub_inbox0_data_register data);
 
 bool dc_dmub_srv_get_diagnostic_data(struct dc_dmub_srv *dc_dmub_srv, struct 
dmub_diagnostic_data *dmub_oca);
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.c 
b/drivers/gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.c
index 9baf8ca0a920..b1b2e3c6f379 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dmub_hw_lock_mgr.c
@@ -56,8 +56,11 @@ void dmub_hw_lock_mgr_inbox0_cmd(struct dc_dmub_srv 
*dmub_srv,
union dmub_inbox0_cmd_lock_hw hw_lock_cmd)
 {
union dmub_inbox0_data_register data = { 0 };
+
data.inbox0_cmd_lock_hw = hw_lock_cmd;
+   dc_dmub_srv_clear_inbox0_ack(dmub_srv);
dc_dmub_srv_send_inbox0_cmd(dmub_srv, data);
+   dc_dmub_srv_wait_for_inbox0_ack(dmub_srv);
 }
 
 bool should_use_dmub_lock(struct dc_link *link)
diff --git a/drivers/gpu/drm/amd/display/dmub/dmub_srv.h 
b/drivers/gpu/drm/amd/display/dmub/dmub_srv.h
index cd204eef073b..90065a09e76a 100644
--- a/drivers/gpu/drm/amd/display/dmub/dmub_srv.h
+++ b/drivers/gpu/drm/amd/display/dmub/dmub_srv.h
@@ -360,6 +360,8 @@ struct dmub_srv_hw_funcs {
 
uint32_t (*get_gpint_dataout)(struct dmub_srv *dmub);
 
+   void (*clear_inbox0_ack_register)(struct dmub_srv *dmub);
+   uint32_t (*read_inbox0_ack_register)(struct dmub_srv *dmub);
void (*send_inbox0_cmd)(struct dmub_srv *dmub, union 
dmub_inbox0_data_register data);
uint32_t (*get_current_time)(struct dmub_srv *dmub);
 
@@ -735

[PATCH 14/22] drm/amd/display: Add callbacks for DMUB HPD IRQ notifications

2021-11-04 Thread Anson Jacob
From: Nicholas Kazlauskas 

[Why]
We need HPD IRQ notifications (RX, short pulse) to properly handle
DP MST for DPIA connections.

[How]
A null pointer exception currently occurs when these are received
so add a check to validate that we have a handler installed for
the notification.

Extend the HPD handler to also handle HPD IRQ (RX) since the logic is
the same.

Fixes: 00be4268d32c ("drm/amd/display: Support for DMUB HPD interrupt handling")

Reviewed-by: Wayne Lin 
Reviewed-by: Jude Shih 
Acked-by: Anson Jacob 
Signed-off-by: Nicholas Kazlauskas 
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c   | 17 +++--
 1 file changed, 15 insertions(+), 2 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 0fa0c7bb07a0..7a54ccb794f9 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -217,6 +217,7 @@ static const struct drm_format_info *
 amd_get_format_info(const struct drm_mode_fb_cmd2 *cmd);
 
 static void handle_hpd_irq_helper(struct amdgpu_dm_connector *aconnector);
+static void handle_hpd_rx_irq(void *param);
 
 static bool
 is_timing_unchanged_for_freesync(struct drm_crtc_state *old_crtc_state,
@@ -683,8 +684,12 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct 
dmub_notification *not
}
drm_connector_list_iter_end(&iter);
 
-   if (hpd_aconnector)
-   handle_hpd_irq_helper(hpd_aconnector);
+   if (hpd_aconnector) {
+   if (notify->type == DMUB_NOTIFICATION_HPD)
+   handle_hpd_irq_helper(hpd_aconnector);
+   else if (notify->type == DMUB_NOTIFICATION_HPD_IRQ)
+   handle_hpd_rx_irq(hpd_aconnector);
+   }
 }
 
 /**
@@ -760,6 +765,10 @@ static void dm_dmub_outbox1_low_irq(void *interrupt_params)
DRM_ERROR("DM: notify type %d invalid!", 
notify.type);
continue;
}
+   if (!dm->dmub_callback[notify.type]) {
+   DRM_DEBUG_DRIVER("DMUB notification skipped, no 
handler: type=%d\n", notify.type);
+   continue;
+   }
if (dm->dmub_thread_offload[notify.type] == true) {
dmub_hpd_wrk = kzalloc(sizeof(*dmub_hpd_wrk), 
GFP_ATOMIC);
if (!dmub_hpd_wrk) {
@@ -1559,6 +1568,10 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
DRM_ERROR("amdgpu: fail to register dmub hpd callback");
goto error;
}
+   if (!register_dmub_notify_callback(adev, 
DMUB_NOTIFICATION_HPD_IRQ, dmub_hpd_callback, true)) {
+   DRM_ERROR("amdgpu: fail to register dmub hpd callback");
+   goto error;
+   }
 #endif /* CONFIG_DRM_AMD_DC_DCN */
}
 
-- 
2.25.1



[PATCH 19/22] drm/amd/display: To support sending TPS3 pattern when restoring link

2021-11-04 Thread Anson Jacob
From: Robin Chen 

[Why]
Some panels require to use TPS3 pattern to wake up link in PSR mode.

[How]
To add TPS3 selection information in PSR settings command and pass to
DMUB FW.

Reviewed-by: Anthony Koo 
Acked-by: Anson Jacob 
Signed-off-by: Robin Chen 
---
 drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c   | 9 +
 drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 5 ++---
 drivers/gpu/drm/amd/display/include/ddc_service_types.h | 3 +++
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c 
b/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c
index e9c0ec2ec4ce..60b2ccffaf90 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c
@@ -330,6 +330,15 @@ static bool dmub_psr_copy_settings(struct dmub_psr *dmub,
copy_settings_data->cmd_version =  DMUB_CMD_PSR_CONTROL_VERSION_1;
copy_settings_data->panel_inst = panel_inst;
 
+   if (link->fec_state == dc_link_fec_enabled &&
+   (!memcmp(link->dpcd_caps.sink_dev_id_str, 
DP_SINK_DEVICE_STR_ID_1,
+   sizeof(link->dpcd_caps.sink_dev_id_str)) ||
+   !memcmp(link->dpcd_caps.sink_dev_id_str, 
DP_SINK_DEVICE_STR_ID_2,
+   sizeof(link->dpcd_caps.sink_dev_id_str
+   copy_settings_data->debug.bitfields.force_wakeup_by_tps3 = 1;
+   else
+   copy_settings_data->debug.bitfields.force_wakeup_by_tps3 = 0;
+
dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd);
dc_dmub_srv_cmd_execute(dc->dmub_srv);
dc_dmub_srv_wait_idle(dc->dmub_srv);
diff --git a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h 
b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
index 1c4cac4a4894..93631b0db881 100644
--- a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
+++ b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
@@ -209,10 +209,9 @@ union dmub_psr_debug_flags {
uint32_t use_hw_lock_mgr : 1;
 
/**
-* Unused.
-* TODO: Remove.
+* Use TPS3 signal when restore main link.
 */
-   uint32_t log_line_nums : 1;
+   uint32_t force_wakeup_by_tps3 : 1;
} bitfields;
 
/**
diff --git a/drivers/gpu/drm/amd/display/include/ddc_service_types.h 
b/drivers/gpu/drm/amd/display/include/ddc_service_types.h
index 4de59b66bb1a..85b25e684464 100644
--- a/drivers/gpu/drm/amd/display/include/ddc_service_types.h
+++ b/drivers/gpu/drm/amd/display/include/ddc_service_types.h
@@ -117,4 +117,7 @@ struct av_sync_data {
uint8_t aud_del_ins3;/* DPCD 0002Dh */
 };
 
+static const uint8_t DP_SINK_DEVICE_STR_ID_1[] = {7, 1, 8, 7, 3, 0};
+static const uint8_t DP_SINK_DEVICE_STR_ID_2[] = {7, 1, 8, 7, 5, 0};
+
 #endif /* __DAL_DDC_SERVICE_TYPES_H__ */
-- 
2.25.1



[PATCH 17/22] drm/amd/display: Adjust code indentation

2021-11-04 Thread Anson Jacob
From: Charlene Liu 

Reviewed-by: Sung joon Kim 
Acked-by: Anson Jacob 
Signed-off-by: Charlene Liu 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 0ded4decee05..e76a2aa65a82 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -221,9 +221,9 @@ static bool create_links(
link = link_create(&link_init_params);
 
if (link) {
-   dc->links[dc->link_count] = link;
-   link->dc = dc;
-   ++dc->link_count;
+   dc->links[dc->link_count] = link;
+   link->dc = dc;
+   ++dc->link_count;
}
}
 
-- 
2.25.1



[PATCH 15/22] drm/amd/display: Fix Coverity Issues

2021-11-04 Thread Anson Jacob
From: Chris Park 

[Why]
Coverity discovers holes in logic that
needs to be addressed for improved
code integrity.

[How]
Address issues found by coverity without
changing the actual logic.

Reviewed-by: Aric Cyr 
Acked-by: Anson Jacob 
Signed-off-by: Chris Park 
---
 drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c 
b/drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c
index 0321b4446e05..2d0f1f4a8fff 100644
--- a/drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c
+++ b/drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c
@@ -574,7 +574,7 @@ static bool decide_dsc_target_bpp_x16(
return *target_bpp_x16 != 0;
 }
 
-#define MIN_AVAILABLE_SLICES_SIZE  4
+#define MIN_AVAILABLE_SLICES_SIZE  6
 
 static int get_available_dsc_slices(union dsc_enc_slice_caps slice_caps, int 
*available_slices)
 {
@@ -860,6 +860,10 @@ static bool setup_dsc_config(
min_slices_h = 0; // DSC TODO: Maybe try increasing the number 
of slices first?
 
is_dsc_possible = (min_slices_h <= max_slices_h);
+
+   if (min_slices_h == 0 && max_slices_h == 0)
+   is_dsc_possible = false;
+
if (!is_dsc_possible)
goto done;
 
-- 
2.25.1



[PATCH 13/22] drm/amd/display: Don't lock connection_mutex for DMUB HPD

2021-11-04 Thread Anson Jacob
From: Nicholas Kazlauskas 

[Why]
Per DRM spec we only need to hold that lock when touching
connector->state - which we do not do in that handler.

Taking this locking introduces unnecessary dependencies with other
threads which is bad for performance and opens up the potential for
a deadlock since there are multiple locks being held at once.

[How]
Remove the connection_mutex lock/unlock routine and just iterate over
the drm connectors normally. The iter helpers implicitly lock the
connection list so this is safe to do.

DC link access also does not need to be guarded since the link
table is static at creation - we don't dynamically add or remove links,
just streams.

Fixes: 00be4268d32c ("drm/amd/display: Support for DMUB HPD interrupt handling")

Reviewed-by: Jude Shih 
Acked-by: Anson Jacob 
Signed-off-by: Nicholas Kazlauskas 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 
 1 file changed, 4 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 5d646acd269d..0fa0c7bb07a0 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -669,10 +669,7 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct 
dmub_notification *not
return;
}
 
-   drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
-
link_index = notify->link_index;
-
link = adev->dm.dc->links[link_index];
 
drm_connector_list_iter_begin(dev, &iter);
@@ -685,7 +682,6 @@ void dmub_hpd_callback(struct amdgpu_device *adev, struct 
dmub_notification *not
}
}
drm_connector_list_iter_end(&iter);
-   drm_modeset_unlock(&dev->mode_config.connection_mutex);
 
if (hpd_aconnector)
handle_hpd_irq_helper(hpd_aconnector);
-- 
2.25.1



[PATCH 12/22] drm/amd/display: retain/release stream pointer in link enc table

2021-11-04 Thread Anson Jacob
From: Sung Joon Kim 

[why]
At every reference to stream pointer, we need
to increment/decrement the kref_count.
Not doing so will result in invalid stream
pointer still alive after hibernate cycle.

[how]
Call stream retain/release whenever
the link encoder assignment is set to
true/false since it indicates if we want
to reference the stream pointer or not.

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Sung Joon Kim 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
index 13a9d55930ed..b96e301f64f2 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
@@ -122,6 +122,7 @@ static void remove_link_enc_assignment(
stream->link_enc = NULL;

state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i].eng_id = 
ENGINE_ID_UNKNOWN;

state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i].stream = NULL;
+   dc_stream_release(stream);
break;
}
}
@@ -144,6 +145,7 @@ static void add_link_enc_assignment(
 */
for (i = 0; i < state->stream_count; i++) {
if (stream == state->streams[i]) {
+   dc_stream_retain(stream);

state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i] = (struct 
link_enc_assignment){
.valid = true,
.ep_id = (struct display_endpoint_id) {
-- 
2.25.1



[PATCH 11/22] drm/amd/display: fix stale info in link encoder assignment

2021-11-04 Thread Anson Jacob
From: Roy Chan 

[Why]
The link encoder assignment leaves the old stream data when it
was unassigned. When the clear encoder assignment is called,
it based on the old stale data to access the de-allocated stream.

[How]
There should be no need to explicitly clean up the link encoder
assignment if the unassign loop does the work properly,
the loop should base on the current state to clean up the assignment.

Also, the unassignment should better clean up the values in the
assignement slots as well.

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Roy Chan 
---
 .../drm/amd/display/dc/core/dc_link_enc_cfg.c | 36 ---
 1 file changed, 14 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
index 25e48a8cbb78..13a9d55930ed 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
@@ -118,7 +118,10 @@ static void remove_link_enc_assignment(
 */
if (get_stream_using_link_enc(state, eng_id) == 
NULL)

state->res_ctx.link_enc_cfg_ctx.link_enc_avail[eng_idx] = eng_id;
+
stream->link_enc = NULL;
+   
state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i].eng_id = 
ENGINE_ID_UNKNOWN;
+   
state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i].stream = NULL;
break;
}
}
@@ -237,28 +240,15 @@ static struct link_encoder *get_link_enc_used_by_link(
return link_enc;
 }
 /* Clear all link encoder assignments. */
-static void clear_enc_assignments(struct dc_state *state)
+static void clear_enc_assignments(struct dc *dc, struct dc_state *state)
 {
int i;
-   enum engine_id eng_id;
-   struct dc_stream_state *stream;
 
for (i = 0; i < MAX_PIPES; i++) {
state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i].valid = 
false;
-   eng_id = 
state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i].eng_id;
-   stream = 
state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i].stream;
-   if (eng_id != ENGINE_ID_UNKNOWN)
-   state->res_ctx.link_enc_cfg_ctx.link_enc_avail[eng_id - 
ENGINE_ID_DIGA] = eng_id;
-   if (stream)
-   stream->link_enc = NULL;
+   state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i].eng_id 
= ENGINE_ID_UNKNOWN;
+   state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i].stream 
= NULL;
}
-}
-
-void link_enc_cfg_init(
-   struct dc *dc,
-   struct dc_state *state)
-{
-   int i;
 
for (i = 0; i < dc->res_pool->res_cap->num_dig_link_enc; i++) {
if (dc->res_pool->link_encoders[i])
@@ -266,8 +256,13 @@ void link_enc_cfg_init(
else
state->res_ctx.link_enc_cfg_ctx.link_enc_avail[i] = 
ENGINE_ID_UNKNOWN;
}
+}
 
-   clear_enc_assignments(state);
+void link_enc_cfg_init(
+   struct dc *dc,
+   struct dc_state *state)
+{
+   clear_enc_assignments(dc, state);
 
state->res_ctx.link_enc_cfg_ctx.mode = LINK_ENC_CFG_STEADY;
 }
@@ -284,12 +279,9 @@ void link_enc_cfg_link_encs_assign(
 
ASSERT(state->stream_count == stream_count);
 
-   if (stream_count == 0)
-   clear_enc_assignments(state);
-
/* Release DIG link encoder resources before running assignment 
algorithm. */
-   for (i = 0; i < stream_count; i++)
-   dc->res_pool->funcs->link_enc_unassign(state, streams[i]);
+   for (i = 0; i < dc->current_state->stream_count; i++)
+   dc->res_pool->funcs->link_enc_unassign(state, 
dc->current_state->streams[i]);
 
for (i = 0; i < MAX_PIPES; i++)

ASSERT(state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i].valid == false);
-- 
2.25.1



[PATCH 10/22] drm/amd/display: use link_rate_set above DPCD 1.3 (#1527)

2021-11-04 Thread Anson Jacob
From: "Huang, ChiaWen" 

[Why & How]
According to eDP spec, DPCD 1.3 is only for eDP DPCD v1.4
In dpcd_set_link_settings function, the driver is just above v1.3

Reviewed-by: Wenjing Liu 
Acked-by: Anson Jacob 
Signed-off-by: ChiawenHuang 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 cb7bf9148904..b21f61e89cba 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
@@ -430,7 +430,7 @@ enum dc_status dpcd_set_link_settings(
status = core_link_write_dpcd(link, DP_LANE_COUNT_SET,
&lane_count_set.raw, 1);
 
-   if (link->dpcd_caps.dpcd_rev.raw >= DPCD_REV_14 &&
+   if (link->dpcd_caps.dpcd_rev.raw >= DPCD_REV_13 &&
lt_settings->link_settings.use_link_rate_set == true) {
rate = 0;
/* WA for some MUX chips that will power down with eDP and lose 
supported
-- 
2.25.1



[PATCH 08/22] drm/amd/display: bring dcn31 clk mgr in line with other version style

2021-11-04 Thread Anson Jacob
From: Dmytro Laktyushkin 

Reviewed-by: Nicholas Kazlauskas 
Acked-by: Anson Jacob 
Signed-off-by: Dmytro Laktyushkin 
---
 .../gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c  | 8 
 .../gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.h  | 7 +++
 2 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
index f4c9a458ace8..a13ff1783b9b 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c
@@ -66,7 +66,7 @@
 #define TO_CLK_MGR_DCN31(clk_mgr)\
container_of(clk_mgr, struct clk_mgr_dcn31, base)
 
-int dcn31_get_active_display_cnt_wa(
+static int dcn31_get_active_display_cnt_wa(
struct dc *dc,
struct dc_state *context)
 {
@@ -118,7 +118,7 @@ static void dcn31_disable_otg_wa(struct clk_mgr 
*clk_mgr_base, bool disable)
}
 }
 
-static void dcn31_update_clocks(struct clk_mgr *clk_mgr_base,
+void dcn31_update_clocks(struct clk_mgr *clk_mgr_base,
struct dc_state *context,
bool safe_to_lower)
 {
@@ -284,7 +284,7 @@ static void dcn31_enable_pme_wa(struct clk_mgr 
*clk_mgr_base)
dcn31_smu_enable_pme_wa(clk_mgr);
 }
 
-static void dcn31_init_clocks(struct clk_mgr *clk_mgr)
+void dcn31_init_clocks(struct clk_mgr *clk_mgr)
 {
memset(&(clk_mgr->clks), 0, sizeof(struct dc_clocks));
// Assumption is that boot state always supports pstate
@@ -294,7 +294,7 @@ static void dcn31_init_clocks(struct clk_mgr *clk_mgr)
clk_mgr->clks.zstate_support = DCN_ZSTATE_SUPPORT_UNKNOWN;
 }
 
-static bool dcn31_are_clock_states_equal(struct dc_clocks *a,
+bool dcn31_are_clock_states_equal(struct dc_clocks *a,
struct dc_clocks *b)
 {
if (a->dispclk_khz != b->dispclk_khz)
diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.h 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.h
index f8f100535526..961b10a49486 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.h
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn31/dcn31_clk_mgr.h
@@ -39,6 +39,13 @@ struct clk_mgr_dcn31 {
struct dcn31_smu_watermark_set smu_wm_set;
 };
 
+bool dcn31_are_clock_states_equal(struct dc_clocks *a,
+   struct dc_clocks *b);
+void dcn31_init_clocks(struct clk_mgr *clk_mgr);
+void dcn31_update_clocks(struct clk_mgr *clk_mgr_base,
+   struct dc_state *context,
+   bool safe_to_lower);
+
 void dcn31_clk_mgr_construct(struct dc_context *ctx,
struct clk_mgr_dcn31 *clk_mgr,
struct pp_smu_funcs *pp_smu,
-- 
2.25.1



[PATCH 05/22] drm/amd/display: Fix RGB MPO underflow with multiple displays

2021-11-04 Thread Anson Jacob
From: Angus Wang 

[WHY]
With RGB MPO enabled, playing a video with multiple displays
connected results in underflow when closing the video window

[HOW]
Reverted the old change to fix this problem, which prevented
pipe splits for multiple display configurations and caused
high MCLK speeds during idle. Added a two step call to
dc_update_planes_and_stream, first time with pipe split
disabled and the second time with pipe split enabled, which
fixed the underflow issue

Change-Id: I2d6fcc146242a30849096f08c52afa13bf4f9225

Reviewed-by: Aric Cyr 
Acked-by: Anson Jacob 
Signed-off-by: Angus Wang 
---
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c   | 2 +-
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c   | 2 +-
 drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c | 2 +-
 drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c | 2 +-
 4 files changed, 4 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 3883f918b3bb..83f5d9aaffcb 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
@@ -1069,7 +1069,7 @@ static const struct dc_debug_options debug_defaults_drv = 
{
.timing_trace = false,
.clock_trace = true,
.disable_pplib_clock_request = true,
-   .pipe_split_policy = MPC_SPLIT_AVOID_MULT_DISP,
+   .pipe_split_policy = MPC_SPLIT_DYNAMIC,
.force_single_disp_pipe_split = false,
.disable_dcc = DCC_ENABLE,
.vsr_support = true,
diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
index 79a66e0c4303..98852b586295 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
@@ -840,7 +840,7 @@ static const struct dc_debug_options debug_defaults_drv = {
.timing_trace = false,
.clock_trace = true,
.disable_pplib_clock_request = true,
-   .pipe_split_policy = MPC_SPLIT_AVOID_MULT_DISP,
+   .pipe_split_policy = MPC_SPLIT_DYNAMIC,
.force_single_disp_pipe_split = false,
.disable_dcc = DCC_ENABLE,
.vsr_support = true,
diff --git a/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c
index fcf96cf08c76..16e7059393fa 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn302/dcn302_resource.c
@@ -211,7 +211,7 @@ static const struct dc_debug_options debug_defaults_drv = {
.timing_trace = false,
.clock_trace = true,
.disable_pplib_clock_request = true,
-   .pipe_split_policy = MPC_SPLIT_AVOID_MULT_DISP,
+   .pipe_split_policy = MPC_SPLIT_DYNAMIC,
.force_single_disp_pipe_split = false,
.disable_dcc = DCC_ENABLE,
.vsr_support = true,
diff --git a/drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c
index 4a9b64023675..87cec14b7870 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn303/dcn303_resource.c
@@ -193,7 +193,7 @@ static const struct dc_debug_options debug_defaults_drv = {
.timing_trace = false,
.clock_trace = true,
.disable_pplib_clock_request = true,
-   .pipe_split_policy = MPC_SPLIT_AVOID_MULT_DISP,
+   .pipe_split_policy = MPC_SPLIT_DYNAMIC,
.force_single_disp_pipe_split = false,
.disable_dcc = DCC_ENABLE,
.vsr_support = true,
-- 
2.25.1



[PATCH 07/22] drm/amd/display: Fix detection of aligned DMUB firmware meta info

2021-11-04 Thread Anson Jacob
From: Nicholas Kazlauskas 

[Why]
A built firmware binary may be aligned to 16-bytes with padding at the
end as necessary. In the case that padding was applied the meta info
will not be detected correctly and we won't be able to allocate the
appropriate firmware and tracebuffer sizes.

[How]
To maintain compatibility with already released firmware where this
occurs we need to try every meta offset from 0..15 inclusive.

Extract out the meta info checker into a helper function that's called
for each of these offsets and exit early when we've found it.

Reviewed-by: Eric Yang 
Acked-by: Anson Jacob 
Signed-off-by: Nicholas Kazlauskas 
---
 .../gpu/drm/amd/display/dmub/src/dmub_srv.c   | 43 ---
 1 file changed, 27 insertions(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c 
b/drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c
index 56d400ffa7ac..4a2cb0cdb0ba 100644
--- a/drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c
+++ b/drivers/gpu/drm/amd/display/dmub/src/dmub_srv.c
@@ -100,24 +100,9 @@ void dmub_flush_buffer_mem(const struct dmub_fb *fb)
 }
 
 static const struct dmub_fw_meta_info *
-dmub_get_fw_meta_info(const struct dmub_srv_region_params *params)
+dmub_get_fw_meta_info_from_blob(const uint8_t *blob, uint32_t blob_size, 
uint32_t meta_offset)
 {
const union dmub_fw_meta *meta;
-   const uint8_t *blob = NULL;
-   uint32_t blob_size = 0;
-   uint32_t meta_offset = 0;
-
-   if (params->fw_bss_data && params->bss_data_size) {
-   /* Legacy metadata region. */
-   blob = params->fw_bss_data;
-   blob_size = params->bss_data_size;
-   meta_offset = DMUB_FW_META_OFFSET;
-   } else if (params->fw_inst_const && params->inst_const_size) {
-   /* Combined metadata region. */
-   blob = params->fw_inst_const;
-   blob_size = params->inst_const_size;
-   meta_offset = 0;
-   }
 
if (!blob || !blob_size)
return NULL;
@@ -134,6 +119,32 @@ dmub_get_fw_meta_info(const struct dmub_srv_region_params 
*params)
return &meta->info;
 }
 
+static const struct dmub_fw_meta_info *
+dmub_get_fw_meta_info(const struct dmub_srv_region_params *params)
+{
+   const struct dmub_fw_meta_info *info = NULL;
+
+   if (params->fw_bss_data && params->bss_data_size) {
+   /* Legacy metadata region. */
+   info = dmub_get_fw_meta_info_from_blob(params->fw_bss_data,
+  params->bss_data_size,
+  DMUB_FW_META_OFFSET);
+   } else if (params->fw_inst_const && params->inst_const_size) {
+   /* Combined metadata region - can be aligned to 16-bytes. */
+   uint32_t i;
+
+   for (i = 0; i < 16; ++i) {
+   info = dmub_get_fw_meta_info_from_blob(
+   params->fw_inst_const, params->inst_const_size, 
i);
+
+   if (info)
+   break;
+   }
+   }
+
+   return info;
+}
+
 static bool dmub_srv_hw_setup(struct dmub_srv *dmub, enum dmub_asic asic)
 {
struct dmub_srv_hw_funcs *funcs = &dmub->hw_funcs;
-- 
2.25.1



[PATCH 09/22] drm/amd/display: clean up some formats and log.

2021-11-04 Thread Anson Jacob
From: Charlene Liu 

[why]
reduce az indirect register dump. need add az
clock_gating control field used in some project.

[how]
conditional output indrect register in the log.
add clock_gating feild

Reviewed-by: Sung joon Kim 
Acked-by: Anson Jacob 
Signed-off-by: Charlene Liu 
---
 drivers/gpu/drm/amd/display/dc/dc_link.h   | 2 +-
 drivers/gpu/drm/amd/display/dc/dce/dce_audio.c | 6 --
 drivers/gpu/drm/amd/display/dc/dce/dce_audio.h | 2 ++
 3 files changed, 3 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc_link.h 
b/drivers/gpu/drm/amd/display/dc/dc_link.h
index 669c162c0c02..b732398dac89 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_link.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_link.h
@@ -302,7 +302,7 @@ enum dc_detect_reason {
DETECT_REASON_HPD,
DETECT_REASON_HPDRX,
DETECT_REASON_FALLBACK,
-   DETECT_REASON_RETRAIN
+   DETECT_REASON_RETRAIN,
 };
 
 bool dc_link_detect(struct dc_link *dc_link, enum dc_detect_reason reason);
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_audio.c 
b/drivers/gpu/drm/amd/display/dc/dce/dce_audio.c
index 27218ede150a..70eaac017624 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_audio.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_audio.c
@@ -67,9 +67,6 @@ static void write_indirect_azalia_reg(struct audio *audio,
/* AZALIA_F0_CODEC_ENDPOINT_DATA  endpoint data  */
REG_SET(AZALIA_F0_CODEC_ENDPOINT_DATA, 0,
AZALIA_ENDPOINT_REG_DATA, reg_data);
-
-   DC_LOG_HW_AUDIO("AUDIO:write_indirect_azalia_reg: index: %u  data: 
%u\n",
-   reg_index, reg_data);
 }
 
 static uint32_t read_indirect_azalia_reg(struct audio *audio, uint32_t 
reg_index)
@@ -85,9 +82,6 @@ static uint32_t read_indirect_azalia_reg(struct audio *audio, 
uint32_t reg_index
/* AZALIA_F0_CODEC_ENDPOINT_DATA  endpoint data  */
value = REG_READ(AZALIA_F0_CODEC_ENDPOINT_DATA);
 
-   DC_LOG_HW_AUDIO("AUDIO:read_indirect_azalia_reg: index: %u  data: %u\n",
-   reg_index, value);
-
return value;
 }
 
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_audio.h 
b/drivers/gpu/drm/amd/display/dc/dce/dce_audio.h
index 5622d5e32d81..dbd2cfed0603 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_audio.h
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_audio.h
@@ -113,6 +113,7 @@ struct dce_audio_shift {
uint8_t DCCG_AUDIO_DTO2_USE_512FBR_DTO;
uint32_t DCCG_AUDIO_DTO0_USE_512FBR_DTO;
uint32_t DCCG_AUDIO_DTO1_USE_512FBR_DTO;
+   uint32_t CLOCK_GATING_DISABLE;
 };
 
 struct dce_audio_mask {
@@ -132,6 +133,7 @@ struct dce_audio_mask {
uint32_t DCCG_AUDIO_DTO2_USE_512FBR_DTO;
uint32_t DCCG_AUDIO_DTO0_USE_512FBR_DTO;
uint32_t DCCG_AUDIO_DTO1_USE_512FBR_DTO;
+   uint32_t CLOCK_GATING_DISABLE;
 
 };
 
-- 
2.25.1



[PATCH 02/22] drm/amd/display: Pass panel inst to a PSR command

2021-11-04 Thread Anson Jacob
From: Mikita Lipski 

[why]
PSR set power command wasn't setting panel instance
and command version which caused both streams
to overwrite the same PSR state.
[how]
Pass panel instance to the set power command function
and to DMUB and set command version enum

Reviewed-by: Anthony Koo 
Acked-by: Anson Jacob 
Signed-off-by: Mikita Lipski 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 2 +-
 drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c | 4 +++-
 drivers/gpu/drm/amd/display/dc/dce/dmub_psr.h | 2 +-
 3 files changed, 5 insertions(+), 3 deletions(-)

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 fe2b4b1d80f9..b4cdf6d43965 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -2997,7 +2997,7 @@ bool dc_link_set_psr_allow_active(struct dc_link *link, 
const bool *allow_active
link->psr_settings.psr_power_opt = *power_opts;
 
if (psr != NULL && link->psr_settings.psr_feature_enabled && 
psr->funcs->psr_set_power_opt)
-   psr->funcs->psr_set_power_opt(psr, 
link->psr_settings.psr_power_opt);
+   psr->funcs->psr_set_power_opt(psr, 
link->psr_settings.psr_power_opt, panel_inst);
}
 
/* Enable or Disable PSR */
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c 
b/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c
index 90eb8eedacf2..e9c0ec2ec4ce 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c
@@ -230,7 +230,7 @@ static void dmub_psr_set_level(struct dmub_psr *dmub, 
uint16_t psr_level, uint8_
 /**
  * Set PSR power optimization flags.
  */
-static void dmub_psr_set_power_opt(struct dmub_psr *dmub, unsigned int 
power_opt)
+static void dmub_psr_set_power_opt(struct dmub_psr *dmub, unsigned int 
power_opt, uint8_t panel_inst)
 {
union dmub_rb_cmd cmd;
struct dc_context *dc = dmub->ctx;
@@ -239,7 +239,9 @@ static void dmub_psr_set_power_opt(struct dmub_psr *dmub, 
unsigned int power_opt
cmd.psr_set_power_opt.header.type = DMUB_CMD__PSR;
cmd.psr_set_power_opt.header.sub_type = DMUB_CMD__SET_PSR_POWER_OPT;
cmd.psr_set_power_opt.header.payload_bytes = sizeof(struct 
dmub_cmd_psr_set_power_opt_data);
+   cmd.psr_set_power_opt.psr_set_power_opt_data.cmd_version = 
DMUB_CMD_PSR_CONTROL_VERSION_1;
cmd.psr_set_power_opt.psr_set_power_opt_data.power_opt = power_opt;
+   cmd.psr_set_power_opt.psr_set_power_opt_data.panel_inst = panel_inst;
 
dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd);
dc_dmub_srv_cmd_execute(dc->dmub_srv);
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.h 
b/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.h
index 5dbd479660f1..01acc01cc191 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.h
+++ b/drivers/gpu/drm/amd/display/dc/dce/dmub_psr.h
@@ -46,7 +46,7 @@ struct dmub_psr_funcs {
void (*psr_force_static)(struct dmub_psr *dmub, uint8_t panel_inst);
void (*psr_get_residency)(struct dmub_psr *dmub, uint32_t *residency,
uint8_t panel_inst);
-   void (*psr_set_power_opt)(struct dmub_psr *dmub, unsigned int 
power_opt);
+   void (*psr_set_power_opt)(struct dmub_psr *dmub, unsigned int 
power_opt, uint8_t panel_inst);
 };
 
 struct dmub_psr *dmub_psr_create(struct dc_context *ctx);
-- 
2.25.1



[PATCH 06/22] drm/amd/display: Use link_enc_cfg API for queries.

2021-11-04 Thread Anson Jacob
From: Jimmy Kizito 

[Why]
The link_enc_cfg API operates in one of two modes depending on
the stage of application of dc_state to hardware. The API is the
safest way to query link encoder assignments.

[How]
Use results of link encoder assignment query using link_enc_cfg
API.

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Jimmy Kizito 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 17 -
 1 file changed, 4 insertions(+), 13 deletions(-)

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 d856f08491de..c4944ba59ec6 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -3964,9 +3964,6 @@ static void update_psp_stream_config(struct pipe_ctx 
*pipe_ctx, bool dpms_off)
struct cp_psp *cp_psp = &pipe_ctx->stream->ctx->cp_psp;
 #if defined(CONFIG_DRM_AMD_DC_DCN)
struct link_encoder *link_enc = NULL;
-   struct dc_state *state = pipe_ctx->stream->ctx->dc->current_state;
-   struct link_enc_assignment link_enc_assign;
-   int i;
 #endif
 
if (cp_psp && cp_psp->funcs.update_stream_config) {
@@ -3994,18 +3991,14 @@ static void update_psp_stream_config(struct pipe_ctx 
*pipe_ctx, bool dpms_off)

pipe_ctx->stream->ctx->dc,
pipe_ctx->stream);
}
+   ASSERT(link_enc);
+
// Initialize PHY ID with ABCDE - 01234 mapping except 
when it is B0
config.phy_idx = link_enc->transmitter - 
TRANSMITTER_UNIPHY_A;
 
-   //look up the link_enc_assignment for the current 
pipe_ctx
-   for (i = 0; i < state->stream_count; i++) {
-   if (pipe_ctx->stream == state->streams[i]) {
-   link_enc_assign = 
state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[i];
-   }
-   }
// Add flag to guard new A0 DIG mapping
if (pipe_ctx->stream->ctx->dc->enable_c20_dtm_b0 == 
true) {
-   config.dig_be = link_enc_assign.eng_id;
+   config.dig_be = link_enc->preferred_engine;
config.dio_output_type = 
pipe_ctx->stream->link->ep_type;
config.dio_output_idx = link_enc->transmitter - 
TRANSMITTER_UNIPHY_A;
} else {
@@ -4017,10 +4010,8 @@ static void update_psp_stream_config(struct pipe_ctx 
*pipe_ctx, bool dpms_off)
if (pipe_ctx->stream->ctx->dc->enable_c20_dtm_b0 == 
true &&
link_enc->ctx->asic_id.hw_internal_rev 
== YELLOW_CARP_B0) {
if (pipe_ctx->stream->link->ep_type == 
DISPLAY_ENDPOINT_USB4_DPIA) {
-   link_enc = 
link_enc_assign.stream->link_enc;
-
// enum ID 1-4 maps to DPIA PHY ID 0-3
-   config.phy_idx = 
link_enc_assign.ep_id.link_id.enum_id - ENUM_ID_1;
+   config.phy_idx = 
pipe_ctx->stream->link->link_id.enum_id - ENUM_ID_1;
} else {  // for non DPIA mode over B0, ABCDE 
maps to 01564
 
switch (link_enc->transmitter) {
-- 
2.25.1



[PATCH 03/22] drm/amd/display: remove dmcub_support cap dependency

2021-11-04 Thread Anson Jacob
From: Charlene Liu 

[why]
matching the dmcub_support with all other dcn version.

Reviewed-by: Sung joon Kim 
Reviewed-by: Martin Leung 
Acked-by: Anson Jacob 
Signed-off-by: Charlene Liu 
---
 drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
index fbaa03f26d8b..2650d3bd50ec 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn301/dcn301_resource.c
@@ -1449,9 +1449,7 @@ static bool dcn301_resource_construct(
dc->caps.post_blend_color_processing = true;
dc->caps.force_dp_tps4_for_cp2520 = true;
dc->caps.extended_aux_timeout_support = true;
-#ifdef CONFIG_DRM_AMD_DC_DMUB
dc->caps.dmcub_support = true;
-#endif
 
/* Color pipeline capabilities */
dc->caps.color.dpp.dcn_arch = 1;
-- 
2.25.1



[PATCH 01/22] drm/amd/display: Add helper for blanking all dp displays

2021-11-04 Thread Anson Jacob
From: "Leo (Hanghong) Ma" 

[Why & How]
1. The code to blank all dp display have been called many times,
so add helpers in dc_link to make it more concise.
2. Add some check to fix the dmesg errors at boot and resume from S3
on dcn3.1 during DQE's promotion test.

Reviewed-by: Alvin Lee 
Reviewed-by: Wesley Chalmers 
Reviewed-by: Aric Cyr 
Acked-by: Anson Jacob 
Signed-off-by: Leo (Hanghong) Ma 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 51 +++
 drivers/gpu/drm/amd/display/dc/dc_link.h  |  4 ++
 .../display/dc/dce110/dce110_hw_sequencer.c   | 22 +---
 .../amd/display/dc/dcn10/dcn10_hw_sequencer.c | 41 ++-
 .../drm/amd/display/dc/dcn30/dcn30_hwseq.c| 39 ++
 .../drm/amd/display/dc/dcn31/dcn31_hwseq.c| 38 ++
 6 files changed, 66 insertions(+), 129 deletions(-)

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 f14f71dd1aa9..fe2b4b1d80f9 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -1999,6 +1999,57 @@ static enum dc_status enable_link_dp_mst(
return enable_link_dp(state, pipe_ctx);
 }
 
+void dc_link_blank_all_dp_displays(struct dc *dc)
+{
+   unsigned int i;
+   uint8_t dpcd_power_state = '\0';
+   enum dc_status status = DC_ERROR_UNEXPECTED;
+
+   for (i = 0; i < dc->link_count; i++) {
+   if ((dc->links[i]->connector_signal != 
SIGNAL_TYPE_DISPLAY_PORT) ||
+   (dc->links[i]->priv == NULL) || 
(dc->links[i]->local_sink == NULL))
+   continue;
+
+   /* DP 2.0 spec requires that we read LTTPR caps first */
+   dp_retrieve_lttpr_cap(dc->links[i]);
+   /* if any of the displays are lit up turn them off */
+   status = core_link_read_dpcd(dc->links[i], DP_SET_POWER,
+   &dpcd_power_state, 
sizeof(dpcd_power_state));
+
+   if (status == DC_OK && dpcd_power_state == DP_POWER_STATE_D0)
+   dc_link_blank_dp_stream(dc->links[i], true);
+   }
+
+}
+
+void dc_link_blank_dp_stream(struct dc_link *link, bool hw_init)
+{
+   unsigned int j;
+   struct dc  *dc = link->ctx->dc;
+   enum signal_type signal = link->connector_signal;
+
+   if ((signal == SIGNAL_TYPE_EDP) ||
+   (signal == SIGNAL_TYPE_DISPLAY_PORT)) {
+   if (link->ep_type == DISPLAY_ENDPOINT_PHY &&
+   link->link_enc->funcs->get_dig_frontend &&
+   link->link_enc->funcs->is_dig_enabled(link->link_enc)) {
+   unsigned int fe = 
link->link_enc->funcs->get_dig_frontend(link->link_enc);
+
+   if (fe != ENGINE_ID_UNKNOWN)
+   for (j = 0; j < dc->res_pool->stream_enc_count; 
j++) {
+   if (fe == 
dc->res_pool->stream_enc[j]->id) {
+   
dc->res_pool->stream_enc[j]->funcs->dp_blank(link,
+   
dc->res_pool->stream_enc[j]);
+   break;
+   }
+   }
+   }
+
+   if ((!link->wa_flags.dp_keep_receiver_powered) || hw_init)
+   dp_receiver_power_ctrl(link, false);
+   }
+}
+
 static bool get_ext_hdmi_settings(struct pipe_ctx *pipe_ctx,
enum engine_id eng_id,
struct ext_hdmi_settings *settings)
diff --git a/drivers/gpu/drm/amd/display/dc/dc_link.h 
b/drivers/gpu/drm/amd/display/dc/dc_link.h
index 180ecd860296..669c162c0c02 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_link.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_link.h
@@ -287,6 +287,10 @@ bool dc_link_setup_psr(struct dc_link *dc_link,
 
 void dc_link_get_psr_residency(const struct dc_link *link, uint32_t 
*residency);
 
+void dc_link_blank_all_dp_displays(struct dc *dc);
+
+void dc_link_blank_dp_stream(struct dc_link *link, bool hw_init);
+
 /* Request DC to detect if there is a Panel connected.
  * boot - If this call is during initial boot.
  * Return false for any type of detection failure or MST detection
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 24e47df526f6..e7e2aa46218d 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
@@ -1655,30 +1655,12 @@ static enum dc_status apply_single_controller_ctx_to_hw(
 
 static void power_down_encoders(struct dc *dc)
 {
-   int

[PATCH 00/22] DC Patches Nov 4, 2021

2021-11-04 Thread Anson Jacob
This DC patchset brings improvements in multiple areas. In summary, we
have:

* Improvements to INBOX0 HW Lock
* Add support for sending TPS3 pattern
* Fix Coverity Issues
* Fixes for DMUB
* Fix RGB MPO underflow with multiple displays
* WS fixes and code restructure

Alvin Lee (1):
  drm/amd/display: Wait for ACK for INBOX0 HW Lock

Angus Wang (1):
  drm/amd/display: Fix RGB MPO underflow with multiple displays

Anson Jacob (1):
  drm/amd/display: Add comment where CONFIG_DRM_AMD_DC_DCN macro ends

Aric Cyr (1):
  drm/amd/display: 3.2.161

Charlene Liu (3):
  drm/amd/display: remove dmcub_support cap dependency
  drm/amd/display: clean up some formats and log.
  drm/amd/display: Adjust code indentation

Chris Park (1):
  drm/amd/display: Fix Coverity Issues

Dmytro Laktyushkin (1):
  drm/amd/display: bring dcn31 clk mgr in line with other version style

Huang, ChiaWen (1):
  drm/amd/display: use link_rate_set above DPCD 1.3 (#1527)

Jimmy Kizito (3):
  drm/amd/display: Use link_enc_cfg API for queries.
  drm/amd/display: Query all entries in assignment table during updates.
  drm/amd/display: Initialise encoder assignment when initialising
dc_state.

Leo (Hanghong) Ma (1):
  drm/amd/display: Add helper for blanking all dp displays

Meenakshikumar Somasundaram (1):
  drm/amd/display: Add hpd pending flag to indicate detection of new
hpd.

Mikita Lipski (1):
  drm/amd/display: Pass panel inst to a PSR command

Nicholas Kazlauskas (3):
  drm/amd/display: Fix detection of aligned DMUB firmware meta info
  drm/amd/display: Don't lock connection_mutex for DMUB HPD
  drm/amd/display: Add callbacks for DMUB HPD IRQ notifications

Robin Chen (1):
  drm/amd/display: To support sending TPS3 pattern when restoring link

Roy Chan (1):
  drm/amd/display: fix stale info in link encoder assignment

Sung Joon Kim (1):
  drm/amd/display: retain/release stream pointer in link enc table

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 29 ---
 .../display/dc/clk_mgr/dcn31/dcn31_clk_mgr.c  |  8 +-
 .../display/dc/clk_mgr/dcn31/dcn31_clk_mgr.h  |  7 ++
 drivers/gpu/drm/amd/display/dc/core/dc.c  | 17 ++--
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 78 ++-
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  |  2 +-
 .../drm/amd/display/dc/core/dc_link_dpia.c| 20 ++---
 .../drm/amd/display/dc/core/dc_link_enc_cfg.c | 51 ++--
 .../gpu/drm/amd/display/dc/core/dc_resource.c |  3 +
 drivers/gpu/drm/amd/display/dc/dc.h   |  2 +-
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c  | 37 -
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h  |  2 +
 drivers/gpu/drm/amd/display/dc/dc_link.h  |  7 +-
 .../gpu/drm/amd/display/dc/dce/dce_audio.c|  6 --
 .../gpu/drm/amd/display/dc/dce/dce_audio.h|  2 +
 .../drm/amd/display/dc/dce/dmub_hw_lock_mgr.c |  3 +
 drivers/gpu/drm/amd/display/dc/dce/dmub_psr.c | 13 +++-
 drivers/gpu/drm/amd/display/dc/dce/dmub_psr.h |  2 +-
 .../display/dc/dce110/dce110_hw_sequencer.c   | 22 +-
 .../amd/display/dc/dcn10/dcn10_hw_sequencer.c | 41 +-
 .../drm/amd/display/dc/dcn20/dcn20_resource.c |  2 +-
 .../drm/amd/display/dc/dcn30/dcn30_hwseq.c| 39 +-
 .../drm/amd/display/dc/dcn30/dcn30_resource.c |  2 +-
 .../amd/display/dc/dcn301/dcn301_resource.c   |  2 -
 .../amd/display/dc/dcn302/dcn302_resource.c   |  2 +-
 .../amd/display/dc/dcn303/dcn303_resource.c   |  2 +-
 .../drm/amd/display/dc/dcn31/dcn31_hwseq.c| 38 +
 drivers/gpu/drm/amd/display/dc/dsc/dc_dsc.c   |  6 +-
 .../gpu/drm/amd/display/dc/inc/link_enc_cfg.h |  2 +-
 drivers/gpu/drm/amd/display/dmub/dmub_srv.h   | 41 ++
 .../gpu/drm/amd/display/dmub/inc/dmub_cmd.h   |  5 +-
 .../gpu/drm/amd/display/dmub/src/dmub_srv.c   | 78 +++
 .../amd/display/include/ddc_service_types.h   |  3 +
 33 files changed, 330 insertions(+), 244 deletions(-)

-- 
2.25.1



[PATCH 04/22] drm/amd/display: Add comment where CONFIG_DRM_AMD_DC_DCN macro ends

2021-11-04 Thread Anson Jacob
Trivial patch which adds a comment for macro
endif's in amdgpu_dm.c

Reviewed-by: Ariel Bernstein 
Reviewed-by: Harry Wentland 
Acked-by: Anson Jacob 
Signed-off-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 8 
 drivers/gpu/drm/amd/display/dc/core/dc.c  | 6 --
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 2 +-
 3 files changed, 9 insertions(+), 7 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 1e26d9be8993..5d646acd269d 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -619,7 +619,7 @@ static void dm_dcn_vertical_interrupt0_high_irq(void 
*interrupt_params)
 
amdgpu_dm_crtc_handle_crc_window_irq(&acrtc->base);
 }
-#endif
+#endif /* CONFIG_DRM_AMD_SECURE_DISPLAY */
 
 /**
  * dmub_aux_setconfig_reply_callback - Callback for AUX or SET_CONFIG command.
@@ -812,7 +812,7 @@ static void dm_dmub_outbox1_low_irq(void *interrupt_params)
if (count > DMUB_TRACE_MAX_READ)
DRM_DEBUG_DRIVER("Warning : count > DMUB_TRACE_MAX_READ");
 }
-#endif
+#endif /* CONFIG_DRM_AMD_DC_DCN */
 
 static int dm_set_clockgating_state(void *handle,
  enum amd_clockgating_state state)
@@ -1563,7 +1563,7 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
DRM_ERROR("amdgpu: fail to register dmub hpd callback");
goto error;
}
-#endif
+#endif /* CONFIG_DRM_AMD_DC_DCN */
}
 
if (amdgpu_dm_initialize_drm_device(adev)) {
@@ -6077,7 +6077,7 @@ static void apply_dsc_policy_for_stream(struct 
amdgpu_dm_connector *aconnector,
if (stream->timing.flags.DSC && 
aconnector->dsc_settings.dsc_bits_per_pixel)
stream->timing.dsc_cfg.bits_per_pixel = 
aconnector->dsc_settings.dsc_bits_per_pixel;
 }
-#endif
+#endif /* CONFIG_DRM_AMD_DC_DCN */
 
 /**
  * DOC: FreeSync Video
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 398de46fb7e4..0ded4decee05 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1892,6 +1892,7 @@ static bool is_flip_pending_in_pipes(struct dc *dc, 
struct dc_state *context)
return false;
 }
 
+#ifdef CONFIG_DRM_AMD_DC_DCN
 /* Perform updates here which need to be deferred until next vupdate
  *
  * i.e. blnd lut, 3dlut, and shaper lut bypass regs are double buffered
@@ -1901,7 +1902,6 @@ static bool is_flip_pending_in_pipes(struct dc *dc, 
struct dc_state *context)
  */
 static void process_deferred_updates(struct dc *dc)
 {
-#ifdef CONFIG_DRM_AMD_DC_DCN
int i = 0;
 
if (dc->debug.enable_mem_low_power.bits.cm) {
@@ -1910,8 +1910,8 @@ static void process_deferred_updates(struct dc *dc)
if (dc->res_pool->dpps[i]->funcs->dpp_deferred_update)

dc->res_pool->dpps[i]->funcs->dpp_deferred_update(dc->res_pool->dpps[i]);
}
-#endif
 }
+#endif /* CONFIG_DRM_AMD_DC_DCN */
 
 void dc_post_update_surfaces_to_stream(struct dc *dc)
 {
@@ -1938,7 +1938,9 @@ void dc_post_update_surfaces_to_stream(struct dc *dc)
dc->hwss.disable_plane(dc, 
&context->res_ctx.pipe_ctx[i]);
}
 
+#ifdef CONFIG_DRM_AMD_DC_DCN
process_deferred_updates(dc);
+#endif
 
dc->hwss.optimize_bandwidth(dc, context);
 
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 b4cdf6d43965..d856f08491de 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -4821,7 +4821,7 @@ uint32_t dc_bandwidth_in_kbps_from_timing(
timing->dsc_cfg.bits_per_pixel,
timing->dsc_cfg.num_slices_h,
timing->dsc_cfg.is_dp);
-#endif
+#endif /* CONFIG_DRM_AMD_DC_DCN */
 
switch (timing->display_color_depth) {
case COLOR_DEPTH_666:
-- 
2.25.1



[PATCH] drm/amdkfd: Fix dummy kgd2kfd_probe parameters

2021-09-30 Thread Anson Jacob
Commit 4d706ed6825f ("drm/amdkfd: clean up parameters in kgd2kfd_probe")
updated paremeters for kgd2kfd_probe. Update the dummy function as well
when CONFIG_HSA_AMD is not enabled.

Fixes: 4d706ed6825f ("drm/amdkfd: clean up parameters in kgd2kfd_probe")
Signed-off-by: Anson Jacob 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
index 38d883dffc20..69de31754907 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
@@ -346,8 +346,7 @@ static inline void kgd2kfd_exit(void)
 }
 
 static inline
-struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, struct pci_dev *pdev,
-   unsigned int asic_type, bool vf)
+struct kfd_dev *kgd2kfd_probe(struct kgd_dev *kgd, bool vf)
 {
return NULL;
 }
-- 
2.25.1



[PATCH 23/24] drm/amd/display: Update VCP X.Y logging to improve usefulness

2021-09-24 Thread Anson Jacob
From: George Shen 

[Why]
Recently debugging efforts have involved setting/checking the
X.Y value used during payload allocation. Current output for
Y was calculated with incorrect bitshift. Y value is also not
human readable.

[How]
Refactor logging into separate function. Fix Y calculation error
and format output to be human readable.

Reviewed-by: Wenjing Liu 
Acked-by: Anson Jacob 
Signed-off-by: George Shen 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 49 ++-
 1 file changed, 25 insertions(+), 24 deletions(-)

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 f3a1219c0bb9..02c7a18c095f 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -3197,6 +3197,29 @@ static void update_mst_stream_alloc_table(
work_table[i];
 }
 #if defined(CONFIG_DRM_AMD_DC_DCN)
+static void dc_log_vcp_x_y(const struct dc_link *link, struct fixed31_32 
avg_time_slots_per_mtp)
+{
+   const uint32_t VCP_Y_PRECISION = 1000;
+   uint64_t vcp_x, vcp_y;
+
+   // Add 0.5*(1/VCP_Y_PRECISION) to round up to decimal precision
+   avg_time_slots_per_mtp = dc_fixpt_add(
+   avg_time_slots_per_mtp, dc_fixpt_from_fraction(1, 2 * 
VCP_Y_PRECISION));
+
+   vcp_x = dc_fixpt_floor(avg_time_slots_per_mtp);
+   vcp_y = dc_fixpt_floor(
+   dc_fixpt_mul_int(
+   dc_fixpt_sub_int(avg_time_slots_per_mtp, 
dc_fixpt_floor(avg_time_slots_per_mtp)),
+   VCP_Y_PRECISION));
+
+   if (link->type == dc_connection_mst_branch)
+   DC_LOG_DP2("MST Update Payload: set_throttled_vcp_size slot X.Y 
for MST stream "
+   "X: %lld Y: %lld/%d", vcp_x, vcp_y, 
VCP_Y_PRECISION);
+   else
+   DC_LOG_DP2("SST Update Payload: set_throttled_vcp_size slot X.Y 
for SST stream "
+   "X: %lld Y: %lld/%d", vcp_x, vcp_y, 
VCP_Y_PRECISION);
+}
+
 /*
  * Payload allocation/deallocation for SST introduced in DP2.0
  */
@@ -3214,18 +3237,7 @@ enum dc_status dc_link_update_sst_payload(struct 
pipe_ctx *pipe_ctx, bool alloca
if (!allocate) {
avg_time_slots_per_mtp = dc_fixpt_from_int(0);
 
-   DC_LOG_DP2("SST Update Payload: set_throttled_vcp_size slot X.Y 
for SST stream"
-   "X: %d "
-   "Y: %d",
-   dc_fixpt_floor(
-   avg_time_slots_per_mtp),
-   dc_fixpt_ceil(
-   dc_fixpt_shl(
-   dc_fixpt_sub_int(
-   avg_time_slots_per_mtp,
-   dc_fixpt_floor(
-   
avg_time_slots_per_mtp)),
-   26)));
+   dc_log_vcp_x_y(link, avg_time_slots_per_mtp);
 
hpo_dp_link_encoder->funcs->set_throttled_vcp_size(
hpo_dp_link_encoder,
@@ -3272,18 +3284,7 @@ enum dc_status dc_link_update_sst_payload(struct 
pipe_ctx *pipe_ctx, bool alloca
if (allocate) {
avg_time_slots_per_mtp = 
calculate_sst_avg_time_slots_per_mtp(stream, link);
 
-   DC_LOG_DP2("SST Update Payload: "
-   "slot.X: %d  "
-   "slot.Y: %d",
-   dc_fixpt_floor(
-   avg_time_slots_per_mtp),
-   dc_fixpt_ceil(
-   dc_fixpt_shl(
-   dc_fixpt_sub_int(
-   avg_time_slots_per_mtp,
-   dc_fixpt_floor(
-   
avg_time_slots_per_mtp)),
-   26)));
+   dc_log_vcp_x_y(link, avg_time_slots_per_mtp);
 
hpo_dp_link_encoder->funcs->set_throttled_vcp_size(
hpo_dp_link_encoder,
-- 
2.25.1



[PATCH 24/24] drm/amd/display: Pass PCI deviceid into DC

2021-09-24 Thread Anson Jacob
From: Charlene Liu 

[why]
pci deviceid not passed to dal dc, without proper break,
dcn2.x falls into dcn3.x code path

[how]
pass in pci deviceid, and break once dal_version initialized.

Reviewed-by: Zhan Liu 
Acked-by: Anson Jacob 
Signed-off-by: Charlene Liu 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +
 1 file changed, 1 insertion(+)

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 18899a391597..e676d0a56d50 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1319,6 +1319,7 @@ static int amdgpu_dm_init(struct amdgpu_device *adev)
 
init_data.asic_id.pci_revision_id = adev->pdev->revision;
init_data.asic_id.hw_internal_rev = adev->external_rev_id;
+   init_data.asic_id.chip_id = adev->pdev->device;
 
init_data.asic_id.vram_width = adev->gmc.vram_width;
/* TODO: initialize init_data.asic_id.vram_type here */
-- 
2.25.1



[PATCH 22/24] drm/amd/display: Handle Y carry-over in VCP X.Y calculation

2021-09-24 Thread Anson Jacob
From: George Shen 

[Why/How]
Theoretically rare corner case where ceil(Y) results in rounding
up to an integer. If this happens, the 1 should be carried over to
the X value.

Reviewed-by: Wenjing Liu 
Acked-by: Anson Jacob 
Signed-off-by: George Shen 
---
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c | 6 ++
 1 file changed, 6 insertions(+)

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 687c3c6881a9..b0c08ee6bc2c 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
@@ -647,6 +647,12 @@ void enc1_stream_encoder_set_throttled_vcp_size(
x),
26));
 
+   // If y rounds up to integer, carry it over to x.
+   if (y >> 26) {
+   x += 1;
+   y = 0;
+   }
+
REG_SET_2(DP_MSE_RATE_CNTL, 0,
DP_MSE_RATE_X, x,
DP_MSE_RATE_Y, y);
-- 
2.25.1



[PATCH 21/24] drm/amd/display: make verified link cap not exceeding max link cap

2021-09-24 Thread Anson Jacob
From: Wenjing Liu 

[why]
There is a chance verified link cap can be greater than max link cap.
This causes software hang because we cannot power up PHY with link rate
that cannot handle.
The change is to guard verfieid link cap from becoming larger than max link cap
our PHy can support.

Reviewed-by: Jimmy Kizito 
Acked-by: Anson Jacob 
Signed-off-by: Wenjing Liu 
---
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  | 43 ---
 1 file changed, 28 insertions(+), 15 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 f55dac1c7ea1..ccfb0aceea5b 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
@@ -2710,14 +2710,25 @@ bool dp_verify_link_cap(
enum link_training_result status;
union hpd_irq_data irq_data;
 
+   /* link training starts with the maximum common settings
+* supported by both sink and ASIC.
+*/
+   max_link_cap = get_max_link_cap(link);
+   initial_link_settings = get_common_supported_link_settings(
+   *known_limit_link_setting,
+   max_link_cap);
+
/* Accept reported capabilities if link supports flexible encoder 
mapping or encoder already in use. */
if (link->dc->debug.skip_detection_link_training ||
link->is_dig_mapping_flexible) {
+   /* TODO - should we check link encoder's max link caps here?
+* How do we know which link encoder to check from?
+*/
link->verified_link_cap = *known_limit_link_setting;
return true;
} else if (link->link_enc && 
link->dc->res_pool->funcs->link_encs_assign &&
!link_enc_cfg_is_link_enc_avail(link->ctx->dc, 
link->link_enc->preferred_engine)) {
-   link->verified_link_cap = *known_limit_link_setting;
+   link->verified_link_cap = initial_link_settings;
return true;
}
 
@@ -2725,8 +2736,6 @@ bool dp_verify_link_cap(
success = false;
skip_link_training = false;
 
-   max_link_cap = get_max_link_cap(link);
-
/* Grant extended timeout request */
if ((link->lttpr_mode == LTTPR_MODE_NON_TRANSPARENT) && 
(link->dpcd_caps.lttpr_caps.max_ext_timeout > 0)) {
uint8_t grant = link->dpcd_caps.lttpr_caps.max_ext_timeout & 
0x80;
@@ -2748,12 +2757,6 @@ bool dp_verify_link_cap(
 
dp_cs_id = get_clock_source_id(link);
 
-   /* link training starts with the maximum common settings
-* supported by both sink and ASIC.
-*/
-   initial_link_settings = get_common_supported_link_settings(
-   *known_limit_link_setting,
-   max_link_cap);
cur_link_setting = initial_link_settings;
 
/* Temporary Renoir-specific workaround for SWDEV-215184;
@@ -2847,7 +2850,7 @@ bool dp_verify_link_cap_with_retries(
link->verified_link_cap.link_spread = 
LINK_SPREAD_DISABLED;
break;
} else if (dp_verify_link_cap(link,
-   &link->reported_link_cap,
+   known_limit_link_setting,
&fail_count) && fail_count == 0) {
success = true;
break;
@@ -2862,11 +2865,21 @@ bool dp_verify_mst_link_cap(
 {
struct dc_link_settings max_link_cap = {0};
 
-   max_link_cap = get_max_link_cap(link);
-   link->verified_link_cap = get_common_supported_link_settings(
-   link->reported_link_cap,
-   max_link_cap);
-
+   if (dp_get_link_encoding_format(&link->reported_link_cap) ==
+   DP_8b_10b_ENCODING) {
+   max_link_cap = get_max_link_cap(link);
+   link->verified_link_cap = get_common_supported_link_settings(
+   link->reported_link_cap,
+   max_link_cap);
+   }
+#if defined(CONFIG_DRM_AMD_DC_DCN)
+   else if (dp_get_link_encoding_format(&link->reported_link_cap) ==
+   DP_128b_132b_ENCODING) {
+   dp_verify_link_cap_with_retries(link,
+   &link->reported_link_cap,
+   LINK_TRAINING_MAX_VERIFY_RETRY);
+   }
+#endif
return true;
 }
 
-- 
2.25.1



[PATCH 20/24] drm/amd/display: initialize backlight_ramping_override to false

2021-09-24 Thread Anson Jacob
From: Josip Pavic 

[Why]
Stack variable params.backlight_ramping_override is uninitialized, so it
contains junk data

[How]
Initialize the variable to false

Reviewed-by: Roman Li 
Acked-by: Anson Jacob 
Signed-off-by: Josip Pavic 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 1 +
 1 file changed, 1 insertion(+)

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 07adac1a8c42..18899a391597 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -1961,6 +1961,7 @@ static int dm_late_init(void *handle)
linear_lut[i] = 0x * i / 15;
 
params.set = 0;
+   params.backlight_ramping_override = false;
params.backlight_ramping_start = 0x;
params.backlight_ramping_reduction = 0x;
params.backlight_lut_array_size = 16;
-- 
2.25.1



[PATCH 18/24] drm/amd/display: Replace referral of dal with dc

2021-09-24 Thread Anson Jacob
From: Qingqing Zhuo 

[Why]
DC should be used in place of DAL in
upstream.

[How]
Replace dal with dc in function names.

Reviewed-by: Rodrigo Siqueira 
Acked-by: Anson Jacob 
Signed-off-by: Qingqing Zhuo 
---
 drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c | 2 +-
 drivers/gpu/drm/amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c| 2 +-
 drivers/gpu/drm/amd/display/dc/irq/dcn20/irq_service_dcn20.c | 2 +-
 drivers/gpu/drm/amd/display/dc/irq/dcn20/irq_service_dcn20.h | 2 +-
 drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c | 2 +-
 drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.h | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c
index 315466f5aade..2108bff49d4e 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c
@@ -243,7 +243,7 @@ void dcn2_update_clocks(struct clk_mgr *clk_mgr_base,
pp_smu = &dc->res_pool->pp_smu->nv_funcs;
 
for (irq_src = DC_IRQ_SOURCE_HPD1; irq_src <= DC_IRQ_SOURCE_HPD6; 
irq_src++) {
-   hpd_state = dal_get_hpd_state_dcn20(dc->res_pool->irqs, 
irq_src);
+   hpd_state = dc_get_hpd_state_dcn20(dc->res_pool->irqs, irq_src);
if (hpd_state)
break;
}
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 3fabf32a0558..ac2d4c4f04e4 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
@@ -152,7 +152,7 @@ void rn_update_clocks(struct clk_mgr *clk_mgr_base,
display_count = rn_get_active_display_cnt_wa(dc, 
context);
 
for (irq_src = DC_IRQ_SOURCE_HPD1; irq_src <= 
DC_IRQ_SOURCE_HPD5; irq_src++) {
-   hpd_state = 
dal_get_hpd_state_dcn21(dc->res_pool->irqs, irq_src);
+   hpd_state = 
dc_get_hpd_state_dcn21(dc->res_pool->irqs, irq_src);
if (hpd_state)
break;
}
diff --git a/drivers/gpu/drm/amd/display/dc/irq/dcn20/irq_service_dcn20.c 
b/drivers/gpu/drm/amd/display/dc/irq/dcn20/irq_service_dcn20.c
index 49d87fe5c167..9ccafe007b23 100644
--- a/drivers/gpu/drm/amd/display/dc/irq/dcn20/irq_service_dcn20.c
+++ b/drivers/gpu/drm/amd/display/dc/irq/dcn20/irq_service_dcn20.c
@@ -132,7 +132,7 @@ enum dc_irq_source to_dal_irq_source_dcn20(
}
 }
 
-uint32_t dal_get_hpd_state_dcn20(struct irq_service *irq_service, enum 
dc_irq_source source)
+uint32_t dc_get_hpd_state_dcn20(struct irq_service *irq_service, enum 
dc_irq_source source)
 {
const struct irq_source_info *info;
uint32_t addr;
diff --git a/drivers/gpu/drm/amd/display/dc/irq/dcn20/irq_service_dcn20.h 
b/drivers/gpu/drm/amd/display/dc/irq/dcn20/irq_service_dcn20.h
index f60a203e7188..4d69ab24ca25 100644
--- a/drivers/gpu/drm/amd/display/dc/irq/dcn20/irq_service_dcn20.h
+++ b/drivers/gpu/drm/amd/display/dc/irq/dcn20/irq_service_dcn20.h
@@ -31,6 +31,6 @@
 struct irq_service *dal_irq_service_dcn20_create(
struct irq_service_init_data *init_data);
 
-uint32_t dal_get_hpd_state_dcn20(struct irq_service *irq_service, enum 
dc_irq_source source);
+uint32_t dc_get_hpd_state_dcn20(struct irq_service *irq_service, enum 
dc_irq_source source);
 
 #endif
diff --git a/drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c 
b/drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c
index 685528734575..78940cb20e10 100644
--- a/drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c
+++ b/drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.c
@@ -135,7 +135,7 @@ enum dc_irq_source to_dal_irq_source_dcn21(
return DC_IRQ_SOURCE_INVALID;
 }
 
-uint32_t dal_get_hpd_state_dcn21(struct irq_service *irq_service, enum 
dc_irq_source source)
+uint32_t dc_get_hpd_state_dcn21(struct irq_service *irq_service, enum 
dc_irq_source source)
 {
const struct irq_source_info *info;
uint32_t addr;
diff --git a/drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.h 
b/drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.h
index 3df2ceeb2b70..616470e32380 100644
--- a/drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.h
+++ b/drivers/gpu/drm/amd/display/dc/irq/dcn21/irq_service_dcn21.h
@@ -31,6 +31,6 @@
 struct irq_service *dal_irq_service_dcn21_create(
struct irq_service_init_data *init_data);
 
-uint32_t dal_get_hpd_state_dcn21(struct irq_service *irq_service, enum 
dc_irq_source source);
+uint32_t dc_get_hpd_state_dcn21(struct irq_service *irq_service, enum 
dc_irq_source source);
 
 #endif
-- 
2.25.1



[PATCH 19/24] drm/amd/display: Defer LUT memory powerdown until LUT bypass latches

2021-09-24 Thread Anson Jacob
From: Michael Strauss 

[WHY]
Blnd, 3dlut, and shaper LUT select registers are double buffered, however
their accompanying LUT memory shutdown registers are not. As a result,
shutting down LUT memory immediately after setting a block to bypass causes
corruption as bypass only happens at next Vupdate.

[HOW]
Re-enable mem low power for CM block
Force optimization on next flip and disable LUT memory during optimization
sequence if LUT select field is then set to bypass

Reviewed-by: Eric Yang 
Acked-by: Anson Jacob 
Signed-off-by: Michael Strauss 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c  | 19 ++
 .../gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c  | 59 +--
 .../drm/amd/display/dc/dcn31/dcn31_resource.c |  2 +-
 drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h   | 12 
 4 files changed, 85 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 644005846433..0f0440408a16 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1793,6 +1793,23 @@ static bool is_flip_pending_in_pipes(struct dc *dc, 
struct dc_state *context)
return false;
 }
 
+/* Perform updates here which need to be deferred until next vupdate
+ *
+ * i.e. blnd lut, 3dlut, and shaper lut bypass regs are double buffered
+ * but forcing lut memory to shutdown state is immediate. This causes
+ * single frame corruption as lut gets disabled mid-frame unless shutdown
+ * is deferred until after entering bypass.
+ */
+static void process_deferred_updates(struct dc *dc)
+{
+   int i;
+
+   if (dc->debug.enable_mem_low_power.bits.cm)
+   for (i = 0; i < dc->dcn_ip->max_num_dpp; i++)
+   if (dc->res_pool->dpps[i]->funcs->dpp_deferred_update)
+   
dc->res_pool->dpps[i]->funcs->dpp_deferred_update(dc->res_pool->dpps[i]);
+}
+
 void dc_post_update_surfaces_to_stream(struct dc *dc)
 {
int i;
@@ -1818,6 +1835,8 @@ void dc_post_update_surfaces_to_stream(struct dc *dc)
dc->hwss.disable_plane(dc, 
&context->res_ctx.pipe_ctx[i]);
}
 
+   process_deferred_updates(dc);
+
dc->hwss.optimize_bandwidth(dc, context);
 
dc->optimized_required = false;
diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c 
b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c
index 23a52d47e61c..ef5f6da5248a 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c
@@ -488,6 +488,40 @@ void dpp3_cnv_set_bias_scale(
REG_UPDATE(FCNV_FP_SCALE_B, FCNV_FP_SCALE_B, 
bias_and_scale->scale_blue);
 }
 
+void dpp3_deferred_update(
+   struct dpp *dpp_base)
+{
+   int bypass_state;
+   struct dcn3_dpp *dpp = TO_DCN30_DPP(dpp_base);
+
+   if (dpp_base->deferred_reg_writes.bits.disable_blnd_lut) {
+   REG_GET(CM_BLNDGAM_CONTROL, CM_BLNDGAM_MODE_CURRENT, 
&bypass_state);
+   if (bypass_state == 0) {// only program if bypass was 
latched
+   REG_UPDATE(CM_MEM_PWR_CTRL, BLNDGAM_MEM_PWR_FORCE, 3);
+   } else
+   ASSERT(0); // LUT select was updated again before 
vupdate
+   dpp_base->deferred_reg_writes.bits.disable_blnd_lut = false;
+   }
+
+   if (dpp_base->deferred_reg_writes.bits.disable_3dlut) {
+   REG_GET(CM_3DLUT_MODE, CM_3DLUT_MODE_CURRENT, &bypass_state);
+   if (bypass_state == 0) {// only program if bypass was 
latched
+   REG_UPDATE(CM_MEM_PWR_CTRL2, HDR3DLUT_MEM_PWR_FORCE, 3);
+   } else
+   ASSERT(0); // LUT select was updated again before 
vupdate
+   dpp_base->deferred_reg_writes.bits.disable_3dlut = false;
+   }
+
+   if (dpp_base->deferred_reg_writes.bits.disable_shaper) {
+   REG_GET(CM_SHAPER_CONTROL, CM_SHAPER_MODE_CURRENT, 
&bypass_state);
+   if (bypass_state == 0) {// only program if bypass was 
latched
+   REG_UPDATE(CM_MEM_PWR_CTRL2, SHAPER_MEM_PWR_FORCE, 3);
+   } else
+   ASSERT(0); // LUT select was updated again before 
vupdate
+   dpp_base->deferred_reg_writes.bits.disable_shaper = false;
+   }
+}
+
 static void dpp3_power_on_blnd_lut(
struct dpp *dpp_base,
bool power_on)
@@ -495,9 +529,13 @@ static void dpp3_power_on_blnd_lut(
struct dcn3_dpp *dpp = TO_DCN30_DPP(dpp_base);
 
if (dpp_base->ctx->dc->debug.enable_mem_low_power.bits.cm) {
-   REG_UPDATE(CM_MEM_PWR_CTRL, BLNDGAM_MEM_PWR_FORCE, power_on ? 0 
: 3);
-   if (power_on)
+   if (power_on) {
+   REG_UPDATE(CM_MEM_PWR_CTRL, BLNDGAM_ME

[PATCH 17/24] drm/amd/display: 3.2.155

2021-09-24 Thread Anson Jacob
From: Aric Cyr 

This version brings along following fixes:
- Fixes to backlight, LUT, PPS, MST
- Use correct vpg for 128b/132b encoding
- Improved logging for VCP
- Replace referral of dal with dc

Acked-by: Anson Jacob 
Signed-off-by: Aric Cyr 
---
 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 a46c663ed8c5..8cc9626fc111 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -45,7 +45,7 @@
 /* forward declaration */
 struct aux_payload;
 
-#define DC_VER "3.2.154"
+#define DC_VER "3.2.155"
 
 #define MAX_SURFACES 3
 #define MAX_PLANES 6
-- 
2.25.1



[PATCH 16/24] drm/amd/display: [FW Promotion] Release 0.0.86

2021-09-24 Thread Anson Jacob
From: Anthony Koo 

Acked-by: Anson Jacob 
Signed-off-by: Anthony Koo 
---
 drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h 
b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
index 4a41549109dd..f5974562aa23 100644
--- a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
+++ b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
@@ -47,10 +47,10 @@
 
 /* Firmware versioning. */
 #ifdef DMUB_EXPOSE_VERSION
-#define DMUB_FW_VERSION_GIT_HASH 0xeb0940cc
+#define DMUB_FW_VERSION_GIT_HASH 0x42c0e74b
 #define DMUB_FW_VERSION_MAJOR 0
 #define DMUB_FW_VERSION_MINOR 0
-#define DMUB_FW_VERSION_REVISION 85
+#define DMUB_FW_VERSION_REVISION 86
 #define DMUB_FW_VERSION_TEST 0
 #define DMUB_FW_VERSION_VBIOS 0
 #define DMUB_FW_VERSION_HOTFIX 0
-- 
2.25.1



[PATCH 14/24] drm/amd/display: Add PPS immediate update flag for DCN2

2021-09-24 Thread Anson Jacob
From: Ilya 

[Why]
This change is needed for DCN2 to make use of the immediate_update
flag. With this flag, update to PPS will be immediate, rather than
always taking place on dig_update signal.

[How]
Set AFMT_GENERIC7_FRAME/IMMEDIATE_UPDATE bits depending on flag
value.

Reviewed-by: Wenjing Liu 
Acked-by: Anson Jacob 
Signed-off-by: Ilya 
---
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c| 5 +
 .../gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c  | 9 ++---
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c
index f6e747f25ebe..c90b8516dcc1 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_optc.c
@@ -467,6 +467,11 @@ void optc2_lock_doublebuffer_enable(struct 
timing_generator *optc)
(h_blank_start - 200 - 1) / optc1->opp_count,
MASTER_UPDATE_LOCK_DB_Y,
v_blank_start - 1);
+
+   REG_SET_3(OTG_VUPDATE_KEEPOUT, 0,
+   MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_START_OFFSET, 0,
+   MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_END_OFFSET, 100,
+   OTG_MASTER_UPDATE_LOCK_VUPDATE_KEEPOUT_EN, 1);
 }
 
 void optc2_lock_doublebuffer_disable(struct timing_generator *optc)
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c
index 11c50b508754..aab25ca8343a 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c
@@ -211,7 +211,8 @@ static void enc2_stream_encoder_stop_hdmi_info_packets(
 /* Update GSP7 SDP 128 byte long */
 static void enc2_update_gsp7_128_info_packet(
struct dcn10_stream_encoder *enc1,
-   const struct dc_info_packet_128 *info_packet)
+   const struct dc_info_packet_128 *info_packet,
+   bool immediate_update)
 {
uint32_t i;
 
@@ -266,7 +267,9 @@ static void enc2_update_gsp7_128_info_packet(
REG_WRITE(AFMT_GENERIC_7, *content++);
}
 
-   REG_UPDATE(AFMT_VBI_PACKET_CONTROL1, AFMT_GENERIC7_FRAME_UPDATE, 1);
+   REG_UPDATE_2(AFMT_VBI_PACKET_CONTROL1,
+   AFMT_GENERIC7_FRAME_UPDATE, !immediate_update,
+   AFMT_GENERIC7_IMMEDIATE_UPDATE, immediate_update);
 }
 
 /* Set DSC-related configuration.
@@ -309,7 +312,7 @@ static void enc2_dp_set_dsc_pps_info_packet(struct 
stream_encoder *enc,
pps_sdp.hb2 = 127;
pps_sdp.hb3 = 0;
memcpy(&pps_sdp.sb[0], dsc_packed_pps, sizeof(pps_sdp.sb));
-   enc2_update_gsp7_128_info_packet(enc1, &pps_sdp);
+   enc2_update_gsp7_128_info_packet(enc1, &pps_sdp, 
immediate_update);
 
/* Enable Generic Stream Packet 7 (GSP) transmission */
//REG_UPDATE(DP_SEC_CNTL,
-- 
2.25.1



[PATCH 15/24] drm/amd/display: Add an extra check for dcn10 OPTC data format

2021-09-24 Thread Anson Jacob
From: Oliver Logush 

Reviewed-by: Charlene Liu 
Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Oliver Logush 
---
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_ipp.h  | 6 --
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c | 2 +-
 drivers/gpu/drm/amd/display/dc/inc/hw/dwb.h   | 1 -
 3 files changed, 1 insertion(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_ipp.h 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_ipp.h
index f0e0d07b0311..1ca4907b144d 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_ipp.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_ipp.h
@@ -62,12 +62,6 @@
 
 #define CURSOR0_CURSOR_CONTROL__CURSOR_2X_MAGNIFY__SHIFT   0x4
 #define CURSOR0_CURSOR_CONTROL__CURSOR_2X_MAGNIFY_MASK 0x0010L
-#define CURSOR1_CURSOR_CONTROL__CURSOR_2X_MAGNIFY__SHIFT   0x4
-#define CURSOR1_CURSOR_CONTROL__CURSOR_2X_MAGNIFY_MASK 0x0010L
-#define CURSOR2_CURSOR_CONTROL__CURSOR_2X_MAGNIFY__SHIFT   0x4
-#define CURSOR2_CURSOR_CONTROL__CURSOR_2X_MAGNIFY_MASK 0x0010L
-#define CURSOR3_CURSOR_CONTROL__CURSOR_2X_MAGNIFY__SHIFT   0x4
-#define CURSOR3_CURSOR_CONTROL__CURSOR_2X_MAGNIFY_MASK 0x0010L
 
 #define IPP_SF(reg_name, field_name, post_fix)\
.field_name = reg_name ## __ ## field_name ## post_fix
diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c
index 37848f4577b1..3d2a2848857a 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_optc.c
@@ -304,7 +304,7 @@ void optc1_program_timing(
if (optc1_is_two_pixels_per_containter(&patched_crtc_timing) || 
optc1->opp_count == 2)
h_div = H_TIMING_DIV_BY2;
 
-   if (REG(OPTC_DATA_FORMAT_CONTROL)) {
+   if (REG(OPTC_DATA_FORMAT_CONTROL) && optc1->tg_mask->OPTC_DATA_FORMAT 
!= 0) {
uint32_t data_fmt = 0;
 
if (patched_crtc_timing.pixel_encoding == 
PIXEL_ENCODING_YCBCR422)
diff --git a/drivers/gpu/drm/amd/display/dc/inc/hw/dwb.h 
b/drivers/gpu/drm/amd/display/dc/inc/hw/dwb.h
index ec28cb9c3a8e..9ccbb2b519b7 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/hw/dwb.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/hw/dwb.h
@@ -171,7 +171,6 @@ struct dwbc {
bool dwb_is_efc_transition;
bool dwb_is_drc;
int wb_src_plane_inst;/*hubp, mpcc, inst*/
-   bool update_privacymask;
uint32_t mask_id;
 int otg_inst;
 bool mvc_cfg;
-- 
2.25.1



[PATCH 13/24] drm/amd/display: Fix MST link encoder availability check.

2021-09-24 Thread Anson Jacob
From: Jimmy Kizito 

[Why]
MST streams share the same link and should share the same encoder.
The current availability check may erroneously determine that an
encoder is unavailable for MST streams.

[How]
When checking for link encoder availability, check if an encoder
in use shares a link with the stream for which the availability
check is being conducted. If the link is shared, then the link
encoder should be shared too and will be deemed available.

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Jimmy Kizito 
---
 .../drm/amd/display/dc/core/dc_link_enc_cfg.c | 23 +++
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
index 4dce25c39b75..1cab4bf06abe 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_enc_cfg.c
@@ -1,5 +1,4 @@
-/*
- * Copyright 2021 Advanced Micro Devices, Inc.
+/* Copyright 2021 Advanced Micro Devices, Inc. All rights reserved.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -177,13 +176,27 @@ static enum engine_id find_first_avail_link_enc(
return eng_id;
 }
 
-static bool is_avail_link_enc(struct dc_state *state, enum engine_id eng_id)
+/* Check for availability of link encoder eng_id. */
+static bool is_avail_link_enc(struct dc_state *state, enum engine_id eng_id, 
struct dc_stream_state *stream)
 {
bool is_avail = false;
int eng_idx = eng_id - ENGINE_ID_DIGA;
 
-   if (eng_id != ENGINE_ID_UNKNOWN && 
state->res_ctx.link_enc_cfg_ctx.link_enc_avail[eng_idx] != ENGINE_ID_UNKNOWN)
+   /* An encoder is available if it is still in the availability pool. */
+   if (eng_id != ENGINE_ID_UNKNOWN && 
state->res_ctx.link_enc_cfg_ctx.link_enc_avail[eng_idx] != ENGINE_ID_UNKNOWN) {
is_avail = true;
+   } else {
+   struct dc_stream_state *stream_assigned = NULL;
+
+   /* MST streams share the same link and should share the same 
encoder.
+* If a stream that has already been assigned a link encoder 
uses as the
+* same link as the stream checking for availability, it is an 
MST stream
+* and should use the same link encoder.
+*/
+   stream_assigned = get_stream_using_link_enc(state, eng_id);
+   if (stream_assigned && stream != stream_assigned && 
stream->link == stream_assigned->link)
+   is_avail = true;
+   }
 
return is_avail;
 }
@@ -296,7 +309,7 @@ void link_enc_cfg_link_encs_assign(
if (stream == prev_stream && stream->link == 
prev_stream->link &&

prev_state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[j].valid) {
eng_id = 
prev_state->res_ctx.link_enc_cfg_ctx.link_enc_assignments[j].eng_id;
-   if (is_avail_link_enc(state, eng_id))
+   if (is_avail_link_enc(state, eng_id, 
stream))
add_link_enc_assignment(state, 
stream, eng_id);
}
}
-- 
2.25.1



[PATCH 12/24] drm/amd/display: Fix for link encoder access for MST.

2021-09-24 Thread Anson Jacob
From: Meenakshikumar Somasundaram 

[Why]
Link encoder in the link could be null for certain links.

[How]
If link encoder in the link is null then get the link encoder
from the stream.

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Meenakshikumar Somasundaram 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 18 --
 1 file changed, 16 insertions(+), 2 deletions(-)

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 cab7993b4cc5..f3a1219c0bb9 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -3305,7 +3305,7 @@ enum dc_status dc_link_allocate_mst_payload(struct 
pipe_ctx *pipe_ctx)
 {
struct dc_stream_state *stream = pipe_ctx->stream;
struct dc_link *link = stream->link;
-   struct link_encoder *link_encoder = link->link_enc;
+   struct link_encoder *link_encoder = NULL;
struct stream_encoder *stream_encoder = pipe_ctx->stream_res.stream_enc;
struct dp_mst_stream_allocation_table proposed_table = {0};
struct fixed31_32 avg_time_slots_per_mtp;
@@ -3315,6 +3315,13 @@ enum dc_status dc_link_allocate_mst_payload(struct 
pipe_ctx *pipe_ctx)
enum act_return_status ret;
DC_LOGGER_INIT(link->ctx->logger);
 
+   /* Link encoder may have been dynamically assigned to non-physical 
display endpoint. */
+   if (link->ep_type == DISPLAY_ENDPOINT_PHY)
+   link_encoder = link->link_enc;
+   else if (link->dc->res_pool->funcs->link_encs_assign)
+   link_encoder = 
link_enc_cfg_get_link_enc_used_by_stream(pipe_ctx->stream->ctx->dc, stream);
+   ASSERT(link_encoder);
+
/* enable_link_dp_mst already check link->enabled_stream_count
 * and stream is in link->stream[]. This is called during set mode,
 * stream_enc is available.
@@ -3392,7 +3399,7 @@ static enum dc_status deallocate_mst_payload(struct 
pipe_ctx *pipe_ctx)
 {
struct dc_stream_state *stream = pipe_ctx->stream;
struct dc_link *link = stream->link;
-   struct link_encoder *link_encoder = link->link_enc;
+   struct link_encoder *link_encoder = NULL;
struct stream_encoder *stream_encoder = pipe_ctx->stream_res.stream_enc;
struct dp_mst_stream_allocation_table proposed_table = {0};
struct fixed31_32 avg_time_slots_per_mtp = dc_fixpt_from_int(0);
@@ -3400,6 +3407,13 @@ static enum dc_status deallocate_mst_payload(struct 
pipe_ctx *pipe_ctx)
bool mst_mode = (link->type == dc_connection_mst_branch);
DC_LOGGER_INIT(link->ctx->logger);
 
+   /* Link encoder may have been dynamically assigned to non-physical 
display endpoint. */
+   if (link->ep_type == DISPLAY_ENDPOINT_PHY)
+   link_encoder = link->link_enc;
+   else if (link->dc->res_pool->funcs->link_encs_assign)
+   link_encoder = 
link_enc_cfg_get_link_enc_used_by_stream(pipe_ctx->stream->ctx->dc, stream);
+   ASSERT(link_encoder);
+
/* deallocate_mst_payload is called before disable link. When mode or
 * disable/enable monitor, new stream is created which is not in link
 * stream[] yet. For this, payload is not allocated yet, so de-alloc
-- 
2.25.1



[PATCH 11/24] drm/amd/display: add two lane settings training options

2021-09-24 Thread Anson Jacob
From: Wenjing Liu 

[why]
option 1: disallow different lanes to have different lane settings
option 2: dpcd lane settings will always use the same hw lane settings
 even if it doesn't match requested lane adjust

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Wenjing Liu 
---
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c   | 18 --
 .../amd/display/include/link_service_types.h   |  6 +-
 2 files changed, 17 insertions(+), 7 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 f13bf8ca93aa..f55dac1c7ea1 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
@@ -733,12 +733,16 @@ void dp_decide_lane_settings(
 #endif
}
 
-   /*
-* We find the maximum of the requested settings across all lanes
-* and set this maximum for all lanes
-*/
-   maximize_lane_settings(hw_lane_settings);
dp_hw_to_dpcd_lane_settings(lt_settings, hw_lane_settings, 
dpcd_lane_settings);
+
+   if (lt_settings->disallow_per_lane_settings) {
+   /* we find the maximum of the requested settings across all 
lanes*/
+   /* and set this maximum for all lanes*/
+   maximize_lane_settings(hw_lane_settings);
+   if (lt_settings->always_match_dpcd_with_hw_lane_settings)
+   dp_hw_to_dpcd_lane_settings(lt_settings, 
hw_lane_settings, dpcd_lane_settings);
+   }
+
 }
 
 static uint8_t get_nibble_at_index(const uint8_t *buf,
@@ -1455,6 +1459,8 @@ static inline void decide_8b_10b_training_settings(
lt_settings->pattern_for_eq = decide_eq_training_pattern(link, 
link_setting);
lt_settings->enhanced_framing = 1;
lt_settings->should_set_fec_ready = true;
+   lt_settings->disallow_per_lane_settings = true;
+   lt_settings->always_match_dpcd_with_hw_lane_settings = true;
dp_hw_to_dpcd_lane_settings(lt_settings, lt_settings->hw_lane_settings, 
lt_settings->dpcd_lane_settings);
 }
 
@@ -1481,6 +1487,7 @@ static inline void 
decide_128b_132b_training_settings(struct dc_link *link,
link->dpcd_caps.lttpr_caps.phy_repeater_cnt) + 1) * 
2;
lt_settings->lttpr_mode = 
dp_convert_to_count(link->dpcd_caps.lttpr_caps.phy_repeater_cnt) ?
LTTPR_MODE_NON_TRANSPARENT : LTTPR_MODE_TRANSPARENT;
+   lt_settings->disallow_per_lane_settings = true;
dp_hw_to_dpcd_lane_settings(lt_settings,
lt_settings->hw_lane_settings, 
lt_settings->dpcd_lane_settings);
 }
@@ -3593,7 +3600,6 @@ static void dp_test_send_phy_test_pattern(struct dc_link 
*link)
dp_hw_to_dpcd_lane_settings(&link_training_settings,
link_training_settings.hw_lane_settings,
link_training_settings.dpcd_lane_settings);
-   link_training_settings.allow_invalid_msa_timing_param = false;
/*Usage: Measure DP physical lane signal
 * by DP SI test equipment automatically.
 * PHY test pattern request is generated by equipment via HPD interrupt.
diff --git a/drivers/gpu/drm/amd/display/include/link_service_types.h 
b/drivers/gpu/drm/amd/display/include/link_service_types.h
index 3fc868b19f2f..e94bcdb3e134 100644
--- a/drivers/gpu/drm/amd/display/include/link_service_types.h
+++ b/drivers/gpu/drm/amd/display/include/link_service_types.h
@@ -116,9 +116,13 @@ struct link_training_settings {
 #endif
 
bool enhanced_framing;
-   bool allow_invalid_msa_timing_param;
enum lttpr_mode lttpr_mode;
 
+   /* disallow different lanes to have different lane settings */
+   bool disallow_per_lane_settings;
+   /* dpcd lane settings will always use the same hw lane settings
+* even if it doesn't match requested lane adjust */
+   bool always_match_dpcd_with_hw_lane_settings;
 
/*
* training states - parameters that can change in link training
-- 
2.25.1



[PATCH 10/24] drm/amd/display: decouple hw_lane_settings from dpcd_lane_settings

2021-09-24 Thread Anson Jacob
From: Wenjing Liu 

[why]
As DP features expands, we have encountered many situations where we
must configure a different DPCD lane setting from hw lane settings we output.
The change is to decouple hw lane settings from dpcd lane settings to provide
flexibility to configure dpcd and hw individually.

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Wenjing Liu 
---
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  | 154 +++---
 drivers/gpu/drm/amd/display/dc/dc_dp_types.h  |   5 -
 .../amd/display/include/link_service_types.h  |  19 ++-
 3 files changed, 70 insertions(+), 108 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 84eabdca8b24..f13bf8ca93aa 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
@@ -515,10 +515,7 @@ static void dpcd_set_lt_pattern_and_lane_settings(
enum dc_dp_training_pattern pattern,
uint32_t offset)
 {
-   union dpcd_training_lane dpcd_lane[LANE_COUNT_DP_MAX] = { { {0} } };
-
uint32_t dpcd_base_lt_offset;
-
uint8_t dpcd_lt_buffer[5] = {0};
union dpcd_training_pattern dpcd_pattern = { {0} };
uint32_t size_in_bytes;
@@ -554,16 +551,14 @@ static void dpcd_set_lt_pattern_and_lane_settings(
dpcd_pattern.v1_4.TRAINING_PATTERN_SET);
}
 
-   dp_hw_to_dpcd_lane_settings(lt_settings, lt_settings->hw_lane_settings, 
dpcd_lane);
-
/* concatenate everything into one buffer*/
-
-   size_in_bytes = lt_settings->link_settings.lane_count * 
sizeof(dpcd_lane[0]);
+   size_in_bytes = lt_settings->link_settings.lane_count *
+   sizeof(lt_settings->dpcd_lane_settings[0]);
 
 // 0x00103 - 0x00102
memmove(
&dpcd_lt_buffer[DP_TRAINING_LANE0_SET - 
DP_TRAINING_PATTERN_SET],
-   dpcd_lane,
+   lt_settings->dpcd_lane_settings,
size_in_bytes);
 
if (is_repeater(link, offset)) {
@@ -575,7 +570,7 @@ static void dpcd_set_lt_pattern_and_lane_settings(
__func__,
offset,
dpcd_base_lt_offset,
-   dpcd_lane[0].tx_ffe.PRESET_VALUE);
+   
lt_settings->dpcd_lane_settings[0].tx_ffe.PRESET_VALUE);
else if 
(dp_get_link_encoding_format(<_settings->link_settings) ==
DP_8b_10b_ENCODING)
 #endif
@@ -584,10 +579,10 @@ static void dpcd_set_lt_pattern_and_lane_settings(
__func__,
offset,
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,
-   dpcd_lane[0].bits.MAX_PRE_EMPHASIS_REACHED);
+   
lt_settings->dpcd_lane_settings[0].bits.VOLTAGE_SWING_SET,
+   
lt_settings->dpcd_lane_settings[0].bits.PRE_EMPHASIS_SET,
+   
lt_settings->dpcd_lane_settings[0].bits.MAX_SWING_REACHED,
+   
lt_settings->dpcd_lane_settings[0].bits.MAX_PRE_EMPHASIS_REACHED);
} else {
 #if defined(CONFIG_DRM_AMD_DC_DCN)
if (dp_get_link_encoding_format(<_settings->link_settings) ==
@@ -595,17 +590,17 @@ static void dpcd_set_lt_pattern_and_lane_settings(
DC_LOG_HW_LINK_TRAINING("%s:\n 0x%X TX_FFE_PRESET_VALUE 
= %x\n",
__func__,
dpcd_base_lt_offset,
-   dpcd_lane[0].tx_ffe.PRESET_VALUE);
+   
lt_settings->dpcd_lane_settings[0].tx_ffe.PRESET_VALUE);
else if 
(dp_get_link_encoding_format(<_settings->link_settings) ==
DP_8b_10b_ENCODING)
 #endif
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__,
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,
-   dpcd_lane[0].bits.MAX_PRE_EMPHASIS_REACHED);
+   
lt_settings->dpcd_lane_settings[0].bits.VOLTAGE_SWING_SET,
+   
lt_settings->dpcd_lane_settings[0].bits.PRE_EMPHASIS_SET,
+   
lt_settings->dpcd_lane_settings[0].bits.MAX_SWING_REACHED,
+   
lt_settings->dpcd_lane_settings[0].bits.MAX_PRE_EMPHASI

[PATCH 09/24] drm/amd/display: rename lane_settings to hw_lane_settings

2021-09-24 Thread Anson Jacob
From: Wenjing Liu 

[why]
This is one of the major steps to decouple hw lane settings
from dpcd lane settings.

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Wenjing Liu 
---
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c |  8 ++--
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  | 38 +--
 .../drm/amd/display/dc/core/dc_link_hwss.c|  4 +-
 .../drm/amd/display/dc/dce/dce_link_encoder.c |  6 +--
 .../amd/display/dc/dcn10/dcn10_link_encoder.c |  6 +--
 .../amd/display/include/link_service_types.h  | 16 +++-
 6 files changed, 46 insertions(+), 32 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index 814f67d86a3c..7ceb4a14fa2a 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -535,11 +535,11 @@ static ssize_t dp_phy_settings_write(struct file *f, 
const char __user *buf,
 
/* apply phy settings from user */
for (r = 0; r < link_lane_settings.link_settings.lane_count; r++) {
-   link_lane_settings.lane_settings[r].VOLTAGE_SWING =
+   link_lane_settings.hw_lane_settings[r].VOLTAGE_SWING =
(enum dc_voltage_swing) (param[0]);
-   link_lane_settings.lane_settings[r].PRE_EMPHASIS =
+   link_lane_settings.hw_lane_settings[r].PRE_EMPHASIS =
(enum dc_pre_emphasis) (param[1]);
-   link_lane_settings.lane_settings[r].POST_CURSOR2 =
+   link_lane_settings.hw_lane_settings[r].POST_CURSOR2 =
(enum dc_post_cursor2) (param[2]);
}
 
@@ -733,7 +733,7 @@ static ssize_t dp_phy_test_pattern_debugfs_write(struct 
file *f, const char __us
}
 
for (i = 0; i < (unsigned 
int)(link_training_settings.link_settings.lane_count); i++)
-   link_training_settings.lane_settings[i] = 
link->cur_lane_setting[i];
+   link_training_settings.hw_lane_settings[i] = 
link->cur_lane_setting[i];
 
dc_link_set_test_pattern(
link,
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 8e6af080cbe9..84eabdca8b24 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
@@ -554,7 +554,7 @@ static void dpcd_set_lt_pattern_and_lane_settings(
dpcd_pattern.v1_4.TRAINING_PATTERN_SET);
}
 
-   dp_hw_to_dpcd_lane_settings(lt_settings, lt_settings->lane_settings, 
dpcd_lane);
+   dp_hw_to_dpcd_lane_settings(lt_settings, lt_settings->hw_lane_settings, 
dpcd_lane);
 
/* concatenate everything into one buffer*/
 
@@ -926,7 +926,7 @@ enum dc_status dpcd_set_lane_settings(
((DP_REPEATER_CONFIGURATION_AND_STATUS_SIZE) * (offset - 1));
 
dp_hw_to_dpcd_lane_settings(link_training_setting,
-   link_training_setting->lane_settings,
+   link_training_setting->hw_lane_settings,
dpcd_lane);
 
status = core_link_write_dpcd(link,
@@ -1006,7 +1006,7 @@ bool dp_is_max_vs_reached(
for (lane = 0; lane <
(uint32_t)(lt_settings->link_settings.lane_count);
lane++) {
-   if (lt_settings->lane_settings[lane].VOLTAGE_SWING
+   if (lt_settings->hw_lane_settings[lane].VOLTAGE_SWING
== VOLTAGE_SWING_MAX_LEVEL)
return true;
}
@@ -1065,9 +1065,9 @@ static bool perform_post_lt_adj_req_sequence(
for (lane = 0; lane < (uint32_t)(lane_count); lane++) {
 
if (lt_settings->
-   lane_settings[lane].VOLTAGE_SWING !=
+   hw_lane_settings[lane].VOLTAGE_SWING !=
dpcd_lane_adjust[lane].bits.VOLTAGE_SWING_LANE 
||
-   lt_settings->lane_settings[lane].PRE_EMPHASIS !=
+   
lt_settings->hw_lane_settings[lane].PRE_EMPHASIS !=
dpcd_lane_adjust[lane].bits.PRE_EMPHASIS_LANE) {
 
req_drv_setting_changed = true;
@@ -1077,7 +1077,7 @@ static bool perform_post_lt_adj_req_sequence(
 
if (req_drv_setting_changed) {
dp_decide_lane_settings(lt_settings, 
dpcd_lane_adjust,
-   lt_settings->lane_settings, 
dpcd_lane_settings);
+   lt_settings->hw_lane_settings, 
dpcd_lane_settings);
 
dc_link_dp_set_drive_settings(link,
lt_settings);

[PATCH 08/24] drm/amd/display: implement decide lane settings

2021-09-24 Thread Anson Jacob
From: Wenjing Liu 

[why]
Decouple lane settings decision logic all to its own function.
The function takes in lane adjust array and link training settings
and decide what hw lane setting and dpcd lane setting should be used.

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Wenjing Liu 
---
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  | 292 ++
 .../gpu/drm/amd/display/dc/inc/dc_link_dp.h   |  16 +-
 2 files changed, 102 insertions(+), 206 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 f7be58800da6..8e6af080cbe9 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
@@ -105,6 +105,7 @@ static bool decide_fallback_link_setting(
 static struct dc_link_settings get_common_supported_link_settings(
struct dc_link_settings link_setting_a,
struct dc_link_settings link_setting_b);
+static void maximize_lane_settings(struct dc_lane_settings 
lane_settings[LANE_COUNT_DP_MAX]);
 
 static uint32_t get_cr_training_aux_rd_interval(struct dc_link *link,
const struct dc_link_settings *link_settings)
@@ -520,7 +521,6 @@ static void dpcd_set_lt_pattern_and_lane_settings(
 
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;
@@ -711,34 +711,39 @@ void dp_hw_to_dpcd_lane_settings(
}
 }
 
-void dp_update_drive_settings(
-   struct link_training_settings *dest,
-   struct link_training_settings src)
+void dp_decide_lane_settings(
+   const struct link_training_settings *lt_settings,
+   const union lane_adjust ln_adjust[LANE_COUNT_DP_MAX],
+   struct dc_lane_settings hw_lane_settings[LANE_COUNT_DP_MAX],
+   union dpcd_training_lane dpcd_lane_settings[LANE_COUNT_DP_MAX])
 {
uint32_t lane;
-   for (lane = 0; lane < src.link_settings.lane_count; lane++) {
-   if (dest->voltage_swing == NULL)
-   dest->lane_settings[lane].VOLTAGE_SWING = 
src.lane_settings[lane].VOLTAGE_SWING;
-   else
-   dest->lane_settings[lane].VOLTAGE_SWING = 
*dest->voltage_swing;
-
-   if (dest->pre_emphasis == NULL)
-   dest->lane_settings[lane].PRE_EMPHASIS = 
src.lane_settings[lane].PRE_EMPHASIS;
-   else
-   dest->lane_settings[lane].PRE_EMPHASIS = 
*dest->pre_emphasis;
-
-   if (dest->post_cursor2 == NULL)
-   dest->lane_settings[lane].POST_CURSOR2 = 
src.lane_settings[lane].POST_CURSOR2;
-   else
-   dest->lane_settings[lane].POST_CURSOR2 = 
*dest->post_cursor2;
 
+   for (lane = 0; lane < 
(uint32_t)(lt_settings->link_settings.lane_count); lane++) {
+   if (dp_get_link_encoding_format(<_settings->link_settings) ==
+   DP_8b_10b_ENCODING) {
+   hw_lane_settings[lane].VOLTAGE_SWING =
+   (enum 
dc_voltage_swing)(ln_adjust[lane].bits.
+   VOLTAGE_SWING_LANE);
+   hw_lane_settings[lane].PRE_EMPHASIS =
+   (enum 
dc_pre_emphasis)(ln_adjust[lane].bits.
+   PRE_EMPHASIS_LANE);
+   }
 #if defined(CONFIG_DRM_AMD_DC_DCN)
-   if (dest->ffe_preset == NULL)
-   dest->lane_settings[lane].FFE_PRESET = 
src.lane_settings[lane].FFE_PRESET;
-   else
-   dest->lane_settings[lane].FFE_PRESET = 
*dest->ffe_preset;
+   else if 
(dp_get_link_encoding_format(<_settings->link_settings) ==
+   DP_128b_132b_ENCODING) {
+   hw_lane_settings[lane].FFE_PRESET.raw =
+   ln_adjust[lane].tx_ffe.PRESET_VALUE;
+   }
 #endif
}
+
+   /*
+* We find the maximum of the requested settings across all lanes
+* and set this maximum for all lanes
+*/
+   maximize_lane_settings(hw_lane_settings);
+   dp_hw_to_dpcd_lane_settings(lt_settings, hw_lane_settings, 
dpcd_lane_settings);
 }
 
 static uint8_t get_nibble_at_index(const uint8_t *buf,
@@ -768,55 +773,28 @@ static enum dc_pre_emphasis 
get_max_pre_emphasis_for_voltage_swing(
 
 }
 
-static void find_max_drive_settings(
-   const struct link_training_settings *link_training_setting,
-   struct link_training_settings *max_lt_setting)
+static void maximize_l

[PATCH 07/24] drm/amd/display: add function to convert hw to dpcd lane settings

2021-09-24 Thread Anson Jacob
From: Wenjing Liu 

[why]
Unify the code which handles the conversion between hw lane setting
and dpcd lane setting.

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Wenjing Liu 
---
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  | 113 ++
 .../gpu/drm/amd/display/dc/inc/dc_link_dp.h   |   5 +-
 2 files changed, 39 insertions(+), 79 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 750f1ae268c3..f7be58800da6 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
@@ -553,45 +553,8 @@ static void dpcd_set_lt_pattern_and_lane_settings(
dpcd_base_lt_offset,
dpcd_pattern.v1_4.TRAINING_PATTERN_SET);
}
-   /*
-   * DpcdAddress_Lane0Set -> DpcdAddress_Lane3Set
-   */
-   for (lane = 0; lane <
-   (uint32_t)(lt_settings->link_settings.lane_count); lane++) {
 
-#if defined(CONFIG_DRM_AMD_DC_DCN)
-   if (dp_get_link_encoding_format(<_settings->link_settings) ==
-   DP_128b_132b_ENCODING) {
-   dpcd_lane[lane].tx_ffe.PRESET_VALUE =
-   
lt_settings->lane_settings[lane].FFE_PRESET.settings.level;
-   } else if 
(dp_get_link_encoding_format(<_settings->link_settings) ==
-   DP_8b_10b_ENCODING) {
-   dpcd_lane[lane].bits.VOLTAGE_SWING_SET =
-   
(uint8_t)(lt_settings->lane_settings[lane].VOLTAGE_SWING);
-   dpcd_lane[lane].bits.PRE_EMPHASIS_SET =
-   
(uint8_t)(lt_settings->lane_settings[lane].PRE_EMPHASIS);
-
-   dpcd_lane[lane].bits.MAX_SWING_REACHED =
-   
(lt_settings->lane_settings[lane].VOLTAGE_SWING ==
-   VOLTAGE_SWING_MAX_LEVEL 
? 1 : 0);
-   dpcd_lane[lane].bits.MAX_PRE_EMPHASIS_REACHED =
-   
(lt_settings->lane_settings[lane].PRE_EMPHASIS ==
-   PRE_EMPHASIS_MAX_LEVEL 
? 1 : 0);
-   }
-#else
-   dpcd_lane[lane].bits.VOLTAGE_SWING_SET =
-   (uint8_t)(lt_settings->lane_settings[lane].VOLTAGE_SWING);
-   dpcd_lane[lane].bits.PRE_EMPHASIS_SET =
-   (uint8_t)(lt_settings->lane_settings[lane].PRE_EMPHASIS);
-
-   dpcd_lane[lane].bits.MAX_SWING_REACHED =
-   (lt_settings->lane_settings[lane].VOLTAGE_SWING ==
-   VOLTAGE_SWING_MAX_LEVEL ? 1 : 0);
-   dpcd_lane[lane].bits.MAX_PRE_EMPHASIS_REACHED =
-   (lt_settings->lane_settings[lane].PRE_EMPHASIS ==
-   PRE_EMPHASIS_MAX_LEVEL ? 1 : 0);
-#endif
-   }
+   dp_hw_to_dpcd_lane_settings(lt_settings, lt_settings->lane_settings, 
dpcd_lane);
 
/* concatenate everything into one buffer*/
 
@@ -717,6 +680,37 @@ bool dp_is_interlane_aligned(union 
lane_align_status_updated align_status)
return align_status.bits.INTERLANE_ALIGN_DONE == 1;
 }
 
+void dp_hw_to_dpcd_lane_settings(
+   const struct link_training_settings *lt_settings,
+   const struct dc_lane_settings 
hw_lane_settings[LANE_COUNT_DP_MAX],
+   union dpcd_training_lane dpcd_lane_settings[LANE_COUNT_DP_MAX])
+{
+   uint8_t lane = 0;
+
+   for (lane = 0; lane < LANE_COUNT_DP_MAX; lane++) {
+   if (dp_get_link_encoding_format(<_settings->link_settings) ==
+   DP_8b_10b_ENCODING) {
+   dpcd_lane_settings[lane].bits.VOLTAGE_SWING_SET =
+   
(uint8_t)(hw_lane_settings[lane].VOLTAGE_SWING);
+   dpcd_lane_settings[lane].bits.PRE_EMPHASIS_SET =
+   
(uint8_t)(hw_lane_settings[lane].PRE_EMPHASIS);
+   dpcd_lane_settings[lane].bits.MAX_SWING_REACHED =
+   (hw_lane_settings[lane].VOLTAGE_SWING ==
+   VOLTAGE_SWING_MAX_LEVEL 
? 1 : 0);
+   dpcd_lane_settings[lane].bits.MAX_PRE_EMPHASIS_REACHED =
+   (hw_lane_settings[lane].PRE_EMPHASIS ==
+   PRE_EMPHASIS_MAX_LEVEL 
? 1 : 0);
+   }
+#if defined(CONFIG_DRM_AMD_DC_DCN)
+   else if 
(dp_get_link_encoding_format(<_settings->link_settings) ==
+   DP_128b_132b_ENCODING) {
+ 

[PATCH 06/24] drm/amd/display: update cur_lane_setting to an array one for each lane

2021-09-24 Thread Anson Jacob
From: Wenjing Liu 

[why]
To support per lane lane setting adjustment, we need to change cur_lane_setting
to an array one for each lane as the first step.

Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
Signed-off-by: Wenjing Liu 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 8 
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c  | 3 ---
 drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c| 3 +++
 drivers/gpu/drm/amd/display/dc/dc_link.h  | 2 +-
 4 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index f3ada9b6be5a..814f67d86a3c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -379,9 +379,9 @@ static ssize_t dp_phy_settings_read(struct file *f, char 
__user *buf,
return -EINVAL;
 
snprintf(rd_buf, rd_buf_size, "  %d  %d  %d\n",
-   link->cur_lane_setting.VOLTAGE_SWING,
-   link->cur_lane_setting.PRE_EMPHASIS,
-   link->cur_lane_setting.POST_CURSOR2);
+   link->cur_lane_setting[0].VOLTAGE_SWING,
+   link->cur_lane_setting[0].PRE_EMPHASIS,
+   link->cur_lane_setting[0].POST_CURSOR2);
 
while (size) {
if (*pos >= rd_buf_size)
@@ -733,7 +733,7 @@ static ssize_t dp_phy_test_pattern_debugfs_write(struct 
file *f, const char __us
}
 
for (i = 0; i < (unsigned 
int)(link_training_settings.link_settings.lane_count); i++)
-   link_training_settings.lane_settings[i] = 
link->cur_lane_setting;
+   link_training_settings.lane_settings[i] = 
link->cur_lane_setting[i];
 
dc_link_set_test_pattern(
link,
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 6421c896f2a1..750f1ae268c3 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
@@ -676,8 +676,6 @@ static void dpcd_set_lt_pattern_and_lane_settings(
dpcd_base_lt_offset,
dpcd_lt_buffer,
size_in_bytes + sizeof(dpcd_pattern.raw));
-
-   link->cur_lane_setting = lt_settings->lane_settings[0];
 }
 
 bool dp_is_cr_done(enum dc_lane_count ln_count,
@@ -1145,7 +1143,6 @@ enum dc_status dpcd_set_lane_settings(
dpcd_lane[0].bits.MAX_SWING_REACHED,
dpcd_lane[0].bits.MAX_PRE_EMPHASIS_REACHED);
}
-   link->cur_lane_setting = link_training_setting->lane_settings[0];
 
return status;
 }
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c
index cc4b28e94727..368e834c6809 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_hwss.c
@@ -372,6 +372,9 @@ void dp_set_hw_lane_settings(
 #else
encoder->funcs->dp_set_lane_settings(encoder, link_settings);
 #endif
+   memmove(link->cur_lane_setting,
+   link_settings->lane_settings,
+   sizeof(link->cur_lane_setting));
 }
 
 void dp_set_hw_test_pattern(
diff --git a/drivers/gpu/drm/amd/display/dc/dc_link.h 
b/drivers/gpu/drm/amd/display/dc/dc_link.h
index 56340a176554..a73d64b1fd33 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_link.h
+++ b/drivers/gpu/drm/amd/display/dc/dc_link.h
@@ -121,7 +121,7 @@ struct dc_link {
struct dc_link_settings reported_link_cap;
struct dc_link_settings verified_link_cap;
struct dc_link_settings cur_link_settings;
-   struct dc_lane_settings cur_lane_setting;
+   struct dc_lane_settings cur_lane_setting[LANE_COUNT_DP_MAX];
struct dc_link_settings preferred_link_setting;
struct dc_link_training_overrides preferred_training_settings;
struct dp_audio_test_data audio_test_data;
-- 
2.25.1



[PATCH 04/24] drm/amd/display: add vsync notify to dmub for abm pause

2021-09-24 Thread Anson Jacob
From: Eric Yang 

[Why]
To prevent unnecessary wake up of DMCUB when ABM is enabled without PSR
enabled, driver will notify DMCUB to stop ABM's vertical interrupts
if vsync is disabled and steady state is reached.

[How]
Send inbox message to notify ABM pause based on vsync on/off

Reviewed-by: Nicholas Kazlauskas 
Acked-by: Anson Jacob 
Signed-off-by: Eric Yang 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c  | 54 +++
 drivers/gpu/drm/amd/display/dc/dc.h   |  2 +
 drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c | 21 
 drivers/gpu/drm/amd/display/dc/inc/hw/abm.h   |  1 +
 .../gpu/drm/amd/display/dmub/inc/dmub_cmd.h   | 54 +++
 5 files changed, 132 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 331a7517176b..644005846433 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -3536,3 +3536,57 @@ void dc_disable_accelerated_mode(struct dc *dc)
 {
bios_set_scratch_acc_mode_change(dc->ctx->dc_bios, 0);
 }
+
+
+/**
+ *
+ *  dc_notify_vsync_int_state() - notifies vsync enable/disable state
+ *  @dc: dc structure
+ * @stream: stream where vsync int state changed
+ * @enable: whether vsync is enabled or disabled
+ *
+ *  Called when vsync is enabled/disabled
+ * Will notify DMUB to start/stop ABM interrupts after steady state is 
reached
+ *
+ *
+ */
+void dc_notify_vsync_int_state(struct dc *dc, struct dc_stream_state *stream, 
bool enable)
+{
+   int i;
+   int edp_num;
+   struct pipe_ctx *pipe = NULL;
+   struct dc_link *link = stream->sink->link;
+   struct dc_link *edp_links[MAX_NUM_EDP];
+
+
+   if (link->psr_settings.psr_feature_enabled)
+   return;
+
+   /*find primary pipe associated with stream*/
+   for (i = 0; i < MAX_PIPES; i++) {
+   pipe = &dc->current_state->res_ctx.pipe_ctx[i];
+
+   if (pipe->stream == stream && pipe->stream_res.tg)
+   break;
+   }
+
+   if (i == MAX_PIPES) {
+   ASSERT(0);
+   return;
+   }
+
+   get_edp_links(dc, edp_links, &edp_num);
+
+   /* Determine panel inst */
+   for (i = 0; i < edp_num; i++) {
+   if (edp_links[i] == link)
+   break;
+   }
+
+   if (i == edp_num) {
+   return;
+   }
+
+   if (pipe->stream_res.abm && pipe->stream_res.abm->funcs->set_abm_pause)
+   
pipe->stream_res.abm->funcs->set_abm_pause(pipe->stream_res.abm, !enable, i, 
pipe->stream_res.tg->inst);
+}
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index e5dcbee6e672..b194a2727bd8 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -1313,6 +1313,8 @@ void dc_interrupt_ack(struct dc *dc, enum dc_irq_source 
src);
 enum dc_irq_source dc_get_hpd_irq_source_at_index(
struct dc *dc, uint32_t link_index);
 
+void dc_notify_vsync_int_state(struct dc *dc, struct dc_stream_state *stream, 
bool enable);
+
 
/***
  * Power Interfaces
  
**/
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c 
b/drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c
index 54a1408c8015..fb0dec4ed3a6 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c
@@ -203,12 +203,33 @@ static bool dmub_abm_init_config(struct abm *abm,
return true;
 }
 
+static bool dmub_abm_set_pause(struct abm *abm, bool pause, unsigned int 
panel_inst, unsigned int stream_inst)
+{
+   union dmub_rb_cmd cmd;
+   struct dc_context *dc = abm->ctx;
+   uint8_t panel_mask = 0x01 << panel_inst;
+
+   memset(&cmd, 0, sizeof(cmd));
+   cmd.abm_pause.header.type = DMUB_CMD__ABM;
+   cmd.abm_pause.header.sub_type = DMUB_CMD__ABM_PAUSE;
+   cmd.abm_pause.abm_pause_data.enable = pause;
+   cmd.abm_pause.abm_pause_data.panel_mask = panel_mask;
+   cmd.abm_set_level.header.payload_bytes = sizeof(struct 
dmub_cmd_abm_pause_data);
+
+   dc_dmub_srv_cmd_queue(dc->dmub_srv, &cmd);
+   dc_dmub_srv_cmd_execute(dc->dmub_srv);
+   dc_dmub_srv_wait_idle(dc->dmub_srv);
+
+   return true;
+}
+
 static const struct abm_funcs abm_funcs = {
.abm_init = dmub_abm_init,
.set_abm_level = dmub_abm_set_level,
.get_current_backlight = dmub_abm_get_current_backlight,
.get_target_backlight = dmub_abm_get_target_backlight,
.init_abm_c

[PATCH 05/24] drm/amd/display: Add debug support to override the Minimum DRAM Clock

2021-09-24 Thread Anson Jacob
From: David Galiffi 

[Why]
Requested feature to assist with Thermal, Acoustic, Power, and
Performance tuning.

[How]
Add a debug field that will override calculated minimum DRAM clock,
if the debug value is larger than the calculate value.

Reviewed-by: Alvin Lee 
Acked-by: Anson Jacob 
Signed-off-by: David Galiffi 
---
 drivers/gpu/drm/amd/display/dc/dc.h   | 1 +
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c | 4 
 2 files changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index b194a2727bd8..a46c663ed8c5 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -565,6 +565,7 @@ struct dc_debug_options {
enum wm_report_mode pplib_wm_report_mode;
unsigned int min_disp_clk_khz;
unsigned int min_dpp_clk_khz;
+   unsigned int min_dram_clk_khz;
int sr_exit_time_dpm0_ns;
int sr_enter_plus_exit_time_dpm0_ns;
int sr_exit_time_ns;
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 3c388afa06dc..aeb868ace31c 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_resource.c
@@ -3117,6 +3117,10 @@ void dcn20_calculate_dlg_params(
context->bw_ctx.bw.dcn.clk.dcfclk_khz = context->bw_ctx.dml.vba.DCFCLK 
* 1000;
context->bw_ctx.bw.dcn.clk.socclk_khz = context->bw_ctx.dml.vba.SOCCLK 
* 1000;
context->bw_ctx.bw.dcn.clk.dramclk_khz = 
context->bw_ctx.dml.vba.DRAMSpeed * 1000 / 16;
+
+   if (dc->debug.min_dram_clk_khz > context->bw_ctx.bw.dcn.clk.dramclk_khz)
+   context->bw_ctx.bw.dcn.clk.dramclk_khz = 
dc->debug.min_dram_clk_khz;
+
context->bw_ctx.bw.dcn.clk.dcfclk_deep_sleep_khz = 
context->bw_ctx.dml.vba.DCFCLKDeepSleep * 1000;
context->bw_ctx.bw.dcn.clk.fclk_khz = 
context->bw_ctx.dml.vba.FabricClock * 1000;
context->bw_ctx.bw.dcn.clk.p_state_change_support =
-- 
2.25.1



[PATCH 03/24] drm/amd/display: Don't enable AFMT for DP audio stream

2021-09-24 Thread Anson Jacob
From: Michael Strauss 

[WHY]
AFMT is unused for DP audio, so powering it on for DP is unnecessary.

[HOW]
APG block should be powered down instead, however HW defaults to shutdown
state when not enabled so no further work is required.

Reviewed-by: Wenjing Liu 
Acked-by: Anson Jacob 
Signed-off-by: Michael Strauss 
---
 drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.c  | 5 -
 .../gpu/drm/amd/display/dc/dcn30/dcn30_dio_stream_encoder.c  | 2 --
 2 files changed, 7 deletions(-)

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 a97bdaa54f73..687c3c6881a9 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
@@ -1402,11 +1402,6 @@ static void enc1_se_disable_dp_audio(
struct dcn10_stream_encoder *enc1 = DCN10STRENC_FROM_STRENC(enc);
uint32_t value = 0;
 
-#if defined(CONFIG_DRM_AMD_DC_DCN)
-   if (enc->afmt && enc->afmt->funcs->afmt_powerdown)
-   enc->afmt->funcs->afmt_powerdown(enc->afmt);
-#endif
-
/* Disable Audio packets */
REG_UPDATE_5(DP_SEC_CNTL,
DP_SEC_ASP_ENABLE, 0,
diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dio_stream_encoder.c 
b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dio_stream_encoder.c
index 3ea6dacec80c..ebd9c35c914f 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dio_stream_encoder.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dio_stream_encoder.c
@@ -710,8 +710,6 @@ static void enc3_se_setup_dp_audio(
 static void enc3_se_dp_audio_enable(
struct stream_encoder *enc)
 {
-   if (enc->afmt->funcs->afmt_poweron)
-   enc->afmt->funcs->afmt_poweron(enc->afmt);
enc1_se_enable_audio_clock(enc, true);
enc3_se_setup_dp_audio(enc);
enc1_se_enable_dp_audio(enc);
-- 
2.25.1



[PATCH 02/24] drm/amd/display: [FW Promotion] Release 0.0.85

2021-09-24 Thread Anson Jacob
From: Anthony Koo 

Acked-by: Anson Jacob 
Signed-off-by: Anthony Koo 
---
 drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h 
b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
index 359f091e37f1..03110f59b50d 100644
--- a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
+++ b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
@@ -47,10 +47,10 @@
 
 /* Firmware versioning. */
 #ifdef DMUB_EXPOSE_VERSION
-#define DMUB_FW_VERSION_GIT_HASH 0x607c9623
+#define DMUB_FW_VERSION_GIT_HASH 0xeb0940cc
 #define DMUB_FW_VERSION_MAJOR 0
 #define DMUB_FW_VERSION_MINOR 0
-#define DMUB_FW_VERSION_REVISION 84
+#define DMUB_FW_VERSION_REVISION 85
 #define DMUB_FW_VERSION_TEST 0
 #define DMUB_FW_VERSION_VBIOS 0
 #define DMUB_FW_VERSION_HOTFIX 0
-- 
2.25.1



[PATCH 01/24] drm/amd/display: use correct vpg instance for 128b/132b encoding

2021-09-24 Thread Anson Jacob
From: Wenjing Liu 

[why]
128b/132b uses the vpg instance assigned to hpo dp stream encoder.
The current vpg used is assigned to dio stream encoder.
This is incorrect and cause display black screen because the
actual vpg is powered off.

Reviewed-by: Michael Strauss 
Acked-by: Anson Jacob 
Signed-off-by: Wenjing Liu 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 6 ++
 1 file changed, 6 insertions(+)

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 2bd38d19a447..cab7993b4cc5 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -3608,6 +3608,9 @@ void core_link_enable_stream(
 #if defined(CONFIG_DRM_AMD_DC_DCN)
enum otg_out_mux_dest otg_out_dest = OUT_MUX_DIO;
struct vpg *vpg = pipe_ctx->stream_res.stream_enc->vpg;
+
+   if (is_dp_128b_132b_signal(pipe_ctx))
+   vpg = pipe_ctx->stream_res.hpo_dp_stream_enc->vpg;
 #endif
DC_LOGGER_INIT(pipe_ctx->stream->ctx->logger);
 
@@ -3853,6 +3856,9 @@ void core_link_disable_stream(struct pipe_ctx *pipe_ctx)
struct dc_link *link = stream->sink->link;
 #if defined(CONFIG_DRM_AMD_DC_DCN)
struct vpg *vpg = pipe_ctx->stream_res.stream_enc->vpg;
+
+   if (is_dp_128b_132b_signal(pipe_ctx))
+   vpg = pipe_ctx->stream_res.hpo_dp_stream_enc->vpg;
 #endif
 
if (!IS_DIAG_DC(dc->ctx->dce_environment) &&
-- 
2.25.1



[PATCH 00/24] DC Patches Sep 24, 2021

2021-09-24 Thread Anson Jacob
This DC patchset brings improvements in multiple areas. In summary, we
have:
- Fixes to backlight, LUT, PPS, MST
- Use correct vpg for 128b/132b encoding
- Improved logging for VCP
- Replace referral of dal with dc

Anthony Koo (2):
  drm/amd/display: [FW Promotion] Release 0.0.85
  drm/amd/display: [FW Promotion] Release 0.0.86

Aric Cyr (1):
  drm/amd/display: 3.2.155

Charlene Liu (1):
  drm/amd/display: Pass PCI deviceid into DC

David Galiffi (1):
  drm/amd/display: Add debug support to override the Minimum DRAM Clock

Eric Yang (1):
  drm/amd/display: add vsync notify to dmub for abm pause

George Shen (2):
  drm/amd/display: Handle Y carry-over in VCP X.Y calculation
  drm/amd/display: Update VCP X.Y logging to improve usefulness

Ilya (1):
  drm/amd/display: Add PPS immediate update flag for DCN2

Jimmy Kizito (1):
  drm/amd/display: Fix MST link encoder availability check.

Josip Pavic (1):
  drm/amd/display: initialize backlight_ramping_override to false

Meenakshikumar Somasundaram (1):
  drm/amd/display: Fix for link encoder access for MST.

Michael Strauss (2):
  drm/amd/display: Don't enable AFMT for DP audio stream
  drm/amd/display: Defer LUT memory powerdown until LUT bypass latches

Oliver Logush (1):
  drm/amd/display: Add an extra check for dcn10 OPTC data format

Qingqing Zhuo (1):
  drm/amd/display: Replace referral of dal with dc

Wenjing Liu (8):
  drm/amd/display: use correct vpg instance for 128b/132b encoding
  drm/amd/display: update cur_lane_setting to an array one for each lane
  drm/amd/display: add function to convert hw to dpcd lane settings
  drm/amd/display: implement decide lane settings
  drm/amd/display: rename lane_settings to hw_lane_settings
  drm/amd/display: decouple hw_lane_settings from dpcd_lane_settings
  drm/amd/display: add two lane settings training options
  drm/amd/display: make verified link cap not exceeding max link cap

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |   2 +
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c |  14 +-
 .../display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c  |   2 +-
 .../amd/display/dc/clk_mgr/dcn21/rn_clk_mgr.c |   2 +-
 drivers/gpu/drm/amd/display/dc/core/dc.c  |  73 +++
 drivers/gpu/drm/amd/display/dc/core/dc_link.c |  73 ++-
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  | 591 +++---
 .../drm/amd/display/dc/core/dc_link_enc_cfg.c |  23 +-
 .../drm/amd/display/dc/core/dc_link_hwss.c|   5 +-
 drivers/gpu/drm/amd/display/dc/dc.h   |   5 +-
 drivers/gpu/drm/amd/display/dc/dc_dp_types.h  |   5 -
 drivers/gpu/drm/amd/display/dc/dc_link.h  |   2 +-
 .../drm/amd/display/dc/dce/dce_link_encoder.c |   6 +-
 drivers/gpu/drm/amd/display/dc/dce/dmub_abm.c |  21 +
 .../gpu/drm/amd/display/dc/dcn10/dcn10_ipp.h  |   6 -
 .../amd/display/dc/dcn10/dcn10_link_encoder.c |   6 +-
 .../gpu/drm/amd/display/dc/dcn10/dcn10_optc.c |   2 +-
 .../display/dc/dcn10/dcn10_stream_encoder.c   |  11 +-
 .../gpu/drm/amd/display/dc/dcn20/dcn20_optc.c |   5 +
 .../drm/amd/display/dc/dcn20/dcn20_resource.c |   4 +
 .../display/dc/dcn20/dcn20_stream_encoder.c   |   9 +-
 .../dc/dcn30/dcn30_dio_stream_encoder.c   |   2 -
 .../gpu/drm/amd/display/dc/dcn30/dcn30_dpp.c  |  59 +-
 .../drm/amd/display/dc/dcn31/dcn31_resource.c |   2 +-
 .../gpu/drm/amd/display/dc/inc/dc_link_dp.h   |  21 +-
 drivers/gpu/drm/amd/display/dc/inc/hw/abm.h   |   1 +
 drivers/gpu/drm/amd/display/dc/inc/hw/dpp.h   |  12 +
 drivers/gpu/drm/amd/display/dc/inc/hw/dwb.h   |   1 -
 .../display/dc/irq/dcn20/irq_service_dcn20.c  |   2 +-
 .../display/dc/irq/dcn20/irq_service_dcn20.h  |   2 +-
 .../display/dc/irq/dcn21/irq_service_dcn21.c  |   2 +-
 .../display/dc/irq/dcn21/irq_service_dcn21.h  |   2 +-
 .../gpu/drm/amd/display/dmub/inc/dmub_cmd.h   |  58 +-
 .../amd/display/include/link_service_types.h  |  29 +-
 34 files changed, 583 insertions(+), 477 deletions(-)

-- 
2.25.1



Re: [3/4] drm/amd/display: Fix rest of pass-by-value structs in DML

2021-09-15 Thread Anson Jacob

Hi Harry,

This patch fixes the following CID's. Thanks.

Addresses-Coverity-ID: 1424031: ("Big parameter passed by value")
Addresses-Coverity-ID: 1424055: ("Big parameter passed by value")
Addresses-Coverity-ID: 1424072: ("Big parameter passed by value")
Addresses-Coverity-ID: 1423779: ("Big parameter passed by value")

-- Anson


Re: [2/4] drm/amd/display: Pass all structs in display_rq_dlg_helpers by pointer

2021-09-15 Thread Anson Jacob

Hi Harry,

This patch fixes the following CID's. Thanks.

Addresses-Coverity-ID: 1423868: ("Big parameter passed by value")
Addresses-Coverity-ID: 1423870: ("Big parameter passed by value")

-- Anson


Re: [1/4] drm/amd/display: Pass display_pipe_params_st as const in DML

2021-09-15 Thread Anson Jacob

Hi Harry,

This patch fixes the following CID's. Thanks.

Addresses-Coverity-ID: 1424031: ("Big parameter passed by value")
Addresses-Coverity-ID: 1423970: ("Big parameter passed by value")
Addresses-Coverity-ID: 1423941: ("Big parameter passed by value")
Addresses-Coverity-ID: 1451742: ("Big parameter passed by value")
Addresses-Coverity-ID: 1451887: ("Big parameter passed by value")
Addresses-Coverity-ID: 1454146: ("Big parameter passed by value")
Addresses-Coverity-ID: 1454152: ("Big parameter passed by value")
Addresses-Coverity-ID: 1454413: ("Big parameter passed by value")
Addresses-Coverity-ID: 1466144: ("Big parameter passed by value")
Addresses-Coverity-ID: 1487237: ("Big parameter passed by value")

-- Anson


Re: drm/amd/display: move FPU associated DSC code to DML folder

2021-09-14 Thread Anson Jacob

Tested on nixeus 4k144hz DSC capable display on

RX5700XT (NAVI10 0x1002:0x731F 0x1DA2:0xE410 0xC1)

on ubuntu 20.04. Display lightsup at 4k144hz with DSC engine on.

Tested-by: Anson Jacob 

On 2021-09-07 10:32 a.m., Qingqing Zhuo wrote:

As part of the FPU isolation work documented in
https://patchwork.freedesktop.org/series/93042/, isolate
code that uses FPU in DSC to DML, where all FPU code
should locate.

This change does not refactor any fuctions but move code
around.

Cc: Anson Jacob 
Cc: Christian König 
Cc: Hersen Wu 
Cc: Harry Wentland 
Cc: Rodrigo Siqueira 
Signed-off-by: Qingqing Zhuo 
---
  drivers/gpu/drm/amd/display/dc/dml/Makefile   |   3 +
  .../amd/display/dc/{ => dml}/dsc/qp_tables.h  |   0
  .../drm/amd/display/dc/dml/dsc/rc_calc_fpu.c  | 287 ++
  .../drm/amd/display/dc/dml/dsc/rc_calc_fpu.h  |  89 ++
  drivers/gpu/drm/amd/display/dc/dsc/Makefile   |   8 -
  drivers/gpu/drm/amd/display/dc/dsc/rc_calc.c  | 257 
  drivers/gpu/drm/amd/display/dc/dsc/rc_calc.h  |  50 +--
  .../gpu/drm/amd/display/dc/dsc/rc_calc_dpi.c  |   1 -
  8 files changed, 380 insertions(+), 315 deletions(-)
  rename drivers/gpu/drm/amd/display/dc/{ => dml}/dsc/qp_tables.h (100%)
  create mode 100644 drivers/gpu/drm/amd/display/dc/dml/dsc/rc_calc_fpu.c
  create mode 100644 drivers/gpu/drm/amd/display/dc/dml/dsc/rc_calc_fpu.h

diff --git a/drivers/gpu/drm/amd/display/dc/dml/Makefile 
b/drivers/gpu/drm/amd/display/dc/dml/Makefile
index 56055df2e8d2..9009b92490f3 100644
--- a/drivers/gpu/drm/amd/display/dc/dml/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/dml/Makefile
@@ -70,6 +70,7 @@ CFLAGS_$(AMDDALPATH)/dc/dml/dcn30/display_mode_vba_30.o := 
$(dml_ccflags) $(fram
  CFLAGS_$(AMDDALPATH)/dc/dml/dcn30/display_rq_dlg_calc_30.o := $(dml_ccflags)
  CFLAGS_$(AMDDALPATH)/dc/dml/dcn31/display_mode_vba_31.o := $(dml_ccflags) 
$(frame_warn_flag)
  CFLAGS_$(AMDDALPATH)/dc/dml/dcn31/display_rq_dlg_calc_31.o := $(dml_ccflags)
+CFLAGS_$(AMDDALPATH)/dc/dml/dsc/rc_calc_fpu.o := $(dml_ccflags)
  CFLAGS_$(AMDDALPATH)/dc/dml/display_mode_lib.o := $(dml_ccflags)
  CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_mode_vba.o := $(dml_rcflags)
  CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn2x/dcn2x.o := $(dml_rcflags)
@@ -84,6 +85,7 @@ 
CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn30/display_rq_dlg_calc_30.o := $(dml_rcfla
  CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn31/display_mode_vba_31.o := 
$(dml_rcflags)
  CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dcn31/display_rq_dlg_calc_31.o := 
$(dml_rcflags)
  CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/display_mode_lib.o := $(dml_rcflags)
+CFLAGS_REMOVE_$(AMDDALPATH)/dc/dml/dsc/rc_calc_fpu.o  := $(dml_rcflags)
  endif
  CFLAGS_$(AMDDALPATH)/dc/dml/dml1_display_rq_dlg_calc.o := $(dml_ccflags)
  CFLAGS_$(AMDDALPATH)/dc/dml/display_rq_dlg_helpers.o := $(dml_ccflags)
@@ -99,6 +101,7 @@ DML += dcn20/display_rq_dlg_calc_20v2.o 
dcn20/display_mode_vba_20v2.o
  DML += dcn21/display_rq_dlg_calc_21.o dcn21/display_mode_vba_21.o
  DML += dcn30/display_mode_vba_30.o dcn30/display_rq_dlg_calc_30.o
  DML += dcn31/display_mode_vba_31.o dcn31/display_rq_dlg_calc_31.o
+DML += dsc/rc_calc_fpu.o
  endif
  
  AMD_DAL_DML = $(addprefix $(AMDDALPATH)/dc/dml/,$(DML))

diff --git a/drivers/gpu/drm/amd/display/dc/dsc/qp_tables.h 
b/drivers/gpu/drm/amd/display/dc/dml/dsc/qp_tables.h
similarity index 100%
rename from drivers/gpu/drm/amd/display/dc/dsc/qp_tables.h
rename to drivers/gpu/drm/amd/display/dc/dml/dsc/qp_tables.h
diff --git a/drivers/gpu/drm/amd/display/dc/dml/dsc/rc_calc_fpu.c 
b/drivers/gpu/drm/amd/display/dc/dml/dsc/rc_calc_fpu.c
new file mode 100644
index ..0436fc64948f
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/dml/dsc/rc_calc_fpu.c
@@ -0,0 +1,287 @@
+/*
+ * Copyright 2021 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 "rc_calc_fpu.h"
+
+#include "q

[PATCH] drm/amdgpu: Remove ununsed variable from amdgpu_ib_pool_init

2021-09-13 Thread Anson Jacob
Remove unused variable 'size'.

Signed-off-by: Anson Jacob 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
index 9274f32c3661..bc1297dcdf97 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ib.c
@@ -300,7 +300,6 @@ int amdgpu_ib_schedule(struct amdgpu_ring *ring, unsigned 
num_ibs,
  */
 int amdgpu_ib_pool_init(struct amdgpu_device *adev)
 {
-   unsigned size;
int r, i;
 
if (adev->ib_pool_ready)
-- 
2.25.1



[PATCH] drm/amdkfd: Add dummy function for kgd2kfd_resume_iommu

2021-09-13 Thread Anson Jacob
Add dummy function when CONFIG_HSA_AMD is not enabled.

Fixes: 433d2448d57c ("drm/amdkfd: separate kfd_iommu_resume from kfd_resume")
Signed-off-by: Anson Jacob 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
index b40ed399d2cf..3bc52b2c604f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h
@@ -367,6 +367,11 @@ static inline void kgd2kfd_suspend(struct kfd_dev *kfd, 
bool run_pm)
 {
 }
 
+static int __maybe_unused kgd2kfd_resume_iommu(struct kfd_dev *kfd)
+{
+   return 0;
+}
+
 static inline int kgd2kfd_resume(struct kfd_dev *kfd, bool run_pm)
 {
return 0;
-- 
2.25.1



[PATCH] drm/amd/display: dc_assert_fp_enabled assert only if FPU is not enabled

2021-09-09 Thread Anson Jacob
Assert only when FPU is not enabled.

Fixes: e549f77c1965 ("drm/amd/display: Add DC_FP helper to check FPU state")
Signed-off-by: Anson Jacob 
Cc: Christian König 
Cc: Hersen Wu 
Cc: Harry Wentland 
Cc: Rodrigo Siqueira 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c
index c9f47d167472..b1bf80da3a55 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_fpu.c
@@ -62,7 +62,7 @@ inline void dc_assert_fp_enabled(void)
depth = *pcpu;
put_cpu_ptr(&fpu_recursion_depth);
 
-   ASSERT(depth > 1);
+   ASSERT(depth >= 1);
 }
 
 /**
-- 
2.25.1



[PATCH 13/13] drm/amd/display: use GFP_ATOMIC in amdgpu_dm_irq_schedule_work

2021-08-06 Thread Anson Jacob
Replace GFP_KERNEL with GFP_ATOMIC as amdgpu_dm_irq_schedule_work
can't sleep.

BUG: sleeping function called from invalid context at 
include/linux/sched/mm.h:196
in_atomic(): 1, irqs_disabled(): 1, non_block: 0, pid: 253, name: kworker/6:1H
CPU: 6 PID: 253 Comm: kworker/6:1H Tainted: GW  OE 
5.11.0-promotion_2021_06_07-18_36_28_prelim_revert_retrain #8
Hardware name: System manufacturer System Product Name/PRIME X570-PRO, BIOS 
3405 02/01/2021
Workqueue: events_highpri dm_irq_work_func [amdgpu]
Call Trace:
 
 dump_stack+0x5e/0x74
 ___might_sleep.cold+0x87/0x98
 __might_sleep+0x4b/0x80
 kmem_cache_alloc_trace+0x390/0x4f0
 amdgpu_dm_irq_handler+0x171/0x230 [amdgpu]
 amdgpu_irq_dispatch+0xc0/0x1e0 [amdgpu]
 amdgpu_ih_process+0x81/0x100 [amdgpu]
 amdgpu_irq_handler+0x26/0xa0 [amdgpu]
 __handle_irq_event_percpu+0x49/0x190
 ? __hrtimer_get_next_event+0x4d/0x80
 handle_irq_event_percpu+0x33/0x80
 handle_irq_event+0x33/0x60
 handle_edge_irq+0x82/0x190
 asm_call_irq_on_stack+0x12/0x20
 
 common_interrupt+0xbb/0x140
 asm_common_interrupt+0x1e/0x40
RIP: 0010:amdgpu_device_rreg.part.0+0x44/0xf0 [amdgpu]
Code: 53 48 89 fb 4c 3b af c8 08 00 00 73 6d 83 e2 02 75 0d f6 87 40 62 01 00 
10 0f 85 83 00 00 00 4c 03 ab d0 08 00 00 45 8b 6d 00 <8b> 05 3e b6 52 00 85 c0 
7e 62 48 8b 43 08 0f b7 70 3e 65 8b 05 e3
RSP: 0018:ae7740fff9e8 EFLAGS: 0286
RAX: c05ee610 RBX: 8aaf8f62 RCX: 0006
RDX:  RSI: 5430 RDI: 8aaf8f62
RBP: ae7740fffa08 R08: 0001 R09: 000a
R10: 0001 R11: 0001 R12: 5430
R13: 7100 R14: 0001 R15: 5430
 ? amdgpu_cgs_write_register+0x20/0x20 [amdgpu]
 amdgpu_device_rreg+0x17/0x20 [amdgpu]
 amdgpu_cgs_read_register+0x14/0x20 [amdgpu]
 dm_read_reg_func+0x38/0xb0 [amdgpu]
 generic_reg_wait+0x80/0x160 [amdgpu]
 dce_aux_transfer_raw+0x324/0x7c0 [amdgpu]
 dc_link_aux_transfer_raw+0x43/0x50 [amdgpu]
 dm_dp_aux_transfer+0x87/0x110 [amdgpu]
 drm_dp_dpcd_access+0x72/0x110 [drm_kms_helper]
 drm_dp_dpcd_read+0xb7/0xf0 [drm_kms_helper]
 drm_dp_get_one_sb_msg+0x349/0x480 [drm_kms_helper]
 drm_dp_mst_hpd_irq+0xc5/0xe40 [drm_kms_helper]
 ? drm_dp_mst_hpd_irq+0xc5/0xe40 [drm_kms_helper]
 dm_handle_hpd_rx_irq+0x184/0x1a0 [amdgpu]
 ? dm_handle_hpd_rx_irq+0x184/0x1a0 [amdgpu]
 handle_hpd_rx_irq+0x195/0x240 [amdgpu]
 ? __switch_to_asm+0x42/0x70
 ? __switch_to+0x131/0x450
 dm_irq_work_func+0x19/0x20 [amdgpu]
 process_one_work+0x209/0x400
 worker_thread+0x4d/0x3e0
 ? cancel_delayed_work+0xa0/0xa0
 kthread+0x124/0x160
 ? kthread_park+0x90/0x90
 ret_from_fork+0x22/0x30

Reviewed-by: Aurabindo Jayamohanan Pillai 
Acked-by: Anson Jacob 
Signed-off-by: Anson Jacob 
Cc: sta...@vger.kernel.org
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
index 40f617bbb86f..4aba0e8c84f8 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c
@@ -584,7 +584,7 @@ static void amdgpu_dm_irq_schedule_work(struct 
amdgpu_device *adev,
handler_data = container_of(handler_list->next, struct 
amdgpu_dm_irq_handler_data, list);
 
/*allocate a new amdgpu_dm_irq_handler_data*/
-   handler_data_add = kzalloc(sizeof(*handler_data), GFP_KERNEL);
+   handler_data_add = kzalloc(sizeof(*handler_data), GFP_ATOMIC);
if (!handler_data_add) {
DRM_ERROR("DM_IRQ: failed to allocate irq handler!\n");
return;
-- 
2.25.1



[PATCH 11/13] drm/amd/display: Clear GPINT after DMCUB has reset

2021-08-06 Thread Anson Jacob
From: Nicholas Kazlauskas 

[Why]
Otherwise we can end up processing whatever was left in the register
if the DMCUB was previously reset.

If DMCUB gets force reset too early from another client then we might
not have even acked the disable yet - causing DMCUB instantly shutdown
if the command was 1002.

[How]
Move the GPINT clear outside of the reset loop and do it unconditionally
after the DMCUB has been properly reset.

Reviewed-by: Roy Chan 
Reviewed-by: Eric Yang 
Acked-by: Anson Jacob 
Signed-off-by: Nicholas Kazlauskas 
---
 drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c 
b/drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c
index 6820012e3b6e..19141bf84a8c 100644
--- a/drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c
+++ b/drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c
@@ -115,10 +115,6 @@ void dmub_dcn31_reset(struct dmub_srv *dmub)
break;
}
 
-   /* Clear the GPINT command manually so we don't reset again. */
-   cmd.all = 0;
-   dmub->hw_funcs.set_gpint(dmub, cmd);
-
/* Force reset in case we timed out, DMCUB is likely hung. */
}
 
@@ -130,6 +126,10 @@ void dmub_dcn31_reset(struct dmub_srv *dmub)
REG_WRITE(DMCUB_OUTBOX1_RPTR, 0);
REG_WRITE(DMCUB_OUTBOX1_WPTR, 0);
REG_WRITE(DMCUB_SCRATCH0, 0);
+
+   /* Clear the GPINT command manually so we don't send anything during 
boot. */
+   cmd.all = 0;
+   dmub->hw_funcs.set_gpint(dmub, cmd);
 }
 
 void dmub_dcn31_reset_release(struct dmub_srv *dmub)
-- 
2.25.1



[PATCH 12/13] drm/amd/display: Increase timeout threshold for DMCUB reset

2021-08-06 Thread Anson Jacob
From: Nicholas Kazlauskas 

[Why]
If we're backdoor loading the DMCUB performs more work than just
the PHY reset so we can end up resetting before the cleanup has fully
finished.

[How]
Increase timeout, add udelay between spins to guarantee a minimum.

Acked-by: Anson Jacob 
Signed-off-by: Nicholas Kazlauskas 
---
 drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c 
b/drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c
index 19141bf84a8c..fc667cb17eb0 100644
--- a/drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c
+++ b/drivers/gpu/drm/amd/display/dmub/src/dmub_dcn31.c
@@ -83,7 +83,7 @@ static inline void dmub_dcn31_translate_addr(const union 
dmub_addr *addr_in,
 void dmub_dcn31_reset(struct dmub_srv *dmub)
 {
union dmub_gpint_data_register cmd;
-   const uint32_t timeout = 30;
+   const uint32_t timeout = 100;
uint32_t in_reset, scratch, i;
 
REG_GET(DMCUB_CNTL2, DMCUB_SOFT_RESET, &in_reset);
@@ -98,21 +98,21 @@ void dmub_dcn31_reset(struct dmub_srv *dmub)
/**
 * Timeout covers both the ACK and the wait
 * for remaining work to finish.
-*
-* This is mostly bound by the PHY disable sequence.
-* Each register check will be greater than 1us, so
-* don't bother using udelay.
 */
 
for (i = 0; i < timeout; ++i) {
if (dmub->hw_funcs.is_gpint_acked(dmub, cmd))
break;
+
+   udelay(1);
}
 
for (i = 0; i < timeout; ++i) {
scratch = dmub->hw_funcs.get_gpint_response(dmub);
if (scratch == DMUB_GPINT__STOP_FW_RESPONSE)
break;
+
+   udelay(1);
}
 
/* Force reset in case we timed out, DMCUB is likely hung. */
-- 
2.25.1



[PATCH 09/13] drm/amd/display: [FW Promotion] Release 0.0.78

2021-08-06 Thread Anson Jacob
From: Anthony Koo 

Acked-by: Anson Jacob 
Signed-off-by: Anthony Koo 
---
 drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h 
b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
index 661b32a5ff9b..5950da7bf252 100644
--- a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
+++ b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
@@ -47,10 +47,10 @@
 
 /* Firmware versioning. */
 #ifdef DMUB_EXPOSE_VERSION
-#define DMUB_FW_VERSION_GIT_HASH 0x6d13d5e2c
+#define DMUB_FW_VERSION_GIT_HASH 0x9b7fa7783
 #define DMUB_FW_VERSION_MAJOR 0
 #define DMUB_FW_VERSION_MINOR 0
-#define DMUB_FW_VERSION_REVISION 77
+#define DMUB_FW_VERSION_REVISION 78
 #define DMUB_FW_VERSION_TEST 0
 #define DMUB_FW_VERSION_VBIOS 0
 #define DMUB_FW_VERSION_HOTFIX 0
-- 
2.25.1



[PATCH 07/13] drm/amd/display: Add AUX I2C tracing.

2021-08-06 Thread Anson Jacob
From: Ashley Thomas 

[Why]
Developers can find it useful if the driver can produce
AUX traces without special equipment.

[How]
Add AUX tracing.

Reviewed-by: Zhan Liu 
Acked-by: Anson Jacob 
Signed-off-by: Ashley Thomas 
---
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c | 192 ++-
 1 file changed, 183 insertions(+), 9 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 058a9356a39a..e14f99b4b0c3 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,11 @@
 #define DC_LOGGER \
engine->ctx->logger
 
+#define DC_TRACE_LEVEL_MESSAGE(...) /* do nothing */
+#define IS_DC_I2CAUX_LOGGING_ENABLED() (false)
+#define LOG_FLAG_Error_I2cAux LOG_ERROR
+#define LOG_FLAG_I2cAux_DceAux LOG_I2C_AUX
+
 #include "reg_helper.h"
 
 #undef FN
@@ -623,6 +628,58 @@ int dce_aux_transfer_dmub_raw(struct ddc_service *ddc,
 #define AUX_MAX_INVALID_REPLY_RETRIES 2
 #define AUX_MAX_TIMEOUT_RETRIES 3
 
+static void dce_aux_log_payload(const char *payload_name,
+   unsigned char *payload, uint32_t length, uint32_t max_length_to_log)
+{
+   if (!IS_DC_I2CAUX_LOGGING_ENABLED())
+   return;
+
+   if (payload && length) {
+   char hex_str[128] = {0};
+   char *hex_str_ptr = &hex_str[0];
+   uint32_t hex_str_remaining = sizeof(hex_str);
+   unsigned char *payload_ptr = payload;
+   unsigned char *payload_max_to_log_ptr = payload_ptr + 
min(max_length_to_log, length);
+   unsigned int count;
+   char *padding = "";
+
+   while (payload_ptr < payload_max_to_log_ptr) {
+   count = snprintf_count(hex_str_ptr, hex_str_remaining, 
"%s%02X", padding, *payload_ptr);
+   padding = " ";
+   hex_str_remaining -= count;
+   hex_str_ptr += count;
+   payload_ptr++;
+   }
+
+   count = snprintf_count(hex_str_ptr, hex_str_remaining, "   ");
+   hex_str_remaining -= count;
+   hex_str_ptr += count;
+
+   payload_ptr = payload;
+   while (payload_ptr < payload_max_to_log_ptr) {
+   count = snprintf_count(hex_str_ptr, hex_str_remaining, 
"%c",
+   *payload_ptr >= ' ' ? *payload_ptr : '.');
+   hex_str_remaining -= count;
+   hex_str_ptr += count;
+   payload_ptr++;
+   }
+
+   DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_VERBOSE,
+   LOG_FLAG_I2cAux_DceAux,
+   "dce_aux_log_payload: %s: length=%u: 
data: %s%s",
+   payload_name,
+   length,
+   hex_str,
+   (length > max_length_to_log ? " (...)" 
: " "));
+   } else {
+   DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_VERBOSE,
+   LOG_FLAG_I2cAux_DceAux,
+   "dce_aux_log_payload: %s: length=%u: 
data: ",
+   payload_name,
+   length);
+   }
+}
+
 bool dce_aux_transfer_with_retries(struct ddc_service *ddc,
struct aux_payload *payload)
 {
@@ -648,7 +705,34 @@ bool dce_aux_transfer_with_retries(struct ddc_service *ddc,
}
 
for (i = 0; i < AUX_MAX_RETRIES; i++) {
+   DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION,
+   LOG_FLAG_I2cAux_DceAux,
+   "dce_aux_transfer_with_retries: 
link_index=%u: START: retry %d of %d: address=0x%04x length=%u write=%d mot=%d",
+   ddc && ddc->link ? 
ddc->link->link_index : UINT_MAX,
+   i + 1,
+   (int)AUX_MAX_RETRIES,
+   payload->address,
+   payload->length,
+   (unsigned int) payload->write,
+   (unsigned int) payload->mot);
+   if (payload->write)
+   dce_aux_log_payload("  write", payload->data, 
payload->length, 16);
ret = dce_aux_transfer_raw(ddc, payload, &operation_result);
+   DC_TRACE_LEVEL_MESSAGE(DAL_TRACE_LEVEL_INFORMATION,
+   LOG_F

[PATCH 04/13] drm/amd/display: refactor the cursor programing codes

2021-08-06 Thread Anson Jacob
From: Roy Chan 

Acked-by: Anson Jacob 
Signed-off-by: Roy Chan 
---
 .../gpu/drm/amd/display/dc/core/dc_stream.c   | 106 +++---
 1 file changed, 65 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
index 327fd1909c51..f0f54f4d3d9b 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_stream.c
@@ -246,6 +246,40 @@ struct dc_stream_status *dc_stream_get_status(
return dc_stream_get_status_from_state(dc->current_state, stream);
 }
 
+static void program_cursor_attributes(
+   struct dc *dc,
+   struct dc_stream_state *stream,
+   const struct dc_cursor_attributes *attributes)
+{
+   int i;
+   struct resource_context *res_ctx;
+   struct pipe_ctx *pipe_to_program = NULL;
+
+   if (!stream)
+   return;
+
+   res_ctx = &dc->current_state->res_ctx;
+
+   for (i = 0; i < MAX_PIPES; i++) {
+   struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i];
+
+   if (pipe_ctx->stream != stream)
+   continue;
+
+   if (!pipe_to_program) {
+   pipe_to_program = pipe_ctx;
+   dc->hwss.cursor_lock(dc, pipe_to_program, true);
+   }
+
+   dc->hwss.set_cursor_attribute(pipe_ctx);
+   if (dc->hwss.set_cursor_sdr_white_level)
+   dc->hwss.set_cursor_sdr_white_level(pipe_ctx);
+   }
+
+   if (pipe_to_program)
+   dc->hwss.cursor_lock(dc, pipe_to_program, false);
+}
+
 #ifndef TRIM_FSFT
 /*
  * dc_optimize_timing_for_fsft() - dc to optimize timing
@@ -270,10 +304,7 @@ bool dc_stream_set_cursor_attributes(
struct dc_stream_state *stream,
const struct dc_cursor_attributes *attributes)
 {
-   int i;
struct dc  *dc;
-   struct resource_context *res_ctx;
-   struct pipe_ctx *pipe_to_program = NULL;
 #if defined(CONFIG_DRM_AMD_DC_DCN)
bool reset_idle_optimizations = false;
 #endif
@@ -293,7 +324,6 @@ bool dc_stream_set_cursor_attributes(
}
 
dc = stream->ctx->dc;
-   res_ctx = &dc->current_state->res_ctx;
stream->cursor_attributes = *attributes;
 
 #if defined(CONFIG_DRM_AMD_DC_DCN)
@@ -305,11 +335,39 @@ bool dc_stream_set_cursor_attributes(
}
 
 #endif
+   program_cursor_attributes(dc, stream, attributes);
+
+#if defined(CONFIG_DRM_AMD_DC_DCN)
+   /* re-enable idle optimizations if necessary */
+   if (reset_idle_optimizations)
+   dc_allow_idle_optimizations(dc, true);
+
+#endif
+   return true;
+}
+
+static void program_cursor_position(
+   struct dc *dc,
+   struct dc_stream_state *stream,
+   const struct dc_cursor_position *position)
+{
+   int i;
+   struct resource_context *res_ctx;
+   struct pipe_ctx *pipe_to_program = NULL;
+
+   if (!stream)
+   return;
+
+   res_ctx = &dc->current_state->res_ctx;
 
for (i = 0; i < MAX_PIPES; i++) {
struct pipe_ctx *pipe_ctx = &res_ctx->pipe_ctx[i];
 
-   if (pipe_ctx->stream != stream)
+   if (pipe_ctx->stream != stream ||
+   (!pipe_ctx->plane_res.mi  && 
!pipe_ctx->plane_res.hubp) ||
+   !pipe_ctx->plane_state ||
+   (!pipe_ctx->plane_res.xfm && 
!pipe_ctx->plane_res.dpp) ||
+   (!pipe_ctx->plane_res.ipp && 
!pipe_ctx->plane_res.dpp))
continue;
 
if (!pipe_to_program) {
@@ -317,31 +375,18 @@ bool dc_stream_set_cursor_attributes(
dc->hwss.cursor_lock(dc, pipe_to_program, true);
}
 
-   dc->hwss.set_cursor_attribute(pipe_ctx);
-   if (dc->hwss.set_cursor_sdr_white_level)
-   dc->hwss.set_cursor_sdr_white_level(pipe_ctx);
+   dc->hwss.set_cursor_position(pipe_ctx);
}
 
if (pipe_to_program)
dc->hwss.cursor_lock(dc, pipe_to_program, false);
-
-#if defined(CONFIG_DRM_AMD_DC_DCN)
-   /* re-enable idle optimizations if necessary */
-   if (reset_idle_optimizations)
-   dc_allow_idle_optimizations(dc, true);
-
-#endif
-   return true;
 }
 
 bool dc_stream_set_cursor_position(
struct dc_stream_state *stream,
const struct dc_cursor_position *position)
 {
-   int i;
struct dc  *dc;
-   struct resource_context *res_ctx;
-   struct pipe_ctx *pipe_to_program = NULL;
 #if defined(CONFIG_DRM_AMD_DC_DCN)
bool reset_idle_optimizations = false;
 #endif
@@ -357,7 +402,6 @@ bool dc_stream_set_cursor_position(
}
 
dc = stream

[PATCH 10/13] drm/amd/display: 3.2.148

2021-08-06 Thread Anson Jacob
From: Anthony Koo 

This version brings along following fixes:
- Fix memory allocation in dm IRQ context to use GFP_ATOMIC
- Increase timeout threshold for DMCUB reset
- Clear GPINT after DMCUB has reset
- Add AUX I2C tracing
- Fix code commenting style
- Some refactoring
- Remove invalid assert for ODM + MPC case

Reviewed-by: Wyatt Wood 
Acked-by: Anson Jacob 
Signed-off-by: Anthony Koo 
---
 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 62c222d0402f..03b81e5c5d67 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -45,7 +45,7 @@
 /* forward declaration */
 struct aux_payload;
 
-#define DC_VER "3.2.147"
+#define DC_VER "3.2.148"
 
 #define MAX_SURFACES 3
 #define MAX_PLANES 6
-- 
2.25.1



[PATCH 02/13] drm/amd/display: fix missing writeback disablement if plane is removed

2021-08-06 Thread Anson Jacob
From: Roy Chan 

[Why]
If the plane has been removed, the writeback disablement logic
doesn't run

[How]
fix the logic order

Acked-by: Anson Jacob 
Signed-off-by: Roy Chan 
---
 drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c | 14 --
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c | 12 +++-
 2 files changed, 19 insertions(+), 7 deletions(-)

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 5c2853654cca..a47ba1d45be9 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_hwseq.c
@@ -1723,13 +1723,15 @@ void dcn20_program_front_end_for_ctx(
 
pipe = pipe->bottom_pipe;
}
-   /* Program secondary blending tree and writeback pipes 
*/
-   pipe = &context->res_ctx.pipe_ctx[i];
-   if (!pipe->prev_odm_pipe && pipe->stream->num_wb_info > 0
-   && (pipe->update_flags.raw || 
pipe->plane_state->update_flags.raw || pipe->stream->update_flags.raw)
-   && 
hws->funcs.program_all_writeback_pipes_in_tree)
-   
hws->funcs.program_all_writeback_pipes_in_tree(dc, pipe->stream, context);
}
+   /* Program secondary blending tree and writeback pipes */
+   pipe = &context->res_ctx.pipe_ctx[i];
+   if (!pipe->top_pipe && !pipe->prev_odm_pipe
+   && pipe->stream && pipe->stream->num_wb_info > 0
+   && (pipe->update_flags.raw || 
(pipe->plane_state && pipe->plane_state->update_flags.raw)
+   || pipe->stream->update_flags.raw)
+   && 
hws->funcs.program_all_writeback_pipes_in_tree)
+   hws->funcs.program_all_writeback_pipes_in_tree(dc, 
pipe->stream, context);
}
 }
 
diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c 
b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c
index 2e8ab9775fa3..fafed1e4a998 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_hwseq.c
@@ -398,12 +398,22 @@ void dcn30_program_all_writeback_pipes_in_tree(
for (i_pipe = 0; i_pipe < dc->res_pool->pipe_count; 
i_pipe++) {
struct pipe_ctx *pipe_ctx = 
&context->res_ctx.pipe_ctx[i_pipe];
 
+   if (!pipe_ctx->plane_state)
+   continue;
+
if (pipe_ctx->plane_state == 
wb_info.writeback_source_plane) {
wb_info.mpcc_inst = 
pipe_ctx->plane_res.mpcc_inst;
break;
}
}
-   ASSERT(wb_info.mpcc_inst != -1);
+
+   if (wb_info.mpcc_inst == -1) {
+   /* Disable writeback pipe and disconnect from 
MPCC
+* if source plane has been removed
+*/
+   dc->hwss.disable_writeback(dc, 
wb_info.dwb_pipe_inst);
+   continue;
+   }
 
ASSERT(wb_info.dwb_pipe_inst < 
dc->res_pool->res_cap->num_dwb);
dwb = dc->res_pool->dwbc[wb_info.dwb_pipe_inst];
-- 
2.25.1



[PATCH 08/13] drm/amd/display: add authentication_complete in hdcp output

2021-08-06 Thread Anson Jacob
From: Wenjing Liu 

[why]
DM needs to be notified when hdcp module has completed
authentication attempt.

Acked-by: Anson Jacob 
Signed-off-by: Wenjing Liu 
---
 .../gpu/drm/amd/display/modules/hdcp/hdcp.c   |  5 +-
 .../gpu/drm/amd/display/modules/hdcp/hdcp.h   |  8 ++
 .../display/modules/hdcp/hdcp1_transition.c   |  8 +-
 .../display/modules/hdcp/hdcp2_transition.c   |  4 +-
 .../drm/amd/display/modules/hdcp/hdcp_log.c   | 74 +++
 .../drm/amd/display/modules/hdcp/hdcp_log.h   | 72 --
 .../drm/amd/display/modules/inc/mod_hdcp.h|  1 +
 7 files changed, 93 insertions(+), 79 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c
index 06d60f031a06..3e81850a7ffe 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.c
@@ -145,6 +145,7 @@ static enum mod_hdcp_status transition(struct mod_hdcp 
*hdcp,
} else {
callback_in_ms(0, output);
set_state_id(hdcp, output, HDCP_CP_NOT_DESIRED);
+   set_auth_complete(hdcp, output);
}
else if (is_hdmi_dvi_sl_hdcp(hdcp))
if (is_cp_desired_hdcp2(hdcp)) {
@@ -156,10 +157,12 @@ static enum mod_hdcp_status transition(struct mod_hdcp 
*hdcp,
} else {
callback_in_ms(0, output);
set_state_id(hdcp, output, HDCP_CP_NOT_DESIRED);
+   set_auth_complete(hdcp, output);
}
else {
callback_in_ms(0, output);
set_state_id(hdcp, output, HDCP_CP_NOT_DESIRED);
+   set_auth_complete(hdcp, output);
}
} else if (is_in_cp_not_desired_state(hdcp)) {
increment_stay_counter(hdcp);
@@ -520,7 +523,7 @@ enum mod_hdcp_status mod_hdcp_process_event(struct mod_hdcp 
*hdcp,
 
/* reset authentication if needed */
if (trans_status == MOD_HDCP_STATUS_RESET_NEEDED) {
-   HDCP_FULL_DDC_TRACE(hdcp);
+   mod_hdcp_log_ddc_trace(hdcp);
reset_status = reset_authentication(hdcp, output);
if (reset_status != MOD_HDCP_STATUS_SUCCESS)
push_error_status(hdcp, reset_status);
diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h
index 7123f0915706..399fbca8947b 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp.h
@@ -324,6 +324,7 @@ enum mod_hdcp_status mod_hdcp_hdcp2_dp_transition(struct 
mod_hdcp *hdcp,
 /* log functions */
 void mod_hdcp_dump_binary_message(uint8_t *msg, uint32_t msg_size,
uint8_t *buf, uint32_t buf_size);
+void mod_hdcp_log_ddc_trace(struct mod_hdcp *hdcp);
 /* TODO: add adjustment log */
 
 /* psp functions */
@@ -494,6 +495,13 @@ static inline void set_watchdog_in_ms(struct mod_hdcp 
*hdcp, uint16_t time,
output->watchdog_timer_delay = time;
 }
 
+static inline void set_auth_complete(struct mod_hdcp *hdcp,
+   struct mod_hdcp_output *output)
+{
+   output->auth_complete = 1;
+   mod_hdcp_log_ddc_trace(hdcp);
+}
+
 /* connection topology helpers */
 static inline uint8_t is_display_active(struct mod_hdcp_display *display)
 {
diff --git a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_transition.c 
b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_transition.c
index 3dda8c1d83fc..7f011196ce98 100644
--- a/drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_transition.c
+++ b/drivers/gpu/drm/amd/display/modules/hdcp/hdcp1_transition.c
@@ -89,7 +89,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_transition(struct 
mod_hdcp *hdcp,
} else {
callback_in_ms(0, output);
set_state_id(hdcp, output, H1_A45_AUTHENTICATED);
-   HDCP_FULL_DDC_TRACE(hdcp);
+   set_auth_complete(hdcp, output);
}
break;
case H1_A45_AUTHENTICATED:
@@ -137,7 +137,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_transition(struct 
mod_hdcp *hdcp,
}
callback_in_ms(0, output);
set_state_id(hdcp, output, H1_A45_AUTHENTICATED);
-   HDCP_FULL_DDC_TRACE(hdcp);
+   set_auth_complete(hdcp, output);
break;
default:
status = MOD_HDCP_STATUS_INVALID_STATE;
@@ -239,7 +239,7 @@ enum mod_hdcp_status mod_hdcp_hdcp1_dp_transition(struct 
mod_hdcp *hdcp,
set_state_id(hdcp, output, D1_A6_WAIT_FOR_READY);
} else {
set_state_id(hdcp, output, D1_A4_AUTHENTICATED);
-   HDCP_FULL_DDC_TRAC

[PATCH 03/13] drm/amd/display: refactor the codes to centralize the stream/pipe checking logic

2021-08-06 Thread Anson Jacob
From: Roy Chan 

Acked-by: Anson Jacob 
Signed-off-by: Roy Chan 
---
 drivers/gpu/drm/amd/display/dc/core/dc.c | 62 
 1 file changed, 41 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c 
b/drivers/gpu/drm/amd/display/dc/core/dc.c
index 605e297b7a59..7a442fcfa6ac 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
@@ -1481,6 +1481,22 @@ bool dc_validate_seamless_boot_timing(const struct dc 
*dc,
return true;
 }
 
+static inline bool should_update_pipe_for_stream(
+   struct dc_state *context,
+   struct pipe_ctx *pipe_ctx,
+   struct dc_stream_state *stream)
+{
+   return (pipe_ctx->stream && pipe_ctx->stream == stream);
+}
+
+static inline bool should_update_pipe_for_plane(
+   struct dc_state *context,
+   struct pipe_ctx *pipe_ctx,
+   struct dc_plane_state *plane_state)
+{
+   return (pipe_ctx->plane_state == plane_state);
+}
+
 void dc_enable_stereo(
struct dc *dc,
struct dc_state *context,
@@ -1491,12 +1507,15 @@ void dc_enable_stereo(
struct pipe_ctx *pipe;
 
for (i = 0; i < MAX_PIPES; i++) {
-   if (context != NULL)
+   if (context != NULL) {
pipe = &context->res_ctx.pipe_ctx[i];
-   else
+   } else {
+   context = dc->current_state;
pipe = &dc->current_state->res_ctx.pipe_ctx[i];
-   for (j = 0 ; pipe && j < stream_count; j++)  {
-   if (streams[j] && streams[j] == pipe->stream &&
+   }
+
+   for (j = 0; pipe && j < stream_count; j++)  {
+   if (should_update_pipe_for_stream(context, pipe, 
streams[j]) &&
dc->hwss.setup_stereo)
dc->hwss.setup_stereo(pipe, dc);
}
@@ -2623,6 +2642,7 @@ static void commit_planes_for_stream(struct dc *dc,
 {
int i, j;
struct pipe_ctx *top_pipe_to_program = NULL;
+   bool should_lock_all_pipes = (update_type != UPDATE_TYPE_FAST);
 
 #if defined(CONFIG_DRM_AMD_DC_DCN)
dc_z10_restore(dc);
@@ -2694,7 +2714,7 @@ static void commit_planes_for_stream(struct dc *dc,

top_pipe_to_program->stream_res.tg);
}
 
-   if ((update_type != UPDATE_TYPE_FAST) && 
dc->hwss.interdependent_update_lock)
+   if (should_lock_all_pipes && dc->hwss.interdependent_update_lock)
dc->hwss.interdependent_update_lock(dc, context, true);
else
/* Lock the top pipe while updating plane addrs, since freesync 
requires
@@ -2717,7 +2737,7 @@ static void commit_planes_for_stream(struct dc *dc,
if (dc->hwss.program_front_end_for_ctx)
dc->hwss.program_front_end_for_ctx(dc, context);
 
-   if ((update_type != UPDATE_TYPE_FAST) && 
dc->hwss.interdependent_update_lock)
+   if (should_lock_all_pipes && 
dc->hwss.interdependent_update_lock)
dc->hwss.interdependent_update_lock(dc, context, false);
else
dc->hwss.pipe_control_lock(dc, top_pipe_to_program, 
false);
@@ -2733,14 +2753,14 @@ static void commit_planes_for_stream(struct dc *dc,
struct pipe_ctx *pipe_ctx = 
&context->res_ctx.pipe_ctx[j];
if (!pipe_ctx->plane_state)
continue;
-   if (pipe_ctx->plane_state != plane_state)
+   if (should_update_pipe_for_plane(context, 
pipe_ctx, plane_state))
continue;
-   plane_state->triplebuffer_flips = false;
+   pipe_ctx->plane_state->triplebuffer_flips = 
false;
if (update_type == UPDATE_TYPE_FAST &&
dc->hwss.program_triplebuffer != NULL &&
-   !plane_state->flip_immediate && 
dc->debug.enable_tri_buf) {
+   !pipe_ctx->plane_state->flip_immediate 
&& dc->debug.enable_tri_buf) {
/*triple buffer for VUpdate  
only*/
-   plane_state->triplebuffer_flips 
= true;
+   
pipe_ctx->plane_state->triplebuffer_flips = true;
}
}
if (update_t

[PATCH 05/13] drm/amd/display: fix incorrect CM/TF programming sequence in dwb

2021-08-06 Thread Anson Jacob
From: Roy Chan 

[How]
the programming sequeune was for old asic.
the correct programming sequeunce should be similar to the one
used in mpc. the fix is copied from the mpc programming sequeunce.

Acked-by: Anson Jacob 
Signed-off-by: Roy Chan 
---
 .../drm/amd/display/dc/dcn30/dcn30_dwb_cm.c   | 90 +--
 1 file changed, 64 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb_cm.c 
b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb_cm.c
index 3fe9e41e4dbd..6a3d3a0ec0a3 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb_cm.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_dwb_cm.c
@@ -49,6 +49,11 @@
 static void dwb3_get_reg_field_ogam(struct dcn30_dwbc *dwbc30,
struct dcn3_xfer_func_reg *reg)
 {
+   reg->shifts.field_region_start_base = 
dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION_START_BASE_B;
+   reg->masks.field_region_start_base = 
dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION_START_BASE_B;
+   reg->shifts.field_offset = dwbc30->dwbc_shift->DWB_OGAM_RAMA_OFFSET_B;
+   reg->masks.field_offset = dwbc30->dwbc_mask->DWB_OGAM_RAMA_OFFSET_B;
+
reg->shifts.exp_region0_lut_offset = 
dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION0_LUT_OFFSET;
reg->masks.exp_region0_lut_offset = 
dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION0_LUT_OFFSET;
reg->shifts.exp_region0_num_segments = 
dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION0_NUM_SEGMENTS;
@@ -66,8 +71,6 @@ static void dwb3_get_reg_field_ogam(struct dcn30_dwbc *dwbc30,
reg->masks.field_region_end_base = 
dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION_END_BASE_B;
reg->shifts.field_region_linear_slope = 
dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION_START_SLOPE_B;
reg->masks.field_region_linear_slope = 
dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION_START_SLOPE_B;
-   reg->masks.field_offset = dwbc30->dwbc_mask->DWB_OGAM_RAMA_OFFSET_B;
-   reg->shifts.field_offset = dwbc30->dwbc_shift->DWB_OGAM_RAMA_OFFSET_B;
reg->shifts.exp_region_start = 
dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION_START_B;
reg->masks.exp_region_start = 
dwbc30->dwbc_mask->DWB_OGAM_RAMA_EXP_REGION_START_B;
reg->shifts.exp_resion_start_segment = 
dwbc30->dwbc_shift->DWB_OGAM_RAMA_EXP_REGION_START_SEGMENT_B;
@@ -147,18 +150,19 @@ static enum dc_lut_mode dwb3_get_ogam_current(
uint32_t state_mode;
uint32_t ram_select;
 
-   REG_GET(DWB_OGAM_CONTROL,
-   DWB_OGAM_MODE, &state_mode);
-   REG_GET(DWB_OGAM_CONTROL,
-   DWB_OGAM_SELECT, &ram_select);
+   REG_GET_2(DWB_OGAM_CONTROL,
+   DWB_OGAM_MODE_CURRENT, &state_mode,
+   DWB_OGAM_SELECT_CURRENT, &ram_select);
 
if (state_mode == 0) {
mode = LUT_BYPASS;
} else if (state_mode == 2) {
if (ram_select == 0)
mode = LUT_RAM_A;
-   else
+   else if (ram_select == 1)
mode = LUT_RAM_B;
+   else
+   mode = LUT_BYPASS;
} else {
// Reserved value
mode = LUT_BYPASS;
@@ -172,10 +176,10 @@ static void dwb3_configure_ogam_lut(
struct dcn30_dwbc *dwbc30,
bool is_ram_a)
 {
-   REG_UPDATE(DWB_OGAM_LUT_CONTROL,
-   DWB_OGAM_LUT_READ_COLOR_SEL, 7);
-   REG_UPDATE(DWB_OGAM_CONTROL,
-   DWB_OGAM_SELECT, is_ram_a == true ? 0 : 1);
+   REG_UPDATE_2(DWB_OGAM_LUT_CONTROL,
+   DWB_OGAM_LUT_WRITE_COLOR_MASK, 7,
+   DWB_OGAM_LUT_HOST_SEL, (is_ram_a == true) ? 0 : 1);
+
REG_SET(DWB_OGAM_LUT_INDEX, 0, DWB_OGAM_LUT_INDEX, 0);
 }
 
@@ -185,17 +189,45 @@ static void dwb3_program_ogam_pwl(struct dcn30_dwbc 
*dwbc30,
 {
uint32_t i;
 
-// triple base implementation
-   for (i = 0; i < num/2; i++) {
-   REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, 
rgb[2*i+0].red_reg);
-   REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, 
rgb[2*i+0].green_reg);
-   REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, 
rgb[2*i+0].blue_reg);
-   REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, 
rgb[2*i+1].red_reg);
-   REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, 
rgb[2*i+1].green_reg);
-   REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, 
rgb[2*i+1].blue_reg);
-   REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, 
rgb[2*i+2].red_reg);
-   REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, 
rgb[2*i+2].green_reg);
-   REG_SET(DWB_OGAM_LUT_DATA, 0, DWB_OGAM_LUT_DATA, 
rgb[2*i+2].blue_reg);
+   uint32_t last_base_value_red = rgb[num-1].red_reg + 
rgb[num-1].delta_red_reg;
+   uint32_t last_base_value_green = rgb[num-1].green_reg + 

[PATCH 06/13] drm/amd/display: Correct comment style

2021-08-06 Thread Anson Jacob
From: Roy Chan 

Acked-by: Anson Jacob 
Signed-off-by: Roy Chan 
---
 drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h 
b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
index aa2707e469c1..661b32a5ff9b 100644
--- a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
+++ b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
@@ -1438,7 +1438,7 @@ struct dmub_cmd_psr_set_level_data {
 * 16-bit value dicated by driver that will enable/disable different 
functionality.
 */
uint16_t psr_level;
-   /**
+   /**
 * PSR control version.
 */
uint8_t cmd_version;
-- 
2.25.1



[PATCH 01/13] drm/amd/display: Remove invalid assert for ODM + MPC case

2021-08-06 Thread Anson Jacob
From: Eric Bernstein 

Reviewed-by: Dmytro Laktyushkin 
Acked-by: Anson Jacob 
Signed-off-by: Eric Bernstein 
Cc: sta...@vger.kernel.org
---
 drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c 
b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
index 253654d605c2..28e15ebf2f43 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn30/dcn30_resource.c
@@ -1788,7 +1788,6 @@ static bool dcn30_split_stream_for_mpc_or_odm(
}
pri_pipe->next_odm_pipe = sec_pipe;
sec_pipe->prev_odm_pipe = pri_pipe;
-   ASSERT(sec_pipe->top_pipe == NULL);
 
if (!sec_pipe->top_pipe)
sec_pipe->stream_res.opp = pool->opps[pipe_idx];
-- 
2.25.1



[PATCH 00/13] DC Patches Aug 6, 2021

2021-08-06 Thread Anson Jacob
This DC patchset brings improvements in multiple areas. In summary, we 
highlight:
- Fix memory allocation in dm IRQ context to use GFP_ATOMIC
- Increase timeout threshold for DMCUB reset
- Clear GPINT after DMCUB has reset
- Add AUX I2C tracing
- Fix code commenting style
- Some refactoring
- Remove invalid assert for ODM + MPC case

Anson Jacob (1):
  drm/amd/display: use GFP_ATOMIC in amdgpu_dm_irq_schedule_work

Anthony Koo (2):
  drm/amd/display: [FW Promotion] Release 0.0.78
  drm/amd/display: 3.2.148

Ashley Thomas (1):
  drm/amd/display: Add AUX I2C tracing.

Eric Bernstein (1):
  drm/amd/display: Remove invalid assert for ODM + MPC case

Nicholas Kazlauskas (2):
  drm/amd/display: Clear GPINT after DMCUB has reset
  drm/amd/display: Increase timeout threshold for DMCUB reset

Roy Chan (5):
  drm/amd/display: fix missing writeback disablement if plane is removed
  drm/amd/display: refactor the codes to centralize the stream/pipe
checking logic
  drm/amd/display: refactor the cursor programing codes
  drm/amd/display: fix incorrect CM/TF programming sequence in dwb
  drm/amd/display: Correct comment style

Wenjing Liu (1):
  drm/amd/display: add authentication_complete in hdcp output

 .../drm/amd/display/amdgpu_dm/amdgpu_dm_irq.c |   2 +-
 drivers/gpu/drm/amd/display/dc/core/dc.c  |  62 --
 .../gpu/drm/amd/display/dc/core/dc_stream.c   | 106 ++
 drivers/gpu/drm/amd/display/dc/dc.h   |   2 +-
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c  | 192 +-
 .../drm/amd/display/dc/dcn20/dcn20_hwseq.c|  14 +-
 .../drm/amd/display/dc/dcn30/dcn30_dwb_cm.c   |  90 +---
 .../drm/amd/display/dc/dcn30/dcn30_hwseq.c|  12 +-
 .../drm/amd/display/dc/dcn30/dcn30_resource.c |   1 -
 .../gpu/drm/amd/display/dmub/inc/dmub_cmd.h   |   6 +-
 .../gpu/drm/amd/display/dmub/src/dmub_dcn31.c |  18 +-
 .../gpu/drm/amd/display/modules/hdcp/hdcp.c   |   5 +-
 .../gpu/drm/amd/display/modules/hdcp/hdcp.h   |   8 +
 .../display/modules/hdcp/hdcp1_transition.c   |   8 +-
 .../display/modules/hdcp/hdcp2_transition.c   |   4 +-
 .../drm/amd/display/modules/hdcp/hdcp_log.c   |  74 +++
 .../drm/amd/display/modules/hdcp/hdcp_log.h   |  72 ---
 .../drm/amd/display/modules/inc/mod_hdcp.h|   1 +
 18 files changed, 479 insertions(+), 198 deletions(-)

-- 
2.25.1



[PATCH] drm/vc4: hdmi: Fix build break caused by merge issue

2021-08-04 Thread Anson Jacob
Commit 6800234ceee0 ("drm/vc4: hdmi: Convert to gpiod")
was reverted partially by
Commit 0600a948942d ("Merge tag 'v5.13' into amd-staging-drm-next")
which caused build break when compiling 'make allmodconfig'

Original Patch: 
https://patchwork.freedesktop.org/patch/msgid/20210524131852.263883-2-max...@cerno.tech
Signed-off-by: Anson Jacob 
---
 drivers/gpu/drm/vc4/vc4_hdmi.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
index df65e0b6449b..aab1b36ceb3c 100644
--- a/drivers/gpu/drm/vc4/vc4_hdmi.c
+++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
@@ -168,10 +168,9 @@ vc4_hdmi_connector_detect(struct drm_connector *connector, 
bool force)
 
WARN_ON(pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev));
 
-   if (vc4_hdmi->hpd_gpio) {
-   if (gpio_get_value_cansleep(vc4_hdmi->hpd_gpio) ^
-   vc4_hdmi->hpd_active_low)
-   connected = true;
+   if (vc4_hdmi->hpd_gpio &&
+   gpiod_get_value_cansleep(vc4_hdmi->hpd_gpio)) {
+   connected = true;
} else if (drm_probe_ddc(vc4_hdmi->ddc)) {
connected = true;
} else if (HDMI_READ(HDMI_HOTPLUG) & VC4_HDMI_HOTPLUG_CONNECTED) {
-- 
2.25.1



[RFC v2 2/2] drm/amd/display: Use PPC FPU functions

2021-07-21 Thread Anson Jacob
Use kernel_fpu_begin & kernel_fpu_end for PPC

Depends on "ppc/fpu: Add generic FPU api similar to x86"

v2:
- Got rid of macro switch for PPC as header file with same
  name as x86 is added by previous patch in the series

Signed-off-by: Anson Jacob 
CC: Christoph Hellwig 
CC: Rodrigo Siqueira 
CC: Harry Wentland 
CC: Christian König 
---
 drivers/gpu/drm/amd/display/dc/os_types.h | 29 ---
 1 file changed, 29 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/os_types.h 
b/drivers/gpu/drm/amd/display/dc/os_types.h
index 126c2f3a4dd3..47ef434f93d8 100644
--- a/drivers/gpu/drm/amd/display/dc/os_types.h
+++ b/drivers/gpu/drm/amd/display/dc/os_types.h
@@ -51,38 +51,9 @@
 #define dm_error(fmt, ...) DRM_ERROR(fmt, ##__VA_ARGS__)
 
 #if defined(CONFIG_DRM_AMD_DC_DCN)
-#if defined(CONFIG_X86)
 #include 
 #define DC_FP_START() kernel_fpu_begin()
 #define DC_FP_END() kernel_fpu_end()
-#elif defined(CONFIG_PPC64)
-#include 
-#include 
-#define DC_FP_START() { \
-   if (cpu_has_feature(CPU_FTR_VSX_COMP)) { \
-   preempt_disable(); \
-   enable_kernel_vsx(); \
-   } else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) { \
-   preempt_disable(); \
-   enable_kernel_altivec(); \
-   } else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) { \
-   preempt_disable(); \
-   enable_kernel_fp(); \
-   } \
-}
-#define DC_FP_END() { \
-   if (cpu_has_feature(CPU_FTR_VSX_COMP)) { \
-   disable_kernel_vsx(); \
-   preempt_enable(); \
-   } else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) { \
-   disable_kernel_altivec(); \
-   preempt_enable(); \
-   } else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) { \
-   disable_kernel_fp(); \
-   preempt_enable(); \
-   } \
-}
-#endif
 #endif
 
 /*
-- 
2.25.1

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


[RFC v2 1/2] ppc/fpu: Add generic FPU api similar to x86

2021-07-21 Thread Anson Jacob
- Add kernel_fpu_begin & kernel_fpu_end API as x86
- Add logic similar to x86 to ensure fpu
  begin/end call correctness
- Add kernel_fpu_enabled to know if FPU is enabled

v2:
- Added asm/fpu/api.h powerpc variant with kernel_fpu_begin/end()
  and kernel_fpu_enabled() declarations
- Updated kernel_fpu_enabled as EXPORT_SYMBOL_GPL

Signed-off-by: Anson Jacob 
CC: Christoph Hellwig 
CC: Rodrigo Siqueira 
CC: Harry Wentland 
CC: Christian König 
---
 arch/powerpc/include/asm/fpu/api.h   |  18 
 arch/powerpc/include/asm/switch_to.h |  25 +-
 arch/powerpc/kernel/process.c| 130 +++
 3 files changed, 151 insertions(+), 22 deletions(-)
 create mode 100644 arch/powerpc/include/asm/fpu/api.h

diff --git a/arch/powerpc/include/asm/fpu/api.h 
b/arch/powerpc/include/asm/fpu/api.h
new file mode 100644
index ..57308cdc65c9
--- /dev/null
+++ b/arch/powerpc/include/asm/fpu/api.h
@@ -0,0 +1,18 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#ifndef _ASM_POWERPC_FPU_API_H
+#define _ASM_POWERPC_FPU_API_H
+
+/*
+ * Use kernel_fpu_begin/end() if you intend to use FPU in kernel context. It
+ * disables preemption so be careful if you intend to use it for long periods
+ * of time.
+ * TODO: If you intend to use the FPU in irq/softirq you need to check first 
with
+ * irq_fpu_usable() if it is possible.
+ */
+
+extern bool kernel_fpu_enabled(void);
+extern void kernel_fpu_begin(void);
+extern void kernel_fpu_end(void);
+
+#endif /* _ASM_POWERPC_FPU_API_H */
diff --git a/arch/powerpc/include/asm/switch_to.h 
b/arch/powerpc/include/asm/switch_to.h
index 9d1fbd8be1c7..a9a919279f48 100644
--- a/arch/powerpc/include/asm/switch_to.h
+++ b/arch/powerpc/include/asm/switch_to.h
@@ -41,10 +41,7 @@ extern void enable_kernel_fp(void);
 extern void flush_fp_to_thread(struct task_struct *);
 extern void giveup_fpu(struct task_struct *);
 extern void save_fpu(struct task_struct *);
-static inline void disable_kernel_fp(void)
-{
-   msr_check_and_clear(MSR_FP);
-}
+extern void disable_kernel_fp(void);
 #else
 static inline void save_fpu(struct task_struct *t) { }
 static inline void flush_fp_to_thread(struct task_struct *t) { }
@@ -55,10 +52,7 @@ extern void enable_kernel_altivec(void);
 extern void flush_altivec_to_thread(struct task_struct *);
 extern void giveup_altivec(struct task_struct *);
 extern void save_altivec(struct task_struct *);
-static inline void disable_kernel_altivec(void)
-{
-   msr_check_and_clear(MSR_VEC);
-}
+extern void disable_kernel_altivec(void);
 #else
 static inline void save_altivec(struct task_struct *t) { }
 static inline void __giveup_altivec(struct task_struct *t) { }
@@ -67,20 +61,7 @@ static inline void __giveup_altivec(struct task_struct *t) { 
}
 #ifdef CONFIG_VSX
 extern void enable_kernel_vsx(void);
 extern void flush_vsx_to_thread(struct task_struct *);
-static inline void disable_kernel_vsx(void)
-{
-   msr_check_and_clear(MSR_FP|MSR_VEC|MSR_VSX);
-}
-#else
-static inline void enable_kernel_vsx(void)
-{
-   BUILD_BUG();
-}
-
-static inline void disable_kernel_vsx(void)
-{
-   BUILD_BUG();
-}
+extern void disable_kernel_vsx(void);
 #endif
 
 #ifdef CONFIG_SPE
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 185beb290580..969096c0123c 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -75,6 +75,17 @@
 #define TM_DEBUG(x...) do { } while(0)
 #endif
 
+/*
+ * Track whether the kernel is using the FPU state
+ * currently.
+ *
+ * This flag is used:
+ *
+ *   - kernel_fpu_begin()/end() correctness
+ *   - kernel_fpu_enabled info
+ */
+static DEFINE_PER_CPU(bool, in_kernel_fpu);
+
 extern unsigned long _get_SP(void);
 
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
@@ -212,6 +223,9 @@ void enable_kernel_fp(void)
unsigned long cpumsr;
 
WARN_ON(preemptible());
+   WARN_ON_ONCE(this_cpu_read(in_kernel_fpu));
+
+   this_cpu_write(in_kernel_fpu, true);
 
cpumsr = msr_check_and_set(MSR_FP);
 
@@ -231,6 +245,15 @@ void enable_kernel_fp(void)
}
 }
 EXPORT_SYMBOL(enable_kernel_fp);
+
+void disable_kernel_fp(void)
+{
+   WARN_ON_ONCE(!this_cpu_read(in_kernel_fpu));
+
+   this_cpu_write(in_kernel_fpu, false);
+   msr_check_and_clear(MSR_FP);
+}
+EXPORT_SYMBOL(disable_kernel_fp);
 #else
 static inline void __giveup_fpu(struct task_struct *tsk) { }
 #endif /* CONFIG_PPC_FPU */
@@ -263,6 +286,9 @@ void enable_kernel_altivec(void)
unsigned long cpumsr;
 
WARN_ON(preemptible());
+   WARN_ON_ONCE(this_cpu_read(in_kernel_fpu));
+
+   this_cpu_write(in_kernel_fpu, true);
 
cpumsr = msr_check_and_set(MSR_VEC);
 
@@ -283,6 +309,14 @@ void enable_kernel_altivec(void)
 }
 EXPORT_SYMBOL(enable_kernel_altivec);
 
+void disable_kernel_altivec(void)
+{
+   WARN_ON_ONCE(!this_cpu_read(in_kernel_fpu));
+
+   this_cpu_write(in_kernel_fpu, false);
+   msr_check_and_clear(MSR_VEC);
+}
+EXPORT_SYMBOL(disable_kernel_alt

[RFC v2 0/2] PPC: Add generic FPU api similar to x86

2021-07-21 Thread Anson Jacob
This is an attempt to have generic FPU enable/disable
calls similar to x86. 
So that we can simplify gpu/drm/amd/display/dc/os_types.h

Also adds FPU correctness logic seen in x86.

v2:
- Added asm/fpu/api.h powerpc variant with kernel_fpu_begin/end()
  and kernel_fpu_enabled() declarations
- Updated kernel_fpu_enabled as EXPORT_SYMBOL_GPL
- Got rid of macro switch for PPC in dc/os_types.h as header file
  with same name as x86 is added by previous patch in the series

Anson Jacob (2):
  ppc/fpu: Add generic FPU api similar to x86
  drm/amd/display: Use PPC FPU functions

 arch/powerpc/include/asm/fpu/api.h|  18 +++
 arch/powerpc/include/asm/switch_to.h  |  25 +
 arch/powerpc/kernel/process.c | 130 ++
 drivers/gpu/drm/amd/display/dc/os_types.h |  29 -
 4 files changed, 151 insertions(+), 51 deletions(-)
 create mode 100644 arch/powerpc/include/asm/fpu/api.h

-- 
2.25.1

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


[PATCH] drm/amd/amdgpu: Add a new line to debugfs phy_settings output

2021-07-20 Thread Anson Jacob
Add new line to phy_settings output

Signed-off-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index 1d15a9af9956..87daa78a32b8 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -377,7 +377,7 @@ static ssize_t dp_phy_settings_read(struct file *f, char 
__user *buf,
if (!rd_buf)
return -EINVAL;
 
-   snprintf(rd_buf, rd_buf_size, "  %d  %d  %d  ",
+   snprintf(rd_buf, rd_buf_size, "  %d  %d  %d\n",
link->cur_lane_setting.VOLTAGE_SWING,
link->cur_lane_setting.PRE_EMPHASIS,
link->cur_lane_setting.POST_CURSOR2);
-- 
2.25.1

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


[PATCH] drm/amd/amdgpu: Update debugfs link_settings output link_rate field in hex

2021-07-20 Thread Anson Jacob
link_rate is updated via debugfs using hex values, set it to output
in hex as well.

eg: Resolution: 1920x1080@144Hz
cat /sys/kernel/debug/dri/0/DP-1/link_settings
Current:  4  0x14  0  Verified:  4  0x1e  0  Reported:  4  0x1e  16  Preferred: 
 0  0x0  0

echo "4 0x1e" > /sys/kernel/debug/dri/0/DP-1/link_settings

cat /sys/kernel/debug/dri/0/DP-1/link_settings
Current:  4  0x1e  0  Verified:  4  0x1e  0  Reported:  4  0x1e  16  Preferred: 
 4  0x1e  0

Signed-off-by: Anson Jacob 
---
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c| 16 
 1 file changed, 8 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index f1145086a468..1d15a9af9956 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -197,29 +197,29 @@ static ssize_t dp_link_settings_read(struct file *f, char 
__user *buf,
 
rd_buf_ptr = rd_buf;
 
-   str_len = strlen("Current:  %d  %d  %d  ");
-   snprintf(rd_buf_ptr, str_len, "Current:  %d  %d  %d  ",
+   str_len = strlen("Current:  %d  0x%x  %d  ");
+   snprintf(rd_buf_ptr, str_len, "Current:  %d  0x%x  %d  ",
link->cur_link_settings.lane_count,
link->cur_link_settings.link_rate,
link->cur_link_settings.link_spread);
rd_buf_ptr += str_len;
 
-   str_len = strlen("Verified:  %d  %d  %d  ");
-   snprintf(rd_buf_ptr, str_len, "Verified:  %d  %d  %d  ",
+   str_len = strlen("Verified:  %d  0x%x  %d  ");
+   snprintf(rd_buf_ptr, str_len, "Verified:  %d  0x%x  %d  ",
link->verified_link_cap.lane_count,
link->verified_link_cap.link_rate,
link->verified_link_cap.link_spread);
rd_buf_ptr += str_len;
 
-   str_len = strlen("Reported:  %d  %d  %d  ");
-   snprintf(rd_buf_ptr, str_len, "Reported:  %d  %d  %d  ",
+   str_len = strlen("Reported:  %d  0x%x  %d  ");
+   snprintf(rd_buf_ptr, str_len, "Reported:  %d  0x%x  %d  ",
link->reported_link_cap.lane_count,
link->reported_link_cap.link_rate,
link->reported_link_cap.link_spread);
rd_buf_ptr += str_len;
 
-   str_len = strlen("Preferred:  %d  %d  %d  ");
-   snprintf(rd_buf_ptr, str_len, "Preferred:  %d  %d  %d\n",
+   str_len = strlen("Preferred:  %d  0x%x  %d  ");
+   snprintf(rd_buf_ptr, str_len, "Preferred:  %d  0x%x  %d\n",
link->preferred_link_setting.lane_count,
link->preferred_link_setting.link_rate,
link->preferred_link_setting.link_spread);
-- 
2.25.1

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


[V2] drm/amdgpu: Fix documentaion for dm_dmub_outbox1_low_irq

2021-07-20 Thread Anson Jacob
Fix make htmldocs complaint:
./drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:628: warning: Excess 
function parameter 'interrupt_params' description in 'DMUB_TRACE_MAX_READ'

v2:
Moved DMUB_TRACE_MAX_READ macro above function documentation

Signed-off-by: Anson Jacob 
CC: Harry Wentland 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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 7ed104e3756b..829d31e04f09 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -618,6 +618,7 @@ static void dm_dcn_vertical_interrupt0_high_irq(void 
*interrupt_params)
 }
 #endif
 
+#define DMUB_TRACE_MAX_READ 64
 /**
  * dm_dmub_outbox1_low_irq() - Handles Outbox interrupt
  * @interrupt_params: used for determining the Outbox instance
@@ -625,7 +626,6 @@ static void dm_dcn_vertical_interrupt0_high_irq(void 
*interrupt_params)
  * Handles the Outbox Interrupt
  * event handler.
  */
-#define DMUB_TRACE_MAX_READ 64
 static void dm_dmub_outbox1_low_irq(void *interrupt_params)
 {
struct dmub_notification notify;
-- 
2.25.1

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


[RFC 0/2] Add generic FPU api similar to x86

2021-07-19 Thread Anson Jacob
This is an attempt to have generic FPU enable/disable
calls similar to x86. 
So that we can simplify gpu/drm/amd/display/dc/os_types.h

Also adds FPU correctness logic seen in x86.

Anson Jacob (2):
  ppc/fpu: Add generic FPU api similar to x86
  drm/amd/display: Use PPC FPU functions

 arch/powerpc/include/asm/switch_to.h  |  29 ++---
 arch/powerpc/kernel/process.c | 130 ++
 drivers/gpu/drm/amd/display/dc/os_types.h |  28 +
 3 files changed, 139 insertions(+), 48 deletions(-)

-- 
2.25.1

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


[RFC 1/2] ppc/fpu: Add generic FPU api similar to x86

2021-07-19 Thread Anson Jacob
- Add kernel_fpu_begin & kernel_fpu_end API as x86
- Add logic similar to x86 to ensure fpu
  begin/end call correctness
- Add kernel_fpu_enabled to know if FPU is enabled

Signed-off-by: Anson Jacob 
---
 arch/powerpc/include/asm/switch_to.h |  29 ++
 arch/powerpc/kernel/process.c| 130 +++
 2 files changed, 137 insertions(+), 22 deletions(-)

diff --git a/arch/powerpc/include/asm/switch_to.h 
b/arch/powerpc/include/asm/switch_to.h
index 9d1fbd8be1c7..aded7aa661c0 100644
--- a/arch/powerpc/include/asm/switch_to.h
+++ b/arch/powerpc/include/asm/switch_to.h
@@ -41,10 +41,7 @@ extern void enable_kernel_fp(void);
 extern void flush_fp_to_thread(struct task_struct *);
 extern void giveup_fpu(struct task_struct *);
 extern void save_fpu(struct task_struct *);
-static inline void disable_kernel_fp(void)
-{
-   msr_check_and_clear(MSR_FP);
-}
+extern void disable_kernel_fp(void);
 #else
 static inline void save_fpu(struct task_struct *t) { }
 static inline void flush_fp_to_thread(struct task_struct *t) { }
@@ -55,10 +52,7 @@ extern void enable_kernel_altivec(void);
 extern void flush_altivec_to_thread(struct task_struct *);
 extern void giveup_altivec(struct task_struct *);
 extern void save_altivec(struct task_struct *);
-static inline void disable_kernel_altivec(void)
-{
-   msr_check_and_clear(MSR_VEC);
-}
+extern void disable_kernel_altivec(void);
 #else
 static inline void save_altivec(struct task_struct *t) { }
 static inline void __giveup_altivec(struct task_struct *t) { }
@@ -67,20 +61,7 @@ static inline void __giveup_altivec(struct task_struct *t) { 
}
 #ifdef CONFIG_VSX
 extern void enable_kernel_vsx(void);
 extern void flush_vsx_to_thread(struct task_struct *);
-static inline void disable_kernel_vsx(void)
-{
-   msr_check_and_clear(MSR_FP|MSR_VEC|MSR_VSX);
-}
-#else
-static inline void enable_kernel_vsx(void)
-{
-   BUILD_BUG();
-}
-
-static inline void disable_kernel_vsx(void)
-{
-   BUILD_BUG();
-}
+extern void disable_kernel_vsx(void);
 #endif
 
 #ifdef CONFIG_SPE
@@ -114,4 +95,8 @@ static inline void clear_task_ebb(struct task_struct *t)
 
 extern int set_thread_tidr(struct task_struct *t);
 
+bool kernel_fpu_enabled(void);
+void kernel_fpu_begin(void);
+void kernel_fpu_end(void);
+
 #endif /* _ASM_POWERPC_SWITCH_TO_H */
diff --git a/arch/powerpc/kernel/process.c b/arch/powerpc/kernel/process.c
index 185beb290580..2ced8c6a3fab 100644
--- a/arch/powerpc/kernel/process.c
+++ b/arch/powerpc/kernel/process.c
@@ -75,6 +75,17 @@
 #define TM_DEBUG(x...) do { } while(0)
 #endif
 
+/*
+ * Track whether the kernel is using the FPU state
+ * currently.
+ *
+ * This flag is used:
+ *
+ *   - kernel_fpu_begin()/end() correctness
+ *   - kernel_fpu_enabled info
+ */
+static DEFINE_PER_CPU(bool, in_kernel_fpu);
+
 extern unsigned long _get_SP(void);
 
 #ifdef CONFIG_PPC_TRANSACTIONAL_MEM
@@ -212,6 +223,9 @@ void enable_kernel_fp(void)
unsigned long cpumsr;
 
WARN_ON(preemptible());
+   WARN_ON_ONCE(this_cpu_read(in_kernel_fpu));
+
+   this_cpu_write(in_kernel_fpu, true);
 
cpumsr = msr_check_and_set(MSR_FP);
 
@@ -231,6 +245,15 @@ void enable_kernel_fp(void)
}
 }
 EXPORT_SYMBOL(enable_kernel_fp);
+
+void disable_kernel_fp(void)
+{
+   WARN_ON_ONCE(!this_cpu_read(in_kernel_fpu));
+
+   this_cpu_write(in_kernel_fpu, false);
+   msr_check_and_clear(MSR_FP);
+}
+EXPORT_SYMBOL(disable_kernel_fp);
 #else
 static inline void __giveup_fpu(struct task_struct *tsk) { }
 #endif /* CONFIG_PPC_FPU */
@@ -263,6 +286,9 @@ void enable_kernel_altivec(void)
unsigned long cpumsr;
 
WARN_ON(preemptible());
+   WARN_ON_ONCE(this_cpu_read(in_kernel_fpu));
+
+   this_cpu_write(in_kernel_fpu, true);
 
cpumsr = msr_check_and_set(MSR_VEC);
 
@@ -283,6 +309,14 @@ void enable_kernel_altivec(void)
 }
 EXPORT_SYMBOL(enable_kernel_altivec);
 
+void disable_kernel_altivec(void)
+{
+   WARN_ON_ONCE(!this_cpu_read(in_kernel_fpu));
+
+   this_cpu_write(in_kernel_fpu, false);
+   msr_check_and_clear(MSR_VEC);
+}
+EXPORT_SYMBOL(disable_kernel_altivec);
 /*
  * Make sure the VMX/Altivec register state in the
  * the thread_struct is up to date for task tsk.
@@ -333,6 +367,9 @@ void enable_kernel_vsx(void)
unsigned long cpumsr;
 
WARN_ON(preemptible());
+   WARN_ON_ONCE(this_cpu_read(in_kernel_fpu));
+
+   this_cpu_write(in_kernel_fpu, true);
 
cpumsr = msr_check_and_set(MSR_FP|MSR_VEC|MSR_VSX);
 
@@ -354,6 +391,15 @@ void enable_kernel_vsx(void)
 }
 EXPORT_SYMBOL(enable_kernel_vsx);
 
+void disable_kernel_vsx(void)
+{
+   WARN_ON_ONCE(!this_cpu_read(in_kernel_fpu));
+
+   this_cpu_write(in_kernel_fpu, false);
+   msr_check_and_clear(MSR_FP|MSR_VEC|MSR_VSX);
+}
+EXPORT_SYMBOL(disable_kernel_vsx);
+
 void flush_vsx_to_thread(struct task_struct *tsk)
 {
if (tsk->thread.regs) {
@@ -406,6 +452,90 @@ void flush_spe_to_thread(struct task_stru

[RFC 2/2] drm/amd/display: Use PPC FPU functions

2021-07-19 Thread Anson Jacob
Use kernel_fpu_begin & kernel_fpu_end for PPC

Depends on "ppc/fpu: Add generic FPU api similar to x86"

Signed-off-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/dc/os_types.h | 28 ++-
 1 file changed, 2 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/os_types.h 
b/drivers/gpu/drm/amd/display/dc/os_types.h
index 126c2f3a4dd3..999c5103357e 100644
--- a/drivers/gpu/drm/amd/display/dc/os_types.h
+++ b/drivers/gpu/drm/amd/display/dc/os_types.h
@@ -57,32 +57,8 @@
 #define DC_FP_END() kernel_fpu_end()
 #elif defined(CONFIG_PPC64)
 #include 
-#include 
-#define DC_FP_START() { \
-   if (cpu_has_feature(CPU_FTR_VSX_COMP)) { \
-   preempt_disable(); \
-   enable_kernel_vsx(); \
-   } else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) { \
-   preempt_disable(); \
-   enable_kernel_altivec(); \
-   } else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) { \
-   preempt_disable(); \
-   enable_kernel_fp(); \
-   } \
-}
-#define DC_FP_END() { \
-   if (cpu_has_feature(CPU_FTR_VSX_COMP)) { \
-   disable_kernel_vsx(); \
-   preempt_enable(); \
-   } else if (cpu_has_feature(CPU_FTR_ALTIVEC_COMP)) { \
-   disable_kernel_altivec(); \
-   preempt_enable(); \
-   } else if (!cpu_has_feature(CPU_FTR_FPU_UNAVAILABLE)) { \
-   disable_kernel_fp(); \
-   preempt_enable(); \
-   } \
-}
-#endif
+#define DC_FP_START() kernel_fpu_begin()
+#define DC_FP_END() kernel_fpu_end()
 #endif
 
 /*
-- 
2.25.1

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


[PATCH] drm/amdgpu: Fix documentaion for dm_dmub_outbox1_low_irq

2021-07-19 Thread Anson Jacob
Fix make htmldocs complaint:
./drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c:628: warning: Excess 
function parameter 'interrupt_params' description in 'DMUB_TRACE_MAX_READ'

Signed-off-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

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 7ed104e3756b..02bba9a202a8 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -625,7 +625,6 @@ static void dm_dcn_vertical_interrupt0_high_irq(void 
*interrupt_params)
  * Handles the Outbox Interrupt
  * event handler.
  */
-#define DMUB_TRACE_MAX_READ 64
 static void dm_dmub_outbox1_low_irq(void *interrupt_params)
 {
struct dmub_notification notify;
@@ -635,6 +634,8 @@ static void dm_dmub_outbox1_low_irq(void *interrupt_params)
struct dmcub_trace_buf_entry entry = { 0 };
uint32_t count = 0;
 
+#define DMUB_TRACE_MAX_READ 64
+
if (dc_enable_dmub_notifications(adev->dm.dc)) {
if (irq_params->irq_src == DC_IRQ_SOURCE_DMCUB_OUTBOX) {
do {
-- 
2.25.1

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


[PATCH] drm/amdgpu: Fix documentaion for amdgpu_bo_add_to_shadow_list

2021-07-19 Thread Anson Jacob
make htmldocs complaints about parameter for amdgpu_bo_add_to_shadow_list

./drivers/gpu/drm/amd/amdgpu/amdgpu_object.c:739: warning: Excess function 
parameter 'bo' description in 'amdgpu_bo_add_to_shadow_list'
./drivers/gpu/drm/amd/amdgpu/amdgpu_object.c:739: warning: Function parameter 
or member 'vmbo' not described in 'amdgpu_bo_add_to_shadow_list'
./drivers/gpu/drm/amd/amdgpu/amdgpu_object.c:739: warning: Excess function 
parameter 'bo' description in 'amdgpu_bo_add_to_shadow_list'

Signed-off-by: Anson Jacob 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
index ea339eaac399..4e2c0270208f 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
@@ -755,7 +755,7 @@ int amdgpu_bo_validate(struct amdgpu_bo *bo)
 /**
  * amdgpu_bo_add_to_shadow_list - add a BO to the shadow list
  *
- * @bo: BO that will be inserted into the shadow list
+ * @vmbo: BO that will be inserted into the shadow list
  *
  * Insert a BO to the shadow list.
  */
-- 
2.25.1

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


[PATCH 18/24] drm/amd/display: Rename constant

2021-06-10 Thread Anson Jacob
From: Wesley Chalmers 

[WHY]
7 is the minimum number of retries TX must attempt on an AUX DEFER, not
the maximum.

Signed-off-by: Wesley Chalmers 
Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c | 6 +++---
 1 file changed, 3 insertions(+), 3 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 83d97dfe328f..9d5e09b188c2 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
@@ -615,7 +615,7 @@ int dce_aux_transfer_dmub_raw(struct ddc_service *ddc,
 }
 
 #define AUX_MAX_RETRIES 7
-#define AUX_MAX_DEFER_RETRIES 7
+#define AUX_MIN_DEFER_RETRIES 7
 #define AUX_MAX_I2C_DEFER_RETRIES 7
 #define AUX_MAX_INVALID_REPLY_RETRIES 2
 #define AUX_MAX_TIMEOUT_RETRIES 3
@@ -664,7 +664,7 @@ bool dce_aux_transfer_with_retries(struct ddc_service *ddc,
retry_on_defer = true;
fallthrough;
case AUX_TRANSACTION_REPLY_I2C_OVER_AUX_NACK:
-   if (++aux_defer_retries >= 
AUX_MAX_DEFER_RETRIES) {
+   if (++aux_defer_retries >= 
AUX_MIN_DEFER_RETRIES) {
goto fail;
} else {
if ((*payload->reply == 
AUX_TRANSACTION_REPLY_AUX_DEFER) ||
@@ -701,7 +701,7 @@ bool dce_aux_transfer_with_retries(struct ddc_service *ddc,
// Check whether a DEFER had occurred before the 
timeout.
// If so, treat timeout as a DEFER.
if (retry_on_defer) {
-   if (++aux_defer_retries >= 
AUX_MAX_DEFER_RETRIES)
+   if (++aux_defer_retries >= 
AUX_MIN_DEFER_RETRIES)
goto fail;
else if (payload->defer_delay > 0)
msleep(payload->defer_delay);
-- 
2.25.1

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


[PATCH 22/24] drm/amd/display: Add interface to get Calibrated Avg Level from FIFO

2021-06-10 Thread Anson Jacob
From: Wesley Chalmers 

[WHY]
Hardware has handed down a new sequence requiring the value of this
register be read from clk_mgr.

Signed-off-by: Wesley Chalmers 
Reviewed-by: Dmytro Laktyushkin 
Acked-by: Anson Jacob 
---
 .../display/dc/dcn10/dcn10_stream_encoder.h   | 24 +++
 .../display/dc/dcn20/dcn20_stream_encoder.c   | 12 ++
 .../display/dc/dcn20/dcn20_stream_encoder.h   |  3 +++
 .../dc/dcn30/dcn30_dio_stream_encoder.c   |  2 ++
 .../dc/dcn30/dcn30_dio_stream_encoder.h   | 12 ++
 .../amd/display/dc/inc/hw/stream_encoder.h|  3 +++
 .../include/asic_reg/dcn/dcn_3_0_1_sh_mask.h  |  2 ++
 .../include/asic_reg/dcn/dcn_3_1_2_sh_mask.h  |  2 ++
 8 files changed, 60 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h 
b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h
index 76b334644f9e..0d86df97878c 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h
+++ b/drivers/gpu/drm/amd/display/dc/dcn10/dcn10_stream_encoder.h
@@ -52,6 +52,7 @@
SRI(AFMT_60958_1, DIG, id), \
SRI(AFMT_60958_2, DIG, id), \
SRI(DIG_FE_CNTL, DIG, id), \
+   SRI(DIG_FIFO_STATUS, DIG, id), \
SRI(HDMI_CONTROL, DIG, id), \
SRI(HDMI_DB_CONTROL, DIG, id), \
SRI(HDMI_GC, DIG, id), \
@@ -124,6 +125,7 @@ struct dcn10_stream_enc_registers {
uint32_t AFMT_60958_2;
uint32_t DIG_FE_CNTL;
uint32_t DIG_FE_CNTL2;
+   uint32_t DIG_FIFO_STATUS;
uint32_t DP_MSE_RATE_CNTL;
uint32_t DP_MSE_RATE_UPDATE;
uint32_t DP_PIXEL_FORMAT;
@@ -266,6 +268,17 @@ struct dcn10_stream_enc_registers {
SE_SF(DIG0_DIG_FE_CNTL, TMDS_COLOR_FORMAT, mask_sh),\
SE_SF(DIG0_DIG_FE_CNTL, DIG_STEREOSYNC_SELECT, mask_sh),\
SE_SF(DIG0_DIG_FE_CNTL, DIG_STEREOSYNC_GATE_EN, mask_sh),\
+   SE_SF(DIG0_DIG_FIFO_STATUS, DIG_FIFO_LEVEL_ERROR, mask_sh),\
+   SE_SF(DIG0_DIG_FIFO_STATUS, DIG_FIFO_USE_OVERWRITE_LEVEL, mask_sh),\
+   SE_SF(DIG0_DIG_FIFO_STATUS, DIG_FIFO_OVERWRITE_LEVEL, mask_sh),\
+   SE_SF(DIG0_DIG_FIFO_STATUS, DIG_FIFO_ERROR_ACK, mask_sh),\
+   SE_SF(DIG0_DIG_FIFO_STATUS, DIG_FIFO_CAL_AVERAGE_LEVEL, mask_sh),\
+   SE_SF(DIG0_DIG_FIFO_STATUS, DIG_FIFO_MAXIMUM_LEVEL, mask_sh),\
+   SE_SF(DIG0_DIG_FIFO_STATUS, DIG_FIFO_MINIMUM_LEVEL, mask_sh),\
+   SE_SF(DIG0_DIG_FIFO_STATUS, DIG_FIFO_READ_CLOCK_SRC, mask_sh),\
+   SE_SF(DIG0_DIG_FIFO_STATUS, DIG_FIFO_CALIBRATED, mask_sh),\
+   SE_SF(DIG0_DIG_FIFO_STATUS, DIG_FIFO_FORCE_RECAL_AVERAGE, mask_sh),\
+   SE_SF(DIG0_DIG_FIFO_STATUS, DIG_FIFO_FORCE_RECOMP_MINMAX, mask_sh),\
SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL, AFMT_GENERIC_LOCK_STATUS, mask_sh),\
SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL, AFMT_GENERIC_CONFLICT, mask_sh),\
SE_SF(DIG0_AFMT_VBI_PACKET_CONTROL, AFMT_GENERIC_CONFLICT_CLR, 
mask_sh),\
@@ -488,6 +501,17 @@ struct dcn10_stream_enc_registers {
type DP_VID_N_MUL;\
type DP_VID_M_DOUBLE_VALUE_EN;\
type DIG_SOURCE_SELECT;\
+   type DIG_FIFO_LEVEL_ERROR;\
+   type DIG_FIFO_USE_OVERWRITE_LEVEL;\
+   type DIG_FIFO_OVERWRITE_LEVEL;\
+   type DIG_FIFO_ERROR_ACK;\
+   type DIG_FIFO_CAL_AVERAGE_LEVEL;\
+   type DIG_FIFO_MAXIMUM_LEVEL;\
+   type DIG_FIFO_MINIMUM_LEVEL;\
+   type DIG_FIFO_READ_CLOCK_SRC;\
+   type DIG_FIFO_CALIBRATED;\
+   type DIG_FIFO_FORCE_RECAL_AVERAGE;\
+   type DIG_FIFO_FORCE_RECOMP_MINMAX;\
type DIG_CLOCK_PATTERN
 
 #define SE_REG_FIELD_LIST_DCN2_0(type) \
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c 
b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c
index 4075ae111530..e6307397e0d2 100644
--- a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c
+++ b/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.c
@@ -552,6 +552,17 @@ void enc2_stream_encoder_dp_set_stream_attribute(
DP_SST_SDP_SPLITTING, enable_sdp_splitting);
 }
 
+uint32_t enc2_get_fifo_cal_average_level(
+   struct stream_encoder *enc)
+{
+   struct dcn10_stream_encoder *enc1 = DCN10STRENC_FROM_STRENC(enc);
+   uint32_t fifo_level;
+
+   REG_GET(DIG_FIFO_STATUS,
+   DIG_FIFO_CAL_AVERAGE_LEVEL, &fifo_level);
+   return fifo_level;
+}
+
 static const struct stream_encoder_funcs dcn20_str_enc_funcs = {
.dp_set_odm_combine =
enc2_dp_set_odm_combine,
@@ -598,6 +609,7 @@ static const struct stream_encoder_funcs 
dcn20_str_enc_funcs = {
.dp_set_dsc_pps_info_packet = enc2_dp_set_dsc_pps_info_packet,
.set_dynamic_metadata = enc2_set_dynamic_metadata,
.hdmi_reset_stream_attribute = enc1_reset_hdmi_stream_attribute,
+   .get_fifo_cal_average_level = enc2_get_fifo_cal_average_level,
 };
 
 void dcn20_stream_encoder_construct(
diff --git a/drivers/gpu/drm/amd/display/dc/dcn20/dcn20_stream_encoder.h 
b/drivers/gpu/drm/amd/display/dc/d

[PATCH 14/24] drm/amd/display: Set LTTPR Transparent Mode after read link cap

2021-06-10 Thread Anson Jacob
From: Wesley Chalmers 

[WHY]
SCR for DP 2.0 Spec states that a DPTX shall put LTTPRs into Transparent
mode after reading LTTPR Capability registers on HPD.

The wording of the SCR is somewhat ambiguous as to whether
Transparent mode must be set explicity, or is implicitly set on LTTPR
capability read. Explicitly setting Transparent mode after LTTPR
capability read should cover all
cases.

Signed-off-by: Wesley Chalmers 
Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
---
 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 38fabaff51ea..586f05a6cd77 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
@@ -3705,9 +3705,10 @@ bool dp_retrieve_lttpr_cap(struct dc_link *link)
link->dpcd_caps.lttpr_caps.max_lane_count > 0 &&
link->dpcd_caps.lttpr_caps.max_lane_count <= 4 
&&
link->dpcd_caps.lttpr_caps.revision.raw >= 
0x14);
-   if (is_lttpr_present)
+   if (is_lttpr_present) {
CONN_DATA_DETECT(link, lttpr_dpcd_data, 
sizeof(lttpr_dpcd_data), "LTTPR Caps: ");
-   else
+   configure_lttpr_mode_transparent(link);
+   } else
link->lttpr_mode = LTTPR_MODE_NON_LTTPR;
}
return is_lttpr_present;
-- 
2.25.1

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


[PATCH 16/24] drm/amd/display: Improve logic for is_lttpr_present

2021-06-10 Thread Anson Jacob
From: Wesley Chalmers 

[WHY]
DP specifies that an LTTPR device is only present if PHY_REPEATER_CNT is
0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, or 0x01.

All other values should be considered no LTTPRs present.

[HOW]
Function dp_convert_to_count already does this check. Use it to determine
if PHY_REPEATER_CNT is a valid LTTPR count.

Signed-off-by: Wesley Chalmers 
Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 3 +--
 1 file changed, 1 insertion(+), 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 c68b49a14f88..7e52bb3047bc 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
@@ -3699,8 +3699,7 @@ bool dp_retrieve_lttpr_cap(struct dc_link *link)

DP_LT_TUNABLE_PHY_REPEATER_FIELD_DATA_STRUCTURE_REV];
 
/* Attempt to train in LTTPR transparent mode if repeater count 
exceeds 8. */
-   is_lttpr_present = (link->dpcd_caps.lttpr_caps.phy_repeater_cnt 
> 0 &&
-   link->dpcd_caps.lttpr_caps.phy_repeater_cnt < 
0xff &&
+   is_lttpr_present = 
(dp_convert_to_count(link->dpcd_caps.lttpr_caps.phy_repeater_cnt) != 0 &&
link->dpcd_caps.lttpr_caps.max_lane_count > 0 &&
link->dpcd_caps.lttpr_caps.max_lane_count <= 4 
&&
link->dpcd_caps.lttpr_caps.revision.raw >= 
0x14);
-- 
2.25.1

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


[PATCH 04/24] drm/amd/display: tune backlight ramping profiles

2021-06-10 Thread Anson Jacob
From: Josip Pavic 

[Why & How]
Tune backlight ramping profiles for each Vari-Bright level to suit
customer preferences

Signed-off-by: Josip Pavic 
Reviewed-by: Anthony Koo 
Acked-by: Anson Jacob 
---
 .../amd/display/modules/power/power_helpers.c | 20 +--
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/modules/power/power_helpers.c 
b/drivers/gpu/drm/amd/display/modules/power/power_helpers.c
index 5e7331be1c0d..2b00f334e93d 100644
--- a/drivers/gpu/drm/amd/display/modules/power/power_helpers.c
+++ b/drivers/gpu/drm/amd/display/modules/power/power_helpers.c
@@ -87,19 +87,19 @@ struct abm_parameters {
 };
 
 static const struct abm_parameters abm_settings_config0[abm_defines_max_level] 
= {
-//  min_red  max_red  bright_pos  dark_pos  bright_gain  contrast  dev   
min_knee  max_knee  blStart  blRed
-   {0xff,   0xbf,0x20,   0x00, 0xff,0x99, 0xb3, 0x40,  
   0xe0, 0x,  0x},
-   {0xde,   0x85,0x20,   0x00, 0xff,0x90, 0xa8, 0x40,  
   0xdf, 0x,  0x},
-   {0xb0,   0x50,0x20,   0x00, 0xc0,0x88, 0x78, 0x70,  
   0xa0, 0x,  0x},
-   {0x82,   0x40,0x20,   0x00, 0x00,0xff, 0xb3, 0x70,  
   0x70, 0x,  0x},
+//  min_red  max_red  bright_pos  dark_pos  bright_gain  contrast  dev   
min_knee  max_knee  blRedblStart
+   {0xff,   0xbf,0x20,   0x00, 0xff,0x99, 0xb3, 
0x40, 0xe0, 0xf777,  0x},
+   {0xde,   0x85,0x20,   0x00, 0xe0,0x90, 0xa8, 
0x40, 0xc8, 0xf777,  0x},
+   {0xb0,   0x50,0x20,   0x00, 0xc0,0x88, 0x78, 
0x70, 0xa0, 0x,  0x},
+   {0x82,   0x40,0x20,   0x00, 0x00,0xb8, 0xb3, 
0x70, 0x70, 0xe333,  0xb333},
 };
 
 static const struct abm_parameters abm_settings_config1[abm_defines_max_level] 
= {
-//  min_red  max_red  bright_pos  dark_pos  bright_gain  contrast  dev   
min_knee  max_knee  blStart  blRed
-   {0xf0,   0xd9,0x20,   0x00, 0x00,0xff, 0xb3, 0x70,  
   0x70, 0x,  0x},
-   {0xcd,   0xa5,0x20,   0x00, 0x00,0xff, 0xb3, 0x70,  
   0x70, 0x,  0x},
-   {0x99,   0x65,0x20,   0x00, 0x00,0xff, 0xb3, 0x70,  
   0x70, 0x,  0x},
-   {0x82,   0x4d,0x20,   0x00, 0x00,0xff, 0xb3, 0x70,  
   0x70, 0x,  0x},
+//  min_red  max_red  bright_pos  dark_pos  bright_gain  contrast  dev   
min_knee  max_knee  blRed  blStart
+   {0xf0,   0xd9,0x20,   0x00, 0x00,0xff, 0xb3, 
0x70, 0x70, 0x,  0x},
+   {0xcd,   0xa5,0x20,   0x00, 0x00,0xff, 0xb3, 
0x70, 0x70, 0x,  0x},
+   {0x99,   0x65,0x20,   0x00, 0x00,0xff, 0xb3, 
0x70, 0x70, 0x,  0x},
+   {0x82,   0x4d,0x20,   0x00, 0x00,0xff, 0xb3, 
0x70, 0x70, 0x,  0x},
 };
 
 static const struct abm_parameters * const abm_settings[] = {
-- 
2.25.1

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


[PATCH 23/24] drm/amd/display: Cover edge-case when changing DISPCLK WDIVIDER

2021-06-10 Thread Anson Jacob
From: Wesley Chalmers 

[WHY]
When changing the DISPCLK_WDIVIDER value from 126 to 127, the change in
clock rate is too great for the FIFOs to handle. This can cause visible
corruption during clock change.

HW has handed down this register sequence to fix the issue.

[HOW]
The sequence, from HW:
a.  127 -> 126
Read  DIG_FIFO_CAL_AVERAGE_LEVEL
FIFO level N = DIG_FIFO_CAL_AVERAGE_LEVEL / 4
Set DCCG_FIFO_ERRDET_OVR_EN = 1
Write 1 to OTGx_DROP_PIXEL for (N-4) times
Set DCCG_FIFO_ERRDET_OVR_EN = 0
Write DENTIST_DISPCLK_RDIVIDER = 126

Because of frequency stepping, sequence a can be executed to change the
divider from 127 to any other divider value.

b.  126 -> 127
Read  DIG_FIFO_CAL_AVERAGE_LEVEL
FIFO level N = DIG_FIFO_CAL_AVERAGE_LEVEL / 4
Set DCCG_FIFO_ERRDET_OVR_EN = 1
Write 1 to OTGx_ADD_PIXEL for (12-N) times
Set DCCG_FIFO_ERRDET_OVR_EN = 0
Write DENTIST_DISPCLK_RDIVIDER = 127

Because of frequency stepping, divider must first be set from any other
divider value to 126 before executing sequence b.

Signed-off-by: Wesley Chalmers 
Reviewed-by: Dmytro Laktyushkin 
Acked-by: Anson Jacob 
---
 .../display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c  | 68 ++-
 .../display/dc/clk_mgr/dcn20/dcn20_clk_mgr.h  |  3 +-
 .../display/dc/clk_mgr/dcn30/dcn30_clk_mgr.c  |  4 +-
 3 files changed, 69 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c 
b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c
index 59d17195bc22..9d1db74de36d 100644
--- a/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c
+++ b/drivers/gpu/drm/amd/display/dc/clk_mgr/dcn20/dcn20_clk_mgr.c
@@ -123,7 +123,7 @@ void dcn20_update_clocks_update_dpp_dto(struct 
clk_mgr_internal *clk_mgr,
}
 }
 
-void dcn20_update_clocks_update_dentist(struct clk_mgr_internal *clk_mgr)
+void dcn20_update_clocks_update_dentist(struct clk_mgr_internal *clk_mgr, 
struct dc_state *context)
 {
int dpp_divider = DENTIST_DIVIDER_RANGE_SCALE_FACTOR
* clk_mgr->base.dentist_vco_freq_khz / 
clk_mgr->base.clks.dppclk_khz;
@@ -132,6 +132,68 @@ void dcn20_update_clocks_update_dentist(struct 
clk_mgr_internal *clk_mgr)
 
uint32_t dppclk_wdivider = dentist_get_did_from_divider(dpp_divider);
uint32_t dispclk_wdivider = dentist_get_did_from_divider(disp_divider);
+   uint32_t current_dispclk_wdivider;
+   uint32_t i;
+
+   REG_GET(DENTIST_DISPCLK_CNTL,
+   DENTIST_DISPCLK_WDIVIDER, ¤t_dispclk_wdivider);
+
+   /* When changing divider to or from 127, some extra programming is 
required to prevent corruption */
+   if (current_dispclk_wdivider == 127 && dispclk_wdivider != 127) {
+   for (i = 0; i < clk_mgr->base.ctx->dc->res_pool->pipe_count; 
i++) {
+   struct pipe_ctx *pipe_ctx = 
&context->res_ctx.pipe_ctx[i];
+   uint32_t fifo_level;
+   struct dccg *dccg = 
clk_mgr->base.ctx->dc->res_pool->dccg;
+   struct stream_encoder *stream_enc = 
pipe_ctx->stream_res.stream_enc;
+   int32_t N;
+   int32_t j;
+
+   if (!pipe_ctx->stream)
+   continue;
+   /* Virtual encoders don't have this function */
+   if (!stream_enc->funcs->get_fifo_cal_average_level)
+   continue;
+   fifo_level = 
stream_enc->funcs->get_fifo_cal_average_level(
+   stream_enc);
+   N = fifo_level / 4;
+   dccg->funcs->set_fifo_errdet_ovr_en(
+   dccg,
+   true);
+   for (j = 0; j < N - 4; j++)
+   dccg->funcs->otg_drop_pixel(
+   dccg,
+   pipe_ctx->stream_res.tg->inst);
+   dccg->funcs->set_fifo_errdet_ovr_en(
+   dccg,
+   false);
+   }
+   } else if (dispclk_wdivider == 127 && current_dispclk_wdivider != 127) {
+   REG_UPDATE(DENTIST_DISPCLK_CNTL,
+   DENTIST_DISPCLK_WDIVIDER, 126);
+   REG_WAIT(DENTIST_DISPCLK_CNTL, DENTIST_DISPCLK_CHG_DONE, 1, 50, 
100);
+   for (i = 0; i < clk_mgr->base.ctx->dc->res_pool->pipe_count; 
i++) {
+   struct pipe_ctx *pipe_ctx = 
&context->res_ctx.pipe_ctx[i];
+   struct dccg *dccg = 
clk_mgr->base.ctx->dc->res_pool->dccg;
+   struct stream_encoder *stream_enc = 
pipe_ctx->stream_res.stream

[PATCH 21/24] drm/amd/display: Partition DPCD address space and break up transactions

2021-06-10 Thread Anson Jacob
From: Wesley Chalmers 

[WHY]
SCR for DP 2.0 spec says that multiple LTTPRs must not be accessed in a
single AUX transaction.
There may be other places in future where breaking up AUX accesses is
necessary.

[HOW]
Partition the entire DPCD address space into blocks. When an incoming AUX
request spans multiple blocks, break up the request into multiple requests.

Signed-off-by: Wesley Chalmers 
Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
---
 .../drm/amd/display/dc/core/dc_link_dpcd.c| 87 ++-
 include/drm/drm_dp_helper.h   | 17 
 2 files changed, 102 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dpcd.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dpcd.c
index 8957565f87bc..27ec1e6e9c43 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_dpcd.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dpcd.c
@@ -43,6 +43,60 @@ static enum dc_status internal_link_write_dpcd(
return DC_OK;
 }
 
+/*
+ * Partition the entire DPCD address space
+ * XXX: This partitioning must cover the entire DPCD address space,
+ * and must contain no gaps or overlapping address ranges.
+ */
+static const struct dpcd_address_range mandatory_dpcd_partitions[] = {
+   { 0, DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR1) - 1},
+   { DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR1), 
DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR2) - 1 },
+   { DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR2), 
DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR3) - 1 },
+   { DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR3), 
DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR4) - 1 },
+   { DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR4), 
DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR5) - 1 },
+   { DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR5), 
DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR6) - 1 },
+   { DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR6), 
DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR7) - 1 },
+   { DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR7), 
DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR8) - 1 },
+   { DP_TRAINING_PATTERN_SET_PHY_REPEATER(DP_PHY_LTTPR8), 
DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR1) - 1 },
+   /*
+* The FEC registers are contiguous
+*/
+   { DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR1), 
DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR1) - 1 },
+   { DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR2), 
DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR2) - 1 },
+   { DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR3), 
DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR3) - 1 },
+   { DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR4), 
DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR4) - 1 },
+   { DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR5), 
DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR5) - 1 },
+   { DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR6), 
DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR6) - 1 },
+   { DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR7), 
DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR7) - 1 },
+   { DP_FEC_STATUS_PHY_REPEATER(DP_PHY_LTTPR8), DP_LTTPR_MAX_ADD },
+   /* all remaining DPCD addresses */
+   { DP_LTTPR_MAX_ADD + 1, DP_DPCD_MAX_ADD } };
+
+static inline bool do_addresses_intersect_with_range(
+   const struct dpcd_address_range *range,
+   const uint32_t start_address,
+   const uint32_t end_address)
+{
+   return start_address <= range->end && end_address >= range->start;
+}
+
+static uint32_t dpcd_get_next_partition_size(const uint32_t address, const 
uint32_t size)
+{
+   const uint32_t end_address = END_ADDRESS(address, size);
+   uint32_t partition_iterator = 0;
+
+   /*
+* find current partition
+* this loop spins forever if partition map above is not surjective
+*/
+   while 
(!do_addresses_intersect_with_range(&mandatory_dpcd_partitions[partition_iterator],
+   address, end_address))
+   partition_iterator++;
+   if (end_address < mandatory_dpcd_partitions[partition_iterator].end)
+   return size;
+   return ADDRESS_RANGE_SIZE(address, 
mandatory_dpcd_partitions[partition_iterator].end);
+}
+
 /*
  * Ranges of DPCD addresses that must be read in a single transaction
  * XXX: Do not allow any two address ranges in this array to overlap
@@ -115,12 +169,28 @@ enum dc_status core_link_read_dpcd(
uint32_t size)
 {
uint32_t extended_address;
+   uint32_t partitioned_address;
uint8_t *extended_data;
uint32_t extended_size;
+   /* size of the remaining partitioned address space */
+   uint32_t size_left_to_read;
enum dc_status status;
+   /* size of the next partition to be read from */
+   uint32_t partition_size;
+   uint32_t data_index = 0;
 
dpcd_extend_address_range(address, data, size, &extended_address, 

[PATCH 19/24] drm/amd/display: 7 retries + 50 ms timeout on AUX DEFER

2021-06-10 Thread Anson Jacob
From: Wesley Chalmers 

[WHY]
DP 2.0 SCR specifies that TX devices must retry at least 7 times when
receiving an AUX DEFER reply from RX. In addition, the specification
states that the TX shall not retry indefinitely, and gives a suggestive
timeout interval of 50ms.

[HOW]
Keep retrying until both 7 or more retries have been made, and the 50ms
interval has passed.

Signed-off-by: Wesley Chalmers 
Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/dc/dce/dce_aux.c | 18 +++---
 1 file changed, 15 insertions(+), 3 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 9d5e09b188c2..49cb4e6d6411 100644
--- a/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
+++ b/drivers/gpu/drm/amd/display/dc/dce/dce_aux.c
@@ -616,6 +616,7 @@ int dce_aux_transfer_dmub_raw(struct ddc_service *ddc,
 
 #define AUX_MAX_RETRIES 7
 #define AUX_MIN_DEFER_RETRIES 7
+#define AUX_MAX_DEFER_TIMEOUT_MS 50
 #define AUX_MAX_I2C_DEFER_RETRIES 7
 #define AUX_MAX_INVALID_REPLY_RETRIES 2
 #define AUX_MAX_TIMEOUT_RETRIES 3
@@ -628,6 +629,10 @@ bool dce_aux_transfer_with_retries(struct ddc_service *ddc,
bool payload_reply = true;
enum aux_return_code_type operation_result;
bool retry_on_defer = false;
+   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);
+   uint32_t defer_time_in_ms = 0;
 
int aux_ack_retries = 0,
aux_defer_retries = 0,
@@ -660,19 +665,26 @@ bool dce_aux_transfer_with_retries(struct ddc_service 
*ddc,
break;
 
case AUX_TRANSACTION_REPLY_AUX_DEFER:
+   /* polling_timeout_period is in us */
+   defer_time_in_ms += 
aux110->polling_timeout_period / 1000;
+   /* fall through */
case AUX_TRANSACTION_REPLY_I2C_OVER_AUX_DEFER:
retry_on_defer = true;
fallthrough;
case AUX_TRANSACTION_REPLY_I2C_OVER_AUX_NACK:
-   if (++aux_defer_retries >= 
AUX_MIN_DEFER_RETRIES) {
+   if (++aux_defer_retries >= AUX_MIN_DEFER_RETRIES
+   && defer_time_in_ms >= 
AUX_MAX_DEFER_TIMEOUT_MS) {
goto fail;
} else {
if ((*payload->reply == 
AUX_TRANSACTION_REPLY_AUX_DEFER) ||
(*payload->reply == 
AUX_TRANSACTION_REPLY_I2C_OVER_AUX_DEFER)) {
-   if (payload->defer_delay > 1)
+   if (payload->defer_delay > 1) {

msleep(payload->defer_delay);
-   else if (payload->defer_delay 
<= 1)
+   defer_time_in_ms += 
payload->defer_delay;
+   } else if (payload->defer_delay 
<= 1) {

udelay(payload->defer_delay * 1000);
+   defer_time_in_ms += 
payload->defer_delay;
+   }
}
}
break;
-- 
2.25.1

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


[PATCH 17/24] drm/amd/display: Enforce DPCD Address ranges

2021-06-10 Thread Anson Jacob
From: Wesley Chalmers 

[WHY]
Some DPCD addresses, notably LTTPR Capability registers, are expected to
be read all together in a single DPCD transaction. Rather than force callers to
read registers they don't need, we want to quietly extend the addresses
read, and only return back the values the caller asked for.
This does not affect DPCD writes.

[HOW]
Create an additional layer above AUX to perform 'checked' DPCD
transactions.
Iterate through an array of DPCD address ranges that are marked as being
contiguous. If a requested read falls within one of those ranges, extend
the read to include the entire range.
After DPCD has been queried, copy the requested bytes into the caller's
data buffer, and deallocate all resources used.

Signed-off-by: Wesley Chalmers 
Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/dc/Makefile   |   2 +-
 drivers/gpu/drm/amd/display/dc/core/dc_link.c |   1 +
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  |   2 +
 .../drm/amd/display/dc/core/dc_link_dpcd.c| 135 ++
 .../drm/amd/display/dc/core/dc_link_hwss.c|  31 +---
 .../amd/display/dc/dcn10/dcn10_hw_sequencer.c |   1 +
 .../drm/amd/display/dc/dcn30/dcn30_hwseq.c|   1 +
 .../drm/amd/display/dc/dcn31/dcn31_hwseq.c|   1 +
 .../gpu/drm/amd/display/dc/hdcp/hdcp_msg.c|   1 +
 .../gpu/drm/amd/display/dc/inc/link_dpcd.h|  18 +++
 .../gpu/drm/amd/display/dc/inc/link_hwss.h|  14 --
 11 files changed, 162 insertions(+), 45 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/dc/core/dc_link_dpcd.c
 create mode 100644 drivers/gpu/drm/amd/display/dc/inc/link_dpcd.h

diff --git a/drivers/gpu/drm/amd/display/dc/Makefile 
b/drivers/gpu/drm/amd/display/dc/Makefile
index 95aca9b0ef7f..34fc36e77595 100644
--- a/drivers/gpu/drm/amd/display/dc/Makefile
+++ b/drivers/gpu/drm/amd/display/dc/Makefile
@@ -60,7 +60,7 @@ include $(AMD_DC)
 
 DISPLAY_CORE = dc.o  dc_stat.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 \
-dc_link_enc_cfg.o
+dc_link_enc_cfg.o dc_link_dpcd.o
 
 ifdef CONFIG_DRM_AMD_DC_DCN
 DISPLAY_CORE += dc_vm_helper.o
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 05c963a5b789..9058e45add92 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -49,6 +49,7 @@
 #include "dmub/dmub_srv.h"
 #include "inc/hw/panel_cntl.h"
 #include "inc/link_enc_cfg.h"
+#include "inc/link_dpcd.h"
 
 #define DC_LOGGER_INIT(logger)
 
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 7e52bb3047bc..1b28b4a40f62 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
@@ -25,6 +25,8 @@ static const uint8_t DP_VGA_LVDS_CONVERTER_ID_3[] = "dnomlA";
link->ctx->logger
 #define DC_TRACE_LEVEL_MESSAGE(...) /* do nothing */
 
+#include "link_dpcd.h"
+
/* maximum pre emphasis level allowed for each voltage swing level*/
static const enum dc_pre_emphasis
voltage_swing_to_pre_emphasis[] = { PRE_EMPHASIS_LEVEL3,
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_dpcd.c 
b/drivers/gpu/drm/amd/display/dc/core/dc_link_dpcd.c
new file mode 100644
index ..8957565f87bc
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_dpcd.c
@@ -0,0 +1,135 @@
+#include 
+#include 
+#include 
+#include 
+#include "drm/drm_dp_helper.h"
+#include 
+#include "dm_helpers.h"
+
+#define END_ADDRESS(start, size) (start + size - 1)
+#define ADDRESS_RANGE_SIZE(start, end) (end - start + 1)
+struct dpcd_address_range {
+   uint32_t start;
+   uint32_t end;
+};
+
+static enum dc_status internal_link_read_dpcd(
+   struct dc_link *link,
+   uint32_t address,
+   uint8_t *data,
+   uint32_t size)
+{
+   if (!link->aux_access_disabled &&
+   !dm_helpers_dp_read_dpcd(link->ctx,
+   link, address, data, size)) {
+   return DC_ERROR_UNEXPECTED;
+   }
+
+   return DC_OK;
+}
+
+static enum dc_status internal_link_write_dpcd(
+   struct dc_link *link,
+   uint32_t address,
+   const uint8_t *data,
+   uint32_t size)
+{
+   if (!link->aux_access_disabled &&
+   !dm_helpers_dp_write_dpcd(link->ctx,
+   link, address, data, size)) {
+   return DC_ERROR_UNEXPECTED;
+   }
+
+   return DC_OK;
+}
+
+/*
+ * Ranges of DPCD addresses that must be read in a single transaction
+ * XXX: Do not allow any two address ranges in this array to overlap
+ */
+static const struct dpcd_address_range mandatory_dpcd_blocks[] = {
+   { DP_LT_TUNABLE_PHY

[PATCH 24/24] drm/amd/display: Extend AUX timeout for DP initial reads

2021-06-10 Thread Anson Jacob
From: Wesley Chalmers 

[WHY]
DP LL Compliance tests require that the first DPCD transactions after a
hotplug have a timeout interval of 3.2 ms.  In cases where LTTPR is
disabled, this means that the first reads from DP_SET_POWER and DP_DPCD_REV 
must have an extended
timeout.

Signed-off-by: Wesley Chalmers 
Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 7 +++
 1 file changed, 3 insertions(+), 4 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 1b28b4a40f62..5ecbe525b676 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
@@ -3750,9 +3750,6 @@ static bool retrieve_link_cap(struct dc_link *link)
LINK_AUX_DEFAULT_LTTPR_TIMEOUT_PERIOD);
 
is_lttpr_present = dp_retrieve_lttpr_cap(link);
-   if (!is_lttpr_present)
-   dc_link_aux_try_to_configure_timeout(link->ddc, 
LINK_AUX_DEFAULT_TIMEOUT_PERIOD);
-
 
status = core_link_read_dpcd(link, DP_SET_POWER,
&dpcd_power_state, sizeof(dpcd_power_state));
@@ -3781,12 +3778,14 @@ static bool retrieve_link_cap(struct dc_link *link)
break;
}
 
-
if (status != DC_OK) {
dm_error("%s: Read receiver caps dpcd data failed.\n", 
__func__);
return false;
}
 
+   if (!is_lttpr_present)
+   dc_link_aux_try_to_configure_timeout(link->ddc, 
LINK_AUX_DEFAULT_TIMEOUT_PERIOD);
+
{
union training_aux_rd_interval aux_rd_interval;
 
-- 
2.25.1

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


[PATCH 11/24] drm/amd/display: Read LTTPR caps first on hotplug

2021-06-10 Thread Anson Jacob
From: Wesley Chalmers 

[WHY]
A new SCR for the DP2.0 spec requires that LTTPR caps be the first thing
read from DPCD upon hotplug.

Signed-off-by: Wesley Chalmers 
Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
---
 .../gpu/drm/amd/display/dc/core/dc_link_dp.c  | 65 ++-
 1 file changed, 33 insertions(+), 32 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 7024589791fe..0e2741cd5f26 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
@@ -3660,38 +3660,6 @@ static bool retrieve_link_cap(struct dc_link *link)
dc_link_aux_try_to_configure_timeout(link->ddc,
LINK_AUX_DEFAULT_LTTPR_TIMEOUT_PERIOD);
 
-   status = core_link_read_dpcd(link, DP_SET_POWER,
-   &dpcd_power_state, sizeof(dpcd_power_state));
-
-   /* Delay 1 ms if AUX CH is in power down state. Based on spec
-* section 2.3.1.2, if AUX CH may be powered down due to
-* write to DPCD 600h = 2. Sink AUX CH is monitoring differential
-* signal and may need up to 1 ms before being able to reply.
-*/
-   if (status != DC_OK || dpcd_power_state == DP_SET_POWER_D3)
-   udelay(1000);
-
-   dpcd_set_source_specific_data(link);
-   /* Sink may need to configure internals based on vendor, so allow some
-* time before proceeding with possibly vendor specific transactions
-*/
-   msleep(post_oui_delay);
-
-   for (i = 0; i < read_dpcd_retry_cnt; i++) {
-   status = core_link_read_dpcd(
-   link,
-   DP_DPCD_REV,
-   dpcd_data,
-   sizeof(dpcd_data));
-   if (status == DC_OK)
-   break;
-   }
-
-   if (status != DC_OK) {
-   dm_error("%s: Read dpcd data failed.\n", __func__);
-   return false;
-   }
-
/* Query BIOS to determine if LTTPR functionality is forced on by 
system */
if (bios->funcs->get_lttpr_caps) {
enum bp_result bp_query_result;
@@ -3778,6 +3746,39 @@ static bool retrieve_link_cap(struct dc_link *link)
dc_link_aux_try_to_configure_timeout(link->ddc, 
LINK_AUX_DEFAULT_TIMEOUT_PERIOD);
 
 
+   status = core_link_read_dpcd(link, DP_SET_POWER,
+   &dpcd_power_state, sizeof(dpcd_power_state));
+
+   /* Delay 1 ms if AUX CH is in power down state. Based on spec
+* section 2.3.1.2, if AUX CH may be powered down due to
+* write to DPCD 600h = 2. Sink AUX CH is monitoring differential
+* signal and may need up to 1 ms before being able to reply.
+*/
+   if (status != DC_OK || dpcd_power_state == DP_SET_POWER_D3)
+   udelay(1000);
+
+   dpcd_set_source_specific_data(link);
+   /* Sink may need to configure internals based on vendor, so allow some
+* time before proceeding with possibly vendor specific transactions
+*/
+   msleep(post_oui_delay);
+
+   for (i = 0; i < read_dpcd_retry_cnt; i++) {
+   status = core_link_read_dpcd(
+   link,
+   DP_DPCD_REV,
+   dpcd_data,
+   sizeof(dpcd_data));
+   if (status == DC_OK)
+   break;
+   }
+
+
+   if (status != DC_OK) {
+   dm_error("%s: Read receiver caps dpcd data failed.\n", 
__func__);
+   return false;
+   }
+
{
union training_aux_rd_interval aux_rd_interval;
 
-- 
2.25.1

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


[PATCH 03/24] drm/amd/display: add config option for eDP hotplug detection

2021-06-10 Thread Anson Jacob
From: Yi-Ling Chen 

[Why]
Some custom platforms use eDP hotplug events to notify panel
capability changes that should be reported

[How]
Add a DC config option that unblocks eDP hotplug events

Signed-off-by: Yi-Ling Chen 
Reviewed-by: Aric Cyr 
Acked-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 10 ++
 drivers/gpu/drm/amd/display/dc/dc.h   |  1 +
 2 files changed, 7 insertions(+), 4 deletions(-)

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 0f91280883a6..33e83c033284 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -904,9 +904,10 @@ static bool dc_link_detect_helper(struct dc_link *link,
if (dc_is_virtual_signal(link->connector_signal))
return false;
 
-   if ((link->connector_signal == SIGNAL_TYPE_LVDS ||
-link->connector_signal == SIGNAL_TYPE_EDP) &&
-   link->local_sink) {
+   if (((link->connector_signal == SIGNAL_TYPE_LVDS ||
+   link->connector_signal == SIGNAL_TYPE_EDP) &&
+   (!link->dc->config.allow_edp_hotplug_detection)) &&
+   link->local_sink) {
// need to re-write OUI and brightness in resume case
if (link->connector_signal == SIGNAL_TYPE_EDP) {
dpcd_set_source_specific_data(link);
@@ -1501,7 +1502,8 @@ static bool dc_link_construct(struct dc_link *link,
link->connector_signal = SIGNAL_TYPE_EDP;
 
if (link->hpd_gpio) {
-   link->irq_source_hpd = DC_IRQ_SOURCE_INVALID;
+   if (!link->dc->config.allow_edp_hotplug_detection)
+   link->irq_source_hpd = DC_IRQ_SOURCE_INVALID;
link->irq_source_hpd_rx =
dal_irq_get_rx_source(link->hpd_gpio);
}
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h 
b/drivers/gpu/drm/amd/display/dc/dc.h
index a70697898025..6470eee8e212 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -303,6 +303,7 @@ struct dc_config {
bool multi_mon_pp_mclk_switch;
bool disable_dmcu;
bool enable_4to1MPC;
+   bool allow_edp_hotplug_detection;
 #if defined(CONFIG_DRM_AMD_DC_DCN)
bool clamp_min_dcfclk;
 #endif
-- 
2.25.1

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


[PATCH 10/24] drm/amd/display: move psr dm interface to separate files

2021-06-10 Thread Anson Jacob
From: Roman Li 

[Why]
Improve the maintain/read abilities of dm code.

[How]
Create amdgpu_dm_psr.c/h files.
Move psr function from amdgpu_dm.c

Signed-off-by: Roman Li 
Reviewed-by: Nicholas Kazlauskas 
Acked-by: Anson Jacob 
---
 .../gpu/drm/amd/display/amdgpu_dm/Makefile|   2 +-
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 137 +--
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c | 166 ++
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_psr.h |  37 
 4 files changed, 205 insertions(+), 137 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.c
 create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_psr.h

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/Makefile 
b/drivers/gpu/drm/amd/display/amdgpu_dm/Makefile
index 9a3b7bf8ab0b..91fb72c96545 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/Makefile
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/Makefile
@@ -28,7 +28,7 @@
 AMDGPUDM = amdgpu_dm.o amdgpu_dm_irq.o amdgpu_dm_mst_types.o amdgpu_dm_color.o
 
 ifneq ($(CONFIG_DRM_AMD_DC),)
-AMDGPUDM += amdgpu_dm_services.o amdgpu_dm_helpers.o amdgpu_dm_pp_smu.o
+AMDGPUDM += amdgpu_dm_services.o amdgpu_dm_helpers.o amdgpu_dm_pp_smu.o 
amdgpu_dm_psr.o
 endif
 
 ifdef CONFIG_DRM_AMD_DC_HDCP
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 c0a3119982b0..03b4ac4bf9ba 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -58,6 +58,7 @@
 #if defined(CONFIG_DEBUG_FS)
 #include "amdgpu_dm_debugfs.h"
 #endif
+#include "amdgpu_dm_psr.h"
 
 #include "ivsrcid/ivsrcid_vislands30.h"
 
@@ -213,12 +214,6 @@ static int amdgpu_dm_atomic_check(struct drm_device *dev,
 static void handle_cursor_update(struct drm_plane *plane,
 struct drm_plane_state *old_plane_state);
 
-static void amdgpu_dm_set_psr_caps(struct dc_link *link);
-static bool amdgpu_dm_psr_enable(struct dc_stream_state *stream);
-static bool amdgpu_dm_link_setup_psr(struct dc_stream_state *stream);
-static bool amdgpu_dm_psr_disable(struct dc_stream_state *stream);
-static bool amdgpu_dm_psr_disable_all(struct amdgpu_display_manager *dm);
-
 static const struct drm_format_info *
 amd_get_format_info(const struct drm_mode_fb_cmd2 *cmd);
 
@@ -10826,136 +10821,6 @@ void amdgpu_dm_update_freesync_caps(struct 
drm_connector *connector,
   freesync_capable);
 }
 
-static void amdgpu_dm_set_psr_caps(struct dc_link *link)
-{
-   uint8_t dpcd_data[EDP_PSR_RECEIVER_CAP_SIZE];
-
-   if (!(link->connector_signal & SIGNAL_TYPE_EDP))
-   return;
-   if (link->type == dc_connection_none)
-   return;
-   if (dm_helpers_dp_read_dpcd(NULL, link, DP_PSR_SUPPORT,
-   dpcd_data, sizeof(dpcd_data))) {
-   link->dpcd_caps.psr_caps.psr_version = dpcd_data[0];
-
-   if (dpcd_data[0] == 0) {
-   link->psr_settings.psr_version = 
DC_PSR_VERSION_UNSUPPORTED;
-   link->psr_settings.psr_feature_enabled = false;
-   } else {
-   link->psr_settings.psr_version = DC_PSR_VERSION_1;
-   link->psr_settings.psr_feature_enabled = true;
-   }
-
-   DRM_INFO("PSR support:%d\n", 
link->psr_settings.psr_feature_enabled);
-   }
-}
-
-/*
- * amdgpu_dm_link_setup_psr() - configure psr link
- * @stream: stream state
- *
- * Return: true if success
- */
-static bool amdgpu_dm_link_setup_psr(struct dc_stream_state *stream)
-{
-   struct dc_link *link = NULL;
-   struct psr_config psr_config = {0};
-   struct psr_context psr_context = {0};
-   bool ret = false;
-
-   if (stream == NULL)
-   return false;
-
-   link = stream->link;
-
-   psr_config.psr_version = link->dpcd_caps.psr_caps.psr_version;
-
-   if (psr_config.psr_version > 0) {
-   psr_config.psr_exit_link_training_required = 0x1;
-   psr_config.psr_frame_capture_indication_req = 0;
-   psr_config.psr_rfb_setup_time = 0x37;
-   psr_config.psr_sdp_transmit_line_num_deadline = 0x20;
-   psr_config.allow_smu_optimizations = 0x0;
-
-   ret = dc_link_setup_psr(link, stream, &psr_config, 
&psr_context);
-
-   }
-   DRM_DEBUG_DRIVER("PSR link: %d\n",  
link->psr_settings.psr_feature_enabled);
-
-   return ret;
-}
-
-/*
- * amdgpu_dm_psr_enable() - enable psr f/w
- * @stream: stream state
- *
- * Return: true if success
- */
-bool amdgpu_dm_psr_enable(struct dc_stream_state *stream)
-{
-   struct dc_link *link = stream->link;
-   unsigned int vsync_rate_hz = 0;
-   struct dc_static_screen_params params = 

[PATCH 15/24] drm/amd/display: Always write repeater mode regardless of LTTPR

2021-06-10 Thread Anson Jacob
From: Wesley Chalmers 

[WHY]
SCR for DP2.0 requires that LT be performed with PHY_REPEATER_MODE
programmed to 0x55 (Transparent) whenever PHY_REPEATER_CNT is any value
other than 0x80, 0x40, 0x20, 0x10, 0x08, 0x04, 0x02, or 0x01.

[HOW]
Write Non-Transparent (0xAA) to PHY_REPEATER_MODE when LTTPRs detected and 
Non-Transparent is
requested.
Write Transparent in all other cases.

Signed-off-by: Wesley Chalmers 
Reviewed-by: Jun Lei 
Acked-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 7 +++
 1 file changed, 3 insertions(+), 4 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 586f05a6cd77..c68b49a14f88 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
@@ -1618,11 +1618,10 @@ enum dc_status dpcd_configure_lttpr_mode(struct dc_link 
*link, struct link_train
 {
enum dc_status status = DC_OK;
 
-   if (lt_settings->lttpr_mode == LTTPR_MODE_TRANSPARENT)
-   status = configure_lttpr_mode_transparent(link);
-
-   else if (lt_settings->lttpr_mode == LTTPR_MODE_NON_TRANSPARENT)
+   if (lt_settings->lttpr_mode == LTTPR_MODE_NON_TRANSPARENT)
status = configure_lttpr_mode_non_transparent(link, 
lt_settings);
+   else
+   status = configure_lttpr_mode_transparent(link);
 
return status;
 }
-- 
2.25.1

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


[PATCH 05/24] drm/amd/display: dp mst detection code refactor

2021-06-10 Thread Anson Jacob
From: Wenjing Liu 

[why]
Move mst start top mgr in dc_link_detect layer.
Remove unused same_dpcd variable.
Move PEAK_FACTOR_X1000 and LINK_TRAINING_MAX_VERIFY_RETRY
to the proper header for defining dc link internal constant.

Signed-off-by: Wenjing Liu 
Reviewed-by: George Shen 
Acked-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link.c | 156 +++---
 .../gpu/drm/amd/display/dc/inc/dc_link_dp.h   |  10 +-
 2 files changed, 70 insertions(+), 96 deletions(-)

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 33e83c033284..05c963a5b789 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link.c
@@ -59,20 +59,6 @@
 #define RETIMER_REDRIVER_INFO(...) \
DC_LOG_RETIMER_REDRIVER(  \
__VA_ARGS__)
-/***
- * Private structures
- 
**/
-
-enum {
-   PEAK_FACTOR_X1000 = 1006,
-   /*
-* Some receivers fail to train on first try and are good
-* on subsequent tries. 2 retries should be plenty. If we
-* don't have a successful training then we don't expect to
-* ever get one.
-*/
-   LINK_TRAINING_MAX_VERIFY_RETRY = 2
-};
 
 
/***
  * Private functions
@@ -718,11 +704,9 @@ static void read_current_link_settings_on_detect(struct 
dc_link *link)
 
 static bool detect_dp(struct dc_link *link,
  struct display_sink_capability *sink_caps,
- bool *converter_disable_audio,
- struct audio_support *audio_support,
  enum dc_detect_reason reason)
 {
-   bool boot = false;
+   struct audio_support *audio_support = 
&link->dc->res_pool->audio_support;
 
sink_caps->signal = link_detect_sink(link, reason);
sink_caps->transaction_type =
@@ -745,60 +729,12 @@ static bool detect_dp(struct dc_link *link,
 * of this function). */
query_hdcp_capability(SIGNAL_TYPE_DISPLAY_PORT_MST, 
link);
 #endif
-   /*
-* This call will initiate MST topology discovery. Which
-* will detect MST ports and add new DRM connector DRM
-* framework. Then read EDID via remote i2c over aux. In
-* the end, will notify DRM detect result and save EDID
-* into DRM framework.
-*
-* .detect is called by .fill_modes.
-* .fill_modes is called by user mode ioctl
-* DRM_IOCTL_MODE_GETCONNECTOR.
-*
-* .get_modes is called by .fill_modes.
-*
-* call .get_modes, AMDGPU DM implementation will create
-* new dc_sink and add to dc_link. For long HPD plug
-* in/out, MST has its own handle.
-*
-* Therefore, just after dc_create, link->sink is not
-* created for MST until user mode app calls
-* DRM_IOCTL_MODE_GETCONNECTOR.
-*
-* Need check ->sink usages in case ->sink = NULL
-* TODO: s3 resume check
-*/
-   if (reason == DETECT_REASON_BOOT)
-   boot = true;
-
-   dm_helpers_dp_update_branch_info(link->ctx, link);
-
-   if (!dm_helpers_dp_mst_start_top_mgr(link->ctx,
-link, boot)) {
-   /* MST not supported */
-   link->type = dc_connection_single;
-   sink_caps->signal = SIGNAL_TYPE_DISPLAY_PORT;
-   }
}
 
if (link->type != dc_connection_mst_branch &&
-   is_dp_branch_device(link)) {
+   is_dp_branch_device(link))
/* DP SST branch */
link->type = dc_connection_sst_branch;
-   if (!link->dpcd_caps.sink_count.bits.SINK_COUNT) {
-   /*
-* SST branch unplug processing for short irq
-*/
-   link_disconnect_sink(link);
-   return true;
-   }
-
-   if (is_dp_active_dongle(li

[PATCH 02/24] drm/amd/display: add DMUB registers to crash dump diagnostic data.

2021-06-10 Thread Anson Jacob
From: Ashley Thomas 

[WHY]
Ability to triage DMCUB is improved with availability of certain
dmub registers not currently captured in crash dump diagnostic data.

[HOW]
Add dmub registers to diagnostic data collection.

Thanks Nicholas Kazlauskas for awesome input on this!

Signed-off-by: Ashley Thomas 
Reviewed-by: Nicholas Kazlauskas 
Acked-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c  | 100 +-
 drivers/gpu/drm/amd/display/dc/dc_dmub_srv.h  |   4 +
 drivers/gpu/drm/amd/display/dmub/dmub_srv.h   |  29 +
 .../gpu/drm/amd/display/dmub/src/dmub_dcn20.c |  65 +++-
 .../gpu/drm/amd/display/dmub/src/dmub_dcn20.h |  14 ++-
 .../gpu/drm/amd/display/dmub/src/dmub_dcn21.c |   5 +-
 .../gpu/drm/amd/display/dmub/src/dmub_dcn30.c |   5 +-
 .../drm/amd/display/dmub/src/dmub_dcn301.c|   5 +-
 .../drm/amd/display/dmub/src/dmub_dcn302.c|   5 +-
 .../drm/amd/display/dmub/src/dmub_dcn303.c|   5 +-
 .../gpu/drm/amd/display/dmub/src/dmub_srv.c   |  10 ++
 11 files changed, 238 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c 
b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
index 48ca23e1e599..36b6fbcc0441 100644
--- a/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
+++ b/drivers/gpu/drm/amd/display/dc/dc_dmub_srv.c
@@ -86,6 +86,7 @@ void dc_dmub_srv_cmd_queue(struct dc_dmub_srv *dc_dmub_srv,
 
 error:
DC_ERROR("Error queuing DMUB command: status=%d\n", status);
+   dc_dmub_srv_log_diagnostic_data(dc_dmub_srv);
 }
 
 void dc_dmub_srv_cmd_execute(struct dc_dmub_srv *dc_dmub_srv)
@@ -95,8 +96,10 @@ void dc_dmub_srv_cmd_execute(struct dc_dmub_srv *dc_dmub_srv)
enum dmub_status status;
 
status = dmub_srv_cmd_execute(dmub);
-   if (status != DMUB_STATUS_OK)
+   if (status != DMUB_STATUS_OK) {
DC_ERROR("Error starting DMUB execution: status=%d\n", status);
+   dc_dmub_srv_log_diagnostic_data(dc_dmub_srv);
+   }
 }
 
 void dc_dmub_srv_wait_idle(struct dc_dmub_srv *dc_dmub_srv)
@@ -106,8 +109,10 @@ void dc_dmub_srv_wait_idle(struct dc_dmub_srv *dc_dmub_srv)
enum dmub_status status;
 
status = dmub_srv_wait_for_idle(dmub, 10);
-   if (status != DMUB_STATUS_OK)
+   if (status != DMUB_STATUS_OK) {
DC_ERROR("Error waiting for DMUB idle: status=%d\n", status);
+   dc_dmub_srv_log_diagnostic_data(dc_dmub_srv);
+   }
 }
 
 void dc_dmub_srv_send_inbox0_cmd(struct dc_dmub_srv *dmub_srv,
@@ -214,3 +219,94 @@ void dc_dmub_trace_event_control(struct dc *dc, bool 
enable)
 {
dm_helpers_dmub_outbox_interrupt_control(dc->ctx, enable);
 }
+
+bool dc_dmub_srv_get_diagnostic_data(struct dc_dmub_srv *dc_dmub_srv, struct 
dmub_diagnostic_data *diag_data)
+{
+   if (!dc_dmub_srv || !dc_dmub_srv->dmub || !diag_data)
+   return false;
+   return dmub_srv_get_diagnostic_data(dc_dmub_srv->dmub, diag_data);
+}
+
+void dc_dmub_srv_log_diagnostic_data(struct dc_dmub_srv *dc_dmub_srv)
+{
+   struct dmub_diagnostic_data diag_data = {0};
+
+   if (!dc_dmub_srv || !dc_dmub_srv->dmub) {
+   DC_LOG_ERROR("%s: invalid parameters.", __func__);
+   return;
+   }
+
+   if (!dc_dmub_srv_get_diagnostic_data(dc_dmub_srv, &diag_data)) {
+   DC_LOG_ERROR("%s: dc_dmub_srv_get_diagnostic_data failed.", 
__func__);
+   return;
+   }
+
+   DC_LOG_DEBUG(
+   "DMCUB STATE\n"
+   "dmcub_version  : %08x\n"
+   "scratch  [0]   : %08x\n"
+   "scratch  [1]   : %08x\n"
+   "scratch  [2]   : %08x\n"
+   "scratch  [3]   : %08x\n"
+   "scratch  [4]   : %08x\n"
+   "scratch  [5]   : %08x\n"
+   "scratch  [6]   : %08x\n"
+   "scratch  [7]   : %08x\n"
+   "scratch  [8]   : %08x\n"
+   "scratch  [9]   : %08x\n"
+   "scratch [10]   : %08x\n"
+   "scratch [11]   : %08x\n"
+   "scratch [12]   : %08x\n"
+   "scratch [13]   : %08x\n"
+   "scratch [14]   : %08x\n"
+   "scratch [15]   : %08x\n"
+   "pc : %08x\n"
+   "unk_fault_addr : %08x\n"
+   "inst_fault_addr: %08x\n"
+   "data_fault_addr: %08x\n"
+   "inbox1_rptr: %08x\n"
+   "inbox1_wptr: %08x\n"
+   "inbox1_siz

[PATCH 08/24] drm/amd/display: [FW Promotion] Release 0.0.70

2021-06-10 Thread Anson Jacob
From: Anthony Koo 

Signed-off-by: Anthony Koo 
Reviewed-by: Anthony Koo 
Acked-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h 
b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
index ff1f4ec1531e..18d2f51eb50d 100644
--- a/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
+++ b/drivers/gpu/drm/amd/display/dmub/inc/dmub_cmd.h
@@ -47,10 +47,10 @@
 
 /* Firmware versioning. */
 #ifdef DMUB_EXPOSE_VERSION
-#define DMUB_FW_VERSION_GIT_HASH 0xefd666c1
+#define DMUB_FW_VERSION_GIT_HASH 0x5cac099d3
 #define DMUB_FW_VERSION_MAJOR 0
 #define DMUB_FW_VERSION_MINOR 0
-#define DMUB_FW_VERSION_REVISION 69
+#define DMUB_FW_VERSION_REVISION 70
 #define DMUB_FW_VERSION_TEST 0
 #define DMUB_FW_VERSION_VBIOS 0
 #define DMUB_FW_VERSION_HOTFIX 0
-- 
2.25.1

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


[PATCH 07/24] drm/amd/display: Updated variable name.

2021-06-10 Thread Anson Jacob
From: David Galiffi 

[Why]
Fixed spelling error.

[How]
Changed "currnet_setting" to "current_setting".

Signed-off-by: David Galiffi 
Reviewed-by: Wesley Chalmers 
Acked-by: Anson Jacob 
---
 drivers/gpu/drm/amd/display/dc/core/dc_link_dp.c | 12 ++--
 1 file changed, 6 insertions(+), 6 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 919c94de2a20..7024589791fe 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
@@ -1806,7 +1806,7 @@ bool perform_link_training_with_retries(
enum dp_panel_mode panel_mode;
struct link_encoder *link_enc;
enum link_training_result status = LINK_TRAINING_CR_FAIL_LANE0;
-   struct dc_link_settings currnet_setting = *link_setting;
+   struct dc_link_settings current_setting = *link_setting;
 
/* Dynamically assigned link encoders associated with stream rather than
 * link.
@@ -1832,7 +1832,7 @@ bool perform_link_training_with_retries(
link,
signal,
pipe_ctx->clock_source->id,
-   &currnet_setting);
+   ¤t_setting);
 
if (stream->sink_patches.dppowerup_delay > 0) {
int delay_dp_power_up_in_ms = 
stream->sink_patches.dppowerup_delay;
@@ -1847,12 +1847,12 @@ bool perform_link_training_with_retries(
 panel_mode != DP_PANEL_MODE_DEFAULT);
 
if (link->aux_access_disabled) {
-   dc_link_dp_perform_link_training_skip_aux(link, 
&currnet_setting);
+   dc_link_dp_perform_link_training_skip_aux(link, 
¤t_setting);
return true;
} else {
status = dc_link_dp_perform_link_training(

link,
-   
&currnet_setting,
+   
¤t_setting,

skip_video_pattern);
if (status == LINK_TRAINING_SUCCESS)
return true;
@@ -1872,12 +1872,12 @@ bool perform_link_training_with_retries(
if (status == LINK_TRAINING_ABORT)
break;
else if (do_fallback) {
-   decide_fallback_link_setting(*link_setting, 
&currnet_setting, status);
+   decide_fallback_link_setting(*link_setting, 
¤t_setting, status);
/* Fail link training if reduced link bandwidth no 
longer meets
 * stream requirements.
 */
if (dc_bandwidth_in_kbps_from_timing(&stream->timing) <
-   dc_link_bandwidth_kbps(link, 
&currnet_setting))
+   dc_link_bandwidth_kbps(link, 
¤t_setting))
break;
}
 
-- 
2.25.1

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


  1   2   3   >