From patchwork Tue Aug 5 12:20:30 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Goode X-Patchwork-Id: 4678561 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 0E35F9F373 for ; Tue, 5 Aug 2014 12:21:15 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1E8A520173 for ; Tue, 5 Aug 2014 12:21:14 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id A508820160 for ; Tue, 5 Aug 2014 12:21:12 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 5BB6F264F0F; Tue, 5 Aug 2014 14:21:11 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Spam-Level: X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=no version=3.3.1 Received: from alsa0.perex.cz (localhost [IPv6:::1]) by alsa0.perex.cz (Postfix) with ESMTP id 905C7264ED5; Tue, 5 Aug 2014 14:21:02 +0200 (CEST) X-Original-To: alsa-devel@alsa-project.org Delivered-To: alsa-devel@alsa-project.org Received: by alsa0.perex.cz (Postfix, from userid 1000) id 284F1264EBF; Tue, 5 Aug 2014 14:20:58 +0200 (CEST) Received: from mail-yh0-f50.google.com (mail-yh0-f50.google.com [209.85.213.50]) by alsa0.perex.cz (Postfix) with ESMTP id 46EAA2625EA for ; Tue, 5 Aug 2014 14:20:50 +0200 (CEST) Received: by mail-yh0-f50.google.com with SMTP id v1so565920yhn.9 for ; Tue, 05 Aug 2014 05:20:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=jPgUI+EhSOz1oH6gi7h5u5uqPLf6ov27Xm1TygwvwLA=; b=W71eKIAoMPjoGAZItNovwQtVLn+7lV3YaskOvo+XhQs0kS/AFGpOKypwUCjdvRQxrH qlGsaJ+ep+4JweZkgN3xrx7jGrKY+AOsM4EfQLRAOPCyiXLMgFVVsGvIomopiisWXw9w nlBNNg/JF5lQ9qYbltzyAOlLhICH6s9KnQryByFdA8AqXOlWFawsfiMQ4JOk4yYHQ9Oi Y+bojdDLTiL7EaNiWQdOtlEc5mrvfZHni6UwDnMXKJ2vhKcpEKYjFJ4sLcFBekzUMUnk TrldhAeIlbCPpD2+hwDckPv5xzT/acQPy0n5bKR8o/OYyiM7lb7Y9q2mki6NYmg8TF+1 ABCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=jPgUI+EhSOz1oH6gi7h5u5uqPLf6ov27Xm1TygwvwLA=; b=me6qoQjGps0qHUPu4PPw4X5lWKyCrTaIDC+tBa45Z6MC83GP9rn+OwJ0wzP3uFWa3G idCfx6YFaw1fNIauBa5FoUA5c6o6lOQ8KKzvqoJOJXWosZ5DDDOzzdxW3ajlJoESPMeJ 9qSVJdMAv3J/tVHcF9cfOLXEhv+0Ial3SDhgI3bsPzyjClIbbgxhLSp5RzGel0Z6OWnB gX+fjqZVEB3iXmkV8vJCeuGTZN761rvrIfG2V6y7/7bsQCx9jmRwe960EtjNzSxeAdLA yX+IUHTFA5VuULfTzMCX0YMS0vjU/ZrrV+P/v8BvZvOBTkN83aadtGpzmGrcSO7eVTsB KyHQ== X-Gm-Message-State: ALoCoQnWKPwZvUDQ+iiAbmaYvsdAFoh8/V41X1VifV40wZZhUMZ2aoI8eaH+Utgt+NVU1xQxEdq/ X-Received: by 10.236.15.6 with SMTP id e6mr5350385yhe.43.1407241248929; Tue, 05 Aug 2014 05:20:48 -0700 (PDT) Received: from wpg-ubiq154.hot.corp.google.com (wpg-ubiq154.hot.corp.google.com [172.24.166.195]) by mx.google.com with ESMTPSA id i24sm2717644yha.12.2014.08.05.05.20.47 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Aug 2014 05:20:47 -0700 (PDT) From: Adam Goode To: patch@alsa-project.org Date: Tue, 5 Aug 2014 08:20:30 -0400 Message-Id: <1407241230-486-1-git-send-email-agoode@google.com> X-Mailer: git-send-email 2.0.0.526.g5318336 Cc: Adam Goode , alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH - sound/usb 1/1] Respond to suspend and resume callbacks for input in sound/usb/midi.c X-BeenThere: alsa-devel@alsa-project.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: alsa-devel-bounces@alsa-project.org Sender: alsa-devel-bounces@alsa-project.org X-Virus-Scanned: ClamAV using ClamSMTP sound/usb/card.c registers USB suspend and resume but did not previously kill the input URBs. This means that USB MIDI devices left open across suspend/resume had non-functional input (output still usually worked, but it looks like that is another issue). Before this change, we would get ESHUTDOWN for each of the input URBs at suspend time, killing input. Signed-off-by: Adam Goode diff --git a/sound/usb/card.c b/sound/usb/card.c index a09e5f3..7ecd0e8 100644 --- a/sound/usb/card.c +++ b/sound/usb/card.c @@ -680,6 +680,7 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) struct snd_usb_audio *chip = usb_get_intfdata(intf); struct snd_usb_stream *as; struct usb_mixer_interface *mixer; + struct list_head *p; if (chip == (void *)-1L) return 0; @@ -692,6 +693,9 @@ static int usb_audio_suspend(struct usb_interface *intf, pm_message_t message) as->substream[0].need_setup_ep = as->substream[1].need_setup_ep = true; } + list_for_each(p, &chip->midi_list) { + snd_usbmidi_suspend(p); + } } } else { /* @@ -713,6 +717,7 @@ static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume) { struct snd_usb_audio *chip = usb_get_intfdata(intf); struct usb_mixer_interface *mixer; + struct list_head *p; int err = 0; if (chip == (void *)-1L) @@ -731,6 +736,10 @@ static int __usb_audio_resume(struct usb_interface *intf, bool reset_resume) goto err_out; } + list_for_each(p, &chip->midi_list) { + snd_usbmidi_resume(p); + } + if (!chip->autosuspended) snd_power_change_state(chip->card, SNDRV_CTL_POWER_D0); chip->autosuspended = 0; diff --git a/sound/usb/midi.c b/sound/usb/midi.c index 9da74d2..e7c6c9d 100644 --- a/sound/usb/midi.c +++ b/sound/usb/midi.c @@ -2187,6 +2187,34 @@ void snd_usbmidi_input_start(struct list_head* p) EXPORT_SYMBOL(snd_usbmidi_input_start); /* + * Prepare for suspend. Typically called from the USB suspend callback. + */ +void snd_usbmidi_suspend(struct list_head* p) +{ + struct snd_usb_midi* umidi; + + umidi = list_entry(p, struct snd_usb_midi, list); + mutex_lock(&umidi->mutex); + snd_usbmidi_input_stop(p); + mutex_unlock(&umidi->mutex); +} +EXPORT_SYMBOL(snd_usbmidi_suspend); + +/* + * Resume. Typically called from the USB resume callback. + */ +void snd_usbmidi_resume(struct list_head* p) +{ + struct snd_usb_midi* umidi; + + umidi = list_entry(p, struct snd_usb_midi, list); + mutex_lock(&umidi->mutex); + snd_usbmidi_input_start(p); + mutex_unlock(&umidi->mutex); +} +EXPORT_SYMBOL(snd_usbmidi_resume); + +/* * Creates and registers everything needed for a MIDI streaming interface. */ int snd_usbmidi_create(struct snd_card *card, diff --git a/sound/usb/midi.h b/sound/usb/midi.h index 2fca80b..46e5b65 100644 --- a/sound/usb/midi.h +++ b/sound/usb/midi.h @@ -46,5 +46,7 @@ int snd_usbmidi_create(struct snd_card *card, void snd_usbmidi_input_stop(struct list_head* p); void snd_usbmidi_input_start(struct list_head* p); void snd_usbmidi_disconnect(struct list_head *p); +void snd_usbmidi_suspend(struct list_head *p); +void snd_usbmidi_resume(struct list_head *p); #endif /* __USBMIDI_H */