From patchwork Tue Jan 10 18:15:02 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: 41566 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2898792wrt; Tue, 10 Jan 2023 10:18:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXsJ68VdhsNgDvRYAwyrkj18h+Is8J2zmewsCBeBoziDp9bsILGNUiHYc8Ndn+m1R9jdHPXm X-Received: by 2002:a17:906:dff5:b0:7ef:b60e:cb02 with SMTP id lc21-20020a170906dff500b007efb60ecb02mr59930117ejc.48.1673374715203; Tue, 10 Jan 2023 10:18:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673374715; cv=none; d=google.com; s=arc-20160816; b=AFy4zZZJ8kQW5k6rBDFl0L/IiPCVFoz13dBJKsu/zePSHOMEXiS0tCnN9Nmz9CFnvT EzZCCPgHhvC763sH6X/xfyjVKR1AUBaEtVjQEf5kk4KU7LCfKp9q5RTnLpeLvBowqlXl mER1EBSH/2zfVm1HxIJNoQdK2O3EDEAPtYNDD5xhn3BqEOHlG3FLrLyq6urIX2yLhkGw vTTkF/Qyry8K/nNuCX4R/y7HJW8W4OrCYDTY7UVR7aoPL6K5tJM0/8wW1dDILFe/pT95 BqnHpQ+PzCG8U9v43yqd47d47UHxx67YvaM9q75EaQ/rwzhju4FabIjwp79vop6JPyBb zEUg== 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=v4UeLl7gdvWWXsIkkYPwzX79LPt1pjf/hSOaZlY9R0k=; b=gPDJG4UzE4lMlIWSabttqyi4weR/2zdcfYP5ZjOehYcw7aslJVTAdUfpuYuiPBqzKJ 5j6rL6yLaRTsKc9rAp8aOjjIxYFYDrvCrabj09egcj77kKTmu3K0Y3duSwHOLPihJ37s /DGOLR2K5qnnvTetDDcAqHPZxoL4yxc/10E4stWmXYWghMXJhztn7/8icRByH6X1IkBB 1KGZu0v6aYcc6nHNWj/QXYSaSkJ4zv462/Kof4JPCO7FDDGWFoAD/s4TsiME2YgeQubi Y2c/oB7kCQ94F49GSx2AXa6fGQM/bF8eFlGjKd49bowI63khwZqdtnDvPPBhGp2C7BMl Yu/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b="Un/LCm+J"; 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 xc13-20020a170907074d00b0084d7c8a4be0si4277390ejb.447.2023.01.10.10.18.08; Tue, 10 Jan 2023 10:18:35 -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="Un/LCm+J"; 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 S238666AbjAJSRo (ORCPT + 99 others); Tue, 10 Jan 2023 13:17:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58292 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235559AbjAJSQp (ORCPT ); Tue, 10 Jan 2023 13:16:45 -0500 Received: from msg-2.mailo.com (msg-2.mailo.com [213.182.54.12]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2726CE95 for ; Tue, 10 Jan 2023 10:15:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1673374506; bh=46jOppxp/mRe0pQqJxxPtA8TacbOHy69iOOY75PAV2I=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:In-Reply-To; b=Un/LCm+JeI9n6St9MsCyhiCrFmzHYsPDJknNa7kR//l5tlYOkHZnyZOdbOaQcT6oo EnX2AFn/vmyQgd+hiV2mx49D8MQtdLKsWEvVB3kPqRm7AePCfSv4JNDf51/oMg8bXs VWRghoJhbkfGkI/9aazql0dWAOeMibjhAvWP0FBo= Received: by b-2.in.mailobj.net [192.168.90.12] with ESMTP via ip-206.mailobj.net [213.182.55.206] Tue, 10 Jan 2023 19:15:06 +0100 (CET) X-EA-Auth: oa3uAoiVMRg8AVocdZ39yqZX4PN6plfP/DcwLlWgrYiXZmOfEdADt0JfkGi+PE73r+I+Zow0WtJW/txY4KbL2GOt8RJypu/x Date: Tue, 10 Jan 2023 23:45:02 +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 v2 1/2] drm/i915/display: Avoid full proxy f_ops for DRRS debug attributes Message-ID: <4f6ae3e9a1f674abd36295772e7ffd0aa3e4a30b.1673343994.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?1754660565518996038?= X-GMAIL-MSGID: =?utf-8?q?1754660565518996038?= 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 Reviewed-by: Rodrigo Vivi --- Changes in v2: - Include coccicheck make command in the patch log message for clarity. Suggested by Rodrigo Vivi drivers/gpu/drm/i915/display/intel_drrs.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) 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) From patchwork Tue Jan 10 18:15:40 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: 41567 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4e01:0:0:0:0:0 with SMTP id p1csp2899258wrt; Tue, 10 Jan 2023 10:19:28 -0800 (PST) X-Google-Smtp-Source: AMrXdXvHOOu0c/u5dwRhHj9e7TnsZ5i7Bn6jdcRFyr9bFuMfsYyuBif33rDsuLBwAogjbP12aZ6P X-Received: by 2002:a05:6402:249a:b0:45c:834b:f287 with SMTP id q26-20020a056402249a00b0045c834bf287mr61556192eda.4.1673374768647; Tue, 10 Jan 2023 10:19:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673374768; cv=none; d=google.com; s=arc-20160816; b=F/NK3arpjeqzQDgl0tSi7BvUw4XMl0x3jNYaZhfZSp2QOGSFzNArkr+MgWMDPkXuih PcsxogxmthLPGgk3c5tmUUG9QqSxvWtlqihINX9q8N39ZOeTY4KAo10GwOTn/02f1zQN AWKdkjrAoMKKFo9Q6lg20+JwghekXcI82FvhBUT993rUKCYZPqGuIPUJpvxeeK1bKwkN Ku+l+5n0sG8Ie0fjg0kJGbdCRLj6I2EEGIjDcutqXqB+78O+JevOVEdzcRlg2reg9NUy jd8gzZzCbYibYr69Jf0JvscqxnxglE7w2jK7CUiXP4OEzwdUefOWlhLOGkunDczUPL29 sO2A== 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=L0et0Iwh4II+l1pzbWwuzkmLuqwO1L41TYxNicl2ZHI=; b=xVLVDSI0It+AmByeZtNBPR16pFw+rWoRfQYXSHZUJcru0Y426J8zMwYt5Axc6YRHJp t9T2tmOuchHoD1j+snS691EL8E8q8ydPQS7Vv4V7Sb/Tqk52NXgikS5lYHqHB5XnwnyC VLvzOZo77eyxqk47DWnlc51DeyPwohX2NO37tM4HF7VanoXYkPc2wHmVBhaQdXDcvt3b XIRTJ+k4DGfbvHiczcUYz3mw7XQnGvR+eOwE5hyowwmdZmZpWCnlcG99T44Q8QLENMk4 etZKrbEO2Vvdvl+FmyAiBe6NgyYcGlrxRRuHQ+9Xz47ufGckmQOq4SpunIZJk/tD5jo7 3h1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mailo.com header.s=mailo header.b=fhuaQCNU; 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 wt9-20020a170906ee8900b007d82520def9si12754560ejb.503.2023.01.10.10.19.05; Tue, 10 Jan 2023 10:19:28 -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=fhuaQCNU; 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 S239152AbjAJSSI (ORCPT + 99 others); Tue, 10 Jan 2023 13:18:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60784 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239186AbjAJSR1 (ORCPT ); Tue, 10 Jan 2023 13:17:27 -0500 Received: from msg-1.mailo.com (msg-1.mailo.com [213.182.54.11]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5ABEE24 for ; Tue, 10 Jan 2023 10:15:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=mailo.com; s=mailo; t=1673374545; bh=NHddBNPO1QQ18FfEaBnCUlI5s+jWgOFNwyia4D6sg7w=; h=X-EA-Auth:Date:From:To:Cc:Subject:Message-ID:References: MIME-Version:Content-Type:In-Reply-To; b=fhuaQCNU4aqkNy8IvltfXYHiKjXNKab7xJ4GdhjO5+iK14gR0KqP8Lb15yJLmdn+4 ZJPUg6ubjpIcioPbFwtvTeeVEKQI/+l+vSc6NPF9fWrQI9NG1KG6oFMyGJn3UQ0wPY Xwf9rHBTzF7IVXITo1NYk6FebqOz7Y1cy/ekDxpI= Received: by b-2.in.mailobj.net [192.168.90.12] with ESMTP via ip-206.mailobj.net [213.182.55.206] Tue, 10 Jan 2023 19:15:45 +0100 (CET) X-EA-Auth: olbET+3pqyTe5pOhLU+kvrYYyDCkdw4Wa79wEbKz/tcHFusbfa3ow6jp8G+CJQgiZHyJbUyq314xdB46+SS0S6uUb8XWeoFS Date: Tue, 10 Jan 2023 23:45:40 +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 v2 2/2] drm/i915/fbc: Avoid full proxy f_ops for FBC debug attributes Message-ID: 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?1754660620896142029?= X-GMAIL-MSGID: =?utf-8?q?1754660620896142029?= 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 Reviewed-by: Rodrigo Vivi --- 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)