Skip to content

Add changes for invokev2 #73

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

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all 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
3 changes: 2 additions & 1 deletion inc/fastrpc_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ struct handle_list {
struct fastrpc_dsp_capabilities cap_info;
int trace_marker_fd;
uint64_t jobid;
uint64_t poll_timeout;
/* Capability flag to check if mapping DMA handle through reverse RPC is supported */
int dma_handle_reverse_rpc_map_capability;
/* Mutex to synchronize ASync init and deinit */
Expand Down Expand Up @@ -525,7 +526,7 @@ int fastrpc_update_module_list(uint32_t req, int domain, remote_handle64 handle,
* @brief functions to wrap ioctl syscalls for downstream and upstream kernel
**/
int ioctl_init(int dev, uint32_t flags, int attr, byte* shell, int shelllen, int shellfd, char* initmem, int initmemlen, int initmemfd, int tessiglen);
int ioctl_invoke(int dev, int req, remote_handle handle, uint32_t sc, void* pra, int* fds, unsigned int* attrs, void *job, unsigned int* crc, uint64_t* perf_kernel, uint64_t* perf_dsp);
int ioctl_invoke(int dev, int req, remote_handle handle, uint32_t sc, void* pra, int* fds, unsigned int* attrs, void *job, unsigned int* crc, uint64_t* perf_kernel, uint64_t* perf_dsp, uint64_t poll_timeout);
int ioctl_invoke2_response(int dev, fastrpc_async_jobid *jobid, remote_handle *handle, uint32_t *sc, int* result, uint64_t *perf_kernel, uint64_t *perf_dsp);
int ioctl_invoke2_notif(int dev, int *domain, int *session, int *status);
int ioctl_mmap(int dev, int req, uint32_t flags, int attr, int fd, int offset, size_t len, uintptr_t vaddrin, uint64_t* vaddr_out);
Expand Down
10 changes: 10 additions & 0 deletions inc/fastrpc_ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#define FASTRPC_IOCTL_MEM_MAP _IOWR('R', 10, struct fastrpc_ioctl_mem_map)
#define FASTRPC_IOCTL_MEM_UNMAP _IOWR('R', 11, struct fastrpc_ioctl_mem_unmap)
#define FASTRPC_IOCTL_GET_DSP_INFO _IOWR('R', 13, struct fastrpc_ioctl_capability)
#define FASTRPC_IOCTL_INVOKEV2 _IOWR('R', 14, struct fastrpc_ioctl_invoke_v2)

#define ADSPRPC_DEVICE "/dev/fastrpc-adsp"
#define SDSPRPC_DEVICE "/dev/fastrpc-sdsp"
Expand Down Expand Up @@ -108,6 +109,15 @@ struct fastrpc_ioctl_invoke {
__u64 args;
};

struct fastrpc_ioctl_invoke_v2 {
struct fastrpc_ioctl_invoke inv;
__u64 crc;
__u64 perf_kernel;
__u64 perf_dsp;
__u64 poll_timeout;
__u32 reserved[18];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

change this to reserved[10]

};

struct fastrpc_ioctl_alloc_dma_buf {
__s32 fd; /* fd */
__u32 flags; /* flags to map with */
Expand Down
24 changes: 13 additions & 11 deletions src/fastrpc_apps_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -1312,6 +1312,9 @@ int remote_handle_invoke_domain(int domain, remote_handle handle,
req = INVOKE_PERF;
}

if (hlist[domain].poll_timeout)
req = INVOKE_PERF;

if (!IS_STATIC_HANDLE(handle)) {
fastrpc_latency_invoke_incr(&hlist[domain].qos);
if ((rpc_timeout = fastrpc_config_get_rpctimeout()) > 0) {
Expand All @@ -1331,7 +1334,7 @@ int remote_handle_invoke_domain(int domain, remote_handle handle,
}
// Macros are initializing and destroying pfds and pattrs.
nErr = ioctl_invoke(dev, req, handle, sc, get_args(), pfds, pattrs, job,
crc_remote, perf_kernel, perf_dsp);
crc_remote, perf_kernel, perf_dsp, hlist[domain].poll_timeout);
if (nErr) {
nErr = convert_kernel_to_user_error(nErr, errno);
}
Expand Down Expand Up @@ -2039,10 +2042,15 @@ static int manage_poll_qos(int domain, remote_handle64 h, uint32_t enable,
VERIFY(AEE_SUCCESS ==
(nErr = adsp_current_process1_poll_mode(handle, enable, latency)));
}
FARF(ALWAYS,
"%s: poll mode updated to %u for domain %d, handle 0x%" PRIx64
" for timeout %u\n",
__func__, enable, domain, h, latency);
if (enable) {
hlist[domain].poll_timeout = latency;
FARF(ALWAYS, "%s: poll mode updated to %u for domain %d, handle 0x%" PRIx64 " for timeout %u\n",
__func__, enable, domain, h, latency);
} else {
hlist[domain].poll_timeout = 0;
FARF(ALWAYS, "%s: poll mode updated to %u for domain %d, handle 0x%" PRIx64 " for timeout %u\n",
__func__, enable, domain, h, latency);
}
bail:
if (nErr) {
FARF(ERROR,
Expand Down Expand Up @@ -2298,12 +2306,6 @@ int remote_handle_control_domain(int domain, remote_handle64 h, uint32_t req,
VERIFY(AEE_SUCCESS ==
(nErr = manage_poll_qos(domain, h, RPC_POLL_QOS, lp->latency)));

/*
* Poll QoS option also enables PM QoS to enable early response from DSP
* and stop the CPU cores from going into deep sleep low power modes.
*/
VERIFY(AEE_SUCCESS == (nErr = manage_pm_qos(domain, h, RPC_PM_QOS,
POLL_MODE_PM_QOS_LATENCY)));
break;
}
default:
Expand Down
30 changes: 24 additions & 6 deletions src/fastrpc_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,24 @@ int ioctl_init(int dev, uint32_t flags, int attr, byte *shell, int shelllen,

int ioctl_invoke(int dev, int req, remote_handle handle, uint32_t sc, void *pra,
int *fds, unsigned int *attrs, void *job, unsigned int *crc,
uint64_t *perf_kernel, uint64_t *perf_dsp) {
uint64_t *perf_kernel, uint64_t *perf_dsp, uint64_t poll_timeout) {
int ioErr = AEE_SUCCESS;
struct fastrpc_ioctl_invoke invoke = {0};
struct fastrpc_ioctl_invoke_v2 invoke2 = {0};

invoke.handle = handle;
invoke.sc = sc;
invoke.args = (uint64_t)pra;
if (req >= INVOKE && req <= INVOKE_FD)
if (req >= INVOKE && req <= INVOKE_FD) {
ioErr = ioctl(dev, FASTRPC_IOCTL_INVOKE, (unsigned long)&invoke);
else
return AEE_EUNSUPPORTED;
} else {
invoke2.inv = invoke;
invoke2.crc = (uint64_t)crc;
invoke2.perf_kernel = (uint64_t)perf_kernel;
invoke2.perf_dsp = (uint64_t)perf_dsp;
invoke2.poll_timeout = (uint64_t)poll_timeout;
ioErr = ioctl(dev, FASTRPC_IOCTL_INVOKEV2, (unsigned long)&invoke2);
}

return ioErr;
}
Expand Down Expand Up @@ -181,7 +188,15 @@ int ioctl_getdspinfo(int dev, int domain, uint32_t attr, uint32_t *capability) {
int ioErr = AEE_SUCCESS;
static struct fastrpc_ioctl_capability cap = {0};

if (attr >= PERF_V2_DRIVER_SUPPORT && attr < FASTRPC_MAX_ATTRIBUTES) {
if (attr == USERSPACE_ALLOCATION_SUPPORT) {
*capability = 1;
return 0;
}
if (attr == PERF_V2_DRIVER_SUPPORT) {
*capability = 2;
return 0;
}
if (attr > PERF_V2_DRIVER_SUPPORT && attr < FASTRPC_MAX_ATTRIBUTES ) {
*capability = 0;
return 0;
}
Expand All @@ -195,10 +210,13 @@ int ioctl_getdspinfo(int dev, int domain, uint32_t attr, uint32_t *capability) {
}

int ioctl_setmode(int dev, int mode) {
return AEE_EUNSUPPORTED;
return AEE_SUCCESS;
}

int ioctl_control(int dev, int req, void *c) {
if (req == DSPRPC_RPC_POLL)
return AEE_SUCCESS;

return AEE_EUNSUPPORTED;
}

Expand Down
Loading