Skip to content

Conversation

@ujfalusi
Copy link
Contributor

Add definition for generic bytes control and fix the get functionality

The LARGE_CONFIG_GET for generic controls have been broken (no module implements it) because the information about the control's ID was not propagated to the modules.

kernel PR: thesofproject/linux#5531

Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

Only minor opens from me.

Comment on lines 1013 to 1027
/* Copy the control payload header from inbox to outbox */
memcpy_s(data_out, data_size,
data_in, sizeof(struct sof_ipc4_control_msg_payload));
}
Copy link
Member

Choose a reason for hiding this comment

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

Reads easier if the memcpy is part of the switch {} ie. the action is contained within the decision block

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK.

if (!set)
msg_reply.extension = config->extension.dat;

return ret;
Copy link
Collaborator

Choose a reason for hiding this comment

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

typos in commit:

  • s/fro example/for example/
  • s/is coped/is copied/
  • s/would not worked/would not have worked/

Add definition for generic bytes control and extend the
sof_ipc4_control_msg_payload struct to be able to handle bytes data as
well.

In other terms, the generic bytes control can be handled in similar way as
the ENUM or SWITCH generic control.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
@ujfalusi ujfalusi force-pushed the peter/pr/generic-bytes-control-01 branch from 2306509 to 280336d Compare September 12, 2025 13:04
@ujfalusi
Copy link
Contributor Author

Changes since v1:

  • typos fixed in commit message
  • moved the memcpy under the case directly

Copy link
Collaborator

@singalsu singalsu left a comment

Choose a reason for hiding this comment

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

Code works and looks good to me.

}

__cold static void
ipc4_prepare_for_kcontrol_get(struct comp_dev *dev, uint8_t param_id,
Copy link
Collaborator

Choose a reason for hiding this comment

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

the two lines can be trivially joined without exceeding the maximum line length

ipc4_prepare_for_kcontrol_get(struct comp_dev *dev, uint8_t param_id,
uint32_t data_size, const char *data_in,
char *data_out)
{
Copy link
Collaborator

Choose a reason for hiding this comment

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

it's ok not to call assert_can_be_cold() here because this is a static function and its only caller already calls it. But maybe we should add a comment here to explain that, so that somebody in the future doesn't re-add it here by mistake

@ujfalusi ujfalusi force-pushed the peter/pr/generic-bytes-control-01 branch from 280336d to 8cbbff8 Compare September 15, 2025 09:39
@ujfalusi
Copy link
Contributor Author

Changes since v2:

  • add call dcache_invalidate_region() on hostbox to refresh the area.

@singalsu
Copy link
Collaborator

  • add call dcache_invalidate_region() on hostbox to refresh the area.

This version runs without problems in MTL platform. Thanks Peter!

@ujfalusi ujfalusi force-pushed the peter/pr/generic-bytes-control-01 branch from 8cbbff8 to 5990229 Compare September 15, 2025 11:29
Some LARGE_CONFIG_GET message includes payload to provide instructions
to the handler modules on how to fulfill the request.

The generic control messages are such examples (they are not related to
VENDOR_CONFIG_PARAM messages):
The payload from host includes the sof_ipc4_control_msg_payload struct to
describe the ID of the control for example. Alone the type (enum, switch
or bytes) is not enough to know _which_ control's information is requested.
Similarly, the control's ID does not identify the control's type.

When such generic control message is received, the payload is copied from
hostbox to the comp_data and the handler module can inspect it before
overwriting it with the requested data.

Note: currently we don't have modules which would handle generic control
get functionality, but they would not have worked, because the information
was not available to them to decide which control's data needs to be
returned.

Signed-off-by: Peter Ujfalusi <peter.ujfalusi@linux.intel.com>
@ujfalusi
Copy link
Contributor Author

Changes since v3:

  • add handling of CONFIG_LIBRARY in similar way as ipc4_set_large_config_module_instance() does it
  • add assert_can_be_cold() call to ipc4_prepare_for_kcontrol_get()

sizeof(struct sof_ipc4_control_msg_payload));
break;
default:
break;
Copy link
Collaborator

Choose a reason for hiding this comment

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

would we more often hit one of the three cases above or end up in default case here? If default is rare, we could unite the dcache_invalidate_region() calls above and in line 1175 to put it directly below line 1170. This is optional and can also be an incremental PR. But if we usually take the default path, then maybe it isn't a good idea.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This will be highly topology dependent and we will only hit these where there is TDFB used (and it is used by user space as well) or we have sound dose enabled and actively used.

During runtime we are likely not even receiving GET_LARGE_CONFIG messages at all. I cannot say which will be the most frequent use in the future.

@lgirdwood lgirdwood merged commit 491bc1c into thesofproject:main Sep 16, 2025
38 of 45 checks passed
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.

5 participants