Skip to content

Commit 4543eda

Browse files
committed
drm/radeon: fix endian bugs in hw i2c atom routines
Need to swap the data fetched over i2c properly. This is the same fix as the endian fix for aux channel transactions. Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: stable@vger.kernel.org
1 parent 1bd4cff commit 4543eda

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

‎drivers/gpu/drm/radeon/atombios_dp.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ static char *pre_emph_names[] = {
5050
* or from atom. Note that atom operates on
5151
* dw units.
5252
*/
53-
static void radeon_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le)
53+
void radeon_atom_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le)
5454
{
5555
#ifdef __BIG_ENDIAN
5656
u8 src_tmp[20], dst_tmp[20]; /* used for byteswapping */
@@ -100,7 +100,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
100100

101101
base = (unsigned char *)(rdev->mode_info.atom_context->scratch + 1);
102102

103-
radeon_copy_swap(base, send, send_bytes, true);
103+
radeon_atom_copy_swap(base, send, send_bytes, true);
104104

105105
args.v1.lpAuxRequest = cpu_to_le16((u16)(0 + 4));
106106
args.v1.lpDataOut = cpu_to_le16((u16)(16 + 4));
@@ -137,7 +137,7 @@ static int radeon_process_aux_ch(struct radeon_i2c_chan *chan,
137137
recv_bytes = recv_size;
138138

139139
if (recv && recv_size)
140-
radeon_copy_swap(recv, base + 16, recv_bytes, false);
140+
radeon_atom_copy_swap(recv, base + 16, recv_bytes, false);
141141

142142
return recv_bytes;
143143
}

‎drivers/gpu/drm/radeon/atombios_i2c.c‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
#include "radeon.h"
2828
#include "atom.h"
2929

30+
extern void radeon_atom_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le);
31+
3032
#define TARGET_HW_I2C_CLOCK 50
3133

3234
/* these are a limitation of ProcessI2cChannelTransaction not the hw */
@@ -77,7 +79,7 @@ static int radeon_process_i2c_ch(struct radeon_i2c_chan *chan,
7779
}
7880

7981
if (!(flags & HW_I2C_WRITE))
80-
memcpy(buf, base, num);
82+
radeon_atom_copy_swap(buf, base, num, false);
8183

8284
return 0;
8385
}

0 commit comments

Comments
 (0)