Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit fedd0e19 authored by Linux Build Service Account's avatar Linux Build Service Account
Browse files

Merge d1e4dff4 on remote branch

Change-Id: Ieecae6ed7f4de15bd1a8cce5e2a74eadf1730efb
parents 64c139cc d1e4dff4
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2018, 2021 The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -146,3 +146,8 @@
	/delete-node/ case-therm-adc;
	/delete-node/ case-therm-adc;
	/delete-node/ case-therm-step;
	/delete-node/ case-therm-step;
};
};
&soc {
	qcom,vidc@1d00000 {
		qcom,max-hw-load = <734400>; /* 1080p@60 dec + 1080p@30 enc */
	};
};
+217 −22
Original line number Original line Diff line number Diff line
@@ -17,7 +17,6 @@
#include <linux/completion.h>
#include <linux/completion.h>
#include <linux/pagemap.h>
#include <linux/pagemap.h>
#include <linux/mm.h>
#include <linux/mm.h>
#include <linux/fs.h>
#include <linux/sched.h>
#include <linux/sched.h>
#include <linux/module.h>
#include <linux/module.h>
#include <linux/cdev.h>
#include <linux/cdev.h>
@@ -32,7 +31,6 @@
#include <soc/qcom/service-notifier.h>
#include <soc/qcom/service-notifier.h>
#include <soc/qcom/service-locator.h>
#include <soc/qcom/service-locator.h>
#include <linux/scatterlist.h>
#include <linux/scatterlist.h>
#include <linux/fs.h>
#include <linux/uaccess.h>
#include <linux/uaccess.h>
#include <linux/device.h>
#include <linux/device.h>
#include <linux/of.h>
#include <linux/of.h>
@@ -51,6 +49,8 @@
#include <soc/qcom/ramdump.h>
#include <soc/qcom/ramdump.h>
#include <linux/debugfs.h>
#include <linux/debugfs.h>
#include <linux/pm_qos.h>
#include <linux/pm_qos.h>
#include <linux/stat.h>

#define TZ_PIL_PROTECT_MEM_SUBSYS_ID 0x0C
#define TZ_PIL_PROTECT_MEM_SUBSYS_ID 0x0C
#define TZ_PIL_CLEAR_PROTECT_MEM_SUBSYS_ID 0x0D
#define TZ_PIL_CLEAR_PROTECT_MEM_SUBSYS_ID 0x0D
#define TZ_PIL_AUTH_QDSP6_PROC 1
#define TZ_PIL_AUTH_QDSP6_PROC 1
@@ -106,8 +106,9 @@
#define FASTRPC_GLINK_INTENT_NUM  (16)
#define FASTRPC_GLINK_INTENT_NUM  (16)


#define PERF_KEYS \
#define PERF_KEYS \
	"count:flush:map:copy:glink:getargs:putargs:invalidate:invoke:tid:ptr"
	"count:flush:map:copy:rpmsg:getargs:putargs:invalidate:invoke:tid:ptr"
#define FASTRPC_STATIC_HANDLE_KERNEL (1)
#define FASTRPC_STATIC_HANDLE_PROCESS_GROUP (1)
#define FASTRPC_STATIC_HANDLE_DSP_UTILITIES (2)
#define FASTRPC_STATIC_HANDLE_LISTENER (3)
#define FASTRPC_STATIC_HANDLE_LISTENER (3)
#define FASTRPC_STATIC_HANDLE_MAX (20)
#define FASTRPC_STATIC_HANDLE_MAX (20)
#define FASTRPC_LATENCY_CTRL_ENB  (1)
#define FASTRPC_LATENCY_CTRL_ENB  (1)
@@ -285,6 +286,11 @@ struct fastrpc_glink_info {
	void *link_notify_handle;
	void *link_notify_handle;
};
};


struct fastrpc_dsp_capabilities {
	uint32_t is_cached;	//! Flag if dsp attributes are cached
	uint32_t dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES];
};

