Skip to contentSkip to conversation

drm/amdgpu: fix 64 bit divide in eeprom code

PATCH In review Alex Deucher 2 participants 2 messages Jun 30, 2021

Subsystems (2)
lore
Share & tools
lore

Alex Deucher

author maintainer
#0 lore raw

PATCH 1/1 drm/amdgpu: fix 64 bit divide in eeprom code

pos is 64 bits.

Fixes 5e98eafa90ca19 ("drm/amdgpu: RAS EEPROM table is now in debugfs")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +9 -5
index 677e379f5fb5..fc70620369e4 100644
@@ -880,13 +880,17 @@ static ssize_t amdgpu_ras_debugfs_table_read(struct file *f, char __user *buf,
 	if (*pos < data_len && size > 0) {
 		u8 dare[RAS_TABLE_RECORD_SIZE];
 		u8 data[rec_hdr_fmt_size + 1];
+		struct eeprom_table_record record;
+		int s, r;
+
 		/* Find the starting record index
 		 */
-		int s = (*pos - strlen(tbl_hdr_str) - tbl_hdr_fmt_size -
-			 strlen(rec_hdr_str)) / rec_hdr_fmt_size;
-		int r = (*pos - strlen(tbl_hdr_str) - tbl_hdr_fmt_size -
-			 strlen(rec_hdr_str)) % rec_hdr_fmt_size;
-		struct eeprom_table_record record;
+		s = *pos - strlen(tbl_hdr_str) - tbl_hdr_fmt_size -
+			strlen(rec_hdr_str);
+		s = s / rec_hdr_fmt_size;
+		r = *pos - strlen(tbl_hdr_str) - tbl_hdr_fmt_size -
+			strlen(rec_hdr_str);
+		r = r % rec_hdr_fmt_size;
 
 		for ( ; size > 0 && s < control->ras_num_recs; s++) {
 			u32 ai = RAS_RI_TO_AI(control, s);
Signature · 6 lines
2.31.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Reviewed-by on v1 1/1
#1 lore raw
Quoted 27 lines · Alex Deucher

pos is 64 bits.

Fixes 5e98eafa90ca19 ("drm/amdgpu: RAS EEPROM table is now in debugfs")
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +3 -4
index 677e379f5fb5..fc70620369e4 100644
@@ -880,13 +880,17 @@ static ssize_t amdgpu_ras_debugfs_table_read(struct file *f, char __user *buf,
 	if (*pos < data_len && size > 0) {
 		u8 dare[RAS_TABLE_RECORD_SIZE];
 		u8 data[rec_hdr_fmt_size + 1];
+		struct eeprom_table_record record;
+		int s, r;
+
 		/* Find the starting record index
 		 */
-		int s = (*pos - strlen(tbl_hdr_str) - tbl_hdr_fmt_size -
-			 strlen(rec_hdr_str)) / rec_hdr_fmt_size;
-		int r = (*pos - strlen(tbl_hdr_str) - tbl_hdr_fmt_size -
-			 strlen(rec_hdr_str)) % rec_hdr_fmt_size;

drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c static ssize_t amdgpu_ras_debugfs_table_read(struct file *f, char __user *buf, · line 896

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +6 -1
-		struct eeprom_table_record record;
+		s = *pos - strlen(tbl_hdr_str) - tbl_hdr_fmt_size -
+			strlen(rec_hdr_str);
+		s = s / rec_hdr_fmt_size;
+		r = *pos - strlen(tbl_hdr_str) - tbl_hdr_fmt_size -
+			strlen(rec_hdr_str);
+		r = r % rec_hdr_fmt_size;
 
 		for ( ; size > 0 && s < control->ras_num_recs; s++) {
 			u32 ai = RAS_RI_TO_AI(control, s);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx