Skip to content

Commit 6196551

Browse files
paravmellanoxSomasundaram Krishnasamy
authored andcommitted
IB/core: Fix unable to change lifespan entry for hw_counters
This patch fixes the case where 'lifespan' entry of the hw_counters is not writable. Currently write callback is not exposed for for the hw_counters sysfs operation. Due to this, modifying lifespan value results into permission denied error in below example. echo 10 > /sys/class/infiniband/mlx5_0/ports/1/hw_counters/lifespan -bash: /sys/class/infiniband/mlx5_0/ports/1/hw_counters/lifespan: Permission denied This patch adds the hook to modify any attribute which implements store() operation. Merge-monkey: Aron Silverton <[email protected]> Merge-monkey-notes: The commit title and commit message body were updated to match the upstream commit which more accurately describes the code change. A reference to the upstream commit this fixes was also added. Orabug: 26761264 MlnxSF: 00384047 Upstream_status: done issue: 1124008 Change-Id: Ieeb30eb65a80e9afab4a0a53bac6edc4a6e6ee73 Fixes: b40f475 ("IB/core: Make device counter infrastructure dynamic") Signed-off-by: Parav Pandit <[email protected]> Signed-off-by: Aron Silverton <[email protected]> Reviewed-by: Håkon Bugge <[email protected]> Signed-off-by: Somasundaram Krishnasamy <[email protected]>
1 parent bc7d58e commit 6196551

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

drivers/infiniband/core/sysfs.c

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,22 @@ static ssize_t port_attr_show(struct kobject *kobj,
108108
return port_attr->show(p, port_attr, buf);
109109
}
110110

111+
static ssize_t port_attr_store(struct kobject *kobj,
112+
struct attribute *attr,
113+
const char *buf, size_t count)
114+
{
115+
struct port_attribute *port_attr =
116+
container_of(attr, struct port_attribute, attr);
117+
struct ib_port *p = container_of(kobj, struct ib_port, kobj);
118+
119+
if (!port_attr->store)
120+
return -EIO;
121+
return port_attr->store(p, port_attr, buf, count);
122+
}
123+
111124
static const struct sysfs_ops port_sysfs_ops = {
112-
.show = port_attr_show
125+
.show = port_attr_show,
126+
.store = port_attr_store
113127
};
114128

115129
static ssize_t gid_attr_show(struct kobject *kobj,

0 commit comments

Comments
 (0)