Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: Francesco Valla <francesco@valla.it>
To: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Bjorn Andersson <andersson@kernel.org>,
	Kees Cook <kees@kernel.org>,
	 "Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Rob Herring <robh@kernel.org>,
	 Krzysztof Kozlowski <krzk+dt@kernel.org>,
	Conor Dooley <conor+dt@kernel.org>,
	 Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	 Randy Dunlap <rdunlap@infradead.org>,
	Frank Li <Frank.Li@nxp.com>,
	 Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	 Fabio Estevam <festevam@gmail.com>, Peng Fan <peng.fan@nxp.com>,
	Robin Murphy <robin.murphy@arm.com>,
	 linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hardening@vger.kernel.org,  devicetree@vger.kernel.org,
	linux-doc@vger.kernel.org, imx@lists.linux.dev,
	 linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH RFC v2 08/11] Documentation: remoteproc: expand virtio support section
Date: Tue, 17 Nov 2026 23:40:14 +0100	[thread overview]
Message-ID: <avzVSG5rvoN0Z9OF@bywater> (raw)
In-Reply-To: <avyPa5rSx9rhf9yO@p14s>

On Tue, Nov 17, 2026 at 11:31:23AM -0600, Mathieu Poirier wrote:
> On Mon, Nov 02, 2026 at 12:26:45AM +0100, Francesco Valla wrote:
> > Expand the section on virtio support over remoteproc with details on
> > memory allocation setup and constraints.
> > 
> > Signed-off-by: Francesco Valla <francesco@valla.it>
> > ---
> >  Documentation/staging/remoteproc.rst | 99 +++++++++++++++++++++++++++++++++++-
> >  1 file changed, 98 insertions(+), 1 deletion(-)
> > 
> > diff --git a/Documentation/staging/remoteproc.rst b/Documentation/staging/remoteproc.rst
> > index c117b060e76c..4b42ed582fb4 100644
> > --- a/Documentation/staging/remoteproc.rst
> > +++ b/Documentation/staging/remoteproc.rst
> > @@ -354,7 +354,104 @@ it supports. A firmware may support any number of virtio devices, and
> >  of any type (a single remote processor can also easily support several
> >  rpmsg virtio devices this way, if desired).
> >  
> > +Memory carveouts
> > +----------------
> > +
> > +For a virtio device at position ``X`` among the RSC_VDEV resources declared by
> > +the resource table, the remoteproc framework will search for memory carveouts
> > +for:
> > +
> > +* all the vrings the specific virtio device requires (as ``vdevXvringY``);
> > +* the memory area to allocate communication buffers from (as ``vdevXbuffer``).
> > +
> > +The carveouts can be provided by the remote processor itself as RSC_CARVEOUT
> > +resources inside the resource table and/or supplied by the remoteproc driver
> > +and will be indexed by their name.
> 
> The remoteproce driver doesn't supply carvouts, it gets them from the device
> tree.
>

Right. I'll rephrase this statement.

> > +If a carveout with the same name is provided through both means, the one
> > +supplied by the remote processor should be marked as dynamically allocable,
> > +i.e., with the device address set to ``FW_RSC_ADDR_ANY`` (-1).
> > +
> 
> Right, as per my comment in the previous patch, carveouts at the virtio level
> should be distinct from those declared at the remote processor level.  Hopefully
> this will keep the remoteproc core simple and make it easy to differentiate
> between code paths that handle legacy and authentic rproc-virtio devices.
>

This statement is not related to carveout at virtio level - or at least
isn't in my mind, I'll try to explain a bit better.

Nowadays, even before this patch set, is possible to declare a carveout
(say: vdev0buffer) both inside the processor's resource table *and* in
devicetree. The remoteproc framework will take care to associate them,
but this will work only if the resource table uses FW_RSC_ADDR_ANY for
the da field (see [1]).