struct fastrpc_channel_ctx {
struct fastrpc_channel_ctx {
	char *name;
	char *name;
	char *subsys;
	char *subsys;
@@ -309,6 +315,9 @@ struct fastrpc_channel_ctx {
	struct fastrpc_glink_info link;
	struct fastrpc_glink_info link;
	/* Indicates, if channel is restricted to secure node only */
	/* Indicates, if channel is restricted to secure node only */
	int secure;
	int secure;
	struct fastrpc_dsp_capabilities dsp_cap_kernel;
	/* Indicates whether the channel supports unsigned PD */
	bool unsigned_support;
};
};


struct fastrpc_apps {
struct fastrpc_apps {
@@ -2032,9 +2041,12 @@ static void fastrpc_init(struct fastrpc_apps *me)
		me->channel[i].sesscount = 0;
		me->channel[i].sesscount = 0;
		/* All channels are secure by default except CDSP */
		/* All channels are secure by default except CDSP */
		me->channel[i].secure = SECURE_CHANNEL;
		me->channel[i].secure = SECURE_CHANNEL;
		me->channel[i].unsigned_support = false;
	}
	}
	/* Set CDSP channel to non secure */
	/* Set CDSP channel to non secure */
	me->channel[CDSP_DOMAIN_ID].secure = NON_SECURE_CHANNEL;
	me->channel[CDSP_DOMAIN_ID].secure = NON_SECURE_CHANNEL;
	/* Set CDSP channel unsigned_support to true*/
	me->channel[CDSP_DOMAIN_ID].unsigned_support = true;
}
}


