staging: tidspbridge: rmgr/node.c code cleanup
Reorganized some code in rmgr/node.c to increase its readability. Most of the changes reduce the code indentation level and simplifiy the code. No functional changes were done. Signed-off-by: Ionut Nicu <ionut.nicu@mindbit.ro> Signed-off-by: Omar Ramirez Luna <omar.ramirez@ti.com>
This commit is contained in:
parent
a994b051b6
commit
57104f0fbe
|
@ -236,9 +236,9 @@ struct node_object {
|
||||||
|
|
||||||
/* Default buffer attributes */
|
/* Default buffer attributes */
|
||||||
static struct dsp_bufferattr node_dfltbufattrs = {
|
static struct dsp_bufferattr node_dfltbufattrs = {
|
||||||
0, /* cb_struct */
|
.cb_struct = 0,
|
||||||
1, /* segment_id */
|
.segment_id = 1,
|
||||||
0, /* buf_alignment */
|
.buf_alignment = 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
static void delete_node(struct node_object *hnode,
|
static void delete_node(struct node_object *hnode,
|
||||||
|
@ -284,8 +284,7 @@ enum node_state node_get_state(void *hnode)
|
||||||
struct node_object *pnode = (struct node_object *)hnode;
|
struct node_object *pnode = (struct node_object *)hnode;
|
||||||
if (!pnode)
|
if (!pnode)
|
||||||
return -1;
|
return -1;
|
||||||
else
|
return pnode->node_state;
|
||||||
return pnode->node_state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -844,6 +843,7 @@ int node_connect(struct node_object *node1, u32 stream1,
|
||||||
char *pstr_dev_name = NULL;
|
char *pstr_dev_name = NULL;
|
||||||
enum node_type node1_type = NODE_TASK;
|
enum node_type node1_type = NODE_TASK;
|
||||||
enum node_type node2_type = NODE_TASK;
|
enum node_type node2_type = NODE_TASK;
|
||||||
|
enum dsp_strmmode strm_mode;
|
||||||
struct node_strmdef *pstrm_def;
|
struct node_strmdef *pstrm_def;
|
||||||
struct node_strmdef *input = NULL;
|
struct node_strmdef *input = NULL;
|
||||||
struct node_strmdef *output = NULL;
|
struct node_strmdef *output = NULL;
|
||||||
|
@ -857,60 +857,49 @@ int node_connect(struct node_object *node1, u32 stream1,
|
||||||
int status = 0;
|
int status = 0;
|
||||||
DBC_REQUIRE(refs > 0);
|
DBC_REQUIRE(refs > 0);
|
||||||
|
|
||||||
if ((node1 != (struct node_object *)DSP_HGPPNODE && !node1) ||
|
if (!node1 || !node2)
|
||||||
(node2 != (struct node_object *)DSP_HGPPNODE && !node2))
|
return -EFAULT;
|
||||||
status = -EFAULT;
|
|
||||||
|
|
||||||
if (!status) {
|
/* The two nodes must be on the same processor */
|
||||||
/* The two nodes must be on the same processor */
|
if (node1 != (struct node_object *)DSP_HGPPNODE &&
|
||||||
if (node1 != (struct node_object *)DSP_HGPPNODE &&
|
node2 != (struct node_object *)DSP_HGPPNODE &&
|
||||||
node2 != (struct node_object *)DSP_HGPPNODE &&
|
node1->hnode_mgr != node2->hnode_mgr)
|
||||||
node1->hnode_mgr != node2->hnode_mgr)
|
return -EPERM;
|
||||||
status = -EPERM;
|
|
||||||
/* Cannot connect a node to itself */
|
|
||||||
if (node1 == node2)
|
|
||||||
status = -EPERM;
|
|
||||||
|
|
||||||
}
|
/* Cannot connect a node to itself */
|
||||||
if (!status) {
|
if (node1 == node2)
|
||||||
/* node_get_type() will return NODE_GPP if hnode =
|
return -EPERM;
|
||||||
* DSP_HGPPNODE. */
|
|
||||||
node1_type = node_get_type(node1);
|
/* node_get_type() will return NODE_GPP if hnode = DSP_HGPPNODE. */
|
||||||
node2_type = node_get_type(node2);
|
node1_type = node_get_type(node1);
|
||||||
/* Check stream indices ranges */
|
node2_type = node_get_type(node2);
|
||||||
if ((node1_type != NODE_GPP && node1_type != NODE_DEVICE &&
|
/* Check stream indices ranges */
|
||||||
stream1 >= MAX_OUTPUTS(node1)) || (node2_type != NODE_GPP
|
if ((node1_type != NODE_GPP && node1_type != NODE_DEVICE &&
|
||||||
&& node2_type !=
|
stream1 >= MAX_OUTPUTS(node1)) ||
|
||||||
NODE_DEVICE
|
(node2_type != NODE_GPP && node2_type != NODE_DEVICE &&
|
||||||
&& stream2 >=
|
stream2 >= MAX_INPUTS(node2)))
|
||||||
MAX_INPUTS(node2)))
|
return -EINVAL;
|
||||||
status = -EINVAL;
|
|
||||||
}
|
/*
|
||||||
if (!status) {
|
* Only the following types of connections are allowed:
|
||||||
/*
|
* task/dais socket < == > task/dais socket
|
||||||
* Only the following types of connections are allowed:
|
* task/dais socket < == > device
|
||||||
* task/dais socket < == > task/dais socket
|
* task/dais socket < == > GPP
|
||||||
* task/dais socket < == > device
|
*
|
||||||
* task/dais socket < == > GPP
|
* ie, no message nodes, and at least one task or dais
|
||||||
*
|
* socket node.
|
||||||
* ie, no message nodes, and at least one task or dais
|
*/
|
||||||
* socket node.
|
if (node1_type == NODE_MESSAGE || node2_type == NODE_MESSAGE ||
|
||||||
*/
|
(node1_type != NODE_TASK &&
|
||||||
if (node1_type == NODE_MESSAGE || node2_type == NODE_MESSAGE ||
|
node1_type != NODE_DAISSOCKET &&
|
||||||
(node1_type != NODE_TASK && node1_type != NODE_DAISSOCKET &&
|
node2_type != NODE_TASK &&
|
||||||
node2_type != NODE_TASK && node2_type != NODE_DAISSOCKET))
|
node2_type != NODE_DAISSOCKET))
|
||||||
status = -EPERM;
|
return -EPERM;
|
||||||
}
|
|
||||||
/*
|
/*
|
||||||
* Check stream mode. Default is STRMMODE_PROCCOPY.
|
* Check stream mode. Default is STRMMODE_PROCCOPY.
|
||||||
*/
|
*/
|
||||||
if (!status && pattrs) {
|
if (pattrs && pattrs->strm_mode != STRMMODE_PROCCOPY)
|
||||||
if (pattrs->strm_mode != STRMMODE_PROCCOPY)
|
return -EPERM; /* illegal stream mode */
|
||||||
status = -EPERM; /* illegal stream mode */
|
|
||||||
|
|
||||||
}
|
|
||||||
if (status)
|
|
||||||
goto func_end;
|
|
||||||
|
|
||||||
if (node1_type != NODE_GPP) {
|
if (node1_type != NODE_GPP) {
|
||||||
hnode_mgr = node1->hnode_mgr;
|
hnode_mgr = node1->hnode_mgr;
|
||||||
|
@ -918,170 +907,145 @@ int node_connect(struct node_object *node1, u32 stream1,
|
||||||
DBC_ASSERT(node2 != (struct node_object *)DSP_HGPPNODE);
|
DBC_ASSERT(node2 != (struct node_object *)DSP_HGPPNODE);
|
||||||
hnode_mgr = node2->hnode_mgr;
|
hnode_mgr = node2->hnode_mgr;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Enter critical section */
|
/* Enter critical section */
|
||||||
mutex_lock(&hnode_mgr->node_mgr_lock);
|
mutex_lock(&hnode_mgr->node_mgr_lock);
|
||||||
|
|
||||||
/* Nodes must be in the allocated state */
|
/* Nodes must be in the allocated state */
|
||||||
if (node1_type != NODE_GPP && node_get_state(node1) != NODE_ALLOCATED)
|
if (node1_type != NODE_GPP &&
|
||||||
|
node_get_state(node1) != NODE_ALLOCATED) {
|
||||||
status = -EBADR;
|
status = -EBADR;
|
||||||
|
goto out_unlock;
|
||||||
|
}
|
||||||
|
|
||||||
if (node2_type != NODE_GPP && node_get_state(node2) != NODE_ALLOCATED)
|
if (node2_type != NODE_GPP &&
|
||||||
|
node_get_state(node2) != NODE_ALLOCATED) {
|
||||||
status = -EBADR;
|
status = -EBADR;
|
||||||
|
goto out_unlock;
|
||||||
|
}
|
||||||
|
|
||||||
if (!status) {
|
/*
|
||||||
/* Check that stream indices for task and dais socket nodes
|
* Check that stream indices for task and dais socket nodes
|
||||||
* are not already be used. (Device nodes checked later) */
|
* are not already be used. (Device nodes checked later)
|
||||||
if (node1_type == NODE_TASK || node1_type == NODE_DAISSOCKET) {
|
*/
|
||||||
output =
|
if (node1_type == NODE_TASK || node1_type == NODE_DAISSOCKET) {
|
||||||
&(node1->create_args.asa.
|
output = &(node1->create_args.asa.
|
||||||
task_arg_obj.strm_out_def[stream1]);
|
task_arg_obj.strm_out_def[stream1]);
|
||||||
if (output->sz_device != NULL)
|
if (output->sz_device) {
|
||||||
status = -EISCONN;
|
status = -EISCONN;
|
||||||
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
if (node2_type == NODE_TASK || node2_type == NODE_DAISSOCKET) {
|
|
||||||
input =
|
|
||||||
&(node2->create_args.asa.
|
|
||||||
task_arg_obj.strm_in_def[stream2]);
|
|
||||||
if (input->sz_device != NULL)
|
|
||||||
status = -EISCONN;
|
|
||||||
|
|
||||||
|
}
|
||||||
|
if (node2_type == NODE_TASK || node2_type == NODE_DAISSOCKET) {
|
||||||
|
input = &(node2->create_args.asa.
|
||||||
|
task_arg_obj.strm_in_def[stream2]);
|
||||||
|
if (input->sz_device) {
|
||||||
|
status = -EISCONN;
|
||||||
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
/* Connecting two task nodes? */
|
/* Connecting two task nodes? */
|
||||||
if (!status && ((node1_type == NODE_TASK ||
|
if ((node1_type == NODE_TASK || node1_type == NODE_DAISSOCKET) &&
|
||||||
node1_type == NODE_DAISSOCKET)
|
(node2_type == NODE_TASK ||
|
||||||
&& (node2_type == NODE_TASK
|
node2_type == NODE_DAISSOCKET)) {
|
||||||
|| node2_type == NODE_DAISSOCKET))) {
|
|
||||||
/* Find available pipe */
|
/* Find available pipe */
|
||||||
pipe_id = find_first_zero_bit(hnode_mgr->pipe_map, MAXPIPES);
|
pipe_id = find_first_zero_bit(hnode_mgr->pipe_map, MAXPIPES);
|
||||||
if (pipe_id == MAXPIPES) {
|
if (pipe_id == MAXPIPES) {
|
||||||
status = -ECONNREFUSED;
|
status = -ECONNREFUSED;
|
||||||
} else {
|
goto out_unlock;
|
||||||
set_bit(pipe_id, hnode_mgr->pipe_map);
|
|
||||||
node1->outputs[stream1].type = NODECONNECT;
|
|
||||||
node2->inputs[stream2].type = NODECONNECT;
|
|
||||||
node1->outputs[stream1].dev_id = pipe_id;
|
|
||||||
node2->inputs[stream2].dev_id = pipe_id;
|
|
||||||
output->sz_device = kzalloc(PIPENAMELEN + 1,
|
|
||||||
GFP_KERNEL);
|
|
||||||
input->sz_device = kzalloc(PIPENAMELEN + 1, GFP_KERNEL);
|
|
||||||
if (output->sz_device == NULL ||
|
|
||||||
input->sz_device == NULL) {
|
|
||||||
/* Undo the connection */
|
|
||||||
kfree(output->sz_device);
|
|
||||||
|
|
||||||
kfree(input->sz_device);
|
|
||||||
|
|
||||||
output->sz_device = NULL;
|
|
||||||
input->sz_device = NULL;
|
|
||||||
clear_bit(pipe_id, hnode_mgr->pipe_map);
|
|
||||||
status = -ENOMEM;
|
|
||||||
} else {
|
|
||||||
/* Copy "/dbpipe<pipId>" name to device names */
|
|
||||||
sprintf(output->sz_device, "%s%d",
|
|
||||||
PIPEPREFIX, pipe_id);
|
|
||||||
strcpy(input->sz_device, output->sz_device);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
set_bit(pipe_id, hnode_mgr->pipe_map);
|
||||||
|
node1->outputs[stream1].type = NODECONNECT;
|
||||||
|
node2->inputs[stream2].type = NODECONNECT;
|
||||||
|
node1->outputs[stream1].dev_id = pipe_id;
|
||||||
|
node2->inputs[stream2].dev_id = pipe_id;
|
||||||
|
output->sz_device = kzalloc(PIPENAMELEN + 1, GFP_KERNEL);
|
||||||
|
input->sz_device = kzalloc(PIPENAMELEN + 1, GFP_KERNEL);
|
||||||
|
if (!output->sz_device || !input->sz_device) {
|
||||||
|
/* Undo the connection */
|
||||||
|
kfree(output->sz_device);
|
||||||
|
kfree(input->sz_device);
|
||||||
|
clear_bit(pipe_id, hnode_mgr->pipe_map);
|
||||||
|
status = -ENOMEM;
|
||||||
|
goto out_unlock;
|
||||||
|
}
|
||||||
|
/* Copy "/dbpipe<pipId>" name to device names */
|
||||||
|
sprintf(output->sz_device, "%s%d", PIPEPREFIX, pipe_id);
|
||||||
|
strcpy(input->sz_device, output->sz_device);
|
||||||
}
|
}
|
||||||
/* Connecting task node to host? */
|
/* Connecting task node to host? */
|
||||||
if (!status && (node1_type == NODE_GPP ||
|
if (node1_type == NODE_GPP || node2_type == NODE_GPP) {
|
||||||
node2_type == NODE_GPP)) {
|
pstr_dev_name = kzalloc(HOSTNAMELEN + 1, GFP_KERNEL);
|
||||||
if (node1_type == NODE_GPP) {
|
if (!pstr_dev_name) {
|
||||||
chnl_mode = CHNL_MODETODSP;
|
status = -ENOMEM;
|
||||||
} else {
|
goto out_unlock;
|
||||||
DBC_ASSERT(node2_type == NODE_GPP);
|
|
||||||
chnl_mode = CHNL_MODEFROMDSP;
|
|
||||||
}
|
}
|
||||||
/* Reserve a channel id. We need to put the name "/host<id>"
|
|
||||||
|
DBC_ASSERT((node1_type == NODE_GPP) ||
|
||||||
|
(node2_type == NODE_GPP));
|
||||||
|
|
||||||
|
chnl_mode = (node1_type == NODE_GPP) ?
|
||||||
|
CHNL_MODETODSP : CHNL_MODEFROMDSP;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Reserve a channel id. We need to put the name "/host<id>"
|
||||||
* in the node's create_args, but the host
|
* in the node's create_args, but the host
|
||||||
* side channel will not be opened until DSPStream_Open is
|
* side channel will not be opened until DSPStream_Open is
|
||||||
* called for this node. */
|
* called for this node.
|
||||||
if (pattrs) {
|
*/
|
||||||
if (pattrs->strm_mode == STRMMODE_RDMA) {
|
strm_mode = pattrs ? pattrs->strm_mode : STRMMODE_PROCCOPY;
|
||||||
chnl_id = find_first_zero_bit(
|
switch (strm_mode) {
|
||||||
hnode_mgr->dma_chnl_map,
|
case STRMMODE_RDMA:
|
||||||
CHNL_MAXCHANNELS);
|
chnl_id = find_first_zero_bit(hnode_mgr->dma_chnl_map,
|
||||||
|
CHNL_MAXCHANNELS);
|
||||||
|
if (chnl_id < CHNL_MAXCHANNELS) {
|
||||||
|
set_bit(chnl_id, hnode_mgr->dma_chnl_map);
|
||||||
/* dma chans are 2nd transport chnl set
|
/* dma chans are 2nd transport chnl set
|
||||||
* ids(e.g. 16-31) */
|
* ids(e.g. 16-31) */
|
||||||
if (chnl_id != CHNL_MAXCHANNELS) {
|
chnl_id = chnl_id + hnode_mgr->ul_num_chnls;
|
||||||
set_bit(chnl_id,
|
}
|
||||||
hnode_mgr->dma_chnl_map);
|
break;
|
||||||
chnl_id = chnl_id +
|
case STRMMODE_ZEROCOPY:
|
||||||
hnode_mgr->ul_num_chnls;
|
chnl_id = find_first_zero_bit(hnode_mgr->zc_chnl_map,
|
||||||
}
|
CHNL_MAXCHANNELS);
|
||||||
} else if (pattrs->strm_mode == STRMMODE_ZEROCOPY) {
|
if (chnl_id < CHNL_MAXCHANNELS) {
|
||||||
chnl_id = find_first_zero_bit(
|
set_bit(chnl_id, hnode_mgr->zc_chnl_map);
|
||||||
hnode_mgr->zc_chnl_map,
|
|
||||||
CHNL_MAXCHANNELS);
|
|
||||||
/* zero-copy chans are 3nd transport set
|
/* zero-copy chans are 3nd transport set
|
||||||
* (e.g. 32-47) */
|
* (e.g. 32-47) */
|
||||||
if (chnl_id != CHNL_MAXCHANNELS) {
|
chnl_id = chnl_id +
|
||||||
set_bit(chnl_id,
|
(2 * hnode_mgr->ul_num_chnls);
|
||||||
hnode_mgr->zc_chnl_map);
|
|
||||||
chnl_id = chnl_id +
|
|
||||||
(2 * hnode_mgr->ul_num_chnls);
|
|
||||||
}
|
|
||||||
} else { /* must be PROCCOPY */
|
|
||||||
DBC_ASSERT(pattrs->strm_mode ==
|
|
||||||
STRMMODE_PROCCOPY);
|
|
||||||
chnl_id = find_first_zero_bit(
|
|
||||||
hnode_mgr->chnl_map,
|
|
||||||
CHNL_MAXCHANNELS);
|
|
||||||
/* e.g. 0-15 */
|
|
||||||
if (chnl_id != CHNL_MAXCHANNELS)
|
|
||||||
set_bit(chnl_id, hnode_mgr->chnl_map);
|
|
||||||
}
|
}
|
||||||
} else {
|
break;
|
||||||
/* default to PROCCOPY */
|
case STRMMODE_PROCCOPY:
|
||||||
chnl_id = find_first_zero_bit(hnode_mgr->chnl_map,
|
chnl_id = find_first_zero_bit(hnode_mgr->chnl_map,
|
||||||
CHNL_MAXCHANNELS);
|
CHNL_MAXCHANNELS);
|
||||||
if (chnl_id != CHNL_MAXCHANNELS)
|
if (chnl_id < CHNL_MAXCHANNELS)
|
||||||
set_bit(chnl_id, hnode_mgr->chnl_map);
|
set_bit(chnl_id, hnode_mgr->chnl_map);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
status = -EINVAL;
|
||||||
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
if (chnl_id == CHNL_MAXCHANNELS) {
|
if (chnl_id == CHNL_MAXCHANNELS) {
|
||||||
status = -ECONNREFUSED;
|
status = -ECONNREFUSED;
|
||||||
goto func_cont2;
|
goto out_unlock;
|
||||||
}
|
}
|
||||||
pstr_dev_name = kzalloc(HOSTNAMELEN + 1, GFP_KERNEL);
|
|
||||||
if (pstr_dev_name != NULL)
|
|
||||||
goto func_cont2;
|
|
||||||
|
|
||||||
if (pattrs) {
|
if (node1 == (struct node_object *)DSP_HGPPNODE) {
|
||||||
if (pattrs->strm_mode == STRMMODE_RDMA) {
|
node2->inputs[stream2].type = HOSTCONNECT;
|
||||||
clear_bit(chnl_id - hnode_mgr->ul_num_chnls,
|
node2->inputs[stream2].dev_id = chnl_id;
|
||||||
hnode_mgr->dma_chnl_map);
|
input->sz_device = pstr_dev_name;
|
||||||
} else if (pattrs->strm_mode == STRMMODE_ZEROCOPY) {
|
|
||||||
clear_bit(chnl_id -
|
|
||||||
(2 * hnode_mgr->ul_num_chnls),
|
|
||||||
hnode_mgr->zc_chnl_map);
|
|
||||||
} else {
|
|
||||||
DBC_ASSERT(pattrs->strm_mode ==
|
|
||||||
STRMMODE_PROCCOPY);
|
|
||||||
clear_bit(chnl_id, hnode_mgr->chnl_map);
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
clear_bit(chnl_id, hnode_mgr->chnl_map);
|
node1->outputs[stream1].type = HOSTCONNECT;
|
||||||
}
|
node1->outputs[stream1].dev_id = chnl_id;
|
||||||
status = -ENOMEM;
|
output->sz_device = pstr_dev_name;
|
||||||
func_cont2:
|
|
||||||
if (!status) {
|
|
||||||
if (node1 == (struct node_object *)DSP_HGPPNODE) {
|
|
||||||
node2->inputs[stream2].type = HOSTCONNECT;
|
|
||||||
node2->inputs[stream2].dev_id = chnl_id;
|
|
||||||
input->sz_device = pstr_dev_name;
|
|
||||||
} else {
|
|
||||||
node1->outputs[stream1].type = HOSTCONNECT;
|
|
||||||
node1->outputs[stream1].dev_id = chnl_id;
|
|
||||||
output->sz_device = pstr_dev_name;
|
|
||||||
}
|
|
||||||
sprintf(pstr_dev_name, "%s%d", HOSTPREFIX, chnl_id);
|
|
||||||
}
|
}
|
||||||
|
sprintf(pstr_dev_name, "%s%d", HOSTPREFIX, chnl_id);
|
||||||
}
|
}
|
||||||
/* Connecting task node to device node? */
|
/* Connecting task node to device node? */
|
||||||
if (!status && ((node1_type == NODE_DEVICE) ||
|
if ((node1_type == NODE_DEVICE) || (node2_type == NODE_DEVICE)) {
|
||||||
(node2_type == NODE_DEVICE))) {
|
|
||||||
if (node2_type == NODE_DEVICE) {
|
if (node2_type == NODE_DEVICE) {
|
||||||
/* node1 == > device */
|
/* node1 == > device */
|
||||||
dev_node_obj = node2;
|
dev_node_obj = node2;
|
||||||
|
@ -1098,60 +1062,58 @@ func_cont2:
|
||||||
/* Set up create args */
|
/* Set up create args */
|
||||||
pstream->type = DEVICECONNECT;
|
pstream->type = DEVICECONNECT;
|
||||||
dw_length = strlen(dev_node_obj->pstr_dev_name);
|
dw_length = strlen(dev_node_obj->pstr_dev_name);
|
||||||
if (conn_param != NULL) {
|
if (conn_param)
|
||||||
pstrm_def->sz_device = kzalloc(dw_length + 1 +
|
pstrm_def->sz_device = kzalloc(dw_length + 1 +
|
||||||
conn_param->cb_data,
|
conn_param->cb_data,
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
} else {
|
else
|
||||||
pstrm_def->sz_device = kzalloc(dw_length + 1,
|
pstrm_def->sz_device = kzalloc(dw_length + 1,
|
||||||
GFP_KERNEL);
|
GFP_KERNEL);
|
||||||
}
|
if (!pstrm_def->sz_device) {
|
||||||
if (pstrm_def->sz_device == NULL) {
|
|
||||||
status = -ENOMEM;
|
status = -ENOMEM;
|
||||||
} else {
|
goto out_unlock;
|
||||||
/* Copy device name */
|
}
|
||||||
strncpy(pstrm_def->sz_device,
|
/* Copy device name */
|
||||||
|
strncpy(pstrm_def->sz_device,
|
||||||
dev_node_obj->pstr_dev_name, dw_length);
|
dev_node_obj->pstr_dev_name, dw_length);
|
||||||
if (conn_param != NULL) {
|
if (conn_param)
|
||||||
strncat(pstrm_def->sz_device,
|
strncat(pstrm_def->sz_device,
|
||||||
(char *)conn_param->node_data,
|
(char *)conn_param->node_data,
|
||||||
(u32) conn_param->cb_data);
|
(u32) conn_param->cb_data);
|
||||||
}
|
dev_node_obj->device_owner = hnode;
|
||||||
dev_node_obj->device_owner = hnode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (!status) {
|
/* Fill in create args */
|
||||||
/* Fill in create args */
|
if (node1_type == NODE_TASK || node1_type == NODE_DAISSOCKET) {
|
||||||
if (node1_type == NODE_TASK || node1_type == NODE_DAISSOCKET) {
|
node1->create_args.asa.task_arg_obj.num_outputs++;
|
||||||
node1->create_args.asa.task_arg_obj.num_outputs++;
|
fill_stream_def(node1, output, pattrs);
|
||||||
fill_stream_def(node1, output, pattrs);
|
|
||||||
}
|
|
||||||
if (node2_type == NODE_TASK || node2_type == NODE_DAISSOCKET) {
|
|
||||||
node2->create_args.asa.task_arg_obj.num_inputs++;
|
|
||||||
fill_stream_def(node2, input, pattrs);
|
|
||||||
}
|
|
||||||
/* Update node1 and node2 stream_connect */
|
|
||||||
if (node1_type != NODE_GPP && node1_type != NODE_DEVICE) {
|
|
||||||
node1->num_outputs++;
|
|
||||||
if (stream1 > node1->max_output_index)
|
|
||||||
node1->max_output_index = stream1;
|
|
||||||
|
|
||||||
}
|
|
||||||
if (node2_type != NODE_GPP && node2_type != NODE_DEVICE) {
|
|
||||||
node2->num_inputs++;
|
|
||||||
if (stream2 > node2->max_input_index)
|
|
||||||
node2->max_input_index = stream2;
|
|
||||||
|
|
||||||
}
|
|
||||||
fill_stream_connect(node1, node2, stream1, stream2);
|
|
||||||
}
|
}
|
||||||
|
if (node2_type == NODE_TASK || node2_type == NODE_DAISSOCKET) {
|
||||||
|
node2->create_args.asa.task_arg_obj.num_inputs++;
|
||||||
|
fill_stream_def(node2, input, pattrs);
|
||||||
|
}
|
||||||
|
/* Update node1 and node2 stream_connect */
|
||||||
|
if (node1_type != NODE_GPP && node1_type != NODE_DEVICE) {
|
||||||
|
node1->num_outputs++;
|
||||||
|
if (stream1 > node1->max_output_index)
|
||||||
|
node1->max_output_index = stream1;
|
||||||
|
|
||||||
|
}
|
||||||
|
if (node2_type != NODE_GPP && node2_type != NODE_DEVICE) {
|
||||||
|
node2->num_inputs++;
|
||||||
|
if (stream2 > node2->max_input_index)
|
||||||
|
node2->max_input_index = stream2;
|
||||||
|
|
||||||
|
}
|
||||||
|
fill_stream_connect(node1, node2, stream1, stream2);
|
||||||
/* end of sync_enter_cs */
|
/* end of sync_enter_cs */
|
||||||
/* Exit critical section */
|
/* Exit critical section */
|
||||||
|
out_unlock:
|
||||||
|
if (status && pstr_dev_name)
|
||||||
|
kfree(pstr_dev_name);
|
||||||
mutex_unlock(&hnode_mgr->node_mgr_lock);
|
mutex_unlock(&hnode_mgr->node_mgr_lock);
|
||||||
func_end:
|
|
||||||
dev_dbg(bridge, "%s: node1: %p stream1: %d node2: %p stream2: %d"
|
dev_dbg(bridge, "%s: node1: %p stream1: %d node2: %p stream2: %d"
|
||||||
"pattrs: %p status: 0x%x\n", __func__, node1,
|
"pattrs: %p status: 0x%x\n", __func__, node1,
|
||||||
stream1, node2, stream2, pattrs, status);
|
stream1, node2, stream2, pattrs, status);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1329,6 +1291,7 @@ int node_create_mgr(struct node_mgr **node_man,
|
||||||
struct nldr_attrs nldr_attrs_obj;
|
struct nldr_attrs nldr_attrs_obj;
|
||||||
int status = 0;
|
int status = 0;
|
||||||
u8 dev_type;
|
u8 dev_type;
|
||||||
|
|
||||||
DBC_REQUIRE(refs > 0);
|
DBC_REQUIRE(refs > 0);
|
||||||
DBC_REQUIRE(node_man != NULL);
|
DBC_REQUIRE(node_man != NULL);
|
||||||
DBC_REQUIRE(hdev_obj != NULL);
|
DBC_REQUIRE(hdev_obj != NULL);
|
||||||
|
@ -1336,89 +1299,88 @@ int node_create_mgr(struct node_mgr **node_man,
|
||||||
*node_man = NULL;
|
*node_man = NULL;
|
||||||
/* Allocate Node manager object */
|
/* Allocate Node manager object */
|
||||||
node_mgr_obj = kzalloc(sizeof(struct node_mgr), GFP_KERNEL);
|
node_mgr_obj = kzalloc(sizeof(struct node_mgr), GFP_KERNEL);
|
||||||
if (node_mgr_obj) {
|
if (!node_mgr_obj)
|
||||||
node_mgr_obj->hdev_obj = hdev_obj;
|
return -ENOMEM;
|
||||||
INIT_LIST_HEAD(&node_mgr_obj->node_list);
|
|
||||||
node_mgr_obj->ntfy_obj = kmalloc(
|
node_mgr_obj->hdev_obj = hdev_obj;
|
||||||
sizeof(struct ntfy_object), GFP_KERNEL);
|
|
||||||
if (node_mgr_obj->ntfy_obj)
|
node_mgr_obj->ntfy_obj = kmalloc(sizeof(struct ntfy_object),
|
||||||
ntfy_init(node_mgr_obj->ntfy_obj);
|
GFP_KERNEL);
|
||||||
else
|
if (!node_mgr_obj->ntfy_obj) {
|
||||||
status = -ENOMEM;
|
|
||||||
node_mgr_obj->num_created = 0;
|
|
||||||
} else {
|
|
||||||
status = -ENOMEM;
|
status = -ENOMEM;
|
||||||
|
goto out_err;
|
||||||
}
|
}
|
||||||
/* get devNodeType */
|
ntfy_init(node_mgr_obj->ntfy_obj);
|
||||||
if (!status)
|
|
||||||
status = dev_get_dev_type(hdev_obj, &dev_type);
|
|
||||||
|
|
||||||
/* Create the DCD Manager */
|
INIT_LIST_HEAD(&node_mgr_obj->node_list);
|
||||||
if (!status) {
|
|
||||||
status =
|
dev_get_dev_type(hdev_obj, &dev_type);
|
||||||
dcd_create_manager(sz_zl_file, &node_mgr_obj->hdcd_mgr);
|
|
||||||
if (!status)
|
status = dcd_create_manager(sz_zl_file, &node_mgr_obj->hdcd_mgr);
|
||||||
status = get_proc_props(node_mgr_obj, hdev_obj);
|
if (status)
|
||||||
|
goto out_err;
|
||||||
|
|
||||||
|
status = get_proc_props(node_mgr_obj, hdev_obj);
|
||||||
|
if (status)
|
||||||
|
goto out_err;
|
||||||
|
|
||||||
}
|
|
||||||
/* Create NODE Dispatcher */
|
/* Create NODE Dispatcher */
|
||||||
if (!status) {
|
disp_attr_obj.ul_chnl_offset = node_mgr_obj->ul_chnl_offset;
|
||||||
disp_attr_obj.ul_chnl_offset = node_mgr_obj->ul_chnl_offset;
|
disp_attr_obj.ul_chnl_buf_size = node_mgr_obj->ul_chnl_buf_size;
|
||||||
disp_attr_obj.ul_chnl_buf_size = node_mgr_obj->ul_chnl_buf_size;
|
disp_attr_obj.proc_family = node_mgr_obj->proc_family;
|
||||||
disp_attr_obj.proc_family = node_mgr_obj->proc_family;
|
disp_attr_obj.proc_type = node_mgr_obj->proc_type;
|
||||||
disp_attr_obj.proc_type = node_mgr_obj->proc_type;
|
|
||||||
status =
|
status = disp_create(&node_mgr_obj->disp_obj, hdev_obj, &disp_attr_obj);
|
||||||
disp_create(&node_mgr_obj->disp_obj, hdev_obj,
|
if (status)
|
||||||
&disp_attr_obj);
|
goto out_err;
|
||||||
}
|
|
||||||
/* Create a STRM Manager */
|
/* Create a STRM Manager */
|
||||||
if (!status)
|
status = strm_create(&node_mgr_obj->strm_mgr_obj, hdev_obj);
|
||||||
status = strm_create(&node_mgr_obj->strm_mgr_obj, hdev_obj);
|
if (status)
|
||||||
|
goto out_err;
|
||||||
|
|
||||||
if (!status) {
|
dev_get_intf_fxns(hdev_obj, &node_mgr_obj->intf_fxns);
|
||||||
dev_get_intf_fxns(hdev_obj, &node_mgr_obj->intf_fxns);
|
/* Get msg_ctrl queue manager */
|
||||||
/* Get msg_ctrl queue manager */
|
dev_get_msg_mgr(hdev_obj, &node_mgr_obj->msg_mgr_obj);
|
||||||
dev_get_msg_mgr(hdev_obj, &node_mgr_obj->msg_mgr_obj);
|
mutex_init(&node_mgr_obj->node_mgr_lock);
|
||||||
mutex_init(&node_mgr_obj->node_mgr_lock);
|
|
||||||
/* Block out reserved channels */
|
|
||||||
for (i = 0; i < node_mgr_obj->ul_chnl_offset; i++)
|
|
||||||
set_bit(i, node_mgr_obj->chnl_map);
|
|
||||||
|
|
||||||
/* Block out channels reserved for RMS */
|
/* Block out reserved channels */
|
||||||
set_bit(node_mgr_obj->ul_chnl_offset, node_mgr_obj->chnl_map);
|
for (i = 0; i < node_mgr_obj->ul_chnl_offset; i++)
|
||||||
set_bit(node_mgr_obj->ul_chnl_offset + 1,
|
set_bit(i, node_mgr_obj->chnl_map);
|
||||||
node_mgr_obj->chnl_map);
|
|
||||||
}
|
/* Block out channels reserved for RMS */
|
||||||
if (!status) {
|
set_bit(node_mgr_obj->ul_chnl_offset, node_mgr_obj->chnl_map);
|
||||||
/* NO RM Server on the IVA */
|
set_bit(node_mgr_obj->ul_chnl_offset + 1, node_mgr_obj->chnl_map);
|
||||||
if (dev_type != IVA_UNIT) {
|
|
||||||
/* Get addresses of any RMS functions loaded */
|
/* NO RM Server on the IVA */
|
||||||
status = get_rms_fxns(node_mgr_obj);
|
if (dev_type != IVA_UNIT) {
|
||||||
}
|
/* Get addresses of any RMS functions loaded */
|
||||||
|
status = get_rms_fxns(node_mgr_obj);
|
||||||
|
if (status)
|
||||||
|
goto out_err;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get loader functions and create loader */
|
/* Get loader functions and create loader */
|
||||||
if (!status)
|
node_mgr_obj->nldr_fxns = nldr_fxns; /* Dyn loader funcs */
|
||||||
node_mgr_obj->nldr_fxns = nldr_fxns; /* Dyn loader funcs */
|
|
||||||
|
|
||||||
if (!status) {
|
nldr_attrs_obj.pfn_ovly = ovly;
|
||||||
nldr_attrs_obj.pfn_ovly = ovly;
|
nldr_attrs_obj.pfn_write = mem_write;
|
||||||
nldr_attrs_obj.pfn_write = mem_write;
|
nldr_attrs_obj.us_dsp_word_size = node_mgr_obj->udsp_word_size;
|
||||||
nldr_attrs_obj.us_dsp_word_size = node_mgr_obj->udsp_word_size;
|
nldr_attrs_obj.us_dsp_mau_size = node_mgr_obj->udsp_mau_size;
|
||||||
nldr_attrs_obj.us_dsp_mau_size = node_mgr_obj->udsp_mau_size;
|
node_mgr_obj->loader_init = node_mgr_obj->nldr_fxns.pfn_init();
|
||||||
node_mgr_obj->loader_init = node_mgr_obj->nldr_fxns.pfn_init();
|
status = node_mgr_obj->nldr_fxns.pfn_create(&node_mgr_obj->nldr_obj,
|
||||||
status =
|
hdev_obj,
|
||||||
node_mgr_obj->nldr_fxns.pfn_create(&node_mgr_obj->nldr_obj,
|
&nldr_attrs_obj);
|
||||||
hdev_obj,
|
if (status)
|
||||||
&nldr_attrs_obj);
|
goto out_err;
|
||||||
}
|
|
||||||
if (!status)
|
*node_man = node_mgr_obj;
|
||||||
*node_man = node_mgr_obj;
|
|
||||||
else
|
|
||||||
delete_node_mgr(node_mgr_obj);
|
|
||||||
|
|
||||||
DBC_ENSURE((status && *node_man == NULL) || (!status && *node_man));
|
DBC_ENSURE((status && *node_man == NULL) || (!status && *node_man));
|
||||||
|
|
||||||
|
return status;
|
||||||
|
out_err:
|
||||||
|
delete_node_mgr(node_mgr_obj);
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1593,16 +1555,14 @@ func_end:
|
||||||
*/
|
*/
|
||||||
int node_delete_mgr(struct node_mgr *hnode_mgr)
|
int node_delete_mgr(struct node_mgr *hnode_mgr)
|
||||||
{
|
{
|
||||||
int status = 0;
|
|
||||||
|
|
||||||
DBC_REQUIRE(refs > 0);
|
DBC_REQUIRE(refs > 0);
|
||||||
|
|
||||||
if (hnode_mgr)
|
if (!hnode_mgr)
|
||||||
delete_node_mgr(hnode_mgr);
|
return -EFAULT;
|
||||||
else
|
|
||||||
status = -EFAULT;
|
|
||||||
|
|
||||||
return status;
|
delete_node_mgr(hnode_mgr);
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1710,38 +1670,37 @@ int node_get_attr(struct node_object *hnode,
|
||||||
struct dsp_nodeattr *pattr, u32 attr_size)
|
struct dsp_nodeattr *pattr, u32 attr_size)
|
||||||
{
|
{
|
||||||
struct node_mgr *hnode_mgr;
|
struct node_mgr *hnode_mgr;
|
||||||
int status = 0;
|
|
||||||
DBC_REQUIRE(refs > 0);
|
DBC_REQUIRE(refs > 0);
|
||||||
DBC_REQUIRE(pattr != NULL);
|
DBC_REQUIRE(pattr != NULL);
|
||||||
DBC_REQUIRE(attr_size >= sizeof(struct dsp_nodeattr));
|
DBC_REQUIRE(attr_size >= sizeof(struct dsp_nodeattr));
|
||||||
|
|
||||||
if (!hnode) {
|
if (!hnode)
|
||||||
status = -EFAULT;
|
return -EFAULT;
|
||||||
} else {
|
|
||||||
hnode_mgr = hnode->hnode_mgr;
|
hnode_mgr = hnode->hnode_mgr;
|
||||||
/* Enter hnode_mgr critical section (since we're accessing
|
/* Enter hnode_mgr critical section (since we're accessing
|
||||||
* data that could be changed by node_change_priority() and
|
* data that could be changed by node_change_priority() and
|
||||||
* node_connect(). */
|
* node_connect(). */
|
||||||
mutex_lock(&hnode_mgr->node_mgr_lock);
|
mutex_lock(&hnode_mgr->node_mgr_lock);
|
||||||
pattr->cb_struct = sizeof(struct dsp_nodeattr);
|
pattr->cb_struct = sizeof(struct dsp_nodeattr);
|
||||||
/* dsp_nodeattrin */
|
/* dsp_nodeattrin */
|
||||||
pattr->in_node_attr_in.cb_struct =
|
pattr->in_node_attr_in.cb_struct =
|
||||||
sizeof(struct dsp_nodeattrin);
|
sizeof(struct dsp_nodeattrin);
|
||||||
pattr->in_node_attr_in.prio = hnode->prio;
|
pattr->in_node_attr_in.prio = hnode->prio;
|
||||||
pattr->in_node_attr_in.utimeout = hnode->utimeout;
|
pattr->in_node_attr_in.utimeout = hnode->utimeout;
|
||||||
pattr->in_node_attr_in.heap_size =
|
pattr->in_node_attr_in.heap_size =
|
||||||
hnode->create_args.asa.task_arg_obj.heap_size;
|
hnode->create_args.asa.task_arg_obj.heap_size;
|
||||||
pattr->in_node_attr_in.pgpp_virt_addr = (void *)
|
pattr->in_node_attr_in.pgpp_virt_addr = (void *)
|
||||||
hnode->create_args.asa.task_arg_obj.ugpp_heap_addr;
|
hnode->create_args.asa.task_arg_obj.ugpp_heap_addr;
|
||||||
pattr->node_attr_inputs = hnode->num_gpp_inputs;
|
pattr->node_attr_inputs = hnode->num_gpp_inputs;
|
||||||
pattr->node_attr_outputs = hnode->num_gpp_outputs;
|
pattr->node_attr_outputs = hnode->num_gpp_outputs;
|
||||||
/* dsp_nodeinfo */
|
/* dsp_nodeinfo */
|
||||||
get_node_info(hnode, &(pattr->node_info));
|
get_node_info(hnode, &(pattr->node_info));
|
||||||
/* end of sync_enter_cs */
|
/* end of sync_enter_cs */
|
||||||
/* Exit critical section */
|
/* Exit critical section */
|
||||||
mutex_unlock(&hnode_mgr->node_mgr_lock);
|
mutex_unlock(&hnode_mgr->node_mgr_lock);
|
||||||
}
|
|
||||||
return status;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue