Received: by 2002:ac0:da4c:0:0:0:0:0 with SMTP id a12csp1002724imi; Fri, 22 Jul 2022 14:45:10 -0700 (PDT) X-Google-Smtp-Source: AGRyM1tPevUT9dHBRapQ4XMkAOVtmspt94+jEqB7bNP2en9/+7KzbbX3VVpgV7faoUDw8iS8KmNi X-Received: by 2002:a65:49c8:0:b0:415:e89d:ea1a with SMTP id t8-20020a6549c8000000b00415e89dea1amr1521746pgs.266.1658526310108; Fri, 22 Jul 2022 14:45:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1658526310; cv=none; d=google.com; s=arc-20160816; b=YJ4HzBGVHHmXXelakM708eCjhXqTLCzHy8HXaf6uMEf+WsQOzUPxLYRO/ZPn1RyXqT NaF85PsHcfo2p/ZaTMht+2sIdPcgtYrJhqOw+2SzvRozeUcXE6f6a6DvErlC6SYD2QrC iowLI0UjiUhO26k38WyjfceAHdSGwIL95cCmiMW9TaBpzumOAAC90g3V9IDqmKdG0tkD qH9RkNpfz+Gzi/yMiusbI2S/KRGfzw9QFCqA9Y0NtbgVEdDZywNXNxxjbCDNX138Pt2P 1Nj7cpBdi0LoqjdWaB+NA5t7YMSx92eLkcoTtezNXzfSTi0aUxiHyV4Gr8lzlesvFqQ2 fryg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=1BGyLBuq3meNkdub1LpDqA0SaKJWYBl5yTRibnE/+hE=; b=yeoHOog4b1aPkEag1zEKN8Th/oNaU/8kDSuRxx6zkOFazwu9AGHnDhAgWaYa+Gjtoo hwIQhA3QwplPHAvyLYGOinwvAtWwrGJ+WyDevtZ3UbV15A1LIiUJKkNgPlUau09rf5fR AXNKFRAjOlIoVe77PR3m1Irgi/Jrjw3+WPTw5GtNHlBzscvjSakJDX52R88nm78oQYEX LbSGUZP8SwE8Wv5HlPQtxubblPE6rpvy41aLHmQsXs5HUYCM8qnJ1VGjmiY7kryWYO1F T6vmMYJRxRu4+Re4qQbErhSUzWKBFxLcPO8slvSCm/HZWmZLZwWKBV7Bb7GCI7DtFMsr YStg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kAfLZfqn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p10-20020a1709026b8a00b0016a1dfe96f4si6624636plk.224.2022.07.22.14.44.53; Fri, 22 Jul 2022 14:45:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=kAfLZfqn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234919AbiGVVcT (ORCPT + 99 others); Fri, 22 Jul 2022 17:32:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36188 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230482AbiGVVcS (ORCPT ); Fri, 22 Jul 2022 17:32:18 -0400 Received: from mail-qk1-x729.google.com (mail-qk1-x729.google.com [IPv6:2607:f8b0:4864:20::729]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62EE4AF843 for ; Fri, 22 Jul 2022 14:32:17 -0700 (PDT) Received: by mail-qk1-x729.google.com with SMTP id f14so4619829qkm.0 for ; Fri, 22 Jul 2022 14:32:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=1BGyLBuq3meNkdub1LpDqA0SaKJWYBl5yTRibnE/+hE=; b=kAfLZfqnVGSljWjnAtlpkQJDWBJSH4MK+UbIahboS+sE0OI+pVFANMnIulcwGJEHTB uvYoLI2W8mHVG1U32SdvfnHQwwlQHm5nQvuJLAtjhMuw31ks877Jvc7sfa9fKBxIpwgJ DCh8jn0tUYSREZ7iofhjBUZT8RfAN98RBwq8s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1BGyLBuq3meNkdub1LpDqA0SaKJWYBl5yTRibnE/+hE=; b=xDdSNg9iYnA0T5xblq7xWIZXDAkdLJglAEVClwSNFL0VByalCKbvdjGpc19kaO9giU qVA5glAcjgu0P9g1TuSNXU8AutVUDkYgdROARxxeEHTs2nf/FMKVqpCm8ayDoPPbjP/j I4lXZBiL3zgjTQ8YMBOiSr/dn3MyIVT+bYtnMaqJL5iZ6hdawkpqltkQzAI6qpQ8Ogxh roRMMGsWUKmYHMgJqDjpEtDE9FqdpOGpqTjVbFY5jH82m2jgBbANv70HqF8JKF7QwLyf /bwKrULnFP8FhPIkfnYsQK5P4B7aYvQDOTx2JfwDpTKjWHamTo9eko/KrKEdX9qk47mt NjHQ== X-Gm-Message-State: AJIora9FsUdkQKxHtH02WIm5idzNWSw7H7GuS7EKxh1HQ8iu01dQaS67 vcYoQipPMYNTsG/QwRytH/uEL17A8sqFWA== X-Received: by 2002:a37:644b:0:b0:6b5:d62f:7ed with SMTP id y72-20020a37644b000000b006b5d62f07edmr1500662qkb.143.1658525536305; Fri, 22 Jul 2022 14:32:16 -0700 (PDT) Received: from jshargo (pool-108-14-42-16.nycmny.fios.verizon.net. [108.14.42.16]) by smtp.gmail.com with ESMTPSA id x9-20020a05620a448900b006b614fe291bsm4657187qkp.28.2022.07.22.14.32.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Jul 2022 14:32:16 -0700 (PDT) From: Jim Shargo To: jshargo@google.com, Rodrigo Siqueira , Melissa Wen , Haneen Mohammed , Daniel Vetter , David Airlie Cc: Jim Shargo , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/5] drm/vkms: Merge default_config and device Date: Fri, 22 Jul 2022 17:32:09 -0400 Message-Id: <20220722213214.1377835-2-jshargo@chromium.org> X-Mailer: git-send-email 2.37.1.359.gd136c6c3e2-goog In-Reply-To: <20220722213214.1377835-1-jshargo@chromium.org> References: <20220722213214.1377835-1-jshargo@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is a small refactor to make ConfigFS support easier. vkms_config is now a member of vkms_device and we now store a top-level reference to vkms_device. This should be a no-op refactor. Signed-off-by: Jim Shargo --- drivers/gpu/drm/vkms/vkms_drv.c | 58 +++++++++--------------------- drivers/gpu/drm/vkms/vkms_drv.h | 5 ++- drivers/gpu/drm/vkms/vkms_output.c | 6 ++-- 3 files changed, 22 insertions(+), 47 deletions(-) diff --git a/drivers/gpu/drm/vkms/vkms_drv.c b/drivers/gpu/drm/vkms/vkms_drv.c index 0ffe5f0e33f7..81ed9417e511 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.c +++ b/drivers/gpu/drm/vkms/vkms_drv.c @@ -37,7 +37,7 @@ #define DRIVER_MAJOR 1 #define DRIVER_MINOR 0 -static struct vkms_config *default_config; +static struct vkms_device *vkms_device; static bool enable_cursor = true; module_param_named(enable_cursor, enable_cursor, bool, 0444); @@ -91,13 +91,9 @@ static void vkms_atomic_commit_tail(struct drm_atomic_state *old_state) static int vkms_config_show(struct seq_file *m, void *data) { - struct drm_info_node *node = (struct drm_info_node *)m->private; - struct drm_device *dev = node->minor->dev; - struct vkms_device *vkmsdev = drm_device_to_vkms_device(dev); - - seq_printf(m, "writeback=%d\n", vkmsdev->config->writeback); - seq_printf(m, "cursor=%d\n", vkmsdev->config->cursor); - seq_printf(m, "overlay=%d\n", vkmsdev->config->overlay); + seq_printf(m, "writeback=%d\n", vkms_device->config.writeback); + seq_printf(m, "cursor=%d\n", vkms_device->config.cursor); + seq_printf(m, "overlay=%d\n", vkms_device->config.overlay); return 0; } @@ -158,11 +154,10 @@ static int vkms_modeset_init(struct vkms_device *vkmsdev) return vkms_output_init(vkmsdev, 0); } -static int vkms_create(struct vkms_config *config) +static int vkms_create(void) { 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)) @@ -179,9 +174,11 @@ static int vkms_create(struct vkms_config *config) ret = PTR_ERR(vkms_device); goto out_devres; } + vkms_device->platform = pdev; - vkms_device->config = config; - config->dev = vkms_device; + vkms_device->config.cursor = enable_cursor; + vkms_device->config.writeback = enable_writeback; + vkms_device->config.overlay = enable_overlay; ret = dma_coerce_mask_and_coherent(vkms_device->drm.dev, DMA_BIT_MASK(64)); @@ -207,6 +204,8 @@ static int vkms_create(struct vkms_config *config) drm_fbdev_generic_setup(&vkms_device->drm, 0); + vkms_device->initialized = true; + return 0; out_devres: @@ -218,46 +217,23 @@ static int vkms_create(struct vkms_config *config) static int __init vkms_init(void) { - struct vkms_config *config; - - config = kmalloc(sizeof(*config), GFP_KERNEL); - if (!config) - return -ENOMEM; - - default_config = config; - - config->cursor = enable_cursor; - config->writeback = enable_writeback; - config->overlay = enable_overlay; - - return vkms_create(config); + return vkms_create(); } -static void vkms_destroy(struct vkms_config *config) +static void __exit vkms_exit(void) { struct platform_device *pdev; - if (!config->dev) { - DRM_INFO("vkms_device is NULL.\n"); + if (!vkms_device || !vkms_device->initialized) { return; } - pdev = config->dev->platform; + pdev = vkms_device->platform; - drm_dev_unregister(&config->dev->drm); - drm_atomic_helper_shutdown(&config->dev->drm); + drm_dev_unregister(&vkms_device->drm); + drm_atomic_helper_shutdown(&vkms_device->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 91e63b12f60f..c7ebc4ee6b14 100644 --- a/drivers/gpu/drm/vkms/vkms_drv.h +++ b/drivers/gpu/drm/vkms/vkms_drv.h @@ -99,15 +99,14 @@ struct vkms_config { bool writeback; bool cursor; bool overlay; - /* 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; + struct vkms_config config; + bool initialized; }; #define drm_crtc_to_vkms_output(target) \ diff --git a/drivers/gpu/drm/vkms/vkms_output.c b/drivers/gpu/drm/vkms/vkms_output.c index ba0e82ae549a..d0061c82003a 100644 --- a/drivers/gpu/drm/vkms/vkms_output.c +++ b/drivers/gpu/drm/vkms/vkms_output.c @@ -63,7 +63,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) if (IS_ERR(primary)) return PTR_ERR(primary); - if (vkmsdev->config->overlay) { + if (vkmsdev->config.overlay) { for (n = 0; n < NUM_OVERLAY_PLANES; n++) { ret = vkms_add_overlay_plane(vkmsdev, index, crtc); if (ret) @@ -71,7 +71,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) } } - if (vkmsdev->config->cursor) { + if (vkmsdev->config.cursor) { cursor = vkms_plane_init(vkmsdev, DRM_PLANE_TYPE_CURSOR, index); if (IS_ERR(cursor)) return PTR_ERR(cursor); @@ -103,7 +103,7 @@ int vkms_output_init(struct vkms_device *vkmsdev, int index) goto err_attach; } - if (vkmsdev->config->writeback) { + if (vkmsdev->config.writeback) { writeback = vkms_enable_writeback_connector(vkmsdev); if (writeback) DRM_ERROR("Failed to init writeback connector\n"); -- 2.37.1.359.gd136c6c3e2-goog