Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp2498923pxb; Mon, 11 Jan 2021 11:09:59 -0800 (PST) X-Google-Smtp-Source: ABdhPJwUzrhsZ0iIvGL59hbPncswi3fwMJs+y0oENn/7p1jXMXsWAA3e/Bi57V7S8lz5hOb4BbF9 X-Received: by 2002:a17:906:3953:: with SMTP id g19mr614130eje.429.1610392199423; Mon, 11 Jan 2021 11:09:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610392199; cv=none; d=google.com; s=arc-20160816; b=O3DNCqBCCL32eT0hCISsKcIfoCF95/mMdsJT+VcRJ3l2EHoSX0XpBpHeiMmD4Tf4W6 SeF/Iu0ZcJYl0R+ETGxDN5qzSOtwH+j+Kt+jk9VxhfTD5Ls/nEYUhSSY6pIYHXeHyeqB UPa2azMtMwDk9J6Ne5a2HUezXDjuL/8pbclBvVYlxOSFJn/U7BGSvWoYQ238na6XNc+j QeXVYrHmQKzlsMKpZzqv6rFIz1MXiUwai/3XjR3StTIFQa9R0whyCs/yZmYbDF0Gk2XM IbCDzekP4BbbX8BOh/cnnMmNr/uRSE1ro/UJh4N3eMmBzbDEdB6H1v7jfUt2qNFnwcRJ wgDw== 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=EIyCJKDhvNH8KI19OBGyEbU3SM6tfKfgJa5ae5NSM3Y=; b=CQlRZUztmgOhXaGwdnZG4gRCz4TGZarXGdN4Qnt12KflQdJha2gXAHDDMYRGpIHZ+y 5+FDOwikGbu4KrxuOsXo6gCPMtObmACBLH6cPmL5A/gHb6QWiLF8S4KVtknIpt9jmjHZ zJyLRbe/RGLvnKtnCxttnQDweciVDhXRCetPPsnf7V65rpKcHK4e5H8oaYWv7wNv1cHA dVd6Vy/qlPsuzh7/zJ8HLvtUOUaVLtDKvZv96C6oyMp38IgegsWBO3sFqV+sREWBpJpn L9ruN3jcfvGbSpTDazBQzlMDAseTe5qPE3Luew7cHcZkJaBuTf7h57DLrkRTsEMV80pj BTwA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=fbBQ87YX; 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 k7si291335edi.32.2021.01.11.11.09.34; Mon, 11 Jan 2021 11:09:59 -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=fbBQ87YX; 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 S2387723AbhAKTHV (ORCPT + 99 others); Mon, 11 Jan 2021 14:07:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41052 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732381AbhAKTHT (ORCPT ); Mon, 11 Jan 2021 14:07:19 -0500 Received: from mail-pg1-x535.google.com (mail-pg1-x535.google.com [IPv6:2607:f8b0:4864:20::535]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B0CFC061794 for ; Mon, 11 Jan 2021 11:06:39 -0800 (PST) Received: by mail-pg1-x535.google.com with SMTP id q7so279583pgm.5 for ; Mon, 11 Jan 2021 11:06:39 -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=EIyCJKDhvNH8KI19OBGyEbU3SM6tfKfgJa5ae5NSM3Y=; b=fbBQ87YXU2W7qZDXQ1APvYVhLACLHf0jqMewwV/mDRFvsSnfDR+pwWoyh4/S8kfYEr 1v15ZzSqtbMtuxVJ93UgiM9geBLlm24aatkaJ46T+OIhDX/o1j8LIL/OFMR+HEPOi129 U+Vv+bKDDYHP3UjdaHrav+ZaYUgfFHlcdTB6ByfQTDv8Um2jMzF93zkyh9W8p/YKV/Eq wzBLRUy+TUWGEJz8XSRBzXooRBuDMZsn6sW8tb1Ug3USDb2O6nzlWdZxwrR3vx3X+v8n QDPzkfut4F6mh+N35Uu5lEHC+srr0z8Z2CnKATrRU2lJss3KHqTPjhUA7lW3CNkCIJnX K98A== 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=EIyCJKDhvNH8KI19OBGyEbU3SM6tfKfgJa5ae5NSM3Y=; b=iqgBa5aBkvJzM8cCwa9kxMAHUn6MIkdQ8hj57MKCTir31ls3ObHIjOMvSTs+4npRVN Bk0rLmpkEQNlzqoWjgmDOvq8uhw8WZRQda/5HKoBAvhonRzYasUmgJoNQ3svRxnGKCgb 4W1Ht82gDSOP7meC2nGGXpDKldWW/T7PnPzcaDe9zP1mbkmYjwhIMe/gCP94LORVIQ+6 Z5UPjoKNg9AJZlWsxYIZRGIvlw8dFLQZjFLMvHa3npM78auH4AEcAbtHV2KM/SA+DITf 78Ol37fEVBc2iDAZsWNvidTIDduMh+EFUcOGOrvOJlohhmV3Q6JhgHZGGmTfP4ORb/NG u88Q== X-Gm-Message-State: AOAM531ryfSbfxrKoo25AuR2+ehzybjqQXpyx69C0e3P1y1No21dA3zx 6Dl15x05AwLuhKLFdkX8SD8= X-Received: by 2002:a63:2cd:: with SMTP id 196mr947417pgc.398.1610391998845; Mon, 11 Jan 2021 11:06:38 -0800 (PST) Received: from adolin ([49.207.206.164]) by smtp.gmail.com with ESMTPSA id b18sm370264pfi.173.2021.01.11.11.06.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Jan 2021 11:06:38 -0800 (PST) Date: Tue, 12 Jan 2021 00:36:34 +0530 From: Sumera Priyadarsini To: melissa.srw@gmail.com 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: [PATCH V5 1/3] drm/vkms: Add vkms_config type Message-ID: References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. Co-developed-by: Daniel Vetter Signed-off-by: Daniel Vetter Signed-off-by: Sumera Priyadarsini --- drivers/gpu/drm/vkms/vkms_drv.c | 40 ++++++++++++++++++++++++------ drivers/gpu/drm/vkms/vkms_drv.h | 12 +++++++-- drivers/gpu/drm/vkms/vkms_output.c | 4 +-- 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index aef29393b811..6b33975a5cb2 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -34,9 +34,9 @@ #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"); @@ -122,10 +122,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 +144,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 +182,42 @@ 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; + + 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..6a27bd8875f2 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,19 @@ struct vkms_output { spinlock_t composer_lock; }; +struct vkms_device; + +struct vkms_config { + bool cursor; + /* only set when instantiated */ + struct vkms_device *dev; +}; + 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) \ @@ -124,3 +131,4 @@ void vkms_set_composer(struct vkms_output *out, bool enabled); int vkms_enable_writeback_connector(struct vkms_device *vkmsdev); #endif /* _VKMS_DRV_H_ */ + diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index 4a1848b0318f..8f3ffb28b9d1 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -46,7 +46,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int 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); @@ -98,7 +98,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