Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp1647294imm; Sat, 4 Aug 2018 07:47:45 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcASAtZ257qcKZA8JmcWY5vCoesP+piO+EL6UT65fIHMmBss21CuQEfpmsDOohDz8GyBNji X-Received: by 2002:a63:cb04:: with SMTP id p4-v6mr7730532pgg.197.1533394065378; Sat, 04 Aug 2018 07:47:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533394065; cv=none; d=google.com; s=arc-20160816; b=IKdPOM07VDbO0UEk1VzpEWeGabiFvSz5qi3LOFVYwT8yZK/PYeBFDh2wL2zQWu90fO IRoLc3hyM74+i73dZCFr2aQI37KzoepWtUlwYvz9XuG28aBVbzj+L8vAoGMhvDsu4B1H i68XO4pSZVFr10VT/za3+jjOY/nXeOVCsciRJqCcU7RpRAFUjfkimfS2pwX7YnpVDoc6 ZKSPoF733jUdkstRjNbFo1gr4yLucCHo/COO/8BQFFmyNNMgx/GJINQpv1jQamJrKDsQ 4tZGwZyQKXn8TQgmp/fD0rEL844J5ui8E6N3lZRnp9ZD+X+b0CJMOHElEy4ogIrhQ8DS yb5w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:in-reply-to :subject:cc:to:from:date:arc-authentication-results; bh=AsYXTl5v18ohCOUH/U6Otfiyhq27515O0R0CcNc/RCg=; b=vSrUhxHB3wemRRfk4KMjcLVssIt2GfBjOICAiF6xK2vek3c8esWdyMPjD0yXWLNSSq mn/aUIwAvoadnHpgN7mr7hQ8C7/za/a2GOgbLpQaU5Hp/MdsWLDZLYTWXoXhds12f257 F8eHwZ3m8F5ySonzJ+tClesGtG7RpwQqj2v8UWM7bXxnB58q9Q+TGVTH6rNL1ROJxtjx 1juYEg/sLAFIJFTpbnsqu6Oy4lW5mO+oVWvuZb2TgA7sP9itvqawit9q4/JCaUsyB0wN isaguyV7ixvsh+2AWseBNswxBus0vqo3LiWSc+zciM5Sc/ncD6UlbohQDLllf0LeyM7M O0zA== 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 w7-v6si7307219pgf.231.2018.08.04.07.47.28; Sat, 04 Aug 2018 07:47:45 -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 S1728067AbeHDQrc (ORCPT + 99 others); Sat, 4 Aug 2018 12:47:32 -0400 Received: from netrider.rowland.org ([192.131.102.5]:58315 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S1726983AbeHDQrc (ORCPT ); Sat, 4 Aug 2018 12:47:32 -0400 Received: (qmail 26165 invoked by uid 500); 4 Aug 2018 10:46:35 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 4 Aug 2018 10:46:35 -0400 Date: Sat, 4 Aug 2018 10:46:35 -0400 (EDT) From: Alan Stern X-X-Sender: stern@netrider.rowland.org To: "Matwey V. Kornilov" cc: Laurent Pinchart , Tomasz Figa , Ezequiel Garcia , Hans de Goede , Hans Verkuil , Mauro Carvalho Chehab , Steven Rostedt , , Mike Isely , Bhumika Goyal , Colin King , Linux Media Mailing List , Linux Kernel Mailing List , Kieran Bingham , Subject: Re: [PATCH 2/2] media: usb: pwc: Don't use coherent DMA buffers for ISO transfer In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Sat, 4 Aug 2018, Matwey V. Kornilov wrote: > 2018-07-30 18:35 GMT+03:00 Laurent Pinchart : > > Hi Matwey, > > > > On Tuesday, 24 July 2018 21:56:09 EEST Matwey V. Kornilov wrote: > >> 2018-07-23 21:57 GMT+03:00 Alan Stern: > >> > On Mon, 23 Jul 2018, Matwey V. Kornilov wrote: > >> >> I've tried to strategies: > >> >> > >> >> 1) Use dma_unmap and dma_map inside the handler (I suppose this is > >> >> similar to how USB core does when there is no URB_NO_TRANSFER_DMA_MAP) > >> > > >> > Yes. > >> > > >> >> 2) Use sync_cpu and sync_device inside the handler (and dma_map only > >> >> once at memory allocation) > >> >> > >> >> It is interesting that dma_unmap/dma_map pair leads to the lower > >> >> overhead (+1us) than sync_cpu/sync_device (+2us) at x86_64 platform. > >> >> At armv7l platform using dma_unmap/dma_map leads to ~50 usec in the > >> >> handler, and sync_cpu/sync_device - ~65 usec. > >> >> > >> >> However, I am not sure is it mandatory to call > >> >> dma_sync_single_for_device for FROM_DEVICE direction? > >> > > >> > According to Documentation/DMA-API-HOWTO.txt, the CPU should not write > >> > to a DMA_FROM_DEVICE-mapped area, so dma_sync_single_for_device() is > >> > not needed. > >> > >> Well, I measured the following at armv7l. The handler execution time > >> (URB_NO_TRANSFER_DMA_MAP is used for all cases): > >> > >> 1) coherent DMA: ~3000 usec (pwc is not functional) > >> 2) explicit dma_unmap and dma_map in the handler: ~52 usec > >> 3) explicit dma_sync_single_for_cpu (no dma_sync_single_for_device): ~56 > >> usec > > > > I really don't understand why the sync option is slower. Could you please > > investigate ? Before doing anything we need to make sure we have a full > > understanding of the problem. > > Hi, > > I've found one drawback in my measurements. I forgot to fix CPU > frequency at lowest state 300MHz. Now, I remeasured > > 2) dma_unmap and dma_map in the handler: > 2A) dma_unmap_single call: 28.8 +- 1.5 usec > 2B) memcpy and the rest: 58 +- 6 usec > 2C) dma_map_single call: 22 +- 2 usec > Total: 110 +- 7 usec > > 3) dma_sync_single_for_cpu > 3A) dma_sync_single_for_cpu call: 29.4 +- 1.7 usec > 3B) memcpy and the rest: 59 +- 6 usec > 3C) noop (trace events overhead): 5 +- 2 usec > Total: 93 +- 7 usec > > So, now we see that 2A and 3A (as well as 2B and 3B) agree good within > error ranges. Taken together, those measurements look like a pretty good argument for always using dma_sync_single_for_cpu in the driver. Provided results on other platforms aren't too far out of line with these results. Alan Stern