-
Notifications
You must be signed in to change notification settings - Fork 140
Ro volatile byte kcontrol #2368
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
0b5c5b7 to
63e526d
Compare
bardliao
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some comments based on SNDRV_CTL_ELEM_ACCESS_TLV_READWRITE = (SNDRV_CTL_ELEM_ACCESS_TLV_READ|SNDRV_CTL_ELEM_ACCESS_TLV_WRITE), and checkpatch.pl errors
63e526d to
76e3a7f
Compare
sound/soc/sof/control.c
Outdated
| SOF_CTRL_TYPE_DATA_GET, scontrol->cmd, false); | ||
|
|
||
| /* Prevent read of other kernel data or possibly corrupt response */ | ||
| data_size = cdata->data->size + sizeof(const struct sof_abi_hdr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should you also include the size of tlv header in this calculation?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi Ranjani,
I dont think TLV header is needed here. For get params IPC, fw sends the response as sof_abi_hdr + model data.
cdata->data->size is just the model data size. So, for the condition check here, cdata->data->size + sizeof(const struct sof_abi_hdr) becomes mandatory(data_size > be->max) be->max is from topology the max control size.
data_size will just hold the actual data size from the firmware(ABI_header + model_data).
The application reading data while allocating the buffer to read will add the size for tlv header.
eg: sof-ctl:
/*
* Allocate buffer for tlv write/read. The buffer needs a two
* words header with tag (SOF_CTRL_CMD_BINARY) and size in bytes.
*/
buffer_size = ctl_data->ctrl_size + 2 * sizeof(unsigned int);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for the explanation @RDharageswari .In that case the check looks fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't know how paranoid we want to be here, but in principle you have an overflow possibility here. If cdata->data->size is returned by the FW as a small negative number (-1), it'll pass the test, but obviously that's invalid.
kv2019i
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @RDharageswari A couple of notes/questions inline.
76e3a7f to
39ba17b
Compare
sound/soc/soc-topology.c
Outdated
|
|
||
| /* vendor specific handlers found ? */ | ||
| if (k->put && k->get && k->info) | ||
| /* RW controls need to have both get/put IO handlers */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@RDharageswari these checks are for the io_ops and not for the ext_ops right? Do we really need to check these here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed the handling here
This patch adds support for write-only and read-only TLV byte kcontrols by checking for appropriate get/put IO handlers. Signed-off-by: Dharageswari R <dharageswari.r@intel.com>
9ab1b78 to
86c21a6
Compare
ranj063
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now @RDharageswari . Thanks!
kv2019i
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good now, thanks @RDharageswari ! One CI fail, but that seems unrelated (BDW version not found -> need to debug this separately as a CI issue).
|
@bardliao you good with the changes now? |
sound/soc/sof/control.c
Outdated
| SOF_CTRL_TYPE_DATA_GET, scontrol->cmd, false); | ||
|
|
||
| /* Prevent read of other kernel data or possibly corrupt response */ | ||
| data_size = cdata->data->size + sizeof(const struct sof_abi_hdr); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't know how paranoid we want to be here, but in principle you have an overflow possibility here. If cdata->data->size is returned by the FW as a small negative number (-1), it'll pass the test, but obviously that's invalid.
sound/soc/sof/control.c
Outdated
| struct sof_ipc_ctrl_data *cdata = scontrol->control_data; | ||
| struct snd_ctl_tlv header; | ||
| struct snd_ctl_tlv __user *tlvd = (struct snd_ctl_tlv __user *)binary_data; | ||
| int data_size; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
size_t
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
cad6e1f
86c21a6 to
cad6e1f
Compare
sound/soc/sof/control.c
Outdated
| data_size = cdata->data->size + sizeof(const struct sof_abi_hdr); | ||
|
|
||
| /* check data size doesn't exceed max coming from topology */ | ||
| if (data_size > be->max) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the point I was trying to make above is, that this test is incomplete. You're writing, that you want to check for corrupted data, but if, as I suggested, cdata->data->size == (uint32_t)-1, which is invalid, you won't catch it. Please have a look at #2383
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
This patch implements the snd_sof_bytes_ext_volatile_get() to read the actual parameters from DSP by sending the SOF_IPC_COMP_GET_DATA IPC for the kcontrol of type SOF_TPLG_KCTL_BYTES_VOLATILE_RO. Signed-off-by: Dharageswari R <dharageswari.r@intel.com>
cad6e1f to
769ca38
Compare
This patch set allows a user to create Readonly and writeonly kcontrols. It also adds the snd_sof_bytes_ext_get_pm IO control to get the "actual values" of the requested parameters from DSP. These patches mainly help for the tuning purpose.