Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1196869pxb; Fri, 1 Oct 2021 05:46:22 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyejbyAZSdKmIGQJxo3zkEJXnbJ9uSxUAfLztAlszpHSnG3/66CkZpH5A4f/29dYVdyXuHN X-Received: by 2002:a17:906:7848:: with SMTP id p8mr5976410ejm.212.1633092381800; Fri, 01 Oct 2021 05:46:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633092381; cv=none; d=google.com; s=arc-20160816; b=VxCkOTof6NmeYhdGzffZBJAGslNjxE7Eb5MQN6dMHDY0SrRIjTATQ9WGkuc/o3NbJo hqbs8CDj+IILjgNEjt3E3lH+Of0XM8lfSSPO8aQ+feF6hZ0Rej8g5TOQIcMP3IyOB7vZ KpREacPKcqqTv2NLYujJm5Eksk9fz31HqsOGUPE1G4+i6jlhA3WUcAnsCWeORoxctz29 JBExyNKZprCC6NS9c2lurM4pVFP8uVDyqnjjFO70WqQ5tXTgcwUUAv7mHVTE1gZQzZK9 TIfysRkOEJGSbcZSBcTr3JHzPygI10cnZ45hKESEGtCf+0bRIebQs1xXhmWMgU7IiuL7 PtbQ== 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=m+VP0hcuRq/Ykjd7M5pZ16VJNgKkpYObCuedev0S0vE=; b=bXq2crorpsEGWCXljuPAJhX6nSvy+M9dEnt2GpXC8kT9lEhUa0eNBvoi0xyQvX6qP7 6nAGmzBlrZ2Nwc2QggO/IBuH5Nd3vYH8DguWMCWsXIBiJDHnI5ZstN61OKCaVhiY2CEp 3DcMK7WuIqKyTaEkbrppJByprUKYY20WIO0hfjtPvRt9HVD4IryUJ2DnMIwm1IwXh/Pc 3fE8OcsnN3hRKJFX2byhVhxvbdifHOj5QzL5ZcNH06+HMTMXUNvO4Fkq3iDZMKD53j5B AdvQNizQ1xcDbrTWdiYnNZ4S3aFxA6vMn2zXlX0LtkTvz7p83OFwVdLHLaiVDJAZEVul D65g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@foss.st.com header.s=selector1 header.b=qWl2iJ8v; 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 s9si6773313edh.633.2021.10.01.05.45.50; Fri, 01 Oct 2021 05:46:21 -0700 (PDT) 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=qWl2iJ8v; 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 S1353529AbhJAKQj (ORCPT + 99 others); Fri, 1 Oct 2021 06:16:39 -0400 Received: from mx07-00178001.pphosted.com ([185.132.182.106]:47736 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1353420AbhJAKQi (ORCPT ); Fri, 1 Oct 2021 06:16:38 -0400 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.1.2/8.16.1.2) with SMTP id 1918I0b7030519; Fri, 1 Oct 2021 12:12:49 +0200 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=m+VP0hcuRq/Ykjd7M5pZ16VJNgKkpYObCuedev0S0vE=; b=qWl2iJ8vSTb0Z+8PHE+REEm9cvgbBe3/p/WWgJGy8moxCNOzwlUkGyIhQ1fKi4GE2/Vp vv2irS4sFqBbuPgcs3IuMphxZI350fhrX+MTSTg92TzbXSRSbSYyJtYhgAFjAD0HTcZE k9aUN41vRPJ6AVp84auZA5YLPOa/aSnpoMIisHo0G5GQGHzEEeAKJh1PvjBrxP+DK9s4 /uv25qTyS4wbKqeaFzuSra4xIqqNJFt0211HN0BPa4nS+VT80EaF4ug2lu+Gui5T8KFb 9AvBUAn76xHEQBY99i6oKGarW2I85cca97iuqrE8xxzZU9yJytJibyenxU34Mq3ukr46 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 3bds9njb56-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 01 Oct 2021 12:12:49 +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 CC727100039; Fri, 1 Oct 2021 12:12:48 +0200 (CEST) Received: from Webmail-eu.st.com (sfhdag2node2.st.com [10.75.127.5]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id C2932226FDD; Fri, 1 Oct 2021 12:12:48 +0200 (CEST) Received: from localhost (10.75.127.48) by SFHDAG2NODE2.st.com (10.75.127.5) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Fri, 1 Oct 2021 12:12:48 +0200 From: Arnaud Pouliquen To: Bjorn Andersson , Ohad Ben-Cohen , Mathieu Poirier CC: , , , Rob Herring , Christoph Hellwig , Stefano Stabellini , Bruce Ashfield , Subject: [RFC PATCH 6/7] remoteproc: virtio: Add helper to create platform device Date: Fri, 1 Oct 2021 12:12:33 +0200 Message-ID: <20211001101234.4247-7-arnaud.pouliquen@foss.st.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20211001101234.4247-1-arnaud.pouliquen@foss.st.com> References: <20211001101234.4247-1-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.75.127.48] X-ClientProxiedBy: SFHDAG2NODE3.st.com (10.75.127.6) To SFHDAG2NODE2.st.com (10.75.127.5) X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.182.1,Aquarius:18.0.790,Hydra:6.0.391,FMLib:17.0.607.475 definitions=2021-10-01_01,2021-09-30_01,2020-04-07_01 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add capability to create platform device for the rproc virtio. This is a step to move forward the management of the rproc virtio as an independent device. Signed-off-by: Arnaud Pouliquen --- drivers/remoteproc/remoteproc_internal.h | 15 ++++++++++ drivers/remoteproc/remoteproc_virtio.c | 36 ++++++++++++++++++++++++ 2 files changed, 51 insertions(+) diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 1b963a8912ed..0bb1b14e5136 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -39,11 +39,26 @@ int rproc_of_parse_firmware(struct device *dev, int index, #if IS_ENABLED(CONFIG_REMOTEPROC_VIRTIO) int rproc_rvdev_add_device(struct rproc_vdev *rvdev); +struct platform_device * +rproc_virtio_register_device(struct rproc *rproc, struct rproc_vdev_data *vdev_data); +void rproc_virtio_unregister_device(struct rproc_vdev *rvdev); irqreturn_t rproc_vq_interrupt(struct rproc *rproc, int vq_id); void rproc_vdev_release(struct kref *ref); #else +static inline struct platform_device * +rproc_virtio_register_device(struct rproc *rproc, struct rproc_vdev_data *vdev_data) +{ + return ERR_PTR(-ENXIO); +} + +static inline void rproc_virtio_unregister_device(struct rproc_vdev *rvdev) +{ + /* This shouldn't be possible */ + WARN_ON(1); +} + int rproc_rvdev_add_device(struct rproc_vdev *rvdev) { /* This shouldn't be possible */ diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c index 9b2ab79e4c4c..7188fb8ce40f 100644 --- a/drivers/remoteproc/remoteproc_virtio.c +++ b/drivers/remoteproc/remoteproc_virtio.c @@ -574,6 +574,42 @@ void rproc_vdev_release(struct kref *ref) rproc_rvdev_remove_device(rvdev); } +/** + * rproc_virtio_register_device() - register a remoteproc virtio device + * @rproc: rproc handle to add the remoteproc virtio device to + * @vdev_data: platform device data + * + * Return: 0 on success, and an appropriate error value otherwise + */ +struct platform_device * +rproc_virtio_register_device(struct rproc *rproc, struct rproc_vdev_data *vdev_data) +{ + struct device *dev = &rproc->dev; + struct platform_device *pdev; + + pdev = platform_device_register_data(dev, "rproc-virtio", vdev_data->index, vdev_data, + sizeof(*vdev_data)); + if (PTR_ERR_OR_ZERO(pdev)) { + dev_err(rproc->dev.parent, + "failed to create rproc-virtio device\n"); + } + + return pdev; +} +EXPORT_SYMBOL(rproc_virtio_register_device); + +/** + * rproc_virtio_unregister_device() - unregister a remoteproc virtio device + * @rvdev: remote proc virtio handle to unregister + * + */ +void rproc_virtio_unregister_device(struct rproc_vdev *rvdev) +{ + if (rvdev->pdev) + platform_device_unregister(rvdev->pdev); +} +EXPORT_SYMBOL(rproc_virtio_unregister_device); + static int rproc_virtio_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; -- 2.17.1