• Robert Hancock's avatar
    hwmon: (pmbus) Add mutex locking for sysfs reads · 18e8db7f
    Robert Hancock authored
    As part of commit a919ba06 ("hwmon: (pmbus) Stop caching register
    values"), the update of the sensor value is now triggered directly by the
    sensor attribute value being read from sysfs. This created (or at least
    made much more likely) a locking issue, since nothing protected the device
    page selection from being unexpectedly modified by concurrent reads. If
    sensor values on different pages on the same device were being concurrently
    read by multiple threads, this could cause spurious read errors due to the
    page register not reading back the same value last written, or sensor
    values being read from the incorrect page.
    
    Add locking of the update_lock mutex in pmbus_show_sensor and
    pmbus_show_samples so that these cannot result in concurrent reads from the
    underlying device.
    
    Fixes: a919ba06
    
     ("hwmon: (pmbus) Stop caching register values")
    Signed-off-by: default avatarRobert Hancock <robert.hancock@calian.com>
    Reviewed-by: default avatarAlex Qiu <xqiu@google.com>
    Link: https://lor...
    18e8db7f
pmbus_core.c 63.8 KB