Skip to content
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

ASoC: SOF: fix return values for mandatory ops #539

Merged
merged 1 commit into from
Feb 7, 2019

Conversation

ranj063
Copy link
Collaborator

@ranj063 ranj063 commented Jan 14, 2019

Fix return value for mandatory ops.

Signed-off-by: Ranjani Sridharan ranjani.sridharan@linux.intel.com

@ranj063
Copy link
Collaborator Author

ranj063 commented Jan 14, 2019

@plbossart this leaves only the PCM ops but I'm not sure whether they are mandotory or not. Could you please comment?

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

this looks ok but I'd like error messages to reflect the name of the function with the _ included. That helps for searches.
Also it'd be good to tag the callbacks in the header file as mandatory/optional so that the information is in one place.

sound/soc/sof/ops.h Show resolved Hide resolved
@ranj063
Copy link
Collaborator Author

ranj063 commented Jan 16, 2019

@plbossart fixed now. Could you please cross-check if the list of mandatory and optional ops is correct?

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

@lgirdwood @keyonjie can you look at the list of mandatory ops and comment? I am afraid we have no documentation of what is expected in a minimal case?

@@ -67,6 +67,9 @@ struct snd_sof_pdata;
* and DSP device(s).
*/
struct snd_sof_dsp_ops {

/* The following ops are mandatory */
Copy link
Member

Choose a reason for hiding this comment

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

it's not very easy to figure out where the list stops. maybe for each op so that is can be searched whether it's optional or mandatory?

Copy link

@keyonjie keyonjie left a comment

Choose a reason for hiding this comment

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

  1. we don't have .remove yet for skl- platforms(please fix that).
  2. stall, core_power_up/down should be optional.
  3. write, read, write64, read64, block_read, block_write are same for all our platforms so let's remove them from struct snd_sof_dsp_ops.

Others looks fine.

@@ -67,6 +67,9 @@ struct snd_sof_pdata;
* and DSP device(s).
*/
struct snd_sof_dsp_ops {

/* The following ops are mandatory */

/* probe and remove */
int (*remove)(struct snd_sof_dev *sof_dev);

Choose a reason for hiding this comment

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

I agree we should make .remove mandatory, but the fact is that we don't have it on skl- platforms yet, better to fix them together at one shot(e.g. define an empty one at least).

Copy link
Member

Choose a reason for hiding this comment

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

why should .remove be mandatory? if all your driver uses devm_ stuff and the hardware is reset correctly in the .probe, why would we care?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@plbossart going by what remove() does for SKL+, we also disable the DSP in remove(). Given that we are not really unloading the topology from the DSP like we do in the case of load, shouldnt we also be turning off the DSP here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@plbossart i believe for module load/unload to work in SOF, we should make remove() mandatory so that the DSP can be turned OFF here. Please let me know if you disagree and I'll make changes accordingly.

sound/soc/sof/sof-priv.h Show resolved Hide resolved
@ranj063
Copy link
Collaborator Author

ranj063 commented Jan 17, 2019

  1. we don't have .remove yet for skl- platforms(please fix that).
  2. stall, core_power_up/down should be optional.

@keyonjie With SMP enabled in the driver, they are no long optional.

  1. write, read, write64, read64, block_read, block_write are same for all our platforms so let's remove them from struct snd_sof_dsp_ops.

Others looks fine.

@keyonjie
Copy link

  1. we don't have .remove yet for skl- platforms(please fix that).
  2. stall, core_power_up/down should be optional.

@keyonjie With SMP enabled in the driver, they are no long optional.

for SKL- platforms, we don't have SMP there, I meant those callbacks are not mandatory for snd_sof_dsp_ops (e.g. no need for byt), but they are mandatory for apl/cnl?

  1. write, read, write64, read64, block_read, block_write are same for all our platforms so let's remove them from struct snd_sof_dsp_ops.

Others looks fine.

@ranj063
Copy link
Collaborator Author

ranj063 commented Jan 17, 2019

  1. we don't have .remove yet for skl- platforms(please fix that).
  2. stall, core_power_up/down should be optional.

@keyonjie With SMP enabled in the driver, they are no long optional.

for SKL- platforms, we don't have SMP there, I meant those callbacks are not mandatory for snd_sof_dsp_ops (e.g. no need for byt), but they are mandatory for apl/cnl?

  1. write, read, write64, read64, block_read, block_write are same for all our platforms so let's remove them from struct snd_sof_dsp_ops.

Others looks fine.

@keyonjie ok Makes sense

@ranj063
Copy link
Collaborator Author

ranj063 commented Jan 17, 2019

