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

Commit ac82b09c authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "ASoC: msm: qdspv2: add mutex to prevent access same memory simultaneously"

parents 83540cac 1a3178e4
Loading
Loading
Loading
Loading
+2 −0
Original line number Original line Diff line number Diff line
@@ -347,6 +347,8 @@ Optional properties:
 - clocks:                                  phandle reference to the parent
 - clocks:                                  phandle reference to the parent
                                            clock.
                                            clock.


 - qcom,mclk-clk-reg:                       Indicate the register address for mclk.

* audio_slimslave
* audio_slimslave


Required properties:
Required properties:
+34 −0
Original line number Original line Diff line number Diff line
@@ -149,6 +149,8 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
	case AUDIO_START: {
	case AUDIO_START: {
		pr_debug("%s: AUDIO_START\n", __func__);
		pr_debug("%s: AUDIO_START\n", __func__);


		mutex_lock(&effects->lock);

		rc = q6asm_open_read_write_v2(effects->ac,
		rc = q6asm_open_read_write_v2(effects->ac,
					FORMAT_LINEAR_PCM,
					FORMAT_LINEAR_PCM,
					FORMAT_MULTI_CHANNEL_LINEAR_PCM,
					FORMAT_MULTI_CHANNEL_LINEAR_PCM,
@@ -160,6 +162,7 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
			pr_err("%s: Open failed for hw accelerated effects:rc=%d\n",
			pr_err("%s: Open failed for hw accelerated effects:rc=%d\n",
				__func__, rc);
				__func__, rc);
			rc = -EINVAL;
			rc = -EINVAL;
			mutex_unlock(&effects->lock);
			goto ioctl_fail;
			goto ioctl_fail;
		}
		}
		effects->opened = 1;
		effects->opened = 1;
@@ -176,6 +179,7 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
			pr_err("%s: Write buffer Allocation failed rc = %d\n",
			pr_err("%s: Write buffer Allocation failed rc = %d\n",
				__func__, rc);
				__func__, rc);
			rc = -ENOMEM;
			rc = -ENOMEM;
			mutex_unlock(&effects->lock);
			goto ioctl_fail;
			goto ioctl_fail;
		}
		}
		atomic_set(&effects->in_count, effects->config.input.num_buf);
		atomic_set(&effects->in_count, effects->config.input.num_buf);
@@ -186,6 +190,7 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
			pr_err("%s: Read buffer Allocation failed rc = %d\n",
			pr_err("%s: Read buffer Allocation failed rc = %d\n",
				__func__, rc);
				__func__, rc);
			rc = -ENOMEM;
			rc = -ENOMEM;
			mutex_unlock(&effects->lock);
			goto readbuf_fail;
			goto readbuf_fail;
		}
		}
		atomic_set(&effects->out_count, effects->config.output.num_buf);
		atomic_set(&effects->out_count, effects->config.output.num_buf);
@@ -200,6 +205,7 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
		if (rc < 0) {
		if (rc < 0) {
			pr_err("%s: pcm read block config failed\n", __func__);
			pr_err("%s: pcm read block config failed\n", __func__);
			rc = -EINVAL;
			rc = -EINVAL;
			mutex_unlock(&effects->lock);
			goto cfg_fail;
			goto cfg_fail;
		}
		}
		pr_debug("%s: dec: sample_rate: %d, num_channels: %d, bit_width: %d\n",
		pr_debug("%s: dec: sample_rate: %d, num_channels: %d, bit_width: %d\n",
@@ -214,6 +220,7 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
			pr_err("%s: pcm write format block config failed\n",
			pr_err("%s: pcm write format block config failed\n",
				__func__);
				__func__);
			rc = -EINVAL;
			rc = -EINVAL;
			mutex_unlock(&effects->lock);
			goto cfg_fail;
			goto cfg_fail;
		}
		}


