Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp6360019imu; Mon, 21 Jan 2019 07:35:54 -0800 (PST) X-Google-Smtp-Source: ALg8bN4OBoKccXejIho2tZlgKbT1tZs8Qfn7UNV7SanxEzOx57L4xhSjQ3wK8X5e2JwtHu2rcjQt X-Received: by 2002:a17:902:3064:: with SMTP id u91mr30073075plb.325.1548084954074; Mon, 21 Jan 2019 07:35:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1548084954; cv=none; d=google.com; s=arc-20160816; b=K4jH2WODxFgnf3lypqDFKWl+J2k0LX9m3aSmcd/88DnXFCUY7B/nkG+u0A9W2sK+jS Qth8lEq82pSbl/7Rw80WuNIWyPW4XUDrQGh/ibltvzA4u3gTdbuiV8GqEH7Z8b7tNken kqI8mZBSOnokx6YCXaYwtLJxyg5yxldCceiDvEICmkLJfI6iabkxbu61TMIeJTl6r95G XH27fa5EP33UVo4t6RronNjFVUE8/gDfQSINPu5r56ZOs/IiQjLLuxWFCFC9C98GiNhn W1OLR09YDBt94Z/zaRA9y/msq9p9iScfzmMWQFC1GtmSYKDKVYCu04YqmNPFiPJnRWm4 G8Yw== 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=3uemtn1t3FusGviom3Dh6L2MT7Zfb+f7Orre/lzjRyI=; b=S0pp7o4TWibVCIJouhptpHsILIcgWjG6d2/1YLUqttH5przpsv3QKH87hwEHov3rZL ShZdFMRp6xfB8wpSwjvR6Fm9KLQ3i4TCxQCyq7fqZEdPWXz3ST951PRkNGrqHVcFzJ0M Z85zOBg/t/j3Oks1MNbmBQilM1ljKy7QCIxUpZHairH0fFatv8s0M2p00Kzc7UXutQGc yWM9flm0l1lm7R2q/3uMemv/1JO4yJogZ8MOk6H08gTk9pisJk4k6D+BbXLIIQQMRzef h9vGMDA2RGSB3aJ4mCCUPLvS7dQ0dK9JVH0sZYQD+SnTa20tvk+FeHjK18Jguj96GI8z hH2g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=dqJjmLJ6; 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 k7si12844142pgm.462.2019.01.21.07.35.38; Mon, 21 Jan 2019 07:35:54 -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=dqJjmLJ6; 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 S1728947AbfAUPdk (ORCPT + 99 others); Mon, 21 Jan 2019 10:33:40 -0500 Received: from mail-io1-f65.google.com ([209.85.166.65]:33467 "EHLO mail-io1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728848AbfAUPdj (ORCPT ); Mon, 21 Jan 2019 10:33:39 -0500 Received: by mail-io1-f65.google.com with SMTP id t24so16726920ioi.0 for ; Mon, 21 Jan 2019 07:33:39 -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=3uemtn1t3FusGviom3Dh6L2MT7Zfb+f7Orre/lzjRyI=; b=dqJjmLJ63qti8gqps928oPHwhz4UXR8Zg7gMXHKCSKejOYWYs6X4HDjuprvOTEipK/ 5IPDgT17lqfkNtm3c+dJFg2V0nw6+IZP5j4Ffbphx2OUzd3ATO2xJXHJKFXTwdHJV7+L asvNzX/0MWAOxqrqqdR+onUhXk+LMbMeMHKYA= 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=3uemtn1t3FusGviom3Dh6L2MT7Zfb+f7Orre/lzjRyI=; b=i5ayOrYVSk2s3lEVflXK/dHdBz3Xq2y0X85OZqRKyQ7CxZ+Llbl29f5q3oKNeGtD+g pxWaRVKiUExuT/HhtmqdFqLi57FlesztIWamEwmh7xn2QhqdmKcjyoVVz1MpG1uUO+2O OHX7sCdk3J0haC9wCrJBm6BuDjmCy7lsB3PqcrU9ftyPxBia4vA7xqNq9hUSRAPhMS9z HL8lA+C5O+CdPD6exQA8ZJkJgT7EqbVcTY39tAKl7PnSR+K6l9Cyerhk2c2xQRUFsiNd JSqpeCJxKM4FvDHNu2sWD6LfQ9Vy6Dj47SLHQZb/FNVgRx3YDRS5Zd94+ZV4LpEFy5M2 v2aQ== X-Gm-Message-State: AJcUukd7kCuNLH5vXnglJHD40NMKQ49lcZF0w1lhMDAIFt4iU4OwOxx8 eSNH+Vskq+5Ea3EaWi+0UX5eGao/pz+Jy8VhjIcBaw== X-Received: by 2002:a5e:c206:: with SMTP id v6mr17704386iop.60.1548084818958; Mon, 21 Jan 2019 07:33:38 -0800 (PST) MIME-Version: 1.0 References: <20190121100617.2311-1-ard.biesheuvel@linaro.org> <20190121150734.GA30582@infradead.org> In-Reply-To: <20190121150734.GA30582@infradead.org> From: Ard Biesheuvel Date: Mon, 21 Jan 2019 16:33:27 +0100 Message-ID: Subject: Re: [RFC PATCH] drm: disable WC optimization for cache coherent devices on non-x86 To: Christoph Hellwig Cc: 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 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 Mon, 21 Jan 2019 at 16:07, Christoph Hellwig wrote: > > > +#include > > This header is not for usage in device drivers, but purely for > dma-mapping implementations! > Is that documented anywhere? > > +static inline bool drm_device_can_wc_memory(struct drm_device *ddev) > > { > > + if (IS_ENABLED(CONFIG_PPC)) > > + return IS_ENABLED(CONFIG_NOT_COHERENT_CACHE); > > + else if (IS_ENABLED(CONFIG_MIPS)) > > + return !IS_ENABLED(CONFIG_CPU_LOONGSON3); > > + else if (IS_ENABLED(CONFIG_X86)) > > + return true; > > + > > + return !dev_is_dma_coherent(ddev->dev); > > And even if something like this was valid to do, it would have to be > a core function with an arch hook, and not hidden in a random driver. Why would it not be valid to do? Is it wrong for a driver to be aware of whether a device is cache coherent or not? And in case it isn't, do you have an alternative suggestion on how to fix this mess?