> > +If a ``vdevXvringY`` carveout is not provided, the remoteproc framework will
> > +try to allocate it using dma_alloc_coherent(), which will resort to allocate it
> > +either from the first ``restricted-dma-pool`` region associated to the virtio
> > +device's parent (i.e., the remote processor device), if present, or the global
> > +DMA pool.
> > +
> > +.. WARNING::
> > +
> > +    This fallback mechanism can result in a vring being allocated using a
> > +    ``vdevXbuffer`` area meant for another vdev, so a particular care shall be
> > +    adopted when defining the carveouts. In particular, ``restricted-dma-pool``
> > +    memory regions should be specified inside the virtio device's devicetree
> > +    nodes and not attached to the parent remote processor.
> > +
> > +If a ``vdevXbuffer`` carveout is not provided, the remoteproc framework will
> > +use the memory region declared by the virtio device's own devicetree node (see
> > +Documentation/devicetree/bindings/remoteproc/remoteproc-virtio.yaml), if any.
> > +Otherwise, it will try to replace it with the first memory region (of any type)
> > +associated to the virtio device's parent (i.e., the remote processor device);
> > +if no such memory region is present, it will be replaced with the global DMA
> > +pool.
> > +
> > +If both a ``vdevXbuffer`` carveout and a memory region inside the virtio
> > +device's devicetree node are present, the carveout takes precedence and the
> > +memory region is ignored.
> > +
> > +Declaring the memory region inside the virtio device's devicetree node is the
> > +preferred method for ``restricted-dma-pool`` regions, since listing them among
> > +the memory regions of the remote processor device would make the first of them
> > +the (forced) bounce buffer for the remote processor device itself as well.
> > +
> > +Buffer allocation
> > +-----------------
> > +
> > +There are different kinds of buffer allocation scenarios:
> > +
> > +* if the remote processor can access the whole DMA memory area of the host, no
> > +  special arrangement needs to be performed, since either the drivers (in case
> > +  of rpmsg and rproc-serial devices) or the DMA APIs (in case of any other
> > +  virtio device type) will take care of any necessary translation;
> > +* if the remote processor has limited access to the host memory space, for
> > +  example because of a different addressing scheme or for memory isolation
> > +  constraints, the memory reserved for buffer allocation shall be selected
> > +  depending on the virtio device type:
> > +
> > +  - for rpmsg and rproc-serial devices, a simple contiguous memory region
> > +    (e.g.: one declared in devicetree as ``shared-dma-pool``) is sufficient and
> > +    should be preferred, since it allows zero-copy message transmission between
> > +    the host and the remote processor;
> > +  - for any other virtio device type, a swiotlb-enabled memory region (e.g.:
> > +    one declared in devicetree as ``restricted-dma-pool``) is required, because
> > +    such devices need bounce buffering to work correctly.
> > +
> > +For virtio devices other than rpmsg and rproc-serial, the remoteproc framework
> > +offers the ``VIRTIO_F_ACCESS_PLATFORM`` feature, so the buffer addresses written
> > +in the vring descriptors are the DMA addresses returned by the DMA APIs for the
> > +virtio device. The virtio device inherits the DMA mask and the DMA range map
> > +(i.e., the translation described by the ``dma-ranges`` devicetree property) of
> > +the remote processor device, and is never attached to an IOMMU: these DMA
> > +addresses are therefore host physical addresses, translated only through the
> > +DMA range map. The remote processor must be able to access the buffers at
> > +these addresses.
> > +
> > +.. WARNING::
> > +
> > +    For remote processors that access memory through an IOMMU managed by the
> > +    remoteproc framework (i.e., with ``has_iommu`` set), the IOMMU domain only
> > +    contains the mappings created for the RSC_CARVEOUT and RSC_DEVMEM entries
> > +    of the resource table, at the device addresses they specify; no mapping is
> > +    created for the buffers of the virtio devices. Such remote processors are
> > +    supported only if all the memory that can hold virtio buffers (e.g., the
> > +    ``restricted-dma-pool`` region associated to the virtio device) is mapped
> > +    with its device address equal to its physical address, for example through
> > +    an RSC_DEVMEM entry. The same constraint applies to any fixed address
> > +    translation applied by the remote processor that is not described by the
> > +    DMA range map of the remote processor device.
> > +
> > +Allocation of virtio devices
> > +----------------------------
> > +
> >  Of course, RSC_VDEV resource entries are only good enough for static
> >  allocation of virtio devices. Dynamic allocations will also be made possible
> >  using the rpmsg bus (similar to how we already do dynamic allocations of
> > -rpmsg channels; read more about it in rpmsg.txt).
> > +rpmsg channels; read more about it in Documentation/staging/rpmsg.rst).
> > 
> > -- 
> > 2.56.0
> > 
>

