Commit 5292221d authored by Alex Deucher's avatar Alex Deucher

Revert "drm/amd/display: Don't return ddc result and read_bytes in same return value"

This reverts commit 018d82e5.

This breaks DDC in certain cases.  Revert for 4.18 and previous kernels.
For 4.19, this is fixed with the following more extensive patches:
drm/amd/display: Serialize is_dp_sink_present
drm/amd/display: Break out function to simply read aux reply
drm/amd/display: Return aux replies directly to DRM
drm/amd/display: Right shift AUX reply value sooner than later
drm/amd/display: Read AUX channel even if only status byte is returned

Link: https://lists.freedesktop.org/archives/amd-gfx/2018-July/023788.htmlAcked-by: default avatarHarry Wentland <harry.wentland@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Cc: stable@vger.kernel.org
parent dc81aab1
...@@ -83,22 +83,21 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, ...@@ -83,22 +83,21 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
enum i2c_mot_mode mot = (msg->request & DP_AUX_I2C_MOT) ? enum i2c_mot_mode mot = (msg->request & DP_AUX_I2C_MOT) ?
I2C_MOT_TRUE : I2C_MOT_FALSE; I2C_MOT_TRUE : I2C_MOT_FALSE;
enum ddc_result res; enum ddc_result res;
uint32_t read_bytes = msg->size; ssize_t read_bytes;
if (WARN_ON(msg->size > 16)) if (WARN_ON(msg->size > 16))
return -E2BIG; return -E2BIG;
switch (msg->request & ~DP_AUX_I2C_MOT) { switch (msg->request & ~DP_AUX_I2C_MOT) {
case DP_AUX_NATIVE_READ: case DP_AUX_NATIVE_READ:
res = dal_ddc_service_read_dpcd_data( read_bytes = dal_ddc_service_read_dpcd_data(
TO_DM_AUX(aux)->ddc_service, TO_DM_AUX(aux)->ddc_service,
false, false,
I2C_MOT_UNDEF, I2C_MOT_UNDEF,
msg->address, msg->address,
msg->buffer, msg->buffer,
msg->size, msg->size);
&read_bytes); return read_bytes;
break;
case DP_AUX_NATIVE_WRITE: case DP_AUX_NATIVE_WRITE:
res = dal_ddc_service_write_dpcd_data( res = dal_ddc_service_write_dpcd_data(
TO_DM_AUX(aux)->ddc_service, TO_DM_AUX(aux)->ddc_service,
...@@ -109,15 +108,14 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, ...@@ -109,15 +108,14 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
msg->size); msg->size);
break; break;
case DP_AUX_I2C_READ: case DP_AUX_I2C_READ:
res = dal_ddc_service_read_dpcd_data( read_bytes = dal_ddc_service_read_dpcd_data(
TO_DM_AUX(aux)->ddc_service, TO_DM_AUX(aux)->ddc_service,
true, true,
mot, mot,
msg->address, msg->address,
msg->buffer, msg->buffer,
msg->size, msg->size);
&read_bytes); return read_bytes;
break;
case DP_AUX_I2C_WRITE: case DP_AUX_I2C_WRITE:
res = dal_ddc_service_write_dpcd_data( res = dal_ddc_service_write_dpcd_data(
TO_DM_AUX(aux)->ddc_service, TO_DM_AUX(aux)->ddc_service,
...@@ -139,9 +137,7 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux, ...@@ -139,9 +137,7 @@ static ssize_t dm_dp_aux_transfer(struct drm_dp_aux *aux,
r == DDC_RESULT_SUCESSFULL); r == DDC_RESULT_SUCESSFULL);
#endif #endif
if (res != DDC_RESULT_SUCESSFULL) return msg->size;
return -EIO;
return read_bytes;
} }
static enum drm_connector_status static enum drm_connector_status
......
...@@ -629,14 +629,13 @@ bool dal_ddc_service_query_ddc_data( ...@@ -629,14 +629,13 @@ bool dal_ddc_service_query_ddc_data(
return ret; return ret;
} }
enum ddc_result dal_ddc_service_read_dpcd_data( ssize_t dal_ddc_service_read_dpcd_data(
struct ddc_service *ddc, struct ddc_service *ddc,
bool i2c, bool i2c,
enum i2c_mot_mode mot, enum i2c_mot_mode mot,
uint32_t address, uint32_t address,
uint8_t *data, uint8_t *data,
uint32_t len, uint32_t len)
uint32_t *read)
{ {
struct aux_payload read_payload = { struct aux_payload read_payload = {
.i2c_over_aux = i2c, .i2c_over_aux = i2c,
...@@ -653,8 +652,6 @@ enum ddc_result dal_ddc_service_read_dpcd_data( ...@@ -653,8 +652,6 @@ enum ddc_result dal_ddc_service_read_dpcd_data(
.mot = mot .mot = mot
}; };
*read = 0;
if (len > DEFAULT_AUX_MAX_DATA_SIZE) { if (len > DEFAULT_AUX_MAX_DATA_SIZE) {
BREAK_TO_DEBUGGER(); BREAK_TO_DEBUGGER();
return DDC_RESULT_FAILED_INVALID_OPERATION; return DDC_RESULT_FAILED_INVALID_OPERATION;
...@@ -664,8 +661,7 @@ enum ddc_result dal_ddc_service_read_dpcd_data( ...@@ -664,8 +661,7 @@ enum ddc_result dal_ddc_service_read_dpcd_data(
ddc->ctx->i2caux, ddc->ctx->i2caux,
ddc->ddc_pin, ddc->ddc_pin,
&command)) { &command)) {
*read = command.payloads->length; return (ssize_t)command.payloads->length;
return DDC_RESULT_SUCESSFULL;
} }
return DDC_RESULT_FAILED_OPERATION; return DDC_RESULT_FAILED_OPERATION;
......
...@@ -102,14 +102,13 @@ bool dal_ddc_service_query_ddc_data( ...@@ -102,14 +102,13 @@ bool dal_ddc_service_query_ddc_data(
uint8_t *read_buf, uint8_t *read_buf,
uint32_t read_size); uint32_t read_size);
enum ddc_result dal_ddc_service_read_dpcd_data( ssize_t dal_ddc_service_read_dpcd_data(
struct ddc_service *ddc, struct ddc_service *ddc,
bool i2c, bool i2c,
enum i2c_mot_mode mot, enum i2c_mot_mode mot,
uint32_t address, uint32_t address,
uint8_t *data, uint8_t *data,
uint32_t len, uint32_t len);
uint32_t *read);
enum ddc_result dal_ddc_service_write_dpcd_data( enum ddc_result dal_ddc_service_write_dpcd_data(
struct ddc_service *ddc, struct ddc_service *ddc,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment