All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Sakamoto <o-takashi@sakamocchi.jp>
To: Takashi Iwai <tiwai@suse.de>
Cc: alsa-devel@alsa-project.org
Subject: Re: [PATCH 2/7] ALSA: core: Add managed card creation
Date: Wed, 3 Oct 2018 13:05:33 +0900	[thread overview]
Message-ID: <ccae39c3-87ec-2ca8-15fe-5abdb314925e@sakamocchi.jp> (raw)
In-Reply-To: <s5hh8i4qpkd.wl-tiwai@suse.de>

Hi,

Thanks for you to be involved in this issue.

On Oct 3 2018 01:30, Takashi Iwai wrote:
>>> The snd_card_free() syncs with the release of the all active files,
>>> i.e. it waits until all accesses get released, then proceed to the
>>> further procedures to free resources, including the call of
>>> private_free.  Hence this call itself should be safe, as long as it's
>>> called at first.
>>
>> I overlooked that snd_card_free() calls 'wait_for_completion()'. Thanks
>> for your indication. As you said, no worries.
>>
>> Here I have another concern about timing for processes to return from
>> unbinding operation. For example:
>>
>> echo '0000:0a:00.1' > /sys/bus/pci/drivers/snd_hda_intel/unbind
>>
>> This process returns when the other processes close all of ALSA
>> character devices related to the sound card because wait for completion
>> is executed in context of the process. Well-programmed userspace
>> applications are expected to release the character devices when
>> received -ENODEV from ioctl(2) or EPOLLERR/EPOLLNVAL from poll(2) to
>> the character devices.
>>
>> I don't know exactly that it's acceptable to block a process which
>> performs unbinding, depending on behaviours of the other processes.
>> In a point of safe ABI, it's worth for us to consider or decide a
>> policy for the point.
> 
> Right, the behavior of unbind is currently sub-optimal.  But basically
> it's above this devres patch series; the unbind behavior itself
> doesn't change no matter whether the resource is released via devres
> or not.  So we can keep discussing about this, but maybe in another
> thread.

Indeed.

For this patch, I have another concern and will post it soon (for a
helper function to release memory object immediately).

> When we see unbind as a sort of hot-unplug action, it's understandable
> that unbind never returns an error.  And that's the current situation,
> and it implies that every driver needs to take care of all pending
> resources by itself.  Hence, you have only two choices: block and sync
> with the pending resources, or make everything in async.
>
> As of now, the most of drivers take the former approach -- at least
> for sound stuff -- just because of simplicity.  Admittedly, the latter
> approach would look better from the user-space POV.  However, it'll be
> far complicated in the actual implementation.

I note that all drivers in ALSA firewire stack are implemented according
to the 'async' scenario. Usage of reference counting of struct device
for units on IEEE 1394 bus is used to achieve it.

> Maybe another consideration would be to allow unbind action actually
> returning -EBUSY error.  This option would require the driver base
> code change, and above all, the consensus from other parties.

At present, 'unbind_store()' in 'drivers/base/bus.c'[1] can return
-ENODEV if error, or the length of given string if success. It's
possible for us to change this function to return -EBUSY when the target
device is still referred after a call of 'device_release_driver()'. But
this is wider issue in Linux DD and should be discussed in a right
place.

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/base/bus.c?h=v4.19-rc6#n177


Thanks

Takashi Sakamoto

  reply	other threads:[~2018-10-03  4:05 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-20 15:54 [PATCH 0/7] Add devres support to card resources Takashi Iwai
2018-09-20 15:54 ` [PATCH 1/7] ALSA: core: Add device-managed page allocator helper Takashi Iwai
2018-09-20 15:54 ` [PATCH 2/7] ALSA: core: Add managed card creation Takashi Iwai
2018-09-21  3:01   ` Takashi Sakamoto
2018-09-21  6:32     ` Takashi Iwai
2018-09-23  8:08       ` Takashi Sakamoto
2018-10-02 16:30         ` Takashi Iwai
2018-10-03  4:05           ` Takashi Sakamoto [this message]
2018-10-03  8:12   ` Takashi Sakamoto
2018-10-03 10:30     ` Takashi Iwai
2018-10-03 13:14       ` Takashi Sakamoto
2018-10-03 15:02         ` Takashi Sakamoto
2018-10-03 15:37           ` Takashi Iwai
2018-10-04  5:33             ` Takashi Sakamoto
2018-10-03 15:32         ` Takashi Iwai
2018-09-20 15:54 ` [PATCH 3/7] ALSA: intel8x0: Allocate resources with device-managed APIs Takashi Iwai
2018-09-20 15:54 ` [PATCH 4/7] ALSA: atiixp: " Takashi Iwai
2018-09-20 15:55 ` [PATCH 5/7] ALSA: hda: " Takashi Iwai
2018-09-20 15:55 ` [PATCH 6/7] ALSA: doc: Brush up the old writing-an-alsa-driver Takashi Iwai
2018-09-20 15:55 ` [PATCH 7/7] ALSA: doc: Add device-managed resource section 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=ccae39c3-87ec-2ca8-15fe-5abdb314925e@sakamocchi.jp \
    --to=o-takashi@sakamocchi.jp \
    --cc=alsa-devel@alsa-project.org \
    --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.