Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp551874imu; Wed, 23 Jan 2019 01:11:05 -0800 (PST) X-Google-Smtp-Source: ALg8bN77EpyeF3MUXihUw11p0Vgm8OL6FAMrYIYP/nfweUkNwJXSSc1KAYRS5XHSJZiPxnUU6pKL X-Received: by 2002:a63:fe48:: with SMTP id x8mr1283846pgj.261.1548234665315; Wed, 23 Jan 2019 01:11:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548234665; cv=none; d=google.com; s=arc-20160816; b=UF54CLuKVh7vxcc/3HJ8BvWzwvebxoYllzsAIiyINvmLEYDXTUPcGflzV81lR5pVrq lVGAGAOZvPNlCt4wOaNrNYDJHiiCSVcvXKnJBKx5zSAaDy7XLcGuTVZ45eA6xM7yYN3o hvkB+xiOI2zoIr7hA3jfG3Cis1hN3LlrQLyc0FwTjbbaicBBfhoBB6FZwJ0dvtDcOIy1 sZ50X/oPQnN6e/TTLmGdN8eA/LkMN4AxKiqfRftumlUKqXoSSRrCAvDeLpvbCKi0S2mk IA6Dkvvl1WhbqcGUGxrKul240bwROIsivp7TAqck04waXGyqp2zg3PvEd58l1iQkuRfI 014w== 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=B3SLQAjcWFTSHuFKqdcoCiPl5duUwcMm1WoAe2zQCBc=; b=Ztev70+YomkaMPmflc6hqm0VrN/vzrQ52RxpqiKLznF+xJ6FNjX/c/iZRrcYYuYl8m 558zHkTCXEwSh1l5lCL+14+p393AG819K8yYHjTp+F0F/iQk969OxiuGA9DdHlyo+jTJ YRPnhz1pNlXW+ywda50S8fKovQE7pfjxqgiNpnGGY7EoLABhdrgCkEf1ahahc1apm99N EkJvJ52D2WVRu3TXmTcklL3QNp+JiYVx9xJ8EXTfjsw57DB1+MvvxGf34C5/qEasPUBD gZGXlDL9C17UytqTj24n3nmsqDiLqAFaZGFdk9ChR2ILqjrNwCb4/NliQz6wHK+KsJJQ rHoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=i9Ydi6Cm; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 1si18394389plk.296.2019.01.23.01.10.50; Wed, 23 Jan 2019 01:11:05 -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=pass header.i=@linaro.org header.s=google header.b=i9Ydi6Cm; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726359AbfAWJIf (ORCPT + 99 others); Wed, 23 Jan 2019 04:08:35 -0500 Received: from mail-it1-f193.google.com ([209.85.166.193]:38765 "EHLO mail-it1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726158AbfAWJIe (ORCPT ); Wed, 23 Jan 2019 04:08:34 -0500 Received: by mail-it1-f193.google.com with SMTP id h65so1962517ith.3 for ; Wed, 23 Jan 2019 01:08:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=B3SLQAjcWFTSHuFKqdcoCiPl5duUwcMm1WoAe2zQCBc=; b=i9Ydi6CmBjJ7Qni4RNgJ7lVtnh7RArk6uu2wSuqNpqsad96ta1d0NpdiQ8BzSHc4bS JSqoFLKVsdEmvHnzmHhGGbByZ+V+aMxHR8SrW0V5DwK0TWDHR6fwuiK7ubFkstFD9yoW jIdGnPi2Kr0fLwvVBBPLZg3ugX1LDdyHHV+Ds= 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=B3SLQAjcWFTSHuFKqdcoCiPl5duUwcMm1WoAe2zQCBc=; b=WzWIeSL5ti0mjJjKxdl/Np848z33VcbCpMwFxNGKZmv4QXFrqSBLajH51eyPO/UBa1 bf+yDD2/6bZmzlZBxNoV1qJS3CpYthoRPyPP9gw9eB9jx6FgCiGP2Rksv10oclNX79Al TUYp6T3j6F5NYafuTP7RPA7OL3hDSJF6i5AEY02kc5YQkXDXFacQ9Qxiv0TZfWIULinZ uK6peAX4JHcG0LeZzQdjsq4ZDPXhdK3lvUNNF4K2CXkPMHiIT+OGXt8hOW0/VggKgPVu HQDpwRI/QQDqOYAETBu7HwPzX+Z7cW1HmB/x10rDD2Fpn89RNG12nr2Saj6+oJ469Ide oMQA== X-Gm-Message-State: AJcUukfU0xyULcNO1HO/rqH4kLRhHkakac7g+jbzDXRN5YPLppl9ERS7 ANx59FGGRT4O+JeJLeOQh3sXiRIoWKo4m+utJK9WAQ== X-Received: by 2002:a02:183:: with SMTP id 3mr834166jak.130.1548234513858; Wed, 23 Jan 2019 01:08:33 -0800 (PST) MIME-Version: 1.0 References: <59ccf85d-b99d-b5c8-ea87-66c2a892e197@daenzer.net> <850b6aee-0040-c333-b125-45211c18ada5@daenzer.net> <047667fd-17be-1c37-5d2a-26768cfd6ab8@daenzer.net> <20190123071521.GB20526@infradead.org> In-Reply-To: <20190123071521.GB20526@infradead.org> From: Ard Biesheuvel Date: Wed, 23 Jan 2019 10:08:22 +0100 Message-ID: Subject: Re: [RFC PATCH] drm: disable WC optimization for cache coherent devices on non-x86 To: Christoph Hellwig Cc: Alex Deucher , =?UTF-8?Q?Michel_D=C3=A4nzer?= , Maxime Ripard , Will Deacon , Linux Kernel Mailing List , amd-gfx list , David Airlie , Huang Rui , dri-devel , Michael Ellerman , Junwei Zhang , Alex Deucher , Sean Paul , Christian Koenig , linux-arm-kernel 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, 23 Jan 2019 at 08:15, Christoph Hellwig wrote: > > On Tue, Jan 22, 2019 at 10:07:07PM +0100, Ard Biesheuvel wrote: > > Yes, so much was clear. And the reason this breaks on some arm64 > > systems is because > > a) non-snooped PCIe TLP attributes may be ignored, and > > b) non-x86 CPUs do not snoop the caches when accessing uncached mappings. > > > > I don't think there is actually any disagreement on this part. And I > > think my patch is reasonable, only Christoph is objecting to it on the > > grounds that drivers should not go around the DMA API and create > > vmap()s of DMA pages with self chosen attributes. > > I object to it on various grounds. While the above is correct it really > is a mid to long-term fix. > > But even in the short term your patch just maintains a random list of > idefs in a random driver, pokes into the dma-mapping internals and lacks > any comments in the code explaining on what is going on, leading to > futher cargo culting. So it very clearly is not acceptable. Fair enough. It would be helpful, though, if you could give more guidance on what you do find acceptable. You haven't answered my question on whether you think drivers should be allowed to reason at all about the device's cache coherence. In any case, I think we (you and I) could easily agree on the correct fix being: - introduce DMA_ATTR_NOSNOOP - implement it as a no-op for non-cache coherent devices (since nosnoop is implied) - permit non-x86 architectures to override/ignore it if not supported - rip out all the explicit vmap()/kmap()s of DMA pages from the DRM drivers, and instead, set the DMA_ATTR_NOSNOOP attribute where desired, and always use the mappings provided by the DMA API. The problem is that we will need the DRM/radeon/amdgpu maintainers on board with this, and until this happens, I am stuck in the middle with a broken arm64 system. So, given the above, what /would/ you find acceptable?