Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp946739pxb; Thu, 4 Feb 2021 00:48:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJwekP7FCuviBxZ6nOTghjnDkfo8MqHk6O+z7LtYSvC+fON8fyIlxz65JIz81UK62kWZ/EI0 X-Received: by 2002:a05:6402:34c3:: with SMTP id w3mr7095358edc.3.1612428530430; Thu, 04 Feb 2021 00:48:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612428530; cv=none; d=google.com; s=arc-20160816; b=lKzgN47IBSLcrp234TA6Ne152iJmg7tCTtw2OrsyfhOcrQOl/QVV313X3XfVhwb5uq pg8NzkLCVGP8Eg0FUkri8Ke8NEqOJn73O8YbX9UH7lBdIJtWmd0oNZX+og5VlgOSPhtW Xiw7udWmsAmCPIGiuUzKEkgnakcWkUxxgAbwCBVmmAN5VSBE313YLN+99PficNwu5/pe 6BiEyK56CugLi4LDFvQ4Ouwa3exqa/7FzYc3uEBhM0xtl/zlIFjgjRdIQETMEdnjB166 N/IU7MWxYIaL8HxH7bDkd4oLHdRrChDC6AkgMPGjqg1X2kNUxzIafKiGMFG8icg0sQML xM3g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=hs5ntI48NvW7gaVrpRXbUA/P/bQnTWX7GlNcZaiJfvw=; b=hw/c1TMmrDH6BXUup6o6R0qXDsr6s3EnxgYb6MFG7vNxqN7bGs3pM+mOatjeaCpObT o4yInt6vYVxGatM+zbGF6qHFByUS1D2NYzxTFYgXuch5Rzm9HI0YpF+44lDRO68K3guU qSMerhfJ/DOUu4vRc8rtiG9Qa8dz9lwZggU4E7S6+mBBEjcho2V3KDwWgsnkIGzMY6iI cJE2MaZ0MJ2XqQRNNz4czZC8Ia6QtUP/ZVXUU8rVufy8LZpPlTR+Ra78e5nyG2MSGwua fO6Kk+GTXcjs2tbPvWYOPaWrv3VxqHI0wSKKPJL6tyWpYvtbclOIY0UNeCSfg3utPDl4 RxHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=ElXJ7Onz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l13si3618333edj.219.2021.02.04.00.48.26; Thu, 04 Feb 2021 00:48:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=ElXJ7Onz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=foss.st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235142AbhBDIrO (ORCPT + 99 others); Thu, 4 Feb 2021 03:47:14 -0500 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:2728 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235096AbhBDIrG (ORCPT ); Thu, 4 Feb 2021 03:47:06 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.43/8.16.0.43) with SMTP id 1148ftTc005300; Thu, 4 Feb 2021 09:46:19 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=foss.st.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-type; s=selector1; bh=hs5ntI48NvW7gaVrpRXbUA/P/bQnTWX7GlNcZaiJfvw=; b=ElXJ7OnzSNT0VEt17IApfGb/8FZbgZIu/ZfTV9xGkcRRIEx1YWZqewXaVqzD3Twl6112 lEbfqkDxNbFLvvx026ZN1GOsZ5LBE1giBEg1CTUHyIFtSPRpiFN/rX5RRmDm6BRQKFFc yvPEkQDUQr9fnW+b4WWufB8sbTDHcwu4fcPxPhxFOAsOJNRsXePq5nWqKza4omgvTOCi dLOduMwofemcFMIOtIPQ0CIXXmde7yiz79Ary8vucj/rUaeeKaCCHkJn9Ag7SB/7xhEe wiUzg8uccT9AKB5DIXPvWtvUuz49jhR/TzSbWHh7C7uoSLUQBqKqYJRmsT19T/b5Qg8M aQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 36d0fs5xst-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 04 Feb 2021 09:46:19 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 57EF510002A; Thu, 4 Feb 2021 09:46:19 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag2node3.st.com [10.75.127.6]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id 4905722AE4D; Thu, 4 Feb 2021 09:46:19 +0100 (CET) Received: from localhost (10.75.127.50) by SFHDAG2NODE3.st.com (10.75.127.6) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Thu, 4 Feb 2021 09:46:18 +0100 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier , Andy Gross CC: , , , , Subject: [PATCH v3 07/15] rpmsg: virtio: probe the rpmsg_ctrl device Date: Thu, 4 Feb 2021 09:45:26 +0100 Message-ID: <20210204084534.10516-8-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210204084534.10516-1-arnaud.pouliquen@foss.st.com> References: <20210204084534.10516-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.50] X-ClientProxiedBy: SFHDAG1NODE2.st.com (10.75.127.2) To SFHDAG2NODE3.st.com (10.75.127.6) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.369,18.0.737 definitions=2021-02-04_03:2021-02-04,2021-02-04 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Instantiate the rpmsg_ioctl device on virtio RPMsg bus creation. This provides the possibility to expose the RPMSG_CREATE_EPT_IOCTL to create RPMsg chdev endpoint. Signed-off-by: Arnaud Pouliquen --- V3: Fix compilation issue Reported-by: kernel test robot Reported-by: Dan Carpenter warnings: drivers/rpmsg/virtio_rpmsg_bus.c:978 rpmsg_probe() error: uninitialized symbol 'vch'. drivers/rpmsg/virtio_rpmsg_bus.c:979 rpmsg_probe() error: uninitialized symbol 'rpdev_ctrl'. --- drivers/rpmsg/virtio_rpmsg_bus.c | 37 +++++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index e87d4cf926eb..5143fdeca306 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -813,6 +813,35 @@ static void rpmsg_xmit_done(struct virtqueue *svq) wake_up_interruptible(&vrp->sendq); } +static struct rpmsg_device *rpmsg_virtio_add_char_dev(struct virtio_device *vdev) +{ + struct virtproc_info *vrp = vdev->priv; + struct virtio_rpmsg_channel *vch; + struct rpmsg_device *rpdev_ctrl; + int err = 0; + + vch = kzalloc(sizeof(*vch), GFP_KERNEL); + if (!vch) + return ERR_PTR(-ENOMEM); + + /* Link the channel to the vrp */ + vch->vrp = vrp; + + /* Assign public information to the rpmsg_device */ + rpdev_ctrl = &vch->rpdev; + rpdev_ctrl->ops = &virtio_rpmsg_ops; + + rpdev_ctrl->dev.parent = &vrp->vdev->dev; + rpdev_ctrl->dev.release = virtio_rpmsg_release_device; + rpdev_ctrl->little_endian = virtio_is_little_endian(vrp->vdev); + + err = rpmsg_ctrl_register_device(rpdev_ctrl); + if (err) + return ERR_PTR(err); + + return rpdev_ctrl; +} + static int rpmsg_probe(struct virtio_device *vdev) { vq_callback_t *vq_cbs[] = { rpmsg_recv_done, rpmsg_xmit_done }; @@ -820,7 +849,7 @@ static int rpmsg_probe(struct virtio_device *vdev) struct virtqueue *vqs[2]; struct virtproc_info *vrp; struct virtio_rpmsg_channel *vch; - struct rpmsg_device *rpdev_ns; + struct rpmsg_device *rpdev_ns = NULL, *rpdev_ctrl = NULL; void *bufs_va; int err = 0, i; size_t total_buf_space; @@ -918,6 +947,11 @@ static int rpmsg_probe(struct virtio_device *vdev) goto free_coherent; } + rpdev_ctrl = rpmsg_virtio_add_char_dev(vdev); + if (IS_ERR(rpdev_ctrl)) { + err = PTR_ERR(rpdev_ctrl); + goto free_coherent; + } /* * Prepare to kick but don't notify yet - we can't do this before * device is ready. @@ -941,6 +975,7 @@ static int rpmsg_probe(struct virtio_device *vdev) free_coherent: kfree(vch); + kfree(to_virtio_rpmsg_channel(rpdev_ctrl)); dma_free_coherent(vdev->dev.parent, total_buf_space, bufs_va, vrp->bufs_dma); vqs_del: -- 2.17.1