Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp5666488ybh; Wed, 7 Aug 2019 09:26:10 -0700 (PDT) X-Google-Smtp-Source: APXvYqw5pDNVLrPMeHAcL+NfkEhGRKh6k2buHf/KQvhRdrZnrQF/s0INZddLvuNFCCnT3p2cB+rM X-Received: by 2002:a63:b11:: with SMTP id 17mr8179219pgl.283.1565195170758; Wed, 07 Aug 2019 09:26:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565195170; cv=none; d=google.com; s=arc-20160816; b=zGiweG7hAhJou3o/x7Io0rqox94TOXHaMYK1jQ14a/DzZuJf5WNnx3Vs6yZYQqOphe RN+zr0Lws1smq/58IQKLfIyzOnG/5rgF2Scm6NGnhpZVVMWiywVnO0htXDAQl45/m9OS MTuIpOqbJFF93h07dKC7LZXyTxsAVPIoP+iBUSx7awrMytLICGLMr+iGSC6d+s/7jMtU GJ/JGlglB+Ctvq3hqD1UGIpOQMI6Dai6y/HuggjK8F9uYSNWDieBF08GvesfP7ICTdpn k6NMxMvGjm2iJvFt9pb2FZjDkAJARU8QyIdcHElgat1gbL/J1GXmhtfrlF450PsEOL73 8HsA== 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=7ytzJIv3QNGK2vpGK5MfHZjc0QgFgcXjo88HR7/oqMA=; b=YHpIHqgnckXPcAI8YZpUVPormRgtMK9HAwtxF8NYJV5KQsZo149N0i5yLKpCqtddhx q5GvTSovUzS6cOT47XwkaYGO6XpMxK34CUyv+QrsEFSKjvta5GwjGcTDChGTDdFXVfV5 9I91J7Fz+sBcleOg3W6SrfbuyJRzw2kAPD6O2KKm/Cao/MNX11XdWPKfRHDcH7JTw5Ei XJc6Dlkw9AjLGSGnVjQ1cb8W4+ONUwKpTwvEXUF3Oeob1UbAPwmi4CbUYB6Tnh3rjsMW sKtxq5AD5y0TzI4vXwxcW/BuaSPp7Aao3gIF0oCkJESwl95JzmIoZFddKvkUV7r8wyqM lGQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZuWolzEz; 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 f33si265289pjg.81.2019.08.07.09.25.55; Wed, 07 Aug 2019 09:26:10 -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=ZuWolzEz; 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 S2388990AbfHGQQG (ORCPT + 99 others); Wed, 7 Aug 2019 12:16:06 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:39845 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388257AbfHGQQG (ORCPT ); Wed, 7 Aug 2019 12:16:06 -0400 Received: by mail-ot1-f66.google.com with SMTP id r21so100534313otq.6 for ; Wed, 07 Aug 2019 09:16:05 -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=7ytzJIv3QNGK2vpGK5MfHZjc0QgFgcXjo88HR7/oqMA=; b=ZuWolzEzTTi6r9XQJ8T7T/obgl1vrSjpszk+SirQmYSfaiKAOopCaOL3uj2/ZeYDN3 q1/SrxJ/WT7l8LX8St0gjRaKvz6kTJ/9FOa2sacVOtxH5/Lzdb9osA9oLZ3F8b0/9m/g 4HGJjtU9zw8oCOcwegO9gIZy0dWA7GpPTHNa0= 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=7ytzJIv3QNGK2vpGK5MfHZjc0QgFgcXjo88HR7/oqMA=; b=sHkDlyS6ZRR7vhEICAIpOR7plR6v0u6LU3197beDXnuZ4At4HZnXUPAaz0jaRdObnt axiVBQETxWYRAHvvZOLsVFErLR8/wilRJpjsG6G5eR/qLi3unopHjXWbw9IFEod+SV4Z sOOxU37FG22Vw3Dk3p8XYleWD1WNGmyQgCUfQEalSRb8zb3WXC/Pgoq+n9WAHAq/Isi+ sphCjUdyfo+AGpGPYWzItmHuOah5YvCln5z4KQZzI0jm6ERJ0YndksPGNj1hXs+HTfyx Vaj5iPw6eTz5u22aitxHgeYxsBVru/mUurk3d795QtvuV5Ix1Ckf3ykriyiJWCncnR8G XTvw== X-Gm-Message-State: APjAAAXKYYtbtuKHDiwiqeUoP+JVJyn3Yq8ekVy/3L5QZjAxKRZtMtpe fhtAWPM9Ft6s0OLg6n4/SnmDoc3bHGrY9la/zdzhpw== X-Received: by 2002:a5e:924d:: with SMTP id z13mr9363595iop.247.1565194565095; Wed, 07 Aug 2019 09:16:05 -0700 (PDT) MIME-Version: 1.0 References: <20190805211451.20176-1-robdclark@gmail.com> <20190806084821.GA17129@lst.de> <20190806143457.GF475@lakrids.cambridge.arm.com> <20190807123807.GD54191@lakrids.cambridge.arm.com> In-Reply-To: <20190807123807.GD54191@lakrids.cambridge.arm.com> From: Rob Clark Date: Wed, 7 Aug 2019 09:15:54 -0700 Message-ID: Subject: Re: [PATCH 1/2] drm: add cache support for arm64 To: Mark Rutland Cc: Christoph Hellwig , 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 Wed, Aug 7, 2019 at 5:38 AM Mark Rutland wrote: > > On Tue, Aug 06, 2019 at 09:31:55AM -0700, Rob Clark wrote: > > On Tue, Aug 6, 2019 at 7:35 AM Mark Rutland wrote: > > > > > > On Tue, Aug 06, 2019 at 07:11:41AM -0700, Rob Clark wrote: > > > > 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. > > > > > > Is there a cacheable alias lying around (e.g. the linear map), or are > > > these addresses only mapped uncached/wc? > > > > > > If there's a cacheable alias, performing an invalidate isn't sufficient, > > > since a CPU can allocate a new (clean) entry at any point in time (e.g. > > > as a result of prefetching or arbitrary speculation). > > > > I *believe* that there are not alias mappings (that I don't control > > myself) for pages coming from > > shmem_file_setup()/shmem_read_mapping_page().. > > AFAICT, that's regular anonymous memory, so there will be a cacheable > alias in the linear/direct map. tbh, I'm not 100% sure whether there is a cacheable alias, or whether any potential linear map is torn down. My understanding is that a cacheable alias is "ok", with some caveats.. ie. that the cacheable alias is not accessed. I'm not entirely sure about pre-fetch from access to adjacent pages. We have been using shmem as a source for pages since the beginning, and I haven't seen it cause any problems in the last 6 years. (This is limited to armv7 and armv8, I'm not really sure what would happen on armv6, but that is a combo I don't have to care about.) BR, -R > > digging around at what dma_sync_sg_* does under the hood, it looks > > like it is just arch_sync_dma_for_cpu/device(), so I guess that should > > be sufficient for what I need. > > I don't think that's the case, per the example I gave above. > > Thanks, > Mark.