Merge "msm: ADSPRPC: Use domain information to open channels"
This commit is contained in:
commit
294fecd4b8
2 changed files with 76 additions and 50 deletions
|
@ -1493,6 +1493,7 @@ static int fastrpc_internal_invoke(struct fastrpc_file *fl, uint32_t mode,
|
|||
return err;
|
||||
}
|
||||
|
||||
static int fastrpc_channel_open(struct fastrpc_file *fl);
|
||||
static int fastrpc_init_process(struct fastrpc_file *fl,
|
||||
struct fastrpc_ioctl_init_attrs *uproc)
|
||||
{
|
||||
|
@ -1501,6 +1502,10 @@ static int fastrpc_init_process(struct fastrpc_file *fl,
|
|||
struct fastrpc_ioctl_init *init = &uproc->init;
|
||||
struct smq_phy_page pages[1];
|
||||
struct fastrpc_mmap *file = 0, *mem = 0;
|
||||
|
||||
VERIFY(err, !fastrpc_channel_open(fl));
|
||||
if (err)
|
||||
goto bail;
|
||||
if (init->flags == FASTRPC_INIT_ATTACH) {
|
||||
remote_arg_t ra[1];
|
||||
int tgid = current->tgid;
|
||||
|
@ -1651,6 +1656,9 @@ static int fastrpc_release_current_dsp_process(struct fastrpc_file *fl)
|
|||
remote_arg_t ra[1];
|
||||
int tgid = 0;
|
||||
|
||||
VERIFY(err, fl->cid >= 0 && fl->cid < NUM_CHANNELS);
|
||||
if (err)
|
||||
goto bail;
|
||||
VERIFY(err, fl->apps->channel[fl->cid].chan != 0);
|
||||
if (err)
|
||||
goto bail;
|
||||
|
@ -2307,42 +2315,20 @@ static const struct file_operations debugfs_fops = {
|
|||
.open = fastrpc_debugfs_open,
|
||||
.read = fastrpc_debugfs_read,
|
||||
};
|
||||
|
||||
static int fastrpc_device_open(struct inode *inode, struct file *filp)
|
||||
static int fastrpc_channel_open(struct fastrpc_file *fl)
|
||||
{
|
||||
int cid = MINOR(inode->i_rdev);
|
||||
struct dentry *debugfs_file;
|
||||
int err = 0;
|
||||
struct fastrpc_apps *me = &gfa;
|
||||
struct fastrpc_file *fl = 0;
|
||||
|
||||
VERIFY(err, fl = kzalloc(sizeof(*fl), GFP_KERNEL));
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
filp->private_data = fl;
|
||||
int cid, err = 0;
|
||||
|
||||
mutex_lock(&me->smd_mutex);
|
||||
|
||||
debugfs_file = debugfs_create_file(current->comm, 0644, debugfs_root,
|
||||
fl, &debugfs_fops);
|
||||
context_list_ctor(&fl->clst);
|
||||
spin_lock_init(&fl->hlock);
|
||||
INIT_HLIST_HEAD(&fl->maps);
|
||||
INIT_HLIST_HEAD(&fl->bufs);
|
||||
INIT_HLIST_NODE(&fl->hn);
|
||||
fl->tgid = current->tgid;
|
||||
fl->apps = me;
|
||||
fl->cid = cid;
|
||||
if (debugfs_file != NULL)
|
||||
fl->debugfs_file = debugfs_file;
|
||||
memset(&fl->perf, 0, sizeof(fl->perf));
|
||||
|
||||
VERIFY(err, !fastrpc_session_alloc_locked(&me->channel[cid], 0,
|
||||
&fl->sctx));
|
||||
VERIFY(err, fl && fl->sctx);
|
||||
if (err)
|
||||
goto bail;
|
||||
cid = fl->cid;
|
||||
VERIFY(err, cid >= 0 && cid < NUM_CHANNELS);
|
||||
if (err)
|
||||
goto bail;
|
||||
fl->cid = cid;
|
||||
fl->ssrcount = me->channel[cid].ssrcount;
|
||||
if ((kref_get_unless_zero(&me->channel[cid].kref) == 0) ||
|
||||
(me->channel[cid].chan == 0)) {
|
||||
|
@ -2368,25 +2354,58 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp)
|
|||
me->channel[cid].ssrcount;
|
||||
}
|
||||
}
|
||||
spin_lock(&me->hlock);
|
||||
hlist_add_head(&fl->hn, &me->drivers);
|
||||
spin_unlock(&me->hlock);
|
||||
|
||||
bail:
|
||||
mutex_unlock(&me->smd_mutex);
|
||||
|
||||
if (err && fl)
|
||||
fastrpc_device_release(inode, filp);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int fastrpc_device_open(struct inode *inode, struct file *filp)
|
||||
{
|
||||
int err = 0;
|
||||
struct fastrpc_file *fl = 0;
|
||||
struct fastrpc_apps *me = &gfa;
|
||||
|
||||
VERIFY(err, fl = kzalloc(sizeof(*fl), GFP_KERNEL));
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
context_list_ctor(&fl->clst);
|
||||
spin_lock_init(&fl->hlock);
|
||||
INIT_HLIST_HEAD(&fl->maps);
|
||||
INIT_HLIST_HEAD(&fl->bufs);
|
||||
INIT_HLIST_NODE(&fl->hn);
|
||||
fl->tgid = current->tgid;
|
||||
fl->apps = me;
|
||||
fl->mode = FASTRPC_MODE_SERIAL;
|
||||
fl->cid = -1;
|
||||
filp->private_data = fl;
|
||||
spin_lock(&me->hlock);
|
||||
hlist_add_head(&fl->hn, &me->drivers);
|
||||
spin_unlock(&me->hlock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int fastrpc_get_info(struct fastrpc_file *fl, uint32_t *info)
|
||||
{
|
||||
int err = 0;
|
||||
uint32_t cid;
|
||||
|
||||
VERIFY(err, fl && fl->sctx);
|
||||
VERIFY(err, fl != 0);
|
||||
if (err)
|
||||
goto bail;
|
||||
if (fl->cid == -1) {
|
||||
cid = *info;
|
||||
VERIFY(err, cid < NUM_CHANNELS);
|
||||
if (err)
|
||||
goto bail;
|
||||
fl->cid = cid;
|
||||
fl->ssrcount = fl->apps->channel[cid].ssrcount;
|
||||
VERIFY(err, !fastrpc_session_alloc_locked(
|
||||
&fl->apps->channel[cid], 0, &fl->sctx));
|
||||
if (err)
|
||||
goto bail;
|
||||
}
|
||||
*info = (fl->sctx->smmu.enabled ? 1 : 0);
|
||||
bail:
|
||||
return err;
|
||||
|
@ -2487,6 +2506,9 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int ioctl_num,
|
|||
goto bail;
|
||||
break;
|
||||
case FASTRPC_IOCTL_GETINFO:
|
||||
VERIFY(err, 0 == copy_from_user(&info, param, sizeof(info)));
|
||||
if (err)
|
||||
goto bail;
|
||||
VERIFY(err, 0 == (err = fastrpc_get_info(fl, &info)));
|
||||
if (err)
|
||||
goto bail;
|
||||
|
@ -2802,6 +2824,7 @@ static struct platform_driver fastrpc_driver = {
|
|||
static int __init fastrpc_device_init(void)
|
||||
{
|
||||
struct fastrpc_apps *me = &gfa;
|
||||
struct device *dev = 0;
|
||||
int err = 0, i;
|
||||
|
||||
memset(me, 0, sizeof(*me));
|
||||
|
@ -2818,7 +2841,7 @@ static int __init fastrpc_device_init(void)
|
|||
cdev_init(&me->cdev, &fops);
|
||||
me->cdev.owner = THIS_MODULE;
|
||||
VERIFY(err, 0 == cdev_add(&me->cdev, MKDEV(MAJOR(me->dev_no), 0),
|
||||
NUM_CHANNELS));
|
||||
1));
|
||||
if (err)
|
||||
goto cdev_init_bail;
|
||||
me->class = class_create(THIS_MODULE, "fastrpc");
|
||||
|
@ -2826,15 +2849,14 @@ static int __init fastrpc_device_init(void)
|
|||
if (err)
|
||||
goto class_create_bail;
|
||||
me->compat = (NULL == fops.compat_ioctl) ? 0 : 1;
|
||||
dev = device_create(me->class, NULL,
|
||||
MKDEV(MAJOR(me->dev_no), 0),
|
||||
NULL, gcinfo[0].name);
|
||||
VERIFY(err, !IS_ERR_OR_NULL(dev));
|
||||
if (err)
|
||||
goto device_create_bail;
|
||||
for (i = 0; i < NUM_CHANNELS; i++) {
|
||||
if (!gcinfo[i].name)
|
||||
continue;
|
||||
me->channel[i].dev = device_create(me->class, NULL,
|
||||
MKDEV(MAJOR(me->dev_no), i),
|
||||
NULL, gcinfo[i].name);
|
||||
VERIFY(err, !IS_ERR(me->channel[i].dev));
|
||||
if (err)
|
||||
goto device_create_bail;
|
||||
me->channel[i].dev = dev;
|
||||
me->channel[i].ssrcount = 0;
|
||||
me->channel[i].prevssrcount = 0;
|
||||
me->channel[i].ramdumpenabled = 0;
|
||||
|
@ -2853,12 +2875,12 @@ static int __init fastrpc_device_init(void)
|
|||
return 0;
|
||||
device_create_bail:
|
||||
for (i = 0; i < NUM_CHANNELS; i++) {
|
||||
if (IS_ERR_OR_NULL(me->channel[i].dev))
|
||||
continue;
|
||||
device_destroy(me->class, MKDEV(MAJOR(me->dev_no), i));
|
||||
subsys_notif_unregister_notifier(me->channel[i].handle,
|
||||
&me->channel[i].nb);
|
||||
if (me->channel[i].handle)
|
||||
subsys_notif_unregister_notifier(me->channel[i].handle,
|
||||
&me->channel[i].nb);
|
||||
}
|
||||
if (!IS_ERR_OR_NULL(dev))
|
||||
device_destroy(me->class, MKDEV(MAJOR(me->dev_no), 0));
|
||||
class_destroy(me->class);
|
||||
class_create_bail:
|
||||
cdev_del(&me->cdev);
|
||||
|
|
|
@ -391,6 +391,10 @@ long compat_fastrpc_device_ioctl(struct file *filp, unsigned int cmd,
|
|||
sizeof(*info))));
|
||||
if (err)
|
||||
return -EFAULT;
|
||||
err = get_user(u, info32);
|
||||
err |= put_user(u, info);
|
||||
if (err)
|
||||
return err;
|
||||
ret = filp->f_op->unlocked_ioctl(filp, FASTRPC_IOCTL_GETINFO,
|
||||
(unsigned long)info);
|
||||
if (ret)
|
||||
|
|
Loading…
Add table
Reference in a new issue