Skip to content

Conversation

@RDharageswari
Copy link

@RDharageswari RDharageswari commented Aug 15, 2020

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.

Copy link
Collaborator

@bardliao bardliao left a 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

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);
Copy link
Collaborator

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?

Copy link
Author

@RDharageswari RDharageswari Aug 20, 2020

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);

Copy link
Collaborator

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.

Copy link
Collaborator

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.

Copy link
Collaborator

@kv2019i kv2019i left a 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.

@RDharageswari RDharageswari force-pushed the RO_volatile_byte_kcontrol branch from 76e3a7f to 39ba17b Compare August 20, 2020 05:59

/* vendor specific handlers found ? */
if (k->put && k->get && k->info)
/* RW controls need to have both get/put IO handlers */
Copy link
Collaborator

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?

Copy link
Author

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>
@RDharageswari RDharageswari force-pushed the RO_volatile_byte_kcontrol branch from 9ab1b78 to 86c21a6 Compare August 20, 2020 21:51
ranj063
ranj063 previously approved these changes Aug 20, 2020
Copy link
Collaborator

@ranj063 ranj063 left a 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!

@RDharageswari RDharageswari requested a review from ranj063 August 20, 2020 22:43
kv2019i
kv2019i previously approved these changes Aug 21, 2020
Copy link
Collaborator

@kv2019i kv2019i left a 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).

@ranj063
Copy link
Collaborator

ranj063 commented Aug 21, 2020

@bardliao you good with the changes now?

bardliao
bardliao previously approved these changes Aug 24, 2020
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);
Copy link
Collaborator

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.

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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

size_t

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@RDharageswari RDharageswari dismissed stale reviews from bardliao, kv2019i, and ranj063 via cad6e1f August 25, 2020 02:47
@RDharageswari RDharageswari force-pushed the RO_volatile_byte_kcontrol branch from 86c21a6 to cad6e1f Compare August 25, 2020 02:47
ranj063
ranj063 previously approved these changes Aug 25, 2020
bardliao
bardliao previously approved these changes Aug 25, 2020
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) {
Copy link
Collaborator

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

Copy link
Author

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>
@RDharageswari RDharageswari dismissed stale reviews from bardliao and ranj063 via 769ca38 August 25, 2020 18:52
@RDharageswari RDharageswari force-pushed the RO_volatile_byte_kcontrol branch from cad6e1f to 769ca38 Compare August 25, 2020 18:52
@plbossart plbossart merged commit 33fd4f9 into topic/sof-dev Aug 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants