/* Key to pathname encoder * * Copyright (C) 2007 Red Hat, Inc. All Rights Reserved. * Written by David Howells (dhowells@redhat.com) * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public Licence * as published by the Free Software Foundation; either version * 2 of the Licence, or (at your option) any later version. */ #include <linux/slab.h> #include "internal.h" static const char cachefiles_charmap[64] = "0123456789" /* 0 - 9 */ "abcdefghijklmnopqrstuvwxyz" /* 10 - 35 */ "ABCDEFGHIJKLMNOPQRSTUVWXYZ" /* 36 - 61 */ "_-" /* 62 - 63 */ ; static const char cachefiles_filecharmap[256] = { /* we skip space and tab and control chars */ [33 ... 46] = 1, /* '!' -> '.' */ /* we skip '/' as it's significant to pathwalk */ [48 ... 127] = 1, /* '0' -> '~' */ }; /* * turn the raw key into something cooked * - the raw key should include the length in the two bytes at the front * - the key may be up to 514 bytes in length (including the length word) * - "base64" encode the strange keys, mapping 3 bytes of raw to four of * cooked * - need to cut the cooked key into 252 char lengths (189 raw bytes) */ char *cachefiles_cook_key(const u8 *raw, int keylen, uint8_t type) { unsigned char csum, ch; unsigned int acc; char *key; int loop, len, max, seg, mark, print; _enter(",%d", keylen); BUG_ON(keylen < 2 || keylen > 514); csum = raw[0] + raw[1]; print = 1; for (loop = 2; loop < keylen; loop++) { ch = raw[loop]; csum += ch; print &= cachefiles_filecharmap[ch]; } if (print) { /* if the path is usable ASCII, then we render it directly */ max = keylen - 2; max += 2; /* two base64'd length chars on the front */ max += 5; /* @checksum/M */ max += 3 * 2; /* maximum number of segment dividers (".../M") * is ((514 + 251) / 252) = 3 */ max += 1; /* NUL on end */ } else { /* calculate the maximum length of the cooked key */ keylen = (keylen + 2) / 3; max = keylen * 4; max += 5; /* @checksum/M */ max += 3 * 2; /* maximum number of segment dividers (".../M") * is ((514 + 188) / 189) = 3 */ max += 1; /* NUL on end */ } max += 1; /* 2nd NUL on end */ _debug("max: %d", max); key = kmalloc(max, cachefiles_gfp); if (!key) return NULL; len = 0; /* build the cooked key */ sprintf(key, "@%02x%c+", (unsigned) csum, 0); len = 5; mark = len - 1; if (print) { acc = *(uint16_t *) raw; raw += 2; key[len + 1] = cachefiles_charmap[acc & 63]; acc >>= 6; key[len] = cachefiles_charmap[acc & 63]; len += 2; seg = 250; for (loop = keylen; loop > 0; loop--) { if (seg <= 0) { key[len++] = '\0'; mark = len; key[len++] = '+'; seg = 252; } key[len++] = *raw++; ASSERT(len < max); } switch (type) { case FSCACHE_COOKIE_TYPE_INDEX: type = 'I'; break; case FSCACHE_COOKIE_TYPE_DATAFILE: type = 'D'; break; default: type = 'S'; break; } } else { seg = 252; for (loop = keylen; loop > 0; loop--) { if (seg <= 0) { key[len++] = '\0'; mark = len; key[len++] = '+'; seg = 252; } acc = *raw++; acc |= *raw++ << 8; acc |= *raw++ << 16; _debug("acc: %06x", acc); key[len++] = cachefiles_charmap[acc & 63]; acc >>= 6; key[len++] = cachefiles_charmap[acc & 63]; acc >>= 6; key[len++] = cachefiles_charmap[acc & 63]; acc >>= 6; key[len++] = cachefiles_charmap[acc & 63]; ASSERT(len < max); } switch (type) { case FSCACHE_COOKIE_TYPE_INDEX: type = 'J'; break; case FSCACHE_COOKIE_TYPE_DATAFILE: type = 'E'; break; default: type = 'T'; break; } } key[mark] = type; key[len++] = 0; key[len] = 0; _leave(" = %p %d", key, len); return key; } on><option value='6'>6</option><option value='7'>7</option><option value='8'>8</option><option value='9'>9</option><option value='10'>10</option><option value='15'>15</option><option value='20'>20</option><option value='25'>25</option><option value='30'>30</option><option value='35'>35</option><option value='40'>40</option></select></td></tr><tr><td class='label'>space:</td><td class='ctrl'><select name='ignorews' onchange='this.form.submit();'><option value='0' selected='selected'>include</option><option value='1'>ignore</option></select></td></tr><tr><td class='label'>mode:</td><td class='ctrl'><select name='dt' onchange='this.form.submit();'><option value='0' selected='selected'>unified</option><option value='1'>ssdiff</option><option value='2'>stat only</option></select></td></tr><tr><td/><td class='ctrl'><noscript><input type='submit' value='reload'/></noscript></td></tr></table></form></div><table summary='commit info' class='commit-info'> <tr><th>author</th><td>Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com></td><td class='right'>2017-02-03 14:18:39 -0800</td></tr> <tr><th>committer</th><td>Rafael J. Wysocki <rafael.j.wysocki@intel.com></td><td class='right'>2017-02-04 00:11:08 +0100</td></tr> <tr><th>commit</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/sound/core/seq/seq_ports.h?id=6e978b22efa1db9f6e71b24440b5f1d93e968ee3'>6e978b22efa1db9f6e71b24440b5f1d93e968ee3</a> (<a href='/cgit.cgi/linux/net-next.git/patch/sound/core/seq/seq_ports.h?id=6e978b22efa1db9f6e71b24440b5f1d93e968ee3'>patch</a>)</td></tr> <tr><th>tree</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/tree/?id=6e978b22efa1db9f6e71b24440b5f1d93e968ee3'>c666f7a26b860674848949e39a610222b0723f89</a> /<a href='/cgit.cgi/linux/net-next.git/tree/sound/core/seq/seq_ports.h?id=6e978b22efa1db9f6e71b24440b5f1d93e968ee3'>sound/core/seq/seq_ports.h</a></td></tr> <tr><th>parent</th><td colspan='2' class='oid'><a href='/cgit.cgi/linux/net-next.git/commit/sound/core/seq/seq_ports.h?id=3c223c19aea85d3dda1416c187915f4a30b04b1f'>3c223c19aea85d3dda1416c187915f4a30b04b1f</a> (<a href='/cgit.cgi/linux/net-next.git/diff/sound/core/seq/seq_ports.h?id=6e978b22efa1db9f6e71b24440b5f1d93e968ee3&id2=3c223c19aea85d3dda1416c187915f4a30b04b1f'>diff</a>)</td></tr></table> <div class='commit-subject'>cpufreq: intel_pstate: Disable energy efficiency optimization</div><div class='commit-msg'>Some Kabylake desktop processors may not reach max turbo when running in HWP mode, even if running under sustained 100% utilization. This occurs when the HWP.EPP (Energy Performance Preference) is set to "balance_power" (0x80) -- the default on most systems. It occurs because the platform BIOS may erroneously enable an energy-efficiency setting -- MSR_IA32_POWER_CTL BIT-EE, which is not recommended to be enabled on this SKU. On the failing systems, this BIOS issue was not discovered when the desktop motherboard was tested with Windows, because the BIOS also neglects to provide the ACPI/CPPC table, that Windows requires to enable HWP, and so Windows runs in legacy P-state mode, where this setting has no effect. Linux' intel_pstate driver does not require ACPI/CPPC to enable HWP, and so it runs in HWP mode, exposing this incorrect BIOS configuration. There are several ways to address this problem. First, Linux can also run in legacy P-state mode on this system. As intel_pstate is how Linux enables HWP, booting with "intel_pstate=disable" will run in acpi-cpufreq/ondemand legacy p-state mode. Or second, the "performance" governor can be used with intel_pstate, which will modify HWP.EPP to 0. Or third, starting in 4.10, the /sys/devices/system/cpu/cpufreq/policy*/energy_performance_preference attribute in can be updated from "balance_power" to "performance". Or fourth, apply this patch, which fixes the erroneous setting of MSR_IA32_POWER_CTL BIT_EE on this model, allowing the default configuration to function as designed. Signed-off-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com> Reviewed-by: Len Brown <len.brown@intel.com> Cc: 4.6+ <stable@vger.kernel.org> # 4.6+ Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> </div><div class='diffstat-header'><a href='/cgit.cgi/linux/net-next.git/diff/?id=6e978b22efa1db9f6e71b24440b5f1d93e968ee3'>Diffstat</a> (limited to 'sound/core/seq/seq_ports.h')</div><table summary='diffstat' class='diffstat'>