Skip to content

Commit

Permalink
Merge tag 'platform-drivers-x86-v6.2-4' of git://git.kernel.org/pub/s…
Browse files Browse the repository at this point in the history
…cm/linux/kernel/git/pdx86/platform-drivers-x86

Pull x86 platform driver fixes from Hans de Goede:
 "A set of AMD PMF fixes + a few other small fixes"

* tag 'platform-drivers-x86-v6.2-4' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
  platform/x86: touchscreen_dmi: Add Chuwi Vi8 (CWI501) DMI match
  platform/x86: thinkpad_acpi: Fix thinklight LED brightness returning 255
  platform/x86/amd: pmc: add CONFIG_SERIO dependency
  platform/x86/amd/pmf: Ensure mutexes are initialized before use
  platform/x86/amd/pmf: Fix to update SPS thermals when power supply change
  platform/x86/amd/pmf: Fix to update SPS default pprof thermals
  platform/x86/amd/pmf: update to auto-mode limits only after AMT event
  platform/x86/amd/pmf: Add helper routine to check pprof is balanced
  platform/x86/amd/pmf: Add helper routine to update SPS thermals
  • Loading branch information
torvalds committed Feb 2, 2023
2 parents 9f266cc + eecf2ac commit 870bb76
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 28 deletions.
1 change: 1 addition & 0 deletions drivers/platform/x86/amd/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ source "drivers/platform/x86/amd/pmf/Kconfig"
config AMD_PMC
tristate "AMD SoC PMC driver"
depends on ACPI && PCI && RTC_CLASS
select SERIO
help
The driver provides support for AMD Power Management Controller
primarily responsible for S2Idle transactions that are driven from
Expand Down
9 changes: 1 addition & 8 deletions drivers/platform/x86/amd/pmf/auto-mode.c
Original file line number Diff line number Diff line change
Expand Up @@ -275,13 +275,8 @@ int amd_pmf_reset_amt(struct amd_pmf_dev *dev)
*/

