aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/mod
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2012-01-25 18:09:05 -0500
committerGreg Kroah-Hartman <gregkh@suse.de>2012-01-26 19:44:41 -0500
commit644e9cbbe3fc032cc92d0936057e166a994dc246 (patch)
tree46f0c35d92419dcedf19067a060e7877dc3d6b28 /scripts/mod
parentd6e486868cde585842d55ba3b6ec57af090fc343 (diff)
Add driver auto probing for x86 features v4
There's a growing number of drivers that support a specific x86 feature or CPU. Currently loading these drivers currently on a generic distribution requires various driver specific hacks and it often doesn't work. This patch adds auto probing for drivers based on the x86 cpuid information, in particular based on vendor/family/model number and also based on CPUID feature bits. For example a common issue is not loading the SSE 4.2 accelerated CRC module: this can significantly lower the performance of BTRFS which relies on fast CRC. Another issue is loading the right CPUFREQ driver for the current CPU. Currently distributions often try all all possible driver until one sticks, which is not really a good way to do this. It works with existing udev without any changes. The code exports the x86 information as a generic string in sysfs that can be matched by udev's pattern matching. This scheme does not support numeric ranges, so if you want to handle e.g. ranges of model numbers they have to be encoded in ASCII or simply all models or families listed. Fixing that would require changing udev. Another issue is that udev will happily load all drivers that match, there is currently no nice way to stop a specific driver from being loaded if it's not needed (e.g. if you don't need fast CRC) But there are not that many cpu specific drivers around and they're all not that bloated, so this isn't a particularly serious issue. Originally this patch added the modalias to the normal cpu sysdevs. However sysdevs don't have all the infrastructure needed for udev, so it couldn't really autoload drivers. This patch instead adds the CPU modaliases to the cpuid devices, which are real devices with full support for udev. This implies that the cpuid driver has to be loaded to use this. This patch just adds infrastructure, some driver conversions in followups. Thanks to Kay for helping with some sysfs magic. v2: Constifcation, some updates v4: (trenn@suse.de): - Use kzalloc instead of kmalloc to terminate modalias buffer - Use uppercase hex values to match correctly against hex values containing letters Cc: Dave Jones <davej@redhat.com> Cc: Kay Sievers <kay.sievers@vrfy.org> Cc: Jen Axboe <axboe@kernel.dk> Cc: Herbert Xu <herbert@gondor.apana.org.au> Cc: Huang Ying <ying.huang@intel.com> Cc: Len Brown <lenb@kernel.org> Signed-off-by: Andi Kleen <ak@linux.intel.com> Signed-off-by: Thomas Renninger <trenn@suse.de> Acked-by: H. Peter Anvin <hpa@zytor.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'scripts/mod')
-rw-r--r--scripts/mod/file2alias.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
index c0e14b3f2306..026ba38759ca 100644
--- a/scripts/mod/file2alias.c
+++ b/scripts/mod/file2alias.c
@@ -1013,6 +1013,30 @@ static int do_amba_entry(const char *filename,
1013} 1013}
1014ADD_TO_DEVTABLE("amba", struct amba_id, do_amba_entry); 1014ADD_TO_DEVTABLE("amba", struct amba_id, do_amba_entry);
1015 1015
1016/* LOOKS like x86cpu:vendor:VVVV:family:FFFF:model:MMMM:feature:*,FEAT,*
1017 * All fields are numbers. It would be nicer to use strings for vendor
1018 * and feature, but getting those out of the build system here is too
1019 * complicated.
1020 */
1021
1022static int do_x86cpu_entry(const char *filename, struct x86_cpu_id *id,
1023 char *alias)
1024{
1025 id->feature = TO_NATIVE(id->feature);
1026 id->family = TO_NATIVE(id->family);
1027 id->model = TO_NATIVE(id->model);
1028 id->vendor = TO_NATIVE(id->vendor);
1029
1030 strcpy(alias, "x86cpu:");
1031 ADD(alias, "vendor:", id->vendor != X86_VENDOR_ANY, id->vendor);
1032 ADD(alias, ":family:", id->family != X86_FAMILY_ANY, id->family);
1033 ADD(alias, ":model:", id->model != X86_MODEL_ANY, id->model);
1034 ADD(alias, ":feature:*,", id->feature != X86_FEATURE_ANY, id->feature);
1035 strcat(alias, ",*");
1036 return 1;
1037}
1038ADD_TO_DEVTABLE("x86cpu", struct x86_cpu_id, do_x86cpu_entry);
1039
1016/* Does namelen bytes of name exactly match the symbol? */ 1040/* Does namelen bytes of name exactly match the symbol? */
1017static bool sym_is(const char *name, unsigned namelen, const char *symbol) 1041static bool sym_is(const char *name, unsigned namelen, const char *symbol)
1018{ 1042{