Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2305710imc; Tue, 12 Mar 2019 11:02:00 -0700 (PDT) X-Google-Smtp-Source: APXvYqx0r6dZG6ZqFwlvjGFaQhjhGoLoPJTkXZOs3y7ra2XLmG5+WYarMiVKdhqliLmCX6zKZNCW X-Received: by 2002:a63:7341:: with SMTP id d1mr36926185pgn.405.1552413720253; Tue, 12 Mar 2019 11:02:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552413720; cv=none; d=google.com; s=arc-20160816; b=gmZIPdrNC0h2FcA4gQb0jlx5TOsus8AktHJd4ZTgXQvrqFv2nlYR6WTOFane8AYON2 fljjXj/a0rxM78v4+GrRmkbm8TGD4G95jOYGOBEM7bil8H84s5+nfs3TwmkNCJ4kE19a /gx8+A5Gxnhky/lm80YKyiQULrO5CiS6Qd4hr3KkeZVH6WJkmyc99nNjOHu6HyWyXwNr 37yRu0dFmlI5oVeB10QfBorNkjI8d5ZM9dzAhhQCixSaGZ8h974TsIFVMygWGfO3VJxX NyDqRrglWrI9EG7ntNu0LWBCAGJ25CJIsjs6B2p74AXFBI3vLvlyNcgI19f4QAnyi1r1 n/9w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TE30hieEgC6qCwuKAqmkJuKroM+2y7QHJD+ID5ZRcSA=; b=Mu52dRo08d4UkIAo9MnfA4/u0B+T08BBPwbmKX7CP7YEX1uZBqeB4DruJrIPvsnW4s tPRNx7caLQlaMQt8oNLUFc1WeU964iJEDHTQ1j+DK/AUvPUgmTofsIkjZ5+RWjHKon1Z rfEMVgi7Tzj4/n9Z+utARbCDECUDAfddoOiq4O1aHwnERPoczGIQoxMX9Z/Xmdshmo6b +aVT9nvgqXLzGLXQzBt6rrzJxM8aoPZPSdHicMaJxzDdNZGoRPMTlb0QN1e7GsdZYizL gBc33K3BBrvPMBGTOwL6bHUkEWakVcnUL5I0iBJBzJCc0MjLL0hm8It9+nGx1DmEL0Tu jlPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=vIZUOlZQ; 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 e2si8077332pgm.568.2019.03.12.11.01.44; Tue, 12 Mar 2019 11:02:00 -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; dkim=pass header.i=@kernel.org header.s=default header.b=vIZUOlZQ; 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 S1728079AbfCLR7m (ORCPT + 99 others); Tue, 12 Mar 2019 13:59:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:50568 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727682AbfCLRNa (ORCPT ); Tue, 12 Mar 2019 13:13:30 -0400 Received: from localhost (unknown [104.133.8.98]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3EF1F21741; Tue, 12 Mar 2019 17:13:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552410809; bh=244Fua93XWB1optCXZhSQPIfmvwcYhUXzkcDy8Cw8Q4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vIZUOlZQCIJUHTMp2v/SgQo5CHr7ZMiOF+nDQ+HmYW+1Hdjn8XXObABq21fco9X53 TyFUfEBOpgkndcKB8g+A+XXRgYPAMB0Xh909GXSft1MQ6Uf0cumoMgVwlM2TxIdENU TgB0tYoRS98v8CP6tYZYUmrm+XPMe5Z/RlwOwAjw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.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 , Christoph Hellwig , Robin Murphy , amd-gfx list , dri-devel , Carsten Haitzler , Ard Biesheuvel , Sasha Levin Subject: [PATCH 4.20 160/171] drm: disable uncached DMA optimization for ARM and arm64 Date: Tue, 12 Mar 2019 10:09:00 -0700 Message-Id: <20190312170401.202933174@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190312170347.868927101@linuxfoundation.org> References: <20190312170347.868927101@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.20-stable review patch. If anyone has any objections, please let me know. ------------------ [ Upstream commit e02f5c1bb2283cfcee68f2f0feddcc06150f13aa ] The DRM driver stack is designed to work with cache coherent devices only, but permits an optimization to be enabled in some cases, where for some buffers, both the CPU and the GPU use uncached mappings, removing the need for DMA snooping and allocation in the CPU caches. The use of uncached GPU mappings relies on the correct implementation of the PCIe NoSnoop TLP attribute by the platform, otherwise the GPU will use cached mappings nonetheless. On x86 platforms, this does not seem to matter, as uncached CPU mappings will snoop the caches in any case. However, on ARM and arm64, enabling this optimization on a platform where NoSnoop is ignored results in loss of coherency, which breaks correct operation of the device. Since we have no way of detecting whether NoSnoop works or not, just disable this optimization entirely for ARM and arm64. Cc: Christian Koenig Cc: Alex Deucher Cc: David Zhou Cc: Huang Rui Cc: Junwei Zhang Cc: Michel Daenzer Cc: David Airlie Cc: Daniel Vetter Cc: Maarten Lankhorst Cc: Maxime Ripard Cc: Sean Paul Cc: Michael Ellerman Cc: Benjamin Herrenschmidt Cc: Will Deacon Cc: Christoph Hellwig Cc: Robin Murphy Cc: amd-gfx list Cc: dri-devel Reported-by: Carsten Haitzler Signed-off-by: Ard Biesheuvel Reviewed-by: Christian König Reviewed-by: Alex Deucher Link: https://patchwork.kernel.org/patch/10778815/ Signed-off-by: Christian König Signed-off-by: Sasha Levin --- include/drm/drm_cache.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/include/drm/drm_cache.h b/include/drm/drm_cache.h index bfe1639df02d..97fc498dc767 100644 --- a/include/drm/drm_cache.h +++ b/include/drm/drm_cache.h @@ -47,6 +47,24 @@ static inline bool drm_arch_can_wc_memory(void) return false; #elif defined(CONFIG_MIPS) && defined(CONFIG_CPU_LOONGSON3) return false; +#elif defined(CONFIG_ARM) || defined(CONFIG_ARM64) + /* + * The DRM driver stack is designed to work with cache coherent devices + * only, but permits an optimization to be enabled in some cases, where + * for some buffers, both the CPU and the GPU use uncached mappings, + * removing the need for DMA snooping and allocation in the CPU caches. + * + * The use of uncached GPU mappings relies on the correct implementation + * of the PCIe NoSnoop TLP attribute by the platform, otherwise the GPU + * will use cached mappings nonetheless. On x86 platforms, this does not + * seem to matter, as uncached CPU mappings will snoop the caches in any + * case. However, on ARM and arm64, enabling this optimization on a + * platform where NoSnoop is ignored results in loss of coherency, which + * breaks correct operation of the device. Since we have no way of + * detecting whether NoSnoop works or not, just disable this + * optimization entirely for ARM and arm64. + */ + return false; #else return true; #endif -- 2.19.1