Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp3990106ybl; Mon, 13 Jan 2020 06:09:53 -0800 (PST) X-Google-Smtp-Source: APXvYqylCzxeL4tzBRQEOO/gXtEx27o2+M7iP6bRqvF+DNQe8ZchTxNBLfwLiHs3mxXFBjBr6Hy3 X-Received: by 2002:aca:4c57:: with SMTP id z84mr11992119oia.0.1578924593443; Mon, 13 Jan 2020 06:09:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578924593; cv=none; d=google.com; s=arc-20160816; b=uJETC1tpb0QsFZ7rDmEMPf4OBmHjcLgLU3WuRA9iYXIonYM9RQ2BuKBIyOiOVu6Ep2 wnEuXUyzEJksxzxL76zemGpIEB9ZKbHYUe+erhkvwabiXl37SjM8fN+QbfEWpJ3QpyAM L9jdS8t7Oe485BXoY73/lA7v277kA6cfHl+jAJ4I0l4mrGOC7gUCD777J+MSwzMIQ0Vk X1jacNQ9yvwd8GGMWc2PZduFIhUkBX6eRB4qOBtWXti2jy/yFDY5HCxJEa0iTMVwsnu7 dbAe6s+0wNJ8sEwrWnVI+2ces3qHe5tEI2wXAfW6wC7ZTfsYAeHy3yowVocoD2e4+vuf Id3A== 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 :message-id:date:subject:cc:to:from:dkim-signature; bh=RmsVJbxfmJIPyEANphpuUuv7UaSpvPm9q6Y+Misk4d8=; b=Okj6gnJZhlCSUtqZqbgYrUsg6eAX4QkPwv/J7BMxmvugFk5R4kxcwsoxZonLhOg6cM kfMLzfX/oiqrJa6ZLoESkZDfgcHSdkfFPh+5g7L9CIT5TirLByq30fjC2AWOTVex9Pi0 4d3NzEklfOKGVR/L05bzDKe6WCWbFj4hNRkr+LIVVJTqkeTaXdtwIZiwp1suZK0iAo0R rGl/e27p8jDl/Du0prAwwwPLSrWbgycXTcp5FLsM6F1wG0T5LZkVQJNPfxWMGWtU6USI CV76Ax3tk3dhigRDHEVjOVhBvDvMqP/qgEBjE33iI48d5ytWRUIsHzAdR0WvocVa5Zjv 3GYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=mail header.b=qZF6AX80; 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=flygoat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11si5957481oie.231.2020.01.13.06.09.40; Mon, 13 Jan 2020 06:09:53 -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=@flygoat.com header.s=mail header.b=qZF6AX80; 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=flygoat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728879AbgAMOHw (ORCPT + 99 others); Mon, 13 Jan 2020 09:07:52 -0500 Received: from forward102j.mail.yandex.net ([5.45.198.243]:58861 "EHLO forward102j.mail.yandex.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728801AbgAMOHw (ORCPT ); Mon, 13 Jan 2020 09:07:52 -0500 Received: from mxback13j.mail.yandex.net (mxback13j.mail.yandex.net [IPv6:2a02:6b8:0:1619::88]) by forward102j.mail.yandex.net (Yandex) with ESMTP id 54AD9F21435; Mon, 13 Jan 2020 17:07:49 +0300 (MSK) Received: from myt2-ea6a2e0cbf34.qloud-c.yandex.net (myt2-ea6a2e0cbf34.qloud-c.yandex.net [2a02:6b8:c00:2e8e:0:640:ea6a:2e0c]) by mxback13j.mail.yandex.net (mxback/Yandex) with ESMTP id 7umar6yfM8-7n6888lG; Mon, 13 Jan 2020 17:07:49 +0300 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; s=mail; t=1578924469; bh=RmsVJbxfmJIPyEANphpuUuv7UaSpvPm9q6Y+Misk4d8=; h=Subject:To:From:Cc:Date:Message-Id; b=qZF6AX80hM491dl4ZurWUU4lIMkEHWZ2xq6wH4E+iLY5NJlzHN7IPzV5B65nwm7W3 QZ1ChF6oqNs/jIs+8zVyiGAhK6lKva7bSvYf5NWYpzdQsZ/49rItwIoBvBmDq2tIP4 7I+umMjtruhdpvIoUBWt+AOooerJVq3NyBDMuj+Q= Authentication-Results: mxback13j.mail.yandex.net; dkim=pass header.i=@flygoat.com Received: by myt2-ea6a2e0cbf34.qloud-c.yandex.net (smtp/Yandex) with ESMTPSA id pGFN2nLtP9-7aV4FhvH; Mon, 13 Jan 2020 17:07:45 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) From: Jiaxun Yang To: linux-mips@vger.kernel.org Cc: chenhc@lemote.com, paul.burton@mips.com, linux-kernel@vger.kernel.org, hch@lst.de, Jiaxun Yang Subject: [PATCH 1/2] MIPS: Define pgprot_dmacoherent according to coherentio status Date: Mon, 13 Jan 2020 22:07:04 +0800 Message-Id: <20200113140705.74605-1-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org For MIPS chips that support coherentio DMA, it's always safe to make DMA requests cached. Signed-off-by: Jiaxun Yang --- arch/mips/include/asm/dma-coherence.h | 14 ++++++++++++++ arch/mips/kernel/setup.c | 1 + 2 files changed, 15 insertions(+) diff --git a/arch/mips/include/asm/dma-coherence.h b/arch/mips/include/asm/dma-coherence.h index 5eaa1fcc878a..bc0df7684cae 100644 --- a/arch/mips/include/asm/dma-coherence.h +++ b/arch/mips/include/asm/dma-coherence.h @@ -9,6 +9,8 @@ #ifndef __ASM_DMA_COHERENCE_H #define __ASM_DMA_COHERENCE_H +#include + enum coherent_io_user_state { IO_COHERENCE_DEFAULT, IO_COHERENCE_ENABLED, @@ -35,4 +37,16 @@ static inline bool dev_is_dma_coherent(struct device *dev) #define hw_coherentio 0 #endif /* CONFIG_DMA_MAYBE_COHERENT */ +#if !defined(CONFIG_DMA_PERDEV_COHERENT) +#define pgprot_dmacoherent pgprot_dmacoherent +static inline pgprot_t pgprot_dmacoherent(pgprot_t prot) +{ + if (coherentio == IO_COHERENCE_ENABLED || + (coherentio == IO_COHERENCE_DEFAULT && hw_coherentio)) + return prot; + + return pgprot_noncached(prot); +} +#endif + #endif diff --git a/arch/mips/kernel/setup.c b/arch/mips/kernel/setup.c index 701f4bc3046f..01f725819df7 100644 --- a/arch/mips/kernel/setup.c +++ b/arch/mips/kernel/setup.c @@ -831,6 +831,7 @@ arch_initcall(debugfs_mips); enum coherent_io_user_state coherentio = IO_COHERENCE_DEFAULT; EXPORT_SYMBOL_GPL(coherentio); int hw_coherentio = 0; /* Actual hardware supported DMA coherency setting. */ +EXPORT_SYMBOL_GPL(hw_coherentio); static int __init setcoherentio(char *str) { -- 2.24.1