From patchwork Wed Oct 19 12:16:20 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 5389 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp303970wrs; Wed, 19 Oct 2022 05:42:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4AdygITbAOmTZi4/rujTdAc2nibt9XWWZnN3jwXcH36p4cwNK5JJ87FGF0xDnNATdCe0kh X-Received: by 2002:a17:902:e748:b0:180:58d7:14be with SMTP id p8-20020a170902e74800b0018058d714bemr8153412plf.153.1666183329361; Wed, 19 Oct 2022 05:42:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666183329; cv=none; d=google.com; s=arc-20160816; b=dTYvpvZIrRb43fId727UfR14IAqjJjtKJ7t2JQeFnlqUg4OBwLUw0dO1jvqSLYkw0e puBHlKTJq7vglvIa2DbZXWJU1Atx3qc0dokW4T9VjvRNHVP/737ziF9KcSl6y9mEljlC JxcnQZSvFjZbawuGxv+ms9XIBG6MeuqTzg3uLRXGv0k/cfEJtiZodtZ3Emare6aR2v1z kVcOGUnrE4mMX/Ejc61XNiEo99Rrdn5rQHIq0qKvDjtO1rwnvGJGtDekTzf+H/Whcocx r5pPF+Lk7nFO/7dJq7eQB/iKWNI4COWUTdGpUdRA+kEUeQqYngADmrwIOfCXwXuH0u9w qlfQ== 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=vAvEVwdPVzOcq2kBtufcX9nitBNib2gQ4gtkOEEFeSI=; b=AQnOZdexRNJugtOwIYT+MVYIrw7YRiZcPpkCmjhFHKWhsFKqvwQH2UZFBiXBkg8AJc ixOgQg2ryJTyXQYtYu8faNrIs3wMZL+EFuwfVi9Nu/JVKvq5aXqHCz+XVOG5EhOSlN0z xUeIKYlqRtukpD9DEYyN8lIkOBmbpBQWJ/XWkL+m9uFOgPIy9YMYawMWmZ6kZ6KCGgVu 7Z4dOvA5UqR3vSdMcOovO5KF8I17qL4CC8GP8azG2bvRy+D9UWq9KkI5IJm0cF9/ZBvQ CIOjSPQg7NEGXa6YCRB5O6L44L5Kt6rgnLDJX6xuECd4jOzg41D0el+h29rdVWJWU9Ux 4rgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=FXlNG2VA; 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: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h12-20020a056a00170c00b00563960fdb21si19291489pfc.260.2022.10.19.05.41.56; Wed, 19 Oct 2022 05:42:09 -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=FXlNG2VA; 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 S231312AbiJSMiQ (ORCPT + 99 others); Wed, 19 Oct 2022 08:38:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50998 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231204AbiJSMh7 (ORCPT ); Wed, 19 Oct 2022 08:37:59 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2D6B1382CA for ; Wed, 19 Oct 2022 05:18:40 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id l4so17061139plb.8 for ; Wed, 19 Oct 2022 05:18:40 -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:subject:date :message-id:reply-to; bh=vAvEVwdPVzOcq2kBtufcX9nitBNib2gQ4gtkOEEFeSI=; b=FXlNG2VASXiEp9WSI7gST2fu64ZG/1MiT8WEB7Uxmw/y0b7OjAUZGRDYvLNjDytDLY pvAzzPZJ+LmY7b0hcxlD//VXwXXsAzaQgD0+mgzzAA8fk5uNO0tA5N5ciZ3kyzQvH8Bp CGJcMh7Ckrw8tGK/ZJHfAaEs+aW//lEy1LnrRfWGZj2aWN3c6RCCzp75an3TiiUC3jOQ 8BXMkRnHTUXGDtYgF4ZaHTmyt6Y8dgQ9LgpxaMpuGc5JoGiwt0363vHJr7OUktUvnxDn XDvjcV2FkSNyeXcazWx6OpYqRLPc24U+hEpQp8qZipU/ROs7HYq/VxgN63U2jrArJFoC 0f/Q== 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 :subject:date:message-id:reply-to; bh=vAvEVwdPVzOcq2kBtufcX9nitBNib2gQ4gtkOEEFeSI=; b=wLGN9OGfO8S/Q6QO1OGJuR6nQAp8FbMzwzY4wdY5QkH47SwZJNf6dEoIdHzkLh5Zjr gxVtoT2cc4Rcw/7Wq/cgoe/JwP2Xm0d44tEQTrm1y1WjbZlDhjSd19TbCCHTBmanLvzK ckv/A/cU3AVnya+IkghnXbPpm/hRclLybFvqNDUkPwmFIRNp9GzD6xnjwomm3bwV5QE6 aKxmSjAO8LG6OoZX1BedN4wM7KZU3gKNb9Ml+1p7ZKiQlHsXBuCbCfbxqZij9oaAWTj6 X2ozenFDzernBndPGrrz4MCHoETxNFDddjwV+JChXlViJ/4Okb7IbjyXQFKBMFNw8Jz1 gagg== X-Gm-Message-State: ACrzQf0UWqE0Sc+8iMh0IUBIUTPKVayaWDztb7eCGPt17Ac5Kc3uYnqi rKmjDTpX22tGVE51b69Ww9XOWw== X-Received: by 2002:a17:902:d4c5:b0:183:6e51:503 with SMTP id o5-20020a170902d4c500b001836e510503mr8105943plg.84.1666181813665; Wed, 19 Oct 2022 05:16:53 -0700 (PDT) Received: from anup-ubuntu64-vm.. ([171.76.82.102]) by smtp.gmail.com with ESMTPSA id x7-20020a170902a38700b0017e93c158d7sm10529824pla.214.2022.10.19.05.16.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Oct 2022 05:16:52 -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 v3 2/4] RISC-V: Fix ioremap_cache() and ioremap_wc() for systems with Svpbmt Date: Wed, 19 Oct 2022 17:46:20 +0530 Message-Id: <20221019121622.179024-3-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221019121622.179024-1-apatel@ventanamicro.com> References: <20221019121622.179024-1-apatel@ventanamicro.com> MIME-Version: 1.0 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 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747119850789354064?= X-GMAIL-MSGID: =?utf-8?q?1747119850789354064?= 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 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[];