From patchwork Sat Jul 31 21:41:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12412745 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A90C8C4338F for ; Sat, 31 Jul 2021 21:42:30 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6A36560F39 for ; Sat, 31 Jul 2021 21:42:30 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6A36560F39 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id C8D786E8C7; Sat, 31 Jul 2021 21:42:27 +0000 (UTC) Received: from mail-io1-xd2f.google.com (mail-io1-xd2f.google.com [IPv6:2607:f8b0:4864:20::d2f]) by gabe.freedesktop.org (Postfix) with ESMTPS id 471646E833; Sat, 31 Jul 2021 21:42:26 +0000 (UTC) Received: by mail-io1-xd2f.google.com with SMTP id a1so1160575ioa.12; Sat, 31 Jul 2021 14:42:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=kmHsDnFQwSbOnRKSJ1vga0OhlV8P3CEw6FanKWDIy40=; b=U9BvI1glpc+yDSbM/DPm8s6F7ztnI0CJPlfd/CvD4PiMnHYiqRFdaAPiOIaj3wy9a5 UBEUc1TXEMS6bFRQRXOsMekQ68EdjCQaKc1Mqogn1UN2W7+7XMdiMJ8AV4fH8sbcUjQm TdlL4IbV9HumLEKzoFkUwYDDZqQwBIhy4Iqwu6aG4l4Fqr+8NEGK5cfzaRd5VM4kHqA+ /gmJNe4dJcAwy8rTTd2WHR5Rej9fhrpZ58dQzRMV///Mmj2uOm/zwHCn+E1CXjtXOvpr OGEBpaj0ipVFD35gduXa+vjXyJfLpFZdhimrND3VFeciLZywwIzpFhe2nqgYqRvnWEAu FqbQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kmHsDnFQwSbOnRKSJ1vga0OhlV8P3CEw6FanKWDIy40=; b=Uxv6bTdavg9Er322BQ/ba8PmgKkQ3+m47DWeqRy2zeRhALsjl9gDQHEiamlY9cYpBa hNBuaMvTIImuf4O07mHX/T+RVRG9KpTXygA+YZqpgxOw42oT4dwQbNYUQeSknss3e1Xn u37ZBWQzR3dCIBBYyYYFZCUndfRi4yo6u+AiwpacKSGMEE+rXprqTlSJWytMPIqq94Hb 0PQH+qb3K/NUzb6Vepeq/8H6JtzJoP6/fnPWQ837sKFdRrTJwjgNOYRfWjUEvhZSjGcD 5WyZlg/M1U4Bj6coI7/+kvHBg7oK+E++3VIIWCvBxOa23XwesGnQ7iACJby+NroANYyL wzeg== X-Gm-Message-State: AOAM533ayuvFk2wNXCocf29nH1V3WlbGSD+TuD/eeRKLzdxiO3zvGV5l hjo042nUFwEUKuTbjZmMwHQ= X-Google-Smtp-Source: ABdhPJwHNkMohciy9QMc9txPm4gNPWvEEssmPLZfOVFLAQW4UOPDVFX6Ry/jP25YRbLh9pAP7h24lA== X-Received: by 2002:a5e:c006:: with SMTP id u6mr6101793iol.66.1627767745609; Sat, 31 Jul 2021 14:42:25 -0700 (PDT) Received: from frodo.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id q10sm3721040ion.3.2021.07.31.14.42.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 14:42:25 -0700 (PDT) From: Jim Cromie To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Harry Wentland , Leo Li , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , Zhenyu Wang , Zhi Wang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Jason Baron , Ashley Thomas , Qingqing Zhuo , Wyatt Wood , Aurabindo Pillai , Jim Cromie , Johan Hovold , Jessica Yu , Nick Desaulniers , Joe Perches , Miguel Ojeda , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [PATCH v4 1/7] drm/print: fixup spelling in a comment Date: Sat, 31 Jul 2021 15:41:58 -0600 Message-Id: <20210731214211.657280-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210731214211.657280-1-jim.cromie@gmail.com> References: <20210731214211.657280-1-jim.cromie@gmail.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" s/prink/printk/ - no functional changes Signed-off-by: Jim Cromie --- include/drm/drm_print.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 9b66be54dd16..15a089a87c22 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -327,7 +327,7 @@ static inline bool drm_debug_enabled(enum drm_debug_category category) /* * struct device based logging * - * Prefer drm_device based logging over device or prink based logging. + * Prefer drm_device based logging over device or printk based logging. */ __printf(3, 4) From patchwork Sat Jul 31 21:41:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12412747 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 47FE5C4338F for ; Sat, 31 Jul 2021 21:42:36 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 0F43660F39 for ; Sat, 31 Jul 2021 21:42:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 0F43660F39 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7E2AE6E2A3; Sat, 31 Jul 2021 21:42:35 +0000 (UTC) Received: from mail-il1-x12b.google.com (mail-il1-x12b.google.com [IPv6:2607:f8b0:4864:20::12b]) by gabe.freedesktop.org (Postfix) with ESMTPS id C7EB76E8F2; Sat, 31 Jul 2021 21:42:32 +0000 (UTC) Received: by mail-il1-x12b.google.com with SMTP id r1so13010025iln.6; Sat, 31 Jul 2021 14:42:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=FVzAd0b7G06F+b9x5+FC/aHuzWCnZbaicUuNK8fUHeA=; b=im7afXLgSWUILaAASEAeZU/LwwVX1SZ6P517INeRbwmW2P/hFuwWJObGJH8hqMSqqj bcO77GbwKF8aa9UNSH2YQo6Jc0lfiHjybWGqyfM1sWZVmbaKm7G/AEhi94bV8Zauy049 Mc95i1CHbX/T/92IWCD6PLmCQBaYSKTtRsvubIh5EWWT643Uxi5REtHwbJE/86rgawga 4ZhtIzDi0lp1xjpELCec1MWDNg9ujPcI7cUvV/MLyoEdv3egmEC7JVqd4/xyxS51uVCK NQeVFQBKnUxB2Pcpha9cPwMO41WTZ3+RSw+NZb9ZalXrRlTLV7nOTEq/dVxUdzkSsvbl KJwg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FVzAd0b7G06F+b9x5+FC/aHuzWCnZbaicUuNK8fUHeA=; b=aJ+G5p7XNGjcH/58PwurQQFhDzgInzfkqVJgs9LM9Kzwrt4TZofhyUu6BGfVRAwiSq fMSoTaGThcldZTTroWiE9kKuIJdJ7knr0BwY+HtiQ/mcvUTrHNStMIMG9hW3RL705HWW TuvsYXk3VFTxEZsyrSAZcfatOlUs8Kg49H4Ebb78K6hIWahuVjZLVaSfrAZF79DDQs+7 fcRaPCCAAua6ROxzufIuttlbpIn8gYKDJOQPkfqKjU9RTxwbMA6BaHjnOI9C07fQAc6F smbHnUKz8ePgELLT4r4JrgUxvpT8C0nTZFW0irJoicc+07GCug2BKbjg42b1rDjZxBnh AhXg== X-Gm-Message-State: AOAM531ngjEPPxftZJmYdpndsHEIJDLLSnqu40H2v8rBRj5JweCkbYhO 2sUxkC/Db2jLAL+aSvdiy68= X-Google-Smtp-Source: ABdhPJwOVDZdNuyCxOD9UoCaMWITVwXrdhXAHTL3qSQNIVo5TmDJ1ed0abVTIJeR08hq9h9Tw27odg== X-Received: by 2002:a92:d112:: with SMTP id a18mr5649773ilb.67.1627767752154; Sat, 31 Jul 2021 14:42:32 -0700 (PDT) Received: from frodo.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id q10sm3721040ion.3.2021.07.31.14.42.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 14:42:31 -0700 (PDT) From: Jim Cromie To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Harry Wentland , Leo Li , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , Zhenyu Wang , Zhi Wang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Jason Baron , Ashley Thomas , Aurabindo Pillai , Qingqing Zhuo , Wyatt Wood , Jim Cromie , Jessica Yu , Johan Hovold , Joe Perches , Miguel Ojeda , Nick Desaulniers , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [PATCH v4 2/7] moduleparam: add data member to struct kernel_param Date: Sat, 31 Jul 2021 15:41:59 -0600 Message-Id: <20210731214211.657280-3-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210731214211.657280-1-jim.cromie@gmail.com> References: <20210731214211.657280-1-jim.cromie@gmail.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a void* data member to the struct, to allow attaching private data that will be used soon by a setter method (via kp->data) to perform more elaborate actions. To attach the data at compile time, add new macros: module_param_cbd() derives from module_param_cb(), adding data param. It calls __module_param_call_wdata(), which has accepts new data param and inits .data with it. Re-define __module_param_call() using it. Use of this new data member will be rare, it might be worth redoing this as a separate/sub-type to keep the base case. Signed-off-by: Jim Cromie --- include/linux/moduleparam.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/include/linux/moduleparam.h b/include/linux/moduleparam.h index eed280fae433..e9495b1e794d 100644 --- a/include/linux/moduleparam.h +++ b/include/linux/moduleparam.h @@ -78,6 +78,7 @@ struct kernel_param { const struct kparam_string *str; const struct kparam_array *arr; }; + void *data; }; extern const struct kernel_param __start___param[], __stop___param[]; @@ -175,6 +176,9 @@ struct kparam_array #define module_param_cb(name, ops, arg, perm) \ __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0) +#define module_param_cbd(name, ops, arg, perm, data) \ + __module_param_call_wdata(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, 0, data) + #define module_param_cb_unsafe(name, ops, arg, perm) \ __module_param_call(MODULE_PARAM_PREFIX, name, ops, arg, perm, -1, \ KERNEL_PARAM_FL_UNSAFE) @@ -284,14 +288,17 @@ struct kparam_array /* This is the fundamental function for registering boot/module parameters. */ -#define __module_param_call(prefix, name, ops, arg, perm, level, flags) \ +#define __module_param_call(prefix, name, ops, arg, perm, level, flags) \ + __module_param_call_wdata(prefix, name, ops, arg, perm, level, flags, NULL) + +#define __module_param_call_wdata(prefix, name, ops, arg, perm, level, flags, data) \ /* Default value instead of permissions? */ \ static const char __param_str_##name[] = prefix #name; \ static struct kernel_param __moduleparam_const __param_##name \ __used __section("__param") \ __aligned(__alignof__(struct kernel_param)) \ = { __param_str_##name, THIS_MODULE, ops, \ - VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg } } + VERIFY_OCTAL_PERMISSIONS(perm), level, flags, { arg }, data } /* Obsolete - use module_param_cb() */ #define module_param_call(name, _set, _get, arg, perm) \ From patchwork Sat Jul 31 21:42:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12412749 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C1E9AC4338F for ; Sat, 31 Jul 2021 21:42:43 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 94CBF60F39 for ; Sat, 31 Jul 2021 21:42:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 94CBF60F39 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id EB66D6E906; Sat, 31 Jul 2021 21:42:42 +0000 (UTC) Received: from mail-io1-xd2e.google.com (mail-io1-xd2e.google.com [IPv6:2607:f8b0:4864:20::d2e]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4765A6E8FB; Sat, 31 Jul 2021 21:42:39 +0000 (UTC) Received: by mail-io1-xd2e.google.com with SMTP id h1so15809633iol.9; Sat, 31 Jul 2021 14:42:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=TarqHKb2wh9HC+czOpmfvpe+4WJMCMhoUET0HeAvQsg=; b=ChHEB9cn1Lk8yB5rfWFQ1d5yu+CRBv6BPI2R74etPqUCzJgU0BAuSuspXSZXz7q+65 Rqx3mbokyv+23fwMzoEP10GrYIrqp9gsrU/wAzIo4KLqsW9Mp88Dp/k5PPfq/nyHPYqv GAAP8fLAEu39c4S5vjxbaUPBTAgMrrpAOQPSwPUHnuzF7S1ZoZY3Hut+uNkJrpoFvsLr ZLm8Yn/ZQDE3Y9R3QyKBW8vnjIMzh1/SrhbwUmlcqvS+PKPewpMtXyeHf08ev2WaqXaJ 1sGc+yd14y5kw11gIiokecM+s+x7KNmonzI4UenSCXK29vNtwUfBomYKRpG06bIEhQXJ D/VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=TarqHKb2wh9HC+czOpmfvpe+4WJMCMhoUET0HeAvQsg=; b=JuRTHgEzL49rDWaId9HOCrBauQ236/DCB0VJPwGUZ8WdMPCoo7Gv3i28xd+CxKMvis nv+L8Y8uAXYKBaJy1TjgmT8MQhJLN1kpKMym0B7ZxQXnr1dkJK0gYdYnmgOXShBumRo1 mXB2wJ4bt4/qL93B1Mo06CrU+neNhEBoUlt2eGovORTZLRjpoqbroMrvfOku+gBCo1qm H5wEEMf7jIELYSZldxIz2diTtspNfazs5ZHH9PosKiq5xNfgHTVCq/DiHaN7BGGpbS2E 3DaL+9e34+4wcerNYdK0q6eu42xYjpkF47y1Ao1XcNANMd1DBTvqIVgsdfnOakA2vXJx wkvw== X-Gm-Message-State: AOAM531mgnalFg9/rZjgcRUTnviOMDvEI+5IAgQZce7KCS9sHK7us47o F3DCszorQw1T+OIOk8aLjtY= X-Google-Smtp-Source: ABdhPJwVYVK0Xb4+Y+xg/kICohGw6QY3fg7nUx88vH0xZrpT+G5YyF7mdDH9vGymQy1CL8T8OS1Lig== X-Received: by 2002:a02:2a07:: with SMTP id w7mr7722468jaw.96.1627767758496; Sat, 31 Jul 2021 14:42:38 -0700 (PDT) Received: from frodo.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id q10sm3721040ion.3.2021.07.31.14.42.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 14:42:38 -0700 (PDT) From: Jim Cromie To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Harry Wentland , Leo Li , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , Zhenyu Wang , Zhi Wang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Jason Baron , Ashley Thomas , Qingqing Zhuo , Aurabindo Pillai , Wyatt Wood , Jim Cromie , Johan Hovold , Jessica Yu , Joe Perches , Miguel Ojeda , Nick Desaulniers , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [PATCH v4 3/7] dyndbg: add dyndbg-bitmap definer and callbacks Date: Sat, 31 Jul 2021 15:42:00 -0600 Message-Id: <20210731214211.657280-4-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210731214211.657280-1-jim.cromie@gmail.com> References: <20210731214211.657280-1-jim.cromie@gmail.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add DEFINE_DYNDBG_BITMAP(name, var, bitmap_desc, @bit_descs) to allow users to define a /sys/module/*/parameter/name, and a mapping from bits[0-N] to the debug-class-prefixes that the author wishes to control. DEFINE_DYNDBG_BITMAP(debug_gvt, __gvt_debug, "dyndbg bitmap desc", { "gvt:cmd: ", "command processing" }, { "gvt:core: ", "core help" }, { "gvt:dpy: ", "display help" }, { "gvt:el: ", "help" }, { "gvt:irq: ", "help" }, { "gvt:mm: ", "help" }, { "gvt:mmio: ", "help" }, { "gvt:render: ", "help" }, { "gvt:sched: ", "help" }); dynamic_debug.c: add 3 new elements: - int param_set_dyndbg() - not working yet, // __gvt_debug - int param_get_dyndbg() - struct param_ops_dyndbg Following the model of kernel/params.c STANDARD_PARAM_DEFS, All 3 are non-static and exported. dynamic_debug.h: extern the struct param_ops_dyndbg prototype. This appears to be needed to reference the var, forex in i915_params.c TBD: set_dyndbg() works to enable categories, but fails to disable them. This is because the code relied on having an old copy of the param (__gvt_debug) to detect +/- changes. Rewriting the loop is probably easier than stashing the old state for change detection. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 36 +++++++++++++++++++++++ lib/dynamic_debug.c | 55 +++++++++++++++++++++++++++++++++++ 2 files changed, 91 insertions(+) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index dce631e678dd..677ad176b167 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -2,6 +2,8 @@ #ifndef _DYNAMIC_DEBUG_H #define _DYNAMIC_DEBUG_H +#include + #if defined(CONFIG_JUMP_LABEL) #include #endif @@ -227,6 +229,40 @@ static inline int dynamic_debug_exec_queries(const char *query, const char *modn return 0; } +static int param_set_dyndbg(const char *instr, struct kernel_param *kp) +{ return 0; } +static int param_get_dyndbg(char *buffer, struct kernel_param *kp) +{ return 0; } + #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ +struct dyndbg_bitdesc { + /* bitpos is inferred from index in containing array */ + char *prefix; + char *help; +}; + +/** + * DYNDBG_BITMAP_DESC(name, var, bitmap_desc, @bit_descs) + * @name: basename under /sys + * @var: C identifier to map + * @bitmap_desc: string summarizing dyndbg categories + * @bit_descs: list of struct dydbg_bitdesc initializations + * + * Defines the mapping of bits 0-N to categories/prefixes of + * debug-callsites to be controlled. + * + * Users should also call MODULE_PARM_DESC(name, bitmap_desc). + * Maybe we can invoke it on their behalf, but we want MOD-NAME to be + * correct, test soon. may also need modname in name - "debug" will + * not be unique. + */ +#define DEFINE_DYNDBG_BITMAP(name, value, bitmap_desc, ...) \ + struct dyndbg_bitdesc dyndbg_classes_##name[] = \ + { __VA_ARGS__, { NULL, NULL } }; \ + module_param_cbd(name, ¶m_ops_dyndbg, value, 0644, \ + &dyndbg_classes_##name); + +extern const struct kernel_param_ops param_ops_dyndbg; + #endif diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index cb5abb42c16a..045e1cf92c44 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1154,3 +1154,58 @@ early_initcall(dynamic_debug_init); /* Debugfs setup must be done later */ fs_initcall(dynamic_debug_init_control); + +#include + +#define OUR_QUERY_SIZE 128 /* typically need <40 */ + +int param_set_dyndbg(const char *instr, const struct kernel_param *kp) +{ + unsigned int val; + unsigned long changes, result; + int rc, chgct = 0, totct = 0, bitpos, bitsmax; + char query[OUR_QUERY_SIZE]; + struct dyndbg_bitdesc *bitmap = (struct dyndbg_bitdesc *) kp->data; + + // pr_info("set_dyndbg: instr: %s curr: %d\n", instr, *kp->arg); + + rc = kstrtouint(instr, 0, &val); + if (rc) { + pr_err("set_dyndbg: failed\n"); + return -EINVAL; + } + result = val; + pr_info("set_dyndbg: result:0x%lx from %s\n", result, instr); + + changes = result; // ^ __gvt_debug; + + for (bitsmax = 0; bitmap[bitsmax].prefix; bitsmax++); + + for_each_set_bit(bitpos, &changes, min(--bitsmax, 64)) { + + sprintf(query, "format '^%s' %cp", bitmap[bitpos].prefix, + test_bit(bitpos, &result) ? '+' : '-'); + + chgct = dynamic_debug_exec_queries(query, "i915"); + + pr_info("bit-%d: %d changes on: %s\n", bitpos, chgct, query); + totct += chgct; + } + pr_info("total changes: %d\n", totct); + // __gvt_debug = result; + return 0; +} +EXPORT_SYMBOL(param_set_dyndbg); + +int param_get_dyndbg(char *buffer, const struct kernel_param *kp) +{ + return scnprintf(buffer, PAGE_SIZE, "%u\n", + *((unsigned int *)kp->arg)); +} +EXPORT_SYMBOL(param_get_dyndbg); + +const struct kernel_param_ops param_ops_dyndbg = { + .set = param_set_dyndbg, + .get = param_get_dyndbg, +}; +EXPORT_SYMBOL(param_ops_dyndbg); From patchwork Sat Jul 31 21:42:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12412751 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 137A6C4338F for ; Sat, 31 Jul 2021 21:42:52 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id D927D60F46 for ; Sat, 31 Jul 2021 21:42:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org D927D60F46 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 707426E833; Sat, 31 Jul 2021 21:42:51 +0000 (UTC) Received: from mail-il1-x132.google.com (mail-il1-x132.google.com [IPv6:2607:f8b0:4864:20::132]) by gabe.freedesktop.org (Postfix) with ESMTPS id EB0616E90A; Sat, 31 Jul 2021 21:42:45 +0000 (UTC) Received: by mail-il1-x132.google.com with SMTP id c3so13024583ilh.3; Sat, 31 Jul 2021 14:42:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=xPck7MMABBW1WtH6n+xcidO56Avpeo49SggTpQTKxus=; b=AexSXd2PXlmD2Clg3eVEPdYp3vl1NLUrBzV3KgrgcMfxWzO8W6+/+i8hXtB8HqNeqm zuCPHcu8pvMJiXxE28nu7X9mNIjYr57YpVy1sOWu+vv3JrksNi9rDQCl5io2q2T/D31A ui/8qTw3jHS3AVmBdWb2syc1XgPVeNWZ908NJHyYJJO/uyAp3PObAKpSaTCLBGnbMNEe SVJYa0kvCwwUvJ5dJtxSLgCcuM60bLkTaiV57aDet/X8y6JZ9CKzWUfS+qMaKq/B8GO7 j91IfyIDkHrfdsSEOT+BSSJ/Y2d21wWsMlRWnoUMMoY1w/6fGTcKr4uc8cArAkDKWV3E y/ag== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xPck7MMABBW1WtH6n+xcidO56Avpeo49SggTpQTKxus=; b=ALQfPCC+WdwPFXcKjwlLu8lx9Q6CWonLa8LuC0mTInBxLdAg/tcgxRQoT+yDbW+oMT e8nw2Q+789Bel+3H3HzEST1r8m3q87c7zQwBPC2iBYNbe9pUQz5gcPxjVsbPUqylXqiv ykK/w3RC7kO+Z72+CiSTNqH1hX6Zs/OIUJTq2G/rDi+LF6a2C3AF3u2oftii6RKK12HJ Y38BCfqTJyEgdU7GBL/g4r9TFBj1h71hMvK+Ggr/QHsfZOEThOi9tZskgDX0g/JnoFcQ YtavsWunbNRxKmwFoygEbLm6R1nd9irhUTMnm6sHpPskPNr2adUw0Dbi1wzDzYVjEfpf 4H7A== X-Gm-Message-State: AOAM532RN3n9D+J1t8aKuxAewblMBfmQNYsn9GWzHVS/xkdfX7lxZXKk 5uFSdDQguZvV31ahgFVPC0k= X-Google-Smtp-Source: ABdhPJwQjrRtHttvc3vCaTEHaO1jjg2Zrk/t8zWB73N8dPAu1dBcfj2fmbzg3rQBcmT5QP+vbvn2zg== X-Received: by 2002:a92:7b13:: with SMTP id w19mr2318517ilc.291.1627767765231; Sat, 31 Jul 2021 14:42:45 -0700 (PDT) Received: from frodo.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id q10sm3721040ion.3.2021.07.31.14.42.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 14:42:44 -0700 (PDT) From: Jim Cromie To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Harry Wentland , Leo Li , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , Zhenyu Wang , Zhi Wang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Jason Baron , Ashley Thomas , Aurabindo Pillai , Wyatt Wood , Qingqing Zhuo , Jim Cromie , Jessica Yu , Johan Hovold , Miguel Ojeda , Joe Perches , Nick Desaulniers , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [PATCH v4 4/7] i915/gvt: remove spaces in pr_debug "gvt: core:" etc prefixes Date: Sat, 31 Jul 2021 15:42:01 -0600 Message-Id: <20210731214211.657280-5-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210731214211.657280-1-jim.cromie@gmail.com> References: <20210731214211.657280-1-jim.cromie@gmail.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Collapsing "gvt: core: " to "gvt:core: " is a better class-prefix; dropping the internal spaces means a trailing space in a query will more clearly terminate the prefix. Consider a generic drm-debug example: # turn off most ATOMIC reports echo format "^drm:atomic: " -p > control # turn off all ATOMIC:* reports echo format "^drm:atomic:" -p > control # turn on ATOMIC:FAIL reports echo format "^drm:atomic:fail: " +p > control Removing embedded spaces in the class-prefixes simplifies the corresponding match-prefix. This means that "quoted" match-prefixes are only needed when the trailing space is desired, in order to exclude explicitly sub-categorized pr-debugs; in this example, "drm:atomic:fail:". RFC: maybe the prefix catenation should paste in the " " class-prefix terminator explicitly. A pr_debug_() flavor could exclude the " ", allowing ad-hoc sub-categorization by appending for example, "fail:" to "drm:atomic:". Signed-off-by: Jim Cromie --- drivers/gpu/drm/i915/gvt/debug.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/i915/gvt/debug.h b/drivers/gpu/drm/i915/gvt/debug.h index c6027125c1ec..b4021f41c546 100644 --- a/drivers/gpu/drm/i915/gvt/debug.h +++ b/drivers/gpu/drm/i915/gvt/debug.h @@ -36,30 +36,30 @@ do { \ } while (0) #define gvt_dbg_core(fmt, args...) \ - pr_debug("gvt: core: "fmt, ##args) + pr_debug("gvt:core: "fmt, ##args) #define gvt_dbg_irq(fmt, args...) \ - pr_debug("gvt: irq: "fmt, ##args) + pr_debug("gvt:irq: "fmt, ##args) #define gvt_dbg_mm(fmt, args...) \ - pr_debug("gvt: mm: "fmt, ##args) + pr_debug("gvt:mm: "fmt, ##args) #define gvt_dbg_mmio(fmt, args...) \ - pr_debug("gvt: mmio: "fmt, ##args) + pr_debug("gvt:mmio: "fmt, ##args) #define gvt_dbg_dpy(fmt, args...) \ - pr_debug("gvt: dpy: "fmt, ##args) + pr_debug("gvt:dpy: "fmt, ##args) #define gvt_dbg_el(fmt, args...) \ - pr_debug("gvt: el: "fmt, ##args) + pr_debug("gvt:el: "fmt, ##args) #define gvt_dbg_sched(fmt, args...) \ - pr_debug("gvt: sched: "fmt, ##args) + pr_debug("gvt:sched: "fmt, ##args) #define gvt_dbg_render(fmt, args...) \ - pr_debug("gvt: render: "fmt, ##args) + pr_debug("gvt:render: "fmt, ##args) #define gvt_dbg_cmd(fmt, args...) \ - pr_debug("gvt: cmd: "fmt, ##args) + pr_debug("gvt:cmd: "fmt, ##args) #endif From patchwork Sat Jul 31 21:42:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12412753 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6F51CC4320A for ; Sat, 31 Jul 2021 21:42:54 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 3E19060F48 for ; Sat, 31 Jul 2021 21:42:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 3E19060F48 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 590FE6E8FB; Sat, 31 Jul 2021 21:42:53 +0000 (UTC) Received: from mail-il1-x12c.google.com (mail-il1-x12c.google.com [IPv6:2607:f8b0:4864:20::12c]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4F4E26E8FB; Sat, 31 Jul 2021 21:42:52 +0000 (UTC) Received: by mail-il1-x12c.google.com with SMTP id f8so9746478ilr.4; Sat, 31 Jul 2021 14:42:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=6viyI1lb5x1+xx5Qj63RWr1BY09/zfid8qOfXD+1kAU=; b=ZurrzBVjqIJ0KIJFYo7Rh5RtFtEyvrQ8/M+1bqOqTvF7ePYZHi1JnfT4s3Z4hHVqQx dKH0Uc0BCha5Fq88ofKm2kIFRZC6keu7HzpcCaH2IWPS/ejSWvAR/53keFwhaSOTrJ2G SwCwPp4IIka9x5SlTg3SyHollTD/qppNu0cBZZ9mOIDmPKE5fUegv337ZaCY61arEHak uBA8xva673w7iW4R8Eq98A6QDqFkC7gMNouatlPYK6j05GndIqtcxOEHyb71n1ijoP5N 60eKtiW7BySlxiALK3U16WY07KvpGOI2f6/MsvqHwss79z1vbvruWU9kuRzNu2o03kOS gQhQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=6viyI1lb5x1+xx5Qj63RWr1BY09/zfid8qOfXD+1kAU=; b=RlpvrpP+bispYejjjqFbnSFVr+IS+MYD9ceElSb+Nzjb/Sibj6JOae6ZT3/YgSp9jZ Zu5bEd6lX3xa5WLB1P/Ot3Wg5+VDHRKJi4O0XY/Ynfb1caArW1McoYxKz+g0rwWnmvIY 0Y3ZUzlAGdOxPvk2w5Asnf0VFvIAwhFWVxLJ+kXDOphn9wYE1r1nBth/RiR2TxKZcYAF ll8/VbRXgD3ouVqJfdam3gOQ2/H91s7anWE/BKxxUv1oTAfKwRO9jKErfwVdtFRk/A1q oC1ZabrTOW/wkYkGgV7GoBMN7cynNwgsnjlGNjvQ0l2m6ycRVu0JkL4Vq/nxjTPgs7Ti 2xRg== X-Gm-Message-State: AOAM5334K7GlbqjFnsn76MpzDxA8FSniiAIpt96BBRHj60niL4u2mXth TE98QGAGCOyecWOif2+H2FI= X-Google-Smtp-Source: ABdhPJzOfp+MdZuDQLTjYPCAaNpyh2MChjD+OMYZKUx9oS5oEezg5v1vuzPLHhZiyVxCn0639TBOWw== X-Received: by 2002:a92:dc06:: with SMTP id t6mr6555546iln.231.1627767771591; Sat, 31 Jul 2021 14:42:51 -0700 (PDT) Received: from frodo.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id q10sm3721040ion.3.2021.07.31.14.42.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 14:42:51 -0700 (PDT) From: Jim Cromie To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Harry Wentland , Leo Li , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , Zhenyu Wang , Zhi Wang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Jason Baron , Ashley Thomas , Qingqing Zhuo , Aurabindo Pillai , Wyatt Wood , Jim Cromie , Jessica Yu , Johan Hovold , Miguel Ojeda , Nick Desaulniers , Joe Perches , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [PATCH v4 5/7] i915/gvt: control pr_debug("gvt:")s with bits in parameters/debug_gvt Date: Sat, 31 Jul 2021 15:42:02 -0600 Message-Id: <20210731214211.657280-6-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210731214211.657280-1-jim.cromie@gmail.com> References: <20210731214211.657280-1-jim.cromie@gmail.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The gvt component of this driver has ~120 pr_debugs, in 9 "classes". Following the interface model of drm.debug, add a parameter to map bits to these classes. If CONFIG_DRM_USE_DYNAMIC_DEBUG=y (and CONFIG_DYNAMIC_DEBUG_CORE), add -DDYNAMIC_DEBUG_MODULE into Makefile. TBD: maybe add a separate CONFIG_I915_USE_DYNAMIC_DEBUG to more fully optionalize this. this is close to our target: DYNDBG_BITMAP_DESC(__gvt_debug, "dyndbg bitmap desc", { "gvt: cmd: ", "command processing" }, { "gvt: core: ", "core help" }, { "gvt: dpy: ", "display help" }, { "gvt: el: ", "help" }, { "gvt: irq: ", "help" }, { "gvt: mm: ", "help" }, { "gvt: mmio: ", "help" }, { "gvt: render: ", "help" }, { "gvt: sched: " "help" }); actual patch has a few details different, helper macros mainly. Signed-off-by: Jim Cromie --- drivers/gpu/drm/i915/gvt/Makefile | 4 ++++ drivers/gpu/drm/i915/i915_params.c | 34 ++++++++++++++++++++++++++++++ include/drm/drm_print.h | 3 ++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/i915/gvt/Makefile b/drivers/gpu/drm/i915/gvt/Makefile index ea8324abc784..846ba73b8de6 100644 --- a/drivers/gpu/drm/i915/gvt/Makefile +++ b/drivers/gpu/drm/i915/gvt/Makefile @@ -7,3 +7,7 @@ GVT_SOURCE := gvt.o aperture_gm.o handlers.o vgpu.o trace_points.o firmware.o \ ccflags-y += -I $(srctree)/$(src) -I $(srctree)/$(src)/$(GVT_DIR)/ i915-y += $(addprefix $(GVT_DIR)/, $(GVT_SOURCE)) + +#ifdef CONFIG_DRM_USE_DYNAMIC_DEBUG +ccflags-y += -DDYNAMIC_DEBUG_MODULE +#endif diff --git a/drivers/gpu/drm/i915/i915_params.c b/drivers/gpu/drm/i915/i915_params.c index e07f4cfea63a..c951ef76454f 100644 --- a/drivers/gpu/drm/i915/i915_params.c +++ b/drivers/gpu/drm/i915/i915_params.c @@ -265,3 +265,37 @@ void i915_params_free(struct i915_params *params) I915_PARAMS_FOR_EACH(FREE); #undef FREE } + +/* POC for callback -> dynamic_debug_exec_queries */ +unsigned long __gvt_debug; +EXPORT_SYMBOL(__gvt_debug); + +#define _help(key) "\t\"" key "\"\t: help for " key "\n" +#define cmd_help(key) { .prefix = key, .help = key ": help for " key } + +#define I915_DYNDBG_PARM_DESC(name) \ + "Enable debug output via /sys/module/i915/parameters/" #name \ + ", where each bit enables a debug category.\n" \ + _help("gvt:cmd:") \ + _help("gvt:core:") \ + _help("gvt:dpy:") \ + _help("gvt:el:") \ + _help("gvt:irq:") \ + _help("gvt:mm:") \ + _help("gvt:mmio:") \ + _help("gvt:render:") \ + _help("gvt:sched:") + +MODULE_PARM_DESC(debug_gvt, I915_DYNDBG_PARM_DESC(debug_gvt)); + +DEFINE_DYNDBG_BITMAP(debug_gvt, &__gvt_debug, + I915_DYNDBG_PARM_DESC(debug_gvt), + cmd_help("gvt:cmd:"), + cmd_help("gvt:core:"), + cmd_help("gvt:dpy:"), + cmd_help("gvt:el:"), + cmd_help("gvt:irq:"), + cmd_help("gvt:mm:"), + cmd_help("gvt:mmio:"), + cmd_help("gvt:render:"), + cmd_help("gvt:sched:")); diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 15a089a87c22..47803c64b144 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -530,7 +530,8 @@ void __drm_err(const char *format, ...); const struct drm_device *drm_ = (drm); \ \ if (drm_debug_enabled(DRM_UT_ ## category) && __ratelimit(&rs_)) \ - drm_dev_printk(drm_ ? drm_->dev : NULL, KERN_DEBUG, fmt, ## __VA_ARGS__); \ + drm_dev_dbg((drm_) ? (drm_)->dev : NULL, \ + DRM_DBG_CLASS_ ## category, fmt, ##__VA_ARGS__); \ }) #define drm_dbg_kms_ratelimited(drm, fmt, ...) \ From patchwork Sat Jul 31 21:42:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12412755 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9428BC432BE for ; Sat, 31 Jul 2021 21:43:02 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6467D60F39 for ; Sat, 31 Jul 2021 21:43:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6467D60F39 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B7C276E91A; Sat, 31 Jul 2021 21:43:01 +0000 (UTC) Received: from mail-il1-x136.google.com (mail-il1-x136.google.com [IPv6:2607:f8b0:4864:20::136]) by gabe.freedesktop.org (Postfix) with ESMTPS id 1CD676E912; Sat, 31 Jul 2021 21:42:59 +0000 (UTC) Received: by mail-il1-x136.google.com with SMTP id y4so13060625ilp.0; Sat, 31 Jul 2021 14:42:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=58/x+2QGDymGfK0lAmzmatXymq82n8t52NOr4OzAqak=; b=q9oE4WUTh+t2KTE5yd/zztvZeVXDqxbspFru6xnKJsszBZrKGgYEdFlcPXLXRaqyRl u6PrGKWxAKMv5dGU8Q7Ub8DhB/hJ6IjifPtriM/IWmMRmV+vTp82C0BqOB1BGHh+uAaz pvU23lgNwvpG2+bPAU2uHgBkKbSZ9w9cth1CqYO6BqKD5lJlero3G7zzMoMP1Hw//s2S v4npaUkiezb7wQSuEPzlUsber0F6iOSMAqpeuGkDT0k/ERDCEaB1OB5af09zx9uTRucQ nsnpnvwEVfhCJmn+0QSTheyjdRIjtN8HAck/IpJKqpqvCPAOJkgI3EjEeQ1WcgvoowHW qnrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=58/x+2QGDymGfK0lAmzmatXymq82n8t52NOr4OzAqak=; b=nPo39eA8i9Eee1M7QLt8THJIXg3hKKSURotmtXFtqcA0YlyIa5Bg71nFGd/TKbDnlC AkFst7tgl2s+RXsK9QQWu4jWKlHytCU68GHQFcRTX7z9ZEsEflj5tAdhspy9U606o0IL t3MZZXN2F+E0LIh2RyPt7w37gvCtjQ+/kg2pTE79GxutriIvxlHaJC+oWMInyER6exUN 6oXLUoXQ/0VKjXMsBg/knCsWMTCEphJUC9Vb3+ovM5/e7DQMRvyV0bLJ4smC7qTAUOLG RVRlWPj7Mqq7c8ov558u1exIc+VPMNXil0XhEqh0YRdHxSZOj1vvMTG78wQatqNKlz4D VwhA== X-Gm-Message-State: AOAM532uyWHdD6GFK/x8PuR95JyyjIPickXRNFZPEtzEOQv3EMuU65jq Wk1/0o+PlZl5+tHPK57ZOgw= X-Google-Smtp-Source: ABdhPJwA5tlcfKu+7uZN4abVjVI9nufJioA7PR6+bjW89rlUIwRw22xzKRIhW1beZt/C3KhfoeCZNw== X-Received: by 2002:a05:6e02:5cc:: with SMTP id l12mr124288ils.60.1627767778265; Sat, 31 Jul 2021 14:42:58 -0700 (PDT) Received: from frodo.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id q10sm3721040ion.3.2021.07.31.14.42.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 14:42:57 -0700 (PDT) From: Jim Cromie To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Harry Wentland , Leo Li , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , Zhenyu Wang , Zhi Wang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Jason Baron , Ashley Thomas , Qingqing Zhuo , Aurabindo Pillai , Wyatt Wood , Jim Cromie , Jessica Yu , Johan Hovold , Joe Perches , Miguel Ojeda , Nick Desaulniers , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [PATCH v4 6/7] drm/print: add choice to use dynamic debug in drm-debug Date: Sat, 31 Jul 2021 15:42:03 -0600 Message-Id: <20210731214211.657280-7-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210731214211.657280-1-jim.cromie@gmail.com> References: <20210731214211.657280-1-jim.cromie@gmail.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" drm's debug system writes 10 distinct categories of messages to syslog using a small API[1]: drm_dbg*(10 names), DRM_DEBUG*(8 names), DRM_DEV_DEBUG*(3 names). There are thousands of these callsites, each categorized by their authors. ~2100 are on my laptop. These callsites are enabled at runtime by their category, each controlled by a bit in drm.debug (/sys/modules/drm/parameter/debug) In the current "basic" implementation, drm_debug_enabled() tests these bits each time an API[1] call is executed; while cheap individually, the costs accumulate. This patch uses dynamic-debug with jump-label to patch enabled calls onto their respective NOOP slots, avoiding all runtime bit-checks of __drm_debug. Dynamic debug has no concept of category, but we can emulate one by replacing enum categories with a set of prefix-strings; "drm:core:", "drm:kms:" "drm:driver:" etc, and prepend them (at compile time) to the given formats. Then we can use: `echo module drm format "^drm:core: " +p > control` to enable every pr_debug("drm:core: ...") with one query. This conversion yields ~2100 new callsites on my i7/i915 laptop: dyndbg: 195 debug prints in module drm_kms_helper dyndbg: 298 debug prints in module drm dyndbg: 1630 debug prints in module i915 CONFIG_DRM_USE_DYNAMIC_DEBUG enables this, and is available if CONFIG_DYNAMIC_DEBUG or CONFIG_DYNAMIC_DEBUG_CORE is chosen, and if CONFIG_JUMP_LABEL is enabled; this because its required to get the promised optimizations. The indirection/switchover is layered into the macro scheme: 0. A new callback on drm.debug (in a previous patch) does: dynamic_debug_exec_queries("format ^drm:kms: +p", "drm*"); DYNDBG_BITMAP_DESC(__drm_debug, "bla blah bitmap yada", { "drm:core:", "enable CORE debug messages" }, { "drm:kms:", "enable KMS debug messages" }); 1. A "converted" or "classy" DRM_UT_* map based on: DRM_UT_* ( symbol => bit-mask ) named it: DRM_DBG_CLASS_* ( symbol => format-class-prefix-string ) So DRM_DBG_CLASS_* is either: basic: DRM_DBG_CLASS_* <-- DRM_UT_* identity map enabled: #define DRM_DBG_CLASS_KMS "drm:kms: " #define DRM_DBG_CLASS_PRIME "drm:prime: " #define DRM_DBG_CLASS_ATOMIC "drm:atomic: " DRM_UT_* are unchanged for now, since theyre used in drm_debug_enabled() and elsewhere. 2. drm_dev_dbg & drm_debug are renamed (prefixed with '__') original names are now macros, calling either: basic: -> to renamed fn enabled: -> dev_dbg & pr_debug, with DRM_DBG_CLASS_* prefix # format. this is where drm_debug_enabled() is avoided. prefix is prepended at compile-time. 3. names in (2) are invoked by API[1] all these macros now use DRM_DBG_CLASS_* to get right token type for both !/!! DRM_USE_DYNAMIC_DEBUG cases NOTES: dyndbg does require that the prefix be in the compiled-in format string; run-time prefixing would look like "format ^%s" in a query (obviously not useful). dyndbg is completely agnostic wrt the categorization scheme used; but the query selectivity is completely dependent upon how the scheme fits with a simple anchored literal substring match (no regex). ad-hoc categories are implicitly allowed, author discipline and review is expected. - "1","2","3" are allowed, 1-9 is effective max. 2 doesnt imply 1. - "1:","2:","3:" are better, avoiding [1-9]\d: etc - "todo:", "rfc:" might be handy. - "drm:*:" is used here. - "drm:*:*:" is a natural extension. - "drm:atomic:fail:" has been suggested. A hierarchical category space is an obvious frontrunner, so it deserves a little more exploration/scrutiny. - "drm:kms: " & "drm:kms:" are different (2nd, w/o trailing space, matches subcats) - "drm:kms" is also different (matches "drm:kmsmart", whatever that would be) - "drm:kms" & "drm:kms*" are different the latter does not work as you might reasonably expect. wildcarding not added for format, which was already special Literal prefixes (as encoded in DRM_DBG_CLASS_* symbols) should include the trailing space, both to terminate the class prefix, and to read naturally in logs with plain #catenation. Prefixes given in args to DYNDBG_BITMAP_DESC() determine the bit-query map; so to insure the map is stable, new categories or 3rd level categories must be added to the end. The prefixes may have trailing spaces, depending upon desired search results. Since bits are applied 0-N, the later categories can countermand the earlier ones. IOW, "drm:atomic:fail:" would override "drm:atomic:", but "drm:atomic: " would never touch "drm:atomic:fail:" callsites. There are plenty of bikeshed rabbit holes available. Signed-off-by: Jim Cromie --- drivers/gpu/drm/Kconfig | 13 +++++ drivers/gpu/drm/drm_print.c | 15 ++++-- include/drm/drm_print.h | 94 +++++++++++++++++++++++++++---------- 3 files changed, 93 insertions(+), 29 deletions(-) diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 7ff89690a976..e4524ccba040 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -57,6 +57,19 @@ config DRM_DEBUG_MM If in doubt, say "N". +config DRM_USE_DYNAMIC_DEBUG + bool "use dynamic debug to implement drm.debug" + default n + depends on DRM + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE + depends on JUMP_LABEL + help + The drm debug category facility does a lot of unlikely bit-field + tests at runtime; while cheap individually, the cost accumulates. + This option uses dynamic debug facility (if configured and + using jump_label) to avoid those runtime checks, patching + the kernel when those debugs are desired. + config DRM_DEBUG_SELFTEST tristate "kselftests for DRM" depends on DRM diff --git a/drivers/gpu/drm/drm_print.c b/drivers/gpu/drm/drm_print.c index 111b932cf2a9..086e7ea6823f 100644 --- a/drivers/gpu/drm/drm_print.c +++ b/drivers/gpu/drm/drm_print.c @@ -52,7 +52,12 @@ MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug cat "\t\tBit 5 (0x20) will enable VBL messages (vblank code)\n" "\t\tBit 7 (0x80) will enable LEASE messages (leasing code)\n" "\t\tBit 8 (0x100) will enable DP messages (displayport code)"); + +#ifndef CONFIG_DRM_USE_DYNAMIC_DEBUG module_param_named(debug, __drm_debug, int, 0600); +#else +module_param_cb(debug, ¶m_ops_dyndbg, &__drm_debug, 0644); +#endif void __drm_puts_coredump(struct drm_printer *p, const char *str) { @@ -256,8 +261,8 @@ void drm_dev_printk(const struct device *dev, const char *level, } EXPORT_SYMBOL(drm_dev_printk); -void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, - const char *format, ...) +void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, + const char *format, ...) { struct va_format vaf; va_list args; @@ -278,9 +283,9 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, va_end(args); } -EXPORT_SYMBOL(drm_dev_dbg); +EXPORT_SYMBOL(__drm_dev_dbg); -void __drm_dbg(enum drm_debug_category category, const char *format, ...) +void ___drm_dbg(enum drm_debug_category category, const char *format, ...) { struct va_format vaf; va_list args; @@ -297,7 +302,7 @@ void __drm_dbg(enum drm_debug_category category, const char *format, ...) va_end(args); } -EXPORT_SYMBOL(__drm_dbg); +EXPORT_SYMBOL(___drm_dbg); void __drm_err(const char *format, ...) { diff --git a/include/drm/drm_print.h b/include/drm/drm_print.h index 47803c64b144..b5256d59ac55 100644 --- a/include/drm/drm_print.h +++ b/include/drm/drm_print.h @@ -319,6 +319,51 @@ enum drm_debug_category { DRM_UT_DRMRES = 0x200, }; +#if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) + +/* Use legacy drm-debug functions, and drm_debug_enabled(). + * For DRM_DBG_CLASS_*, identity map to DRM_UT_* + */ +#define __drm_dbg(cls, fmt, ...) \ + ___drm_dbg(cls, fmt, ##__VA_ARGS__) +#define drm_dev_dbg(dev, cls, fmt, ...) \ + __drm_dev_dbg(dev, cls, fmt, ##__VA_ARGS__) + +#define DRM_DBG_CLASS_CORE DRM_UT_CORE +#define DRM_DBG_CLASS_DRIVER DRM_UT_DRIVER +#define DRM_DBG_CLASS_KMS DRM_UT_KMS +#define DRM_DBG_CLASS_PRIME DRM_UT_PRIME +#define DRM_DBG_CLASS_ATOMIC DRM_UT_ATOMIC +#define DRM_DBG_CLASS_VBL DRM_UT_VBL +#define DRM_DBG_CLASS_STATE DRM_UT_STATE +#define DRM_DBG_CLASS_LEASE DRM_UT_LEASE +#define DRM_DBG_CLASS_DP DRM_UT_DP +#define DRM_DBG_CLASS_DRMRES DRM_UT_DRMRES + +#else /* !CONFIG_DRM_USE_DYNAMIC_DEBUG */ + +/* use dynamic_debug to avoid drm_debug_enabled(). + * dyndbg has no category, so we prefix the format with a "class" + * string; DRM_DBG_CLASS_* maps to those class strings + */ +#define __drm_dbg(cls, fmt, ...) \ + pr_debug(cls # fmt, ##__VA_ARGS__) +#define drm_dev_dbg(dev, cls, fmt, ...) \ + dev_dbg(dev, cls # fmt, ##__VA_ARGS__) + +#define DRM_DBG_CLASS_CORE "drm:core: " +#define DRM_DBG_CLASS_DRIVER "drm:drvr: " +#define DRM_DBG_CLASS_KMS "drm:kms: " +#define DRM_DBG_CLASS_PRIME "drm:prime: " +#define DRM_DBG_CLASS_ATOMIC "drm:atomic: " +#define DRM_DBG_CLASS_VBL "drm:vbl: " +#define DRM_DBG_CLASS_STATE "drm:state: " +#define DRM_DBG_CLASS_LEASE "drm:lease: " +#define DRM_DBG_CLASS_DP "drm:dp: " +#define DRM_DBG_CLASS_DRMRES "drm:res " + +#endif /* !CONFIG_DRM_USE_DYNAMIC_DEBUG */ + static inline bool drm_debug_enabled(enum drm_debug_category category) { return unlikely(__drm_debug & category); @@ -334,8 +379,8 @@ __printf(3, 4) void drm_dev_printk(const struct device *dev, const char *level, const char *format, ...); __printf(3, 4) -void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, - const char *format, ...); +void __drm_dev_dbg(const struct device *dev, enum drm_debug_category category, + const char *format, ...); /** * DRM_DEV_ERROR() - Error output. @@ -383,7 +428,7 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, * @fmt: printf() like format string. */ #define DRM_DEV_DEBUG(dev, fmt, ...) \ - drm_dev_dbg(dev, DRM_UT_CORE, fmt, ##__VA_ARGS__) + drm_dev_dbg(dev, DRM_DBG_CLASS_CORE, fmt, ##__VA_ARGS__) /** * DRM_DEV_DEBUG_DRIVER() - Debug output for vendor specific part of the driver * @@ -391,7 +436,7 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, * @fmt: printf() like format string. */ #define DRM_DEV_DEBUG_DRIVER(dev, fmt, ...) \ - drm_dev_dbg(dev, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) + drm_dev_dbg(dev, DRM_DBG_CLASS_DRIVER, fmt, ##__VA_ARGS__) /** * DRM_DEV_DEBUG_KMS() - Debug output for modesetting code * @@ -399,7 +444,7 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, * @fmt: printf() like format string. */ #define DRM_DEV_DEBUG_KMS(dev, fmt, ...) \ - drm_dev_dbg(dev, DRM_UT_KMS, fmt, ##__VA_ARGS__) + drm_dev_dbg(dev, DRM_DBG_CLASS_KMS, fmt, ##__VA_ARGS__) /* * struct drm_device based logging @@ -443,25 +488,25 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, #define drm_dbg_core(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_CORE, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CLASS_CORE, fmt, ##__VA_ARGS__) #define drm_dbg(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CLASS_DRIVER, fmt, ##__VA_ARGS__) #define drm_dbg_kms(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CLASS_KMS, fmt, ##__VA_ARGS__) #define drm_dbg_prime(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_PRIME, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CLASS_PRIME, fmt, ##__VA_ARGS__) #define drm_dbg_atomic(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_ATOMIC, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CLASS_ATOMIC, fmt, ##__VA_ARGS__) #define drm_dbg_vbl(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_VBL, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CLASS_VBL, fmt, ##__VA_ARGS__) #define drm_dbg_state(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_STATE, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CLASS_STATE, fmt, ##__VA_ARGS__) #define drm_dbg_lease(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_LEASE, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CLASS_LEASE, fmt, ##__VA_ARGS__) #define drm_dbg_dp(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DP, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CLASS_DP, fmt, ##__VA_ARGS__) #define drm_dbg_drmres(drm, fmt, ...) \ - drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__) + drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_DBG_CLASS_DRMRES, fmt, ##__VA_ARGS__) /* @@ -471,7 +516,7 @@ void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, */ __printf(2, 3) -void __drm_dbg(enum drm_debug_category category, const char *format, ...); +void ___drm_dbg(enum drm_debug_category category, const char *format, ...); __printf(1, 2) void __drm_err(const char *format, ...); @@ -500,29 +545,30 @@ void __drm_err(const char *format, ...); #define DRM_ERROR_RATELIMITED(fmt, ...) \ DRM_DEV_ERROR_RATELIMITED(NULL, fmt, ##__VA_ARGS__) + #define DRM_DEBUG(fmt, ...) \ - __drm_dbg(DRM_UT_CORE, fmt, ##__VA_ARGS__) + __drm_dbg(DRM_DBG_CLASS_CORE, fmt, ##__VA_ARGS__) #define DRM_DEBUG_DRIVER(fmt, ...) \ - __drm_dbg(DRM_UT_DRIVER, fmt, ##__VA_ARGS__) + __drm_dbg(DRM_DBG_CLASS_DRIVER, fmt, ##__VA_ARGS__) #define DRM_DEBUG_KMS(fmt, ...) \ - __drm_dbg(DRM_UT_KMS, fmt, ##__VA_ARGS__) + __drm_dbg(DRM_DBG_CLASS_KMS, fmt, ##__VA_ARGS__) #define DRM_DEBUG_PRIME(fmt, ...) \ - __drm_dbg(DRM_UT_PRIME, fmt, ##__VA_ARGS__) + __drm_dbg(DRM_DBG_CLASS_PRIME, fmt, ##__VA_ARGS__) #define DRM_DEBUG_ATOMIC(fmt, ...) \ - __drm_dbg(DRM_UT_ATOMIC, fmt, ##__VA_ARGS__) + __drm_dbg(DRM_DBG_CLASS_ATOMIC, fmt, ##__VA_ARGS__) #define DRM_DEBUG_VBL(fmt, ...) \ - __drm_dbg(DRM_UT_VBL, fmt, ##__VA_ARGS__) + __drm_dbg(DRM_DBG_CLASS_VBL, fmt, ##__VA_ARGS__) #define DRM_DEBUG_LEASE(fmt, ...) \ - __drm_dbg(DRM_UT_LEASE, fmt, ##__VA_ARGS__) + __drm_dbg(DRM_DBG_CLASS_LEASE, fmt, ##__VA_ARGS__) #define DRM_DEBUG_DP(fmt, ...) \ - __drm_dbg(DRM_UT_DP, fmt, ## __VA_ARGS__) + __drm_dbg(DRM_DBG_CLASS_DP, fmt, ## __VA_ARGS__) #define __DRM_DEFINE_DBG_RATELIMITED(category, drm, fmt, ...) \ ({ \ From patchwork Sat Jul 31 21:42:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jim Cromie X-Patchwork-Id: 12412757 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.9 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,UNWANTED_LANGUAGE_BODY, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E88BAC4320A for ; Sat, 31 Jul 2021 21:43:07 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id B8DCD60F39 for ; Sat, 31 Jul 2021 21:43:07 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org B8DCD60F39 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E55C46E905; Sat, 31 Jul 2021 21:43:06 +0000 (UTC) Received: from mail-il1-x12f.google.com (mail-il1-x12f.google.com [IPv6:2607:f8b0:4864:20::12f]) by gabe.freedesktop.org (Postfix) with ESMTPS id D1D5A6E939; Sat, 31 Jul 2021 21:43:05 +0000 (UTC) Received: by mail-il1-x12f.google.com with SMTP id j18so9992524ile.8; Sat, 31 Jul 2021 14:43:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=Fjsw3W3/UmlQsTKfLEE1H6kTd7xaAkJp0etT9YYbz+I=; b=DUQOmqbS6V186tr3AR4AQ/htc0Bg66ZwKaVnDhi8fD4VVZlKCf/XiMXwkRotjoP/oD OlEohbOBL4Yoa9TdR+Rt4U35G0nEQ8KC1XEx4lPrsDTudjD848VcRX4MLxvsBeZw/1G1 sTsh+9jmrH/+DkMS13G8ysj2cw3Gbc0Y/imnc903XG+ZXkdCSUgEye1gO5kadZ0NHB/7 QoTZ/7GP4NjMU6SpCQNZxUXX0+r7NF0RdNFHb5ATQxh2tgpzFKgYwf2gNYLWlmt9BMSY cz2ik8KJfEIuoyTSo19BihMCTNQfO9StMfPsChEJF5EwgtM60BYWqB8C+i00hvEv47mX w6Wg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Fjsw3W3/UmlQsTKfLEE1H6kTd7xaAkJp0etT9YYbz+I=; b=jHyaa3yzQHrk8f78TjOdoGWjbk3dYjis6gUd7m1nGkQT3v1WTF+OafJX+KuS/uPrBy 93ovNyDydSJJ9oo3QIVOjVTjaUXlJpoH9tsVpC62aUZAY7y4iB0HTOeKx9j2acBz603V 8Sk8e2jKV2y8PzNUFqNSbPe2+2hVGgGHZqlT/VLRFbtzSEEMLnPuxQcbhgs/svn5pPdG Wj54rf04BPZSl8cU5lFleWLiZnIxnIaAjKrU5dteWFviicKlGIpNW8b9Hbiz375YWlS9 FYkon1k5UQPm6DOWTTgrmWm0N3EoU7ycYXxIyGnBx8TlVPM6IuQ/uPH1MkGLyhvYdrsr kyFA== X-Gm-Message-State: AOAM530vRMd5GVmmRX02BynQO8F8r8K2IMTYmuWQ5OiNA72dsa8nQB9N bBqnAmYVEX1zak41m4bPAxlRPuFoGTSCzSgy X-Google-Smtp-Source: ABdhPJz/2EtrrYIqo1LVW1aQs2Xb4oaL2S+YhuZgVD/CT6F5x/mjSOje1mie7ejlt/ixr3AwR/U9tQ== X-Received: by 2002:a92:c7d0:: with SMTP id g16mr6296943ilk.278.1627767785160; Sat, 31 Jul 2021 14:43:05 -0700 (PDT) Received: from frodo.. (c-24-9-77-57.hsd1.co.comcast.net. [24.9.77.57]) by smtp.googlemail.com with ESMTPSA id q10sm3721040ion.3.2021.07.31.14.43.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 31 Jul 2021 14:43:04 -0700 (PDT) From: Jim Cromie To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Harry Wentland , Leo Li , Alex Deucher , =?utf-8?q?Christian_K=C3=B6nig?= , "Pan, Xinhui" , Zhenyu Wang , Zhi Wang , Jani Nikula , Joonas Lahtinen , Rodrigo Vivi , Jason Baron , Ashley Thomas , Aurabindo Pillai , Wyatt Wood , Qingqing Zhuo , Jim Cromie , Johan Hovold , Jessica Yu , Joe Perches , Miguel Ojeda , Nick Desaulniers , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Subject: [PATCH v4 7/7] amdgpu: define a dydbg-bitmap to control categorized pr_debugs Date: Sat, 31 Jul 2021 15:42:04 -0600 Message-Id: <20210731214211.657280-8-jim.cromie@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210731214211.657280-1-jim.cromie@gmail.com> References: <20210731214211.657280-1-jim.cromie@gmail.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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" logger_types.h defines many DC_LOG_*() categorized debug wrappers. Many of these use DRM_DEBUG_*, so are controllable using drm.debug, but others use bare pr_debug()s, each with a different class-prefix matching "^[\w+]:" Use DYNDBG_BITMAP_DESC() to create a parameter/debug_dc, and to define bits to control those pr_debugs by their category. Signed-off-by: Jim Cromie --- .../gpu/drm/amd/display/dc/core/dc_debug.c | 42 ++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_debug.c b/drivers/gpu/drm/amd/display/dc/core/dc_debug.c index 21be2a684393..3041e0c3d726 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_debug.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_debug.c @@ -36,8 +36,48 @@ #include "resource.h" -#define DC_LOGGER_INIT(logger) +/* define a drm.debug style dyndbg pr-debug control point */ +unsigned long __debug_dc; +EXPORT_SYMBOL(__debug_dc); + +#define _help(key) "\t\t" key " : help for " key "\n" +#define cmd_help(key) { .prefix = key, .help = "help for " key } + +/* Id like to do these inside DEFINE_DYNDBG_BITMAP, later */ +#define MY_DYNDBG_PARM_DESC(name) \ + "Enable debug output via /sys/module/amdgpu/parameters/" #name \ + ", where each bit enables a debug category.\n" \ + _help("[SURFACE]:") \ + _help("[CURSOR]:") \ + _help("[PFLIP]:") \ + _help("[VBLANK]:") \ + _help("[HW_LINK_TRAINING]:") \ + _help("[HW_AUDIO]:") \ + _help("[SCALER]:") \ + _help("[BIOS]:") \ + _help("[BANDWIDTH_CALCS]:") \ + _help("[DML]:") \ + _help("[IF_TRACE]:") \ + _help("[GAMMA]:") \ + _help("[SMU_MSG]:") +MODULE_PARM_DESC(debug_dc, MY_DYNDBG_PARM_DESC(name)); + +DEFINE_DYNDBG_BITMAP(debug_dc, &__debug_dc, + MY_DYNDBG_PARM_DESC(debug_dc), + cmd_help("[CURSOR]:"), + cmd_help("[PFLIP]:"), + cmd_help("[VBLANK]:"), + cmd_help("[HW_LINK_TRAINING]:"), + cmd_help("[HW_AUDIO]:"), + cmd_help("[SCALER]:"), + cmd_help("[BIOS]:"), + cmd_help("[BANDWIDTH_CALCS]:"), + cmd_help("[DML]:"), + cmd_help("[IF_TRACE]:"), + cmd_help("[GAMMA]:"), + cmd_help("[SMU_MSG]:")); +#define DC_LOGGER_INIT(logger) #define SURFACE_TRACE(...) do {\ if (dc->debug.surface_trace) \