Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4157415ybh; Tue, 6 Aug 2019 07:13:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqx6V8nqn1x3uSF/UjwcqWluoEnTk7r36UeagXTTqg3MG7wy86OE1BYkqturSoTRcftsd86B X-Received: by 2002:aa7:9359:: with SMTP id 25mr3751587pfn.261.1565100803020; Tue, 06 Aug 2019 07:13:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565100803; cv=none; d=google.com; s=arc-20160816; b=Z403yFMOP3KCIPEOuMp/jOUtC+vdw8giIZ6B8d5BC+uykuJ95QkSQlgWXZ6lEITAo9 WWP0x1hhrDfVk4+ep3ExssV3UAHa8gjawjzIUryARgRpsJ8/CM0YdZZS5GfuXA3X+7+6 7cWgrHq8ujXJpGHglcHCqSQrfYHWycgXvM71zu4KQc7bqHnXnmcu/BNhNJ3ViYAiMxZ/ Z2RLgIPs62/l/PCX9p47x8k+hEUif4VztuaJ0B6pqp0THTQd85/1TFwUzikS6BE5mHTH rO7EhiGc+9cV4Dgp2JpeN/IegnfoQgjbeu4PO+LYVtoW2zPvwdy/d/wczWJhTRIgtiee MpVQ== 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=KSZHR8G3MghKTiH3RE/z9t0oAkPmKdy9XO/QMCZqNZU=; b=pGzaSASyc7YH3qGCsLITl6Xli7yIc7nM0PrtMMqlaS5t5TaMXQrCRg3P+XV9RUwLvT /UnyIOqyii14V/ah2MV1MPUDWqro8Npy6oOoOQiW5dVZ2AEvVtxUvebOgquLKC9Q3vyK u5+QkTgnFK6o+4J0q3/ivV+rjVX9ceUaxeTR3qgUYutCA0PIBl95EYTMp5P6NuaskJIC 513CAkI2lwbkjG3umrYJ3eOHgrvSdq8p0WsYAngozbuJlt6XLXLVuJSq3JKcN0ISKT+m lvn3Xzbz1OHJNbUF+dL4zt0LTOe0IVxAgBLFOH5cPQI5IlGf3zEYFZFabTztaT84EryS 1jaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=SZo4fdmX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v2si14695103pjy.48.2019.08.06.07.13.06; Tue, 06 Aug 2019 07:13:23 -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; dkim=pass header.i=@chromium.org header.s=google header.b=SZo4fdmX; 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=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732833AbfHFOLx (ORCPT + 99 others); Tue, 6 Aug 2019 10:11:53 -0400 Received: from mail-oi1-f194.google.com ([209.85.167.194]:36130 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726834AbfHFOLx (ORCPT ); Tue, 6 Aug 2019 10:11:53 -0400 Received: by mail-oi1-f194.google.com with SMTP id c15so11369218oic.3 for ; Tue, 06 Aug 2019 07:11:52 -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=KSZHR8G3MghKTiH3RE/z9t0oAkPmKdy9XO/QMCZqNZU=; b=SZo4fdmXeH8WXLZpaSB/sTV0Fj/AOoy8kq3bwOXiCeK8jvWHo70O+zD6FGjZ4ESlzG MJwNG4UTGW0T+1XmwKK1L0YCnIqCOJzMb+NEEP94tgXzPcO60WWioadGoDrAlJhawAxu C6B3hppVH+zXeBCt8Dxdu3vMqTF2xSy6yZ4Us= 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=KSZHR8G3MghKTiH3RE/z9t0oAkPmKdy9XO/QMCZqNZU=; b=r33EYGYM+Lgq0Mh9FzI1J5sWNWxGHqf3gy4XVSeh0uTmvIvlYXotOBuVi6cmm7s6y7 NEdjDgRubrukKbIhA3La3XHGefeq6kMkdSSoMarvlBppcZmnpfwChpKmaGXs4tevWgRD Js/pX+/VvN8BEMqcJpYJQinDIdV3ZYSIqDJMj6qc0lAyli6/ltonr5PoR3EcPPbaVvP5 O1JW5AG8sa1Sd6OGEToApD8xjNSmYAKj7fP0doxp4qGopNVTjTW/thFR0EUbgq7JejqV fQdAegEmj24T5x+48MfXKpwLbGWrBa34afQ3uHPlAmevRzL0jj7T7/WhobEAvd0qnFMD IkRg== X-Gm-Message-State: APjAAAXtP7AWx681ag9610VJdebig4jUjtn6KoOZI68T/chbJWyuq4ym Uw7xd/MlRUebCmdXrgpcCWp7tNZZx2gxVZWNHlEJGWg5/M4= X-Received: by 2002:a02:c916:: with SMTP id t22mr4302514jao.24.1565100712372; Tue, 06 Aug 2019 07:11:52 -0700 (PDT) MIME-Version: 1.0 References: <20190805211451.20176-1-robdclark@gmail.com> <20190806084821.GA17129@lst.de> In-Reply-To: <20190806084821.GA17129@lst.de> From: Rob Clark Date: Tue, 6 Aug 2019 07:11:41 -0700 Message-ID: Subject: Re: [PATCH 1/2] drm: add cache support for arm64 To: Christoph Hellwig Cc: Rob Clark , dri-devel , Catalin Marinas , Will Deacon , Maarten Lankhorst , Maxime Ripard , Sean Paul , David Airlie , Daniel Vetter , Allison Randal , Greg Kroah-Hartman , Thomas Gleixner , linux-arm-kernel@lists.infradead.org, LKML 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 Tue, Aug 6, 2019 at 1:48 AM Christoph Hellwig wrote: > > This goes in the wrong direction. drm_cflush_* are a bad API we need to > get rid of, not add use of it. The reason for that is two-fold: > > a) it doesn't address how cache maintaince actually works in most > platforms. When talking about a cache we three fundamental operations: > > 1) write back - this writes the content of the cache back to the > backing memory > 2) invalidate - this remove the content of the cache > 3) write back + invalidate - do both of the above Agreed that drm_cflush_* isn't a great API. In this particular case (IIUC), I need wb+inv so that there aren't dirty cache lines that drop out to memory later, and so that I don't get a cache hit on uncached/wc mmap'ing. > b) which of the above operation you use when depends on a couple of > factors of what you want to do with the range you do the cache > maintainance operations > > Take a look at the comment in arch/arc/mm/dma.c around line 30 that > explains how this applies to buffer ownership management. Note that > "for device" applies to "for userspace" in the same way, just that > userspace then also needs to follow this protocol. So the whole idea > that random driver code calls random low-level cache maintainance > operations (and use the non-specific term flush to make it all more > confusing) is a bad idea. Fortunately enough we have really good > arch helpers for all non-coherent architectures (this excludes the > magic i915 won't be covered by that, but that is a separate issue > to be addressed later, and the fact that while arm32 did grew them > very recently and doesn't expose them for all configs, which is easily > fixable if needed) with arch_sync_dma_for_device and > arch_sync_dma_for_cpu. So what we need is to figure out where we > have valid cases for buffer ownership transfer outside the DMA > API, and build proper wrappers around the above function for that. > My guess is it should probably be build to go with the iommu API > as that is the only other way to map memory for DMA access, but > if you have a better idea I'd be open to discussion. Tying it in w/ iommu seems a bit weird to me.. but maybe that is just me, I'm certainly willing to consider proposals or to try things and see how they work out. Exposing the arch_sync_* API and using that directly (bypassing drm_cflush_*) actually seems pretty reasonable and pragmatic. I did have one doubt, as phys_to_virt() is only valid for kernel direct mapped memory (AFAIU), what happens for pages that are not in kernel linear map? Maybe it is ok to ignore those pages, since they won't have an aliased mapping? BR, -R