All of lore.kernel.org
 help / color / mirror / Atom feed
From: vladimir.murzin@arm.com (Vladimir Murzin)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 01/10] ARM: factor out CSSELR/CCSIDR operations that use cp15 directly
Date: Mon, 13 Jun 2016 16:03:00 +0100	[thread overview]
Message-ID: <1465830189-20128-2-git-send-email-vladimir.murzin@arm.com> (raw)
In-Reply-To: <1465830189-20128-1-git-send-email-vladimir.murzin@arm.com>

From: Jonathan Austin <jonathan.austin@arm.com>

Currently we use raw cp15 operations to access the cache setup data.

This patch abstracts the CSSELR and CCSIDR accessors out to a header so
that the implementation for them can be switched out as we do with other
cpu/cachetype operations.

Signed-off-by: Jonathan Austin <jonathan.austin@arm.com>
Signed-off-by: Vladimir Murzin <vladimir.murzin@arm.com>
---
 arch/arm/include/asm/cachetype.h |   24 ++++++++++++++++++++++++
 arch/arm/kernel/setup.c          |    7 ++-----
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/arch/arm/include/asm/cachetype.h b/arch/arm/include/asm/cachetype.h
index 7ea7814..8609de8 100644
--- a/arch/arm/include/asm/cachetype.h
+++ b/arch/arm/include/asm/cachetype.h
@@ -56,4 +56,28 @@ static inline unsigned int __attribute__((pure)) cacheid_is(unsigned int mask)
 	       (~__CACHEID_NEVER & __CACHEID_ARCH_MIN & mask & cacheid);
 }
 
+#define CSSELR_ICACHE	1
+#define CSSELR_DCACHE	0
+
+#define CSSELR_L1	(0 << 1)
+#define CSSELR_L2	(1 << 1)
+#define CSSELR_L3	(2 << 1)
+#define CSSELR_L4	(3 << 1)
+#define CSSELR_L5	(4 << 1)
+#define CSSELR_L6	(5 << 1)
+#define CSSELR_L7	(6 << 1)
+
+static inline void set_csselr(unsigned int cache_selector)
+{
+	asm volatile("mcr p15, 2, %0, c0, c0, 0" : : "r" (cache_selector));
+}
+
+static inline unsigned int read_ccsidr(void)
+{
+	unsigned int val;
+
+	asm volatile("mrc p15, 1, %0, c0, c0, 0" : "=r" (val));
+	return val;
+}
+
 #endif
diff --git a/arch/arm/kernel/setup.c b/arch/arm/kernel/setup.c
index 7b53500..e414f50 100644
--- a/arch/arm/kernel/setup.c
+++ b/arch/arm/kernel/setup.c
@@ -291,12 +291,9 @@ static int cpu_has_aliasing_icache(unsigned int arch)
 	/* arch specifies the register format */
 	switch (arch) {
 	case CPU_ARCH_ARMv7:
-		asm("mcr	p15, 2, %0, c0, c0, 0 @ set CSSELR"
-		    : /* No output operands */
-		    : "r" (1));
+		set_csselr(CSSELR_ICACHE | CSSELR_L1);
 		isb();
-		asm("mrc	p15, 1, %0, c0, c0, 0 @ read CCSIDR"
-		    : "=r" (id_reg));
+		id_reg = read_ccsidr();
 		line_size = 4 << ((id_reg & 0x7) + 2);
 		num_sets = ((id_reg >> 13) & 0x7fff) + 1;
 		aliasing_icache = (line_size * num_sets) > PAGE_SIZE;
-- 
1.7.9.5

  reply	other threads:[~2016-06-13 15:03 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-13 15:02 [PATCH 00/10] ARM: V7M: Support caches Vladimir Murzin
2016-06-13 15:03 ` Vladimir Murzin [this message]
2016-06-13 15:03 ` [PATCH 02/10] ARM: V7M: Make read_cpuid() generally available on V7M Vladimir Murzin
2016-06-13 15:15   ` Russell King - ARM Linux
2016-06-13 16:21     ` Vladimir Murzin
2016-06-13 15:03 ` [PATCH 03/10] ARM: V7M: Add addresses for mem-mapped V7M cache operations Vladimir Murzin
2016-06-13 15:03 ` [PATCH 04/10] ARM: V7M: Add support for reading the CTR with CPUID_CACHETYPE Vladimir Murzin
2016-06-13 15:03 ` [PATCH 05/10] ARM: Extract cp15 operations from cache flush code Vladimir Murzin
2016-06-13 15:03 ` [PATCH 06/10] ARM: V7M: Implement cache macros for V7M Vladimir Murzin
2016-06-13 15:18   ` Russell King - ARM Linux
2016-06-13 16:27     ` Vladimir Murzin
2016-06-13 16:29       ` Russell King - ARM Linux
2016-06-13 16:34         ` Vladimir Murzin
2016-06-13 15:03 ` [PATCH 07/10] ARM: V7M: fix notrace variant of save_and_disable_irqs Vladimir Murzin
2016-06-13 15:03 ` [PATCH 08/10] ARM: V7M: Wire up caches for V7M processors with cache support Vladimir Murzin
2016-06-13 15:03 ` [PATCH 09/10] ARM: V7M: Indirect proc_info construction for V7M CPUs Vladimir Murzin
2016-06-13 15:03 ` [PATCH 10/10] ARM: V7M: Add support for the Cortex-M7 processor Vladimir Murzin
2016-06-13 16:09 ` [PATCH 00/10] ARM: V7M: Support caches Alexandre Torgue
2016-06-13 16:19   ` Vladimir Murzin
2016-06-13 16:29     ` Alexandre Torgue
2016-06-15 10:14       ` Alexandre Torgue
2016-06-15 12:43         ` Vladimir Murzin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1465830189-20128-2-git-send-email-vladimir.murzin@arm.com \
    --to=vladimir.murzin@arm.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.