Linux Trace Kernel
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Dmitry Guzman" <Dmitry.Guzman@mobileye.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH RFC v3 12/14] i2c: nomadik: add support for I2C_XFER_V2 - detailed fault reporting
Date: Thu, 05 Nov 2026 18:13:44 +0000	[thread overview]
Message-ID: <sashiko-outbox-199706@kernel.org> (raw)
In-Reply-To: <20261105-i2c-fault-reporting-v3-12-515ad74ac4c9@mobileye.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] i2c: nomadik: unpopulated transfer report on pm_runtime_get_sync() early exit
--

commit 22d1a25cd553d39ed6c3ad6c9998ec471c05f948
Author: Dmitry Guzman <Dmitry.Guzman@mobileye.com>

i2c: nomadik: add support for I2C_XFER_V2 - detailed fault reporting

This commit converts the i2c-nomadik driver to the xfer_v2 callback so it can
populate struct i2c_transfer_report with the number of completed messages,
completed bytes, and the faulting message index when a transfer fails.

> diff --git a/drivers/i2c/busses/i2c-nomadik.c b/drivers/i2c/busses/i2c-nomadik.c
> index 958adc51615e4..a8ccd863a6edf 100644
> --- a/drivers/i2c/busses/i2c-nomadik.c
> +++ b/drivers/i2c/busses/i2c-nomadik.c

[ ... ]

