lkml.org 
[lkml]   [2020]   [Sep]   [14]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    Patch in this message
    /
    From
    Subject[RFC PATCH 2/2] hwmon: (pmbus/ucd9000) Throttle SMBus transfers to avoid poor behaviour
    Date
    Short turn-around times between transfers to e.g. the UCD90320 can lead
    to problematic behaviour, including excessive clock stretching, bus
    lockups and potential corruption of the device's volatile state.

    Introduce transfer throttling for the device with a minimum access
    delay of 1ms.

    Signed-off-by: Andrew Jeffery <andrew@aj.id.au>
    ---
    drivers/hwmon/pmbus/ucd9000.c | 6 ++++++
    1 file changed, 6 insertions(+)

    diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c
    index 81f4c4f166cd..a0b97d035326 100644
    --- a/drivers/hwmon/pmbus/ucd9000.c
    +++ b/drivers/hwmon/pmbus/ucd9000.c
    @@ -9,6 +9,7 @@
    #include <linux/debugfs.h>
    #include <linux/kernel.h>
    #include <linux/module.h>
    +#include <linux/moduleparam.h>
    #include <linux/of_device.h>
    #include <linux/init.h>
    #include <linux/err.h>
    @@ -18,6 +19,9 @@
    #include <linux/gpio/driver.h>
    #include "pmbus.h"

    +static unsigned long smbus_delay_us = 1000;
    +module_param(smbus_delay_us, ulong, 0664);
    +
    enum chips { ucd9000, ucd90120, ucd90124, ucd90160, ucd90320, ucd9090,
    ucd90910 };

    @@ -502,6 +506,8 @@ static int ucd9000_probe(struct i2c_client *client,
    I2C_FUNC_SMBUS_BLOCK_DATA))
    return -ENODEV;

    + i2c_smbus_throttle_client(client, smbus_delay_us);
    +
    ret = i2c_smbus_read_block_data(client, UCD9000_DEVICE_ID,
    block_buffer);
    if (ret < 0) {
    --
    2.25.1
    \
     
     \ /
      Last update: 2020-09-14 19:25    [W:3.649 / U:0.116 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site