drm/amdgpu: Fix a bug for input with double sscanf
Subsystems (2)
PATCH 1/4 drm/amdgpu: Fix a bug for input with double sscanf
Remove double-sscanf to scan for %llu and 0x%llx, as that is not going to work!
The %llu will consume the "0" in "0x" of your input, and the hex value you think you're entering will always be 0. That is, a valid hex value can never be consumed.
On the other hand, just entering a hex number without leading 0x will either be scanned as a string and not match, for instance FAB123, or the leading decimal portion is scanned as the %llu, for instance 123FAB will be scanned as 123, which is not correct.
Thus remove the first %llu scan and leave only the %llx scan, removing the leading 0x since %llx can scan either.
Addresses are usually always hex values, so this suffices.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +5 -8
@@ -230,9 +230,8 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,if (op !=-1 ) {if (op ==3 ) { -if (sscanf (str,"%*s %llu" , &address) !=1 ) -if (sscanf (str,"%*s 0x%llx" , &address) !=1 ) -return -EINVAL ; +if (sscanf (str,"%*s %llx" , &address) !=1 ) +return -EINVAL ; data->op = op; data->inject.address = address;
@@ -255,11 +254,9 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f, data->op = op;if (op ==2 ) { -if (sscanf (str,"%*s %*s %*s %u %llu %llu" , - &sub_block, &address, &value) !=3 ) -if (sscanf (str,"%*s %*s %*s 0x%x 0x%llx 0x%llx" , - &sub_block, &address, &value) !=3 ) -return -EINVAL ; +if (sscanf (str,"%*s %*s %*s %x %llx %llx" , + &sub_block, &address, &value) !=3 ) +return -EINVAL ; data->head.sub_block_index = sub_block; data->inject.address = address; data->inject.value = value;
Signature · 6 lines
2.31.0.97.g1424303384 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 2/4 drm/amdgpu: Fix a bug in checking the result of reserve page
Fix if (ret) --> if (!ret), a bug, for "retire_page", which caused the kernel to recall the method with *pos == end of file, and that bounced back with error. On the first run, we advanced *pos, but returned 0 back to fs layer, also a bug.
Fix the logic of the check of the result of amdgpu_reserve_page_direct()--it is 0 on success, and non-zero on error, not the other way around. This patch fixes this bug.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +3 -6
@@ -114,7 +114,7 @@ static int amdgpu_reserve_page_direct(struct amdgpu_device *adev, uint64_t addreif (amdgpu_ras_check_bad_page (adev, address)) {dev_warn (adev->dev, -"RAS WARN: 0x%llx has been marked as bad page!\n" , +"RAS WARN: 0x%llx has already been marked as bad page!\n" , address);return 0 ; }
@@ -228,7 +228,6 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,return -EINVAL ;if (op !=-1 ) { -if (op ==3 ) {if (sscanf (str,"%*s %llx" , &address) !=1 )return -EINVAL ;
@@ -364,11 +363,9 @@ static ssize_t amdgpu_ras_debugfs_ctrl_write(struct file *f, const char __user *if (ret)return -EINVAL ; -if (data.op ==3 ) - { +if (data.op ==3 ) { ret =amdgpu_reserve_page_direct (adev, data.inject.address); - -if (ret) +if (!ret)return size;else return ret;
Signature · 6 lines
2.31.0.97.g1424303384 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 3/4 drm/amdgpu: Add bad_page_cnt_threshold to debugfs
In reply to Luben TuikovAdd bad_page_cnt_threshold to debugfs, an optional file system used for debugging, for reporting purposes only--it usually matches the size of EEPROM but may be different depending on the "bad_page_threshold" kernel module option.
The "bad_page_cnt_threshold" is a dynamically computed value. It depends on three things: the VRAM size; the size of the EEPROM (or the size allocated to the RAS table therein); and the "bad_page_threshold" module parameter. It is a dynamically computed value, when the amdgpu module is run, on which further parameters and logic depend, and as such it is helpful to see the dynamically computed value in debugfs.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 ++ 1 file changed, 2 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +2 -0
@@ -1263,6 +1263,8 @@ static struct dentry *amdgpu_ras_debugfs_create_ctrl_node(struct amdgpu_device * &amdgpu_ras_debugfs_ctrl_ops);debugfs_create_file ("ras_eeprom_reset" ,S_IWUGO |S_IRUGO , dir, adev, &amdgpu_ras_debugfs_eeprom_ops); +debugfs_create_u32 ("bad_page_cnt_threshold" ,0444 , dir, + &con->bad_page_cnt_threshold);/* * After one uncorrectable error happens, usually GPU recovery will
Signature · 6 lines
2.31.0.97.g1424303384 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
PATCH 4/4 drm/amdgpu: Fix kernel-doc for the RAS sysfs interface
In reply to Luben TuikovImporve the kernel-doc for the RAS sysfs interface. Fix the grammar, fix the context.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 47 +++++++++++++------------ 1 file changed, 24 insertions(+), 23 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +24 -23
@@ -274,7 +274,7 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,/** * DOC: AMDGPU RAS debugfs control interface * -* It accepts struct ras_debug_if who has two members. +* The control interface accepts struct ras_debug_if which has two members. * * First member: ras_debug_if::head or ras_debug_if::inject. *
@@ -299,32 +299,33 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,* * How to use the interface? * -* Programs +* In a program * -* Copy the struct ras_debug_if in your codes and initialize it. -* Write the struct to the control node. +* Copy the struct ras_debug_if in your code and initialize it. +* Write the struct to the control interface. * -* Shells +* From shell * * .. code-block:: bash * -* echo op block [error [sub_block address value]] > .../ras/ras_ctrl +* echo "disable <block>" > /sys/kernel/debug/dri/<N>/ras/ras_ctrl +* echo "enable <block> <error>" > /sys/kernel/debug/dri/<N>/ras/ras_ctrl +* echo "inject <block> <error> <sub-block> <address> <value> > /sys/kernel/debug/dri/<N>/ras/ras_ctrl * -* Parameters: +* Where N, is the card which you want to affect. * -* op: disable, enable, inject -* disable: only block is needed -* enable: block and error are needed -* inject: error, address, value are needed -* block: umc, sdma, gfx, ......... +* "disable" requires only the block. +* "enable" requires the block and error type. +* "inject" requires the block, error type, address, and value. +* The block is one of: umc, sdma, gfx, etc. * see ras_block_string[] for details -* error: ue, ce -* ue: multi_uncorrectable -* ce: single_correctable -* sub_block: -* sub block index, pass 0 if there is no sub block +* The error type is one of: ue, ce, where, +* ue is multi-uncorrectable +* ce is single-correctable +* The sub-block is a the sub-block index, pass 0 if there is no sub-block. +* The address and value are hexadecimal numbers, leading 0x is optional. * -* here are some examples for bash commands: +* For instance, * * .. code-block:: bash *
@@ -332,17 +333,17 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,* echo inject umc ce 0 0 0 > /sys/kernel/debug/dri/0/ras/ras_ctrl * echo disable umc > /sys/kernel/debug/dri/0/ras/ras_ctrl * -* How to check the result? +* How to check the result of the operation? * -* For disable/enable, please check ras features at +* To check disable/enable, see "ras" features at, * /sys/class/drm/card[0/1/2...]/device/ras/features * -* For inject, please check corresponding err count at -* /sys/class/drm/card[0/1/2...]/device/ras/[gfx/sdma/...]_err_count +* To check inject, see the corresponding error count at, +* /sys/class/drm/card[0/1/2...]/device/ras/[gfx|sdma|umc|...]_err_count * * .. note:: * Operations are only allowed on blocks which are supported. -* Please check ras mask at /sys/module/amdgpu/parameters/ras_mask +* Check the "ras" mask at /sys/module/amdgpu/parameters/ras_mask * to see which blocks support RAS on a particular asic. * */
Signature · 6 lines
2.31.0.97.g1424303384 _______________________________________________ amd-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/amd-gfx
RE: [PATCH 4/4] drm/amdgpu: Fix kernel-doc for the RAS sysfs interface
[AMD Public Use]
Series is
Regards,
Hawking
-----Original Message-----
From: Tuikov, Luben <[email protected]>
Sent: Tuesday, April 13, 2021 20:56
To: [email protected]
Cc: Tuikov, Luben <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [PATCH 4/4] drm/amdgpu: Fix kernel-doc for the RAS sysfs interface
Imporve the kernel-doc for the RAS sysfs interface. Fix the grammar, fix the context.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 47 +++++++++++++------------ 1 file changed, 24 insertions(+), 23 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +25 -23
@@ -274,7 +274,7 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,/** * DOC: AMDGPU RAS debugfs control interface * -* It accepts struct ras_debug_if who has two members. +* The control interface accepts struct ras_debug_if which has two members. * * First member: ras_debug_if::head or ras_debug_if::inject. *
@@ -299,32 +299,33 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,* * How to use the interface? * -* Programs +* In a program * -* Copy the struct ras_debug_if in your codes and initialize it. -* Write the struct to the control node. +* Copy the struct ras_debug_if in your code and initialize it. +* Write the struct to the control interface. * -* Shells +* From shell * * .. code-block:: bash * -* echo op block [error [sub_block address value]] > .../ras/ras_ctrl +* echo "disable <block>" > /sys/kernel/debug/dri/<N>/ras/ras_ctrl +* echo "enable <block> <error>" > /sys/kernel/debug/dri/<N>/ras/ras_ctrl +* echo "inject <block> <error> <sub-block> <address> <value> > /sys/kernel/debug/dri/<N>/ras/ras_ctrl * -* Parameters: +* Where N, is the card which you want to affect. * -* op: disable, enable, inject -* disable: only block is needed -* enable: block and error are needed -* inject: error, address, value are needed -* block: umc, sdma, gfx, ......... +* "disable" requires only the block. +* "enable" requires the block and error type. +* "inject" requires the block, error type, address, and value. +* The block is one of: umc, sdma, gfx, etc. * see ras_block_string[] for details -* error: ue, ce -* ue: multi_uncorrectable -* ce: single_correctable -* sub_block: -* sub block index, pass 0 if there is no sub block +* The error type is one of: ue, ce, where, +* ue is multi-uncorrectable +* ce is single-correctable +* The sub-block is a the sub-block index, pass 0 if there is no sub-block. +* The address and value are hexadecimal numbers, leading 0x is optional. * -* here are some examples for bash commands: +* For instance, * * .. code-block:: bash *
@@ -332,17 +333,17 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,* echo inject umc ce 0 0 0 > /sys/kernel/debug/dri/0/ras/ras_ctrl * echo disable umc > /sys/kernel/debug/dri/0/ras/ras_ctrl * -* How to check the result? +* How to check the result of the operation? * -* For disable/enable, please check ras features at +* To check disable/enable, see "ras" features at, * /sys/class/drm/card[0/1/2...]/device/ras/features * -* For inject, please check corresponding err count at -* /sys/class/drm/card[0/1/2...]/device/ras/[gfx/sdma/...]_err_count +* To check inject, see the corresponding error count at, +* +/sys/class/drm/card[0/1/2...]/device/ras/[gfx|sdma|umc|...]_err_count * * .. note:: * Operations are only allowed on blocks which are supported. -* Please check ras mask at /sys/module/amdgpu/parameters/ras_mask +* Check the "ras" mask at /sys/module/amdgpu/parameters/ras_mask * to see which blocks support RAS on a particular asic. *
*/
--
2.31.0.97.g1424303384
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
Re: [PATCH 4/4] drm/amdgpu: Fix kernel-doc for the RAS sysfs interface
[AMD Public Use]
Series is:
________________________________
From: Zhang, Hawking <[email protected]>
Sent: Tuesday, April 13, 2021 9:04 AM
To: Tuikov, Luben <[email protected]>; [email protected] <[email protected]>
Cc: Deucher, Alexander <[email protected]>
Subject: RE: [PATCH 4/4] drm/amdgpu: Fix kernel-doc for the RAS sysfs interface
[AMD Public Use]
Series is
Regards,
Hawking
-----Original Message-----
From: Tuikov, Luben <[email protected]>
Sent: Tuesday, April 13, 2021 20:56
To: [email protected]
Cc: Tuikov, Luben <[email protected]>; Deucher, Alexander <[email protected]>; Zhang, Hawking <[email protected]>
Subject: [PATCH 4/4] drm/amdgpu: Fix kernel-doc for the RAS sysfs interface
Imporve the kernel-doc for the RAS sysfs interface. Fix the grammar, fix the context.
--- drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 47 +++++++++++++------------ 1 file changed, 24 insertions(+), 23 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c +25 -23
@@ -274,7 +274,7 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,/** * DOC: AMDGPU RAS debugfs control interface * -* It accepts struct ras_debug_if who has two members. +* The control interface accepts struct ras_debug_if which has two members. * * First member: ras_debug_if::head or ras_debug_if::inject. *
@@ -299,32 +299,33 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,* * How to use the interface? * -* Programs +* In a program * -* Copy the struct ras_debug_if in your codes and initialize it. -* Write the struct to the control node. +* Copy the struct ras_debug_if in your code and initialize it. +* Write the struct to the control interface. * -* Shells +* From shell * * .. code-block:: bash * -* echo op block [error [sub_block address value]] > .../ras/ras_ctrl +* echo "disable <block>" > /sys/kernel/debug/dri/<N>/ras/ras_ctrl +* echo "enable <block> <error>" > /sys/kernel/debug/dri/<N>/ras/ras_ctrl +* echo "inject <block> <error> <sub-block> <address> <value> > /sys/kernel/debug/dri/<N>/ras/ras_ctrl * -* Parameters: +* Where N, is the card which you want to affect. * -* op: disable, enable, inject -* disable: only block is needed -* enable: block and error are needed -* inject: error, address, value are needed -* block: umc, sdma, gfx, ......... +* "disable" requires only the block. +* "enable" requires the block and error type. +* "inject" requires the block, error type, address, and value. +* The block is one of: umc, sdma, gfx, etc. * see ras_block_string[] for details -* error: ue, ce -* ue: multi_uncorrectable -* ce: single_correctable -* sub_block: -* sub block index, pass 0 if there is no sub block +* The error type is one of: ue, ce, where, +* ue is multi-uncorrectable +* ce is single-correctable +* The sub-block is a the sub-block index, pass 0 if there is no sub-block. +* The address and value are hexadecimal numbers, leading 0x is optional. * -* here are some examples for bash commands: +* For instance, * * .. code-block:: bash *
@@ -332,17 +333,17 @@ static int amdgpu_ras_debugfs_ctrl_parse_data(struct file *f,* echo inject umc ce 0 0 0 > /sys/kernel/debug/dri/0/ras/ras_ctrl * echo disable umc > /sys/kernel/debug/dri/0/ras/ras_ctrl * -* How to check the result? +* How to check the result of the operation? * -* For disable/enable, please check ras features at +* To check disable/enable, see "ras" features at, * /sys/class/drm/card[0/1/2...]/device/ras/features * -* For inject, please check corresponding err count at -* /sys/class/drm/card[0/1/2...]/device/ras/[gfx/sdma/...]_err_count +* To check inject, see the corresponding error count at, +* +/sys/class/drm/card[0/1/2...]/device/ras/[gfx|sdma|umc|...]_err_count * * .. note:: * Operations are only allowed on blocks which are supported. -* Please check ras mask at /sys/module/amdgpu/parameters/ras_mask +* Check the "ras" mask at /sys/module/amdgpu/parameters/ras_mask * to see which blocks support RAS on a particular asic. *
*/
--
2.31.0.97.g1424303384
_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx