From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: adrianhoyin.ng@altera.com
Cc: Frank.Li@nxp.com, linux-i3c@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 2/5] i3c: add sysfs attribute for device NACK retry
Date: Wed, 10 Dec 2025 17:22:27 +0100 [thread overview]
Message-ID: <20251210162227450e28fd@mail.local> (raw)
In-Reply-To: <39c0289a838af7e6bbc5736f0d114b2e895556b3.1765177110.git.adrianhoyin.ng@altera.com>
On 08/12/2025 15:11:17+0800, adrianhoyin.ng@altera.com wrote:
> From: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
>
> Add a `dev_nack_retry` sysfs attribute to allow reading and updating the
> device NACK retry count. A new `dev_nack_retry` field and an optional
> `set_dev_nack_retry()` callback are added to i3c_master_controller.
> The attribute is created only when the callback is implemented.
>
> Updates are applied under the I3C bus maintenance lock to ensure safe
> hardware reconfiguration.
>
> Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
> ---
> drivers/i3c/master.c | 38 ++++++++++++++++++++++++++++++++++++++
> include/linux/i3c/master.h | 6 ++++++
> 2 files changed, 44 insertions(+)
>
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index d946db75df70..2903725bee03 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -685,6 +685,38 @@ static ssize_t hotjoin_show(struct device *dev, struct device_attribute *da, cha
>
> static DEVICE_ATTR_RW(hotjoin);
>
> +static ssize_t dev_nack_retry_show(struct device *dev, struct device_attribute *attr,
> + char *buf)
> +{
> + return sysfs_emit(buf, "%u\n", dev_to_i3cmaster(dev)->dev_nack_retry);
> +}
> +
> +static ssize_t dev_nack_retry_store(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct i3c_bus *i3cbus = dev_to_i3cbus(dev);
> + struct i3c_master_controller *master = dev_to_i3cmaster(dev);
> + unsigned long val;
> + int ret;
> +
> + ret = kstrtoul(buf, 0, &val);
> + if (ret)
> + return ret;
> +
> + i3c_bus_maintenance_lock(i3cbus);
> + ret = master->ops->set_dev_nack_retry(master, val);
> + i3c_bus_maintenance_unlock(i3cbus);
> +
> + if (ret)
> + return ret;
> +
> + master->dev_nack_retry = val;
> +
> + return count;
> +}
> +
> +static DEVICE_ATTR_RW(dev_nack_retry);
Shouldn't that be dev_nack_retry_count ?
> +
> static struct attribute *i3c_masterdev_attrs[] = {
> &dev_attr_mode.attr,
> &dev_attr_current_master.attr,
> @@ -2962,6 +2994,9 @@ int i3c_master_register(struct i3c_master_controller *master,
> i3c_master_register_new_i3c_devs(master);
> i3c_bus_normaluse_unlock(&master->bus);
>
> + if (master->ops->set_dev_nack_retry)
> + device_create_file(&master->dev, &dev_attr_dev_nack_retry);
> +
> return 0;
>
> err_del_dev:
> @@ -2987,6 +3022,9 @@ void i3c_master_unregister(struct i3c_master_controller *master)
> {
> i3c_bus_notify(&master->bus, I3C_NOTIFY_BUS_REMOVE);
>
> + if (master->ops->set_dev_nack_retry)
> + device_remove_file(&master->dev, &dev_attr_dev_nack_retry);
> +
> i3c_master_i2c_adapter_cleanup(master);
> i3c_master_unregister_i3c_devs(master);
> i3c_master_bus_cleanup(master);
> diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h
> index c52a82dd79a6..5a03e5aea6c2 100644
> --- a/include/linux/i3c/master.h
> +++ b/include/linux/i3c/master.h
> @@ -462,6 +462,8 @@ struct i3c_bus {
> * @enable_hotjoin: enable hot join event detect.
> * @disable_hotjoin: disable hot join event detect.
> * @set_speed: adjust I3C open drain mode timing.
> + * @set_dev_nack_retry: configure device NACK retry count for the master
> + * controller.
> */
> struct i3c_master_controller_ops {
> int (*bus_init)(struct i3c_master_controller *master);
> @@ -491,6 +493,8 @@ struct i3c_master_controller_ops {
> int (*enable_hotjoin)(struct i3c_master_controller *master);
> int (*disable_hotjoin)(struct i3c_master_controller *master);
> int (*set_speed)(struct i3c_master_controller *master, enum i3c_open_drain_speed speed);
> + int (*set_dev_nack_retry)(struct i3c_master_controller *master,
> + unsigned long dev_nack_retry_cnt);
> };
>
> /**
> @@ -510,6 +514,7 @@ struct i3c_master_controller_ops {
> * @boardinfo: board-level information attached to devices connected on the bus
> * @bus: I3C bus exposed by this master
> * @wq: workqueue which can be used by master
> + * @dev_nack_retry: retry count when slave device nack
> * drivers if they need to postpone operations that need to take place
> * in a thread context. Typical examples are Hot Join processing which
> * requires taking the bus lock in maintenance, which in turn, can only
> @@ -534,6 +539,7 @@ struct i3c_master_controller {
> } boardinfo;
> struct i3c_bus bus;
> struct workqueue_struct *wq;
> + unsigned int dev_nack_retry;
> };
>
> /**
> --
> 2.49.GIT
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
--
linux-i3c mailing list
linux-i3c@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-i3c
WARNING: multiple messages have this Message-ID (diff)
From: Alexandre Belloni <alexandre.belloni@bootlin.com>
To: adrianhoyin.ng@altera.com
Cc: Frank.Li@nxp.com, linux-i3c@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v7 2/5] i3c: add sysfs attribute for device NACK retry
Date: Wed, 10 Dec 2025 17:22:27 +0100 [thread overview]
Message-ID: <20251210162227450e28fd@mail.local> (raw)
In-Reply-To: <39c0289a838af7e6bbc5736f0d114b2e895556b3.1765177110.git.adrianhoyin.ng@altera.com>
On 08/12/2025 15:11:17+0800, adrianhoyin.ng@altera.com wrote:
> From: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
>
> Add a `dev_nack_retry` sysfs attribute to allow reading and updating the
> device NACK retry count. A new `dev_nack_retry` field and an optional
> `set_dev_nack_retry()` callback are added to i3c_master_controller.
> The attribute is created only when the callback is implemented.
>
> Updates are applied under the I3C bus maintenance lock to ensure safe
> hardware reconfiguration.
>
> Signed-off-by: Adrian Ng Ho Yin <adrianhoyin.ng@altera.com>
> ---
> drivers/i3c/master.c | 38 ++++++++++++++++++++++++++++++++++++++
> include/linux/i3c/master.h | 6 ++++++
> 2 files changed, 44 insertions(+)
>
> diff --git a/drivers/i3c/master.c b/drivers/i3c/master.c
> index d946db75df70..2903725bee03 100644
> --- a/drivers/i3c/master.c
> +++ b/drivers/i3c/master.c
> @@ -685,6 +685,38 @@ static ssize_t hotjoin_show(struct device *dev, struct device_attribute *da, cha
>
> static DEVICE_ATTR_RW(hotjoin);
>
> +static ssize_t dev_nack_retry_show(struct device *dev, struct device_attribute *attr,
> + char *buf)
> +{
> + return sysfs_emit(buf, "%u\n", dev_to_i3cmaster(dev)->dev_nack_retry);
> +}
> +
> +static ssize_t dev_nack_retry_store(struct device *dev, struct device_attribute *attr,
> + const char *buf, size_t count)
> +{
> + struct i3c_bus *i3cbus = dev_to_i3cbus(dev);
> + struct i3c_master_controller *master = dev_to_i3cmaster(dev);
> + unsigned long val;
> + int ret;
> +
> + ret = kstrtoul(buf, 0, &val);
> + if (ret)
> + return ret;
> +
> + i3c_bus_maintenance_lock(i3cbus);
> + ret = master->ops->set_dev_nack_retry(master, val);
> + i3c_bus_maintenance_unlock(i3cbus);
> +
> + if (ret)
> + return ret;
> +
> + master->dev_nack_retry = val;
> +
> + return count;
> +}
> +
> +static DEVICE_ATTR_RW(dev_nack_retry);
Shouldn't that be dev_nack_retry_count ?
> +
> static struct attribute *i3c_masterdev_attrs[] = {
> &dev_attr_mode.attr,
> &dev_attr_current_master.attr,
> @@ -2962,6 +2994,9 @@ int i3c_master_register(struct i3c_master_controller *master,
> i3c_master_register_new_i3c_devs(master);
> i3c_bus_normaluse_unlock(&master->bus);
>
> + if (master->ops->set_dev_nack_retry)
> + device_create_file(&master->dev, &dev_attr_dev_nack_retry);
> +
> return 0;
>
> err_del_dev:
> @@ -2987,6 +3022,9 @@ void i3c_master_unregister(struct i3c_master_controller *master)
> {
> i3c_bus_notify(&master->bus, I3C_NOTIFY_BUS_REMOVE);
>
> + if (master->ops->set_dev_nack_retry)
> + device_remove_file(&master->dev, &dev_attr_dev_nack_retry);
> +
> i3c_master_i2c_adapter_cleanup(master);
> i3c_master_unregister_i3c_devs(master);
> i3c_master_bus_cleanup(master);
> diff --git a/include/linux/i3c/master.h b/include/linux/i3c/master.h
> index c52a82dd79a6..5a03e5aea6c2 100644
> --- a/include/linux/i3c/master.h
> +++ b/include/linux/i3c/master.h
> @@ -462,6 +462,8 @@ struct i3c_bus {
> * @enable_hotjoin: enable hot join event detect.
> * @disable_hotjoin: disable hot join event detect.
> * @set_speed: adjust I3C open drain mode timing.
> + * @set_dev_nack_retry: configure device NACK retry count for the master
> + * controller.
> */
> struct i3c_master_controller_ops {
> int (*bus_init)(struct i3c_master_controller *master);
> @@ -491,6 +493,8 @@ struct i3c_master_controller_ops {
> int (*enable_hotjoin)(struct i3c_master_controller *master);
> int (*disable_hotjoin)(struct i3c_master_controller *master);
> int (*set_speed)(struct i3c_master_controller *master, enum i3c_open_drain_speed speed);
> + int (*set_dev_nack_retry)(struct i3c_master_controller *master,
> + unsigned long dev_nack_retry_cnt);
> };
>
> /**
> @@ -510,6 +514,7 @@ struct i3c_master_controller_ops {
> * @boardinfo: board-level information attached to devices connected on the bus
> * @bus: I3C bus exposed by this master
> * @wq: workqueue which can be used by master
> + * @dev_nack_retry: retry count when slave device nack
> * drivers if they need to postpone operations that need to take place
> * in a thread context. Typical examples are Hot Join processing which
> * requires taking the bus lock in maintenance, which in turn, can only
> @@ -534,6 +539,7 @@ struct i3c_master_controller {
> } boardinfo;
> struct i3c_bus bus;
> struct workqueue_struct *wq;
> + unsigned int dev_nack_retry;
> };
>
> /**
> --
> 2.49.GIT
>
--
Alexandre Belloni, co-owner and COO, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
next prev parent reply other threads:[~2025-12-10 16:22 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-08 7:11 [PATCH v7 0/5] i3c: dw-i3c: Enable support for dw-i3c controller NACK retry sysfs and DAT restore fix adrianhoyin.ng
2025-12-08 7:11 ` adrianhoyin.ng
2025-12-08 7:11 ` [PATCH v7 1/5] i3c: add sysfs entry for Device NACK Retry count adrianhoyin.ng
2025-12-08 7:11 ` adrianhoyin.ng
2025-12-10 16:21 ` Alexandre Belloni
2025-12-10 16:21 ` Alexandre Belloni
2025-12-08 7:11 ` [PATCH v7 2/5] i3c: add sysfs attribute for device NACK retry adrianhoyin.ng
2025-12-08 7:11 ` adrianhoyin.ng
2025-12-08 15:25 ` Frank Li
2025-12-08 15:25 ` Frank Li
2025-12-10 16:22 ` Alexandre Belloni [this message]
2025-12-10 16:22 ` Alexandre Belloni
2025-12-08 7:11 ` [PATCH v7 3/5] i3c: dw: Add support for Device NACK Retry configuration adrianhoyin.ng
2025-12-08 7:11 ` adrianhoyin.ng
2025-12-08 15:27 ` Frank Li
2025-12-08 15:27 ` Frank Li
2025-12-08 7:11 ` [PATCH v7 4/5] i3c: dw: use FIELD_PREP for device address table macros adrianhoyin.ng
2025-12-08 7:11 ` adrianhoyin.ng
2025-12-08 7:11 ` [PATCH v7 5/5] i3c: dw: Preserve DAT entry bits when restoring addresses adrianhoyin.ng
2025-12-08 7:11 ` adrianhoyin.ng
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251210162227450e28fd@mail.local \
--to=alexandre.belloni@bootlin.com \
--cc=Frank.Li@nxp.com \
--cc=adrianhoyin.ng@altera.com \
--cc=linux-i3c@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.