Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp503338pxa; Wed, 19 Aug 2020 07:23:54 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy2MlWNOnlaBj8eslNlqdqk5eg5eLpaNuZsLhetghMIehc6PJ+z8jjw8xQn7z0rdoMpXI3Z X-Received: by 2002:a17:906:260f:: with SMTP id h15mr24928167ejc.48.1597847034789; Wed, 19 Aug 2020 07:23:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597847034; cv=none; d=google.com; s=arc-20160816; b=q98+dp1DowEHeNUc5E6WYBvKrtVVVeyACx/LeTKkUe/EVkNf0ZTNvjH6hyywY+JyuO +Zy9r1XlBcoDGnhYhuk1TpucFQ/c3nm5WKVRRu30/uQlS0g58IBylu4u/r9SwwQliRLn emeFRYs5b7YH8KmyuQtCgStrShFPpjnj1EMlAMUZirVhsWf3qQKA23vvF0si+6gXpYzj LQipE6+0eng3NY8TS3Ge80Cyz1flZ+BVowsYIO3eX7y+o23bvFY5tGwRon5l84No30ta m/BWr5ooMlpBHwX3p+JF6Oyi3Pp1hV7wQxUzjcBNj5gNvy1kZzNTnm/fgo2YBq5yJ7wX ntbw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=uEY7dk9y/9x4HcaWjwFAfwvm+T0doGz7atsT11F+few=; b=VMp0AHQUR6sVbItFRyuXKZFH78a3BzMg6wuAq3NatC1N2m5iwGR+QyYgsWL4mws+cl 5YWJxZMuc2S8QrwCIXkIz/iPWM2APxtW1RLaAV8KeUkqwcwJgKxGXOFLR0aaUBAgk4jJ XJzWkrPIKvHMTJo6o/0su6yclhDVWGStfhAv5FR7u0/EO0u2KpdgZNtVr8OK6ivse4me 3ibsnpHz67r9EmWIr7eMUmtNLhQrJT7HBcKEP42xPlYxpRjtRkX4uzZTY0pKjrs9wJCJ hupkcDEfI7poF86pdiUjJiwiZh5uInL+inUKlhOvA60+ao/7IKEQ1HXfUvQV8zxUgNWx 4K2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MwoQKU4R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t23si17004065edc.163.2020.08.19.07.23.30; Wed, 19 Aug 2020 07:23:54 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MwoQKU4R; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728442AbgHSOWy (ORCPT + 99 others); Wed, 19 Aug 2020 10:22:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49262 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726560AbgHSOWt (ORCPT ); Wed, 19 Aug 2020 10:22:49 -0400 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C25A2C061757 for ; Wed, 19 Aug 2020 07:22:48 -0700 (PDT) Received: by mail-ed1-x543.google.com with SMTP id i6so18252202edy.5 for ; Wed, 19 Aug 2020 07:22:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=uEY7dk9y/9x4HcaWjwFAfwvm+T0doGz7atsT11F+few=; b=MwoQKU4RRVGBwswghQT2kEA4PWtzNJ9PP0GlvGH+VtAzrSvBnEW2dUpr0fs6tqB36t NEatNz3nTo9Srl8JZAX9oVp9pc5TQLgcK+vTRNeNePaaHI1s5H4G84GiGqxdAJ9X51ZU 9RjLZl32ILMLyADH9W9JtyN4rfe/+nXKgJFvs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=uEY7dk9y/9x4HcaWjwFAfwvm+T0doGz7atsT11F+few=; b=nxJmMAHa+GLc27m1S6crodUJx27tB0Sz9i5xj9mttS1FRz4stLwi+7bDhDPp7TNx3W ewWAOQXGU/xV63S6pyiWM3q6jtYlWnuoC3Yqz/4P6xrZZKLum/SdPzIZ2TFqRcZLUlPj P1k0xfV6Qr10FTRWiBkLvzNo8c06EIvdRv1GA7fLrHnBJpzEvDTgxN35V3VzsM/wuy1J I8bP1sLzrztqmQzv/8rD6zehqZp8P1k+NaeqWtqKZYn+uJ/2iMsLl7VGdq/jY7sJ/NDp KVpsRMp+q9h25EUArki7kiIha75t44Qtth7LEDzyOswFROx/uGGu6EbVDe6r+vXtvtob bNCA== X-Gm-Message-State: AOAM532oGO7vPyeL75ZbpYZzpouSnXtlHzFf5pmnhGDK3UUKaYJKBfp2 uW1gKsYOb3xqJdx3gwZJL8l1xRAsn+wb8w== X-Received: by 2002:a05:6402:1457:: with SMTP id d23mr24894960edx.149.1597846967511; Wed, 19 Aug 2020 07:22:47 -0700 (PDT) Received: from mail-wr1-f41.google.com (mail-wr1-f41.google.com. [209.85.221.41]) by smtp.gmail.com with ESMTPSA id i5sm18700973ejg.121.2020.08.19.07.22.46 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 19 Aug 2020 07:22:47 -0700 (PDT) Received: by mail-wr1-f41.google.com with SMTP id r4so21690368wrx.9 for ; Wed, 19 Aug 2020 07:22:46 -0700 (PDT) X-Received: by 2002:adf:ec45:: with SMTP id w5mr25495420wrn.415.1597846966201; Wed, 19 Aug 2020 07:22:46 -0700 (PDT) MIME-Version: 1.0 References: <20200819065555.1802761-1-hch@lst.de> <20200819065555.1802761-6-hch@lst.de> <62e4f4fc-c8a5-3ee8-c576-fe7178cb4356@arm.com> <2b32f1d8-16f7-3352-40a5-420993d52fb5@arm.com> In-Reply-To: <2b32f1d8-16f7-3352-40a5-420993d52fb5@arm.com> From: Tomasz Figa Date: Wed, 19 Aug 2020 16:22:29 +0200 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 05/28] media/v4l2: remove V4L2-FLAG-MEMORY-NON-CONSISTENT To: Robin Murphy Cc: Christoph Hellwig , alsa-devel@alsa-project.org, linux-ia64@vger.kernel.org, Linux Doc Mailing List , nouveau@lists.freedesktop.org, linux-nvme@lists.infradead.org, Linux Kernel Mailing List , "James E.J. Bottomley" , linux-mm@kvack.org, Marek Szyprowski , linux-samsung-soc , Joonyoung Shim , linux-scsi@vger.kernel.org, Kyungmin Park , Ben Skeggs , Matt Porter , Linux Media Mailing List , Tom Lendacky , Pawel Osciak , Mauro Carvalho Chehab , "list@263.net:IOMMU DRIVERS" , Joerg Roedel , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Thomas Bogendoerfer , linux-parisc@vger.kernel.org, netdev@vger.kernel.org, Seung-Woo Kim , linux-mips@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Aug 19, 2020 at 4:07 PM Robin Murphy wrote: > > On 2020-08-19 13:49, Tomasz Figa wrote: > > On Wed, Aug 19, 2020 at 1:51 PM Robin Murphy wrote: > >> > >> Hi Tomasz, > >> > >> On 2020-08-19 12:16, Tomasz Figa wrote: > >>> Hi Christoph, > >>> > >>> On Wed, Aug 19, 2020 at 8:56 AM Christoph Hellwig wrote: > >>>> > >>>> The V4L2-FLAG-MEMORY-NON-CONSISTENT flag is entirely unused, > >>> > >>> Could you explain what makes you think it's unused? It's a feature of > >>> the UAPI generally supported by the videobuf2 framework and relied on > >>> by Chromium OS to get any kind of reasonable performance when > >>> accessing V4L2 buffers in the userspace. > >>> > >>>> and causes > >>>> weird gymanstics with the DMA_ATTR_NON_CONSISTENT flag, which is > >>>> unimplemented except on PARISC and some MIPS configs, and about to be > >>>> removed. > >>> > >>> It is implemented by the generic DMA mapping layer [1], which is used > >>> by a number of architectures including ARM64 and supposed to be used > >>> by new architectures going forward. > >> > >> AFAICS all that V4L2_FLAG_MEMORY_NON_CONSISTENT does is end up > >> controling whether DMA_ATTR_NON_CONSISTENT is added to vb2_queue::dma_attrs. > >> > >> Please can you point to where DMA_ATTR_NON_CONSISTENT does anything at > >> all on arm64? > >> > > > > With the default config it doesn't, but with > > CONFIG_DMA_NONCOHERENT_CACHE_SYNC enabled it makes dma_pgprot() keep > > the pgprot value as is, without enforcing coherence attributes. > > How active are the PA-RISC and MIPS ports of Chromium OS? Not active. We enable CONFIG_DMA_NONCOHERENT_CACHE_SYNC for ARM64, given the directions received back in April when discussing the noncoherent memory functionality on the mailing list in the thread I pointed out in my previous message and no clarification on why it is disabled for ARM64 in upstream, despite making several attempts to get some. > > Hacking CONFIG_DMA_NONCOHERENT_CACHE_SYNC into an architecture that > doesn't provide dma_cache_sync() is wrong, since at worst it may break > other drivers. If downstream is wildly misusing an API then so be it, > but it's hardly a strong basis for an upstream argument. I guess it means that we're wildly misusing the API, but it still does work. Could you explain how it could break other drivers? > > >> Also, I posit that videobuf2 is not actually relying on > >> DMA_ATTR_NON_CONSISTENT anyway, since it's clearly not using it properly: > >> > >> "By using this API, you are guaranteeing to the platform > >> that you have all the correct and necessary sync points for this memory > >> in the driver should it choose to return non-consistent memory." > >> > >> $ git grep dma_cache_sync drivers/media > >> $ > > > > AFAIK dma_cache_sync() isn't the only way to perform the cache > > synchronization. The earlier patch series that I reviewed relied on > > dma_get_sgtable() and then dma_sync_sg_*() (which existed in the > > vb2-dc since forever [1]). However, it looks like with the final code > > the sgtable isn't acquired and the synchronization isn't happening, so > > you have a point. > > Using the streaming sync calls on coherent allocations has also always > been wrong per the API, regardless of the bodies of code that have > happened to get away with it for so long. > > > FWIW, I asked back in time what the plan is for non-coherent > > allocations and it seemed like DMA_ATTR_NON_CONSISTENT and > > dma_sync_*() was supposed to be the right thing to go with. [2] The > > same thread also explains why dma_alloc_pages() isn't suitable for the > > users of dma_alloc_attrs() and DMA_ATTR_NON_CONSISTENT. > > AFAICS even back then Christoph was implying getting rid of > NON_CONSISTENT and *replacing* it with something streaming-API-based - That's not how I read his reply from the thread I pointed to, but that might of course be my misunderstanding. > i.e. this series - not encouraging mixing the existing APIs. It doesn't > seem impossible to implement a remapping version of this new > dma_alloc_pages() for IOMMU-backed ops if it's really warranted > (although at that point it seems like "non-coherent" vb2-dc starts to > have significant conceptual overlap with vb2-sg). No, there is no overlap between vb2-dc and vb2-sg. They differ on another level - the former is to be used by devices without scatter-gather or internal mapping capabilities and gives the driver a single DMA address for the whole buffer, regardless of whether it's IOVA-contiguous (for devices behind an IOMMU) or physically contiguous (for the others), while the latter gives the driver an sgtable, which of course may be DMA-contiguous internally, but doesn't have to and usually isn't. This model makes it possible to hide the SoC implementation details from particular drivers, since those are very often reused on many SoCs which differ in the availability of IOMMU, DMA addressing restrictions and so on. Best regards, Tomasz