  1. we don't have .remove yet for skl- platforms(please fix that).
  2. stall, core_power_up/down should be optional.
  3. write, read, write64, read64, block_read, block_write are same for all our platforms so let's remove them from struct snd_sof_dsp_ops.

@keyonjie hsw-spi.c has a different set of ops!

Others looks fine.

@ranj063 ranj063 closed this Jan 17, 2019
@ranj063 ranj063 deleted the upstream/ops_fixes branch January 17, 2019 07:27
@ranj063 ranj063 restored the upstream/ops_fixes branch January 17, 2019 07:29
@ranj063 ranj063 reopened this Jan 17, 2019
@ranj063 ranj063 closed this Jan 17, 2019
@ranj063 ranj063 deleted the upstream/ops_fixes branch January 17, 2019 07:30
@ranj063 ranj063 restored the upstream/ops_fixes branch January 17, 2019 07:30
@ranj063 ranj063 reopened this Jan 17, 2019
@ranj063
Copy link
Collaborator Author

ranj063 commented Jan 17, 2019

@keyonjie @plbossart PR updated now.

@plbossart
Copy link
Member

@ranj063 can you rebase, there is conflict. Also please mark each function as mandatory/optional, you are mixing the two styles (per function and per block) which will make searches more complicated.
Thanks!

@ranj063
Copy link
Collaborator Author

ranj063 commented Jan 22, 2019

@plbossart this one has been updated too. There are 2 lines over 80 chars which checkpatch complains about but I think there's no simple way to address it while keeping the style consistent for marking the ops are madatory/optional.

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

Humm, I am not sure I agree with the mandatory support for PCM (SueCreek being the counter example) and there are some inconsistencies between the errors and tags. Maybe we should shoot for a lower bar of what is really mandatory?

@@ -330,7 +345,8 @@ snd_sof_pcm_platform_pointer(struct snd_sof_dev *sdev,
if (sof_ops(sdev) && sof_ops(sdev)->pcm_pointer)
return sof_ops(sdev)->pcm_pointer(sdev, substream);

return 0;
dev_err(sdev->dev, "error: %s not defined\n", __func__);
return -ENOTSUPP;
Copy link
Member

Choose a reason for hiding this comment

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

Are PCM operations actually required? Take the example of Sue Creek, you may have all the processing done on the device itself with no PCM being passed back to the host?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@plbossart ok i will make these optional

u64 (*read64)(struct snd_sof_dev *sof_dev, void __iomem *addr);
u64 value); /* mandatory */
u64 (*read64)(struct snd_sof_dev *sof_dev,
void __iomem *addr); /* mandatory */
Copy link
Member

Choose a reason for hiding this comment

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

this is inconsistent with the fact that those functions return 0 if not supported?

@ranj063
Copy link
Collaborator Author

ranj063 commented Jan 26, 2019

@plbossart i've updated the PR based on your comments.

@wenqingfu
Copy link

ping @plbossart

@plbossart
Copy link
Member

plbossart commented Jan 29, 2019 via email

@ranj063
Copy link
Collaborator Author

ranj063 commented Feb 5, 2019

@plbossart I've updated this PR now to address your comment about the is_ready() op. There will be conflicts between this one and my other PR where I have changed the name for this op. I will update them depending on which one gets merged first.

@ranj063
Copy link
Collaborator Author

ranj063 commented Feb 5, 2019

@plbossart please dont merge this. with the return value of undefined values change to < 0, I need to ensure the check is done correctly.

@ranj063
Copy link
Collaborator Author

ranj063 commented Feb 6, 2019

@plbossart this one has been updated now.

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

Sorry, this still needs more work, some of the mandatory parts are not used so something's wrong.

if (is_dsp_ipc_ready < 0) {
spin_unlock_irq(&sdev->ipc_lock);
return -EBUSY;
}
Copy link
Member

Choose a reason for hiding this comment

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

sorry, what does this do?
The is_ready op is marked a mandatory
int (*is_ready)(struct snd_sof_dev sof_dev); / mandatory */

The comment seems wrong?

/* FW loading */
int (*load_firmware)(struct snd_sof_dev *sof_dev); /* mandatory */
int (*load_module)(struct snd_sof_dev *sof_dev,
struct snd_sof_mod_hdr *hdr); /* mandatory */
Copy link
Member

Choose a reason for hiding this comment

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

meh, this is not defined for HDAudio.

int (*reset)(struct snd_sof_dev *sof_dev);
int (*run)(struct snd_sof_dev *sof_dev); /* mandatory */
int (*stall)(struct snd_sof_dev *sof_dev); /* optional */
int (*reset)(struct snd_sof_dev *sof_dev); /* mandatory */
Copy link
Member

Choose a reason for hiding this comment

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

meh. not defined for HDaudio.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@plbossart all 3 comments addressed and PR updated now.

Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

minor nit-pick on dev_err when we return void, looks ok otherwise

return;
}

dev_err(sdev->dev, "error: %s not defined\n", __func__);
Copy link
Member

Choose a reason for hiding this comment

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

Ah sorry, I just thought about this one. Since this will not interrupt the flow, we may want to add a _once or _ratelimited qualifier to avoid polluting dmesg. Same remark for all cases where we return void.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@plbossart done

Clarify the mandatory and optional dsp ops and fix
return value for mandatory ops.

Signed-off-by: Ranjani Sridharan <ranjani.sridharan@linux.intel.com>
Copy link
Member

@plbossart plbossart left a comment

Choose a reason for hiding this comment

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

Thanks, merging now.

@plbossart plbossart merged commit 4066063 into thesofproject:topic/sof-dev Feb 7, 2019
@ranj063 ranj063 deleted the upstream/ops_fixes branch February 8, 2019 06:36
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.

4 participants