From 218e3f3a040686a6288a38feec4587d189d6c785 Mon Sep 17 00:00:00 2001 From: averne Date: Sat, 25 Jan 2025 10:46:03 +0100 Subject: [PATCH] nvchannel: fix submit ioctl --- nx/include/switch/nvidia/ioctl.h | 3 +++ nx/source/nvidia/ioctl/nvchannel.c | 28 +++++++++++++++------------- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/nx/include/switch/nvidia/ioctl.h b/nx/include/switch/nvidia/ioctl.h index 5ff880a9c..7ad234edb 100644 --- a/nx/include/switch/nvidia/ioctl.h +++ b/nx/include/switch/nvidia/ioctl.h @@ -154,6 +154,9 @@ typedef struct { typedef struct { u32 syncpt_id; u32 syncpt_incrs; + u32 waitbase_id; // Always -1 + u32 next; //< Next valid incr index, or -1 + u32 prev; //< Previous valid incr index, or -1 } nvioctl_syncpt_incr; typedef struct { diff --git a/nx/source/nvidia/ioctl/nvchannel.c b/nx/source/nvidia/ioctl/nvchannel.c index 86578ae9a..e29358eb1 100644 --- a/nx/source/nvidia/ioctl/nvchannel.c +++ b/nx/source/nvidia/ioctl/nvchannel.c @@ -204,16 +204,15 @@ Result nvioctlChannel_Submit(u32 fd, const nvioctl_cmdbuf *cmdbufs, u32 num_cmdb return MAKERESULT(Module_Libnx, LibnxError_OutOfMemory); struct { - __nv_in u32 num_cmdbufs; - __nv_in u32 num_relocs; - __nv_in u32 num_syncpt_incrs; - __nv_in u32 num_fences; - __nv_in nvioctl_cmdbuf cmdbufs [num_cmdbufs]; - __nv_in nvioctl_reloc relocs [num_relocs]; - __nv_in nvioctl_reloc_shift reloc_shifts[num_relocs]; - __nv_in nvioctl_syncpt_incr syncpt_incrs[num_syncpt_incrs]; - __nv_in nvioctl_syncpt_incr wait_checks [num_syncpt_incrs]; - __nv_out nvioctl_fence fences [num_fences]; + __nv_in u32 num_cmdbufs; + __nv_in u32 num_relocs; + __nv_in u32 num_syncpt_incrs; + __nv_in u32 num_fences; + __nv_in nvioctl_cmdbuf cmdbufs [num_cmdbufs]; + __nv_in nvioctl_reloc relocs [num_relocs]; + __nv_in nvioctl_reloc_shift reloc_shifts[num_relocs]; + __nv_in nvioctl_syncpt_incr syncpt_incrs[num_syncpt_incrs]; + __nv_inout u32 thresholds [num_fences]; } data; memset(&data, 0, sizeof(data)); @@ -229,9 +228,12 @@ Result nvioctlChannel_Submit(u32 fd, const nvioctl_cmdbuf *cmdbufs, u32 num_cmdb Result rc = nvIoctl(fd, _NV_IOWR(0, 0x01, data), &data); if (R_SUCCEEDED(rc)) { - memcpy(fences, data.fences, num_fences * sizeof(nvioctl_fence)); - for (int i = 0; i < num_fences; ++i) - fences[i].id = data.syncpt_incrs[i].syncpt_id; + for (int i = 0; i < num_fences; ++i) { + fences[i] = (nvioctl_fence){ + .id = syncpt_incrs[i].syncpt_id, + .value = data.thresholds[i], + }; + } } return rc;