/* * rfkill-regulator.c - Regulator consumer driver for rfkill * * Copyright (C) 2009 Guiming Zhuo * Copyright (C) 2011 Antonio Ospite * * Implementation inspired by leds-regulator driver. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License version 2 as * published by the Free Software Foundation. * */ #include #include #include #include #include #include #include struct rfkill_regulator_data { struct rfkill *rf_kill; bool reg_enabled; struct regulator *vcc; }; static int rfkill_regulator_set_block(void *data, bool blocked) { struct rfkill_regulator_data *rfkill_data = data; int ret = 0; pr_debug("%s: blocked: %d\n", __func__, blocked); if (blocked) { if (rfkill_data->reg_enabled) { regulator_disable(rfkill_data->vcc); rfkill_data->reg_enabled = false; } } else { if (!rfkill_data->reg_enabled) { ret = regulator_enable(rfkill_data->vcc); if (!ret) rfkill_data->reg_enabled = true; } } pr_debug("%s: regulator_is_enabled after set_block: %d\n", __func__, regulator_is_enabled(rfkill_data->vcc)); return ret; } static struct rfkill_ops rfkill_regulator_ops = { .set_block = rfkill_regulator_set_block, }; static int rfkill_regulator_probe(struct platform_device *pdev) { struct rfkill_regulator_platform_data *pdata = pdev->dev.platform_data; struct rfkill_regulator_data *rfkill_data; struct regulator *vcc; struct rfkill *rf_kill; int ret = 0; if (pdata == NULL) { dev_err(&pdev->dev, "no platform data\n"); return -ENODEV; } if (pdata->name == NULL || pdata->type == 0) { dev_err(&pdev->dev, "invalid name or type in platform data\n"); return -EINVAL; } vcc = regulator_get_exclusive(&pdev->dev, "vrfkill"); if (IS_ERR(vcc)) { dev_err(&pdev->dev, "Cannot get vcc for %s\n", pdata->name); ret = PTR_ERR(vcc); goto out; } rfkill_data = kzalloc(sizeof(*rfkill_data), GFP_KERNEL); if (rfkill_data == NULL) { ret = -ENOMEM; goto err_data_alloc; } rf_kill = rfkill_alloc(pdata->name, &pdev->dev, pdata->type, &rfkill_regulator_ops, rfkill_data); if (rf_kill == NULL) { ret = -ENOMEM; goto err_rfkill_alloc; } if (regulator_is_enabled(vcc)) { dev_dbg(&pdev->dev, "Regulator already enabled\n"); rfkill_data->reg_enabled = true; } rfkill_data->vcc = vcc; rfkill_data->rf_kill = rf_kill; ret = rfkill_register(rf_kill); if (ret) { dev_err(&pdev->dev, "Cannot register rfkill device\n"); goto err_rfkill_register; } platform_set_drvdata(pdev, rfkill_data); dev_info(&pdev->dev, "%s initialized\n", pdata->name); return 0; err_rfkill_register: rfkill_destroy(rf_kill); err_rfkill_alloc: kfree(rfkill_data); err_data_alloc: regulator_put(vcc); out: return ret; } static int rfkill_regulator_remove(struct platform_device *pdev) { struct rfkill_regulator_data *rfkill_data = platform_get_drvdata(pdev); struct rfkill *rf_kill = rfkill_data->rf_kill; rfkill_unregister(rf_kill); rfkill_destroy(rf_kill); regulator_put(rfkill_data->vcc); kfree(rfkill_data); return 0; } static struct platform_driver rfkill_regulator_driver = { .probe = rfkill_regulator_probe, .remove = rfkill_regulator_remove, .driver = { .name = "rfkill-regulator", }, }; module_platform_driver(rfkill_regulator_driver); MODULE_AUTHOR("Guiming Zhuo "); MODULE_AUTHOR("Antonio Ospite "); MODULE_DESCRIPTION("Regulator consumer driver for rfkill"); MODULE_LICENSE("GPL"); MODULE_ALIAS("platform:rfkill-regulator"); option>space:mode:
authorSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>2017-02-03 14:18:39 -0800
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2017-02-04 00:11:08 +0100
commit6e978b22efa1db9f6e71b24440b5f1d93e968ee3 (patch)
treec666f7a26b860674848949e39a610222b0723f89 /include/net/geneve.h
parent3c223c19aea85d3dda1416c187915f4a30b04b1f (diff)
cpufreq: intel_pstate: Disable energy efficiency optimization
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>
Diffstat (limited to 'include/net/geneve.h')