platform/x86: hp_accel: Avoid invoking _INI to speed up resume

hp_accel can take almost two seconds to resume on some HP laptops.

The bottleneck is on evaluating _INI, which is only needed to run once.

Resolve the issue by only invoking _INI when it's necessary. Namely, on
probe and on hibernation restore.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
Acked-by: Éric Piel <eric.piel@trempplin-utc.net>
Link: https://lore.kernel.org/r/20210430060736.590321-1-kai.heng.feng@canonical.com
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
This commit is contained in:
Kai-Heng Feng 2021-04-30 14:07:35 +08:00 committed by Hans de Goede
parent b09aaa3f2c
commit 79d341e26e
2 changed files with 22 additions and 1 deletions

View File

@ -271,6 +271,7 @@ struct lis3lv02d {
int regs_size; int regs_size;
u8 *reg_cache; u8 *reg_cache;
bool regs_stored; bool regs_stored;
bool init_required;
u8 odr_mask; /* ODR bit mask */ u8 odr_mask; /* ODR bit mask */
u8 whoami; /* indicates measurement precision */ u8 whoami; /* indicates measurement precision */
s16 (*read_data) (struct lis3lv02d *lis3, int reg); s16 (*read_data) (struct lis3lv02d *lis3, int reg);

View File

@ -88,6 +88,9 @@ MODULE_DEVICE_TABLE(acpi, lis3lv02d_device_ids);
static int lis3lv02d_acpi_init(struct lis3lv02d *lis3) static int lis3lv02d_acpi_init(struct lis3lv02d *lis3)
{ {
struct acpi_device *dev = lis3->bus_priv; struct acpi_device *dev = lis3->bus_priv;
if (!lis3->init_required)
return 0;
if (acpi_evaluate_object(dev->handle, METHOD_NAME__INI, if (acpi_evaluate_object(dev->handle, METHOD_NAME__INI,
NULL, NULL) != AE_OK) NULL, NULL) != AE_OK)
return -EINVAL; return -EINVAL;
@ -356,6 +359,7 @@ static int lis3lv02d_add(struct acpi_device *device)
} }
/* call the core layer do its init */ /* call the core layer do its init */
lis3_dev.init_required = true;
ret = lis3lv02d_init_device(&lis3_dev); ret = lis3lv02d_init_device(&lis3_dev);
if (ret) if (ret)
return ret; return ret;
@ -403,11 +407,27 @@ static int lis3lv02d_suspend(struct device *dev)
static int lis3lv02d_resume(struct device *dev) static int lis3lv02d_resume(struct device *dev)
{ {
lis3_dev.init_required = false;
lis3lv02d_poweron(&lis3_dev); lis3lv02d_poweron(&lis3_dev);
return 0; return 0;
} }
static SIMPLE_DEV_PM_OPS(hp_accel_pm, lis3lv02d_suspend, lis3lv02d_resume); static int lis3lv02d_restore(struct device *dev)
{
lis3_dev.init_required = true;
lis3lv02d_poweron(&lis3_dev);
return 0;
}
static const struct dev_pm_ops hp_accel_pm = {
.suspend = lis3lv02d_suspend,
.resume = lis3lv02d_resume,
.freeze = lis3lv02d_suspend,
.thaw = lis3lv02d_resume,
.poweroff = lis3lv02d_suspend,
.restore = lis3lv02d_restore,
};
#define HP_ACCEL_PM (&hp_accel_pm) #define HP_ACCEL_PM (&hp_accel_pm)
#else #else
#define HP_ACCEL_PM NULL #define HP_ACCEL_PM NULL