[PATCH] ALSA: hda - Don't register a cb func if it is registered already

Jaroslav Kysela perex at perex.cz
Wed Sep 30 11:28:59 CEST 2020


Dne 30. 09. 20 v 11:21 Takashi Iwai napsal(a):
> On Wed, 30 Sep 2020 09:19:50 +0200,
> Jaroslav Kysela wrote:
>>
>> Dne 30. 09. 20 v 7:51 Hui Wang napsal(a):
>>> If the caller of enable_callback_mst() passes a cb func, the callee
>>> function will malloc memory and link this cb func to the list
>>> unconditionally. This will introduce problem if caller is in the
>>> hda_codec_ops.init() since the init() will be repeatedly called in the
>>> codec rt_resume().
>>>
>>> So far, the patch_hdmi.c and patch_ca0132.c call enable_callback_mst()
>>> in the hda_codec_ops.init().
>>
>> Won't be better to handle this double invocation at the callback call time? I
>> believe that some refcounting and pointing to one allocated callback structure
>> for all instances is better.
> 
> IMO, Hui's fix is correct in this case; otherwise it'll result in
> endless number of allocations at each time the runtime resume is
> performed.  So I'm going to take it as is.

I meant to allocate the structure only once with refcounting and multiple
invocation protection. In the proposed change, you lose the bindings. But as
you prefer.

					Jaroslav

-- 
Jaroslav Kysela <perex at perex.cz>
Linux Sound Maintainer; ALSA Project; Red Hat, Inc.


More information about the Alsa-devel mailing list