> @@ -739,8 +755,9 @@ static int nmk_i2c_xfer_one(struct nmk_i2c_dev *priv, u16 flags)
>   * please use the i2c_smbus_read_i2c_block_data()
>   * or i2c_smbus_write_i2c_block_data() API
>   */
> -static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
> -		struct i2c_msg msgs[], int num_msgs)
> +static int nmk_i2c_xfer_v2(struct i2c_adapter *i2c_adap,
> +		struct i2c_msg msgs[], int num_msgs,
> +		struct i2c_transfer_report *report)
>  {
>  	int status = 0;
>  	int i;
> @@ -750,6 +767,8 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
>  	if (i)
>  		return i;
>  
> +	priv->bytes_cplt = 0;
> +
>  	/* setup the i2c controller */
>  	setup_i2c_controller(priv);
>  
> @@ -768,10 +787,15 @@ static int nmk_i2c_xfer(struct i2c_adapter *i2c_adap,
>  	pm_runtime_put_sync(&priv->adev->dev);
>  
>  	/* return the no. messages processed */
> -	if (status)
> +	if (status) {
> +		report->msgs_cplt = i;
> +		report->bytes_cplt = priv->bytes_cplt;
> +		report->fault_msg_idx = i;
>  		return status;
> -	else
> +	} else {
> +		i2c_transfer_report_success(report, num_msgs);
>  		return num_msgs;
> +	}
>  }

[Severity: Medium]
What happens to the transfer report in drivers/i2c/busses/i2c-nomadik.c when
nmk_i2c_xfer_v2() takes the early return on pm_runtime_get_sync()?

Before invoking adap->algo->xfer_v2(), __i2c_transfer_v2() in
drivers/i2c/i2c-core-base.c initializes all fields of struct
i2c_transfer_report to -EOPNOTSUPP via i2c_transfer_report_init(report):

drivers/i2c/i2c-core-base.c:__i2c_transfer_v2() {
	...
	if (adap->algo->xfer_v2) {
		i2c_transfer_report_init(report);
		...
		ret = adap->algo->xfer_v2(adap, msgs, num, report);
	...
}

In nmk_i2c_xfer_v2(), if pm_runtime_get_sync(&priv->adev->dev) returns a
non-zero value, the function returns immediately before reaching the block at
the end of nmk_i2c_xfer_v2() that populates report:

	i = pm_runtime_get_sync(&priv->adev->dev);
	if (i)
		return i;

If pm_runtime_get_sync() fails with a negative error code, 0 messages and 0
bytes have been transferred before failing on message 0, but report->msgs_cplt,
report->bytes_cplt, and report->fault_msg_idx remain -EOPNOTSUPP instead of 0,
telling callers of i2c_transfer_v2() and the I2C_RDWR_V2 ioctl that the
controller does not support fault reporting.

In addition, if pm_runtime_get_sync() returns 1 because the device was already
active, nmk_i2c_xfer_v2() returns 1 while leaving all fields of report set to
-EOPNOTSUPP, resulting in a positive return value paired with a negative
report->msgs_cplt.

Should nmk_i2c_xfer_v2() populate report (or use pm_runtime_resume_and_get()
and set msgs_cplt, bytes_cplt, and fault_msg_idx to 0 on error) before
returning when runtime resume fails?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261105-i2c-fault-reporting-v3-0-515ad74ac4c9@mobileye.com?part=12

  reply	other threads:[~2026-11-05 18:13 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05 17:15 [PATCH RFC v3 00/14] I2C - detailed transfer reporting in case of a fault Dmitry Guzman
2026-11-05 17:15 ` [PATCH RFC v3 01/14] i2c: uapi: add i2c_transfer_report structure Dmitry Guzman
2026-11-05 17:15 ` [PATCH RFC v3 02/14] i2c: core: add xfer_v2() to i2c_algorithm structure Dmitry Guzman
2026-11-05 17:15 ` [PATCH RFC v3 03/14] i2c: core: add helper functions for transfer report generation Dmitry Guzman
2026-11-05 17:15 ` [PATCH RFC v3 04/14] i2c: core: add i2c_xfer_to_xfer_v2() helper function Dmitry Guzman
2026-11-05 17:15 ` [PATCH RFC v3 05/14] i2c: trace: pass message length separately in trace_i2c_reply() Dmitry Guzman
2026-11-05 17:15 ` [PATCH RFC v3 06/14] i2c: core: make i2c_check_for_quirks() return pointer to the message Dmitry Guzman
2026-11-05 17:15 ` [PATCH RFC v3 07/14] i2c: core: implement i2c_transfer_v2() - transfer with detailed reporting Dmitry Guzman
2026-11-05 17:34   ` sashiko-bot
2026-11-05 18:28   ` Andy Shevchenko
2026-11-05 17:15 ` [PATCH RFC v3 08/14] i2c: uapi: add I2C_XFER_V2 ioctl - detailed fault reporting Dmitry Guzman
2026-11-05 17:35   ` sashiko-bot
2026-11-05 17:15 ` [PATCH RFC v3 09/14] i2c: core: implement I2C_RDWR_V2 ioctl - transfer with detailed report Dmitry Guzman
2026-11-05 17:51   ` sashiko-bot
2026-11-05 17:15 ` [PATCH RFC v3 10/14] i2c: doc: add section for I2C_RDWR_V2 ioctl Dmitry Guzman
2026-11-05 17:44   ` sashiko-bot
2026-11-05 17:15 ` [PATCH RFC v3 11/14] i2c: nomadik: save I2C_CR register before resetting HW in IRQ handler Dmitry Guzman
2026-11-05 17:53   ` sashiko-bot
2026-11-05 17:15 ` [PATCH RFC v3 12/14] i2c: nomadik: add support for I2C_XFER_V2 - detailed fault reporting Dmitry Guzman
2026-11-05 18:13   ` sashiko-bot [this message]
2026-11-05 17:15 ` [PATCH RFC v3 13/14] i2c: designware: use separate `i2c_algorithm` for AMD_NAVI_GPU Dmitry Guzman
2026-11-05 17:15 ` [PATCH RFC v3 14/14] i2c: designware: add support for I2C_XFER_V2 - detailed fault reporting Dmitry Guzman
2026-11-05 18:21   ` sashiko-bot

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=sashiko-outbox-199706@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Dmitry.Guzman@mobileye.com \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=sashiko-reviews@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