From nobody Mon Feb 9 10:28:10 2026 Received: from mail-ot1-f66.google.com (mail-ot1-f66.google.com [209.85.210.66]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EBAC82FE59A for ; Wed, 14 Jan 2026 02:00:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.210.66 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768356049; cv=none; b=nQTOGYIYm1tzD1fH7DX3PgT12PIKGTHrsSNg0L4cEDmrdXbLLyaf1/vuYeRiSx8aw1WV844VAON0taSftkIr5cpDV8nRdirega+QHSUQSRmPYbmebcXGob8NV75wmDg8St9CQi65VPcfg2xChP6+MCtE4z/k2+vcMsK5NVmgnJs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768356049; c=relaxed/simple; bh=nceTOBGC2okYO9sP3q2miltoB/YTSAMOyq1icNZq98U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=LeK19M92r5QCEYZsMEYxHKZpyrjLH0wzOcmwER6/L7tNKsfqMv5WUUULlNuHP8gLeMfil770I+Yd3SHVHlEjugW5YWqOZxzaEnmke2UHyIipLeu134QNrJJlvznOtONu5IG+tKOauqsZOOVlX+aYvYpRMci9/ILwBUHz69/jTtM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=V9bd4w7H; arc=none smtp.client-ip=209.85.210.66 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="V9bd4w7H" Received: by mail-ot1-f66.google.com with SMTP id 46e09a7af769-7c75fc222c3so4277597a34.0 for ; Tue, 13 Jan 2026 18:00:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1768356046; x=1768960846; 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=EtGFYvkXzuLDBdoPBBG7Nml2rAKHXpifaucUiL+T8bk=; b=V9bd4w7H5CbuZpzq9oiJVB4G7IUQfpB4d3ZaBrO1YjPO8JT5xOuqDXC7F6RtGp8/ld XO1ErYypQn2IIJkrpHJtiaBRHlBfC9LaUrPNVfVg/lS9Y2s4jpL8rYpIbNi+Hs8vFKBy aC7RKvh8hMgeNObFz+s6fylBi6ZHxyWAcDDrr+OQ+2jXCv9/hUkdfaUZe1xDsvckZxqW 2R8Ix8qMwNcszF+n/1jC3jkF54H2WfTe7xA7QIIzBqQ9mZeIZCPsjqkP1yMF3ByEBLx4 Ms+0M1FU9Ww3S/n1mOLT13X/BNU7lZdw9MBf97IfvkyBbMvElEmeuFePlB2cIvk7IVQO ZS4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768356046; x=1768960846; 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=EtGFYvkXzuLDBdoPBBG7Nml2rAKHXpifaucUiL+T8bk=; b=nitnjjAeTsjDtx+FGgSkDEGzX0FKGVxKrIkouR9OQ/Y5K3Umy9EFTdHMpgxh6XMCqf g/DeTRjYxsYS6X38TnWUWSRCe0Ylf6alsp77VHkdiHlFNbeJdIR9gkumNdnYAJu7mChI fAY6xq1ORAxAj8Z6Kr9UZZFI1+6y5WBWE9O4TmIB1iXjPDOV6+XCb4YkQSMP5xsgbxhS Bp7hBYgMMvUdeRTJ6FpkGlaNZeCMCHVmjPkuYnuy6+nkDS29ZFlGPsefGArIa5t5i/We p5FZdfaAjXzt5tg11Ea4vDXSxCUWhMIuhT4GZiHpKXi4Vwk6ybHaoEgkrSBDSW1ws7Qz qeqA== X-Forwarded-Encrypted: i=1; AJvYcCWc7k8NiOrRe1ouS8OS7z9Mvz7oPBde16G8D0eLxBNo0mpGhDhr0/fQEXGrbU8TaTHcc7fWixiJCXHJ4/U=@vger.kernel.org X-Gm-Message-State: AOJu0YziLUAPigBRQFvqYEO2MxWgtu9p4ByAx5pDwxPEKCuDA44ZMq0B 1JwJS96a138kLUvEtbjbHNcDpDf1fw0gVjVUHIzGpAWzBNfF8yP5QC6v X-Gm-Gg: AY/fxX71w7wg1iA7REufFgrG7fEpxrSwkypr6J+7+NSW2sdAspOd/7tWhiSIdYrccQf 7Es7wYdbhBxjSPDZJAdZaRZcel6GcJLj6jrSPmyXa/dIAwFs0D3osp1JmCHzNJdNu2UdHbSK7lx ZG7dS1GrqCxeJqbwVoQKM+lvADrCZurcjoD2b48LAUiS9sBdU9rDfpwwobN5ldgLc7chkBrkOth HZimVs5WH2UxqK0nA1IGksSulDbmRpUpmFxNleU5xVwmxD10LCVG/t/V/nxvyMZ1A9j3kJKrukN M1v7uez+0Jni8GOi8KmkhBaNsX3rp2c0NCpqmkZRG+e9QvwFFVPSKG+CkvUY/wIUHeRRXhm9hAX Ny5n4X5n6FpzzCNH99lf9GBVdXf5JjPR4rYUindGpvU/HmeM/fI4nuT4NemS+a9nGhnTfFDHCs4 LmMaa8SouKSmz41KQkWIsGbdpquBDuSzhOmu+D X-Received: by 2002:a05:6820:229b:b0:65f:5c73:e350 with SMTP id 006d021491bc7-6610064699amr803336eaf.30.1768356046602; Tue, 13 Jan 2026 18:00:46 -0800 (PST) Received: from frodo (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 006d021491bc7-65f48ced969sm8999238eaf.17.2026.01.13.18.00.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jan 2026 18:00:46 -0800 (PST) From: Jim Cromie To: gregkh@linuxfoundation.org, linux-kernel@vger.kernel.org Cc: Jim Cromie , Jason Baron , =?UTF-8?q?=C5=81ukasz=20Bartosik?= , Louis Chauvet , Bagas Sanjaya , Dave Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , dri-devel@lists.freedesktop.org, Petr Mladek , Shuah Khan , linux-doc@vger.kernel.org, Steven Rostedt , "Liam R. Howlett" Subject: [PATCH v8 30/31] dyndbg: add DYNAMIC_DEBUG_CLASSMAP_USE_(dd_class_name, offset) Date: Tue, 13 Jan 2026 18:57:46 -0700 Message-ID: <20260114015815.1565725-31-jim.cromie@gmail.com> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260114015815.1565725-1-jim.cromie@gmail.com> References: <20260114015815.1565725-1-jim.cromie@gmail.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Allow a module to use 2 classmaps together that would otherwise have a class_id range conflict. Suppose a drm-driver does: DYNAMIC_DEBUG_CLASSMAP_USE(drm_debug_classes); DYNAMIC_DEBUG_CLASSMAP_USE(drm_accel_xfer_debug); If (for some reason) drm-accel will not define their constants to avoid DRM's 0..10 reservations, we have a reserved-ids conflict. This seems unlikely. I don't think this potential conflict would become an issue until we have at least a 3-X-3 of classmap-defns X classmap-users. This is an untested interface extension, so drop this patch if it feels too speculative, knowing theres at least a notional solution should the situation arise. Signed-off-by: Jim Cromie --- include/linux/dynamic_debug.h | 27 ++++++++++++++++++++++----- lib/dynamic_debug.c | 19 ++++++++++++------- 2 files changed, 34 insertions(+), 12 deletions(-) diff --git a/include/linux/dynamic_debug.h b/include/linux/dynamic_debug.h index 315050507fd3..1ec5d8a44deb 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -87,7 +87,7 @@ struct _ddebug_class_map { struct _ddebug_class_user { char *mod_name; struct _ddebug_class_map *map; - const int offset; /* user offset to re-number the used map */ + const int offset; /* offset from map->base */ }; =20 /* @@ -238,11 +238,28 @@ struct _ddebug_class_param { * * This tells dyndbg that the module has prdbgs with classids defined * in the named classmap. This qualifies "class NAME" >controls on - * the user module, and ignores unknown names. + * the user module, and ignores unknown names. This is a wrapper for + * DYNAMIC_DEBUG_CLASSMAP_USE_() with a base offset of 0. */ -#define DYNAMIC_DEBUG_CLASSMAP_USE(_var) \ - DYNAMIC_DEBUG_CLASSMAP_USE_(_var, 0, __UNIQUE_ID(_ddebug_class_user)) -#define DYNAMIC_DEBUG_CLASSMAP_USE_(_var, _offset, _uname) \ +#define DYNAMIC_DEBUG_CLASSMAP_USE(_var) \ + DYNAMIC_DEBUG_CLASSMAP_USE_(_var, 0) + +/** + * DYNAMIC_DEBUG_CLASSMAP_USE_ - refer to a classmap with a manual offset. + * @_var: name of the exported classmap var to use. + * @_offset: an integer offset to add to the class IDs of the used map. + * + * This is an extended version of DYNAMIC_DEBUG_CLASSMAP_USE(). It should + * only be used to resolve class ID conflicts when a module uses multiple + * classmaps that have overlapping ID ranges. + * + * The final class IDs for the used map will be calculated as: + * original_map_base + class_index + @_offset. + */ +#define DYNAMIC_DEBUG_CLASSMAP_USE_(_var, _offset) \ + __DYNAMIC_DEBUG_CLASSMAP_USE(_var, _offset, __UNIQUE_ID(_ddebug_class_use= r)) + +#define __DYNAMIC_DEBUG_CLASSMAP_USE(_var, _offset, _uname) \ extern struct _ddebug_class_map _var; \ static struct _ddebug_class_user __aligned(8) __used \ __section("__dyndbg_class_users") _uname =3D { \ diff --git a/lib/dynamic_debug.c b/lib/dynamic_debug.c index f60a723a441b..b0da3dd4ac44 100644 --- a/lib/dynamic_debug.c +++ b/lib/dynamic_debug.c @@ -198,7 +198,7 @@ ddebug_find_valid_class(struct _ddebug_info const *di, = const char *query_class, if (idx >=3D 0) { vpr_di_info(di, "class-ref: %s -> %s.%s ", cli->mod_name, cli->map->mod_name, query_class); - *class_id =3D idx + cli->map->base; + *class_id =3D idx + cli->map->base - cli->offset; return cli->map; } } @@ -206,12 +206,17 @@ ddebug_find_valid_class(struct _ddebug_info const *di= , const char *query_class, return NULL; } =20 -static bool ddebug_class_in_range(const int class_id, const struct _ddebug= _class_map *map) +static bool ddebug_class_map_in_range(const int class_id, const struct _dd= ebug_class_map *map) { return (class_id >=3D map->base && class_id < map->base + map->length); } =20 +static bool ddebug_class_user_in_range(const int class_id, const struct _d= debug_class_user *user) +{ + return ddebug_class_map_in_range(class_id - user->offset, user->map); +} + static struct _ddebug_class_map * ddebug_find_map_by_class_id(struct _ddebug_info *di, int class_id) { @@ -220,11 +225,11 @@ ddebug_find_map_by_class_id(struct _ddebug_info *di, = int class_id) int i; =20 for_subvec(i, map, di, maps) - if (ddebug_class_in_range(class_id, map)) + if (ddebug_class_map_in_range(class_id, map)) return map; =20 for_subvec(i, cli, di, users) - if (ddebug_class_in_range(class_id, cli->map)) + if (ddebug_class_user_in_range(class_id, cli)) return cli->map; =20 return NULL; @@ -1177,12 +1182,12 @@ static const char *ddebug_class_name(struct _ddebug= _info *di, struct _ddebug *dp int i; =20 for_subvec(i, map, di, maps) - if (ddebug_class_in_range(dp->class_id, map)) + if (ddebug_class_map_in_range(dp->class_id, map)) return map->class_names[dp->class_id - map->base]; =20 for_subvec(i, cli, di, users) - if (ddebug_class_in_range(dp->class_id, cli->map)) - return cli->map->class_names[dp->class_id - cli->map->base]; + if (ddebug_class_user_in_range(dp->class_id, cli)) + return cli->map->class_names[dp->class_id - cli->map->base - cli->offse= t]; =20 return NULL; } --=20 2.52.0