Commit c7138f7a authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'platform-drivers-x86-v6.8-3' of...

Merge tag 'platform-drivers-x86-v6.8-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86

Pull x86 platform driver fixes from Hans de Goede:
 "Regression fixes:

   - Fix INT0002 vGPIO events no longer working after 6.8 ACPI SCI
     changes

   - AMD-PMF: Fix laptops (e.g. Framework 13 AMD) hanging on suspend

   - x86-android-tablets: Fix touchscreen no longer working on Lenovo
     Yogabook

   - x86-android-tablets: Fix serdev instantiation regression

   - intel-vbtn: Fix ThinkPad X1 Tablet Gen2 no longer suspending

  Bug fixes:

   - think-lmi: Fix changing BIOS settings on Lenovo workstations

   - touchscreen_dmi: Fix Hi8 Air touchscreen data sometimes missing

   - AMD-PMF: Fix Smart PC support not working after suspend/resume

  Other misc small fixes"

* tag 'platform-drivers-x86-v6.8-3' of git://git.kernel.org/pub/scm/linux/kernel/git/pdx86/platform-drivers-x86:
  platform/x86: thinkpad_acpi: Only update profile if successfully converted
  platform/x86: intel-vbtn: Stop calling "VBDL" from notify_handler
  platform/x86: x86-android-tablets: Fix acer_b1_750_goodix_gpios name
  platform/x86: x86-android-tablets: Fix serdev instantiation no longer working
  platform/x86: Add new get_serdev_controller() helper
  platform/x86: x86-android-tablets: Fix keyboard touchscreen on Lenovo Yogabook1 X90
  platform/x86/amd/pmf: Fix a potential race with policy binary sideload
  platform/x86/amd/pmf: Fixup error handling for amd_pmf_init_smart_pc()
  platform/x86/amd/pmf: Add debugging message for missing policy data
  platform/x86/amd/pmf: Fix a suspend hang on Framework 13
  platform/x86/amd/pmf: Fix TEE enact command failure after suspend and resume
  platform/x86/amd/pmf: Remove smart_pc_status enum
  platform/x86: touchscreen_dmi: Consolidate Goodix upside-down touchscreen data
  platform/x86: touchscreen_dmi: Allow partial (prefix) matches for ACPI names
  platform/x86: intel: int0002_vgpio: Pass IRQF_ONESHOT to request_irq()
  platform/x86: think-lmi: Fix password opcode ordering for workstations
