From: Wolfram Sang <wsa+renesas@sang-engineering.com>
To: linux-renesas-soc@vger.kernel.org,
Roman Gushchin <roman.gushchin@linux.dev>
Cc: linux-kernel@vger.kernel.org,
Jassi Brar <jassisinghbrar@gmail.com>,
Kuninori Morimoto <kuninori.morimoto.gx@renesas.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>
Subject: Sashiko review feedback (was Re: [PATCH 2/3] soc: renesas: Add Renesas R-Car MFIS driver)
Date: Sun, 22 Mar 2026 09:59:05 +0100 [thread overview]
Message-ID: <ab-vWbjdlAIt1qaX@ninjato> (raw)
In-Reply-To: <20260317130638.2804-3-wsa+renesas@sang-engineering.com>
[-- Attachment #1: Type: text/plain, Size: 5267 bytes --]
Hi all,
I am usually not into AI but I can definitely see value in its review
assistance. So, I checked what Sashiko thinks of my series and found the
comments to be largely reasonable. I'll copy and answer them here, a)
for a more complete review process and b) to give feedback to the
Sashiko-devs (CCed). Thank you for the service and efforts, I hope we
can justify the additional energy consumption here. Please let me know
if such replies are actually helpful for you.
> > +static void mfis_write(struct mfis_reg *mreg, u32 reg, u32 val)
> > +{
> > + struct mfis_priv *priv = mreg->priv;
> > + u32 unprotect_mask = priv->info->unprotect_mask;
> > + u32 unprotect_code;
> > +
> > + /*
> > + * [Gen4] key: 0xACCE0000, mask: 0x0000FFFF
> > + * [Gen5] key: 0xACC00000, mask: 0x000FFFFF
> > + */
> > + unprotect_code = (MFIS_UNPROTECT_KEY & ~unprotect_mask) |
> > + ((mreg->start | reg) & unprotect_mask);
>
> The mreg->start and reg variables are combined with a bitwise OR. If
> mreg->start has overlapping bits with the reg offset, could this yield an
> incorrect physical address for the unprotect code? Should this use
> addition like mreg->start + reg instead?
No, if a device tree is so wrongly setup that the bits overlap, then '+'
instead of '|' will only lead to a different wrong address.
> > +
> > + iowrite32(unprotect_code, priv->common_reg.base + MFISWACNTR);
> > + iowrite32(val, mreg->base + reg);
> > +}
> Can mfis_write() be called concurrently by different processors or
> interrupted by an interrupt handler like mfis_mb_iicr_interrupt()?
Yes, it can. It even needs a hwspinlock instead of a regular spinlock
because it needs protection against cores which may not run Linux.
hwspinlock support will only be added later because of dependency
issues. My plan was to add the protection once we got hwspinlocks. But
maybe I should add just spinlocks now and convert them to hwspinlocks
once their support is in.
> > +static void mfis_mb_shutdown(struct mbox_chan *chan)
> > +{
> > + struct mfis_per_chan_priv *per_chan_priv = chan->con_priv;
> > +
> > + free_irq(per_chan_priv->irq, chan);
> > +}
> Since mfis_mb_of_xlate() skips interrupt lookup for transmit-only channels,
> leaving per_chan_priv->irq as 0, and mfis_mb_startup() guards the request
> with if (per_chan_priv->irq), will this unconditional free_irq() trigger a
> kernel warning when shutting down a transmit-only channel?
Yes, I seemed to remember that free_irq() can handle this, but it will
in-deed trigger a warning. Also, the reasons Geert mentioned in his
review apply.
> [ ... ]
> > +static struct mbox_chan *mfis_mb_of_xlate(struct mbox_controller *mbox,
> > + const struct of_phandle_args *sp)
> > +{
> > + struct mfis_priv *priv = mfis_mb_mbox_to_priv(mbox);
> > + struct mfis_per_chan_priv *per_chan_priv;
> > + struct mbox_chan *chan;
> > + u32 chan_num, chan_flags;
> > + bool tx_uses_eicr, is_only_rx;
> > +
> > + if (sp->args_count != 2)
> > + return ERR_PTR(-EINVAL);
> > +
> > + chan_num = sp->args[0];
> > + chan_flags = sp->args[1];
> > +
> > + /* Channel layout is described in mfis_mb_probe() */
> > + if (priv->info->mb_channels_are_unidir) {
> > + is_only_rx = chan_flags & MFIS_CHANNEL_RX;
> > + chan = mbox->chans + 2 * chan_num + is_only_rx;
> Does this code allow out-of-bounds access if a malformed device tree
> provides an arbitrarily large chan_num? Should chan_num be checked against
> priv->info->mb_num_channels before computing the chan pointer?
Yes, Geert pointed this out as well.
> [ ... ]
> > +static int mfis_mb_probe(struct mfis_priv *priv)
> > +{
> [ ... ]
> > + mbox->chans = chan;
> > + mbox->num_chans = num_chan;
> > + mbox->txdone_poll = true;
> > + mbox->ops = &mfis_iicr_ops;
> > + mbox->dev = dev;
> > + mbox->of_xlate = mfis_mb_of_xlate;
> > +
> > + return mbox_controller_register(mbox);
> > +}
> The mailbox controller is registered using mbox_controller_register(), but
> the driver lacks a remove callback to unregister it.
> If the driver is unbound, devres will free the devm_kzalloc structures
> backing the mailbox. Will this result in a use-after-free regression since
> the mailbox subsystem still retains the controller in its global lists?
> Should devm_mbox_controller_register() be used instead?
> [ ... ]
Yes, this was overlooked so far.
> > +static int mfis_probe(struct platform_device *pdev)
> > +{
> > + struct mfis_priv *priv;
> > + struct device *dev = &pdev->dev;
> > + int ret;
> > +
> > + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL);
> > + if (!priv)
> > + return -ENOMEM;
> > +
> > + priv->dev = dev;
> > + priv->info = of_device_get_match_data(dev);
> Can of_device_get_match_data() return a null pointer here?
> If the driver is bound manually via sysfs or instantiated in an environment
> lacking device tree match data, would this lead to a null pointer
> dereference regression later when accessing priv->info->mb_num_channels in
> mfis_mb_probe()?
The latter case would be clearly a driver bug. In addition with the
former case, it probably makes sense to handle this more gracefully,
though.
Happy hacking,
Wolfram
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2026-03-22 8:59 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-17 13:06 [PATCH 0/3] soc: renesas: add MFIS driver Wolfram Sang
2026-03-17 13:06 ` [PATCH 1/3] dt-bindings: soc: renesas: add MFIS binding documentation Wolfram Sang
2026-03-18 9:17 ` Krzysztof Kozlowski
2026-03-18 9:19 ` Krzysztof Kozlowski
2026-03-19 8:54 ` Geert Uytterhoeven
2026-03-19 8:58 ` Krzysztof Kozlowski
2026-03-19 9:15 ` Wolfram Sang
2026-03-18 9:17 ` Krzysztof Kozlowski
2026-03-19 8:58 ` Geert Uytterhoeven
2026-03-17 13:06 ` [PATCH 2/3] soc: renesas: Add Renesas R-Car MFIS driver Wolfram Sang
2026-03-19 12:58 ` Geert Uytterhoeven
2026-03-22 19:58 ` Wolfram Sang
2026-03-23 8:12 ` Geert Uytterhoeven
2026-03-23 9:29 ` Wolfram Sang
2026-03-23 10:06 ` Geert Uytterhoeven
2026-03-22 8:59 ` Wolfram Sang [this message]
2026-03-23 10:02 ` Sashiko review feedback (was Re: [PATCH 2/3] soc: renesas: Add Renesas R-Car MFIS driver) Geert Uytterhoeven
2026-03-23 10:58 ` Wolfram Sang
2026-03-24 2:21 ` Roman Gushchin
2026-03-24 6:18 ` Wolfram Sang
2026-03-24 14:54 ` Roman Gushchin
2026-03-17 13:06 ` [PATCH 3/3] soc: renesas: add X5H PRR support Wolfram Sang
2026-03-19 9:04 ` Geert Uytterhoeven
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=ab-vWbjdlAIt1qaX@ninjato \
--to=wsa+renesas@sang-engineering.com \
--cc=geert+renesas@glider.be \
--cc=jassisinghbrar@gmail.com \
--cc=kuninori.morimoto.gx@renesas.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=magnus.damm@gmail.com \
--cc=roman.gushchin@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