Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-13.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A804CC4743C for ; Mon, 21 Jun 2021 15:55:28 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 11090600D3 for ; Mon, 21 Jun 2021 15:55:28 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 11090600D3 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ravnborg.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 89F816E083; Mon, 21 Jun 2021 15:55:27 +0000 (UTC) Received: from mx2.smtp.larsendata.com (mx2.smtp.larsendata.com [91.221.196.228]) by gabe.freedesktop.org (Postfix) with ESMTPS id 15E4F6E083 for ; Mon, 21 Jun 2021 15:55:25 +0000 (UTC) Received: from mail01.mxhotel.dk (mail01.mxhotel.dk [91.221.196.236]) by mx2.smtp.larsendata.com (Halon) with ESMTPS id 1eeaea4c-d2a9-11eb-a36f-0050568cd888; Mon, 21 Jun 2021 15:55:37 +0000 (UTC) Received: from ravnborg.org (80-162-45-141-cable.dk.customer.tdc.net [80.162.45.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: sam@ravnborg.org) by mail01.mxhotel.dk (Postfix) with ESMTPSA id 8E4B3194B7E; Mon, 21 Jun 2021 17:55:24 +0200 (CEST) Date: Mon, 21 Jun 2021 17:55:17 +0200 X-Report-Abuse-To: abuse@mxhotel.dk From: Sam Ravnborg To: Tomohito Esaki Subject: Re: [PATH 1/4] drm: Add Virtual DRM device driver Message-ID: <20210621155517.GB823900@ravnborg.org> References: <20210621064403.26663-1-etom@igel.co.jp> <20210621064403.26663-2-etom@igel.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210621064403.26663-2-etom@igel.co.jp> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Thomas Zimmermann , linux-doc@vger.kernel.org, David Airlie , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, linux-renesas-soc@vger.kernel.org, Kieran Bingham , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Hi Tomohito On Mon, Jun 21, 2021 at 03:44:00PM +0900, Tomohito Esaki wrote: > Virtual DRM splits the resources of an overlay plane into multiple > virtual devices to allow each plane to be accessed by each process. > > This makes it possible to overlay images output from multiple processes > on a display. For example, one process displays the camera image without > compositor while another process overlays the compositor's drawing of > the UI. > > The virtual DRM creates standalone virtual device and make DRM planes > from a master device (e.g. card0) accessible via one or more virtual > devices. However, these plane are no longer accessible from the original > device. > Each virtual device (and plane) can be accessed via a separate > device file. > > Signed-off-by: Tomohito Esaki > --- > drivers/gpu/drm/Kconfig | 7 + > drivers/gpu/drm/Makefile | 1 + > drivers/gpu/drm/vdrm/vdrm_api.h | 68 +++ > drivers/gpu/drm/vdrm/vdrm_drv.c | 859 ++++++++++++++++++++++++++++++++ > drivers/gpu/drm/vdrm/vdrm_drv.h | 80 +++ Plase consider making the header files self-contained. So there are no hdden dependencies between the two. Use forward declarations rahter than including header files is possible. A few trivial comments in the following. I did not try to follow all the functionality of the driver and I expect others to comment on the idea. Sam > 5 files changed, 1015 insertions(+) > create mode 100644 drivers/gpu/drm/vdrm/vdrm_api.h > create mode 100644 drivers/gpu/drm/vdrm/vdrm_drv.c > create mode 100644 drivers/gpu/drm/vdrm/vdrm_drv.h > > diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig > index 3c16bd1afd87..ba7f4eeab385 100644 > --- a/drivers/gpu/drm/Kconfig > +++ b/drivers/gpu/drm/Kconfig > @@ -294,6 +294,13 @@ config DRM_VKMS > > If M is selected the module will be called vkms. > > +config DRM_VDRM > + tristate "Virtual DRM" > + depends on DRM > + help > + Virtual DRM splits the resources of an overlay plane into multiple > + virtual devices to allow each plane to be accessed by each process. Could you look into pulling a bit more info here. You made a very nice intro to the patch, consider using it in the help text too. > + > source "drivers/gpu/drm/exynos/Kconfig" > > source "drivers/gpu/drm/rockchip/Kconfig" > diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile > index 5279db4392df..55dbf85e2579 100644 > --- a/drivers/gpu/drm/Makefile > +++ b/drivers/gpu/drm/Makefile > @@ -82,6 +82,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/ > obj-$(CONFIG_DRM_VIA) +=via/ > obj-$(CONFIG_DRM_VGEM) += vgem/ > obj-$(CONFIG_DRM_VKMS) += vkms/ > +obj-$(CONFIG_DRM_VDRM) += vdrm/ Alphabetic order (mostly) so before vgem/ > obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/ > obj-$(CONFIG_DRM_EXYNOS) +=exynos/ > obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/ > diff --git a/drivers/gpu/drm/vdrm/vdrm_api.h b/drivers/gpu/drm/vdrm/vdrm_api.h > new file mode 100644 > index 000000000000..dd4d7e774800 > --- /dev/null > +++ b/drivers/gpu/drm/vdrm/vdrm_api.h > @@ -0,0 +1,68 @@ > +/* SPDX-License-Identifier: GPL-2.0+ */ > +/* > + * vdrm_api.h -- Virtual DRM API > + * > + * Copyright (C) 2021 Renesas Electronics Corporation > + */ > + > +#ifndef __VDRM_API__ > +#define __VDRM_API__ > + > +#include > +#include > + > +/** > + * struct vdrm_property_info - Information about the properties passed from > + * the DRM driver to vDRM > + * @prop: Parent property to pass to vDRM > + * @default_val: Default value for the property passed to vDRM > + */ > +struct vdrm_property_info { > + struct drm_property *prop; > + uint64_t default_val; > +}; It would be nice that all structs used inline comments - and then you are consistent too. > + > +/** > + * struct vdrm_funcs - Callbacks to parent DRM driver > + */ > +struct vdrm_funcs { > + /** > + * @dumb_create: > + * > + * Called by &drm_driver.dumb_create. Please read the documentation > + * for the &drm_driver.dumb_create hook for more details. > + */ > + int (*dumb_create)(struct drm_file *file, struct drm_device *dev, > + struct drm_mode_create_dumb *args); > + > + /** > + * @crtc_flush: > + * > + * Called by &drm_crtc_helper_funcs.atomic_flush. Please read the > + * documentation for the &drm_crtc_helper_funcs.atomic_flush hook for > + * more details. > + */ > + void (*crtc_flush)(struct drm_crtc *crtc); > +}; > + > +struct vdrm_device; > +struct vdrm_display; > + > +void vdrm_drv_handle_vblank(struct vdrm_display *vdisplay); > +void vdrm_drv_finish_page_flip(struct vdrm_display *vdisplay); > +struct vdrm_device *vdrm_drv_init(struct drm_device *dev, > + struct device_node *np, int num_props, > + struct vdrm_property_info *props, > + const struct vdrm_funcs *funcs); > +int vdrm_drv_plane_init(struct vdrm_device *vdrm, struct drm_plane *plane, > + const struct drm_plane_funcs *funcs, > + const struct drm_plane_helper_funcs *helper_funcs, > + const u32 *formats, unsigned int num_formats, > + int max_zpos); > +struct vdrm_display *vdrm_drv_display_init(struct vdrm_device *vdrm, > + struct drm_crtc *crtc, > + struct drm_plane *plane); > +int vdrm_drv_register(struct vdrm_device *vdrm); > +void vdrm_drv_fini(struct vdrm_device *vdrm); > + > +#endif /* __VDRM_API__ */ > diff --git a/drivers/gpu/drm/vdrm/vdrm_drv.c b/drivers/gpu/drm/vdrm/vdrm_drv.c > new file mode 100644 > index 000000000000..835bdecfc8e6 > --- /dev/null > +++ b/drivers/gpu/drm/vdrm/vdrm_drv.c > @@ -0,0 +1,859 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * vdrm_drv.c -- Virtual DRM driver > + * > + * Copyright (C) 2021 Renesas Electronics Corporation > + * > + * This driver is based on drivers/gpu/drm/drm_simple_kms_helper.c. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include