Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp1952319pxb; Fri, 22 Oct 2021 10:44:19 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzczZkNO1/GXqdi4FZkMLLUvQJalTk2QnHivpB8v3ROjoZWhdPgRlBfc7uAuMaz4UIXeCmt X-Received: by 2002:a17:902:c410:b0:13e:cfac:45ad with SMTP id k16-20020a170902c41000b0013ecfac45admr1194495plk.68.1634924659192; Fri, 22 Oct 2021 10:44:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1634924659; cv=none; d=google.com; s=arc-20160816; b=CDyhmAR5VZGGds670mpyskdMabbiX8ObIlD4fKMl55gG6IG8rorBPHMmFAN572O0FQ YTBgMy32YHBGAQc7h6AVBgmfNSTVnn5PxhWrEoGRwf9IllnFEsn0j4ldDlcrOxC2GSA/ a6mrVwueJ/lVrMiV6bbz15YDlcjj9GrTuJxhvtaX/qXXtvPgGhFriYAa+87rlgrV2Jwb 1DnOXx7H7RlLYqMiDu1nNZLB9tfYiEEwOBFZxH9p94xTM+8Z8krxsGab50rUZP07eRgy P97l002/SDNn9fb40+LcapzjKi7CoexDh6Udn2TvGyT+r+0ZwbE/YAbQatJjechnvl6+ YrfQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=9n/cqrzRbqe+8NgRURNa9xyWoP4yHX8hd+RzSNaaxRM=; b=UWt/BpgHS7WpVJfHFZ5zGbBgZurGRWlx5zt27VGzPaU9d3YdrZS3MLy+MlPeF1X0Hk zAbYFdchdRwkcm7IcjlYQKjxhBtrlWtLfUOSlohtoOuqY+qEW17XzBbVurYd22ogT9ev LxriQiTDkmq/IkVr7MOp7IAUPYO7iei+nv3agobl864PV/TACwAYwJlXAeZZTqf7viDk TD/itw/b3Jx2iZlkqDa+tdBwMWz1wydccd8nTq8yWthsta4BS6UdGGumuW2Xp4fBdnSX 74CXtd4cNSy3HOfrftk34I6d4DhVLedwovN+LJyPgwxSA5JT+t+GBnqeVbuGowy0GN9A Loaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nzYbGo7K; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z10si15930973pga.82.2021.10.22.10.44.06; Fri, 22 Oct 2021 10:44:19 -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=@linaro.org header.s=google header.b=nzYbGo7K; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233643AbhJVRpV (ORCPT + 99 others); Fri, 22 Oct 2021 13:45:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42128 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233855AbhJVRpT (ORCPT ); Fri, 22 Oct 2021 13:45:19 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F1E9FC061764 for ; Fri, 22 Oct 2021 10:43:01 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id m26so4301504pff.3 for ; Fri, 22 Oct 2021 10:43:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=9n/cqrzRbqe+8NgRURNa9xyWoP4yHX8hd+RzSNaaxRM=; b=nzYbGo7KXNJ+pz9cuiwU9Et1Mhjpd9qmzBAJPhTz/EY2AyAu+nrL6LRL0mn9i0Y7cY 4WjRzRGmQpIa2RhU8uw/NgsAMyXnlHjd0PLI0TXEN0dDUtkzb8qvOgYoq1vH3uUHgcoe W8oqq8wQ+5Q4ffoKQcKSBv28/YiHcgpzde+/zGV0QVJ55g1wJ9wrO3YsuIF5XRXhaH13 yc01/smZgcUa9KfuDd4ZdhzDWkUt9NHgvGIXROrIZ3satkK04u+s3gsdUTEeM+W/rG68 xneGbKP8fJ5W5Jn0suJ0dAvUx/PGbTzpi/HSM0GAGlodBQXTO4e8XGjYmoFqjsfijV8V uqsg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=9n/cqrzRbqe+8NgRURNa9xyWoP4yHX8hd+RzSNaaxRM=; b=AiBhoAO/Bjn0eeKyQiQU/V4M8XQTKt48CUo4FhlTJfkeCdrZWkdv+Mh6BfPcSBMLTO 3myKokjOsPdheNK3zETDhNGA+FyiK9UuiPwJpwQhkL9S6znD2TToct6UT4tczUG4Z/A7 v70LQliyqwryHLZYTpyosotfG5DzraAuJcQ52yNdwMwZD/bOJaOL9ZOm+YNdKdVQVvRl P5bdAjXlnwGgKZeMPiXjYMJ+xYsYBXklyl3mIr3SgxhBB2NBXpMU0m0vjoRz4/IYAEji nVQ6qNCFlcLHF1TOU/0DkfQbrnvDJOn0vIzR/sRnlJ5yufdj4N9P6gfAcad8ne3xCxff 07xA== X-Gm-Message-State: AOAM533ahDQJq8iM/6CAGWQrfS7cVg8nQxk9J4ctsvojtBEfI48nIXks SVDPWp44lJbMCKiyOmyzX1cyFA== X-Received: by 2002:a63:561a:: with SMTP id k26mr894072pgb.144.1634924581389; Fri, 22 Oct 2021 10:43:01 -0700 (PDT) Received: from p14s (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id b18sm12047386pfl.24.2021.10.22.10.42.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Oct 2021 10:43:00 -0700 (PDT) Date: Fri, 22 Oct 2021 11:42:58 -0600 From: Mathieu Poirier To: Arnaud Pouliquen Cc: Bjorn Andersson , Ohad Ben-Cohen , linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, Rob Herring , Christoph Hellwig , Stefano Stabellini , Bruce Ashfield Subject: Re: [RFC PATCH 5/7] remoteproc: virtio: Create platform device for the remoteproc_virtio Message-ID: <20211022174258.GC3659113@p14s> References: <20211001101234.4247-1-arnaud.pouliquen@foss.st.com> <20211001101234.4247-6-arnaud.pouliquen@foss.st.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211001101234.4247-6-arnaud.pouliquen@foss.st.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Oct 01, 2021 at 12:12:32PM +0200, Arnaud Pouliquen wrote: > Define a platform device for the remoteproc virtio to prepare the > management of the remoteproc virtio as a platform device. > > The platform device allows to pass rproc_vdev_data platform data to > specify properties that are stored in the rproc_vdev structure. > > Such approach will allow to preserve legacy remoteproc virtio device > creation but also to probe the device using device tree mechanism. > > Signed-off-by: Arnaud Pouliquen > --- > drivers/remoteproc/remoteproc_internal.h | 6 +++ > drivers/remoteproc/remoteproc_virtio.c | 65 ++++++++++++++++++++++++ > include/linux/remoteproc.h | 2 + > 3 files changed, 73 insertions(+) > > diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h > index 4ce012c353c0..1b963a8912ed 100644 > --- a/drivers/remoteproc/remoteproc_internal.h > +++ b/drivers/remoteproc/remoteproc_internal.h > @@ -24,6 +24,12 @@ struct rproc_debug_trace { > struct rproc_mem_entry trace_mem; > }; > > +struct rproc_vdev_data { s/rproc_vdev_data/rproc_vdev_pdata > + u32 rsc_offset; > + unsigned int id; > + unsigned int index; > +}; > + > /* from remoteproc_core.c */ > void rproc_release(struct kref *kref); > int rproc_of_parse_firmware(struct device *dev, int index, > diff --git a/drivers/remoteproc/remoteproc_virtio.c b/drivers/remoteproc/remoteproc_virtio.c > index c9eecd2f9fb2..9b2ab79e4c4c 100644 > --- a/drivers/remoteproc/remoteproc_virtio.c > +++ b/drivers/remoteproc/remoteproc_virtio.c > @@ -4,6 +4,7 @@ > * > * Copyright (C) 2011 Texas Instruments, Inc. > * Copyright (C) 2011 Google, Inc. > + * Copyright (C) 2021 STMicroelectronics > * > * Ohad Ben-Cohen > * Brian Swetland > @@ -13,6 +14,7 @@ > #include > #include > #include > +#include > #include > #include > #include > @@ -571,3 +573,66 @@ void rproc_vdev_release(struct kref *ref) > > rproc_rvdev_remove_device(rvdev); > } > + > +static int rproc_virtio_probe(struct platform_device *pdev) > +{ > + struct device *dev = &pdev->dev; > + struct rproc_vdev_data *vdev_data = dev->platform_data; > + struct rproc_vdev *rvdev; > + struct rproc *rproc; > + > + if (!vdev_data) > + return -EINVAL; > + > + rvdev = devm_kzalloc(dev, sizeof(*rvdev), GFP_KERNEL); > + if (!rvdev) > + return -ENOMEM; > + > + rproc = container_of(dev->parent, struct rproc, dev); > + > + rvdev->rsc_offset = vdev_data->rsc_offset; > + rvdev->id = vdev_data->id; > + rvdev->index = vdev_data->index; > + > + rvdev->pdev = pdev; > + rvdev->rproc = rproc; > + > + platform_set_drvdata(pdev, rvdev); > + > + return rproc_rvdev_add_device(rvdev); > +} > + > +static int rproc_virtio_remove(struct platform_device *pdev) > +{ > + struct rproc_vdev *rvdev = dev_get_drvdata(&pdev->dev); > + 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); > + rproc_unregister_rvdev(rvdev); > + dev_dbg(&pdev->dev, "virtio dev %d removed\n", rvdev->index); > + > + 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, > + }, > +}; > +builtin_platform_driver(rproc_virtio_driver); > diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h > index e0600e1e5c17..542a3d4664f2 100644 > --- a/include/linux/remoteproc.h > +++ b/include/linux/remoteproc.h > @@ -616,6 +616,7 @@ 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 > * @dev: device struct used for reference count semantics > * @id: virtio device id (as in virtio_ids.h) > * @node: list node > @@ -628,6 +629,7 @@ struct rproc_vdev { > struct kref refcount; > > struct rproc_subdev subdev; > + struct platform_device *pdev; > struct device dev; > > unsigned int id; > -- > 2.17.1 >