Thank you!

Regards,
Francesco

[1] https://elixir.bootlin.com/linux/v7.4-rc1/source/drivers/remoteproc/remoteproc_core.c#L856


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

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-01 23:26 [PATCH RFC v2 00/11] remoteproc: add support for any virtio device Francesco Valla
2026-11-01 23:26 ` [PATCH RFC v2 01/11] remoteproc: virtio: cleanup rproc_add_virtio_dev error path Francesco Valla
2026-11-01 23:26 ` [PATCH RFC v2 02/11] remoteproc: virtio: replace commas with semicolons Francesco Valla
2026-11-01 23:26 ` [PATCH RFC v2 03/11] remoteproc: virtio: support dynamic number of vrings Francesco Valla
2026-11-01 23:26 ` [PATCH RFC v2 04/11] remoteproc: report VIRTIO_F_VERSION_1 for non-rproc-specific vdevs Francesco Valla
2026-11-10 15:46   ` Mathieu Poirier
2026-11-10 16:58     ` Francesco Valla
2026-11-01 23:26 ` [PATCH RFC v2 05/11] remoteproc: virtio: report VIRTIO_F_ACCESS_PLATFORM when required Francesco Valla
2026-11-16 17:16   ` Mathieu Poirier
2026-11-17 22:18     ` Francesco Valla
2026-11-01 23:26 ` [PATCH RFC v2 06/11] dt-bindings: remoteproc: add remoteproc-virtio Francesco Valla
2026-11-01 23:26 ` [PATCH RFC v2 07/11] remoteproc: assign fwnode during vdev registration Francesco Valla
2026-11-02  0:02   ` sashiko-bot
2026-11-17 16:28   ` Mathieu Poirier
2026-11-17 22:29     ` Francesco Valla
2026-11-01 23:26 ` [PATCH RFC v2 08/11] Documentation: remoteproc: expand virtio support section Francesco Valla
2026-11-17 17:31   ` Mathieu Poirier
2026-11-17 22:40     ` Francesco Valla [this message]
2026-11-01 23:26 ` [PATCH RFC v2 09/11] remoteproc: imx_rproc: always use non-blocking mailboxes Francesco Valla
2026-11-02  0:03   ` sashiko-bot
2026-11-01 23:26 ` [PATCH RFC v2 10/11] dt-bindings: remoteproc: imx-rproc: support virtio Francesco Valla
2026-11-01 23:26 ` [PATCH RFC v2 11/11] PoC: arm64: dts: imx93-11x11-frdm: add multiple vdevs Francesco Valla
2026-11-02  0:16   ` sashiko-bot

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=avzVSG5rvoN0Z9OF@bywater \
    --to=francesco@valla.it \
    --cc=Frank.Li@nxp.com \
    --cc=andersson@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --cc=gustavoars@kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=kees@kernel.org \
    --cc=kernel@pengutronix.de \
    --cc=krzk+dt@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=mathieu.poirier@linaro.org \
    --cc=peng.fan@nxp.com \
    --cc=rdunlap@infradead.org \
    --cc=robh@kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=s.hauer@pengutronix.de \
    --cc=skhan@linuxfoundation.org \
    /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