Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4363718pxj; Mon, 21 Jun 2021 21:14:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVRq9MwSrRusNypJaDsWfSTG6MmebeIOCTwXQVN2guVJut/4T5UVFX8aKh/vUqLqopzKpk X-Received: by 2002:a17:907:6fd:: with SMTP id yh29mr1711354ejb.432.1624335250478; Mon, 21 Jun 2021 21:14:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624335250; cv=none; d=google.com; s=arc-20160816; b=Be1NgbzB5EbA8jb9KrHV09zJfrx73nWobGTkiN1Ixy5ZRIKSU9WVfhe0dabO4th/xk RgvSPhSkchpgbFwbF4ag7XeqACkVcXSPi3DfXY8ND6uzzArpz9wEkt/aL7jFDo3SqEpe DQo+K8X5FufdjM6S4ubfp73kGgSFW7AX/CLxZVIaTqit827WJL7Ylz1ehiAYV6H6bNpa nrmbaje76waaf18eZnQXL0+36d6ck4VDb95dfLAaKOB9OfdBJRpZQ3qtwt27F1gPwv4I b/szADzLgieSthWP75H7SX0YkvRChs5ShIV/Lwlw3n7neCVCaBUcc8zeLIl1zBz2A68z lZ7A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=5v4KFtqSZ9EZ4ACWSXEximwNK2Um/W7YtCh8sLOGaU8=; b=Yuw7XxgVLs1DB+KpuHLLvWV1G1Z5IJdciOLyUluRu2mZvBDx9mk3kyeLT+i0mmi4Pl GRgsU7QLph3ZG5Vd0pD5z6JBlPil/NVGfKctgU0HHwl2qep+ZpIYqAV4TV7Naen0Pnvh Pj7ehP76/Ars21JAlrnuQt/mQsCt1j5W6qPdXrz2WlYNI6LTjHEJghCkE+36rb3mE/e7 p3HeiNG3dVw/fFVGZTUR+GlzJJgJm3xmQqwT1YpUoI0xXkIV8MiYyVDVJcqHVh5nlfRF uFw8SYpCAunBTvulB12edkzhi7mZt9kyIz/EXGcLcHCdX8rzBNdpwghBG47iTFwQPt1B HrRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@igel-co-jp.20150623.gappssmtp.com header.s=20150623 header.b=PMqRAl1I; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s19si12680564ejj.534.2021.06.21.21.13.47; Mon, 21 Jun 2021 21:14:10 -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=@igel-co-jp.20150623.gappssmtp.com header.s=20150623 header.b=PMqRAl1I; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229675AbhFVENB (ORCPT + 99 others); Tue, 22 Jun 2021 00:13:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45550 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229574AbhFVENA (ORCPT ); Tue, 22 Jun 2021 00:13:00 -0400 Received: from mail-pg1-x529.google.com (mail-pg1-x529.google.com [IPv6:2607:f8b0:4864:20::529]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12D67C061756 for ; Mon, 21 Jun 2021 21:10:45 -0700 (PDT) Received: by mail-pg1-x529.google.com with SMTP id t13so4196475pgu.11 for ; Mon, 21 Jun 2021 21:10:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20150623.gappssmtp.com; s=20150623; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=5v4KFtqSZ9EZ4ACWSXEximwNK2Um/W7YtCh8sLOGaU8=; b=PMqRAl1IxFL+5gAIk8yEY0kg7tp2N+aBOznIzHV7apaGu06XRgh95VhZIP8KDvhUHg jQe3Q6eZWJswIuMesZbEeajY+owvwGTZ6lGM3Q39FUjs1CZvuQRexFykT/24IRLG1dHB 8uXqKWqv+mcH73tZbcoiescKE69xM4laYTx4M3axNeM8r2EqpFMmGTlTPqtrVoOiid04 2To/KlSgXYhPEh9hrNAGfgA0bd5VYfS0AzaPtYH7bQu6EJvF11zz4B8wGp98bFYF4bwP 6PKUQyF00+aek79IpWD+95LwRBqrsFrf55jtqP3qit+wvd+Lm1H1v/6GFFHzCJ6FLF4r wo3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=5v4KFtqSZ9EZ4ACWSXEximwNK2Um/W7YtCh8sLOGaU8=; b=tBI6H2xw9UySoPhmt31ua7+UtDYUH/luQugu9fwlLdw2TtnDcdrBM9sueZeZCXQd1i hLT9ldSrtqX33AaYQvIv2Ogg9wZ8QobAgTIYizY1ITcC9nBTXbJGAlSz6rOUj7EhzQOj oCi09Hl4vahnONpKkqO/+qUNRDq+wfXAtCmJMaBjVpaACKv0Sgqg+6dKuHCUnzb5zD4u XzKmQk3uq2fkBJHU7FD+ITbqnUj8p1QpdyX2ipf/dHTYGaR04VZa/H9heiIr9WgRoe7X dkvmNEjrbTv3pGNxAP54GW31xGQ1lZorzdU66/wXIjABq40KaWHUCN+vF/Nbh/NocpUz DVOw== X-Gm-Message-State: AOAM532hRfJUni1JH9Xmjt34LbWcinxRurIaPmKnGRNf8AsMcP5+oae7 nmUYffaGICjY9jMcgFh2+A03lg== X-Received: by 2002:a65:4c46:: with SMTP id l6mr1809454pgr.91.1624335044092; Mon, 21 Jun 2021 21:10:44 -0700 (PDT) Received: from ?IPv6:240b:10:c9a0:ca00:5192:32ad:e5be:23cd? ([240b:10:c9a0:ca00:5192:32ad:e5be:23cd]) by smtp.gmail.com with ESMTPSA id 136sm12226925pge.75.2021.06.21.21.10.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 21 Jun 2021 21:10:43 -0700 (PDT) Subject: Re: [PATH 1/4] drm: Add Virtual DRM device driver To: Sam Ravnborg Cc: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Laurent Pinchart , Kieran Bingham , devicetree@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, Damian Hobson-Garcia , Takanari Hayama References: <20210621064403.26663-1-etom@igel.co.jp> <20210621064403.26663-2-etom@igel.co.jp> <20210621155517.GB823900@ravnborg.org> From: Esaki Tomohito Message-ID: <38c87751-9aad-03bd-074a-c4c8c958cead@igel.co.jp> Date: Tue, 22 Jun 2021 13:10:39 +0900 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210621155517.GB823900@ravnborg.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Sam Thank you for looking at the details. I will fix it according to your comment. Best regards Tomohito Esaki On 2021/06/22 0:55, Sam Ravnborg wrote: > 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