From patchwork Mon Jan 6 08:22:11 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 3436431 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id E47A09F163 for ; Mon, 6 Jan 2014 08:25:24 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id D2D562016D for ; Mon, 6 Jan 2014 08:25:23 +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 9B34F2016A for ; Mon, 6 Jan 2014 08:25:22 +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 1W05TH-0006P0-Va; Mon, 06 Jan 2014 08:23:40 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1W05T2-0003I2-E7; Mon, 06 Jan 2014 08:23:24 +0000 Received: from mail-wg0-f44.google.com ([74.125.82.44]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1W05SW-0003CC-Cv for linux-arm-kernel@lists.infradead.org; Mon, 06 Jan 2014 08:22:53 +0000 Received: by mail-wg0-f44.google.com with SMTP id a1so15243459wgh.11 for ; Mon, 06 Jan 2014 00:22:27 -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=BHJJu5ndGbYcim66pRDkjB7cGMn2E3keOoc6ILk9yZg=; b=XmUdM3cQGNvqC2GlKYDVYSoebN2JChg/GAselc97ZX0x37vZR6mxno5WZvyTgwBl1f q1VrS1wjUOknWDC7ktWzGB0qZeh3Y56IbOzkTZWx3DNHnyDxjz24GNKVhy0avgjtCEsk tKqmwVKVfNIeySVm7gzRl7pnBsxwTBQRjIzos4pIUo4F1AgdTc+uEhn7p/uEurQgzJ2h U/J5Vxs3u640Yj3SEehY1MA/8fle975VvkUE2Uo+5+r3NWoiTsqTj/UykvXrcFACZKx0 gZ1+wGHkF82T/5u1ctMYMcQygLZDQ6g38224unsdDAT1JURwig8NEoR8Q/IapdWVVuPB iqag== X-Gm-Message-State: ALoCoQm1VS3U5CutFvIZE8JhFCEoiV4CI8Dcngq2RG2fLNPRMLFi8vJkGbOfrlZqN2+OY6kZI7+a X-Received: by 10.180.104.164 with SMTP id gf4mr4845401wib.35.1388996546962; Mon, 06 Jan 2014 00:22:26 -0800 (PST) Received: from ards-mac-mini.local (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id ci4sm41930498wjc.21.2014.01.06.00.22.25 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 06 Jan 2014 00:22:26 -0800 (PST) From: Ard Biesheuvel To: catalin.marinas@arm.com, will.deacon@arm.com, gregkh@linuxfoundation.org, akpm@linux-foundation.org, hpa@zytor.com, ak@linux.intel.com Subject: [PATCH 3/8] cpu: advertise CPU features over udev in a generic way Date: Mon, 6 Jan 2014 09:22:11 +0100 Message-Id: <1388996536-27014-4-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1388996536-27014-1-git-send-email-ard.biesheuvel@linaro.org> References: <1388996536-27014-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140106_032252_557669_7089563F X-CRM114-Status: GOOD ( 12.36 ) X-Spam-Score: -2.6 (--) Cc: Ard Biesheuvel , herbert@gondor.apana.org.au, nico@linaro.org, x86@kernel.org, linux-kernel@vger.kernel.org, mingo@redhat.com, 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.5 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 patch implements a generic modalias 'cpu:type:...:feature:...' which enables CPU feature flag based module loading in a generic way. All the arch needs to do is enable CONFIG_ARCH_HAS_CPU_AUTOPROBE and implement arch_print_cpu_modalias(). The modules need to declare the CPU feature they depend on with MODULE_DEVICE_TABLE(cpu, ...) Signed-off-by: Ard Biesheuvel --- include/linux/mod_devicetable.h | 15 +++++++++++++++ scripts/mod/devicetable-offsets.c | 3 +++ scripts/mod/file2alias.c | 10 ++++++++++ 3 files changed, 28 insertions(+) diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 45e921401b06..3aad3c0f765c 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -564,6 +564,21 @@ struct x86_cpu_id { #define X86_MODEL_ANY 0 #define X86_FEATURE_ANY 0 /* Same as FPU, you can't test for that */ +/* + * Generic table type for matching CPU features. + * @feature: the bit number of the feature (0 - 65535) + * + * How the bit numbers map to actual CPU features is entirely up to the arch, + * although using the same ID space as hwcaps seems obvious. + */ + +struct cpu_feature { + __u16 feature; +}; + +/* hwcap const are bit masks, so take the log when using them as feature IDs */ +#define CPU_FEATURE_HWCAP(x) ilog2(x) + #define IPACK_ANY_FORMAT 0xff #define IPACK_ANY_ID (~0) struct ipack_device_id { diff --git a/scripts/mod/devicetable-offsets.c b/scripts/mod/devicetable-offsets.c index bb5d115ca671..f282516acc7b 100644 --- a/scripts/mod/devicetable-offsets.c +++ b/scripts/mod/devicetable-offsets.c @@ -174,6 +174,9 @@ int main(void) DEVID_FIELD(x86_cpu_id, model); DEVID_FIELD(x86_cpu_id, vendor); + DEVID(cpu_feature); + DEVID_FIELD(cpu_feature, feature); + DEVID(mei_cl_device_id); DEVID_FIELD(mei_cl_device_id, name); diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c index 23708636b05c..8a69005228d8 100644 --- a/scripts/mod/file2alias.c +++ b/scripts/mod/file2alias.c @@ -1135,6 +1135,16 @@ static int do_x86cpu_entry(const char *filename, void *symval, } ADD_TO_DEVTABLE("x86cpu", x86_cpu_id, do_x86cpu_entry); +/* LOOKS like cpu:type:*:feature:*FEAT* */ +static int do_cpu_entry(const char *filename, void *symval, char *alias) +{ + DEF_FIELD(symval, cpu_feature, feature); + + sprintf(alias, "cpu:type:*:feature:*%04X*", feature); + return 1; +} +ADD_TO_DEVTABLE("cpu", cpu_feature, do_cpu_entry); + /* Looks like: mei:S */ static int do_mei_entry(const char *filename, void *symval, char *alias)