All of lore.kernel.org
 help / color / mirror / Atom feed
From: Stefan Richter <stefanr@s5r6.in-berlin.de>
To: Takashi Sakamoto <o-takashi@sakamocchi.jp>
Cc: tiwai@suse.de, alsa-devel@alsa-project.org, clemens@ladisch.de,
	ffado-devel@lists.sf.net
Subject: Re: [PATCH 2/4] ALSA: dice: postpone card registration
Date: Thu, 24 Dec 2015 16:12:34 +0100	[thread overview]
Message-ID: <20151224161234.39828fc7@kant> (raw)
In-Reply-To: <1450911310-15507-3-git-send-email-o-takashi@sakamocchi.jp>

On Dec 24 Takashi Sakamoto wrote:
[...]
> Between bootstrap, firmware loading and post configuration, some bus resets
> are observed.
> 
> This commit offloads most processing of probe function into workqueue and
> schedules the workqueue after successive bus resets. This has an effect to
> get correct hardware information and avoid involvement to bus reset storm.
> 
> For code simplicity, this change effects all of Dice-based models, i.e.
> Dice II, Dice Jr., Dice Mini and Dice III. Due to the same reason, sound
> card instance is kept till card free function even if some errors are
> detected in the workqueue.
[...]
> --- a/sound/firewire/dice/dice.c
> +++ b/sound/firewire/dice/dice.c
> @@ -18,6 +18,8 @@ MODULE_LICENSE("GPL v2");
>  #define WEISS_CATEGORY_ID	0x00
>  #define LOUD_CATEGORY_ID	0x10
>  
> +#define PROBE_DELAY_MS		(2 * MSEC_PER_SEC)
> +
>  static int check_dice_category(struct fw_unit *unit)
>  {
>  	struct fw_device *device = fw_parent_device(unit);
> @@ -185,6 +187,9 @@ static void dice_card_free(struct snd_card *card)
>  {
>  	struct snd_dice *dice = card->private_data;
>  
> +	/* The workqueue for registration uses the memory block. */
> +	cancel_work_sync(&dice->dwork.work);

According to the kerneldoc comment at cancel_work_sync, this should
actually be cancel_delayed_work_sync(&dice->dwork);.

> +
>  	snd_dice_stream_destroy_duplex(dice);
>  	snd_dice_transaction_destroy(dice);
>  	fw_unit_put(dice->unit);
> @@ -192,6 +197,66 @@ static void dice_card_free(struct snd_card *card)
>  	mutex_destroy(&dice->mutex);
>  }
>  
> +static void do_registration(struct work_struct *work)
> +{
> +	struct snd_dice *dice = container_of(work, struct snd_dice, dwork.work);
> +	int err;
> +
> +	mutex_lock(&dice->mutex);

So the worker needs to obtain &dice->mutex.  But...

[...]
> @@ -263,14 +307,25 @@ static void dice_remove(struct fw_unit *unit)
>  {
>  	struct snd_dice *dice = dev_get_drvdata(&unit->device);
>  
> +	/* For a race condition of struct snd_card.shutdown. */
> +	mutex_lock(&dice->mutex);
> +
>  	/* No need to wait for releasing card object in this context. */
>  	snd_card_free_when_closed(dice->card);
> +
> +	mutex_unlock(&dice->mutex);
>  }

...if I read snd_card_free_when_closed() and its surrounding code
correctly, then dice_card_free() is called from within this, which can
cause a deadlock.  Right?

If so, then it seems to me that cancel_delayed_work_sync(&dice->dwork)
should be moved out of dice_card_free() and be put at the beginning of
dice_remove().
-- 
Stefan Richter
-=====-===== ==-- ==---
http://arcgraph.de/sr/

  parent reply	other threads:[~2015-12-24 15:12 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-12-23 22:55 [PATCH 0/4 v2] ALSA: dice: improve card registration processing Takashi Sakamoto
2015-12-23 22:55 ` [PATCH 1/4] ALSA: dice: split subaddress check from category check Takashi Sakamoto
2015-12-23 22:55 ` [PATCH 2/4] ALSA: dice: postpone card registration Takashi Sakamoto
2015-12-24  5:04   ` Takashi Sakamoto
2015-12-24 15:12   ` Stefan Richter [this message]
2015-12-24 19:10     ` Stefan Richter
2015-12-25  0:04       ` Takashi Sakamoto
2015-12-24 20:51   ` Stefan Richter
2015-12-24 21:04     ` Stefan Richter
2015-12-25  0:21     ` Takashi Sakamoto
2015-12-23 22:55 ` [PATCH 3/4] ALSA: dice: purge transaction initialization at timeout of Dice notification Takashi Sakamoto
2015-12-23 22:55 ` [PATCH 4/4] ALSA: dice: expand timeout to wait for " Takashi Sakamoto
  -- strict thread matches above, loose matches on Subject: below --
2015-12-31  4:58 [PATCH 0/4 v5] ALSA: dice: improve card registration processing Takashi Sakamoto
2015-12-31  4:58 ` [PATCH 2/4] ALSA: dice: postpone card registration Takashi Sakamoto
2015-12-22 13:45 [PATCH 0/4] ALSA: dice: improve card registration processing Takashi Sakamoto
2015-12-22 13:45 ` [PATCH 2/4] ALSA: dice: postpone card registration Takashi Sakamoto
2015-12-22 14:03   ` Takashi Iwai
2015-12-23  4:21     ` Takashi Sakamoto
2015-12-23  7:29       ` Takashi Iwai
2015-12-23  9:33         ` Takashi Sakamoto
2015-12-23 14:06           ` Takashi Iwai

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=20151224161234.39828fc7@kant \
    --to=stefanr@s5r6.in-berlin.de \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=ffado-devel@lists.sf.net \
    --cc=o-takashi@sakamocchi.jp \
    --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.