Alsa-Devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Stefan Richter <stefanr@s5r6.in-berlin.de>
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: Fri, 25 Dec 2015 09:21:22 +0900	[thread overview]
Message-ID: <567C8C02.7070406@sakamocchi.jp> (raw)
In-Reply-To: <20151224215147.1fae080b@kant>

On De 25 2015 05:51, Stefan Richter wrote:
> On Dec 24 Takashi Sakamoto wrote:
>> --- a/sound/firewire/dice/dice.c
>> +++ b/sound/firewire/dice/dice.c
> [...]
>>  static void dice_bus_reset(struct fw_unit *unit)
>>  {
>>  	struct snd_dice *dice = dev_get_drvdata(&unit->device);
>>  
>> +	/* Postpone a workqueue for deferred registration. */
>> +	if (!dice->registered) {
>> +		schedule_registration(dice);
>> +		return;
>> +	}
>> +
>>  	/* The handler address register becomes initialized. */
>>  	snd_dice_transaction_reinit(dice);
>>  
> 
> In previous versions of the patch, you used
> 	schedule_delayed_work(&dice->dwork, delay);
> in dice_probe() and
> 	mod_delayed_work(dice->dwork.wq, &dice->dwork, delay);
> in dice_bus_reset().
> 
> Now you are using schedule_delayed_work() in both.  This means that
> dice_bus_reset() is now unable to further defer the work.  Is this
> intentional?

No intention, just my mistake. Originally, I had an intention to use
'mod_delayed_work()' here.
https://www.kernel.org/doc/htmldocs/device-drivers/API-mod-delayed-work.html

> By the way, in drivers/firewire/core-cdev.c, I used a somewhat different
> workqueue scheduling scheme.  Problem:
>   - The first 1000 ms after a bus reset are to be used for re-allocations
>     of previously allocated isochronous resources.  Attempts for new iso
>     resource allocations shall be deferred until after 1000 ms after the
>     latest bus reset.
> My solution:
>   - The work which is to perform allocations/ reallocations/ deallocations
>     is scheduled immediately.  But the worker function (iso_resource_work)
>     reschedules itself if it notices that (1.) its job is to allocate and
>     (2.) the last bus reset was less than 1 s ago.
> 
> I used the same principle in drivers/firewire/core-card.c.  Problem:
>   - If system software wants to reset the bus, it shall wait at least
>     2000 ms until after the last bus reset.  The reason is to allow for
>     various bus reset handling protocols to be performed first (e.g.
>     isochronous resource allocations, re-logins and the likes).
> My solution:
>   - br_work() reschedules itself if it detects that the last bus reset was
>     less than 2 s ago.
> 
> Admittedly there is a small remaining window after the worker looked at
> card->reset_jiffies and before it performs its real work, and another bus
> rest could happen in this window.  I suppose if I wanted to close even
> this window, I would have to couple card->reset_jiffies with a
> bus generation counter and then make the remaining work depended on this
> bus generation.
> 
> Back to your patch:  I am not sure how strictly you want to guarantee the
> delay between last reset and do_registration()'s execution.  Maybe it
> would be beneficial to put the check for card->reset_jiffies and self-
> rescheduling into do_registration(), similar to the two examples from
> firewire-core, or maybe that's not really necessary for your purposes.

On Dec 25 2015 06:04, Stefan Richter wrote:
> Or as I wrote in the other thread:
> Maybe you can live with less precision and simply use a fixed relative
> delay, disregarding card->reset_jiffies altogether.

For the case that users execute insmod/rmmod by their own. In this case,
no need to be delay for the registration work.



Thanks

Takashi Sakamoto

  parent reply	other threads:[~2015-12-25  0:21 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
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 [this message]
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=567C8C02.7070406@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --cc=clemens@ladisch.de \
    --cc=ffado-devel@lists.sf.net \
    --cc=stefanr@s5r6.in-berlin.de \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox