From nobody Tue Apr 7 12:55:33 2026 Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) (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 D72F33A5E79 for ; Fri, 13 Mar 2026 13:24:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408248; cv=none; b=e0K5YTwPKfaZz/bfDmoJzofaH4xNeGMyNVLEFoIldx0LsH5l/gy+CjwwwEZ3nn6+PKuBTaRtea2jsm4LSu1V/RMirultN860pnuTYbHPn5O2nrZV9ddsSWaUj4TOo70SI4Tr3QjRqI0JSWhXgtbzd6xKOrVdIeV9n9wddh9HA/0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773408248; c=relaxed/simple; bh=D/yX53Om7UtaCAARmzXSvsAdQ2fZm9aOiO7pyGBbY8w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PmDnMfbjZ0gHYD0ISyZ9ITHuqKPSX8wIw9fqaVQ/RVuuaKpH2gNOE9Fxc8mPTzGUnb1GzujBeMTiQc8FpxYAuAQA2NI3t5O2XmXZzWT80mrqugY2x2zkLOOhmHlIb/Xlaz5IrXNTQmRg4BtHMxgTO/62w+656XtH7yrwlyvYrQM= 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=hTG2uQHl; arc=none smtp.client-ip=209.85.167.180 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="hTG2uQHl" Received: by mail-oi1-f180.google.com with SMTP id 5614622812f47-46703fb602fso906868b6e.0 for ; Fri, 13 Mar 2026 06:24:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1773408245; x=1774013045; 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=qdG+Un7f/ck3xLwdvB5oV2R2xxQrjM1Me1J1P6bJ/B8=; b=hTG2uQHl/JMH/VScBOMrwkmpgZTsfhPDdjZLjgqzRNmfFcFquhqlOuQ6w2PsqkSgSB 92yyj8RsVeuEZhXBS1FYztfTx3KkkqS77Fj3ymEnTM9lA0ZMWZMxvz3CCi/iLz8s6wDc p9JgfrtV7FVO6Gqp3LtwUjIeQTQvoZ4xDIxoiEudbwuDB54vAXk4x1kQE3j2A+w+UQdc 5qx3FRKh7JVpu1su7GC2O421GmvQ2Km6SIXqG81NCnU53QxJcwXzvQI+2i9YFs90aKmT EwGyeFvJX9qUHKS69AhDruJkbfBy+eoh8NGQ2dgrxW5+D+bqGJrxf4PAIMJHGg7P9pPI 69iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773408245; x=1774013045; 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=qdG+Un7f/ck3xLwdvB5oV2R2xxQrjM1Me1J1P6bJ/B8=; b=fOWvMZlZ8PXq3SHQ1nuzBmuFsjnfnLH1guuQv8pf+f7AwPKyZjQekcY4rs9bzR+2yT sGr6MJ1jHGo0Y3h1lJxxZLQLd84qbYgSf94t8IpDkwkovXnqRD8VY9kwNgMdI5lMNL2T biJi7OmJvxoJf5rsZMbYOBAhC/MHEOosSe++ECoi96p7gt/dNpHRdzl7fRHtw9GAnXUV Pf3eG1yTvCeFoMb4rVFimdRsL4ahR4T/pZp5Q1OKpGU0x1RVlC3kF7njFMvDQfxUasVR gIZztuLb9uEbkuyz1jVVE+leqn6loZftPLNTae+E19+Ly6sR48lAFQZaKcZ8zOGzEAm7 3Ltg== X-Forwarded-Encrypted: i=1; AJvYcCWTq2iIovO9h3ZBBhZiCxy9OZ4WN82XXi+DYtmRhuh1Xm+mXWdue6yRYM+RJLdYsHeRDK3FPmGPVN5Ca0w=@vger.kernel.org X-Gm-Message-State: AOJu0Yzk9UJ/0/hb9hCmVHGlyeDVZoeXPnSxl5Df1qTnAMFyDYFxMPPA g4fusGa8yQfWeKtNDwuHYLYwXvL6G8uCV9Ou6d8WS33j/FTiCtdXUb2O X-Gm-Gg: ATEYQzy6ugGVfmNphm5hbXpbrtdRWDARcLZQQFWnxs9YjsVltBrEXzRWN+Io9AoWnAs 9+xtu4tHU97MyIdPIoiWAJjJb+mbznaFUi3vOBZgTAo80onpgnFn4U660YzCta45WUjrUX4hsDl PWtY2cTbtikLOduBuQy1YN6dbCiaWB3VU1nPcgVxtc5UZ6C1AyRLxCw6uTYtHyXvpvna1IBCr7p U9ytpweymvaY5EUkeTy09wobLMjN7wmysEjBVFCVFkvRshw36XcAqRtCxoQcr9jH5IFVAFc1Lgh W6raXq1t6pz1Oq21EEcWDofP4NdgdHBFH5jEt1xFpUs+nVsqL4Z4Hup/bhkYGkMkbQ3lP50HVIf oeOmM9szhjjgIPva4dpbKCU2NYsMGDXU3y7iGwAicrTUk/ofcSrwfC0/VU6T57ioxQlKUEDlYiy pRpaRAX6esNlzSKCwUuh11dDKIaEdCt6NOTL4iRJjXfK0pc3ZU X-Received: by 2002:a05:6808:4783:b0:466:f60b:19c5 with SMTP id 5614622812f47-46757052ad7mr1017669b6e.6.1773408244642; Fri, 13 Mar 2026 06:24:04 -0700 (PDT) Received: from frodo (c-98-38-17-99.hsd1.co.comcast.net. [98.38.17.99]) by smtp.googlemail.com with ESMTPSA id 5614622812f47-4673434a35csm4795987b6e.20.2026.03.13.06.24.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Mar 2026 06:24:04 -0700 (PDT) From: Jim Cromie To: airlied@gmail.com, simona@ffwll.ch, jbaron@akamai.com, gregkh@linuxfoundation.org, Jim Cromie , Andrew Morton , linux-kernel@vger.kernel.org Cc: mripard@kernel.org, tzimmermann@suse.de, maarten.lankhorst@linux.intel.com, jani.nikula@intel.com, ville.syrjala@linux.intel.com, christian.koenig@amd.com, matthew.auld@intel.com, arunpravin.paneerselvam@amd.com, louis.chauvet@bootlin.com, skhan@linuxfoundation.org, pmladek@suse.com, ukaszb@chromium.org, dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, amd-gfx@lists.freedesktop.org Subject: [PATCH v11 31/65] dyndbg: add DYNAMIC_DEBUG_CLASSMAP_USE_(dd_class_name, offset) Date: Fri, 13 Mar 2026 07:19:56 -0600 Message-ID: <20260313132103.2529746-32-jim.cromie@gmail.com> X-Mailer: git-send-email 2.53.0 In-Reply-To: <20260313132103.2529746-1-jim.cromie@gmail.com> References: <20260313132103.2529746-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 cannot define their constants to avoid DRM's drm_debug_category 0..10 reservations, we would have a conflict with reserved-ids. In this case a driver needing to use both would _USE_ one of them with an offset to avoid the conflict. This will handle most foreseeable cases; perhaps a 3-X-3 of classmap-defns X classmap-users would get too awkward and fiddly. 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. NB: this gets a checkpatch warning about unused _offset arg, apparently because the arg is 5 lines down, and out of the chunk context window. 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 a1454db1bcb0..0d1245aefc69 100644 --- a/include/linux/dynamic_debug.h +++ b/include/linux/dynamic_debug.h @@ -88,7 +88,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 /* @@ -239,11 +239,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 e9fa0c8868db..2083a8546460 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; @@ -1178,12 +1183,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.53.0