Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2708717imu; Tue, 6 Nov 2018 20:53:47 -0800 (PST) X-Google-Smtp-Source: AJdET5dziFKrqtK1uYrgdkGaDG+O45P6Pld3lshMx4M+Qck314pXBO7n0mohARWiuGZliTnwymRJ X-Received: by 2002:a62:6bc8:: with SMTP id g191-v6mr498953pfc.134.1541566426944; Tue, 06 Nov 2018 20:53:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1541566426; cv=none; d=google.com; s=arc-20160816; b=Zdrct90u852+6xN6PlyMFZea23Gs3Yol0L/21WFIFwkYgNRsuLTVsclQJNrhPOMwai p5dpEo7/OAreDf7fNIXN9BC0ls6oGrYnXYF3mMQ8jmaPPtk3ARTesCkFy4TE8kL/3yQf mJkbNjFumlVf/41rahEu+u4coBvExT9jhOfDu+ppvqdW4c4Qej9d3x8CgdKStkJoqq7T Exs+aHYvxu2W2RHTQmFBrLBiU+x0lzMxjxEEa7nYZoYVQqLfkhDemJ8KRSfxeU7gwdtW 2AnYM5rctZVIagv8MPz8V40TRbptjhzwV1ijXZz4PjV3POTVWhrHl77/OShnm9Vo/WHr I6NQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=hL28HXW30M7RjFZtG0lnuAG5WYEvZwiKm6NA/ZWDifs=; b=kB9k1ExnQqlK0RB8gJTcR4Z9u2IVgMUMmwkmd20T6A0hJovMuC4XTcCXcEoB8YS5jT 88qxhZ9gx6yGxtWytV03Wr+eqJz/dYEDw2ead8JwUo8Bf40gJWq6uiXP99oGZKVrmgKi rpIlynHqvmPs9p5tAyxs8VKbi0abYBeOLbRwLgtaZqcqEB8LNoFf+jQyWFQlDeneu3/n nXrsG1nET2wRiNdnRIZjR3poBbk+LfAlcyEq3+II1iaYRJbNqIcNOerCkIbLqDZVxWvp AV3HQbZ8ZX8zWNYHc9tKv3xLDNWLQ9VCd8puduEV0ICcfmBniyb32c71BSnWtPymMlHf bnzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KOCVhsBp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y12-v6si22797120pgg.158.2018.11.06.20.53.24; Tue, 06 Nov 2018 20:53:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=KOCVhsBp; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388824AbeKGOHN (ORCPT + 99 others); Wed, 7 Nov 2018 09:07:13 -0500 Received: from mail-yb1-f195.google.com ([209.85.219.195]:35615 "EHLO mail-yb1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388424AbeKGOHN (ORCPT ); Wed, 7 Nov 2018 09:07:13 -0500 Received: by mail-yb1-f195.google.com with SMTP id z2-v6so6347386ybj.2 for ; Tue, 06 Nov 2018 20:38:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=hL28HXW30M7RjFZtG0lnuAG5WYEvZwiKm6NA/ZWDifs=; b=KOCVhsBpPWO3gLKHXX4zLgwtz35r3JtHhkmho9z92CLxj9dE/+Cubg14STvkn5bdKc BcY6uP45jA73buR0aoIVnru192dhJi7zT7rn+JE8WsVWJfqen89gsHI71Gdg5H1+45d+ NWR0JfQDhJYVs7IKdTAQtvi29t8jyQvo+MSUI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=hL28HXW30M7RjFZtG0lnuAG5WYEvZwiKm6NA/ZWDifs=; b=H1v34ixq0Aai4NjZZQVsJrXOmsmRMoXXsIzor52wBWRAgn9+rSCDJhdkHoXPybDCsD qnLlhfXRRNs/lsmM0NdPyoC8XNcI8ybl/ClYyQWQNToiD24pPAsgsEppqcJ6Yk9YVqKl l2RuNQMl+5mlXh9WqTyOmgKmE79RIOdVxNtHgLS09JwxietZmqB/7qba0ch9IcmGcsgO SugJm/HJqFbJPL+1+kbbd3ALYRCCJQb80jSX34FXPG8D1wN43zozthJ7ECvxQ+E3K034 YcDgrlu9/5OwzKjKAmPM2FrCn0WESW5BE14cY6kC5CJNEsF1lwZmWisuxNKVNt/1QY9T ow1Q== X-Gm-Message-State: AGRZ1gJ3fnbuEGLcAIO9AkPqOlXLIq81l1g2tZG+ET5AKypQdmAqe7uE +eue3T76AoWW2cq3g7iDtv1UMV2yQvI= X-Received: by 2002:a25:6d06:: with SMTP id i6-v6mr240054ybc.333.1541565512421; Tue, 06 Nov 2018 20:38:32 -0800 (PST) Received: from mail-yb1-f180.google.com (mail-yb1-f180.google.com. [209.85.219.180]) by smtp.gmail.com with ESMTPSA id v129-v6sm2078885ywa.8.2018.11.06.20.38.31 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Nov 2018 20:38:31 -0800 (PST) Received: by mail-yb1-f180.google.com with SMTP id u103-v6so4783852ybi.5 for ; Tue, 06 Nov 2018 20:38:31 -0800 (PST) X-Received: by 2002:a25:9a46:: with SMTP id r6-v6mr250702ybo.303.1541565510737; Tue, 06 Nov 2018 20:38:30 -0800 (PST) MIME-Version: 1.0 References: <4fa1b96d-912c-ec07-f08e-d8de164a0186@ideasonboard.com> In-Reply-To: <4fa1b96d-912c-ec07-f08e-d8de164a0186@ideasonboard.com> From: Tomasz Figa Date: Wed, 7 Nov 2018 13:38:19 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v4 6/6] media: uvcvideo: Move decode processing to process context To: Kieran Bingham Cc: Laurent Pinchart , Linux Media Mailing List , Guennadi Liakhovetski , olivier.braun@stereolabs.com, troy.kisky@boundarydevices.com, Randy Dunlap , Philipp Zabel , Mauro Carvalho Chehab , Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kieran, On Wed, Nov 7, 2018 at 12:13 AM Kieran Bingham wrote: > > Hi Tomasz, > > On 07/08/2018 10:54, Tomasz Figa wrote: > > Hi Kieran, > > > > On Wed, Mar 28, 2018 at 1:47 AM Kieran Bingham > > wrote: > > [snip] > >> @@ -1544,25 +1594,29 @@ static int uvc_alloc_urb_buffers(struct uvc_streaming *stream, > >> */ > >> static void uvc_uninit_video(struct uvc_streaming *stream, int free_buffers) > >> { > >> - struct urb *urb; > >> - unsigned int i; > >> + struct uvc_urb *uvc_urb; > >> > >> uvc_video_stats_stop(stream); > >> > >> - for (i = 0; i < UVC_URBS; ++i) { > >> - struct uvc_urb *uvc_urb = &stream->uvc_urb[i]; > >> + /* > >> + * We must poison the URBs rather than kill them to ensure that even > >> + * after the completion handler returns, any asynchronous workqueues > >> + * will be prevented from resubmitting the URBs > >> + */ > >> + for_each_uvc_urb(uvc_urb, stream) > >> + usb_poison_urb(uvc_urb->urb); > >> > >> - urb = uvc_urb->urb; > >> - if (urb == NULL) > >> - continue; > >> + flush_workqueue(stream->async_wq); > >> > >> - usb_kill_urb(urb); > >> - usb_free_urb(urb); > >> + for_each_uvc_urb(uvc_urb, stream) { > >> + usb_free_urb(uvc_urb->urb); > >> uvc_urb->urb = NULL; > >> } > >> > >> if (free_buffers) > >> uvc_free_urb_buffers(stream); > >> + > >> + destroy_workqueue(stream->async_wq); > > > > In our testing, this function ends up being called twice, if before > > suspend the camera is streaming and if the camera disconnects between > > suspend and resume. This is because uvc_video_suspend() calls this > > function (with free_buffers = 0), but uvc_video_resume() wouldn't call > > uvc_init_video() due to an earlier failure and uvc_v4l2_release() > > would end up calling this function again, while the workqueue is > > already destroyed. > > > > The following diff seems to take care of it: > > Thank you for this. After discussing with Laurent, I have gone with the > approach of keeping the workqueue for the lifetime of the stream, rather > than the lifetime of the streamon. > Sounds good to me. Thanks for heads up! Best regards, Tomasz