From mboxrd@z Thu Jan 1 00:00:00 1970 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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 8863BECD6FD for ; Thu, 12 Feb 2026 00:14:42 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7893F10E69E; Thu, 12 Feb 2026 00:14:41 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="MIpb+/dV"; dkim-atps=neutral Received: from mail-oa1-f67.google.com (mail-oa1-f67.google.com [209.85.160.67]) by gabe.freedesktop.org (Postfix) with ESMTPS id EADA110E689 for ; Thu, 12 Feb 2026 00:14:37 +0000 (UTC) Received: by mail-oa1-f67.google.com with SMTP id 586e51a60fabf-409521ba360so1581693fac.2 for ; Wed, 11 Feb 2026 16:14:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1770855277; x=1771460077; darn=lists.freedesktop.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=B3chjRiSVuKjtG+NfIIwWt+Up1eTHK9CuSPAe4u/FnI=; b=MIpb+/dVEMfsdx0z6+4Hb7IY2li02AbV2yxvvh8ZBLxPQNyxXWF7M6Adf46i3XtPok OAZ2Zl4nZZXiGH3I9hG95xcte3PF+n8Pf9MLbyx5m/kQcSNLrHD7i6J1wOaPMsbQgGPb tGlc7kpgF8Lj+Up9LoxH45pN3dUPGXdT1EOxljK+ime8EJXMWlwLzGI32NqD0oTut1Ys OQq9Jf0PS391/GoXXqMbYso0Al8P1FuMQFaAVYtPxGeKmeF6TOIIAF0GQ7PrxMYP3XBY UKns1IpLXy+tNVqXQpfdaPn3KOJcSZyZudZv7liLmsv/6Iekk2HDm9WEBxUMu+eP6VfB ApaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1770855277; x=1771460077; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=B3chjRiSVuKjtG+NfIIwWt+Up1eTHK9CuSPAe4u/FnI=; b=Qv7L6z3ivJyVacJr/giYSoVXDT8gdQ/GWqj6zTyEUlKj38vxY9PQ/83l4x5uZtj5yb uOEZKMA4R/+ynZYx5qfd8UyE+zzG/fcT+gBjoFRVs7vrUessX9biDSRiK/U7hcg3Z467 vs8G2K1gRdulMTlYp9JMM2ACb9DUatPnRzUbq1f7qJJIqqB34BWvyVMLIir6xrdoJM/d 80EVo9UPC0nrP7des6bIyq62JMUwHT0tt5sdJILO7Xr8eBFZ4wTVjbGiEa1KmLFfV4af S9BcFTFR+36CXl7vXUqVzan8keKM8Vq+Ne8Kb7mbhVHeKjhSWWXbSSRcqklTcDjyuepO xZQg== X-Gm-Message-State: AOJu0YyNF9Ln0cvgU8hkS+2rIDNWafq4Cblf5u2ViNr+NpfYt8Emj//6 /rV2W6jmQfw1WaUDJMggi+c502SPW4/CfYUZD+VObVkoPtyucsAeHLA8wb2blOcn X-Gm-Gg: AZuq6aKerkj42Ca7FtCoCHe8ZplwiAn1n7rOfwACpHpVh9Rr/kWbDIuowq6UQtUghH/ NkmNgQj8KRCi3L9KlEfZP5DX2GFcwE3NJP836nMzV4pcjsW5EOXnNuOL8e95JrZecM7J8vAC3+L Duf935OUTH6jKkfljPIm3xmlUANJe9/frjP1dnOHOxqsEMIdmVXA87K5Q5RW9DIxWIuMwHBQebA 1Skeugs6an8+/0lZbPRAsw+OGAogpPn0GkX8k9mnOZ5G5CfbEc8eJEhVejquZxaRo1sj4Y6dRaB myhISauTMKhQDKCEmUR2rEcXgjwfJLqd+CyRd/FamjGPJUGrvMUKwrIFpCSEvOBOKro8lZvK51z Jy/Kzn+u85UwSHiZYJb3IygYBizLLfNM56VJo1FZq1CgIs3W+LRtzimcqGt4MArVcPirqn4brZ+ 23KeMY053lSfms61vLK6/Mohm5atMoIb/DRMW6JAHdQtn3U0eTPpC1 X-Received: by 2002:a05:6870:2421:b0:409:70e2:fbf4 with SMTP id 586e51a60fabf-40eca1fe28cmr318119fac.27.1770855277006; Wed, 11 Feb 2026 16:14:37 -0800 (PST) Received: from godzilla (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 586e51a60fabf-40eaf1062ffsm2331939fac.13.2026.02.11.16.14.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 11 Feb 2026 16:14:36 -0800 (PST) From: Jim Cromie To: dri-devel@lists.freedesktop.org, intel-gfx-trybot@lists.freedesktop.org Cc: Jim Cromie Subject: [PATCH 23/61] dyndbg: detect class_id reservation conflicts Date: Wed, 11 Feb 2026 17:13:18 -0700 Message-ID: <20260212001359.97296-24-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260212001359.97296-23-jim.cromie@gmail.com> References: <20260212001359.97296-1-jim.cromie@gmail.com> <20260212001359.97296-2-jim.cromie@gmail.com> <20260212001359.97296-3-jim.cromie@gmail.com> <20260212001359.97296-4-jim.cromie@gmail.com> <20260212001359.97296-5-jim.cromie@gmail.com> <20260212001359.97296-6-jim.cromie@gmail.com> <20260212001359.97296-7-jim.cromie@gmail.com> <20260212001359.97296-8-jim.cromie@gmail.com> <20260212001359.97296-9-jim.cromie@gmail.com> <20260212001359.97296-10-jim.cromie@gmail.com> <20260212001359.97296-11-jim.cromie@gmail.com> <20260212001359.97296-12-jim.cromie@gmail.com> <20260212001359.97296-13-jim.cromie@gmail.com> <20260212001359.97296-14-jim.cromie@gmail.com> <20260212001359.97296-15-jim.cromie@gmail.com> <20260212001359.97296-16-jim.cromie@gmail.com> <20260212001359.97296-17-jim.cromie@gmail.com> <20260212001359.97296-18-jim.cromie@gmail.com> <20260212001359.97296-19-jim.cromie@gmail.com> <20260212001359.97296-20-jim.cromie@gmail.com> <20260212001359.97296-21-jim.cromie@gmail.com> <20260212001359.97296-22-jim.cromie@gmail.com> <20260212001359.97296-23-jim.cromie@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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" If a module _DEFINEs 2 or more classmaps, it must devise them to share the per-module 0..62 class-id space; ie their respective base,+length reservations cannot overlap. To detect conflicts at modprobe, add ddebug_class_range_overlap(), call it from ddebug_add_module(), and WARN and return -EINVAL when they're detected. This insures that class_id -> classname lookup has just 1 answer, so the 1st-found search in find-class-name works properly. test_dynamic_debug.c: If built with -DFORCE_CLASSID_CONFLICT, the test-modules invoke 2 conflicting DYNAMIC_DEBUG_CLASSMAP_DEFINE() declarations, into parent and the _submod. These conflict with one of the good ones in the parent (D2_CORE..etc), causing the modprobe(s) to warn Signed-off-by: Jim Cromie --- v9 - fix WARN() by adding new 1st arg 1. --- lib/dynamic_debug.c | 10 ++++++++++ lib/test_dynamic_debug.c | 8 ++++++++ 2 files changed, 18 insertions(+) diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index 5565ffa18c11..b59252e0665a 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -1318,6 +1318,7 @@ static int ddebug_add_module(struct _ddebug_info *di) struct ddebug_table *dt; struct _ddebug_class_map *cm; struct _ddebug_class_user *cli; + u64 reserved_ids = 0; int i; if (!di->descs.len) @@ -1342,6 +1343,11 @@ static int ddebug_add_module(struct _ddebug_info *di) dd_mark_vector_subrange(i, cli, &dt->info, users, dt); /* now di is stale */ + /* insure 2+ classmaps share the per-module 0..62 class_id space */ + for_subvec(i, cm, &dt->info, maps) + if (ddebug_class_range_overlap(cm, &reserved_ids)) + goto cleanup; + mutex_lock(&ddebug_lock); list_add_tail(&dt->link, &ddebug_tables); mutex_unlock(&ddebug_lock); @@ -1354,6 +1360,10 @@ static int ddebug_add_module(struct _ddebug_info *di) vpr_info("%3u debug prints in module %s\n", dt->info.descs.len, dt->info.mod_name); return 0; +cleanup: + WARN_ONCE(1, "dyndbg multi-classmap conflict in %s\n", di->mod_name); + kfree(dt); + return -EINVAL; } /* helper for ddebug_dyndbg_(boot|module)_param_cb */ diff --git a/lib/test_dynamic_debug.c b/lib/test_dynamic_debug.c index 6c4548f63512..1ba4be9a403a 100644 --- a/lib/test_dynamic_debug.c +++ b/lib/test_dynamic_debug.c @@ -128,6 +128,14 @@ DYNAMIC_DEBUG_CLASSMAP_DEFINE(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, DYNAMIC_DEBUG_CLASSMAP_PARAM(disjoint_bits, p); DYNAMIC_DEBUG_CLASSMAP_PARAM(level_num, p); +#ifdef FORCE_CLASSID_CONFLICT +/* + * Enable with -Dflag on compile to test overlapping class-id range + * detection. This should warn on modprobes. + */ +DYNDBG_CLASSMAP_DEFINE(classid_range_conflict, 0, D2_CORE + 1, "D3_CORE"); +#endif + #else /* TEST_DYNAMIC_DEBUG_SUBMOD */ /* -- 2.53.0