From nobody Sun Feb 8 04:23:21 2026 Received: from mx07-00376f01.pphosted.com (mx07-00376f01.pphosted.com [185.132.180.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7500738A2A7 for ; Tue, 13 Jan 2026 10:17:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.132.180.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299445; cv=none; b=THuTWjCk1BCQZi0siCZD4kB61C2OCilbA+mcfucVZqvoHIwmR3BUAKSd+JH/XTqnuVn6r4U30fdO47FAgjWt+D3japvNdvD8XurVfmcNnD3x5tnHD8rgCm+1x/TYCdRdQ5L5+1PHFsSUE39bhtGKSDxQ8IfKXOZxgGHeyPY7G8A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299445; c=relaxed/simple; bh=6aqVeJpps/3ZhmTvQaT6R5v+8BB2w0ReDbd5719z0LU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=n35PfBhzwMfeloPk3CUF81xCUVt4bY0mnNbRIeuPf3VU7z4FQw/nYVMS7E1DUCKemmarvO0ZR2/NXxeflZZw6KrbrKrnVutXDIVvtfsmPfxiWJbrnVgkku0h3+MQnv/v37DFxOs3dEMgmhJ5h9+jSrNdfLPo/OgkoSGVTQ2uV5Y= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=imgtec.com; spf=pass smtp.mailfrom=imgtec.com; dkim=pass (2048-bit key) header.d=imgtec.com header.i=@imgtec.com header.b=pwNSCw+o; arc=none smtp.client-ip=185.132.180.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=imgtec.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=imgtec.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=imgtec.com header.i=@imgtec.com header.b="pwNSCw+o" Received: from pps.filterd (m0168889.ppops.net [127.0.0.1]) by mx07-00376f01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60D5o3eK3118609; Tue, 13 Jan 2026 10:16:57 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imgtec.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=dk201812; bh=f Jm9vmmZLy2U33YDNX0kpovc6Ih90z166NKY84u6Ulw=; b=pwNSCw+oy9rCfCOtA Lzav+tWFBCvek01ZyrXqoBqUykoFCO6ND0uvfG9PQtbE0MjWwFXmC4EK4SfihC3e F7d/uB+ZAKd9TW98R5gE0Kc1LL63GVr7t93s2JSTKu2zyGfBLRzdVj8EQAolcQ1y D68gV9Xo61kcMiVag8o/4sR+SKZktXCm7gkXfiNUYe6xonNcNfYssYp3+gNXkM0X IYo6iSKLHGeIPNJ1GLydyXSqdJ12rvbp4LYH5HbWrVK/T6ZIvnEXW9o42jto4ZyZ 7hLEQ5/OQortKU1MoaO7SOW1lvcLmjjXu97YuzyzMKBD4RMJYVPpEEq/M2CvOOjF CQYOA== Received: from hhmail01.hh.imgtec.org (83-244-153-141.cust-83.exponential-e.net [83.244.153.141]) by mx07-00376f01.pphosted.com (PPS) with ESMTPS id 4bkfqua1rr-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jan 2026 10:16:57 +0000 (GMT) Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa (172.25.4.58) by HHMAIL01.hh.imgtec.org (10.100.10.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Tue, 13 Jan 2026 10:16:55 +0000 From: Matt Coster Date: Tue, 13 Jan 2026 10:16:39 +0000 Subject: [PATCH 1/6] drm/imagination: Simplify module parameters Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260113-device-support-info-v1-1-91e5db7f7294@imgtec.com> References: <20260113-device-support-info-v1-0-91e5db7f7294@imgtec.com> In-Reply-To: <20260113-device-support-info-v1-0-91e5db7f7294@imgtec.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter CC: Frank Binns , Brajesh Gupta , Alessio Belle , Alexandru Dadu , Matt Coster , , X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=15589; i=matt.coster@imgtec.com; h=from:subject:message-id; bh=6aqVeJpps/3ZhmTvQaT6R5v+8BB2w0ReDbd5719z0LU=; b=owGbwMvMwCFWuUfy8817WRsYT6slMWSmSU+zY7TdVBdYWbnwVf8k+YRKlReai4PW3tzENmHlh BQ13lvNHaUsDGIcDLJiiiw7VliuUPujpiVx41cxzBxWJpAhDFycAjARoW8M/yOt1BWNvP/NM5gi o8677UOVTY/vpxVKtb87k+0WXjzO/Zjhf1ZUYmxx8Z1JS0983FfgWtv1K/H/VeaHXN0+exZYt2s 95gYA X-Developer-Key: i=matt.coster@imgtec.com; a=openpgp; fpr=05A40CFCE7269D61D97100A1747F0A9036F90DFA X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTEzMDA4NiBTYWx0ZWRfX7JbDwh8H8FHh ZS169yFfKKtZRJNNqXTh4TWrAw5ZXupf46yLuJX1S7st2k5nV6xr1byo9TknY90Dy5LwFYhIwc+ mMMRGjUMsZlInxy2Anr+DMm/uhp505toEFuZ+6Y1oz6Bl1X9mMEhYT/HUZ3CuCwQGWNFSyyBWdg 799vxa/J+AUWX1GzytuTxJEONrEMN51Jl8jfde8/NH9lFbUJ84yrTKUNcqdU0jtTETOUw4SRuBQ uV8IuuWFzuJa1dnOc3yV+lkBXfR46upkFE+8erjZwOuhgY8E5guo+Ug0r/nhBH5wjqugBcvulHo y1V8T4fMlelfXHWavxyCFoDJa0upuVIbvPwWgRB+xM9NWCP9MGHaYgsfm3PSNl+ftJHnqatiFwh s/xQN/67HpdHEucBMtxV0QJb4qRqsg0Z3kMP8vcF4uVJnwY+/UednLGLbLhfbe1t4R6/5azrwld EeMGcZajbfqDxymY0Tg== X-Proofpoint-GUID: _S6YtbFmLBAd7LQnxJQ-5T1VEfaaVS-e X-Proofpoint-ORIG-GUID: _S6YtbFmLBAd7LQnxJQ-5T1VEfaaVS-e X-Authority-Analysis: v=2.4 cv=aexsXBot c=1 sm=1 tr=0 ts=69661b99 cx=c_pps a=AKOq//PuzOIrVTIF9yBwbA==:117 a=AKOq//PuzOIrVTIF9yBwbA==:17 a=jNdnsKvOq7QA:10 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=r_1tXGB3AAAA:8 a=6dx0svsTsglNHlDHw4cA:9 a=QEXdDO2ut3YA:10 a=t8nPyN_e6usw4ciXM-Pk:22 We had a whole load of bloaty infrastructure to deal with module parameters in a way that's wholly unnecessary. Strip it all back to basics to make adding new parameters less of a headache. Signed-off-by: Matt Coster Reviewed-by: Alessio Belle --- drivers/gpu/drm/imagination/Makefile | 1 - drivers/gpu/drm/imagination/pvr_debugfs.c | 2 - drivers/gpu/drm/imagination/pvr_device.c | 9 -- drivers/gpu/drm/imagination/pvr_device.h | 10 -- drivers/gpu/drm/imagination/pvr_fw_trace.c | 46 ++++++++- drivers/gpu/drm/imagination/pvr_fw_trace.h | 3 - drivers/gpu/drm/imagination/pvr_params.c | 147 -------------------------= ---- drivers/gpu/drm/imagination/pvr_params.h | 72 -------------- 8 files changed, 42 insertions(+), 248 deletions(-) diff --git a/drivers/gpu/drm/imagination/Makefile b/drivers/gpu/drm/imagina= tion/Makefile index 7cca66f00a38a..ab63eac9ba7f7 100644 --- a/drivers/gpu/drm/imagination/Makefile +++ b/drivers/gpu/drm/imagination/Makefile @@ -20,7 +20,6 @@ powervr-y :=3D \ pvr_hwrt.o \ pvr_job.o \ pvr_mmu.o \ - pvr_params.o \ pvr_power.o \ pvr_queue.o \ pvr_stream.o \ diff --git a/drivers/gpu/drm/imagination/pvr_debugfs.c b/drivers/gpu/drm/im= agination/pvr_debugfs.c index c7ce7daaa87a0..ebdb05de40728 100644 --- a/drivers/gpu/drm/imagination/pvr_debugfs.c +++ b/drivers/gpu/drm/imagination/pvr_debugfs.c @@ -5,7 +5,6 @@ =20 #include "pvr_device.h" #include "pvr_fw_trace.h" -#include "pvr_params.h" =20 #include #include @@ -18,7 +17,6 @@ #include =20 static const struct pvr_debugfs_entry pvr_debugfs_entries[] =3D { - {"pvr_params", pvr_params_debugfs_init}, {"pvr_fw", pvr_fw_trace_debugfs_init}, }; =20 diff --git a/drivers/gpu/drm/imagination/pvr_device.c b/drivers/gpu/drm/ima= gination/pvr_device.c index 78d6b8a0a4506..abe8ad1d447ac 100644 --- a/drivers/gpu/drm/imagination/pvr_device.c +++ b/drivers/gpu/drm/imagination/pvr_device.c @@ -5,7 +5,6 @@ #include "pvr_device_info.h" =20 #include "pvr_fw.h" -#include "pvr_params.h" #include "pvr_power.h" #include "pvr_queue.h" #include "pvr_rogue_cr_defs.h" @@ -607,14 +606,6 @@ pvr_device_init(struct pvr_device *pvr_dev) /* Get the platform-specific data based on the compatible string. */ pvr_dev->device_data =3D of_device_get_match_data(dev); =20 - /* - * Setup device parameters. We do this first in case other steps - * depend on them. - */ - err =3D pvr_device_params_init(&pvr_dev->params); - if (err) - return err; - /* Enable and initialize clocks required for the device to operate. */ err =3D pvr_device_clk_init(pvr_dev); if (err) diff --git a/drivers/gpu/drm/imagination/pvr_device.h b/drivers/gpu/drm/ima= gination/pvr_device.h index ec53ff2755418..d0e61923fd9b4 100644 --- a/drivers/gpu/drm/imagination/pvr_device.h +++ b/drivers/gpu/drm/imagination/pvr_device.h @@ -7,7 +7,6 @@ #include "pvr_ccb.h" #include "pvr_device_info.h" #include "pvr_fw.h" -#include "pvr_params.h" #include "pvr_rogue_fwif_stream.h" #include "pvr_stream.h" =20 @@ -192,15 +191,6 @@ struct pvr_device { /** @fw_dev: Firmware related data. */ struct pvr_fw_device fw_dev; =20 - /** - * @params: Device-specific parameters. - * - * The values of these parameters are initialized from the - * defaults specified as module parameters. They may be - * modified at runtime via debugfs (if enabled). - */ - struct pvr_device_params params; - /** @stream_musthave_quirks: Bit array of "must-have" quirks for stream c= ommands. */ u32 stream_musthave_quirks[PVR_STREAM_TYPE_MAX][PVR_STREAM_EXTHDR_TYPE_MA= X]; =20 diff --git a/drivers/gpu/drm/imagination/pvr_fw_trace.c b/drivers/gpu/drm/i= magination/pvr_fw_trace.c index 8a56952f6730e..a607e5b108915 100644 --- a/drivers/gpu/drm/imagination/pvr_fw_trace.c +++ b/drivers/gpu/drm/imagination/pvr_fw_trace.c @@ -14,9 +14,26 @@ #include #include #include +#include #include #include =20 +/* + * Don't gate this behind CONFIG_DEBUG_FS so that it can be used as an ini= tial + * value without further conditional code... + */ +static u32 pvr_fw_trace_init_mask; + +/* + * ...but do only expose the module parameter if debugfs is enabled, since + * there's no reason to turn on fw_trace without it. + */ +#if IS_ENABLED(CONFIG_DEBUG_FS) +module_param_named(init_fw_trace_mask, pvr_fw_trace_init_mask, hexint, 060= 0); +MODULE_PARM_DESC(init_fw_trace_mask, + "Enable FW trace for the specified groups at device init time"); +#endif + static void tracebuf_ctrl_init(void *cpu_ptr, void *priv) { @@ -126,6 +143,8 @@ void pvr_fw_trace_fini(struct pvr_device *pvr_dev) * @group_mask: New log group mask. * * Returns: + * * 0 if the provided @group_mask is the same as the current value (this= is a + * short-circuit evaluation), * * 0 on success, * * Any error returned by pvr_kccb_send_cmd(), or * * -%EIO if the device is lost. @@ -138,6 +157,10 @@ update_logtype(struct pvr_device *pvr_dev, u32 group_m= ask) int idx; int err; =20 + /* No change in group_mask =3D> nothing to update. */ + if (fw_trace->group_mask =3D=3D group_mask) + return 0; + if (group_mask) fw_trace->tracebuf_ctrl->log_type =3D ROGUE_FWIF_LOG_TYPE_TRACE | group_= mask; else @@ -437,13 +460,25 @@ static const struct file_operations pvr_fw_trace_fops= =3D { .release =3D fw_trace_release, }; =20 -void -pvr_fw_trace_mask_update(struct pvr_device *pvr_dev, u32 old_mask, u32 new= _mask) +static int pvr_fw_trace_mask_get(void *data, u64 *value) +{ + struct pvr_device *pvr_dev =3D data; + + *value =3D pvr_dev->fw_dev.fw_trace.group_mask; + + return 0; +} + +static int pvr_fw_trace_mask_set(void *data, u64 value) { - if (IS_ENABLED(CONFIG_DEBUG_FS) && old_mask !=3D new_mask) - update_logtype(pvr_dev, new_mask); + struct pvr_device *pvr_dev =3D data; + + return update_logtype(pvr_dev, (u32)value); } =20 +DEFINE_DEBUGFS_ATTRIBUTE(pvr_fw_trace_mask_fops, pvr_fw_trace_mask_get, + pvr_fw_trace_mask_set, "0x%08llx\n"); + void pvr_fw_trace_debugfs_init(struct pvr_device *pvr_dev, struct dentry *dir) { @@ -463,4 +498,7 @@ pvr_fw_trace_debugfs_init(struct pvr_device *pvr_dev, s= truct dentry *dir) &fw_trace->buffers[thread_nr], &pvr_fw_trace_fops); } + + debugfs_create_file("trace_mask", 0600, dir, fw_trace, + &pvr_fw_trace_mask_fops); } diff --git a/drivers/gpu/drm/imagination/pvr_fw_trace.h b/drivers/gpu/drm/i= magination/pvr_fw_trace.h index 1d0ef937427a5..0cc57f66675d8 100644 --- a/drivers/gpu/drm/imagination/pvr_fw_trace.h +++ b/drivers/gpu/drm/imagination/pvr_fw_trace.h @@ -68,9 +68,6 @@ void pvr_fw_trace_fini(struct pvr_device *pvr_dev); /* Forward declaration from . */ struct dentry; =20 -void pvr_fw_trace_mask_update(struct pvr_device *pvr_dev, u32 old_mask, - u32 new_mask); - void pvr_fw_trace_debugfs_init(struct pvr_device *pvr_dev, struct dentry *= dir); =20 #endif /* PVR_FW_TRACE_H */ diff --git a/drivers/gpu/drm/imagination/pvr_params.c b/drivers/gpu/drm/ima= gination/pvr_params.c deleted file mode 100644 index b91759f362c57..0000000000000 --- a/drivers/gpu/drm/imagination/pvr_params.c +++ /dev/null @@ -1,147 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-only OR MIT -/* Copyright (c) 2023 Imagination Technologies Ltd. */ - -#include "pvr_params.h" - -#include -#include - -static struct pvr_device_params pvr_device_param_defaults __read_mostly = =3D { -#define X(type_, name_, value_, desc_, ...) .name_ =3D (value_), - PVR_DEVICE_PARAMS -#undef X -}; - -#define PVR_DEVICE_PARAM_NAMED(name_, type_, desc_) \ - module_param_named(name_, pvr_device_param_defaults.name_, type_, \ - 0400); \ - MODULE_PARM_DESC(name_, desc_); - -/* - * This list of defines must contain every type specified in "pvr_params.h= " as - * ``PVR_PARAM_TYPE_*_C``. - */ -#define PVR_PARAM_TYPE_X32_MODPARAM uint - -#define X(type_, name_, value_, desc_, ...) \ - PVR_DEVICE_PARAM_NAMED(name_, PVR_PARAM_TYPE_##type_##_MODPARAM, desc_); -PVR_DEVICE_PARAMS -#undef X - -int -pvr_device_params_init(struct pvr_device_params *params) -{ - /* - * If heap-allocated parameters are added in the future (e.g. - * modparam's charp type), they must be handled specially here (via - * kstrdup() in the case of charp). Since that's not necessary yet, - * a straight copy will do for now. This change will also require a - * pvr_device_params_fini() function to free any heap-allocated copies. - */ - - *params =3D pvr_device_param_defaults; - - return 0; -} - -#if defined(CONFIG_DEBUG_FS) -#include "pvr_device.h" - -#include -#include -#include -#include -#include - -/* - * This list of defines must contain every type specified in "pvr_params.h= " as - * ``PVR_PARAM_TYPE_*_C``. - */ -#define PVR_PARAM_TYPE_X32_FMT "0x%08llx" - -#define X_SET(name_, mode_) X_SET_##mode_(name_) -#define X_SET_DEF(name_, update_, mode_) X_SET_DEF_##mode_(name_, update_) - -#define X_SET_RO(name_) NULL -#define X_SET_RW(name_) __pvr_device_param_##name_##set - -#define X_SET_DEF_RO(name_, update_) -#define X_SET_DEF_RW(name_, update_) \ - static int \ - X_SET_RW(name_)(void *data, u64 val) \ - { \ - struct pvr_device *pvr_dev =3D data; \ - /* This is not just (update_) to suppress -Waddress. */ \ - if ((void *)(update_) !=3D NULL) \ - (update_)(pvr_dev, pvr_dev->params.name_, val); \ - pvr_dev->params.name_ =3D val; \ - return 0; \ - } - -#define X(type_, name_, value_, desc_, mode_, update_) = \ - static int \ - __pvr_device_param_##name_##_get(void *data, u64 *val) \ - { \ - struct pvr_device *pvr_dev =3D data; \ - *val =3D pvr_dev->params.name_; \ - return 0; \ - } \ - X_SET_DEF(name_, update_, mode_) \ - static int \ - __pvr_device_param_##name_##_open(struct inode *inode, \ - struct file *file) \ - { \ - __simple_attr_check_format(PVR_PARAM_TYPE_##type_##_FMT, \ - 0ull); \ - return simple_attr_open(inode, file, \ - __pvr_device_param_##name_##_get, \ - X_SET(name_, mode_), \ - PVR_PARAM_TYPE_##type_##_FMT); \ - } -PVR_DEVICE_PARAMS -#undef X - -#undef X_SET -#undef X_SET_RO -#undef X_SET_RW -#undef X_SET_DEF -#undef X_SET_DEF_RO -#undef X_SET_DEF_RW - -static struct { -#define X(type_, name_, value_, desc_, mode_, update_) \ - const struct file_operations name_; - PVR_DEVICE_PARAMS -#undef X -} pvr_device_param_debugfs_fops =3D { -#define X(type_, name_, value_, desc_, mode_, update_) \ - .name_ =3D { \ - .owner =3D THIS_MODULE, \ - .open =3D __pvr_device_param_##name_##_open, \ - .release =3D simple_attr_release, \ - .read =3D simple_attr_read, \ - .write =3D simple_attr_write, \ - .llseek =3D generic_file_llseek, \ - }, - PVR_DEVICE_PARAMS -#undef X -}; - -void -pvr_params_debugfs_init(struct pvr_device *pvr_dev, struct dentry *dir) -{ -#define X_MODE(mode_) X_MODE_##mode_ -#define X_MODE_RO 0400 -#define X_MODE_RW 0600 - -#define X(type_, name_, value_, desc_, mode_, update_) \ - debugfs_create_file(#name_, X_MODE(mode_), dir, pvr_dev, \ - &pvr_device_param_debugfs_fops.name_); - PVR_DEVICE_PARAMS -#undef X - -#undef X_MODE -#undef X_MODE_RO -#undef X_MODE_RW -} -#endif diff --git a/drivers/gpu/drm/imagination/pvr_params.h b/drivers/gpu/drm/ima= gination/pvr_params.h deleted file mode 100644 index 5807915b456bf..0000000000000 --- a/drivers/gpu/drm/imagination/pvr_params.h +++ /dev/null @@ -1,72 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ -/* Copyright (c) 2023 Imagination Technologies Ltd. */ - -#ifndef PVR_PARAMS_H -#define PVR_PARAMS_H - -#include "pvr_rogue_fwif.h" - -#include -#include - -/* - * This is the definitive list of types allowed in the definition of - * %PVR_DEVICE_PARAMS. - */ -#define PVR_PARAM_TYPE_X32_C u32 - -/* - * This macro defines all device-specific parameters; that is parameters w= hich - * are set independently per device. - * - * The X-macro accepts the following arguments. Arguments marked with [deb= ugfs] - * are ignored when debugfs is disabled; values used for these arguments m= ay - * safely be gated behind CONFIG_DEBUG_FS. - * - * @type_: The definitive list of allowed values is PVR_PARAM_TYPE_*_C. - * @name_: Name of the parameter. This is used both as the field name in C= and - * stringified as the parameter name. - * @value_: Initial/default value. - * @desc_: String literal used as help text to describe the usage of this - * parameter. - * @mode_: [debugfs] One of {RO,RW}. The access mode of the debugfs entry = for - * this parameter. - * @update_: [debugfs] When debugfs support is enabled, parameters may be - * updated at runtime. When this happens, this function will be - * called to allow changes to propagate. The signature of this - * function is: - * - * void (*)(struct pvr_device *pvr_dev, T old_val, T new_val) - * - * Where T is the C type associated with @type_. - * - * If @mode_ does not allow write access, this function will nev= er be - * called. In this case, or if no update callback is required, y= ou - * should specify NULL for this argument. - */ -#define PVR_DEVICE_PARAMS = \ - X(X32, fw_trace_mask, ROGUE_FWIF_LOG_TYPE_NONE, \ - "Enable FW trace for the specified groups. Specifying 0 disables " \ - "all FW tracing.", \ - RW, pvr_fw_trace_mask_update) - -struct pvr_device_params { -#define X(type_, name_, value_, desc_, ...) \ - PVR_PARAM_TYPE_##type_##_C name_; - PVR_DEVICE_PARAMS -#undef X -}; - -int pvr_device_params_init(struct pvr_device_params *params); - -#if defined(CONFIG_DEBUG_FS) -/* Forward declaration from "pvr_device.h". */ -struct pvr_device; - -/* Forward declaration from . */ -struct dentry; - -void pvr_params_debugfs_init(struct pvr_device *pvr_dev, struct dentry *di= r); -#endif /* defined(CONFIG_DEBUG_FS) */ - -#endif /* PVR_PARAMS_H */ --=20 2.52.0 From nobody Sun Feb 8 04:23:21 2026 Received: from mx07-00376f01.pphosted.com (mx07-00376f01.pphosted.com [185.132.180.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C2DD38A9B7 for ; Tue, 13 Jan 2026 10:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.132.180.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299445; cv=none; b=E5A//X8AMnAJ4dH+QsVsRMIipsSVd8tYLFtscCyzocv8PLUfSx0fmf9T7+H824k40urU+jsHLsh6WXfXcoXUd9BahRoWLYFrNP/463SmBukdwirkpj514EdQpvo01C2Pu5Zg4il9Dij2lykzyI+qZQkZL45WG0EaZspDXhJ9Sy4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299445; c=relaxed/simple; bh=e48rK276oHs7zkZU1GPlTK5G1OMsY6vbZe40B8Ci+g4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=KJSKBhov5O4zEUzpqKH5mxh7Su3ynW4r24BeA6uPfYoVEQPGZrGYExjuUAKqUUqYDtikmwTd8AqUqOF5nIpxLga2W1+6GtuafK6a8hMJ1RaSZlf7z6lqLLkq0fdTCc9Oq3j1V3MY5gsNqep8quWRomopUYebBlUe/Vr4X9tWr/8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=imgtec.com; spf=pass smtp.mailfrom=imgtec.com; dkim=pass (2048-bit key) header.d=imgtec.com header.i=@imgtec.com header.b=v9La1J1b; arc=none smtp.client-ip=185.132.180.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=imgtec.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=imgtec.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=imgtec.com header.i=@imgtec.com header.b="v9La1J1b" Received: from pps.filterd (m0168889.ppops.net [127.0.0.1]) by mx07-00376f01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60D6XiIS3196794; Tue, 13 Jan 2026 10:16:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imgtec.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=dk201812; bh=Z w788SzHZ6X+qopWNgn6e9jJ+VJXNluv2HjpPwnE7i0=; b=v9La1J1b8nnODhY9+ dwR6IVSBGg4MT41GT6rHgig6g+1tf7r8P6SujMQa2VWNsMFOPqbWZMmus+zl3bPs /pBVkB0nR8PINDPivMsNOjssIsiAJphcC7Ka5YZ7hrymPcntdC3PhvIT8X+M6EY/ B332oJ/v6GRz8dyeTOi3eQzT5NPhU2Gik/V+VQRE/5xfvohynwoMf1LOTImkiuz4 6aiAeBHMNf0cjxp3jN7D5uws2Y45VHyisKS50nqt/nEICR9h+w4Ve1XwQ5yEEhh4 HtWBkJ0zwMgSc3tjlvI2lubeHm+/zxyq0aVzhZ+OoGNAiOCbL74VPqT0CCE4PaiD idL3w== Received: from hhmail01.hh.imgtec.org (83-244-153-141.cust-83.exponential-e.net [83.244.153.141]) by mx07-00376f01.pphosted.com (PPS) with ESMTPS id 4bkfqua1rs-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jan 2026 10:16:57 +0000 (GMT) Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa (172.25.4.58) by HHMAIL01.hh.imgtec.org (10.100.10.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Tue, 13 Jan 2026 10:16:56 +0000 From: Matt Coster Date: Tue, 13 Jan 2026 10:16:40 +0000 Subject: [PATCH 2/6] drm/imagination: Validate fw trace group_mask Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260113-device-support-info-v1-2-91e5db7f7294@imgtec.com> References: <20260113-device-support-info-v1-0-91e5db7f7294@imgtec.com> In-Reply-To: <20260113-device-support-info-v1-0-91e5db7f7294@imgtec.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter CC: Frank Binns , Brajesh Gupta , Alessio Belle , Alexandru Dadu , Matt Coster , , X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=4987; i=matt.coster@imgtec.com; h=from:subject:message-id; bh=e48rK276oHs7zkZU1GPlTK5G1OMsY6vbZe40B8Ci+g4=; b=owGbwMvMwCFWuUfy8817WRsYT6slMWSmSU8LPBzet+LYsm1t/uXZbllzLSaubf3SXeNgxF1ss 2Z9NHNNRykLgxgHg6yYIsuOFZYr1P6oaUnc+FUMM4eVCWQIAxenAEykV4uRYeEk32+WMqGHfab4 WLWc9z2mzhLttedzHI/M5NDIBDGhCEaGW6HyU+WuNek8di/f+WX/UYOb396ureBfGtcQteDNzmw 2fgA= X-Developer-Key: i=matt.coster@imgtec.com; a=openpgp; fpr=05A40CFCE7269D61D97100A1747F0A9036F90DFA X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTEzMDA4NiBTYWx0ZWRfX2LgACICv+lMY MK6nPAkr/vlKM5TId0Yn/1Zp0NmFCcSrQsgLff0qOnsBFKx5QS5cAdxhxRGgAun8o4r1FUlW9IM FaGan9sP7l21yIH+BSyfTiTJGVX0Be9RndwRrrvXk6HJIXBsCuXaAPzfM7wy2vUNbiJe/Ij6AVo kgu7OOz8r+E/Fi4atjSiEqn5wk+W4UTFW0fL2gZYePxarn3O1xfX6NikQI4D9sfSDlhCNo0r62t TOO6uByXqgF6SR24bRfwNUYOJR4gPHKCYJHrfm7Ua43TzhNGhbArBdaGkoxb7xBP/n9gyIRTsgC iKlhbFsosEDP6g3Y3aVV0/wrhGFgEFyZo8O1sKkrL8oMm05U+sGqXdsUweS3vyC9OtQFgMM848l 28IfGHGFNov3N59we9wzV286FXBpLTM+10H1iOaoNbwm8/pbhKMo53ErqjwbusqrtUlupIM/mSH LiCrGl2rad24+Dav0JA== X-Proofpoint-GUID: ppISc8BZrdA-8qX2HTFw-0qEPa7ugPoP X-Proofpoint-ORIG-GUID: ppISc8BZrdA-8qX2HTFw-0qEPa7ugPoP X-Authority-Analysis: v=2.4 cv=aexsXBot c=1 sm=1 tr=0 ts=69661b99 cx=c_pps a=AKOq//PuzOIrVTIF9yBwbA==:117 a=AKOq//PuzOIrVTIF9yBwbA==:17 a=jNdnsKvOq7QA:10 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=r_1tXGB3AAAA:8 a=Nbp4WR2GB4CHkkDwQf0A:9 a=QEXdDO2ut3YA:10 a=t8nPyN_e6usw4ciXM-Pk:22 This value can come from two places: a module parameter or a debugfs file. In both cases, validate it early to provide feedback to userspace at the time the value is set instead of deferring until the value is used. Signed-off-by: Matt Coster Reviewed-by: Alessio Belle --- drivers/gpu/drm/imagination/pvr_fw_trace.c | 76 ++++++++++++++++++++++++--= ---- 1 file changed, 62 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/imagination/pvr_fw_trace.c b/drivers/gpu/drm/i= magination/pvr_fw_trace.c index a607e5b108915..a2aa588cbe5fa 100644 --- a/drivers/gpu/drm/imagination/pvr_fw_trace.c +++ b/drivers/gpu/drm/imagination/pvr_fw_trace.c @@ -12,12 +12,35 @@ #include =20 #include +#include #include #include #include #include #include =20 +static int +validate_group_mask(struct pvr_device *pvr_dev, const u32 group_mask) +{ + if (group_mask & ~ROGUE_FWIF_LOG_TYPE_GROUP_MASK) { + drm_warn(from_pvr_device(pvr_dev), + "Invalid fw_trace group mask 0x%08x (must be a subset of 0x%08x)", + group_mask, ROGUE_FWIF_LOG_TYPE_GROUP_MASK); + return -EINVAL; + } + + return 0; +} + +static inline u32 +build_log_type(const u32 group_mask) +{ + if (!group_mask) + return ROGUE_FWIF_LOG_TYPE_NONE; + + return group_mask | ROGUE_FWIF_LOG_TYPE_TRACE; +} + /* * Don't gate this behind CONFIG_DEBUG_FS so that it can be used as an ini= tial * value without further conditional code... @@ -29,7 +52,33 @@ static u32 pvr_fw_trace_init_mask; * there's no reason to turn on fw_trace without it. */ #if IS_ENABLED(CONFIG_DEBUG_FS) -module_param_named(init_fw_trace_mask, pvr_fw_trace_init_mask, hexint, 060= 0); +static int +pvr_fw_trace_init_mask_set(const char *val, const struct kernel_param *kp) +{ + u32 mask =3D 0; + int err; + + err =3D kstrtouint(val, 0, &mask); + if (err) + return err; + + err =3D validate_group_mask(NULL, mask); + if (err) + return err; + + *(unsigned int *)kp->arg =3D mask; + + return 0; +} + +const struct kernel_param_ops pvr_fw_trace_init_mask_ops =3D { + .set =3D pvr_fw_trace_init_mask_set, + .get =3D param_get_hexint, +}; + +param_check_hexint(init_fw_trace_mask, &pvr_fw_trace_init_mask); +module_param_cb(init_fw_trace_mask, &pvr_fw_trace_init_mask_ops, &pvr_fw_t= race_init_mask, 0600); +__MODULE_PARM_TYPE(init_fw_trace_mask, "hexint"); MODULE_PARM_DESC(init_fw_trace_mask, "Enable FW trace for the specified groups at device init time"); #endif @@ -42,11 +91,7 @@ tracebuf_ctrl_init(void *cpu_ptr, void *priv) =20 tracebuf_ctrl->tracebuf_size_in_dwords =3D ROGUE_FW_TRACE_BUF_DEFAULT_SIZ= E_IN_DWORDS; tracebuf_ctrl->tracebuf_flags =3D 0; - - if (fw_trace->group_mask) - tracebuf_ctrl->log_type =3D fw_trace->group_mask | ROGUE_FWIF_LOG_TYPE_T= RACE; - else - tracebuf_ctrl->log_type =3D ROGUE_FWIF_LOG_TYPE_NONE; + tracebuf_ctrl->log_type =3D build_log_type(fw_trace->group_mask); =20 for (u32 thread_nr =3D 0; thread_nr < ARRAY_SIZE(fw_trace->buffers); thre= ad_nr++) { struct rogue_fwif_tracebuf_space *tracebuf_space =3D @@ -140,7 +185,7 @@ void pvr_fw_trace_fini(struct pvr_device *pvr_dev) /** * update_logtype() - Send KCCB command to trigger FW to update logtype * @pvr_dev: Target PowerVR device - * @group_mask: New log group mask. + * @group_mask: New log group mask; must pass validate_group_mask(). * * Returns: * * 0 if the provided @group_mask is the same as the current value (this= is a @@ -153,6 +198,7 @@ static int update_logtype(struct pvr_device *pvr_dev, u32 group_mask) { struct pvr_fw_trace *fw_trace =3D &pvr_dev->fw_dev.fw_trace; + struct drm_device *drm_dev =3D from_pvr_device(pvr_dev); struct rogue_fwif_kccb_cmd cmd; int idx; int err; @@ -161,15 +207,11 @@ update_logtype(struct pvr_device *pvr_dev, u32 group_= mask) if (fw_trace->group_mask =3D=3D group_mask) return 0; =20 - if (group_mask) - fw_trace->tracebuf_ctrl->log_type =3D ROGUE_FWIF_LOG_TYPE_TRACE | group_= mask; - else - fw_trace->tracebuf_ctrl->log_type =3D ROGUE_FWIF_LOG_TYPE_NONE; - fw_trace->group_mask =3D group_mask; + fw_trace->tracebuf_ctrl->log_type =3D build_log_type(group_mask); =20 down_read(&pvr_dev->reset_sem); - if (!drm_dev_enter(from_pvr_device(pvr_dev), &idx)) { + if (!drm_dev_enter(drm_dev, &idx)) { err =3D -EIO; goto err_up_read; } @@ -472,8 +514,14 @@ static int pvr_fw_trace_mask_get(void *data, u64 *valu= e) static int pvr_fw_trace_mask_set(void *data, u64 value) { struct pvr_device *pvr_dev =3D data; + const u32 group_mask =3D (u32)value; + int err; + + err =3D validate_group_mask(pvr_dev, group_mask); + if (err) + return err; =20 - return update_logtype(pvr_dev, (u32)value); + return update_logtype(pvr_dev, group_mask); } =20 DEFINE_DEBUGFS_ATTRIBUTE(pvr_fw_trace_mask_fops, pvr_fw_trace_mask_get, --=20 2.52.0 From nobody Sun Feb 8 04:23:21 2026 Received: from mx07-00376f01.pphosted.com (mx07-00376f01.pphosted.com [185.132.180.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7515B38A70F for ; Tue, 13 Jan 2026 10:17:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.132.180.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299444; cv=none; b=qcRUgmDLhyafnkU7mgE0vzJN3iWHdQM9ybOKJrmURXaUpkTJ6AzJMOdY+6jXxSUqZMfWD9tejVngGxSGzuDitc2Gk/cXCmeB/qu1l99pfI8xyS507tS4TkX/rFpIYH7mhNhEIP8rhee0EjvD+kOPP/a52eTOsz/B0Lm33N/F57w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299444; c=relaxed/simple; bh=5EcW8XdUmOfp836puLffKDqVJ8rRli7zcv/+RK2YIfQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=fhUsfSkW8V0+9FkNjtq+6cdr4Gy0LWo8HRPl8zAcmLvkIIuIDCWvhiNJ7LulRCQI1GmRWegJrkzRJsU7lB+YTHyewncKdW0LEYE3bZL/HgaJCK2feYOeYx45xyd4xxEWUB+DmXZUiU7DsxH/VndJ0lNPYik68t8YrikgjZpMjXo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=imgtec.com; spf=pass smtp.mailfrom=imgtec.com; dkim=pass (2048-bit key) header.d=imgtec.com header.i=@imgtec.com header.b=Me1qJjmR; arc=none smtp.client-ip=185.132.180.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=imgtec.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=imgtec.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=imgtec.com header.i=@imgtec.com header.b="Me1qJjmR" Received: from pps.filterd (m0168889.ppops.net [127.0.0.1]) by mx07-00376f01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60D6XiIT3196794; Tue, 13 Jan 2026 10:16:58 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imgtec.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=dk201812; bh=O 9U7zjzOjCEzi5GIRDwZrE0mEmBXOKSi9S9+0WqO3fg=; b=Me1qJjmREiRmuaBsk oiPLCbdhYNxcH99mwKy8VdRRAybrMQa7QXfLNQ00Z6QYqYUkhkqnF73eL7tJO2X4 vMzBex+shSK8xU+4QJWzdrTW1DVvdrrCqzSL1Q+AA39avpCZ7sJxsfxAERK2FFF2 ljpGDln8Z/iorf1/IDLQa6LoF6TKIXB+6kStdcYJ2k9lUWwJ1VEmJuyKvuIgzd1j UAGKbbLDYA2kcEawIaPsziq5Hb5gwBbrm4JO014k2Txwnn3lJucm2QHa6SSiXKM/ 2jtpEVPNX0QNu5rY1pWA7XXY6aoBmbVTFbcqkzHftbCAREu71y1gNYvDXtLtjE80 Sys+g== Received: from hhmail01.hh.imgtec.org (83-244-153-141.cust-83.exponential-e.net [83.244.153.141]) by mx07-00376f01.pphosted.com (PPS) with ESMTPS id 4bkfqua1rs-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jan 2026 10:16:58 +0000 (GMT) Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa (172.25.4.58) by HHMAIL01.hh.imgtec.org (10.100.10.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Tue, 13 Jan 2026 10:16:57 +0000 From: Matt Coster Date: Tue, 13 Jan 2026 10:16:41 +0000 Subject: [PATCH 3/6] drm/imagination: Load FW trace config at init Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260113-device-support-info-v1-3-91e5db7f7294@imgtec.com> References: <20260113-device-support-info-v1-0-91e5db7f7294@imgtec.com> In-Reply-To: <20260113-device-support-info-v1-0-91e5db7f7294@imgtec.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter CC: Frank Binns , Brajesh Gupta , Alessio Belle , Alexandru Dadu , Matt Coster , , X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=1237; i=matt.coster@imgtec.com; h=from:subject:message-id; bh=5EcW8XdUmOfp836puLffKDqVJ8rRli7zcv/+RK2YIfQ=; b=owGbwMvMwCFWuUfy8817WRsYT6slMWSmSU9bVNzdoXC2eM2slzd/7N29acv2RU2CqlJuKkl+L 1avUd+1o6OUhUGMg0FWTJFlxwrLFWp/1LQkbvwqhpnDygQyhIGLUwAmEmHNyDD1VdfmbYxTLIST lzxS7LRIUzx7LjuYJ/O0p2fodE2fhecYfrPEW2izTy3Kcl3d9O/M7f3sfGI9b9+VvOZObFdRbXZ 7ywMA X-Developer-Key: i=matt.coster@imgtec.com; a=openpgp; fpr=05A40CFCE7269D61D97100A1747F0A9036F90DFA X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTEzMDA4NiBTYWx0ZWRfX6XSF99NPkCYa 7raHqa7iI8dku3qu3r9fOkXMmsz9hSzUPq5aa1QouJ0m/x8nGxM7FPc6OReH0HSiWblKvuneDZU IycJ4f5WUphgkUfnZBP+mWIUsS67ti7W2Bas7b/T17JWOTibsQQ+LAjw777B9vXKSaXZCgFoHNr YIEtaZs8taRmrxvjkR7BtxS6Ax9VE+FPYhNdv7H3IMPu0YmGmGhJ8R9pPScOfHWnU7kNJ/Ud6O1 Yga+1ExgxHsLktqDDhqIQWtrKrlskyeM2ZrALtJANrH9jT0QzSoDErtNs6dKqnLI83yFbUA86Tw 7QkgzQL9ZNdqAAEiekpaxHfuW2uaJiTv1V3tCYdIAl9sMgFPT/X37m/ogCdqExzNuS1hUvE8nW6 CfSl0thKkWx0cxv2IfhbD6MMATzs4gCMaf8TDNSHv4dqLUK9PelRCMMeZasbxDpSujxUN9Y5vpm XZ7NO7V4tkmscOZfLIQ== X-Proofpoint-GUID: aGia30f4RZjsG6SKkTo1fpAfYo4MaRiJ X-Proofpoint-ORIG-GUID: aGia30f4RZjsG6SKkTo1fpAfYo4MaRiJ X-Authority-Analysis: v=2.4 cv=aexsXBot c=1 sm=1 tr=0 ts=69661b9a cx=c_pps a=AKOq//PuzOIrVTIF9yBwbA==:117 a=AKOq//PuzOIrVTIF9yBwbA==:17 a=jNdnsKvOq7QA:10 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=r_1tXGB3AAAA:8 a=F4SZs_XWik5TpCwB3EkA:9 a=QEXdDO2ut3YA:10 a=t8nPyN_e6usw4ciXM-Pk:22 We have a module parameter to set the initial group mask before debugfs is available for any specific device, but don't currently use that value when initialising devices. Use the module parameter value as the initial value for group_mask. Signed-off-by: Matt Coster Reviewed-by: Alessio Belle --- drivers/gpu/drm/imagination/pvr_fw_trace.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/imagination/pvr_fw_trace.c b/drivers/gpu/drm/i= magination/pvr_fw_trace.c index a2aa588cbe5fa..93119f0f23a92 100644 --- a/drivers/gpu/drm/imagination/pvr_fw_trace.c +++ b/drivers/gpu/drm/imagination/pvr_fw_trace.c @@ -130,8 +130,13 @@ int pvr_fw_trace_init(struct pvr_device *pvr_dev) } } =20 - /* TODO: Provide control of group mask. */ - fw_trace->group_mask =3D 0; + /* + * Load the initial group_mask from the init_fw_trace_mask module + * parameter. This allows early tracing before the user can write to + * debugfs. Unlike update_logtype(), we don't set log_type here as that + * is initialised by tracebuf_ctrl_init(). + */ + fw_trace->group_mask =3D pvr_fw_trace_init_mask; =20 fw_trace->tracebuf_ctrl =3D pvr_fw_object_create_and_map(pvr_dev, --=20 2.52.0 From nobody Sun Feb 8 04:23:21 2026 Received: from mx07-00376f01.pphosted.com (mx07-00376f01.pphosted.com [185.132.180.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C36438A9C2 for ; Tue, 13 Jan 2026 10:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.132.180.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299446; cv=none; b=KhxUNCmQ/v0FmPHWHgrcNEBDAO6EKl/AVmVSs6mQpfPlYvqyZORmUVoudSuVG7utE3cvvNNBnxoFnZ0sOCNNZT4KzJ3XVjuqkl0DdJmPPJvqVdnlrKWLRW9NauwsdMRp9xIrGfogOVx/y0YKtGh0I2IPA5LQUc9YFes2sHU8FAc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299446; c=relaxed/simple; bh=QaYdkwqzhfz6F415XvNobyn5CdpW5o8qGTOpWNts8MI=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=Xpl9aj0CCkqcy4sNTbr/7XxB7WsFH9K7lWeeb2H55DS5SbjSwB9ID/v+gkAwi/ac3Gk+uZM0GJkzXxZeVAELi6McYNjq7L7vIy3AygUXFyWS3BY6gFJhWHEAma0GpD82jPXXyUlER98jYfe7cIMW+dwJxyhEWquB4gInVFfTvME= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=imgtec.com; spf=pass smtp.mailfrom=imgtec.com; dkim=pass (2048-bit key) header.d=imgtec.com header.i=@imgtec.com header.b=Y1MajCw0; arc=none smtp.client-ip=185.132.180.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=imgtec.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=imgtec.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=imgtec.com header.i=@imgtec.com header.b="Y1MajCw0" Received: from pps.filterd (m0168889.ppops.net [127.0.0.1]) by mx07-00376f01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60D6s9BD3231942; Tue, 13 Jan 2026 10:16:59 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imgtec.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=dk201812; bh=y 7KbZH7pJe4OUK8l8BTzMgqTxGTSurHYwOj4kGCSNcY=; b=Y1MajCw0ympEARzwL sOhbjrbTPb5HSX36VVoCzZXWPBDXPRZ64QhMPWSv/7NhMQxM97cC9OC1SN1m8mWw 9fbgfv7YdIdtspGc/S47SPcoU3jUcTgWR/T0/btNPdWJXWqilgGFDdl0SeS4bFC8 Bh/nrZw2uJRRM+nytGZY9OUomWhYL4pzu8+d0/cQzEzYrWfA58gjdLuXaq78ihQ6 etZ0KQwDwn4e4RrOPfZhXX8qjFbc0Hk6Tgb7jI33qR/yXY9t+fveJptv2G1b/2ni bEh9umTRitCmkzKqn399MEZ8Rh2Y424BUU2hmhriiJIeESBaU5hb87F13vnYUk8O 4m93A== Received: from hhmail01.hh.imgtec.org (83-244-153-141.cust-83.exponential-e.net [83.244.153.141]) by mx07-00376f01.pphosted.com (PPS) with ESMTPS id 4bkfqua1rv-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jan 2026 10:16:59 +0000 (GMT) Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa (172.25.4.58) by HHMAIL01.hh.imgtec.org (10.100.10.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Tue, 13 Jan 2026 10:16:58 +0000 From: Matt Coster Date: Tue, 13 Jan 2026 10:16:42 +0000 Subject: [PATCH 4/6] drm/imagination: Add gpuid module parameter Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260113-device-support-info-v1-4-91e5db7f7294@imgtec.com> References: <20260113-device-support-info-v1-0-91e5db7f7294@imgtec.com> In-Reply-To: <20260113-device-support-info-v1-0-91e5db7f7294@imgtec.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter CC: Frank Binns , Brajesh Gupta , Alessio Belle , Alexandru Dadu , Matt Coster , , X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=6114; i=matt.coster@imgtec.com; h=from:subject:message-id; bh=+y/dBA+BeRbuqFYzY1p34KWE4SaglYANlS150uP+4/A=; b=owGbwMvMwCFWuUfy8817WRsYT6slMWSmSU+bL2wptvDc0lsmMXx7/a+8W8Nqlbl1n6fO4cpXB y/PWn5bsqOUhUGMg0FWTJFlxwrLFWp/1LQkbvwqhpnDygQyhIGLUwAmkijByDBR7XRMeu007uoF xhfOGUUfu/7bLtzvDtOF9g/bBE385M4yMmxeEvjhSNTNu4dWFc7/nRTQJhqsESPxcN2ciMQvv/Z zP2IEAA== X-Developer-Key: i=matt.coster@imgtec.com; a=openpgp; fpr=05A40CFCE7269D61D97100A1747F0A9036F90DFA X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTEzMDA4NiBTYWx0ZWRfXy/Bt3WDvRCSa LTZzt25+ldDnAjhMBi/HAgBvLY9Ixy9tG54UVD0RcnoaDvp6FP6bk/bAZZQV+DD4q+o6tsYVL2U aW94uOJKPwXdy/0C4WEjTN9pB1aTBD4LAmEfUrhTvuEeX664AYvRXBXubHX/hkcNWgdsqTRgNpk VNMvvyRqlyOH6tdznWwpzoENt9mycR5XDQz5La/mbaB2frCJvWNsSSMQ4614W1t95ZgAy9eL3xJ iGv8DgjhO0sXT9rhtf+LJNHU2jB60ABcwh5aFNTA2K6VCX0fUAL7l3Qxcjd17HudsFp2tQnTVg/ NyLJB3O4xGmc2ZeuMXUmGX2PuFPhNwKCwFLz513lrk3pkXhNVayOP9NpM1kzVs4S7GHcQiw7aT7 spws2E1WvsIR+/prm8u+AUSfJIfaNk4GPG9l8owO+cu4B7UnGWK07murhhRLzw7SPtJ1CtPmESS PsLSKIm61IpuMOYONHQ== X-Proofpoint-GUID: VHxVPakON5Yq925irH0h015hDOFaYbws X-Proofpoint-ORIG-GUID: VHxVPakON5Yq925irH0h015hDOFaYbws X-Authority-Analysis: v=2.4 cv=aexsXBot c=1 sm=1 tr=0 ts=69661b9b cx=c_pps a=AKOq//PuzOIrVTIF9yBwbA==:117 a=AKOq//PuzOIrVTIF9yBwbA==:17 a=jNdnsKvOq7QA:10 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=r_1tXGB3AAAA:8 a=4Q53omCfAPGnJu_YSsAA:9 a=QEXdDO2ut3YA:10 a=t8nPyN_e6usw4ciXM-Pk:22 From: Alexandru Dadu The "gpuid" module parameter is used to override the gpuid read from a hardware register and is useful for testing the loading of different firmware (including processing of the firmware header) without having the hardware to hand. Signed-off-by: Alexandru Dadu Signed-off-by: Matt Coster Reviewed-by: Alessio Belle --- drivers/gpu/drm/imagination/pvr_device.c | 117 +++++++++++++++++++++++++++= +--- drivers/gpu/drm/imagination/pvr_device.h | 7 +- 2 files changed, 114 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/imagination/pvr_device.c b/drivers/gpu/drm/ima= gination/pvr_device.c index abe8ad1d447ac..db844e4e2e945 100644 --- a/drivers/gpu/drm/imagination/pvr_device.c +++ b/drivers/gpu/drm/imagination/pvr_device.c @@ -421,23 +421,21 @@ pvr_request_firmware(struct pvr_device *pvr_dev) } =20 /** - * pvr_load_gpu_id() - Load a PowerVR device's GPU ID (BVNC) from control = registers. + * pvr_gpuid_decode_reg() - Decode the GPU ID from GPU register * - * Sets struct pvr_dev.gpu_id. + * Sets the b, v, n, c fields of struct pvr_dev.gpu_id. * * @pvr_dev: Target PowerVR device. + * @gpu_id: Output to be updated with the GPU ID. */ static void -pvr_load_gpu_id(struct pvr_device *pvr_dev) +pvr_gpuid_decode_reg(const struct pvr_device *pvr_dev, struct pvr_gpu_id *= gpu_id) { - struct pvr_gpu_id *gpu_id =3D &pvr_dev->gpu_id; - u64 bvnc; - /* * Try reading the BVNC using the newer (cleaner) method first. If the * B value is zero, fall back to the older method. */ - bvnc =3D pvr_cr_read64(pvr_dev, ROGUE_CR_CORE_ID__PBVNC); + u64 bvnc =3D pvr_cr_read64(pvr_dev, ROGUE_CR_CORE_ID__PBVNC); =20 gpu_id->b =3D PVR_CR_FIELD_GET(bvnc, CORE_ID__PBVNC__BRANCH_ID); if (gpu_id->b !=3D 0) { @@ -456,6 +454,107 @@ pvr_load_gpu_id(struct pvr_device *pvr_dev) } } =20 +/** + * pvr_gpuid_decode_string() - Decode the GPU ID from a module input string + * + * Sets the b, v, n, c fields of struct pvr_dev.gpu_id. + * + * @pvr_dev: Target PowerVR device. + * @param_bvnc: GPU ID (BVNC) module parameter. + * @gpu_id: Output to be updated with the GPU ID. + */ +static int +pvr_gpuid_decode_string(const struct pvr_device *pvr_dev, + const char *param_bvnc, struct pvr_gpu_id *gpu_id) +{ + const struct drm_device *drm_dev =3D &pvr_dev->base; + char str_cpy[PVR_GPUID_STRING_MAX_LENGTH]; + char *pos, *tkn; + int ret, idx =3D 0; + u16 user_bvnc_u16[4]; + u8 dot_cnt =3D 0; + + ret =3D strscpy(str_cpy, param_bvnc); + + /* + * strscpy() should return at least a size 7 for the input to be valid. + * Returns -E2BIG for the case when the string is empty or too long. + */ + if (ret < PVR_GPUID_STRING_MIN_LENGTH) { + drm_info(drm_dev, + "Invalid size of the input GPU ID (BVNC): %s", + str_cpy); + return -EINVAL; + } + + while (*param_bvnc) { + if (*param_bvnc =3D=3D '.') + dot_cnt++; + param_bvnc++; + } + + if (dot_cnt !=3D 3) { + drm_info(drm_dev, + "Invalid format of the input GPU ID (BVNC): %s", + str_cpy); + return -EINVAL; + } + + pos =3D str_cpy; + + while ((tkn =3D strsep(&pos, ".")) !=3D NULL && idx < 4) { + /* kstrtou16() will also handle the case of consecutive dots */ + ret =3D kstrtou16(tkn, 10, &user_bvnc_u16[idx]); + if (ret) { + drm_info(drm_dev, + "Invalid format of the input GPU ID (BVNC): %s", + str_cpy); + return -EINVAL; + } + idx++; + } + + gpu_id->b =3D user_bvnc_u16[0]; + gpu_id->v =3D user_bvnc_u16[1]; + gpu_id->n =3D user_bvnc_u16[2]; + gpu_id->c =3D user_bvnc_u16[3]; + + return 0; +} + +static char *pvr_gpuid_override; +module_param_named(gpuid, pvr_gpuid_override, charp, 0400); +MODULE_PARM_DESC(gpuid, "GPU ID (BVNC) to be used instead of the value rea= d from hardware."); + +/** + * pvr_load_gpu_id() - Load a PowerVR device's GPU ID (BVNC) from control + * registers or input parameter. The input parameter is processed instead + * of the GPU register if provided. + * + * Sets the arch field of struct pvr_dev.gpu_id. + * + * @pvr_dev: Target PowerVR device. + */ +static int +pvr_load_gpu_id(struct pvr_device *pvr_dev) +{ + struct pvr_gpu_id *gpu_id =3D &pvr_dev->gpu_id; + + if (!pvr_gpuid_override || !pvr_gpuid_override[0]) { + pvr_gpuid_decode_reg(pvr_dev, gpu_id); + } else { + drm_warn(from_pvr_device(pvr_dev), + "Using custom GPU ID (BVNC) provided by the user!"); + + int err =3D pvr_gpuid_decode_string(pvr_dev, pvr_gpuid_override, + gpu_id); + if (err) + return err; + } + + return 0; +} + /** * pvr_set_dma_info() - Set PowerVR device DMA information * @pvr_dev: Target PowerVR device. @@ -516,7 +615,9 @@ pvr_device_gpu_init(struct pvr_device *pvr_dev) { int err; =20 - pvr_load_gpu_id(pvr_dev); + err =3D pvr_load_gpu_id(pvr_dev); + if (err) + return err; =20 err =3D pvr_request_firmware(pvr_dev); if (err) diff --git a/drivers/gpu/drm/imagination/pvr_device.h b/drivers/gpu/drm/ima= gination/pvr_device.h index d0e61923fd9b4..5608a977f6d21 100644 --- a/drivers/gpu/drm/imagination/pvr_device.h +++ b/drivers/gpu/drm/imagination/pvr_device.h @@ -39,6 +39,9 @@ struct firmware; /* Forward declaration from */ struct pwrseq_desc; =20 +#define PVR_GPUID_STRING_MIN_LENGTH 7U +#define PVR_GPUID_STRING_MAX_LENGTH 32U + /** * struct pvr_gpu_id - Hardware GPU ID information for a PowerVR device * @b: Branch ID. @@ -558,7 +561,7 @@ pvr_device_has_feature(struct pvr_device *pvr_dev, u32 = feature); * Return: The value of the requested register. */ static __always_inline u32 -pvr_cr_read32(struct pvr_device *pvr_dev, u32 reg) +pvr_cr_read32(const struct pvr_device *pvr_dev, u32 reg) { return ioread32(pvr_dev->regs + reg); } @@ -571,7 +574,7 @@ pvr_cr_read32(struct pvr_device *pvr_dev, u32 reg) * Return: The value of the requested register. */ static __always_inline u64 -pvr_cr_read64(struct pvr_device *pvr_dev, u32 reg) +pvr_cr_read64(const struct pvr_device *pvr_dev, u32 reg) { return ioread64(pvr_dev->regs + reg); } --=20 2.52.0 From nobody Sun Feb 8 04:23:21 2026 Received: from mx07-00376f01.pphosted.com (mx07-00376f01.pphosted.com [185.132.180.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3C25538A71B for ; Tue, 13 Jan 2026 10:17:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.132.180.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299445; cv=none; b=HSjSrjRQTg3umrpX0Lo5TruNtZjH0gBbJRYVPnU7tLMTaJnOAMCS54OPTNanmoTJnB+Bv1z2vjwOeUAyj2ZuK8iGrzhXlwddKB18aa5dBfs0j7DA+rmRTi1FNUW4gwsNWJOIfmJLuUGX7MGNzWB05fm18PwvJmloxH/SLUuZZuA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299445; c=relaxed/simple; bh=FWlMta4Uljf7/nzzWPEVlYNk15Xf+Jqsvc2mUkSuWRo=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=j60o70HpB6qYrAbAQ4mnknVBJnCvlL3/ODsKPY2zq1iZkr1zi3XHYAWLdnsy8Hh3qf03quzsDwAihpxBk3nc9x6RUkUOA6j8mRfUgXdalwp8icde+TyMuZXlcTNmrR9GaVd2JBrxL45fvv115g1QhLlkYV/jYSRZIUpvazE7fak= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=imgtec.com; spf=pass smtp.mailfrom=imgtec.com; dkim=pass (2048-bit key) header.d=imgtec.com header.i=@imgtec.com header.b=UEAk+cyY; arc=none smtp.client-ip=185.132.180.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=imgtec.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=imgtec.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=imgtec.com header.i=@imgtec.com header.b="UEAk+cyY" Received: from pps.filterd (m0168889.ppops.net [127.0.0.1]) by mx07-00376f01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60D5mmMg3116559; Tue, 13 Jan 2026 10:17:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imgtec.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=dk201812; bh=W uJORSLGkBNgb2whSilesJ8ZVajo6Inym/LHHlLH+sc=; b=UEAk+cyY0tgOz8mdF bi98BM2L6p3K66r+Ezf6AoNIxg/XNWrL7EBv+rup7rj6w1D81/yhId908ODt8Awt NV/7p1wstulWmXc7vrmjUv9/FLenCje4hhGaOtdNy88XDG0cbTUo8RZuYw0BkKHY cTer67ENR+DsemUfR/Idvt3f10eTSWijbq/f8dzYtqQ2pLy9ERxzrQ0J2NNntpGu KiS3wUMECk7mZtgE0DZ1zUzJ+tfKPFpv+EjKzFv0cM4LnklAVjXOghZAMckZ1Yp1 FzBc2D/xUH8rLovhkpOZrW/DA4ftlTwBInUPMSO3EPGdJv0gFWrQSmhqRiXKZ+ro GGmjg== Received: from hhmail01.hh.imgtec.org (83-244-153-141.cust-83.exponential-e.net [83.244.153.141]) by mx07-00376f01.pphosted.com (PPS) with ESMTPS id 4bkfqua1rw-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jan 2026 10:16:59 +0000 (GMT) Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa (172.25.4.58) by HHMAIL01.hh.imgtec.org (10.100.10.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Tue, 13 Jan 2026 10:16:58 +0000 From: Matt Coster Date: Tue, 13 Jan 2026 10:16:43 +0000 Subject: [PATCH 5/6] drm/imagination: KUnit test for pvr_gpuid_decode_string() Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260113-device-support-info-v1-5-91e5db7f7294@imgtec.com> References: <20260113-device-support-info-v1-0-91e5db7f7294@imgtec.com> In-Reply-To: <20260113-device-support-info-v1-0-91e5db7f7294@imgtec.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter CC: Frank Binns , Brajesh Gupta , Alessio Belle , Alexandru Dadu , Matt Coster , , X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=6169; i=matt.coster@imgtec.com; h=from:subject:message-id; bh=FWlMta4Uljf7/nzzWPEVlYNk15Xf+Jqsvc2mUkSuWRo=; b=owGbwMvMwCFWuUfy8817WRsYT6slMWSmSU9z/LKoJnZaYaKf78a1x3gdGWaXnJjME/nmc2iGR pPCtcqDHaUsDGIcDLJiiiw7VliuUPujpiVx41cxzBxWJpAhDFycAjARwQUM//S/b+RnZtyi3Rwn f/qxxGHmunk28TkXL/S1vVQW+rM0TZDhf/qDib8c+rsF9I9I2eouuiww3aNk687SGN6OxTOM96z 8xwcA X-Developer-Key: i=matt.coster@imgtec.com; a=openpgp; fpr=05A40CFCE7269D61D97100A1747F0A9036F90DFA X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTEzMDA4NiBTYWx0ZWRfX3+tXUe+CHD/R s9jBEuSd76lG6duszm9+4zIMnVeAxPH9UNzyP1aBVoyOzBKvxxzZbTx8lEdW2EoBPPHVyhLmIw/ XkjFFzrFEbyMtJWeic3N2/TZEbK3AwsW2+YeVZL5zyJ9gLEHgEUHpmOQq2q6W8ZFV9R0Hi4Thm7 u8PcxMTaYG4E1iCWluOPP7xnm/HLmE5Tdo4fb0V6a3/0N9m6e6jT/jK37M9I+APqAD/ALaAbO7+ 4e5d91w24xuySexf1jurVUZf7hH8IOQ660KwtEGfELmBQGWNwxlGyyjrc93rXgkVYoZhMFjZ2Rn CuJGlPzF6TvQWahHQilukxyeRE9zOHW10zEKtbKTw/JfsE28WFmkjMZDrf9cS1ConYV/HAMjorY hisfD9k9iL6dvIxd83/r+Z9ZFq88XzLyo3fFtaHg4EdwynivJ+98KERQvp8vxYy1cMV0wp/uG8l fh3ckeaK/IoT/DayTwQ== X-Proofpoint-GUID: BFaEvU7O3YWiKCPvmdVTGKvMN2a13G21 X-Proofpoint-ORIG-GUID: BFaEvU7O3YWiKCPvmdVTGKvMN2a13G21 X-Authority-Analysis: v=2.4 cv=aexsXBot c=1 sm=1 tr=0 ts=69661b9b cx=c_pps a=AKOq//PuzOIrVTIF9yBwbA==:117 a=AKOq//PuzOIrVTIF9yBwbA==:17 a=jNdnsKvOq7QA:10 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=r_1tXGB3AAAA:8 a=l8_E3HPGGmWK6_1WluoA:9 a=QEXdDO2ut3YA:10 a=t8nPyN_e6usw4ciXM-Pk:22 This is a nice self-contained function to serve as the basis of our first KUnit tests. Signed-off-by: Matt Coster Reviewed-by: Alessio Belle --- drivers/gpu/drm/imagination/Kconfig | 12 ++++++ drivers/gpu/drm/imagination/Makefile | 2 + drivers/gpu/drm/imagination/pvr_device.c | 5 ++- drivers/gpu/drm/imagination/pvr_device.h | 7 ++- drivers/gpu/drm/imagination/pvr_test.c | 73 ++++++++++++++++++++++++++++= ++++ 5 files changed, 97 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/drm/imagination/Kconfig b/drivers/gpu/drm/imaginat= ion/Kconfig index 0482bfcefdde3..1fd4c635c2c96 100644 --- a/drivers/gpu/drm/imagination/Kconfig +++ b/drivers/gpu/drm/imagination/Kconfig @@ -18,3 +18,15 @@ config DRM_POWERVR Technologies PowerVR (Series 6 or later) or IMG GPU. =20 If "M" is selected, the module will be called powervr. + +config DRM_POWERVR_KUNIT_TEST + tristate "KUnit tests for the drm powervr driver" if !KUNIT_ALL_TESTS + depends on DRM_POWERVR && KUNIT + default KUNIT_ALL_TESTS + help + Choose this option to allow the driver to perform selftests under + the kunit framework + + Recommended for driver developers only. + + If in doubt, say "N". diff --git a/drivers/gpu/drm/imagination/Makefile b/drivers/gpu/drm/imagina= tion/Makefile index ab63eac9ba7f7..f5072f06b4c41 100644 --- a/drivers/gpu/drm/imagination/Makefile +++ b/drivers/gpu/drm/imagination/Makefile @@ -32,3 +32,5 @@ powervr-$(CONFIG_DEBUG_FS) +=3D \ pvr_debugfs.o =20 obj-$(CONFIG_DRM_POWERVR) +=3D powervr.o + +obj-$(CONFIG_DRM_POWERVR_KUNIT_TEST) +=3D pvr_test.o diff --git a/drivers/gpu/drm/imagination/pvr_device.c b/drivers/gpu/drm/ima= gination/pvr_device.c index db844e4e2e945..d87557812409a 100644 --- a/drivers/gpu/drm/imagination/pvr_device.c +++ b/drivers/gpu/drm/imagination/pvr_device.c @@ -31,6 +31,8 @@ #include #include =20 +#include + /* Major number for the supported version of the firmware. */ #define PVR_FW_VERSION_MAJOR 1 =20 @@ -463,7 +465,7 @@ pvr_gpuid_decode_reg(const struct pvr_device *pvr_dev, = struct pvr_gpu_id *gpu_id * @param_bvnc: GPU ID (BVNC) module parameter. * @gpu_id: Output to be updated with the GPU ID. */ -static int +VISIBLE_IF_KUNIT int pvr_gpuid_decode_string(const struct pvr_device *pvr_dev, const char *param_bvnc, struct pvr_gpu_id *gpu_id) { @@ -521,6 +523,7 @@ pvr_gpuid_decode_string(const struct pvr_device *pvr_de= v, =20 return 0; } +EXPORT_SYMBOL_IF_KUNIT(pvr_gpuid_decode_string); =20 static char *pvr_gpuid_override; module_param_named(gpuid, pvr_gpuid_override, charp, 0400); diff --git a/drivers/gpu/drm/imagination/pvr_device.h b/drivers/gpu/drm/ima= gination/pvr_device.h index 5608a977f6d21..cfda215e7428e 100644 --- a/drivers/gpu/drm/imagination/pvr_device.h +++ b/drivers/gpu/drm/imagination/pvr_device.h @@ -519,7 +519,7 @@ struct pvr_file { * Return: Packed BVNC. */ static __always_inline u64 -pvr_gpu_id_to_packed_bvnc(struct pvr_gpu_id *gpu_id) +pvr_gpu_id_to_packed_bvnc(const struct pvr_gpu_id *gpu_id) { return PVR_PACKED_BVNC(gpu_id->b, gpu_id->v, gpu_id->n, gpu_id->c); } @@ -544,6 +544,11 @@ pvr_device_has_uapi_enhancement(struct pvr_device *pvr= _dev, u32 enhancement); bool pvr_device_has_feature(struct pvr_device *pvr_dev, u32 feature); =20 +#if IS_ENABLED(CONFIG_KUNIT) +int pvr_gpuid_decode_string(const struct pvr_device *pvr_dev, + const char *param_bvnc, struct pvr_gpu_id *gpu_id); +#endif + /** * PVR_CR_FIELD_GET() - Extract a single field from a PowerVR control regi= ster * @val: Value of the target register. diff --git a/drivers/gpu/drm/imagination/pvr_test.c b/drivers/gpu/drm/imagi= nation/pvr_test.c new file mode 100644 index 0000000000000..506cfa5a02f1e --- /dev/null +++ b/drivers/gpu/drm/imagination/pvr_test.c @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* Copyright (c) 2025 Imagination Technologies Ltd. */ + +#include "pvr_device.h" + +#include +#include +#include +#include + +#include +#include + +static void decode_gpuid_string(struct kunit *test) +{ + const struct pvr_gpu_id bad_gpuid =3D { 0xdead, 0xbeef, 0xcafe, 0xface }; + const u64 packed_bad_gpuid =3D pvr_gpu_id_to_packed_bvnc(&bad_gpuid); + +#define GPUID_TEST_CASE(str_, err_, value_) \ + do { \ + struct pvr_gpu_id _gpuid_out =3D bad_gpuid; \ + int _err; \ + _err =3D pvr_gpuid_decode_string(NULL, str_, &_gpuid_out); \ + KUNIT_EXPECT_EQ(test, _err, err_); \ + KUNIT_EXPECT_EQ(test, \ + pvr_gpu_id_to_packed_bvnc(&_gpuid_out), \ + value_); \ + } while (0) + +#define GPUID_TEST_CASE_OK(str_, b_, v_, n_, c_) \ + GPUID_TEST_CASE(str_, 0, PVR_PACKED_BVNC(b_, v_, n_, c_)) + +#define GPUID_TEST_CASE_INVAL(str_) \ + GPUID_TEST_CASE(str_, -EINVAL, packed_bad_gpuid) + + GPUID_TEST_CASE_OK("12.34.56.78", 12, 34, 56, 78); + GPUID_TEST_CASE_OK("0.0.0.0", 0, 0, 0, 0); + + GPUID_TEST_CASE_INVAL(""); + GPUID_TEST_CASE_INVAL("42.foobar-invalid.gpuid.bvnc"); + + /* String longer than PVR_GPUID_STRING_MAX_LENGTH. */ + GPUID_TEST_CASE_INVAL("12.34.56.789012345678901234567890123456"); + + /* Single value overflowing u16. */ + GPUID_TEST_CASE_INVAL("12.34.56.999999"); + + /* Wrong number of parts and/or dots. */ + GPUID_TEST_CASE_INVAL("12.34.56.78.90"); + GPUID_TEST_CASE_INVAL("12.34.56..78"); + GPUID_TEST_CASE_INVAL("12.34..56"); + GPUID_TEST_CASE_INVAL("12.34.56"); + +#undef GPUID_TEST_CASE_INVAL +#undef GPUID_TEST_CASE_OK +#undef GPUID_TEST_CASE +} + +static struct kunit_case pvr_tests_cases[] =3D { + KUNIT_CASE(decode_gpuid_string), + {}, +}; + +static struct kunit_suite pvr_tests_suite =3D { + .name =3D "pvr_tests", + .test_cases =3D pvr_tests_cases, +}; +kunit_test_suite(pvr_tests_suite); + +MODULE_AUTHOR("Imagination Technologies Ltd."); +MODULE_LICENSE("Dual MIT/GPL"); +MODULE_DESCRIPTION("pvr kunit tests"); +MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); --=20 2.52.0 From nobody Sun Feb 8 04:23:21 2026 Received: from mx07-00376f01.pphosted.com (mx07-00376f01.pphosted.com [185.132.180.163]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8E07938B7BF for ; Tue, 13 Jan 2026 10:17:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.132.180.163 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299446; cv=none; b=Qj9cnaLFtOFcwS6/ArgxtLHWhqmmUidrW/hEhVmYQhtRwNhq5tjQypThUu7SRP3GHSvDBOi2/NsjPasqnIjXbFM3mYO/0gBT1c4ZwgHxEwK4nGkAkK1Byqm+vP+Z/k7skr1WF6rnkNPc7JMVdeLj/99LXmrmIMOyB+ciSKhDaRk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1768299446; c=relaxed/simple; bh=PS8KNaN5fO3P9PKVidE6vGWm9jrWqRjCwvhUPfKqjcE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-ID:References: In-Reply-To:To:CC; b=EU8tCx/6tQ6twLoRCzIqouXzHxgAIHZhNapXFkGGvgMDnIRy/8C7wG3kdK+lchudYvLDeLhyxZbQVoJ7DPYxrDrzj4Lfmubd9wVySZjr7xD2qzgvN1qaSBFaJ3SBTGzQz0b8hG3uQR6a5pBwyAVe4SB21s8Gl1aKrLgDIJtw2dE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=imgtec.com; spf=pass smtp.mailfrom=imgtec.com; dkim=pass (2048-bit key) header.d=imgtec.com header.i=@imgtec.com header.b=tEVWLStN; arc=none smtp.client-ip=185.132.180.163 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=imgtec.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=imgtec.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=imgtec.com header.i=@imgtec.com header.b="tEVWLStN" Received: from pps.filterd (m0168889.ppops.net [127.0.0.1]) by mx07-00376f01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60D5mmMh3116559; Tue, 13 Jan 2026 10:17:00 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=imgtec.com; h=cc :content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=dk201812; bh=X xdMkijMGY/BD48Tk2m2tmTv4RrhIGPyTTgSUykOlnY=; b=tEVWLStNgZlEQASP5 e1Anvp0GoBQWJ6AxcaiaW6ADoQpG5rJjuRr8Lo7gbEjnkKd9mcL20VqrZVttwu0U n4vXkqnqDufQVBfkaVUq0LUyZ5GARfhXlETi+4AdEh64n7gU/YhC9Tch/7yMrjL/ fOEG7jVSuwsFuzBpXIy5NQm+cYieQOm5KHDIWA4WoUV9CWOMpBIUruJhkdYgFQrC 5ah60CUjK7SpbKS2GrOqTxSa9/jgSAXiN9/spMCV4+kAs5PN6p+vRNFGoZmdSOty bFbli+KAL5FT0XZDS07nIE0V2TZkIWajKoV0Y9HufcF8sbYNAD6qEfK36qaXzNcK AdzAA== Received: from hhmail01.hh.imgtec.org (83-244-153-141.cust-83.exponential-e.net [83.244.153.141]) by mx07-00376f01.pphosted.com (PPS) with ESMTPS id 4bkfqua1ry-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 13 Jan 2026 10:17:00 +0000 (GMT) Received: from 1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.ip6.arpa (172.25.4.58) by HHMAIL01.hh.imgtec.org (10.100.10.19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.29; Tue, 13 Jan 2026 10:16:59 +0000 From: Matt Coster Date: Tue, 13 Jan 2026 10:16:44 +0000 Subject: [PATCH 6/6] drm/imagination: Warn or error on unsupported hardware Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-ID: <20260113-device-support-info-v1-6-91e5db7f7294@imgtec.com> References: <20260113-device-support-info-v1-0-91e5db7f7294@imgtec.com> In-Reply-To: <20260113-device-support-info-v1-0-91e5db7f7294@imgtec.com> To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter CC: Frank Binns , Brajesh Gupta , Alessio Belle , Alexandru Dadu , Matt Coster , , X-Mailer: b4 0.14.3 X-Developer-Signature: v=1; a=openpgp-sha256; l=3212; i=matt.coster@imgtec.com; h=from:subject:message-id; bh=PS8KNaN5fO3P9PKVidE6vGWm9jrWqRjCwvhUPfKqjcE=; b=owGbwMvMwCFWuUfy8817WRsYT6slMWSmSU/z7Rc7dHdJgU5Tkeec16EytZccGSc/UqhhL+lsN zOZsndnRykLgxgHg6yYIsuOFZYr1P6oaUnc+FUMM4eVCWQIAxenAEzkZAojwx3bCZmfDdnyF0fN Pukl7qKpw/TjZo7sHL3F0ZPb/zlEzGNk2PyRze9Q4pkHUnd48mqO5dqe1yx9yn5l4Y4iz/VZLNM PsQIA X-Developer-Key: i=matt.coster@imgtec.com; a=openpgp; fpr=05A40CFCE7269D61D97100A1747F0A9036F90DFA X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTEzMDA4NiBTYWx0ZWRfX271D35w3Rgzh fijf9fKohZCvvSCorXGyG9L6AIAlq2SI//RM7IQnwy5U9vg0MALAeVTOgA0jWRkE5to3jkWajhk wtJS0T/XLM01ATCvblQn+/K4gHYm0YBVlhkEhRtOwWwcjd91gLxlPKTniJwrkH+1ZN1O05z2ZKW oblOVYtDkvdvjQdLIXzK6k1r41VvwukcvZio1azPLikuKAWzHkwQpViWQlw2Ec2V6Ih5xodPRDT ZIfGlnM68uWgrZoXcWEnzsWozjXvo+S9jx1GURpUmaqEdUCrRpm3ikvnj1k4EY2FVHNQmKF47bn y8GO70XcgDxzOe6VIHeaiYjJsK0mIBFiA+Sp3/lRvaWvRdLxkb47ZzOuRP4+VZhTktxQiSftjQa SQIRxQ9cuYCKBW9qUnKqg1Xt1KpDFYIE1EuP7JjDfnqmq9v3fsP8A2GEAJFnr1LQ+fWKE9Znnnn IIYqaugw+YKacV4kAFw== X-Proofpoint-GUID: F_hqvqp_PY0Wj41-qjEtvftlcxAdr__I X-Proofpoint-ORIG-GUID: F_hqvqp_PY0Wj41-qjEtvftlcxAdr__I X-Authority-Analysis: v=2.4 cv=aexsXBot c=1 sm=1 tr=0 ts=69661b9c cx=c_pps a=AKOq//PuzOIrVTIF9yBwbA==:117 a=AKOq//PuzOIrVTIF9yBwbA==:17 a=jNdnsKvOq7QA:10 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=VkNPw1HP01LnGYTKEx00:22 a=r_1tXGB3AAAA:8 a=p27HXWpvGPb40MpNPkkA:9 a=QEXdDO2ut3YA:10 a=t8nPyN_e6usw4ciXM-Pk:22 Gate the use of unsupported hardware behind a new module parameter (exp_hw_support). Signed-off-by: Matt Coster Reviewed-by: Alessio Belle --- drivers/gpu/drm/imagination/pvr_device.c | 73 ++++++++++++++++++++++++++++= +++- 1 file changed, 72 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/imagination/pvr_device.c b/drivers/gpu/drm/ima= gination/pvr_device.c index d87557812409a..f58bb66a63275 100644 --- a/drivers/gpu/drm/imagination/pvr_device.c +++ b/drivers/gpu/drm/imagination/pvr_device.c @@ -525,6 +525,77 @@ pvr_gpuid_decode_string(const struct pvr_device *pvr_d= ev, } EXPORT_SYMBOL_IF_KUNIT(pvr_gpuid_decode_string); =20 +static bool pvr_exp_hw_support; +module_param_named(exp_hw_support, pvr_exp_hw_support, bool, 0600); +MODULE_PARM_DESC(exp_hw_support, "Bypass runtime checks for fully supporte= d GPU cores. WARNING: enabling this option may result in a buggy, insecure,= or otherwise unusable driver."); + +/** + * enum pvr_gpu_support_level - The level of support for a gpu_id in the c= urrent + * version of the driver. + * + * @PVR_GPU_UNKNOWN: Cores that are unknown to the driver. These may not e= ven exist. + * @PVR_GPU_EXPERIMENTAL: Cores that have experimental support. + * @PVR_GPU_SUPPORTED: Cores that are supported and maintained. + */ +enum pvr_gpu_support_level { + PVR_GPU_UNKNOWN, + PVR_GPU_EXPERIMENTAL, + PVR_GPU_SUPPORTED, +}; + +static enum pvr_gpu_support_level +pvr_gpu_support_level(const struct pvr_gpu_id *gpu_id) +{ + switch (pvr_gpu_id_to_packed_bvnc(gpu_id)) { + case PVR_PACKED_BVNC(33, 15, 11, 3): + case PVR_PACKED_BVNC(36, 53, 104, 796): + return PVR_GPU_SUPPORTED; + + case PVR_PACKED_BVNC(36, 52, 104, 182): + return PVR_GPU_EXPERIMENTAL; + + default: + return PVR_GPU_UNKNOWN; + } +} + +static int +pvr_check_gpu_supported(struct pvr_device *pvr_dev, + const struct pvr_gpu_id *gpu_id) +{ + struct drm_device *drm_dev =3D from_pvr_device(pvr_dev); + + switch (pvr_gpu_support_level(gpu_id)) { + case PVR_GPU_SUPPORTED: + if (pvr_exp_hw_support) + drm_info(drm_dev, "Module parameter 'exp_hw_support' was set, but this = hardware is fully supported by the current driver."); + + break; + + case PVR_GPU_EXPERIMENTAL: + if (!pvr_exp_hw_support) { + drm_err(drm_dev, "Unsupported GPU! Set 'exp_hw_support' to bypass this = check."); + return -ENODEV; + } + + drm_warn(drm_dev, "Running on unsupported hardware; you may encounter bu= gs!"); + break; + + /* NOTE: This code path may indicate misbehaving hardware. */ + case PVR_GPU_UNKNOWN: + default: + if (!pvr_exp_hw_support) { + drm_err(drm_dev, "Unknown GPU! Set 'exp_hw_support' to bypass this chec= k."); + return -ENODEV; + } + + drm_warn(drm_dev, "Running on unknown hardware; expect issues."); + break; + } + + return 0; +} + static char *pvr_gpuid_override; module_param_named(gpuid, pvr_gpuid_override, charp, 0400); MODULE_PARM_DESC(gpuid, "GPU ID (BVNC) to be used instead of the value rea= d from hardware."); @@ -555,7 +626,7 @@ pvr_load_gpu_id(struct pvr_device *pvr_dev) return err; } =20 - return 0; + return pvr_check_gpu_supported(pvr_dev, gpu_id); } =20 /** --=20 2.52.0