Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp146851imm; Thu, 30 Aug 2018 10:22:34 -0700 (PDT) X-Google-Smtp-Source: ANB0VdY7iDMr4choh+O2oOBtd2gRO87GNyUcnpQL1j7WrzICvjL5wt/yL9gxYhPr8N+ca/ERGkXL X-Received: by 2002:a17:902:b40e:: with SMTP id x14-v6mr10943962plr.314.1535649754288; Thu, 30 Aug 2018 10:22:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535649754; cv=none; d=google.com; s=arc-20160816; b=UZ9Fsi+rnL+cm3XN4UekFDys2AxiobwP2EAmPR7hGXoo+XMwch+3JLFTWAwsL8iYxI FkD4pA/IxTEDCIII6wj8yfBG6R+6LONWalpP8pV2GAdjwutnPQ4rFf6braECvSXOYKFY q5rX+yJEs2Oe8SKGJ9+puSpeMjZRgAEvEk+alOOB7yQKtkM/KA7QT70cW4slYvE+35bq lDmkL0P7EC9gkxiWA7zuezs8kSJuMT/Ch7pQvpk/vIyUo1tolZts5MCg0iJ6qEX3YfHa nSD2uCMjnDc2rP0qZGxmsj+P+/gaHQ2Ij6JszDcnij1kmEYjoNwwJcjzHyxN2I7xflE0 5F2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:arc-authentication-results; bh=9LigINqKrrwXmhPNBF1Xk/YLTfXRxxzN82kRN8qTTb4=; b=EMc5oUF0rC1qZRV+CfN9z+EouteV2lum5W81ZSVhAC51Yjttj7w6NTuQMenoatJ0V8 MKQXIT1SFnqLzkz1tiWnT7qCyq1nOKmBmgJILN8DU+eOeOcAhUaP9wR98TfJ4+nyISyY /+jGlo3xl8xb7owPf4sqdpFHUZ3j0kaiTNB42J2vbPQwPbnpXy00zDSHx5FFcQN3xw6k 6J7UUACWyiZpelNyUzUhVK6QC4rRv0Ad1RqLvzz92eyMJvOUCkDfVeDeY1siGmcxg0tr xMCFZzupJ85Pfit+1rhSJncO0rwP6+f7yICllV4hVrIokX9uAziOKSZJ3yigXMrV0p29 apyw== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h62-v6si7278418pge.298.2018.08.30.10.22.19; Thu, 30 Aug 2018 10:22:34 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727510AbeH3VYV (ORCPT + 99 others); Thu, 30 Aug 2018 17:24:21 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:38074 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727363AbeH3VYV (ORCPT ); Thu, 30 Aug 2018 17:24:21 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id 8F0BB27D7C9 From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Laurent Pinchart , Tomasz Figa , "Matwey V . Kornilov" , Alan Stern , kernel@collabora.com, Keiichi Watanabe , Ezequiel Garcia Subject: [RFC 3/3] stk1160: Use non-coherent buffers for USB transfers Date: Thu, 30 Aug 2018 14:20:30 -0300 Message-Id: <20180830172030.23344-4-ezequiel@collabora.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180830172030.23344-1-ezequiel@collabora.com> References: <20180830172030.23344-1-ezequiel@collabora.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Platforms without hardware coherency can benefit a lot from using non-coherent buffers. Moreover, platforms with hardware coherency aren't impacted by this change. For instance, on AM335x, while it's still not possible to capture full resolution frames, this patch enables half-resolution frame streams to work. Signed-off-by: Ezequiel Garcia --- drivers/media/usb/stk1160/stk1160-video.c | 22 ++++++---------------- 1 file changed, 6 insertions(+), 16 deletions(-) diff --git a/drivers/media/usb/stk1160/stk1160-video.c b/drivers/media/usb/stk1160/stk1160-video.c index 2811f612820f..aeb4264d1998 100644 --- a/drivers/media/usb/stk1160/stk1160-video.c +++ b/drivers/media/usb/stk1160/stk1160-video.c @@ -240,6 +240,9 @@ static void stk1160_process_isoc(struct stk1160 *dev, struct urb *urb) return; } + dma_sync_single_for_cpu(&urb->dev->dev, urb->transfer_dma, + urb->transfer_buffer_length, DMA_FROM_DEVICE); + for (i = 0; i < urb->number_of_packets; i++) { status = urb->iso_frame_desc[i].status; if (status < 0) { @@ -379,16 +382,11 @@ void stk1160_free_isoc(struct stk1160 *dev) urb = dev->isoc_ctl.urb[i]; if (urb) { - if (dev->isoc_ctl.transfer_buffer[i]) { -#ifndef CONFIG_DMA_NONCOHERENT - usb_free_coherent(dev->udev, + if (dev->isoc_ctl.transfer_buffer[i]) + usb_free_noncoherent(dev->udev, urb->transfer_buffer_length, dev->isoc_ctl.transfer_buffer[i], urb->transfer_dma); -#else - kfree(dev->isoc_ctl.transfer_buffer[i]); -#endif - } usb_free_urb(urb); dev->isoc_ctl.urb[i] = NULL; } @@ -461,12 +459,8 @@ int stk1160_alloc_isoc(struct stk1160 *dev) goto free_i_bufs; dev->isoc_ctl.urb[i] = urb; -#ifndef CONFIG_DMA_NONCOHERENT - dev->isoc_ctl.transfer_buffer[i] = usb_alloc_coherent(dev->udev, + dev->isoc_ctl.transfer_buffer[i] = usb_alloc_noncoherent(dev->udev, sb_size, GFP_KERNEL, &urb->transfer_dma); -#else - dev->isoc_ctl.transfer_buffer[i] = kmalloc(sb_size, GFP_KERNEL); -#endif if (!dev->isoc_ctl.transfer_buffer[i]) { stk1160_err("cannot alloc %d bytes for tx[%d] buffer\n", sb_size, i); @@ -490,11 +484,7 @@ int stk1160_alloc_isoc(struct stk1160 *dev) urb->interval = 1; urb->start_frame = 0; urb->number_of_packets = max_packets; -#ifndef CONFIG_DMA_NONCOHERENT urb->transfer_flags = URB_ISO_ASAP | URB_NO_TRANSFER_DMA_MAP; -#else - urb->transfer_flags = URB_ISO_ASAP; -#endif k = 0; for (j = 0; j < max_packets; j++) { -- 2.18.0