diff options
-rw-r--r-- | .SRCINFO | 22 | ||||
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | 0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch | 103 | ||||
-rw-r--r-- | 0002-Revert-drm-i915-edp-Allow-alternate-fixed-mode-for-e.patch | 242 | ||||
-rw-r--r-- | 0003-ACPI-watchdog-Prefer-iTCO_wdt-always-when-WDAT-table.patch | 132 | ||||
-rw-r--r-- | 0004-mac80211-disable-BHs-preemption-in-ieee80211_tx_cont.patch | 46 | ||||
-rw-r--r-- | PKGBUILD | 83 | ||||
-rw-r--r-- | config | 7 | ||||
-rw-r--r-- | intel-pstate-backport.patch | 1117 | ||||
-rw-r--r-- | linux.install | 15 |
10 files changed, 24 insertions, 1744 deletions
@@ -1,5 +1,5 @@ pkgbase = linux-macbook - pkgver = 4.17.10 + pkgver = 4.17.11 pkgrel = 1 url = https://www.kernel.org/ arch = x86_64 @@ -9,36 +9,24 @@ pkgbase = linux-macbook makedepends = inetutils makedepends = bc makedepends = libelf + makedepends = git options = !strip - source = https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.17.tar.xz - source = https://www.kernel.org/pub/linux/kernel/v4.x/linux-4.17.tar.sign - source = https://www.kernel.org/pub/linux/kernel/v4.x/patch-4.17.10.xz - source = https://www.kernel.org/pub/linux/kernel/v4.x/patch-4.17.10.sign + source = archlinux-linux::git+https://github.com/archlinux/linux?signed#tag=v4.17.11-arch1 source = config source = 60-linux.hook source = 90-linux.hook source = linux.preset - source = 0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch - source = 0002-Revert-drm-i915-edp-Allow-alternate-fixed-mode-for-e.patch - source = 0003-ACPI-watchdog-Prefer-iTCO_wdt-always-when-WDAT-table.patch - source = 0004-mac80211-disable-BHs-preemption-in-ieee80211_tx_cont.patch source = macbook-wakeup.service source = RFC-PCI-Workaround-to-enable-poweroff-on-Mac-Pro-11.patch source = RFC-v2-PCI-Workaround-to-enable-poweroff-on-Mac-Pro-11.patch validpgpkeys = ABAF11C65A2970B130ABE3C479BE3E4300411886 validpgpkeys = 647F28654894E3BD457199BE38DBBDC86092693E - sha256sums = 9faa1dd896eaea961dc6e886697c0b3301277102e5bc976b2758f9a62d3ccd13 + validpgpkeys = 8218F88849AAC522E94CF470A5E9288C4FA415FA sha256sums = SKIP - sha256sums = 41ad005296c7a1b5245a87881f666b3f4d7aa05a6b9409454b2e473d473c4cee - sha256sums = SKIP - sha256sums = f8e890eac9779a89009c1e2339f757e9781864df09805211fad005146fe2578b + sha256sums = aa7b6756f193f3b3a3fc4947e7a77b09e249df2e345e6495292055d757ba8be6 sha256sums = ae2e95db94ef7176207c690224169594d49445e04249d2499e9d2fbc117a0b21 sha256sums = 75f99f5239e03238f88d1a834c50043ec32b1dc568f2cc291b07d04718483919 sha256sums = ad6344badc91ad0630caacde83f7f9b97276f80d26a20619a87952be65492c65 - sha256sums = 92f848d0e21fbb2400e50d1c1021514893423641e5450896d7b1d88aa880b2b9 - sha256sums = fc3c50ae6bd905608e0533a883ab569fcf54038fb9d6569b391107d9fd00abbc - sha256sums = bc50c605bd0e1fa7437c21ddef728b83b6de3322b988e14713032993dfa1fc69 - sha256sums = 66284102261c4ed53db050e9045c8672ba0e5171884b46e58f6cd417774d8578 sha256sums = c5a714823c3418692bc5c212dd5d094a0e2ae6147d6726822911f1c26e3a1d1b sha256sums = 7c99aaeaea7837f83a3ad215cf07277934ccf39720acee7f1c371dc86bdf89fc sha256sums = 09189eb269a9fd16898cf90a477df23306236fb897791e8d04e5a75d5007bbff diff --git a/.gitignore b/.gitignore index 2f010a3c14a2..424afb423851 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ syncrepo.sh src pkg +archlinux-linux *.xz *.pkg *.sign diff --git a/0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch b/0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch deleted file mode 100644 index 72c4f979ef86..000000000000 --- a/0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch +++ /dev/null @@ -1,103 +0,0 @@ -From a2d2476ffec7d988b1a5396586869570e0d6f9d8 Mon Sep 17 00:00:00 2001 -Message-Id: <a2d2476ffec7d988b1a5396586869570e0d6f9d8.1531335939.git.jan.steffens@gmail.com> -From: Serge Hallyn <serge.hallyn@canonical.com> -Date: Fri, 31 May 2013 19:12:12 +0100 -Subject: [PATCH 1/4] add sysctl to disallow unprivileged CLONE_NEWUSER by - default - -Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com> -[bwh: Remove unneeded binary sysctl bits] -Signed-off-by: Daniel Micay <danielmicay@gmail.com> ---- - kernel/fork.c | 15 +++++++++++++++ - kernel/sysctl.c | 12 ++++++++++++ - kernel/user_namespace.c | 3 +++ - 3 files changed, 30 insertions(+) - -diff --git a/kernel/fork.c b/kernel/fork.c -index a5d21c42acfc..675eb3f3a1d1 100644 ---- a/kernel/fork.c -+++ b/kernel/fork.c -@@ -103,6 +103,11 @@ - - #define CREATE_TRACE_POINTS - #include <trace/events/task.h> -+#ifdef CONFIG_USER_NS -+extern int unprivileged_userns_clone; -+#else -+#define unprivileged_userns_clone 0 -+#endif - - /* - * Minimum number of threads to boot the kernel -@@ -1592,6 +1597,10 @@ static __latent_entropy struct task_struct *copy_process( - if ((clone_flags & (CLONE_NEWUSER|CLONE_FS)) == (CLONE_NEWUSER|CLONE_FS)) - return ERR_PTR(-EINVAL); - -+ if ((clone_flags & CLONE_NEWUSER) && !unprivileged_userns_clone) -+ if (!capable(CAP_SYS_ADMIN)) -+ return ERR_PTR(-EPERM); -+ - /* - * Thread groups must share signals as well, and detached threads - * can only be started up within the thread group. -@@ -2386,6 +2395,12 @@ int ksys_unshare(unsigned long unshare_flags) - if (unshare_flags & CLONE_NEWNS) - unshare_flags |= CLONE_FS; - -+ if ((unshare_flags & CLONE_NEWUSER) && !unprivileged_userns_clone) { -+ err = -EPERM; -+ if (!capable(CAP_SYS_ADMIN)) -+ goto bad_unshare_out; -+ } -+ - err = check_unshare_flags(unshare_flags); - if (err) - goto bad_unshare_out; -diff --git a/kernel/sysctl.c b/kernel/sysctl.c -index 6a78cf70761d..35a1d24282f4 100644 ---- a/kernel/sysctl.c -+++ b/kernel/sysctl.c -@@ -105,6 +105,9 @@ extern int core_uses_pid; - extern char core_pattern[]; - extern unsigned int core_pipe_limit; - #endif -+#ifdef CONFIG_USER_NS -+extern int unprivileged_userns_clone; -+#endif - extern int pid_max; - extern int pid_max_min, pid_max_max; - extern int percpu_pagelist_fraction; -@@ -519,6 +522,15 @@ static struct ctl_table kern_table[] = { - .proc_handler = proc_dointvec, - }, - #endif -+#ifdef CONFIG_USER_NS -+ { -+ .procname = "unprivileged_userns_clone", -+ .data = &unprivileged_userns_clone, -+ .maxlen = sizeof(int), -+ .mode = 0644, -+ .proc_handler = proc_dointvec, -+ }, -+#endif - #ifdef CONFIG_PROC_SYSCTL - { - .procname = "tainted", -diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c -index 246d4d4ce5c7..f64432b45cec 100644 ---- a/kernel/user_namespace.c -+++ b/kernel/user_namespace.c -@@ -26,6 +26,9 @@ - #include <linux/bsearch.h> - #include <linux/sort.h> - -+/* sysctl */ -+int unprivileged_userns_clone; -+ - static struct kmem_cache *user_ns_cachep __read_mostly; - static DEFINE_MUTEX(userns_state_mutex); - --- -2.18.0 - diff --git a/0002-Revert-drm-i915-edp-Allow-alternate-fixed-mode-for-e.patch b/0002-Revert-drm-i915-edp-Allow-alternate-fixed-mode-for-e.patch deleted file mode 100644 index 8c4ceba16c97..000000000000 --- a/0002-Revert-drm-i915-edp-Allow-alternate-fixed-mode-for-e.patch +++ /dev/null @@ -1,242 +0,0 @@ -From bc49947e26285cf644492f9d58981e3c985d8c76 Mon Sep 17 00:00:00 2001 -Message-Id: <bc49947e26285cf644492f9d58981e3c985d8c76.1531335939.git.jan.steffens@gmail.com> -In-Reply-To: <a2d2476ffec7d988b1a5396586869570e0d6f9d8.1531335939.git.jan.steffens@gmail.com> -References: <a2d2476ffec7d988b1a5396586869570e0d6f9d8.1531335939.git.jan.steffens@gmail.com> -From: Jani Nikula <jani.nikula@intel.com> -Date: Wed, 16 May 2018 11:01:10 +0300 -Subject: [PATCH 2/4] Revert "drm/i915/edp: Allow alternate fixed mode for eDP - if available." - -This reverts commit dc911f5bd8aacfcf8aabd5c26c88e04c837a938e. - -Per the report, no matter what display mode you select with xrandr, the -i915 driver will always select the alternate fixed mode. For the -reporter this means that the display will always run at 40Hz which is -quite annoying. This may be due to the mode comparison. - -But there are some other potential issues. The choice of alt_fixed_mode -seems dubious. It's the first non-preferred mode, but there are no -guarantees that the only difference would be refresh rate. Similarly, -there may be more than one preferred mode in the probed modes list, and -the commit changes the preferred mode selection to choose the last one -on the list instead of the first. - -(Note that the probed modes list is the raw, unfiltered, unsorted list -of modes from drm_add_edid_modes(), not the pretty result after a -drm_helper_probe_single_connector_modes() call.) - -Finally, we already have eerily similar code in place to find the -downclock mode for DRRS that seems like could be reused here. - -Back to the drawing board. - -Note: This is a hand-crafted revert due to conflicts. If it fails to -backport, please just try reverting the original commit directly. - -Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=105469 -Reported-by: Rune Petersen <rune@megahurts.dk> -Reported-by: Mark Spencer <n7u4722r35@ynzlx.anonbox.net> -Fixes: dc911f5bd8aa ("drm/i915/edp: Allow alternate fixed mode for eDP if available.") -Cc: Clint Taylor <clinton.a.taylor@intel.com> -Cc: David Weinehall <david.weinehall@linux.intel.com> -Cc: Rodrigo Vivi <rodrigo.vivi@intel.com> -Cc: Paulo Zanoni <paulo.r.zanoni@intel.com> -Cc: Jani Nikula <jani.nikula@intel.com> -Cc: Chris Wilson <chris@chris-wilson.co.uk> -Cc: Jim Bride <jim.bride@linux.intel.com> -Cc: Jani Nikula <jani.nikula@linux.intel.com> -Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> -Cc: intel-gfx@lists.freedesktop.org -Cc: <stable@vger.kernel.org> # v4.14+ -Signed-off-by: Jani Nikula <jani.nikula@intel.com> -Reviewed-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com> -Link: https://patchwork.freedesktop.org/patch/msgid/20180516080110.22770-1-jani.nikula@intel.com ---- - drivers/gpu/drm/i915/intel_dp.c | 38 ++++-------------------------- - drivers/gpu/drm/i915/intel_drv.h | 2 -- - drivers/gpu/drm/i915/intel_dsi.c | 2 +- - drivers/gpu/drm/i915/intel_dvo.c | 2 +- - drivers/gpu/drm/i915/intel_lvds.c | 3 +-- - drivers/gpu/drm/i915/intel_panel.c | 6 ----- - 6 files changed, 8 insertions(+), 45 deletions(-) - -diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c -index cd6e87756509..492b0cb9bb2b 100644 ---- a/drivers/gpu/drm/i915/intel_dp.c -+++ b/drivers/gpu/drm/i915/intel_dp.c -@@ -1674,23 +1674,6 @@ static int intel_dp_compute_bpp(struct intel_dp *intel_dp, - return bpp; - } - --static bool intel_edp_compare_alt_mode(struct drm_display_mode *m1, -- struct drm_display_mode *m2) --{ -- bool bres = false; -- -- if (m1 && m2) -- bres = (m1->hdisplay == m2->hdisplay && -- m1->hsync_start == m2->hsync_start && -- m1->hsync_end == m2->hsync_end && -- m1->htotal == m2->htotal && -- m1->vdisplay == m2->vdisplay && -- m1->vsync_start == m2->vsync_start && -- m1->vsync_end == m2->vsync_end && -- m1->vtotal == m2->vtotal); -- return bres; --} -- - bool - intel_dp_compute_config(struct intel_encoder *encoder, - struct intel_crtc_state *pipe_config, -@@ -1737,16 +1720,8 @@ intel_dp_compute_config(struct intel_encoder *encoder, - pipe_config->has_audio = intel_conn_state->force_audio == HDMI_AUDIO_ON; - - if (intel_dp_is_edp(intel_dp) && intel_connector->panel.fixed_mode) { -- struct drm_display_mode *panel_mode = -- intel_connector->panel.alt_fixed_mode; -- struct drm_display_mode *req_mode = &pipe_config->base.mode; -- -- if (!intel_edp_compare_alt_mode(req_mode, panel_mode)) -- panel_mode = intel_connector->panel.fixed_mode; -- -- drm_mode_debug_printmodeline(panel_mode); -- -- intel_fixed_panel_mode(panel_mode, adjusted_mode); -+ intel_fixed_panel_mode(intel_connector->panel.fixed_mode, -+ adjusted_mode); - - if (INTEL_GEN(dev_priv) >= 9) { - int ret; -@@ -6123,7 +6098,6 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp, - struct drm_i915_private *dev_priv = to_i915(dev); - struct drm_connector *connector = &intel_connector->base; - struct drm_display_mode *fixed_mode = NULL; -- struct drm_display_mode *alt_fixed_mode = NULL; - struct drm_display_mode *downclock_mode = NULL; - bool has_dpcd; - struct drm_display_mode *scan; -@@ -6178,14 +6152,13 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp, - } - intel_connector->edid = edid; - -- /* prefer fixed mode from EDID if available, save an alt mode also */ -+ /* prefer fixed mode from EDID if available */ - list_for_each_entry(scan, &connector->probed_modes, head) { - if ((scan->type & DRM_MODE_TYPE_PREFERRED)) { - fixed_mode = drm_mode_duplicate(dev, scan); - downclock_mode = intel_dp_drrs_init( - intel_connector, fixed_mode); -- } else if (!alt_fixed_mode) { -- alt_fixed_mode = drm_mode_duplicate(dev, scan); -+ break; - } - } - -@@ -6222,8 +6195,7 @@ static bool intel_edp_init_connector(struct intel_dp *intel_dp, - pipe_name(pipe)); - } - -- intel_panel_init(&intel_connector->panel, fixed_mode, alt_fixed_mode, -- downclock_mode); -+ intel_panel_init(&intel_connector->panel, fixed_mode, downclock_mode); - intel_connector->panel.backlight.power = intel_edp_backlight_power; - intel_panel_setup_backlight(connector, pipe); - -diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h -index a80fbad9be0f..7f3e83f17adb 100644 ---- a/drivers/gpu/drm/i915/intel_drv.h -+++ b/drivers/gpu/drm/i915/intel_drv.h -@@ -269,7 +269,6 @@ struct intel_encoder { - - struct intel_panel { - struct drm_display_mode *fixed_mode; -- struct drm_display_mode *alt_fixed_mode; - struct drm_display_mode *downclock_mode; - - /* backlight */ -@@ -1820,7 +1819,6 @@ void intel_overlay_reset(struct drm_i915_private *dev_priv); - /* intel_panel.c */ - int intel_panel_init(struct intel_panel *panel, - struct drm_display_mode *fixed_mode, -- struct drm_display_mode *alt_fixed_mode, - struct drm_display_mode *downclock_mode); - void intel_panel_fini(struct intel_panel *panel); - void intel_fixed_panel_mode(const struct drm_display_mode *fixed_mode, -diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c -index 384b37e2da70..f349b3920199 100644 ---- a/drivers/gpu/drm/i915/intel_dsi.c -+++ b/drivers/gpu/drm/i915/intel_dsi.c -@@ -1852,7 +1852,7 @@ void intel_dsi_init(struct drm_i915_private *dev_priv) - connector->display_info.width_mm = fixed_mode->width_mm; - connector->display_info.height_mm = fixed_mode->height_mm; - -- intel_panel_init(&intel_connector->panel, fixed_mode, NULL, NULL); -+ intel_panel_init(&intel_connector->panel, fixed_mode, NULL); - intel_panel_setup_backlight(connector, INVALID_PIPE); - - intel_dsi_add_properties(intel_connector); -diff --git a/drivers/gpu/drm/i915/intel_dvo.c b/drivers/gpu/drm/i915/intel_dvo.c -index 6604806f89d5..61d908e0df0e 100644 ---- a/drivers/gpu/drm/i915/intel_dvo.c -+++ b/drivers/gpu/drm/i915/intel_dvo.c -@@ -542,7 +542,7 @@ void intel_dvo_init(struct drm_i915_private *dev_priv) - */ - intel_panel_init(&intel_connector->panel, - intel_dvo_get_current_mode(intel_encoder), -- NULL, NULL); -+ NULL); - intel_dvo->panel_wants_dither = true; - } - -diff --git a/drivers/gpu/drm/i915/intel_lvds.c b/drivers/gpu/drm/i915/intel_lvds.c -index 34dd1e5233ac..48f618dc9abb 100644 ---- a/drivers/gpu/drm/i915/intel_lvds.c -+++ b/drivers/gpu/drm/i915/intel_lvds.c -@@ -1180,8 +1180,7 @@ void intel_lvds_init(struct drm_i915_private *dev_priv) - out: - mutex_unlock(&dev->mode_config.mutex); - -- intel_panel_init(&intel_connector->panel, fixed_mode, NULL, -- downclock_mode); -+ intel_panel_init(&intel_connector->panel, fixed_mode, downclock_mode); - intel_panel_setup_backlight(connector, INVALID_PIPE); - - lvds_encoder->is_dual_link = compute_is_dual_link_lvds(lvds_encoder); -diff --git a/drivers/gpu/drm/i915/intel_panel.c b/drivers/gpu/drm/i915/intel_panel.c -index 41d00b1603e3..b443278e569c 100644 ---- a/drivers/gpu/drm/i915/intel_panel.c -+++ b/drivers/gpu/drm/i915/intel_panel.c -@@ -1928,30 +1928,24 @@ intel_panel_init_backlight_funcs(struct intel_panel *panel) - - int intel_panel_init(struct intel_panel *panel, - struct drm_display_mode *fixed_mode, -- struct drm_display_mode *alt_fixed_mode, - struct drm_display_mode *downclock_mode) - { - intel_panel_init_backlight_funcs(panel); - - panel->fixed_mode = fixed_mode; -- panel->alt_fixed_mode = alt_fixed_mode; - panel->downclock_mode = downclock_mode; - - return 0; - } - - void intel_panel_fini(struct intel_panel *panel) - { - struct intel_connector *intel_connector = - container_of(panel, struct intel_connector, panel); - - if (panel->fixed_mode) - drm_mode_destroy(intel_connector->base.dev, panel->fixed_mode); - -- if (panel->alt_fixed_mode) -- drm_mode_destroy(intel_connector->base.dev, -- panel->alt_fixed_mode); -- - if (panel->downclock_mode) - drm_mode_destroy(intel_connector->base.dev, - panel->downclock_mode); --- -2.18.0 - diff --git a/0003-ACPI-watchdog-Prefer-iTCO_wdt-always-when-WDAT-table.patch b/0003-ACPI-watchdog-Prefer-iTCO_wdt-always-when-WDAT-table.patch deleted file mode 100644 index 00ae30e9e4ac..000000000000 --- a/0003-ACPI-watchdog-Prefer-iTCO_wdt-always-when-WDAT-table.patch +++ /dev/null @@ -1,132 +0,0 @@ -From 598ca9d1cc714cb530141c20a90dc25d34f861fd Mon Sep 17 00:00:00 2001 -Message-Id: <598ca9d1cc714cb530141c20a90dc25d34f861fd.1531335939.git.jan.steffens@gmail.com> -In-Reply-To: <a2d2476ffec7d988b1a5396586869570e0d6f9d8.1531335939.git.jan.steffens@gmail.com> -References: <a2d2476ffec7d988b1a5396586869570e0d6f9d8.1531335939.git.jan.steffens@gmail.com> -From: Mika Westerberg <mika.westerberg@linux.intel.com> -Date: Tue, 22 May 2018 14:16:50 +0300 -Subject: [PATCH 3/4] ACPI / watchdog: Prefer iTCO_wdt always when WDAT table - uses RTC SRAM - -After we added quirk for Lenovo Z50-70 it turns out there are at least -two more systems where WDAT table includes instructions accessing RTC -SRAM. Instead of quirking each system separately, look for such -instructions in the table and automatically prefer iTCO_wdt if found. - -Link: https://bugzilla.kernel.org/show_bug.cgi?id=199033 -Reported-by: Arnold Guy <aurnoldg@gmail.com> -Reported-by: Alois Nespor <nespor@fssp.cz> -Reported-by: Yury Pakin <zxwarior@gmail.com> -Reported-by: Ihor Chyhin <ihorchyhin@ukr.net> -Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com> -Acked-by: Guenter Roeck <linux@roeck-us.net> ---- - drivers/acpi/acpi_watchdog.c | 72 ++++++++++++++++++++++-------------- - 1 file changed, 45 insertions(+), 27 deletions(-) - -diff --git a/drivers/acpi/acpi_watchdog.c b/drivers/acpi/acpi_watchdog.c -index 4bde16fb97d8..95600309ce42 100644 ---- a/drivers/acpi/acpi_watchdog.c -+++ b/drivers/acpi/acpi_watchdog.c -@@ -12,54 +12,72 @@ - #define pr_fmt(fmt) "ACPI: watchdog: " fmt - - #include <linux/acpi.h> --#include <linux/dmi.h> - #include <linux/ioport.h> - #include <linux/platform_device.h> - - #include "internal.h" - --static const struct dmi_system_id acpi_watchdog_skip[] = { -- { -- /* -- * On Lenovo Z50-70 there are two issues with the WDAT -- * table. First some of the instructions use RTC SRAM -- * to store persistent information. This does not work well -- * with Linux RTC driver. Second, more important thing is -- * that the instructions do not actually reset the system. -- * -- * On this particular system iTCO_wdt seems to work just -- * fine so we prefer that over WDAT for now. -- * -- * See also https://bugzilla.kernel.org/show_bug.cgi?id=199033. -- */ -- .ident = "Lenovo Z50-70", -- .matches = { -- DMI_MATCH(DMI_SYS_VENDOR, "LENOVO"), -- DMI_MATCH(DMI_PRODUCT_NAME, "20354"), -- DMI_MATCH(DMI_PRODUCT_VERSION, "Lenovo Z50-70"), -- }, -- }, -- {} --}; -+#ifdef CONFIG_RTC_MC146818_LIB -+#include <linux/mc146818rtc.h> -+ -+/* -+ * There are several systems where the WDAT table is accessing RTC SRAM to -+ * store persistent information. This does not work well with the Linux RTC -+ * driver so on those systems we skip WDAT driver and prefer iTCO_wdt -+ * instead. -+ * -+ * See also https://bugzilla.kernel.org/show_bug.cgi?id=199033. -+ */ -+static bool acpi_watchdog_uses_rtc(const struct acpi_table_wdat *wdat) -+{ -+ const struct acpi_wdat_entry *entries; -+ int i; -+ -+ entries = (struct acpi_wdat_entry *)(wdat + 1); -+ for (i = 0; i < wdat->entries; i++) { -+ const struct acpi_generic_address *gas; -+ -+ gas = &entries[i].register_region; -+ if (gas->space_id == ACPI_ADR_SPACE_SYSTEM_IO) { -+ switch (gas->address) { -+ case RTC_PORT(0): -+ case RTC_PORT(1): -+ case RTC_PORT(2): -+ case RTC_PORT(3): -+ return true; -+ } -+ } -+ } -+ -+ return false; -+} -+#else -+static bool acpi_watchdog_uses_rtc(const struct acpi_table_wdat *wdat) -+{ -+ return false; -+} -+#endif - - static const struct acpi_table_wdat *acpi_watchdog_get_wdat(void) - { - const struct acpi_table_wdat *wdat = NULL; - acpi_status status; - - if (acpi_disabled) - return NULL; - -- if (dmi_check_system(acpi_watchdog_skip)) -- return NULL; -- - status = acpi_get_table(ACPI_SIG_WDAT, 0, - (struct acpi_table_header **)&wdat); - if (ACPI_FAILURE(status)) { - /* It is fine if there is no WDAT */ - return NULL; - } - -+ if (acpi_watchdog_uses_rtc(wdat)) { -+ pr_info("Skipping WDAT on this system because it uses RTC SRAM\n"); -+ return NULL; -+ } -+ - return wdat; - } - --- -2.18.0 - diff --git a/0004-mac80211-disable-BHs-preemption-in-ieee80211_tx_cont.patch b/0004-mac80211-disable-BHs-preemption-in-ieee80211_tx_cont.patch deleted file mode 100644 index de3385e8d517..000000000000 --- a/0004-mac80211-disable-BHs-preemption-in-ieee80211_tx_cont.patch +++ /dev/null @@ -1,46 +0,0 @@ -From 32a72bee7a275f47c235fdb36249703c892ce8d8 Mon Sep 17 00:00:00 2001 -Message-Id: <32a72bee7a275f47c235fdb36249703c892ce8d8.1531335939.git.jan.steffens@gmail.com> -In-Reply-To: <a2d2476ffec7d988b1a5396586869570e0d6f9d8.1531335939.git.jan.steffens@gmail.com> -References: <a2d2476ffec7d988b1a5396586869570e0d6f9d8.1531335939.git.jan.steffens@gmail.com> -From: Denis Kenzior <denkenz@gmail.com> -Date: Tue, 19 Jun 2018 10:39:50 -0500 -Subject: [PATCH 4/4] mac80211: disable BHs/preemption in - ieee80211_tx_control_port() - -On pre-emption enabled kernels the following print was being seen due to -missing local_bh_disable/local_bh_enable calls. mac80211 assumes that -pre-emption is disabled in the data path. - - BUG: using smp_processor_id() in preemptible [00000000] code: iwd/517 - caller is __ieee80211_subif_start_xmit+0x144/0x210 [mac80211] - [...] - Call Trace: - dump_stack+0x5c/0x80 - check_preemption_disabled.cold.0+0x46/0x51 - __ieee80211_subif_start_xmit+0x144/0x210 [mac80211] - -Fixes: 911806491425 ("mac80211: Add support for tx_control_port") -Signed-off-by: Denis Kenzior <denkenz@gmail.com> -[commit message rewrite, fixes tag] -Signed-off-by: Johannes Berg <johannes.berg@intel.com> ---- - net/mac80211/tx.c | 2 ++ - 1 file changed, 2 insertions(+) - -diff --git a/net/mac80211/tx.c b/net/mac80211/tx.c -index 05a265cd573d..7404a5114597 100644 ---- a/net/mac80211/tx.c -+++ b/net/mac80211/tx.c -@@ -4800,7 +4800,9 @@ int ieee80211_tx_control_port(struct wiphy *wiphy, struct net_device *dev, - skb_reset_network_header(skb); - skb_reset_mac_header(skb); - -+ local_bh_disable(); - __ieee80211_subif_start_xmit(skb, skb->dev, flags); -+ local_bh_enable(); - - return 0; - } --- -2.18.0 - @@ -1,29 +1,25 @@ # $Id$ +# Maintainer: Jan Alexander Steffens (heftig) <jan.steffens@gmail.com> # Maintainer: Tobias Powalowski <tpowa@archlinux.org> # Maintainer: Thomas Baechler <thomas@archlinux.org> # Maintainer: Tony Lambiris <tony@critialstack.com> -#pkgbase=linux # Build stock -ARCH kernel -pkgbase=linux-macbook # Build kernel with a different name -_srcname=linux-4.17 -pkgver=4.17.10 +#pkgbase=linux # Build stock -arch kernel +pkgbase=linux-macbook # Build kernel with a different name +pkgver=4.17.11 pkgrel=1 arch=('x86_64') url="https://www.kernel.org/" license=('GPL2') -makedepends=('xmlto' 'kmod' 'inetutils' 'bc' 'libelf') +makedepends=('xmlto' 'kmod' 'inetutils' 'bc' 'libelf' 'git') options=('!strip') +_srcname=archlinux-linux source=( - https://www.kernel.org/pub/linux/kernel/v4.x/${_srcname}.tar.{xz,sign} - https://www.kernel.org/pub/linux/kernel/v4.x/patch-${pkgver}.{xz,sign} + "$_srcname::git+https://github.com/archlinux/linux?signed#tag=v$pkgver-arch${pkgrel%%.*}" config # the main kernel config file 60-linux.hook # pacman hook for depmod 90-linux.hook # pacman hook for initramfs regeneration linux.preset # standard config files for mkinitcpio ramdisk - 0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch - 0002-Revert-drm-i915-edp-Allow-alternate-fixed-mode-for-e.patch - 0003-ACPI-watchdog-Prefer-iTCO_wdt-always-when-WDAT-table.patch - 0004-mac80211-disable-BHs-preemption-in-ieee80211_tx_cont.patch macbook-wakeup.service # service file for suspend/resume events RFC-PCI-Workaround-to-enable-poweroff-on-Mac-Pro-11.patch RFC-v2-PCI-Workaround-to-enable-poweroff-on-Mac-Pro-11.patch @@ -31,85 +27,36 @@ source=( validpgpkeys=( 'ABAF11C65A2970B130ABE3C479BE3E4300411886' # Linus Torvalds '647F28654894E3BD457199BE38DBBDC86092693E' # Greg Kroah-Hartman + '8218F88849AAC522E94CF470A5E9288C4FA415FA' # Jan Alexander Steffens (heftig) ) -sha256sums=('9faa1dd896eaea961dc6e886697c0b3301277102e5bc976b2758f9a62d3ccd13' - 'SKIP' - '41ad005296c7a1b5245a87881f666b3f4d7aa05a6b9409454b2e473d473c4cee' - 'SKIP' - 'f8e890eac9779a89009c1e2339f757e9781864df09805211fad005146fe2578b' +sha256sums=('SKIP' + 'aa7b6756f193f3b3a3fc4947e7a77b09e249df2e345e6495292055d757ba8be6' 'ae2e95db94ef7176207c690224169594d49445e04249d2499e9d2fbc117a0b21' '75f99f5239e03238f88d1a834c50043ec32b1dc568f2cc291b07d04718483919' 'ad6344badc91ad0630caacde83f7f9b97276f80d26a20619a87952be65492c65' - '92f848d0e21fbb2400e50d1c1021514893423641e5450896d7b1d88aa880b2b9' - 'fc3c50ae6bd905608e0533a883ab569fcf54038fb9d6569b391107d9fd00abbc' - 'bc50c605bd0e1fa7437c21ddef728b83b6de3322b988e14713032993dfa1fc69' - '66284102261c4ed53db050e9045c8672ba0e5171884b46e58f6cd417774d8578' 'c5a714823c3418692bc5c212dd5d094a0e2ae6147d6726822911f1c26e3a1d1b' '7c99aaeaea7837f83a3ad215cf07277934ccf39720acee7f1c371dc86bdf89fc' '09189eb269a9fd16898cf90a477df23306236fb897791e8d04e5a75d5007bbff') _kernelname=${pkgbase#linux} -: ${_kernelname:=-ARCH} +: ${_kernelname:=-arch} prepare() { cd ${_srcname} - - # add upstream patch - patch -p1 -i ../patch-${pkgver} - - # add latest fixes from stable queue, if needed - # http://git.kernel.org/?p=linux/kernel/git/stable/stable-queue.git + scripts/setlocalversion --save-scmversion msg "patch -Np1 -i ../RFC-PCI-Workaround-to-enable-poweroff-on-Mac-Pro-11.patch" patch -Np1 -i ../RFC-PCI-Workaround-to-enable-poweroff-on-Mac-Pro-11.patch - # https://patchwork.kernel.org/patch/9288825/ msg "patch -Np1 -i ../RFC-v2-PCI-Workaround-to-enable-poweroff-on-Mac-Pro-11.patch" patch -Np1 -i ../RFC-v2-PCI-Workaround-to-enable-poweroff-on-Mac-Pro-11.patch - # disable USER_NS for non-root users by default - patch -Np1 -i ../0001-add-sysctl-to-disallow-unprivileged-CLONE_NEWUSER-by.patch - - # https://bugs.archlinux.org/task/56711 - patch -Np1 -i ../0002-Revert-drm-i915-edp-Allow-alternate-fixed-mode-for-e.patch - - # https://bugs.archlinux.org/task/56780 - patch -Np1 -i ../0003-ACPI-watchdog-Prefer-iTCO_wdt-always-when-WDAT-table.patch - - # Fix iwd provoking a BUG - patch -Np1 -i ../0004-mac80211-disable-BHs-preemption-in-ieee80211_tx_cont.patch - - cat ../config - >.config <<END -CONFIG_LOCALVERSION="${_kernelname}" -CONFIG_LOCALVERSION_AUTO=n -END - - # set extraversion to pkgrel and empty localversion - sed -e "/^EXTRAVERSION =/s/=.*/= -${pkgrel}/" \ - -e "/^EXTRAVERSION =/aLOCALVERSION =" \ - -i Makefile - - # don't run depmod on 'make install'. We'll do this ourselves in packaging - sed -i '2iexit 0' scripts/depmod.sh - - # get kernel version - make prepare - - # load configuration - # Configure the kernel. Replace the line below with one of your choice. - #make menuconfig # CLI menu for configuration - #make nconfig # new CLI menu for configuration - #make xconfig # X-based configuration - #make oldconfig # using old config from previous kernel version - # ... or manually edit .config - - # rewrite configuration - yes "" | make config >/dev/null + cp ../config .config + make olddefconfig } build() { cd ${_srcname} - make bzImage modules } @@ -129,7 +76,7 @@ _package() { _basekernel=${_basekernel%.*} mkdir -p "${pkgdir}"/{boot,usr/lib/modules} - make INSTALL_MOD_PATH="${pkgdir}/usr" modules_install + make INSTALL_MOD_PATH="${pkgdir}/usr" DEPMOD=/doesnt/exist modules_install cp arch/x86/boot/bzImage "${pkgdir}/boot/vmlinuz-${pkgbase}" # make room for external modules @@ -1,6 +1,6 @@ # # Automatically generated file; DO NOT EDIT. -# Linux/x86 4.17.6-1 Kernel Configuration +# Linux/x86 4.17.11-arch1 Kernel Configuration # CONFIG_64BIT=y CONFIG_X86_64=y @@ -53,8 +53,8 @@ CONFIG_THREAD_INFO_IN_TASK=y CONFIG_INIT_ENV_ARG_LIMIT=32 CONFIG_CROSS_COMPILE="" # CONFIG_COMPILE_TEST is not set -CONFIG_LOCALVERSION="-ARCH" -# CONFIG_LOCALVERSION_AUTO is not set +CONFIG_LOCALVERSION="" +CONFIG_LOCALVERSION_AUTO=y CONFIG_HAVE_KERNEL_GZIP=y CONFIG_HAVE_KERNEL_BZIP2=y CONFIG_HAVE_KERNEL_LZMA=y @@ -9328,7 +9328,6 @@ CONFIG_CRYPTO_DES3_EDE_X86_64=m CONFIG_CRYPTO_FCRYPT=m CONFIG_CRYPTO_KHAZAD=m CONFIG_CRYPTO_SALSA20=m -CONFIG_CRYPTO_SALSA20_X86_64=m CONFIG_CRYPTO_CHACHA20=m CONFIG_CRYPTO_CHACHA20_X86_64=m CONFIG_CRYPTO_SEED=m diff --git a/intel-pstate-backport.patch b/intel-pstate-backport.patch deleted file mode 100644 index cf1427867261..000000000000 --- a/intel-pstate-backport.patch +++ /dev/null @@ -1,1117 +0,0 @@ ---- drivers/cpufreq/intel_pstate.c.orig 2017-02-19 17:34:00.000000000 -0500 -+++ drivers/cpufreq/intel_pstate.c 2017-03-23 23:47:19.095511820 -0400 -@@ -19,7 +19,7 @@ - #include <linux/hrtimer.h> - #include <linux/tick.h> - #include <linux/slab.h> --#include <linux/sched.h> -+#include <linux/sched/cpufreq.h> - #include <linux/list.h> - #include <linux/cpu.h> - #include <linux/cpufreq.h> -@@ -39,11 +39,6 @@ - - #define INTEL_CPUFREQ_TRANSITION_LATENCY 20000 - --#define ATOM_RATIOS 0x66a --#define ATOM_VIDS 0x66b --#define ATOM_TURBO_RATIOS 0x66c --#define ATOM_TURBO_VIDS 0x66d -- - #ifdef CONFIG_ACPI - #include <acpi/processor.h> - #include <acpi/cppc_acpi.h> -@@ -89,6 +84,11 @@ - return div64_u64(x << EXT_FRAC_BITS, y); - } - -+static inline int32_t percent_ext_fp(int percent) -+{ -+ return div_ext_fp(percent, 100); -+} -+ - /** - * struct sample - Store performance sample - * @core_avg_perf: Ratio of APERF/MPERF which is the actual average -@@ -358,42 +358,24 @@ - static int hwp_active __read_mostly; - static bool per_cpu_limits __read_mostly; - -+static bool driver_registered __read_mostly; -+ - #ifdef CONFIG_ACPI - static bool acpi_ppc; - #endif - --static struct perf_limits performance_limits = { -- .no_turbo = 0, -- .turbo_disabled = 0, -- .max_perf_pct = 100, -- .max_perf = int_ext_tofp(1), -- .min_perf_pct = 100, -- .min_perf = int_ext_tofp(1), -- .max_policy_pct = 100, -- .max_sysfs_pct = 100, -- .min_policy_pct = 0, -- .min_sysfs_pct = 0, --}; -- --static struct perf_limits powersave_limits = { -- .no_turbo = 0, -- .turbo_disabled = 0, -- .max_perf_pct = 100, -- .max_perf = int_ext_tofp(1), -- .min_perf_pct = 0, -- .min_perf = 0, -- .max_policy_pct = 100, -- .max_sysfs_pct = 100, -- .min_policy_pct = 0, -- .min_sysfs_pct = 0, --}; -+static struct perf_limits global; - --#ifdef CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE --static struct perf_limits *limits = &performance_limits; --#else --static struct perf_limits *limits = &powersave_limits; --#endif -+static void intel_pstate_init_limits(struct perf_limits *limits) -+{ -+ memset(limits, 0, sizeof(*limits)); -+ limits->max_perf_pct = 100; -+ limits->max_perf = int_ext_tofp(1); -+ limits->max_policy_pct = 100; -+ limits->max_sysfs_pct = 100; -+} - -+static DEFINE_MUTEX(intel_pstate_driver_lock); - static DEFINE_MUTEX(intel_pstate_limits_lock); - - #ifdef CONFIG_ACPI -@@ -515,7 +497,7 @@ - * correct max turbo frequency based on the turbo state. - * Also need to convert to MHz as _PSS freq is in MHz. - */ -- if (!limits->turbo_disabled) -+ if (!global.turbo_disabled) - cpu->acpi_perf_data.states[0].core_frequency = - policy->cpuinfo.max_freq / 1000; - cpu->valid_pss_table = true; -@@ -538,7 +520,6 @@ - - acpi_processor_unregister_performance(policy->cpu); - } -- - #else - static inline void intel_pstate_init_acpi_perf_limits(struct cpufreq_policy *policy) - { -@@ -635,7 +616,7 @@ - - cpu = all_cpu_data[0]; - rdmsrl(MSR_IA32_MISC_ENABLE, misc_en); -- limits->turbo_disabled = -+ global.turbo_disabled = - (misc_en & MSR_IA32_MISC_ENABLE_TURBO_DISABLE || - cpu->pstate.max_pstate == cpu->pstate.turbo_pstate); - } -@@ -859,12 +840,11 @@ - - static void intel_pstate_hwp_set(struct cpufreq_policy *policy) - { -- int min, hw_min, max, hw_max, cpu, range, adj_range; -- struct perf_limits *perf_limits = limits; -+ int min, hw_min, max, hw_max, cpu; -+ struct perf_limits *perf_limits = &global; - u64 value, cap; - - for_each_cpu(cpu, policy->cpus) { -- int max_perf_pct, min_perf_pct; - struct cpudata *cpu_data = all_cpu_data[cpu]; - s16 epp; - -@@ -873,26 +853,22 @@ - - rdmsrl_on_cpu(cpu, MSR_HWP_CAPABILITIES, &cap); - hw_min = HWP_LOWEST_PERF(cap); -- hw_max = HWP_HIGHEST_PERF(cap); -- range = hw_max - hw_min; -+ if (global.no_turbo) -+ hw_max = HWP_GUARANTEED_PERF(cap); -+ else -+ hw_max = HWP_HIGHEST_PERF(cap); - -- max_perf_pct = perf_limits->max_perf_pct; -- min_perf_pct = perf_limits->min_perf_pct; -+ max = fp_ext_toint(hw_max * perf_limits->max_perf); -+ if (cpu_data->policy == CPUFREQ_POLICY_PERFORMANCE) -+ min = max; -+ else -+ min = fp_ext_toint(hw_max * perf_limits->min_perf); - - rdmsrl_on_cpu(cpu, MSR_HWP_REQUEST, &value); -- adj_range = min_perf_pct * range / 100; -- min = hw_min + adj_range; -+ - value &= ~HWP_MIN_PERF(~0L); - value |= HWP_MIN_PERF(min); - -- adj_range = max_perf_pct * range / 100; -- max = hw_min + adj_range; -- if (limits->no_turbo) { -- hw_max = HWP_GUARANTEED_PERF(cap); -- if (hw_max < max) -- max = hw_max; -- } -- - value &= ~HWP_MAX_PERF(~0L); - value |= HWP_MAX_PERF(max); - -@@ -996,6 +972,7 @@ - static int pid_param_set(void *data, u64 val) - { - *(u32 *)data = val; -+ pid_params.sample_rate_ns = pid_params.sample_rate_ms * NSEC_PER_MSEC; - intel_pstate_reset_all_pid(); - return 0; - } -@@ -1007,35 +984,57 @@ - } - DEFINE_SIMPLE_ATTRIBUTE(fops_pid_param, pid_param_get, pid_param_set, "%llu\n"); - -+static struct dentry *debugfs_parent; -+ - struct pid_param { - char *name; - void *value; -+ struct dentry *dentry; - }; - - static struct pid_param pid_files[] = { -- {"sample_rate_ms", &pid_params.sample_rate_ms}, -- {"d_gain_pct", &pid_params.d_gain_pct}, -- {"i_gain_pct", &pid_params.i_gain_pct}, -- {"deadband", &pid_params.deadband}, -- {"setpoint", &pid_params.setpoint}, -- {"p_gain_pct", &pid_params.p_gain_pct}, -- {NULL, NULL} -+ {"sample_rate_ms", &pid_params.sample_rate_ms, }, -+ {"d_gain_pct", &pid_params.d_gain_pct, }, -+ {"i_gain_pct", &pid_params.i_gain_pct, }, -+ {"deadband", &pid_params.deadband, }, -+ {"setpoint", &pid_params.setpoint, }, -+ {"p_gain_pct", &pid_params.p_gain_pct, }, -+ {NULL, NULL, } - }; - --static void __init intel_pstate_debug_expose_params(void) -+static void intel_pstate_debug_expose_params(void) - { -- struct dentry *debugfs_parent; -- int i = 0; -+ int i; - - debugfs_parent = debugfs_create_dir("pstate_snb", NULL); - if (IS_ERR_OR_NULL(debugfs_parent)) - return; -- while (pid_files[i].name) { -- debugfs_create_file(pid_files[i].name, 0660, -- debugfs_parent, pid_files[i].value, -- &fops_pid_param); -- i++; -+ -+ for (i = 0; pid_files[i].name; i++) { -+ struct dentry *dentry; -+ -+ dentry = debugfs_create_file(pid_files[i].name, 0660, -+ debugfs_parent, pid_files[i].value, -+ &fops_pid_param); -+ if (!IS_ERR(dentry)) -+ pid_files[i].dentry = dentry; -+ } -+} -+ -+static void intel_pstate_debug_hide_params(void) -+{ -+ int i; -+ -+ if (IS_ERR_OR_NULL(debugfs_parent)) -+ return; -+ -+ for (i = 0; pid_files[i].name; i++) { -+ debugfs_remove(pid_files[i].dentry); -+ pid_files[i].dentry = NULL; - } -+ -+ debugfs_remove(debugfs_parent); -+ debugfs_parent = NULL; - } - - /************************** debugfs end ************************/ -@@ -1045,9 +1044,37 @@ - static ssize_t show_##file_name \ - (struct kobject *kobj, struct attribute *attr, char *buf) \ - { \ -- return sprintf(buf, "%u\n", limits->object); \ -+ return sprintf(buf, "%u\n", global.object); \ - } - -+static ssize_t intel_pstate_show_status(char *buf); -+static int intel_pstate_update_status(const char *buf, size_t size); -+ -+static ssize_t show_status(struct kobject *kobj, -+ struct attribute *attr, char *buf) -+{ -+ ssize_t ret; -+ -+ mutex_lock(&intel_pstate_driver_lock); -+ ret = intel_pstate_show_status(buf); -+ mutex_unlock(&intel_pstate_driver_lock); -+ -+ return ret; -+} -+ -+static ssize_t store_status(struct kobject *a, struct attribute *b, -+ const char *buf, size_t count) -+{ -+ char *p = memchr(buf, '\n', count); -+ int ret; -+ -+ mutex_lock(&intel_pstate_driver_lock); -+ ret = intel_pstate_update_status(buf, p ? p - buf : count); -+ mutex_unlock(&intel_pstate_driver_lock); -+ -+ return ret < 0 ? ret : count; -+} -+ - static ssize_t show_turbo_pct(struct kobject *kobj, - struct attribute *attr, char *buf) - { -@@ -1055,12 +1082,22 @@ - int total, no_turbo, turbo_pct; - uint32_t turbo_fp; - -+ mutex_lock(&intel_pstate_driver_lock); -+ -+ if (!driver_registered) { -+ mutex_unlock(&intel_pstate_driver_lock); -+ return -EAGAIN; -+ } -+ - cpu = all_cpu_data[0]; - - total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; - no_turbo = cpu->pstate.max_pstate - cpu->pstate.min_pstate + 1; - turbo_fp = div_fp(no_turbo, total); - turbo_pct = 100 - fp_toint(mul_fp(turbo_fp, int_tofp(100))); -+ -+ mutex_unlock(&intel_pstate_driver_lock); -+ - return sprintf(buf, "%u\n", turbo_pct); - } - -@@ -1070,8 +1107,18 @@ - struct cpudata *cpu; - int total; - -+ mutex_lock(&intel_pstate_driver_lock); -+ -+ if (!driver_registered) { -+ mutex_unlock(&intel_pstate_driver_lock); -+ return -EAGAIN; -+ } -+ - cpu = all_cpu_data[0]; - total = cpu->pstate.turbo_pstate - cpu->pstate.min_pstate + 1; -+ -+ mutex_unlock(&intel_pstate_driver_lock); -+ - return sprintf(buf, "%u\n", total); - } - -@@ -1080,11 +1127,20 @@ - { - ssize_t ret; - -+ mutex_lock(&intel_pstate_driver_lock); -+ -+ if (!driver_registered) { -+ mutex_unlock(&intel_pstate_driver_lock); -+ return -EAGAIN; -+ } -+ - update_turbo_state(); -- if (limits->turbo_disabled) -- ret = sprintf(buf, "%u\n", limits->turbo_disabled); -+ if (global.turbo_disabled) -+ ret = sprintf(buf, "%u\n", global.turbo_disabled); - else -- ret = sprintf(buf, "%u\n", limits->no_turbo); -+ ret = sprintf(buf, "%u\n", global.no_turbo); -+ -+ mutex_unlock(&intel_pstate_driver_lock); - - return ret; - } -@@ -1099,21 +1155,31 @@ - if (ret != 1) - return -EINVAL; - -+ mutex_lock(&intel_pstate_driver_lock); -+ -+ if (!driver_registered) { -+ mutex_unlock(&intel_pstate_driver_lock); -+ return -EAGAIN; -+ } -+ - mutex_lock(&intel_pstate_limits_lock); - - update_turbo_state(); -- if (limits->turbo_disabled) { -+ if (global.turbo_disabled) { - pr_warn("Turbo disabled by BIOS or unavailable on processor\n"); - mutex_unlock(&intel_pstate_limits_lock); -+ mutex_unlock(&intel_pstate_driver_lock); - return -EPERM; - } - -- limits->no_turbo = clamp_t(int, input, 0, 1); -+ global.no_turbo = clamp_t(int, input, 0, 1); - - mutex_unlock(&intel_pstate_limits_lock); - - intel_pstate_update_policies(); - -+ mutex_unlock(&intel_pstate_driver_lock); -+ - return count; - } - -@@ -1127,21 +1193,27 @@ - if (ret != 1) - return -EINVAL; - -+ mutex_lock(&intel_pstate_driver_lock); -+ -+ if (!driver_registered) { -+ mutex_unlock(&intel_pstate_driver_lock); -+ return -EAGAIN; -+ } -+ - mutex_lock(&intel_pstate_limits_lock); - -- limits->max_sysfs_pct = clamp_t(int, input, 0 , 100); -- limits->max_perf_pct = min(limits->max_policy_pct, -- limits->max_sysfs_pct); -- limits->max_perf_pct = max(limits->min_policy_pct, -- limits->max_perf_pct); -- limits->max_perf_pct = max(limits->min_perf_pct, -- limits->max_perf_pct); -- limits->max_perf = div_ext_fp(limits->max_perf_pct, 100); -+ global.max_sysfs_pct = clamp_t(int, input, 0 , 100); -+ global.max_perf_pct = min(global.max_policy_pct, global.max_sysfs_pct); -+ global.max_perf_pct = max(global.min_policy_pct, global.max_perf_pct); -+ global.max_perf_pct = max(global.min_perf_pct, global.max_perf_pct); -+ global.max_perf = percent_ext_fp(global.max_perf_pct); - - mutex_unlock(&intel_pstate_limits_lock); - - intel_pstate_update_policies(); - -+ mutex_unlock(&intel_pstate_driver_lock); -+ - return count; - } - -@@ -1155,27 +1227,34 @@ - if (ret != 1) - return -EINVAL; - -+ mutex_lock(&intel_pstate_driver_lock); -+ -+ if (!driver_registered) { -+ mutex_unlock(&intel_pstate_driver_lock); -+ return -EAGAIN; -+ } -+ - mutex_lock(&intel_pstate_limits_lock); - -- limits->min_sysfs_pct = clamp_t(int, input, 0 , 100); -- limits->min_perf_pct = max(limits->min_policy_pct, -- limits->min_sysfs_pct); -- limits->min_perf_pct = min(limits->max_policy_pct, -- limits->min_perf_pct); -- limits->min_perf_pct = min(limits->max_perf_pct, -- limits->min_perf_pct); -- limits->min_perf = div_ext_fp(limits->min_perf_pct, 100); -+ global.min_sysfs_pct = clamp_t(int, input, 0 , 100); -+ global.min_perf_pct = max(global.min_policy_pct, global.min_sysfs_pct); -+ global.min_perf_pct = min(global.max_policy_pct, global.min_perf_pct); -+ global.min_perf_pct = min(global.max_perf_pct, global.min_perf_pct); -+ global.min_perf = percent_ext_fp(global.min_perf_pct); - - mutex_unlock(&intel_pstate_limits_lock); - - intel_pstate_update_policies(); - -+ mutex_unlock(&intel_pstate_driver_lock); -+ - return count; - } - - show_one(max_perf_pct, max_perf_pct); - show_one(min_perf_pct, min_perf_pct); - -+define_one_global_rw(status); - define_one_global_rw(no_turbo); - define_one_global_rw(max_perf_pct); - define_one_global_rw(min_perf_pct); -@@ -1183,6 +1262,7 @@ - define_one_global_ro(num_pstates); - - static struct attribute *intel_pstate_attributes[] = { -+ &status.attr, - &no_turbo.attr, - &turbo_pct.attr, - &num_pstates.attr, -@@ -1258,7 +1338,7 @@ - { - u64 value; - -- rdmsrl(ATOM_RATIOS, value); -+ rdmsrl(MSR_ATOM_CORE_RATIOS, value); - return (value >> 8) & 0x7F; - } - -@@ -1266,7 +1346,7 @@ - { - u64 value; - -- rdmsrl(ATOM_RATIOS, value); -+ rdmsrl(MSR_ATOM_CORE_RATIOS, value); - return (value >> 16) & 0x7F; - } - -@@ -1274,7 +1354,7 @@ - { - u64 value; - -- rdmsrl(ATOM_TURBO_RATIOS, value); -+ rdmsrl(MSR_ATOM_CORE_TURBO_RATIOS, value); - return value & 0x7F; - } - -@@ -1285,7 +1365,7 @@ - u32 vid; - - val = (u64)pstate << 8; -- if (limits->no_turbo && !limits->turbo_disabled) -+ if (global.no_turbo && !global.turbo_disabled) - val |= (u64)1 << 32; - - vid_fp = cpudata->vid.min + mul_fp( -@@ -1336,7 +1416,7 @@ - { - u64 value; - -- rdmsrl(ATOM_VIDS, value); -+ rdmsrl(MSR_ATOM_CORE_VIDS, value); - cpudata->vid.min = int_tofp((value >> 8) & 0x7f); - cpudata->vid.max = int_tofp((value >> 16) & 0x7f); - cpudata->vid.ratio = div_fp( -@@ -1344,7 +1424,7 @@ - int_tofp(cpudata->pstate.max_pstate - - cpudata->pstate.min_pstate)); - -- rdmsrl(ATOM_TURBO_VIDS, value); -+ rdmsrl(MSR_ATOM_CORE_TURBO_VIDS, value); - cpudata->vid.turbo = value & 0x7f; - } - -@@ -1364,48 +1444,71 @@ - return (value >> 8) & 0xFF; - } - -+static int core_get_tdp_ratio(u64 plat_info) -+{ -+ /* Check how many TDP levels present */ -+ if (plat_info & 0x600000000) { -+ u64 tdp_ctrl; -+ u64 tdp_ratio; -+ int tdp_msr; -+ int err; -+ -+ /* Get the TDP level (0, 1, 2) to get ratios */ -+ err = rdmsrl_safe(MSR_CONFIG_TDP_CONTROL, &tdp_ctrl); -+ if (err) -+ return err; -+ -+ /* TDP MSR are continuous starting at 0x648 */ -+ tdp_msr = MSR_CONFIG_TDP_NOMINAL + (tdp_ctrl & 0x03); -+ err = rdmsrl_safe(tdp_msr, &tdp_ratio); -+ if (err) -+ return err; -+ -+ /* For level 1 and 2, bits[23:16] contain the ratio */ -+ if (tdp_ctrl & 0x03) -+ tdp_ratio >>= 16; -+ -+ tdp_ratio &= 0xff; /* ratios are only 8 bits long */ -+ pr_debug("tdp_ratio %x\n", (int)tdp_ratio); -+ -+ return (int)tdp_ratio; -+ } -+ -+ return -ENXIO; -+} -+ - static int core_get_max_pstate(void) - { - u64 tar; - u64 plat_info; - int max_pstate; -+ int tdp_ratio; - int err; - - rdmsrl(MSR_PLATFORM_INFO, plat_info); - max_pstate = (plat_info >> 8) & 0xFF; - -+ tdp_ratio = core_get_tdp_ratio(plat_info); -+ if (tdp_ratio <= 0) -+ return max_pstate; -+ -+ if (hwp_active) { -+ /* Turbo activation ratio is not used on HWP platforms */ -+ return tdp_ratio; -+ } -+ - err = rdmsrl_safe(MSR_TURBO_ACTIVATION_RATIO, &tar); - if (!err) { -+ int tar_levels; -+ - /* Do some sanity checking for safety */ -- if (plat_info & 0x600000000) { -- u64 tdp_ctrl; -- u64 tdp_ratio; -- int tdp_msr; -- -- err = rdmsrl_safe(MSR_CONFIG_TDP_CONTROL, &tdp_ctrl); -- if (err) -- goto skip_tar; -- -- tdp_msr = MSR_CONFIG_TDP_NOMINAL + (tdp_ctrl & 0x3); -- err = rdmsrl_safe(tdp_msr, &tdp_ratio); -- if (err) -- goto skip_tar; -- -- /* For level 1 and 2, bits[23:16] contain the ratio */ -- if (tdp_ctrl) -- tdp_ratio >>= 16; -- -- tdp_ratio &= 0xff; /* ratios are only 8 bits long */ -- if (tdp_ratio - 1 == tar) { -- max_pstate = tar; -- pr_debug("max_pstate=TAC %x\n", max_pstate); -- } else { -- goto skip_tar; -- } -+ tar_levels = tar & 0xff; -+ if (tdp_ratio - 1 == tar_levels) { -+ max_pstate = tar_levels; -+ pr_debug("max_pstate=TAC %x\n", max_pstate); - } - } - --skip_tar: - return max_pstate; - } - -@@ -1432,7 +1535,7 @@ - u64 val; - - val = (u64)pstate << 8; -- if (limits->no_turbo && !limits->turbo_disabled) -+ if (global.no_turbo && !global.turbo_disabled) - val |= (u64)1 << 32; - - return val; -@@ -1558,9 +1661,9 @@ - int max_perf = cpu->pstate.turbo_pstate; - int max_perf_adj; - int min_perf; -- struct perf_limits *perf_limits = limits; -+ struct perf_limits *perf_limits = &global; - -- if (limits->no_turbo || limits->turbo_disabled) -+ if (global.no_turbo || global.turbo_disabled) - max_perf = cpu->pstate.max_pstate; - - if (per_cpu_limits) -@@ -1695,7 +1798,7 @@ - - sample->busy_scaled = busy_frac * 100; - -- target = limits->no_turbo || limits->turbo_disabled ? -+ target = global.no_turbo || global.turbo_disabled ? - cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; - target += target >> 2; - target = mul_fp(target, busy_frac); -@@ -1759,13 +1862,11 @@ - - intel_pstate_get_min_max(cpu, &min_perf, &max_perf); - pstate = clamp_t(int, pstate, min_perf, max_perf); -- trace_cpu_frequency(pstate * cpu->pstate.scaling, cpu->cpu); - return pstate; - } - - static void intel_pstate_update_pstate(struct cpudata *cpu, int pstate) - { -- pstate = intel_pstate_prepare_request(cpu, pstate); - if (pstate == cpu->pstate.current_pstate) - return; - -@@ -1785,6 +1886,8 @@ - - update_turbo_state(); - -+ target_pstate = intel_pstate_prepare_request(cpu, target_pstate); -+ trace_cpu_frequency(target_pstate * cpu->pstate.scaling, cpu->cpu); - intel_pstate_update_pstate(cpu, target_pstate); - - sample = &cpu->sample; -@@ -1952,53 +2055,37 @@ - synchronize_sched(); - } - --static void intel_pstate_set_performance_limits(struct perf_limits *limits) --{ -- limits->no_turbo = 0; -- limits->turbo_disabled = 0; -- limits->max_perf_pct = 100; -- limits->max_perf = int_ext_tofp(1); -- limits->min_perf_pct = 100; -- limits->min_perf = int_ext_tofp(1); -- limits->max_policy_pct = 100; -- limits->max_sysfs_pct = 100; -- limits->min_policy_pct = 0; -- limits->min_sysfs_pct = 0; --} -- - static void intel_pstate_update_perf_limits(struct cpufreq_policy *policy, - struct perf_limits *limits) - { -+ int32_t max_policy_perf, min_policy_perf; - -- limits->max_policy_pct = DIV_ROUND_UP(policy->max * 100, -- policy->cpuinfo.max_freq); -- limits->max_policy_pct = clamp_t(int, limits->max_policy_pct, 0, 100); -+ max_policy_perf = div_ext_fp(policy->max, policy->cpuinfo.max_freq); -+ max_policy_perf = clamp_t(int32_t, max_policy_perf, 0, int_ext_tofp(1)); - if (policy->max == policy->min) { -- limits->min_policy_pct = limits->max_policy_pct; -+ min_policy_perf = max_policy_perf; - } else { -- limits->min_policy_pct = DIV_ROUND_UP(policy->min * 100, -- policy->cpuinfo.max_freq); -- limits->min_policy_pct = clamp_t(int, limits->min_policy_pct, -- 0, 100); -- } -- -- /* Normalize user input to [min_policy_pct, max_policy_pct] */ -- limits->min_perf_pct = max(limits->min_policy_pct, -- limits->min_sysfs_pct); -- limits->min_perf_pct = min(limits->max_policy_pct, -- limits->min_perf_pct); -- limits->max_perf_pct = min(limits->max_policy_pct, -- limits->max_sysfs_pct); -- limits->max_perf_pct = max(limits->min_policy_pct, -- limits->max_perf_pct); -+ min_policy_perf = div_ext_fp(policy->min, -+ policy->cpuinfo.max_freq); -+ min_policy_perf = clamp_t(int32_t, min_policy_perf, -+ 0, max_policy_perf); -+ } -+ -+ /* Normalize user input to [min_perf, max_perf] */ -+ limits->min_perf = max(min_policy_perf, -+ percent_ext_fp(limits->min_sysfs_pct)); -+ limits->min_perf = min(limits->min_perf, max_policy_perf); -+ limits->max_perf = min(max_policy_perf, -+ percent_ext_fp(limits->max_sysfs_pct)); -+ limits->max_perf = max(min_policy_perf, limits->max_perf); - -- /* Make sure min_perf_pct <= max_perf_pct */ -- limits->min_perf_pct = min(limits->max_perf_pct, limits->min_perf_pct); -+ /* Make sure min_perf <= max_perf */ -+ limits->min_perf = min(limits->min_perf, limits->max_perf); - -- limits->min_perf = div_ext_fp(limits->min_perf_pct, 100); -- limits->max_perf = div_ext_fp(limits->max_perf_pct, 100); - limits->max_perf = round_up(limits->max_perf, EXT_FRAC_BITS); - limits->min_perf = round_up(limits->min_perf, EXT_FRAC_BITS); -+ limits->max_perf_pct = fp_ext_toint(limits->max_perf * 100); -+ limits->min_perf_pct = fp_ext_toint(limits->min_perf * 100); - - pr_debug("cpu:%d max_perf_pct:%d min_perf_pct:%d\n", policy->cpu, - limits->max_perf_pct, limits->min_perf_pct); -@@ -2007,7 +2094,7 @@ - static int intel_pstate_set_policy(struct cpufreq_policy *policy) - { - struct cpudata *cpu; -- struct perf_limits *perf_limits = NULL; -+ struct perf_limits *perf_limits = &global; - - if (!policy->cpuinfo.max_freq) - return -ENODEV; -@@ -2030,28 +2117,8 @@ - - mutex_lock(&intel_pstate_limits_lock); - -- if (policy->policy == CPUFREQ_POLICY_PERFORMANCE) { -- if (!perf_limits) { -- limits = &performance_limits; -- perf_limits = limits; -- } -- if (policy->max >= policy->cpuinfo.max_freq && -- !limits->no_turbo) { -- pr_debug("set performance\n"); -- intel_pstate_set_performance_limits(perf_limits); -- goto out; -- } -- } else { -- pr_debug("set powersave\n"); -- if (!perf_limits) { -- limits = &powersave_limits; -- perf_limits = limits; -- } -- -- } -- - intel_pstate_update_perf_limits(policy, perf_limits); -- out: -+ - if (cpu->policy == CPUFREQ_POLICY_PERFORMANCE) { - /* - * NOHZ_FULL CPUs need this as the governor callback may not -@@ -2072,6 +2139,13 @@ - - static int intel_pstate_verify_policy(struct cpufreq_policy *policy) - { -+ struct cpudata *cpu = all_cpu_data[policy->cpu]; -+ -+ update_turbo_state(); -+ policy->cpuinfo.max_freq = global.turbo_disabled || global.no_turbo ? -+ cpu->pstate.max_freq : -+ cpu->pstate.turbo_freq; -+ - cpufreq_verify_within_cpu_limits(policy); - - if (policy->policy != CPUFREQ_POLICY_POWERSAVE && -@@ -2083,9 +2157,9 @@ - unsigned int max_freq, min_freq; - - max_freq = policy->cpuinfo.max_freq * -- limits->max_sysfs_pct / 100; -+ global.max_sysfs_pct / 100; - min_freq = policy->cpuinfo.max_freq * -- limits->min_sysfs_pct / 100; -+ global.min_sysfs_pct / 100; - cpufreq_verify_within_limits(policy, min_freq, max_freq); - } - -@@ -2128,13 +2202,8 @@ - - cpu = all_cpu_data[policy->cpu]; - -- /* -- * We need sane value in the cpu->perf_limits, so inherit from global -- * perf_limits limits, which are seeded with values based on the -- * CONFIG_CPU_FREQ_DEFAULT_GOV_*, during boot up. -- */ - if (per_cpu_limits) -- memcpy(cpu->perf_limits, limits, sizeof(struct perf_limits)); -+ intel_pstate_init_limits(cpu->perf_limits); - - policy->min = cpu->pstate.min_pstate * cpu->pstate.scaling; - policy->max = cpu->pstate.turbo_pstate * cpu->pstate.scaling; -@@ -2142,7 +2211,7 @@ - /* cpuinfo and default policy values */ - policy->cpuinfo.min_freq = cpu->pstate.min_pstate * cpu->pstate.scaling; - update_turbo_state(); -- policy->cpuinfo.max_freq = limits->turbo_disabled ? -+ policy->cpuinfo.max_freq = global.turbo_disabled ? - cpu->pstate.max_pstate : cpu->pstate.turbo_pstate; - policy->cpuinfo.max_freq *= cpu->pstate.scaling; - -@@ -2162,7 +2231,7 @@ - return ret; - - policy->cpuinfo.transition_latency = CPUFREQ_ETERNAL; -- if (limits->min_perf_pct == 100 && limits->max_perf_pct == 100) -+ if (IS_ENABLED(CONFIG_CPU_FREQ_DEFAULT_GOV_PERFORMANCE)) - policy->policy = CPUFREQ_POLICY_PERFORMANCE; - else - policy->policy = CPUFREQ_POLICY_POWERSAVE; -@@ -2186,46 +2255,16 @@ - static int intel_cpufreq_verify_policy(struct cpufreq_policy *policy) - { - struct cpudata *cpu = all_cpu_data[policy->cpu]; -- struct perf_limits *perf_limits = limits; - - update_turbo_state(); -- policy->cpuinfo.max_freq = limits->turbo_disabled ? -+ policy->cpuinfo.max_freq = global.no_turbo || global.turbo_disabled ? - cpu->pstate.max_freq : cpu->pstate.turbo_freq; - - cpufreq_verify_within_cpu_limits(policy); - -- if (per_cpu_limits) -- perf_limits = cpu->perf_limits; -- -- mutex_lock(&intel_pstate_limits_lock); -- -- intel_pstate_update_perf_limits(policy, perf_limits); -- -- mutex_unlock(&intel_pstate_limits_lock); -- - return 0; - } - --static unsigned int intel_cpufreq_turbo_update(struct cpudata *cpu, -- struct cpufreq_policy *policy, -- unsigned int target_freq) --{ -- unsigned int max_freq; -- -- update_turbo_state(); -- -- max_freq = limits->no_turbo || limits->turbo_disabled ? -- cpu->pstate.max_freq : cpu->pstate.turbo_freq; -- policy->cpuinfo.max_freq = max_freq; -- if (policy->max > max_freq) -- policy->max = max_freq; -- -- if (target_freq > max_freq) -- target_freq = max_freq; -- -- return target_freq; --} -- - static int intel_cpufreq_target(struct cpufreq_policy *policy, - unsigned int target_freq, - unsigned int relation) -@@ -2234,8 +2273,10 @@ - struct cpufreq_freqs freqs; - int target_pstate; - -+ update_turbo_state(); -+ - freqs.old = policy->cur; -- freqs.new = intel_cpufreq_turbo_update(cpu, policy, target_freq); -+ freqs.new = target_freq; - - cpufreq_freq_transition_begin(policy, &freqs); - switch (relation) { -@@ -2255,6 +2296,7 @@ - wrmsrl_on_cpu(policy->cpu, MSR_IA32_PERF_CTL, - pstate_funcs.get_val(cpu, target_pstate)); - } -+ freqs.new = target_pstate * cpu->pstate.scaling; - cpufreq_freq_transition_end(policy, &freqs, false); - - return 0; -@@ -2266,10 +2308,12 @@ - struct cpudata *cpu = all_cpu_data[policy->cpu]; - int target_pstate; - -- target_freq = intel_cpufreq_turbo_update(cpu, policy, target_freq); -+ update_turbo_state(); -+ - target_pstate = DIV_ROUND_UP(target_freq, cpu->pstate.scaling); -+ target_pstate = intel_pstate_prepare_request(cpu, target_pstate); - intel_pstate_update_pstate(cpu, target_pstate); -- return target_freq; -+ return target_pstate * cpu->pstate.scaling; - } - - static int intel_cpufreq_cpu_init(struct cpufreq_policy *policy) -@@ -2299,6 +2343,113 @@ - - static struct cpufreq_driver *intel_pstate_driver = &intel_pstate; - -+static void intel_pstate_driver_cleanup(void) -+{ -+ unsigned int cpu; -+ -+ get_online_cpus(); -+ for_each_online_cpu(cpu) { -+ if (all_cpu_data[cpu]) { -+ if (intel_pstate_driver == &intel_pstate) -+ intel_pstate_clear_update_util_hook(cpu); -+ -+ kfree(all_cpu_data[cpu]); -+ all_cpu_data[cpu] = NULL; -+ } -+ } -+ put_online_cpus(); -+} -+ -+static int intel_pstate_register_driver(void) -+{ -+ int ret; -+ -+ intel_pstate_init_limits(&global); -+ -+ ret = cpufreq_register_driver(intel_pstate_driver); -+ if (ret) { -+ intel_pstate_driver_cleanup(); -+ return ret; -+ } -+ -+ mutex_lock(&intel_pstate_limits_lock); -+ driver_registered = true; -+ mutex_unlock(&intel_pstate_limits_lock); -+ -+ if (intel_pstate_driver == &intel_pstate && !hwp_active && -+ pstate_funcs.get_target_pstate != get_target_pstate_use_cpu_load) -+ intel_pstate_debug_expose_params(); -+ -+ return 0; -+} -+ -+static int intel_pstate_unregister_driver(void) -+{ -+ if (hwp_active) -+ return -EBUSY; -+ -+ if (intel_pstate_driver == &intel_pstate && !hwp_active && -+ pstate_funcs.get_target_pstate != get_target_pstate_use_cpu_load) -+ intel_pstate_debug_hide_params(); -+ -+ mutex_lock(&intel_pstate_limits_lock); -+ driver_registered = false; -+ mutex_unlock(&intel_pstate_limits_lock); -+ -+ cpufreq_unregister_driver(intel_pstate_driver); -+ intel_pstate_driver_cleanup(); -+ -+ return 0; -+} -+ -+static ssize_t intel_pstate_show_status(char *buf) -+{ -+ if (!driver_registered) -+ return sprintf(buf, "off\n"); -+ -+ return sprintf(buf, "%s\n", intel_pstate_driver == &intel_pstate ? -+ "active" : "passive"); -+} -+ -+static int intel_pstate_update_status(const char *buf, size_t size) -+{ -+ int ret; -+ -+ if (size == 3 && !strncmp(buf, "off", size)) -+ return driver_registered ? -+ intel_pstate_unregister_driver() : -EINVAL; -+ -+ if (size == 6 && !strncmp(buf, "active", size)) { -+ if (driver_registered) { -+ if (intel_pstate_driver == &intel_pstate) -+ return 0; -+ -+ ret = intel_pstate_unregister_driver(); -+ if (ret) -+ return ret; -+ } -+ -+ intel_pstate_driver = &intel_pstate; -+ return intel_pstate_register_driver(); -+ } -+ -+ if (size == 7 && !strncmp(buf, "passive", size)) { -+ if (driver_registered) { -+ if (intel_pstate_driver != &intel_pstate) -+ return 0; -+ -+ ret = intel_pstate_unregister_driver(); -+ if (ret) -+ return ret; -+ } -+ -+ intel_pstate_driver = &intel_cpufreq; -+ return intel_pstate_register_driver(); -+ } -+ -+ return -EINVAL; -+} -+ - static int no_load __initdata; - static int no_hwp __initdata; - static int hwp_only __initdata; -@@ -2486,9 +2637,9 @@ - - static int __init intel_pstate_init(void) - { -- int cpu, rc = 0; - const struct x86_cpu_id *id; - struct cpu_defaults *cpu_def; -+ int rc = 0; - - if (no_load) - return -ENODEV; -@@ -2520,45 +2671,29 @@ - if (intel_pstate_platform_pwr_mgmt_exists()) - return -ENODEV; - -+ if (!hwp_active && hwp_only) -+ return -ENOTSUPP; -+ - pr_info("Intel P-state driver initializing\n"); - - all_cpu_data = vzalloc(sizeof(void *) * num_possible_cpus()); - if (!all_cpu_data) - return -ENOMEM; - -- if (!hwp_active && hwp_only) -- goto out; -- - intel_pstate_request_control_from_smm(); - -- rc = cpufreq_register_driver(intel_pstate_driver); -- if (rc) -- goto out; -- -- if (intel_pstate_driver == &intel_pstate && !hwp_active && -- pstate_funcs.get_target_pstate != get_target_pstate_use_cpu_load) -- intel_pstate_debug_expose_params(); -- - intel_pstate_sysfs_expose_params(); - -+ mutex_lock(&intel_pstate_driver_lock); -+ rc = intel_pstate_register_driver(); -+ mutex_unlock(&intel_pstate_driver_lock); -+ if (rc) -+ return rc; -+ - if (hwp_active) - pr_info("HWP enabled\n"); - -- return rc; --out: -- get_online_cpus(); -- for_each_online_cpu(cpu) { -- if (all_cpu_data[cpu]) { -- if (intel_pstate_driver == &intel_pstate) -- intel_pstate_clear_update_util_hook(cpu); -- -- kfree(all_cpu_data[cpu]); -- } -- } -- -- put_online_cpus(); -- vfree(all_cpu_data); -- return -ENODEV; -+ return 0; - } - device_initcall(intel_pstate_init); - diff --git a/linux.install b/linux.install index c8e5a68d75ba..37ba37494605 100644 --- a/linux.install +++ b/linux.install @@ -1,22 +1,7 @@ -display_requirements () { -cat <<-EOF - - To get suspend working properly you must do the following: - - Enable the macbook-wakeup service for suspend/resume on LID events: - systemctl enable --now macbook-wakeup.service - - Optionally, include the kernel boot option processor.ignore_ppc=1 - to allow frequency changing on battery power. - -EOF -} - post_upgrade() { if findmnt --fstab -uno SOURCE /boot &>/dev/null && ! mountpoint -q /boot; then echo "WARNING: /boot appears to be a separate partition but is not mounted." fi - display_requirements } post_remove() { |