From patchwork Tue Aug 5 16:44:50 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Goode X-Patchwork-Id: 4680521 X-Patchwork-Delegate: tiwai@suse.de Return-Path: X-Original-To: patchwork-alsa-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 448FEC0338 for ; Tue, 5 Aug 2014 16:46:30 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 49C852018E for ; Tue, 5 Aug 2014 16:46:29 +0000 (UTC) Received: from alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) by mail.kernel.org (Postfix) with ESMTP id 1024C2018A for ; Tue, 5 Aug 2014 16:46:28 +0000 (UTC) Received: by alsa0.perex.cz (Postfix, from userid 1000) id 20B75261B08; Tue, 5 Aug 2014 18:46:27 +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 52ECB261B14; Tue, 5 Aug 2014 18:45:56 +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 BE9B3265510; Tue, 5 Aug 2014 18:45:54 +0200 (CEST) Received: from mail-yh0-f48.google.com (mail-yh0-f48.google.com [209.85.213.48]) by alsa0.perex.cz (Postfix) with ESMTP id 5E84F261B08 for ; Tue, 5 Aug 2014 18:45:11 +0200 (CEST) Received: by mail-yh0-f48.google.com with SMTP id i57so813369yha.35 for ; Tue, 05 Aug 2014 09:45:10 -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:in-reply-to:references; bh=FvJoBHAkWVAyZDMaUWNC6dekajDmpb2c8OEtfrl8Cu4=; b=Y3saawGpwNXkNE0FMGAFgTHNsXEWSrOADXAwTOd+0Z5O6LGt0VSAJJ28SCl6+UPNji +oEPPK1BdnI3dA5Rkd1qrE42N7iJxlOyCl5RhXe8chpHjsK+8YH23/oHxe6My2kAwB72 7A3MHnNMdBoLW9VwgrPLyZbF3gvUf5A4RE5M4Lll6tXIaVVzAgJnf0zOz2iR9Ppz3ibI g7++E4CPqYylmSCorC6b/k5j3Ar4qEZPakSBTYHCv5KI02o/RBEELVDhRcGyStx8O+VX YhlqGViJC477P8rtqIIhgizNMxpIcAt/FJuPqDpV803z00s3S3vm2A9ZY/StKaPefOMb PEMA== 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:in-reply-to :references; bh=FvJoBHAkWVAyZDMaUWNC6dekajDmpb2c8OEtfrl8Cu4=; b=aru1zHVXxx7kb4PoQFTJRbskgJjLrhHgT/F7wAZwNhG1FuJbaIbsnbW3QO0W0ByaED tdyuJsVa0P83RlyBhlDiJQBmBMFe9HMsqdUmBeP2ubBo+QADA1QnH67NcDQYWT+4dJ/9 pW0leF0Zk8n3DNlnAsv1IaQql0V5WHbWVp87RUlbiRhX2x9ILD1aITKjHeeV5Is0ceAW lLO/lcQ70YkinqTk/upyuUfPEEjC3qiqbV3lGwVwPS5cbhO4ao2nJUA2hDc3sxsQM+IR APRYDetwD6k7gduyQZ+TFfeH+dY9GdiASoH9oFf3HVgUNSS3qtS8naHbUk1D/cS15143 7Liw== X-Gm-Message-State: ALoCoQkoKAb2vqBi9Infd/iSaYgLZ+uGY5hAyJxVXYVSIO9IB+VHWhBujrVXy5Sj+CmgjEMfm+7U X-Received: by 10.236.73.102 with SMTP id u66mr7603752yhd.160.1407257110617; Tue, 05 Aug 2014 09:45:10 -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 u23sm3738428yhg.28.2014.08.05.09.45.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 05 Aug 2014 09:45:09 -0700 (PDT) From: Adam Goode To: patch@alsa-project.org Date: Tue, 5 Aug 2014 12:44:50 -0400 Message-Id: <1407257091-16462-2-git-send-email-agoode@google.com> X-Mailer: git-send-email 2.0.0.526.g5318336 In-Reply-To: <1407257091-16462-1-git-send-email-agoode@google.com> References: <1407257091-16462-1-git-send-email-agoode@google.com> Cc: Adam Goode , alsa-devel@alsa-project.org Subject: [alsa-devel] [PATCH v2 - sound/usb 1/2] Respond to suspend and resume callbacks for MIDI input in sound/usb 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..9a4e82c 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 */