From 50fa9cf67eca071ab4a6251bd39ff0fa5af47877 Mon Sep 17 00:00:00 2001 From: Jianping Li Date: Wed, 27 Aug 2025 10:40:39 +0800 Subject: [PATCH] cleanup: remove stale async fastrpc code (#218) Removed async-related fastrpc code. It is stale code that is no longer used or maintained. Signed-off-by: Jianping Li --- inc/AEEStdErr.h | 2 - inc/Makefile.am | 1 - inc/fastrpc_async.h | 73 ------ inc/fastrpc_internal.h | 15 +- inc/remote.h | 129 ----------- src/Makefile.am | 1 - src/fastrpc_apps_user.c | 211 +---------------- src/fastrpc_async.c | 489 ---------------------------------------- src/fastrpc_cap.c | 6 - src/fastrpc_ioctl.c | 15 +- src/symbols.lst | 4 - 11 files changed, 12 insertions(+), 934 deletions(-) delete mode 100644 inc/fastrpc_async.h delete mode 100644 src/fastrpc_async.c diff --git a/inc/AEEStdErr.h b/inc/AEEStdErr.h index 8b7d5ff0..8621f130 100644 --- a/inc/AEEStdErr.h +++ b/inc/AEEStdErr.h @@ -289,8 +289,6 @@ #define AEE_DEFAULT_PROCESS (AEE_EOFFSET + 0x180) ///< Default process in Guest OS is not present #define AEE_ENULLCONTEXT (AEE_EOFFSET + 0x181) ///< User NULL context vote -#define AEE_EINVALIDJOB (AEE_EOFFSET + 0x182) ///< AsyncRPC Invalid job -#define AEE_EBUSY (AEE_EOFFSET + 0x183) ///< AsyncRPC Pending job /** @defgroup heaperror Heap error codes * @{ diff --git a/inc/Makefile.am b/inc/Makefile.am index 24f281f3..5e9256de 100644 --- a/inc/Makefile.am +++ b/inc/Makefile.am @@ -36,7 +36,6 @@ noinst_HEADERS = \ dspqueue_shared.h \ dspsignal.h \ fastrpc_apps_user.h \ - fastrpc_async.h \ fastrpc_cap.h \ fastrpc_common.h \ fastrpc_config.h \ diff --git a/inc/fastrpc_async.h b/inc/fastrpc_async.h deleted file mode 100644 index 76c244dd..00000000 --- a/inc/fastrpc_async.h +++ /dev/null @@ -1,73 +0,0 @@ -// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved. -// SPDX-License-Identifier: BSD-3-Clause - -#ifndef FASTRPC_ASYNC_H -#define FASTRPC_ASYNC_H - -#include "remote64.h" -#include "fastrpc_internal.h" - -#define POS_TO_MASK(pos) ((1UL << pos) - 1) - -#define FASTRPC_ASYNC_JOB_POS 4 // Position in jobid where job starts - -// Store jobs in Queue. Index of queue calculated based on hash value of job. Always needs to be 2^value -#define FASTRPC_ASYNC_QUEUE_LIST_LEN 16 - -// Position where hash ends in jobid -#define FASTRPC_ASYNC_HASH_IDX_POS (FASTRPC_ASYNC_JOB_POS + (FASTRPC_ASYNC_QUEUE_LIST_LEN >> 2)) - -// Position in jobid where timespec starts -#define FASTRPC_ASYNC_TIME_SPEC_POS 48 - -#define SECONDS_PER_HOUR (3600) - -#define FASTRPC_ASYNC_DOMAIN_MASK (POS_TO_MASK(FASTRPC_ASYNC_JOB_POS)) -#define FASTRPC_ASYNC_JOB_CNT_MASK (POS_TO_MASK(FASTRPC_ASYNC_TIME_SPEC_POS) & ~FASTRPC_ASYNC_DOMAIN_MASK) -#define FASTRPC_ASYNC_HASH_MASK (POS_TO_MASK(FASTRPC_ASYNC_HASH_IDX_POS) & ~FASTRPC_ASYNC_DOMAIN_MASK) - -// Async job structure -struct fastrpc_async_job { - uint32_t isasyncjob; // set if async job - /* - * Fastrpc async job ID bit-map: - * - * bits 0-3 : domain ID - * bits 4-47 : job counter - * bits 48-63 : timespec - */ - fastrpc_async_jobid jobid; - uint32_t reserved; // reserved -}; - -/* - * Internal function to save async job information before submitting to DSP - * @ domain: domain to which Async job is submitted - * @ asyncjob: Async job structure - * @ desc: Async desc passed by user - * returns 0 on success - * - */ -int fastrpc_save_async_job(int domain, struct fastrpc_async_job *asyncjob, fastrpc_async_descriptor_t *desc); - -/* - * Internal function to remove async job, if async invocation to DSP fails - * @ jobid: domain to which Async job is submitted - * @ asyncjob: Async job id - * @ dsp_invoke_done: DSP invocation is successful - * returns 0 on success - * - */ -int fastrpc_remove_async_job(fastrpc_async_jobid jobid, bool dsp_invoke_done); - -/* - * API to initialize async module data strcutures and globals - */ -int fastrpc_async_domain_init(int domain); - -/* - * API to de-initialize async module data strcutures and globals - */ -void fastrpc_async_domain_deinit(int domain); - -#endif // FASTRPC_ASYNC_H diff --git a/inc/fastrpc_internal.h b/inc/fastrpc_internal.h index 859bfe8c..41c2e823 100644 --- a/inc/fastrpc_internal.h +++ b/inc/fastrpc_internal.h @@ -43,8 +43,6 @@ * Update these values for any additions to * the corresponding enums. **/ -/* Max value of fastrpc_async_notify_type, used to validate the user input */ -#define FASTRPC_ASYNC_TYPE_MAX FASTRPC_ASYNC_POLL + 1 /* Max value of remote_dsp_attributes, used to validate the attribute ID*/ #define FASTRPC_MAX_DSP_ATTRIBUTES MCID_MULTICAST + 1 @@ -190,7 +188,6 @@ enum fastrpc_control_type { FASTRPC_CONTROL_WAKELOCK = 4, FASTRPC_CONTROL_PM = 5, FASTRPC_CONTROL_RPC_POLL = 7, - FASTRPC_CONTROL_ASYNC_WAKE = 8, FASTRPC_CONTROL_NOTIF_WAKE = 9, }; @@ -316,11 +313,8 @@ struct handle_list { int disable_exit_logs; struct fastrpc_dsp_capabilities cap_info; int trace_marker_fd; - uint64_t jobid; /* 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 */ - pthread_mutex_t async_init_deinit_mut; uint32_t pd_initmem_size; /** Initial memory allocated for remote userPD */ uint32_t refs; // Number of multi-domain handles + contexts on session bool is_session_reserved; /** Set if session is reserved or used */ @@ -377,11 +371,6 @@ int check_rpc_error(int err); **/ void fastrpc_qos_activity(int domain); -/** - * @brief Make IOCTL call to exit async thread - */ -int fastrpc_exit_async_thread(int domain); - /** * @brief Make IOCTL call to exit notif thread */ @@ -502,8 +491,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, unsigned char* 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_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_invoke(int dev, int req, remote_handle handle, uint32_t sc, void* pra, int* fds, unsigned int* attrs, unsigned int* crc, 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); int ioctl_munmap(int dev, int req, int attr, void* buf, int fd, int len, uint64_t vaddr); @@ -539,7 +527,6 @@ int ioctl_mdctx_manage(int dev, int req, void *user_ctx, unsigned int *domain_ids, unsigned int num_domain_ids, uint64_t *ctx); const char* get_secure_domain_name(int domain_id); -int is_async_fastrpc_supported(void); #include "fastrpc_ioctl.h" diff --git a/inc/remote.h b/inc/remote.h index 1fa3baa8..532496c8 100644 --- a/inc/remote.h +++ b/inc/remote.h @@ -196,40 +196,6 @@ typedef union { remote_dma_handle dma; /** 32-bit remote dma handle */ } remote_arg; -/** 64-bit Remote Arg structure for RPC calls */ -typedef union { - remote_buf64 buf; /** 64-bit remote buffer */ - remote_handle h; /** non-domains remote handle */ - remote_handle64 h64; /** multi-domains remote handle */ - remote_dma_handle64 dma; /** 64-bit remote dma handle */ -} remote_arg64; - -/** Async response type */ -enum fastrpc_async_notify_type { - FASTRPC_ASYNC_NO_SYNC, /** No notification required */ - FASTRPC_ASYNC_CALLBACK, /** Callback notification using fastrpc_async_callback */ - FASTRPC_ASYNC_POLL, /** User will poll for the notification */ -/** Update FASTRPC_ASYNC_TYPE_MAX when adding new value to this enum */ -}; - -/** Job id of Async job queued to DSP */ -typedef uint64_t fastrpc_async_jobid; - -/** Async call back response type, input structure */ -typedef struct fastrpc_async_callback { - /** Callback function for async notification */ - void (*fn)(fastrpc_async_jobid jobid, void* context, int result); - /** Current context to identify the callback */ - void *context; -}fastrpc_async_callback_t; - -/** Async descriptor to submit async job */ -typedef struct fastrpc_async_descriptor { - enum fastrpc_async_notify_type type; /** Async response type */ - fastrpc_async_jobid jobid; /** Job id of Async job queued to DSP */ - fastrpc_async_callback_t cb; /** Async call back response type */ -}fastrpc_async_descriptor_t; - /** * Flags used in struct remote_rpc_control_latency @@ -937,101 +903,6 @@ __QAIC_REMOTE_EXPORT __QAIC_RETURN int __QAIC_REMOTE(remote_handle64_control)(__ __QAIC_REMOTE_EXPORT __QAIC_RETURN int __QAIC_REMOTE(remote_session_control)(__QAIC_IN uint32_t req, __QAIC_IN_LEN(datalen) void *data, __QAIC_IN uint32_t datalen) __QAIC_REMOTE_ATTRIBUTE; -/** - * Invokes a remote handle asynchronously - * - * This function allows asynchronous invocation of remote methods, providing non-blocking - * execution and callback mechanisms. - * - * @param h [in] Remote handle obtained from remote_handle_open() - * - * @param desc [in] Async descriptor containing: - * - type: Type of async job (FASTRPC_ASYNC_NO_SYNC, FASTRPC_ASYNC_CALLBACK) - * - context: User context passed to callback - * - cb: Callback function and arguments (for FASTRPC_ASYNC_CALLBACK type) - * See fastrpc_async_descriptor_t for details - * - * @param dwScalars [in] Method invocation parameters encoded as scalar value: - * - Number of input/output buffers - * - Number of input/output handles - * Use REMOTE_SCALARS_* macros to decode - * - * @param pra [in] Array of remote_arg structures containing: - * 1. Input buffers - * 2. Output buffers - * 3. Input handles - * 4. Output handles - * Output buffers must be allocated via rpcmem_alloc() or - * registered as ION buffers using register_buf() - * - * @return 0 on success, otherwise error code: - * - AEE_EBADPARM: Invalid parameters - * - AEE_EUNSUPPORTED: Async operations not supported - * - AEE_ENOSUCH: Invalid handle - * - Other error codes from FastRPC framework - * - * @note The async job status can be queried using fastrpc_async_get_status() - * @note Resources must be released using fastrpc_release_async_job() after completion - */ -__QAIC_REMOTE_EXPORT __QAIC_RETURN int __QAIC_REMOTE(remote_handle_invoke_async)(__QAIC_IN remote_handle h, __QAIC_IN fastrpc_async_descriptor_t *desc, __QAIC_IN uint32_t dwScalars, __QAIC_IN remote_arg *pra) __QAIC_REMOTE_ATTRIBUTE; -__QAIC_REMOTE_EXPORT __QAIC_RETURN int __QAIC_REMOTE(remote_handle64_invoke_async)(__QAIC_IN remote_handle64 h, __QAIC_IN fastrpc_async_descriptor_t *desc, __QAIC_IN uint32_t dwScalars, __QAIC_IN remote_arg *pra) __QAIC_REMOTE_ATTRIBUTE; - - -/** - * Gets the status and result of an asynchronous FastRPC job - * - * This function allows checking the completion status of an asynchronous FastRPC job - * and retrieving its result. It can be configured to wait for job completion with - * different timeout behaviors. - * - * @param jobid [in] Job ID returned by remote_handle_invoke_async() when submitting - * the asynchronous job - * - * @param timeout_us [in] Timeout value in microseconds: - * - 0: Returns immediately with current status/result - * - Positive value: Waits up to specified microseconds for completion - * - Negative value: Waits indefinitely until job completes - * - * @param result [out] Pointer to store the job result: - * - 0 if job completed successfully - * - Error code if job failed - * Only valid when function returns 0 (job completed) - * - * @return 0 on success (job completed), otherwise error code: - * - AEE_EBUSY: Job is still pending and not completed within timeout - * - AEE_EBADPARM: Invalid job ID provided - * - AEE_EFAILED: Internal FastRPC framework error - * - * @note After job completion, resources must be released using fastrpc_release_async_job() - * @note This function is thread-safe and can be called concurrently from multiple threads - */ -__QAIC_REMOTE_EXPORT __QAIC_RETURN int __QAIC_REMOTE(fastrpc_async_get_status)(__QAIC_IN fastrpc_async_jobid jobid,__QAIC_IN int timeout_us,__QAIC_OUT int *result); - - -/** - * Releases resources associated with an asynchronous FastRPC job - * - * This function must be called after an asynchronous job completes to free associated - * resources and cleanup internal state. It should only be called after receiving job - * completion status either through: - * - Callback notification (for FASTRPC_ASYNC_CALLBACK jobs) - * - Polling via fastrpc_async_get_status() (for FASTRPC_ASYNC_POLL jobs) - * - * @param jobid [in] Job ID returned by remote_handle_invoke_async() when submitting - * the asynchronous job - * - * @return 0 on success, otherwise error code: - * - AEE_EBUSY: Job is still pending and has not completed yet - * - AEE_EBADPARM: Invalid job ID provided - * - AEE_EFAILED: Internal FastRPC framework error - * - * @note This function is thread-safe and can be called concurrently from multiple threads - * @note Calling this function before job completion will return AEE_EBUSY - * @note Resources must be released exactly once per async job to avoid memory leaks - */ -__QAIC_REMOTE_EXPORT __QAIC_RETURN int __QAIC_REMOTE(fastrpc_release_async_job)(__QAIC_IN fastrpc_async_jobid jobid); - - /** * DEPRECATED: Use fastrpc_mmap() instead. * diff --git a/src/Makefile.am b/src/Makefile.am index 7c28c49a..e335d098 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -7,7 +7,6 @@ LIBDSPRPC_SOURCES = \ fastrpc_perf.c \ fastrpc_pm.c \ fastrpc_config.c \ - fastrpc_async.c \ fastrpc_mem.c \ fastrpc_notif.c \ fastrpc_latency.c \ diff --git a/src/fastrpc_apps_user.c b/src/fastrpc_apps_user.c index 81fef0ab..104d397c 100644 --- a/src/fastrpc_apps_user.c +++ b/src/fastrpc_apps_user.c @@ -52,7 +52,6 @@ #include "apps_std_internal.h" #include "dspsignal.h" #include "fastrpc_apps_user.h" -#include "fastrpc_async.h" #include "fastrpc_cap.h" #include "fastrpc_common.h" #include "fastrpc_config.h" @@ -1158,8 +1157,7 @@ static void fastrpc_delete_timer(timer_t *timer) { } int remote_handle_invoke_domain(int domain, remote_handle handle, - fastrpc_async_descriptor_t *desc, uint32_t sc, - remote_arg *pra) { + uint32_t sc, remote_arg *pra) { int dev, total, bufs, handles, i, nErr = 0, wake_lock = 0, rpc_timeout = 0; unsigned req; uint32_t len; @@ -1168,7 +1166,6 @@ int remote_handle_invoke_domain(int domain, remote_handle handle, uint32_t *crc_local = NULL; uint64_t *perf_kernel = NULL; uint64_t *perf_dsp = NULL; - struct fastrpc_async_job asyncjob = {0}, *job = NULL; fastrpc_timer frpc_timer; int trace_marker_fd = hlist[domain].trace_marker_fd; bool trace_enabled = false; @@ -1212,31 +1209,6 @@ int remote_handle_invoke_domain(int domain, remote_handle handle, INITIALIZE_REMOTE_ARGS(total); - if (desc) { - struct timespec time_spec; - // Check for valid user async descriptor - VERIFYC(desc->type >= FASTRPC_ASYNC_NO_SYNC && - desc->type < FASTRPC_ASYNC_TYPE_MAX, - AEE_EBADPARM); - VERIFYC(!(desc->type == FASTRPC_ASYNC_CALLBACK && desc->cb.fn == NULL), - AEE_EBADPARM); - pthread_mutex_lock(&hlist[domain].async_init_deinit_mut); - if (AEE_SUCCESS != (nErr = fastrpc_async_domain_init(domain))) { - pthread_mutex_unlock(&hlist[domain].async_init_deinit_mut); - goto bail; - } - asyncjob.jobid = ++list->jobid; - pthread_mutex_unlock(&hlist[domain].async_init_deinit_mut); - clock_gettime(CLOCK_MONOTONIC, &time_spec); - asyncjob.jobid = ((((time_spec.tv_sec) / SECONDS_PER_HOUR) - << (FASTRPC_ASYNC_TIME_SPEC_POS / 2)) - << ((FASTRPC_ASYNC_TIME_SPEC_POS + 1) / 2) | - (asyncjob.jobid << FASTRPC_ASYNC_JOB_POS) | domain); - asyncjob.isasyncjob = 1; - fastrpc_save_async_job(domain, &asyncjob, desc); - job = &asyncjob; - } - req = INVOKE; VERIFYC(!(NULL == pra && total > 0), AEE_EBADPARM); for (i = 0; i < bufs; i++) { @@ -1251,11 +1223,6 @@ int remote_handle_invoke_domain(int domain, remote_handle handle, set_args_fd(i, fd); req = INVOKE_FD; } - // AsyncRPC doesn't support Non-ion output buffers - if (asyncjob.isasyncjob && i >= (int)REMOTE_SCALARS_INBUFS(sc)) { - VERIFYM(fd != -1, AEE_EBADPARM, - "AsyncRPC doesn't support Non-ion output buffers"); - } if (nova) { req = INVOKE_ATTRS; append_args_attr(i, FASTRPC_ATTR_NOVA); @@ -1313,7 +1280,7 @@ int remote_handle_invoke_domain(int domain, remote_handle handle, } if (IS_CRC_CHECK_ENABLED(hlist[domain].procattrs) && - (!IS_STATIC_HANDLE(handle)) && !asyncjob.isasyncjob) { + (!IS_STATIC_HANDLE(handle))) { int nInBufs = REMOTE_SCALARS_INBUFS(sc); crc_local = (uint32_t *)calloc(M_CRCLIST, sizeof(uint32_t)); crc_remote = (uint32_t *)calloc(M_CRCLIST, sizeof(uint32_t)); @@ -1357,7 +1324,7 @@ int remote_handle_invoke_domain(int domain, remote_handle handle, wake_lock = 0; } // Macros are initializing and destroying pfds and pattrs. - nErr = ioctl_invoke(dev, req, handle, sc, get_args(), pfds, pattrs, job, + nErr = ioctl_invoke(dev, req, handle, sc, get_args(), pfds, pattrs, crc_remote, perf_kernel, perf_dsp); if (nErr) { nErr = convert_kernel_to_user_error(nErr, errno); @@ -1373,7 +1340,7 @@ int remote_handle_invoke_domain(int domain, remote_handle handle, } if (IS_CRC_CHECK_ENABLED(hlist[domain].procattrs) && - (!IS_STATIC_HANDLE(handle)) && !asyncjob.isasyncjob) { + (!IS_STATIC_HANDLE(handle))) { int nInBufs = REMOTE_SCALARS_INBUFS(sc); VERIFYC(crc_local != NULL && crc_remote != NULL, AEE_ENOMEMORY); for (i = nInBufs; i < bufs; i++) @@ -1389,7 +1356,7 @@ int remote_handle_invoke_domain(int domain, remote_handle handle, } if (IS_KERNEL_PERF_ENABLED(hlist[domain].procattrs) && - (!IS_STATIC_HANDLE(handle)) && !asyncjob.isasyncjob) { + (!IS_STATIC_HANDLE(handle))) { VERIFYC(perf_kernel != NULL, AEE_ENOMEMORY); FARF(ALWAYS, "RPCPERF-K H:0x%x SC:0x%x C:%" PRIu64 " F:%" PRIu64 " ns M:%" PRIu64 @@ -1400,7 +1367,7 @@ int remote_handle_invoke_domain(int domain, remote_handle handle, perf_kernel[7], perf_kernel[8]); } if (IS_DSP_PERF_ENABLED(hlist[domain].procattrs) && - (!IS_STATIC_HANDLE(handle)) && !asyncjob.isasyncjob) { + (!IS_STATIC_HANDLE(handle))) { VERIFYC(perf_dsp != NULL, AEE_ENOMEMORY); FARF(ALWAYS, "RPCPERF-D H:0x%x SC:0x%x C:%" PRIu64 " M_H:%" PRIu64 " us M:%" PRIu64 @@ -1417,16 +1384,6 @@ int remote_handle_invoke_domain(int domain, remote_handle handle, fastrpc_perf_update(dev, handle, sc); } bail: - if (asyncjob.isasyncjob) { - if (!nErr) { - FARF(RUNTIME_RPC_HIGH, "adsprpc : %s Async job Queued, job 0x%" PRIx64 "", - __func__, asyncjob.jobid); - desc->jobid = asyncjob.jobid; - } else { - fastrpc_remove_async_job(asyncjob.jobid, false); - desc->jobid = -1; - } - } DESTROY_REMOTE_ARGS(); if (crc_local) { free(crc_local); @@ -1436,11 +1393,11 @@ int remote_handle_invoke_domain(int domain, remote_handle handle, free(crc_remote); crc_remote = NULL; } - if (perf_kernel && !asyncjob.isasyncjob) { + if (perf_kernel) { free(perf_kernel); perf_kernel = NULL; } - if (perf_dsp && !asyncjob.isasyncjob) { + if (perf_dsp) { free(perf_dsp); perf_dsp = NULL; } @@ -1479,7 +1436,7 @@ int remote_handle_invoke(remote_handle handle, uint32_t sc, remote_arg *pra) { domain = get_current_domain(); FASTRPC_GET_REF(domain); VERIFY(AEE_SUCCESS == - (nErr = remote_handle_invoke_domain(domain, handle, NULL, sc, pra))); + (nErr = remote_handle_invoke_domain(domain, handle, sc, pra))); bail: FASTRPC_PUT_REF(domain); if (nErr != AEE_SUCCESS) { @@ -1527,7 +1484,7 @@ int remote_handle64_invoke(remote_handle64 local, uint32_t sc, FASTRPC_GET_REF(domain); VERIFY(AEE_SUCCESS == (nErr = get_handle_remote(local, &remote))); VERIFY(AEE_SUCCESS == - (nErr = remote_handle_invoke_domain(domain, remote, NULL, sc, pra))); + (nErr = remote_handle_invoke_domain(domain, remote, sc, pra))); bail: FASTRPC_PUT_REF(domain); if (nErr != AEE_SUCCESS) { @@ -1548,72 +1505,6 @@ int remote_handle64_invoke(remote_handle64 local, uint32_t sc, return nErr; } -int remote_handle_invoke_async(remote_handle handle, - fastrpc_async_descriptor_t *desc, uint32_t sc, - remote_arg *pra) { - int domain = -1, nErr = AEE_SUCCESS, ref = 0; - - VERIFY(AEE_SUCCESS == (nErr = fastrpc_init_once())); - - FARF(RUNTIME_RPC_HIGH, "Entering %s, handle %u desc %p sc %X remote_arg %p\n", - __func__, handle, desc, sc, pra); - FASTRPC_ATRACE_BEGIN_L("%s called with handle 0x%x , scalar 0x%x", __func__, - (int)handle, sc); - VERIFYC(handle != (remote_handle)-1, AEE_EINVHANDLE); - - domain = get_current_domain(); - FASTRPC_GET_REF(domain); - VERIFY(AEE_SUCCESS == - (nErr = remote_handle_invoke_domain(domain, handle, desc, sc, pra))); -bail: - FASTRPC_PUT_REF(domain); - if (nErr != AEE_SUCCESS) { - if (0 == check_rpc_error(nErr)) { - FARF(ERROR, - "Error 0x%x: %s failed for handle 0x%x, method %d async type %d on " - "domain %d (sc 0x%x) (errno %s)\n", - nErr, __func__, (int)handle, REMOTE_SCALARS_METHOD(sc), desc->type, - domain, sc, strerror(errno)); - } - } - FASTRPC_ATRACE_END(); - return nErr; -} - -int remote_handle64_invoke_async(remote_handle64 local, - fastrpc_async_descriptor_t *desc, uint32_t sc, - remote_arg *pra) { - remote_handle64 remote = 0; - int nErr = AEE_SUCCESS, domain = -1, ref = 0; - - VERIFY(AEE_SUCCESS == (nErr = fastrpc_init_once())); - - FARF(RUNTIME_RPC_HIGH, "Entering %s, handle %llu desc %p sc %X remote_arg %p\n", __func__, - local, desc, sc, pra); - FASTRPC_ATRACE_BEGIN_L("%s called with handle 0x%x , scalar 0x%x", __func__, - (int)local, sc); - VERIFYC(local != (remote_handle64)-1, AEE_EINVHANDLE); - - VERIFY(AEE_SUCCESS == (nErr = get_domain_from_handle(local, &domain))); - FASTRPC_GET_REF(domain); - VERIFY(AEE_SUCCESS == (nErr = get_handle_remote(local, &remote))); - VERIFY(AEE_SUCCESS == - (nErr = remote_handle_invoke_domain(domain, remote, desc, sc, pra))); -bail: - FASTRPC_PUT_REF(domain); - if (nErr != AEE_SUCCESS) { - if (0 == check_rpc_error(nErr)) { - FARF(ERROR, - "Error 0x%x: %s failed for handle 0x%" PRIx64 - ", method %d on domain %d (sc 0x%x) (errno %s)\n", - nErr, __func__, local, REMOTE_SCALARS_METHOD(sc), domain, sc, - strerror(errno)); - } - } - FASTRPC_ATRACE_END(); - return nErr; -} - int listener_android_geteventfd(int domain, int *fd); int remote_handle_open_domain(int domain, const char *name, remote_handle *ph, uint64_t *t_spawn, uint64_t *t_load) { @@ -2117,81 +2008,6 @@ static inline int enable_process_state_notif_on_dsp(int domain) { return nErr; } -/* - * Internal function to get async response from kernel. Waits in kernel until - * response is received from DSP - * @ domain: domain to which Async job is submitted - * @ async_data: IOCTL structure that is sent to kernel to get async response - * job information returns 0 on success - * - */ -int get_remote_async_response(int domain, fastrpc_async_jobid *jobid, - int *result) { - int nErr = AEE_SUCCESS, dev = -1; - uint64_t *perf_kernel = NULL, *perf_dsp = NULL; - fastrpc_async_jobid job = -1; - int res = -1; - remote_handle handle = -1; - uint32_t sc = 0; - - VERIFYC(IS_VALID_EFFECTIVE_DOMAIN_ID(domain), AEE_EBADPARM); - VERIFY(AEE_SUCCESS == (nErr = domain_init(domain, &dev))); - VERIFYM(-1 != dev, AEE_ERPC, "open dev failed\n"); - if (IS_KERNEL_PERF_ENABLED(hlist[domain].procattrs)) { - perf_kernel = (uint64_t *)calloc(PERF_KERNEL_KEY_MAX, sizeof(uint64_t)); - VERIFYC(perf_kernel != NULL, AEE_ENOMEMORY); - } - if (IS_DSP_PERF_ENABLED(hlist[domain].procattrs)) { - perf_dsp = (uint64_t *)calloc(PERF_DSP_KEY_MAX, sizeof(uint64_t)); - VERIFYC(perf_dsp != NULL, AEE_ENOMEMORY); - } - nErr = ioctl_invoke2_response(dev, &job, &handle, &sc, &res, perf_kernel, - perf_dsp); - if (IS_KERNEL_PERF_ENABLED(hlist[domain].procattrs) && - (!IS_STATIC_HANDLE(handle))) { - VERIFYC(perf_kernel != NULL, AEE_ENOMEMORY); - FARF(ALWAYS, - "RPCPERF-K H:0x%x SC:0x%x C:%" PRIu64 " F:%" PRIu64 " ns M:%" PRIu64 - " ns CP:%" PRIu64 " ns L:%" PRIu64 " ns G:%" PRIu64 " ns P:%" PRIu64 - " ns INV:%" PRIu64 " ns INVOKE:%" PRIu64 " ns\n", - handle, sc, perf_kernel[0], perf_kernel[1], perf_kernel[2], - perf_kernel[3], perf_kernel[4], perf_kernel[5], perf_kernel[6], - perf_kernel[7], perf_kernel[8]); - } - if (IS_DSP_PERF_ENABLED(hlist[domain].procattrs) && - (!IS_STATIC_HANDLE(handle))) { - VERIFYC(perf_dsp != NULL, AEE_ENOMEMORY); - FARF(ALWAYS, - "RPCPERF-D H:0x%x SC:0x%x C:%" PRIu64 " M_H:%" PRIu64 " us M:%" PRIu64 - " us G:%" PRIu64 " us INVOKE:%" PRIu64 " us P:%" PRIu64 - " us CACHE:%" PRIu64 " us UM:%" PRIu64 " us " - "UM_H:%" PRIu64 " us R:%" PRIu64 " us E_R:%" PRIu64 - " us J_S_T:%" PRIu64 " us\n", - handle, sc, perf_dsp[0], perf_dsp[1], perf_dsp[2], perf_dsp[3], - perf_dsp[4], perf_dsp[5], perf_dsp[6], perf_dsp[7], perf_dsp[8], - perf_dsp[9], perf_dsp[10], perf_dsp[11]); - } - *jobid = job; - *result = res; - -bail: - if (perf_kernel) { - free(perf_kernel); - perf_kernel = NULL; - } - if (perf_dsp) { - free(perf_dsp); - perf_dsp = NULL; - } - if (nErr) { - FARF(ERROR, - "Error 0x%x: %s failed to get async response data for domain %d errno " - "%s", - nErr, __func__, domain, strerror(errno)); - } - return nErr; -} - /* fastrpc_set_qos_latency: Send user QoS latency requirement to DSP. DSP will use required features to meet the requirement. @@ -3154,7 +2970,6 @@ PL_DEP(gpls); PL_DEP(apps_std); PL_DEP(rpcmem); PL_DEP(listener_android); -PL_DEP(fastrpc_async); static int attach_guestos(int domain) { int attach; @@ -3205,9 +3020,6 @@ static void domain_deinit(int domain) { dspsignal_domain_deinit(domain); listener_android_domain_deinit(domain); hlist[domain].first_revrpc_done = 0; - pthread_mutex_lock(&hlist[domain].async_init_deinit_mut); - fastrpc_async_domain_deinit(domain); - pthread_mutex_unlock(&hlist[domain].async_init_deinit_mut); fastrpc_notif_domain_deinit(domain); fastrpc_clear_handle_list(MULTI_DOMAIN_HANDLE_LIST_ID, domain); fastrpc_clear_handle_list(REVERSE_HANDLE_LIST_ID, domain); @@ -4100,7 +3912,6 @@ static void fastrpc_apps_user_deinit(void) { pthread_mutex_destroy(&hlist[i].mut); pthread_mutex_destroy(&hlist[i].lmut); pthread_mutex_destroy(&hlist[i].init); - pthread_mutex_destroy(&hlist[i].async_init_deinit_mut); } listener_android_deinit(); free(hlist); @@ -4181,7 +3992,6 @@ static int fastrpc_apps_user_init(void) { FOR_EACH_EFFECTIVE_DOMAIN_ID(i) { hlist[i].dev = -1; hlist[i].th_params.thread_priority = DEFAULT_UTHREAD_PRIORITY; - hlist[i].jobid = 1; hlist[i].info = -1; hlist[i].th_params.stack_size = DEFAULT_UTHREAD_STACK_SIZE; sem_init(&hlist[i].th_params.r_sem, 0, @@ -4198,7 +4008,6 @@ static int fastrpc_apps_user_init(void) { pthread_mutex_init(&hlist[i].mut, &attr); pthread_mutex_init(&hlist[i].lmut, 0); pthread_mutex_init(&hlist[i].init, 0); - pthread_mutex_init(&hlist[i].async_init_deinit_mut, 0); } listener_android_init(); VERIFY(AEE_SUCCESS == (nErr = pthread_key_create(&tlsKey, exit_thread))); diff --git a/src/fastrpc_async.c b/src/fastrpc_async.c deleted file mode 100644 index c3b69e50..00000000 --- a/src/fastrpc_async.c +++ /dev/null @@ -1,489 +0,0 @@ -// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved. -// SPDX-License-Identifier: BSD-3-Clause - -#ifndef VERIFY_PRINT_ERROR -#define VERIFY_PRINT_ERROR -#endif /* VERIFY_PRINT_ERROR */ - -#define FARF_ERROR 1 - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "AEEQList.h" -#include "AEEStdErr.h" -#include "AEEstd.h" -#include "HAP_farf.h" -#include "fastrpc_perf.h" -#include "fastrpc_common.h" -#include "fastrpc_async.h" -#include "platform_libs.h" -#include "verify.h" - -#define GET_DOMAIN_FROM_JOBID(jobid) (jobid & FASTRPC_ASYNC_DOMAIN_MASK) -#define GET_HASH_FROM_JOBID(jobid) \ - ((jobid & FASTRPC_ASYNC_HASH_MASK) >> FASTRPC_ASYNC_JOB_POS) -#define EVENT_COMPLETE 0xff - -struct fastrpc_async { - QList ql[FASTRPC_ASYNC_QUEUE_LIST_LEN]; - pthread_mutex_t mut; - pthread_t thread; - int init_done; - int deinit_started; -}; - -struct fastrpc_async_job_node { - QNode qn; - fastrpc_async_descriptor_t async_desc; - bool isjobdone; - struct pollfd pfd; - int result; -}; - -pthread_mutex_t async_mut = PTHREAD_MUTEX_INITIALIZER; -static struct fastrpc_async lasyncinfo[NUM_DOMAINS_EXTEND]; - -extern void set_thread_context(int domain); -static int get_remote_async_response(int domain, fastrpc_async_jobid *jobid, - int *result); - -int fastrpc_search_async_job(fastrpc_async_jobid jobid, - struct fastrpc_async_job_node **async_node) { - int nErr = AEE_SUCCESS; - int domain, hash; - struct fastrpc_async *me = NULL; - QNode *pn, *pnn; - bool jobfound = false; - struct fastrpc_async_job_node *lasync_node; - - domain = GET_DOMAIN_FROM_JOBID(jobid); - hash = GET_HASH_FROM_JOBID(jobid); - VERIFYC(IS_VALID_EFFECTIVE_DOMAIN_ID(domain), AEE_EBADPARM); - me = &lasyncinfo[domain]; - VERIFYC(me->init_done == 1, AEE_EBADPARM); - pthread_mutex_lock(&me->mut); - QLIST_NEXTSAFE_FOR_ALL(&me->ql[hash], pn, pnn) { - lasync_node = STD_RECOVER_REC(struct fastrpc_async_job_node, qn, pn); - if (lasync_node->async_desc.jobid == jobid) { - jobfound = true; - break; - } - } - pthread_mutex_unlock(&me->mut); - VERIFYC(jobfound, AEE_EBADPARM); - *async_node = lasync_node; -bail: - return nErr; -} - -int fastrpc_async_get_status(fastrpc_async_jobid jobid, int timeout_us, - int *result) { - int nErr = AEE_SUCCESS; - int domain; - struct fastrpc_async *me = NULL; - struct fastrpc_async_job_node *lasync_node = NULL; - eventfd_t event = 0; - - VERIFYC(result != NULL, AEE_EBADPARM); - VERIFY(AEE_SUCCESS == (nErr = fastrpc_search_async_job(jobid, &lasync_node))); - domain = GET_DOMAIN_FROM_JOBID(jobid); - me = &lasyncinfo[domain]; - pthread_mutex_lock(&me->mut); - if (lasync_node->isjobdone) { // If job is done, return result - *result = lasync_node->result; - goto unlock_bail; - } else if (timeout_us == 0) { // If timeout 0, then return PENDING - nErr = AEE_EBUSY; - goto unlock_bail; - } - // If valid timeout(+ve/-ve), create poll event and wait on poll - if (-1 == (lasync_node->pfd.fd = eventfd(0, 0))) { - nErr = AEE_EFAILED; - FARF(ERROR, - "Error 0x%x: %s failed to create poll event for jobid 0x%" PRIx64 - " (%s)\n", - nErr, __func__, jobid, strerror(errno)); - goto unlock_bail; - } - lasync_node->pfd.events = POLLIN; - lasync_node->pfd.revents = 0; - pthread_mutex_unlock(&me->mut); - while (1) { - VERIFYC(0 < poll(&lasync_node->pfd, 1, timeout_us), AEE_EFAILED); - VERIFYC(0 == eventfd_read(lasync_node->pfd.fd, &event), AEE_EFAILED); - if (event) { - break; - } - } - VERIFYC(lasync_node->isjobdone, AEE_EBUSY); - *result = lasync_node->result; - goto bail; -unlock_bail: - pthread_mutex_unlock(&me->mut); -bail: - if (nErr) { - FARF(ERROR, "Error 0x%x: %s failed for jobid 0x%" PRIx64 " (%s)\n", nErr, - __func__, jobid, strerror(errno)); - } - return nErr; -} - -int fastrpc_remove_async_job(fastrpc_async_jobid jobid, - bool dsp_invoke_done) { - int nErr = AEE_SUCCESS; - struct fastrpc_async *me = NULL; - struct fastrpc_async_job_node *lasync_node = NULL; - int domain = -1; - - VERIFY(AEE_SUCCESS == (nErr = fastrpc_search_async_job(jobid, &lasync_node))); - domain = GET_DOMAIN_FROM_JOBID(jobid); - me = &lasyncinfo[domain]; - pthread_mutex_lock(&me->mut); - if (dsp_invoke_done && !lasync_node->isjobdone) { - pthread_mutex_unlock(&me->mut); - nErr = AEE_EBUSY; - goto bail; - } - QNode_DequeueZ(&lasync_node->qn); - pthread_mutex_unlock(&me->mut); - if (lasync_node->async_desc.type == FASTRPC_ASYNC_POLL && - lasync_node->pfd.fd != -1) { - close(lasync_node->pfd.fd); - lasync_node->pfd.fd = -1; - } - free(lasync_node); - lasync_node = NULL; -bail: - if (nErr) { - FARF(ERROR, - "Error 0x%x: %s failed for domain %d and jobid 0x%" PRIx64 " (%s)\n", - nErr, __func__, domain, jobid, strerror(errno)); - } - return nErr; -} - -int fastrpc_release_async_job(fastrpc_async_jobid jobid) { - return fastrpc_remove_async_job(jobid, true); -} - -int fastrpc_save_async_job(int domain, struct fastrpc_async_job *async_job, - fastrpc_async_descriptor_t *desc) { - int nErr = AEE_SUCCESS; - struct fastrpc_async *me = &lasyncinfo[domain]; - struct fastrpc_async_job_node *lasync_job = 0; - int hash = -1; - - VERIFYC(me->init_done == 1, AEE_EINVALIDJOB); - VERIFYC(NULL != (lasync_job = calloc(1, sizeof(*lasync_job))), AEE_ENOMEMORY); - QNode_CtorZ(&lasync_job->qn); - lasync_job->async_desc.jobid = async_job->jobid; - lasync_job->async_desc.type = desc->type; - lasync_job->async_desc.cb.fn = desc->cb.fn; - lasync_job->async_desc.cb.context = desc->cb.context; - lasync_job->isjobdone = false; - lasync_job->result = -1; - lasync_job->pfd.fd = -1; - hash = GET_HASH_FROM_JOBID(lasync_job->async_desc.jobid); - pthread_mutex_lock(&me->mut); - QList_AppendNode(&me->ql[hash], &lasync_job->qn); - pthread_mutex_unlock(&me->mut); - FARF(RUNTIME_RPC_HIGH, "adsprpc: %s : Saving job with jobid 0x%" PRIx64 "", - __func__, lasync_job->async_desc.jobid); -bail: - if (nErr) { - FARF(ERROR, "Error 0x%x: %s failed for domain %d (%s)\n", nErr, __func__, - domain, strerror(errno)); - } - return nErr; -} - -void fastrpc_async_respond_all_pending_jobs(int domain) { - int i = 0; - struct fastrpc_async *me = &lasyncinfo[domain]; - struct fastrpc_async_job_node *lasync_node = NULL; - QNode *pn; - - for (i = 0; i < FASTRPC_ASYNC_QUEUE_LIST_LEN; i++) { - pthread_mutex_lock(&me->mut); - while (!QList_IsEmpty(&me->ql[i])) { - pn = QList_GetFirst(&me->ql[i]); - lasync_node = STD_RECOVER_REC(struct fastrpc_async_job_node, qn, pn); - if (!lasync_node) { - continue; - } - QNode_DequeueZ(&lasync_node->qn); - lasync_node->result = -ECONNRESET; - pthread_mutex_unlock(&me->mut); - if (lasync_node->async_desc.type == FASTRPC_ASYNC_CALLBACK) { - FARF(RUNTIME_RPC_HIGH, - "adsprpc: %s callback jobid 0x%" PRIx64 " and result 0x%x", - __func__, lasync_node->async_desc.jobid, lasync_node->result); - lasync_node->async_desc.cb.fn(lasync_node->async_desc.jobid, - lasync_node->async_desc.cb.context, - lasync_node->result); - } else if (lasync_node->async_desc.type == FASTRPC_ASYNC_POLL) { - FARF(RUNTIME_RPC_HIGH, - "adsprpc: %s poll jobid 0x%" PRIx64 " and result 0x%x", __func__, - lasync_node->async_desc.jobid, lasync_node->result); - if (lasync_node->pfd.fd != -1) { - eventfd_write(lasync_node->pfd.fd, (eventfd_t)EVENT_COMPLETE); - } - } - free(lasync_node); - lasync_node = NULL; - pthread_mutex_lock(&me->mut); - } - pthread_mutex_unlock(&me->mut); - } -} - -static void *async_fastrpc_thread(void *arg) { - int nErr = AEE_SUCCESS; - struct fastrpc_async *me = (struct fastrpc_async *)arg; - int domain = (int)(me - &lasyncinfo[0]); - struct fastrpc_async_job_node *lasync_node = NULL; - int result = -1; - fastrpc_async_jobid jobid = -1; - QNode *pn, *pnn; - - int hash = -1; - bool isjobfound = false; - - /// TODO: Do we really need this line? - set_thread_context(domain); - do { - nErr = get_remote_async_response(domain, &jobid, &result); - VERIFY(nErr == AEE_SUCCESS); - FARF(RUNTIME_RPC_HIGH, - "adsprpc: %s received async response for jobid 0x%" PRIx64 - " and result 0x%x", - __func__, jobid, result); - isjobfound = false; - hash = GET_HASH_FROM_JOBID(jobid); - pthread_mutex_lock(&me->mut); - QLIST_NEXTSAFE_FOR_ALL(&me->ql[hash], pn, pnn) { - lasync_node = STD_RECOVER_REC(struct fastrpc_async_job_node, qn, pn); - if (lasync_node->async_desc.jobid == jobid) { - lasync_node->isjobdone = true; - lasync_node->result = result; - isjobfound = true; - switch (lasync_node->async_desc.type) { - case FASTRPC_ASYNC_NO_SYNC: - FARF(RUNTIME_RPC_HIGH, - "adsprpc: %s nosync jobid 0x%" PRIx64 " and result 0x%x", - __func__, lasync_node->async_desc.jobid, result); - QNode_DequeueZ(&lasync_node->qn); - pthread_mutex_unlock(&me->mut); - free(lasync_node); - lasync_node = NULL; - break; - case FASTRPC_ASYNC_POLL: - FARF(RUNTIME_RPC_HIGH, - "adsprpc: %s poll jobid 0x%" PRIx64 " and result 0x%x", __func__, - lasync_node->async_desc.jobid, result); - if (lasync_node->pfd.fd != -1) { - eventfd_write(lasync_node->pfd.fd, (eventfd_t)EVENT_COMPLETE); - } - pthread_mutex_unlock(&me->mut); - break; - case FASTRPC_ASYNC_CALLBACK: - pthread_mutex_unlock(&me->mut); - FARF(RUNTIME_RPC_HIGH, - "adsprpc: %s callback jobid 0x%" PRIx64 " and result 0x%x", - __func__, lasync_node->async_desc.jobid, result); - lasync_node->async_desc.cb.fn(lasync_node->async_desc.jobid, - lasync_node->async_desc.cb.context, - result); - break; - default: - pthread_mutex_unlock(&me->mut); - FARF(RUNTIME_RPC_HIGH, - "adsprpc: %s Invalid job type for jobid 0x%" PRIx64 "", __func__, - lasync_node->async_desc.jobid); - break; - } - break; - } - } - if (!isjobfound) - pthread_mutex_unlock(&me->mut); - } while (1); -bail: - if (nErr != AEE_SUCCESS) { - VERIFY_EPRINTF("Error 0x%x: %s AsyncFastRPC worker thread exited for " - "domain %d (errno %s), async_domain_deinit started %d", - nErr, __func__, domain, strerror(errno), me->deinit_started); - } - dlerror(); - return (void *)(uintptr_t)nErr; -} - -void async_thread_exit_handler(int sig) { - FARF(ALWAYS, "Async FastRPC worker thread exiting with signal %d\n", sig); - pthread_exit(0); -} - -void fastrpc_async_domain_deinit(int domain) { - struct fastrpc_async *me = &lasyncinfo[domain]; - int err = 0; - - pthread_mutex_lock(&async_mut); - if (!me->init_done) { - goto fasync_deinit_done; - } - FARF(ALWAYS, "%s: Waiting for AsyncRPC worker thread to join for domain %d\n", - __func__, domain); - if (me->thread) { - me->deinit_started = 1; - err = fastrpc_exit_async_thread(domain); - if (err) { - pthread_kill(me->thread, SIGUSR1); - } - pthread_join(me->thread, 0); - me->thread = 0; - } - FARF(ALWAYS, "fastrpc async thread joined for domain %d", domain); - fastrpc_async_respond_all_pending_jobs(domain); - pthread_mutex_destroy(&me->mut); - me->init_done = 0; -fasync_deinit_done: - pthread_mutex_unlock(&async_mut); - return; -} - -int fastrpc_async_domain_init(int domain) { - struct fastrpc_async *me = &lasyncinfo[domain]; - int nErr = AEE_EUNKNOWN, i = 0; - struct sigaction siga; - uint32_t capability = 0; - - pthread_mutex_lock(&async_mut); - if (me->init_done) { - nErr = AEE_SUCCESS; - goto bail; - } - VERIFY(AEE_SUCCESS == - (nErr = fastrpc_get_cap(domain, ASYNC_FASTRPC_SUPPORT, &capability))); - VERIFYC(capability == 1, AEE_EUNSUPPORTED); - me->thread = 0; - pthread_mutex_init(&me->mut, 0); - for (i = 0; i < FASTRPC_ASYNC_QUEUE_LIST_LEN; i++) { - QList_Ctor(&me->ql[i]); - } - VERIFY(AEE_SUCCESS == - (nErr = pthread_create(&me->thread, 0, async_fastrpc_thread, - (void *)me))); - memset(&siga, 0, sizeof(siga)); - siga.sa_flags = 0; - siga.sa_handler = async_thread_exit_handler; - VERIFY(AEE_SUCCESS == (nErr = sigaction(SIGUSR1, &siga, NULL))); - me->init_done = 1; - me->deinit_started = 0; - FARF(ALWAYS, "%s: AsyncRPC worker thread launched for domain %d\n", __func__, - domain); -bail: - pthread_mutex_unlock(&async_mut); - if (nErr != AEE_SUCCESS) { - VERIFY_EPRINTF("Error 0x%x: %s failed for domain %d (%s)\n", nErr, __func__, - domain, strerror(errno)); - fastrpc_async_domain_deinit(domain); - } - return nErr; -} - -/* - * Internal function to get async response from kernel. Waits in kernel until - * response is received from DSP - * @ domain: domain to which Async job is submitted - * @ async_data: IOCTL structure that is sent to kernel to get async response - * job information returns 0 on success - * - */ -static int get_remote_async_response(int domain, fastrpc_async_jobid *jobid, - int *result) { - int nErr = AEE_SUCCESS, dev = -1; - uint64_t *perf_kernel = NULL, *perf_dsp = NULL; - fastrpc_async_jobid job = -1; - int res = -1; - remote_handle handle = -1; - uint32_t sc = 0; - - VERIFYC(IS_VALID_EFFECTIVE_DOMAIN_ID(domain), AEE_EBADPARM); - VERIFY(AEE_SUCCESS == (nErr = fastrpc_session_dev(domain, &dev))); - VERIFYM(-1 != dev, AEE_ERPC, "open dev failed\n"); - if (is_kernel_perf_enabled()) { - perf_kernel = (uint64_t *)calloc(PERF_KERNEL_KEY_MAX, sizeof(uint64_t)); - VERIFYC(perf_kernel != NULL, AEE_ENOMEMORY); - } - if (is_dsp_perf_enabled(domain)) { - perf_dsp = (uint64_t *)calloc(PERF_DSP_KEY_MAX, sizeof(uint64_t)); - VERIFYC(perf_dsp != NULL, AEE_ENOMEMORY); - } - nErr = ioctl_invoke2_response(dev, &job, &handle, &sc, &res, perf_kernel, - perf_dsp); - if (perf_kernel) { - FARF(ALWAYS, - "RPCPERF-K H:0x%x SC:0x%x C:%" PRIu64 " F:%" PRIu64 " ns M:%" PRIu64 - " ns CP:%" PRIu64 " ns L:%" PRIu64 " ns G:%" PRIu64 " ns P:%" PRIu64 - " ns INV:%" PRIu64 " ns INVOKE:%" PRIu64 " ns\n", - handle, sc, perf_kernel[0], perf_kernel[1], perf_kernel[2], - perf_kernel[3], perf_kernel[4], perf_kernel[5], perf_kernel[6], - perf_kernel[7], perf_kernel[8]); - } - if (perf_dsp) { - FARF(ALWAYS, - "RPCPERF-D H:0x%x SC:0x%x C:%" PRIu64 " M_H:%" PRIu64 " us M:%" PRIu64 - " us G:%" PRIu64 " us INVOKE:%" PRIu64 " us P:%" PRIu64 - " us CACHE:%" PRIu64 " us UM:%" PRIu64 " us " - "UM_H:%" PRIu64 " us R:%" PRIu64 " us E_R:%" PRIu64 - " us J_S_T:%" PRIu64 " us\n", - handle, sc, perf_dsp[0], perf_dsp[1], perf_dsp[2], perf_dsp[3], - perf_dsp[4], perf_dsp[5], perf_dsp[6], perf_dsp[7], perf_dsp[8], - perf_dsp[9], perf_dsp[10], perf_dsp[11]); - } - *jobid = job; - *result = res; - -bail: - if (perf_kernel) { - free(perf_kernel); - perf_kernel = NULL; - } - if (perf_dsp) { - free(perf_dsp); - perf_dsp = NULL; - } - if (nErr) { - FARF(ERROR, - "Error 0x%x: %s failed to get async response data for domain %d errno " - "%s", - nErr, __func__, domain, strerror(errno)); - } - return nErr; -} - -// Make IOCTL call to exit async thread -int fastrpc_exit_async_thread(int domain) { - int nErr = AEE_SUCCESS, dev; - - VERIFY(AEE_SUCCESS == (nErr = fastrpc_session_dev(domain, &dev))); - nErr = ioctl_control(dev, DSPRPC_ASYNC_WAKE, NULL); -bail: - if (nErr) - FARF(ERROR, - "Error 0x%x: %s failed for domain %d (errno: %s), ignore if ioctl not " - "supported, try pthread kill ", - nErr, __func__, domain, strerror(errno)); - return nErr; -} diff --git a/src/fastrpc_cap.c b/src/fastrpc_cap.c index 0ad169ed..c088a747 100644 --- a/src/fastrpc_cap.c +++ b/src/fastrpc_cap.c @@ -108,12 +108,6 @@ int fastrpc_get_cap(uint32_t domain, uint32_t attributeID, uint32_t *capability) } goto bail; } - if(attributeID == ASYNC_FASTRPC_SUPPORT) { - if(!is_async_fastrpc_supported() ) { - *capability = 0; - goto bail; - } - } VERIFY(AEE_SUCCESS == (nErr = fastrpc_session_open(dom, &dev))); errno = 0; diff --git a/src/fastrpc_ioctl.c b/src/fastrpc_ioctl.c index e0329e13..560c9eb6 100644 --- a/src/fastrpc_ioctl.c +++ b/src/fastrpc_ioctl.c @@ -5,18 +5,11 @@ #include "AEEStdErr.h" #include "HAP_farf.h" -#include "fastrpc_async.h" #include "fastrpc_internal.h" #include "fastrpc_notif.h" #include "remote.h" #include -/* check async support */ -int is_async_fastrpc_supported(void) { - /* async not supported by upstream driver */ - return 0; -} - /* Returns the name of the domain based on the following ADSP/SLPI/MDSP/CDSP - Return Secure node */ @@ -91,7 +84,7 @@ int ioctl_init(int dev, uint32_t flags, int attr, unsigned char *shell, int shel } 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, + int *fds, unsigned int *attrs, unsigned int *crc, uint64_t *perf_kernel, uint64_t *perf_dsp) { int ioErr = AEE_SUCCESS; struct fastrpc_ioctl_invoke invoke = {0}; @@ -107,12 +100,6 @@ int ioctl_invoke(int dev, int req, remote_handle handle, uint32_t sc, void *pra, return ioErr; } -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) { - return AEE_EUNSUPPORTED; -} - int ioctl_invoke2_notif(int dev, int *domain, int *session, int *status) { return AEE_EUNSUPPORTED; } diff --git a/src/symbols.lst b/src/symbols.lst index 05f6adb9..6e6bfd1f 100644 --- a/src/symbols.lst +++ b/src/symbols.lst @@ -34,10 +34,6 @@ rpcmem_alloc2; rpcmem_free; rpcmem_to_fd; - remote_handle_invoke_async; - remote_handle64_invoke_async; - fastrpc_async_get_status; - fastrpc_release_async_job; dspqueue_create; dspqueue_close; dspqueue_export;