<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from rtf -->
<style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<font face="Calibri" size="2"><span style="font-size:10pt;">
<div style="padding-right:5pt;padding-left:5pt;"><font color="blue">[AMD Official Use Only - AMD Internal Distribution Only]<br>

</font></div>
<div style="margin-top:5pt;"><font face="Times New Roman" size="3"><span style="font-size:12pt;"><br>

</span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">The limit variable in amdgpu_eeprom_xfer is not 0, so the buf_size will be cut into smaller pieces, u16 is enough for <font face="Calibri">__amdgpu_eeprom_xfer</font><font face="Calibri">.</font></span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">Anyway, use u32 for __amdgpu_eeprom_xfer and make sure the msgs[1].len is less than U16_MAX is better, will create a new patch for the purpose.</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div><font face="Calibri" size="2"><span style="font-size:11pt;">Tao</span></font></div>
<div><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-left:36pt;"><font face="DengXian" size="2"><span style="font-size:11pt;">_____________________________________________<br>

<b>From:</b> Zhang, Hawking <Hawking.Zhang@amd.com> <br>

<b>Sent:</b> Monday, May 20, 2024 11:23 AM<br>

<b>To:</b> Zhou1, Tao <Tao.Zhou1@amd.com>; amd-gfx@lists.freedesktop.org<br>

<b>Cc:</b> Zhou1, Tao <Tao.Zhou1@amd.com><br>

<b>Subject:</b> RE: [PATCH] drm/amdgpu: update type of buf size to u32 for eeprom functions</span></font></div>
<div style="padding-left:36pt;"><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-left:36pt;"><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-right:5pt;padding-left:41pt;"><font face="Calibri" color="blue">[AMD Official Use Only - AMD Internal Distribution Only]<br>

</font></div>
<div style="padding-left:36pt;"><font face="Times New Roman" size="2"><span style="font-size:11pt;"><br>

</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">Hmm… but in __amdgpu_eeprom_xfer, the u32 will still be cut to u16.</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">__amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr, u8 *eeprom_buf, <b>u16 buf_size</b>, bool read)</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">Regards,<br>

Hawking</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">-----Original Message-----<br>

From: amd-gfx <<a href="mailto:amd-gfx-bounces@lists.freedesktop.org"><font color="#0563C1"><u>amd-gfx-bounces@lists.freedesktop.org</u></font></a>> On Behalf Of Tao Zhou<br>

Sent: Monday, May 20, 2024 10:46<br>

To: <a href="mailto:amd-gfx@lists.freedesktop.org"><font color="#0563C1"><u>amd-gfx@lists.freedesktop.org</u></font></a><br>

Cc: Zhou1, Tao <<a href="mailto:Tao.Zhou1@amd.com"><font color="#0563C1"><u>Tao.Zhou1@amd.com</u></font></a>><br>

Subject: [PATCH] drm/amdgpu: update type of buf size to u32 for eeprom functions</span></font></div>
<div style="padding-left:36pt;"><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">Avoid overflow issue.</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">Signed-off-by: Tao Zhou <<a href="mailto:tao.zhou1@amd.com">tao.zhou1@amd.com</a>></span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">---</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c | 6 +++---  drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.h | 4 ++--</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> 2 files changed, 5 insertions(+), 5 deletions(-)</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">index e71768661ca8..09a34c7258e2 100644</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.c</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">@@ -179,7 +179,7 @@ static int __amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">  * Returns the number of bytes read/written; -errno on error.</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">  */</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> static int amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">-                             u8 *eeprom_buf, u16 buf_size, bool read)</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">+                             u8 *eeprom_buf, u32 buf_size, bool read)</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> {</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">         const struct i2c_adapter_quirks *quirks = i2c_adap->quirks;</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">         u16 limit;</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">@@ -225,7 +225,7 @@ static int amdgpu_eeprom_xfer(struct i2c_adapter *i2c_adap, u32 eeprom_addr,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> int amdgpu_eeprom_read(struct i2c_adapter *i2c_adap,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">                        u32 eeprom_addr, u8 *eeprom_buf,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">-                      u16 bytes)</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">+                      u32 bytes)</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> {</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">         return amdgpu_eeprom_xfer(i2c_adap, eeprom_addr, eeprom_buf, bytes,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">                                   true);</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">@@ -233,7 +233,7 @@ int amdgpu_eeprom_read(struct i2c_adapter *i2c_adap,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> int amdgpu_eeprom_write(struct i2c_adapter *i2c_adap,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">                         u32 eeprom_addr, u8 *eeprom_buf,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">-                       u16 bytes)</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">+                       u32 bytes)</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> {</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">         return amdgpu_eeprom_xfer(i2c_adap, eeprom_addr, eeprom_buf, bytes,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">                                   false);</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.h</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">index 6935adb2be1f..8083b8253ef4 100644</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.h</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_eeprom.h</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">@@ -28,10 +28,10 @@</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> int amdgpu_eeprom_read(struct i2c_adapter *i2c_adap,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">                        u32 eeprom_addr, u8 *eeprom_buf,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">-                      u16 bytes);</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">+                      u32 bytes);</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> int amdgpu_eeprom_write(struct i2c_adapter *i2c_adap,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">                         u32 eeprom_addr, u8 *eeprom_buf,</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">-                       u16 bytes);</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">+                       u32 bytes);</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> </span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;"> #endif</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">--</span></font></div>
<div style="padding-left:36pt;"><font face="Calibri" size="2"><span style="font-size:11pt;">2.34.1</span></font></div>
<div style="padding-left:36pt;"><font face="Times New Roman" size="2"><span style="font-size:11pt;"> </span></font></div>
</span></font>
</body>
</html>