ASoC: hda: increment codec device refcount when it is added to the card
PATCH 1/1 ASoC: hda: increment codec device refcount when it is added to the card
Calling snd_device_new() makes the codec devices managed by the card. So, when the card is removed, the refcount for the codec device is decremented and results in the codec device's kobject being cleaned up if the refcount is 0. But, this leads to a NULL pointer exception while attempting to remove the symlinks when the codec driver is released later on. Therefore, increment the codec device's refcount before adding it to the card to prevent this.
--- sound/pci/hda/hda_codec.c | 8 ++++++++ 1 file changed, 8 insertions(+)
sound/pci/hda/hda_codec.c +8 -0
@@ -985,6 +985,14 @@ int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card, codec->core.subsystem_id, codec->core.revision_id);snd_component_add (card, component); +/* +* snd_device_new() makes the codec device managed by the card. +* When the card is removed, the device reference count is +* decremented. Therefore, increment it here to prevent removing +* the codec device's kobject when the card is removed. +*/ +get_device (hda_codec_dev (codec)); + err =snd_device_new (card,SNDRV_DEV_CODEC , codec, &dev_ops);if (err <0 ) goto error;
Signature · 1 line
2.17.1
Quoted 7 lines · Ranjani Sridharan
Calling
snd_device_new()makes the codec devices managed by the card. So, when the card is removed, the refcount for the codec device is decremented and results in the codec device's kobject being cleaned up if the refcount is 0. But, this leads to a NULL pointer exception while attempting to remove the symlinks when the codec driver is released later on. Therefore, increment the codec device's refcount before adding it to the card to prevent this.
Ranjani, you should add a bit of context for the rest of the list...
This patch suggest a solution to a set of sightings occurring when removing/adding modules in a loop, and the current analysis points to a difference between the way the HDMI and HDaudio codecs are handled.
https://github.com/thesofproject/linux/issues/981
https://github.com/thesofproject/linux/issues/966
https://github.com/thesofproject/linux/pull/988
Since it's not SOF specific it's better to get feedback directly from the large ALSA community/maintainers. We probably want to focus on the platform-specific/vendor-specific stuff on GitHub and use the mailing list for such framework-level changes.
Quoted 26 lines
Signed-off-by Ranjani Sridharan <[email protected]>--- sound/pci/hda/hda_codec.c | 8 ++++++++ 1 file changed, 8 insertions(+)sound/pci/hda/hda_codec.c +8
-0@@ -985,6 +985,14 @@ int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card, codec->core.subsystem_id, codec->core.revision_id);snd_component_add (card, component); +/* +* snd_device_new() makes the codec device managed by the card. +* When the card is removed, the device reference count is +* decremented. Therefore, increment it here to prevent removing +* the codec device's kobject when the card is removed. +*/ +get_device (hda_codec_dev (codec)); + err =snd_device_new (card,SNDRV_DEV_CODEC , codec, &dev_ops);if (err <0 ) goto error;
Quoted 18 lines · Pierre-Louis Bossart
Quoted 7 lines · Ranjani Sridharan
Calling
snd_device_new()makes the codec devices managed by the card. So, when the card is removed, the refcount for the codec device is decremented and results in the codec device's kobject being cleaned up if the refcount is 0. But, this leads to a NULL pointer exception while attempting to remove the symlinks when the codec driver is released later on. Therefore, increment the codec device's refcount before adding it to the card to prevent this.Ranjani, you should add a bit of context for the rest of the list...
This patch suggest a solution to a set of sightings occurring when removing/adding modules in a loop, and the current analysis points to a difference between the way the HDMI and HDaudio codecs are handled.
Quoted 8 lines
https://github.com/thesofproject/linux/issues/981
https://github.com/thesofproject/linux/issues/966
https://github.com/thesofproject/linux/pull/988Since it's not SOF specific it's better to get feedback directly from the large ALSA community/maintainers. We probably want to focus on the platform-specific/vendor-specific stuff on GitHub and use the mailing list for such framework-level changes.
Hm, I still wonder why this doens't happen with the HDA legacy.
What is the shortest way to trigger the bug manually without a script?
thanks,
Takashi
Quoted 25 lines
Quoted 24 lines
Signed-off-by Ranjani Sridharan <[email protected]>--- sound/pci/hda/hda_codec.c | 8 ++++++++ 1 file changed, 8 insertions(+)sound/pci/hda/hda_codec.c +7
-0@@ -985,6 +985,14 @@ int snd_hda_codec_device_new(struct hda_bus *bus, struct snd_card *card, codec->core.subsystem_id, codec->core.revision_id);snd_component_add (card, component); +/* +* snd_device_new() makes the codec device managed by the card. +* When the card is removed, the device reference count is +* decremented. Therefore, increment it here to prevent removing +* the codec device's kobject when the card is removed. +*/ +get_device (hda_codec_dev (codec)); + err =snd_device_new (card,SNDRV_DEV_CODEC , codec, &dev_ops);if (err <0 ) goto error;
Quoted 37 lines · Takashi Iwai
Quoted 27 lines · Pierre-Louis Bossart
Quoted 9 lines · Ranjani Sridharan
Calling
snd_device_new()makes the codec devices managed by the card.
So, when the card is removed, the refcount for the codec device is decremented and results in the codec device's kobject being cleaned up if the refcount is 0. But, this leads to a NULL pointer exception while attempting to remove the symlinks when the
codec driver is released later on. Therefore, increment the codec device's refcount before adding it to the card to prevent this.Ranjani, you should add a bit of context for the rest of the list...
This patch suggest a solution to a set of sightings occurring when removing/adding modules in a loop, and the current analysis points to
a difference between the way the HDMI and HDaudio codecs are handled.https://github.com/thesofproject/linux/issues/981
https://github.com/thesofproject/linux/issues/966
https://github.com/thesofproject/linux/pull/988Quoted 7 lines
Since it's not SOF specific it's better to get feedback directly from
the large ALSA community/maintainers. We probably want to focus on the
platform-specific/vendor-specific stuff on GitHub and use the mailing
list for such framework-level changes.
Quoted 4 lines
Hm, I still wonder why this doens't happen with the HDA legacy.
What is the shortest way to trigger the bug manually without a script?
Hi Takashi,
With SOF, I can reproduce the issue if I just unload the sof_pci_dev module with rmmod.
Basically, the remove routine for the SOF pci device, unregisters the machine driver and then removes the codec device. So the first step of unregistering the machine driver frees the card which decrements the refcount for the HDA codec's kobject. In the case of HDMI codec, since it is not managed by the card, the refcount is not decremented when the card is removed.
Thanks,
Ranjani
Quoted 7 lines
thanks,
Takashi
Quoted 48 lines · Ranjani Sridharan
Quoted 37 lines · Takashi Iwai
Quoted 27 lines · Pierre-Louis Bossart
Quoted 9 lines · Ranjani Sridharan
Calling
snd_device_new()makes the codec devices managed by the card.
So, when the card is removed, the refcount for the codec device is decremented and results in the codec device's kobject being cleaned up if the refcount is 0. But, this leads to a NULL pointer exception while attempting to remove the symlinks when the
codec driver is released later on. Therefore, increment the codec device's refcount before adding it to the card to prevent this.Ranjani, you should add a bit of context for the rest of the list...
This patch suggest a solution to a set of sightings occurring when removing/adding modules in a loop, and the current analysis points to
a difference between the way the HDMI and HDaudio codecs are handled.https://github.com/thesofproject/linux/issues/981
https://github.com/thesofproject/linux/issues/966
https://github.com/thesofproject/linux/pull/988Quoted 7 lines
Since it's not SOF specific it's better to get feedback directly from
the large ALSA community/maintainers. We probably want to focus on the
platform-specific/vendor-specific stuff on GitHub and use the mailing
list for such framework-level changes.Quoted 4 lines
Hm, I still wonder why this doens't happen with the HDA legacy.
What is the shortest way to trigger the bug manually without a script?
Hi Takashi,
With SOF, I can reproduce the issue if I just unload the
sof_pci_devmodule with rmmod.
Quoted 6 lines
Basically, the remove routine for the SOF pci device, unregisters the machine driver and then removes the codec device. So the first step of unregistering the machine driver frees the card which decrements the refcount for the HDA codec's kobject. In the case of HDMI codec, since it is not managed by the card, the refcount is not decremented when the card is removed.
So it's only about hdac_hdmi codec, or only about hdac_hda codec?
And why HDMI codec isn't managed by the card...? IOW, isn't it dangerous -- it means the codec being always removable after bound to the card?
thanks,
Takashi
Quoted 74 lines · Takashi Iwai
Quoted 60 lines · Ranjani Sridharan
Quoted 47 lines · Takashi Iwai
Quoted 35 lines · Pierre-Louis Bossart
Quoted 7 lines · Ranjani Sridharan
Calling
snd_device_new()makes the codec devices managed by the
card.
So, when the card is removed, the refcount for the codec device is decremented and results in the codec device's kobject
being cleaned up if the refcount is 0. But, this leads to aQuoted 8 lines
NULL
pointer exception while attempting to remove the symlinks when
the
codec driver is released later on. Therefore, increment the codec
device's refcount before adding it to the card to prevent this.Ranjani, you should add a bit of context for the rest of the list...
This patch suggest a solution to a set of sightings occurring when
removing/adding modules in a loop, and the current analysis points
to
a difference between the way the HDMI and HDaudio codecs are handled.https://github.com/thesofproject/linux/issues/981
https://github.com/thesofproject/linux/issues/966
https://github.com/thesofproject/linux/pull/988Quoted 9 lines
Since it's not SOF specific it's better to get feedback directly
from
the large ALSA community/maintainers. We probably want to focus on
the
platform-specific/vendor-specific stuff on GitHub and use the mailing
list for such framework-level changes.Quoted 4 lines
Hm, I still wonder why this doens't happen with the HDA legacy.
What is the shortest way to trigger the bug manually without a script?
Hi Takashi,
With SOF, I can reproduce the issue if I just unload the
sof_pci_dev
module with rmmod.Quoted 11 lines
Basically, the remove routine for the SOF pci device, unregisters the
machine driver and then removes the codec device. So the first step of
unregistering the machine driver frees the card which decrements the
refcount for the HDA codec's kobject. In the case of HDMI codec, since
it is not managed by the card, the refcount is not decremented when the
card is removed.
Quoted 1 line
So it's only about
hdac_hdmicodec, or only abouthdac_hdacodec?
It is only about the hdac_hda codec.
Quoted 4 lines
And why HDMI codec isn't managed by the card...? IOW, isn't it dangerous -- it means the codec being always removable after bound to the card?
That is a good point. Probably this needs to be fixed as well. I can include the change for that if you think it is the right thing to do.
But I was wondering if it makes sense to increment the refcount when the device is added to the card with snd_device_new()? I'm not sure how it affects the other devices so didnt go down this route.
Thanks,
Ranjani
Quoted 5 lines
thanks,
Takashi
Quoted 83 lines · Ranjani Sridharan
Quoted 74 lines · Takashi Iwai
Quoted 60 lines · Ranjani Sridharan
Quoted 47 lines · Takashi Iwai
Quoted 35 lines · Pierre-Louis Bossart
Quoted 7 lines · Ranjani Sridharan
Calling
snd_device_new()makes the codec devices managed by the
card.
So, when the card is removed, the refcount for the codec device is decremented and results in the codec device's kobject
being cleaned up if the refcount is 0. But, this leads to aQuoted 8 lines
NULL
pointer exception while attempting to remove the symlinks when
the
codec driver is released later on. Therefore, increment the codec
device's refcount before adding it to the card to prevent this.Ranjani, you should add a bit of context for the rest of the list...
This patch suggest a solution to a set of sightings occurring when
removing/adding modules in a loop, and the current analysis points
to
a difference between the way the HDMI and HDaudio codecs are handled.https://github.com/thesofproject/linux/issues/981
https://github.com/thesofproject/linux/issues/966
https://github.com/thesofproject/linux/pull/988Quoted 9 lines
Since it's not SOF specific it's better to get feedback directly
from
the large ALSA community/maintainers. We probably want to focus on
the
platform-specific/vendor-specific stuff on GitHub and use the mailing
list for such framework-level changes.Quoted 4 lines
Hm, I still wonder why this doens't happen with the HDA legacy.
What is the shortest way to trigger the bug manually without a script?
Hi Takashi,
With SOF, I can reproduce the issue if I just unload the
sof_pci_dev
module with rmmod.Quoted 11 lines
Basically, the remove routine for the SOF pci device, unregisters the
machine driver and then removes the codec device. So the first step of
unregistering the machine driver frees the card which decrements the
refcount for the HDA codec's kobject. In the case of HDMI codec, since
it is not managed by the card, the refcount is not decremented when the
card is removed.Quoted 1 line
So it's only about
hdac_hdmicodec, or only abouthdac_hdacodec?It is only about the
hdac_hdacodec.Quoted 4 lines
And why HDMI codec isn't managed by the card...? IOW, isn't it dangerous -- it means the codec being always removable after bound to the card?
Quoted 7 lines
That is a good point. Probably this needs to be fixed as well. I can include the change for that if you think it is the right thing to do.
But I was wondering if it makes sense to increment the refcount when the device is added to the card with
snd_device_new()? I'm not sure how it affects the other devices so didnt go down this route.
If you mean really snd_device_new() calls generically, not specific to snd_hda_codec_device_new() -- then no, something must be wrong.
And even for snd_hda_codec_device_new(), I'm not sure about it.
Actually, who decrements the device refcount at which timing...? It'd be helpful if you can clarify it, then we might see a better solution or a better explanation.
thanks,
Takashi
Quoted 94 lines · Takashi Iwai
Quoted 83 lines · Ranjani Sridharan
Quoted 74 lines · Takashi Iwai
Quoted 60 lines · Ranjani Sridharan
Quoted 47 lines · Takashi Iwai
Quoted 35 lines · Pierre-Louis Bossart
Quoted 7 lines · Ranjani Sridharan
Calling
snd_device_new()makes the codec devices managed by the
card.
So, when the card is removed, the refcount for the codec device is decremented and results in the codec device's kobject
being cleaned up if the refcount is 0. But, this leads to aQuoted 8 lines
NULL
pointer exception while attempting to remove the symlinks when
the
codec driver is released later on. Therefore, increment the codec
device's refcount before adding it to the card to prevent this.Ranjani, you should add a bit of context for the rest of the list...
This patch suggest a solution to a set of sightings occurring when
removing/adding modules in a loop, and the current analysis points
to
a difference between the way the HDMI and HDaudio codecs are handled.https://github.com/thesofproject/linux/issues/981
https://github.com/thesofproject/linux/issues/966
https://github.com/thesofproject/linux/pull/988Quoted 9 lines
Since it's not SOF specific it's better to get feedback directly
from
the large ALSA community/maintainers. We probably want to focus on
the
platform-specific/vendor-specific stuff on GitHub and use the mailing
list for such framework-level changes.Quoted 4 lines
Hm, I still wonder why this doens't happen with the HDA legacy.
What is the shortest way to trigger the bug manually without a script?
Hi Takashi,
With SOF, I can reproduce the issue if I just unload the
sof_pci_dev
module with rmmod.Quoted 11 lines
Basically, the remove routine for the SOF pci device, unregisters the
machine driver and then removes the codec device. So the first step of
unregistering the machine driver frees the card which decrements the
refcount for the HDA codec's kobject. In the case of HDMI codec, since
it is not managed by the card, the refcount is not decremented when the
card is removed.Quoted 1 line
So it's only about
hdac_hdmicodec, or only abouthdac_hdacodec?It is only about the
hdac_hdacodec.Quoted 4 lines
And why HDMI codec isn't managed by the card...? IOW, isn't it dangerous -- it means the codec being always removable after bound to the card?
Quoted 7 lines
That is a good point. Probably this needs to be fixed as well. I can include the change for that if you think it is the right thing to do.
But I was wondering if it makes sense to increment the refcount when the device is added to the card with
snd_device_new()? I'm not sure how it affects the other devices so didnt go down this route.
Quoted 8 lines
If you mean really
snd_device_new()calls generically, not specific tosnd_hda_codec_device_new()-- then no, something must be wrong.And even for
snd_hda_codec_device_new(), I'm not sure about it.Actually, who decrements the device refcount at which timing...? It'd be helpful if you can clarify it, then we might see a better solution or a better explanation.
Now I'm reading the code again. Is it about the put_device() in snd_hdac_ext_bus_device_remove()?
void snd_hdac_ext_bus_device_remove(struct hdac_bus *bus)
{
struct hdac_device *codec, *__codec;
/*
* we need to remove all the codec devices objects created in the
* snd_hdac_ext_bus_device_init
*/
list_for_each_entry_safe(codec, __codec, &bus->codec_list, list) {
snd_hdac_device_unregister(codec);
put_device(&codec->dev);
}
}I don't figure out why put_device() is needed at this place...
Takashi
Quoted 150 lines · Takashi Iwai
Quoted 124 lines · Takashi Iwai
Quoted 110 lines · Ranjani Sridharan
Quoted 93 lines · Takashi Iwai
Quoted 74 lines · Ranjani Sridharan
Quoted 59 lines · Takashi Iwai
Quoted 45 lines · Pierre-Louis Bossart
Quoted 13 lines · Ranjani Sridharan
Calling
snd_device_new()makes the codec devices managed by
the
card.
So, when the card is removed, the refcount for the codec
device is decremented and results in the codec device's kobject
being cleaned up if the refcount is 0. But, this leads to a
NULL
pointer exception while attempting to remove the symlinksQuoted 8 lines
when
the
codec driver is released later on. Therefore, increment the
codec
device's refcount before adding it to the card to prevent
this.Ranjani, you should add a bit of context for the rest of the
list...This patch suggest a solution to a set of sightings occurring
when
removing/adding modules in a loop, and the current analysis
points
to
a difference between the way the HDMI and HDaudio codecs are
handled.https://github.com/thesofproject/linux/issues/981
https://github.com/thesofproject/linux/issues/966
https://github.com/thesofproject/linux/pull/988Quoted 11 lines
Since it's not SOF specific it's better to get feedback directly
from
the large ALSA community/maintainers. We probably want to focus
on
the
platform-specific/vendor-specific stuff on GitHub and use the
mailing
list for such framework-level changes.Quoted 6 lines
Hm, I still wonder why this doens't happen with the HDA legacy.
What is the shortest way to trigger the bug manually without a
script?Hi Takashi,
With SOF, I can reproduce the issue if I just unload the
sof_pci_dev
module with rmmod.Quoted 16 lines
Basically, the remove routine for the SOF pci device, unregisters
the
machine driver and then removes the codec device. So the first step
of
unregistering the machine driver frees the card which decrements
the
refcount for the HDA codec's kobject. In the case of HDMI codec,
since
it is not managed by the card, the refcount is not decremented when
the
card is removed.Quoted 2 lines
So it's only about
hdac_hdmicodec, or only abouthdac_hdacodec?It is only about the
hdac_hdacodec.Quoted 5 lines
And why HDMI codec isn't managed by the card...? IOW, isn't it dangerous -- it means the codec being always removable after bound to
the card?That is a good point. Probably this needs to be fixed as well. I can
include the change for that if you think it is the right thing to do.Quoted 6 lines
But I was wondering if it makes sense to increment the refcount when
the device is added to the card withsnd_device_new()? I'm not sure how it affects the other devices so didnt go down this
route.If you mean really
snd_device_new()calls generically, not specific tosnd_hda_codec_device_new()-- then no, something must be wrong.Quoted 5 lines
And even for
snd_hda_codec_device_new(), I'm not sure about it.Actually, who decrements the device refcount at which timing...? It'd be helpful if you can clarify it, then we might see a better solution or a better explanation.
Now I'm reading the code again. Is it about the
put_device()insnd_hdac_ext_bus_device_remove()?void
snd_hdac_ext_bus_device_remove(struct hdac_bus *bus){ struct hdac_device *codec, *__codec; /* * we need to remove all the codec devices objects created in the * snd_hdac_ext_bus_device_init */ list_for_each_entry_safe(codec, __codec, &bus->codec_list, list) { snd_hdac_device_unregister(codec); put_device(&codec->dev); } }
Quoted 1 line
I don't figure out why
put_device()is needed at this place...
Hi Takashi,
No, this actually comes at the second step in the case of SOF (ie after the machine driver is unregistered).
Actually, I just found out what's causing the issue. It is the call to snd_hda_codec_dev_free() which calls put_device() when snd_card_free() is invoked. So, adding a get_device() in snd_hda_codec_device_new() would make the refcount balanced.
On the other hand, removing the put_device() in snd_hda_codec_dev_free() would also address the problem. I'm not sure which would be the preferred route.
THanks,
Ranjani
Quoted 7 lines
Takashi
_______________________________________________
Alsa-devel mailing list
[email protected]
https://mailman.alsa-project.org/mailman/listinfo/alsa-devel
Quoted 158 lines · Ranjani Sridharan
Quoted 150 lines · Takashi Iwai
Quoted 124 lines · Takashi Iwai
Quoted 110 lines · Ranjani Sridharan
Quoted 93 lines · Takashi Iwai
Quoted 74 lines · Ranjani Sridharan
Quoted 59 lines · Takashi Iwai
Quoted 45 lines · Pierre-Louis Bossart
Quoted 13 lines · Ranjani Sridharan
Calling
snd_device_new()makes the codec devices managed by
the
card.
So, when the card is removed, the refcount for the codec
device is decremented and results in the codec device's kobject
being cleaned up if the refcount is 0. But, this leads to a
NULL
pointer exception while attempting to remove the symlinksQuoted 8 lines
when
the
codec driver is released later on. Therefore, increment the
codec
device's refcount before adding it to the card to prevent
this.Ranjani, you should add a bit of context for the rest of the
list...This patch suggest a solution to a set of sightings occurring
when
removing/adding modules in a loop, and the current analysis
points
to
a difference between the way the HDMI and HDaudio codecs are
handled.https://github.com/thesofproject/linux/issues/981
https://github.com/thesofproject/linux/issues/966
https://github.com/thesofproject/linux/pull/988Quoted 11 lines
Since it's not SOF specific it's better to get feedback directly
from
the large ALSA community/maintainers. We probably want to focus
on
the
platform-specific/vendor-specific stuff on GitHub and use the
mailing
list for such framework-level changes.Quoted 6 lines
Hm, I still wonder why this doens't happen with the HDA legacy.
What is the shortest way to trigger the bug manually without a
script?Hi Takashi,
With SOF, I can reproduce the issue if I just unload the
sof_pci_dev
module with rmmod.Quoted 16 lines
Basically, the remove routine for the SOF pci device, unregisters
the
machine driver and then removes the codec device. So the first step
of
unregistering the machine driver frees the card which decrements
the
refcount for the HDA codec's kobject. In the case of HDMI codec,
since
it is not managed by the card, the refcount is not decremented when
the
card is removed.Quoted 2 lines
So it's only about
hdac_hdmicodec, or only abouthdac_hdacodec?It is only about the
hdac_hdacodec.Quoted 5 lines
And why HDMI codec isn't managed by the card...? IOW, isn't it dangerous -- it means the codec being always removable after bound to
the card?That is a good point. Probably this needs to be fixed as well. I can
include the change for that if you think it is the right thing to do.Quoted 6 lines
But I was wondering if it makes sense to increment the refcount when
the device is added to the card withsnd_device_new()? I'm not sure how it affects the other devices so didnt go down this
route.If you mean really
snd_device_new()calls generically, not specific tosnd_hda_codec_device_new()-- then no, something must be wrong.Quoted 5 lines
And even for
snd_hda_codec_device_new(), I'm not sure about it.Actually, who decrements the device refcount at which timing...? It'd be helpful if you can clarify it, then we might see a better solution or a better explanation.
Now I'm reading the code again. Is it about the
put_device()insnd_hdac_ext_bus_device_remove()?void
snd_hdac_ext_bus_device_remove(struct hdac_bus *bus){ struct hdac_device *codec, *__codec; /* * we need to remove all the codec devices objects created in the * snd_hdac_ext_bus_device_init */ list_for_each_entry_safe(codec, __codec, &bus->codec_list, list) { snd_hdac_device_unregister(codec); put_device(&codec->dev); } }Quoted 1 line
I don't figure out why
put_device()is needed at this place...Hi Takashi,
No, this actually comes at the second step in the case of SOF (ie after the machine driver is unregistered).
Quoted 8 lines
Actually, I just found out what's causing the issue. It is the call to
snd_hda_codec_dev_free()which callsput_device()whensnd_card_free()is invoked. So, adding aget_device()insnd_hda_codec_device_new()would make the refcount balanced.On the other hand, removing the
put_device()insnd_hda_codec_dev_free()would also address the problem. I'm not sure which would be the preferred route.
The latter one, I'd say.
Actually the difference between ASoC and the legacy HDA bus is who releases the device object. For HDA legacy bus, it's supposed to be done via snd_device_free() chain, while ASoC bus releases explicitly as shown in my previous post.
So, if any, I'd paper over it like below.
thanks,
Takashi
sound/pci/hda/hda_codec.c +6 -1
@@ -840,7 +840,12 @@ static int snd_hda_codec_dev_free(struct snd_device *device)if (codec->core.type ==HDA_DEV_LEGACY )snd_hdac_device_unregister (&codec->core);codec_display_power (codec, false); -put_device (hda_codec_dev (codec)); +/* +* again, ASoC HD-audio bus manages differently; it's released in +* snd_hdac_ext_bus_device_remove() explicitly +*/ +if (codec->core.type ==HDA_DEV_LEGACY ) +put_device (hda_codec_dev (codec));return 0 ; }
Quoted 18 lines
Quoted 13 lines
Hi Takashi,
No, this actually comes at the second step in the case of SOF (ie after
the machine driver is unregistered).Actually, I just found out what's causing the issue. It is the call to
snd_hda_codec_dev_free()which callsput_device()whensnd_card_free()
is invoked. So, adding aget_device()insnd_hda_codec_device_new()would make the refcount balanced.Quoted 4 lines
On the other hand, removing the
put_device()insnd_hda_codec_dev_free()would also address the problem. I'm not sure
which would be the preferred route.
Quoted 8 lines
The latter one, I'd say.
Actually the difference between ASoC and the legacy HDA bus is who releases the device object. For HDA legacy bus, it's supposed to be done via
snd_device_free()chain, while ASoC bus releases explicitly as shown in my previous post.So, if any, I'd paper over it like below.
OK, makes sense. Let me send a V2 with the change.
Also, should I also look into adding the change to make hdac_hdmi codec card managed as well?
Thanks,
Ranjani
Quoted 24 lines
thanks,
Takashi
sound/pci/hda/hda_codec.c +2
-1@@ -840,7 +840,12 @@ static int snd_hda_codec_dev_free(struct snd_device *device)if (codec->core.type ==HDA_DEV_LEGACY )snd_hdac_device_unregister (&codec->core);codec_display_power (codec, false); -put_device (hda_codec_dev (codec)); +/* +* again, ASoC HD-audio bus manages differently; it's released in
sound/pci/hda/hda_codec.c +4
-0+* snd_hdac_ext_bus_device_remove() explicitly +*/ +if (codec->core.type ==HDA_DEV_LEGACY ) +put_device (hda_codec_dev (codec));return 0 ; }
Quoted 26 lines · Ranjani Sridharan
Quoted 26 lines
Quoted 14 lines
Hi Takashi,
No, this actually comes at the second step in the case of SOF (ie after
the machine driver is unregistered).Actually, I just found out what's causing the issue. It is the call to
snd_hda_codec_dev_free()which callsput_device()whensnd_card_free()
is invoked. So, adding aget_device()insnd_hda_codec_device_new()would make the refcount balanced.Quoted 4 lines
On the other hand, removing the
put_device()insnd_hda_codec_dev_free()would also address the problem. I'm not sure
which would be the preferred route.The latter one, I'd say.
Actually the difference between ASoC and the legacy HDA bus is who releases the device object. For HDA legacy bus, it's supposed to be done via
snd_device_free()chain, while ASoC bus releases explicitly as shown in my previous post.
Quoted 5 lines
Quoted 1 line
So, if any, I'd paper over it like below.
OK, makes sense. Let me send a V2 with the change.
Also, should I also look into adding the change to make
hdac_hdmicodec card managed as well?
Well, feel free to fix more bugs, of course ;)
BTW, I'll be on vacation from tomorrow for a week, so my reply will be delayed.
thanks,
Takashi