From patchwork Thu Apr 16 16:13:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493453 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42A716CA for ; Thu, 16 Apr 2020 16:16:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2A74D20857 for ; Thu, 16 Apr 2020 16:16:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="QdU4LEVN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2410746AbgDPQQG (ORCPT ); Thu, 16 Apr 2020 12:16:06 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:47085 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2438465AbgDPQOQ (ORCPT ); Thu, 16 Apr 2020 12:14:16 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGCFLB010378; Thu, 16 Apr 2020 18:14:08 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=fjXKxPxzbyDDVi3DEAO1z1G4S222u7YWRmiegBuibKg=; b=QdU4LEVNSHbgtgFd4+R31NIe94HOR2k7qZEywHTvP0MEe2gFAcjHDT+It1wbyfsz8b9T Phk1HEJ7+5mB/UQhYZJJQB56Rh7ZYg4vdYfW9fE1WVufUZDgZ39+a083xmR1rTuCTw8f OVY78E4JkPQ/UA9PNJyCALj4G8KN9akaBge0GTwRd5CKIZcW2AFkctmpspwtXGnkaag+ YUbd5O1uATKGyWc9FURS2JJzEVXMuLVqNpXkyEkbfby2Afa2yrdEJ7mtqGaPL/NOCiuu FWbhwEp02EolXqQcWVBBouqec9F3XmEAS1fcQPANBgObzw46yxfYirJ1XbHT3V1EJENf Gw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn94kmux-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:08 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C141E100034; Thu, 16 Apr 2020 18:14:07 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B278F2B2D2A; Thu, 16 Apr 2020 18:14:07 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:07 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 01/18] remoteproc: Store resource table address in rvdev Date: Thu, 16 Apr 2020 18:13:14 +0200 Message-ID: <20200416161331.7606-2-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG1NODE1.st.com (10.75.127.1) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Store the resource table address in rvdev struct to be able to retrieve it from vdev device. This patch prepares the migration of rdev management in rproc_virtio. Indeed remoteproc virtio will have to complete the vdev and vrings resource table structures. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 1 + include/linux/remoteproc.h | 2 ++ 2 files changed, 3 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 097f33e4f1f3..2a0425ab82a7 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -504,6 +504,7 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, kref_init(&rvdev->refcount); + rvdev->rsc = rsc; rvdev->id = rsc->id; rvdev->rproc = rproc; rvdev->index = rproc->nb_vdev++; diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 16ad66683ad0..a78e28bda962 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -567,6 +567,7 @@ struct rproc_vring { * @rproc: the rproc handle * @vdev: the virio device * @vring: the vrings for this vdev + * @rsc: address of the resource table * @rsc_offset: offset of the vdev's resource entry * @index: vdev position versus other vdev declared in resource table */ @@ -580,6 +581,7 @@ struct rproc_vdev { struct list_head node; struct rproc *rproc; struct rproc_vring vring[RVDEV_NUM_VRINGS]; + struct fw_rsc_vdev *rsc; u32 rsc_offset; u32 index; }; From patchwork Thu Apr 16 16:13:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493391 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 358F6112C for ; Thu, 16 Apr 2020 16:14:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DF4A92078B for ; Thu, 16 Apr 2020 16:14:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="wymU8dLC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2503501AbgDPQOQ (ORCPT ); Thu, 16 Apr 2020 12:14:16 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:13624 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2388004AbgDPQON (ORCPT ); Thu, 16 Apr 2020 12:14:13 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGDXZ7026476; Thu, 16 Apr 2020 18:14:09 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=Cwjql6eiDaqwrFTsuNZJ1xtw/Hxa6DOpsF+k+xk4lPI=; b=wymU8dLCKivMPa2f4wr9o+F3jfZOuZGwt3XBEB49bakagWRP6/DY5v4nmbD6IcE350xz 2Y/oB+k4wulbye3TzvfHdtRsxtefARQhAeoRrW32rGq3d60318fF+tJ56LSSG8hM4s8t goIcUil5iIz2cwLccsCnUEsKghdWCJMjTdJBYni+IVk8ea7EiH0wuKbC8RUulpYmNf9l fwb97Wjz43656k/irklATGPOnjTdUivNiu6ePdDOA8Bj2OR4khR01oI4BkEnDMme3KQw Tl4Y4FZh9CWxj3i436F56fdqV6Bpebvx3wcmeS0nTBY2CV/aIdO1tl3CHwdUTIpZxk3M UA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn8s3kky-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:09 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 1382B10002A; Thu, 16 Apr 2020 18:14:09 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 082A42B2D2A; Thu, 16 Apr 2020 18:14:09 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:08 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 02/18] remoteproc: Introduce virtio device add/remove functions in core. Date: Thu, 16 Apr 2020 18:13:15 +0200 Message-ID: <20200416161331.7606-3-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG7NODE3.st.com (10.75.127.21) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org In preparation of the migration of the management of rvdev in rproc_virtio, this patch spins off new functions to manage the virtio device. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 149 +++++++++++++++------------ 1 file changed, 83 insertions(+), 66 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 2a0425ab82a7..5c90d569c0f7 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -441,6 +441,86 @@ static void rproc_rvdev_release(struct device *dev) kfree(rvdev); } +static int rproc_rvdev_add_device(struct rproc_vdev *rvdev) +{ + struct rproc *rproc = rvdev->rproc; + struct fw_rsc_vdev *rsc = rvdev->rsc; + char name[16]; + int ret, i; + + /* Initialise vdev subdevice */ + snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index); + rvdev->dev.parent = &rproc->dev; + rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset; + rvdev->dev.release = rproc_rvdev_release; + dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev->dev.parent), name); + dev_set_drvdata(&rvdev->dev, rvdev); + + ret = device_register(&rvdev->dev); + if (ret) { + put_device(&rvdev->dev); + return ret; + } + /* Make device dma capable by inheriting from parent's capabilities */ + set_dma_ops(&rvdev->dev, get_dma_ops(rproc->dev.parent)); + + ret = dma_coerce_mask_and_coherent(&rvdev->dev, + dma_get_mask(rproc->dev.parent)); + if (ret) { + dev_warn(&rvdev->dev, + "Failed to set DMA mask %llx. Trying to continue... %x\n", + dma_get_mask(rproc->dev.parent), ret); + } + + /* parse the vrings */ + for (i = 0; i < rsc->num_of_vrings; i++) { + ret = rproc_parse_vring(rvdev, rsc, i); + if (ret) + goto free_rvdev; + } + + /* allocate the vring resources */ + for (i = 0; i < rsc->num_of_vrings; i++) { + ret = rproc_alloc_vring(rvdev, i); + if (ret) + goto free_vg; + } + + rvdev->subdev.start = rproc_vdev_do_start; + rvdev->subdev.stop = rproc_vdev_do_stop; + + rproc_add_subdev(rproc, &rvdev->subdev); + + return 0; + +free_vg: + for (i--; i >= 0; i--) { + struct rproc_vring *rvring = &rvdev->vring[i]; + + rproc_free_vring(rvring); + } + +free_rvdev: + device_unregister(&rvdev->dev); + + return ret; +} + +static void rproc_rvdev_remove_device(struct rproc_vdev *rvdev) +{ + struct rproc *rproc = rvdev->rproc; + struct rproc_vring *rvring; + int id; + + for (id = 0; id < ARRAY_SIZE(rvdev->vring); id++) { + rvring = &rvdev->vring[id]; + rproc_free_vring(rvring); + } + + rproc_remove_subdev(rproc, &rvdev->subdev); + device_unregister(&rvdev->dev); +} + /** * rproc_handle_vdev() - handle a vdev fw resource * @rproc: the remote processor @@ -473,8 +553,6 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, { struct device *dev = &rproc->dev; struct rproc_vdev *rvdev; - int i, ret; - char name[16]; /* make sure resource isn't truncated */ if (struct_size(rsc, vring, rsc->num_of_vrings) + rsc->config_len > @@ -505,83 +583,22 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, kref_init(&rvdev->refcount); rvdev->rsc = rsc; + rvdev->rsc_offset = offset; rvdev->id = rsc->id; rvdev->rproc = rproc; rvdev->index = rproc->nb_vdev++; - /* Initialise vdev subdevice */ - snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index); - rvdev->dev.parent = rproc->dev.parent; - rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset; - rvdev->dev.release = rproc_rvdev_release; - dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev->dev.parent), name); - dev_set_drvdata(&rvdev->dev, rvdev); - - ret = device_register(&rvdev->dev); - if (ret) { - put_device(&rvdev->dev); - return ret; - } - /* Make device dma capable by inheriting from parent's capabilities */ - set_dma_ops(&rvdev->dev, get_dma_ops(rproc->dev.parent)); - - ret = dma_coerce_mask_and_coherent(&rvdev->dev, - dma_get_mask(rproc->dev.parent)); - if (ret) { - dev_warn(dev, - "Failed to set DMA mask %llx. Trying to continue... %x\n", - dma_get_mask(rproc->dev.parent), ret); - } - - /* parse the vrings */ - for (i = 0; i < rsc->num_of_vrings; i++) { - ret = rproc_parse_vring(rvdev, rsc, i); - if (ret) - goto free_rvdev; - } - - /* remember the resource offset*/ - rvdev->rsc_offset = offset; - - /* allocate the vring resources */ - for (i = 0; i < rsc->num_of_vrings; i++) { - ret = rproc_alloc_vring(rvdev, i); - if (ret) - goto unwind_vring_allocations; - } - list_add_tail(&rvdev->node, &rproc->rvdevs); - rvdev->subdev.start = rproc_vdev_do_start; - rvdev->subdev.stop = rproc_vdev_do_stop; - - rproc_add_subdev(rproc, &rvdev->subdev); - - return 0; - -unwind_vring_allocations: - for (i--; i >= 0; i--) - rproc_free_vring(&rvdev->vring[i]); -free_rvdev: - device_unregister(&rvdev->dev); - return ret; + return rproc_rvdev_add_device(rvdev); } void rproc_vdev_release(struct kref *ref) { struct rproc_vdev *rvdev = container_of(ref, struct rproc_vdev, refcount); - struct rproc_vring *rvring; - struct rproc *rproc = rvdev->rproc; - int id; - - for (id = 0; id < ARRAY_SIZE(rvdev->vring); id++) { - rvring = &rvdev->vring[id]; - rproc_free_vring(rvring); - } - rproc_remove_subdev(rproc, &rvdev->subdev); + rproc_rvdev_remove_device(rvdev); list_del(&rvdev->node); - device_unregister(&rvdev->dev); } /** From patchwork Thu Apr 16 16:13:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493443 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2EB041392 for ; Thu, 16 Apr 2020 16:15:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 110302223E for ; Thu, 16 Apr 2020 16:15:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="KFEsE8s2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2896302AbgDPQPo (ORCPT ); Thu, 16 Apr 2020 12:15:44 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:45094 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2502401AbgDPQOR (ORCPT ); Thu, 16 Apr 2020 12:14:17 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGBreO014920; Thu, 16 Apr 2020 18:14:11 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=bdtZ9VkkZnE7BFSpijC37IudgmgIFBFdoZiHyG6aWFM=; b=KFEsE8s2S2ImiaFSGT4tvu4+SMNF7VV24sGayZIkb0hF/onbbNqsvb9Cc/Bs481ZH+yh NuHsycQXkfXg0M3pq+2XCPKJR639YMepgVcafeQx5nFRtbvS/nQ/aoYHIDixjtUw+0NO KQlYZC+C/qf5ghliJoV9soAdoTCgnnysZopGkMJMhix2eXMtHG9IOIq+3Bf8D15BkEBp EQ9UrWIlCznCCLUGyiAzMvdDyhF7mZy3GoRNWzFgHYMKET+8PA5kp7afTi6eUa5+xZkR g/z3Lxhzuy4nfeoBQ4g2erqlEWuTZsbWzs8qIQ3iQvl0W51Hhqwcg8XSN0bEuWeLZkuo Zw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn75umcf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:11 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 8F01A10002A; Thu, 16 Apr 2020 18:14:10 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 7F7712B2D2A; Thu, 16 Apr 2020 18:14:10 +0200 (CEST) Received: from localhost (10.75.127.44) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:09 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 03/18] remoteproc: Move rvdev management in rproc_virtio Date: Thu, 16 Apr 2020 18:13:16 +0200 Message-ID: <20200416161331.7606-4-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG7NODE3.st.com (10.75.127.21) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Migrate the management of the rvdev device and subdev from core to virtio, to prepare the rpmsg virtio platform device creation. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 118 +------------------- drivers/remoteproc/remoteproc_internal.h | 5 +- drivers/remoteproc/remoteproc_virtio.c | 136 +++++++++++++++++++++-- 3 files changed, 131 insertions(+), 128 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 5c90d569c0f7..4fcd685cbfd8 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -371,8 +371,7 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) return 0; } -static int -rproc_parse_vring(struct rproc_vdev *rvdev, struct fw_rsc_vdev *rsc, int i) +int rproc_parse_vring(struct rproc_vdev *rvdev, struct fw_rsc_vdev *rsc, int i) { struct rproc *rproc = rvdev->rproc; struct device *dev = &rproc->dev; @@ -410,117 +409,6 @@ void rproc_free_vring(struct rproc_vring *rvring) rsc->vring[idx].notifyid = -1; } -static int rproc_vdev_do_start(struct rproc_subdev *subdev) -{ - struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, subdev); - - return rproc_add_virtio_dev(rvdev, rvdev->id); -} - -static void rproc_vdev_do_stop(struct rproc_subdev *subdev, bool crashed) -{ - struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, subdev); - int ret; - - ret = device_for_each_child(&rvdev->dev, NULL, rproc_remove_virtio_dev); - if (ret) - dev_warn(&rvdev->dev, "can't remove vdev child device: %d\n", ret); -} - -/** - * rproc_rvdev_release() - release the existence of a rvdev - * - * @dev: the subdevice's dev - */ -static void rproc_rvdev_release(struct device *dev) -{ - struct rproc_vdev *rvdev = container_of(dev, struct rproc_vdev, dev); - - of_reserved_mem_device_release(dev); - - kfree(rvdev); -} - -static int rproc_rvdev_add_device(struct rproc_vdev *rvdev) -{ - struct rproc *rproc = rvdev->rproc; - struct fw_rsc_vdev *rsc = rvdev->rsc; - char name[16]; - int ret, i; - - /* Initialise vdev subdevice */ - snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index); - rvdev->dev.parent = &rproc->dev; - rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset; - rvdev->dev.release = rproc_rvdev_release; - dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev->dev.parent), name); - dev_set_drvdata(&rvdev->dev, rvdev); - - ret = device_register(&rvdev->dev); - if (ret) { - put_device(&rvdev->dev); - return ret; - } - /* Make device dma capable by inheriting from parent's capabilities */ - set_dma_ops(&rvdev->dev, get_dma_ops(rproc->dev.parent)); - - ret = dma_coerce_mask_and_coherent(&rvdev->dev, - dma_get_mask(rproc->dev.parent)); - if (ret) { - dev_warn(&rvdev->dev, - "Failed to set DMA mask %llx. Trying to continue... %x\n", - dma_get_mask(rproc->dev.parent), ret); - } - - /* parse the vrings */ - for (i = 0; i < rsc->num_of_vrings; i++) { - ret = rproc_parse_vring(rvdev, rsc, i); - if (ret) - goto free_rvdev; - } - - /* allocate the vring resources */ - for (i = 0; i < rsc->num_of_vrings; i++) { - ret = rproc_alloc_vring(rvdev, i); - if (ret) - goto free_vg; - } - - rvdev->subdev.start = rproc_vdev_do_start; - rvdev->subdev.stop = rproc_vdev_do_stop; - - rproc_add_subdev(rproc, &rvdev->subdev); - - return 0; - -free_vg: - for (i--; i >= 0; i--) { - struct rproc_vring *rvring = &rvdev->vring[i]; - - rproc_free_vring(rvring); - } - -free_rvdev: - device_unregister(&rvdev->dev); - - return ret; -} - -static void rproc_rvdev_remove_device(struct rproc_vdev *rvdev) -{ - struct rproc *rproc = rvdev->rproc; - struct rproc_vring *rvring; - int id; - - for (id = 0; id < ARRAY_SIZE(rvdev->vring); id++) { - rvring = &rvdev->vring[id]; - rproc_free_vring(rvring); - } - - rproc_remove_subdev(rproc, &rvdev->subdev); - device_unregister(&rvdev->dev); -} - /** * rproc_handle_vdev() - handle a vdev fw resource * @rproc: the remote processor @@ -590,14 +478,14 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, list_add_tail(&rvdev->node, &rproc->rvdevs); - return rproc_rvdev_add_device(rvdev); + return rproc_virtio_device_add(rvdev); } void rproc_vdev_release(struct kref *ref) { struct rproc_vdev *rvdev = container_of(ref, struct rproc_vdev, refcount); - rproc_rvdev_remove_device(rvdev); + rproc_virtio_device_remove(rvdev); list_del(&rvdev->node); } diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 493ef9262411..fad95f1a50c1 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -30,8 +30,8 @@ irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); void rproc_vdev_release(struct kref *ref); /* from remoteproc_virtio.c */ -int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id); -int rproc_remove_virtio_dev(struct device *dev, void *data); +int rproc_virtio_device_add(struct rproc_vdev *rvdev); +void rproc_virtio_device_remove(struct rproc_vdev *rvdev); /* from remoteproc_debugfs.c */ void rproc_remove_trace_file(struct dentry *tfile); @@ -47,6 +47,7 @@ extern struct class rproc_class; int rproc_init_sysfs(void); void rproc_exit_sysfs(void); +int rproc_parse_vring(struct rproc_vdev *rvdev, struct fw_rsc_vdev *rsc, int i); void rproc_free_vring(struct rproc_vring *rvring); int rproc_alloc_vring(struct rproc_vdev *rvdev, int i); diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index 8c07cb2ca8ba..0f7efac7d4f3 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -296,6 +296,20 @@ static const struct virtio_config_ops rproc_virtio_config_ops = { .set = rproc_virtio_set, }; +/** + * rproc_rvdev_release() - release the existence of a rvdev + * + * @dev: the subdevice's dev + */ +static void rproc_virtio_rvdev_release(struct device *dev) +{ + struct rproc_vdev *rvdev = container_of(dev, struct rproc_vdev, dev); + + of_reserved_mem_device_release(dev); + + kfree(rvdev); +} + /* * This function is called whenever vdev is released, and is responsible * to decrement the remote processor's refcount which was taken when vdev was @@ -318,16 +332,18 @@ static void rproc_virtio_dev_release(struct device *dev) } /** - * rproc_add_virtio_dev() - register an rproc-induced virtio device - * @rvdev: the remote vdev + * rproc_vdev_start() - register an rproc-induced virtio device + * @subdev: the rproc virtio subdevice * * This function registers a virtio device. This vdev's partent is * the rproc device. * * Returns 0 on success or an appropriate error value otherwise. */ -int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) +static int rproc_vitio_start(struct rproc_subdev *subdev) { + struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, + subdev); struct rproc *rproc = rvdev->rproc; struct device *dev = &rvdev->dev; struct virtio_device *vdev; @@ -376,7 +392,7 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) ret = -ENOMEM; goto out; } - vdev->id.device = id, + vdev->id.device = rvdev->id, vdev->config = &rproc_virtio_config_ops, vdev->dev.parent = dev; vdev->dev.release = rproc_virtio_dev_release; @@ -401,23 +417,121 @@ int rproc_add_virtio_dev(struct rproc_vdev *rvdev, int id) goto out; } - dev_info(dev, "registered %s (type %d)\n", dev_name(&vdev->dev), id); + dev_info(dev, "registered %s (type %d)\n", dev_name(&vdev->dev), + rvdev->id); out: return ret; } +static int rproc_remove_virtio_dev(struct device *dev, void *data) +{ + struct virtio_device *vdev = dev_to_virtio(dev); + struct rproc_vdev *rvdev = vdev_to_rvdev(vdev); + struct rproc_vring *rvring; + int id; + + unregister_virtio_device(vdev); + + for (id = 0; id < ARRAY_SIZE(rvdev->vring); id++) { + rvring = &rvdev->vring[id]; + rproc_free_vring(rvring); + } + + return 0; +} /** * rproc_remove_virtio_dev() - remove an rproc-induced virtio device - * @dev: the virtio device - * @data: must be null + * @subdev: the rproc virtio subdevice + * @crashed: indicate if the stop is the result of a crash * - * This function unregisters an existing virtio device. + * This function unregisters existing virtio devices. */ -int rproc_remove_virtio_dev(struct device *dev, void *data) +static void rproc_vitio_stop(struct rproc_subdev *subdev, bool crashed) { - struct virtio_device *vdev = dev_to_virtio(dev); + struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, + subdev); + int ret; + + ret = device_for_each_child(&rvdev->dev, NULL, rproc_remove_virtio_dev); + if (ret) + dev_warn(&rvdev->dev, "can't remove vdev child device: %d\n", + ret); +} + +static const struct rproc_subdev rproc_virtio_subdev = { + .start = rproc_vitio_start, + .stop = rproc_vitio_stop +}; + +int rproc_virtio_device_add(struct rproc_vdev *rvdev) +{ + struct rproc *rproc = rvdev->rproc; + struct fw_rsc_vdev *rsc = rvdev->rsc; + char name[16]; + int ret, i; + + /* Initialise vdev subdevice */ + snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index); + rvdev->dev.parent = &rproc->dev; + rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset; + rvdev->dev.release = rproc_virtio_rvdev_release; + dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev->dev.parent), name); + dev_set_drvdata(&rvdev->dev, rvdev); + + ret = device_register(&rvdev->dev); + if (ret) { + put_device(&rvdev->dev); + return ret; + } + /* Make device dma capable by inheriting from parent's capabilities */ + set_dma_ops(&rvdev->dev, get_dma_ops(rproc->dev.parent)); + + ret = dma_coerce_mask_and_coherent(&rvdev->dev, + dma_get_mask(rproc->dev.parent)); + if (ret) { + dev_warn(&rvdev->dev, + "Failed to set DMA mask %llx. Trying to continue... %x\n", + dma_get_mask(rproc->dev.parent), ret); + } + + /* parse the vrings */ + for (i = 0; i < rsc->num_of_vrings; i++) { + ret = rproc_parse_vring(rvdev, rsc, i); + if (ret) + goto free_rvdev; + } + + /* allocate the vring resources */ + for (i = 0; i < rsc->num_of_vrings; i++) { + ret = rproc_alloc_vring(rvdev, i); + if (ret) + goto free_vg; + } + + rvdev->subdev = rproc_virtio_subdev; + + rproc_add_subdev(rproc, &rvdev->subdev); - unregister_virtio_device(vdev); return 0; + +free_vg: + for (i--; i >= 0; i--) { + struct rproc_vring *rvring = &rvdev->vring[i]; + + rproc_free_vring(rvring); + } + +free_rvdev: + device_unregister(&rvdev->dev); + + return ret; +} + +void rproc_virtio_device_remove(struct rproc_vdev *rvdev) +{ + struct rproc *rproc = rvdev->rproc; + + rproc_remove_subdev(rproc, &rvdev->subdev); + device_unregister(&rvdev->dev); } From patchwork Thu Apr 16 16:13:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493447 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 182B16CA for ; Thu, 16 Apr 2020 16:16:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F2FE220857 for ; Thu, 16 Apr 2020 16:15:59 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="S5BoDHi7" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1414576AbgDPQPo (ORCPT ); Thu, 16 Apr 2020 12:15:44 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:4048 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2410725AbgDPQOQ (ORCPT ); Thu, 16 Apr 2020 12:14:16 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGDXZ9026476; Thu, 16 Apr 2020 18:14:12 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=KXRIrH9Ae0pX/k70Vo3qC2ZlR604P+0OK1B0a7N8Gos=; b=S5BoDHi7XiofvM6AZHQ0HGIgOEuixNf2v4oh9upneAfUoeFvzUulh1c15J+1ON3QS7/e K77ud9wrpRUtOauhZZqYIXVCwTIHEg46jKUsBrdazCY0B+wvutPL3nsyfRZuigiLlHIp YNzp2q/iY5jC0rc4dn8Se9Pq/OqHTUcghhjWjjUGFTgYCHlH/W4mtNRWhZ1jVH/1jBpT OYdMIa6qrp7NLRdEZaOExZz8NGgvk8LpC/4H/ZccDUvIn+r5Pvf8qr8DsYBps7RM/Nfn LjFj7qK6X8v+0oCGFv9ECFVIPxtbmBF3d+DQ5Sav8TFu+wTw35amzhbrxQdHzH/oQDaJ yA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn8s3kma-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:12 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id ECA4A10002A; Thu, 16 Apr 2020 18:14:11 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id DDD2F2B2D2A; Thu, 16 Apr 2020 18:14:11 +0200 (CEST) Received: from localhost (10.75.127.44) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:11 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 04/18] remoteproc: Add rproc_get_by_node helper Date: Thu, 16 Apr 2020 18:13:17 +0200 Message-ID: <20200416161331.7606-5-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG7NODE1.st.com (10.75.127.19) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Allow to retrieve the rproc structure from a rproc platform child declared in the device tree. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 14 ++++++-------- include/linux/remoteproc.h | 7 ++++++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 4fcd685cbfd8..32056449bb72 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1739,10 +1739,10 @@ void rproc_shutdown(struct rproc *rproc) EXPORT_SYMBOL(rproc_shutdown); /** - * rproc_get_by_phandle() - find a remote processor by phandle - * @phandle: phandle to the rproc + * rproc_get_by_node() - find a remote processor by device node + * @np: device tree node * - * Finds an rproc handle using the remote processor's phandle, and then + * Finds an rproc handle using the remote processor's node, and then * return a handle to the rproc. * * This function increments the remote processor's refcount, so always @@ -1751,12 +1751,10 @@ EXPORT_SYMBOL(rproc_shutdown); * Returns the rproc handle on success, and NULL on failure. */ #ifdef CONFIG_OF -struct rproc *rproc_get_by_phandle(phandle phandle) +struct rproc *rproc_get_by_node(struct device_node *np) { struct rproc *rproc = NULL, *r; - struct device_node *np; - np = of_find_node_by_phandle(phandle); if (!np) return NULL; @@ -1781,12 +1779,12 @@ struct rproc *rproc_get_by_phandle(phandle phandle) return rproc; } #else -struct rproc *rproc_get_by_phandle(phandle phandle) +struct rproc *rproc_get_by_node(struct device_node *np) { return NULL; } #endif -EXPORT_SYMBOL(rproc_get_by_phandle); +EXPORT_SYMBOL(rproc_get_by_node); /** * rproc_add() - register a remote processor diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index a78e28bda962..ab9762563ae0 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -586,9 +586,14 @@ struct rproc_vdev { u32 index; }; -struct rproc *rproc_get_by_phandle(phandle phandle); +struct rproc *rproc_get_by_node(struct device_node *np); struct rproc *rproc_get_by_child(struct device *dev); +static inline struct rproc *rproc_get_by_phandle(phandle phandle) +{ + return rproc_get_by_node(of_find_node_by_phandle(phandle)); +} + struct rproc *rproc_alloc(struct device *dev, const char *name, const struct rproc_ops *ops, const char *firmware, int len); From patchwork Thu Apr 16 16:13:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493399 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A9EF6186E for ; Thu, 16 Apr 2020 16:14:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8D99020857 for ; Thu, 16 Apr 2020 16:14:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="jSuvQtP8" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2636484AbgDPQOZ (ORCPT ); Thu, 16 Apr 2020 12:14:25 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:60762 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2506882AbgDPQOV (ORCPT ); Thu, 16 Apr 2020 12:14:21 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGDEcA005340; Thu, 16 Apr 2020 18:14:14 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=YZpO0MFVW9vkv1rWFiaUKKC8KtUwKhF7TJEzzRaiSig=; b=jSuvQtP8C4bkThZade7Gr7g5EmOAKrdv17XxcdCMhpYEbbxKNruIHyIMEYWjNrTKCifq JQYwIz5mGlK6lA5fzi5Q7AY/xWnZZx1Rv0ZVmKmrA8cRANawKOO3s56xYHRCw5sgi9Ns IINiHjentlBBy8uvcF+MQo9h6F8u4JqzvsBqU7HcCjI1J8v5kcpuOpJOYJmUMsf1L3E9 ZUHx9KNahYz+4hM21hxs8uv47XCcLYMteaSW/BCOl3FKwqsSEVfh+pLdMbgXa4V0B6V0 ranTFllTyjMla+G5hFQcQdgJG5RExP+OJ21ZM9mu28cQKZJSmO4ocaKTkob1Cj8wM6Vy rQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn6t3nbq-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:14 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id C63D410002A; Thu, 16 Apr 2020 18:14:13 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id B8AD62B2D2A; Thu, 16 Apr 2020 18:14:13 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:12 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 05/18] remoteproc: Create platform device for vdev Date: Thu, 16 Apr 2020 18:13:18 +0200 Message-ID: <20200416161331.7606-6-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG1NODE3.st.com (10.75.127.3) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Manage the vdev as a platform device. The platform device is created when a vdev resource is detected in the resource table. The rvdev is now managed in rproc_virtio platform. The rdev->refcount is now useless. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 57 +++--- drivers/remoteproc/remoteproc_internal.h | 10 +- drivers/remoteproc/remoteproc_virtio.c | 213 ++++++++++++++--------- include/linux/remoteproc.h | 9 +- 4 files changed, 175 insertions(+), 114 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 32056449bb72..5dcef62d8d1d 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -31,6 +31,7 @@ #include #include #include +#include #include #include #include @@ -440,7 +441,9 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, int offset, int avail) { struct device *dev = &rproc->dev; - struct rproc_vdev *rvdev; + struct rproc_vdev_data vdev_data; + struct platform_device *pdev; + int ret; /* make sure resource isn't truncated */ if (struct_size(rsc, vring, rsc->num_of_vrings) + rsc->config_len > @@ -455,37 +458,43 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, return -EINVAL; } - dev_dbg(dev, "vdev rsc: id %d, dfeatures 0x%x, cfg len %d, %d vrings\n", - rsc->id, rsc->dfeatures, rsc->config_len, rsc->num_of_vrings); + vdev_data.rsc_offset = offset; + vdev_data.rsc = rsc; + vdev_data.id = rsc->id; + vdev_data.index = rproc->nb_vdev; - /* we currently support only two vrings per rvdev */ - if (rsc->num_of_vrings > ARRAY_SIZE(rvdev->vring)) { - dev_err(dev, "too many vrings: %d\n", rsc->num_of_vrings); - return -EINVAL; + dev_dbg(dev, "%s: rsc_offset = %d rsc = %p id = %d\n", + __func__, vdev_data.rsc_offset, vdev_data.rsc, vdev_data.id); + + pdev = platform_device_register_data(dev, "rproc-virtio", + rproc->nb_vdev, &vdev_data, + sizeof(vdev_data)); + ret = PTR_ERR_OR_ZERO(pdev); + if (ret) { + dev_err(rproc->dev.parent, + "failed to create rproc-virtio device\n"); + return ret; } + rproc->nb_vdev++; - rvdev = kzalloc(sizeof(*rvdev), GFP_KERNEL); - if (!rvdev) - return -ENOMEM; + return 0; +} - kref_init(&rvdev->refcount); +static void rproc_vdev_release(struct rproc_vdev *rvdev) +{ + struct device *dev = &rvdev->pdev->dev; - rvdev->rsc = rsc; - rvdev->rsc_offset = offset; - rvdev->id = rsc->id; - rvdev->rproc = rproc; - rvdev->index = rproc->nb_vdev++; + if (!dev->of_node) + platform_device_unregister(rvdev->pdev); +} +void rproc_register_rvdev(struct rproc *rproc, struct rproc_vdev *rvdev) +{ list_add_tail(&rvdev->node, &rproc->rvdevs); - - return rproc_virtio_device_add(rvdev); } -void rproc_vdev_release(struct kref *ref) +void rproc_unregister_rvdev(struct rproc_vdev *rvdev) { - struct rproc_vdev *rvdev = container_of(ref, struct rproc_vdev, refcount); - - rproc_virtio_device_remove(rvdev); list_del(&rvdev->node); } @@ -1192,9 +1201,9 @@ static void rproc_resource_cleanup(struct rproc *rproc) kfree(entry); } - /* clean up remote vdev entries */ + /* clean up virtio platform devices */ list_for_each_entry_safe(rvdev, rvtmp, &rproc->rvdevs, node) - kref_put(&rvdev->refcount, rproc_vdev_release); + rproc_vdev_release(rvdev); rproc_coredump_cleanup(rproc); } diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index fad95f1a50c1..f5eaffac2fcd 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -24,10 +24,18 @@ struct rproc_debug_trace { struct rproc_mem_entry trace_mem; }; +struct rproc_vdev_data { + u32 rsc_offset; + struct fw_rsc_vdev *rsc; + unsigned int id; + unsigned int index; +}; + /* from remoteproc_core.c */ void rproc_release(struct kref *kref); irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); -void rproc_vdev_release(struct kref *ref); +void rproc_register_rvdev(struct rproc *rproc, struct rproc_vdev *rvdev); +void rproc_unregister_rvdev(struct rproc_vdev *rvdev); /* from remoteproc_virtio.c */ int rproc_virtio_device_add(struct rproc_vdev *rvdev); diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index 0f7efac7d4f3..2a0f33ccd929 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -2,6 +2,7 @@ /* * Remote processor messaging transport (OMAP platform-specific bits) * + * Copyright (C) 2020 ST STMicroelectronics. * Copyright (C) 2011 Texas Instruments, Inc. * Copyright (C) 2011 Google, Inc. * @@ -11,14 +12,15 @@ #include #include +#include #include +#include #include #include #include #include #include #include -#include #include #include "remoteproc_internal.h" @@ -296,41 +298,23 @@ static const struct virtio_config_ops rproc_virtio_config_ops = { .set = rproc_virtio_set, }; -/** - * rproc_rvdev_release() - release the existence of a rvdev - * - * @dev: the subdevice's dev - */ -static void rproc_virtio_rvdev_release(struct device *dev) -{ - struct rproc_vdev *rvdev = container_of(dev, struct rproc_vdev, dev); - - of_reserved_mem_device_release(dev); - - kfree(rvdev); -} - -/* - * This function is called whenever vdev is released, and is responsible - * to decrement the remote processor's refcount which was taken when vdev was - * added. - * - * Never call this function directly; it will be called by the driver - * core when needed. - */ static void rproc_virtio_dev_release(struct device *dev) { struct virtio_device *vdev = dev_to_virtio(dev); - struct rproc_vdev *rvdev = vdev_to_rvdev(vdev); struct rproc *rproc = vdev_to_rproc(vdev); - kfree(vdev); - - kref_put(&rvdev->refcount, rproc_vdev_release); - put_device(&rproc->dev); } +static void rproc_virtio_dev_init(struct rproc_vdev *rvdev) +{ + memset(&rvdev->vdev, 0, sizeof(rvdev->vdev)); + rvdev->vdev.dev.parent = &rvdev->pdev->dev; + rvdev->vdev.dev.release = rproc_virtio_dev_release; + rvdev->vdev.config = &rproc_virtio_config_ops; + rvdev->vdev.id.device = rvdev->id; +} + /** * rproc_vdev_start() - register an rproc-induced virtio device * @subdev: the rproc virtio subdevice @@ -345,8 +329,8 @@ static int rproc_vitio_start(struct rproc_subdev *subdev) struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, subdev); struct rproc *rproc = rvdev->rproc; - struct device *dev = &rvdev->dev; - struct virtio_device *vdev; + struct device *dev = &rvdev->pdev->dev; + struct virtio_device *vdev = &rvdev->vdev; struct rproc_mem_entry *mem; int ret; @@ -387,29 +371,15 @@ static int rproc_vitio_start(struct rproc_subdev *subdev) } /* Allocate virtio device */ - vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); - if (!vdev) { - ret = -ENOMEM; - goto out; - } - vdev->id.device = rvdev->id, - vdev->config = &rproc_virtio_config_ops, - vdev->dev.parent = dev; - vdev->dev.release = rproc_virtio_dev_release; + rproc_virtio_dev_init(rvdev); /* * We're indirectly making a non-temporary copy of the rproc pointer * here, because drivers probed with this vdev will indirectly * access the wrapping rproc. - * - * Therefore we must increment the rproc refcount here, and decrement - * it _only_ when the vdev is released. */ get_device(&rproc->dev); - /* Reference the vdev and vring allocations */ - kref_get(&rvdev->refcount); - ret = register_virtio_device(vdev); if (ret) { put_device(&vdev->dev); @@ -427,17 +397,9 @@ static int rproc_vitio_start(struct rproc_subdev *subdev) static int rproc_remove_virtio_dev(struct device *dev, void *data) { struct virtio_device *vdev = dev_to_virtio(dev); - struct rproc_vdev *rvdev = vdev_to_rvdev(vdev); - struct rproc_vring *rvring; - int id; unregister_virtio_device(vdev); - for (id = 0; id < ARRAY_SIZE(rvdev->vring); id++) { - rvring = &rvdev->vring[id]; - rproc_free_vring(rvring); - } - return 0; } /** @@ -451,12 +413,12 @@ static void rproc_vitio_stop(struct rproc_subdev *subdev, bool crashed) { struct rproc_vdev *rvdev = container_of(subdev, struct rproc_vdev, subdev); + struct device *dev = &rvdev->pdev->dev; int ret; - ret = device_for_each_child(&rvdev->dev, NULL, rproc_remove_virtio_dev); + ret = device_for_each_child(dev, NULL, rproc_remove_virtio_dev); if (ret) - dev_warn(&rvdev->dev, "can't remove vdev child device: %d\n", - ret); + dev_warn(dev, "can't remove vdev child device: %d\n", ret); } static const struct rproc_subdev rproc_virtio_subdev = { @@ -464,42 +426,35 @@ static const struct rproc_subdev rproc_virtio_subdev = { .stop = rproc_vitio_stop }; -int rproc_virtio_device_add(struct rproc_vdev *rvdev) +static int rproc_virtio_bind(struct device *dev) { + struct rproc_vdev *rvdev = dev_get_drvdata(dev); struct rproc *rproc = rvdev->rproc; struct fw_rsc_vdev *rsc = rvdev->rsc; - char name[16]; int ret, i; - /* Initialise vdev subdevice */ - snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index); - rvdev->dev.parent = &rproc->dev; - rvdev->dev.dma_pfn_offset = rproc->dev.parent->dma_pfn_offset; - rvdev->dev.release = rproc_virtio_rvdev_release; - dev_set_name(&rvdev->dev, "%s#%s", dev_name(rvdev->dev.parent), name); - dev_set_drvdata(&rvdev->dev, rvdev); + /* test if a resource has been associated to the vdev */ + if (!rvdev->rsc) + return 0; - ret = device_register(&rvdev->dev); - if (ret) { - put_device(&rvdev->dev); - return ret; - } - /* Make device dma capable by inheriting from parent's capabilities */ - set_dma_ops(&rvdev->dev, get_dma_ops(rproc->dev.parent)); + dev_dbg(dev, "vdev rsc: id %d, dfeatures 0x%x, cfg len %d, %d vrings\n", + rsc->id, rsc->dfeatures, rsc->config_len, rsc->num_of_vrings); - ret = dma_coerce_mask_and_coherent(&rvdev->dev, - dma_get_mask(rproc->dev.parent)); - if (ret) { - dev_warn(&rvdev->dev, - "Failed to set DMA mask %llx. Trying to continue... %x\n", - dma_get_mask(rproc->dev.parent), ret); + /* we currently support only two vrings per rvdev */ + if (rsc->num_of_vrings > ARRAY_SIZE(rvdev->vring)) { + dev_err(dev, "too many vrings: %d\n", rsc->num_of_vrings); + return -EINVAL; } + /* If no resource table or no vdev nothing to do */ + if (!rsc || !rsc->num_of_vrings) + return 0; + /* parse the vrings */ for (i = 0; i < rsc->num_of_vrings; i++) { ret = rproc_parse_vring(rvdev, rsc, i); if (ret) - goto free_rvdev; + return ret; } /* allocate the vring resources */ @@ -510,9 +465,12 @@ int rproc_virtio_device_add(struct rproc_vdev *rvdev) } rvdev->subdev = rproc_virtio_subdev; + rvdev->id = rsc->id; rproc_add_subdev(rproc, &rvdev->subdev); + dev_dbg(dev, "virtio dev %d bound\n", rvdev->index); + return 0; free_vg: @@ -522,16 +480,103 @@ int rproc_virtio_device_add(struct rproc_vdev *rvdev) rproc_free_vring(rvring); } -free_rvdev: - device_unregister(&rvdev->dev); - return ret; } -void rproc_virtio_device_remove(struct rproc_vdev *rvdev) +static void rproc_virtio_unbind(struct device *dev) { + struct rproc_vdev *rvdev = dev_get_drvdata(dev); struct rproc *rproc = rvdev->rproc; + struct rproc_vring *rvring; + int id; + + /*test if a resource has been associated to the vdev */ + if (!rvdev->rsc) + return; + + for (id = 0; id < ARRAY_SIZE(rvdev->vring); id++) { + rvring = &rvdev->vring[id]; + rproc_free_vring(rvring); + } rproc_remove_subdev(rproc, &rvdev->subdev); - device_unregister(&rvdev->dev); + + dev_dbg(dev, "virtio dev %d unbound\n", rvdev->index); } + +static int rproc_virtio_probe(struct platform_device *pdev) +{ + struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct rproc_vdev *rvdev; + struct rproc *rproc; + int ret; + + rvdev = devm_kzalloc(&pdev->dev, sizeof(*rvdev), GFP_KERNEL); + if (!rvdev) + return -ENOMEM; + + if (dev->of_node) { + /* + * The platform device is declared in the device tree + * retrieve rproc struct through the remoteproc platform + */ + rproc = rproc_get_by_node(dev->parent->of_node); + + /* the reg is used to specify the vdev index */ + if (of_property_read_u32(np, "reg", &rvdev->index)) + return -EINVAL; + } else { + struct rproc_vdev_data *vdev_data = pdev->dev.platform_data; + + if (!vdev_data) + return -EINVAL; + + rproc = container_of(dev->parent, struct rproc, dev); + + rvdev->rsc_offset = vdev_data->rsc_offset; + rvdev->rsc = vdev_data->rsc; + rvdev->id = vdev_data->id; + rvdev->index = vdev_data->index; + + ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32)); + if (ret) + return ret; + } + rvdev->pdev = pdev; + rvdev->rproc = rproc; + + platform_set_drvdata(pdev, rvdev); + + rproc_register_rvdev(rproc, rvdev); + + return rproc_virtio_bind(dev); +} + +static int rproc_virtio_remove(struct platform_device *pdev) +{ + rproc_virtio_unbind(&pdev->dev); + + return 0; +} + +/* Platform driver */ +static const struct of_device_id rproc_virtio_match[] = { + { .compatible = "rproc-virtio", }, + {}, +}; + +static struct platform_driver rproc_virtio_driver = { + .probe = rproc_virtio_probe, + .remove = rproc_virtio_remove, + .driver = { + .name = "rproc-virtio", + .of_match_table = rproc_virtio_match, + }, +}; + +module_platform_driver(rproc_virtio_driver); + +MODULE_AUTHOR("Arnaud Pouliquen "); +MODULE_DESCRIPTION("Platform bus driver for rproc based virtio devices"); +MODULE_LICENSE("GPL"); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index ab9762563ae0..eb5bd568f11e 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -560,8 +560,8 @@ struct rproc_vring { /** * struct rproc_vdev - remoteproc state for a supported virtio device - * @refcount: reference counter for the vdev and vring allocations * @subdev: handle for registering the vdev as a rproc subdevice + * @pdev: remoteproc virtio platform device * @id: virtio device id (as in virtio_ids.h) * @node: list node * @rproc: the rproc handle @@ -572,10 +572,9 @@ struct rproc_vring { * @index: vdev position versus other vdev declared in resource table */ struct rproc_vdev { - struct kref refcount; - struct rproc_subdev subdev; - struct device dev; + struct platform_device *pdev; + struct virtio_device vdev; unsigned int id; struct list_head node; @@ -628,7 +627,7 @@ int rproc_coredump_add_custom_segment(struct rproc *rproc, static inline struct rproc_vdev *vdev_to_rvdev(struct virtio_device *vdev) { - return container_of(vdev->dev.parent, struct rproc_vdev, dev); + return container_of(vdev, struct rproc_vdev, vdev); } static inline struct rproc *vdev_to_rproc(struct virtio_device *vdev) From patchwork Thu Apr 16 16:13:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493393 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7A657112C for ; Thu, 16 Apr 2020 16:14:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 601732223E for ; Thu, 16 Apr 2020 16:14:24 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="YeZbZYRX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2636438AbgDPQOX (ORCPT ); Thu, 16 Apr 2020 12:14:23 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:16640 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732881AbgDPQOU (ORCPT ); Thu, 16 Apr 2020 12:14:20 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGDE7R005334; Thu, 16 Apr 2020 18:14:15 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=9k0FNhJOPSvwIJNPLmFrVLya7+VY5EmTPJ6xttH4GPs=; b=YeZbZYRXQTmO9XDUeIuCvzaFn91Kd+T3rf0iGQCGfFDVULmOCcLptryRRfiJlVgdPSXM fDsdBUzG7fiXpSJMOmEblM3ueKRpIBjk2d+3BRGT6JCm5T2+SUs5I/UCVhHm8CknbGfS AA5KzT4tO5v2EvNHo4BQOiE84cxw9u2TG+GoVBr47Rd1179k4W6nE2D6B1RrlNtmfmxy dvCmbgV8kBUrshGketf22kzp+azQNDICeN/bWTFoUpmTvQ6Z6Znpv4SH0cCOrFrk9P0A 7ZdYbLnBUZYwAgQDV9FWDbu9v5RMNUDdiUOZt/zHHVOnfT7769NxbzgrnWngfN1nwN2v 4w== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn6t3nbv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:15 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3AE3710002A; Thu, 16 Apr 2020 18:14:15 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 2EB4B2B2D2A; Thu, 16 Apr 2020 18:14:15 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:14 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 06/18] remoteproc: Add component in core for child devices synchronization Date: Thu, 16 Apr 2020 18:13:19 +0200 Message-ID: <20200416161331.7606-7-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG6NODE2.st.com (10.75.127.17) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org As virtio is now a platform device. We need to ensure that the virtio device is initialized before subdev ops are called. Add a rproc master component to synchronize child devices bind/unbind before the resource allocation and the firmware start. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 96 +++++++++++++++++++++++++++- include/linux/remoteproc.h | 4 ++ 2 files changed, 98 insertions(+), 2 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 5dcef62d8d1d..cb40aae12b98 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -16,6 +16,7 @@ #define pr_fmt(fmt) "%s: " fmt, __func__ +#include #include #include #include @@ -42,6 +43,8 @@ #define HIGH_BITS_MASK 0xFFFFFFFF00000000ULL +#define BIND_TIMEOUT_MS 1000 + static DEFINE_MUTEX(rproc_list_mutex); static LIST_HEAD(rproc_list); @@ -410,6 +413,45 @@ void rproc_free_vring(struct rproc_vring *rvring) rsc->vring[idx].notifyid = -1; } +static int rproc_compare_of(struct device *dev, void *data) +{ + if (dev->of_node) + return dev->of_node == data; + else + return dev == data; +} + +static void rproc_release_of(struct device *dev, void *data) +{ + if (dev->of_node) + of_node_put(data); +} + +static void rproc_unbind(struct device *dev) +{ + struct rproc *rproc = container_of(dev, struct rproc, dev); + + /* undbind all child components */ + component_unbind_all(dev, NULL); + complete(&rproc->completed); +} + +static int rproc_bind(struct device *dev) +{ + struct rproc *rproc = container_of(dev, struct rproc, dev); + + /* bind all child components */ + rproc->bind_status = component_bind_all(dev, NULL); + complete(&rproc->completed); + + return rproc->bind_status; +} + +static const struct component_master_ops rproc_cmp_ops = { + .bind = rproc_bind, + .unbind = rproc_unbind, +}; + /** * rproc_handle_vdev() - handle a vdev fw resource * @rproc: the remote processor @@ -475,6 +517,10 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, "failed to create rproc-virtio device\n"); return ret; } + /* register a component associated to the virtio platform */ + component_match_add_release(&pdev->dev, &rproc->match, + rproc_release_of, rproc_compare_of, + &pdev->dev); rproc->nb_vdev++; return 0; @@ -1318,20 +1364,51 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw) goto clean_up_resources; } + /* + * bind all the children associated to the resources before starting + * the remote processor. This synchro point ensures that everything is + * ready to run. + */ + init_completion(&rproc->completed); + if (rproc->match) { + ret = component_master_add_with_match(dev, &rproc_cmp_ops, + rproc->match); + if (ret) { + dev_err(dev, "failed to bind rproc\n"); + goto clean_up_resources; + } + } + /* Wait for all children to be bound */ + if (!wait_for_completion_timeout(&rproc->completed, + msecs_to_jiffies(BIND_TIMEOUT_MS))) { + dev_err(dev, "failed to bind child device(s)\n"); + ret = -ETIMEDOUT; + goto clean_up_resources; + } + + ret = rproc->bind_status; + if (ret) { + dev_err(dev, "failed to bind\n"); + goto clean_up_resources; + } + /* Allocate carveout resources associated to rproc */ ret = rproc_alloc_registered_carveouts(rproc); if (ret) { dev_err(dev, "Failed to allocate associated carveouts: %d\n", ret); - goto clean_up_resources; + goto unbind_comp; } ret = rproc_start(rproc, fw); if (ret) - goto clean_up_resources; + goto unbind_comp; return 0; +unbind_comp: + component_master_del(dev, &rproc_cmp_ops); + rproc->match = NULL; clean_up_resources: rproc_resource_cleanup(rproc); kfree(rproc->cached_table); @@ -1733,6 +1810,21 @@ void rproc_shutdown(struct rproc *rproc) goto out; } + /* + * Unbind all the children before cleaning resources. This synchro + * point ensures that everything has been released before resources are + * freed. + */ + init_completion(&rproc->completed); + + component_master_del(dev, &rproc_cmp_ops); + rproc->match = NULL; + + if (!wait_for_completion_timeout(&rproc->completed, + msecs_to_jiffies(BIND_TIMEOUT_MS))) { + dev_err(dev, "failed to unbind child device(s)\n"); + } + /* clean up all acquired resources */ rproc_resource_cleanup(rproc); diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index eb5bd568f11e..d7235f7356e2 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -514,6 +514,10 @@ struct rproc { bool auto_boot; struct list_head dump_segments; int nb_vdev; + struct component_match *match; + struct completion completed; + int bind_status; + }; /** From patchwork Thu Apr 16 16:13:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493429 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63A5F186E for ; Thu, 16 Apr 2020 16:15:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 487FD22243 for ; Thu, 16 Apr 2020 16:15:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="RToF/KLF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2636442AbgDPQOX (ORCPT ); Thu, 16 Apr 2020 12:14:23 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:46907 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2636317AbgDPQOV (ORCPT ); Thu, 16 Apr 2020 12:14:21 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGCFET010375; Thu, 16 Apr 2020 18:14:17 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=HSxCJna+r5+8UesgNfnHzloc46YrqYjXP5KDUxOljAY=; b=RToF/KLFRTZwOODwY0YFkp6PU/uVLUwzjIT/u1mhdzeeOjmZe16DAIuogtvAxUR6MM+L D4zJ2fLpyHChxRI6Pie4fI4YExEGmnVWMjKwYWAIZaRab2sgZUktMVHxiLnsuZbhc0X+ wCIh8D9W9KvCs1coz6G8J6HWFC2w17PoOraFTnv9sANOFWjGZRe0Fgh7Zb+PxAkEX19c G+905Q4DlkQ6QP0OV1HODDTbIKfbgfwnLHpQRR60c9YdnHj4lzHd7pSTylHn6+fMBwJ9 9oo/Op+t+QVwxAOi//OMP81JgbrhfNA/ASaDN6/bzPohuoPPEqlLQMv7COPPAHOU3P5d Pg== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn94kmvm-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:17 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9890C100034; Thu, 16 Apr 2020 18:14:16 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 8C9202B2D2A; Thu, 16 Apr 2020 18:14:16 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:16 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 07/18] remoteproc: Add component bind/unbind for virtio platform Date: Thu, 16 Apr 2020 18:13:20 +0200 Message-ID: <20200416161331.7606-8-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG2NODE2.st.com (10.75.127.5) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add component to declare bind and unbind functions. Theses functions are used to ensure that the remoteproc virtio device is probed and registered as a subdev of the rproc device before rproc request the the prepare and start of the subdevice. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_virtio.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index 2a0f33ccd929..e1d7371d2d64 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -10,6 +10,7 @@ * Brian Swetland */ +#include #include #include #include @@ -426,7 +427,8 @@ static const struct rproc_subdev rproc_virtio_subdev = { .stop = rproc_vitio_stop }; -static int rproc_virtio_bind(struct device *dev) +static int rproc_virtio_bind(struct device *dev, struct device *master, + void *data) { struct rproc_vdev *rvdev = dev_get_drvdata(dev); struct rproc *rproc = rvdev->rproc; @@ -483,7 +485,8 @@ static int rproc_virtio_bind(struct device *dev) return ret; } -static void rproc_virtio_unbind(struct device *dev) +static void rproc_virtio_unbind(struct device *dev, struct device *master, + void *data) { struct rproc_vdev *rvdev = dev_get_drvdata(dev); struct rproc *rproc = rvdev->rproc; @@ -504,6 +507,11 @@ static void rproc_virtio_unbind(struct device *dev) dev_dbg(dev, "virtio dev %d unbound\n", rvdev->index); } +static const struct component_ops rproc_virtio_ops = { + .bind = rproc_virtio_bind, + .unbind = rproc_virtio_unbind, +}; + static int rproc_virtio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -548,14 +556,21 @@ static int rproc_virtio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, rvdev); + ret = component_add(&pdev->dev, &rproc_virtio_ops); + if (ret) + return ret; + rproc_register_rvdev(rproc, rvdev); - return rproc_virtio_bind(dev); + return 0; } static int rproc_virtio_remove(struct platform_device *pdev) { - rproc_virtio_unbind(&pdev->dev); + struct rproc_vdev *rvdev = dev_get_drvdata(&pdev->dev); + + component_del(&pdev->dev, &rproc_virtio_ops); + rproc_unregister_rvdev(rvdev); return 0; } From patchwork Thu Apr 16 16:13:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493397 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6CD5F1871 for ; Thu, 16 Apr 2020 16:14:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4DE3420857 for ; Thu, 16 Apr 2020 16:14:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="AMoIFXo6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2636462AbgDPQOY (ORCPT ); Thu, 16 Apr 2020 12:14:24 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:4082 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2636348AbgDPQOW (ORCPT ); Thu, 16 Apr 2020 12:14:22 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGDTaa026465; Thu, 16 Apr 2020 18:14:19 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=rdlFbvTHYiRhQAGAdaBWjnrQBxVGbSk8UU7HWs673BI=; b=AMoIFXo6eDSYO+z/GA7/VaaG8IzjMVl6iucdpL+KIj9VRm1gTVNgbMCfqBOVdIXUQ5A7 nLKRy7DhZOWFlTkMTYdCfXB2MYL2L/hvqVk8Ow2UkpKPYxXNZyzWt4WavEhRG5meyod6 xHLdYHzMuVzV34MlohhEGYncVwgtGh9T4TMw/NsEnsjXv/r8kpPmOJ3+Hjpg8HavRkoK HwVxYU2Ef1wu01BiVfUxVsPeGVRbWT7LjiYNPJYVRtLei9DzgOg+NUwdkCjtru+QgXA4 gUz7Ahrz2rNyh8eMCykqyEH9qpLS7yvCQvUUiUorsCwseQ6tYgf6qPJmWBfd3gAwA5JB Pw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn8s3kn1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:18 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 751AA10002A; Thu, 16 Apr 2020 18:14:18 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 686E62B2D2A; Thu, 16 Apr 2020 18:14:18 +0200 (CEST) Received: from localhost (10.75.127.44) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:17 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 08/18] remoteproc: Externalize carveout functions Date: Thu, 16 Apr 2020 18:13:21 +0200 Message-ID: <20200416161331.7606-9-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org The carveout functions are also used for the vring memories. Externalize related functions to prepare migration of the vring management in rproc virtio. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 18 +++++++----------- drivers/remoteproc/remoteproc_internal.h | 4 ++++ 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index cb40aae12b98..ac57cd8016be 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -51,11 +51,6 @@ static LIST_HEAD(rproc_list); typedef int (*rproc_handle_resource_t)(struct rproc *rproc, void *, int offset, int avail); -static int rproc_alloc_carveout(struct rproc *rproc, - struct rproc_mem_entry *mem); -static int rproc_release_carveout(struct rproc *rproc, - struct rproc_mem_entry *mem); - /* Unique indices for remoteproc devices */ static DEFINE_IDA(rproc_dev_index); @@ -281,8 +276,8 @@ rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...) * * Return: 0 if carveout matches request else error */ -static int rproc_check_carveout_da(struct rproc *rproc, - struct rproc_mem_entry *mem, u32 da, u32 len) +int rproc_check_carveout_da(struct rproc *rproc, + struct rproc_mem_entry *mem, u32 da, u32 len) { struct device *dev = &rproc->dev; int delta; @@ -315,6 +310,7 @@ static int rproc_check_carveout_da(struct rproc *rproc, return 0; } +EXPORT_SYMBOL(rproc_check_carveout_da); int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) { @@ -695,8 +691,7 @@ static int rproc_handle_devmem(struct rproc *rproc, struct fw_rsc_devmem *rsc, * This function allocate specified memory entry @mem using * dma_alloc_coherent() as default allocator */ -static int rproc_alloc_carveout(struct rproc *rproc, - struct rproc_mem_entry *mem) +int rproc_alloc_carveout(struct rproc *rproc, struct rproc_mem_entry *mem) { struct rproc_mem_entry *mapping = NULL; struct device *dev = &rproc->dev; @@ -791,6 +786,7 @@ static int rproc_alloc_carveout(struct rproc *rproc, dma_free_coherent(dev->parent, mem->len, va, dma); return ret; } +EXPORT_SYMBOL(rproc_alloc_carveout); /** * rproc_release_carveout() - release acquired carveout @@ -800,8 +796,7 @@ static int rproc_alloc_carveout(struct rproc *rproc, * This function releases specified memory entry @mem allocated via * rproc_alloc_carveout() function by @rproc. */ -static int rproc_release_carveout(struct rproc *rproc, - struct rproc_mem_entry *mem) +int rproc_release_carveout(struct rproc *rproc, struct rproc_mem_entry *mem) { struct device *dev = &rproc->dev; @@ -809,6 +804,7 @@ static int rproc_release_carveout(struct rproc *rproc, dma_free_coherent(dev->parent, mem->len, mem->va, mem->dma); return 0; } +EXPORT_SYMBOL(rproc_release_carveout); /** * rproc_handle_carveout() - handle phys contig memory allocation requests diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index f5eaffac2fcd..f230296908ac 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -71,6 +71,10 @@ struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw); struct rproc_mem_entry * rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); +int rproc_check_carveout_da(struct rproc *rproc, struct rproc_mem_entry *mem, + u32 da, u32 len); +int rproc_alloc_carveout(struct rproc *rproc, struct rproc_mem_entry *mem); +int rproc_release_carveout(struct rproc *rproc, struct rproc_mem_entry *mem); static inline int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) From patchwork Thu Apr 16 16:13:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493437 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 16D89186E for ; Thu, 16 Apr 2020 16:15:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA5D42223E for ; Thu, 16 Apr 2020 16:15:41 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="ae2jYbNB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2406605AbgDPQP3 (ORCPT ); Thu, 16 Apr 2020 12:15:29 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:46871 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728958AbgDPQOZ (ORCPT ); Thu, 16 Apr 2020 12:14:25 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGCFia010372; Thu, 16 Apr 2020 18:14:20 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=BnLDwpVavIoWUlJvnJXxlP7jRIgDXwSpYFB3LVEa9rQ=; b=ae2jYbNByuYpMObCYUimmLeavvGxBYez7RROONuWOeoptsMV+WYpaitC94VTSA1y3zhC RwuXaysBQpUcXp7PhAbnmSQm7St8wlGXtpyP/ejn+VldOR7thWVEvwe4I1U9DluKoSxA NwGEzvYuvc1DoCVxwCIfbd6Nq8jz5exHcmISAMPAHEt2dPEu5WVAuVjvKuJW5f5BMHES tNxxZ/sWz37IlqVWa1B+IN/Z71zbW0UCDVaKMeH9yuL6hwjY1TdW6dmfsn74a+bo+N/f StEyjehyfpEmYMTEbTM2UU4db6cp9rOKaeb2tMrKDtyZ9YAAHIvRyNbBW5fbC325a0Aw mQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn94kmvx-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:20 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 06EEB10002A; Thu, 16 Apr 2020 18:14:20 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id ED8962B2D2A; Thu, 16 Apr 2020 18:14:19 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:19 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 09/18] remoteproc: Move vring management from core to virtio Date: Thu, 16 Apr 2020 18:13:22 +0200 Message-ID: <20200416161331.7606-10-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG1NODE3.st.com (10.75.127.3) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org The vrings are correlated to the virtio implementation. Move following functions to rproc virtio: - rproc_alloc_vring - rproc_free_vring - rproc_parse_vring Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 97 ----------------------- drivers/remoteproc/remoteproc_internal.h | 4 - drivers/remoteproc/remoteproc_virtio.c | 98 ++++++++++++++++++++++++ 3 files changed, 98 insertions(+), 101 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index ac57cd8016be..c9e07c53ed0c 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -312,103 +312,6 @@ int rproc_check_carveout_da(struct rproc *rproc, } EXPORT_SYMBOL(rproc_check_carveout_da); -int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) -{ - struct rproc *rproc = rvdev->rproc; - struct device *dev = &rproc->dev; - struct rproc_vring *rvring = &rvdev->vring[i]; - struct fw_rsc_vdev *rsc; - int ret, size, notifyid; - struct rproc_mem_entry *mem; - - /* actual size of vring (in bytes) */ - size = PAGE_ALIGN(vring_size(rvring->len, rvring->align)); - - rsc = (void *)rproc->table_ptr + rvdev->rsc_offset; - - /* Search for pre-registered carveout */ - mem = rproc_find_carveout_by_name(rproc, "vdev%dvring%d", rvdev->index, - i); - if (mem) { - if (rproc_check_carveout_da(rproc, mem, rsc->vring[i].da, size)) - return -ENOMEM; - } else { - /* Register carveout in in list */ - mem = rproc_mem_entry_init(dev, NULL, 0, - size, rsc->vring[i].da, - rproc_alloc_carveout, - rproc_release_carveout, - "vdev%dvring%d", - rvdev->index, i); - if (!mem) { - dev_err(dev, "Can't allocate memory entry structure\n"); - return -ENOMEM; - } - - rproc_add_carveout(rproc, mem); - } - - /* - * Assign an rproc-wide unique index for this vring - * TODO: assign a notifyid for rvdev updates as well - * TODO: support predefined notifyids (via resource table) - */ - ret = idr_alloc(&rproc->notifyids, rvring, 0, 0, GFP_KERNEL); - if (ret < 0) { - dev_err(dev, "idr_alloc failed: %d\n", ret); - return ret; - } - notifyid = ret; - - /* Potentially bump max_notifyid */ - if (notifyid > rproc->max_notifyid) - rproc->max_notifyid = notifyid; - - rvring->notifyid = notifyid; - - /* Let the rproc know the notifyid of this vring.*/ - rsc->vring[i].notifyid = notifyid; - return 0; -} - -int rproc_parse_vring(struct rproc_vdev *rvdev, struct fw_rsc_vdev *rsc, int i) -{ - struct rproc *rproc = rvdev->rproc; - struct device *dev = &rproc->dev; - struct fw_rsc_vdev_vring *vring = &rsc->vring[i]; - struct rproc_vring *rvring = &rvdev->vring[i]; - - dev_dbg(dev, "vdev rsc: vring%d: da 0x%x, qsz %d, align %d\n", - i, vring->da, vring->num, vring->align); - - /* verify queue size and vring alignment are sane */ - if (!vring->num || !vring->align) { - dev_err(dev, "invalid qsz (%d) or alignment (%d)\n", - vring->num, vring->align); - return -EINVAL; - } - - rvring->len = vring->num; - rvring->align = vring->align; - rvring->rvdev = rvdev; - - return 0; -} - -void rproc_free_vring(struct rproc_vring *rvring) -{ - struct rproc *rproc = rvring->rvdev->rproc; - int idx = rvring - rvring->rvdev->vring; - struct fw_rsc_vdev *rsc; - - idr_remove(&rproc->notifyids, rvring->notifyid); - - /* reset resource entry info */ - rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset; - rsc->vring[idx].da = 0; - rsc->vring[idx].notifyid = -1; -} - static int rproc_compare_of(struct device *dev, void *data) { if (dev->of_node) diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index f230296908ac..5139cca646ca 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -55,10 +55,6 @@ extern struct class rproc_class; int rproc_init_sysfs(void); void rproc_exit_sysfs(void); -int rproc_parse_vring(struct rproc_vdev *rvdev, struct fw_rsc_vdev *rsc, int i); -void rproc_free_vring(struct rproc_vring *rvring); -int rproc_alloc_vring(struct rproc_vdev *rvdev, int i); - void *rproc_da_to_va(struct rproc *rproc, u64 da, int len); phys_addr_t rproc_va_to_pa(void *cpu_addr); int rproc_trigger_recovery(struct rproc *rproc); diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index e1d7371d2d64..4634cd63d547 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -26,6 +26,104 @@ #include "remoteproc_internal.h" +static int rproc_alloc_vring(struct rproc_vdev *rvdev, int i) +{ + struct rproc *rproc = rvdev->rproc; + struct device *dev = &rproc->dev; + struct rproc_vring *rvring = &rvdev->vring[i]; + struct fw_rsc_vdev *rsc; + int ret, size, notifyid; + struct rproc_mem_entry *mem; + + /* actual size of vring (in bytes) */ + size = PAGE_ALIGN(vring_size(rvring->len, rvring->align)); + + rsc = (void *)rproc->table_ptr + rvdev->rsc_offset; + + /* Search for pre-registered carveout */ + mem = rproc_find_carveout_by_name(rproc, "vdev%dvring%d", rvdev->index, + i); + if (mem) { + if (rproc_check_carveout_da(rproc, mem, rsc->vring[i].da, size)) + return -ENOMEM; + } else { + /* Register carveout in in list */ + mem = rproc_mem_entry_init(dev, NULL, 0, + size, rsc->vring[i].da, + rproc_alloc_carveout, + rproc_release_carveout, + "vdev%dvring%d", + rvdev->index, i); + if (!mem) { + dev_err(dev, "Can't allocate memory entry structure\n"); + return -ENOMEM; + } + + rproc_add_carveout(rproc, mem); + } + + /* + * Assign an rproc-wide unique index for this vring + * TODO: assign a notifyid for rvdev updates as well + * TODO: support predefined notifyids (via resource table) + */ + ret = idr_alloc(&rproc->notifyids, rvring, 0, 0, GFP_KERNEL); + if (ret < 0) { + dev_err(dev, "idr_alloc failed: %d\n", ret); + return ret; + } + notifyid = ret; + + /* Potentially bump max_notifyid */ + if (notifyid > rproc->max_notifyid) + rproc->max_notifyid = notifyid; + + rvring->notifyid = notifyid; + + /* Let the rproc know the notifyid of this vring.*/ + rsc->vring[i].notifyid = notifyid; + return 0; +} + +static int rproc_parse_vring(struct rproc_vdev *rvdev, struct fw_rsc_vdev *rsc, + int i) +{ + struct rproc *rproc = rvdev->rproc; + struct device *dev = &rproc->dev; + struct fw_rsc_vdev_vring *vring = &rsc->vring[i]; + struct rproc_vring *rvring = &rvdev->vring[i]; + + dev_dbg(dev, "vdev rsc: vring%d: da 0x%x, qsz %d, align %d\n", + i, vring->da, vring->num, vring->align); + + /* verify queue size and vring alignment are sane */ + if (!vring->num || !vring->align) { + dev_err(dev, "invalid qsz (%d) or alignment (%d)\n", + vring->num, vring->align); + return -EINVAL; + } + + rvring->len = vring->num; + rvring->align = vring->align; + rvring->rvdev = rvdev; + + return 0; +} + +static void rproc_free_vring(struct rproc_vring *rvring) +{ + struct rproc *rproc = rvring->rvdev->rproc; + int idx = rvring - rvring->rvdev->vring; + struct fw_rsc_vdev *rsc; + + idr_remove(&rproc->notifyids, rvring->notifyid); + + /* reset resource entry info */ + rsc = (void *)rproc->table_ptr + rvring->rvdev->rsc_offset; + rsc->vring[idx].da = 0; + rsc->vring[idx].notifyid = -1; +} + /* kick the remote processor, and let it know which virtqueue to poke at */ static bool rproc_virtio_notify(struct virtqueue *vq) { From patchwork Thu Apr 16 16:13:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493431 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id ACB141392 for ; Thu, 16 Apr 2020 16:15:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9484A20771 for ; Thu, 16 Apr 2020 16:15:29 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="kNxtSLkd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2442914AbgDPQP3 (ORCPT ); Thu, 16 Apr 2020 12:15:29 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:3988 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2636453AbgDPQOZ (ORCPT ); Thu, 16 Apr 2020 12:14:25 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGDTiP026461; Thu, 16 Apr 2020 18:14:21 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=agyR1ppdr+Eyr30Bf9LkTx+EimYHLQAtT1Py/m/yieE=; b=kNxtSLkdGTEkqabTVTr5xwwiOvFr+CK5GzI6NE+TzQjco7oxDNSYUm5VXulS8bF/LNYJ g71gQNxe998zXeac1aIvkW9oqiwoYMXVPtEmlIyCMMTBg73xSfQIXcCaD4esXa0ECkaV x3ejaRAQfE6LLlfl7kW6JNXUG5mVk53S1YLDG+/Io8hQqigBqIQcoTRqyaixOpY4IDta DoWumD8KCW82WtkgSBkF4fSrTdHEKT2XDRCXHB7mFHTiq9R9G0THZ5C7f5LZIxmhOEKc unIbGqS3cuPKhuZoJ4bHG+pxSexDEALtYE4EoEbchvoxZTi7/ZeufaSo1+RMr8gEC6M0 KA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn8s3kn4-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:21 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 3C2F410002A; Thu, 16 Apr 2020 18:14:21 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 2C9A12B2D2A; Thu, 16 Apr 2020 18:14:21 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:20 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 10/18] remoteproc: Add capability to populate rproc subnode devices Date: Thu, 16 Apr 2020 18:13:23 +0200 Message-ID: <20200416161331.7606-11-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG6NODE2.st.com (10.75.127.17) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add the capability to add rproc sub nodes in device tree. Devices declared as rproc sub node will be probed before the remote firmware boot sequence. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index c9e07c53ed0c..75f84fd3bd60 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1605,6 +1605,26 @@ static void rproc_crash_handler_work(struct work_struct *work) rproc_trigger_recovery(rproc); } +static int rproc_platform_populate(struct rproc *rproc) +{ + struct device *dev = rproc->dev.parent; + int ret; + + ret = of_platform_populate(dev->of_node, NULL, NULL, dev); + if (ret < 0) { + dev_err(dev, "failed to populate child devices (%d)\n", ret); + + goto depopulate; + } + + return 0; + +depopulate: + of_platform_depopulate(dev); + + return ret; +} + /** * rproc_boot() - boot a remote processor * @rproc: handle of a remote processor @@ -1629,6 +1649,10 @@ int rproc_boot(struct rproc *rproc) dev = &rproc->dev; + ret = rproc_platform_populate(rproc); + if (ret) + return ret; + ret = mutex_lock_interruptible(&rproc->lock); if (ret) { dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret); @@ -1735,6 +1759,7 @@ void rproc_shutdown(struct rproc *rproc) rproc->table_ptr = NULL; out: mutex_unlock(&rproc->lock); + of_platform_depopulate(rproc->dev.parent); } EXPORT_SYMBOL(rproc_shutdown); From patchwork Thu Apr 16 16:13:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493439 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F2E7C6CA for ; Thu, 16 Apr 2020 16:15:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DAE2D2223E for ; Thu, 16 Apr 2020 16:15:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="G0ZBoztV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2442906AbgDPQP2 (ORCPT ); Thu, 16 Apr 2020 12:15:28 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:3984 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2636463AbgDPQO0 (ORCPT ); Thu, 16 Apr 2020 12:14:26 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGDTqq026413; Thu, 16 Apr 2020 18:14:23 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=sTzUdiEhwGBva7XLbcJkZ9s5PAssf4muQMmT2uqz+CI=; b=G0ZBoztVJpQ47jRS9QWRmzksdMPYQPCciv1bd9oV1Qmrp6aYGFpIHUI2Mlra29VIdRd4 i78j+rlLguqOfmveC60cPGKtXY8ATublAnNvY9bZYTvED60gcAHYgDgGZ7MZV8uFr/qX 99uIPgTke9cZz7PFd6m5uNg8KHzDSc0Im6JGDK0jVCzLIKo4rOJBAXeAoJiBmeTVXgrT uRt8UyQL48vR0b5tkVCDLS7pevHz5QXH45h8NTuLKvt11KVSF7D0kS+8qysB5i0K92t2 dWO0lAnqBAR+Fxv5zl0hpDI8dqLpehf/xb8mIIRnWL7J/WPolDvyBJAD5v/LpT6Le+Vv 7w== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn8s3kn6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:23 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EDB9210002A; Thu, 16 Apr 2020 18:14:22 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id E299F2B2D2A; Thu, 16 Apr 2020 18:14:22 +0200 (CEST) Received: from localhost (10.75.127.44) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:22 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 11/18] remoteproc: Add child node component in rproc match list Date: Thu, 16 Apr 2020 18:13:24 +0200 Message-ID: <20200416161331.7606-12-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG1NODE1.st.com (10.75.127.1) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add the components, associated to the child devices populated, in the match list for synchronization relying on bind/unbind mechanism. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 75f84fd3bd60..ecb36f64b1a0 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1608,6 +1608,8 @@ static void rproc_crash_handler_work(struct work_struct *work) static int rproc_platform_populate(struct rproc *rproc) { struct device *dev = rproc->dev.parent; + struct device_node *node = dev->of_node; + struct device_node *child_np; int ret; ret = of_platform_populate(dev->of_node, NULL, NULL, dev); @@ -1617,6 +1619,19 @@ static int rproc_platform_populate(struct rproc *rproc) goto depopulate; } + child_np = of_get_next_available_child(node, NULL); + + while (child_np) { + of_node_get(node); + component_match_add_release(dev, &rproc->match, + rproc_release_of, rproc_compare_of, + child_np); + child_np = of_get_next_available_child(node, child_np); + } + + if (!rproc->match) + dev_dbg(dev, "No available child\n"); + return 0; depopulate: From patchwork Thu Apr 16 16:13:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493421 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5B7471392 for ; Thu, 16 Apr 2020 16:15:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3FA2F22240 for ; Thu, 16 Apr 2020 16:15:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="IPix+z6b" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2636618AbgDPQOa (ORCPT ); Thu, 16 Apr 2020 12:14:30 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:61124 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2636521AbgDPQO2 (ORCPT ); Thu, 16 Apr 2020 12:14:28 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGDEcC005340; Thu, 16 Apr 2020 18:14:24 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=x/YFvpKguyxR4K0R9rEA/U7cUeNFm3Fzc4388HJ8uh8=; b=IPix+z6bgetGW5L+Zp0JYcGILP6KJi7xFb+o9q4/8rfLr9NUaRWMAhtlYrpio5SHaDIs 6C01weLAHT4VP7NuIHu4tNaLnWxqWMizwWaQcvlg0Ut5Pcfm2IHUD8NtLO4vxtM+XVQa +F9TePZ+nEsnwnlbsCJqljZPecVNnDrF4pbOvhafYGku7TQgpm9LLpC00xCwXNafG8ZH QMOIpWGIIvvSOAsyQVMxwFnfA+WUbal3aEPBvtEjYGvbijvXrykG+KjbtGFVURgtEaky nx8VPaPda3jBC2Gnri8jE7D1nLvarrTjwr66b25eGrIWluCYydIepRG/xKOyVAJsIMS+ GA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn6t3ncs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:24 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 6041310002A; Thu, 16 Apr 2020 18:14:24 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 5361A2B2D2A; Thu, 16 Apr 2020 18:14:24 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:23 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 12/18] remoteproc: Support of pre-registered virtio device Date: Thu, 16 Apr 2020 18:13:25 +0200 Message-ID: <20200416161331.7606-13-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG5NODE1.st.com (10.75.127.13) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Management of the virtio device declared in the devicetree as a sub device of the remoteproc. Instead of creating a new platform device, we parse first the rvdevs list to look for a pre-registered rvdev with an index, that matches with the vdev instance of the resource table. If no pre-registered vdev is found a new platform device is created. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 51 +++++++++++++++++----------- 1 file changed, 32 insertions(+), 19 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index ecb36f64b1a0..9238aa292644 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -383,8 +383,8 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, { struct device *dev = &rproc->dev; struct rproc_vdev_data vdev_data; + struct rproc_vdev *rvdev = NULL, *tmp_rvdev; struct platform_device *pdev; - int ret; /* make sure resource isn't truncated */ if (struct_size(rsc, vring, rsc->num_of_vrings) + rsc->config_len > @@ -399,27 +399,40 @@ static int rproc_handle_vdev(struct rproc *rproc, struct fw_rsc_vdev *rsc, return -EINVAL; } - vdev_data.rsc_offset = offset; - vdev_data.rsc = rsc; - vdev_data.id = rsc->id; - vdev_data.index = rproc->nb_vdev; + /* Try to find a pre-registered rproc virtio device */ + list_for_each_entry(tmp_rvdev, &rproc->rvdevs, node) { + if (tmp_rvdev->index == rproc->nb_vdev) { + rvdev = tmp_rvdev; + break; + } + } - dev_dbg(dev, "%s: rsc_offset = %d rsc = %p id = %d\n", - __func__, vdev_data.rsc_offset, vdev_data.rsc, vdev_data.id); + if (rvdev) { + /* assign the resource offset */ + rvdev->rsc_offset = offset; + rvdev->rsc = rsc; + rvdev->id = rsc->id; - pdev = platform_device_register_data(dev, "rproc-virtio", - rproc->nb_vdev, &vdev_data, - sizeof(vdev_data)); - ret = PTR_ERR_OR_ZERO(pdev); - if (ret) { - dev_err(rproc->dev.parent, - "failed to create rproc-virtio device\n"); - return ret; + } else { + /* no rproc vdev found, register one */ + vdev_data.rsc_offset = offset; + vdev_data.rsc = rsc; + vdev_data.id = rsc->id; + vdev_data.index = rproc->nb_vdev; + + pdev = platform_device_register_data(dev, "rproc-virtio", + rproc->nb_vdev, &vdev_data, + sizeof(vdev_data)); + if (PTR_ERR_OR_ZERO(pdev)) { + dev_err(rproc->dev.parent, + "failed to create rproc-virtio device\n"); + return PTR_ERR_OR_ZERO(pdev); + } + /* register a component associated to the virtio platform */ + component_match_add_release(&pdev->dev, &rproc->match, + rproc_release_of, rproc_compare_of, + &pdev->dev); } - /* register a component associated to the virtio platform */ - component_match_add_release(&pdev->dev, &rproc->match, - rproc_release_of, rproc_compare_of, - &pdev->dev); rproc->nb_vdev++; return 0; From patchwork Thu Apr 16 16:13:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493403 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 31D2A14B4 for ; Thu, 16 Apr 2020 16:14:31 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19AC920857 for ; Thu, 16 Apr 2020 16:14:31 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="bcnSKedP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2636631AbgDPQOa (ORCPT ); Thu, 16 Apr 2020 12:14:30 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:4002 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2636557AbgDPQO3 (ORCPT ); Thu, 16 Apr 2020 12:14:29 -0400 Received: from pps.filterd (m0046660.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGDTqs026413; Thu, 16 Apr 2020 18:14:26 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=eeai/sSDA7yw0YAME0STQXmQf2U/BhDMnF4JiuPgFGA=; b=bcnSKedPRhpuXMGraK7fOequ647brxc0twauwXsfPDLuUr6ADcgmdS7LFCYJk99eDQhL Y7WeZi/RWbBzeNmcen8C0lAJFOFIuMqlzOyCKtPbWbHt1iFbZxChtOJDYbmhBFIooe3m zBTaagj7COUYEBoPbnfRye7vRjLPa6XYdFyDpLILZqknErg994I4hh4gvw/bhZLbvde3 wfSWzvQsFBJb8W1+MLdAOWcUJORX4xyohu5huMFlY4ikRAdHXPHE/raRq/3iCE/Z8xKV oL2LoTanrdBVCHbu2GhhI2T0TeTwRC+J/ucDp5Fuw/bED3/8/upTkr3Z/db01svb9Scs zA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn8s3knd-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:26 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id B56FC10002A; Thu, 16 Apr 2020 18:14:25 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id AA3AD2B2D2A; Thu, 16 Apr 2020 18:14:25 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:25 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 13/18] remoteproc: Add memory default allocator helper Date: Thu, 16 Apr 2020 18:13:26 +0200 Message-ID: <20200416161331.7606-14-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG1NODE1.st.com (10.75.127.1) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add a default basic allocator based on ioremap, to allocate carveout memories. These functions can be used by platforms that do not need specific management of the memory region (no MPU, no IOMMU, ...) Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 50 ++++++++++++++++++++++++ drivers/remoteproc/remoteproc_internal.h | 2 + 2 files changed, 52 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 9238aa292644..f9d04e59081c 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -220,6 +220,56 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, int len) } EXPORT_SYMBOL(rproc_da_to_va); +/** + * rproc_default_mem_alloc() - Simple mmap of the memory + * @rproc: handle of a remote processor + * @mem: memory entry descriptor + * + * Memory allocator for basic remote processors that do not need to manage + * specific memory allocation ( no MPU; no IOMMU, ....). In this case the + * memory is just mapped in in kernel space. + * + * Return: 0 on success else error + */ +int rproc_default_mem_alloc(struct rproc *rproc, struct rproc_mem_entry *mem) +{ + struct device *dev = rproc->dev.parent; + void *va; + + dev_dbg(dev, "map memory: %pa+%x\n", &mem->dma, mem->len); + va = ioremap_wc(mem->dma, mem->len); + if (IS_ERR_OR_NULL(va)) { + dev_err(dev, "Unable to map memory region: %pa+%x\n", + &mem->dma, mem->len); + return -ENOMEM; + } + + /* Update memory entry va */ + mem->va = va; + + return 0; +} +EXPORT_SYMBOL(rproc_default_mem_alloc); + +/** + * rproc_default_mem_release() - release of the mmaped memory + * @rproc: handle of a remote processor + * @mem: memory entry descriptor + * + * Memory release for basic remote processors allocated by + * @rproc_default_mem_alloc + * + * Return: 0 on success else error + */ +int rproc_default_mem_release(struct rproc *rproc, struct rproc_mem_entry *mem) +{ + dev_dbg(rproc->dev.parent, "unmap memory: %pa\n", &mem->dma); + iounmap(mem->va); + + return 0; +} +EXPORT_SYMBOL(rproc_default_mem_release); + /** * rproc_find_carveout_by_name() - lookup the carveout region by a name * @rproc: handle of a remote processor diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 5139cca646ca..608aeea564b4 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -65,6 +65,8 @@ int rproc_elf_load_segments(struct rproc *rproc, const struct firmware *fw); int rproc_elf_load_rsc_table(struct rproc *rproc, const struct firmware *fw); struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, const struct firmware *fw); +int rproc_default_mem_alloc(struct rproc *rproc, struct rproc_mem_entry *mem); +int rproc_default_mem_release(struct rproc *rproc, struct rproc_mem_entry *mem); struct rproc_mem_entry * rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); int rproc_check_carveout_da(struct rproc *rproc, struct rproc_mem_entry *mem, From patchwork Thu Apr 16 16:13:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493405 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9727A14B4 for ; Thu, 16 Apr 2020 16:14:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7FB2E22243 for ; Thu, 16 Apr 2020 16:14:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="cGpXFzqA" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2442845AbgDPQOf (ORCPT ); Thu, 16 Apr 2020 12:14:35 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:61090 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2439167AbgDPQOd (ORCPT ); Thu, 16 Apr 2020 12:14:33 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGDE3h005331; Thu, 16 Apr 2020 18:14:29 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=VGuKiENXB4g+nYignzR0Sc0mT76eLrYMZJujuuwAYk4=; b=cGpXFzqALuH/em3ROP3/sU2rUi2hfvi7KYTKvUWHLHRKD3TMfG6SFw8pVa+fSEXy4EKj 3BqqcqARJ+5CmK5K9+uqpQB7eTwewNMfY1rNkZwCltkUCEO7t8DTzK4H3Qcso+GRkfCK FKK1AcNK6PCfJi14BggVr7IZ+EfAFBss2Daq3YJbiIVd/ElsGoJbV/Y+cM4+AM8aHO13 hB68f9qN4zRkqT9cxBtm7WeNGp3vx6fZl+Sp465fqBvi+io1/fMCUOBKInm3T4NUakoO Fuqk0XKCka/fsWhic1AirP2uS73O+3O+FmoQAtcHFxrxnXRyOuxRRNhL9GjzIALz9SHo jQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn6t3ndb-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:29 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id DB503100034; Thu, 16 Apr 2020 18:14:28 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id D00AD2B2D2A; Thu, 16 Apr 2020 18:14:28 +0200 (CEST) Received: from localhost (10.75.127.44) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:28 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 14/18] remoteproc: Add pa to da translation API Date: Thu, 16 Apr 2020 18:13:27 +0200 Message-ID: <20200416161331.7606-15-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.44] X-ClientProxiedBy: SFHDAG5NODE3.st.com (10.75.127.15) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add remote proc API to allow IPC client to translate address from local to device paradigm. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 24 ++++++++++++++++++++++++ include/linux/remoteproc.h | 4 ++++ 2 files changed, 28 insertions(+) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index f9d04e59081c..72fb97f28048 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1939,6 +1939,30 @@ int rproc_add(struct rproc *rproc) } EXPORT_SYMBOL(rproc_add); +/** + * rproc_pa_to_da() - memory translation from local physical address to + * remote device address + * @rproc: the remote processor handle to register + * @pa: local physical address + * @da: remote device address + * + * Return the device address associated to the physical address + * The translation is delegated to the platform driver if the ops is + * implemented. By default this function returns the physical address. + * + * Returns 0 on success and an appropriate error code otherwise. + */ +int rproc_pa_to_da(struct rproc *rproc, phys_addr_t pa, u64 *da) +{ + if (!rproc->ops->pa_to_da) { + *da = pa; + return 0; + } + + return rproc->ops->pa_to_da(rproc, pa, da); +} +EXPORT_SYMBOL(rproc_pa_to_da); + /** * rproc_type_release() - release a remote processor instance * @dev: the rproc's device diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index d7235f7356e2..7b8a6c3ef519 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -359,6 +359,7 @@ enum rsc_handling_status { * @stop: power off the device * @kick: kick a virtqueue (virtqueue id given as a parameter) * @da_to_va: optional platform hook to perform address translations + * @pa_to_da: optional platform hook to perform address translations * @parse_fw: parse firmware to extract information (e.g. resource table) * @handle_rsc: optional platform hook to handle vendor resources. Should return * RSC_HANDLED if resource was handled, RSC_IGNORED if not handled and a @@ -375,6 +376,7 @@ struct rproc_ops { int (*stop)(struct rproc *rproc); void (*kick)(struct rproc *rproc, int vqid); void * (*da_to_va)(struct rproc *rproc, u64 da, int len); + int (*pa_to_da)(struct rproc *rproc, phys_addr_t pa, u64 *da); int (*parse_fw)(struct rproc *rproc, const struct firmware *fw); int (*handle_rsc)(struct rproc *rproc, u32 rsc_type, void *rsc, int offset, int avail); @@ -618,6 +620,8 @@ struct rproc_mem_entry * rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, int len, u32 da, const char *name, ...); +int rproc_pa_to_da(struct rproc *rproc, phys_addr_t pa, u64 *da); + int rproc_boot(struct rproc *rproc); void rproc_shutdown(struct rproc *rproc); void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type); From patchwork Thu Apr 16 16:13:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493427 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F0D476CA for ; Thu, 16 Apr 2020 16:15:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D8DC420771 for ; Thu, 16 Apr 2020 16:15:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="SoBzXXW/" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2502209AbgDPQPR (ORCPT ); Thu, 16 Apr 2020 12:15:17 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:46915 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2440769AbgDPQOe (ORCPT ); Thu, 16 Apr 2020 12:14:34 -0400 Received: from pps.filterd (m0046037.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGCFEW010375; Thu, 16 Apr 2020 18:14:30 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=vcBb3r+viNdyKV64k5Eo4jYHRVkTS6JjhvXLvx/2TH8=; b=SoBzXXW/u/aE2SWP3JwtzkUOQ+sPDRadWKLF9Gz5UhHA4quSzVHdetdyKoeHnUarJVdQ peJEEcO32DQ9TwMqgC7hHYB7NIe4fUpu/E6jJiGfzBQvefesaVG9CJmY6tsHdlf9wePv l9L+P4LLpZZlWKpOmuU/tc7sja6caj1xmrd6RZxktms6ZVaX6v7TNTL9mUAIVpQ/vU6T vJiMj8ZSGwXK9fIvIr2EhUyEYrREIDNFTDwD/+ng0u4HaKmg9EQrizq4UL9bpUn5hXn2 y/st/+DLF8CmmS0G9uzQFg67yAV1nrl82rjz1GFrVPisLsAMJEF9j7GlvodnrVJZiwEQ Aw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn94kmx3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:30 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 37B8010002A; Thu, 16 Apr 2020 18:14:30 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 206082B2D2C; Thu, 16 Apr 2020 18:14:30 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:29 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 15/18] remoteproc: associate memory entry to a device Date: Thu, 16 Apr 2020 18:13:28 +0200 Message-ID: <20200416161331.7606-16-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG8NODE2.st.com (10.75.127.23) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org mem entry could be registered at different levels, platform driver or virtio device itself. Add device information in rproc_mem_entry struct to retrieve a memory region registered by another device. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_core.c | 2 ++ drivers/remoteproc/remoteproc_virtio.c | 2 +- include/linux/remoteproc.h | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 72fb97f28048..e72d681033d3 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -892,6 +892,7 @@ rproc_mem_entry_init(struct device *dev, if (!mem) return mem; + mem->dev = dev; mem->va = va; mem->dma = dma; mem->da = da; @@ -932,6 +933,7 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, int len, if (!mem) return mem; + mem->dev = dev; mem->da = da; mem->len = len; mem->rsc_offset = FW_RSC_ADDR_ANY; diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index 4634cd63d547..0fd938afd146 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -439,7 +439,7 @@ static int rproc_vitio_start(struct rproc_subdev *subdev) phys_addr_t pa; if (mem->of_resm_idx != -1) { - struct device_node *np = rproc->dev.parent->of_node; + struct device_node *np = mem->dev->of_node; /* Associate reserved memory to vdev device */ ret = of_reserved_mem_device_init_by_idx(dev, np, diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h index 7b8a6c3ef519..36abc9bc4def 100644 --- a/include/linux/remoteproc.h +++ b/include/linux/remoteproc.h @@ -331,6 +331,7 @@ struct rproc_mem_entry { dma_addr_t dma; int len; u32 da; + struct device *dev; void *priv; char name[32]; struct list_head node; From patchwork Thu Apr 16 16:13:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493423 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C2EAD1392 for ; Thu, 16 Apr 2020 16:15:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A73EF20771 for ; Thu, 16 Apr 2020 16:15:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="ctuniGyV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2896072AbgDPQPS (ORCPT ); Thu, 16 Apr 2020 12:15:18 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:45362 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2441904AbgDPQOe (ORCPT ); Thu, 16 Apr 2020 12:14:34 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGBred014920; Thu, 16 Apr 2020 18:14:31 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=pa2XKTGGGIC2Vn05mbBcixvwehzmq3xfK9D+yvR8aDA=; b=ctuniGyVBb/CSSktXIwtrf4cIzhh/SE4J02vC1c/q9ms5aJ6vP7UBwNolnOT8dq/bEMZ pSY2sXRCQPSANeKInNiuFO+kyKz5n/cMlNQPIMWW2l2pxmMeGpBkvBwzv2fCra9LtuUU WXWzJwMiWg1PgQFX9/l9o7SCBsZkHQkq1G7IME90wqf1xuCH2ZEBn64WcAea0XBa7IhK DPu1kd/TpeUkowvpdBz1sDwZZSIe0eKSCA5Y1XWB6nARkLxbXZsGVEGhK3ZXtKc5mTru QkyeiztmT1jTLfNGeQ7kzYQ7/FlL5ohT/DZ3D+RThuxhEr5lb33AOneELH59ROkcE2or bA== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn75umfc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:31 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 4D23610002A; Thu, 16 Apr 2020 18:14:31 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 40D832B2D2C; Thu, 16 Apr 2020 18:14:31 +0200 (CEST) Received: from localhost (10.75.127.47) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:30 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 16/18] remoteproc: Parse virtio node for memory region Date: Thu, 16 Apr 2020 18:13:29 +0200 Message-ID: <20200416161331.7606-17-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG5NODE1.st.com (10.75.127.13) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add the possibility to declare memories associated to the virtio paltform in the device tree. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_virtio.c | 77 +++++++++++++++++++++++--- 1 file changed, 68 insertions(+), 9 deletions(-) diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index 0fd938afd146..3302ee7d6c14 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -610,12 +610,71 @@ static const struct component_ops rproc_virtio_ops = { .unbind = rproc_virtio_unbind, }; +static int rproc_virtio_of_parse(struct device *dev, struct rproc_vdev *rvdev) +{ + struct device_node *np = dev->of_node; + struct rproc *rproc = rvdev->rproc; + struct of_phandle_iterator it; + struct rproc_mem_entry *mem; + struct reserved_mem *rmem; + char name[32]; + u64 da; + int index = 0; + + /* the reg is used to specify the vdev index */ + if (of_property_read_u32(np, "reg", &rvdev->index)) + return -EINVAL; + /* Register associated reserved memory regions */ + of_phandle_iterator_init(&it, np, "memory-region", NULL, 0); + + while (of_phandle_iterator_next(&it) == 0) { + rmem = of_reserved_mem_lookup(it.node); + if (!rmem) { + dev_err(dev, "unable to acquire memory-region\n"); + return -EINVAL; + } + + if (rproc_pa_to_da(rproc, rmem->base, &da) < 0) { + dev_err(dev, "memory region not valid %pa\n", + &rmem->base); + return -EINVAL; + } + + snprintf(name, sizeof(name), "vdev%dbuffer", rvdev->index); + if (strcmp(it.node->name, name)) { + /* Register memory region */ + mem = rproc_mem_entry_init(dev, NULL, + (dma_addr_t)rmem->base, + rmem->size, da, + rproc_default_mem_alloc, + rproc_default_mem_release, + it.node->name); + + if (mem) + rproc_coredump_add_segment(rproc, da, + rmem->size); + } else { + /* Register reserved memory for vdev buffer alloc */ + mem = rproc_of_resm_mem_entry_init(dev, index, + rmem->size, + rmem->base, + it.node->name); + } + + if (!mem) + return -ENOMEM; + + rproc_add_carveout(rproc, mem); + index++; + } + + return 0; +} + static int rproc_virtio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; - struct device_node *np = dev->of_node; struct rproc_vdev *rvdev; - struct rproc *rproc; int ret; rvdev = devm_kzalloc(&pdev->dev, sizeof(*rvdev), GFP_KERNEL); @@ -627,18 +686,16 @@ static int rproc_virtio_probe(struct platform_device *pdev) * The platform device is declared in the device tree * retrieve rproc struct through the remoteproc platform */ - rproc = rproc_get_by_node(dev->parent->of_node); + rvdev->rproc = rproc_get_by_node(dev->parent->of_node); - /* the reg is used to specify the vdev index */ - if (of_property_read_u32(np, "reg", &rvdev->index)) - return -EINVAL; + ret = rproc_virtio_of_parse(dev, rvdev); } else { struct rproc_vdev_data *vdev_data = pdev->dev.platform_data; if (!vdev_data) return -EINVAL; - rproc = container_of(dev->parent, struct rproc, dev); + rvdev->rproc = container_of(dev->parent, struct rproc, dev); rvdev->rsc_offset = vdev_data->rsc_offset; rvdev->rsc = vdev_data->rsc; @@ -649,8 +706,10 @@ static int rproc_virtio_probe(struct platform_device *pdev) if (ret) return ret; } + if (ret) + return ret; + rvdev->pdev = pdev; - rvdev->rproc = rproc; platform_set_drvdata(pdev, rvdev); @@ -658,7 +717,7 @@ static int rproc_virtio_probe(struct platform_device *pdev) if (ret) return ret; - rproc_register_rvdev(rproc, rvdev); + rproc_register_rvdev(rvdev->rproc, rvdev); return 0; } From patchwork Thu Apr 16 16:13:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493419 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 711211392 for ; Thu, 16 Apr 2020 16:15:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 59B6022240 for ; Thu, 16 Apr 2020 16:15:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="m4npXIVv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2636648AbgDPQOi (ORCPT ); Thu, 16 Apr 2020 12:14:38 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:45368 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S2442785AbgDPQOg (ORCPT ); Thu, 16 Apr 2020 12:14:36 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGBqO0014914; Thu, 16 Apr 2020 18:14:32 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=i7rw/RtCj8mfGz7yhHkYABF7/EhksBCp43vLFplujnY=; b=m4npXIVvf17hNsHFXkA/EiYKrvP9Wbk7Mift9UB6b2O2h1/3cHsaGTXmB3H3FfhQ+mqa G3Q0aWuuCvF4hBGzb7VHrG3TOHTdACHf0mfkra4XKtJB3ghfOYpiTtOr1zb1s0R2ywyh hBM/4YkoQTfV+Kt9/rtiufieh9CVm5bSfKwHogb0/fnBipy2rI4chkl7BTP8P+rbq+2w bX42EDitSKu16ku0oywvqTNTKZgFUKGdhOPVAMcgb1aJu2FlUqeHq7fmZn5FzAycdl5e OvzZ65uWBZAuS88A3lIuXA4V5w/Mf1UARxSY1njoX5BZRRsVnZEmbBiBnTYMiRINb1lA Uw== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn75umff-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:32 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 79BAF10002A; Thu, 16 Apr 2020 18:14:32 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 6EF222B2D2C; Thu, 16 Apr 2020 18:14:32 +0200 (CEST) Received: from localhost (10.75.127.45) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:32 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 17/18] remoteproc: stm32: Add the pa to da ops. Date: Thu, 16 Apr 2020 18:13:30 +0200 Message-ID: <20200416161331.7606-18-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.45] X-ClientProxiedBy: SFHDAG7NODE3.st.com (10.75.127.21) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add pa_to_da ops to translate the physical address into device address. Signed-off-by: Arnaud Pouliquen Change-Id: Ie1aa26769635d6d4c4581486700c4061f0f99ff1 --- drivers/remoteproc/stm32_rproc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index a18f88044111..1dd4c0f9c423 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -507,6 +507,7 @@ static struct rproc_ops st_rproc_ops = { .find_loaded_rsc_table = rproc_elf_find_loaded_rsc_table, .sanity_check = rproc_elf_sanity_check, .get_boot_addr = rproc_elf_get_boot_addr, + .pa_to_da = stm32_rproc_pa_to_da, }; static const struct of_device_id stm32_rproc_match[] = { From patchwork Thu Apr 16 16:13:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arnaud POULIQUEN X-Patchwork-Id: 11493417 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2491F6CA for ; Thu, 16 Apr 2020 16:15:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0AF992223E for ; Thu, 16 Apr 2020 16:15:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=st.com header.i=@st.com header.b="uDEgwfep" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2636685AbgDPQOq (ORCPT ); Thu, 16 Apr 2020 12:14:46 -0400 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:17074 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2442867AbgDPQOj (ORCPT ); Thu, 16 Apr 2020 12:14:39 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 03GGDEcF005340; Thu, 16 Apr 2020 18:14:34 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=STMicroelectronics; bh=BECJGiUvhGzClMdYvElFVDvpweq8Gq2dCCcfEt+39VM=; b=uDEgwfep1IxcMNE3qQYLz7nmAf7hRsnCEl2UqP0aBHrsslBvDeBlhzBOaowRWi2eejG1 Lii/Ye/5Rf7muXqnQhi0wIqPuuESWBYCvhLSFPf8KXM2106qEK0LGVPHgoZ36z/0RSwj PVAtuZ8whFjfSVrOtnyR8HQYSe/BspgNeElg/cVonS3EiGMLwPg/BgMO1MUWvrb5xD+G eIRWiw4Lz39TG3GZmXJfynyaUuEcRngu0GmHyYnj/fIQE7ML+Dd8F5mizwly3n2K0yfQ C3JlNQnV3T78RhYb9dI2YWQ2SfWfW6kBMIXiy6cTbgk7BhYJFog4sSwvvmxB4euekuzF 0Q== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 30dn6t3nds-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 16 Apr 2020 18:14:34 +0200 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2952210002A; Thu, 16 Apr 2020 18:14:34 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 1E6B22B2D2C; Thu, 16 Apr 2020 18:14:34 +0200 (CEST) Received: from localhost (10.75.127.46) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 16 Apr 2020 18:14:33 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Subject: [RFC 18/18] ARM: dts: stm32: Declare a virtio device Date: Thu, 16 Apr 2020 18:13:31 +0200 Message-ID: <20200416161331.7606-19-arnaud.pouliquen@st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200416161331.7606-1-arnaud.pouliquen@st.com> References: <20200416161331.7606-1-arnaud.pouliquen@st.com> MIME-Version: 1.0 X-Originating-IP: [10.75.127.46] X-ClientProxiedBy: SFHDAG4NODE2.st.com (10.75.127.11) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.138,18.0.676 definitions=2020-04-16_06:2020-04-14,2020-04-16 signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Declare a virtio device as sub device of the stm32 remote proc Signed-off-by: Arnaud Pouliquen --- arch/arm/boot/dts/stm32mp15xx-dkx.dtsi | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/arch/arm/boot/dts/stm32mp15xx-dkx.dtsi b/arch/arm/boot/dts/stm32mp15xx-dkx.dtsi index f6672e87aef3..2bb16c860c82 100644 --- a/arch/arm/boot/dts/stm32mp15xx-dkx.dtsi +++ b/arch/arm/boot/dts/stm32mp15xx-dkx.dtsi @@ -414,6 +414,16 @@ interrupt-parent = <&exti>; interrupts = <68 1>; status = "okay"; + + #address-cells = <1>; + #size-cells = <0>; + + vdev@0 { + memory-region = <&vdev0vring0>, <&vdev0vring1>, <&vdev0buffer>; + compatible = "rproc-virtio"; + reg = <0>; + status = "okay"; + }; }; &pwr_regulators {