From: sashiko-bot@kernel.org
To: "Ali Rouhi" <arouhi@sitime.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH net-next v12 03/12] dpll: add basic SiTime SiT9531x support
Date: Sat, 10 Oct 2026 18:32:07 +0000 [thread overview]
Message-ID: <sashiko-outbox-166805@kernel.org> (raw)
In-Reply-To: <20261009183151.78497-4-arouhi@sitime.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] dpll: sit9531x: race condition in regmap cache invalidation on I2C failure
--
commit 1fc3c6add951f10b8266bc8b2d155767ac703b33
Author: Oleg Zadorozhnyi <Oleg.Zadorozhnyi@devoxsoftware.com>
dpll: add basic SiTime SiT9531x support
This commit adds basic I2C support for the SiTime SiT9531x clock generator
family. It introduces paged regmap configuration, register access helpers,
and device probe functionality.
> diff --git a/drivers/dpll/sit9531x/core.c b/drivers/dpll/sit9531x/core.c
> new file mode 100644
> index 0000000000000..c7c14442df922
> --- /dev/null
> +++ b/drivers/dpll/sit9531x/core.c
[ ... ]
> +int sit9531x_read_u8(struct sit9531x_dev *sitdev, unsigned int reg,
> + u8 *val)
> +{
> + unsigned int vreg, tmp;
> + int rc;
> +
> + vreg = (SIT9531X_REG_PAGE(reg) * SIT9531X_PAGE_SIZE) +
> + SIT9531X_REG_OFFSET(reg) + SIT9531X_RANGE_OFFSET;
> +
> + rc = regmap_read(sitdev->regmap, vreg, &tmp);
> + if (rc) {
> + sit9531x_page_cache_drop(sitdev);
[Severity: Medium]
Could this create a race window during the cache invalidation?
The internal regmap lock is dropped after regmap_read returns. If an I2C
transfer fails, there is an unprotected race window between regmap dropping
its lock and regcache_drop_region re-acquiring it inside
sit9531x_page_cache_drop.
A concurrent thread could initiate another regmap access in this window,
observe the stale cached page selector, incorrectly assume the hardware is
on the requested page, and perform an I2C transfer. Since the failed
transfer may have left the hardware on a different page, the concurrent
access could hit the wrong registers.
Should the driver serialize the regmap access and the error-path cache
invalidation within a single lock (such as sitdev->multiop_lock) to ensure
the cache is invalidated atomically?
> + dev_err(sitdev->dev,
> + "Failed to read page 0x%02x reg 0x%02x: %d\n",
> + SIT9531X_REG_PAGE(reg), SIT9531X_REG_OFFSET(reg), rc);
> + } else {
> + *val = (u8)tmp;
> + }
> +
> + return rc;
> +}
> +
> +/*
> + * sit9531x_write_u8 - write an 8-bit register
> + * @reg: register in SIT9531X_REG(page, offset) form
> + * @val: value to write
> + */
> +int sit9531x_write_u8(struct sit9531x_dev *sitdev, unsigned int reg,
> + u8 val)
> +{
> + unsigned int vreg;
> + int rc;
> +
> + vreg = (SIT9531X_REG_PAGE(reg) * SIT9531X_PAGE_SIZE) +
> + SIT9531X_REG_OFFSET(reg) + SIT9531X_RANGE_OFFSET;
> +
> + rc = regmap_write(sitdev->regmap, vreg, val);
> + if (rc) {
> + sit9531x_page_cache_drop(sitdev);
[Severity: Medium]
Does this have the same race window where the internal regmap lock is
dropped after regmap_write returns, before the cache is invalidated?
> + dev_err(sitdev->dev,
> + "Failed to write page 0x%02x reg 0x%02x: %d\n",
> + SIT9531X_REG_PAGE(reg), SIT9531X_REG_OFFSET(reg), rc);
> + }
> +
> + return rc;
> +}
[ ... ]
> +int sit9531x_update_pll_u8(struct sit9531x_dev *sitdev, u8 pll_idx,
> + u8 offset, u8 mask, u8 val)
> +{
> + u8 page = sit9531x_pll_page(pll_idx);
> + unsigned int vreg;
> + int rc;
> +
> + vreg = (page * SIT9531X_PAGE_SIZE) + offset + SIT9531X_RANGE_OFFSET;
> +
> + /*
> + * A read-modify-write is a read and a write, and either can leave
> + * the cached page selector wrong, so fail the way the single
> + * accessors do.
> + */
> + rc = regmap_update_bits(sitdev->regmap, vreg, mask, val);
> + if (rc) {
> + sit9531x_page_cache_drop(sitdev);
[Severity: Medium]
Does this also expose the same race window when regmap_update_bits releases
its lock before the cache invalidation can happen?
> + dev_err(sitdev->dev,
> + "Failed to update page 0x%02x reg 0x%02x: %d\n",
> + page, offset, rc);
> + }
> +
> + return rc;
> +}
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261009183151.78497-1-arouhi@sitime.com?part=3
next prev parent reply other threads:[~2026-10-10 18:32 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-09 18:31 [PATCH net-next v12 00/12] dpll: add SiTime SiT9531x DPLL clock driver Ali Rouhi
2026-10-09 18:31 ` [PATCH net-next v12 01/12] dt-bindings: vendor-prefixes: add SiTime Corporation Ali Rouhi
2026-10-09 18:31 ` [PATCH net-next v12 02/12] dt-bindings: dpll: add SiTime SiT95316 clock generator Ali Rouhi
2026-10-09 18:31 ` [PATCH net-next v12 03/12] dpll: add basic SiTime SiT9531x support Ali Rouhi
2026-10-10 18:32 ` sashiko-bot [this message]
2026-10-09 18:31 ` [PATCH net-next v12 05/12] dpll: sit9531x: register DPLL devices and pins Ali Rouhi
2026-10-10 18:32 ` sashiko-bot
2026-10-09 18:31 ` [PATCH net-next v12 04/12] dpll: sit9531x: read DPLL types and pin properties from system firmware Ali Rouhi
2026-10-09 18:31 ` [PATCH net-next v12 06/12] dpll: sit9531x: implement input pin state on a DPLL Ali Rouhi
2026-10-09 18:31 ` [PATCH net-next v12 08/12] dpll: sit9531x: add support to get and set frequency on pins Ali Rouhi
2026-10-10 18:32 ` sashiko-bot
2026-10-09 18:31 ` [PATCH net-next v12 07/12] dpll: sit9531x: add support to get and set priority on input pins Ali Rouhi
2026-10-09 18:31 ` [PATCH net-next v12 09/12] dpll: sit9531x: implement output pin state on a DPLL Ali Rouhi
2026-10-09 18:31 ` [PATCH net-next v12 10/12] dpll: sit9531x: add support to adjust output phase Ali Rouhi
2026-10-09 18:31 ` [PATCH net-next v12 11/12] dpll: sit9531x: add support to get phase offset on the connected input pin Ali Rouhi
2026-10-09 18:32 ` [PATCH net-next v12 12/12] dpll: sit9531x: model the inter-PLL sync net as a pair of pins Ali Rouhi
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-166805@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=arouhi@sitime.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=robh@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