Skip to content

Commit 7ac37f0

Browse files
Wayne Linalexdeucher
authored andcommitted
drm/amd/display: Correct the reply value when AUX write incomplete
[Why] Now forcing aux->transfer to return 0 when incomplete AUX write is inappropriate. It should return bytes have been transferred. [How] aux->transfer is asked not to change original msg except reply field of drm_dp_aux_msg structure. Copy the msg->buffer when it's write request, and overwrite the first byte when sink reply 1 byte indicating partially written byte number. Then we can return the correct value without changing the original msg. Fixes: 3637e45 ("drm/amd/display: Fix wrong handling for AUX_DEFER case") Cc: Mario Limonciello <[email protected]> Cc: Alex Deucher <[email protected]> Reviewed-by: Ray Wu <[email protected]> Signed-off-by: Wayne Lin <[email protected]> Signed-off-by: Ray Wu <[email protected]> Tested-by: Daniel Wheeler <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 3705217 commit 7ac37f0

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12854,7 +12854,8 @@ int amdgpu_dm_process_dmub_aux_transfer_sync(
1285412854
/* The reply is stored in the top nibble of the command. */
1285512855
payload->reply[0] = (adev->dm.dmub_notify->aux_reply.command >> 4) & 0xF;
1285612856

12857-
if (!payload->write && p_notify->aux_reply.length)
12857+
/*write req may receive a byte indicating partially written number as well*/
12858+
if (p_notify->aux_reply.length)
1285812859
memcpy(payload->data, p_notify->aux_reply.data,
1285912860
p_notify->aux_reply.length);
1286012861

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
6262
enum aux_return_code_type operation_result;
6363
struct amdgpu_device *adev;
6464
struct ddc_service *ddc;
65+
uint8_t copy[16];
6566

6667
if (WARN_ON(msg->size > 16))
6768
return -E2BIG;
@@ -77,6 +78,11 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
7778
(msg->request & DP_AUX_I2C_WRITE_STATUS_UPDATE) != 0;
7879
payload.defer_delay = 0;
7980

81+
if (payload.write) {
82+
memcpy(copy, msg->buffer, msg->size);
83+
payload.data = copy;
84+
}
85+
8086
result = dc_link_aux_transfer_raw(TO_DM_AUX(aux)->ddc_service, &payload,
8187
&operation_result);
8288

@@ -100,9 +106,9 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
100106
*/
101107
if (payload.write && result >= 0) {
102108
if (result) {
103-
/*one byte indicating partially written bytes. Force 0 to retry*/
109+
/*one byte indicating partially written bytes*/
104110
drm_info(adev_to_drm(adev), "amdgpu: AUX partially written\n");
105-
result = 0;
111+
result = payload.data[0];
106112
} else if (!payload.reply[0])
107113
/*I2C_ACK|AUX_ACK*/
108114
result = msg->size;

0 commit comments

Comments
 (0)