From: sashiko-bot@kernel.org
To: "Dmitry Guzman" <Dmitry.Guzman@mobileye.com>
Cc: linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCH v2 12/12] i2c: designware: add support for I2C_XFER_V2 - detailed fault reporting
Date: Thu, 03 Sep 2026 05:59:24 +0000 [thread overview]
Message-ID: <20260903055924.E572F1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260903-i2c-fault-reporting-v2-12-fedeb91792e6@mobileye.com>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Medium] Uninitialized stack variable `stat` is evaluated if `regmap_read` fails.
- [Medium] i2c_dw_fault_report incorrectly reports transmission progress on non-abort errors, and unconditional addition corrupts potential error returns.
--
commit ace9d554c2f401ddd92040765e5f36fab0bfd74c
Author: Dmitry Guzman <Dmitry.Guzman@mobileye.com>
Subject: i2c: designware: add support for I2C_XFER_V2 - detailed fault reporting
This commit introduces support for I2C_XFER_V2 in the i2c-designware driver.
It enables clients to get detailed reports on transmission failures by
detecting the number of un-sent bytes via the FLUSH_CNT field and checking
abort flags after FIFO reads and writes.
> diff --git a/drivers/i2c/busses/i2c-designware-master.c b/drivers/i2c/busses/i2c-designware-master.c
> index f029aa1eadbf8..bc23c3fdaaf2e 100644
> --- a/drivers/i2c/busses/i2c-designware-master.c
> +++ b/drivers/i2c/busses/i2c-designware-master.c
[ ... ]
> @@ -33,6 +34,16 @@
> #define AMD_TIMEOUT_MAX_US 250
> #define AMD_MASTERCFG_MASK GENMASK(15, 0)
>
> +static int i2c_dw_fault_report(struct dw_i2c_dev *dev, struct i2c_transfer_report *report);
> +
> +static inline bool i2c_dw_check_abort_flag(struct dw_i2c_dev *dev)
> +{
> + u32 stat;
> +
> + regmap_read(dev->map, DW_IC_RAW_INTR_STAT, &stat);
> + return (!!(stat & DW_IC_INTR_TX_ABRT));
> +}
[Severity: Medium]
If regmap_read() fails (for example, due to a bus error or PM state),
could this result in evaluating an uninitialized stack variable?
If stat contains a garbage value, this might spuriously detect a TX abort,
prematurely breaking the FIFO read/write loops and causing non-deterministic
transfer behavior.
[ ... ]
> @@ -918,16 +980,83 @@ i2c_dw_xfer_common(struct dw_i2c_dev *dev, struct i2c_msg msgs[], int num)
>
> i2c_dw_release_lock(dev);
>
> - if (ret < 0)
> + if (ret < 0) {
> + if (report) {
> + i2c_dw_fault_report(dev, report);
> + report->msgs_cplt += msgs_in_prev_parts;
> + report->fault_msg_idx += msgs_in_prev_parts;
> + }
> return ret;
> + }
[Severity: Medium]
Will this unconditional addition corrupt a negative error code if
i2c_dw_fault_report() sets report->msgs_cplt to a negative value to indicate
an indeterminate state?
[ ... ]
> +static int i2c_dw_fault_report(struct dw_i2c_dev *dev, struct i2c_transfer_report *report)
> +{
> + int idx;
> + int n_flushed = FIELD_GET(DW_IC_TX_ABRT_SOURCE_FLUSH_CNT_MASK, dev->abort_source);
[Severity: Medium]
Does this code correctly handle non-abort errors like timeouts?
If a timeout occurs and dev->abort_source is 0, n_flushed will be 0. Could
this cause bytes stuck in the FIFO to be incorrectly reported as successfully
sent on the wire?
[ ... ]
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260903-i2c-fault-reporting-v2-0-fedeb91792e6@mobileye.com?part=12
next prev parent reply other threads:[~2026-09-03 5:59 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 5:38 [PATCH v2 00/12] I2C - detailed transfer reporting in case of a fault Dmitry Guzman
2026-09-03 5:38 ` [PATCH v2 01/12] i2c: core: add I2C_XFER_V2 - support for detailed transfer reporting Dmitry Guzman
2026-09-03 5:52 ` sashiko-bot
2026-09-03 7:21 ` Andy Shevchenko
2026-09-04 10:53 ` Dmitry Guzman
2026-09-03 5:38 ` [PATCH v2 02/12] i2c: nomadik: optimize struct layout, change unsigned char into u8 Dmitry Guzman
2026-09-03 5:38 ` [PATCH v2 03/12] i2c: nomadik: do not try to retransmit I2C message series on errors Dmitry Guzman
2026-09-03 5:53 ` sashiko-bot
2026-09-03 5:38 ` [PATCH v2 04/12] i2c: nomadik: return proper fault codes Dmitry Guzman
2026-09-03 5:38 ` [PATCH v2 05/12] i2c: nomadik: change print level for fault messages to debug Dmitry Guzman
2026-09-03 5:50 ` sashiko-bot
2026-09-03 5:38 ` [PATCH v2 06/12] i2c: nomadik: add quirks max_len=2047 and no_zero_len_read Dmitry Guzman
2026-09-03 5:38 ` [PATCH v2 07/12] i2c: nomadik: add support for I2C_XFER_V2 - detailed fault reporting Dmitry Guzman
2026-09-03 5:56 ` sashiko-bot
2026-09-03 5:38 ` [PATCH v2 08/12] i2c: designware: return proper fault codes Dmitry Guzman
2026-09-03 5:38 ` [PATCH v2 09/12] i2c: designware: no SMBUS_READ_BLOCK_DATA without EMPTYFIFO_HOLD_MASTER Dmitry Guzman
2026-09-03 7:39 ` Andy Shevchenko
2026-09-03 5:38 ` [PATCH v2 10/12] i2c: designware: stop transfer if spurious STOP is detected Dmitry Guzman
2026-09-03 5:49 ` sashiko-bot
2026-09-03 5:38 ` [PATCH v2 11/12] i2c: designware: use separate `i2c_algorithm` for AMD_NAVI_GPU Dmitry Guzman
2026-09-03 5:56 ` sashiko-bot
2026-09-03 5:38 ` [PATCH v2 12/12] i2c: designware: add support for I2C_XFER_V2 - detailed fault reporting Dmitry Guzman
2026-09-03 5:59 ` sashiko-bot [this message]
2026-09-03 7:47 ` Andy Shevchenko
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=20260903055924.E572F1F000E9@smtp.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