Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

nouveau/gsp: use rpc sequence numbers properly.

There are two layers of sequence numbers, one at the msg level
and one at the rpc level.

570 firmware started asserting on the sequence numbers being
in the right order, and we would see nocat records with asserts
in them.

Add the rpc level sequence number support.

Fixes: 53dac0623853 ("drm/nouveau/gsp: add support for 570.144")
Cc: <stable@vger.kernel.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Lyude Paul <lyude@redhat.com>
Tested-by: Lyude Paul <lyude@redhat.com>
Link: https://patch.msgid.link/20260203052431.2219998-2-airlied@gmail.com

+15 -3
+6
drivers/gpu/drm/nouveau/include/nvkm/subdev/gsp.h
··· 44 44 * NVKM_GSP_RPC_REPLY_NOWAIT - If specified, immediately return to the 45 45 * caller after the GSP RPC command is issued. 46 46 * 47 + * NVKM_GSP_RPC_REPLY_NOSEQ - If specified, exactly like NOWAIT 48 + * but don't emit RPC sequence number. 49 + * 47 50 * NVKM_GSP_RPC_REPLY_RECV - If specified, wait and receive the entire GSP 48 51 * RPC message after the GSP RPC command is issued. 49 52 * ··· 56 53 */ 57 54 enum nvkm_gsp_rpc_reply_policy { 58 55 NVKM_GSP_RPC_REPLY_NOWAIT = 0, 56 + NVKM_GSP_RPC_REPLY_NOSEQ, 59 57 NVKM_GSP_RPC_REPLY_RECV, 60 58 NVKM_GSP_RPC_REPLY_POLL, 61 59 }; ··· 245 241 246 242 /* The size of the registry RPC */ 247 243 size_t registry_rpc_size; 244 + 245 + u32 rpc_seq; 248 246 249 247 #ifdef CONFIG_DEBUG_FS 250 248 /*
+2 -2
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/gsp.c
··· 704 704 705 705 build_registry(gsp, rpc); 706 706 707 - return nvkm_gsp_rpc_wr(gsp, rpc, NVKM_GSP_RPC_REPLY_NOWAIT); 707 + return nvkm_gsp_rpc_wr(gsp, rpc, NVKM_GSP_RPC_REPLY_NOSEQ); 708 708 709 709 fail: 710 710 clean_registry(gsp); ··· 921 921 info->pciConfigMirrorSize = device->pci->func->cfg.size; 922 922 r535_gsp_acpi_info(gsp, &info->acpiMethodData); 923 923 924 - return nvkm_gsp_rpc_wr(gsp, info, NVKM_GSP_RPC_REPLY_NOWAIT); 924 + return nvkm_gsp_rpc_wr(gsp, info, NVKM_GSP_RPC_REPLY_NOSEQ); 925 925 } 926 926 927 927 static int
+6
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r535/rpc.c
··· 557 557 558 558 switch (policy) { 559 559 case NVKM_GSP_RPC_REPLY_NOWAIT: 560 + case NVKM_GSP_RPC_REPLY_NOSEQ: 560 561 break; 561 562 case NVKM_GSP_RPC_REPLY_RECV: 562 563 reply = r535_gsp_msg_recv(gsp, fn, gsp_rpc_len); ··· 588 587 print_hex_dump(KERN_INFO, "rpc: ", DUMP_PREFIX_OFFSET, 16, 1, 589 588 rpc->data, rpc->length - sizeof(*rpc), true); 590 589 } 590 + 591 + if (policy == NVKM_GSP_RPC_REPLY_NOSEQ) 592 + rpc->sequence = 0; 593 + else 594 + rpc->sequence = gsp->rpc_seq++; 591 595 592 596 ret = r535_gsp_cmdq_push(gsp, rpc); 593 597 if (ret)
+1 -1
drivers/gpu/drm/nouveau/nvkm/subdev/gsp/rm/r570/gsp.c
··· 176 176 info->bIsPrimary = video_is_primary_device(device->dev); 177 177 info->bPreserveVideoMemoryAllocations = false; 178 178 179 - return nvkm_gsp_rpc_wr(gsp, info, NVKM_GSP_RPC_REPLY_NOWAIT); 179 + return nvkm_gsp_rpc_wr(gsp, info, NVKM_GSP_RPC_REPLY_NOSEQ); 180 180 } 181 181 182 182 static void