Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nvchannel: Fix SET_CLK_RATE, implement GET_CLK_RATE and SET_SUBMIT_TIMEOUT #637

Merged
merged 3 commits into from
Feb 3, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions nx/include/switch/nvidia/ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ typedef struct {
u32 iova;
} nvioctl_command_buffer_map;

typedef struct {
uint32_t rate;
uint32_t moduleid;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
uint32_t rate;
uint32_t moduleid;
u32 rate;
u32 moduleid;

} nvioctl_clk_rate;

#define NVGPU_ZBC_TYPE_INVALID 0
#define NVGPU_ZBC_TYPE_COLOR 1
#define NVGPU_ZBC_TYPE_DEPTH 2
Expand Down Expand Up @@ -284,5 +289,7 @@ Result nvioctlChannel_Submit(u32 fd, const nvioctl_cmdbuf *cmdbufs, u32 num_cmdb
const nvioctl_syncpt_incr *syncpt_incrs, u32 num_syncpt_incrs, nvioctl_fence *fences, u32 num_fences);
Result nvioctlChannel_GetSyncpt(u32 fd, u32 module_id, u32 *syncpt);
Result nvioctlChannel_GetModuleClockRate(u32 fd, u32 module_id, u32 *freq);
Result nvioctlChannel_SetModuleClockRate(u32 fd, u32 module_id, u32 freq);
Result nvioctlChannel_MapCommandBuffer(u32 fd, nvioctl_command_buffer_map *maps, u32 num_maps, bool compressed);
Result nvioctlChannel_UnmapCommandBuffer(u32 fd, const nvioctl_command_buffer_map *maps, u32 num_maps, bool compressed);
Result nvioctlChannel_SetSubmitTimeout(u32 fd, u32 timeout);
30 changes: 23 additions & 7 deletions nx/source/nvidia/ioctl/nvchannel.c
Original file line number Diff line number Diff line change
Expand Up @@ -254,22 +254,38 @@ Result nvioctlChannel_GetSyncpt(u32 fd, u32 id, u32 *syncpt) {
}

Result nvioctlChannel_GetModuleClockRate(u32 fd, u32 module_id, u32 *freq) {
struct {
__nv_out u32 rate;
__nv_in u32 module;
} data = {
.module = module_id,
nvioctl_clk_rate data = {
.moduleid = module_id,
};

u32 ioctl = _NV_IOWR(0, hosversionAtLeast(8,0,0) ? 0x14 : 0x23, data);
Result rc = nvIoctl(fd, ioctl, &data);
u32 nr = _NV_IOWR(0, hosversionBefore(8,0,0) ? 0x14 : 0x23, data);
Result rc = nvIoctl(fd, nr, &data);

if (R_SUCCEEDED(rc) && freq)
*freq = data.rate;

return rc;
}

Result nvioctlChannel_SetModuleClockRate(u32 fd, u32 module_id, u32 freq) {
nvioctl_clk_rate data = {
.rate = freq,
.moduleid = module_id,
};

return nvIoctl(fd, _NV_IOW(0, 0x08, data), &data);
}

Result nvioctlChannel_SetSubmitTimeout(u32 fd, u32 timeout) {
struct {
__nv_in u32 timeout;
} data = {
.timeout = timeout,
};

return nvIoctl(fd, _NV_IOW(0, 0x07, data), &data);
}

Result nvioctlChannel_MapCommandBuffer(u32 fd, nvioctl_command_buffer_map *maps, u32 num_maps, bool compressed) {
if (num_maps > 0x200)
return MAKERESULT(Module_Libnx, LibnxError_OutOfMemory);
Expand Down
Loading