From patchwork Thu Mar 22 12:48:17 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gianluca Gennari X-Patchwork-Id: 10447 Received: from mail.tu-berlin.de ([130.149.7.33]) by www.linuxtv.org with esmtp (Exim 4.72) (envelope-from ) id 1SAhRO-000368-7p for patchwork@linuxtv.org; Thu, 22 Mar 2012 13:48:30 +0100 X-tubIT-Incoming-IP: 209.132.180.67 Received: from vger.kernel.org ([209.132.180.67]) by mail.tu-berlin.de (exim-4.75/mailfrontend-4) with esmtp for id 1SAhRN-0005r2-BP; Thu, 22 Mar 2012 13:48:30 +0100 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755125Ab2CVMs1 (ORCPT ); Thu, 22 Mar 2012 08:48:27 -0400 Received: from mail-ee0-f46.google.com ([74.125.83.46]:37048 "EHLO mail-ee0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753664Ab2CVMs0 (ORCPT ); Thu, 22 Mar 2012 08:48:26 -0400 Received: by eekc41 with SMTP id c41so677305eek.19 for ; Thu, 22 Mar 2012 05:48:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; bh=crKNwrWdf+fw0lTC4xtvP1VdHwO/efKWBaTimEjhlj8=; b=W2V0XCNlZ6AxPHTJi2RmGnyeAAjuOxuG1Ui6K7X9X+eGNibI3C7ivEfgKd1R3M0SOR Ra/tIOfUnoGdnOAqgQjLmvTDfUG+IVfWU15izd3vRhcheD02FhswepoHUQ1OO3rJJgCM ufo70EegndtOuGSe+Wzx/rZmzGo8FMixAdJdYOHrGtzVPHfa+MO9I64AVBeB0KOCqrp5 UvslPR/oP8DTNw9BPUlf9E/4RabBfIQNA5bfLpmx6LMTqPYQi6t1UbVtvh+eNdYRpET9 ZRN+c0RswFWatk3d7HthjqhAxu0+eY/I7YMx5qkHeo1WpuGzHRjQ8PvjzD295Gr6dQ6/ 5D4g== Received: by 10.213.33.14 with SMTP id f14mr588192ebd.140.1332420505232; Thu, 22 Mar 2012 05:48:25 -0700 (PDT) Received: from localhost.localdomain (93-50-34-119.ip150.fastwebnet.it. [93.50.34.119]) by mx.google.com with ESMTPS id x8sm16733936eea.10.2012.03.22.05.48.23 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 22 Mar 2012 05:48:24 -0700 (PDT) From: Gianluca Gennari To: linux-media@vger.kernel.org, mchehab@redhat.com Cc: crope@iki.fi, Gianluca Gennari Subject: [PATCH] em28xx-dvb: stop URBs when stopping the streaming Date: Thu, 22 Mar 2012 13:48:17 +0100 Message-Id: <1332420497-16352-1-git-send-email-gennarone@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <4F6B0CF9.2030608@gmail.com> References: <4F6B0CF9.2030608@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-PMX-Version: 5.6.1.2065439, Antispam-Engine: 2.7.2.376379, Antispam-Data: 2012.3.22.123622 X-PMX-Spam: Gauge=IIIIIIIII, Probability=9%, Report=' FORGED_FROM_GMAIL 0.1, MULTIPLE_RCPTS 0.1, HTML_00_01 0.05, HTML_00_10 0.05, BODY_SIZE_3000_3999 0, BODY_SIZE_5000_LESS 0, BODY_SIZE_7000_LESS 0, __ANY_URI 0, __CP_MEDIA_BODY 0, __CP_URI_IN_BODY 0, __FRAUD_BODY_WEBMAIL 0, __FRAUD_WEBMAIL 0, __FRAUD_WEBMAIL_FROM 0, __FROM_GMAIL 0, __HAS_MSGID 0, __HAS_X_MAILER 0, __HAS_X_MAILING_LIST 0, __MIME_TEXT_ONLY 0, __MULTIPLE_RCPTS_CC_X2 0, __PHISH_SPEAR_STRUCTURE_1 0, __SANE_MSGID 0, __SUBJ_ALPHA_END 0, __TO_MALFORMED_2 0, __TO_NO_NAME 0, __URI_NO_WWW 0, __URI_NS ' Stop the URBs in em28xx_stop_streaming(), so that em28xx_irq_callback() cannot be called after the streaming has stopped. This should eliminate the crashes reported by Antti Palosaari and the warnings reported by Andy Furniss. Signed-off-by: Gianluca Gennari --- drivers/media/video/em28xx/em28xx-core.c | 26 +++++++++++++++++++++++++- drivers/media/video/em28xx/em28xx-dvb.c | 2 +- drivers/media/video/em28xx/em28xx.h | 1 + 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/drivers/media/video/em28xx/em28xx-core.c b/drivers/media/video/em28xx/em28xx-core.c index 53a9fb9..cbbe399 100644 --- a/drivers/media/video/em28xx/em28xx-core.c +++ b/drivers/media/video/em28xx/em28xx-core.c @@ -666,7 +666,6 @@ int em28xx_capture_start(struct em28xx *dev, int start) return rc; } -EXPORT_SYMBOL_GPL(em28xx_capture_start); int em28xx_vbi_supported(struct em28xx *dev) { @@ -1008,6 +1007,31 @@ void em28xx_uninit_isoc(struct em28xx *dev, enum em28xx_mode mode) EXPORT_SYMBOL_GPL(em28xx_uninit_isoc); /* + * Stop URBs + */ +void em28xx_stop_urbs(struct em28xx *dev) +{ + int i; + struct urb *urb; + struct em28xx_usb_isoc_bufs *isoc_bufs = &dev->isoc_ctl.digital_bufs; + + em28xx_isocdbg("em28xx: called em28xx_stop_urbs\n"); + + for (i = 0; i < isoc_bufs->num_bufs; i++) { + urb = isoc_bufs->urb[i]; + if (urb) { + if (!irqs_disabled()) + usb_kill_urb(urb); + else + usb_unlink_urb(urb); + } + } + + em28xx_capture_start(dev, 0); +} +EXPORT_SYMBOL_GPL(em28xx_stop_urbs); + +/* * Allocate URBs */ int em28xx_alloc_isoc(struct em28xx *dev, enum em28xx_mode mode, diff --git a/drivers/media/video/em28xx/em28xx-dvb.c b/drivers/media/video/em28xx/em28xx-dvb.c index 503a8d5..2d73ee2 100644 --- a/drivers/media/video/em28xx/em28xx-dvb.c +++ b/drivers/media/video/em28xx/em28xx-dvb.c @@ -183,7 +183,7 @@ static int em28xx_stop_streaming(struct em28xx_dvb *dvb) { struct em28xx *dev = dvb->adapter.priv; - em28xx_capture_start(dev, 0); + em28xx_stop_urbs(dev); em28xx_set_mode(dev, EM28XX_SUSPEND); diff --git a/drivers/media/video/em28xx/em28xx.h b/drivers/media/video/em28xx/em28xx.h index 2868b19..286b9f8 100644 --- a/drivers/media/video/em28xx/em28xx.h +++ b/drivers/media/video/em28xx/em28xx.h @@ -695,6 +695,7 @@ int em28xx_init_isoc(struct em28xx *dev, enum em28xx_mode mode, int max_packets, int num_bufs, int max_pkt_size, int (*isoc_copy) (struct em28xx *dev, struct urb *urb)); void em28xx_uninit_isoc(struct em28xx *dev, enum em28xx_mode mode); +void em28xx_stop_urbs(struct em28xx *dev); int em28xx_isoc_dvb_max_packetsize(struct em28xx *dev); int em28xx_set_mode(struct em28xx *dev, enum em28xx_mode set_mode); int em28xx_gpio_set(struct em28xx *dev, struct em28xx_reg_seq *gpio);