Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions sound/soc/sof/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)

if (IS_ERR(plat_data->pdev_mach)) {
ret = PTR_ERR(plat_data->pdev_mach);
goto comp_err;
goto fw_run_err;
}

dev_dbg(sdev->dev, "created machine %s\n",
Expand All @@ -391,8 +391,6 @@ static int sof_probe_continue(struct snd_sof_dev *sdev)

return 0;

comp_err:
snd_soc_unregister_component(sdev->dev);

@keyonjie keyonjie May 6, 2019 •

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Is this really helpful for fixing #861 or only changing it while you are at here? My understanding is that we can invoke unregister specifically for resource-managed component device.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

yup, just while i'm at it. Not relevant for #861. Only the first commit is needed to fix the issue

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'm not sure this is a good idea. This is a .probe() "bottom half," it's often performed in a work context after the actual probing has completed and returned success. Usually when you use managed allocations, it's done within .probe(), so that a failure leads to the .probe() failing and then all such allocations are freed. In this case an allocation failure will not lead to .probe() failing, so, the resource will stay allocated. This isn't bad, it will be freed if the modules are unloaded, but it's also not useful to keep it in the error case. So, maybe better to keep that unregister.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@lyakh i havent tried this yet but what happens if you leave the unregister here, the machine driver registration fails and then you try to unload sof device?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

@ranj063 I haven't tried either. Nothing bad should happen at the resource management level, you have already unregistered the resource, so, no second unregistering will be attempted by the resource management system. But I don't know whether the driver's .release() method would choke because it assumes that the registration has completed successfully.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@lyakh i just tried it and nothing bad happened. I am OK to leave it here or remove it. removing it makes more sense to me but if you prefer leaving it here i'm OK with it too.

fw_run_err:
snd_sof_fw_unload(sdev);
fw_load_err:
Expand Down Expand Up @@ -482,7 +480,6 @@ int snd_sof_device_remove(struct device *dev)
snd_sof_ipc_free(sdev);
snd_sof_free_debug(sdev);
snd_sof_free_trace(sdev);
snd_sof_remove(sdev);

/*
* Unregister machine driver. This will unbind the snd_card which
Expand All @@ -492,6 +489,14 @@ int snd_sof_device_remove(struct device *dev)
if (!IS_ERR_OR_NULL(pdata->pdev_mach))
platform_device_unregister(pdata->pdev_mach);

/*
* Unregistering the machine driver results in unloading the topology.
* Some widgets, ex: scheduler, attempt to power down the core they are
* scheduled on, when they are unloaded. Therefore, the DSP must be
* removed only after the topology has been unloaded.
*/
snd_sof_remove(sdev);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Good catch, but still one question unclear to me:

In your commit message it is stated "snd_hdac_ext_bus_device_remove() to remove the codec which unregisters the component driver thereby also removing the topology.", per my understanding, this only remove the codec soc component(not the soc component we register here?), how does it removing the topology.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

@keyonjie take a look at __snd_soc_unregister_component() in soc-core.c. It removes the tplg for all components who's dev matches the input argument "dev". Now, in our case both the hdmic codec component device and the SOF component device are the same and thats why snd_hdac_ext_bus_device_remove() results in removing the topology

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

yes, if we share the "dev" in both hdmi codec and SOF component, that explains, thanks.

/* release firmware */
release_firmware(pdata->fw);
pdata->fw = NULL;
Expand Down