From patchwork Wed Jan 29 16:50:45 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 3552771 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id B679DC02DC for ; Wed, 29 Jan 2014 17:00:50 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id A7A742018A for ; Wed, 29 Jan 2014 17:00:49 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 54F1F20181 for ; Wed, 29 Jan 2014 17:00:48 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W8YUq-0003G3-FA; Wed, 29 Jan 2014 17:00:16 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W8YUg-0001z5-FT; Wed, 29 Jan 2014 17:00:06 +0000 Received: from mail-ee0-f51.google.com ([74.125.83.51]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W8YUS-0001x3-Hj for linux-arm-kernel@lists.infradead.org; Wed, 29 Jan 2014 16:59:53 +0000 Received: by mail-ee0-f51.google.com with SMTP id b57so1041772eek.38 for ; Wed, 29 Jan 2014 08:59:30 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xXTixiV3Z0ZXWD+/skHD7fmHkLYNcY9kCUmqdP4z3Yw=; b=kqwuaRXPD3TggxxLZzEgA7RtS/OWhlJ0INEEgYbLeSRlyIH2lug4lBvTea9e/6e4El Mev0odfiaDgJK2+Ang6NvGzpQDzHNAOackS0clSMRujPZDaSJvB/lDK5X9IS+V6kJDmg chLW+kKmtp7Ey7NO8I0IsduJIzWBwUJfZDydzBGatsxC6eT226+hSutigtd/ApNV4rgz ZsAWIjAtDSMRVtWvs2A6JSd82deI3ZQXwYp25J+up2sBdsUY9z9AnYDkptjqhjyZbmJh Bsop1iNA+hyKftUE6RkGJzc7pACVtihrMn+wccQkHCo99+brN2Ne8UsqfgrBEVp9GPia sKGg== X-Gm-Message-State: ALoCoQm6/gkcqOiOG/wcPpSk8dXhKthn/8ion5vtGIMLVAk+QF5Bnfhd4r4FrV1aKq0j+TKMRp0a X-Received: by 10.14.8.131 with SMTP id 3mr1185402eer.111.1391014299111; Wed, 29 Jan 2014 08:51:39 -0800 (PST) Received: from ards-macbook-pro.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id m1sm10892118een.7.2014.01.29.08.51.28 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Jan 2014 08:51:38 -0800 (PST) From: Ard Biesheuvel To: linux-kernel@vger.kernel.org Subject: [PATCH 4/5] arm64: enable generic CPU feature modalias matching for this arch Date: Wed, 29 Jan 2014 17:50:45 +0100 Message-Id: <1391014246-9715-5-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1391014246-9715-1-git-send-email-ard.biesheuvel@linaro.org> References: <1391014246-9715-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140129_115952_758023_C535855A X-CRM114-Status: GOOD ( 14.86 ) X-Spam-Score: -2.6 (--) Cc: Ard Biesheuvel , arnd@arndb.de, gregkh@linuxfoundation.org, catalin.marinas@arm.com, x86@kernel.org, will.deacon@arm.com, mingo@redhat.com, hpa@zytor.com, tglx@linutronix.de, akpm@linux-foundation.org, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.7 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This enables support for the generic CPU feature modalias implementation that wires up optional CPU features to udev based module autoprobing. A file is provided that maps CPU feature numbers to elf_hwcap bits, which is the standard way on arm64 to advertise optional CPU features both internally and to user space. Signed-off-by: Ard Biesheuvel --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/cpufeature.h | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 arch/arm64/include/asm/cpufeature.h diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index dd4327f09ba4..e339099b6fbd 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -16,6 +16,7 @@ config ARM64 select DCACHE_WORD_ACCESS select GENERIC_CLOCKEVENTS select GENERIC_CLOCKEVENTS_BROADCAST if SMP + select GENERIC_CPU_AUTOPROBE select GENERIC_IOMAP select GENERIC_IRQ_PROBE select GENERIC_IRQ_SHOW diff --git a/arch/arm64/include/asm/cpufeature.h b/arch/arm64/include/asm/cpufeature.h new file mode 100644 index 000000000000..1d902efa201d --- /dev/null +++ b/arch/arm64/include/asm/cpufeature.h @@ -0,0 +1,30 @@ +/* + * Copyright (C) 2014 Linaro Ltd. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + */ + +#ifndef __ASM_CPUFEATURE_H +#define __ASM_CPUFEATURE_H + +#include +#include + +/* + * In the arm64 world (as in the ARM world), elf_hwcap is used both internally + * in the kernel and for user space to keep track of which optional features + * are supported by the current system. So let's map feature 'x' to HWCAP_x. + * Note that HWCAP_x constants are bit fields so we need to take the log. + */ + +#define MAX_CPU_FEATURES sizeof(elf_hwcap) +#define cpu_feature(x) ((unsigned int)ilog2(HWCAP_ ## x)) + +static inline bool cpu_have_feature(unsigned int num) +{ + return !!(elf_hwcap & (1 << num)); +} + +#endif