Skip to contentSkip to conversation

arm64: topology: add MPIDR-based detection

PATCH In review Zi Shen Lim 2 participants 2 messages Apr 29, 2014 – May 2, 2014 arm64

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 arm64: topology: add MPIDR-based detection

Create cpu topology based on MPIDR. When hardware sets MPIDR to sane values, this method will always work. Therefore it should also work well as the fallback method. [1]

When we have multiple processing elements in the system, we create the cpu topology by mapping each affinity level (from lowest to highest) to threads (if they exist), cores, and clusters.

We combine data from all higher affinity levels into cluster_id so we don't lose any information from MPIDR. [2]

[1] http://www.spinics.net/lists/arm-kernel/msg317445.html
[2] https://lkml.org/lkml/2014/4/23/703

---
v1->v2: Addressed comments from Mark Brown.
- Reduce noise. Use pr_debug instead of pr_info.
- Don't ignore higher affinity levels.

v2->v3: Addressed comments from Lorenzo Pieralisi.
- Rebased on top of Mark Brown's DT topology series.
- Make MPIDR fallback option.
- Fixed usage of mpidr_hash.shift_aff. Please review :)

Tested on my multi-core multi-thread model.

 arch/arm64/include/asm/cputype.h |  5 +++++
 arch/arm64/kernel/topology.c     | 44 +++++++++++++++++++++++++++++++++++++---
 2 files changed, 46 insertions(+), 3 deletions(-)
arch/arm64/include/asm/cputype.h +5 -0
index c404fb0..b3b3287 100644
@@ -18,6 +18,8 @@
 
 #define INVALID_HWID		ULONG_MAX
 
+#define MPIDR_UP_BITMASK	(0x1 << 30)
+#define MPIDR_MT_BITMASK	(0x1 << 24)
 #define MPIDR_HWID_BITMASK	0xff00ffffff
 
 #define MPIDR_LEVEL_BITS_SHIFT	3
@@ -30,6 +32,9 @@
 #define MPIDR_AFFINITY_LEVEL(mpidr, level) \
 	((mpidr >> MPIDR_LEVEL_SHIFT(level)) & MPIDR_LEVEL_MASK)
 
+#define MPIDR_AFF_MASK(level) \
+	((u64)MPIDR_LEVEL_MASK << MPIDR_LEVEL_SHIFT(level))
+
 #define read_cpuid(reg) ({						\
 	u64 __val;							\
 	asm("mrs	%0, " #reg : "=r" (__val));			\
arch/arm64/kernel/topology.c +41 -3

62 lines not on this page · raw message

Signature · 1 line
1.8.4.3
#1 lore raw

On Tue, Apr 29, 2014 at 04:36:13PM -0700, Zi Shen Lim wrote:

This looks good to me, modulo a couple of really tiny nitpicks.

I'm just doing some brief testing now, I'll repost my series with this and Lorenzo's changes included shortly assuming no issues.

arch/arm64/kernel/topology.c static void update_siblings_masks(unsigned int cpuid) · line 370

Quoted 8 lines
arch/arm64/kernel/topology.c +1 -3
 	if (cpuid_topo->cluster_id == -1) {
-		/*
-		 * DT does not contain topology information for this cpu.
-		 */
+		/* No topology information for this cpu ?! */
 		pr_debug("CPU%u: No topology information configured\n", cpuid);
 		return;
 	}

Now that we have MPIDR support (well, will with this patch) this should probably be raised to a pr_err() since we've got ourselves confused somehow if it ever happens - we should always be able to get topology from MPIDR. I'll tweak this when I repost.

arch/arm64/kernel/topology.c static void update_siblings_masks(unsigned int cpuid) · line 429

Quoted 3 lines
arch/arm64/kernel/topology.c +3 -0
+	pr_debug("CPU%u: cluster %d core %d thread %d mpidr %llx\n",
+		 cpuid, cpuid_topo->cluster_id, cpuid_topo->core_id,
+		 cpuid_topo->thread_id, mpidr);

I do wonder if we should print this either unconditionally or not at
all (rather than only if using MPIDR), I know Catalin and/or Lorenzo
weren't keen on noise but it is just at debug level and it's nice and
easy to refer to.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20140502/aa5272e8/attachment-0001.sig>