if (is_apmf_func_supported(dev, APMF_FUNC_STATIC_SLIDER_GRANULAR)) {
int mode = amd_pmf_get_pprof_modes(dev);

if (mode < 0)
return mode;

dev_dbg(dev->dev, "resetting AMT thermals\n");
amd_pmf_update_slider(dev, SLIDER_OP_SET, mode, NULL);
amd_pmf_set_sps_power_limits(dev);
}
return 0;
}
Expand All @@ -299,7 +294,5 @@ void amd_pmf_deinit_auto_mode(struct amd_pmf_dev *dev)
void amd_pmf_init_auto_mode(struct amd_pmf_dev *dev)
{
amd_pmf_load_defaults_auto_mode(dev);
/* update the thermal limits for Automode */
amd_pmf_set_automode(dev, config_store.current_mode, NULL);
amd_pmf_init_metrics_table(dev);
}
14 changes: 5 additions & 9 deletions drivers/platform/x86/amd/pmf/cnqf.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ int amd_pmf_trans_cnqf(struct amd_pmf_dev *dev, int socket_power, ktime_t time_l

src = amd_pmf_cnqf_get_power_source(dev);

if (dev->current_profile == PLATFORM_PROFILE_BALANCED) {
if (is_pprof_balanced(dev)) {
amd_pmf_set_cnqf(dev, src, config_store.current_mode, NULL);
} else {
/*
Expand Down Expand Up @@ -307,25 +307,21 @@ static ssize_t cnqf_enable_store(struct device *dev,
const char *buf, size_t count)
{
struct amd_pmf_dev *pdev = dev_get_drvdata(dev);
int mode, result, src;
int result, src;
bool input;

mode = amd_pmf_get_pprof_modes(pdev);
if (mode < 0)
return mode;

result = kstrtobool(buf, &input);
if (result)
return result;

src = amd_pmf_cnqf_get_power_source(pdev);
pdev->cnqf_enabled = input;

if (pdev->cnqf_enabled && pdev->current_profile == PLATFORM_PROFILE_BALANCED) {
if (pdev->cnqf_enabled && is_pprof_balanced(pdev)) {
amd_pmf_set_cnqf(pdev, src, config_store.current_mode, NULL);
} else {
if (is_apmf_func_supported(pdev, APMF_FUNC_STATIC_SLIDER_GRANULAR))
amd_pmf_update_slider(pdev, SLIDER_OP_SET, mode, NULL);
amd_pmf_set_sps_power_limits(pdev);
}

dev_dbg(pdev->dev, "Received CnQF %s\n", input ? "on" : "off");
Expand Down Expand Up @@ -386,7 +382,7 @@ int amd_pmf_init_cnqf(struct amd_pmf_dev *dev)
dev->cnqf_enabled = amd_pmf_check_flags(dev);

/* update the thermal for CnQF */
if (dev->cnqf_enabled && dev->current_profile == PLATFORM_PROFILE_BALANCED) {
if (dev->cnqf_enabled && is_pprof_balanced(dev)) {
src = amd_pmf_cnqf_get_power_source(dev);
amd_pmf_set_cnqf(dev, src, config_store.current_mode, NULL);
}
Expand Down
32 changes: 28 additions & 4 deletions drivers/platform/x86/amd/pmf/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,25 @@ static bool force_load;
module_param(force_load, bool, 0444);
MODULE_PARM_DESC(force_load, "Force load this driver on supported older platforms (experimental)");

static int amd_pmf_pwr_src_notify_call(struct notifier_block *nb, unsigned long event, void *data)
{
struct amd_pmf_dev *pmf = container_of(nb, struct amd_pmf_dev, pwr_src_notifier);

if (event != PSY_EVENT_PROP_CHANGED)
return NOTIFY_OK;

if (is_apmf_func_supported(pmf, APMF_FUNC_AUTO_MODE) ||
is_apmf_func_supported(pmf, APMF_FUNC_DYN_SLIDER_DC) ||
is_apmf_func_supported(pmf, APMF_FUNC_DYN_SLIDER_AC)) {
if ((pmf->amt_enabled || pmf->cnqf_enabled) && is_pprof_balanced(pmf))
return NOTIFY_DONE;
}

amd_pmf_set_sps_power_limits(pmf);

return NOTIFY_OK;
}

static int current_power_limits_show(struct seq_file *seq, void *unused)
{
struct amd_pmf_dev *dev = seq->private;
Expand Down Expand Up @@ -366,14 +385,18 @@ static int amd_pmf_probe(struct platform_device *pdev)
if (!dev->regbase)
return -ENOMEM;

mutex_init(&dev->lock);
mutex_init(&dev->update_mutex);

apmf_acpi_init(dev);
platform_set_drvdata(pdev, dev);
amd_pmf_init_features(dev);
apmf_install_handler(dev);
amd_pmf_dbgfs_register(dev);

mutex_init(&dev->lock);
mutex_init(&dev->update_mutex);
dev->pwr_src_notifier.notifier_call = amd_pmf_pwr_src_notify_call;
power_supply_reg_notifier(&dev->pwr_src_notifier);

dev_info(dev->dev, "registered PMF device successfully\n");

return 0;
Expand All @@ -383,11 +406,12 @@ static int amd_pmf_remove(struct platform_device *pdev)
{
struct amd_pmf_dev *dev = platform_get_drvdata(pdev);

mutex_destroy(&dev->lock);
mutex_destroy(&dev->update_mutex);
power_supply_unreg_notifier(&dev->pwr_src_notifier);
amd_pmf_deinit_features(dev);
apmf_acpi_deinit(dev);
amd_pmf_dbgfs_unregister(dev);
mutex_destroy(&dev->lock);
mutex_destroy(&dev->update_mutex);
kfree(dev->buf);
return 0;
}
Expand Down
3 changes: 3 additions & 0 deletions drivers/platform/x86/amd/pmf/pmf.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ struct amd_pmf_dev {
struct mutex update_mutex; /* protects race between ACPI handler and metrics thread */
bool cnqf_enabled;
bool cnqf_supported;
struct notifier_block pwr_src_notifier;
};

struct apmf_sps_prop_granular {
Expand Down Expand Up @@ -391,9 +392,11 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev);
void amd_pmf_deinit_sps(struct amd_pmf_dev *dev);
int apmf_get_static_slider_granular(struct amd_pmf_dev *pdev,
struct apmf_static_slider_granular_output *output);
bool is_pprof_balanced(struct amd_pmf_dev *pmf);


int apmf_update_fan_idx(struct amd_pmf_dev *pdev, bool manual, u32 idx);
int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf);

/* Auto Mode Layer */
int apmf_get_auto_mode_def(struct amd_pmf_dev *pdev, struct apmf_auto_mode *data);
Expand Down
28 changes: 22 additions & 6 deletions drivers/platform/x86/amd/pmf/sps.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,24 @@ void amd_pmf_update_slider(struct amd_pmf_dev *dev, bool op, int idx,
}
}

int amd_pmf_set_sps_power_limits(struct amd_pmf_dev *pmf)
{
int mode;

mode = amd_pmf_get_pprof_modes(pmf);
if (mode < 0)
return mode;

amd_pmf_update_slider(pmf, SLIDER_OP_SET, mode, NULL);

return 0;
}

bool is_pprof_balanced(struct amd_pmf_dev *pmf)
{
return (pmf->current_profile == PLATFORM_PROFILE_BALANCED) ? true : false;
}

static int amd_pmf_profile_get(struct platform_profile_handler *pprof,
enum platform_profile_option *profile)
{
Expand Down Expand Up @@ -105,15 +123,10 @@ static int amd_pmf_profile_set(struct platform_profile_handler *pprof,
enum platform_profile_option profile)
{
struct amd_pmf_dev *pmf = container_of(pprof, struct amd_pmf_dev, pprof);
int mode;

pmf->current_profile = profile;
mode = amd_pmf_get_pprof_modes(pmf);
if (mode < 0)
return mode;

amd_pmf_update_slider(pmf, SLIDER_OP_SET, mode, NULL);
return 0;
return amd_pmf_set_sps_power_limits(pmf);
}

int amd_pmf_init_sps(struct amd_pmf_dev *dev)
Expand All @@ -123,6 +136,9 @@ int amd_pmf_init_sps(struct amd_pmf_dev *dev)
dev->current_profile = PLATFORM_PROFILE_BALANCED;
amd_pmf_load_defaults_sps(dev);

/* update SPS balanced power mode thermals */
amd_pmf_set_sps_power_limits(dev);

dev->pprof.profile_get = amd_pmf_profile_get;
dev->pprof.profile_set = amd_pmf_profile_set;

Expand Down
2 changes: 1 addition & 1 deletion drivers/platform/x86/thinkpad_acpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -5563,7 +5563,7 @@ static int light_sysfs_set(struct led_classdev *led_cdev,

static enum led_brightness light_sysfs_get(struct led_classdev *led_cdev)
{
return (light_get_status() == 1) ? LED_FULL : LED_OFF;
return (light_get_status() == 1) ? LED_ON : LED_OFF;
}

static struct tpacpi_led_classdev tpacpi_led_thinklight = {
Expand Down
9 changes: 9 additions & 0 deletions drivers/platform/x86/touchscreen_dmi.c
Original file line number Diff line number Diff line change
Expand Up @@ -1097,6 +1097,15 @@ const struct dmi_system_id touchscreen_dmi_table[] = {
DMI_MATCH(DMI_BIOS_DATE, "05/07/2016"),
},
},
{
/* Chuwi Vi8 (CWI501) */
.driver_data = (void *)&chuwi_vi8_data,
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Insyde"),
DMI_MATCH(DMI_PRODUCT_NAME, "i86"),
DMI_MATCH(DMI_BIOS_VERSION, "CHUWI.W86JLBNR01"),
},
},
{
/* Chuwi Vi8 (CWI506) */
.driver_data = (void *)&chuwi_vi8_data,
Expand Down

0 comments on commit 870bb76

Please sign in to comment.