@@ -226,6 +233,7 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
			effects->started = 0;
			effects->started = 0;
			pr_err("%s: ASM run state failed\n", __func__);
			pr_err("%s: ASM run state failed\n", __func__);
		}
		}
		mutex_unlock(&effects->lock);
		break;
		break;
	}
	}
	case AUDIO_EFFECTS_WRITE: {
	case AUDIO_EFFECTS_WRITE: {
@@ -287,8 +295,11 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
		uint32_t idx = 0;
		uint32_t idx = 0;
		uint32_t size = 0;
		uint32_t size = 0;


		mutex_lock(&effects->lock);

		if (!effects->started) {
		if (!effects->started) {
			rc = -EFAULT;
			rc = -EFAULT;
			mutex_unlock(&effects->lock);
			goto ioctl_fail;
			goto ioctl_fail;
		}
		}


@@ -305,11 +316,13 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
		if (!rc) {
		if (!rc) {
			pr_err("%s: read wait_event_timeout\n", __func__);
			pr_err("%s: read wait_event_timeout\n", __func__);
			rc = -EFAULT;
			rc = -EFAULT;
			mutex_unlock(&effects->lock);
			goto ioctl_fail;
			goto ioctl_fail;
		}
		}
		if (!atomic_read(&effects->in_count)) {
		if (!atomic_read(&effects->in_count)) {
			pr_err("%s: pcm stopped in_count 0\n", __func__);
			pr_err("%s: pcm stopped in_count 0\n", __func__);
			rc = -EFAULT;
			rc = -EFAULT;
			mutex_unlock(&effects->lock);
			goto ioctl_fail;
			goto ioctl_fail;
		}
		}


@@ -317,15 +330,18 @@ static int audio_effects_shared_ioctl(struct file *file, unsigned int cmd,
		if (bufptr) {
		if (bufptr) {
			if (!((void *)arg)) {
			if (!((void *)arg)) {
				rc = -EFAULT;
				rc = -EFAULT;
				mutex_unlock(&effects->lock);
				goto ioctl_fail;
				goto ioctl_fail;
			}
			}
			if ((effects->config.buf_cfg.input_len > size) ||
			if ((effects->config.buf_cfg.input_len > size) ||
				copy_to_user((void *)arg, bufptr,
				copy_to_user((void *)arg, bufptr,
					  effects->config.buf_cfg.input_len)) {
					  effects->config.buf_cfg.input_len)) {
				rc = -EFAULT;
				rc = -EFAULT;
				mutex_unlock(&effects->lock);
				goto ioctl_fail;
				goto ioctl_fail;
			}
			}
		}
		}
		mutex_unlock(&effects->lock);
		break;
		break;
	}
	}
	default:
	default:
@@ -459,6 +475,7 @@ static long audio_effects_ioctl(struct file *file, unsigned int cmd,
	switch (cmd) {
	switch (cmd) {
	case AUDIO_SET_EFFECTS_CONFIG: {
	case AUDIO_SET_EFFECTS_CONFIG: {
		pr_debug("%s: AUDIO_SET_EFFECTS_CONFIG\n", __func__);
		pr_debug("%s: AUDIO_SET_EFFECTS_CONFIG\n", __func__);
		mutex_lock(&effects->lock);
		memset(&effects->config, 0, sizeof(effects->config));
		memset(&effects->config, 0, sizeof(effects->config));
		if (copy_from_user(&effects->config, (void *)arg,
		if (copy_from_user(&effects->config, (void *)arg,
				   sizeof(effects->config))) {
				   sizeof(effects->config))) {
@@ -476,6 +493,7 @@ static long audio_effects_ioctl(struct file *file, unsigned int cmd,
			 effects->config.input.num_buf,
			 effects->config.input.num_buf,
			 effects->config.input.sample_rate,
			 effects->config.input.sample_rate,
			 effects->config.input.num_channels);
			 effects->config.input.num_channels);
		mutex_unlock(&effects->lock);
		break;
		break;
	}
	}
	case AUDIO_EFFECTS_SET_BUF_LEN: {
	case AUDIO_EFFECTS_SET_BUF_LEN: {
@@ -497,6 +515,7 @@ static long audio_effects_ioctl(struct file *file, unsigned int cmd,


		buf_avail.input_num_avail = atomic_read(&effects->in_count);
		buf_avail.input_num_avail = atomic_read(&effects->in_count);
		buf_avail.output_num_avail = atomic_read(&effects->out_count);
		buf_avail.output_num_avail = atomic_read(&effects->out_count);
		mutex_lock(&effects->lock);
		pr_debug("%s: write buf avail: %d, read buf avail: %d\n",
		pr_debug("%s: write buf avail: %d, read buf avail: %d\n",
			 __func__, buf_avail.output_num_avail,
			 __func__, buf_avail.output_num_avail,
			 buf_avail.input_num_avail);
			 buf_avail.input_num_avail);
@@ -506,16 +525,20 @@ static long audio_effects_ioctl(struct file *file, unsigned int cmd,
				__func__);
				__func__);
			rc = -EFAULT;
			rc = -EFAULT;
		}
		}
		mutex_unlock(&effects->lock);
		break;
		break;
	}
	}
	case AUDIO_EFFECTS_SET_PP_PARAMS: {
	case AUDIO_EFFECTS_SET_PP_PARAMS: {
		mutex_lock(&effects->lock);
		if (copy_from_user(argvalues, (void *)arg,
		if (copy_from_user(argvalues, (void *)arg,
				   MAX_PP_PARAMS_SZ*sizeof(long))) {
				   MAX_PP_PARAMS_SZ*sizeof(long))) {
			pr_err("%s: copy from user for pp params failed\n",
			pr_err("%s: copy from user for pp params failed\n",
				__func__);
				__func__);
			mutex_unlock(&effects->lock);
			return -EFAULT;
			return -EFAULT;
		}
		}
		rc = audio_effects_set_pp_param(effects, argvalues);
		rc = audio_effects_set_pp_param(effects, argvalues);
		mutex_unlock(&effects->lock);
		break;
		break;
	}
	}
	default:
	default:
@@ -582,12 +605,14 @@ static long audio_effects_compat_ioctl(struct file *file, unsigned int cmd,
		struct msm_hwacc_effects_config32 config32;
		struct msm_hwacc_effects_config32 config32;
		struct msm_hwacc_effects_config *config = &effects->config;
		struct msm_hwacc_effects_config *config = &effects->config;


		mutex_lock(&effects->lock);
		memset(&effects->config, 0, sizeof(effects->config));
		memset(&effects->config, 0, sizeof(effects->config));
		if (copy_from_user(&config32, (void *)arg,
		if (copy_from_user(&config32, (void *)arg,
				   sizeof(config32))) {
				   sizeof(config32))) {
			pr_err("%s: copy to user for AUDIO_SET_EFFECTS_CONFIG failed\n",
			pr_err("%s: copy to user for AUDIO_SET_EFFECTS_CONFIG failed\n",
				__func__);
				__func__);
			rc = -EFAULT;
			rc = -EFAULT;
			mutex_unlock(&effects->lock);
			break;
			break;
		}
		}
		config->input.buf_size = config32.input.buf_size;
		config->input.buf_size = config32.input.buf_size;
@@ -624,17 +649,20 @@ static long audio_effects_compat_ioctl(struct file *file, unsigned int cmd,
			 effects->config.input.num_buf,
			 effects->config.input.num_buf,
			 effects->config.input.sample_rate,
			 effects->config.input.sample_rate,
			 effects->config.input.num_channels);
			 effects->config.input.num_channels);
		mutex_unlock(&effects->lock);
		break;
		break;
	}
	}
	case AUDIO_EFFECTS_SET_BUF_LEN32: {
	case AUDIO_EFFECTS_SET_BUF_LEN32: {
		struct msm_hwacc_buf_cfg32 buf_cfg32;
		struct msm_hwacc_buf_cfg32 buf_cfg32;
		struct msm_hwacc_effects_config *config = &effects->config;
		struct msm_hwacc_effects_config *config = &effects->config;


		mutex_lock(&effects->lock);
		if (copy_from_user(&buf_cfg32, (void *)arg,
		if (copy_from_user(&buf_cfg32, (void *)arg,
				   sizeof(buf_cfg32))) {
				   sizeof(buf_cfg32))) {
			pr_err("%s: copy from user for AUDIO_EFFECTS_SET_BUF_LEN failed\n",
			pr_err("%s: copy from user for AUDIO_EFFECTS_SET_BUF_LEN failed\n",
				__func__);
				__func__);
			rc = -EFAULT;
			rc = -EFAULT;
			mutex_unlock(&effects->lock);
			break;
			break;
		}
		}
		config->buf_cfg.input_len = buf_cfg32.input_len;
		config->buf_cfg.input_len = buf_cfg32.input_len;
@@ -642,6 +670,7 @@ static long audio_effects_compat_ioctl(struct file *file, unsigned int cmd,
		pr_debug("%s: write buf len: %d, read buf len: %d\n",
		pr_debug("%s: write buf len: %d, read buf len: %d\n",
			 __func__, effects->config.buf_cfg.output_len,
			 __func__, effects->config.buf_cfg.output_len,
			 effects->config.buf_cfg.input_len);
			 effects->config.buf_cfg.input_len);
		mutex_unlock(&effects->lock);
		break;
		break;
	}
	}
	case AUDIO_EFFECTS_GET_BUF_AVAIL32: {
	case AUDIO_EFFECTS_GET_BUF_AVAIL32: {
@@ -649,6 +678,7 @@ static long audio_effects_compat_ioctl(struct file *file, unsigned int cmd,


		memset(&buf_avail, 0, sizeof(buf_avail));
		memset(&buf_avail, 0, sizeof(buf_avail));


		mutex_lock(&effects->lock);
		buf_avail.input_num_avail = atomic_read(&effects->in_count);
		buf_avail.input_num_avail = atomic_read(&effects->in_count);
		buf_avail.output_num_avail = atomic_read(&effects->out_count);
		buf_avail.output_num_avail = atomic_read(&effects->out_count);
		pr_debug("%s: write buf avail: %d, read buf avail: %d\n",
		pr_debug("%s: write buf avail: %d, read buf avail: %d\n",
@@ -660,22 +690,26 @@ static long audio_effects_compat_ioctl(struct file *file, unsigned int cmd,
				__func__);
				__func__);
			rc = -EFAULT;
			rc = -EFAULT;
		}
		}
		mutex_unlock(&effects->lock);
		break;
		break;
	}
	}
	case AUDIO_EFFECTS_SET_PP_PARAMS32: {
	case AUDIO_EFFECTS_SET_PP_PARAMS32: {
		long argvalues[MAX_PP_PARAMS_SZ] = {0};
		long argvalues[MAX_PP_PARAMS_SZ] = {0};
		int argvalues32[MAX_PP_PARAMS_SZ] = {0};
		int argvalues32[MAX_PP_PARAMS_SZ] = {0};


		mutex_lock(&effects->lock);
		if (copy_from_user(argvalues32, (void *)arg,
		if (copy_from_user(argvalues32, (void *)arg,
				   MAX_PP_PARAMS_SZ*sizeof(int))) {
				   MAX_PP_PARAMS_SZ*sizeof(int))) {
			pr_err("%s: copy from user failed for pp params\n",
			pr_err("%s: copy from user failed for pp params\n",
				__func__);
				__func__);
			mutex_unlock(&effects->lock);
			return -EFAULT;
			return -EFAULT;
		}
		}
		for (i = 0; i < MAX_PP_PARAMS_SZ; i++)
		for (i = 0; i < MAX_PP_PARAMS_SZ; i++)
			argvalues[i] = argvalues32[i];
			argvalues[i] = argvalues32[i];


		rc = audio_effects_set_pp_param(effects, argvalues);
		rc = audio_effects_set_pp_param(effects, argvalues);
		mutex_unlock(&effects->lock);
		break;
		break;
	}
	}
	case AUDIO_START32: {
	case AUDIO_START32: {
+8 −2
Original line number Original line Diff line number Diff line
@@ -118,12 +118,12 @@ static const u32 lpi_offset[] = {
	0x00005010,
	0x00005010,
	0x00005020,
	0x00005020,
	0x00005030,
	0x00005030,
	0x00005040,
	0x00005050,
	0x00006000,
	0x00006000,
	0x00006010,
	0x00006010,
	0x00007000,
	0x00007000,
	0x00007010,
	0x00007010,
	0x00005040,
	0x00005050,
	0x00008000,
	0x00008000,
	0x00008010,
	0x00008010,
	0x00008020,
	0x00008020,
@@ -406,13 +406,19 @@ static void lpi_gpio_set(struct gpio_chip *chip, unsigned int pin, int value)
static int lpi_notifier_service_cb(struct notifier_block *this,
static int lpi_notifier_service_cb(struct notifier_block *this,
				   unsigned long opcode, void *ptr)
				   unsigned long opcode, void *ptr)
{
{
	static bool initial_boot = true;

	pr_debug("%s: Service opcode 0x%lx\n", __func__, opcode);
	pr_debug("%s: Service opcode 0x%lx\n", __func__, opcode);


	switch (opcode) {
	switch (opcode) {
	case AUDIO_NOTIFIER_SERVICE_DOWN:
	case AUDIO_NOTIFIER_SERVICE_DOWN:
		if (initial_boot)
			break;
		lpi_dev_up = false;
		lpi_dev_up = false;
		break;
		break;
	case AUDIO_NOTIFIER_SERVICE_UP:
	case AUDIO_NOTIFIER_SERVICE_UP:
		if (initial_boot)
			initial_boot = false;
		lpi_dev_up = true;
		lpi_dev_up = true;
		break;
		break;
	default:
	default:
+1 −2
Original line number Original line Diff line number Diff line
@@ -97,8 +97,7 @@ static int __apr_tal_write(struct apr_svc_ch_dev *apr_ch, void *data,
	unsigned long flags;
	unsigned long flags;


	spin_lock_irqsave(&apr_ch->w_lock, flags);
	spin_lock_irqsave(&apr_ch->w_lock, flags);
	rc = glink_tx(apr_ch->handle, pkt_priv, data, len,
	rc = glink_tx(apr_ch->handle, pkt_priv, data, len, GLINK_TX_ATOMIC);
			GLINK_TX_REQ_INTENT | GLINK_TX_ATOMIC);
	spin_unlock_irqrestore(&apr_ch->w_lock, flags);
	spin_unlock_irqrestore(&apr_ch->w_lock, flags);


	if (rc)
	if (rc)
+8 −0
Original line number Original line Diff line number Diff line
@@ -531,6 +531,13 @@ static int wdsp_glink_ch_info_init(struct wdsp_glink_priv *wpriv,
	u8 *payload;
	u8 *payload;
	u32 ch_size, ch_cfg_size;
	u32 ch_size, ch_cfg_size;


	mutex_lock(&wpriv->glink_mutex);
	if (wpriv->ch) {
		dev_err(wpriv->dev, "%s: glink ch memory is already allocated\n",
			 __func__);
		ret = -EINVAL;
		goto done;
	}
	payload = (u8 *)pkt->payload;
	payload = (u8 *)pkt->payload;
	no_of_channels = pkt->no_of_channels;
	no_of_channels = pkt->no_of_channels;


@@ -611,6 +618,7 @@ static int wdsp_glink_ch_info_init(struct wdsp_glink_priv *wpriv,
	wpriv->no_of_channels = 0;
	wpriv->no_of_channels = 0;


done:
done:
	mutex_unlock(&wpriv->glink_mutex);
	return ret;
	return ret;
}
}


Loading