From patchwork Tue Dec 27 07:54:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 36783 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp1275281wrt; Mon, 26 Dec 2022 23:59:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXstjtompeefLFQNI/5EwBnPXBfqqErBSrFzxsibc62J5StC0KzM6vyjqppRWO5M0A4NmQZo X-Received: by 2002:a05:6a21:c011:b0:af:fcb6:2ee2 with SMTP id bm17-20020a056a21c01100b000affcb62ee2mr27675734pzc.47.1672127981794; Mon, 26 Dec 2022 23:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672127981; cv=none; d=google.com; s=arc-20160816; b=YyP73jQusBBfs8YCBDu56m7sAeD64LOR5eiaujbNd0iruYTIMh2W1iKa3kFxOzwB79 w3iTATHzC2Q9hv/WzLvFfUFMcJmc6Myo+F40haUY/BYn4fZPKGRW8zcCSEH2MGSiKioY R3gQ60g6l5aDlmiN2ksJP/YM7JoXBnsbSg/JdWYqn6l/Pi58UPOdptAlmUXOL3vs6WBF 33H/dC/B2jq47lMWIr8XKBnuoiKt1pbiZwVhrfp2bMQEh8Ldr3Y0Qih6Wihy0ZUaX2VO z9VSeQFP5LfP1+CenvlqPzAy4e3OykD3ZaydsqY/xNQYPP0nwyKeo2rdofLtD2Wbaqb2 /9Gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-disposition:mime-version:message-id :subject:cc:to:from:date:dkim-signature; bh=ZcPb3Jubc2v3jzKWKnzliys86epUxILQP2jQGeOEv7g=; b=tTRiGkkH+eIN+lTSWRLTg5O0HJ5HgWdPtEJt/oq4TF/2wxkb3FVQQX3oF/P1EmIHiP KP8NKQZsDfB2mD1utMa7K/9D2V3yrxCcM2IfiUz9GNC1A6inHaLhVzLiQgIqGVI+kJab taS7AhPFdacKBwNyOuxD25kGfIklXAHovfWajBI8n8xczpp3fqsgJJdwjlXjCX9wE49o eaqNLQUmJ7XeRKsBoV0ThtAIT8roy3cmjEUGEyQ2cLFJeRQKUcXFtDjukZ2m5CtyjHLp EOL2VadcNzaEluRXFB/cSMJkeOadLTDvXCdorDFuC00C41Y6eg7hW1KbxzAXiW4JzQZQ UhgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=QCqXgq8O; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k9-20020a634b49000000b0047ff30aeacesi13678605pgl.301.2022.12.26.23.59.29; Mon, 26 Dec 2022 23:59:41 -0800 (PST) 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=fail header.i=@mailo.com header.s=mailo header.b=QCqXgq8O; 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=fail (p=NONE sp=NONE dis=NONE) header.from=mailo.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230325AbiL0HzO (ORCPT + 99 others); Tue, 27 Dec 2022 02:55:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51848 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230259AbiL0HzG (ORCPT ); Tue, 27 Dec 2022 02:55:06 -0500 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 60F906147 for ; Mon, 26 Dec 2022 23:55:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1672127688; bh=giLygN6VCt7V445nQatslkp77AOYXtWjJUE7E0bEqc0=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:MIME-Version: Content-Type; b=QCqXgq8OvC0nS2bvkqSJGiSC4vJEpFoCCALoQUcVCT4D3XEaiDtb1L8tJGJKo9bHo 0wVRz/R+tSsQ6WUVRx4ievKOIoP4Lu5e6PBAYCTxWlJYcxB8v5UReEZRb0q8O5ro3G ZLqMs3FLEz9Cheb7v1fV9WXMRCBL5GQ8egm0c11k= Received: by b-2.in.mailobj.net [192.168.90.12] with ESMTP via ip-206.mailobj.net [213.182.55.206] Tue, 27 Dec 2022 08:54:48 +0100 (CET) X-EA-Auth: Y/txN7h7M1NSBRb/aAVjjQNqoV1iyiWxffr+VZOusP9tx6BTq8pNJEqpfWcIfiLuIBYbzBtgFVghFHIsVPbvkC8b7+YujL3P Date: Tue, 27 Dec 2022 13:24:39 +0530 From: Deepak R Varma To: Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Tvrtko Ursulin , David Airlie , Daniel Vetter , intel-gfx@lists.freedesktop.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Cc: Saurabh Singh Sengar , Praveen Kumar , Deepak R Varma Subject: [PATCH] drm/i915/display: Avoid full proxy f_ops for DRRS debug attributes Message-ID: MIME-Version: 1.0 Content-Disposition: inline X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1753353270789313019?= X-GMAIL-MSGID: =?utf-8?q?1753353270789313019?= Using DEFINE_SIMPLE_ATTRIBUTE macro with the debugfs_create_file() function adds the overhead of introducing a proxy file operation functions to wrap the original read/write inside file removal protection functions. This adds significant overhead in terms of introducing and managing the proxy factory file operations structure and function wrapping at runtime. As a replacement, a combination of DEFINE_DEBUGFS_ATTRIBUTE macro paired with debugfs_create_file_unsafe() is suggested to be used instead. The DEFINE_DEBUGFS_ATTRIBUTE utilises debugfs_file_get() and debugfs_file_put() wrappers to protect the original read and write function calls for the debug attributes. There is no need for any runtime proxy file operations to be managed by the debugfs core. This Change is reported by the debugfs_simple_attr.cocci Coccinelle semantic patch. Signed-off-by: Deepak R Varma --- drivers/gpu/drm/i915/display/intel_drrs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.34.1 diff --git a/drivers/gpu/drm/i915/display/intel_drrs.c b/drivers/gpu/drm/i915/display/intel_drrs.c index 5b9e44443814..84ba7379d6f8 100644 --- a/drivers/gpu/drm/i915/display/intel_drrs.c +++ b/drivers/gpu/drm/i915/display/intel_drrs.c @@ -374,16 +374,16 @@ static int intel_drrs_debugfs_ctl_set(void *data, u64 val) return ret; } -DEFINE_SIMPLE_ATTRIBUTE(intel_drrs_debugfs_ctl_fops, - NULL, intel_drrs_debugfs_ctl_set, "%llu\n"); +DEFINE_DEBUGFS_ATTRIBUTE(intel_drrs_debugfs_ctl_fops, + NULL, intel_drrs_debugfs_ctl_set, "%llu\n"); void intel_drrs_crtc_debugfs_add(struct intel_crtc *crtc) { debugfs_create_file("i915_drrs_status", 0444, crtc->base.debugfs_entry, crtc, &intel_drrs_debugfs_status_fops); - debugfs_create_file("i915_drrs_ctl", 0644, crtc->base.debugfs_entry, - crtc, &intel_drrs_debugfs_ctl_fops); + debugfs_create_file_unsafe("i915_drrs_ctl", 0644, crtc->base.debugfs_entry, + crtc, &intel_drrs_debugfs_ctl_fops); } static int intel_drrs_debugfs_type_show(struct seq_file *m, void *unused)