Skip to content

Conversation

@lyakh
Copy link
Collaborator

@lyakh lyakh commented Jul 15, 2025

Don't override const attributes to modify read-only data.

@lyakh
Copy link
Collaborator Author

lyakh commented Jul 15, 2025

should resolve #10117

@lyakh lyakh force-pushed the ops branch 2 times, most recently from 949d6d4 to 8d642b3 Compare July 15, 2025 11:02
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.

One open on driver const. Others patches all good.

/** \brief Holds constant pointer to component driver */
struct comp_driver_info {
const struct comp_driver *drv; /**< pointer to component driver */
struct comp_driver *dyn_drv; /**< pointer to dynamically created component driver -
Copy link
Member

Choose a reason for hiding this comment

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

What fields are being modified in driver ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@lgirdwood the module adapter operations pointer - it is set when a module is loaded fa2fe34#diff-957336c9ebdbe16dab94f6e49620e9b112d3b373d3de4d1035cdf289f745a00dL521-R532 . But thinking about it - maybe it's better to only store a pointer to that pointer here, not to the complete struct comp_driver object. Let me change that.

lyakh added 2 commits July 16, 2025 12:16
Zephyr inserts function names into logs automatically, no need to
duplicate them in log format strings.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
comp_drivers_get()->lock is guarding the global list of component
drivers, no need for the chain DMA driver to take it.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
@lyakh
Copy link
Collaborator Author

lyakh commented Jul 16, 2025

having observed PTL failures https://sof-ci.01.org/sofpr/PR10118/build13953/devicetest/index.html with the original version, trying to drop supposedly the only commit, that can cause such regressions - "ipc4: remove needless interrupt disabling"

Using a type-cast to override a "const" attribute and modify read-
only data is unsafe. Add a writable pointer to struct
comp_driver_info instead and use it when creating component drivers
dynamically.

Signed-off-by: Guennadi Liakhovetski <guennadi.liakhovetski@linux.intel.com>
@lyakh
Copy link
Collaborator Author

lyakh commented Jul 17, 2025

This obviously conflicts with #10098 but should be easy to resolve either way, whichever PR gets merged first.

@lyakh lyakh marked this pull request as ready for review July 17, 2025 07:56
@lyakh
Copy link
Collaborator Author

lyakh commented Jul 18, 2025

having observed PTL failures https://sof-ci.01.org/sofpr/PR10118/build13953/devicetest/index.html with the original version, trying to drop supposedly the only commit, that can cause such regressions - "ipc4: remove needless interrupt disabling"

UPDATE: that isn't a regression, the issue is known #10116

key = k_spin_lock(&drivers->lock);
switch (cd->chain_task.state) {
case SOF_TASK_STATE_QUEUED:
k_spin_unlock(&drivers->lock, key);
Copy link
Contributor

@jsarha jsarha Jul 22, 2025

Choose a reason for hiding this comment

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

Even if the used lock is wrong, it does not automatically mean that no locking is needed. Even the wrong lock protects against interleaved function calls. I have no idea if those can happen, so this is just a worried comment.

Copy link
Member

Choose a reason for hiding this comment

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

@lyakh I suppose you could followup with a comment declaring where the lock is held for the state check.

@lgirdwood lgirdwood merged commit 632dca3 into thesofproject:main Jul 22, 2025
40 of 45 checks passed
@lyakh lyakh deleted the ops branch July 22, 2025 13:43
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.

3 participants