diff --git a/inc/fastrpc_ioctl.h b/inc/fastrpc_ioctl.h index 779d0345..b9cee804 100644 --- a/inc/fastrpc_ioctl.h +++ b/inc/fastrpc_ioctl.h @@ -43,24 +43,6 @@ #define FASTRPC_ATTR_NOVA (256) -/* Secure and default device nodes */ -#if DEFAULT_DOMAIN_ID==ADSP_DOMAIN_ID - #define SECURE_DEVICE "/dev/fastrpc-adsp-secure" - #define DEFAULT_DEVICE "/dev/fastrpc-adsp" -#elif DEFAULT_DOMAIN_ID==MDSP_DOMAIN_ID - #define SECURE_DEVICE "/dev/fastrpc-mdsp-secure" - #define DEFAULT_DEVICE "/dev/fastrpc-mdsp" -#elif DEFAULT_DOMAIN_ID==SDSP_DOMAIN_ID - #define SECURE_DEVICE "/dev/fastrpc-sdsp-secure" - #define DEFAULT_DEVICE "/dev/fastrpc-sdsp" -#elif DEFAULT_DOMAIN_ID==CDSP_DOMAIN_ID - #define SECURE_DEVICE "/dev/fastrpc-cdsp-secure" - #define DEFAULT_DEVICE "/dev/fastrpc-cdsp" -#else - #define SECURE_DEVICE "" - #define DEFAULT_DEVICE "" -#endif - #define INITIALIZE_REMOTE_ARGS(total) int *pfds = NULL; \ unsigned *pattrs = NULL; \ args = (struct fastrpc_invoke_args*) calloc(sizeof(*args), total); \ diff --git a/src/adsp_default_listener.c b/src/adsp_default_listener.c index e37648ae..901018dd 100644 --- a/src/adsp_default_listener.c +++ b/src/adsp_default_listener.c @@ -71,7 +71,7 @@ static domain_t *get_domain_uri(int domain_id) { } static const char *get_secure_device_name(int domain_id) { - const char *name; + const char *name = NULL; int domain = GET_DOMAIN_FROM_EFFEC_DOMAIN_ID(domain_id); switch (domain) { @@ -97,15 +97,15 @@ static const char *get_secure_device_name(int domain_id) { name = GDSP1_SECURE_DEVICE_NAME; break; default: - name = DEFAULT_DEVICE; + FARF(ERROR, "ERROR: %s Invalid domain_id %d", __func__, domain_id); break; } return name; } -static const char *get_default_device_name(int domain_id) { - const char *name; +static const char *get_non_secure_device_name(int domain_id) { + const char *name = NULL; int domain = GET_DOMAIN_FROM_EFFEC_DOMAIN_ID(domain_id); switch (domain) { @@ -131,7 +131,7 @@ static const char *get_default_device_name(int domain_id) { name = GDSP1_DEVICE_NAME; break; default: - name = DEFAULT_DEVICE; + FARF(ERROR, "ERROR: %s Invalid domain_id %d", __func__, domain_id); break; } @@ -152,6 +152,9 @@ static bool fastrpc_dev_exists(const char* dev_name) char *path = NULL; uint64_t len; + if (!dev_name) + return false; + len = snprintf(0, 0, "/dev/%s", dev_name) + 1; if(NULL == (path = (char *)malloc(len * sizeof(char)))) return false; @@ -172,13 +175,13 @@ static bool fastrpc_dev_exists(const char* dev_name) static int fastrpc_wait_for_device(int domain) { int inotify_fd = -1, watch_fd = -1, err = 0; - const char *sec_dev_name = NULL, *def_dev_name = NULL; + const char *sec_dev_name = NULL, *non_sec_dev_name = NULL; struct pollfd pfd[1]; sec_dev_name = get_secure_device_name(domain); - def_dev_name = get_default_device_name(domain); + non_sec_dev_name = get_non_secure_device_name(domain); - if (fastrpc_dev_exists(sec_dev_name) || fastrpc_dev_exists(def_dev_name)) + if (fastrpc_dev_exists(sec_dev_name) || fastrpc_dev_exists(non_sec_dev_name)) return 0; inotify_fd = inotify_init(); @@ -194,7 +197,7 @@ static int fastrpc_wait_for_device(int domain) return AEE_EINVALIDFD; } - if (fastrpc_dev_exists(sec_dev_name) || fastrpc_dev_exists(def_dev_name)) + if (fastrpc_dev_exists(sec_dev_name) || fastrpc_dev_exists(non_sec_dev_name)) goto bail; memset(pfd, 0 , sizeof(pfd)); @@ -231,7 +234,7 @@ static int fastrpc_wait_for_device(int domain) /* Check if the event corresponds to the creation of the device node. */ if (event->wd == watch_fd && (event->mask & IN_CREATE) && ((strcmp(sec_dev_name, event->name) == 0) || - (strcmp(def_dev_name, event->name) == 0))) { + (strcmp(non_sec_dev_name, event->name) == 0))) { /* Device node created, process proceed to open and use it. */ VERIFY_IPRINTF("Device node %s created!\n", event->name); goto bail; /* Exit the loop after device creation is detected. */ diff --git a/src/fastrpc_apps_user.c b/src/fastrpc_apps_user.c index 81fef0ab..4ada79aa 100644 --- a/src/fastrpc_apps_user.c +++ b/src/fastrpc_apps_user.c @@ -3254,7 +3254,7 @@ static void domain_deinit(int domain) { } static const char *get_domain_name(int domain_id) { - const char *name; + const char *name = NULL; int domain = GET_DOMAIN_FROM_EFFEC_DOMAIN_ID(domain_id); switch (domain) { @@ -3280,7 +3280,7 @@ static const char *get_domain_name(int domain_id) { name = GDSP1RPC_DEVICE; break; default: - name = DEFAULT_DEVICE; + FARF(ERROR, "ERROR: %s Invalid domain_id %d", __func__, domain_id); break; } return name; @@ -3305,20 +3305,9 @@ int open_device_node(int domain_id) { dev = open(get_domain_name(domain), O_NONBLOCK); if ((dev < 0) && (errno == ENOENT)) { FARF(RUNTIME_RPC_HIGH, - "Device node %s open failed for domain %d (errno %s)," - "falling back to node %s \n", - get_domain_name(domain), domain, strerror(errno), DEFAULT_DEVICE); - dev = open(DEFAULT_DEVICE, O_NONBLOCK); + "Device node %s open failed for domain %d (errno %s)\n", + get_domain_name(domain), domain, strerror(errno)); } - } else if ((dev < 0) && (errno == EACCES)) { - // Open the default device node if unable to open the - // secure device node due to permissions - FARF(RUNTIME_RPC_HIGH, - "Device node %s open failed for domain %d (errno %s)," - "falling back to node %s \n", - get_secure_domain_name(domain), domain, strerror(errno), - DEFAULT_DEVICE); - dev = open(DEFAULT_DEVICE, O_NONBLOCK); } break; case CDSP_DOMAIN_ID: @@ -3334,13 +3323,9 @@ int open_device_node(int domain_id) { get_domain_name(domain)); dev = open(get_domain_name(domain), O_NONBLOCK); if ((dev < 0) && ((errno == ENOENT) || (errno == EACCES))) { - // Open the default device node if actual device node - // is not present FARF(RUNTIME_RPC_HIGH, - "Device node %s open failed for domain %d (errno %s)," - "falling back to node %s \n", - get_domain_name(domain), domain, strerror(errno), DEFAULT_DEVICE); - dev = open(DEFAULT_DEVICE, O_NONBLOCK); + "Device node %s open failed for domain %d (errno %s)\n", + get_domain_name(domain), domain, strerror(errno)); } } break; diff --git a/src/fastrpc_ioctl.c b/src/fastrpc_ioctl.c index e0329e13..13e43782 100644 --- a/src/fastrpc_ioctl.c +++ b/src/fastrpc_ioctl.c @@ -21,7 +21,7 @@ int is_async_fastrpc_supported(void) { ADSP/SLPI/MDSP/CDSP - Return Secure node */ const char *get_secure_domain_name(int domain_id) { - const char *name; + const char *name = NULL; int domain = GET_DOMAIN_FROM_EFFEC_DOMAIN_ID(domain_id); switch (domain) { @@ -47,7 +47,7 @@ const char *get_secure_domain_name(int domain_id) { name = GDSP1RPC_SECURE_DEVICE; break; default: - name = DEFAULT_DEVICE; + FARF(ERROR, "ERROR: %s Invalid domain_id %d", __func__, domain_id); break; } return name; diff --git a/src/gdsprpcd b/src/gdsprpcd new file mode 100755 index 00000000..8408b100 Binary files /dev/null and b/src/gdsprpcd differ