From: Takashi Iwai <tiwai@suse.de>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Cc: linux-kernel@vger.kernel.org, stable@vger.kernel.org,
alan@lxorguk.ukuu.org.uk
Subject: Re: [ 42/66] ALSA: Avoid endless sleep after disconnect
Date: Thu, 15 Nov 2012 08:25:11 +0100 [thread overview]
Message-ID: <s5h8va3ba5k.wl%tiwai@suse.de> (raw)
In-Reply-To: <20121115040942.165674081@linuxfoundation.org>
At Wed, 14 Nov 2012 20:10:47 -0800,
Greg Kroah-Hartman wrote:
>
> 3.6-stable review patch. If anyone has any objections, please let me know.
It turned out that this patch series for fixing USB-audio
disconnection races need two more commits. One is already in Linus
tree,
commit 8bb4d9ce08b0a92ca174e41d92c180328f86173f
ALSA: Fix card refcount unbalance
and another is included in the pull request I sent out to Linus right
now,
commit 10e44239f67d0b6fb74006e61a7e883b8075247a
ALSA: usb-audio: Fix mutex deadlock at disconnection
Please pick them up when possible, too.
Sorry for inconvenience.
thanks,
Takashi
>
> ------------------
>
>
> From: Takashi Iwai <tiwai@suse.de>
>
> commit 0914f7961babbf28aaa2f19b453951fb4841c03f upstream.
>
> When disconnect callback is called, each component should wake up
> sleepers and check card->shutdown flag for avoiding the endless sleep
> blocking the proper resource release.
>
> Signed-off-by: Takashi Iwai <tiwai@suse.de>
> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> ---
> sound/core/control.c | 2 ++
> sound/core/hwdep.c | 7 +++++++
> sound/core/oss/pcm_oss.c | 4 ++++
> sound/core/pcm.c | 6 +++++-
> sound/core/pcm_native.c | 8 ++++++++
> sound/core/rawmidi.c | 20 ++++++++++++++++++++
> 6 files changed, 46 insertions(+), 1 deletion(-)
>
> --- a/sound/core/control.c
> +++ b/sound/core/control.c
> @@ -1436,6 +1436,8 @@ static ssize_t snd_ctl_read(struct file
> spin_unlock_irq(&ctl->read_lock);
> schedule();
> remove_wait_queue(&ctl->change_sleep, &wait);
> + if (ctl->card->shutdown)
> + return -ENODEV;
> if (signal_pending(current))
> return -ERESTARTSYS;
> spin_lock_irq(&ctl->read_lock);
> --- a/sound/core/hwdep.c
> +++ b/sound/core/hwdep.c
> @@ -131,6 +131,10 @@ static int snd_hwdep_open(struct inode *
> mutex_unlock(&hw->open_mutex);
> schedule();
> mutex_lock(&hw->open_mutex);
> + if (hw->card->shutdown) {
> + err = -ENODEV;
> + break;
> + }
> if (signal_pending(current)) {
> err = -ERESTARTSYS;
> break;
> @@ -462,12 +466,15 @@ static int snd_hwdep_dev_disconnect(stru
> mutex_unlock(®ister_mutex);
> return -EINVAL;
> }
> + mutex_lock(&hwdep->open_mutex);
> + wake_up(&hwdep->open_wait);
> #ifdef CONFIG_SND_OSSEMUL
> if (hwdep->ossreg)
> snd_unregister_oss_device(hwdep->oss_type, hwdep->card, hwdep->device);
> #endif
> snd_unregister_device(SNDRV_DEVICE_TYPE_HWDEP, hwdep->card, hwdep->device);
> list_del_init(&hwdep->list);
> + mutex_unlock(&hwdep->open_mutex);
> mutex_unlock(®ister_mutex);
> return 0;
> }
> --- a/sound/core/oss/pcm_oss.c
> +++ b/sound/core/oss/pcm_oss.c
> @@ -2441,6 +2441,10 @@ static int snd_pcm_oss_open(struct inode
> mutex_unlock(&pcm->open_mutex);
> schedule();
> mutex_lock(&pcm->open_mutex);
> + if (pcm->card->shutdown) {
> + err = -ENODEV;
> + break;
> + }
> if (signal_pending(current)) {
> err = -ERESTARTSYS;
> break;
> --- a/sound/core/pcm.c
> +++ b/sound/core/pcm.c
> @@ -1087,12 +1087,16 @@ static int snd_pcm_dev_disconnect(struct
> goto unlock;
>
> mutex_lock(&pcm->open_mutex);
> + wake_up(&pcm->open_wait);
> list_del_init(&pcm->list);
> for (cidx = 0; cidx < 2; cidx++)
> for (substream = pcm->streams[cidx].substream; substream; substream = substream->next) {
> snd_pcm_stream_lock_irq(substream);
> - if (substream->runtime)
> + if (substream->runtime) {
> substream->runtime->status->state = SNDRV_PCM_STATE_DISCONNECTED;
> + wake_up(&substream->runtime->sleep);
> + wake_up(&substream->runtime->tsleep);
> + }
> snd_pcm_stream_unlock_irq(substream);
> }
> list_for_each_entry(notify, &snd_pcm_notify_list, list) {
> --- a/sound/core/pcm_native.c
> +++ b/sound/core/pcm_native.c
> @@ -1518,6 +1518,10 @@ static int snd_pcm_drain(struct snd_pcm_
> down_read(&snd_pcm_link_rwsem);
> snd_pcm_stream_lock_irq(substream);
> remove_wait_queue(&to_check->sleep, &wait);
> + if (card->shutdown) {
> + result = -ENODEV;
> + break;
> + }
> if (tout == 0) {
> if (substream->runtime->status->state == SNDRV_PCM_STATE_SUSPENDED)
> result = -ESTRPIPE;
> @@ -2168,6 +2172,10 @@ static int snd_pcm_open(struct file *fil
> mutex_unlock(&pcm->open_mutex);
> schedule();
> mutex_lock(&pcm->open_mutex);
> + if (pcm->card->shutdown) {
> + err = -ENODEV;
> + break;
> + }
> if (signal_pending(current)) {
> err = -ERESTARTSYS;
> break;
> --- a/sound/core/rawmidi.c
> +++ b/sound/core/rawmidi.c
> @@ -424,6 +424,10 @@ static int snd_rawmidi_open(struct inode
> mutex_unlock(&rmidi->open_mutex);
> schedule();
> mutex_lock(&rmidi->open_mutex);
> + if (rmidi->card->shutdown) {
> + err = -ENODEV;
> + break;
> + }
> if (signal_pending(current)) {
> err = -ERESTARTSYS;
> break;
> @@ -995,6 +999,8 @@ static ssize_t snd_rawmidi_read(struct f
> spin_unlock_irq(&runtime->lock);
> schedule();
> remove_wait_queue(&runtime->sleep, &wait);
> + if (rfile->rmidi->card->shutdown)
> + return -ENODEV;
> if (signal_pending(current))
> return result > 0 ? result : -ERESTARTSYS;
> if (!runtime->avail)
> @@ -1238,6 +1244,8 @@ static ssize_t snd_rawmidi_write(struct
> spin_unlock_irq(&runtime->lock);
> timeout = schedule_timeout(30 * HZ);
> remove_wait_queue(&runtime->sleep, &wait);
> + if (rfile->rmidi->card->shutdown)
> + return -ENODEV;
> if (signal_pending(current))
> return result > 0 ? result : -ERESTARTSYS;
> if (!runtime->avail && !timeout)
> @@ -1613,9 +1621,20 @@ static int snd_rawmidi_dev_register(stru
> static int snd_rawmidi_dev_disconnect(struct snd_device *device)
> {
> struct snd_rawmidi *rmidi = device->device_data;
> + int dir;
>
> mutex_lock(®ister_mutex);
> + mutex_lock(&rmidi->open_mutex);
> + wake_up(&rmidi->open_wait);
> list_del_init(&rmidi->list);
> + for (dir = 0; dir < 2; dir++) {
> + struct snd_rawmidi_substream *s;
> + list_for_each_entry(s, &rmidi->streams[dir].substreams, list) {
> + if (s->runtime)
> + wake_up(&s->runtime->sleep);
> + }
> + }
> +
> #ifdef CONFIG_SND_OSSEMUL
> if (rmidi->ossreg) {
> if ((int)rmidi->device == midi_map[rmidi->card->number]) {
> @@ -1630,6 +1649,7 @@ static int snd_rawmidi_dev_disconnect(st
> }
> #endif /* CONFIG_SND_OSSEMUL */
> snd_unregister_device(SNDRV_DEVICE_TYPE_RAWMIDI, rmidi->card, rmidi->device);
> + mutex_unlock(&rmidi->open_mutex);
> mutex_unlock(®ister_mutex);
> return 0;
> }
>
>
next prev parent reply other threads:[~2012-11-15 7:25 UTC|newest]
Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-15 4:10 [ 00/66] 3.6.7-stable review Greg Kroah-Hartman
2012-11-15 4:10 ` [ 01/66] xen/gntdev: dont leak memory from IOCTL_GNTDEV_MAP_GRANT_REF Greg Kroah-Hartman
2012-11-15 4:10 ` [ 02/66] xen/mmu: Use Xen specific TLB flush instead of the generic one Greg Kroah-Hartman
2012-11-15 4:10 ` [ 03/66] ixgbe: PTP get_ts_info missing software support Greg Kroah-Hartman
2012-11-15 4:10 ` [ 04/66] Input: tsc40 - remove wrong announcement of pressure support Greg Kroah-Hartman
2012-11-15 4:10 ` [ 05/66] ath9k: fix stale pointers potentially causing access to freed skbs Greg Kroah-Hartman
2012-11-15 4:10 ` [ 06/66] ath9k: Test for TID only in BlockAcks while checking tx status Greg Kroah-Hartman
2012-11-15 4:10 ` [ 07/66] rt2800: validate step value for temperature compensation Greg Kroah-Hartman
2012-11-15 4:10 ` [ 08/66] target: Dont return success from module_init() if setup fails Greg Kroah-Hartman
2012-11-15 4:10 ` [ 09/66] target: Avoid integer overflow in se_dev_align_max_sectors() Greg Kroah-Hartman
2012-11-15 4:10 ` [ 10/66] iscsi-target: Fix missed wakeup race in TX thread Greg Kroah-Hartman
2012-11-15 4:10 ` [ 11/66] target: Fix incorrect usage of nested IRQ spinlocks in ABORT_TASK path Greg Kroah-Hartman
2012-11-15 4:10 ` [ 12/66] target: Re-add explict zeroing of INQUIRY bounce buffer memory Greg Kroah-Hartman
2012-11-15 4:10 ` [ 13/66] cfg80211: fix antenna gain handling Greg Kroah-Hartman
2012-11-15 4:10 ` [ 14/66] wireless: drop invalid mesh address extension frames Greg Kroah-Hartman
2012-11-15 4:10 ` [ 15/66] mac80211: use blacklist for duplicate IE check Greg Kroah-Hartman
2012-11-15 4:10 ` [ 16/66] mac80211: Only process mesh config header on frames that RA_MATCH Greg Kroah-Hartman
2012-11-15 4:10 ` [ 17/66] mac80211: dont inspect Sequence Control field on control frames Greg Kroah-Hartman
2012-11-15 4:10 ` [ 18/66] DRM/Radeon: Fix Load Detection on legacy primary DAC Greg Kroah-Hartman
2012-11-15 4:10 ` [ 19/66] drm/udl: fix stride issues scanning out stride != width*bpp Greg Kroah-Hartman
2012-11-15 4:10 ` [ 20/66] drm/i915: clear the entire sdvo infoframe buffer Greg Kroah-Hartman
2012-11-15 4:10 ` [ 21/66] drm/i915: fix overlay on i830M Greg Kroah-Hartman
2012-11-16 16:14 ` Ben Hutchings
2012-11-21 1:25 ` Greg Kroah-Hartman
2012-11-15 4:10 ` [ 22/66] drm/i915: Only kick out vesafb if we takeover the fbcon with KMS Greg Kroah-Hartman
2012-11-15 4:10 ` [ 23/66] mac80211: check management frame header length Greg Kroah-Hartman
2012-11-15 4:10 ` [ 24/66] mac80211: verify that skb data is present Greg Kroah-Hartman
2012-11-15 4:10 ` [ 25/66] mac80211: make sure data is accessible in EAPOL check Greg Kroah-Hartman
2012-11-15 4:10 ` [ 26/66] mac80211: fix SSID copy on IBSS JOIN Greg Kroah-Hartman
2012-11-15 4:10 ` [ 27/66] nfsv3: Make v3 mounts fail with ETIMEDOUTs instead EIO on mountd timeouts Greg Kroah-Hartman
2012-11-15 4:10 ` [ 28/66] nfs: Show original device name verbatim in /proc/*/mount{s,info} Greg Kroah-Hartman
2012-11-15 4:10 ` [ 29/66] NFSv4: nfs4_locku_done must release the sequence id Greg Kroah-Hartman
2012-11-15 4:10 ` [ 30/66] NFSv4.1: We must release the sequence id when we fail to get a session slot Greg Kroah-Hartman
2012-11-15 4:10 ` [ 31/66] NFS: Wait for session recovery to finish before returning Greg Kroah-Hartman
2012-11-16 16:17 ` Ben Hutchings
2012-11-21 1:26 ` Greg Kroah-Hartman
2012-11-15 4:10 ` [ 32/66] NFS: fix bug in legacy DNS resolver Greg Kroah-Hartman
2012-11-15 4:10 ` [ 33/66] batman-adv: Fix broadcast packet CRC calculation Greg Kroah-Hartman
2012-11-15 4:10 ` [ 34/66] drm: restore open_count if drm_setup fails Greg Kroah-Hartman
2012-11-15 4:10 ` [ 35/66] drm: set dev_mapping before calling drm_open_helper Greg Kroah-Hartman
2012-11-15 4:10 ` [ 36/66] hwmon: (w83627ehf) Force initial bank selection Greg Kroah-Hartman
2012-11-15 4:10 ` [ 37/66] ALSA: PCM: Fix some races at disconnection Greg Kroah-Hartman
2012-11-15 4:10 ` [ 38/66] ALSA: usb-audio: Fix " Greg Kroah-Hartman
2012-11-15 4:10 ` [ 39/66] ALSA: usb-audio: Use rwsem for disconnect protection Greg Kroah-Hartman
2012-11-15 4:10 ` [ 40/66] ALSA: usb-audio: Fix races at disconnection in mixer_quirks.c Greg Kroah-Hartman
2012-11-15 4:10 ` [ 41/66] ALSA: Add a reference counter to card instance Greg Kroah-Hartman
2012-11-15 4:10 ` [ 42/66] ALSA: Avoid endless sleep after disconnect Greg Kroah-Hartman
2012-11-15 7:25 ` Takashi Iwai [this message]
2012-11-15 22:49 ` Greg Kroah-Hartman
2012-11-15 4:10 ` [ 43/66] sctp: fix call to SCTP_CMD_PROCESS_SACK in sctp_cmd_interpreter() Greg Kroah-Hartman
2012-11-15 4:10 ` [ 44/66] ipv4: Fix flushing of cached routing informations Greg Kroah-Hartman
2012-11-15 4:10 ` [ 45/66] netlink: use kfree_rcu() in netlink_release() Greg Kroah-Hartman
2012-11-15 4:10 ` [ 46/66] tcp: fix FIONREAD/SIOCINQ Greg Kroah-Hartman
2012-11-15 4:10 ` [ 47/66] net: fix secpath kmemleak Greg Kroah-Hartman
2012-11-15 4:10 ` [ 48/66] ipv6: Set default hoplimit as zero Greg Kroah-Hartman
2012-11-15 4:10 ` [ 49/66] net: usb: Fix memory leak on Tx data path Greg Kroah-Hartman
2012-11-15 4:10 ` [ 50/66] net: fix divide by zero in tcp algorithm illinois Greg Kroah-Hartman
2012-11-15 4:10 ` [ 51/66] drivers/net/ethernet/nxp/lpc_eth.c: Call mdiobus_unregister before mdiobus_free Greg Kroah-Hartman
2012-11-15 4:10 ` [ 52/66] l2tp: fix oops in l2tp_eth_create() error path Greg Kroah-Hartman
2012-11-15 4:10 ` [ 53/66] tcp-repair: Handle zero-length data put in rcv queue Greg Kroah-Hartman
2012-11-15 4:10 ` [ 54/66] net: inet_diag -- Return error code if protocol handler is missed Greg Kroah-Hartman
2012-11-15 4:11 ` [ 55/66] af-packet: fix oops when socket is not present Greg Kroah-Hartman
2012-11-15 4:11 ` [ 56/66] ipv6: send unsolicited neighbour advertisements to all-nodes Greg Kroah-Hartman
2012-11-15 4:11 ` [ 57/66] futex: Handle futex_pi OWNER_DIED take over correctly Greg Kroah-Hartman
2012-11-15 4:11 ` [ 58/66] mmc: sh_mmcif: fix use after free Greg Kroah-Hartman
2012-11-15 4:11 ` [ 59/66] mmc: sdhci: fix NULL dereference in sdhci_request() tuning Greg Kroah-Hartman
2012-11-15 4:11 ` [ 60/66] drm/vmwgfx: Fix hibernation device reset Greg Kroah-Hartman
2012-11-15 4:11 ` [ 61/66] drm/vmwgfx: Fix a case where the code would BUG when trying to pin GMR memory Greg Kroah-Hartman
2012-11-15 4:11 ` [ 62/66] drm/radeon/cayman: add some missing regs to the VM reg checker Greg Kroah-Hartman
2012-11-15 4:11 ` [ 63/66] drm/radeon/si: " Greg Kroah-Hartman
2012-11-15 4:11 ` [ 64/66] GFS2: Test bufdata with buffer locked and gfs2_log_lock held Greg Kroah-Hartman
2012-11-25 13:11 ` Ben Hutchings
2012-11-26 15:13 ` Steven Whitehouse
2012-12-02 3:52 ` Ben Hutchings
2012-11-15 4:11 ` [ 65/66] xfs: fix reading of wrapped log data Greg Kroah-Hartman
2012-11-15 4:11 ` [ 66/66] xfs: fix buffer shudown reference count mismatch Greg Kroah-Hartman
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=s5h8va3ba5k.wl%tiwai@suse.de \
--to=tiwai@suse.de \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
/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
all inboxes | Powered by JetHome®