Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2020264imu; Thu, 24 Jan 2019 06:03:11 -0800 (PST) X-Google-Smtp-Source: ALg8bN5ronH0imECxTX2gNP42EyxUhJ4k4yF2kJ5Ik7O7ZWflhRRxjzN7eG8xpgQ9yTCSc/ZqWuD X-Received: by 2002:a17:902:b18b:: with SMTP id s11mr6650208plr.56.1548338591332; Thu, 24 Jan 2019 06:03:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548338591; cv=none; d=google.com; s=arc-20160816; b=I0yqyEdLI1LfajX9d+/BBAsvIqw9TTWrUrvfIkU6y+A5h5k9hxh+C12VbMvA1y3Ocv js6bhg1xy7Ne5PwPB76/rR4dYlOw2ZN8DLzGc+FIYdELHBuhT5lIssjF5lop6zBAZWum DxuY8wIU3brOGhn2EUVxUxx1NVZulp6hZ8fSHDg2aaCDEnOOl+TWTl2Ki2TOVsz+0pRw Wz0SAc+1nY0m2ogHY4mCUFa4xIM1Z/oszwD7Rtw2GQfyAxhxufrvH3Y0kxnVcczw/AUz gft9YvmsXGFz+/NFKGPb6+U5vPgGx6fXRvy/Fxz/aYQPZk4JX5S32731wNsApJeiH2k+ 8JMQ== 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=iI4CRWe2LKTfCV7bVfyN+5k3FytPSzrn9R+fO7Dhq9g=; b=S6v5FFFYyyjEUl3fR2iBN1xwqhoqPDwWP3ihMkEBz3/EJysBaSsSrgX7w1ZUxadmYh lVqd9Uq8h1mn6gORp7Ss8wlbYedxFZzdf2i4hQzL4L0+28o1HaaTwgwc8GMAzgaYQE6X TWuXgo5ld3CFlB1e9Y1dtM1a3atdh0CFvt2Hxzffaua2dn5vkcOsMxj1n5o2SakU9Qpn lkt6YIOnE9tDEUjrbhp+Lzuugv0Lr7QEkFPSCRo2fVs2lzzGqK3AHZHrhgYcreod68Xj kIUrBXygsJ0DDLg8e7RaUxhQeYFMtZrrQF+KHeeLh6fbe2cvucuvtYo/QRKl8PeYGZmS AF0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=odtwtirQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id c65si21704055pfa.148.2019.01.24.06.02.50; Thu, 24 Jan 2019 06:03:11 -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=@gmail.com header.s=20161025 header.b=odtwtirQ; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728259AbfAXOAv (ORCPT + 99 others); Thu, 24 Jan 2019 09:00:51 -0500 Received: from mail-wr1-f66.google.com ([209.85.221.66]:33657 "EHLO mail-wr1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728225AbfAXOAt (ORCPT ); Thu, 24 Jan 2019 09:00:49 -0500 Received: by mail-wr1-f66.google.com with SMTP id p7so6628522wru.0 for ; Thu, 24 Jan 2019 06:00:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=iI4CRWe2LKTfCV7bVfyN+5k3FytPSzrn9R+fO7Dhq9g=; b=odtwtirQcCV+PtR+Iu7d8wJH5w2mp3qy1VMrMw9NrybybUHnybw2fRzweMy3HGhBjh fqJFKRooGCuZ6ukniGdrLdVh0T8H59l8TTga+aFW2EkS1GM4nRUBYLbgA3Zc3PMmNV2R aVV2KaT2KrJhwSAw+pkEiaHGyWAP5SmUGIfIoSJED5G6/TXdfuLP42jGk3bowdfag4dW bGkShaYczEQHlQtE15tUtexd6xhcwf/VEYi56vYQXTr/MNBf7rvJ5btShTOiuay0475c 4H+Rb280Mb4pvelDuZRWuZkWKWGg1WhTToOo9Tf6yjFRYoZN+V/mM4ivSiPKx8JkeS3N qzAA== 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=iI4CRWe2LKTfCV7bVfyN+5k3FytPSzrn9R+fO7Dhq9g=; b=sJaedCQ8yMkIhCevpyQXP31fzOIc89eU/7rzHRs1RnPrY2mMBUEcCFmuhX+WfaBdqR MRmur8e6M+KaS9wAiLve+Ra8rw2fPH8M4vqqoNUt+WanKbBJvS/a9Rcif2vuFTTEVWgd RP6b2w80IAXNalWbCiy4OBgiAfyE68WxHwJYWuM8QjK1CXoKdCbOwrQsL/1Sxs8hMt2q PexVJgZeMFv8zra3ztc0mO7TZu/dRvfJmVPNZOgnrh3/2I8NE197kfaqeazzeDRbQjFn ONOpusm0cujPgR3MkzYvbL+Cv8pvhxoLrbyKBJI6V4J8rPQ0aamOYFxYG5Ixpd2NkZ4g KduA== X-Gm-Message-State: AJcUukeow6KnqgfQsV5BSVn0z5vgVLeaJyb3SHGm9AW/Tizlhn6veEGT I8bIbF1v7Sdxm24vgHst5/PI7i2U/A4ZEWK76ao= X-Received: by 2002:adf:8506:: with SMTP id 6mr7608882wrh.128.1548338446976; Thu, 24 Jan 2019 06:00:46 -0800 (PST) MIME-Version: 1.0 References: <850b6aee-0040-c333-b125-45211c18ada5@daenzer.net> <047667fd-17be-1c37-5d2a-26768cfd6ab8@daenzer.net> <20190123071521.GB20526@infradead.org> <20190123164428.GA9367@infradead.org> <20190124091316.GA22796@infradead.org> <953e5e5f-5d47-d6df-40df-c8c94db5447f@amd.com> <57590a48-4629-e2a1-8673-ce9eb2ec210b@amd.com> <40ad3ae7-9970-0cb9-d35c-05e128f83820@amd.com> In-Reply-To: From: Alex Deucher Date: Thu, 24 Jan 2019 09:00:34 -0500 Message-ID: Subject: Re: [RFC PATCH] drm: disable WC optimization for cache coherent devices on non-x86 To: Ard Biesheuvel Cc: "Koenig, Christian" , Christoph Hellwig , =?UTF-8?Q?Michel_D=C3=A4nzer?= , Maxime Ripard , Will Deacon , Linux Kernel Mailing List , amd-gfx list , David Airlie , "Huang, Ray" , dri-devel , Michael Ellerman , "Zhang, Jerry" , "Deucher, Alexander" , Sean Paul , 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 Thu, Jan 24, 2019 at 8:57 AM Ard Biesheuvel wrote: > > On Thu, 24 Jan 2019 at 14:54, Alex Deucher wrote: > > > > On Thu, Jan 24, 2019 at 6:45 AM Ard Biesheuvel > > wrote: > > > > > > On Thu, 24 Jan 2019 at 12:37, Koenig, Christian > > > wrote: > > > > > > > > Am 24.01.19 um 12:26 schrieb Ard Biesheuvel: > > > > > On Thu, 24 Jan 2019 at 12:23, Koenig, Christian > > > > > wrote: > > > > >> Am 24.01.19 um 10:59 schrieb Ard Biesheuvel: > > > > >>> [SNIP] > > > > >>> This is *exactly* my point the whole time. > > > > >>> > > > > >>> The current code has > > > > >>> > > > > >>> static inline bool drm_arch_can_wc_memory(void) > > > > >>> { > > > > >>> #if defined(CONFIG_PPC) && !defined(CONFIG_NOT_COHERENT_CACHE) > > > > >>> return false; > > > > >>> > > > > >>> which means the optimization is disabled *unless the system is > > > > >>> non-cache coherent* > > > > >>> > > > > >>> So if you have reports that the optimization works on some PowerPC, it > > > > >>> must be non-cache coherent PowerPC, because that is the only place > > > > >>> where it is enabled in the first place. > > > > >>> > > > > >>>> The only problematic here actually seems to be ARM, so you should > > > > >>>> probably just add an "#ifdef .._ARM return false;". > > > > >>>> > > > > >>> ARM/arm64 does not have a Kconfig symbol like > > > > >>> CONFIG_NOT_COHERENT_CACHE, so we can only disable it everywhere. If > > > > >>> there are non-coherent ARM systems that are currently working in the > > > > >>> same way as those non-coherent PowerPC systems, we will break them by > > > > >>> doing this. > > > > >> Summing the things I've read so far for ARM up I actually think it > > > > >> depends on a runtime configuration and not on compile time one. > > > > >> > > > > >> So the whole idea of providing the device to the drm_*_can_wc_memory() > > > > >> function isn't so far fetched. > > > > >> > > > > > Thank you. > > > > > > > > > >> But for now I do prefer working and slightly slower system over broken > > > > >> one, so I think we should just disable this on ARM for now. > > > > >> > > > > > Again, this is not about non-cache coherent being slower without the > > > > > optimization, it is about non-cache coherent likely not working *at > > > > > all* unless the optimization is enabled. > > > > > > > > As Michel tried to explain this CAN'T happen. The optimization is a > > > > purely optional request from userspace. > > > > > > > > > > Right. > > > > > > So in that case, we can assume that the following test > > > > > > static inline bool drm_arch_can_wc_memory(void) > > > { > > > #if defined(CONFIG_PPC) && !defined(CONFIG_NOT_COHERENT_CACHE) > > > return false; > > > > > > is bogus, and it was just unnecessary caution on the part of the > > > author to disregard non-cache coherent devices. > > > Unfortunately, those commits have no log messages whatsoever, so it is > > > difficult to infer the intent retroactively. > > > > > > > > Otherwise, the driver will vmap() DMA pages with cacheable attributes, > > > > > while the non-cache coherent device uses uncached attributes, breaking > > > > > coherency. > > > > > > > > Again this is mandated by the userspace APIs anyway. E.g. we can't > > > > vmap() pages in any other way or our userspace APIs would break. > > > > > > > > > > OK, > > > > > > So let's just disable this for all ARM and arm64 then, given that > > > non-cache coherent is not supported in any case > > > > So I think we are back to this patch: > > https://patchwork.kernel.org/patch/10739023/ > > > > Apart from the fact that the issue has nothing to do with write-combining, yes. Your patch has a better description. Let's go with that. Alex