<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<p style="font-family:Arial;font-size:10pt;color:#317100;margin:15pt;" align="Left">
[AMD Public Use]<br>
</p>
<br>
<div>
<div style="font-family: Calibri, Arial, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Acked-by: Alex Deucher <alexander.deucher@amd.com><br>
</div>
<div id="appendonsend"></div>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Quan, Evan <Evan.Quan@amd.com><br>
<b>Sent:</b> Wednesday, July 15, 2020 2:52 AM<br>
<b>To:</b> amd-gfx@lists.freedesktop.org <amd-gfx@lists.freedesktop.org><br>
<b>Cc:</b> Deucher, Alexander <Alexander.Deucher@amd.com>; Quan, Evan <Evan.Quan@amd.com><br>
<b>Subject:</b> [PATCH] drm/amd/powerplay: suppress compile error around BUG_ON</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">To suppress the compile error below for "ARCH=arc".<br>
   drivers/gpu/drm/amd/amdgpu/../powerplay/arcturus_ppt.c: In function 'arcturus_fill_eeprom_i2c_req':<br>
>> arch/arc/include/asm/bug.h:22:2: error: implicit declaration of function 'pr_warn'; did you mean 'pci_warn'? [-Werror=implicit-function-declaration]<br>
      22 |  pr_warn("BUG: failure at %s:%d/%s()!\n", __FILE__, __LINE__, __func__); \<br>
         |  ^~~~~~~<br>
   include/asm-generic/bug.h:62:57: note: in expansion of macro 'BUG'<br>
      62 | #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)<br>
         |                                                         ^~~<br>
   drivers/gpu/drm/amd/amdgpu/../powerplay/arcturus_ppt.c:2157:2: note: in expansion of macro 'BUG_ON'<br>
    2157 |  BUG_ON(numbytes > MAX_SW_I2C_COMMANDS);<br>
<br>
Change-Id: I314b0d08197398a04b5439bce6546c4c68ca5dff<br>
Signed-off-by: Evan Quan <evan.quan@amd.com><br>
---<br>
 drivers/gpu/drm/amd/powerplay/arcturus_ppt.c | 14 ++++++++++++--<br>
 1 file changed, 12 insertions(+), 2 deletions(-)<br>
<br>
diff --git a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c<br>
index fde6a8242565..0784a97bd67b 100644<br>
--- a/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c<br>
+++ b/drivers/gpu/drm/amd/powerplay/arcturus_ppt.c<br>
@@ -1881,8 +1881,6 @@ static void arcturus_fill_eeprom_i2c_req(SwI2cRequest_t  *req, bool write,<br>
 {<br>
         int i;<br>
 <br>
-       BUG_ON(numbytes > MAX_SW_I2C_COMMANDS);<br>
-<br>
         req->I2CcontrollerPort = 0;<br>
         req->I2CSpeed = 2;<br>
         req->SlaveAddress = address;<br>
@@ -1920,6 +1918,12 @@ static int arcturus_i2c_eeprom_read_data(struct i2c_adapter *control,<br>
         struct smu_table_context *smu_table = &adev->smu.smu_table;<br>
         struct smu_table *table = &smu_table->driver_table;<br>
 <br>
+       if (numbytes > MAX_SW_I2C_COMMANDS) {<br>
+               dev_err(adev->dev, "numbytes requested %d is over max allowed %d\n",<br>
+                       numbytes, MAX_SW_I2C_COMMANDS);<br>
+               return -EINVAL;<br>
+       }<br>
+<br>
         memset(&req, 0, sizeof(req));<br>
         arcturus_fill_eeprom_i2c_req(&req, false, address, numbytes, data);<br>
 <br>
@@ -1956,6 +1960,12 @@ static int arcturus_i2c_eeprom_write_data(struct i2c_adapter *control,<br>
         SwI2cRequest_t req;<br>
         struct amdgpu_device *adev = to_amdgpu_device(control);<br>
 <br>
+       if (numbytes > MAX_SW_I2C_COMMANDS) {<br>
+               dev_err(adev->dev, "numbytes requested %d is over max allowed %d\n",<br>
+                       numbytes, MAX_SW_I2C_COMMANDS);<br>
+               return -EINVAL;<br>
+       }<br>
+<br>
         memset(&req, 0, sizeof(req));<br>
         arcturus_fill_eeprom_i2c_req(&req, true, address, numbytes, data);<br>
 <br>
-- <br>
2.27.0<br>
<br>
</div>
</span></font></div>
</div>
</body>
</html>