Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 150
Fix HDaudio probe/remove #274
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
Uh oh!
There was an error while loading. Please reload this page.
Changes from all commits
8c4b55836bc50906f240290277c3304a29652e0435bdfd569aeb1db3dc91aead8f615aFile filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -459,8 +459,11 @@ static int hda_init_caps(struct snd_sof_dev *sdev) | ||
| ret = hda_dsp_ctrl_init_chip(sdev, true); | ||
| if (ret < 0) { | ||
| dev_err(bus->dev, "Init chip failed with ret: %d\n", ret); | ||
| if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) | ||
| snd_hdac_display_power(bus, false); | ||
| if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { | ||
| ret = hda_codec_i915_put(sdev); | ||
| if (ret < 0) | ||
| return ret; | ||
| } | ||
| return ret; | ||
| } | ||
| @@ -477,11 +480,9 @@ static int hda_init_caps(struct snd_sof_dev *sdev) | ||
| hda_codec_probe_bus(sdev); | ||
| if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) { | ||
| ret = snd_hdac_display_power(bus, false); | ||
| if (ret < 0) { | ||
| dev_err(bus->dev, "Cannot turn off display power on i915\n"); | ||
| ret = hda_codec_i915_put(sdev); | ||
| if (ret < 0) | ||
| return ret; | ||
| } | ||
| } | ||
| /* | ||
| @@ -563,15 +564,17 @@ int hda_dsp_probe(struct snd_sof_dev *sdev) | ||
| #endif | ||
| /* set up HDA base */ | ||
| bus = sof_to_bus(sdev); | ||
| ret = hda_init(sdev); | ||
| if (ret < 0) | ||
| return ret; | ||
| goto hdac_bus_unmap; | ||
| /* DSP base */ | ||
| sdev->bar[HDA_DSP_BAR] = pci_ioremap_bar(pci, HDA_DSP_BAR); | ||
| if (!sdev->bar[HDA_DSP_BAR]) { | ||
| dev_err(&pci->dev, "error: ioremap error\n"); | ||
| return -ENXIO; | ||
| ret = -ENXIO; | ||
| goto hdac_bus_unmap; | ||
| } | ||
| sdev->mmio_bar = HDA_DSP_BAR; | ||
| @@ -595,7 +598,7 @@ int hda_dsp_probe(struct snd_sof_dev *sdev) | ||
| * not all errors are due to memory issues, but trying | ||
| * to free everything does not harm | ||
| */ | ||
| goto err; | ||
| goto free_streams; | ||
| } | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. initial streams fails, no streams to be freed? if streams are partially initialized success, better to do free to those initialized inside stream_init(), at e.g. it's exiting of function. | ||
| /* | ||
| @@ -619,7 +622,6 @@ int hda_dsp_probe(struct snd_sof_dev *sdev) | ||
| sdev->ipc_irq = sdev->hda->irq; | ||
| } | ||
| bus = sof_to_bus(sdev); | ||
| dev_dbg(sdev->dev, "using HDA IRQ %d\n", sdev->hda->irq); | ||
| ret = request_threaded_irq(sdev->hda->irq, hda_dsp_stream_interrupt, | ||
| hda_dsp_stream_threaded_handler, | ||
| @@ -720,10 +722,11 @@ int hda_dsp_probe(struct snd_sof_dev *sdev) | ||
| pci_free_irq_vectors(pci); | ||
| free_streams: | ||
| hda_dsp_stream_free(sdev); | ||
| /* dsp_unmap: not currently used */ | ||
| iounmap(sdev->bar[HDA_DSP_BAR]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, this is what I mentioned above. | ||
| hdac_bus_unmap: | ||
| iounmap(bus->remap_addr); | ||
| err: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And when looking into hda_init() more, only pci_ioremap_bar() may get error and return the error(hda_dsp_ctrl_get_caps() returns 0 always, maybe we should change its return type to void also), so we may don't need this iounmap() here, and do iounmap() in hda_dsp_remove(). | ||
| /* disable DSP */ | ||
| snd_sof_dsp_update_bits(sdev, HDA_DSP_PP_BAR, SOF_HDA_REG_PP_PPCTL, | ||
| SOF_HDA_PPCTL_GPROCEN, 0); | ||
| return ret; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this removing is good. | ||
| } | ||
| @@ -756,10 +759,17 @@ int hda_dsp_remove(struct snd_sof_dev *sdev) | ||
| SOF_HDA_PPCTL_GPROCEN, 0); | ||
| free_irq(sdev->ipc_irq, sdev); | ||
| free_irq(sdev->pci->irq, bus); | ||
| free_irq(sdev->hda->irq, bus); | ||
| pci_free_irq_vectors(pci); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto.
| ||
| hda_dsp_stream_free(sdev); | ||
| iounmap(sdev->bar[HDA_DSP_BAR]); | ||
| iounmap(bus->remap_addr); | ||
| if (IS_ENABLED(CONFIG_SND_SOC_HDAC_HDMI)) | ||
| hda_codec_i915_exit(sdev); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this LGTM. | ||
| return 0; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. these are good, but I still like adding conditions such as 'if (bus->remap_addr)'. MemberAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it's not necessary, you will not have a case where this is NULL since .remove is not called when .probe fails? | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This 'goto hdac_bus_unmap' is fine, but we may need add some error point e.g. 'dsp_bar_unmap' where we will do iounmap for sdev->bar[HDA_DSP_BAR].