static int fastrpc_release_current_dsp_process(struct fastrpc_file *fl);
static int fastrpc_release_current_dsp_process(struct fastrpc_file *fl);
@@ -2066,10 +2078,13 @@ static int fastrpc_internal_invoke(struct fastrpc_file *fl, uint32_t mode,
		getnstimeofday(&invoket);
		getnstimeofday(&invoket);


	if (!kernel) {
	if (!kernel) {
		VERIFY(err, invoke->handle != FASTRPC_STATIC_HANDLE_KERNEL);
		VERIFY(err, invoke->handle !=
			FASTRPC_STATIC_HANDLE_PROCESS_GROUP);
		VERIFY(err, invoke->handle !=
			FASTRPC_STATIC_HANDLE_DSP_UTILITIES);
		if (err) {
		if (err) {
			pr_err("adsprpc: ERROR: %s: user application %s trying to send a kernel RPC message to channel %d",
			pr_err("adsprpc: ERROR: %s: user application %s trying to send a kernel RPC message to channel %d, handle 0x%x\n",
				__func__, current->comm, cid);
				__func__, current->comm, cid, invoke->handle);
			goto bail;
			goto bail;
		}
		}
	}
	}
@@ -2193,6 +2208,20 @@ static int fastrpc_init_process(struct fastrpc_file *fl,
	struct fastrpc_buf *imem = NULL;
	struct fastrpc_buf *imem = NULL;
	unsigned long imem_dma_attr = 0;
	unsigned long imem_dma_attr = 0;
	char *proc_name = NULL;
	char *proc_name = NULL;
	int unsigned_request = (uproc->attrs & FASTRPC_MODE_UNSIGNED_MODULE);
	int cid = fl->cid;
	struct fastrpc_channel_ctx *chan = &me->channel[cid];

	if (chan->unsigned_support &&
		fl->dev_minor == MINOR_NUM_DEV) {
		/* Make sure third party applications */
		/* can spawn only unsigned PD when */
		/* channel configured as secure. */
		if (chan->secure && !unsigned_request) {
			err = -ECONNREFUSED;
			goto bail;
		}
	}


	VERIFY(err, 0 == (err = fastrpc_channel_open(fl)));
	VERIFY(err, 0 == (err = fastrpc_channel_open(fl)));
	if (err)
	if (err)
@@ -2204,7 +2233,7 @@ static int fastrpc_init_process(struct fastrpc_file *fl,


		ra[0].buf.pv = (void *)&tgid;
		ra[0].buf.pv = (void *)&tgid;
		ra[0].buf.len = sizeof(tgid);
		ra[0].buf.len = sizeof(tgid);
		ioctl.inv.handle = FASTRPC_STATIC_HANDLE_KERNEL;
		ioctl.inv.handle = FASTRPC_STATIC_HANDLE_PROCESS_GROUP;
		ioctl.inv.sc = REMOTE_SCALARS_MAKE(0, 1, 0);
		ioctl.inv.sc = REMOTE_SCALARS_MAKE(0, 1, 0);
		ioctl.inv.pra = ra;
		ioctl.inv.pra = ra;
		ioctl.fds = NULL;
		ioctl.fds = NULL;
@@ -2299,7 +2328,7 @@ static int fastrpc_init_process(struct fastrpc_file *fl,
		ra[5].buf.len = sizeof(inbuf.siglen);
		ra[5].buf.len = sizeof(inbuf.siglen);
		fds[5] = 0;
		fds[5] = 0;


		ioctl.inv.handle = FASTRPC_STATIC_HANDLE_KERNEL;
		ioctl.inv.handle = FASTRPC_STATIC_HANDLE_PROCESS_GROUP;
		ioctl.inv.sc = REMOTE_SCALARS_MAKE(6, 4, 0);
		ioctl.inv.sc = REMOTE_SCALARS_MAKE(6, 4, 0);
		if (uproc->attrs)
		if (uproc->attrs)
			ioctl.inv.sc = REMOTE_SCALARS_MAKE(7, 6, 0);
			ioctl.inv.sc = REMOTE_SCALARS_MAKE(7, 6, 0);
@@ -2385,7 +2414,7 @@ static int fastrpc_init_process(struct fastrpc_file *fl,
		ra[2].buf.pv = (void *)pages;
		ra[2].buf.pv = (void *)pages;
		ra[2].buf.len = sizeof(*pages);
		ra[2].buf.len = sizeof(*pages);
		fds[2] = 0;
		fds[2] = 0;
		ioctl.inv.handle = FASTRPC_STATIC_HANDLE_KERNEL;
		ioctl.inv.handle = FASTRPC_STATIC_HANDLE_PROCESS_GROUP;


		ioctl.inv.sc = REMOTE_SCALARS_MAKE(8, 3, 0);
		ioctl.inv.sc = REMOTE_SCALARS_MAKE(8, 3, 0);
		ioctl.inv.pra = ra;
		ioctl.inv.pra = ra;
@@ -2421,6 +2450,119 @@ static int fastrpc_init_process(struct fastrpc_file *fl,
	return err;
	return err;
}
}


static int fastrpc_get_info_from_dsp(struct fastrpc_file *fl,
				uint32_t *dsp_attr_buf,
				uint32_t dsp_attr_buf_len,
				uint32_t domain)
{
	int err = 0, dsp_support = 0;
	struct fastrpc_ioctl_invoke_crc ioctl;
	remote_arg_t ra[2];
	struct fastrpc_apps *me = &gfa;

	// Querying device about DSP support
	switch (domain) {
	case ADSP_DOMAIN_ID:
	case SDSP_DOMAIN_ID:
	case CDSP_DOMAIN_ID:
		if (me->channel[domain].issubsystemup)
			dsp_support = 1;
		break;
	case MDSP_DOMAIN_ID:
		//Modem not supported for fastRPC
		break;
	default:
		dsp_support = 0;
		break;
	}
	dsp_attr_buf[0] = dsp_support;

	if (dsp_support == 0) {
		err = -ENOTCONN;
		goto bail;
	}

	err = fastrpc_channel_open(fl);
	if (err)
		goto bail;

	ra[0].buf.pv = (void *)&dsp_attr_buf_len;
	ra[0].buf.len = sizeof(dsp_attr_buf_len);
	ra[1].buf.pv = (void *)(&dsp_attr_buf[1]);
	ra[1].buf.len = dsp_attr_buf_len * sizeof(uint32_t);
	ioctl.inv.handle = FASTRPC_STATIC_HANDLE_DSP_UTILITIES;
	ioctl.inv.sc = REMOTE_SCALARS_MAKE(0, 1, 1);
	ioctl.inv.pra = ra;
	ioctl.fds = NULL;
	ioctl.attrs = NULL;
	ioctl.crc = NULL;
	fl->pd = 1;

	err = fastrpc_internal_invoke(fl, FASTRPC_MODE_PARALLEL, 1, &ioctl);
bail:

	if (err)
		pr_err("adsprpc: %s: %s: could not obtain dsp information, err val 0x%x\n",
		current->comm, __func__, err);
	return err;
}

static int fastrpc_get_info_from_kernel(
		struct fastrpc_ioctl_dsp_capabilities *dsp_cap,
		struct fastrpc_file *fl)
{
	int err = 0;
	uint32_t domain_support;
	uint32_t domain = dsp_cap->domain;

	if (!gcinfo[domain].dsp_cap_kernel.is_cached) {
		/*
		 * Information not on kernel, query device for information
		 * and cache on kernel
		 */
		err = fastrpc_get_info_from_dsp(fl, dsp_cap->dsp_attributes,
				FASTRPC_MAX_DSP_ATTRIBUTES - 1,
				domain);
		if (err)
			goto bail;

		domain_support = dsp_cap->dsp_attributes[0];
		switch (domain_support) {
		case 0:
			memset(dsp_cap->dsp_attributes, 0,
				sizeof(dsp_cap->dsp_attributes));
			memset(&gcinfo[domain].dsp_cap_kernel.dsp_attributes,
				0, sizeof(dsp_cap->dsp_attributes));
			break;
		case 1:
			memcpy(&gcinfo[domain].dsp_cap_kernel.dsp_attributes,
				dsp_cap->dsp_attributes,
				sizeof(dsp_cap->dsp_attributes));
			break;
		default:
			err = -1;
			/*
			 * Reset is_cached flag to 0 so subsequent calls
			 * can try to query dsp again
			 */
			gcinfo[domain].dsp_cap_kernel.is_cached = 0;
			pr_warn("adsprpc: %s: %s: returned bad domain support value %d\n",
					current->comm,
					__func__,
					domain_support);
			goto bail;
		}
		gcinfo[domain].dsp_cap_kernel.is_cached = 1;
	} else {
		// Information on Kernel, pass it to user
		memcpy(dsp_cap->dsp_attributes,
			&gcinfo[domain].dsp_cap_kernel.dsp_attributes,
			sizeof(dsp_cap->dsp_attributes));
	}
bail:
	return err;
}

static int fastrpc_release_current_dsp_process(struct fastrpc_file *fl)
static int fastrpc_release_current_dsp_process(struct fastrpc_file *fl)
{
{
	int err = 0;
	int err = 0;
@@ -2440,7 +2582,7 @@ static int fastrpc_release_current_dsp_process(struct fastrpc_file *fl)
	tgid = fl->tgid;
	tgid = fl->tgid;
	ra[0].buf.pv = (void *)&tgid;
	ra[0].buf.pv = (void *)&tgid;
	ra[0].buf.len = sizeof(tgid);
	ra[0].buf.len = sizeof(tgid);
	ioctl.inv.handle = FASTRPC_STATIC_HANDLE_KERNEL;
	ioctl.inv.handle = FASTRPC_STATIC_HANDLE_PROCESS_GROUP;
	ioctl.inv.sc = REMOTE_SCALARS_MAKE(1, 1, 0);
	ioctl.inv.sc = REMOTE_SCALARS_MAKE(1, 1, 0);
	ioctl.inv.pra = ra;
	ioctl.inv.pra = ra;
	ioctl.fds = NULL;
	ioctl.fds = NULL;
@@ -2486,7 +2628,7 @@ static int fastrpc_mmap_on_dsp(struct fastrpc_file *fl, uint32_t flags,
	ra[2].buf.pv = (void *)&routargs;
	ra[2].buf.pv = (void *)&routargs;
	ra[2].buf.len = sizeof(routargs);
	ra[2].buf.len = sizeof(routargs);


	ioctl.inv.handle = FASTRPC_STATIC_HANDLE_KERNEL;
	ioctl.inv.handle = FASTRPC_STATIC_HANDLE_PROCESS_GROUP;
	if (fl->apps->compat)
	if (fl->apps->compat)
		ioctl.inv.sc = REMOTE_SCALARS_MAKE(4, 2, 1);
		ioctl.inv.sc = REMOTE_SCALARS_MAKE(4, 2, 1);
	else
	else
@@ -2547,7 +2689,7 @@ static int fastrpc_munmap_on_dsp_rh(struct fastrpc_file *fl, uint64_t phys,
		ra[1].buf.pv = (void *)&routargs;
		ra[1].buf.pv = (void *)&routargs;
		ra[1].buf.len = sizeof(routargs);
		ra[1].buf.len = sizeof(routargs);


		ioctl.inv.handle = FASTRPC_STATIC_HANDLE_KERNEL;
		ioctl.inv.handle = FASTRPC_STATIC_HANDLE_PROCESS_GROUP;
		ioctl.inv.sc = REMOTE_SCALARS_MAKE(9, 1, 1);
		ioctl.inv.sc = REMOTE_SCALARS_MAKE(9, 1, 1);
		ioctl.inv.pra = ra;
		ioctl.inv.pra = ra;
		ioctl.fds = NULL;
		ioctl.fds = NULL;
@@ -2609,7 +2751,7 @@ static int fastrpc_munmap_on_dsp(struct fastrpc_file *fl, uintptr_t raddr,
	ra[0].buf.pv = (void *)&inargs;
	ra[0].buf.pv = (void *)&inargs;
	ra[0].buf.len = sizeof(inargs);
	ra[0].buf.len = sizeof(inargs);


	ioctl.inv.handle = FASTRPC_STATIC_HANDLE_KERNEL;
	ioctl.inv.handle = FASTRPC_STATIC_HANDLE_PROCESS_GROUP;
	if (fl->apps->compat)
	if (fl->apps->compat)
		ioctl.inv.sc = REMOTE_SCALARS_MAKE(5, 1, 0);
		ioctl.inv.sc = REMOTE_SCALARS_MAKE(5, 1, 0);
	else
	else
@@ -3649,6 +3791,7 @@ static int fastrpc_get_info(struct fastrpc_file *fl, uint32_t *info)
{
{
	int err = 0;
	int err = 0;
	uint32_t cid;
	uint32_t cid;
	struct fastrpc_apps *me = &gfa;


	VERIFY(err, fl != NULL);
	VERIFY(err, fl != NULL);
	if (err)
	if (err)
@@ -3656,8 +3799,10 @@ static int fastrpc_get_info(struct fastrpc_file *fl, uint32_t *info)
	err = fastrpc_set_process_info(fl);
	err = fastrpc_set_process_info(fl);
	if (err)
	if (err)
		goto bail;
		goto bail;
	if (fl->cid == -1) {
	cid = *info;
	cid = *info;
	if (fl->cid == -1) {
		struct fastrpc_channel_ctx *chan = &me->channel[cid];

		VERIFY(err, cid < NUM_CHANNELS);
		VERIFY(err, cid < NUM_CHANNELS);
		if (err)
		if (err)
			goto bail;
			goto bail;
@@ -3665,13 +3810,13 @@ static int fastrpc_get_info(struct fastrpc_file *fl, uint32_t *info)
		if (fl->dev_minor == MINOR_NUM_DEV &&
		if (fl->dev_minor == MINOR_NUM_DEV &&
			fl->apps->secure_flag == true) {
			fl->apps->secure_flag == true) {
			/*
			/*
			 * For non secure device node check and make sure that
			 * If an app is trying to offload to a secure remote
			 * the channel allows non-secure access
			 * channel by opening the non-secure device node, allow
			 * If not, bail. Session will not start.
			 * the access if the subsystem supports unsigned
			 * cid will remain -1 and client will not be able to
			 * offload. Untrusted apps will be restricted.
			 * invoke any other methods without failure
			 */
			 */
			if (fl->apps->channel[cid].secure == SECURE_CHANNEL) {
			if (chan->secure == SECURE_CHANNEL &&
					!chan->unsigned_support) {
				err = -EPERM;
				err = -EPERM;
				pr_err("adsprpc: GetInfo failed dev %d, cid %d, secure %d\n",
				pr_err("adsprpc: GetInfo failed dev %d, cid %d, secure %d\n",
				  fl->dev_minor, cid,
				  fl->dev_minor, cid,
@@ -3739,6 +3884,47 @@ static int fastrpc_internal_control(struct fastrpc_file *fl,
	return err;
	return err;
}
}


static int fastrpc_get_dsp_info(struct fastrpc_ioctl_dsp_capabilities *dsp_cap,
				void *param, struct fastrpc_file *fl)
{
	int err = 0;

	K_COPY_FROM_USER(err, 0, dsp_cap, param,
			sizeof(struct fastrpc_ioctl_dsp_capabilities));
	VERIFY(err, dsp_cap->domain < NUM_CHANNELS);
	if (err)
		goto bail;

	err = fastrpc_get_info_from_kernel(dsp_cap, fl);
	if (err)
		goto bail;
	K_COPY_TO_USER(err, 0, param, dsp_cap,
			sizeof(struct fastrpc_ioctl_dsp_capabilities));
bail:
	return err;
}

static int fastrpc_update_cdsp_support(struct fastrpc_file *fl)
{
	struct fastrpc_ioctl_dsp_capabilities *dsp_query;
	struct fastrpc_apps *me = &gfa;
	int err = 0;

	VERIFY(err, NULL != (dsp_query = kzalloc(sizeof(*dsp_query),
				GFP_KERNEL)));
	if (err)
		goto bail;
	dsp_query->domain = CDSP_DOMAIN_ID;
	err = fastrpc_get_info_from_kernel(dsp_query, fl);
	if (err)
		goto bail;
	if (!(dsp_query->dsp_attributes[1]))
		me->channel[CDSP_DOMAIN_ID].unsigned_support = false;
bail:
	kfree(dsp_query);
	return err;
}

static long fastrpc_device_ioctl(struct file *file, unsigned int ioctl_num,
static long fastrpc_device_ioctl(struct file *file, unsigned int ioctl_num,
				 unsigned long ioctl_param)
				 unsigned long ioctl_param)
{
{
@@ -3752,6 +3938,7 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int ioctl_num,
		struct fastrpc_ioctl_init_attrs init;
		struct fastrpc_ioctl_init_attrs init;
		struct fastrpc_ioctl_perf perf;
		struct fastrpc_ioctl_perf perf;
		struct fastrpc_ioctl_control cp;
		struct fastrpc_ioctl_control cp;
		struct fastrpc_ioctl_dsp_capabilities dsp_cap;
	} p;
	} p;
	union {
	union {
		struct fastrpc_ioctl_mmap mmap;
		struct fastrpc_ioctl_mmap mmap;
@@ -3761,6 +3948,7 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int ioctl_num,
	struct fastrpc_file *fl = (struct fastrpc_file *)file->private_data;
	struct fastrpc_file *fl = (struct fastrpc_file *)file->private_data;
	int size = 0, err = 0;
	int size = 0, err = 0;
	uint32_t info;
	uint32_t info;
	static bool isQueryDone;


	VERIFY(err, fl != NULL);
	VERIFY(err, fl != NULL);
	if (err) {
	if (err) {
@@ -3961,8 +4149,15 @@ static long fastrpc_device_ioctl(struct file *file, unsigned int ioctl_num,
		VERIFY(err, 0 == (err = fastrpc_init_process(fl, &p.init)));
		VERIFY(err, 0 == (err = fastrpc_init_process(fl, &p.init)));
		if (err)
		if (err)
			goto bail;
			goto bail;
		if ((fl->cid == CDSP_DOMAIN_ID) && !isQueryDone) {
			err = fastrpc_update_cdsp_support(fl);
			if (!err)
				isQueryDone = true;
		}
		break;
	case FASTRPC_IOCTL_GET_DSP_INFO:
		err = fastrpc_get_dsp_info(&p.dsp_cap, param, fl);
		break;
		break;

	default:
	default:
		err = -ENOTTY;
		err = -ENOTTY;
		pr_info("bad ioctl: %d\n", ioctl_num);
		pr_info("bad ioctl: %d\n", ioctl_num);
+57 −1
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
 * Copyright (c) 2014-2021, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -43,6 +43,8 @@
		_IOWR('R', 14, struct compat_fastrpc_ioctl_mmap_64)
		_IOWR('R', 14, struct compat_fastrpc_ioctl_mmap_64)
#define COMPAT_FASTRPC_IOCTL_MUNMAP_64 \
#define COMPAT_FASTRPC_IOCTL_MUNMAP_64 \
		_IOWR('R', 15, struct compat_fastrpc_ioctl_munmap_64)
		_IOWR('R', 15, struct compat_fastrpc_ioctl_munmap_64)
#define COMPAT_FASTRPC_IOCTL_GET_DSP_INFO \
		_IOWR('R', 16, struct compat_fastrpc_ioctl_dsp_capabilities)


struct compat_remote_buf {
struct compat_remote_buf {
	compat_uptr_t pv;	/* buffer pointer */
	compat_uptr_t pv;	/* buffer pointer */
@@ -151,6 +153,11 @@ struct compat_fastrpc_ioctl_control {
	};
	};
};
};


struct compat_fastrpc_ioctl_dsp_capabilities {
	compat_uint_t domain;	/* DSP domain to query capabilities */
	compat_uint_t dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES];
};

static int compat_get_fastrpc_ioctl_invoke(
static int compat_get_fastrpc_ioctl_invoke(
			struct compat_fastrpc_ioctl_invoke_crc __user *inv32,
			struct compat_fastrpc_ioctl_invoke_crc __user *inv32,
			struct fastrpc_ioctl_invoke_crc __user **inva,
			struct fastrpc_ioctl_invoke_crc __user **inva,
@@ -389,6 +396,53 @@ static int compat_get_fastrpc_ioctl_init(
	return err;
	return err;
}
}


static int compat_put_fastrpc_ioctl_get_dsp_info(
		struct compat_fastrpc_ioctl_dsp_capabilities __user *info32,
		struct fastrpc_ioctl_dsp_capabilities __user *info)
{
	compat_uint_t u;
	int err, ii;

	for (ii = 0, err = 0; ii < FASTRPC_MAX_DSP_ATTRIBUTES; ii++) {
		err |= get_user(u, &info->dsp_attributes[ii]);
		err |= put_user(u, &info32->dsp_attributes[ii]);
	}

	return err;
}



static int compat_fastrpc_get_dsp_info(struct file *filp,
		unsigned long arg)
{
	struct compat_fastrpc_ioctl_dsp_capabilities __user *info32;
	struct fastrpc_ioctl_dsp_capabilities __user *info;
	compat_uint_t u;
	long ret;
	int err = 0;

	info32 = compat_ptr(arg);
	VERIFY(err, NULL != (info = compat_alloc_user_space(
						sizeof(*info))));
	if (err)
		return -EFAULT;

	err = get_user(u, &info32->domain);
	err |= put_user(u, &info->domain);
	if (err)
		return err;

	ret = filp->f_op->unlocked_ioctl(filp,
			FASTRPC_IOCTL_GET_DSP_INFO,
			(unsigned long)info);
	if (ret)
		return ret;

	err = compat_put_fastrpc_ioctl_get_dsp_info(info32, info);
	return err;
}

long compat_fastrpc_device_ioctl(struct file *filp, unsigned int cmd,
long compat_fastrpc_device_ioctl(struct file *filp, unsigned int cmd,
				unsigned long arg)
				unsigned long arg)
{
{
@@ -588,6 +642,8 @@ long compat_fastrpc_device_ioctl(struct file *filp, unsigned int cmd,
		err |= put_user(u, &perf32->numkeys);
		err |= put_user(u, &perf32->numkeys);
		return err;
		return err;
	}
	}
	case COMPAT_FASTRPC_IOCTL_GET_DSP_INFO:
		return compat_fastrpc_get_dsp_info(filp, arg);
	default:
	default:
		return -ENOIOCTLCMD;
		return -ENOIOCTLCMD;
	}
	}
+24 −1
Original line number Original line Diff line number Diff line
/*
/*
 * Copyright (c) 2012-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -32,6 +32,8 @@
#define FASTRPC_IOCTL_INVOKE_CRC _IOWR('R', 11, struct fastrpc_ioctl_invoke_crc)
#define FASTRPC_IOCTL_INVOKE_CRC _IOWR('R', 11, struct fastrpc_ioctl_invoke_crc)
#define FASTRPC_IOCTL_CONTROL   _IOWR('R', 12, struct fastrpc_ioctl_control)
#define FASTRPC_IOCTL_CONTROL   _IOWR('R', 12, struct fastrpc_ioctl_control)
#define FASTRPC_IOCTL_MUNMAP_FD _IOWR('R', 13, struct fastrpc_ioctl_munmap_fd)
#define FASTRPC_IOCTL_MUNMAP_FD _IOWR('R', 13, struct fastrpc_ioctl_munmap_fd)
#define FASTRPC_IOCTL_GET_DSP_INFO \
			_IOWR('R', 16, struct fastrpc_ioctl_dsp_capabilities)


#define FASTRPC_GLINK_GUID "fastrpcglink-apps-dsp"
#define FASTRPC_GLINK_GUID "fastrpcglink-apps-dsp"
#define FASTRPC_SMD_GUID "fastrpcsmd-apps-dsp"
#define FASTRPC_SMD_GUID "fastrpcsmd-apps-dsp"
@@ -269,6 +271,12 @@ struct fastrpc_ioctl_control {
	};
	};
};
};


#define FASTRPC_MAX_DSP_ATTRIBUTES	(7)
struct fastrpc_ioctl_dsp_capabilities {
	uint32_t domain;	//! DSP domain to query capabilities
	uint32_t dsp_attributes[FASTRPC_MAX_DSP_ATTRIBUTES];
};

struct smq_null_invoke {
struct smq_null_invoke {
	uint64_t ctx;			/* invoke caller context */
	uint64_t ctx;			/* invoke caller context */
	uint32_t handle;	    /* handle to invoke */
	uint32_t handle;	    /* handle to invoke */
@@ -317,4 +325,19 @@ static inline struct smq_phy_page *smq_phy_page_start(uint32_t sc,
	return (struct smq_phy_page *)(&buf[nTotal]);
	return (struct smq_phy_page *)(&buf[nTotal]);
}
}


enum fastrpc_proc_attr {
	/* Macro for Debug attr */
	FASTRPC_MODE_DEBUG				= 1 << 0,
	/* Macro for Ptrace */
	FASTRPC_MODE_PTRACE				= 1 << 1,
	/* Macro for CRC Check */
	FASTRPC_MODE_CRC				= 1 << 2,
	/* Macro for Unsigned PD */
	FASTRPC_MODE_UNSIGNED_MODULE	= 1 << 3,
	/* Macro for Adaptive QoS */
	FASTRPC_MODE_ADAPTIVE_QOS		= 1 << 4,
	/* Macro for System Process */
	FASTRPC_MODE_SYSTEM_PROCESS		= 1 << 5,
};

#endif
#endif
+6 −1
Original line number Original line Diff line number Diff line
/* Copyright (c) 2012-2020, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2021, The Linux Foundation. All rights reserved.
 *
 *
 * This program is free software; you can redistribute it and/or modify
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
 * it under the terms of the GNU General Public License version 2 and
@@ -1063,6 +1063,11 @@ void extract_dci_pkt_rsp(unsigned char *buf, int len, int data_source,
		return;
		return;
	}
	}


	if (token != entry->client_info.token) {
		mutex_unlock(&driver->dci_mutex);
		return;
	}

	mutex_lock(&entry->buffers[data_source].buf_mutex);
	mutex_lock(&entry->buffers[data_source].buf_mutex);
	rsp_buf = entry->buffers[data_source].buf_cmd;
	rsp_buf = entry->buffers[data_source].buf_cmd;


Loading