On 3/18/2025 2:21 PM, Bart Van Assche wrote:
On 3/14/25 3:55 PM, Bao D. Nguyen wrote:
+ if (status & hba->ee_drv_mask & MASK_EE_DEV_LVL_EXCEPTION) {
+ hba->dev_lvl_exception_count++;
+ sysfs_notify(&hba->dev->kobj, NULL,
"device_lvl_exception_count");
+ }
This increment can race with the code in
device_lvl_exception_count_store() for clearing
hba->dev_lvl_exception_count. Shouldn't the clearing code and the
code for incrementing hba->dev_lvl_exception_count be serialized in
some way?
Thank you for the good catch, Bart. I do need to protect this racing
condition in the functions you mentioned. This dev_lvl_exception_count
variable is also initialized in the ufshcd_device_lvl_exception_probe()
function at which point the sysfs nodes have already been initialized,
but since both the device_lvl_exception_count_store() and the
ufshcd_device_lvl_exception_probe() write 0 to dev_lvl_exception_count,
it should be no problem there.
I will fix it.
Thanks, Bao