Skip to contentSkip to conversation

drm/amdgpu: Add amdgpu_ras_eeprom_reset_table

PATCH In review Andrey Grodzovsky 3 participants 4 messages Sep 9, 2019 – Sep 10, 2019 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 drm/amdgpu: Add amdgpu_ras_eeprom_reset_table

This will allow to reset the table on the fly.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 25 +++++++++++++++++--------
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h |  1 +
 2 files changed, 18 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +17 -8
index 43dd4ab..11a8445 100644
@@ -102,6 +102,22 @@ static int __update_table_header(struct amdgpu_ras_eeprom_control *control,
 
 static uint32_t  __calc_hdr_byte_sum(struct amdgpu_ras_eeprom_control *control);
 
+int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control *control)
+{
+	unsigned char buff[EEPROM_ADDRESS_SIZE + EEPROM_TABLE_HEADER_SIZE] = { 0 };
+	struct amdgpu_device *adev = to_amdgpu_device(control);
+	struct amdgpu_ras_eeprom_table_header *hdr = &control->tbl_hdr;
+
+	hdr->header = EEPROM_TABLE_HDR_VAL;
+	hdr->version = EEPROM_TABLE_VER;
+	hdr->first_rec_offset = EEPROM_RECORD_START;
+	hdr->tbl_size = EEPROM_TABLE_HEADER_SIZE;
+
+	adev->psp.ras.ras->eeprom_control.tbl_byte_sum =
+			__calc_hdr_byte_sum(&adev->psp.ras.ras->eeprom_control);
+	return __update_table_header(control, buff);
+}
+
 int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control)
 {
 	int ret = 0;
@@ -149,14 +165,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control)
 	} else {
 		DRM_INFO("Creating new EEPROM table");
 
-		hdr->header = EEPROM_TABLE_HDR_VAL;
-		hdr->version = EEPROM_TABLE_VER;
-		hdr->first_rec_offset = EEPROM_RECORD_START;
-		hdr->tbl_size = EEPROM_TABLE_HEADER_SIZE;
-
-		adev->psp.ras.ras->eeprom_control.tbl_byte_sum =
-				__calc_hdr_byte_sum(&adev->psp.ras.ras->eeprom_control);
-		ret = __update_table_header(control, buff);
+		ret = amdgpu_ras_eeprom_reset_table(control);
 	}
 
 	/* Start inserting records from here */
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +1 -0
index 41f3fcb..6222699 100644
@@ -79,6 +79,7 @@ struct eeprom_table_record {
 
 int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control);
 void amdgpu_ras_eeprom_fini(struct amdgpu_ras_eeprom_control *control);
