Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp788735imu; Fri, 21 Dec 2018 07:23:49 -0800 (PST) X-Google-Smtp-Source: ALg8bN72d2IQiG8Mne+MhI+Ee1ClBzY6sGrhH+8Jvs5oHjMm+irmX3moYmeKHDhQEAP6twO9LSag X-Received: by 2002:a17:902:82c2:: with SMTP id u2mr2995317plz.110.1545405829836; Fri, 21 Dec 2018 07:23:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545405829; cv=none; d=google.com; s=arc-20160816; b=DHqB8m642xcCpDCMwDj/aHUu801cLpUkYVJH2tLuuDKJ83StsLSirbgSoXoGqFYjin TUPImPuCaclvxvGD4YKpRdCHyF/VuKvDK12pf/zM4Xc7pW+FYMm/ESbgOErWrjvyuKEt zndCnrut1/915pHe0l9zP6dj0ucXrom+CQP0TzSwgBstiY5Bh6Usl2JSnLG6ptwwesmd Xik5bNC4gfXsr2jTcqxGDOvQpUPu+U7IKqOtc4eerVjVqGIM9oAEMl4pZw1x0cKWGg83 UOikYGRkVmj5VD7hfjB87y6b8xlijh/D0jfOEEaYNCBgpfD3/v5pxwuUYaq2rLIs7O7o LdrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xj8v9RiCbsYFgncrU2PXgIx0psdaYzSXHjjjO5PYYDk=; b=d4HI+tOwG0F+DbyQW6gXZRgL2HgFKXIBk4WM+cphUefkEc9cXInE8hXmA1A5ijsctF 8eAOfSxA7AjBbR7NPgyQSt63BNwVGC35VOLhPy6pPsZEVR4T5g3NRcN3o052K0MuUyHB G+4DYTdAtzfj9A/Eq7/KyeQHsicxkeSZvDHQIkHStk+TIuvFJPlYwrHpY9jTYXKBivW8 mITGxXiMqAd+ztxcLqUNmEfJGh0TqmfFuC8Amw7h3dXrSLmwHNLtY9duVuKmH89f2Xos kM/Tp23sKf3CIYyTcVjzkogyHmqGTdZFM/yJhTwI5E2upG3y9DY9N1+AhOdbFA6Cz/lM Q2Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=mMlR30Ny; 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 h16si20958514pgj.203.2018.12.21.07.23.34; Fri, 21 Dec 2018 07:23:49 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=mMlR30Ny; 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 S1733053AbeLUIOH (ORCPT + 99 others); Fri, 21 Dec 2018 03:14:07 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48506 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732939AbeLUIOG (ORCPT ); Fri, 21 Dec 2018 03:14:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=In-Reply-To:Content-Type:MIME-Version :References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=xj8v9RiCbsYFgncrU2PXgIx0psdaYzSXHjjjO5PYYDk=; b=mMlR30NyrMrmYfpBUO82lGYR1 Q18NYmKiGGVfpsJ9GRadPhfVQ9QJO+dBjiqGVmB1B8H7GqjVyjxhB/84x9CzEGoUeKAag9uCkk70S dVCUjthvBBH0LMaEB9+cIXafXBG7jBIy2NxEKu8jEMlKAfBlPvuAf2OX/iDrmUKXjDv0gt0/U+l4V 7vXphmaPJobkLr91Pik7s5CchCARLNQmiI5tbEl5H5TERiQZR+JLynokQBiBSmfNvJq1HYDPlHb7e xEH48Ycj8ElbCfWPrwEu5lZzrCGP3HQ7mu5a6KSI8FQIMc74IjhBlMGxeKeiKmCJijsZW9waLvkfa EctBE5gHw==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1gaFwV-0005p4-Le; Fri, 21 Dec 2018 08:13:59 +0000 Date: Fri, 21 Dec 2018 00:13:59 -0800 From: Christoph Hellwig To: Tomasz Figa Cc: Christoph Hellwig , Laurent Pinchart , "Matwey V. Kornilov" , Linux Media Mailing List , Linux Kernel Mailing List , "Matwey V. Kornilov" , Alan Stern , Ezequiel Garcia , hdegoede@redhat.com, Hans Verkuil , Mauro Carvalho Chehab , rostedt@goodmis.org, mingo@redhat.com, Mike Isely , Bhumika Goyal , Colin King , Kieran Bingham , keiichiw@chromium.org Subject: Re: [PATCH v5 2/2] media: usb: pwc: Don't use coherent DMA buffers for ISO transfer Message-ID: <20181221081359.GA14707@infradead.org> References: <20181213140329.GA25339@infradead.org> <20181214123624.GA5824@infradead.org> <20181218073847.GA4552@infradead.org> <20181219075150.GA26656@infradead.org> <20181219145122.GA31947@infradead.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.9.2 (2017-12-15) X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Dec 20, 2018 at 12:23:46PM +0900, Tomasz Figa wrote: > I haven't been following the problems with virtually tagged cases, > would you mind sharing some background, so that we can consider it > when adding non-consistent allocations to VB2? The problem exists at least partially with the current consistent allocator, and we need to fix it. My non-coherent series does not have it, but we would add it if we allowed virtual remapping. The problem with get_sgtable is that it creates aliasing of kernel virtual addresses used to access memory and thus the cache. We have the mapping return from dma_alloc_*, which in case of a remap contains a vmap/ioremap style address that is different from the kernel direct mapping address you get from using page_address/kmap on the pages backing that mapping. (assuming you even have pages - in a few corner cases we don't and the whole interface concept breaks down). This creates various problems as the the scatterlist returned from get_stable now gives a second way to access this memory through direct mapping addresses in the pages contained in it, but as soon as we do that we: a) don't use the nocache mapping used by the coherent allocator if that is on a per-mapping basis (which it is for many architectures), so you do get data in the cache even when that might not be assumed b) if the data returned from dma_alloc_coherent was not actually a remap but a special pool of non-cached address the cache flushing instructions might be invalid and caused problems c) any cache flushing now operates on just those direct mappings, which in case of the non-coherent allocator and access through the remapped address does the wrong thing for virtually tagged caches