From: sashiko-bot@kernel.org
To: "Oleksij Rempel" <o.rempel@pengutronix.de>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org,
krzk+dt@kernel.org, linux-hwmon@vger.kernel.org
Subject: Re: [PATCH v12 4/6] pinctrl: add NXP MC33978/MC34978 pinctrl driver
Date: Fri, 15 May 2026 18:07:05 +0000 [thread overview]
Message-ID: <20260515180705.C32BAC2BCB0@smtp.kernel.org> (raw)
In-Reply-To: <20260515160537.115808-5-o.rempel@pengutronix.de>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] The `cached_bias` and `cached_drive` arrays independently cache the same physical hardware state (`MC33978_REG_CONFIG`), leading to conflicting state restoration when changing GPIO direction.
--
commit ae57c2734af81a36d2a256fc43f258b7210de10a
Author: David Jander <david@protonic.nl>
pinctrl: add NXP MC33978/MC34978 pinctrl driver
Add pin control and GPIO driver for the NXP MC33978/MC34978 Multiple Switch
Detection Interface (MSDI) devices. This driver translates physical switch
states to logical GPIO levels, emulates outputs via hardware tri-state,
and implements a hierarchical irq_chip for interrupt routing.
> diff --git a/drivers/pinctrl/pinctrl-mc33978.c b/drivers/pinctrl/pinctrl-mc33978.c
> index 0000000000000..2ee1b1284c87a
> --- /dev/null
> +++ b/drivers/pinctrl/pinctrl-mc33978.c
[ ... ]
> +struct mc33978_pinctrl {
[ ... ]
> + enum mc33978_bias_state cached_bias[MC33978_NGPIO];
> + enum mc33978_drive_mode cached_drive[MC33978_NGPIO];
> +};
Does the separation of cached_bias and cached_drive lead to conflicting
state restoration?
Both arrays appear to independently cache the same physical hardware state
(MC33978_REG_CONFIG) for SP pins:
[ ... ]
> +static int mc33978_set_drive(struct mc33978_pinctrl *mpc, unsigned int pin,
> + enum mc33978_drive_mode mode)
> +{
[ ... ]
> + ret = mc33978_update_bits(mpc, MC33978_REG_CONFIG, mask,
> + (mode == MC33978_OPEN_DRAIN) ? mask : 0);
> + if (!ret)
> + mpc->cached_drive[pin] = mode;
> +
> + return ret;
> +}
When mc33978_set_drive() updates MC33978_REG_CONFIG and cached_drive,
cached_bias is left stale.
[ ... ]
> +static int mc33978_set_pull(struct mc33978_pinctrl *mpc, unsigned int pin,
> + enum mc33978_bias_state val)
> +{
[ ... ]
> + /* Configure direction (Exclusively for SP pins) */
> + if (mc33978_is_sp(pin) && val != MC33978_TRISTATE) {
> + ret = mc33978_update_bits(mpc, MC33978_REG_CONFIG, mask,
> + (val == MC33978_PD) ? mask : 0);
> + if (ret)
> + return ret;
> + }
> +
> + /* Enable current source or set to tri-state */
> + ret = mc33978_update_bits(mpc, mc33978_spsg(MC33978_REG_TRI_SP, pin),
> + mask,
> + (val == MC33978_TRISTATE) ? mask : 0);
> + if (!ret)
> + mpc->cached_bias[pin] = val;
> +
> + return ret;
> +}
Similarly, when mc33978_set_pull() updates MC33978_REG_CONFIG and
cached_bias, cached_drive is left stale.
[ ... ]
> +static int mc33978_direction_input(struct gpio_chip *chip, unsigned int offset)
> +{
> + struct mc33978_pinctrl *mpc = gpiochip_get_data(chip);
> +
> + guard(mutex)(&mpc->lock);
[ ... ]
> + return mc33978_set_pull(mpc, offset, mpc->cached_bias[offset]);
> +}
If mc33978_direction_input() unconditionally restores cached_bias, could
this write back stale MC33978_REG_CONFIG data, clobbering a recently
configured output drive mode?
[ ... ]
> +static int mc33978_direction_output(struct gpio_chip *chip, unsigned int offset,
> + int value)
> +{
> + struct mc33978_pinctrl *mpc = gpiochip_get_data(chip);
> + u32 mask = BIT(offset);
> + u32 bits = value ? mask : 0;
> + int ret;
> +
> + guard(mutex)(&mpc->lock);
> +
> + ret = mc33978_set_drive(mpc, offset, mpc->cached_drive[offset]);
> + if (ret)
> + return ret;
> +
> + return mc33978_update_tri_state(mpc, mask, bits);
> +}
And likewise, could mc33978_direction_output() clobber the pinctrl bias
setting when it restores the potentially stale cached_drive?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260515160537.115808-1-o.rempel@pengutronix.de?part=4
next prev parent reply other threads:[~2026-05-15 18:07 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-15 16:05 [PATCH v12 0/6] mfd: Add support for NXP MC33978/MC34978 MSDI Oleksij Rempel
2026-05-15 16:05 ` [PATCH v12 1/6] dt-bindings: pinctrl: add " Oleksij Rempel
2026-05-15 16:05 ` [PATCH v12 2/6] mfd: add NXP MC33978/MC34978 core driver Oleksij Rempel
2026-05-15 16:48 ` sashiko-bot
2026-05-15 16:05 ` [PATCH v12 3/6] pinctrl: core: Make pin group callbacks optional for pin-only drivers Oleksij Rempel
2026-05-15 17:43 ` sashiko-bot
2026-05-16 8:06 ` Krzysztof Kozlowski
2026-05-15 16:05 ` [PATCH v12 4/6] pinctrl: add NXP MC33978/MC34978 pinctrl driver Oleksij Rempel
2026-05-15 18:07 ` sashiko-bot [this message]
2026-05-15 16:05 ` [PATCH v12 5/6] hwmon: add NXP MC33978/MC34978 driver Oleksij Rempel
2026-05-15 18:38 ` sashiko-bot
2026-05-16 8:06 ` Krzysztof Kozlowski
2026-05-15 16:05 ` [PATCH v12 6/6] mux: add NXP MC33978/MC34978 AMUX driver Oleksij Rempel
2026-05-15 19:07 ` sashiko-bot
2026-05-16 7:56 ` Krzysztof Kozlowski
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=20260515180705.C32BAC2BCB0@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=o.rempel@pengutronix.de \
--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 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.