Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp1227799rwi; Wed, 19 Oct 2022 08:06:56 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4RptS8zpqdAoGrgCzGA8DjxsCYQl7asNi5TbE3VaEV/VsqNN0nh/7B938w5+qS2GCsOBzE X-Received: by 2002:a05:6402:1c1c:b0:45c:35b2:2a98 with SMTP id ck28-20020a0564021c1c00b0045c35b22a98mr8122908edb.182.1666192009743; Wed, 19 Oct 2022 08:06:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666192009; cv=none; d=google.com; s=arc-20160816; b=vLqrwNRSUSb6Ebpy5ro9WCS5NAygnXPrvENmLzRNEEtR1GkaHoywNAXDAypsinC8zr GPYQyySzscjG3Mg+mGGzBK4MbrKxq7KkbcfBOBoWNv2TxYazCxpPdHuc+KkjgD0yI7Dw c1H1Vmg7nyXm09C+yamJcaIhTYwMFs3dpCl6j69JCttAxlsoQNGcLt32L+P4SOB4EbC/ i14ya5ErSPVBlDf+J1tOub/D2IutC7Etx+vIpc2bpIvjIP/W0lHsQir1XruXOvp6Hg4H R/J4kxTNtpJLVR0JLG2ei3BozMolC4xyUd5UAWBMGuz5o9cWUdAyaayObYu3rjMKAFCP W2JA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=F6u98vUJvv7ebMxNaRL/9NguAuzNGl1YFnUukfGcZ2o=; b=LYYFFNmXTDgIo7gAncLqzp7LO6liIhyuiEhiROHSiRL5A7Te2QLCPAIHd86yzcYev+ IkSuYcfS1y08xlKlAe3QpUHqplTJ8l9wUQNK2lB6gYPgzFGqMEF6PT6IVRxq9hVqz3zf SBF87boydBUVZcg4qA3edYSmxX5BDlLlKnZQDP3m7mbLRBxdvB477ZDjkJ5sz1m4HqO9 t035Dnq8WgSe4F85LdPNoauyyrOzdeUrhnOKwr+9goJg1ha5g2fUDR+qSCNIPRJNvtZR 65AtxPGrXdzfMnzQHqHmO4w6g3ZBvPBJPCwB4HcjuLrFq5umOKA2j7/EMyGOXnHE4cqu wPYA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cz3-20020a0564021ca300b00459be46b0f4si12509939edb.131.2022.10.19.08.05.56; Wed, 19 Oct 2022 08:06:49 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=sntech.de Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230172AbiJSOgr (ORCPT + 99 others); Wed, 19 Oct 2022 10:36:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58954 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231894AbiJSOgY (ORCPT ); Wed, 19 Oct 2022 10:36:24 -0400 Received: from gloria.sntech.de (gloria.sntech.de [185.11.138.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BE252CC89 for ; Wed, 19 Oct 2022 07:20:41 -0700 (PDT) Received: from p508fdae2.dip0.t-ipconnect.de ([80.143.218.226] helo=phil.localnet) by gloria.sntech.de with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1ol9ux-0006Hx-9G; Wed, 19 Oct 2022 16:19:35 +0200 From: Heiko Stuebner To: Palmer Dabbelt , Paul Walmsley , Anup Patel Cc: Atish Patra , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel , Mayuresh Chitale Subject: Re: [PATCH v4 2/4] RISC-V: Fix ioremap_cache() and ioremap_wc() for systems with Svpbmt Date: Wed, 19 Oct 2022 16:19:34 +0200 Message-ID: <13122510.uLZWGnKmhe@phil> In-Reply-To: <20221019131128.237026-3-apatel@ventanamicro.com> References: <20221019131128.237026-1-apatel@ventanamicro.com> <20221019131128.237026-3-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_PASS, T_SPF_HELO_TEMPERROR autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am Mittwoch, 19. Oktober 2022, 15:11:26 CEST schrieb Anup Patel: > Currently, all flavors of ioremap_xyz() function maps to the generic > ioremap() which means any ioremap_xyz() call will always map the > target memory as IO using _PAGE_IOREMAP page attributes. This breaks > ioremap_cache() and ioremap_wc() on systems with Svpbmt because memory > remapped using ioremap_cache() and ioremap_wc() will use _PAGE_IOREMAP > page attributes. > > To address above (just like other architectures), we implement RISC-V > specific ioremap_cache() and ioremap_wc() which maps memory using page > attributes as defined by the Svpbmt specification. > > Fixes: ff689fd21cb1 ("riscv: add RISC-V Svpbmt extension support") > Co-developed-by: Mayuresh Chitale > Signed-off-by: Mayuresh Chitale > Signed-off-by: Anup Patel Wasn't there discussion around those functions in general in v2? In any case, the patch doesn't break anything on qemu and d1, so Tested-by: Heiko Stuebner > --- > arch/riscv/include/asm/io.h | 10 ++++++++++ > arch/riscv/include/asm/pgtable.h | 2 ++ > 2 files changed, 12 insertions(+) > > diff --git a/arch/riscv/include/asm/io.h b/arch/riscv/include/asm/io.h > index 92080a227937..92a31e543388 100644 > --- a/arch/riscv/include/asm/io.h > +++ b/arch/riscv/include/asm/io.h > @@ -133,6 +133,16 @@ __io_writes_outs(outs, u64, q, __io_pbr(), __io_paw()) > #define outsq(addr, buffer, count) __outsq(PCI_IOBASE + (addr), buffer, count) > #endif > > +#ifdef CONFIG_MMU > +#define ioremap_wc(addr, size) \ > + ioremap_prot((addr), (size), _PAGE_IOREMAP_WC) > +#endif > + > #include > > +#ifdef CONFIG_MMU > +#define ioremap_cache(addr, size) \ > + ioremap_prot((addr), (size), _PAGE_KERNEL) > +#endif > + > #endif /* _ASM_RISCV_IO_H */ > diff --git a/arch/riscv/include/asm/pgtable.h b/arch/riscv/include/asm/pgtable.h > index 7ec936910a96..346b7c1a3eeb 100644 > --- a/arch/riscv/include/asm/pgtable.h > +++ b/arch/riscv/include/asm/pgtable.h > @@ -182,6 +182,8 @@ extern struct pt_alloc_ops pt_ops __initdata; > #define PAGE_TABLE __pgprot(_PAGE_TABLE) > > #define _PAGE_IOREMAP ((_PAGE_KERNEL & ~_PAGE_MTMASK) | _PAGE_IO) > +#define _PAGE_IOREMAP_WC ((_PAGE_KERNEL & ~_PAGE_MTMASK) | \ > + _PAGE_NOCACHE) > #define PAGE_KERNEL_IO __pgprot(_PAGE_IOREMAP) > > extern pgd_t swapper_pg_dir[]; >