All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Jaroslav Kysela <perex@perex.cz>,
	ALSA development <alsa-devel@alsa-project.org>
Cc: Takashi Iwai <tiwai@suse.de>, Perry Yuan <Perry.Yuan@dell.com>
Subject: Re: [PATCH v2 0/5] ALSA: control - add generic LED API
Date: Sun, 21 Feb 2021 20:32:41 +0100	[thread overview]
Message-ID: <30904946-0d70-c13e-91c7-5cf65387fef1@redhat.com> (raw)
In-Reply-To: <1509c137-c977-c9af-95c4-8d4040e619e3@perex.cz>

Hi,

On 2/21/21 7:01 PM, Jaroslav Kysela wrote:
> Dne 21. 02. 21 v 14:14 Hans de Goede napsal(a):
> 
>>> v2 changes:
>>>   - fix the locking - remove the controls_rwsem read lock
>>>     in the element get (the consistency is already protected
>>>     with the global snd_ctl_led_mutex and possible partial
>>>     value writes are catched with the next value change
>>>     notification callback)
>>
>> I'm afraid that lockdep still is unhappy. With v2 there is a new
>> (different) lockdep warning.
> 
>> If you can send me another fixup-diff then I'll make sure to
>> test this before you do a v3, so that we can be sure that
>> all cases which my setup catches are resolved before sending
>> out v3.
> 
> Thank you for your test. This change (on top of v2) should resolve this
> remaining lockdep:

I can confirm that I'm not seeing any more lockdeps warning after
applying this on top of v2 of the series.

Regards,

Hans



> diff --git a/sound/core/control.c b/sound/core/control.c
> index c9f062fada0a..494f0154e8be 100644
> --- a/sound/core/control.c
> +++ b/sound/core/control.c
> @@ -2051,7 +2051,9 @@ void snd_ctl_register_layer(struct snd_ctl_layer_ops *lops)
>  	for (card_number = 0; card_number < SNDRV_CARDS; card_number++) {
>  		card = snd_card_ref(card_number);
>  		if (card) {
> +			down_read(&card->controls_rwsem);
>  			lops->lregister(card);
> +			up_read(&card->controls_rwsem);
>  			snd_card_unref(card);
>  		}
>  	}
> @@ -2113,10 +2115,12 @@ static int snd_ctl_dev_register(struct snd_device *device)
>  				  &snd_ctl_f_ops, card, &card->ctl_dev);
>  	if (err < 0)
>  		return err;
> +	down_read(&card->controls_rwsem);
>  	down_read(&snd_ctl_layer_rwsem);
>  	for (lops = snd_ctl_layer; lops; lops = lops->next)
>  		lops->lregister(card);
>  	up_read(&snd_ctl_layer_rwsem);
> +	up_read(&card->controls_rwsem);
>  	return 0;
>  }
> 
> @@ -2137,10 +2141,12 @@ static int snd_ctl_dev_disconnect(struct snd_device
> *device)
>  	}
>  	read_unlock_irqrestore(&card->ctl_files_rwlock, flags);
> 
> +	down_read(&card->controls_rwsem);
>  	down_read(&snd_ctl_layer_rwsem);
>  	for (lops = snd_ctl_layer; lops; lops = lops->next)
>  		lops->ldisconnect(card);
>  	up_read(&snd_ctl_layer_rwsem);
> +	up_read(&card->controls_rwsem);
> 
>  	return snd_unregister_device(&card->ctl_dev);
>  }
> diff --git a/sound/core/control_led.c b/sound/core/control_led.c
> index cafe4c82ca35..b8bb8fd46686 100644
> --- a/sound/core/control_led.c
> +++ b/sound/core/control_led.c
> @@ -235,11 +235,10 @@ static void snd_ctl_led_register(struct snd_card *card)
>  	mutex_lock(&snd_ctl_led_mutex);
>  	snd_ctl_led_card_valid[card->number] = true;
>  	mutex_unlock(&snd_ctl_led_mutex);
> -	down_read(&card->controls_rwsem);
> +	/* the register callback is already called with held card->controls_rwsem */
>  	list_for_each_entry(kctl, &card->controls, list)
>  		for (ioff = 0; ioff < kctl->count; ioff++)
>  			snd_ctl_led_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, kctl, ioff);
> -	up_read(&card->controls_rwsem);
>  	snd_ctl_led_refresh();
>  }
> 
> 
> 					Jaroslav
> 


      reply	other threads:[~2021-02-21 19:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-15 17:24 [PATCH v2 0/5] ALSA: control - add generic LED API Jaroslav Kysela
2021-02-15 17:24 ` [PATCH v2 1/5] ALSA: control - introduce snd_ctl_notify_one() helper Jaroslav Kysela
2021-02-15 17:24 ` [PATCH v2 2/5] ALSA: control - add layer registration routines Jaroslav Kysela
2021-02-15 17:24 ` [PATCH v2 3/5] ALSA: control - add generic LED trigger module as the new control layer Jaroslav Kysela
2021-02-15 17:24 ` [PATCH v2 4/5] ALSA: HDA - remove the custom implementation for the audio LED trigger Jaroslav Kysela
2021-02-15 17:24 ` [PATCH v2 5/5] ALSA: control - add sysfs support to the LED trigger module Jaroslav Kysela
2021-02-21 13:14 ` [PATCH v2 0/5] ALSA: control - add generic LED API Hans de Goede
2021-02-21 18:01   ` Jaroslav Kysela
2021-02-21 19:32     ` Hans de Goede [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=30904946-0d70-c13e-91c7-5cf65387fef1@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=Perry.Yuan@dell.com \
    --cc=alsa-devel@alsa-project.org \
    --cc=perex@perex.cz \
    --cc=tiwai@suse.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.