Skip to content

Commit 3512dc8

Browse files
Abhishek SinghEkansh
authored andcommitted
Do not allocate a handle for the staticPD configuration
Handles are allocated while configuring the staticPD information; however, these handles are not used to communicate with the DSP. Therefore, there is no point in allocating these handles; instead, return predefined values for these handles. Signed-off-by: Abhishek Singh <abhishes@qti.qualcomm.com>
1 parent 1f93b9b commit 3512dc8

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

inc/fastrpc_apps_user.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,22 @@
2020
#define __CONSTRUCTOR_ATTRIBUTE__ __attribute__((constructor))
2121
#endif
2222

23+
/* Verify if the handle is configured for staticPD. */
24+
#define IS_STATICPD_HANDLE(h) ((h > 0xff) && (h <= 0x200))
25+
26+
/*
27+
* Enum defined for static PD handles.
28+
* The range for constant handles is <0,255>,
29+
* and the range for staticPD handles is <256,512>
30+
*/
31+
typedef enum {
32+
OISPD_HANDLE = 256,
33+
AUDIOPD_HANDLE = 257,
34+
SENSORPD_HANDLE = 258,
35+
ATTACHGUESTOS_HANDLE = 259,
36+
ROOTPD_HANDLE = 260,
37+
SECUREPD_HANDLE = 261
38+
} static_pd_handle;
2339
/*
2440
* API to initialize rpcmem data structures for ION allocation
2541
*/

src/fastrpc_apps_user.c

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1506,6 +1506,13 @@ int remote_handle64_invoke(remote_handle64 local, uint32_t sc,
15061506
int nErr = AEE_SUCCESS, domain = -1, ref = 0;
15071507
struct handle_info *h = (struct handle_info*)local;
15081508

1509+
if (IS_STATICPD_HANDLE(local)) {
1510+
nErr = AEE_EINVHANDLE;
1511+
FARF(ERROR, "Error 0x%x: %s cannot be called for staticPD handle 0x%"PRIx64"\n",
1512+
nErr, __func__, local);
1513+
goto bail;
1514+
}
1515+
15091516
VERIFY(AEE_SUCCESS == (nErr = fastrpc_init_once()));
15101517

15111518
FASTRPC_ATRACE_BEGIN_L("%s called with handle 0x%x , scalar 0x%x", __func__,
@@ -1632,6 +1639,7 @@ int remote_handle_open_domain(int domain, const char *name, remote_handle *ph,
16321639
if (!std_strncmp(name, ITRANSPORT_PREFIX "attachguestos",
16331640
std_strlen(ITRANSPORT_PREFIX "attachguestos"))) {
16341641
FARF(RUNTIME_RPC_HIGH, "setting attach mode to guestos : %d", domain);
1642+
*ph = ATTACHGUESTOS_HANDLE;
16351643
hlist[domain].dsppd = ROOT_PD;
16361644
return AEE_SUCCESS;
16371645
}
@@ -1666,15 +1674,20 @@ int remote_handle_open_domain(int domain, const char *name, remote_handle *ph,
16661674
VERIFYC(MAX_DSPPD_NAMELEN > std_strlen(pdName), AEE_EBADPARM);
16671675
std_strlcpy(hlist[domain].dsppdname, pdName, std_strlen(pdName) + 1);
16681676
if (!std_strncmp(pdName, "audiopd", std_strlen("audiopd"))) {
1677+
*ph = AUDIOPD_HANDLE;
16691678
hlist[domain].dsppd = AUDIO_STATICPD;
16701679
} else if (!std_strncmp(pdName, "securepd", std_strlen("securepd"))) {
16711680
FARF(ALWAYS, "%s: attaching to securePD\n", __func__);
1681+
*ph = SECUREPD_HANDLE;
16721682
hlist[domain].dsppd = SECURE_STATICPD;
16731683
} else if (!std_strncmp(pdName, "sensorspd", std_strlen("sensorspd"))) {
1684+
*ph = SENSORPD_HANDLE;
16741685
hlist[domain].dsppd = SENSORS_STATICPD;
16751686
} else if (!std_strncmp(pdName, "rootpd", std_strlen("rootpd"))) {
1687+
*ph = ROOTPD_HANDLE;
16761688
hlist[domain].dsppd = GUEST_OS_SHARED;
16771689
} else if (!std_strncmp(pdName, "oispd", std_strlen("oispd"))) {
1690+
*ph = OISPD_HANDLE;
16781691
hlist[domain].dsppd = OIS_STATICPD;
16791692
}
16801693
return AEE_SUCCESS;
@@ -1801,7 +1814,8 @@ int remote_handle64_open(const char *name, remote_handle64 *ph) {
18011814
polls on it, hence return remote handle (which is the actual fd) for
18021815
"geteventd" call*/
18031816
if (!std_strncmp(name, ITRANSPORT_PREFIX "geteventfd",
1804-
std_strlen(ITRANSPORT_PREFIX "geteventfd"))) {
1817+
std_strlen(ITRANSPORT_PREFIX "geteventfd")) ||
1818+
IS_STATICPD_HANDLE(h)) {
18051819
*ph = h;
18061820
} else {
18071821
fastrpc_update_module_list(DOMAIN_LIST_PREPEND, domain, h, &local, name);
@@ -1916,6 +1930,8 @@ int remote_handle64_close(remote_handle64 handle) {
19161930
bool start_deinit = false;
19171931
struct handle_info *hi = (struct handle_info*)handle;
19181932

1933+
if (IS_STATICPD_HANDLE(handle))
1934+
return AEE_SUCCESS;
19191935
FARF(RUNTIME_RPC_HIGH, "Entering %s, handle %llu\n", __func__, handle);
19201936
FASTRPC_ATRACE_BEGIN_L("%s called with handle 0x%" PRIx64 "\n", __func__,
19211937
handle);

0 commit comments

Comments
 (0)