Linux Hardware Monitor development
 help / color / mirror / Atom feed
From: "Abdurrahman Hussain" <abdurrahman@nexthop.ai>
To: "Guenter Roeck" <linux@roeck-us.net>,
	"Abdurrahman Hussain" <abdurrahman@nexthop.ai>,
	<sashiko@lists.linux.dev>
Cc: <linux-hwmon@vger.kernel.org>, "Guenter Roeck" <groeck7@gmail.com>
Subject: Re: [PATCH RESEND v2 2/5] hwmon: (pmbus/adm1266) add clear_blackbox debugfs entry
Date: Tue, 12 May 2026 03:20:46 -0700	[thread overview]
Message-ID: <DIGMFKP4POUI.2ZTJ4UM3GJW02@nexthop.ai> (raw)
In-Reply-To: <eaf93149-a7cf-4a11-8ccc-8aa1b1e83b7e@roeck-us.net>

On Tue May 12, 2026 at 2:19 AM PDT, Guenter Roeck wrote:
> On 5/12/26 01:27, Abdurrahman Hussain wrote:
>> On Mon May 11, 2026 at 5:52 PM PDT, sashiko-bot wrote:
>>> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
>>> - [High] The debugfs write handler `adm1266_clear_blackbox_write` performs an I2C transaction without acquiring the required hardware monitoring locks, violating hwmon subsystem guidelines.
>>> --
>>>
>>> commit ab9c19373562d58415e28511b037545cfd278c2a
>>> Author: Abdurrahman Hussain <abdurrahman@nexthop.ai>
>>> Subject: hwmon: (pmbus/adm1266) add clear_blackbox debugfs entry
>>>
>>> This commit adds a debugfs entry to clear the ADM1266 blackbox buffer by
>>> issuing a block-write command to the device. This is needed when the
>>> device operates in single-recording mode to preserve fault history.
>>>
>>>> diff --git a/drivers/hwmon/pmbus/adm1266.c b/drivers/hwmon/pmbus/adm1266.c
>>>> index 7b8433226176f..31aefa8fc75f5 100644
>>>> --- a/drivers/hwmon/pmbus/adm1266.c
>>>> +++ b/drivers/hwmon/pmbus/adm1266.c
>>>
>>> [ ... ]
>>>
>>>> +static ssize_t adm1266_clear_blackbox_write(struct file *file, const char __user *ubuf,
>>>> +					    size_t count, loff_t *ppos)
>>>> +{
>>>> +	struct i2c_client *client = file->private_data;
>>>> +	u8 payload[2] = { 0xFE, 0x00 };
>>>> +	int ret;
>>>> +
>>>> +	ret = i2c_smbus_write_block_data(client, ADM1266_READ_BLACKBOX,
>>>> +					 sizeof(payload), payload);
>>>
>>> Does this I2C block write need to be protected by hwmon_lock() and
>>> hwmon_unlock()?
>>>
>>> The hardware monitoring subsystem guidelines require drivers to implement
>>> locking for attributes registered outside of the core registration functions,
>>> such as debugfs entries.
>>>
>>> Without these locks, could this write operation race with other multi-record
>>> transactions? For example, if this clear command is interleaved while
>>> adm1266_nvmem_read_blackbox() is iterating through multiple records, might
>>> it corrupt the read sequence?
>>>
>>>> +	if (ret < 0)
>>>> +		return ret;
>>>> +
>>>> +	return count;
>>>> +}
>> 
>> Good catch!
>> 
>> Will use pmbus_lock_interruptible() in v3.
>> 
>
> There is also "guard(pmbus_lock)(client);" or "scoped_guard(pmbus_lock, client) { ... }".
> Guenter

Thanks for the tip! Does that mean you're ok with losing the
interruptibility, since there's no DEFINE_GUARD_COND for interruptible
variant?

Abdurrahman


  reply	other threads:[~2026-05-12 10:20 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-11  7:51 [PATCH RESEND v2 0/5] hwmon: (pmbus/adm1266) blackbox, FW rev, rtc_class, GPIO label Abdurrahman Hussain
2026-05-11  7:51 ` [PATCH RESEND v2 1/5] hwmon: (pmbus/adm1266) add firmware_revision debugfs entry Abdurrahman Hussain
2026-05-11  7:51 ` [PATCH RESEND v2 2/5] hwmon: (pmbus/adm1266) add clear_blackbox " Abdurrahman Hussain
2026-05-12  0:52   ` sashiko-bot
2026-05-12  8:27     ` Abdurrahman Hussain
2026-05-12  9:19       ` Guenter Roeck
2026-05-12 10:20         ` Abdurrahman Hussain [this message]
2026-05-12 13:55           ` Guenter Roeck
2026-05-11  7:51 ` [PATCH RESEND v2 3/5] hwmon: (pmbus/adm1266) add powerup_counter " Abdurrahman Hussain
2026-05-12  1:29   ` sashiko-bot
2026-05-12  8:34     ` Abdurrahman Hussain
2026-05-11  7:51 ` [PATCH RESEND v2 4/5] hwmon: (pmbus/adm1266) replace probe-time RTC seed with rtc_class device Abdurrahman Hussain
2026-05-12  3:32   ` sashiko-bot
2026-05-12  8:42     ` Abdurrahman Hussain
2026-05-11  7:51 ` [PATCH RESEND v2 5/5] hwmon: (pmbus/adm1266) include adapter number in GPIO line label Abdurrahman Hussain
2026-05-11 14:10 ` [PATCH RESEND v2 0/5] hwmon: (pmbus/adm1266) blackbox, FW rev, rtc_class, GPIO label Guenter Roeck
2026-05-11 18:34   ` Abdurrahman Hussain

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=DIGMFKP4POUI.2ZTJ4UM3GJW02@nexthop.ai \
    --to=abdurrahman@nexthop.ai \
    --cc=groeck7@gmail.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=sashiko@lists.linux.dev \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox