Received: by 2002:a05:6358:45e:b0:b5:b6eb:e1f9 with SMTP id 30csp3815819rwe; Mon, 29 Aug 2022 21:50:44 -0700 (PDT) X-Google-Smtp-Source: AA6agR7QLLTiPA7MG9w57dKbWi/sLsNMBZRwfsPZOitOE/zYtJlzmX10BjdhM6vmtjvVaUdZipDD X-Received: by 2002:a17:906:ae85:b0:742:299b:4f39 with SMTP id md5-20020a170906ae8500b00742299b4f39mr1299685ejb.567.1661835044474; Mon, 29 Aug 2022 21:50:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1661835044; cv=none; d=google.com; s=arc-20160816; b=YCjLixdQAvYhmdFBxfjezHeXPB4R9VVlcC0KzSdmt85NYVZLpmVKtEyD+i2rWrjCup lBcosaOkVeZYxDlTtz4j38jVr4v9Nlt8rd3EWGYaREdCT3gVG6/22VcIX+ag57fLdsoB pZZK50mKHFWyM3tEhIsM+M4t0W3yZsJih9QRyS/dugCr8N80OuXdxy30lnUur7wctQr9 4JCuDHRg4fp0pCdfHDQgvCj5HattLPBG7Oy3R4Bgg/eJC+7tmW/E9sh/NZBz5mBipSot BXDgg6zZi2eCxLNEicrOWVkc/XYvMAEcXUiZXbPWAzfQMcZcavA1GUukSI9wc1V2tb1e yIDw== 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 :dkim-signature; bh=DF3EHZACZLIxZm103wJfkyVVUnHhmNz4e84k34pg8iM=; b=x4Df7W7dHF6JQgj6DsOFkUJk+DlJAS/6/thPiQ2qJrl27THPunoTg+9D4h28ZwmSLd fyyRti39fNRgWmnSE2oef7BUK5YXyvmxfGbtDKz4j1fLpoxVbWz4IcKpJb7SQ+3DA5nr rlmn5I6rtHeBcXS4lsNkYOp1A0ej4zvxZWwhvHmJov6uDd/4/wZ/hQx/a4c0FNnrfWJZ u/Af7nFL/ZWd35wBPwmRZW9s199YgLXDucHNBKPmWumJMdshcCo7FfrHRe8L8DD5bpM2 XYWEcMDP7cbKPyP+3H63shN5R+orV9k2oMF44mST8yMX+wc0S21THVd05GgBxmciapxl 6z+w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="d//IYFbF"; 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a14-20020a509e8e000000b00447bac336ebsi7423566edf.527.2022.08.29.21.50.19; Mon, 29 Aug 2022 21:50:44 -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; dkim=pass header.i=@ventanamicro.com header.s=google header.b="d//IYFbF"; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229625AbiH3Erm (ORCPT + 99 others); Tue, 30 Aug 2022 00:47:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59078 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229830AbiH3Erf (ORCPT ); Tue, 30 Aug 2022 00:47:35 -0400 Received: from mail-pj1-x1031.google.com (mail-pj1-x1031.google.com [IPv6:2607:f8b0:4864:20::1031]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6EF36AB4F9 for ; Mon, 29 Aug 2022 21:47:34 -0700 (PDT) Received: by mail-pj1-x1031.google.com with SMTP id z3-20020a17090abd8300b001fd803e34f1so8110603pjr.1 for ; Mon, 29 Aug 2022 21:47:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc; bh=DF3EHZACZLIxZm103wJfkyVVUnHhmNz4e84k34pg8iM=; b=d//IYFbFbRj/XGv/L+vodF9VdUAaDfuMlXokuJPWHcVkRNgY84J/Nq6BwNLvkQJH+l qIY3tux1IkH+TGS1zi/PJWIDe/9R1ROlQPIotY7+VEvdoMJ4/thsof72inQ0Cn80VXj+ xltiE7undvWYlNF+uMHyz6euWLMHSPsJoRSnEupUASGZx1lcKIDaxRaywMxGeyC3jOfj +B6i5IFJw98Qv6rfWsaCKPTgHuNrb7NawC+gGZG3zQg9LKTo8SVMHL6JYCYJrlJh8M3h ZYz+ouRwEeFK43KJD33wD1e4BwnP/wFeR9+Qkjk++zoL5wsLEeHee6JpThHE5socKCRj crFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc; bh=DF3EHZACZLIxZm103wJfkyVVUnHhmNz4e84k34pg8iM=; b=FUauNUsngEg/b4s8V1hDkjyVR2nGleImwImNGPq6gjjIGOKS/On+eKY5/RVmqIeAgZ WljI4PsXqFh20i0ZuePNoVNgn8Ck0xW84D9+e/k05inGwT9bIKa42xaUn8yZprxI9iXB ji5HwqX+KWJTubLNotNj/FNoB3Ade0wMp8pMhmxBeIX/CPPP8AXNpiLiwK9c7qnrt1ch kjrfgrJpiCj0S3femuKxeyQ5BvybIvyBpp1y7alDalwedxAELljg4rR3EpVY6ZbOvja3 z0KZ5F3JdXqCK6pW2azh51ViQhdwZx8nqqdsnooN7cHCG6lo1YPZvtkiEKZk9uTfapMB dtBQ== X-Gm-Message-State: ACgBeo3Mu/FNlKRdCUNw7RKM/9b9mLVwtip7o8zm0r5gNaWnN835CaRa olKWxzsW2Fr+YnMCZQZ+PPAvRQ== X-Received: by 2002:a17:90b:4d07:b0:1ef:521c:f051 with SMTP id mw7-20020a17090b4d0700b001ef521cf051mr22130876pjb.164.1661834853798; Mon, 29 Aug 2022 21:47:33 -0700 (PDT) Received: from anup-ubuntu64-vm.. ([171.76.81.23]) by smtp.gmail.com with ESMTPSA id y27-20020a634b1b000000b0041cd5ddde6fsm592240pga.76.2022.08.29.21.47.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 29 Aug 2022 21:47:33 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley Cc: Atish Patra , Heiko Stuebner , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Anup Patel , Mayuresh Chitale Subject: [PATCH v2 1/4] RISC-V: Fix ioremap_cache() and ioremap_wc() for systems with Svpbmt Date: Tue, 30 Aug 2022 10:16:39 +0530 Message-Id: <20220830044642.566769-2-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20220830044642.566769-1-apatel@ventanamicro.com> References: <20220830044642.566769-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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 --- 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 69605a474270..07ac63999575 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((void __iomem *)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[]; -- 2.34.1