Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 26 Jul 2021 16:13:23 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org
Subject:   git: 645d0710fc48 - stable/13 - ibcore: Fix unable to change lifespan entry for hw_counters.
Message-ID:  <202107261613.16QGDNjU005383@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch stable/13 has been updated by hselasky:

URL: https://cgit.FreeBSD.org/src/commit/?id=645d0710fc48e255ea74ede8bd2c08aab2207965

commit 645d0710fc48e255ea74ede8bd2c08aab2207965
Author:     Hans Petter Selasky <hselasky@FreeBSD.org>
AuthorDate: 2021-06-16 13:01:39 +0000
Commit:     Hans Petter Selasky <hselasky@FreeBSD.org>
CommitDate: 2021-07-26 16:04:30 +0000

    ibcore: 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.
    
    Linux commit:
    79c4d80b43b8e43684894574a508a871f0c196bf
    
    Reviewed by:    kib
    Sponsored by:   Mellanox Technologies // NVIDIA Networking
    
    (cherry picked from commit d7d833e20ba33f5b9f3052a534af7ecdd602f152)
---
 sys/ofed/drivers/infiniband/core/ib_sysfs.c | 16 +++++++++++++++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/sys/ofed/drivers/infiniband/core/ib_sysfs.c b/sys/ofed/drivers/infiniband/core/ib_sysfs.c
index d12b5803e722..55e7b5395b8e 100644
--- a/sys/ofed/drivers/infiniband/core/ib_sysfs.c
+++ b/sys/ofed/drivers/infiniband/core/ib_sysfs.c
@@ -114,8 +114,22 @@ static ssize_t port_attr_show(struct kobject *kobj,
 	return port_attr->show(p, port_attr, buf);
 }
 
+static ssize_t port_attr_store(struct kobject *kobj,
+			       struct attribute *attr,
+			       const char *buf, size_t count)
+{
+	struct port_attribute *port_attr =
+		container_of(attr, struct port_attribute, attr);
+	struct ib_port *p = container_of(kobj, struct ib_port, kobj);
+
+	if (!port_attr->store)
+		return -EIO;
+	return port_attr->store(p, port_attr, buf, count);
+}
+
 static const struct sysfs_ops port_sysfs_ops = {
-	.show = port_attr_show
+	.show	= port_attr_show,
+	.store	= port_attr_store
 };
 
 static ssize_t gid_attr_show(struct kobject *kobj,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202107261613.16QGDNjU005383>