From patchwork Mon Oct 22 06:49:18 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoffer Dall X-Patchwork-Id: 1623671 Return-Path: X-Original-To: patchwork-kvm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork1.kernel.org (Postfix) with ESMTP id 99F7F400E8 for ; Mon, 22 Oct 2012 06:49:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755029Ab2JVGtK (ORCPT ); Mon, 22 Oct 2012 02:49:10 -0400 Received: from mail-vb0-f46.google.com ([209.85.212.46]:33620 "EHLO mail-vb0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754935Ab2JVGtJ (ORCPT ); Mon, 22 Oct 2012 02:49:09 -0400 Received: by mail-vb0-f46.google.com with SMTP id ff1so2599170vbb.19 for ; Sun, 21 Oct 2012 23:49:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=subject:to:from:cc:date:message-id:in-reply-to:references :user-agent:mime-version:content-type:content-transfer-encoding :x-gm-message-state; bh=ktV9CUwBlK4g1J2qboz/vKvN6VstEoKvTOkm+NU05Kw=; b=odi4BXBBGGLkSzmT9hc1zXiTpIAwoulAoB6OXkAXng95oLAFmc5oNieOdFvoM0BgN6 qFPgdxxYhyXUc1lYsh0BhVA6zo1RY5M5w5RePlK1if6WiRSXQNo5I9tephJRXiCSnbx9 UztPHgnoRc+YIIFyb/bEywY7mrA5YhXM7pwj8BYikmIU2NMPUORRwgvRV+zGt5zsa7el AZpP2JKTk95xG7pG+YOCFL4g9kGLtfEJihLBGgl2Jea6Vv5wft5aRbgp96XDEIxGjci2 30W3xNPmOgiRu69Vldvax4nVO3OKFjvTmrXwSulXxkDOOYWnTiY3M/TswJhaDLvKMVif W7uA== Received: by 10.58.12.231 with SMTP id b7mr14315950vec.28.1350888548826; Sun, 21 Oct 2012 23:49:08 -0700 (PDT) Received: from [127.0.1.1] (pool-72-80-83-148.nycmny.fios.verizon.net. [72.80.83.148]) by mx.google.com with ESMTPS id dq8sm8966025vdc.4.2012.10.21.23.49.07 (version=TLSv1/SSLv3 cipher=OTHER); Sun, 21 Oct 2012 23:49:08 -0700 (PDT) Subject: [PATCH v3 03/14] ARM: Factor out cpuid implementor and part number To: kvm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, kvmarm@lists.cs.columbia.edu From: Christoffer Dall Cc: Marcelo Tosatti Date: Mon, 22 Oct 2012 02:49:18 -0400 Message-ID: <20121022064918.18444.99781.stgit@ubuntu> In-Reply-To: <20121022064831.18444.73273.stgit@ubuntu> References: <20121022064831.18444.73273.stgit@ubuntu> User-Agent: StGit/0.15 MIME-Version: 1.0 X-Gm-Message-State: ALoCoQmsQRSYzkJyzic5+wZYpW2mpbOOPcPXaPA9hzWeBaWQkEdslAC0Y2I7hHsHAwaBK/kJ44eS Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org Decoding the implementor and part number of the CPU id in the CPU ID register is needed by KVM, so we factor it out to share the code. Reviewed-by: Marcelo Tosatti Signed-off-by: Christoffer Dall --- arch/arm/include/asm/cputype.h | 26 ++++++++++++++++++++++++++ arch/arm/kernel/perf_event_cpu.c | 30 +++++++++++++++--------------- 2 files changed, 41 insertions(+), 15 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe kvm" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/arch/arm/include/asm/cputype.h b/arch/arm/include/asm/cputype.h index cb47d28..306fb2c 100644 --- a/arch/arm/include/asm/cputype.h +++ b/arch/arm/include/asm/cputype.h @@ -51,6 +51,22 @@ extern unsigned int processor_id; #define read_cpuid_ext(reg) 0 #endif +#define IMPLEMENTOR_ARM 0x41 +#define IMPLEMENTOR_INTEL 0x69 + +#define PART_NUMBER_ARM1136 0xB360 +#define PART_NUMBER_ARM1156 0xB560 +#define PART_NUMBER_ARM1176 0xB760 +#define PART_NUMBER_ARM11MPCORE 0xB020 +#define PART_NUMBER_CORTEX_A8 0xC080 +#define PART_NUMBER_CORTEX_A9 0xC090 +#define PART_NUMBER_CORTEX_A5 0xC050 +#define PART_NUMBER_CORTEX_A15 0xC0F0 +#define PART_NUMBER_CORTEX_A7 0xC070 + +#define PART_NUMBER_XSCALE1 0x1 +#define PART_NUMBER_XSCALE2 0x2 + /* * The CPU ID never changes at run time, so we might as well tell the * compiler that it's constant. Use this function to read the CPU ID @@ -61,6 +77,16 @@ static inline unsigned int __attribute_const__ read_cpuid_id(void) return read_cpuid(CPUID_ID); } +static inline unsigned int __attribute_const__ read_cpuid_implementor(void) +{ + return (read_cpuid_id() & 0xFF000000) >> 24; +} + +static inline unsigned int __attribute_const__ read_cpuid_part_number(void) +{ + return (read_cpuid_id() & 0xFFF0); +} + static inline unsigned int __attribute_const__ read_cpuid_cachetype(void) { return read_cpuid(CPUID_CACHETYPE); diff --git a/arch/arm/kernel/perf_event_cpu.c b/arch/arm/kernel/perf_event_cpu.c index 8d7d8d4..ff18566 100644 --- a/arch/arm/kernel/perf_event_cpu.c +++ b/arch/arm/kernel/perf_event_cpu.c @@ -200,46 +200,46 @@ static struct arm_pmu *__devinit probe_current_pmu(void) struct arm_pmu *pmu = NULL; int cpu = get_cpu(); unsigned long cpuid = read_cpuid_id(); - unsigned long implementor = (cpuid & 0xFF000000) >> 24; - unsigned long part_number = (cpuid & 0xFFF0); + unsigned long implementor = read_cpuid_implementor(); + unsigned long part_number = read_cpuid_part_number(); pr_info("probing PMU on CPU %d\n", cpu); /* ARM Ltd CPUs. */ - if (0x41 == implementor) { + if (implementor == IMPLEMENTOR_ARM) { switch (part_number) { - case 0xB360: /* ARM1136 */ - case 0xB560: /* ARM1156 */ - case 0xB760: /* ARM1176 */ + case PART_NUMBER_ARM1136: + case PART_NUMBER_ARM1156: + case PART_NUMBER_ARM1176: pmu = armv6pmu_init(); break; - case 0xB020: /* ARM11mpcore */ + case PART_NUMBER_ARM11MPCORE: pmu = armv6mpcore_pmu_init(); break; - case 0xC080: /* Cortex-A8 */ + case PART_NUMBER_CORTEX_A8: pmu = armv7_a8_pmu_init(); break; - case 0xC090: /* Cortex-A9 */ + case PART_NUMBER_CORTEX_A9: pmu = armv7_a9_pmu_init(); break; - case 0xC050: /* Cortex-A5 */ + case PART_NUMBER_CORTEX_A5: pmu = armv7_a5_pmu_init(); break; - case 0xC0F0: /* Cortex-A15 */ + case PART_NUMBER_CORTEX_A15: pmu = armv7_a15_pmu_init(); break; - case 0xC070: /* Cortex-A7 */ + case PART_NUMBER_CORTEX_A7: pmu = armv7_a7_pmu_init(); break; } /* Intel CPUs [xscale]. */ - } else if (0x69 == implementor) { + } else if (implementor == IMPLEMENTOR_INTEL) { part_number = (cpuid >> 13) & 0x7; switch (part_number) { - case 1: + case PART_NUMBER_XSCALE1: pmu = xscale1pmu_init(); break; - case 2: + case PART_NUMBER_XSCALE2: pmu = xscale2pmu_init(); break; }