Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp56328imm; Tue, 24 Jul 2018 13:56:38 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcN7o4kX6l2pU6a7Fn4+9xG6cMCJYdZRM8IL7/A8+QHjjG+S14nhmLaQ2ws0eX8UnSS8ytF X-Received: by 2002:a63:1f20:: with SMTP id f32-v6mr17104351pgf.84.1532465798516; Tue, 24 Jul 2018 13:56:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532465798; cv=none; d=google.com; s=arc-20160816; b=HNCbF0F4QdmCrgV3UnISV+TBHwE2mHc/xo2zBOcfh3+b6XpSbBijYdirJ+U/ELTCtk +xs5NcC4jQ7HNHqbyRCz9SqeFjA6yuDnwLcbtoVP+DWbTFIX2hgGL4OJJYmAC3kRgTow 5Q3Z5DicWCyjQNd6K50to/I3RCvOc1U4B6tZVQxRg+yqg9NYKqYqz07Xz2Qi0xI9UnUK pyeESeakB/TDiT0Nqdu0QktTVX9ms0gWbIGcZ1A75CT1paj4rJWUPdwNujIuZ9SiVUkx OdzKJ4P5oIPu+hQC6GvcSrQu2wyPDqzNzOsXf9iVReO1bVcBSbTO1dXQQ2Q4Nnhk1U32 3deQ== 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=Is19qALzL/lbV9zq2/7BfpgZqRCTLMr815Xf8IqVxmY=; b=k7Z2kP+pje+WbOLNwJkbQWJB18e39hPwLGbu6KXLDA/hfB76lyoDuM3wvzCCtFuUzG ap2G0LarAEsaN7vWJab7oMyuHV0kV66gXUBcAubKUQDvWINq9clFEOtu6QuV1FYERSsE rA2dM5xM6XXIa1Rhb/EK1Ga/2h12rad5AKTM1+aFNoPkG80hoMtYVfVE+v32Xdn6y+kP gYdgHLYzGdVKACg0wqzR0wPU4Ss4qJ8LRotcK0S+KYgsLMNM0Kn34J2Jq/GpSeMseQYA OzHKmAm5LJbNu1TRe8mYrNS27XqEFQVWHQubejpRFIfFzeKk/L6Pm4SX57xbuANps/x0 +bow== 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 5-v6si11832302pgp.439.2018.07.24.13.56.23; Tue, 24 Jul 2018 13:56:38 -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 S2388817AbeGXWDm (ORCPT + 99 others); Tue, 24 Jul 2018 18:03:42 -0400 Received: from iolanthe.rowland.org ([192.131.102.54]:46400 "HELO iolanthe.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S2388640AbeGXWDm (ORCPT ); Tue, 24 Jul 2018 18:03:42 -0400 Received: (qmail 24302 invoked by uid 2102); 24 Jul 2018 16:55:24 -0400 Received: from localhost (sendmail-bs@127.0.0.1) by localhost with SMTP; 24 Jul 2018 16:55:24 -0400 Date: Tue, 24 Jul 2018 16:55:24 -0400 (EDT) From: Alan Stern X-X-Sender: stern@iolanthe.rowland.org To: "Matwey V. Kornilov" cc: Tomasz Figa , Ezequiel Garcia , Hans de Goede , Hans Verkuil , Mauro Carvalho Chehab , Laurent Pinchart , 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 Tue, 24 Jul 2018, 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 > > So, I suppose that unfortunately Tomasz suggestion doesn't work. There > is no performance improvement when dma_sync_single is used. > > At x86_64 the following happens: > > 1) coherent DMA: ~2 usec > 2) explicit dma_unmap and dma_map in the handler: ~3.5 usec > 3) explicit dma_sync_single_for_cpu (no dma_sync_single_for_device): ~4 usec > > So, whats to do next? Personally, I think that DMA streaming API > introduces not so great overhead. > Does anybody happy with turning to streaming DMA or I'll introduce > module-level switch as Ezequiel suggested? How about using the dma_unmap and dma_map calls in the USB core? If they add the same overhead as putting them in the handler, I think it would be acceptable for x86_64. It certainly is odd that the dma_sync_single APIs take longer than simply mapping and unmapping. Alan Stern