+int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control *control);
 
 int amdgpu_ras_eeprom_process_recods(struct amdgpu_ras_eeprom_control *control,
 					    struct eeprom_table_record *records,
Signature · 6 lines
2.7.4

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

A message that is not in the archive (sent off-list or not yet received): 1568059469-29450-1-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org

#2 lore raw

PATCH 2/2 drm/amdgpu: Allow to reset to EERPOM table.

The table grows quickly during debug/development effort when multiple RAS errors are injected. Allow to avoid this by setting table header back to empty if needed.

v2: Switch to debugfs entry instead of load time parameter.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +20 -0
index 119bedc..52c5c61 100644
@@ -303,6 +303,17 @@ static ssize_t amdgpu_ras_debugfs_ctrl_write(struct file *f, const char __user *
 	return size;
 }
 
+static ssize_t amdgpu_ras_debugfs_eeprom_write(struct file *f, const char __user *buf,
+		size_t size, loff_t *pos)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *)file_inode(f)->i_private;
+	int ret;
+
+	ret = amdgpu_ras_eeprom_reset_table(&adev->psp.ras.ras->eeprom_control);
+
+	return ret == 1 ? size : -EIO;
+}
+
 static const struct file_operations amdgpu_ras_debugfs_ctrl_ops = {
 	.owner = THIS_MODULE,
 	.read = NULL,
@@ -310,6 +321,13 @@ static const struct file_operations amdgpu_ras_debugfs_ctrl_ops = {
 	.llseek = default_llseek
 };
 
+static const struct file_operations amdgpu_ras_debugfs_eeprom_ops = {
+	.owner = THIS_MODULE,
+	.read = NULL,
+	.write = amdgpu_ras_debugfs_eeprom_write,
+	.llseek = default_llseek
+};
+
 static ssize_t amdgpu_ras_sysfs_read(struct device *dev,
 		struct device_attribute *attr, char *buf)
 {
@@ -951,6 +969,8 @@ static void amdgpu_ras_debugfs_create_ctrl_node(struct amdgpu_device *adev)
 	con->dir = debugfs_create_dir("ras", minor->debugfs_root);
 	con->ent = debugfs_create_file("ras_ctrl", S_IWUGO | S_IRUGO, con->dir,
 				       adev, &amdgpu_ras_debugfs_ctrl_ops);
+	con->ent = debugfs_create_file("ras_eeprom_reset", S_IWUGO | S_IRUGO, con->dir,
+					       adev, &amdgpu_ras_debugfs_eeprom_ops);
 }
 
 void amdgpu_ras_debugfs_create(struct amdgpu_device *adev,
Signature · 6 lines
2.7.4

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

A message that is not in the archive (sent off-list or not yet received): 1568059469-29450-2-git-send-email-andrey.grodzovsky-5C7GfCeVMHo@public.gmane.org

Reviewed-by Tao Zhou
#4 lore raw

RE: [PATCH 2/2] drm/amdgpu: Allow to reset to EERPOM table.

Quoted 39 lines

-----Original Message-----
From: Andrey Grodzovsky <[email protected]>
Sent: 2019年9月10日 4:04
To: [email protected]
Cc: Chen, Guchun <[email protected]>; Zhou1, Tao <[email protected]>; Deucher, Alexander <[email protected]>; Grodzovsky, Andrey <[email protected]>
Subject: [PATCH 2/2] drm/amdgpu: Allow to reset to EERPOM table.

The table grows quickly during debug/development effort when multiple RAS errors are injected. Allow to avoid this by setting table header back to empty if needed.

v2: Switch to debugfs entry instead of load time parameter.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
index 119bedc..52c5c61 100644
@@ -303,6 +303,17 @@ static ssize_t amdgpu_ras_debugfs_ctrl_write(struct

file *f, const char __user *

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
 	return size;
 }
 
+static ssize_t amdgpu_ras_debugfs_eeprom_write(struct file *f, const char

__user *buf,

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -0
+		size_t size, loff_t *pos)
+{
+	struct amdgpu_device *adev = (struct amdgpu_device *)file_inode(f)-
Quoted 1 line

i_private;

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c static ssize_t amdgpu_ras_debugfs_ctrl_write(struct file *f, const char __user *

Quoted 4 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +4 -0
+	int ret;
+
+	ret =
+amdgpu_ras_eeprom_reset_table(&adev->psp.ras.ras->eeprom_control);

[Tao] It's better to add table key in front of the function, with this fixed, the series is:

Quoted 33 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +11 -0
+
+	return ret == 1 ? size : -EIO;
+}
+
 static const struct file_operations amdgpu_ras_debugfs_ctrl_ops = {
 	.owner = THIS_MODULE,
 	.read = NULL,
@@ -310,6 +321,13 @@ static const struct file_operations
 amdgpu_ras_debugfs_ctrl_ops = {
 	.llseek = default_llseek
 };
 
+static const struct file_operations amdgpu_ras_debugfs_eeprom_ops = {
+	.owner = THIS_MODULE,
+	.read = NULL,
+	.write = amdgpu_ras_debugfs_eeprom_write,
+	.llseek = default_llseek
+};
+
 static ssize_t amdgpu_ras_sysfs_read(struct device *dev,
 		struct device_attribute *attr, char *buf)  { @@ -951,6 +969,8

@@ static void amdgpu_ras_debugfs_create_ctrl_node(struct amdgpu_device *adev)

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +0 -0
 	con->dir = debugfs_create_dir("ras", minor->debugfs_root);
 	con->ent = debugfs_create_file("ras_ctrl", S_IWUGO | S_IRUGO, con-
Quoted 1 line

dir,

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
 				       adev, &amdgpu_ras_debugfs_ctrl_ops);
+	con->ent = debugfs_create_file("ras_eeprom_reset", S_IWUGO |

S_IRUGO, con->dir,

drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +1 -0
+					       adev,

&amdgpu_ras_debugfs_eeprom_ops);
}

Quoted 3 lines

void amdgpu_ras_debugfs_create(struct amdgpu_device *adev,
--
2.7.4

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

#5 lore raw
In reply to a message not in the archive

Series is: Reviewed-by: Guchun Chen <[email protected]>

Regards,
Guchun

-----Original Message-----
From: Andrey Grodzovsky <[email protected]>
Sent: Tuesday, September 10, 2019 4:04 AM
To: [email protected]
Cc: Chen, Guchun <[email protected]>; Zhou1, Tao <[email protected]>; Deucher, Alexander <[email protected]>; Grodzovsky, Andrey <[email protected]>
Subject: [PATCH 1/2] drm/amdgpu: Add amdgpu_ras_eeprom_reset_table

This will allow to reset the table on the fly.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c | 25 +++++++++++++++++--------  drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h |  1 +
 2 files changed, 18 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c +16 -8
index 43dd4ab..11a8445 100644
@@ -102,6 +102,22 @@ static int __update_table_header(struct amdgpu_ras_eeprom_control *control,
 
 static uint32_t  __calc_hdr_byte_sum(struct amdgpu_ras_eeprom_control *control);
 
+int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control 
+*control) {
+	unsigned char buff[EEPROM_ADDRESS_SIZE + EEPROM_TABLE_HEADER_SIZE] = { 0 };
+	struct amdgpu_device *adev = to_amdgpu_device(control);
+	struct amdgpu_ras_eeprom_table_header *hdr = &control->tbl_hdr;
+
+	hdr->header = EEPROM_TABLE_HDR_VAL;
+	hdr->version = EEPROM_TABLE_VER;
+	hdr->first_rec_offset = EEPROM_RECORD_START;
+	hdr->tbl_size = EEPROM_TABLE_HEADER_SIZE;
+
+	adev->psp.ras.ras->eeprom_control.tbl_byte_sum =
+			__calc_hdr_byte_sum(&adev->psp.ras.ras->eeprom_control);
+	return __update_table_header(control, buff); }
+
 int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control)  {
 	int ret = 0;
@@ -149,14 +165,7 @@ int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control)
 	} else {
 		DRM_INFO("Creating new EEPROM table");
 
-		hdr->header = EEPROM_TABLE_HDR_VAL;
-		hdr->version = EEPROM_TABLE_VER;
-		hdr->first_rec_offset = EEPROM_RECORD_START;
-		hdr->tbl_size = EEPROM_TABLE_HEADER_SIZE;
-
-		adev->psp.ras.ras->eeprom_control.tbl_byte_sum =
-				__calc_hdr_byte_sum(&adev->psp.ras.ras->eeprom_control);
-		ret = __update_table_header(control, buff);
+		ret = amdgpu_ras_eeprom_reset_table(control);
 	}
 
 	/* Start inserting records from here */ diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h

index 41f3fcb..6222699 100644

drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.h +2 -1
@@ -79,6 +79,7 @@ struct eeprom_table_record {
 
 int amdgpu_ras_eeprom_init(struct amdgpu_ras_eeprom_control *control);  void amdgpu_ras_eeprom_fini(struct amdgpu_ras_eeprom_control *control);
+int amdgpu_ras_eeprom_reset_table(struct amdgpu_ras_eeprom_control 
+*control);
 
 int amdgpu_ras_eeprom_process_recods(struct amdgpu_ras_eeprom_control *control,
 					    struct eeprom_table_record *records,
--

2.7.4

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