Skip to content
Open
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
18 changes: 0 additions & 18 deletions inc/fastrpc_ioctl.h
Original file line number Diff line number Diff line change
Expand Up @@ -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); \
Expand Down
23 changes: 13 additions & 10 deletions src/adsp_default_listener.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

okay, I checked and this function cannot be removed. The reason is that some old platform use non-secure devices for daemons(if non-secure-domain property is added in DT).

You can just rename the function as get_non_secure_device_name and modify the default: case here.

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) {
Expand All @@ -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;
}

Expand All @@ -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;
Expand All @@ -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;
Copy link
Contributor

Choose a reason for hiding this comment

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

check for non-secure device also to maintain backward compatibility

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();
Expand All @@ -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));
Expand Down Expand Up @@ -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. */
Expand Down
27 changes: 6 additions & 21 deletions src/fastrpc_apps_user.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand All @@ -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:
Expand All @@ -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;
Expand Down
4 changes: 2 additions & 2 deletions src/fastrpc_ioctl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;
Expand Down
Binary file added src/gdsprpcd
Binary file not shown.
Loading