Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6410253imu; Mon, 21 Jan 2019 08:25:55 -0800 (PST) X-Google-Smtp-Source: ALg8bN4bAC1xbqH37tkcQhjqfFrH34YvZM6BPcUweEch6rbyGZNy/kp8uo9u2Hhsb2C6kHJN0xEo X-Received: by 2002:a17:902:d70b:: with SMTP id w11mr31145072ply.294.1548087955728; Mon, 21 Jan 2019 08:25:55 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548087955; cv=none; d=google.com; s=arc-20160816; b=PBZKRV5gbqD0QX0npxVTKsYKFgbrHDzjnpe6Db3j2VypreXsueIpUolcrwJGOPj2Jy PxaS+8dQlnm5RfTx7ymLyL+mNjbjRtpL0TND1CtwgX36AVPIYcF4+Xhrcls3kZh+MS39 OKlLiKCJtZt72LgHNstD71PV2H/AyrsJsygMRsNKF/mmYNTyTNH7YHHzKl7cDKCl0UOq Fe1QBE/BNzJJj8ZNMLw0KbTsEZ1qSKKTA020HGHysuVGN8+ehWCc8rlJbbD5y42OYoPG yjdSFemJk7KaFX0mMrhKR2//SYzYSnTdbez3BkHhLqU9Vq67Q5aUqlbP6SauIRc4YbaY 8+4A== 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=ddLMmpwg07bDKig77yyfZoBxTi30hmKOTn48Y4iVA9w=; b=MVPpUMgBoLUA5KWqbmy3iHHNT8cVTmQme57y9wSqmz/mtRQ49JTXuCX6QzBAWgJt9h O9A60JBJEm/+Zk8hZWkt9k5Xgp2R7jSdJH/CSiQBKmowIysaRu2brYMpx6Cxerh2hoi1 Rxna7UBe07iCLSQ+iGbl8d5moUYU5nwNGuRPOQFWj0lk1nUNYLZXKtZA9WIoDHuo+5dI +3Nl98KQF7IyExm8VZBhgOPP2Yw2qCeF2nZUr6Pzszzm4aWTqOsJfXMWCKGo6vpluY3/ 6yK4bplZbMEAFIZ01UO5QMKgcACiE/a1tVxHWecbquJrqXGF+2+X3V9ZDGn20DnFDC22 v2mw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=tzo9Ah2W; 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 c13si5980052pgi.531.2019.01.21.08.25.29; Mon, 21 Jan 2019 08:25:55 -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=tzo9Ah2W; 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 S1729776AbfAUQWk (ORCPT + 99 others); Mon, 21 Jan 2019 11:22:40 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:57092 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728754AbfAUQWk (ORCPT ); Mon, 21 Jan 2019 11:22:40 -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=ddLMmpwg07bDKig77yyfZoBxTi30hmKOTn48Y4iVA9w=; b=tzo9Ah2WnduWLPC8rDKi208Ul Wjdq5G8lYqIJvB22CRfDcWxjrgutd05cioRQ2goRLjBon1QhRjqowa2LYbqcUqZqWaC5puxe5pg7w tSV1uBiN79BzLVD36g7Qy1RENAxOjugO35KbPzP3E0icUqL5auHz/L1anBByw7YRiDcf7M1Z4CF55 kzeQFHLd8F8l1QG0KO7MQuS2+1QEeJvZlHysn6LWojE3L/Mz/nQE6rk29IksQgMialJiHvbP//SQN gDB4OsTzvtLxlz9Dtrq9Oam0Fqz61Po/quJhilyx+CgVQHu/dtjqKFjfJfT005V5naqL0Ltsp62HY 6sMVF3ceg==; Received: from hch by bombadil.infradead.org with local (Exim 4.90_1 #2 (Red Hat Linux)) id 1glcLO-0007Io-TC; Mon, 21 Jan 2019 16:22:38 +0000 Date: Mon, 21 Jan 2019 08:22:38 -0800 From: Christoph Hellwig To: Ard Biesheuvel Cc: Christoph Hellwig , linux-arm-kernel , dri-devel , Linux Kernel Mailing List , amd-gfx@lists.freedesktop.org, Christian Koenig , Alex Deucher , David Zhou , Huang Rui , Junwei Zhang , Michel Daenzer , David Airlie , Daniel Vetter , Maarten Lankhorst , Maxime Ripard , Sean Paul , Michael Ellerman , Benjamin Herrenschmidt , Will Deacon Subject: Re: [RFC PATCH] drm: disable WC optimization for cache coherent devices on non-x86 Message-ID: <20190121162238.GA17651@infradead.org> References: <20190121100617.2311-1-ard.biesheuvel@linaro.org> <20190121150734.GA30582@infradead.org> <20190121155908.GA8084@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 Mon, Jan 21, 2019 at 05:14:37PM +0100, Ard Biesheuvel wrote: > > I'll add big fat comments. But the fact that nothing is exported > > there should be a fairly big hint. > > > > I don't follow. How do other header files 'export' things in a way > that this header doesn't? Well, I'll add comments to make it more obvious.. > As far as I can tell, these drivers allocate DMA'able memory [in > ttm_tt_populate()] and subsequently create their own CPU mappings for > it, assuming that > a) the default is cache coherent, so vmap()ing those pages with > cacheable attributes works, and Yikes. vmaping with different attributes is generally prone to create problems on a lot of architectures. > b) telling the GPU to use NoSnoop attributes makes the accesses it > performs coherent with non-cacheable CPU mappings of those physical > pages > > Since the latter is not true for many arm64 systems, I need this patch > to get a working system. Do we know that this actually works anywhere but x86? In general I would call these above sequence rather bogus and would prefer we could get rid of such antipatterns in the kernel and just use dma_alloc_attrs with DMA_ATTR_WRITECOMBINE if we want writecombine semantics. Until that happens we should just change the driver ifdefs to default the hacks to off and only enable them on setups where we 100% positively know that they actually work. And document that fact in big fat comments.