|
| 1 | +From ca9daf437f0910493a6eb8ced900662223ea3cf7 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Prince George < [email protected]> |
| 3 | +Date: Mon, 16 Aug 2021 16:04:15 +0000 |
| 4 | +Subject: [PATCH] Dynamic write_max support for optoe driver |
| 5 | + In current optoe driver, the value of write_max is hardcoded to one byte. |
| 6 | + CMIS spec supports firmware upgrade on QSFP-DD transceivers which means |
| 7 | + there is significant overhead due to this one byte write limit when a |
| 8 | + platform wants to upgrade the firmware over an i2c bus at 100Khz. |
| 9 | + The overhead is more pronounced when a platform has shared master and |
| 10 | + platform needs to perform firmware upgrade on multiple transceivers. |
| 11 | + |
| 12 | + Added sysfs file 'write_max' for each i2c device (that use optoe driver) |
| 13 | + so that the platform can override the default write max which is one byte. |
| 14 | + |
| 15 | + Test result:- |
| 16 | + Firmware file of size 1.9MB takes ~ 33 mins with write-max size = 1 Byte |
| 17 | + Firmware file of size 1.9MB takes ~ 8 mins with write-max size = 64 Bytes |
| 18 | + |
| 19 | +Signed-off-by: Prince George < [email protected]> |
| 20 | +--- |
| 21 | + drivers/misc/eeprom/optoe.c | 36 ++++++++++++++++++++++++++++++++++++ |
| 22 | + 1 file changed, 36 insertions(+) |
| 23 | + |
| 24 | +diff --git a/drivers/misc/eeprom/optoe.c b/drivers/misc/eeprom/optoe.c |
| 25 | +index 16287fdc5..cacfb1848 100644 |
| 26 | +--- a/drivers/misc/eeprom/optoe.c |
| 27 | ++++ b/drivers/misc/eeprom/optoe.c |
| 28 | +@@ -822,6 +822,39 @@ static int optoe_remove(struct i2c_client *client) |
| 29 | + return 0; |
| 30 | + } |
| 31 | + |
| 32 | ++static ssize_t show_dev_write_max_size(struct device *dev, |
| 33 | ++ struct device_attribute *dattr, char *buf) |
| 34 | ++{ |
| 35 | ++ struct i2c_client *client = to_i2c_client(dev); |
| 36 | ++ struct optoe_data *optoe = i2c_get_clientdata(client); |
| 37 | ++ ssize_t count; |
| 38 | ++ |
| 39 | ++ mutex_lock(&optoe->lock); |
| 40 | ++ count = sprintf(buf, "%u\n", optoe->write_max); |
| 41 | ++ mutex_unlock(&optoe->lock); |
| 42 | ++ |
| 43 | ++ return count; |
| 44 | ++} |
| 45 | ++ |
| 46 | ++static ssize_t set_dev_write_max_size(struct device *dev, |
| 47 | ++ struct device_attribute *attr, |
| 48 | ++ const char *buf, size_t count) |
| 49 | ++{ |
| 50 | ++ struct i2c_client *client = to_i2c_client(dev); |
| 51 | ++ struct optoe_data *optoe = i2c_get_clientdata(client); |
| 52 | ++ int write_max_size; |
| 53 | ++ |
| 54 | ++ if (kstrtouint(buf, 0, &write_max_size) != 0 || |
| 55 | ++ write_max_size < 1 || write_max_size > OPTOE_PAGE_SIZE) |
| 56 | ++ return -EINVAL; |
| 57 | ++ |
| 58 | ++ mutex_lock(&optoe->lock); |
| 59 | ++ optoe->write_max = write_max_size; |
| 60 | ++ mutex_unlock(&optoe->lock); |
| 61 | ++ |
| 62 | ++ return count; |
| 63 | ++} |
| 64 | ++ |
| 65 | + static ssize_t show_dev_class(struct device *dev, |
| 66 | + struct device_attribute *dattr, char *buf) |
| 67 | + { |
| 68 | +@@ -928,12 +961,15 @@ static ssize_t set_port_name(struct device *dev, |
| 69 | + static DEVICE_ATTR(port_name, 0644, show_port_name, set_port_name); |
| 70 | + #endif /* if NOT defined EEPROM_CLASS, the common case */ |
| 71 | + |
| 72 | ++static DEVICE_ATTR(write_max, 0644, show_dev_write_max_size, |
| 73 | ++ set_dev_write_max_size); |
| 74 | + static DEVICE_ATTR(dev_class, 0644, show_dev_class, set_dev_class); |
| 75 | + |
| 76 | + static struct attribute *optoe_attrs[] = { |
| 77 | + #ifndef EEPROM_CLASS |
| 78 | + &dev_attr_port_name.attr, |
| 79 | + #endif |
| 80 | ++ &dev_attr_write_max.attr, |
| 81 | + &dev_attr_dev_class.attr, |
| 82 | + NULL, |
| 83 | + }; |
| 84 | +-- |
| 85 | +2.17.1 |
| 86 | + |
0 commit comments