Skip to content

Commit

Permalink
nvchannel: fix submit ioctl
Browse files Browse the repository at this point in the history
  • Loading branch information
averne authored and fincs committed Jan 25, 2025
1 parent a063ceb commit 218e3f3
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 13 deletions.
3 changes: 3 additions & 0 deletions nx/include/switch/nvidia/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
28 changes: 15 additions & 13 deletions nx/source/nvidia/ioctl/nvchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand All @@ -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;
Expand Down

0 comments on commit 218e3f3

Please sign in to comment.