]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
drm/imagination: Improve handling of unknown FWCCB commands
authorMatt Coster <matt.coster@imgtec.com>
Fri, 6 Feb 2026 16:02:12 +0000 (16:02 +0000)
committerMatt Coster <matt.coster@imgtec.com>
Tue, 10 Feb 2026 10:01:10 +0000 (10:01 +0000)
A couple small changes:
 - Validate the magic value at the head of FWCCB commands, and
 - Mask off the magic value before logging unknown command types to make
   them easier to interpret on sight.

Reviewed-by: Frank Binns <frank.binns@imgtec.com>
Link: https://patch.msgid.link/20260206-improve-bad-fwccb-cmd-v1-1-831a852ca127@imgtec.com
Signed-off-by: Matt Coster <matt.coster@imgtec.com>
drivers/gpu/drm/imagination/pvr_ccb.c

index 9294b4ba1de7708db315a87b0df8070536f66d5c..2f4356a1e69f9031bd0de3557a46a7c53d43aa1e 100644 (file)
@@ -136,6 +136,14 @@ pvr_ccb_slot_available_locked(struct pvr_ccb *pvr_ccb, u32 *write_offset)
 static void
 process_fwccb_command(struct pvr_device *pvr_dev, struct rogue_fwif_fwccb_cmd *cmd)
 {
+       struct drm_device *drm_dev = from_pvr_device(pvr_dev);
+
+       if ((cmd->cmd_type & ROGUE_CMD_MAGIC_DWORD_MASK) != ROGUE_CMD_MAGIC_DWORD_SHIFTED) {
+               drm_warn_once(drm_dev, "Received FWCCB command with bad magic value; ignoring (type=0x%08x)\n",
+                             cmd->cmd_type);
+               return;
+       }
+
        switch (cmd->cmd_type) {
        case ROGUE_FWIF_FWCCB_CMD_REQUEST_GPU_RESTART:
                pvr_power_reset(pvr_dev, false);
@@ -151,8 +159,8 @@ process_fwccb_command(struct pvr_device *pvr_dev, struct rogue_fwif_fwccb_cmd *c
                break;
 
        default:
-               drm_info(from_pvr_device(pvr_dev), "Received unknown FWCCB command %x\n",
-                        cmd->cmd_type);
+               drm_info(drm_dev, "Received unknown FWCCB command (type=%d)\n",
+                        cmd->cmd_type & ~ROGUE_CMD_MAGIC_DWORD_MASK);
                break;
        }
 }