Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp1059356pxu; Wed, 6 Jan 2021 11:11:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJzyalj06TZpAizyYOJqOgpQwLNu4JaYhJLlglrd0YunO5WGfZUBHWnuMK+lB9uUHgtGFOJE X-Received: by 2002:a17:906:6606:: with SMTP id b6mr3738395ejp.151.1609960283156; Wed, 06 Jan 2021 11:11:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609960283; cv=none; d=google.com; s=arc-20160816; b=dHeEvYz1LEv6To0mDqsf93ksPfQLHSMtDFti/984xOaMpIg8roWaY1npkfo07rZr8o BcRrREOK9nP6mjbV98zBOjM9L+7EhiEndAotS4s2BzsAJA1h6dOUTVCzfrNhj9rH6DiJ 0DOuWjz8yZYPMDksHWdpu3Od/5s/9CKyqAtc8AUqHVmX3gCfmZDOosU6T9gesLuK7ECQ 4PeENtXypfpNRn4AxU220sJgmKLfigaZgGgrCE5KUHMRgr++1rRX1U7dRiOwQXSuCrAg vCrHyej8+cQpgiu41L5zx51UMmZ0us9BI/4y0Fjtv7Iax93l4T9TRwtk0HoWKAqHsSGX af3w== 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=4KW/gQds2UZRxF+0UsRPVqfC4ctbeb1eJIOWPKMrFE8=; b=NmUaAJA/caiQTWN0E3vIg147lYHMY+IHzJa2zFzBPSPndgDIZRLygcDowh54Z5hwOS GGLKkCN9MSGpu37ZF10D/U6xUTv4dfrkxubNrv4SRLq0wSwP4eBXcoczN/7MVAFxW6ws Uwg07vEcBETnX0ZcLL9sqQ71g9O740kc4ejfd/h5x1MZKy9NEZVWvvXizkv9xBfK38s1 w+OuFSBmLg9u6q4VnsyNYUgO+7mb0OWMq52P2ocv5owgNaP/dmyAWmRUPih/mziibvlJ mmieSHXmCvJmUOQvZKVQgVPUA/o9qNNMGLCm83uBbhhjhbZ2WN19rtoJOcmfVFjySXoH jx+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=iB3TV8mu; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id s5si1205257ejz.284.2021.01.06.11.10.59; Wed, 06 Jan 2021 11:11:23 -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=@gmail.com header.s=20161025 header.b=iB3TV8mu; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726768AbhAFTJW (ORCPT + 99 others); Wed, 6 Jan 2021 14:09:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726406AbhAFTJV (ORCPT ); Wed, 6 Jan 2021 14:09:21 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 25E8CC061575 for ; Wed, 6 Jan 2021 11:08:41 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id t30so3420196wrb.0 for ; Wed, 06 Jan 2021 11:08:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=4KW/gQds2UZRxF+0UsRPVqfC4ctbeb1eJIOWPKMrFE8=; b=iB3TV8muZwiqAKxLfBO3/oCj9PsnKnYi6UaqZZz7Od+gtJx8VXU5c9t0klmdUEHTN9 QX0jcCxfLutPuS/NhlvuwtdyTfG5G4qlkzUKymDs2h46B7yLttWvu23gCWI1/Fwj3uug oUNged6QUcehKqcDWUv9Z7m36+5X42Te61MuR7Sba0cY3k318YK5yiAjWPtCy4+rXlRH qbAnQP5rGL4Jv9mIrs/dU141j9n26/WijEFrdS/z23rIfxOkyZjEOn3tc+PyRrXK3a4T Tir+VsfLMLYY4h5f6oPWlvnyiNFxGH4+R3gMYtcpWl26r9ZHTA+R+RzrHOgVVmOrODLo 0jZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=4KW/gQds2UZRxF+0UsRPVqfC4ctbeb1eJIOWPKMrFE8=; b=U2b02TuTVsyuTL5gwkZJjxIIVShVuROeLrPkC0m2PGSl9NpiXS3bCv5eErU1bOXwcl 5BxALlRWWIxtQUMhTr2HkQ7ixF7Bi5ABrACCTKj5rNzsGx/cDVu4I0fc76asDh20ejKV SnEMyMzhdpMssf/YI64P5qwzkJ5F1B0dDp8JqvER996FAacBrqp3Hp3WvyivQuk+HpxF 3DwSbMm22u/nqQMcszVA+JrAr4JvOlC0cWnpXdpV3k5pDCsd77i2gkp1buHaiUl+yWLI 2TMdHdyp6qxW0QtKS3qsi1kHekA9RCFhVAeFBtEyx40eVZs8h+q2LHp+XPt6Wn2LgSV7 Yt3A== X-Gm-Message-State: AOAM533x/9NQUtqU53S0JxSlzf9m/v0CyXImNFL7/ltQMokTHg4DOGqe yHwV2eyvpjFaQF4oSAcAMPw= X-Received: by 2002:adf:8185:: with SMTP id 5mr5452525wra.44.1609960119753; Wed, 06 Jan 2021 11:08:39 -0800 (PST) Received: from smtp.gmail.com (a95-92-181-29.cpe.netcabo.pt. [95.92.181.29]) by smtp.gmail.com with ESMTPSA id n17sm4002270wmc.33.2021.01.06.11.08.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Jan 2021 11:08:39 -0800 (PST) Date: Wed, 6 Jan 2021 16:08:32 -0300 From: Melissa Wen To: Sumera Priyadarsini Cc: rodrigosiqueiramelo@gmail.com, hamohammed.sa@gmail.com, daniel@ffwll.ch, airlied@linux.ie, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH V3] drm/vkms: Decouple config data for configfs Message-ID: <20210106190832.7fmwzohejkdohtck@smtp.gmail.com> References: <20210105145958.r5q553i6ji7fru6l@adolin> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210105145958.r5q553i6ji7fru6l@adolin> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/05, Sumera Priyadarsini wrote: > Currently, data for the device instance is held by vkms_device. > Add a separate type, vkms_config to contain configuration details > for the device and various modes to be later used by configfs. > This config data stays constant once the device is created. > > Accordingly, add vkms_create and vkms_destroy to initialize/destroy > device through configfs. Currently, they are being called from vkms_init > and vkms_exit, but will be evoked from configfs later on. When configfs > is added, device configuration will be tracked by configfs and only vkms > device lifetime will be handled by vkms_init and vkms_exit functions. > > Modify usage of enable_cursor feature to reflect the changes in > relevant files. > > Add enable_writeback_connector feature to vkms_config type. > > Co-developed-by: Daniel Vetter > Signed-off-by: Daniel Vetter > Signed-off-by: Sumera Priyadarsini > > --- > Changes in v2: > - add Co-developed-by tag > > Changes in v3: > - correct usage of Co-developed by tag(Melissa) > - add enable_writeback_feature(Melissa) > - modify commit message(Melissa) > --- > drivers/gpu/drm/vkms/vkms_drv.c | 45 ++++++++++++++++++++++++------ > drivers/gpu/drm/vkms/vkms_drv.h | 12 ++++++-- > drivers/gpu/drm/vkms/vkms_output.c | 13 +++++---- > 3 files changed, 54 insertions(+), 16 deletions(-) > > diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c > index aef29393b811..fab964900dce 100644 > --- a/drivers/gpu/drm/vkms/vkms_drv.c > +++ b/drivers/gpu/drm/vkms/vkms_drv.c > @@ -34,12 +34,16 @@ > #define DRIVER_MAJOR 1 > #define DRIVER_MINOR 0 > > -static struct vkms_device *vkms_device; > +static struct vkms_config *default_config; > > -bool enable_cursor = true; > +static bool enable_cursor = true; > module_param_named(enable_cursor, enable_cursor, bool, 0444); > MODULE_PARM_DESC(enable_cursor, "Enable/Disable cursor support"); > > +static bool enable_writeback_connector = true; > +module_param_named(enable_writeback_connector, enable_writeback_connector, bool, 0444); > +MODULE_PARM_DESC(enable_writeback_connector, "Enable/Disable writeback connector support"); > + Even though the limit is now 100 characteres, I consider 'enable_writeback' enough here. I think removing this _connector suffix doesn't affect the undestanding and also save some space to avoid break lines in the future > DEFINE_DRM_GEM_FOPS(vkms_driver_fops); > > static void vkms_release(struct drm_device *dev) > @@ -122,10 +126,11 @@ static int vkms_modeset_init(struct vkms_device *vkmsdev) > return vkms_output_init(vkmsdev, 0); > } > > -static int __init vkms_init(void) > +static int vkms_create(struct vkms_config *config) > { > int ret; > struct platform_device *pdev; > + struct vkms_device *vkms_device; > > pdev = platform_device_register_simple(DRIVER_NAME, -1, NULL, 0); > if (IS_ERR(pdev)) > @@ -143,6 +148,8 @@ static int __init vkms_init(void) > goto out_devres; > } > vkms_device->platform = pdev; > + vkms_device->config = config; > + config->dev = vkms_device; > > ret = dma_coerce_mask_and_coherent(vkms_device->drm.dev, > DMA_BIT_MASK(64)); > @@ -179,21 +186,43 @@ static int __init vkms_init(void) > return ret; > } > > -static void __exit vkms_exit(void) > +static int __init vkms_init(void) > +{ > + struct vkms_config *config = kmalloc(sizeof(*config), GFP_KERNEL); > + > + default_config = config; > + > + config->cursor = enable_cursor; > + config->writeback = enable_writeback_connector; > + > + return vkms_create(config); > +} > + > +static void vkms_destroy(struct vkms_config *config) > { > struct platform_device *pdev; > > - if (!vkms_device) { > + if (!config->dev) { > DRM_INFO("vkms_device is NULL.\n"); > return; > } > > - pdev = vkms_device->platform; > + pdev = config->dev->platform; > > - drm_dev_unregister(&vkms_device->drm); > - drm_atomic_helper_shutdown(&vkms_device->drm); > + drm_dev_unregister(&config->dev->drm); > + drm_atomic_helper_shutdown(&config->dev->drm); > devres_release_group(&pdev->dev, NULL); > platform_device_unregister(pdev); > + > + config->dev = NULL; > +} > + > +static void __exit vkms_exit(void) > +{ > + if (default_config->dev) > + vkms_destroy(default_config); > + > + kfree(default_config); > } > > module_init(vkms_init); > diff --git a/drivers/gpu/drm/vkms/vkms_drv.h b/drivers/gpu/drm/vkms/vkms_drv.h > index 5ed91ff08cb3..caa1fafb6ca7 100644 > --- a/drivers/gpu/drm/vkms/vkms_drv.h > +++ b/drivers/gpu/drm/vkms/vkms_drv.h > @@ -19,8 +19,6 @@ > #define XRES_MAX 8192 > #define YRES_MAX 8192 > > -extern bool enable_cursor; > - > struct vkms_composer { > struct drm_framebuffer fb; > struct drm_rect src, dst; > @@ -82,10 +80,18 @@ struct vkms_output { > spinlock_t composer_lock; > }; > > +struct vkms_device; > +struct vkms_config { > + bool writeback; > + bool cursor; > + /* only set when instantiated */ > + struct vkms_device *dev; > +}; Still in time, checkpatch complains here: CHECK: Please use a blank line after function/struct/union/enum declarations > struct vkms_device { > struct drm_device drm; > struct platform_device *platform; > struct vkms_output output; > + const struct vkms_config *config; > }; > > #define drm_crtc_to_vkms_output(target) \ > @@ -123,4 +129,4 @@ void vkms_set_composer(struct vkms_output *out, bool enabled); > /* Writeback */ > int vkms_enable_writeback_connector(struct vkms_device *vkmsdev); > > -#endif /* _VKMS_DRV_H_ */ > +#endif /* _VKMS_DRV_H_ */ > \ No newline at end of file > diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c > index 4a1848b0318f..f5f6f15c362c 100644 > --- a/drivers/gpu/drm/vkms/vkms_output.c > +++ b/drivers/gpu/drm/vkms/vkms_output.c > @@ -41,12 +41,13 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) > struct drm_crtc *crtc = &output->crtc; > struct drm_plane *primary, *cursor = NULL; > int ret; > + int writeback; > > primary = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_PRIMARY, index); > if (IS_ERR(primary)) > return PTR_ERR(primary); > > - if (enable_cursor) { > + if (vkmsdev->config->cursor) { > cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index); > if (IS_ERR(cursor)) { > ret = PTR_ERR(cursor); > @@ -80,9 +81,11 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) > goto err_attach; > } > > - ret = vkms_enable_writeback_connector(vkmsdev); > - if (ret) > - DRM_ERROR("Failed to init writeback connector\n"); > + if (vkmsdev->config->writeback) { > + writeback = vkms_enable_writeback_connector(vkmsdev); > + if (writeback) > + DRM_ERROR("Failed to init writeback connector\n"); > + } I would recommend the changes related to module options come in a second patch of a patch series. I mean, a patchset with (1) decoupling configs from device and (2) conversions. besides that, lgtm. but maybe Daniel has additional/other recommendations to share... > > drm_mode_config_reset(dev); > > @@ -98,7 +101,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) > drm_crtc_cleanup(crtc); > > err_crtc: > - if (enable_cursor) > + if (vkmsdev->config->cursor) > drm_plane_cleanup(cursor); > > err_cursor: > -- > 2.25.1 >