parents 88953761 427c70de
......@@ -296,7 +296,8 @@ static int amd_pmf_suspend_handler(struct device *dev)
{
struct amd_pmf_dev *pdev = dev_get_drvdata(dev);
kfree(pdev->buf);
if (pdev->smart_pc_enabled)
cancel_delayed_work_sync(&pdev->pb_work);
return 0;
}
......@@ -312,6 +313,9 @@ static int amd_pmf_resume_handler(struct device *dev)
return ret;
}
if (pdev->smart_pc_enabled)
schedule_delayed_work(&pdev->pb_work, msecs_to_jiffies(2000));
return 0;
}
......@@ -330,9 +334,14 @@ static void amd_pmf_init_features(struct amd_pmf_dev *dev)
dev_dbg(dev->dev, "SPS enabled and Platform Profiles registered\n");
}
if (!amd_pmf_init_smart_pc(dev)) {
amd_pmf_init_smart_pc(dev);
if (dev->smart_pc_enabled) {
dev_dbg(dev->dev, "Smart PC Solution Enabled\n");
} else if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) {
/* If Smart PC is enabled, no need to check for other features */
return;
}
if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) {
amd_pmf_init_auto_mode(dev);
dev_dbg(dev->dev, "Auto Mode Init done\n");
} else if (is_apmf_func_supported(dev, APMF_FUNC_DYN_SLIDER_AC) ||
......@@ -351,7 +360,7 @@ static void amd_pmf_deinit_features(struct amd_pmf_dev *dev)
amd_pmf_deinit_sps(dev);
}
if (!dev->smart_pc_enabled) {
if (dev->smart_pc_enabled) {
amd_pmf_deinit_smart_pc(dev);
} else if (is_apmf_func_supported(dev, APMF_FUNC_AUTO_MODE)) {
amd_pmf_deinit_auto_mode(dev);
......
......@@ -441,11 +441,6 @@ struct apmf_dyn_slider_output {
struct apmf_cnqf_power_set ps[APMF_CNQF_MAX];
} __packed;
enum smart_pc_status {
PMF_SMART_PC_ENABLED,
PMF_SMART_PC_DISABLED,
};
/* Smart PC - TA internals */
enum system_state {
SYSTEM_STATE_S0i3,
......
......@@ -252,15 +252,17 @@ static int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev)
cookie = readl(dev->policy_buf + POLICY_COOKIE_OFFSET);
length = readl(dev->policy_buf + POLICY_COOKIE_LEN);
if (cookie != POLICY_SIGN_COOKIE || !length)
if (cookie != POLICY_SIGN_COOKIE || !length) {
dev_dbg(dev->dev, "cookie doesn't match\n");
return -EINVAL;
}
/* Update the actual length */
dev->policy_sz = length + 512;
res = amd_pmf_invoke_cmd_init(dev);
if (res == TA_PMF_TYPE_SUCCESS) {
/* Now its safe to announce that smart pc is enabled */
dev->smart_pc_enabled = PMF_SMART_PC_ENABLED;
dev->smart_pc_enabled = true;
/*
* Start collecting the data from TA FW after a small delay
* or else, we might end up getting stale values.
......@@ -268,7 +270,7 @@ static int amd_pmf_start_policy_engine(struct amd_pmf_dev *dev)
schedule_delayed_work(&dev->pb_work, msecs_to_jiffies(pb_actions_ms * 3));
} else {
dev_err(dev->dev, "ta invoke cmd init failed err: %x\n", res);
dev->smart_pc_enabled = PMF_SMART_PC_DISABLED;
dev->smart_pc_enabled = false;
return res;
}
......@@ -336,25 +338,6 @@ static void amd_pmf_remove_pb(struct amd_pmf_dev *dev) {}
static void amd_pmf_hex_dump_pb(struct amd_pmf_dev *dev) {}
#endif
static int amd_pmf_get_bios_buffer(struct amd_pmf_dev *dev)
{
dev->policy_buf = kzalloc(dev->policy_sz, GFP_KERNEL);
if (!dev->policy_buf)
return -ENOMEM;
dev->policy_base = devm_ioremap(dev->dev, dev->policy_addr, dev->policy_sz);
if (!dev->policy_base)
return -ENOMEM;
memcpy(dev->policy_buf, dev->policy_base, dev->policy_sz);
amd_pmf_hex_dump_pb(dev);
if (pb_side_load)
amd_pmf_open_pb(dev, dev->dbgfs_dir);
return amd_pmf_start_policy_engine(dev);
}
static int amd_pmf_amdtee_ta_match(struct tee_ioctl_version_data *ver, const void *data)
{
return ver->impl_id == TEE_IMPL_ID_AMDTEE;
......@@ -453,22 +436,57 @@ int amd_pmf_init_smart_pc(struct amd_pmf_dev *dev)
return ret;
INIT_DELAYED_WORK(&dev->pb_work, amd_pmf_invoke_cmd);
amd_pmf_set_dram_addr(dev, true);
amd_pmf_get_bios_buffer(dev);
ret = amd_pmf_set_dram_addr(dev, true);
if (ret)
goto error;
dev->policy_base = devm_ioremap(dev->dev, dev->policy_addr, dev->policy_sz);
if (!dev->policy_base) {
ret = -ENOMEM;
goto error;
}
dev->policy_buf = kzalloc(dev->policy_sz, GFP_KERNEL);
if (!dev->policy_buf) {
ret = -ENOMEM;
goto error;
}
memcpy(dev->policy_buf, dev->policy_base, dev->policy_sz);
amd_pmf_hex_dump_pb(dev);
dev->prev_data = kzalloc(sizeof(*dev->prev_data), GFP_KERNEL);
if (!dev->prev_data)
return -ENOMEM;
goto error;
ret = amd_pmf_start_policy_engine(dev);
if (ret)
goto error;
return dev->smart_pc_enabled;
if (pb_side_load)
amd_pmf_open_pb(dev, dev->dbgfs_dir);
return 0;
error:
amd_pmf_deinit_smart_pc(dev);
return ret;
}
void amd_pmf_deinit_smart_pc(struct amd_pmf_dev *dev)
{
if (pb_side_load)
if (pb_side_load && dev->esbin)
amd_pmf_remove_pb(dev);
cancel_delayed_work_sync(&dev->pb_work);
kfree(dev->prev_data);
dev->prev_data = NULL;
kfree(dev->policy_buf);
cancel_delayed_work_sync(&dev->pb_work);
dev->policy_buf = NULL;
kfree(dev->buf);
dev->buf = NULL;
amd_pmf_tee_deinit(dev);
}
......@@ -196,7 +196,7 @@ static int int0002_probe(struct platform_device *pdev)
* IRQs into gpiolib.
*/
ret = devm_request_irq(dev, irq, int0002_irq,
IRQF_SHARED, "INT0002", chip);
IRQF_ONESHOT | IRQF_SHARED, "INT0002", chip);
if (ret) {
dev_err(dev, "Error requesting IRQ %d: %d\n", irq, ret);
return ret;
......
......@@ -200,9 +200,6 @@ static void notify_handler(acpi_handle handle, u32 event, void *context)
autorelease = val && (!ke_rel || ke_rel->type == KE_IGNORE);
sparse_keymap_report_event(input_dev, event, val, autorelease);
/* Some devices need this to report further events */
acpi_evaluate_object(handle, "VBDL", NULL, NULL);
}
/*
......
/* SPDX-License-Identifier: GPL-2.0-or-later */
/*
* In some cases UART attached devices which require an in kernel driver,
* e.g. UART attached Bluetooth HCIs are described in the ACPI tables
* by an ACPI device with a broken or missing UartSerialBusV2() resource.
*
* This causes the kernel to create a /dev/ttyS# char-device for the UART
* instead of creating an in kernel serdev-controller + serdev-device pair
* for the in kernel driver.
*
* The quirk handling in acpi_quirk_skip_serdev_enumeration() makes the kernel
* create a serdev-controller device for these UARTs instead of a /dev/ttyS#.
*
* Instantiating the actual serdev-device to bind to is up to pdx86 code,
* this header provides a helper for getting the serdev-controller device.
*/
#include <linux/acpi.h>
#include <linux/device.h>
#include <linux/err.h>
#include <linux/printk.h>
#include <linux/sprintf.h>
#include <linux/string.h>
static inline struct device *
get_serdev_controller(const char *serial_ctrl_hid,
const char *serial_ctrl_uid,
int serial_ctrl_port,
const char *serdev_ctrl_name)
{
struct device *ctrl_dev, *child;
struct acpi_device *ctrl_adev;
char name[32];
int i;
ctrl_adev = acpi_dev_get_first_match_dev(serial_ctrl_hid, serial_ctrl_uid, -1);
if (!ctrl_adev) {
pr_err("error could not get %s/%s serial-ctrl adev\n",
serial_ctrl_hid, serial_ctrl_uid);
return ERR_PTR(-ENODEV);
}
/* get_first_physical_node() returns a weak ref */
ctrl_dev = get_device(acpi_get_first_physical_node(ctrl_adev));
if (!ctrl_dev) {
pr_err("error could not get %s/%s serial-ctrl physical node\n",
serial_ctrl_hid, serial_ctrl_uid);
ctrl_dev = ERR_PTR(-ENODEV);
goto put_ctrl_adev;
}
/* Walk host -> uart-ctrl -> port -> serdev-ctrl */
for (i = 0; i < 3; i++) {
switch (i) {
case 0:
snprintf(name, sizeof(name), "%s:0", dev_name(ctrl_dev));
break;
case 1:
snprintf(name, sizeof(name), "%s.%d",
dev_name(ctrl_dev), serial_ctrl_port);
break;
case 2:
strscpy(name, serdev_ctrl_name, sizeof(name));
break;
}
child = device_find_child_by_name(ctrl_dev, name);
put_device(ctrl_dev);
if (!child) {
pr_err("error could not find '%s' device\n", name);
ctrl_dev = ERR_PTR(-ENODEV);
goto put_ctrl_adev;
}
ctrl_dev = child;
}
put_ctrl_adev:
acpi_dev_put(ctrl_adev);
return ctrl_dev;
}
......@@ -1009,7 +1009,16 @@ static ssize_t current_value_store(struct kobject *kobj,
* Note - this sets the variable and then the password as separate
* WMI calls. Function tlmi_save_bios_settings will error if the
* password is incorrect.
* Workstation's require the opcode to be set before changing the
* attribute.
*/
if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) {
ret = tlmi_opcode_setting("WmiOpcodePasswordAdmin",
tlmi_priv.pwd_admin->password);
if (ret)
goto out;
}
set_str = kasprintf(GFP_KERNEL, "%s,%s;", setting->display_name,
new_setting);
if (!set_str) {
......@@ -1021,17 +1030,10 @@ static ssize_t current_value_store(struct kobject *kobj,
if (ret)
goto out;
if (tlmi_priv.save_mode == TLMI_SAVE_BULK) {
if (tlmi_priv.save_mode == TLMI_SAVE_BULK)
tlmi_priv.save_required = true;
} else {
if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) {
ret = tlmi_opcode_setting("WmiOpcodePasswordAdmin",
tlmi_priv.pwd_admin->password);
if (ret)
goto out;
}
else
ret = tlmi_save_bios_settings("");
}
} else { /* old non-opcode based authentication method (deprecated) */
if (tlmi_priv.pwd_admin->valid && tlmi_priv.pwd_admin->password[0]) {
auth_str = kasprintf(GFP_KERNEL, "%s,%s,%s;",
......
......@@ -10308,6 +10308,7 @@ static int convert_dytc_to_profile(int funcmode, int dytcmode,
return 0;
default:
/* Unknown function */
pr_debug("unknown function 0x%x\n", funcmode);
return -EOPNOTSUPP;
}
return 0;
......@@ -10493,8 +10494,8 @@ static void dytc_profile_refresh(void)
return;
perfmode = (output >> DYTC_GET_MODE_BIT) & 0xF;
convert_dytc_to_profile(funcmode, perfmode, &profile);
if (profile != dytc_current_profile) {
err = convert_dytc_to_profile(funcmode, perfmode, &profile);
if (!err && profile != dytc_current_profile) {
dytc_current_profile = profile;
platform_profile_notify();
}
......
......@@ -81,7 +81,7 @@ static const struct property_entry chuwi_hi8_air_props[] = {
};
static const struct ts_dmi_data chuwi_hi8_air_data = {
.acpi_name = "MSSL1680:00",
.acpi_name = "MSSL1680",
.properties = chuwi_hi8_air_props,
};
......@@ -415,18 +415,13 @@ static const struct property_entry gdix1001_upside_down_props[] = {
{ }
};
static const struct ts_dmi_data gdix1001_00_upside_down_data = {
.acpi_name = "GDIX1001:00",
.properties = gdix1001_upside_down_props,
};
static const struct ts_dmi_data gdix1001_01_upside_down_data = {
.acpi_name = "GDIX1001:01",
static const struct ts_dmi_data gdix1001_upside_down_data = {
.acpi_name = "GDIX1001",
.properties = gdix1001_upside_down_props,
};
static const struct ts_dmi_data gdix1002_00_upside_down_data = {
.acpi_name = "GDIX1002:00",
static const struct ts_dmi_data gdix1002_upside_down_data = {
.acpi_name = "GDIX1002",
.properties = gdix1001_upside_down_props,
};
......@@ -1412,7 +1407,7 @@ const struct dmi_system_id touchscreen_dmi_table[] = {
},
{
/* Juno Tablet */
.driver_data = (void *)&gdix1002_00_upside_down_data,
.driver_data = (void *)&gdix1002_upside_down_data,
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "Default string"),
/* Both product- and board-name being "Default string" is somewhat rare */
......@@ -1658,7 +1653,7 @@ const struct dmi_system_id touchscreen_dmi_table[] = {
},
{
/* Teclast X89 (Android version / BIOS) */
.driver_data = (void *)&gdix1001_00_upside_down_data,
.driver_data = (void *)&gdix1001_upside_down_data,
.matches = {
DMI_MATCH(DMI_BOARD_VENDOR, "WISKY"),
DMI_MATCH(DMI_BOARD_NAME, "3G062i"),
......@@ -1666,7 +1661,7 @@ const struct dmi_system_id touchscreen_dmi_table[] = {
},
{
/* Teclast X89 (Windows version / BIOS) */
.driver_data = (void *)&gdix1001_01_upside_down_data,
.driver_data = (void *)&gdix1001_upside_down_data,
.matches = {
/* tPAD is too generic, also match on bios date */
DMI_MATCH(DMI_BOARD_VENDOR, "TECLAST"),
......@@ -1684,7 +1679,7 @@ const struct dmi_system_id touchscreen_dmi_table[] = {
},
{
/* Teclast X98 Pro */
.driver_data = (void *)&gdix1001_00_upside_down_data,
.driver_data = (void *)&gdix1001_upside_down_data,
.matches = {
/*
* Only match BIOS date, because the manufacturers
......@@ -1788,7 +1783,7 @@ const struct dmi_system_id touchscreen_dmi_table[] = {
},
{
/* "WinBook TW100" */
.driver_data = (void *)&gdix1001_00_upside_down_data,
.driver_data = (void *)&gdix1001_upside_down_data,
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "WinBook"),
DMI_MATCH(DMI_PRODUCT_NAME, "TW100")
......@@ -1796,7 +1791,7 @@ const struct dmi_system_id touchscreen_dmi_table[] = {
},
{
/* WinBook TW700 */
.driver_data = (void *)&gdix1001_00_upside_down_data,
.driver_data = (void *)&gdix1001_upside_down_data,
.matches = {
DMI_MATCH(DMI_SYS_VENDOR, "WinBook"),
DMI_MATCH(DMI_PRODUCT_NAME, "TW700")
......@@ -1821,7 +1816,7 @@ static void ts_dmi_add_props(struct i2c_client *client)
int error;
if (has_acpi_companion(dev) &&
!strncmp(ts_data->acpi_name, client->name, I2C_NAME_SIZE)) {
strstarts(client->name, ts_data->acpi_name)) {
error = device_create_managed_software_node(dev, ts_data->properties, NULL);
if (error)
dev_err(dev, "failed to add properties: %d\n", error);
......
......@@ -21,6 +21,7 @@
#include <linux/string.h>
#include "x86-android-tablets.h"
#include "../serdev_helpers.h"
static struct platform_device *x86_android_tablet_device;
......@@ -113,6 +114,9 @@ int x86_acpi_irq_helper_get(const struct x86_acpi_irq_data *data)
if (irq_type != IRQ_TYPE_NONE && irq_type != irq_get_trigger_type(irq))
irq_set_irq_type(irq, irq_type);
if (data->free_gpio)
devm_gpiod_put(&x86_android_tablet_device->dev, gpiod);
return irq;
case X86_ACPI_IRQ_TYPE_PMIC:
status = acpi_get_handle(NULL, data->chip, &handle);
......@@ -229,38 +233,20 @@ static __init int x86_instantiate_spi_dev(const struct x86_dev_info *dev_info, i
static __init int x86_instantiate_serdev(const struct x86_serdev_info *info, int idx)
{
struct acpi_device *ctrl_adev, *serdev_adev;
struct acpi_device *serdev_adev;
struct serdev_device *serdev;
struct device *ctrl_dev;
int ret = -ENODEV;
ctrl_adev = acpi_dev_get_first_match_dev(info->ctrl_hid, info->ctrl_uid, -1);
if (!ctrl_adev) {
pr_err("error could not get %s/%s ctrl adev\n",
info->ctrl_hid, info->ctrl_uid);
return -ENODEV;
}
ctrl_dev = get_serdev_controller(info->ctrl_hid, info->ctrl_uid, 0,
info->ctrl_devname);
if (IS_ERR(ctrl_dev))
return PTR_ERR(ctrl_dev);
serdev_adev = acpi_dev_get_first_match_dev(info->serdev_hid, NULL, -1);
if (!serdev_adev) {
pr_err("error could not get %s serdev adev\n", info->serdev_hid);
goto put_ctrl_adev;
}
/* get_first_physical_node() returns a weak ref, no need to put() it */
ctrl_dev = acpi_get_first_physical_node(ctrl_adev);
if (!ctrl_dev) {
pr_err("error could not get %s/%s ctrl physical dev\n",
info->ctrl_hid, info->ctrl_uid);
goto put_serdev_adev;
}
/* ctrl_dev now points to the controller's parent, get the controller */
ctrl_dev = device_find_child_by_name(ctrl_dev, info->ctrl_devname);
if (!ctrl_dev) {
pr_err("error could not get %s/%s %s ctrl dev\n",
info->ctrl_hid, info->ctrl_uid, info->ctrl_devname);
goto put_serdev_adev;
goto put_ctrl_dev;
}
serdev = serdev_device_alloc(to_serdev_controller(ctrl_dev));
......@@ -283,8 +269,8 @@ static __init int x86_instantiate_serdev(const struct x86_serdev_info *info, int
put_serdev_adev:
acpi_dev_put(serdev_adev);
put_ctrl_adev:
acpi_dev_put(ctrl_adev);
put_ctrl_dev:
put_device(ctrl_dev);
return ret;
}
......
......@@ -116,6 +116,7 @@ static const struct x86_i2c_client_info lenovo_yb1_x90_i2c_clients[] __initconst
.trigger = ACPI_EDGE_SENSITIVE,
.polarity = ACPI_ACTIVE_LOW,
.con_id = "goodix_ts_irq",
.free_gpio = true,
},
}, {
/* Wacom Digitizer in keyboard half */
......
......@@ -68,7 +68,7 @@ static const struct x86_i2c_client_info acer_b1_750_i2c_clients[] __initconst =
},
};
static struct gpiod_lookup_table acer_b1_750_goodix_gpios = {
static struct gpiod_lookup_table acer_b1_750_nvt_ts_gpios = {
.dev_id = "i2c-NVT-ts",
.table = {
GPIO_LOOKUP("INT33FC:01", 26, "reset", GPIO_ACTIVE_LOW),
......@@ -77,7 +77,7 @@ static struct gpiod_lookup_table acer_b1_750_goodix_gpios = {
};
static struct gpiod_lookup_table * const acer_b1_750_gpios[] = {
&acer_b1_750_goodix_gpios,
&acer_b1_750_nvt_ts_gpios,
&int3496_reference_gpios,
NULL
};
......
......@@ -39,6 +39,7 @@ struct x86_acpi_irq_data {
int index;
int trigger; /* ACPI_EDGE_SENSITIVE / ACPI_LEVEL_SENSITIVE */
int polarity; /* ACPI_ACTIVE_HIGH / ACPI_ACTIVE_LOW / ACPI_ACTIVE_BOTH */
bool free_gpio; /* Release GPIO after getting IRQ (for TYPE_GPIOINT) */
const char *con_id;
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment