Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ben Levinsky" <ben.levinsky@amd.com>
Cc: devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 4/4] remoteproc: amd_mbv_bram: Add RPMsg support
Date: Thu, 19 Nov 2026 22:19:09 +0000	[thread overview]
Message-ID: <sashiko-outbox-224128@kernel.org> (raw)
In-Reply-To: <20261119220405.2838553-5-ben.levinsky@amd.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] remoteproc: amd_mbv_bram: active mailboxes in
  amd_bram_rproc_stop() race
- [Medium] remoteproc: amd_mbv_bram: unmapped vdev0buffer added to
  coredump segments
- [Medium] remoteproc: amd_mbv_bram: leaked carveouts on
  amd_bram_rproc_prepare() error
- [Low] remoteproc: amd_mbv_bram: dev_err_probe() used outside probe in
  prepare path
--

commit 8f91a29d9a83c18ff06a14340aaa60590fc44b4c
Author: Ben Levinsky <ben.levinsky@amd.com>

remoteproc: amd_mbv_bram: Add RPMsg support

This commit adds optional RPMsg support to the AMD MicroBlaze/V BRAM
remoteproc driver using mailbox channels for virtqueue notifications and
reserved memory regions for vrings and buffers.

> diff --git a/drivers/remoteproc/amd_mbv_bram_rproc.c b/drivers/remoteproc/amd_mbv_bram_rproc.c
> index e4a103cf84558..0b54a6cc3e62b 100644
> --- a/drivers/remoteproc/amd_mbv_bram_rproc.c
> +++ b/drivers/remoteproc/amd_mbv_bram_rproc.c
[ ... ]
> @@ -31,13 +36,266 @@
[ ... ]
> +static int amd_bram_rproc_get_reserved_mem(struct amd_bram_rproc *priv, int i,
> +					   const char **name,
> +					   struct resource *res)
> +{
> +	struct device_node *np = priv->dev->of_node;
> +	int ret;
> +
> +	ret = of_property_read_string_index(np, "memory-region-names", i, name);
> +	if (ret)
> +		return dev_err_probe(priv->dev, ret,
> +				     "failed to read memory-region name %d\n", i);
> +
> +	ret = of_reserved_mem_region_to_resource(np, i, res);
> +	if (ret)
> +		return dev_err_probe(priv->dev, ret,
> +				     "failed to parse memory-region %d\n", i);
> +
> +	/* The remote uses the physical address as device address. */
> +	if (res->end > U32_MAX)
> +		return dev_err_probe(priv->dev, -EINVAL,
> +				     "memory-region %d %pR is above 4 GiB\n",
> +				     i, res);
> +
> +	return 0;
> +}

[Severity: Low]
Should amd_bram_rproc_get_reserved_mem() use dev_err() instead of
dev_err_probe()?  This helper is only called from amd_bram_rproc_prepare()
when booting the remote processor, never during probe.

[ ... ]

> +static int amd_bram_rproc_add_reserved_mem(struct rproc *rproc)
> +{
> +	struct amd_bram_rproc *priv = rproc->priv;
> +	struct rproc_mem_entry *mem;
> +	int count;
> +	int ret;
> +	int i;
> +
> +	count = amd_bram_rproc_reserved_mem_count(priv);
> +	if (count < 0)
> +		return count;
> +
> +	for (i = 0; i < count; i++) {
> +		struct resource res;
> +		const char *name;
> +
> +		ret = amd_bram_rproc_get_reserved_mem(priv, i, &name, &res);
> +		if (ret)
> +			return ret;
> +
> +		if (!strcmp(name, "vdev0buffer"))
> +			mem = rproc_of_resm_mem_entry_init(priv->dev, i,
> +							   resource_size(&res),
> +							   res.start, name);
> +		else
> +			mem = rproc_mem_entry_init(priv->dev, NULL,
> +						   (dma_addr_t)res.start,
> +						   resource_size(&res), res.start,
> +						   rproc_mem_entry_ioremap_wc,
> +						   rproc_mem_entry_iounmap,
> +						   "%s", name);
> +		if (!mem)
> +			return -ENOMEM;
> +
> +		rproc_add_carveout(rproc, mem);
> +		rproc_coredump_add_segment(rproc, res.start, resource_size(&res));

[Severity: Medium]
Should the vdev0buffer region be excluded from
rproc_coredump_add_segment()?

rproc_of_resm_mem_entry_init() leaves mem->va and mem->alloc NULL because
vdev0buffer is attached to the child virtio device as a DMA pool rather
than mapped as a carveout.  During coredump collection, rproc_copy_segment()
calls rproc_da_to_va(), which skips carveouts with a NULL va, logs an
invalid copy request error, and fills the vdev0buffer segment in the dump
with 0xff.

> +		dev_dbg(priv->dev, "reserved memory carveout %pR\n", &res);
> +	}
> +
> +	return 0;
> +}
> +
>  static int amd_bram_rproc_prepare(struct rproc *rproc)
>  {
[ ... ]
> @@ -68,6 +326,10 @@ static int amd_bram_rproc_prepare(struct rproc *rproc)
>  		return ret;
>  	}
>  
> +	ret = amd_bram_rproc_check_reserved_mem(priv);
> +	if (ret)
> +		return ret;
> +
>  	mem = rproc_mem_entry_init(priv->dev, NULL, (dma_addr_t)res.start,
>  				   resource_size(&res), da,
>  				   rproc_mem_entry_ioremap_wc,
> @@ -79,7 +341,7 @@ static int amd_bram_rproc_prepare(struct rproc *rproc)
>  	rproc_add_carveout(rproc, mem);
>  	rproc_coredump_add_segment(rproc, da, resource_size(&res));
>  
> -	return 0;
> +	return amd_bram_rproc_add_reserved_mem(rproc);
>  }

[Severity: Medium]
Does an allocation failure in amd_bram_rproc_add_reserved_mem() leave the
already-added carveouts and coredump segments on rproc->carveouts and
rproc->dump_segments?

When rproc_prepare_device() fails in rproc_fw_boot(), it jumps to
disable_iommu without calling rproc_resource_cleanup().  Any entries linked
before the failure remain on the lists, causing duplicate carveouts and
dump segments on subsequent boot attempts or leaking them if the device is
unbound while offline.  Also, the return value of
rproc_coredump_add_segment() is not checked here or in
amd_bram_rproc_add_reserved_mem().

> @@ -116,6 +378,9 @@ static int amd_bram_rproc_stop(struct rproc *rproc)
>  		dev_err(priv->dev, "failed to assert reset: %d\n", ret);
>  		return ret;
>  	}
> +	cancel_work_sync(&priv->rx_work);
> +	bitmap_zero(priv->pending_notify_ids,
> +		    ARRAY_SIZE(priv->notify_msgs));

[Severity: High]
Can a late mailbox RX interrupt race with amd_bram_rproc_stop() while
priv->rx_chan and priv->tx_chan stay active across stop?

CPU0                              CPU1
amd_bram_rproc_stop()
  gpiod_set_value_cansleep(..., 1)
  cancel_work_sync(&priv->rx_work)
                                  amd_pl_mbox_irq_thread()
                                    amd_bram_rproc_rx_callback()
                                      set_bit(..., pending_notify_ids)
  bitmap_zero(pending_notify_ids)
                                      schedule_work(&priv->rx_work)
rproc_resource_cleanup()
  rproc_free_vring()
                                  amd_bram_rproc_rx_work()
                                    rproc_vq_interrupt()  <-- races teardown

Because the mailbox channels are requested at probe time and only shut
down on device unbind, RX interrupts remain enabled and any word already in
the hardware RX FIFO when reset is asserted can still trigger
amd_bram_rproc_rx_callback().  On the TX side, if the remote processor stops
before draining a kick word from the hardware FIFO, the channel's active
request never completes, leaving the mailbox core hrtimer polling while
the processor is offline and delivering a stale notification on the next
boot.  Requesting the mailbox channels in .start() and freeing them in
.stop() would synchronously disable the RX IRQ and reset both hardware
FIFOs.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261119220405.2838553-1-ben.levinsky@amd.com?part=4

      reply	other threads:[~2026-11-19 22:19 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 22:04 [PATCH v3 0/4] Add AMD PL Mailbox and RPMsg support for the AMD BRAM remoteproc Ben Levinsky
2026-11-19 22:04 ` [PATCH v3 1/4] dt-bindings: mailbox: Add AMD PL Mailbox IP Ben Levinsky
2026-11-19 22:04 ` [PATCH v3 2/4] mailbox: Add AMD PL Mailbox soft IP controller Ben Levinsky
2026-11-19 22:18   ` sashiko-bot
2026-11-19 22:04 ` [PATCH v3 3/4] dt-bindings: remoteproc: Add RPMsg resources to AMD BRAM rproc Ben Levinsky
2026-11-19 22:04 ` [PATCH v3 4/4] remoteproc: amd_mbv_bram: Add RPMsg support Ben Levinsky
2026-11-19 22:19   ` sashiko-bot [this message]

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-224128@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=ben.levinsky@amd.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