From nobody Sun Sep 14 08:34:43 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CE1D5CA0EC3 for ; Tue, 12 Sep 2023 01:34:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235361AbjILBeo (ORCPT ); Mon, 11 Sep 2023 21:34:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53772 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235485AbjILBe3 (ORCPT ); Mon, 11 Sep 2023 21:34:29 -0400 Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AFF614E70F; Mon, 11 Sep 2023 16:48:51 -0700 (PDT) Received: by mail-pf1-x434.google.com with SMTP id d2e1a72fcca58-68fbb10dec7so1508836b3a.3; Mon, 11 Sep 2023 16:48:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1694476068; x=1695080868; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=e6NIZdlLmgRQPJbwwmBZ102ypc9HsrQnlZpRMUUA7Yk=; b=WuPww4EZtLQn/iaQjipacQRqX7FORCnQv6ajdlhK97kBqqOHQSg8rt6LwxPtMh1HbB jhBzng7MYPquWuBBhd96vaHOWrENM/ziG3g0hEkNpd9Dkz5ItIlWPqiTsfn3hB1vUNUO bEhFrq9CnkvXgnIHDt2hWEanyu5IMD8AvYo2tPwzEnRldQ+Sn7XSISBWRGHmI0Z6fE93 cZwh5GmRa+E10f1kFzZP3WgdRFb4dIfkMq8M6QuIGNsqYHxGjnkCRX+74IeHfzJvPK6M zOBarIiQf73lMPpQoiUCcVflfQtk1UaHCbxvrxH/Map2zuagCDPwliKfQV3PFybmTwV0 66qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694476068; x=1695080868; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=e6NIZdlLmgRQPJbwwmBZ102ypc9HsrQnlZpRMUUA7Yk=; b=cxQ+gZ6dP8u1WbhzgnUzwrs8f3EtylhO0VyHyJPtUStWNfbBlODNv2I80Bu8ovJ1WI nG9hKNVtUHMVh3RpHeXFcICwzpfSt3blNmwPNN8kd7cROTBZGJY21FNNzNB/rPWGzyU8 8C9d0ZnCFx5Moyx9aMOmWF+FjO+KNeBYZV+QCkpKb6fBXS4lFuQUMxg4D4PFdlUCJ7ow y8VTEKNQRm1p5HauJj5ZCV1frO+Tu+ZuZRnQgRK/6uLhF//kR6wOTV7btJUzcnzsyDa2 vSq1aw+h9rAOMpqN02nCCL60pLh2NBHqxribZZMytRHuzAKjAjc1YH69raMI/zXaieff XItw== X-Gm-Message-State: AOJu0YweQL9RP65ia/D35/gJ/KoGCcGfTuYwdy8xnZanj6Uvmk+aHOFP onNmO0CdtseRsB6GtpYtQi2lZHAYOo6Kkw== X-Google-Smtp-Source: AGHT+IFDCPReJlF/HoZtIiXFIPqYEeXcnDWZ2HXPByAzvqeS7BuEUfkb9nxR1SNOcZEto4daJII3TQ== X-Received: by 2002:a6b:fd0c:0:b0:783:6272:afbb with SMTP id c12-20020a6bfd0c000000b007836272afbbmr12043668ioi.9.1694473724899; Mon, 11 Sep 2023 16:08:44 -0700 (PDT) Received: from frodo.. (c-73-78-62-130.hsd1.co.comcast.net. [73.78.62.130]) by smtp.googlemail.com with ESMTPSA id z4-20020a029f04000000b00423240c7296sm2512607jal.69.2023.09.11.16.08.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Sep 2023 16:08:44 -0700 (PDT) From: Jim Cromie To: jbaron@akamai.com, gregkh@linuxfoundation.org, mcgrof@kernel.org, daniel.vetter@ffwll.ch Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, intel-gvt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, jani.nikula@intel.com, ville.syrjala@linux.intel.com, seanpaul@chromium.org, robdclark@gmail.com, linux-doc@vger.kernel.org, Jim Cromie Subject: [PATCH v6 01/22] test-dyndbg: fixup CLASSMAP usage error Date: Mon, 11 Sep 2023 17:08:17 -0600 Message-ID: <20230911230838.14461-2-jim.cromie@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230911230838.14461-1-jim.cromie@gmail.com> References: <20230911230838.14461-1-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" more careful reading of test output reveals: lib/test_dynamic_debug.c:103 [test_dynamic_debug]do_cats =3Dpmf "doing cate= gories\n" lib/test_dynamic_debug.c:105 [test_dynamic_debug]do_cats =3Dp "LOW msg\n" c= lass:MID lib/test_dynamic_debug.c:106 [test_dynamic_debug]do_cats =3Dp "MID msg\n" c= lass:HI lib/test_dynamic_debug.c:107 [test_dynamic_debug]do_cats =3D_ "HI msg\n" cl= ass unknown, _id:13 That last line is wrong, the HI class is declared. But the enum's 1st val (explicitly initialized) was wrong; it must be _base, not _base+1 (a DECLARE_DYNDBG_CLASSMAP[1] param). So the last enumeration exceeded the range of mapped class-id's, which triggered the "class unknown" report. I intentionally coded in an error, but forgot to verify its detection and remove it. RFC: This patch fixes a bad usage of DECLARE_DYNDBG_CLASSMAP(), showing that it is too error-prone. As noted in test-mod comments: * Using the CLASSMAP api: * - classmaps must have corresponding enum * - enum symbols must match/correlate with class-name strings in the map. * - base must equal enum's 1st value * - multiple maps must set their base to share the 0-62 class_id space !! * (build-bug-on tips welcome) Those shortcomings could largely be fixed with a __stringify_list (which doesn't exist,) used in DECLARE_DYNDBG_CLASSMAP to stringify __VA_ARGS__. Then, API would accept DRM_UT_* values literally; all the categories, in order, and not their stringifications, which created all the usage complications above. [1] name changes later to DYNDBG_CLASSMAP_DEFINE Signed-off-by: Jim Cromie --- lib/test_dynamic_debug.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 8dd250ad022b..a01f0193a419 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -75,7 +75,7 @@ DD_SYS_WRAP(disjoint_bits, p); DD_SYS_WRAP(disjoint_bits, T); =20 /* symbolic input, independent bits */ -enum cat_disjoint_names { LOW =3D 11, MID, HI }; +enum cat_disjoint_names { LOW =3D 10, MID, HI }; DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, = 10, "LOW", "MID", "HI"); DD_SYS_WRAP(disjoint_names, p); --=20 2.41.0