From patchwork Mon Jan 16 10:28:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Ma=C3=ADra_Canal?= X-Patchwork-Id: 13102872 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org 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 smtp.lore.kernel.org (Postfix) with ESMTPS id DB2A3C54EBE for ; Mon, 16 Jan 2023 10:30:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id A6FC110E2CC; Mon, 16 Jan 2023 10:30:05 +0000 (UTC) Received: from fanzine2.igalia.com (fanzine2.igalia.com [213.97.179.56]) by gabe.freedesktop.org (Postfix) with ESMTPS id 671C810E2CE for ; Mon, 16 Jan 2023 10:30:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=igalia.com; s=20170329; h=Content-Transfer-Encoding:Content-Type:MIME-Version:References: In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=rvUyhBI0p9mKbIQ6G2ck3ZzU8mGQdsnv+Z6Waiy56uU=; b=hLoD1GbuxfXoiwhtMlbwUjmHQE Rg+3+Y6fgTRsQFHQiyLGLK7mPPzdfSXoaMQANtCEYjbGhf0bVm56hriWVzPgD12nO3gCurcus/I8q xXTzL2uyEseWfuNaFJi4bu/eIxKt0FgHNebDpF2pZM7KAghcd6SrfoCs+lDqE9XaTbPNkehDr7qiG JpAfD0jGP18AKPgzFd37S61iIrAhdNU4bFaBdxvQeA0eWvl02qggM2+/WxqZJON7vf7mPWE4u5DgY TBwdzfV54fJVnmgy5Qk/LxRs5y8w7I9ZzYW8FrtTvrty0qU405XS5YBV152Zxd90MphkioThhyY8S LBFhh/jw==; Received: from [187.36.234.139] (helo=bowie..) by fanzine2.igalia.com with esmtpsa (Cipher TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim) id 1pHMkS-009j44-Ix; Mon, 16 Jan 2023 11:29:53 +0100 From: =?utf-8?q?Ma=C3=ADra_Canal?= To: Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , Liviu Dudau , Brian Starkey , =?utf-8?q?Noralf_Tr=C3=B8nnes?= , Emma Anholt , Melissa Wen , Rodrigo Siqueira , Jani Nikula Subject: [PATCH 2/6] drm/debugfs: Make drm_device use the struct drm_debugfs_list Date: Mon, 16 Jan 2023 07:28:12 -0300 Message-Id: <20230116102815.95063-3-mcanal@igalia.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230116102815.95063-1-mcanal@igalia.com> References: <20230116102815.95063-1-mcanal@igalia.com> MIME-Version: 1.0 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: =?utf-8?q?Ma=C3=ADra_Canal?= , =?utf-8?q?Andr=C3=A9_A?= =?utf-8?q?lmeida?= , dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The struct drm_debugfs_list encapsulates all the debugfs-related objects, so that they can be initialized and destroyed with two helpers. Therefore, make the struct drm_device use the struct drm_debugfs_list instead of instantiating the debugfs list and mutex separated. Signed-off-by: MaĆ­ra Canal --- drivers/gpu/drm/drm_debugfs.c | 10 +++++----- drivers/gpu/drm/drm_drv.c | 7 ++++--- include/drm/drm_debugfs.h | 3 +++ include/drm/drm_device.h | 10 ++-------- 4 files changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 2f104a9e4276..176b0f8614e5 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -256,7 +256,7 @@ int drm_debugfs_init(struct drm_minor *minor, int minor_id, if (dev->driver->debugfs_init) dev->driver->debugfs_init(minor); - list_for_each_entry_safe(entry, tmp, &dev->debugfs_list, list) { + list_for_each_entry_safe(entry, tmp, &dev->debugfs_list.list, list) { debugfs_create_file(entry->file.name, 0444, minor->debugfs_root, entry, &drm_debugfs_entry_fops); list_del(&entry->list); @@ -273,7 +273,7 @@ void drm_debugfs_late_register(struct drm_device *dev) if (!minor) return; - list_for_each_entry_safe(entry, tmp, &dev->debugfs_list, list) { + list_for_each_entry_safe(entry, tmp, &dev->debugfs_list.list, list) { debugfs_create_file(entry->file.name, 0444, minor->debugfs_root, entry, &drm_debugfs_entry_fops); list_del(&entry->list); @@ -350,9 +350,9 @@ void drm_debugfs_add_file(struct drm_device *dev, const char *name, entry->file.data = data; entry->dev = dev; - mutex_lock(&dev->debugfs_mutex); - list_add(&entry->list, &dev->debugfs_list); - mutex_unlock(&dev->debugfs_mutex); + mutex_lock(&dev->debugfs_list.mutex); + list_add(&entry->list, &dev->debugfs_list.list); + mutex_unlock(&dev->debugfs_list.mutex); } EXPORT_SYMBOL(drm_debugfs_add_file); diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c index 11748dd513c3..89c63ead8653 100644 --- a/drivers/gpu/drm/drm_drv.c +++ b/drivers/gpu/drm/drm_drv.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -575,7 +576,7 @@ static void drm_dev_init_release(struct drm_device *dev, void *res) mutex_destroy(&dev->clientlist_mutex); mutex_destroy(&dev->filelist_mutex); mutex_destroy(&dev->struct_mutex); - mutex_destroy(&dev->debugfs_mutex); + drm_debugfs_list_destroy(&dev->debugfs_list); drm_legacy_destroy_members(dev); } @@ -609,14 +610,14 @@ static int drm_dev_init(struct drm_device *dev, INIT_LIST_HEAD(&dev->filelist_internal); INIT_LIST_HEAD(&dev->clientlist); INIT_LIST_HEAD(&dev->vblank_event_list); - INIT_LIST_HEAD(&dev->debugfs_list); spin_lock_init(&dev->event_lock); mutex_init(&dev->struct_mutex); mutex_init(&dev->filelist_mutex); mutex_init(&dev->clientlist_mutex); mutex_init(&dev->master_mutex); - mutex_init(&dev->debugfs_mutex); + + drm_debugfs_list_init(&dev->debugfs_list); ret = drmm_add_action_or_reset(dev, drm_dev_init_release, NULL); if (ret) diff --git a/include/drm/drm_debugfs.h b/include/drm/drm_debugfs.h index 8658e97a88cf..b4e22e7d4016 100644 --- a/include/drm/drm_debugfs.h +++ b/include/drm/drm_debugfs.h @@ -36,6 +36,9 @@ #include #include #include + +struct drm_device; + /** * struct drm_info_list - debugfs info list entry * diff --git a/include/drm/drm_device.h b/include/drm/drm_device.h index 282a171164ee..6ce10f9c7bae 100644 --- a/include/drm/drm_device.h +++ b/include/drm/drm_device.h @@ -6,6 +6,7 @@ #include #include +#include #include #include @@ -308,20 +309,13 @@ struct drm_device { */ struct drm_fb_helper *fb_helper; - /** - * @debugfs_mutex: - * - * Protects &debugfs_list access. - */ - struct mutex debugfs_mutex; - /** * @debugfs_list: * * List of debugfs files to be created by the DRM device. The files * must be added during drm_dev_register(). */ - struct list_head debugfs_list; + struct drm_debugfs_list debugfs_list; /* Everything below here is for legacy driver, never use! */ /* private: */