Received: by 2002:ac0:950c:0:0:0:0:0 with SMTP id f12csp2295420imc; Tue, 12 Mar 2019 10:48:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqyVJ0Du3oD5vyDcXHqgqLlknG2FUehFCaBEdALdkd6fBiAwLcIO5FBP4esXSsiKf1ZHqYIn X-Received: by 2002:a65:4bce:: with SMTP id p14mr11159578pgr.68.1552412891950; Tue, 12 Mar 2019 10:48:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1552412891; cv=none; d=google.com; s=arc-20160816; b=tT0DvrEeS0Ze93tqdmi0/Gg6uAdaFLt2jM7lP5ODSVOZcuC70UnPyjWSwul/QstouX n/lR31lYGVKQ7QAe+f60PbmQFIIVHSBpoMUonlMJT3ugZypMSxPBukXYm1i2tFU5LMcY EfyV8+YsTlwZg/CPJv/kvehneB7pxnd38tXzecZqPI+pMId63LSurjBD1i8/MTTZNDxn LiHsi2X76jmP3ROdEGU6V5PrHUIrrGf9OcA5p/fDg2qBI5Vsmv2Bb/bKGLTa0eKcgyT5 +CCtyeze/xPh59KZ5+uMdiWMbZSd7cQuTvYZr4mroTIhQ46r4bQMeOsYH0cx14o18i0Q ksTA== 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=r8K2xu9UCqyVttOK2NqaEDD8pCaCty7PXQne7KEuTuY=; b=jKNwLa6tmg5wrxv28a3JwYQ9kiK6Te+0JlUdd3DvybMwj7ONlQ9HFBdPI448gre3N2 TDNuwNcYEgtaQI0QlXERriar64T8cGOeln7xIDnEw98JNkYwnBbt49vvWcd4cF2NutNn 2oTIiErcJ+JoJ+zgyb9U/Lo6WYnUfd5CjLQDT9A7trvL+e9KbcmppKBPHm8ucngjl+sv wrDWzOjgerbSG+t/JTG7RN429g8x3EngqY/iXyQLqK5kavB+YYiHW9ye4jEy7EcBbbzC 8p9PMBovJiyDIUPSBNB0EIh7sfiIsHzzd7vpdhoC2Is+IJWWAJZ49ciMs2UWjt/RC0xO /r7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rgOXHsyP; 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 r5si3628195plo.40.2019.03.12.10.47.56; Tue, 12 Mar 2019 10:48:11 -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=rgOXHsyP; 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 S1728814AbfCLRq5 (ORCPT + 99 others); Tue, 12 Mar 2019 13:46:57 -0400 Received: from mail.kernel.org ([198.145.29.99]:55460 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728662AbfCLRPR (ORCPT ); Tue, 12 Mar 2019 13:15:17 -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 0F9222184E; Tue, 12 Mar 2019 17:15:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1552410916; bh=lSDZ07B4cx11chIbe59u1OQ9QCcfoO42p8xo2tDJoxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rgOXHsyPDrUe5bM5oDj2tnBs/Lc0pqJnOIhIhdoR5IuFC4d++KaD+1ShdRc2Y/N3+ bt7nrsBOJQSABHWQiUK+Yse8WC7omty2j86xtcqaB/78b7BbKC+kbwvLbZt93K4d71 Et7SZAWxJLSXXcJ61vbpRUDzdUdNcgfwcTyNtlJU= 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.19 134/149] drm: disable uncached DMA optimization for ARM and arm64 Date: Tue, 12 Mar 2019 10:09:12 -0700 Message-Id: <20190312170400.589983836@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190312170349.421581206@linuxfoundation.org> References: <20190312170349.421581206@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.19-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