Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp3527314imm; Mon, 4 Jun 2018 05:12:47 -0700 (PDT) X-Google-Smtp-Source: ADUXVKKejiGspMJNiXkSoodUcL/8RLTzxeagSBhDtTipwmg1Vf1ETvNznROGRsh1/q7thvTY1meG X-Received: by 2002:a63:6b84:: with SMTP id g126-v6mr16661680pgc.272.1528114367647; Mon, 04 Jun 2018 05:12:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528114367; cv=none; d=google.com; s=arc-20160816; b=mHgugLRMBOt9Qea9OhHvt1UqkTICJ5ZqUiwWUfI4CuxYKlKjpodRJu3nUt1rr4cAIO Ep8qydCHeidPBac28+Zi8oy6ifLGAsqhHUnOnQGr4ZNtDqvcnGxeakAmK0CHOPJqJ5eL gsaQRkNhZOHvHXlXvhpdwQ19fmzn/WQCEiu2c57eqVQl8QIPyw/26jKBexozrLvXCfjH JI/GCLXnhrxHtwTCRejM69O6pH3lGq7UlvDRMkjajtW9bUevFX8ayc3oNBXLX6dgwJwa RwF6kNaeN3QStTZlbzyErIy/WR62cfqD4qpVG5IXnYGgx4xHs/6nXutKP6Hh+nrhb6Hy 2ymQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :message-id:in-reply-to:subject:cc:to:from:date :arc-authentication-results; bh=iNzPz9wAaRneWaoMl5iu1Wq/66sGMqe0HZCxp5gpV4Q=; b=nz4+poQ3sFMHtdKqcWeRwZy3eTVWWIrVtWvBDjcXd53aAEGY59iAF1xtQvOfSSjeZB xVGbiw3yFmge3XrCeaepwDhobCKqh73Aeh+gpynK7NfDgLI6i1paZauahD4QxI6TPMUS 5bMZi8XNu75MjHgULl64vAaw3+3+LN4Tdq0SxSK/xSPGFDvblLRidCzYQ9HVmwabo2jE 7hD0LSuSu5MyOCDTT7eN5RWJYthccNHVCmhn9VA3weyv+4YJQBZAkuabr5S4hOkeH99t syCbJ37IgMS8qPpcUR0IpJPtK5bMvjRfpJ7pO1i4y8g+IwkmAa6eu0GVqdJCjGWVRnx3 fP8w== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k8-v6si8711541pgc.182.2018.06.04.05.12.31; Mon, 04 Jun 2018 05:12:47 -0700 (PDT) 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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752474AbeFDMK4 (ORCPT + 99 others); Mon, 4 Jun 2018 08:10:56 -0400 Received: from mout.gmx.net ([212.227.15.18]:37991 "EHLO mout.gmx.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750868AbeFDMKz (ORCPT ); Mon, 4 Jun 2018 08:10:55 -0400 Received: from axis700.grange ([87.78.226.14]) by mail.gmx.com (mrgmx001 [212.227.17.190]) with ESMTPSA (Nemesis) id 0MDymt-1fVYgC0DKp-00HNFj; Mon, 04 Jun 2018 14:09:43 +0200 Received: by axis700.grange (Postfix, from userid 1000) id 84CCB60574; Mon, 4 Jun 2018 14:09:41 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by axis700.grange (Postfix) with ESMTP id 6C505603EE; Mon, 4 Jun 2018 14:09:41 +0200 (CEST) Date: Mon, 4 Jun 2018 14:09:41 +0200 (CEST) From: Guennadi Liakhovetski X-X-Sender: lyakh@axis700.grange To: Kieran Bingham cc: Laurent Pinchart , linux-media@vger.kernel.org, Olivier BRAUN , Troy Kisky , Randy Dunlap , Philipp Zabel , Mauro Carvalho Chehab , open list Subject: Re: [PATCH v4 6/6] media: uvcvideo: Move decode processing to process context In-Reply-To: Message-ID: References: User-Agent: Alpine 2.20 (DEB 67 2015-01-07) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Provags-ID: V03:K1:VEdFm2pV6/eLtkgvfFjGjSECJc1GS4AvacdZwdNJVrqtEJa4hZ9 IH9tn0oo0vONTJzIzHGOcmoVEM4d/gSgRzZGYNvZjSwA4C0s8DSTML14QSsDlQrtu/65ep3 Vf1TN2UcFVdcTdRrOt8Bo8RyzOZCvqCHksJnUGUfX45IyUtjUOTH7240TIRs9ZvfdD5T7HQ pIiwO5sOqMY/QCGOtxQsg== X-UI-Out-Filterresults: notjunk:1;V01:K0:e+EBR5ekqrU=:NFM8asTaXOZ4W7BOKQS27C Wtd7LEIgKFz15ESRrsulD3qma9MJjgOKLNf0JX8y4/XTVYYhsiJc/udil0FHXUTpG8lZyIhzB kA2IlyK/1bN4hSg6vuG8SsZcy48OgrnBS/zLFRNQrjeSelSNY7bwv6iufapTxJsZaKTeZ4+Do lq7y7ma5JQK6d2GbsLwA/hhBahC9CPrYQjokbjNM3khwt3+x4scI5aTxiPYl+I8fDGr+0PNjx dgV9uLvOF1NUgL+myR+WouzjzmIy7qT+FmgvcEmaZ4CVZ8zflsgJGTc6LueEIbXdeDUe6DSJo g+4vbkvQh0YVhuRrNZZQkBNbRoSMhUsEnbabh6K9SpFBaVl742TzeTJjnhpiLaa38QzTZpQNA hkgRzRgt+Bm8DSePSMWO3i9po5KcW/XDlTnR0AU0Mb4k6hopVL9PNmfe3ZGYKhYU7wBjawMwS u9hrx1i6Kqv8n6F7PYxiZ4oiMAYHl+4tivBf+0BamC0TyxTVjEwR0YrnjCdfE6EJo5DAJZcG4 l8G+aPP+eBfiMlDAQlNLZuAq5Rl84CBXjOtMxdOWlnJWSnp9ApUv+tK71fnEJRaRjEw6Dmjlz IsMRW3A7uyDjGJWamuuFucx5cXrU+GQpaTYYi3bX4axoC/at24Dqh992Hh621irAb32+qxGlW ykQAc7vLn8pB+awoXTeOAEgXvS5xJO91WI0iVqbrR1sO/JE2KdrtNkvvcMCBLW5+kg6kbhCPe UeJ0cyNbAS4uXjZD/Z8NBYRGBLg9vVm08LJAGvrt49MjcpR6NRdarpmf0UZcCX33Ect2uYO4x lMihgfa Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Kieran, I've got a question: On Tue, 27 Mar 2018, Kieran Bingham wrote: > Newer high definition cameras, and cameras with multiple lenses such as > the range of stereo-vision cameras now available have ever increasing > data rates. > > The inclusion of a variable length packet header in URB packets mean > that we must memcpy the frame data out to our destination 'manually'. > This can result in data rates of up to 2 gigabits per second being > processed. > > To improve efficiency, and maximise throughput, handle the URB decode > processing through a work queue to move it from interrupt context, and > allow multiple processors to work on URBs in parallel. > > Signed-off-by: Kieran Bingham > > --- > v2: > - Lock full critical section of usb_submit_urb() > > v3: > - Fix race on submitting uvc_video_decode_data_work() to work queue. > - Rename uvc_decode_op -> uvc_copy_op (Generic to encode/decode) > - Rename decodes -> copy_operations > - Don't queue work if there is no async task > - obtain copy op structure directly in uvc_video_decode_data() > - uvc_video_decode_data_work() -> uvc_video_copy_data_work() > > v4: > - Provide for_each_uvc_urb() > - Simplify fix for shutdown race to flush queue before freeing URBs > - Rebase to v4.16-rc4 (linux-media/master) adjusting for metadata > conflicts. > > drivers/media/usb/uvc/uvc_video.c | 107 ++++++++++++++++++++++++------- > drivers/media/usb/uvc/uvcvideo.h | 28 ++++++++- > 2 files changed, 111 insertions(+), 24 deletions(-) > > diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c > index 7dd0dcb457f3..a62e8caf367c 100644 > --- a/drivers/media/usb/uvc/uvc_video.c > +++ b/drivers/media/usb/uvc/uvc_video.c > @@ -1042,21 +1042,54 @@ static int uvc_video_decode_start(struct uvc_streaming *stream, > return data[0]; > } > > -static void uvc_video_decode_data(struct uvc_streaming *stream, > +/* > + * uvc_video_decode_data_work: Asynchronous memcpy processing > + * > + * Perform memcpy tasks in process context, with completion handlers > + * to return the URB, and buffer handles. > + */ > +static void uvc_video_copy_data_work(struct work_struct *work) > +{ > + struct uvc_urb *uvc_urb = container_of(work, struct uvc_urb, work); > + unsigned int i; > + int ret; > + > + for (i = 0; i < uvc_urb->async_operations; i++) { > + struct uvc_copy_op *op = &uvc_urb->copy_operations[i]; > + > + memcpy(op->dst, op->src, op->len); > + > + /* Release reference taken on this buffer */ > + uvc_queue_buffer_release(op->buf); > + } > + > + ret = usb_submit_urb(uvc_urb->urb, GFP_ATOMIC); Does this still have to be ATOMIC now that it's called from a work queue context? > + if (ret < 0) > + uvc_printk(KERN_ERR, "Failed to resubmit video URB (%d).\n", > + ret); > +} [snip] Thannks Guennadi