All of lore.kernel.org
 help / color / mirror / Atom feed
From: Sergey Senozhatsky <senozhatsky@chromium.org>
To: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
Cc: pierre-louis.bossart@linux.intel.com,
	alsa-devel@alsa-project.org, kai.vehmanen@linux.intel.com,
	cujomalainey@google.com, ranjani.sridharan@linux.intel.com,
	lgirdwood@gmail.com, senozhatsky@chromium.org,
	broonie@kernel.org
Subject: Re: [PATCH] ASoC: SOF: ipc3-topology: Correct get_control_data for non bytes payload
Date: Wed, 27 Apr 2022 19:36:57 +0900	[thread overview]
Message-ID: <YmkcyRlTeTRYeUH+@google.com> (raw)
In-Reply-To: <20220427085011.21805-1-peter.ujfalusi@linux.intel.com>

On (22/04/27 11:50), Peter Ujfalusi wrote:
> @@ -784,16 +785,23 @@ static int sof_get_control_data(struct snd_soc_component *scomp,
>  		}
>  
>  		cdata = wdata[i].control->ipc_control_data;
> -		wdata[i].pdata = cdata->data;
> -		if (!wdata[i].pdata)
> -			return -EINVAL;
>  
>  		/* make sure data is valid - data can be updated at runtime */
> -		if (widget->dobj.widget.kcontrol_type[i] == SND_SOC_TPLG_TYPE_BYTES &&
> -		    wdata[i].pdata->magic != SOF_ABI_MAGIC)
> -			return -EINVAL;
> +		if (widget->dobj.widget.kcontrol_type[i] == SND_SOC_TPLG_TYPE_BYTES) {
> +			if (!cdata->data)
> +				return -EINVAL;
> +
> +			if (cdata->data->magic != SOF_ABI_MAGIC)
> +				return -EINVAL;
> +
> +			wdata[i].pdata = cdata->data->data;
> +			wdata[i].pdata_size = cdata->data->size;
> +		} else {
> +			wdata[i].pdata = cdata->chanv; /* points to the control data union */
> +			wdata[i].pdata_size = wdata[i].control->size;
				^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
A question, so here wdata[i].control->size is

	scontrol->size = struct_size(scontrol->control_data, chanv,
					le32_to_cpu(mc->num_channels));

Right?

If so, then is this really what we memcpy()? We memcpy() control->data->chanv
and its size is `sizeof(chanv) * le32_to_cpu(mc->num_channels)`, isn't it?

[..]
>  	if (ipc_data_size) {
>  		for (i = 0; i < widget->num_kcontrols; i++) {
> +			if (!wdata[i].pdata_size)
> +				continue;
> +
> +			memcpy(&process->data[offset], wdata[i].pdata,
> +			       wdata[i].pdata_size);
> +			offset += wdata[i].pdata_size;
>  		}
>  	}

So should sof_get_control_data() have instead of this

	wdata[i].pdata_size = wdata[i].control->size;

something like this

	wdata[i].pdata_size = wdata[i].control->size - sizeof(struct sof_ipc_ctrl_data);

So that we will copy payload data, which is a bunch of chanv structs 8
bytes each.

  reply	other threads:[~2022-04-27 10:38 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-27  8:50 [PATCH] ASoC: SOF: ipc3-topology: Correct get_control_data for non bytes payload Peter Ujfalusi
2022-04-27 10:36 ` Sergey Senozhatsky [this message]
2022-04-27 10:43   ` Péter Ujfalusi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=YmkcyRlTeTRYeUH+@google.com \
    --to=senozhatsky@chromium.org \
    --cc=alsa-devel@alsa-project.org \
    --cc=broonie@kernel.org \
    --cc=cujomalainey@google.com \
    --cc=kai.vehmanen@linux.intel.com \
    --cc=lgirdwood@gmail.com \
    --cc=peter.ujfalusi@linux.intel.com \
    --cc=pierre-louis.bossart@linux.intel.com \
    --cc=ranjani.sridharan@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.