From patchwork Wed Jan 11 15:51:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Deepak R Varma X-Patchwork-Id: 42068 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp3397173wrt; Wed, 11 Jan 2023 07:55:10 -0800 (PST) X-Google-Smtp-Source: AMrXdXvvNWjAmFsnMI1vmuJO5D4+C5Z6rDLoD8bAqspOymIZ0IE05WqLxoEP+0/TGrEfVXO8DfOJ X-Received: by 2002:a62:148f:0:b0:582:46a4:87f6 with SMTP id 137-20020a62148f000000b0058246a487f6mr34053118pfu.22.1673452510272; Wed, 11 Jan 2023 07:55:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673452510; cv=none; d=google.com; s=arc-20160816; b=jgit860G5F5M67H3BH9svDVp0Kb/ItiP89K/YFl+4cwUEwhPOv6oA7yRGP0iTFlJ0q fSa2CjAnWeWURW51z3SwVk8zj8k9HyluXv9WkXOKge28yC/bMUzZE7RxPx5hVCJD05eU RYpXJrQFqyaYFEp6ZKkOers9LRHtRM5TqRuO23RlIikF699l8dgPfzX10K2UTjwki4Co 8oKXkab0HMsAAveV58k2tJ+x0oYxV3HpH1HzGh6NfgAeinpKEcPDWCOHA1/jKW3KmqOx iJpagBnf7h9+CLqimcnDgzWdaITvyg2t9vKBTJhO4tzq0All6LWIbH9FFszl8ff1RyVU t0uQ== 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=U51mL0vqiEPuVw5+AgbgTiev79Jw0LZJiiekNarO7rU=; b=B4rbAuA8CfTtP1T7Xqyc2ci97lOMPiz6BLLUpAzrclk6RLK1zm5OiuvhM4tCRqrcXI gMyND1zjg2BPF6sx2wQXXRDUhzMwxEc2LuiLvKJeaULp99Vw7sKegcWZVKh3o+iLgm7/ 4HzWVSDnd4GB3pJlqEnFPESWEwVdQwfq22wfqWVkNM7jA4JqPhkebKXF7D+b9KYN+P89 yUqzCu+zn/j67NN82G6/iCKvyoNvH/tO9uAKoBS/5vBVxrKITMwOComEnSfbCnvvGYWh 0c+k3sDnaeYPzrGuQunQKpcL7w9FcoC/oKJ6vHHanSLbA7X5frCPqPu9WU518Uk2h5R9 hVMw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=dhQ76Q5q; 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 e10-20020a056a001a8a00b0056aafb43783si15703785pfv.155.2023.01.11.07.54.57; Wed, 11 Jan 2023 07:55:10 -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=dhQ76Q5q; 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 S232134AbjAKPwt (ORCPT + 99 others); Wed, 11 Jan 2023 10:52:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40704 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239532AbjAKPwZ (ORCPT ); Wed, 11 Jan 2023 10:52:25 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C75EB3475B for ; Wed, 11 Jan 2023 07:52:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1673452324; bh=QHeZldMKVWp9Cp9mxOeha2QFBOXYtsTVP8kjQEfSrZw=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:In-Reply-To; b=dhQ76Q5qWbdwieoX7S8a3HflKBaJR5R0TTGJXGnzA32tstm4XcijZEOvFS62J5qM5 VaQJIcf8JLwEM0aMQYeS8QIdcD7CJm5uN1jgkn/WSHLOy0PbnPvxXEKQzPhgzUzccW a0baxbbbXs7geGagVcVdV/18+jQTMvgzKA4nmfMc= Received: by b-1.in.mailobj.net [192.168.90.11] with ESMTP via ip-206.mailobj.net [213.182.55.206] Wed, 11 Jan 2023 16:52:03 +0100 (CET) X-EA-Auth: u5jvOLR5x9//Zkc8IMR5oNVJAAF0lJRlVIyLovRtl5gS15Vj30kxR2eXf+WDRR0PXE7lTP9chqyCJpfbE+S9CoqnkWNXnn/t Date: Wed, 11 Jan 2023 21:21:59 +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 Subject: [PATCH v3 2/2] drm/i915/fbc: Avoid full proxy f_ops for FBC debug attributes Message-ID: <5d26e924ec8dea21925c77fa79a2bf2a34cef705.1673451705.git.drv@mailo.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: 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?1754742139420274492?= X-GMAIL-MSGID: =?utf-8?q?1754742139420274492?= 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. Following coccicheck make command helped identify this change: make coccicheck M=drivers/gpu/drm/i915/ MODE=patch COCCI=./scripts/coccinelle/api/debugfs/debugfs_simple_attr.cocci Signed-off-by: Deepak R Varma --- Changes in v3: - None Changes in v2: - Include coccicheck make command in the patch log message for clarity. Suggested by Rodrigo Vivi drivers/gpu/drm/i915/display/intel_fbc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/i915/display/intel_fbc.c b/drivers/gpu/drm/i915/display/intel_fbc.c index 5e69d3c11d21..c508dcf415b4 100644 --- a/drivers/gpu/drm/i915/display/intel_fbc.c +++ b/drivers/gpu/drm/i915/display/intel_fbc.c @@ -1807,10 +1807,10 @@ static int intel_fbc_debugfs_false_color_set(void *data, u64 val) return 0; } -DEFINE_SIMPLE_ATTRIBUTE(intel_fbc_debugfs_false_color_fops, - intel_fbc_debugfs_false_color_get, - intel_fbc_debugfs_false_color_set, - "%llu\n"); +DEFINE_DEBUGFS_ATTRIBUTE(intel_fbc_debugfs_false_color_fops, + intel_fbc_debugfs_false_color_get, + intel_fbc_debugfs_false_color_set, + "%llu\n"); static void intel_fbc_debugfs_add(struct intel_fbc *fbc, struct dentry *parent) @@ -1819,8 +1819,8 @@ static void intel_fbc_debugfs_add(struct intel_fbc *fbc, fbc, &intel_fbc_debugfs_status_fops); if (fbc->funcs->set_false_color) - debugfs_create_file("i915_fbc_false_color", 0644, parent, - fbc, &intel_fbc_debugfs_false_color_fops); + debugfs_create_file_unsafe("i915_fbc_false_color", 0644, parent, + fbc, &intel_fbc_debugfs_false_color_fops); } void intel_fbc_crtc_debugfs_add(struct intel_crtc *crtc)