From patchwork Mon Nov 11 10:19:33 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 3166981 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 98CD29F3AE for ; Mon, 11 Nov 2013 10:26:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 7A12720259 for ; Mon, 11 Nov 2013 10:26:24 +0000 (UTC) Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 0E31D20258 for ; Mon, 11 Nov 2013 10:26:23 +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 1VfohE-0004qC-Tz; Mon, 11 Nov 2013 10:26:17 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1VfohC-000330-Gp; Mon, 11 Nov 2013 10:26:14 +0000 Received: from mail-wi0-f179.google.com ([209.85.212.179]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Vfoh9-00032E-FS for linux-arm-kernel@lists.infradead.org; Mon, 11 Nov 2013 10:26:12 +0000 Received: by mail-wi0-f179.google.com with SMTP id fb10so1899663wid.0 for ; Mon, 11 Nov 2013 02:25:48 -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=lNPZR3dPg2kFIsDeijfNd5F1MePP/Pm1I4733Mi5DYs=; b=LS5/abcS3SdT/dBZ5XECIQfuPqeY98sgl578P6rLYa04cCH/AWycimiibC9Va6faqM eeYQHG59bOo7w9+XVFk1Vr4uPuLZUrzoovBp0YkV/p4tH3x8dsfeHAmqakV4P6mWsIXF G19nL/TTT+/9byiZF6RvvF2j/yREpDxgwEPHjUaCCtHy9AMGwbQYZlDW5KDY7NSjcKRn eJ32HuSEPoiQagc7YY7rYr3MukqEdyQ+ubYnQC1AeeAJ6KeMaT6nl1yq0rreL5VseUCi 0L56YwfRJMAF+yll0FDoxcxsk5quN9ABtFqnlrlCFrMEoOYnSW/uYfI4BVmyLeZL3Dti 7nhQ== X-Gm-Message-State: ALoCoQl5jekSvPaL+Ql4XaKtUUJo+qMRYeI6XtQCyqfiStQP7/qc6mgGgyw3tROWouGA4pP5qTpP X-Received: by 10.180.189.80 with SMTP id gg16mr11689675wic.32.1384165185829; Mon, 11 Nov 2013 02:19:45 -0800 (PST) Received: from localhost.localdomain (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by mx.google.com with ESMTPSA id gg20sm33709571wic.1.2013.11.11.02.19.44 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 11 Nov 2013 02:19:45 -0800 (PST) From: Ard Biesheuvel To: x86@kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/4] cpu: advertise CPU features over udev in a generic way Date: Mon, 11 Nov 2013 11:19:33 +0100 Message-Id: <1384165175-16134-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1384165175-16134-1-git-send-email-ard.biesheuvel@linaro.org> References: <1384165175-16134-1-git-send-email-ard.biesheuvel@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20131111_052611_622110_8D1858DC X-CRM114-Status: GOOD ( 12.58 ) X-Spam-Score: -2.6 (--) Cc: ak@linux.intel.com, steve.capper@linaro.org, Ard Biesheuvel , gregkh@linuxfoundation.org, hpa@zytor.com, catalin.marinas@arm.com, dave.martin@arm.com 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.2 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 | 11 +++++++++++ scripts/mod/devicetable-offsets.c | 3 +++ scripts/mod/file2alias.c | 10 ++++++++++ 3 files changed, 24 insertions(+) diff --git a/include/linux/mod_devicetable.h b/include/linux/mod_devicetable.h index 45e9214..da20e57 100644 --- a/include/linux/mod_devicetable.h +++ b/include/linux/mod_devicetable.h @@ -564,6 +564,17 @@ 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 tracking CPU features. + * @feature: the bit number of the feature (0000 - ffff) + * + * How the bit numbers map to actual CPU features is entirely up to the arch + */ + +struct generic_cpu_id { + __u16 feature; +}; + #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 bb5d115..1aa2126 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(generic_cpu_id); + DEVID_FIELD(generic_cpu_id, 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 2370863..efc7abe 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, generic_cpu_id, feature); + + sprintf(alias, "cpu:type:*:feature:*%04X*", feature); + return 1; +} +ADD_TO_DEVTABLE("cpu", generic_cpu_id, do_cpu_entry); + /* Looks like: mei:S */ static int do_mei_entry(const char *filename, void *symval, char *alias)