Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp3814629ybh; Tue, 6 Aug 2019 01:50:47 -0700 (PDT) X-Google-Smtp-Source: APXvYqzxBhf4jbxCzgADAwgmKg51LqRITaFtBp4DZ4kYADjIoN6XvnNOTkW7lut1zsfO4Gib+uxs X-Received: by 2002:a63:db47:: with SMTP id x7mr2015169pgi.375.1565081447644; Tue, 06 Aug 2019 01:50:47 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565081447; cv=none; d=google.com; s=arc-20160816; b=SOqbUhWM8p97AJ141Fwoh+GBLQW/1Jbgby4nqCVShlqRJnlNlvvNU2BoWs6nhesScP Y+ZUyF4PTNMJcoQV5348wKCPAc6B1KcvX5JlQAtWKOP+wAK69H+/ybaO4qFfOsC32YjV iEWJWpntQTcmaGYoRd2KwHrMV/n+bXH45ix+YgXYsRAG4MOD1uEvHNrTKKWv75UADVil o2YBCgzdjK9HL9c9kZH2JC4iWmAQw7cYAjAmxUkymeA4/DaNm6Oo/g1Qe0+J6G5v9EkY NNkKRz20Mu9hvcpDjBmEeCmH2347BzkRPKGwCn++NJHSAaJ7IV4EsOx/GUpdstXhcSSp NQHg== 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; bh=l8auQ2MfYdzHbSoHsLzv6wow97rgIxi2Z+/hQ+6h9CU=; b=rmxj8qqC0zsF8RMY3vFXbe2jpBnTgIDHV9SFGGnjBBFEdUroaXW1SUfC34qt2zICsS tmM8edUqWKcOu35Ra1iDJgIGUi46mKjHm/crk1vCjCc6cSAClhSAxIkTOMPfYvQg/5sM QaNMRTgNS261+ZrtRW4Z/B2eRQlgshZJ5i1LtS/XdcPAjg6aB7fk1fbOvYMz+cJ3vqZ3 IjdshrDbEcYYkQNnxtwAwrDsiU9hp+qAjQaSUVFSKthkgpjsQb8+N3RJWIL/PrUyBt6E 4mYXwcwquXNG5gSnbiC60ARg36LhXWz1Ua/JXvoa1b/4JcgCAKQE3LduBM1azRRuJsfN OM6A== 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 q15si11243129pls.184.2019.08.06.01.50.31; Tue, 06 Aug 2019 01:50:47 -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 S1732376AbfHFIs2 (ORCPT + 99 others); Tue, 6 Aug 2019 04:48:28 -0400 Received: from verein.lst.de ([213.95.11.211]:54580 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728998AbfHFIs2 (ORCPT ); Tue, 6 Aug 2019 04:48:28 -0400 Received: by verein.lst.de (Postfix, from userid 2407) id 5B809227A81; Tue, 6 Aug 2019 10:48:22 +0200 (CEST) Date: Tue, 6 Aug 2019 10:48:21 +0200 From: Christoph Hellwig To: Rob Clark Cc: dri-devel@lists.freedesktop.org, Christoph Hellwig , Rob Clark , 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, linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/2] drm: add cache support for arm64 Message-ID: <20190806084821.GA17129@lst.de> References: <20190805211451.20176-1-robdclark@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190805211451.20176-1-robdclark@gmail.com> User-Agent: Mutt/1.5.17 (2007-11-01) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 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.