From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=185.56.87.9 ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass; t=1795020605; b=He0hGwGobjssIMbbzttHeWswrXbk1oPrSJyA0qz0vZQaupTd0STC54hZN3jWswKHdhJf NLnu03cnn9xbhaaFFWJTI4lulDAzLczhH9EsOJPXkG6FnshY4o7jCXm/LfcjD8LXFsddp nQ6CJD1RSpv6kOPKQorsQ/SLtAGkjlPF67aw1AI2V+II3YNGOvql19uVPfVixG8w4Vzvg IW4IzDw/nGbLPZClVVeNBf2G97088JAn8Yewg4T2emP4C+/lBMkCo/HVtAIhtK38qiO8d Idv4N6+qX7gE9I6K+Zy0rPou1PVLWllWO6LqOvUEz2Gye1oTMBrFqG9x3XuAIM4eWsQ== ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1795020605; h=DMARC-Filter:DKIM-Signature:Received:DKIM-Signature:Received:Date: From:To:Cc:Subject:Message-ID:References:MIME-Version:Content-Type: Content-Disposition:In-Reply-To:X-AntiAbuse:X-AntiAbuse:X-AntiAbuse: X-AntiAbuse:X-AntiAbuse:X-Source:X-Source-Args:X-Source-Dir: X-SGantispam-id:X-AntiAbuse:AntiSpam-DLS:AntiSpam-DLSP:AntiSpam-DLSRS: AntiSpam-TS:CFBL-Address:CFBL-Feedback-ID; bh=2uPA2P1zslLeIVOa70XvA0evtGpxjtPjWoywnGVn/F4=; b=Kf1fzHP1aZhlWVVXNZo+yTIzbQltRI/JA51gdPqV/oSoMeoYXH4+VUDe+Trhalv3z1w3 2Wd7UsDQOz6iefNerD2PsF95CjgXC/5RxGJNJ8V9kABH94LSpBRHP1G4vsLoRz01f5/hU Pks4N3Os68eL+b9KgzhdSJGUoRQiTfYwbyio2+sZ9EIDMSUDCb/b6S8FLh2gRvWW9r4PH t7Hr1CrdPXYyFHPCzbZSAvUled/N2qcgjFcZ8/4GkpS5aQCdYLTDi36RaAckzoEfehuQI l2kGhPF1omch0lWaDknQaJHcon+POnGy0BIB2dDZV8W90dssa1GihzcRjm+rvzCKNrQ== ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass header.from=valla.it; spf=pass smtp.mailfrom=valla.it; dkim=pass header.d=antispam.mailspamprotection.com header.i=@antispam.mailspamprotection.com header.a=rsa-sha256 header.s=default header.b=dglV3O6g; dkim=pass header.d=valla.it header.i=@valla.it header.a=rsa-sha256 header.s=default header.b=gM18Xna2; arc=pass header.oldest-pass=0 smtp.remote-ip=185.56.87.9 Received: from delivery.antispam.mailspamprotection.com (delivery.antispam.mailspamprotection.com [185.56.87.9]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2208A606A325 for ; Wed, 18 Nov 2026 16:50:04 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 2208A606A325 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=valla.it Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=valla.it Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=antispam.mailspamprotection.com header.i=@antispam.mailspamprotection.com header.a=rsa-sha256 header.s=default header.b=dglV3O6g; dkim=pass (1024-bit key, unprotected) header.d=valla.it header.i=@valla.it header.a=rsa-sha256 header.s=default header.b=gM18Xna2 ARC-Seal: i=1; cv=none; a=rsa-sha256; d=outgoing.instance-europe-west4-4zq2.prod.antispam.mailspamprotection.com; s=arckey; t=1795020604; b=ZFX+lPm1/axBhqLkWrpm3YPp558vab1h7ktffOPH9QX6ZZfArqTt4YjU4IftRcfv6xm/sO6OAY /q/A6sKvJpIl/WwgiVJ3LMsBVaDqu3491eKKMKPWcH7MufSNxWI4T1rkr6SxEmIygJg+UouPEA O6kfvP2eov1ZESj7C7SbaKyOHpS9aA9eKAnsf8Qk7jyV27Fik2QPFfsrqXBY/Ojt3jEtk5gG0d H7TTu2C1hHKApSX/WEzwPbDpu4VLheHXul+1r3627oavBoWPs1GAShG0NhyD1n5rBPcEtbfVmr BlS/9GlEl7Rgf3GQEPw5TzBqeFn3yigaw0q0F2/ik5ea1Q==; ARC-Authentication-Results: i=1; outgoing.instance-europe-west4-4zq2.prod.antispam.mailspamprotection.com; smtp.remote-ip=35.214.173.214; iprev=pass (214.173.214.35.bc.googleusercontent.com) smtp.remote-ip=35.214.173.214; auth=pass (LOGIN) smtp.auth=esm19.siteground.biz; dkim=pass header.d=valla.it header.s=default header.a=rsa-sha256; arc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed; d=outgoing.instance-europe-west4-4zq2.prod.antispam.mailspamprotection.com; s=arckey; t=1795020604; bh=Gb4r+Pw57CuiAbJfXKIlWAJvWJKiFvHYFDez1//PX1I=; h=In-Reply-To:Content-Type:MIME-Version:References:Message-ID:Subject:Cc:To: From:Date:DKIM-Signature:DKIM-Signature; b=OEtabkO2VDPINA6Z7HBh7TqV/7MHdiwjo0dYpQxhwuChEjl00/4P8qy648q6B8yhXT0LH2k6iu XfRQ37q4QoYIF8HzYAo723ZYXjZVZY7jvZd3FstrZEXJpi4MSubAIbR1TSKL6OfNKrgU16orTJ ih/6EYfSNZJhA3AadpV89NQNPtdDTVkvhpuevq9Pn2HM6ihZeSnvB5Xux2PPsjTF9X41vqRvOw EivAAf6oUyBfxSIaNJ1hnbqTYspakABcKK5sKFQq+qbNcTndpxjlWX+9P+W7j7z/GJZNjr6B8r 9SszSgdttky2+kM87Wx5VbHOV42wDeotIxzZmTuS1o9dtQ==; DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=antispam.mailspamprotection.com; s=default; h=CFBL-Feedback-ID:CFBL-Address :Content-Type:MIME-Version:Message-ID:Subject:Cc:To:From:Date:Reply-To: List-Unsubscribe:Content-Transfer-Encoding; bh=2uPA2P1zslLeIVOa70XvA0evtGpxjtPjWoywnGVn/F4=; b=dglV3O6g0BPJ4S56E2ezeQpu5L LBphRqBRm6rNS7JmJyx+HNip6QNykM4da2pf6dtyBLiyRb+qLgOExGQIEs/F6ZPDgjPTltEgmmnOd x48XMedMfAV5kJvUftA/JmSiBUGTKvoJVP6rmC7fGV5b2kBZ+STdUTqoi8rbewDxwCQo=; Received: from 214.173.214.35.bc.googleusercontent.com ([35.214.173.214] helo=esm19.siteground.biz) by instance-europe-west4-4zq2.prod.antispam.mailspamprotection.com with esmtpsa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xTir6-00000000PmR-4AFv for imx@lists.linux.dev; Wed, 18 Nov 2026 16:49:57 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=valla.it; s=default; h=Subject:Cc:To:From:Date:list-help:list-unsubscribe: list-subscribe:list-post:list-owner:list-archive; bh=2uPA2P1zslLeIVOa70XvA0evtGpxjtPjWoywnGVn/F4=; b=gM18Xna2Uj2X83uizi6araxZZH m1rLkElSQywAMzKEJY0UxFTrnhQwBA9uwbY7Y0a3UNP5X5A2qxh+SAXJ5Fy27LcYbtEaDuWLz2ZiG 0PZbwjarxKKRy1k/kOedspw7PVkh0uQ2FgEUyhq5dyXPj4UVu3xR5zbeDJRz+739G91g=; Received: from [95.251.96.187] (port=60573 helo=bywater) by esm19.siteground.biz with essmtpa (TLS1.3) tls TLS_AES_256_GCM_SHA384 (Exim 4.100.1) (envelope-from ) id 1xTiqk-00000000MNz-2g4b; Wed, 18 Nov 2026 16:49:34 +0000 Date: Wed, 18 Nov 2026 17:49:32 +0100 From: Francesco Valla To: Mathieu Poirier Cc: Bjorn Andersson , Kees Cook , "Gustavo A. R. Silva" , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , Shuah Khan , Randy Dunlap , Frank Li , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam , Peng Fan , Robin Murphy , 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 07/11] remoteproc: assign fwnode during vdev registration Message-ID: References: <20261102-remoteproc_virtio_map-v2-0-26b300e01c62@valla.it> <20261102-remoteproc_virtio_map-v2-7-26b300e01c62@valla.it> X-Mailing-List: imx@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - esm19.siteground.biz X-AntiAbuse: Original Domain - lists.linux.dev X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - valla.it X-Source: X-Source-Args: X-Source-Dir: X-SGantispam-id: f94ff4954434a7eca121c8fd053e871b X-AntiAbuse: ID - f94ff4954434a7eca121c8fd053e871b AntiSpam-DLS: false AntiSpam-DLSP: AntiSpam-DLSRS: AntiSpam-TS: 1.0 CFBL-Address: feedback@antispam.mailspamprotection.com; report=arf CFBL-Feedback-ID: 1xTir6-00000000PmR-4AFv-feedback@antispam.mailspamprotection.com Authentication-Results: outgoing.instance-europe-west4-4zq2.prod.antispam.mailspamprotection.com; iprev=pass (214.173.214.35.bc.googleusercontent.com) smtp.remote-ip=35.214.173.214; auth=pass (LOGIN) smtp.auth=esm19.siteground.biz; dkim=pass header.d=valla.it header.s=default header.a=rsa-sha256; arc=none On Wed, Nov 18, 2026 at 09:54:49AM -0600, Mathieu Poirier wrote: > On Tue, Nov 17, 2026 at 11:29:01PM +0100, Francesco Valla wrote: > > On Tue, Nov 17, 2026 at 10:28:38AM -0600, Mathieu Poirier wrote: > > > On Mon, Nov 02, 2026 at 12:26:44AM +0100, Francesco Valla wrote: > > > > The virtio subsystem already supports a fwnode describing a vdev; search > > > > for a specific node during vdev registration and supply it to the > > > > rproc-virtio platform device that is being registered. > > > > > > > > A memory-region specified inside that node is also used for the virtio > > > > device if a carveout was not supplied for it through the parent device's > > > > node. > > > > > > > > Signed-off-by: Francesco Valla > > > > --- > > > > drivers/remoteproc/remoteproc_core.c | 48 +++++++++++++++++++++++++++++++--- > > > > drivers/remoteproc/remoteproc_virtio.c | 41 +++++++++++++++++++++++++++++ > > > > 2 files changed, 85 insertions(+), 4 deletions(-) > > > > > > > > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c > > > > index c946ecd980a5..e833853ae7f6 100644 > > > > --- a/drivers/remoteproc/remoteproc_core.c > > > > +++ b/drivers/remoteproc/remoteproc_core.c > > > > @@ -440,6 +440,33 @@ void rproc_remove_rvdev(struct rproc_vdev *rvdev) > > > > if (rvdev) > > > > list_del(&rvdev->node); > > > > } > > > > + > > > > +static struct fwnode_handle *rproc_get_vdev_fwnode(struct device *dev, u32 idx) > > > > +{ > > > > + struct fwnode_handle *group, *child; > > > > + u32 reg; > > > > + int ret; > > > > + > > > > + group = device_get_named_child_node(dev, "virtio"); > > > > + if (!fwnode_device_is_available(group)) { > > > > + fwnode_handle_put(group); > > > > + return NULL; > > > > + } > > > > + > > > > + fwnode_for_each_available_child_node(group, child) { > > > > + ret = fwnode_property_read_u32(child, "reg", ®); > > > > + if (ret) > > > > + continue; > > > > + > > > > + if (idx == reg) > > > > + break; > > > > + } > > > > + > > > > + fwnode_handle_put(group); > > > > + > > > > + return child; > > > > +} > > > > + > > > > /** > > > > * rproc_handle_vdev() - handle a vdev fw resource > > > > * @rproc: the remote processor > > > > @@ -475,7 +502,16 @@ static int rproc_handle_vdev(struct rproc *rproc, void *ptr, > > > > struct device *dev = &rproc->dev; > > > > size_t rsc_size; > > > > struct rproc_vdev_data rvdev_data; > > > > + struct platform_device_info pdev_info = { > > > > + .parent = dev, > > > > + .name = "rproc-virtio", > > > > + .id = PLATFORM_DEVID_AUTO, > > > > + .data = &rvdev_data, > > > > + .size_data = sizeof(rvdev_data), > > > > + }; > > > > struct platform_device *pdev; > > > > + struct fwnode_handle *fwnode; > > > > + int ret = 0; > > > > > > > > /* make sure resource isn't truncated */ > > > > rsc_size = struct_size(rsc, vring, rsc->num_of_vrings); > > > > @@ -498,20 +534,24 @@ static int rproc_handle_vdev(struct rproc *rproc, void *ptr, > > > > rvdev_data.rsc_offset = offset; > > > > rvdev_data.rsc = rsc; > > > > > > > > + fwnode = rproc_get_vdev_fwnode(dev->parent, rvdev_data.index); > > > > + pdev_info.fwnode = fwnode; > > > > + > > > > /* > > > > * When there is more than one remote processor, rproc->nb_vdev number is > > > > * same for each separate instances of "rproc". If rvdev_data.index is used > > > > * as device id, then we get duplication in sysfs, so need to use > > > > * PLATFORM_DEVID_AUTO to auto select device id. > > > > */ > > > > - pdev = platform_device_register_data(dev, "rproc-virtio", PLATFORM_DEVID_AUTO, &rvdev_data, > > > > - sizeof(rvdev_data)); > > > > + pdev = platform_device_register_full(&pdev_info); > > > > if (IS_ERR(pdev)) { > > > > dev_err(dev, "failed to create rproc-virtio device\n"); > > > > - return PTR_ERR(pdev); > > > > + ret = PTR_ERR(pdev); > > > > } > > > > > > > > - return 0; > > > > + fwnode_handle_put(fwnode); > > > > + > > > > + return ret; > > > > } > > > > > > > > /** > > > > diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c > > > > index 1496659ddff9..950d65480be5 100644 > > > > --- a/drivers/remoteproc/remoteproc_virtio.c > > > > +++ b/drivers/remoteproc/remoteproc_virtio.c > > > > @@ -13,10 +13,12 @@ > > > > #include > > > > #include > > > > #include > > > > +#include > > > > #include > > > > #include > > > > #include > > > > #include > > > > +#include > > > > #include > > > > #include > > > > #include > > > > @@ -394,6 +396,23 @@ static void rproc_virtio_dev_release(struct device *dev) > > > > put_device(&rvdev->pdev->dev); > > > > } > > > > > > > > +/* > > > > + * Attach the memory region declared inside the vdev's own devicetree node. > > > > + * > > > > + * A restricted-dma-pool region is attached by of_dma_configure() when the > > > > + * platform device is probed, but it is released together with the virtio > > > > + * device (see rproc_virtio_dev_release()); attach it again if needed, e.g. > > > > + * when the remote processor is restarted during a crash recovery. > > > > + * Any other kind of region (e.g., shared-dma-pool) is attached only here. > > > > + */ > > > > +static int rproc_virtio_init_vdev_mem(struct device *dev) > > > > +{ > > > > + if (is_swiotlb_for_alloc(dev)) > > > > + return 0; > > > > + > > > > + return of_reserved_mem_device_init_by_idx(dev, dev->of_node, 0); > > > > +} > > > > + > > > > /** > > > > * rproc_add_virtio_dev() - register an rproc-induced virtio device > > > > * @rvdev: the remote vdev > > > > @@ -410,6 +429,7 @@ static int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) > > > > struct device *dev = &rvdev->pdev->dev; > > > > struct virtio_device *vdev; > > > > struct rproc_mem_entry *mem; > > > > + bool has_mem_region; > > > > int ret; > > > > > > > > if (rproc->ops->kick == NULL) { > > > > @@ -417,11 +437,24 @@ static int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) > > > > return -EINVAL; > > > > } > > > > > > > > + has_mem_region = of_property_present(dev->of_node, "memory-region"); > > > > + > > > > /* Try to find dedicated vdev buffer carveout */ > > > > mem = rproc_find_carveout_by_name(rproc, "vdev%dbuffer", rvdev->index); > > > > if (mem) { > > > > phys_addr_t pa; > > > > > > > > + if (has_mem_region) { > > > > + /* > > > > + * The carveout takes precedence: drop the region that > > > > + * of_dma_configure() might have attached at probe time. > > > > > > I don't understand this part - why would someone configure vdevXbuffer with the > > > same name at the rproc and rproc-virtio level? This should be an error. > > > > > > > The carveout might come from the remote processor's resource table. I > > was unsure on how to treat it (warning or error) - if you advise for > > the second I'll go that route. > > > > Ok, so this is also related to my for patch [5/11], i.e handling of authentic > rproc-virtio device should follow modern practices. > Ok. > > > > + */ > > > > + dev_warn(dev, > > > > + "vdev%dbuffer carveout found, ignoring memory-region\n", > > > > + rvdev->index); > > > > + of_reserved_mem_device_release(dev); > > > > > > Who would have called of_reserved_mem_device_init_by_XYZ()? The remoteproc core > > > or virtio core? > > > > > The of_dma_configure() call that is part of the platform DMA > > configuration automatically associates to the device the first > > restricted-dma-pool node referenced by memory-region; see [1]. > > > > This is actually beneficial to the proposed solution, but current > > implementation requires this step to avoid leaking the association (this > > will be required also in case of error, because of_dma_configure() is > > called during the probe). > > > > Ok > > > > > + } > > > > + > > > > if (mem->of_resm_idx != -1) { > > > > struct device_node *np = rproc->dev.parent->of_node; > > > > > > > > @@ -451,6 +484,14 @@ static int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) > > > > return ret; > > > > } > > > > } > > > > + } else if (has_mem_region) { > > > > + /* Use the memory region declared in the vdev's own node */ > > > > + ret = rproc_virtio_init_vdev_mem(dev); > > > > + if (ret) { > > > > + dev_err(dev, "Can't associate vdev memory-region: %d\n", > > > > + ret); > > > > + return ret; > > > > + } > > > > > > Mixing the initialisation of the legacy rproc-virtio and authentic rproc-virtio > > > devices is very confusing. I think there is value in splitting them, even if it > > > entails some code duplication. > > > > > > > Ok, I'll split them for V3. > > > > Please move forward on that. Since it will introduce a fair amount of churn, I > will simply stop reviewing the current set and wait for V3. You can remove the > "RFC" tag, we are well past that now. > Ok. That will take some days, though. Thank you for the review you did so far! Regards, Francesco