From patchwork Wed Apr 19 11:10:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216658 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 62132C77B73 for ; Wed, 19 Apr 2023 11:10:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=g2dl8YKwARtou7+f8LA35eC7B46U+bBXFS1u01D/PsU=; b=b+hnjqGfbTOUXQ StZfCu+1rXPMoKfnvPuRgLibF99QU2zZSgkUYTWWQFBrYUBBS/KQjRrH1eithUx5/8IRvgXn9mj1i W4zGTttGpzUO7kZquH9W3/Q8eqmCXyDOwTDngl3DDM+l87YYqn5KfoFkt6NpgSiN9yRshe+VDGJkk 23AqTLkQzLxxeGyPdArpQ6/39IcCRXicB1tu/LqPoMSp0b5p5aDfaI0AuD3YZ5gH9QARolNlZtv6B 9DcEEjykxcs3cc+SCL14LXssIKmf1btKvWqsYSs0StFv3KSObBVhRbOUriCB1wQ3idk8+4CK5JrUU AOoB/ohmRS5XpHl9nZkQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hY-00585c-09; Wed, 19 Apr 2023 11:10:16 +0000 Received: from mail-pj1-x1036.google.com ([2607:f8b0:4864:20::1036]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hT-005847-2S for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:14 +0000 Received: by mail-pj1-x1036.google.com with SMTP id 98e67ed59e1d1-247048f86c7so1754625a91.2 for ; Wed, 19 Apr 2023 04:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902609; x=1684494609; 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=qOmhE21FgoLvBz4/9K8B1nYj/1N6YhDVDpnvXhhmMHI=; b=MCc3RKujUUOi8hHvnbPZFeUjt8Qd74fXOJWfbDL8OnevMgMRtLCwWwwiC8fo+YtseC Z5CdLbzGTCTc4FrEZwKeoFosFYCULmjriRg7z6nNiNBZZHcqQYlcVxtc/8J/iXL6FnGM Ak1bog8/XCv67o576rPkqx6VVqQB2wiWJUaX4SuFrHLX9Y0r9Nriqgke9p5gwyKw4+mb 6ggfeHji4wYa2rfl88PSkZkxOMDnEFJ8zEx21rVh0Pi1oTVIcQlQYajwFvO958MKvKTP oex460ebviHF9yAeC9yopjk8xV4Lw4HLQclBLRYFseX4PFAQ3a+cloav1If/fEXDS+8S AqkQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902609; x=1684494609; 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=qOmhE21FgoLvBz4/9K8B1nYj/1N6YhDVDpnvXhhmMHI=; b=J+vKvMKmD+/GC79U/EOpxMq2sb/haODyBIPU6xpkucVyPjtPVrk/7g3YTbOyF58gR3 we5SwY3y70r2jUutccArdjXvsrpFkaJ6gXBESwLf8hLKg7DSSc60Ri+7Es+xKT5PJD6V 8nM2yYipGIvrOGYxVCkJxxlmIIBsN6tUgD4gC1b3J+BDoNkqYuWFDn00k8dX69GSGl/3 nKw+Tg0Y97GMDVQbEiWI5c1WtSvXPENiiizwMQ/I9uDlAwvtOGNLPHf26kgvgHkGle+Q 1ZJ84bp893lRdGVnrEadmEa5JaqiDCso3y0LhdMw3Weo2zc1VZjxgPv4J/xYH/Vol9Gm yTNw== X-Gm-Message-State: AAQBX9dBcn+q3Hq3cIOYQN7+sP6FU56RTtRsfmRJ+Yh3euarHxB6PJ0t UiNCpVR3RVIENmAezKR3hTB4ZrMA5dz/FolvqqA= X-Google-Smtp-Source: AKy350aog1v27ScFai211i+05TpdB/RC9uovpGnFFaweBZPoBKDGxR8qKvX3uA8bKz6iyCPjFywS4Q== X-Received: by 2002:a17:90b:3901:b0:247:193b:ce84 with SMTP id ob1-20020a17090b390100b00247193bce84mr2501295pjb.15.1681902609085; Wed, 19 Apr 2023 04:10:09 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:08 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 01/21] RISC-V: Detect the Ssqosid extension Date: Wed, 19 Apr 2023 04:10:51 -0700 Message-Id: <20230419111111.477118-2-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041011_801357_3FEA760D X-CRM114-Status: GOOD ( 13.95 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Ssqosid is the Supervisor QoS ID extension defined in the RISC-V CBQRI (Capacity and Bandwidth QoS Register Interface) specification. Link: https://github.com/riscv-non-isa/riscv-cbqri/blob/main/riscv-cbqri.pdf Signed-off-by: Kornel Dulęba [dfustini: rebase from v6.0 to v6.3] Signed-off-by: Drew Fustini --- Note: - A version of this patch rebased on riscv/for-next was already submitted as an RFC to linux-riscv [1] with Message-ID: 20230410043646.3138446-1-dfustini@baylibre.com - This patch is included in this RFC series so as to provide a cohesive demonstration in one series. [1] https://lore.kernel.org/lkml/20230410043646.3138446-1-dfustini@baylibre.com/ arch/riscv/include/asm/hwcap.h | 2 ++ arch/riscv/kernel/cpu.c | 1 + arch/riscv/kernel/cpufeature.c | 1 + 3 files changed, 4 insertions(+) diff --git a/arch/riscv/include/asm/hwcap.h b/arch/riscv/include/asm/hwcap.h index e3021b2590de..255c5c4d0a24 100644 --- a/arch/riscv/include/asm/hwcap.h +++ b/arch/riscv/include/asm/hwcap.h @@ -42,6 +42,8 @@ #define RISCV_ISA_EXT_ZBB 30 #define RISCV_ISA_EXT_ZICBOM 31 #define RISCV_ISA_EXT_ZIHINTPAUSE 32 +#define RISCV_ISA_EXT_SSQOSID 35 + #define RISCV_ISA_EXT_MAX 64 #define RISCV_ISA_EXT_NAME_LEN_MAX 32 diff --git a/arch/riscv/kernel/cpu.c b/arch/riscv/kernel/cpu.c index 8400f0cc9704..d1441872f173 100644 --- a/arch/riscv/kernel/cpu.c +++ b/arch/riscv/kernel/cpu.c @@ -189,6 +189,7 @@ static struct riscv_isa_ext_data isa_ext_arr[] = { __RISCV_ISA_EXT_DATA(zihintpause, RISCV_ISA_EXT_ZIHINTPAUSE), __RISCV_ISA_EXT_DATA(zbb, RISCV_ISA_EXT_ZBB), __RISCV_ISA_EXT_DATA(sscofpmf, RISCV_ISA_EXT_SSCOFPMF), + __RISCV_ISA_EXT_DATA(ssqosid, RISCV_ISA_EXT_SSQOSID), __RISCV_ISA_EXT_DATA(sstc, RISCV_ISA_EXT_SSTC), __RISCV_ISA_EXT_DATA(svinval, RISCV_ISA_EXT_SVINVAL), __RISCV_ISA_EXT_DATA(svpbmt, RISCV_ISA_EXT_SVPBMT), diff --git a/arch/riscv/kernel/cpufeature.c b/arch/riscv/kernel/cpufeature.c index 59d58ee0f68d..80317d2d3975 100644 --- a/arch/riscv/kernel/cpufeature.c +++ b/arch/riscv/kernel/cpufeature.c @@ -222,6 +222,7 @@ void __init riscv_fill_hwcap(void) } else { /* sorted alphabetically */ SET_ISA_EXT_MAP("sscofpmf", RISCV_ISA_EXT_SSCOFPMF); + SET_ISA_EXT_MAP("ssqosid", RISCV_ISA_EXT_SSQOSID); SET_ISA_EXT_MAP("sstc", RISCV_ISA_EXT_SSTC); SET_ISA_EXT_MAP("svinval", RISCV_ISA_EXT_SVINVAL); SET_ISA_EXT_MAP("svpbmt", RISCV_ISA_EXT_SVPBMT); From patchwork Wed Apr 19 11:10:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216660 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 053D8C77B75 for ; Wed, 19 Apr 2023 11:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=iTXJcKjHzgQEa0vuzTcZlh2ukHh/MAQwooXjEJ5g6Gc=; b=yyKylDW06rEJZA HYMpIq0nJ4Z0GuNNIqnXIIdcwl5l/NAMRP4INFn3OATXGSWsx79IGw/eRvNCQum1IiYatkUMkU7mq rLGRByqQmkwZPeJd3ipTNOJTmaGwbjgQIsGEiuy0SUXGMXgrsj008i49JR5BZqbzDIvjnw8YM3ms6 3RZQuplz7aiJAYM0uY5mrBpbQ4RAZy8BBZpL4VVktnf4IriZ83MC7jegDsiGD6EddKNbg4LwYTWoS /T1Eja3ehaJ7OXdlFgATeGBhDQveeHrzDMpXatIhmUKYOGqyzVDMhzQacIMLHT4iuJYW7u4NeCicl Ql3Wd+nzckD9J1lsC9sA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hb-00588C-1M; Wed, 19 Apr 2023 11:10:19 +0000 Received: from mail-pl1-x636.google.com ([2607:f8b0:4864:20::636]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hW-00584g-0t for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:16 +0000 Received: by mail-pl1-x636.google.com with SMTP id d9443c01a7336-1a66b9bd893so26431035ad.1 for ; Wed, 19 Apr 2023 04:10:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902611; x=1684494611; 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=s9eEO9ZSQHehmRVwlaaNhzbm/IQf1ILPfvFx8ATSlnk=; b=nM88pRf/8GbdydpA0PP59ZJw6KWtk+CReKDnuabgXXMLywUgP8jhNzJYgb+cjDguai OwcZks3oek4D8CauNV//M+GGG84t9v8BrXspxTYPgj7NoYmjKUFElRaaahMEE0bo6GAZ FtdkgabxoZkOMQNnXOB3g9hc4yKmhsOxhjccntE7GQ7MO7BlGELiFMFHqVKcxoxYa+D/ UGrVjOBB/J4w3p2eo9fxlnm9kLTKgC25ESbticBubAHIxpm4o0/6AyM2fj10z3HC7k8p kORWjTcvG2LSfK/BXCcK7QTGjUOLUeviuj3O4CtyJ2TPGJzX7UHGVgZ0baILjf5rs3jp kBUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902611; x=1684494611; 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=s9eEO9ZSQHehmRVwlaaNhzbm/IQf1ILPfvFx8ATSlnk=; b=R28CbXejK3+Bq7Rkj7PbVmbXOQ2sM4gU6L+6zeKNM+PIO6b3FjiOLoaWaPZmoPgbFW M/5GbyxuInnL/Eh97V9xUjhHnHrV3dSqCRJtI6RjYCU79Z+sXhckt7pU7WmfP2S68S7d w/h4pF4uKlfbwS2uB5+CCXW679ZKzrsJaiGZZ3xRJ2BFPabr6N7zlVokk7p4LJktlOty VQlFbEWbY9xsimdOcB0qxN/06pRXC8kDzL7jQXYq8ROFpqfZffX/ETDth/hr7SUWavrQ prIUfwAm0iKKJmyBJK/wbfHt2Ery/UTuqvlmxYZrCAuIB0JStCixyV1jXjNz2SLVYn4G BVmw== X-Gm-Message-State: AAQBX9frhL7AyiPub3XYj/jZ5o2SeAuVnAtBy3AhKgw/jxhs71/0FN7+ bFRrWNMxcrH5QNaiRwMPTl9nmsoslWGnnmuQWLo= X-Google-Smtp-Source: AKy350bhv5stQ0WnqrTJGtJwB7abMIt3eVgi0yKf8TCk3qK2vODWs8w+pscnRiChOTW/REaSB/AhWA== X-Received: by 2002:a17:902:e847:b0:1a4:ee94:a79c with SMTP id t7-20020a170902e84700b001a4ee94a79cmr5668813plg.14.1681902611548; Wed, 19 Apr 2023 04:10:11 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:09 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 02/21] RISC-V: Add support for sqoscfg CSR Date: Wed, 19 Apr 2023 04:10:52 -0700 Message-Id: <20230419111111.477118-3-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041014_321974_1F8D07FF X-CRM114-Status: GOOD ( 28.19 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add support for the sqoscfg CSR defined in the Ssqosid ISA extension (Supervisor-mode Quality of Service ID). The CSR contains two fields: - Resource Control ID (RCID) used determine resource allocation - Monitoring Counter ID (MCID) used to track resource usage Requests from a hart to shared resources like cache will be tagged with these IDs. This allows the usage of shared resources to be associated with the task currently running on the hart. A sqoscfg field is added to thread_struct and has the same format as the sqoscfg CSR. This allows the scheduler to set the hart's sqoscfg CSR to contain the RCID and MCID for the task that is being scheduled in. The sqoscfg CSR is only written to if the thread_struct.sqoscfg is different than the current value of the CSR. A per-cpu variable cpu_sqoscfg is used to mirror that state of the CSR. This is because access to L1D hot memory should be several times faster than a CSR read. Also, in the case of virtualization, accesses to this CSR are trapped in the hypervisor. Link: https://github.com/riscv-non-isa/riscv-cbqri/blob/main/riscv-cbqri.pdf Co-developed-by: Kornel Dulęba Signed-off-by: Kornel Dulęba Signed-off-by: Drew Fustini --- Note: - A version of this patch rebased on riscv/for-next was already submitted as an RFC to linux-riscv [1] with Message-ID: 20230410043646.3138446-1-dfustini@baylibre.com - This patch is included in this RFC series so as to provide a cohesive demonstration in one series. [1] https://lore.kernel.org/lkml/20230410043646.3138446-1-dfustini@baylibre.com/ arch/riscv/Kconfig | 19 ++++++++++++++ arch/riscv/include/asm/csr.h | 8 ++++++ arch/riscv/include/asm/processor.h | 3 +++ arch/riscv/include/asm/qos.h | 40 ++++++++++++++++++++++++++++++ arch/riscv/include/asm/switch_to.h | 2 ++ 5 files changed, 72 insertions(+) create mode 100644 arch/riscv/include/asm/qos.h diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index c5e42cc37604..9d4c8c505191 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -398,6 +398,25 @@ config RISCV_ISA_C If you don't know what to do here, say Y. +config RISCV_ISA_SSQOSID + bool "Ssqosid extension support for supervisor mode Quality of Service ID" + default y + help + Adds support for the Ssqosid ISA extension (Supervisor-mode + Quality of Service ID). + + Ssqosid defines the sqoscfg CSR which allows the system to tag + the running process with RCID (Resource Control ID) and MCID + (Monitoring Counter ID). The RCID is used to determine resource + allocation. The MCID is used to track resource usage in event + counters. + + For example, a cache controller may use the RCID to apply a + cache partitioning scheme and use the MCID to track how much + cache a process, or a group of processes, is using. + + If you don't know what to do here, say Y. + config RISCV_ISA_SVPBMT bool "SVPBMT extension support" depends on 64BIT && MMU diff --git a/arch/riscv/include/asm/csr.h b/arch/riscv/include/asm/csr.h index 0e571f6483d9..ab222ca15799 100644 --- a/arch/riscv/include/asm/csr.h +++ b/arch/riscv/include/asm/csr.h @@ -60,6 +60,13 @@ #define SATP_ASID_MASK _AC(0xFFFF, UL) #endif +/* SQOSCFG fields */ +#define SQOSCFG_RCID_MASK _AC(0x00000FFF, UL) +#define SQOSCFG_MCID_MASK SQOSCFG_RCID_MASK +#define SQOSCFG_MCID_SHIFT 16 +#define SQOSCFG_MASK ((SQOSCFG_MCID_MASK << SQOSCFG_MCID_SHIFT) | \ + SQOSCFG_RCID_MASK) + /* Exception cause high bit - is an interrupt if set */ #define CAUSE_IRQ_FLAG (_AC(1, UL) << (__riscv_xlen - 1)) @@ -246,6 +253,7 @@ #define CSR_STVAL 0x143 #define CSR_SIP 0x144 #define CSR_SATP 0x180 +#define CSR_SQOSCFG 0x181 #define CSR_STIMECMP 0x14D #define CSR_STIMECMPH 0x15D diff --git a/arch/riscv/include/asm/processor.h b/arch/riscv/include/asm/processor.h index 94a0590c6971..724b2aa2732d 100644 --- a/arch/riscv/include/asm/processor.h +++ b/arch/riscv/include/asm/processor.h @@ -39,6 +39,9 @@ struct thread_struct { unsigned long s[12]; /* s[0]: frame pointer */ struct __riscv_d_ext_state fstate; unsigned long bad_cause; +#ifdef CONFIG_RISCV_ISA_SSQOSID + u32 sqoscfg; +#endif }; /* Whitelist the fstate from the task_struct for hardened usercopy */ diff --git a/arch/riscv/include/asm/qos.h b/arch/riscv/include/asm/qos.h new file mode 100644 index 000000000000..297e7fb64d80 --- /dev/null +++ b/arch/riscv/include/asm/qos.h @@ -0,0 +1,40 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_RISCV_QOS_H +#define _ASM_RISCV_QOS_H + +#ifdef CONFIG_RISCV_ISA_SSQOSID + +#include +#include + +#include +#include +#include + +/* cached value of sqoscfg csr for each cpu */ +static DEFINE_PER_CPU(u32, cpu_sqoscfg); + +static void __qos_sched_in(struct task_struct *task) +{ + u32 *cpu_sqoscfg_ptr = this_cpu_ptr(&cpu_sqoscfg); + u32 thread_sqoscfg; + + thread_sqoscfg = READ_ONCE(task->thread.sqoscfg); + + if (thread_sqoscfg != *cpu_sqoscfg_ptr) { + *cpu_sqoscfg_ptr = thread_sqoscfg; + csr_write(CSR_SQOSCFG, thread_sqoscfg); + } +} + +static inline void qos_sched_in(struct task_struct *task) +{ + if (riscv_has_extension_likely(RISCV_ISA_EXT_SSQOSID)) + __qos_sched_in(task); +} +#else + +static inline void qos_sched_in(struct task_struct *task) {} + +#endif /* CONFIG_RISCV_ISA_SSQOSID */ +#endif /* _ASM_RISCV_QOS_H */ diff --git a/arch/riscv/include/asm/switch_to.h b/arch/riscv/include/asm/switch_to.h index 60f8ca01d36e..75d9bfd766af 100644 --- a/arch/riscv/include/asm/switch_to.h +++ b/arch/riscv/include/asm/switch_to.h @@ -12,6 +12,7 @@ #include #include #include +#include #ifdef CONFIG_FPU extern void __fstate_save(struct task_struct *save_to); @@ -79,6 +80,7 @@ do { \ if (has_fpu()) \ __switch_to_aux(__prev, __next); \ ((last) = __switch_to(__prev, __next)); \ + qos_sched_in(__next); \ } while (0) #endif /* _ASM_RISCV_SWITCH_TO_H */ From patchwork Wed Apr 19 11:10:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216661 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2B5E0C77B7C for ; Wed, 19 Apr 2023 11:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=tpcs7FbksCsExAsMiZd6ywj5zNrvPGP4Qq/v5mcfudY=; b=yz6xRQe/W9uIVA MD15jyenhfo8LbietIrbWOucVaoDV7erthas8MA74CAPyVyvS0kreFO5Vw/dFNAoC4S6ZzXzTDack 7QQOrqJsnqlCkF1M6fC0tsk2iA21bAElvXbwQF7Pj8Urd8ZXiooSJ5Riyit3Gj3TAnHbhVYIl2/ld mlFssDKU4mw3OWdjkyFdtoWpFziooEctWdTirzWAVfobih7gQvGAyYk/bP2WVFh21PlPENllPLhJk JYJgCz+FyLewQFFq91YDQLhgGlhgY4vD6QgzTY41W5T4JbxLxCeEB/ikW/CFy5A+9iZFJeetqXUWb FN6k9lU52zckP7uuW9Bw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hc-00588u-0e; Wed, 19 Apr 2023 11:10:20 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hY-00584t-02 for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:17 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1a69f686345so20889125ad.2 for ; Wed, 19 Apr 2023 04:10:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902614; x=1684494614; 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=iSeKxrM1bks+EefhwDp2KyUEcfeaeDF9wQYuIpi9EW0=; b=49f1VRB4kGVGgl4N0u5BK8ILp9SHeHM+SfTX6b8+b51pY3zpNaPJ1K5jK6EgtzX3Y+ kgWIGu6FPEKFP21/XhNG9ezgg8K2EDcY4BsaH8hKcEgdKBEuXmWAnn7TXhj2pKL8Q80X gsM5BK6Q5MzRmp5iQrFFtt4800JiQbPBCGAiDimIVHwL4tXsJ0gdBDYT/3nSwEGUZcEh WGOPTVgisYyoEj1/vrQ8+Yu0qA+ueJ9JN+d6q3LauLhlb+RVvV1B/ctylOExID/3S9N4 IS3ZV6k4Wca8TNpiWs7+F0/PMjynSVx4U5joLQeEYF/fIm9t9xc4G8+hr0OJ8DDfaRLN aWZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902614; x=1684494614; 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=iSeKxrM1bks+EefhwDp2KyUEcfeaeDF9wQYuIpi9EW0=; b=CpyAfSnEf5TWSsZzZUkdpVwcmbM833HPhP0G8u/ksaJ7SZEtTXyej00cS5d4T8n+wT AzeLrr+Sho7GrgJ56evJFmWS1nG4wQQ3h1aS/Rm2pdlTE6/3vKI6ztObtMd5Vi+EMOQt usyeduCzOkleEhvHktlSyD+4dy491uZtmW6exg0b/yGLWq4GZvYhaWhaOWwy1IBfOvb5 pyYx1gEyjMpi+B+ZemKqpE1uCUoIYbrtzcALhYEaTUDb4ik0z1ebnEFi9RlC9J+91ZNt GgjCzpV10dJvrpPayYvmbk+3n4lWGhsNNdM9QU3S1WzFsVcm0rYdTpi+cEU/V5cQaj2F ShOw== X-Gm-Message-State: AAQBX9fbXuBO9e37ranKS0dkCN52rS4wz8Feb4lXYoV510Dc+0LHL/wX V7lUFj8TH6f9JMv8a2r6FriDAm0uPYOymK2bE/4= X-Google-Smtp-Source: AKy350YXwjwRD1sLQ1B+t50/t+W8RZ+WsFbplLKM9L7G1ogdxUChyw8fsx9ITeD7FpbPkTpMpgzC+Q== X-Received: by 2002:a17:902:8d98:b0:1a6:ee5a:7208 with SMTP id v24-20020a1709028d9800b001a6ee5a7208mr4745154plo.18.1681902613761; Wed, 19 Apr 2023 04:10:13 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:12 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 03/21] RISC-V: QoS: define properties of CBQRI controllers Date: Wed, 19 Apr 2023 04:10:53 -0700 Message-Id: <20230419111111.477118-4-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041016_050295_5B95AFCE X-CRM114-Status: GOOD ( 13.64 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Define data structure to represent the CBQRI properties that a driver for an CBQRI-capable controller would discover during probe. Each instance of a CBQRI-capable controller is added to a list that the RISC-V CBQRI resctrl implementation will consume. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- include/linux/riscv_qos.h | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 include/linux/riscv_qos.h diff --git a/include/linux/riscv_qos.h b/include/linux/riscv_qos.h new file mode 100644 index 000000000000..95016810b575 --- /dev/null +++ b/include/linux/riscv_qos.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ + +#ifndef __LINUX_RISCV_QOS_H +#define __LINUX_RISCV_QOS_H + +#include +#include + +#include + +enum cbqri_controller_type { + CBQRI_CONTROLLER_TYPE_CAPACITY, + CBQRI_CONTROLLER_TYPE_BANDWIDTH, + CBQRI_CONTROLLER_TYPE_UNKNOWN +}; + +struct cbqri_controller_info { + unsigned long addr; + unsigned long size; + enum cbqri_controller_type type; + u32 rcid_count; + u32 mcid_count; + struct list_head list; + + struct cache_controller { + int cache_level; + u32 cache_size; /* in bytes */ + struct cpumask cpu_mask; + } cache; +}; + +extern struct list_head cbqri_controllers; + +#endif /* __LINUX_RISCV_QOS_H */ From patchwork Wed Apr 19 11:10:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216664 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BFC76C77B7F for ; Wed, 19 Apr 2023 11:10:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PqQo6ay7BDwMQe8wzWlIc/llKRmD5G1PPQDp9Va5TJI=; b=HeuvxmDyPuyAqy 4OrPdVINRyqwmSJ1mB2h1AmkYm3KLxivYM+iDnLTku9IUJp08BroCEztRKcbxGlQzpkQf3k1s/vTj zhQD6UM1Waxiqxfa7cxUbHwOFYFgmcOeU8PUagKiIUyAX53/W6JQkrOKujb9+kImA3TXXqarByuJF fUplmsRIDude4isw6WLAph4CjZPBrWdgncmcquFqmqcGqLFzoKLrSgSk5HTE9v+VRCP3ChX61OrsH AcspcsxO33JujBiM74t82lH5wiWlG+HQyJiuNLRCsXCwO2eVKBy/I6Igp5NyM91ebHsQuvInxlt7z CVCJddTCvMSabvwrO/Xw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hd-00589i-31; Wed, 19 Apr 2023 11:10:21 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5ha-00585b-1k for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:20 +0000 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-63d4595d60fso6106595b3a.0 for ; Wed, 19 Apr 2023 04:10:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902615; x=1684494615; 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=g1OkcmhU53RbhkMQs1OOfT4IMIpFMn/hvoMN7xVvdpQ=; b=tOvJ2jomn2lCN7CzbmQxXUPM+RMt5nQnovetT4UyRyBVZdKUWLTslytcs5Fijiw4IH nco6zem+f6UyYuypUHPg1WuTBPSd2/yCDcny+7RkWgqWQf6nzPkIwbw/3Dt98SE9CPvL bDcp7NZayY/ZA69jSqsfc5HVI4qcdaRTuNSY2IFurnSljwY1lMjPIXSf+3T0aiTV0o5r 4n5tZ0OdGGQ6duEP5C7OqQB1lM5CkTP6CiCPoKhWB6nO4I8xW1GzxZZjbtm3NM74MCNo Zk0F+k0cZbSeF6eMPaV4vRVlNYRwLkB1D4SHSNlgs8uFm8QORgJqfpI2wKA4eOUjwUOU WNFw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902615; x=1684494615; 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=g1OkcmhU53RbhkMQs1OOfT4IMIpFMn/hvoMN7xVvdpQ=; b=WI+J1loUgUd6NiP6amHgeHf+o5ogkx/Wa933hEUdZUeGWXPIVXLiZ2I3DMR077F6pm m/5CCePBnQpfYGKxs3vi2ltNF+fyp5EgEMr77JpU+kn2LuRDRGN2kFby4/NmF3luwSJ6 YvBlDrc5BKta85jo/M+91TyjNajV92rqmhbLTskNg3qi4eMKVwaambzLd4H0kewasoNm 2FHxIikOkw4XMKRVYZaJD1XhJ+WlXO0YQVgQrhWRiCyl4sxj1kmp6KSklanpfW27GXbC R0cOwOpfBAobHqz2LOfeUnMQCoSVZLGprKc+SuXYTszgaAwHPVaqRFUgC9KRiQPPlYY2 Kniw== X-Gm-Message-State: AAQBX9dh7bmXCBeSW+1bUntwLjpyjUl0SCkfPK80+DEp5AIN2HSDw7wb iaoOvF8BpxukQUdh601JIotkr/Kvt9bFRUe9Kb4= X-Google-Smtp-Source: AKy350aNbAzQPxeM67oYUfXFpZ0iKay8dELpBUn0YBN78d+E7FjUtYnNE1XfqtnYpe6qJVX9PR/weg== X-Received: by 2002:a17:903:26c9:b0:1a2:7462:d674 with SMTP id jg9-20020a17090326c900b001a27462d674mr1959521plb.24.1681902615276; Wed, 19 Apr 2023 04:10:15 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:14 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 04/21] RISC-V: QoS: define CBQRI capacity and bandwidth capabilities Date: Wed, 19 Apr 2023 04:10:54 -0700 Message-Id: <20230419111111.477118-5-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041018_576530_CEA8E4CA X-CRM114-Status: GOOD ( 13.20 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Define data structures to store the capacity and bandwidth capabilities that are discovered for a CBQRI-capable controller. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- arch/riscv/kernel/qos/internal.h | 130 +++++++++++++++++++++++++++++++ 1 file changed, 130 insertions(+) create mode 100644 arch/riscv/kernel/qos/internal.h diff --git a/arch/riscv/kernel/qos/internal.h b/arch/riscv/kernel/qos/internal.h new file mode 100644 index 000000000000..e07d7f92e206 --- /dev/null +++ b/arch/riscv/kernel/qos/internal.h @@ -0,0 +1,130 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef _ASM_RISCV_QOS_INTERNAL_H +#define _ASM_RISCV_QOS_INTERNAL_H + +#include + +#define CBQRI_CC_CAPABILITIES_OFF 0 +#define CBQRI_CC_MON_CTL_OFF 8 +#define CBQRI_CC_MON_CTL_VAL_OFF 16 +#define CBQRI_CC_ALLOC_CTL_OFF 24 +#define CBQRI_CC_BLOCK_MASK_OFF 32 + +#define CBQRI_BC_CAPABILITIES_OFF 0 +#define CBQRI_BC_MON_CTL_OFF 8 +#define CBQRI_BC_MON_CTR_VAL_OFF 16 +#define CBQRI_BC_ALLOC_CTL_OFF 24 +#define CBQRI_BC_BW_ALLOC_OFF 32 + +#define CBQRI_CC_CAPABILITIES_VER_MINOR_MASK GENMASK(3, 0) +#define CBQRI_CC_CAPABILITIES_VER_MAJOR_MASK GENMASK(7, 4) + +#define CBQRI_CC_CAPABILITIES_FRCID_MASK 0x1 +#define CBQRI_CC_CAPABILITIES_FRCID_SHIFT 24 + +#define CBQRI_CC_CAPABILITIES_NCBLKS_SHIFT 8 +#define CBQRI_CC_CAPABILITIES_NCBLKS_MASK 0xFFFF + +#define CBQRI_BC_CAPABILITIES_VER_MINOR_MASK GENMASK(3, 0) +#define CBQRI_BC_CAPABILITIES_VER_MAJOR_MASK GENMASK(7, 4) + +#define CBQRI_BC_CAPABILITIES_NBWBLKS_SHIFT 8 +#define CBQRI_BC_CAPABILITIES_NBWBLKS_MASK 0xFFFF +#define CBQRI_BC_CAPABILITIES_MRBWB_SHIFT 32 +#define CBQRI_BC_CAPABILITIES_MRBWB_MASK 0xFFFF + +#define CBQRI_CONTROL_REGISTERS_BUSY_SHIFT 39 +#define CBQRI_CONTROL_REGISTERS_BUSY_MASK 0x01 +#define CBQRI_CONTROL_REGISTERS_STATUS_SHIFT 32 +#define CBQRI_CONTROL_REGISTERS_STATUS_MASK 0x7F +#define CBQRI_CONTROL_REGISTERS_OP_SHIFT 0 +#define CBQRI_CONTROL_REGISTERS_OP_MASK 0x1F +#define CBQRI_CONTROL_REGISTERS_AT_SHIFT 5 +#define CBQRI_CONTROL_REGISTERS_AT_MASK 0x07 +#define CBQRI_CONTROL_REGISTERS_AT_DATA 0 +#define CBQRI_CONTROL_REGISTERS_AT_CODE 1 +#define CBQRI_CONTROL_REGISTERS_RCID_SHIFT 8 +#define CBQRI_CONTROL_REGISTERS_RCID_MASK 0xFFF +#define CBQRI_CONTROL_REGISTERS_RBWB_SHIFT 0 +#define CBQRI_CONTROL_REGISTERS_RBWB_MASK 0xFF + +#define CBQRI_CC_MON_CTL_OP_CONFIG_EVENT 1 +#define CBQRI_CC_MON_CTL_OP_READ_COUNTER 2 +#define CBQRI_CC_MON_CTL_STATUS_SUCCESS 1 + +#define CBQRI_CC_ALLOC_CTL_OP_CONFIG_LIMIT 1 +#define CBQRI_CC_ALLOC_CTL_OP_READ_LIMIT 2 +#define CBQRI_CC_ALLOC_CTL_OP_FLUSH_RCID 3 +#define CBQRI_CC_ALLOC_CTL_STATUS_SUCCESS 1 + +#define CBQRI_BC_MON_CTL_OP_CONFIG_EVENT 1 +#define CBQRI_BC_MON_CTL_OP_READ_COUNTER 2 +#define CBQRI_BC_MON_CTL_STATUS_SUCCESS 1 + +#define CBQRI_BC_ALLOC_CTL_OP_CONFIG_LIMIT 1 +#define CBQRI_BC_ALLOC_CTL_OP_READ_LIMIT 2 +#define CBQRI_BC_ALLOC_CTL_STATUS_SUCCESS 1 + +/* Capacity Controller hardware capabilities */ +/* from qemu/include/hw/riscv/cbqri.h */ +struct riscv_cbqri_capacity_caps { + u16 ncblks; + u16 cache_level; + u32 blk_size; + + bool supports_alloc_at_data; + bool supports_alloc_at_code; + + bool supports_alloc_op_config_limit; + bool supports_alloc_op_read_limit; + bool supports_alloc_op_flush_rcid; + + bool supports_mon_at_data; + bool supports_mon_at_code; + + bool supports_mon_op_config_event; + bool supports_mon_op_read_counter; + + bool supports_mon_evt_id_none; + bool supports_mon_evt_id_occupancy; +}; + +/* Bandwidth Controller hardware capabilities */ +/* from qemu/include/hw/riscv/cbqri.h */ +struct riscv_cbqri_bandwidth_caps { + u16 nbwblks; /* number of bandwidth block */ + u16 mrbwb; /* max reserved bw blocks */ + + bool supports_alloc_at_data; + bool supports_alloc_at_code; + + bool supports_alloc_op_config_limit; + bool supports_alloc_op_read_limit; + + bool supports_mon_at_data; + bool supports_mon_at_code; + + bool supports_mon_op_config_event; + bool supports_mon_op_read_counter; + + bool supports_mon_evt_id_none; + bool supports_mon_evt_id_rdwr_count; + bool supports_mon_evt_id_rdonly_count; + bool supports_mon_evt_id_wronly_count; +}; + +struct cbqri_controller { + struct cbqri_controller_info *ctrl_info; + void __iomem *base; + + int ver_major; + int ver_minor; + + struct riscv_cbqri_bandwidth_caps bc; + struct riscv_cbqri_capacity_caps cc; + + bool alloc_capable; + bool mon_capable; +}; + +#endif /* _ASM_RISCV_QOS_INTERNAL_H */ From patchwork Wed Apr 19 11:10:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216663 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1D80BC77B7E for ; Wed, 19 Apr 2023 11:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=ZprFIVTFx7vo5oQnU8sGej6WL9Xgkaz2/FCM47Lv3pY=; b=aMXlwnFNFFBZLi HgUwxSaBcMRhM7kjgcdlP59RJi0TZ2x40vdpFPS9k/m98X3eBNspAtz6wOeY20IVeek+v9QUN/w65 POGEKOsr/rQLskbsVP7RNtfcUq+0Pl1qH/q0ItVmDDcEs9yqCEdzDwu6u7W89aS8USZguFazcKkF3 WXLrf8b1V8efcqfKCiHMB/0XaVW5exiZ9akT3HEMWiBRlaAE710r4+8tRVi8kXUXwQiqRNobxzM9H ND7zpF1unKAnV03RfIC/8lG2MhmbAhq3t0GR6XI4vldLgfTSTXHoWer5daoae+aW7qE/tV2rPGVTq AeFNNpDgEsBAtq57nh8w==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp5he-0058A3-1P; Wed, 19 Apr 2023 11:10:22 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5ha-00586k-2f for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:20 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-63b50a02bffso2732397b3a.2 for ; Wed, 19 Apr 2023 04:10:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902617; x=1684494617; 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=XmVkd/UrXriHJHxvxxsPlqAajEG3FYZbywzFeJQXIHk=; b=zPbQZG9UKwm7GRyIqZChI5pPpnjrvhb8Q5Cx0LVS9GCn0om8iAHe+VSMXHgYhN4iIE 8hHCqRn6dwTm2nsiT9GilKXMZ1FCN5xuGY6ikI9a3/jb7VDcGrJSy6OtfIdK3QlW6N6+ RxvuxkbB2fpmlt3qaEEq/XF6YsyaBgL3a3uLDu9C3fO+5Ry3wbbsbycb9tLDG71pLFqj 6Ph52NPqQie9WLd/4O6LUZjHBRNlMGRcO41aMzbPqSyM/UYae08hx6DIu6+5KiIvg/BL iP1p9QGFXCiDa/ohQY7K8Ow0ju7miafcpNFTqcaScbcUWUl3Y1ontHOlSlMSlZHcrBr2 V3aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902617; x=1684494617; 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=XmVkd/UrXriHJHxvxxsPlqAajEG3FYZbywzFeJQXIHk=; b=QmnwxGEPriPfX9uzodCzLqpw9twWREfX4QqFzZbUM5W+FxMVdOWPOzuSibBL/HY2z8 CGXDeoMZY77E5ZzLuXYuF8ZL2XJMBwjCKnZfE5dqMe71CI1JhsXIbQGX3XY0dbiGpcmN 3jyCCwIDW99pqr725wiCE/Ya89Q7dmGROEdnHZIy/SAlvQVbRpMM08GWTzexHYxqx1M4 9fcXZuiRwJBY0SjTvizrV4VV1k0tdLHysocPSMupLr3VeSJvFLChI5LeTLOy0QiwxHHf GKNDNndQ12YRoVDKNV9YsX6J4lok/fwhGMdT9RIkAb5nMSw2f/PceqR9BC4AexjJSf36 q6pA== X-Gm-Message-State: AAQBX9fDpRw0WeEJFOJFlOoOvpFWQUsiDIw5aTkvYODWKw+nQk+nyQin a4KTUo0cHMAJMa4aBLiDUN9Pvol2pG5aC/xBcMo= X-Google-Smtp-Source: AKy350Zyw3Ulaxp08aBwcGKciKhzrEtrdld4xIv32oyd3Jnf/nHEuPYG4H87WQ56JWkt1m7BYEv28Q== X-Received: by 2002:a17:902:c941:b0:1a6:387a:6572 with SMTP id i1-20020a170902c94100b001a6387a6572mr6089976pla.13.1681902616795; Wed, 19 Apr 2023 04:10:16 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:16 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 05/21] RISC-V: QoS: define prototypes for resctrl interface Date: Wed, 19 Apr 2023 04:10:55 -0700 Message-Id: <20230419111111.477118-6-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041018_877100_48466ED6 X-CRM114-Status: GOOD ( 12.98 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Define the prototypes for the resctrl interface functions that are implemented on RISC-V. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- include/linux/riscv_qos.h | 58 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/include/linux/riscv_qos.h b/include/linux/riscv_qos.h index 95016810b575..537e503a8e99 100644 --- a/include/linux/riscv_qos.h +++ b/include/linux/riscv_qos.h @@ -3,6 +3,7 @@ #ifndef __LINUX_RISCV_QOS_H #define __LINUX_RISCV_QOS_H +#include #include #include @@ -31,4 +32,61 @@ struct cbqri_controller_info { extern struct list_head cbqri_controllers; +bool resctrl_arch_alloc_capable(void); +bool resctrl_arch_mon_capable(void); +bool resctrl_arch_is_llc_occupancy_enabled(void); +bool resctrl_arch_is_mbm_local_enabled(void); +bool resctrl_arch_is_mbm_total_enabled(void); + +struct rdt_resource; +/* + * Note about terminology between x86 (Intel RDT/AMD QoS) and RISC-V: + * CLOSID on x86 is RCID on RISC-V + * RMID on x86 is MCID on RISC-V + * CDP on x86 is AT (access type) on RISC-V + */ +bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level ignored); +bool resctrl_arch_match_closid(struct task_struct *tsk, u32 closid); +bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid); +int resctrl_arch_mon_ctx_alloc_no_wait(struct rdt_resource *r, int evtid); +void resctrl_arch_mon_ctx_free(struct rdt_resource *r, int evtid, int ctx); +void resctrl_arch_reset_resources(void); +void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 *rmid); +u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid); +int resctrl_arch_set_cdp_enabled(enum resctrl_res_level ignored, bool enable); +void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid); +void resctrl_arch_set_cpu_default_closid(int cpu, u32 closid); +void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 pmg); +u32 resctrl_arch_system_num_rmid_idx(void); +void resctrl_sched_in(void); + +static inline bool resctrl_arch_event_is_free_running(enum resctrl_event_id evt) +{ + /* must be true for resctrl L3 monitoring files to be created */ + return true; +} + +static inline unsigned int resctrl_arch_round_mon_val(unsigned int val) +{ + return val; +} + +/* Pseudo lock is not supported on RISC-V */ +static inline int resctrl_arch_pseudo_lock_fn(void *_plr) { return 0; } +static inline int resctrl_arch_measure_l2_residency(void *_plr) { return 0; } +static inline int resctrl_arch_measure_l3_residency(void *_plr) { return 0; } +static inline int resctrl_arch_measure_cycles_lat_fn(void *_plr) { return 0; } +static inline u64 resctrl_arch_get_prefetch_disable_bits(void) { return 0; } + +/* Not needed for RISC-V */ +bool resctrl_arch_match_iommu_closid(struct iommu_group *group, u32 closid); +bool resctrl_arch_match_iommu_closid_rmid(struct iommu_group *group, u32 closid, u32 rmid); +int resctrl_arch_set_iommu_closid_rmid(struct iommu_group *group, u32 closid, u32 rmid); + +/* Not needed for RISC-V */ +static inline void resctrl_arch_enable_mon(void) { } +static inline void resctrl_arch_disable_mon(void) { } +static inline void resctrl_arch_enable_alloc(void) { } +static inline void resctrl_arch_disable_alloc(void) { } + #endif /* __LINUX_RISCV_QOS_H */ From patchwork Wed Apr 19 11:10:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216662 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 67711C7EE20 for ; Wed, 19 Apr 2023 11:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=mQi6bs1ZZsGr2pYeMxARhsqmJl/cl8Y6iGRvf7Y3geg=; b=IRVDasuaWOcSFy k9xFRzvU6VjLGE9tqHafjcJQ1oQI2SgAXOEmqh/AqOSF/hM4ncJSh11frE+IYlpl3UIuhWDhGD/Eu cqPfwlTBzM/RkXr4+l/jDEwmcnfJDQfQ0FVqAw1DWY5lZ3pYCabUdSDgto5p2Ga9XE+F846EqYI5R RrRdqAMMuy6SMaMLu8NB8WzFtg1Bmi77yAs5jJVMPCwb6CeDDxeQ8iod5iplpfu5doaV7+4Kmk1jF aJeoJfzgKuGk+opajrKHXMuE7kmb+kj2O9/SkDXyK0sXbqrlTPOekc8Xg4UVDXFt6zVWOq0dmxgrL 0FejUuinH3ZhFh7jw+6g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hf-0058Ab-06; Wed, 19 Apr 2023 11:10:23 +0000 Received: from mail-pl1-x62b.google.com ([2607:f8b0:4864:20::62b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hb-005882-1W for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:21 +0000 Received: by mail-pl1-x62b.google.com with SMTP id d9443c01a7336-1a52667955dso35500515ad.1 for ; Wed, 19 Apr 2023 04:10:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902618; x=1684494618; 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=erF7h0FFrrflFOP1De39iTiQwqZxcNsKEc8OIQm5UJM=; b=wz3bVzECh81V9P/8eSWWBlXF/ppb7Eo6YzU8zyukUtrt3VzZ0IEpHBtlfje9DVEk8A WgQ43IxHuPg5JxpS+AeX0+JDT9BXNewP9GBxLEbdYftK7bLLCUGMUBxE7QFEhweo+hXs ikPvUAgfl+FTTZIHdjmvg1mvLBoejr44HJSj8MVhg6jkkNQb0V/xq7HvECgQM+xvxg07 /rhj2VeNHkSdv02dw84Cnm0BPWlGc4/tYeOszJHSqvjMvIJoOYvVzIpUznLiSKPl9ow8 IW5VIWbPwZJgWUbhYU2YozHm+nuM/R3jyKv8aDekyuNVAe3ivBaYboWEbeNyyV528ZgP kQ1A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902618; x=1684494618; 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=erF7h0FFrrflFOP1De39iTiQwqZxcNsKEc8OIQm5UJM=; b=IoO86J57w7i+PHVqDNagA9+Kp2ZKyZiSD0ezcwcZXa8VsyEvv1sUSyLT0+QHenO83p ulEAF+DeSy/EV/TuXd5LOH8TX6PRmKKPxYatFN5QNmdGHWTtlnkHQostG+a4/2BNxJXP 0iLu+D9r/GRaEhJmLq0YGheneIZIybsraMhwoZEXuWPdGDdXo8q8nwbY9pPUDz07Vhv/ crlzt/pzoXu3sX2zQJYz4kOv+v7A0DRkFLkTt2g1p81CWQGMQCNsZRbjk0hmFL6sg1nb 5q1U/vecJt1avFk9VnFsFJVGBgm6ganSrlrSNzu0qtmQyIpISrOzTvIbTyT/tOZimILv hG2g== X-Gm-Message-State: AAQBX9fNp6NeUx27igZ4fWjYuxZDuphYH14I0B948AtrFYzttRVri2MH aPXgxhKqfFXEOgSBnZS0nLFEOxhvre0DEjRDiJw= X-Google-Smtp-Source: AKy350ZRSZ8md3xymsWabEgKJyV9SXGwr0uyWNsabbIVXDib5OEDsFleXNsdFcITKR6mAw9AfBngJw== X-Received: by 2002:a17:903:41c2:b0:1a8:106c:4a1a with SMTP id u2-20020a17090341c200b001a8106c4a1amr3748412ple.1.1681902618470; Wed, 19 Apr 2023 04:10:18 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:17 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 06/21] RISC-V: QoS: define CBQRI resctrl resources and domains Date: Wed, 19 Apr 2023 04:10:56 -0700 Message-Id: <20230419111111.477118-7-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041019_520130_78E1A741 X-CRM114-Status: GOOD ( 11.59 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Define data structures to encapsulate the resctrl resource and domain structures. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- arch/riscv/kernel/qos/internal.h | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/arch/riscv/kernel/qos/internal.h b/arch/riscv/kernel/qos/internal.h index e07d7f92e206..a3ed98ce5dd6 100644 --- a/arch/riscv/kernel/qos/internal.h +++ b/arch/riscv/kernel/qos/internal.h @@ -65,6 +65,11 @@ #define CBQRI_BC_ALLOC_CTL_OP_READ_LIMIT 2 #define CBQRI_BC_ALLOC_CTL_STATUS_SUCCESS 1 +int qos_resctrl_setup(void); +void qos_resctrl_exit(void); +int qos_resctrl_online_cpu(unsigned int cpu); +int qos_resctrl_offline_cpu(unsigned int cpu); + /* Capacity Controller hardware capabilities */ /* from qemu/include/hw/riscv/cbqri.h */ struct riscv_cbqri_capacity_caps { @@ -127,4 +132,26 @@ struct cbqri_controller { bool mon_capable; }; +struct cbqri_resctrl_res { + struct rdt_resource resctrl_res; + struct cbqri_controller controller; + u32 max_rcid; + u32 max_mcid; +}; + +struct cbqri_resctrl_dom { + struct rdt_domain resctrl_dom; + // NCBLKS is 16 bit which is 2^16 = 65536 + // If each bit is a block, then cc_block_mask could 1024 times 64 byte + u64 cbm; + u64 rbwb; + u64 *ctrl_val; + struct cbqri_controller *hw_ctrl; +}; + +struct cbqri_config { + u64 cbm; /* capacity block mask */ + u64 rbwb; /* reserved bandwidth blocks */ +}; + #endif /* _ASM_RISCV_QOS_INTERNAL_H */ From patchwork Wed Apr 19 11:10:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216665 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 2F648C77B75 for ; Wed, 19 Apr 2023 11:10:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=bSbiNpzfKY0caEX9p59mjxNxdsW8b/Dr4y0yn6wxOqg=; b=tT+oDQwScuGoKg dVGqKXcCfl+y6H6qBHGmnh2uleHy3s3VAmucXW7d4gKvaBMnDinL+LMsxdl4fhD+/oA/khHvNTpp/ KMd4r2TMx1zo0aVuc7W8+g+vy5WzKKkLGrstopBsbJXDkgTQZxMeqNnvK6ljQhJDM1guvY7cRctvg +YCXSjrNaJ+Og2Ds7phximYEbHimSdu4abkLcCj51MBU6vev44dg85ccisQ+9ryW+L9kYJyeQs7ug CBcT+wCSpITYuoIhxh9GwVL11TJlq+SX/Ijw83f2e0brJa3dmdsr/u/cEUhx/hU7PRdqLL+gUxYwt i9AK49/9+1yRI4CEq6wQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hk-0058ET-2V; Wed, 19 Apr 2023 11:10:28 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hf-00589W-1t for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:27 +0000 Received: by mail-pj1-x1031.google.com with SMTP id 98e67ed59e1d1-246f856d751so2176109a91.0 for ; Wed, 19 Apr 2023 04:10:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902620; x=1684494620; 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=wRqDYjVwLNTwFZ6eNRmIXekZ/lW+bncYt6+OIKBCY18=; b=AMhaf7SUiRzLmkSyVSEAP9V8LSH4NK1HWqoH4fU5X6n+5OlFnW1RMbq/UNlr9qxVDU yQHpexaxYJHaFQjbY5D7inckZTfB8fRNt1qVkHZGphd+zJ1448Lzm/JbffD84cnJS2ME 4FkcT2cxgbDMIQHPn49fMRyWYDy/HWUZMxrOGSqRHpBaD6iQlAvr9AEmB9VltUpeRv1n D6yQfDGFkXT+DLBtQ3/CxjB8W+soWe3eEYzejQ5e7WsEizDZhClU3bbldHULe+fQ8fPR 13ZOvzMhL9UyP6+GxT/KWMysBoUI56YnqdvBJ1/RLmAGpn/d1449aoQvH8GkY4nVhxgW 4mgw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902620; x=1684494620; 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=wRqDYjVwLNTwFZ6eNRmIXekZ/lW+bncYt6+OIKBCY18=; b=e339zNF5YuMYDlZYCl/Ot8nKz5g9Y1kZrVEVYWSinTdpbJBeBKf+UCj7x+zXLHqXcX zvnTh+j/G0gEllQgisbmJNeCA9VdY2MUyYTc3KUlSMdhzQwdfxrLXzakFF4S2hyvAOUD RU4Oo3Z3/gzE3I9zpoSM26thJs0OwDJKg5h9f5jeo1MqKE8tqynQAP/3eCK2SWOcrtyJ Aa5DrSEbZ/jrsUJbr1Nfhvh+V34l/l+yaPLCQM6Exb5Ha9sZgV5k/a+fdH6ZMhAXpmNy s4MMGWa+Ii32Fs/HJz4TmCEfgKdIblOb7A8slO02ddRzFuCMXZvI0ecfLDQBIHBeymYx H0Vg== X-Gm-Message-State: AAQBX9fKQcRjY+ESztFjW3khT804INSijx6PLsV/pdN4g/5wfWP0ilku EwDlvCfF3rPbAV/ZTilyllEhUwrwEYtCimxIKc0= X-Google-Smtp-Source: AKy350aJTyyRzP/AjtxdcxE4LbMUmnBfAO+o3y7q7SIIW93BSjsMrJQkI2iPwQYMwFxAVnFm/ADUeA== X-Received: by 2002:a17:90a:ee86:b0:249:8963:c6b with SMTP id i6-20020a17090aee8600b0024989630c6bmr1471908pjz.18.1681902619937; Wed, 19 Apr 2023 04:10:19 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:19 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 07/21] RISC-V: QoS: add resctrl interface for CBQRI controllers Date: Wed, 19 Apr 2023 04:10:57 -0700 Message-Id: <20230419111111.477118-8-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041023_629137_99C7E5EE X-CRM114-Status: GOOD ( 25.26 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add interface for CBQRI controller drivers to make use of the resctrl filesystem. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- arch/riscv/kernel/qos/qos_resctrl.c | 1231 +++++++++++++++++++++++++++ 1 file changed, 1231 insertions(+) create mode 100644 arch/riscv/kernel/qos/qos_resctrl.c diff --git a/arch/riscv/kernel/qos/qos_resctrl.c b/arch/riscv/kernel/qos/qos_resctrl.c new file mode 100644 index 000000000000..f4116d9a9f04 --- /dev/null +++ b/arch/riscv/kernel/qos/qos_resctrl.c @@ -0,0 +1,1231 @@ +// SPDX-License-Identifier: GPL-2.0-only +// Copyright (C) 2023 Rivos Inc. + +#define pr_fmt(fmt) "qos: resctrl: " fmt + +#include +#include +#include +#include +#include +#include +#include +#include "internal.h" + +#define MAX_CONTROLLERS 6 +static struct cbqri_resctrl_res cbqri_resctrl_resources[RDT_NUM_RESOURCES]; +/* + * The size of the controllers array reflects that number of CBQRI controllers + * (3x capacity, 3x bandwidth) in the hypothetical SoC that Qemu implements for + * the CBQRI proof-of-concept. + * + * The proper solution will involve dynamically allocating cbqri_controller + * structures and adding them to a list of controllers. This avoids having to + * make assumptions about the system. + */ +static struct cbqri_controller controllers[MAX_CONTROLLERS]; +static int found_controllers; + +static bool exposed_alloc_capable; +static bool exposed_mon_capable; +/* CDP (code data prioritization) on x86 is AT (access type) on RISC-V */ +static bool exposed_cdp_l2_capable; +static bool exposed_cdp_l3_capable; +static bool is_cdp_l2_enabled; +static bool is_cdp_l3_enabled; + +/* used by resctrl_arch_system_num_rmid_idx() */ +static u32 max_rmid; + +LIST_HEAD(cbqri_controllers); + +static int qos_wait_busy_flag(struct cbqri_controller *ctrl, int reg_offset); + +bool resctrl_arch_alloc_capable(void) +{ + return exposed_alloc_capable; +} + +bool resctrl_arch_mon_capable(void) +{ + return exposed_mon_capable; +} + +bool resctrl_arch_is_mbm_local_enabled(void) +{ + /* + * Seems to be the bandwidth between a L2 cache and L3 cache + * according to Intel resctrl implementation. There is no meaning + * in supporting such stat when we use resctrl MON_DATA feature + * to support CBQRI bandwidth monitoring. + */ + return false; +} + +bool resctrl_arch_is_mbm_total_enabled(void) +{ + return true; +} + +bool resctrl_arch_get_cdp_enabled(enum resctrl_res_level rid) +{ + switch (rid) { + case RDT_RESOURCE_L2: + return is_cdp_l2_enabled; + + case RDT_RESOURCE_L3: + return is_cdp_l3_enabled; + + default: + return false; + } +} + +int resctrl_arch_set_cdp_enabled(enum resctrl_res_level rid, bool enable) +{ + switch (rid) { + case RDT_RESOURCE_L2: + if (!exposed_cdp_l2_capable) + return -ENODEV; + is_cdp_l2_enabled = enable; + break; + + case RDT_RESOURCE_L3: + if (!exposed_cdp_l3_capable) + return -ENODEV; + is_cdp_l3_enabled = enable; + break; + + default: + return -ENODEV; + } + + return 0; +} + +bool resctrl_arch_is_llc_occupancy_enabled(void) +{ + /* + * There is no occupancy in CBQRI bandwidth controller (resctrl MON_DATA + * was the only available way to implement RISC-V memory monitoring). + * As we need occupancy for CBQRI capacity controller, this global + * setting is true, but the ll_occupancy files of CBQRI bandwidth + * controllers will return an error. + */ + return true; +} + +/* + * Note about terminology between x86 (Intel RDT/AMD QoS) and RISC-V: + * CLOSID on x86 is RCID on RISC-V + * RMID on x86 is MCID on RISC-V + */ +u32 resctrl_arch_get_num_closid(struct rdt_resource *res) +{ + struct cbqri_resctrl_res *hw_res; + + hw_res = container_of(res, struct cbqri_resctrl_res, resctrl_res); + + return hw_res->max_rcid; +} + +u32 resctrl_arch_system_num_rmid_idx(void) +{ + return max_rmid; +} + +u32 resctrl_arch_rmid_idx_encode(u32 closid, u32 rmid) +{ + return rmid; +} + +void resctrl_arch_rmid_idx_decode(u32 idx, u32 *closid, u32 *rmid) +{ + *closid = ((u32)~0); /* refer to X86_RESCTRL_BAD_CLOSID */ + *rmid = idx; +} + +/* RISC-V resctrl interface does not maintain a default sqoscfg value for a given CPU */ +void resctrl_arch_set_cpu_default_closid_rmid(int cpu, u32 closid, u32 rmid) { } + +void resctrl_sched_in(void) +{ + qos_sched_in(current); +} + +void resctrl_arch_sync_cpu_defaults(void *info) +{ + resctrl_sched_in(); +} + +void resctrl_arch_set_closid_rmid(struct task_struct *tsk, u32 closid, u32 rmid) +{ + u32 sqoscfg; + + WARN_ON_ONCE((closid & SQOSCFG_RCID_MASK) != closid); + WARN_ON_ONCE((rmid & SQOSCFG_MCID_MASK) != rmid); + + sqoscfg = rmid << SQOSCFG_MCID_SHIFT; + sqoscfg |= closid; + WRITE_ONCE(tsk->thread.sqoscfg, sqoscfg); +} + +bool resctrl_arch_match_closid(struct task_struct *tsk, u32 closid) +{ + u32 sqoscfg; + bool match; + + sqoscfg = READ_ONCE(tsk->thread.sqoscfg); + match = (sqoscfg & SQOSCFG_RCID_MASK) == closid; + return match; +} + +bool resctrl_arch_match_rmid(struct task_struct *tsk, u32 closid, u32 rmid) +{ + u32 tsk_rmid; + + tsk_rmid = READ_ONCE(tsk->thread.sqoscfg); + tsk_rmid >>= SQOSCFG_MCID_SHIFT; + tsk_rmid &= SQOSCFG_MCID_MASK; + + return tsk_rmid == rmid; +} + +struct rdt_resource *resctrl_arch_get_resource(enum resctrl_res_level l) +{ + if (l >= RDT_NUM_RESOURCES) + return NULL; + + return &cbqri_resctrl_resources[l].resctrl_res; +} + +struct rdt_domain *resctrl_arch_find_domain(struct rdt_resource *r, int id) +{ + struct rdt_domain *domain; + struct list_head *l; + + list_for_each(l, &r->domains) { + domain = list_entry(l, struct rdt_domain, list); + if (id == domain->id) + return domain; + } + + return NULL; +} + +void resctrl_arch_reset_resources(void) +{ + /* not implemented for the RISC-V resctrl implementation */ +} + +int resctrl_arch_mon_ctx_alloc_no_wait(struct rdt_resource *r, int evtid) +{ + /* RISC-V can always read an rmid, nothing needs allocating */ + return 0; +} + +void resctrl_arch_mon_ctx_free(struct rdt_resource *r, int evtid, int ctx) +{ + /* not implemented for the RISC-V resctrl interface */ +} + +bool resctrl_arch_is_evt_configurable(enum resctrl_event_id evt) +{ + return false; +} + +int resctrl_arch_rmid_read(struct rdt_resource *r, struct rdt_domain *d, + u32 closid, u32 rmid, enum resctrl_event_id eventid, + u64 *val, int arch_mon_ctx) +{ + /* + * The current Qemu implementation of CBQRI capacity and bandwidth + * controllers do not emulate the utilization of resources over + * time. Therefore, Qemu currently sets the invalid bit in + * cc_mon_ctr_val and bc_mon_ctr_val, and there is no meaningful + * value other than 0 to return for reading an RMID (e.g. MCID in + * CBQRI terminology) + */ + + return 0; +} + +void resctrl_arch_reset_rmid(struct rdt_resource *r, struct rdt_domain *d, + u32 closid, u32 rmid, enum resctrl_event_id eventid) +{ + /* not implemented for the RISC-V resctrl interface */ +} + +void resctrl_arch_mon_event_config_read(void *info) +{ + /* not implemented for the RISC-V resctrl interface */ +} + +void resctrl_arch_mon_event_config_write(void *info) +{ + /* not implemented for the RISC-V resctrl interface */ +} + +void resctrl_arch_reset_rmid_all(struct rdt_resource *r, struct rdt_domain *d) +{ + /* not implemented for the RISC-V resctrl implementation */ +} + +/* Set capacity block mask (cc_block_mask) */ +static void cbqri_set_cbm(struct cbqri_controller *ctrl, u64 cbm) +{ + int reg_offset; + u64 reg; + + reg_offset = CBQRI_CC_BLOCK_MASK_OFF; + reg = ioread64(ctrl->base + reg_offset); + + reg = cbm; + iowrite64(reg, ctrl->base + reg_offset); + + reg = ioread64(ctrl->base + reg_offset); +} + +/* Set the Rbwb (reserved bandwidth blocks) field in bc_bw_alloc */ +static void cbqri_set_rbwb(struct cbqri_controller *ctrl, u64 rbwb) +{ + int reg_offset; + u64 reg; + + reg_offset = CBQRI_BC_BW_ALLOC_OFF; + reg = ioread64(ctrl->base + reg_offset); + reg |= rbwb & CBQRI_CONTROL_REGISTERS_RBWB_MASK; + iowrite64(reg, ctrl->base + reg_offset); +} + +/* Get the Rbwb (reserved bandwidth blocks) field in bc_bw_alloc */ +static u64 cbqri_get_rbwb(struct cbqri_controller *ctrl) +{ + int reg_offset; + u64 reg; + + reg_offset = CBQRI_BC_BW_ALLOC_OFF; + reg = ioread64(ctrl->base + reg_offset); + reg &= CBQRI_CONTROL_REGISTERS_RBWB_MASK; + + return reg; +} + +static int qos_wait_busy_flag(struct cbqri_controller *ctrl, int reg_offset) +{ + unsigned long timeout = jiffies + (HZ / 10); /* Timeout after 100ms */ + u64 reg; + int busy; + + while (time_before(jiffies, timeout)) { + reg = ioread64(ctrl->base + reg_offset); + busy = (reg >> CBQRI_CONTROL_REGISTERS_BUSY_SHIFT) & + CBQRI_CONTROL_REGISTERS_BUSY_MASK; + if (!busy) + return 0; + } + + pr_warn("%s(): busy timeout", __func__); + return -EIO; +} + +/* Perform operation on capacity controller */ +static int do_capacity_alloc_op(struct cbqri_controller *ctrl, int operation, + enum resctrl_conf_type type, int rcid) +{ + int reg_offset = CBQRI_CC_ALLOC_CTL_OFF; + int status; + u64 reg; + + reg = ioread64(ctrl->base + reg_offset); + reg &= ~(CBQRI_CONTROL_REGISTERS_OP_MASK << CBQRI_CONTROL_REGISTERS_OP_SHIFT); + reg |= (operation & CBQRI_CONTROL_REGISTERS_OP_MASK) << + CBQRI_CONTROL_REGISTERS_OP_SHIFT; + reg &= ~(CBQRI_CONTROL_REGISTERS_RCID_MASK << + CBQRI_CONTROL_REGISTERS_RCID_SHIFT); + reg |= (rcid & CBQRI_CONTROL_REGISTERS_RCID_MASK) << + CBQRI_CONTROL_REGISTERS_RCID_SHIFT; + + /* CBQRI capacity AT is only supported on caches for now */ + if (ctrl->ctrl_info->type == CBQRI_CONTROLLER_TYPE_CAPACITY && + ((ctrl->ctrl_info->cache.cache_level == 2 && is_cdp_l2_enabled) || + (ctrl->ctrl_info->cache.cache_level == 3 && is_cdp_l3_enabled))) { + reg &= ~(CBQRI_CONTROL_REGISTERS_AT_MASK << + CBQRI_CONTROL_REGISTERS_AT_SHIFT); + switch (type) { + case CDP_CODE: + reg |= (CBQRI_CONTROL_REGISTERS_AT_CODE & + CBQRI_CONTROL_REGISTERS_AT_MASK) << + CBQRI_CONTROL_REGISTERS_AT_SHIFT; + break; + case CDP_DATA: + default: + reg |= (CBQRI_CONTROL_REGISTERS_AT_DATA & + CBQRI_CONTROL_REGISTERS_AT_MASK) << + CBQRI_CONTROL_REGISTERS_AT_SHIFT; + break; + } + } + + iowrite64(reg, ctrl->base + reg_offset); + + if (qos_wait_busy_flag(ctrl, reg_offset) < 0) { + pr_err("%s(): BUSY timeout when executing the operation", __func__); + return -EIO; + } + + reg = ioread64(ctrl->base + reg_offset); + status = (reg >> CBQRI_CONTROL_REGISTERS_STATUS_SHIFT) & + CBQRI_CONTROL_REGISTERS_STATUS_MASK; + if (status != 1) { + pr_err("%s(): operation %d failed: status=%d", __func__, operation, status); + return -EIO; + } + + return 0; +} + +/* Perform operation on bandwidth controller */ +static int do_bandwidth_alloc_op(struct cbqri_controller *ctrl, int operation, int rcid) +{ + int reg_offset = CBQRI_BC_ALLOC_CTL_OFF; + int status; + u64 reg; + + reg = ioread64(ctrl->base + reg_offset); + reg &= ~(CBQRI_CONTROL_REGISTERS_OP_MASK << CBQRI_CONTROL_REGISTERS_OP_SHIFT); + reg |= (operation & CBQRI_CONTROL_REGISTERS_OP_MASK) << + CBQRI_CONTROL_REGISTERS_OP_SHIFT; + reg &= ~(CBQRI_CONTROL_REGISTERS_RCID_MASK << CBQRI_CONTROL_REGISTERS_RCID_SHIFT); + reg |= (rcid & CBQRI_CONTROL_REGISTERS_RCID_MASK) << + CBQRI_CONTROL_REGISTERS_RCID_SHIFT; + iowrite64(reg, ctrl->base + reg_offset); + + if (qos_wait_busy_flag(ctrl, reg_offset) < 0) { + pr_err("%s(): BUSY timeout when executing the operation", __func__); + return -EIO; + } + + reg = ioread64(ctrl->base + reg_offset); + status = (reg >> CBQRI_CONTROL_REGISTERS_STATUS_SHIFT) & + CBQRI_CONTROL_REGISTERS_STATUS_MASK; + if (status != 1) { + pr_err("%s(): operation %d failed with status = %d", + __func__, operation, status); + return -EIO; + } + + return 0; +} + +static int cbqri_apply_bw_config(struct cbqri_resctrl_dom *hw_dom, u32 closid, + enum resctrl_conf_type type, struct cbqri_config *cfg) +{ + struct cbqri_controller *ctrl = hw_dom->hw_ctrl; + int ret = 0; + u64 rbwb; + + if (cfg->cbm != hw_dom->ctrl_val[closid]) { + /* Store the new rbwb in the ctrl_val array for this closid in this domain */ + hw_dom->ctrl_val[closid] = cfg->rbwb; + + /* set reserved bandwidth blocks */ + cbqri_set_rbwb(ctrl, cfg->rbwb); + /* get reserved bandwidth blocks */ + rbwb = cbqri_get_rbwb(ctrl); + + /* Capacity config limit operation for RCID (closid) */ + ret = do_capacity_alloc_op(ctrl, CBQRI_CC_ALLOC_CTL_OP_CONFIG_LIMIT, type, closid); + if (ret < 0) { + pr_err("%s(): operation failed: ret = %d", __func__, ret); + return ret; + } + + /* Clear rbwb before read limit to verify op works*/ + cbqri_set_rbwb(ctrl, 0); + + /* Bandwidth allocation read limit operation for RCID (closid) to verify */ + ret = do_capacity_alloc_op(ctrl, CBQRI_CC_ALLOC_CTL_OP_READ_LIMIT, type, closid); + if (ret < 0) { + pr_err("%s(): operation failed: ret = %d", __func__, ret); + return ret; + } + + /* Read capacity block mask for RCID (closid) to verify */ + rbwb = cbqri_get_rbwb(ctrl); + } + + return ret; +} + +static int cbqri_apply_cache_config(struct cbqri_resctrl_dom *hw_dom, u32 closid, + enum resctrl_conf_type type, struct cbqri_config *cfg) +{ + struct cbqri_controller *ctrl = hw_dom->hw_ctrl; + int reg_offset, err = 0; + u64 reg; + + if (cfg->cbm != hw_dom->ctrl_val[closid]) { + /* store the new cbm in the ctrl_val array for this closid in this domain */ + hw_dom->ctrl_val[closid] = cfg->cbm; + + /* set capacity block mask (cc_block_mask) */ + cbqri_set_cbm(ctrl, cfg->cbm); + + /* Capacity config limit operation for RCID (closid) */ + err = do_capacity_alloc_op(ctrl, CBQRI_CC_ALLOC_CTL_OP_CONFIG_LIMIT, type, closid); + if (err < 0) { + pr_err("%s(): operation failed: err = %d", __func__, err); + return err; + } + + /* clear cc_block_mask before read limit to verify op works*/ + cbqri_set_cbm(ctrl, 0); + + /* Capacity read limit operation for RCID (closid) to verify */ + err = do_capacity_alloc_op(ctrl, CBQRI_CC_ALLOC_CTL_OP_READ_LIMIT, type, closid); + if (err < 0) { + pr_err("%s(): operation failed: err = %d", __func__, err); + return err; + } + + /* Read capacity block mask for RCID (closid) to verify */ + reg_offset = CBQRI_CC_BLOCK_MASK_OFF; + reg = ioread64(ctrl->base + reg_offset); + } + + return err; +} + +int resctrl_arch_update_one(struct rdt_resource *r, struct rdt_domain *d, + u32 closid, enum resctrl_conf_type t, u32 cfg_val) +{ + struct cbqri_resctrl_res *res; + struct cbqri_resctrl_dom *dom; + struct cbqri_config cfg; + int err = 0; + + res = container_of(r, struct cbqri_resctrl_res, resctrl_res); + dom = container_of(d, struct cbqri_resctrl_dom, resctrl_dom); + + if (!r->alloc_capable) + return -EINVAL; + + switch (r->rid) { + case RDT_RESOURCE_L2: + case RDT_RESOURCE_L3: + cfg.cbm = cfg_val; + err = cbqri_apply_cache_config(dom, closid, t, &cfg); + break; + case RDT_RESOURCE_MBA: + cfg.rbwb = cfg_val; + err = cbqri_apply_bw_config(dom, closid, t, &cfg); + break; + default: + return -EINVAL; + } + + return err; +} + +int resctrl_arch_update_domains(struct rdt_resource *r, u32 closid) +{ + struct resctrl_staged_config *cfg; + enum resctrl_conf_type t; + struct rdt_domain *d; + int err = 0; + + list_for_each_entry(d, &r->domains, list) { + for (t = 0; t < CDP_NUM_TYPES; t++) { + cfg = &d->staged_config[t]; + if (!cfg->have_new_ctrl) + continue; + err = resctrl_arch_update_one(r, d, closid, t, cfg->new_ctrl); + if (err) { + pr_debug("%s(): return err=%d", __func__, err); + return err; + } + } + } + return err; +} + +u32 resctrl_arch_get_config(struct rdt_resource *r, struct rdt_domain *d, + u32 closid, enum resctrl_conf_type type) +{ + struct cbqri_resctrl_res *hw_res; + struct cbqri_resctrl_dom *hw_dom; + struct cbqri_controller *ctrl; + int reg_offset; + int err; + u64 reg; + + hw_res = container_of(r, struct cbqri_resctrl_res, resctrl_res); + hw_dom = container_of(d, struct cbqri_resctrl_dom, resctrl_dom); + + ctrl = hw_dom->hw_ctrl; + + if (!r->alloc_capable) + return -EINVAL; + + switch (r->rid) { + case RDT_RESOURCE_L2: + case RDT_RESOURCE_L3: + + /* Clear cc_block_mask before read limit operation */ + cbqri_set_cbm(ctrl, 0); + + /* Capacity read limit operation for RCID (closid) */ + err = do_capacity_alloc_op(ctrl, CBQRI_CC_ALLOC_CTL_OP_READ_LIMIT, type, closid); + if (err < 0) { + pr_err("%s(): operation failed: err = %d", __func__, err); + return -EIO; + } + + /* Read capacity block mask for RCID (closid) */ + reg_offset = CBQRI_CC_BLOCK_MASK_OFF; + reg = ioread64(ctrl->base + reg_offset); + + /* Update the config value for the closid in this domain */ + hw_dom->ctrl_val[closid] = reg; + + return hw_dom->ctrl_val[closid]; + + case RDT_RESOURCE_MBA: + + /* Capacity read limit operation for RCID (closid) */ + err = do_bandwidth_alloc_op(ctrl, CBQRI_CC_ALLOC_CTL_OP_READ_LIMIT, closid); + if (err < 0) { + pr_err("%s(): operation failed: err = %d", __func__, err); + return -EIO; + } + + hw_dom->ctrl_val[closid] = cbqri_get_rbwb(ctrl); + + return hw_dom->ctrl_val[closid]; + + default: + return -EINVAL; + } +} + +static int qos_discover_controller_feature(struct cbqri_controller *ctrl, + int reg_offset, + int operation, + int *status, + bool *access_type_supported) +{ + u64 reg, saved_reg; + int at; + + /* Keep the initial register value to preserve the WPRI fields */ + reg = ioread64(ctrl->base + reg_offset); + saved_reg = reg; + + /* Execute the requested operation to find if the register is implemented */ + reg &= ~(CBQRI_CONTROL_REGISTERS_OP_MASK << CBQRI_CONTROL_REGISTERS_OP_SHIFT); + reg |= (operation & CBQRI_CONTROL_REGISTERS_OP_MASK) << CBQRI_CONTROL_REGISTERS_OP_SHIFT; + iowrite64(reg, ctrl->base + reg_offset); + if (qos_wait_busy_flag(ctrl, reg_offset) < 0) { + pr_err("%s(): BUSY timeout when executing the operation", __func__); + return -EIO; + } + + /* Get the operation status */ + reg = ioread64(ctrl->base + reg_offset); + *status = (reg >> CBQRI_CONTROL_REGISTERS_STATUS_SHIFT) & + CBQRI_CONTROL_REGISTERS_STATUS_MASK; + + /* + * Check for the AT support if the register is implemented + * (if not, the status value will remain 0) + */ + if (*status != 0) { + /* Set the AT field to a valid value */ + reg = saved_reg; + reg &= ~(CBQRI_CONTROL_REGISTERS_AT_MASK << CBQRI_CONTROL_REGISTERS_AT_SHIFT); + reg |= CBQRI_CONTROL_REGISTERS_AT_CODE << CBQRI_CONTROL_REGISTERS_AT_SHIFT; + iowrite64(reg, ctrl->base + reg_offset); + if (qos_wait_busy_flag(ctrl, reg_offset) < 0) { + pr_err("%s(): BUSY timeout when setting AT field", __func__); + return -EIO; + } + + /* + * If the AT field value has been reset to zero, + * then the AT support is not present + */ + reg = ioread64(ctrl->base + reg_offset); + at = (reg >> CBQRI_CONTROL_REGISTERS_AT_SHIFT) & CBQRI_CONTROL_REGISTERS_AT_MASK; + if (at == CBQRI_CONTROL_REGISTERS_AT_CODE) + *access_type_supported = true; + else + *access_type_supported = false; + } + + /* Restore the original register value */ + iowrite64(saved_reg, ctrl->base + reg_offset); + if (qos_wait_busy_flag(ctrl, reg_offset) < 0) { + pr_err("%s(): BUSY timeout when restoring the original register value", __func__); + return -EIO; + } + + return 0; +} + +/* + * Note: for the purposes of the CBQRI proof-of-concept, debug logging + * has been left in this function that discovers the properties of CBQRI + * capable controllers in the system. pr_debug calls would be removed + * before submitting non-RFC patches. + */ +static int qos_resctrl_discover_controller(struct cbqri_controller_info *ctrl_info, + struct cbqri_controller *ctrl) +{ + int err = 0, status; + u64 reg; + + pr_debug("controller info: type=%d addr=0x%lx size=%lu max-rcid=%u max-mcid=%u", + ctrl_info->type, ctrl_info->addr, ctrl_info->size, + ctrl_info->rcid_count, ctrl_info->mcid_count); + + /* max_rmid is used by resctrl_arch_system_num_rmid_idx() */ + max_rmid = ctrl_info->mcid_count; + + ctrl->ctrl_info = ctrl_info; + + /* Try to access the memory-mapped CBQRI registers */ + if (!request_mem_region(ctrl_info->addr, ctrl_info->size, "cbqri_controller")) { + pr_debug("%s(): return %d", __func__, err); + return err; + } + ctrl->base = ioremap(ctrl_info->addr, ctrl_info->size); + if (!ctrl->base) { + pr_debug("%s(): goto err_release_mem_region", __func__); + goto err_release_mem_region; + } + + ctrl->alloc_capable = false; + ctrl->mon_capable = false; + + /* Discover capacity allocation and monitoring features */ + if (ctrl_info->type == CBQRI_CONTROLLER_TYPE_CAPACITY) { + pr_debug("probe capacity controller"); + + /* Make sure the register is implemented */ + reg = ioread64(ctrl->base + CBQRI_CC_CAPABILITIES_OFF); + if (reg == 0) { + err = -ENODEV; + goto err_iounmap; + } + + ctrl->ver_minor = reg & CBQRI_CC_CAPABILITIES_VER_MINOR_MASK; + ctrl->ver_major = reg & CBQRI_CC_CAPABILITIES_VER_MAJOR_MASK; + + ctrl->cc.supports_alloc_op_flush_rcid = (reg >> CBQRI_CC_CAPABILITIES_FRCID_SHIFT) + & CBQRI_CC_CAPABILITIES_FRCID_MASK; + + ctrl->cc.ncblks = (reg >> CBQRI_CC_CAPABILITIES_NCBLKS_SHIFT) & + CBQRI_CC_CAPABILITIES_NCBLKS_MASK; + + /* Calculate size of capacity block in bytes */ + ctrl->cc.blk_size = ctrl_info->cache.cache_size / ctrl->cc.ncblks; + ctrl->cc.cache_level = ctrl_info->cache.cache_level; + + pr_debug("version=%d.%d ncblks=%d blk_size=%d cache_level=%d", + ctrl->ver_major, ctrl->ver_minor, + ctrl->cc.ncblks, ctrl->cc.blk_size, ctrl->cc.cache_level); + + /* Discover monitoring features */ + err = qos_discover_controller_feature(ctrl, CBQRI_CC_MON_CTL_OFF, + CBQRI_CC_MON_CTL_OP_READ_COUNTER, + &status, &ctrl->cc.supports_mon_at_code); + if (err) { + pr_err("%s() failed to discover cc_mon_ctl feature", __func__); + goto err_iounmap; + } + + if (status == CBQRI_CC_MON_CTL_STATUS_SUCCESS) { + pr_debug("cc_mon_ctl is supported"); + ctrl->cc.supports_mon_op_config_event = true; + ctrl->cc.supports_mon_op_read_counter = true; + ctrl->mon_capable = true; + } else { + pr_debug("cc_mon_ctl is NOT supported"); + ctrl->cc.supports_mon_op_config_event = false; + ctrl->cc.supports_mon_op_read_counter = false; + ctrl->mon_capable = false; + } + /* + * AT data is "always" supported as it has the same value + * than when AT field is not supported. + */ + ctrl->cc.supports_mon_at_data = true; + pr_debug("supports_mon_at_data: %d, supports_mon_at_code: %d", + ctrl->cc.supports_mon_at_data, ctrl->cc.supports_mon_at_code); + + /* Discover allocation features */ + err = qos_discover_controller_feature(ctrl, CBQRI_CC_ALLOC_CTL_OFF, + CBQRI_CC_ALLOC_CTL_OP_READ_LIMIT, + &status, &ctrl->cc.supports_alloc_at_code); + if (err) { + pr_err("%s() failed to discover cc_alloc_ctl feature", __func__); + goto err_iounmap; + } + + if (status == CBQRI_CC_ALLOC_CTL_STATUS_SUCCESS) { + pr_debug("cc_alloc_ctl is supported"); + ctrl->cc.supports_alloc_op_config_limit = true; + ctrl->cc.supports_alloc_op_read_limit = true; + ctrl->alloc_capable = true; + exposed_alloc_capable = true; + } else { + pr_debug("cc_alloc_ctl is NOT supported"); + ctrl->cc.supports_alloc_op_config_limit = false; + ctrl->cc.supports_alloc_op_read_limit = false; + ctrl->alloc_capable = false; + } + /* + * AT data is "always" supported as it has the same value + * than when AT field is not supported + */ + ctrl->cc.supports_alloc_at_data = true; + pr_debug("supports_alloc_at_data: %d, supports_alloc_at_code: %d", + ctrl->cc.supports_alloc_at_data, + ctrl->cc.supports_alloc_at_code); + } else if (ctrl_info->type == CBQRI_CONTROLLER_TYPE_BANDWIDTH) { + pr_debug("probe bandwidth controller"); + + /* Make sure the register is implemented */ + reg = ioread64(ctrl->base + CBQRI_BC_CAPABILITIES_OFF); + if (reg == 0) { + err = -ENODEV; + goto err_iounmap; + } + + ctrl->ver_minor = reg & CBQRI_BC_CAPABILITIES_VER_MINOR_MASK; + ctrl->ver_major = reg & CBQRI_BC_CAPABILITIES_VER_MAJOR_MASK; + + ctrl->bc.nbwblks = (reg >> CBQRI_BC_CAPABILITIES_NBWBLKS_SHIFT) & + CBQRI_BC_CAPABILITIES_NBWBLKS_MASK; + ctrl->bc.mrbwb = (reg >> CBQRI_BC_CAPABILITIES_MRBWB_SHIFT) & + CBQRI_BC_CAPABILITIES_MRBWB_MASK; + + pr_debug("version=%d.%d nbwblks=%d mrbwb=%d", + ctrl->ver_major, ctrl->ver_minor, + ctrl->bc.nbwblks, ctrl->bc.mrbwb); + + // Discover monitoring features + err = qos_discover_controller_feature(ctrl, CBQRI_BC_MON_CTL_OFF, + CBQRI_BC_MON_CTL_OP_READ_COUNTER, + &status, &ctrl->bc.supports_mon_at_code); + if (err) { + pr_err("%s() failed to discover bc_mon_ctl feature", __func__); + goto err_iounmap; + } + + if (status == CBQRI_BC_MON_CTL_STATUS_SUCCESS) { + pr_debug("bc_mon_ctl is supported"); + ctrl->bc.supports_mon_op_config_event = true; + ctrl->bc.supports_mon_op_read_counter = true; + ctrl->mon_capable = true; + exposed_mon_capable = true; + } else { + pr_debug("bc_mon_ctl is NOT supported"); + ctrl->bc.supports_mon_op_config_event = false; + ctrl->bc.supports_mon_op_read_counter = false; + ctrl->mon_capable = false; + } + // AT data is "always" supported as it has the same value + // than when AT field is not supported + ctrl->bc.supports_mon_at_data = true; + pr_debug("supports_mon_at_data: %d, supports_mon_at_code: %d", + ctrl->bc.supports_mon_at_data, ctrl->bc.supports_mon_at_code); + + // Discover allocation features + err = qos_discover_controller_feature(ctrl, CBQRI_BC_ALLOC_CTL_OFF, + CBQRI_BC_ALLOC_CTL_OP_READ_LIMIT, + &status, &ctrl->bc.supports_alloc_at_code); + if (err) { + pr_err("%s() failed to discover bc_alloc_ctl feature", __func__); + goto err_iounmap; + } + + if (status == CBQRI_BC_ALLOC_CTL_STATUS_SUCCESS) { + pr_debug("bc_alloc_ctl is supported"); + ctrl->bc.supports_alloc_op_config_limit = true; + ctrl->bc.supports_alloc_op_read_limit = true; + ctrl->alloc_capable = true; + exposed_alloc_capable = true; + } else { + pr_debug("bc_alloc_ctl is NOT supported"); + ctrl->bc.supports_alloc_op_config_limit = false; + ctrl->bc.supports_alloc_op_read_limit = false; + ctrl->alloc_capable = false; + } + + /* + * AT data is "always" supported as it has the same value + * than when AT field is not supported + */ + ctrl->bc.supports_alloc_at_data = true; + pr_debug("supports_alloc_at_data: %d, supports_alloc_at_code: %d", + ctrl->bc.supports_alloc_at_data, ctrl->bc.supports_alloc_at_code); + } else { + pr_err("controller type is UNKNOWN"); + err = -ENODEV; + goto err_release_mem_region; + } + + return 0; + +err_iounmap: + pr_err("%s(): err_iounmap", __func__); + iounmap(ctrl->base); + +err_release_mem_region: + pr_err("%s(): err_release_mem_region", __func__); + release_mem_region(ctrl_info->addr, ctrl_info->size); + + return err; +} + +static struct rdt_domain *qos_new_domain(struct cbqri_controller *ctrl) +{ + struct cbqri_resctrl_dom *hw_dom; + struct rdt_domain *domain; + + hw_dom = kzalloc(sizeof(*hw_dom), GFP_KERNEL); + if (!hw_dom) + return NULL; + + /* associate this cbqri_controller with the domain */ + hw_dom->hw_ctrl = ctrl; + + /* the rdt_domain struct from inside the cbqri_resctrl_dom struct */ + domain = &hw_dom->resctrl_dom; + + INIT_LIST_HEAD(&domain->list); + + return domain; +} + +static int qos_bw_blocks_to_percentage(struct cbqri_controller *ctrl, int blocks) +{ + int percentage; + + if (ctrl->ctrl_info->type != CBQRI_CONTROLLER_TYPE_BANDWIDTH) + return -1; + + blocks *= 100; + percentage = blocks / ctrl->bc.nbwblks; + if (blocks % ctrl->bc.nbwblks) + percentage++; + + return percentage; +} + +static int domain_setup_ctrlval(struct rdt_resource *r, struct rdt_domain *d) +{ + struct cbqri_resctrl_res *hw_res; + struct cbqri_resctrl_dom *hw_dom; + u64 *dc; + int i; + + hw_res = container_of(r, struct cbqri_resctrl_res, resctrl_res); + hw_dom = container_of(d, struct cbqri_resctrl_dom, resctrl_dom); + + dc = kmalloc_array(hw_res->max_rcid, sizeof(*hw_dom->ctrl_val), + GFP_KERNEL); + if (!dc) + return -ENOMEM; + + hw_dom->ctrl_val = dc; + + for (i = 0; i < hw_res->max_rcid; i++, dc++) + *dc = r->default_ctrl; + + /* + * The Qemu implementation for the CBQRI proof-of-concept has + * known reset values for all registers. A proper solution would + * be to perform a CONFIG_LIMIT operation to set the default for + * each RCID + */ + return 0; +} + +static int qos_resctrl_add_controller_domain(struct cbqri_controller *ctrl, int *id) +{ + struct rdt_domain *domain, *mon_domain = NULL; + struct cbqri_resctrl_res *cbqri_res = NULL; + struct cbqri_resctrl_dom *hw_dom_to_free; + struct rdt_resource *res; + int internal_id = *id; + int err; + + domain = qos_new_domain(ctrl); + if (!domain) + return -ENOSPC; + + if (ctrl->ctrl_info->type == CBQRI_CONTROLLER_TYPE_CAPACITY) { + cpumask_copy(&domain->cpu_mask, &ctrl->ctrl_info->cache.cpu_mask); + + if (ctrl->ctrl_info->cache.cache_level == 2) { + cbqri_res = &cbqri_resctrl_resources[RDT_RESOURCE_L2]; + cbqri_res->max_rcid = ctrl->ctrl_info->rcid_count; + cbqri_res->max_mcid = ctrl->ctrl_info->mcid_count; + res = &cbqri_res->resctrl_res; + res->num_rmid = ctrl->ctrl_info->mcid_count; + res->fflags = RFTYPE_RES_CACHE; + res->rid = RDT_RESOURCE_L2; + res->name = "L2"; + res->alloc_capable = ctrl->alloc_capable; + res->mon_capable = ctrl->mon_capable; + res->format_str = "%d=%0*x"; + res->cache_level = 2; + res->data_width = 3; + res->cache.arch_has_sparse_bitmaps = false; + res->cache.arch_has_per_cpu_cfg = false; + res->cache.shareable_bits = 0x000; + res->cache.min_cbm_bits = 1; + res->cache.cbm_len = ctrl->cc.ncblks; + res->default_ctrl = BIT_MASK(ctrl->cc.ncblks) - 1; + } else if (ctrl->ctrl_info->cache.cache_level == 3) { + cbqri_res = &cbqri_resctrl_resources[RDT_RESOURCE_L3]; + cbqri_res->max_rcid = ctrl->ctrl_info->rcid_count; + cbqri_res->max_mcid = ctrl->ctrl_info->mcid_count; + res = &cbqri_res->resctrl_res; + res->num_rmid = ctrl->ctrl_info->mcid_count; + res->fflags = RFTYPE_RES_CACHE; + res->rid = RDT_RESOURCE_L3; + res->name = "L3"; + res->cache_level = 3; + res->alloc_capable = ctrl->alloc_capable; + res->mon_capable = ctrl->mon_capable; + res->format_str = "%d=%0*x"; + res->data_width = 4; + res->cache.arch_has_sparse_bitmaps = false; + res->cache.arch_has_per_cpu_cfg = false; + res->cache.shareable_bits = 0x000; + res->cache.min_cbm_bits = 1; + res->cache.cbm_len = ctrl->cc.ncblks; + res->default_ctrl = BIT_MASK(ctrl->cc.ncblks) - 1; + } else { + pr_err("%s(): unknown cache level %d", __func__, + ctrl->ctrl_info->cache.cache_level); + err = -ENODEV; + goto err_free_domain; + } + } else if (ctrl->ctrl_info->type == CBQRI_CONTROLLER_TYPE_BANDWIDTH) { + if (ctrl->alloc_capable) { + cbqri_res = &cbqri_resctrl_resources[RDT_RESOURCE_MBA]; + cbqri_res->max_rcid = ctrl->ctrl_info->rcid_count; + cbqri_res->max_mcid = ctrl->ctrl_info->mcid_count; + res = &cbqri_res->resctrl_res; + res->num_rmid = ctrl->ctrl_info->mcid_count; + res->fflags = RFTYPE_RES_MB; + res->rid = RDT_RESOURCE_MBA; + res->name = "MB"; + res->alloc_capable = ctrl->alloc_capable; + /* + * MBA resource is only for allocation and + * monitoring can only be done with L3 resource + */ + res->mon_capable = false; + res->format_str = "%d=%*u"; + res->data_width = 4; + /* + * MBA schemata expects percentage so convert + * maximum reserved bw blocks to percentage + */ + res->default_ctrl = qos_bw_blocks_to_percentage(ctrl, ctrl->bc.mrbwb); + /* + * Use values from 0 to MBA_MAX instead of power of two values, + * see Intel System Programming Guide manual section 18.19.7.2 + */ + res->membw.delay_linear = true; + res->membw.arch_needs_linear = true; + /* Disable non-linear values support */ + res->membw.throttle_mode = THREAD_THROTTLE_UNDEFINED; + // The minimum percentage allowed by the CBQRI spec + res->membw.min_bw = 1; + res->membw.bw_gran = 1; + } + + /* + * Monitoring is not possible with Intel MBA resource, + * so add a L3 domain if monitoring is supported by the CBQRI + * bandwidth controller. + */ + if (ctrl->mon_capable) { + struct cbqri_resctrl_res *mon_cbqri_res; + + mon_cbqri_res = &cbqri_resctrl_resources[RDT_RESOURCE_L3]; + mon_domain = qos_new_domain(ctrl); + if (!domain) + goto err_free_mon_domain; + + /* + * For CBQRI, any cpu (technically a hart in RISC-V terms) + * can access the memory-mapped registers of any CBQRI + * controller in the system. Thus it does not matter for + * RISC-V which cpu runs the resctrl code. + */ + cpumask_setall(&domain->cpu_mask); + + err = domain_setup_ctrlval(&mon_cbqri_res->resctrl_res, mon_domain); + if (err) + goto err_free_mon_domain; + + mon_domain->id = internal_id; + internal_id++; + list_add_tail(&mon_domain->list, &mon_cbqri_res->resctrl_res.domains); + err = resctrl_online_domain(res, mon_domain); + if (err) { + pr_debug("%s(): BW monitoring domain online failed", __func__); + goto err_free_mon_domain; + } + } + } else { + pr_err("%s(): unknown resource %d", __func__, ctrl->ctrl_info->type); + err = -ENODEV; + goto err_free_domain; + } + + domain->id = internal_id; + err = domain_setup_ctrlval(res, domain); + if (err) + goto err_free_mon_domain; + + if (cbqri_res) { + list_add_tail(&domain->list, &cbqri_res->resctrl_res.domains); + *id = internal_id; + err = resctrl_online_domain(res, domain); + if (err) { + pr_debug("%s(): failed to online cbqri_res domain", __func__); + goto err_free_domain; + } + } + + return 0; + +err_free_mon_domain: + if (!mon_domain) { + /* + * mon_domain is a struct rdt_domain which is a member of + * struct cbqri_resctrl_dom. That cbqri_resctrl_dom was + * allocated in qos_new_domain() and must be freed. + */ + hw_dom_to_free = container_of(mon_domain, struct cbqri_resctrl_dom, resctrl_dom); + kfree(hw_dom_to_free); + } + +err_free_domain: + /* similar to err_free_mon_domain but the ptr is 'domain' instead */ + hw_dom_to_free = container_of(domain, struct cbqri_resctrl_dom, resctrl_dom); + kfree(hw_dom_to_free); + + return err; +} + +static int qos_resctrl_setup_resources(void) +{ + struct rdt_domain *domain, *domain_temp; + struct cbqri_controller_info *ctrl_info; + struct cbqri_controller *ctrl; + struct cbqri_resctrl_res *res; + int err = 0, i, id = 0; + + list_for_each_entry(ctrl_info, &cbqri_controllers, list) { + err = qos_resctrl_discover_controller(ctrl_info, &controllers[found_controllers]); + if (err) { + pr_err("%s(): qos_resctrl_discover_controller failed (%d)", __func__, err); + goto err_unmap_controllers; + } + + found_controllers++; + if (found_controllers > MAX_CONTROLLERS) { + pr_warn("%s(): increase MAX_CONTROLLERS value", __func__); + break; + } + } + + for (i = 0; i < RDT_NUM_RESOURCES; i++) { + res = &cbqri_resctrl_resources[i]; + INIT_LIST_HEAD(&res->resctrl_res.domains); + INIT_LIST_HEAD(&res->resctrl_res.evt_list); + res->resctrl_res.rid = i; + } + + for (i = 0; i < found_controllers; i++) { + ctrl = &controllers[i]; + err = qos_resctrl_add_controller_domain(ctrl, &id); + if (err) { + pr_err("%s(): failed to add controller domain (%d)", __func__, err); + goto err_free_controllers_list; + } + id++; + + /* + * CDP (code data prioritization) on x86 is similar to + * the AT (access type) field in CBQRI. CDP only supports + * caches so this must be a CBQRI capacity controller. + */ + if (ctrl->ctrl_info->type == CBQRI_CONTROLLER_TYPE_CAPACITY && + ctrl->cc.supports_alloc_at_code && + ctrl->cc.supports_alloc_at_data) { + if (ctrl->ctrl_info->cache.cache_level == 2) + exposed_cdp_l2_capable = true; + else + exposed_cdp_l3_capable = true; + } + } + + pr_debug("exposed_alloc_capable = %d", exposed_alloc_capable); + pr_debug("exposed_mon_capable = %d", exposed_mon_capable); + pr_debug("exposed_cdp_l2_capable = %d", exposed_cdp_l2_capable); + pr_debug("exposed_cdp_l3_capable = %d", exposed_cdp_l3_capable); + return 0; + +err_free_controllers_list: + for (i = 0; i < RDT_NUM_RESOURCES; i++) { + res = &cbqri_resctrl_resources[i]; + list_for_each_entry_safe(domain, domain_temp, &res->resctrl_res.domains, list) { + kfree(domain); + } + } + +err_unmap_controllers: + for (i = 0; i < found_controllers; i++) { + iounmap(controllers[i].base); + release_mem_region(controllers[i].ctrl_info->addr, controllers[i].ctrl_info->size); + } + + return err; +} + +int qos_resctrl_setup(void) +{ + s32 err; + + err = qos_resctrl_setup_resources(); + if (err) { + pr_err("%s() failed with error %d\n", __func__, err); + return err; + } + + err = resctrl_init(); + + return err; +} + +int qos_resctrl_online_cpu(unsigned int cpu) +{ + return resctrl_online_cpu(cpu); +} + +int qos_resctrl_offline_cpu(unsigned int cpu) +{ + resctrl_offline_cpu(cpu); + return 0; +} From patchwork Wed Apr 19 11:10:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216728 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 74004C6FD18 for ; Wed, 19 Apr 2023 12:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Q1bbMbuQMS/h5pH31bmFfROhPvU1bkqFMN4pbuofyEg=; b=g/OiQ2BAN84oOA SUj3vfYVHKS8hJ/UF/0gVGYvIWJ/GMezFbgRrsxrgFAR8wkknwUxVSaWUU5VCxGoL1aXa7LvuRucN 9G2jsT8h2lmaFQhf6IVkFKq9syvEhJ7KKHmm+tEu0aGNlUMlVa/eJ5sLq/WPfA8cIswjyq8y4w6u9 QX98+e0r/Gp5O+8iZfXtMJlHMOFym+Fh73/1wmx/9sZMhnrpQlr/PHoR9SYRAzm7FBChe55XZDkjl iZVZKF+9W1HAIvOeteXNvhDcQQng+14LFpRvoXz/EjV1h4gPpPqEwcg+zWKGD8bms6gV/XRto2ug3 Paspwro7BSl2PL1/ISXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6ik-005JBa-0k; Wed, 19 Apr 2023 12:15:34 +0000 Received: from mail-pl1-x62d.google.com ([2607:f8b0:4864:20::62d]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hh-0058A4-0Q for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:28 +0000 Received: by mail-pl1-x62d.google.com with SMTP id d9443c01a7336-1a814fe0ddeso8931095ad.2 for ; Wed, 19 Apr 2023 04:10:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902622; x=1684494622; 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=Sl6ZZPHDkI9/+UU2TcDaa7qsesK/iY8UwQlFo2pnRGU=; b=teXl9sZA/vikfdnyID3OxKrmidpT4xgl6Dzon/dM8dfFMedyiwryINMJF1Ivem0Ntw 9eg4qqI0ib3racb7edyRvjU0vYn7vHgSUpIDQeg8WtOLg5oElpv+znRGFB0uo1y3FaE5 8DSuROEgor7W6zjph2142OtZ9pV5uYq83FEvjYsly8hshW1K5QBY1HsOIpvv1LQ1zFQU y9mwCdPTo37EzbUCFWZsZ0vqtVaFDqjPYdj/gKjiYkwJgCDWMN8t3LMTNLRnkrUzTTVu v9TDsLX6+Yz2HkWVQqGwpd7PpXFdpgq+TaHrzHWnlfXSYvptMWnaKAyv6Mxbehoj4Rxt LqDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902622; x=1684494622; 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=Sl6ZZPHDkI9/+UU2TcDaa7qsesK/iY8UwQlFo2pnRGU=; b=WE1isdNNryOyXB2yTck+EoQFU59PXf1D1LAhjyHVFEBj3241fVV1pr0sMQKHpyVEiZ 1zaGWRvskRspAdLRpseltinIW1o88TYV5DhG0z3g0AThi6977rTT56LoNMFXgT1CH283 toeofGnBXpOS6WstYvPcIicipZBxVP50aNG+cCBDTuFCTatjJs+TRBwn0WCrRf+zwTYp KE99Mtvcfv8N7bQejddQbpIwdGDEqXzNkYDnSW/i5P/1OKSow4O0+IggHKahgNiujSLV OYWiS2O/A5qLoNY1T36V2+EzqU2zlOvKzOP3216IBMiH84K/uht5SuS9EDtUIx9U8W6l 70ow== X-Gm-Message-State: AAQBX9embURSUofJp+P7RkU2AZBHXu79++2XWTOKyvenjRKwD6GrfIjQ cyxswsvKzSKNj8LSrovV8oZOi8vIvLN5Z+Hoo9U= X-Google-Smtp-Source: AKy350bNAAjh2WZPLBif71YYYSuewAeEIsbLtcoFmPJ/ErtgNLYslU7rMW2Oz+4DNRkcioOfHCCkiA== X-Received: by 2002:a17:903:22d0:b0:1a6:74ce:9bed with SMTP id y16-20020a17090322d000b001a674ce9bedmr5688908plg.46.1681902621989; Wed, 19 Apr 2023 04:10:21 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:21 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 08/21] RISC-V: QoS: expose implementation to resctrl Date: Wed, 19 Apr 2023 04:10:58 -0700 Message-Id: <20230419111111.477118-9-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041025_165041_56A09D00 X-CRM114-Status: GOOD ( 11.05 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The generic resctrl header include/linux/resctrl.h includes asm/resctrl.h when CONFIG_ARCH_HAS_CPU_RESCTRL is set. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- arch/riscv/include/asm/resctrl.h | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 arch/riscv/include/asm/resctrl.h diff --git a/arch/riscv/include/asm/resctrl.h b/arch/riscv/include/asm/resctrl.h new file mode 100644 index 000000000000..7d247d87dab9 --- /dev/null +++ b/arch/riscv/include/asm/resctrl.h @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#include From patchwork Wed Apr 19 11:10:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216730 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id E93A2C77B7E for ; Wed, 19 Apr 2023 12:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=EoReWqXVt3ANF1SkGSArjDmeztpWm2ZDO2X0te1vQDE=; b=Gnp/bQAg9yaNWQ +FLL3aXX0Yb1iiB9r53T3LFjsZxkuwb+EO4VWPSdJvlqLorT8VDCJHGTKCMO3fkG8Ucs+EWjKQsWY 0VVMoxFMQexhPmaiySHa5eT4pDzqjb3L/zvvxmUc3AiQYnwxRwVk6qWlkHSIBcgLcqSUQ6S5FY6Is MZVpgzPbWrBsbHn/hXs7xy0LbAl1ixsZCPy+dQ9X0QyQGc6+8dIfjrfsrdjLCdNNbU/pPIAVvQOG3 FyEDiF/3/AUyAvDHDAGEu1DzNU1tkUCb9FsJiW1vcGLBpuA/0ZrF+tU46pCchVcVycH1eJIZ84ZCV 02jjB9WL0HEXSW10tcNg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6ik-005JBq-2F; Wed, 19 Apr 2023 12:15:34 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hj-0058B9-1F for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:29 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1a6f0d8cdfeso15173715ad.2 for ; Wed, 19 Apr 2023 04:10:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902623; x=1684494623; 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=Eblfm/T6iTpx+B5jQxcafLiaSwdeB6MwJNMx1053fIM=; b=DeZfx01ZX7Sehx3CCekOj5Wmh5/0E6L27Vt1u0RCG6Af7W4Ww6d99E98VCdUMc5ILQ ppeTAQ4ynNy3TiNv6XuWSxIGB7HqcDqzwIX1tzEXE/xJHgae/7yiQ786zEhoR6k3gOvX L8RXwIuD/Bcpb+fx+/tEgYMPtOMn/5RGiZHZQSsVTwbwnESwjJZgQKjJgS+CYdiWmv/X sTlTz+tcJxIHBX9j344JEvQHen6NftYor8JECB66GT3RicUQttnGHRgNi5k9OBP15w4r +bm2YkMfwA9+FPgWxfcfMf6baW+J4rq9LuYDUDbRWAWXCt8WxTxt6hmZHGKv+vMZxzEt z6Og== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902623; x=1684494623; 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=Eblfm/T6iTpx+B5jQxcafLiaSwdeB6MwJNMx1053fIM=; b=IOEmc/202miHbb2P96d56qZUolDnu8e1k6KebmFw7m40aXZdQEG2ZiV1Y5334LkkNE pn0y6nhD36DSYMHpvOg7uiTRPddgRMSq6eZBEQgnEz30eLUC2crm7cDtZ4L8TpZNWUKl d5HVLjhrkxudNZXRcSYpR0J8bFhmQrvQia2qTNH6GAza+AAfizfv0PFKXCQlfb/I5cvG D+EaCtfg4fuX+T5qnpvVyFa35Vw0e+JW6lxWp4KOogiNw8+IH3YCSH79daJROLHCDOGC RRR5Wh6gxd+zekq8Dn3rEqxu3U96lU5WwAukG8VysEXWPrwVnB8Pf8tiEmC1bs8WnrXd Oy2Q== X-Gm-Message-State: AAQBX9f6OAC0LvbJIQZXozBkQma9xWrl7hMwN5h2xvcKLrtpaTdPODrd 6Kys+BNlWccjmGhR71jVq6f45aPUhTXH5Z8PEUg= X-Google-Smtp-Source: AKy350bJa8ymH8vz3WwMTgd0nDwI9tA5BpeE2IV7rV3XHn6aSE8c09ru5XOxb+Nqph2c5N8uPATfhA== X-Received: by 2002:a17:902:ab81:b0:1a6:4e7b:7037 with SMTP id f1-20020a170902ab8100b001a64e7b7037mr4418984plr.69.1681902623318; Wed, 19 Apr 2023 04:10:23 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:22 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 09/21] RISC-V: QoS: add late_initcall to setup resctrl interface Date: Wed, 19 Apr 2023 04:10:59 -0700 Message-Id: <20230419111111.477118-10-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041027_442974_25EC6BC4 X-CRM114-Status: GOOD ( 12.56 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add late_initcall which checks if the Ssqosid extension is present, and if so, calls resctrl setup and sets cpu hotplug state to "qos:online". Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- arch/riscv/kernel/qos/qos.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 arch/riscv/kernel/qos/qos.c diff --git a/arch/riscv/kernel/qos/qos.c b/arch/riscv/kernel/qos/qos.c new file mode 100644 index 000000000000..0b5fde06cbe1 --- /dev/null +++ b/arch/riscv/kernel/qos/qos.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0-only +// Copyright (C) 2023 Rivos Inc. + +#include +#include +#include +#include +#include + +#include +#include + +#include "internal.h" + +static int __init qos_arch_late_init(void) +{ + int err; + + if (!riscv_isa_extension_available(NULL, SSQOSID)) + return -ENODEV; + + err = qos_resctrl_setup(); + if (err != 0) + return err; + + cpuhp_setup_state(CPUHP_AP_ONLINE_DYN, "qos:online", qos_resctrl_online_cpu, + qos_resctrl_offline_cpu); + + return err; +} +late_initcall(qos_arch_late_init); From patchwork Wed Apr 19 11:11:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216733 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id BA28FC77B7C for ; Wed, 19 Apr 2023 12:15:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=sKK1IFaNdsde0QdKuAs1Y9sPt1uS4m+eQ29IbFCaLfY=; b=HDBA8VJ4Wj4qW5 Jmrl/gKDnjKU7XPYA9CyhfUR2OxI5Vcv2C1nnVdEYiUaS4CUetw36WrqSktfibxAFuFTJ9bQf23Ha xt2gz+MH9mWK7+B+dZJa9fBY6HCu9pqEgOWLMOqKcdkcR3GsIlLYYp1VEWur060mUt81imlTjhCGG ryWfVlgrUBryBZBKR/tNY2sZlkvkp+KjmJfPIGppvISVbAXGN8i3JuVnxffS+O1eHTpcdjTnMeyR1 jKntas0YCrMdwa6sxZex1EEJLY+UxR2WKWhaPyrPJPSaBbYRmUpZwXByx7s5G3IsuCc1rt8dakqtq NGQ/5Si0mSxLtaSztkGA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6il-005JCf-2n; Wed, 19 Apr 2023 12:15:35 +0000 Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hj-0058C3-1s for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:30 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1a66888cb89so25361625ad.3 for ; Wed, 19 Apr 2023 04:10:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902625; x=1684494625; 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=4hp9NpznKrrhFUn5kY4plzR5MQ6NWWu6XSocDBe3Nh8=; b=bSlEbec9/6HF6hffS50ZidbvyeHeOIIlvjS3fkxYt9p2ccPaMCloBmttbuqqmsN+pP DQKv+mly9xKqQ4DR+95+zT4hxj70m32RkOVien5/iCyTKT/aF057uciiXJCz04ujXg4j 9UYRl+7MZAmd5jQbkwrSe4SmKcvX1AYAsUQJbwA/7i+dCzahPypNFubuZwsTbBHpKRkV nM3OfcozCj/et54NEGR796BoVTOz7l/50j92hxQPhew31E9fQbhqC9Tiv0CFffEHVVLL qGT+FuApfG1S8zPBFa1RInxm7TqmigulH7DtfZowilsJGVx+WXKTVPZlCDvlmAvfTUZP uFUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902625; x=1684494625; 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=4hp9NpznKrrhFUn5kY4plzR5MQ6NWWu6XSocDBe3Nh8=; b=TOFZRzDfrVII4sH440cMpaG1jSX5bdA80vR8s/DVP3l9iEP6jbhC7Q/wjjUgD1WXu+ Vw+VEX1ws3BLbjXxus5MGLCZlexQaUOc5lsZn9zcm13c9Z8OrTmv8x0LpJ++mCAfQ5M9 XQg98p81hrmWG+9tbJFcD2gMFLbee+pGHv91/8ZKY0sUmId0B5rT6R2FpgJ8QCMJmFiH H5V3zaNVph2BZmE8I+9vgkPwFkMN0s+hJ7MfpEtW7eqCn5qtfh/egQTISHpCrvwiUwd5 dNefg8kKSumMZYWkocse2y2Ziy/DiK8swpBsX26EIbm/K/DXEHJIFZbj8wuxhbEFHsgr YYeA== X-Gm-Message-State: AAQBX9fx+RG+jxi1mhNujTiSlpHKs4LgyqVoCRWHOqr4rAAmljRdRmXt mZkVjUxNGzkAZibKSfVTb1s82ILkfIbVJvXE8tk= X-Google-Smtp-Source: AKy350ai+UBLN/89dPos+Z6tfCAIHn5xTLWvbGJuKVAtD1FBL63oRuudBwAa0ym8BXor3JGzI2co3w== X-Received: by 2002:a17:902:ee4d:b0:1a6:9f09:866d with SMTP id 13-20020a170902ee4d00b001a69f09866dmr5126919plo.61.1681902624856; Wed, 19 Apr 2023 04:10:24 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:24 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 10/21] RISC-V: QoS: make CONFIG_RISCV_ISA_SSQOSID select resctrl Date: Wed, 19 Apr 2023 04:11:00 -0700 Message-Id: <20230419111111.477118-11-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041027_688475_B598522F X-CRM114-Status: UNSURE ( 8.98 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Make CONFIG_RISCV_ISA_SSQOSID select the config options for resctrl: ARCH_HAS_CPU_RESCTRL and RESCTRL_FS Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- arch/riscv/Kconfig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig index 9d4c8c505191..683349c2e809 100644 --- a/arch/riscv/Kconfig +++ b/arch/riscv/Kconfig @@ -401,6 +401,9 @@ config RISCV_ISA_C config RISCV_ISA_SSQOSID bool "Ssqosid extension support for supervisor mode Quality of Service ID" default y + select ARCH_HAS_CPU_RESCTRL + select RESCTRL_FS + select MISC_FILESYSTEMS help Adds support for the Ssqosid ISA extension (Supervisor-mode Quality of Service ID). From patchwork Wed Apr 19 11:11:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216737 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AEBEBC6FD18 for ; Wed, 19 Apr 2023 12:15:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=zzlDH8iatSo/Nr29307pXaB0udldXwmtC1hXY7W/V1o=; b=Qfpp+FpYwkP1r8 0XN96n+FwGBCXmKs5EOI7rBSyh5Q0wxrLrHgG2gWDh9nWCj47JN9oiBgXyq2yfvpZ4eSpiOmrvjiM MiSLStF9vsIsbi/lnVDhpbIv0ZGZbvT0/EJGX/4wV7UoYsP+Zy3C9HLid/kKnyfJj8kiXNCqAElzL NkeelhymIQW9fDHgifYdiFEUcEtshM74VXQzRV6p6z9khRaXN823vPJrPYl0OpJ4vRiw4oOOMHPrh YsIvJro4uxd8UUYsJjvayPWe3ohAw1/cshGEmS0VKXXkL92Xy3A0mVDr/hxLBUq8nr3wR56JDeU7Y dtkrZGy3qKl96BwIDNVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6il-005JCD-0f; Wed, 19 Apr 2023 12:15:35 +0000 Received: from mail-pl1-x62c.google.com ([2607:f8b0:4864:20::62c]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hj-0058Cs-1F for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:29 +0000 Received: by mail-pl1-x62c.google.com with SMTP id d9443c01a7336-1a667067275so25321475ad.1 for ; Wed, 19 Apr 2023 04:10:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902626; x=1684494626; 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=1F7zU+i+fgt15KwVVGwxKhOm7NGAJEpboJ7iHtKcEtA=; b=aV4uFLLXRbU0iBRIE297Q6EuQGVnLdUjGgZomWyhtilxlo1Xq5JPOtPmXFKRcqinT0 ofpucAcyCK12hWD3OSGm2ZBa8cCd7SRz725V46cfkz9Mc3how+qc46mk/Pv1Iir4XwH3 I+W9X2ydKb5X5SejIFVpYeCGYnMLe84eo3oyFXWBojouGseR4qBtPkM36th81qqCXb6S xugkArjRhlFMZwiJYvBNhF+f6h98sog5nw474YuDtsxZCN2cq0gloi3bUk3KqowxoeZk zrdDTH+1ANXXhbvzhlyXrcyTllVHQhr4OuyPAT2dipwlDOYDrEYiFYl4VgX1JrWJnY+3 NgrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902626; x=1684494626; 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=1F7zU+i+fgt15KwVVGwxKhOm7NGAJEpboJ7iHtKcEtA=; b=gZrIZ0B3jI+xtYttAcquw2JjiOkICHTrqvs/856BGjcwWm+JKG/89bI+53UAjVuXhx Y+DVsBvrqi+9z70T5QQozfRMVJsKQ5JzKQlJhcE2fZKiyyWtAbM+1ZI6fhfucrl88KF+ AHf4K9GT5TLIsZwrKumiN4lODKIDJMDPbe67AmRcp9JRsBfI0V9TlNMlNpmJIFoETFOw k0qBBTvhBznjl9er3L6Qm2xJn24mVKfgX1KPg88IRomSQe1EEfvF7toqNiBbvWj/vCo5 E0euFa+4pU5yGW1045MKlM4HilrY+dOw1Uk2bl0KeFWFQGWmfDC09WIfB7eT4uCfTl5o dHGA== X-Gm-Message-State: AAQBX9cGyZ23I+BnUzSC7aHB8opoawYbH4Kv7G44Llf1QL60S0mVX5SC mEKciHqxJDcnXLYavWEmFyE9Eg0O/5e1reHgyhE= X-Google-Smtp-Source: AKy350aB3waRCVBrNPWUpTvTFh7Oe7hWlqGLAXwcnE0SSE6o5sCO8frWgwt3jy/dLmWZ5MGyUsHLZQ== X-Received: by 2002:a17:903:230b:b0:1a6:a6e7:8846 with SMTP id d11-20020a170903230b00b001a6a6e78846mr6108159plh.40.1681902626375; Wed, 19 Apr 2023 04:10:26 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:25 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 11/21] RISC-V: QoS: add to build when CONFIG_RISCV_ISA_SSQOSID set Date: Wed, 19 Apr 2023 04:11:01 -0700 Message-Id: <20230419111111.477118-12-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041027_452612_B7664B07 X-CRM114-Status: GOOD ( 12.55 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add the sqoscfg CSR handling and the resctrl interface to the build when CONFIG_RISCV_ISA_SSQOSID is set. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- arch/riscv/kernel/Makefile | 2 ++ arch/riscv/kernel/qos/Makefile | 2 ++ 2 files changed, 4 insertions(+) create mode 100644 arch/riscv/kernel/qos/Makefile diff --git a/arch/riscv/kernel/Makefile b/arch/riscv/kernel/Makefile index 4cf303a779ab..57d57e430fb9 100644 --- a/arch/riscv/kernel/Makefile +++ b/arch/riscv/kernel/Makefile @@ -89,3 +89,5 @@ obj-$(CONFIG_EFI) += efi.o obj-$(CONFIG_COMPAT) += compat_syscall_table.o obj-$(CONFIG_COMPAT) += compat_signal.o obj-$(CONFIG_COMPAT) += compat_vdso/ + +obj-$(CONFIG_RISCV_ISA_SSQOSID) += qos/ diff --git a/arch/riscv/kernel/qos/Makefile b/arch/riscv/kernel/qos/Makefile new file mode 100644 index 000000000000..9ed0c13a854d --- /dev/null +++ b/arch/riscv/kernel/qos/Makefile @@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_RISCV_ISA_SSQOSID) += qos.o qos_resctrl.o From patchwork Wed Apr 19 11:11:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216736 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 6694BC7EE20 for ; Wed, 19 Apr 2023 12:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=coBRdh6Q0Kl2PkURWKN55mF/iyPIoS//dRPzV+G446o=; b=qp66ct81ZaZJOy k0nU85vwdWiaQ/FxvSInuG8DvYkqfW/yPv26vfe7KoCXbLCV+dlzkaYY5iAvBsyFB0JON7/xghLSo t9T+UdERXIGSRMK5C5pWRLCdPQ3irMEIkR8duJuxF5TerW/krAXToLt3VcDmKpEaggIUEQ0AGmE87 uJ0rztZ/DIx6qIqnqJkvPxmmhll3NzrbjsQvRCPP0eeCtjGsYTdOfpD+URdFmnWNu4RkqpPhNyT8z T047oyCAIQXMqApk6O2pwO1p34E/UZE1lSRXxIuBMptZe1KuziJazJlX6IjnpbWFT54xGD7dq12lK TVp9ug2tGOoHqdwcIs/A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6in-005JE6-1K; Wed, 19 Apr 2023 12:15:37 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hs-0058Jx-0R for linux-riscv@bombadil.infradead.org; Wed, 19 Apr 2023 11:10:36 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=IeP1c5FHkO2iYuai0o4JGoTDumRIxR3IsfyyPznXUZQ=; b=aOexigcGm3Jucd9WFZ14M8jEvs D9hN43kb9j5aXovREbnUUt2a21iDpE1KZaJ+pJDtr4RC8GgcubBsKX1GU8eZCI1yJtdVb7SYbd3gz n+bNhwuYhiVRaQSp3ieIPwQ+sLmk71jfrsomHNiGb6EoqOitcRAFQy+yoxVPEjoGbLUJ1k/pAa/SV KsS+xNQgEQU6Gcgedb4OX/rw1yDvHFi6MRqN45TgU0l+UtFxgQQcWRb/g9xaM1+hspo+UKLIbxP6z +rrnG1Exa9h2XIEdwE0KXu+dnYd4ba+fCS4UwUesS1A5nF/GCoJuBq/gzieW1A5hQYGkGiv/hgEc0 zF+lxIdg==; Received: from mail-pl1-x62e.google.com ([2607:f8b0:4864:20::62e]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hm-001sON-2G for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:34 +0000 Received: by mail-pl1-x62e.google.com with SMTP id d9443c01a7336-1a6817adde4so26022045ad.0 for ; Wed, 19 Apr 2023 04:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902627; x=1684494627; 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=IeP1c5FHkO2iYuai0o4JGoTDumRIxR3IsfyyPznXUZQ=; b=koEw/uiEXJ4P6r+2zoaiHPM5ok/d28q5pyhF5LbHc6I1XBnEv7ikHPdbKOO5lffn/K pKDES30EiXACKywfHsDUvjjt0cOPKfvLpyg9IeEb5NLAba+5aa/Q/MLSvGSDEPWntDpi abS8us22/q+V5R+SCMXTfaaDbuG1buySAT/syibcEKpDziulkNwfG1g/R2vwvlaUG+P7 fl09D+ZXUj4CtB6cdojZ/MWvx8OjwgAgpdsksCYdzZrmbJqBWSzxhAdKGStPebuYbxLb xjGTza0fpYTfOqnhex0mFm1BxYCeEx7xKzQ1po6NxzdlGYosdnG647RnUtd+HmnyvEj7 uvrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902627; x=1684494627; 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=IeP1c5FHkO2iYuai0o4JGoTDumRIxR3IsfyyPznXUZQ=; b=Nm73HHnAGMYeuVntkPLz3Uqlb0uy77uJD+KLTwY+D9AvlS89WO2dkp2srLyqUWg2Mq 9jgJ9mpOIJrsMXh412hlv7VmuSGcWjVxhjZHOQj3VsssEUrL87wKmlv/pGcJEcQ1JOlI OpcQ8AQoUtard+w0ljiDQtWJdFMXghhHIa/7AzoovorG81TEXfEFpgYSEZntw9SyARaD yPXHmRge5xN9wtgX1+ggUpPz2HPxBy8XIX4tQ8sU1jI4U34LcbMzkk4XWeaReClqv3q4 boUe0gZfmS8FrYyYBL+gdRUR5dRMK83Jy+WE7wKi+VAqtNAQDrPxkhwtHlc5MciLx5AG Rshw== X-Gm-Message-State: AAQBX9cQUHaqeuiZRDZAoRft6yVfdca/QQrjBCFzKLFjoE4Tkhs3vo4m S5ToUmboOfkMbASfr/JifTrTy+PT5CPaX0YPC9A= X-Google-Smtp-Source: AKy350as/KHWHZ+shgMkN9Cq1xyi0sRUDBIGVeroXLacVjHMk99lR8iksTM1dFoEjEk5V5sXMqlvAA== X-Received: by 2002:a17:903:11cf:b0:1a6:81bd:c4d9 with SMTP id q15-20020a17090311cf00b001a681bdc4d9mr5507947plh.39.1681902627683; Wed, 19 Apr 2023 04:10:27 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:27 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 12/21] dt-bindings: riscv: add riscv,cbqri bindings Date: Wed, 19 Apr 2023 04:11:02 -0700 Message-Id: <20230419111111.477118-13-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_121030_950012_DCA19BBE X-CRM114-Status: GOOD ( 12.38 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Document properties that can be used in the bindings for controllers that implement the RISC-V CBQRI specification. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- .../bindings/riscv/riscv,cbqri.yaml | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Documentation/devicetree/bindings/riscv/riscv,cbqri.yaml diff --git a/Documentation/devicetree/bindings/riscv/riscv,cbqri.yaml b/Documentation/devicetree/bindings/riscv/riscv,cbqri.yaml new file mode 100644 index 000000000000..3f017c6b1fb1 --- /dev/null +++ b/Documentation/devicetree/bindings/riscv/riscv,cbqri.yaml @@ -0,0 +1,28 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/riscv/riscv,cbqri.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: RISC-V Capacity and Bandwidth Register Interface (CBQRI) properties + +description: | + Common properties for cache and memory controllers that implement the + RISC-V CBQRI specification: + https://github.com/riscv-non-isa/riscv-cbqri/blob/main/riscv-cbqri.pdf + +maintainers: + - Drew Fustini + +properties: + riscv,cbqri-rcid: + $ref: /schemas/types.yaml#/definitions/uint32 + description: The maximum number of RCIDs the controller supports + + riscv,cbqri-mcid: + $ref: /schemas/types.yaml#/definitions/uint32 + description: The maximum number of MCIDs the controller supports + +additionalProperties: true + +... From patchwork Wed Apr 19 11:11:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216731 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D7750C77B75 for ; Wed, 19 Apr 2023 12:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=drTsP5zT0yz7utxGfuTmbTPU2GYnwLamxJF6p8SaeNc=; b=4MDyLiy3xlqA+9 KlRTD3++a1a5/rr74KG6Uj5kwV78u1gfuI8O080o7sOOmcDc3c/oI6wZR4f4qwFMeiKELS0ybyNCN gtMavAkZ8WDM6kuiq4meJG7OCc4ORyv7eFlGElwBBbwzGhcy82EolYCHLGr76Yw/YdTjI5/H5RVgN e8k3TPvXeaCRMajmaNF9S1FCvmMg/x8uzPVRD4lYthAeLpNnt3uH1LTHbV3ISo5ssZGIENuiklEl1 j4U7jx3OPDoPBvx7Ggr8pCC6N+CGicH8qGUF8fRd8irITpPvZDE52hVK+b16usH37Sxsa+9APWGgv G40L4fEPeAlw6jYlPbHQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6im-005JD9-18; Wed, 19 Apr 2023 12:15:36 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hl-00584t-2G for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:31 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1a69f686345so20890975ad.2 for ; Wed, 19 Apr 2023 04:10:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902629; x=1684494629; 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=HCr/XD0oj4/oPWH13NzthrUuXXX/7UUm/KiUydqd3Cw=; b=aAPwq8SLoEojqf4NHO3Fq0Ic/0+QaSA4EA9zAFf3kHDUX2voaRramQ8jdGtKzVoPbx hLWXAYGn/it0j+rhFp9uZZ8mKg2OcYP8EQFbNmn4OdAxK5bYiLFwjMg5GpBppnG96Z/4 pNSb46QlwFQuO/D8WH9DGcEuODlqBKQPMlFseu2hz+salHNUZ8p1Wy5D60h3JSb5edS1 VFmN/9xzQeyAcRFhvLLY5YCg0Y4bhZYIQjTCfrdFsQC27BhhP5IURYfb9Jf+MTOY59ZN vfNaXPcls+Qfcukd38Dfzi82cAxdVPVUshQpCQMfJPVDkJzVDZZOyiOrDa0CxTekRJC/ XS/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902629; x=1684494629; 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=HCr/XD0oj4/oPWH13NzthrUuXXX/7UUm/KiUydqd3Cw=; b=YGIzDHrlXgf5+ys6F3GDHTk106G99M93Myv5iWZIy9Xsv4qyDmwCiLlo9DJ7l4z63m 2fv5wJum983Y5SMefCNCYpyhAgqg06ZFXKd6I0jwCGKxbUF8v1ufsXw5wlzBKhm5DjI5 Pdr7bfrdGcdMhKZ97P5O/LP19QYv4e2t00AdZgyhUgdViwo33rPv3H3YPTc5weT9aqDk qKCdtqZWFKatycjC6mbbDKij2ZBbmlgwpXqo+mw7KqnBY3A9+WZC9pKo/9pNqSpYmYsY nIxle+BRkqu3aa3bVuBImizQnvIsb4cEaezUNGfLndE650yZRqcMmIwpnhlUeKRHu/Yq u23A== X-Gm-Message-State: AAQBX9ca9+LkWJ8Xt91qdN61/QEvw+FwJscwA4xa8loDEoA3KdJjyCOv Dg6N/newW9Q22w+QxjzopL4hpbtU1tWN1ISshfI= X-Google-Smtp-Source: AKy350YvL1e3iKZvub4t9UQbFZ9Y8KdT0xLTr/OSwyPVoBE0WDLhmou6jM+HdDHR/Nje7IH58BiY8w== X-Received: by 2002:a17:903:1c5:b0:19e:ecaf:c4b4 with SMTP id e5-20020a17090301c500b0019eecafc4b4mr6514342plh.4.1681902629140; Wed, 19 Apr 2023 04:10:29 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:28 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 13/21] DO_NOT_MERGE dt-bindings: add foobar vendor-prefix Date: Wed, 19 Apr 2023 04:11:03 -0700 Message-Id: <20230419111111.477118-14-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041029_760956_D4D9E528 X-CRM114-Status: UNSURE ( 8.99 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add prefix for an example SoC vendor whose designs include controllers that implement CBQRI. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index ed64e06ecca4..426f4eef06eb 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -470,6 +470,8 @@ patternProperties: description: Shenzhen Fly Young Technology Co.,LTD. "^fii,.*": description: Foxconn Industrial Internet + "^foobar,.*": + description: Foobar Systems "^firefly,.*": description: Firefly "^focaltech,.*": From patchwork Wed Apr 19 11:11:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216732 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85A87C77B7F for ; Wed, 19 Apr 2023 12:15:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=RBsobsB4ILhAdTEqh6IGtTV+5dcc5eeGb+2kF7eM+zo=; b=PbnR/QQEViUGqS XRSbNaIixjbKF6aWQ7RcwOkxwgsvl5dIAQ4lwDimYZ5kHuZb7+G+yr88c1pAPdl1UKkg3GiRGN0Bb zH8yn7OpejIaNJWeOEGFJTGUR6Y5XCeY4NaNrtrWW2HnV/JihHQP6/dQkTM9HY5vGChe7JE9HPlUJ lzXf93XHwGjDtFBru/AMmJfY+tlwe+ckXD+7I6w2MpGxUVSCpLCgruRlC9Zby94N4G2SCFPyT7Ybr OfJj4v6AXnFlw+zW1ahdkAUVA6qITY6EISLKcsvVDe4aqd2SvB/8nlsTryGBbR/M7fBV7d9nmFCV8 +/8/Bk7oEuwkkt+8zoNA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6io-005JFR-1k; Wed, 19 Apr 2023 12:15:38 +0000 Received: from mail-pf1-x430.google.com ([2607:f8b0:4864:20::430]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hp-0058Gy-28 for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:36 +0000 Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-63b73203e0aso15254003b3a.1 for ; Wed, 19 Apr 2023 04:10:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902630; x=1684494630; 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=z6zQom7c9ZPxaL0AlvEMhKoZ47HVwA0KXR3RYZHyFgk=; b=way4ScdIS96YRKdHcgBpyse+tOSSXOie7JmzQ3ruykWd+bvImdobFO37hhT77+L3/U kaqojTkCN3wGLtbhwA90MgVOAgFVGf4Dedela1TNzHBvJRZjXQSXWFwPwduhVj6TPdzX GIc+Nuk7F+h6MKBmdyl2qvDlk02/j2I47Ppo5mo1ZpuQIvpD572EFN7U+sOSUY8XSxOw WOi4FCrreEQEdHwpWijIg+JK2+Lnl3ALjpm7l3mTxtaHBsOCVR7Bn5fo01aFxF/GJUow MnGtG2IiDAagEyhqLKjTxyj+uGdYLVG4BA2My74jN6jA7ZYKA/Gg5Wy1kJphb7t+NVe8 GiJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902630; x=1684494630; 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=z6zQom7c9ZPxaL0AlvEMhKoZ47HVwA0KXR3RYZHyFgk=; b=Cutltdd3f9Bu+iGQlvVNG2grv/aKHxmPTkN7ZDb0vkJperr9pq0mtPeAEU148LIQrn qeMAnmT0+zOHde2+jqB5lVIJltlVb8FUh3TmMNWSMr4/iKuJA+BeLWsuDnG4XxKQlrZJ pkVWTmcg62An44SwKqCKggdF30Gy7+XLN8SRPv+BjpvmFJv4w+2GR6obO1quxSoBQGsf 7YMyLVSv5JMyhoVweO+1L6bSC1LWbjd5q+fIM+rEjOLEMmTnZpjK14AaYJEdkPFJRIVl ux18KzJJF4+TJkb2BbvUMJ+t6S8FFliMR3L6jz6xZTLiJObEUrNOhxml4+qcrajWfjJ4 L0aA== X-Gm-Message-State: AAQBX9fOUopFNPh2o4DTzAMGgDvamybcDScjca1vCJdLWfyd7M236qzd DCQ2ljvDSb6q5YlN51fSReyHmq8g5m+VTZ3OtHQ= X-Google-Smtp-Source: AKy350ZMyASO/6WHrB2YnJ1c5qAAic0H4uqyutx85aVkcy8OYWscNutmT//7hNt7yI5Yb0peas0zAA== X-Received: by 2002:a17:902:dad0:b0:1a2:a904:c42e with SMTP id q16-20020a170902dad000b001a2a904c42emr1574829plx.24.1681902630432; Wed, 19 Apr 2023 04:10:30 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:29 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 14/21] DO_NOT_MERGE dt-bindings: soc: add Foobar SoC cache controller Date: Wed, 19 Apr 2023 04:11:04 -0700 Message-Id: <20230419111111.477118-15-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041033_697865_4C2EE228 X-CRM114-Status: GOOD ( 12.36 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add bindings for an example SoC cache controller that implements CBQRI. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- .../soc/foobar/foobar,cache-controller.yaml | 51 +++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/foobar/foobar,cache-controller.yaml diff --git a/Documentation/devicetree/bindings/soc/foobar/foobar,cache-controller.yaml b/Documentation/devicetree/bindings/soc/foobar/foobar,cache-controller.yaml new file mode 100644 index 000000000000..6348483bbe09 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/foobar/foobar,cache-controller.yaml @@ -0,0 +1,51 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/foobar/foobar,cache-controller.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Foobar SoC Cache Controller + +maintainers: + - Drew Fustini + +description: + Foobar SoC cache controller implements the RISC-V CBQRI interface for + capacity allocaiton and usage monitoring. + +allOf: + - $ref: /schemas/cache-controller.yaml# + - $ref: /schemas/riscv/riscv,cbqri.yaml# + +properties: + compatible: + items: + - const: foobar,cache-controller + reg: + maxItems: 1 + description: A memory region containing registers as defined in CBQRI spec + + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + + cache-controller@fff12000 { + compatible = "foobar,cache-controller"; + reg = <0xfff12000 0x2000>; + cache-level = <2>; + riscv,cbqri-rcid = <64>; + riscv,cbqri-mcid = <256>; + }; + +... From patchwork Wed Apr 19 11:11:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216729 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 301D0C77B73 for ; Wed, 19 Apr 2023 12:15:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=2J6xJgxGUVITXuFrMa40Le3OWym+T61KXWrf++COMkE=; b=vbweiDXGDAmmR6 NKJzuvaHE11qmgzSoIWc1ngLA2XB0JMPSoa+8gARU3FY6Ldpr/s/Ng8wMPB5zT3oyasRTdV7Jb0X3 wGjWlGBicOjPAaPCzOELn/o8yP5ar+OZQ+A46GrLIYOzesMJ+zsKLzNFcf1aqcdSsggVDjsKGuhDk xC/HgbpCjvu2PCvb8NF9YTEFrL3WcjJJ3LbUxutps4SpgbwWNUHvtyC1O6HkwcZWnv7IsedTdVrLV jvZ0vIthxVF9C7Sh+9EqaurPKhjQdNPER2K32daltYVeFx+dim3k6ThpV4CHfDS1iJfr5Q6aDq6qc aysvKqcujs6NG4FZfGWw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6im-005JDj-2u; Wed, 19 Apr 2023 12:15:36 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5ho-0058He-1e for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:34 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-63b8b19901fso2360632b3a.3 for ; Wed, 19 Apr 2023 04:10:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902632; x=1684494632; 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=hTUdiTLb+sfXCVtetWlAgKKAKfkEOw5o717LduaEZcE=; b=xsELkwofXkO/cQsRhRzGSc4LNBA8d5ZwB4JnQLYCH4ZaGVuBP+nbM8feALhCz/sIMz MyuAV7iJQoGOCditkX7ry8YYdS0Nawh0XkuVc25RdlnISTlsepB5DEmsSviF6P1Gq8W4 sluFvFa7S6qFMHylgIRnoWU+6wHZRBJBUaeX7Sg9yxxQWXO1Q99it5uMYgycZZad/mrL L8gpu72e7D0hEFnYS3yPVgIo9Q/KR5HvUJJ8GoySwWCZyTXYyPT6AAPNupIgcX6fR6M5 jjYX2ppBNUoKa7qiG/Pd8D5X9175xTqsx/8xUD1d+dBmEDXhg71wkyYYTOIWDsckkHdb 50sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902632; x=1684494632; 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=hTUdiTLb+sfXCVtetWlAgKKAKfkEOw5o717LduaEZcE=; b=b6D7X8wOO+hELhi0OdwgaZ4ay9Wt4qqrU3FSWKqp5zHfWd8j+G3GNIPCXl7mjCCmeY aQwcH+4oYhU4S4ayCMNQeB7Z7SIV3bn98vEeWG4oubv+jONy+G9IyrQxSSwW8aOr/2D7 DJKni8xAos/wst37qmqVByDF2RfUUd07cIKctbZrZSFEMzRHFq3IZ+Zwh54g9sh9d6PO kGzr1rSshD6DOiGlJxwSGqXGeqx9KkK88kuKu7M3AfHGHmIdhb7wg6MoY4QJ4SK49tWS QByNkV3QrsbcmcVvf5aX4gh0LS4t29xfeNZfVBT+3qDAei5yITdcIzT7G8ftEs2ViecN Xy+Q== X-Gm-Message-State: AAQBX9eJ5bL0xaPt7UhNk/sQHxfSphRg1Ojddvzr6Zk9aymeVQ8cbEXL 5TAUqKZBBD0RWsB60DV88Vp4Nikf2np32hUSQa4= X-Google-Smtp-Source: AKy350brfXXAlUzH+qw561taTYPU1WAFCWw0yqnL0lAKNxrOpHa9fu+9+OhVuIBQrfZgZmagCJ0UZw== X-Received: by 2002:a17:902:b60a:b0:1a5:5e7:a1cc with SMTP id b10-20020a170902b60a00b001a505e7a1ccmr4412371pls.58.1681902631792; Wed, 19 Apr 2023 04:10:31 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:31 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 15/21] DO_NOT_MERGE dt-bindings: soc: add Foobar SoC memory controller Date: Wed, 19 Apr 2023 04:11:05 -0700 Message-Id: <20230419111111.477118-16-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041032_558943_48267AD8 X-CRM114-Status: GOOD ( 12.65 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add bindings for an example SoC memory controller that implements CBQRI. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- .../soc/foobar/foobar,memory-controller.yaml | 49 +++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Documentation/devicetree/bindings/soc/foobar/foobar,memory-controller.yaml diff --git a/Documentation/devicetree/bindings/soc/foobar/foobar,memory-controller.yaml b/Documentation/devicetree/bindings/soc/foobar/foobar,memory-controller.yaml new file mode 100644 index 000000000000..859ee52680d5 --- /dev/null +++ b/Documentation/devicetree/bindings/soc/foobar/foobar,memory-controller.yaml @@ -0,0 +1,49 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/soc/foobar/foobar,memory-controller.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Foobar SoC Memory Controller + +maintainers: + - Drew Fustini + +description: + Foobar SoC memory controller implements the RISC-V CBQRI interface for + capacity allocaiton and usage monitoring. + +allOf: + - $ref: /schemas/riscv/riscv,cbqri.yaml# + +properties: + compatible: + items: + - const: foobar,memory-controller + reg: + maxItems: 1 + description: A memory region containing registers as defined in CBQRI spec + + '#address-cells': + const: 1 + + '#size-cells': + const: 0 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + + memory-controller@fff12000 { + compatible = "foobar,memory-controller"; + reg = <0xfff12000 0x2000>; + riscv,cbqri-rcid = <64>; + riscv,cbqri-mcid = <256>; + }; + +... From patchwork Wed Apr 19 11:11:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216734 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D3F8EC7EE21 for ; Wed, 19 Apr 2023 12:15:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=1J/Vfy5RgiAfiXtMlYtWuMpMJ3guwd7MCFUOeBVo/oo=; b=RWec6KC6/hh8o9 Ap1ncQszBFSCIpYvK+co4ju2zt+smr7RTFEBobYrTh7gFrzj4yc39eG8ySncNaQmh9FzdS8o11fdx F8Qisk5tvjpZHQyM5pqPJjQSPN446XEIpiCz0ws64U/a42galfXXNi4P4W58m9Z3L29Qe5EHNglcf eK+UVLsAB+89QRXPvapFX1LTE17BnXuQepbC5ssnhHCGknvNK4F7zgimfdngp6WJV7vkfsrIO5Ppn h9wHUhq2ZCGERx2W2MFLp0jzWy6KT1RnW0EsiLue8RA0jhmUXwTjGQ4o0n6ep1vfvES/xSVmq46pI ARvnOAXE0IglnTZYvNxQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6io-005JEn-00; Wed, 19 Apr 2023 12:15:38 +0000 Received: from mail-pf1-x431.google.com ([2607:f8b0:4864:20::431]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hp-0058Il-2I for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:36 +0000 Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-63b5c4c76aaso2295073b3a.2 for ; Wed, 19 Apr 2023 04:10:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902633; x=1684494633; 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=4KIa9LYf0ODhdzKLybQD/gUKKX1O1GxO+uhQNo6blW0=; b=pUSEDOCWgGuTM6CKmcMbLe7K+VOkG5kdfv7sgvZJDVGFEauQg8GskJ5TTq2rw1I6ez a4gXs8myGV03gRZXVVqsyS/7/8DH7w0epDUQ3fvNC7tevtjQjX0gSYw70qXumUZaaFa6 DH6lCMZCnrzOYMP0MppSRHS0q2PYutLF7G3iwmA9AWub3Qok28lGtTEQVcvehX88Kxzj U+7U70eWTaa3h+dXWUwmrKUrXXA+R4glloG/L9M30GuYrk6RwK0JTFwq/4BqBd86WiG4 uowQOItfzun2u7UVpigFCvFhsY+Q4pjh4qafYnaUIgZfcaXOcwVTIOfBSzvLVMchFfCU MtXw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902633; x=1684494633; 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=4KIa9LYf0ODhdzKLybQD/gUKKX1O1GxO+uhQNo6blW0=; b=M+uf4rj9zBSqTyQNo/Xt8tAHdFyySnDUmBULd7kpAfwvMvfcEL/9UhgNCLEUHcFViw 5RSZVIX9R/VZBWMeTjCkbjI+yYM61tVKRTnOwrHSEDrP6+1mgYnhFrXy5NcTuBuVQwtd Fz5H9Cp9MQ8t90P4aB66LXsMVTkmSUjhjKdehUw0UFwBrLGpedvSE8NIrpSzSc0Vdq7N Rncw9wKcgr693y5VPKRPXMwQO+Ivnua4UV/I1rsmd77d4iOINatAt1g7OahplMP5Kleh BsrNyqD1UYvkWuKDVuzrBrYqMda5DTLoPAs0WJN5maiCKH3IdF/jmwpmtYCJ0LH/A9zc eoVg== X-Gm-Message-State: AAQBX9eQYJFkrhHjYRaAHXAkMSHHiDgYsG2YidsykW9HX8r3iau+za5e DW3GnFt+tj/sPngjD3rZcFHvk8QllcVcj8vGWIw= X-Google-Smtp-Source: AKy350alD0YaRVGGNagBcrgS+2r6G4GIg0rKJmQJt7bkhxnweSuXRSxUzkixMdfbGE9ubu0LMJS1wQ== X-Received: by 2002:a17:902:d4c6:b0:1a6:523c:8583 with SMTP id o6-20020a170902d4c600b001a6523c8583mr5718626plg.68.1681902633050; Wed, 19 Apr 2023 04:10:33 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:32 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 16/21] DO_NOT_MERGE soc: add Foobar SoC cache controller driver Date: Wed, 19 Apr 2023 04:11:06 -0700 Message-Id: <20230419111111.477118-17-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041033_762476_35710E69 X-CRM114-Status: GOOD ( 17.33 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add example driver for a cache controller that implements CBQRI. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- drivers/soc/foobar/foobar_cbqri_cache.c | 110 ++++++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 drivers/soc/foobar/foobar_cbqri_cache.c diff --git a/drivers/soc/foobar/foobar_cbqri_cache.c b/drivers/soc/foobar/foobar_cbqri_cache.c new file mode 100644 index 000000000000..e880488243d8 --- /dev/null +++ b/drivers/soc/foobar/foobar_cbqri_cache.c @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Foobar Systems CBQRI cache controller + */ + +#define pr_fmt(fmt) "foobar-cache: " fmt + +#include +#include +#include + +static const struct of_device_id foobar_cbqri_cache_ids[] = { + { .compatible = "foobar,cache-controller" }, + { } +}; + +static int __init foobar_cbqri_cache_init(void) +{ + struct device_node *np; + int err; + u32 value; + struct cbqri_controller_info *ctrl_info; + + for_each_matching_node(np, foobar_cbqri_cache_ids) { + if (!of_device_is_available(np)) { + of_node_put(np); + continue; + } + + ctrl_info = kzalloc(sizeof(*ctrl_info), GFP_KERNEL); + if (!ctrl_info) + goto err_node_put; + ctrl_info->type = CBQRI_CONTROLLER_TYPE_CAPACITY; + + err = of_property_read_u32_index(np, "reg", 1, &value); + if (err) { + pr_err("Failed to read reg base address (%d)", err); + goto err_kfree_ctrl_info; + } + ctrl_info->addr = value; + + err = of_property_read_u32_index(np, "reg", 3, &value); + if (err) { + pr_err("Failed to read reg size (%d)", err); + goto err_kfree_ctrl_info; + } + ctrl_info->size = value; + + err = of_property_read_u32(np, "cache-level", &value); + if (err) { + pr_err("Failed to read cache level (%d)", err); + goto err_kfree_ctrl_info; + } + ctrl_info->cache.cache_level = value; + + err = of_property_read_u32(np, "cache-size", &value); + if (err) { + pr_err("Failed to read cache size (%d)", err); + goto err_kfree_ctrl_info; + } + ctrl_info->cache.cache_size = value; + + err = of_property_read_u32(np, "riscv,cbqri-rcid", &value); + if (err) { + pr_err("Failed to read RCID count (%d)", err); + goto err_kfree_ctrl_info; + } + ctrl_info->rcid_count = value; + + err = of_property_read_u32(np, "riscv,cbqri-mcid", &value); + if (err) { + pr_err("Failed to read MCID count (%d)", err); + goto err_kfree_ctrl_info; + } + ctrl_info->mcid_count = value; + + /* + * For CBQRI, any cpu (technically a hart in RISC-V terms) + * can access the memory-mapped registers of any CBQRI + * controller in the system. Therefore, set the CPU mask + * to 'FF' to allow all 8 cores in the example Foobar SoC + */ + err = cpumask_parse("FF", &ctrl_info->cache.cpu_mask); + if (err) { + pr_err("Failed to convert cores mask string to cpumask (%d)", err); + goto err_kfree_ctrl_info; + } + + of_node_put(np); + + pr_debug("addr=0x%lx max-rcid=%u max-mcid=%u level=%d size=%u", + ctrl_info->addr, ctrl_info->rcid_count, ctrl_info->mcid_count, + ctrl_info->cache.cache_level, ctrl_info->cache.cache_size); + + /* Fill the list shared with RISC-V QoS resctrl */ + INIT_LIST_HEAD(&ctrl_info->list); + list_add_tail(&ctrl_info->list, &cbqri_controllers); + } + + return 0; + +err_kfree_ctrl_info: + kfree(ctrl_info); + +err_node_put: + of_node_put(np); + + return err; +} +device_initcall(foobar_cbqri_cache_init); From patchwork Wed Apr 19 11:11:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216685 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id AD47BC6FD18 for ; Wed, 19 Apr 2023 11:45:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=PRA+6qbbVCv989P5SA30LJgF498TMc929egRzQStjCk=; b=FFKGnyjDddd/6/ JrIixAdMZcLzQjA0jdgxRHLj0AMA1qxF5t4l0dTJdcxaYBhUO1CEiKyjx73SzEclHDNLFh8JGdVsY 3El2ARjHfZRnEZsay4A9wM/qWvaI6fclhiOnp0wysB2y7dVYfnQfYMHO2YNF+JyabctXLS4lmviO0 LIj6TnSYjTo7xr5Jctr2lVDsioVdiT8X5hwbb0wqdn+od4UX1fnQBOPCI+MsBoIF4xfGXOq1hRUtN y2ZjQpzRVwOHeW5xF4fCZRsMMTnE3kab3to5K1iojkzzZgL/saePJlglzdEI6KFJdpPHPVvCATcEi 7QMSA4AGpYw8YPPSRmrw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6Fc-005E3Y-0D; Wed, 19 Apr 2023 11:45:28 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp6Fa-005E3F-0L for linux-riscv@bombadil.infradead.org; Wed, 19 Apr 2023 11:45:26 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=8VRpPNkDuAyz+Ft5imrcs9KDU5p5mtKUYR9cIj3QRd4=; b=iPOHcttdQWpR7jE3yI55MPOIec 8Pgjr0hX2Fe9eSKxN5fc1wB/OyIPPFwk7Sd+iLfBGRKlATFEJHczQ41s+SB/jkUlbGCobVYeJqf5Z 5cErZXfuDqGApPqILrJJWbMZrtQNeBCOVT3cYz+Y2CnPX2/3ZWOPDXR1wPAa+6kjDmGAxB+1d+5rp uSYlszp1kBLAwxjqd2gmOaiYlRPgT7nRckzv2gimd213azj2d37vwHdsZbpXynALuD4x7utdqiXQB KTdNV/PwIexK0EY+4rSbql0Wdt18GDnpMDgRNJBBwrLKVbzBM0d/gWRN81NdbEO2BSKzKbw2o3+4y tzk5XeXA==; Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hs-001sOg-38 for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:39 +0000 Received: by mail-pl1-x631.google.com with SMTP id d9443c01a7336-1a645fd0c6dso24014545ad.1 for ; Wed, 19 Apr 2023 04:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902634; x=1684494634; 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=8VRpPNkDuAyz+Ft5imrcs9KDU5p5mtKUYR9cIj3QRd4=; b=x/8pGfsLNTo4M60IL76aQ5x040uI2InLj1/EScIFp6VYlhbjP5l3eNVgN+y4avjRTt H5fzYWvVhJT2Rq7bzjd2zo6SGa9b70+iPd7q+BYZOfnbxUKSB2gBI+v9EID/w220Xv6A ogg1jlEVmqJYIyFKd2qTHBIQq91+m87zuaTfEpDGjS4JjD5plCp7XDP57KjGuKZ+kOiN SVYdRu2DZSdcypVQLwcCpNb8l4lKH0jilJ++oP1hk4KiAaDnMtqJcq8eN39x6hZzCeaP j6FiQUn7+p1qacItyHJxcwZOT4dU4m7qvkAF3FVlQoqYsjD4V5HP3V7p3ikdeOowNAkl 8kWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902634; x=1684494634; 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=8VRpPNkDuAyz+Ft5imrcs9KDU5p5mtKUYR9cIj3QRd4=; b=c99Y2snmy76vrNTnUBXwQ2apjODyFPGE7m2cDSY9AIXUgNb4v22MwBcgIUig2nc7hI /RvOa6n3c7I0L7FVcAMVOMbqjyHWccF8ONQNcVTD0xbkQtsx1B2kd/wOun6meYRL8lBL 0zPXVfeQ5kA4yN9QtwgMEwXlfEgpIajuH/XJYYXuEOlyQBD+48QL0R509rasQD+V2+fz LuHTtPsam550bgOmqb6p9VyvaLfOq8G3PEpiqOZj5lT2svM7pil1xhtpz6XVbbayRX6C WhjL0CAXaYQ1yXprZJZDvNYVGuPXOlu0YSv1Fo9EFN5G8PX4C3wiu2NrzEICqkEolF9r Qh3g== X-Gm-Message-State: AAQBX9eKdp9Wn9MdOIRaNW6sT6NOPfe/di4U1yroNoquOK/RmfYR6Man Q1E8zyBhL/rFxTt19ZPr1sI0+U0ZP3b6PSCPbQs= X-Google-Smtp-Source: AKy350boG05NBC+OyMdfVB4g1lkdqwK+pdBb8M8du2YV2tJ6Pxg4DvMv0hsz2y7ET8IQwFhAUURrrw== X-Received: by 2002:a17:902:db0f:b0:1a1:a9a4:ba26 with SMTP id m15-20020a170902db0f00b001a1a9a4ba26mr5908976plx.8.1681902634412; Wed, 19 Apr 2023 04:10:34 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:33 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 17/21] DO_NOT_MERGE soc: add Foobar SoC memory controller driver Date: Wed, 19 Apr 2023 04:11:07 -0700 Message-Id: <20230419111111.477118-18-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_121037_186078_5F6BB143 X-CRM114-Status: GOOD ( 15.99 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add example driver for a SoC memory controller that implements CBQRI. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- drivers/soc/foobar/foobar_cbqri_memory.c | 83 ++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 drivers/soc/foobar/foobar_cbqri_memory.c diff --git a/drivers/soc/foobar/foobar_cbqri_memory.c b/drivers/soc/foobar/foobar_cbqri_memory.c new file mode 100644 index 000000000000..0a0c542a25e1 --- /dev/null +++ b/drivers/soc/foobar/foobar_cbqri_memory.c @@ -0,0 +1,83 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Foobar Systems CBQRI memory controller + */ + +#define pr_fmt(fmt) "foobar-mem: " fmt + +#include +#include +#include + +static const struct of_device_id foobar_cbqri_memory_ids[] = { + { .compatible = "foobar,memory-controller" }, + { } +}; + +static int __init foobar_cbqri_memory_init(void) +{ + struct device_node *np; + int err; + u32 value; + struct cbqri_controller_info *ctrl_info; + + for_each_matching_node(np, foobar_cbqri_memory_ids) { + if (!of_device_is_available(np)) { + of_node_put(np); + continue; + } + + ctrl_info = kzalloc(sizeof(*ctrl_info), GFP_KERNEL); + if (!ctrl_info) + goto err_node_put; + ctrl_info->type = CBQRI_CONTROLLER_TYPE_BANDWIDTH; + + err = of_property_read_u32_index(np, "reg", 1, &value); + if (err) { + pr_err("Failed to read reg base address (%d)", err); + goto err_kfree_ctrl_info; + } + ctrl_info->addr = value; + + err = of_property_read_u32_index(np, "reg", 3, &value); + if (err) { + pr_err("Failed to read reg size (%d)", err); + goto err_kfree_ctrl_info; + } + ctrl_info->size = value; + + err = of_property_read_u32(np, "riscv,cbqri-rcid", &value); + if (err) { + pr_err("Failed to read RCID count (%d)", err); + goto err_kfree_ctrl_info; + } + ctrl_info->rcid_count = value; + + err = of_property_read_u32(np, "riscv,cbqri-mcid", &value); + if (err) { + pr_err("Failed to read MCID count (%d)", err); + goto err_kfree_ctrl_info; + } + ctrl_info->mcid_count = value; + + of_node_put(np); + + pr_debug("addr=0x%lx max-rcid=%u max-mcid=%u", ctrl_info->addr, + ctrl_info->rcid_count, ctrl_info->mcid_count); + + /* Fill the list shared with RISC-V QoS resctrl */ + INIT_LIST_HEAD(&ctrl_info->list); + list_add_tail(&ctrl_info->list, &cbqri_controllers); + } + + return 0; + +err_kfree_ctrl_info: + kfree(ctrl_info); + +err_node_put: + of_node_put(np); + + return err; +} +device_initcall(foobar_cbqri_memory_init); From patchwork Wed Apr 19 11:11:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216735 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7F82DC7EE22 for ; Wed, 19 Apr 2023 12:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=twgevVnO4qNMtqTHL9LcywBiZrlUcrPmTAuDBcJK6mI=; b=ihwJBSMO1zGv2G VrIRVXzgB5ZKlHyXuzHBmSI9Ggu0NcDoPMv+2YR0Bj7p0m2s50kKtQe638qFur+eWM9ZjeMnl1h9E 8I+7QYtKFhMeUbpLfumbR11ODDzw6Ursx1lMgTeRo4HbO504xE+yzN8kBW5JjIYwH3qM95e7RHvsH t6FZVFDGnqx+YlT1MDSuAL/2NpKhjX+WAXxJXnvI0jxjaLRTLG/50RreGGibXPT4VxRa8VLmzxvTJ gD5uHJkYezku1OAB1Vran7K39eFRWtP8Fj7NIYNhHJZod5xUImbdzYBigSUJ5CN6JNz+kC7g/vJZR iyBGlGO3A3V0M0lejpNw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6ip-005JG9-0J; Wed, 19 Apr 2023 12:15:39 +0000 Received: from mail-pf1-x42b.google.com ([2607:f8b0:4864:20::42b]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hs-00585b-0i for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:37 +0000 Received: by mail-pf1-x42b.google.com with SMTP id d2e1a72fcca58-63d4595d60fso6108567b3a.0 for ; Wed, 19 Apr 2023 04:10:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902635; x=1684494635; 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=QMTmZYX45TS17GLlk7oZqME3pRStBNddDLQwkiv9SHY=; b=46+5TNw+d2+58D3lEwkZD1Q8Gjos23n16w76kwCbjIECo1omLOWdsqJ46O7WHdtCVf D6qRVkiwMOMRAxvlv69gS5768jAdvZ3q7SLH2mCNoo7pA6DoTBc59/I15a15pUslSRDK /sazIdZh4izVkCBDGPfmF4UdHbNV47UlD3fcXsGPM4eRj25LcXDU0OhV/GDD0igGJuqH ml6QdIY3yH15VCschcFTjCoiOk0b8wP3ZHQkAxu3r7qM6fXIOAtfEp8TawssQfzZ+3jQ Pz4fkHwI1vBeH+6KTWIqpWvkeSeuRVl81TzDA/3EEnLNJgOPMIAgi3B1w0h0VX43lGZj JPxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902635; x=1684494635; 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=QMTmZYX45TS17GLlk7oZqME3pRStBNddDLQwkiv9SHY=; b=fhjma3hw5OUSh3+gF3BquDU3c/1ic8LvjQa2VMvajIBadmCPT8/nhK1xrPwm1sL6Ie w7fcDNlSsdSUSZ9/XG397yS22mccwN4ArYdjq5fUwe45awD7Mlg59k1RDBfbl4MBvHL+ TkL8iVRTTG6RDfbN8/4ZpN6jObZ82rk8WYGQWZ/6BU6s2YKD44GtdOFxgC+CFMQJMGhR 5wpKTO31iXeACqEbhqJmggTGJl5wyoW8y7Dd2/VFRCziR3D7adN+om8iMPAK2fSrbAgO 2sqA+/dg0m05dxN4nAIKp+LGPBSifz9YkWr/jmK/r3EQwUBNvpZD+DU1OJXg5+8waR5r 0XcA== X-Gm-Message-State: AAQBX9ccsTPIOXcewFfV5bh3UO6dvqDuwkSMLvY4ce1058xGEGEf30Wn uhC4rk311ThlIWrRXzAPQulhAiGgQvOluYOOJCI= X-Google-Smtp-Source: AKy350bNtcXmBs3y7eW4IdMHqOa9Oa7W5HHD92Z47TlERpw2rIKTANDR14gbiWN3KKUZ+zGReRRKzw== X-Received: by 2002:a17:902:fb06:b0:1a2:89eb:3d1a with SMTP id le6-20020a170902fb0600b001a289eb3d1amr2109505plb.6.1681902635547; Wed, 19 Apr 2023 04:10:35 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:35 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 18/21] DO_NOT_MERGE soc: build Foobar SoC drivers Date: Wed, 19 Apr 2023 04:11:08 -0700 Message-Id: <20230419111111.477118-19-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041036_307319_DB9176AA X-CRM114-Status: GOOD ( 15.37 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add Foobar SoC cache and memory controller drivers to the build. The hypothetical Foobar SoC serves as an example of an SoC with controllers that implement the RISC-V Capacity and Bandwidth QoS Register Interface (CBQRI) specification. Link: https://github.com/riscv-non-isa/riscv-cbqri/blob/main/riscv-cbqri.pdf Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- drivers/soc/Kconfig | 1 + drivers/soc/Makefile | 1 + drivers/soc/foobar/Kconfig | 21 +++++++++++++++++++++ drivers/soc/foobar/Makefile | 4 ++++ 4 files changed, 27 insertions(+) create mode 100644 drivers/soc/foobar/Kconfig create mode 100644 drivers/soc/foobar/Makefile diff --git a/drivers/soc/Kconfig b/drivers/soc/Kconfig index 4e176280113a..8578f8c607ff 100644 --- a/drivers/soc/Kconfig +++ b/drivers/soc/Kconfig @@ -8,6 +8,7 @@ source "drivers/soc/aspeed/Kconfig" source "drivers/soc/atmel/Kconfig" source "drivers/soc/bcm/Kconfig" source "drivers/soc/canaan/Kconfig" +source "drivers/soc/foobar/Kconfig" source "drivers/soc/fsl/Kconfig" source "drivers/soc/fujitsu/Kconfig" source "drivers/soc/imx/Kconfig" diff --git a/drivers/soc/Makefile b/drivers/soc/Makefile index 3b0f9fb3b5c8..37a77c2dab94 100644 --- a/drivers/soc/Makefile +++ b/drivers/soc/Makefile @@ -11,6 +11,7 @@ obj-y += bcm/ obj-$(CONFIG_SOC_CANAAN) += canaan/ obj-$(CONFIG_ARCH_DOVE) += dove/ obj-$(CONFIG_MACH_DOVE) += dove/ +obj-y += foobar/ obj-y += fsl/ obj-y += fujitsu/ obj-$(CONFIG_ARCH_GEMINI) += gemini/ diff --git a/drivers/soc/foobar/Kconfig b/drivers/soc/foobar/Kconfig new file mode 100644 index 000000000000..4548e822357e --- /dev/null +++ b/drivers/soc/foobar/Kconfig @@ -0,0 +1,21 @@ +# SPDX-License-Identifier: GPL-2.0 + +config FOOBAR_CBQRI_CACHE + bool "Foobar cache controller for RISC-V CBQRI testing" + default y + help + Support the cache controller in a hypothetical "Foobar" SoC that + implements the RISC-V Capacity and Bandwidth QoS Register Interface + (CBQRI) specification. + + If you do not care about testing RISC-V CBQRI, then choose 'N'. + +config FOOBAR_CBQRI_MEMORY + bool "Foobar memory controller for RISC-V CBQRI testing" + default y + help + Support the memory controller in a hypothetical "Foobar" SoC that + implements the RISC-V Capacity and Bandwidth QoS Register Interface + (CBQRI) specification. + + If you do not care about testing RISC-V CBQRI, then choose 'N'. diff --git a/drivers/soc/foobar/Makefile b/drivers/soc/foobar/Makefile new file mode 100644 index 000000000000..e4f34058e39e --- /dev/null +++ b/drivers/soc/foobar/Makefile @@ -0,0 +1,4 @@ +# SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_FOOBAR_CBQRI_CACHE) += foobar_cbqri_cache.o +obj-$(CONFIG_FOOBAR_CBQRI_MEMORY) += foobar_cbqri_memory.o From patchwork Wed Apr 19 11:11:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216738 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9EAC8C7EE24 for ; Wed, 19 Apr 2023 12:15:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=E4yKfgTW/UsTZW0j32mHdyMkf30eKw3Bu2zbEemd7js=; b=XszjLtm36w0EVe 9+W3GTTv3qcRcT51LWZWfToY3yv0N5TQ6BgeKEb4+3reQZNP9AvHQvDxcid2/wIsNSXdTbHulImHp qnLSkRgYc2knIov8OAWz7QgZWbHRJ2Yyt/8XZiHCWWg/28nZWmBgySWEOmEGS7xN2C4cDTLCvB2lu 0XuI5dwayl7wL193T6jPkfHAhXBklahD1hX8x0ujcu2f4WnyTA3B1/ryOTj6l7bey9xqS/4mZgSjl MnRaLlHClaL8H2xuSxs0Pgd6dsA8oNnCNpoWdqXFkG+5sHIxg4YGqWvvQiGw4U45tuTnXOAMGxfSW hrBtZRNf2Kpsa0caf52Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6ip-005JGn-2B; Wed, 19 Apr 2023 12:15:39 +0000 Received: from mail-pf1-x42f.google.com ([2607:f8b0:4864:20::42f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hv-0058ML-1J for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:41 +0000 Received: by mail-pf1-x42f.google.com with SMTP id d2e1a72fcca58-63b5c48ea09so2658992b3a.1 for ; Wed, 19 Apr 2023 04:10:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902637; x=1684494637; 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=c7Svk0AxAB3qoYix/qOEG4Vz2rPPucsqQxdMzpYchZI=; b=XmTXt7ZqxWddAV0JDjC4c6Eovx0mOpcDKBV+L7pg9kHRvcw0NrF6W5p8otcbboa+62 0Yk50tsyKQO7E16Y/ShbQGi0tV2oXZlaNnHeVE6My6EBSsLfSGdR1+H6hWc/4acwEQ7I sWiwrUzhpp1UOdQZv3Ffz/odeJ0xUcVsv6OZr4R81gtBHSsPz8N3GNMSFdOKlQ1aHAs8 /spzVKy5R+TMO/mlwy+UzyNZCIWi2iWBDIZpNtT4Ax7/9NE7gFAnx/7iTw594j+hUdmv 76inOtM+g2caKo9rqPK7MQtjifRFGMhyGybonQmyu8ffgr+glE+3PiwJvmG3YUL2vKP6 mFvw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902637; x=1684494637; 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=c7Svk0AxAB3qoYix/qOEG4Vz2rPPucsqQxdMzpYchZI=; b=PmrabT15wTRL55jwNXvdIowu2I8iZ+Y+xYvil+3xDDBc2F/8iCqMAxRpFVq/8CVBls 0ALNUTo6o38dxMVz0zvpYaVzR8wDrDRtdLCrlCy/oblE/QIGK7ladgwlILA0diDsTEQi rQ1GFOxNEKvnIgTsg/9r9oG1teRa7nstaM6vIS+diNQp7xteGVZtjjSZQFrfT1L+t1tn aEvUZ6Avx/2bdpz9PoRzvARaCPswz1AWHpKxY0GT+OGrTmlx6holpvxqh/Afv0nQqc4F LewkfPndbWTHIGRYbxj17rce9iWVXH1/kcCsLXLGcinXeDQnwnMI+DpFP7tuUCEzn5Hl 1/dw== X-Gm-Message-State: AAQBX9dAM2Lg9z80yBrwmwQUnxqoLmtWQ0iAZRueYywz7RM9kaE8EcT5 FfM1+vxLsN19PPgpHV+iHyLpMD3z2PRtRHgiXJE= X-Google-Smtp-Source: AKy350Y+nSBqUtz+XvYHUUrNKxlm15TSYw6mypxGarQ1iC83U3uspOXzd41NldV5dyN0PmskVrA9XA== X-Received: by 2002:a17:903:294c:b0:1a6:ebc1:c54d with SMTP id li12-20020a170903294c00b001a6ebc1c54dmr4710186plb.30.1681902636996; Wed, 19 Apr 2023 04:10:36 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:36 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 19/21] DO_NOT_MERGE riscv: dts: qemu: add dump from riscv-cbqri-rfc Date: Wed, 19 Apr 2023 04:11:09 -0700 Message-Id: <20230419111111.477118-20-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_041039_447614_7A91899F X-CRM114-Status: GOOD ( 13.42 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Dumped dtb from qemu branch riscv-cbqri-rfc which is on top of qemu master (tag: v8.0.0-rc4) with qemu/VERSION of 7.2.94 invoked with: qemu-system-riscv64 \ -M virt \ -nographic \ -smp 8 \ -bios output/images/fw_jump.elf \ -kernel $HOME/kernel/cbqri-linux/arch/riscv/boot/Image \ -append "root=/dev/vda ro" \ -drive file=output/images/rootfs.ext2,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 \ -machine dumpdtb=qemu.dtb Link: https://gitlab.baylibre.com/baylibre/qemu/-/tree/riscv-cbqri-rfc Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- Note: this is necessary as Qemu branch riscv-cbqri-rfc does not yet support generating a dtb with the nodes and properties needed for CBQRI controllers. Thus, those lines must be added in the next patch and an external dtb (qemu-virt-cbqri.dtb) built by Linux is used when invoking qemu-system-riscv64 arch/riscv/boot/dts/qemu/qemu-virt-cbqri.dts | 371 +++++++++++++++++++ 1 file changed, 371 insertions(+) create mode 100644 arch/riscv/boot/dts/qemu/qemu-virt-cbqri.dts diff --git a/arch/riscv/boot/dts/qemu/qemu-virt-cbqri.dts b/arch/riscv/boot/dts/qemu/qemu-virt-cbqri.dts new file mode 100644 index 000000000000..400ed48a06af --- /dev/null +++ b/arch/riscv/boot/dts/qemu/qemu-virt-cbqri.dts @@ -0,0 +1,371 @@ +// SPDX-License-Identifier: GPL-2.0 OR MIT +/dts-v1/; + +/ { + #address-cells = <0x02>; + #size-cells = <0x02>; + compatible = "riscv-virtio"; + model = "riscv-virtio,qemu"; + + fw-cfg@10100000 { + dma-coherent; + reg = <0x00 0x10100000 0x00 0x18>; + compatible = "qemu,fw-cfg-mmio"; + }; + + flash@20000000 { + bank-width = <0x04>; + reg = <0x00 0x20000000 0x00 0x2000000 0x00 0x22000000 0x00 0x2000000>; + compatible = "cfi-flash"; + }; + + chosen { + bootargs = "root=/dev/vda ro ftrace=function_graph ftrace_filter=\"*resctrl*,*qos*\""; + rng-seed = <0xb87c09c5 0xc8f0c713 0x9c217b2a 0xa6f44e14 0xb6e99df6 0x205d482b 0x6d4c34f4 0x6466fc08>; + stdout-path = "/soc/serial@10000000"; + }; + + poweroff { + value = <0x5555>; + offset = <0x00>; + regmap = <0x12>; + compatible = "syscon-poweroff"; + }; + + reboot { + value = <0x7777>; + offset = <0x00>; + regmap = <0x12>; + compatible = "syscon-reboot"; + }; + + platform-bus@4000000 { + interrupt-parent = <0x11>; + ranges = <0x00 0x00 0x4000000 0x2000000>; + #address-cells = <0x01>; + #size-cells = <0x01>; + compatible = "qemu,platform\0simple-bus"; + }; + + memory@80000000 { + device_type = "memory"; + reg = <0x00 0x80000000 0x00 0x8000000>; + }; + + cpus { + #address-cells = <0x01>; + #size-cells = <0x00>; + timebase-frequency = <0x989680>; + + cpu@0 { + phandle = <0x0f>; + device_type = "cpu"; + reg = <0x00>; + status = "okay"; + compatible = "riscv"; + riscv,cboz-block-size = <0x40>; + riscv,cbom-block-size = <0x40>; + riscv,isa = "rv64imafdch_zicbom_zicboz_zicsr_zifencei_zihintpause_zawrs_zba_zbb_zbc_zbs_ssqosid_sstc_svadu"; + mmu-type = "riscv,sv57"; + + interrupt-controller { + #interrupt-cells = <0x01>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + phandle = <0x10>; + }; + }; + + cpu@1 { + phandle = <0x0d>; + device_type = "cpu"; + reg = <0x01>; + status = "okay"; + compatible = "riscv"; + riscv,cboz-block-size = <0x40>; + riscv,cbom-block-size = <0x40>; + riscv,isa = "rv64imafdch_zicbom_zicboz_zicsr_zifencei_zihintpause_zawrs_zba_zbb_zbc_zbs_ssqosid_sstc_svadu"; + mmu-type = "riscv,sv57"; + + interrupt-controller { + #interrupt-cells = <0x01>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + phandle = <0x0e>; + }; + }; + + cpu@2 { + phandle = <0x0b>; + device_type = "cpu"; + reg = <0x02>; + status = "okay"; + compatible = "riscv"; + riscv,cboz-block-size = <0x40>; + riscv,cbom-block-size = <0x40>; + riscv,isa = "rv64imafdch_zicbom_zicboz_zicsr_zifencei_zihintpause_zawrs_zba_zbb_zbc_zbs_ssqosid_sstc_svadu"; + mmu-type = "riscv,sv57"; + + interrupt-controller { + #interrupt-cells = <0x01>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + phandle = <0x0c>; + }; + }; + + cpu@3 { + phandle = <0x09>; + device_type = "cpu"; + reg = <0x03>; + status = "okay"; + compatible = "riscv"; + riscv,cboz-block-size = <0x40>; + riscv,cbom-block-size = <0x40>; + riscv,isa = "rv64imafdch_zicbom_zicboz_zicsr_zifencei_zihintpause_zawrs_zba_zbb_zbc_zbs_ssqosid_sstc_svadu"; + mmu-type = "riscv,sv57"; + + interrupt-controller { + #interrupt-cells = <0x01>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + phandle = <0x0a>; + }; + }; + + cpu@4 { + phandle = <0x07>; + device_type = "cpu"; + reg = <0x04>; + status = "okay"; + compatible = "riscv"; + riscv,cboz-block-size = <0x40>; + riscv,cbom-block-size = <0x40>; + riscv,isa = "rv64imafdch_zicbom_zicboz_zicsr_zifencei_zihintpause_zawrs_zba_zbb_zbc_zbs_ssqosid_sstc_svadu"; + mmu-type = "riscv,sv57"; + + interrupt-controller { + #interrupt-cells = <0x01>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + phandle = <0x08>; + }; + }; + + cpu@5 { + phandle = <0x05>; + device_type = "cpu"; + reg = <0x05>; + status = "okay"; + compatible = "riscv"; + riscv,cboz-block-size = <0x40>; + riscv,cbom-block-size = <0x40>; + riscv,isa = "rv64imafdch_zicbom_zicboz_zicsr_zifencei_zihintpause_zawrs_zba_zbb_zbc_zbs_ssqosid_sstc_svadu"; + mmu-type = "riscv,sv57"; + + interrupt-controller { + #interrupt-cells = <0x01>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + phandle = <0x06>; + }; + }; + + cpu@6 { + phandle = <0x03>; + device_type = "cpu"; + reg = <0x06>; + status = "okay"; + compatible = "riscv"; + riscv,cboz-block-size = <0x40>; + riscv,cbom-block-size = <0x40>; + riscv,isa = "rv64imafdch_zicbom_zicboz_zicsr_zifencei_zihintpause_zawrs_zba_zbb_zbc_zbs_ssqosid_sstc_svadu"; + mmu-type = "riscv,sv57"; + + interrupt-controller { + #interrupt-cells = <0x01>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + phandle = <0x04>; + }; + }; + + cpu@7 { + phandle = <0x01>; + device_type = "cpu"; + reg = <0x07>; + status = "okay"; + compatible = "riscv"; + riscv,cboz-block-size = <0x40>; + riscv,cbom-block-size = <0x40>; + riscv,isa = "rv64imafdch_zicbom_zicboz_zicsr_zifencei_zihintpause_zawrs_zba_zbb_zbc_zbs_ssqosid_sstc_svadu"; + mmu-type = "riscv,sv57"; + + interrupt-controller { + #interrupt-cells = <0x01>; + interrupt-controller; + compatible = "riscv,cpu-intc"; + phandle = <0x02>; + }; + }; + + cpu-map { + + cluster0 { + + core0 { + cpu = <0x0f>; + }; + + core1 { + cpu = <0x0d>; + }; + + core2 { + cpu = <0x0b>; + }; + + core3 { + cpu = <0x09>; + }; + + core4 { + cpu = <0x07>; + }; + + core5 { + cpu = <0x05>; + }; + + core6 { + cpu = <0x03>; + }; + + core7 { + cpu = <0x01>; + }; + }; + }; + }; + + soc { + #address-cells = <0x02>; + #size-cells = <0x02>; + compatible = "simple-bus"; + ranges; + + pmu { + riscv,event-to-mhpmcounters = <0x01 0x01 0x7fff9 0x02 0x02 0x7fffc 0x10019 0x10019 0x7fff8 0x1001b 0x1001b 0x7fff8 0x10021 0x10021 0x7fff8 0x00 0x00 0x00 0x00 0x00>; + compatible = "riscv,pmu"; + }; + + rtc@101000 { + interrupts = <0x0b>; + interrupt-parent = <0x11>; + reg = <0x00 0x101000 0x00 0x1000>; + compatible = "google,goldfish-rtc"; + }; + + serial@10000000 { + interrupts = <0x0a>; + interrupt-parent = <0x11>; + clock-frequency = "\08@"; + reg = <0x00 0x10000000 0x00 0x100>; + compatible = "ns16550a"; + }; + + test@100000 { + phandle = <0x12>; + reg = <0x00 0x100000 0x00 0x1000>; + compatible = "sifive,test1\0sifive,test0\0syscon"; + }; + + pci@30000000 { + interrupt-map-mask = <0x1800 0x00 0x00 0x07>; + interrupt-map = <0x00 0x00 0x00 0x01 0x11 0x20 0x00 0x00 0x00 0x02 0x11 0x21 0x00 0x00 0x00 0x03 0x11 0x22 0x00 0x00 0x00 0x04 0x11 0x23 0x800 0x00 0x00 0x01 0x11 0x21 0x800 0x00 0x00 0x02 0x11 0x22 0x800 0x00 0x00 0x03 0x11 0x23 0x800 0x00 0x00 0x04 0x11 0x20 0x1000 0x00 0x00 0x01 0x11 0x22 0x1000 0x00 0x00 0x02 0x11 0x23 0x1000 0x00 0x00 0x03 0x11 0x20 0x1000 0x00 0x00 0x04 0x11 0x21 0x1800 0x00 0x00 0x01 0x11 0x23 0x1800 0x00 0x00 0x02 0x11 0x20 0x1800 0x00 0x00 0x03 0x11 0x21 0x1800 0x00 0x00 0x04 0x11 0x22>; + ranges = <0x1000000 0x00 0x00 0x00 0x3000000 0x00 0x10000 0x2000000 0x00 0x40000000 0x00 0x40000000 0x00 0x40000000 0x3000000 0x04 0x00 0x04 0x00 0x04 0x00>; + reg = <0x00 0x30000000 0x00 0x10000000>; + dma-coherent; + bus-range = <0x00 0xff>; + linux,pci-domain = <0x00>; + device_type = "pci"; + compatible = "pci-host-ecam-generic"; + #size-cells = <0x02>; + #interrupt-cells = <0x01>; + #address-cells = <0x03>; + }; + + virtio_mmio@10008000 { + interrupts = <0x08>; + interrupt-parent = <0x11>; + reg = <0x00 0x10008000 0x00 0x1000>; + compatible = "virtio,mmio"; + }; + + virtio_mmio@10007000 { + interrupts = <0x07>; + interrupt-parent = <0x11>; + reg = <0x00 0x10007000 0x00 0x1000>; + compatible = "virtio,mmio"; + }; + + virtio_mmio@10006000 { + interrupts = <0x06>; + interrupt-parent = <0x11>; + reg = <0x00 0x10006000 0x00 0x1000>; + compatible = "virtio,mmio"; + }; + + virtio_mmio@10005000 { + interrupts = <0x05>; + interrupt-parent = <0x11>; + reg = <0x00 0x10005000 0x00 0x1000>; + compatible = "virtio,mmio"; + }; + + virtio_mmio@10004000 { + interrupts = <0x04>; + interrupt-parent = <0x11>; + reg = <0x00 0x10004000 0x00 0x1000>; + compatible = "virtio,mmio"; + }; + + virtio_mmio@10003000 { + interrupts = <0x03>; + interrupt-parent = <0x11>; + reg = <0x00 0x10003000 0x00 0x1000>; + compatible = "virtio,mmio"; + }; + + virtio_mmio@10002000 { + interrupts = <0x02>; + interrupt-parent = <0x11>; + reg = <0x00 0x10002000 0x00 0x1000>; + compatible = "virtio,mmio"; + }; + + virtio_mmio@10001000 { + interrupts = <0x01>; + interrupt-parent = <0x11>; + reg = <0x00 0x10001000 0x00 0x1000>; + compatible = "virtio,mmio"; + }; + + plic@c000000 { + phandle = <0x11>; + riscv,ndev = <0x5f>; + reg = <0x00 0xc000000 0x00 0x600000>; + interrupts-extended = <0x10 0x0b 0x10 0x09 0x0e 0x0b 0x0e 0x09 0x0c 0x0b 0x0c 0x09 0x0a 0x0b 0x0a 0x09 0x08 0x0b 0x08 0x09 0x06 0x0b 0x06 0x09 0x04 0x0b 0x04 0x09 0x02 0x0b 0x02 0x09>; + interrupt-controller; + compatible = "sifive,plic-1.0.0\0riscv,plic0"; + #address-cells = <0x00>; + #interrupt-cells = <0x01>; + }; + + clint@2000000 { + interrupts-extended = <0x10 0x03 0x10 0x07 0x0e 0x03 0x0e 0x07 0x0c 0x03 0x0c 0x07 0x0a 0x03 0x0a 0x07 0x08 0x03 0x08 0x07 0x06 0x03 0x06 0x07 0x04 0x03 0x04 0x07 0x02 0x03 0x02 0x07>; + reg = <0x00 0x2000000 0x00 0x10000>; + compatible = "sifive,clint0\0riscv,clint0"; + }; + }; +}; From patchwork Wed Apr 19 11:11:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216687 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 25A02C77B7C for ; Wed, 19 Apr 2023 11:45:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=wCg/5krH4cNqHuikHeYaHk3DgaDTeqndFa2p01kBGoQ=; b=tgaFzh6Z4vSR+z UeIig+w3e2Qqw9QTWt9YGeNXpztis45a7/H/kcyossaL+IjwaljI6k0AgTmJdXg49oWojUJVuUpSP Vlg/4jBuY1iJgShE1cLfHaaYhaeydJyIYvdCwfAxfkWnMH/A3hLAgPTw+rl2jEc6obZTUn2uENDE0 YtPor5hXthRRCNvEhaQ0gOSK+nAOxCgl2AwOkstQ1CdP2bNPJHutrgtbEa8VtJ1+KPh1gBW2Frx0a YHnzYhjsfObwGh4UWMIxt9uyTJBM5/irxmfMXmzGYXdypMQkGtuCAUSwbSpL6uUyXlANBZ6rAytdL vFImbcHcFtdVz8P+tV5g==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6Fg-005E4i-0l; Wed, 19 Apr 2023 11:45:32 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp6Fe-005E3o-0P for linux-riscv@bombadil.infradead.org; Wed, 19 Apr 2023 11:45:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=B4LpILR7uuc84V0nBeCkFyyltCgxgJA346GsW698exo=; b=UePpOd/3g1ofXzA7PR1C1Ec9aV qrCEbWgwBbB0QFBBX7xG2vazY0ME8D2mGlgr+KO1EsUZwbFMbHMlidTQE1wvqFlMs0+kqBX9TWZQe 0JACQ20T85uOEcEPYCCVB/MBJBaU8E7/9kSyY9jSNz9UPuIaFUVHlX3FRZIy6uDwFacsIgpCfRCy9 ZTFC7pLcJwGtXcG26s5/xOhxXfPWSUIVYKwVkPAWq2zZeJVWyFhpi9YtH0zNX9y7Qv5WC72Cv/5jD xCyj+PWFAiEBeX8VreL2YO5hl4ptjAKUFdYPggAlcpuRq1mCNejZs8Oysz35nCy3I5YmJRkzUJy9/ VTgz5vgg==; Received: from mail-pl1-x634.google.com ([2607:f8b0:4864:20::634]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hx-001sPK-1I for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:43 +0000 Received: by mail-pl1-x634.google.com with SMTP id d9443c01a7336-1a645fd0c6dso24014895ad.1 for ; Wed, 19 Apr 2023 04:10:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902638; x=1684494638; 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=B4LpILR7uuc84V0nBeCkFyyltCgxgJA346GsW698exo=; b=t7Dv+2N+QyIlF3rBqJ4Yw+dboRf/N5xEHL2v5J6yE8SzdkFIHKT+ft3xzMqnOvvWtG c73fE87KpwIAcE94sAtSve8nl4GaovkVh6Fn6Jc1trDM09dLWJtNDjrtNeeuNW43fLDq 4m51S9CKnzl0sMFYrEj7vzX2NwMCb50ZlvH26tOiItQ+Tcn2IJHg07eABhYBUNS/y0nj CJmXX3IjPKbMDGd+Wzd00nqNjBqs5zER84mmVHtQtveHb2wbk2U7Bs6lorj4N4OtdvXE izAooKlxyqE6K+IQdYgVU6POxvNISn+BRm1HTHKsOPAbta521PPxg8Ucog3XZMuI/yrr cOpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902638; x=1684494638; 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=B4LpILR7uuc84V0nBeCkFyyltCgxgJA346GsW698exo=; b=aU9wD9QEzIo85byL3z3etRP0t3nPohRh/NkOwdzDVGEh/Kghg4+u1OJnn1YM0jRjzO DYLxF5qnkM1puZKMOVrZ6rgEa1T+7qT9snEao5e2i5YSix2twbbLx6pWw80tCzIE9j4k /Dq2U/vOh1YOinIVUYXq9CZj1WVTENEMHjs4xa3++EkUU+yBL2e5Ws+hTlpRVj3Jhma9 A/v7t4i8WJ5I0/7w3ZiZ0D0RZfi0jEGa6twlB1Bc081w0rQgnU10C++F6es8M0miSuYw lcWoXQzZFe+hSnw/f5TDvqRmXLsEuqli6sBRIA0VQy9tedCH+0a3YylbGshBQ3FklN2h KIgQ== X-Gm-Message-State: AAQBX9fZcBLWckAPVDCy38yEprQ2XHNn2HlS8PH4jR7yROsBXKP6SRnB N1aMihHn3wLry0C8yp0Xay5njWF7gIaKWNLMHfY= X-Google-Smtp-Source: AKy350blBgJTgWuZgwD/ElBAI6xPXER2rPw+XTMHx0qcnAQYuIXvYmMpwQt5BTkTII5ML0gDgkFSGQ== X-Received: by 2002:a17:902:f70f:b0:1a1:aa68:7e61 with SMTP id h15-20020a170902f70f00b001a1aa687e61mr5676956plo.33.1681902638229; Wed, 19 Apr 2023 04:10:38 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:37 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 20/21] DO_NOT_MERGE riscv: dts: qemu: add cbqri-capable controllers Date: Wed, 19 Apr 2023 04:11:10 -0700 Message-Id: <20230419111111.477118-21-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_121041_546837_658F4EBE X-CRM114-Status: GOOD ( 10.04 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add nodes to for CBQRI-capable cache and memory controllers. This is necessary as the qemu branch riscv-cbqri-rfc (based on v8.0.0-rc4) does not yet support generating a dtb with the nodes and properties needed for CBQRI controllers. Thus, an external dtb (qemu-virt-cbqri.dtb) built by Linux is used when invoking qemu-system-riscv64: qemu-system-riscv64 \ -M virt \ -nographic \ -smp 8 \ -bios output/images/fw_jump.elf \ -kernel ${LINUX}/arch/riscv/boot/Image \ -dtb ${LINUX}/arch/riscv/boot/dts/qemu/qemu-virt-cbqri.dtb \ -append "root=/dev/vda ro" \ -drive file=output/images/rootfs.ext2,format=raw,id=hd0 \ -device virtio-blk-device,drive=hd0 \ Link: https://gitlab.baylibre.com/baylibre/qemu/-/tree/riscv-cbqri-rfc Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- arch/riscv/boot/dts/qemu/qemu-virt-cbqri.dts | 59 ++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/arch/riscv/boot/dts/qemu/qemu-virt-cbqri.dts b/arch/riscv/boot/dts/qemu/qemu-virt-cbqri.dts index 400ed48a06af..2c4ddc4271cc 100644 --- a/arch/riscv/boot/dts/qemu/qemu-virt-cbqri.dts +++ b/arch/riscv/boot/dts/qemu/qemu-virt-cbqri.dts @@ -367,5 +367,64 @@ clint@2000000 { reg = <0x00 0x2000000 0x00 0x10000>; compatible = "sifive,clint0\0riscv,clint0"; }; + + cluster0_l2: controller@4820000 { + compatible = "foobar,cache-controller"; + reg = <0x0 0x4820000 0x0 0x1000>; /* 4KB at 0x04820000 */ + cache-unified; + cache-line-size = <64>; + cache-level = <2>; + cache-sets = <1000>; + cache-size = <768000>; /* 750 KiB */ + next-level-cache = <&shared_llc>; + riscv,cbqri-rcid = <64>; + riscv,cbqri-mcid = <256>; + }; + + cluster1_l2: controller@4821000 { + compatible = "foobar,cache-controller"; + reg = <0x0 0x4821000 0x0 0x1000>; /* 4KB at 0x04821000 */ + cache-unified; + cache-line-size = <64>; + cache-level = <2>; + cache-sets = <1000>; + cache-size = <768000>; /* 750 KiB */ + next-level-cache = <&shared_llc>; + riscv,cbqri-rcid = <64>; + riscv,cbqri-mcid = <256>; + }; + + shared_llc: controller@482b000 { + compatible = "foobar,cache-controller"; + reg = <0x0 0x482b000 0x0 0x1000>; /* 4KB at 0x0482B000 */ + cache-unified; + cache-line-size = <64>; + cache-level = <3>; + cache-sets = <4096>; + cache-size = <3145728>; /* 3 MiB */ + riscv,cbqri-rcid = <64>; + riscv,cbqri-mcid = <256>; + }; + + mem0: controller@4828000 { + compatible = "foobar,memory-controller"; + reg = <0x0 0x4828000 0x0 0x1000>; /* 4KB at 0x04828000 */ + riscv,cbqri-rcid = <64>; + riscv,cbqri-mcid = <256>; + }; + + mem1: controller@4829000 { + compatible = "foobar,memory-controller"; + reg = <0x0 0x4829000 0x0 0x1000>; /* 4KB at 0x04829000 */ + riscv,cbqri-rcid = <64>; + riscv,cbqri-mcid = <256>; + }; + + mem2: controller@482a000 { + compatible = "foobar,memory-controller"; + reg = <0x0 0x482a000 0x0 0x1000>; /* 4KB at 0x0482A000 */ + riscv,cbqri-rcid = <64>; + riscv,cbqri-mcid = <256>; + }; }; }; From patchwork Wed Apr 19 11:11:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Drew Fustini X-Patchwork-Id: 13216686 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A498FC77B73 for ; Wed, 19 Apr 2023 11:45:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=e82mDZj7DKhgXX0zHdPGrdtfMkKEIWQvpikR5UyOU2c=; b=3IIRKHbIxjiUJn ojiHsTWsCKmu5W+qtFaRieyyV1KatfBcaBP9U4mkZgAq0odrdV/KDA9zSftrx5NIGK/Hl70Cnb4U0 XCkCheFbyoifVQXrFCDBtOfdR684i7ILtovpZAkjW1mkdWmsr8KtcPst2o6KvvP+RZU1ldUT959BD gIYEkhBAVzj3ps8mpc0ho8LyeUAGwT3cGwR1e/xMDmdc4l5iNYRzl3bgN/Cp2GcNFb3dOwsXAhqZZ 4KgD/VN/C+42uhNHicktzh11HqRgjv1y7KzS/eNTMVipyFEbZ2IPnsSkzXlgKdc5hz5nJuhjuGdbE HtYvfUI7aUEpXVeaAEBg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1pp6Fe-005E4G-28; Wed, 19 Apr 2023 11:45:30 +0000 Received: from desiato.infradead.org ([2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp6Fd-005E3o-2C for linux-riscv@bombadil.infradead.org; Wed, 19 Apr 2023 11:45:29 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=Content-Transfer-Encoding:MIME-Version :References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To: Content-Type:Content-ID:Content-Description; bh=H7zDmqn6U8Eyb17uAoVJJPhK0/Ifl27eJMXTrX2OOHM=; b=db7QIzGBqFtMSlc0T1yJvT0bzf hVZc/Mt6lIh6YqakyBRRa9P7jP3/KEgdggRbA7VFxgpDoyFUT3U2Z20jlyS7LEpxTFWqS4Nr+nNm5 UD8JlA2keSY5iYIGW6hEVb3XDPqQPXcSfJA0FcxuNya1Jip7wE8WCmqIB18aE11BXJdNOE12ZHQWf h/YaOCzvIXJ8qGjc/kMIVHNroeLbOVFnS7ef6RpODcp8mVPZ52FXVTdzxaqfY+cRfyX4uO2Ou+We4 GKvSKLsmFKIZB+Y1BafY0A1aRPDllPySwAHsMOUuj9V6kUegpHB0po/ucAie+9mtndD/Al6yxdx1O P2D7JC1Q==; Received: from mail-pl1-x635.google.com ([2607:f8b0:4864:20::635]) by desiato.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1pp5hx-001sQH-3C for linux-riscv@lists.infradead.org; Wed, 19 Apr 2023 11:10:46 +0000 Received: by mail-pl1-x635.google.com with SMTP id d9443c01a7336-1a68d61579bso18252755ad.1 for ; Wed, 19 Apr 2023 04:10:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20221208.gappssmtp.com; s=20221208; t=1681902639; x=1684494639; 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=H7zDmqn6U8Eyb17uAoVJJPhK0/Ifl27eJMXTrX2OOHM=; b=rzuEY2qOeKpq90xSbNAhUvw+t3I72kxsPlvEC7slbJx9oZ6mmu89DjDgnsFLhq7KuO Wt57Eklvz6MGerBhZn+zO7UFpZ15XNmpuuwUhsEG37gK93liaWtJlKCwrt2a/FnzUTe+ z5HCg6VZUjUOIo9F8rfd8VaOHjPNwVA+1x+kc2wTDwm7qonkWTsRz8jC1Itvm7NSNSAY a5X1WkIgUhDoNCGAK2F6F/Mxe4xIl1aVgypMSHghWGGh6VIPhepcxxkeK6szAoLR/YUN CS3WZYDAECq7UnQZ5nHRW9sRRpHAl9XVfxsKrrcgn0szOs0qnXHXC7l5tQ1KG31eQtEE cRUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681902639; x=1684494639; 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=H7zDmqn6U8Eyb17uAoVJJPhK0/Ifl27eJMXTrX2OOHM=; b=D6B+KL2pCrBskHQlXVF4Dmhog85rE4tJLvgDcWwxpzBnOzdjq2ULFixmP/fI9rojU9 NPVDsD1gt6CoqNauxR9edzokVPQdh+zZgYzr3lsLdxQ8Z2naQ73eo1uTltBuWO4NtLC8 +bgY4h+ALAqnWs3VVBKa4rCKD0eWn/Uro7XjtZvAQeZqQa89vwXuT1IknmWVan+pq5Ug b7LerNEo51VHmno2y24zMfVHdHfyCXxgA+wvaMYc4+Hj4eRRCDftgiiahKCVz0spAXcz k8KowSxeO5+kd4wOxaz37KcXLz5iLVPcQTTMnzZuU9BQ93hW3mU5IdHEExXAIPq1VAbZ LgQQ== X-Gm-Message-State: AAQBX9dQy9jJZtkiaX4jJmLX+AHUypw67NskS14qYPT35wFEbme37KMm NXmDtMuMclGwi3lOIFaYIq0YlKBAsKuMXU8PyvI= X-Google-Smtp-Source: AKy350bRyAzNw2aBgYQca4A9Dl58PbRRLG96ePo7DalZ4z4sxpKHS+SDAbx+Cwj9P+bi7KJe2/jZ7A== X-Received: by 2002:a17:902:daca:b0:1a2:19c1:a974 with SMTP id q10-20020a170902daca00b001a219c1a974mr5715862plx.68.1681902639573; Wed, 19 Apr 2023 04:10:39 -0700 (PDT) Received: from x1.hsd1.or.comcast.net ([2601:1c2:1800:f680:eaf2:1d7a:7338:16cb]) by smtp.gmail.com with ESMTPSA id g12-20020a1709026b4c00b001a24cded097sm11180774plt.236.2023.04.19.04.10.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Apr 2023 04:10:38 -0700 (PDT) From: Drew Fustini To: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, Palmer Dabbelt , Paul Walmsley , Conor Dooley , Ved Shanbhogue , =?utf-8?q?Kornel_Dul=C4=99ba?= , Adrien Ricciardi , Nicolas Pitre , Fenghua Yu , Reinette Chatre , Babu Moger , Peter Newman , x86@kernel.org, Rob Herring , James Morse Cc: Drew Fustini Subject: [RFC PATCH 21/21] DO_NOT_MERGE riscv: dts: build qemu virt device tree Date: Wed, 19 Apr 2023 04:11:11 -0700 Message-Id: <20230419111111.477118-22-dfustini@baylibre.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230419111111.477118-1-dfustini@baylibre.com> References: <20230419111111.477118-1-dfustini@baylibre.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230419_121044_920122_E2F2D7F9 X-CRM114-Status: GOOD ( 13.42 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org Add the device tree for the qemu virt machine to the build. The resulting dtb will be consumed by qemu-system-riscv64. Co-developed-by: Adrien Ricciardi Signed-off-by: Adrien Ricciardi Signed-off-by: Drew Fustini --- arch/riscv/boot/dts/Makefile | 1 + arch/riscv/boot/dts/qemu/Makefile | 3 +++ 2 files changed, 4 insertions(+) create mode 100644 arch/riscv/boot/dts/qemu/Makefile diff --git a/arch/riscv/boot/dts/Makefile b/arch/riscv/boot/dts/Makefile index f0d9f89054f8..74d99d28522f 100644 --- a/arch/riscv/boot/dts/Makefile +++ b/arch/riscv/boot/dts/Makefile @@ -5,5 +5,6 @@ subdir-y += starfive subdir-y += canaan subdir-y += microchip subdir-y += renesas +subdir-y += qemu obj-$(CONFIG_BUILTIN_DTB) := $(addsuffix /, $(subdir-y)) diff --git a/arch/riscv/boot/dts/qemu/Makefile b/arch/riscv/boot/dts/qemu/Makefile new file mode 100644 index 000000000000..07252b4ff455 --- /dev/null +++ b/arch/riscv/boot/dts/qemu/Makefile @@ -0,0 +1,3 @@ +# SPDX-License-Identifier: GPL-2.0 +dtb-$(CONFIG_SOC_VIRT) += qemu-virt-cbqri.dtb +obj-$(CONFIG_BUILTIN_DTB) += $(addsuffix .o, $(dtb-y))