linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH AUTOSEL 4.4 01/16] platform/x86: hp_accel: Avoid invoking _INI to speed up resume
@ 2021-05-24 14:51 Sasha Levin
  2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 02/16] net: fujitsu: fix potential null-ptr-deref Sasha Levin
                   ` (14 more replies)
  0 siblings, 15 replies; 18+ messages in thread
From: Sasha Levin @ 2021-05-24 14:51 UTC (permalink / raw)
  To: linux-kernel, stable
  Cc: Kai-Heng Feng, Éric Piel, Hans de Goede, Sasha Levin,
	platform-driver-x86

From: Kai-Heng Feng <kai.heng.feng@canonical.com>

[ Upstream commit 79d341e26ebcdbc622348aaaab6f8f89b6fdb25f ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/misc/lis3lv02d/lis3lv02d.h |  1 +
 drivers/platform/x86/hp_accel.c    | 22 +++++++++++++++++++++-
 2 files changed, 22 insertions(+), 1 deletion(-)

diff --git a/drivers/misc/lis3lv02d/lis3lv02d.h b/drivers/misc/lis3lv02d/lis3lv02d.h
index c439c827eea8..0ef759671b54 100644
--- a/drivers/misc/lis3lv02d/lis3lv02d.h
+++ b/drivers/misc/lis3lv02d/lis3lv02d.h
@@ -284,6 +284,7 @@ struct lis3lv02d {
 	int			regs_size;
 	u8                      *reg_cache;
 	bool			regs_stored;
+	bool			init_required;
 	u8                      odr_mask;  /* ODR bit mask */
 	u8			whoami;    /* indicates measurement precision */
 	s16 (*read_data) (struct lis3lv02d *lis3, int reg);
diff --git a/drivers/platform/x86/hp_accel.c b/drivers/platform/x86/hp_accel.c
index 10ce6cba4455..a06262e91a93 100644
--- a/drivers/platform/x86/hp_accel.c
+++ b/drivers/platform/x86/hp_accel.c
@@ -101,6 +101,9 @@ MODULE_DEVICE_TABLE(acpi, lis3lv02d_device_ids);
 static int lis3lv02d_acpi_init(struct lis3lv02d *lis3)
 {
 	struct acpi_device *dev = lis3->bus_priv;
+	if (!lis3->init_required)
+		return 0;
+
 	if (acpi_evaluate_object(dev->handle, METHOD_NAME__INI,
 				 NULL, NULL) != AE_OK)
 		return -EINVAL;
@@ -361,6 +364,7 @@ static int lis3lv02d_add(struct acpi_device *device)
 	}
 
 	/* call the core layer do its init */
+	lis3_dev.init_required = true;
 	ret = lis3lv02d_init_device(&lis3_dev);
 	if (ret)
 		return ret;
@@ -408,11 +412,27 @@ static int lis3lv02d_suspend(struct device *dev)
 
 static int lis3lv02d_resume(struct device *dev)
 {
+	lis3_dev.init_required = false;
+	lis3lv02d_poweron(&lis3_dev);
+	return 0;
+}
+
+static int lis3lv02d_restore(struct device *dev)
+{
+	lis3_dev.init_required = true;
 	lis3lv02d_poweron(&lis3_dev);
 	return 0;
 }
 
-static SIMPLE_DEV_PM_OPS(hp_accel_pm, lis3lv02d_suspend, lis3lv02d_resume);
+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)
 #else
 #define HP_ACCEL_PM NULL
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2021-05-31 21:14 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-24 14:51 [PATCH AUTOSEL 4.4 01/16] platform/x86: hp_accel: Avoid invoking _INI to speed up resume Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 02/16] net: fujitsu: fix potential null-ptr-deref Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 03/16] net: caif: remove BUG_ON(dev == NULL) in caif_xmit Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 04/16] char: hpet: add checks after calling ioremap Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 05/16] ALSA: sb8: Add a comment note regarding an unused pointer Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 06/16] isdn: mISDNinfineon: check/cleanup ioremap failure correctly in setup_io Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 07/16] ath6kl: return error code in ath6kl_wmi_set_roam_lrssi_cmd() Sasha Levin
2021-05-31 20:47   ` Pavel Machek
2021-05-31 21:14     ` Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 08/16] libertas: register sysfs groups properly Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 09/16] media: dvb: Add check on sp8870_readreg return Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 10/16] media: gspca: mt9m111: Check write_bridge for timeout Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 11/16] media: gspca: properly check for errors in po1030_probe() Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 12/16] cdrom: gdrom: initialize global variable at init time Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 13/16] scsi: BusLogic: Fix 64-bit system enumeration error for Buslogic Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 14/16] openrisc: Define memory barrier mb Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 15/16] btrfs: do not BUG_ON in link_to_fixup_dir Sasha Levin
2021-05-24 14:51 ` [PATCH AUTOSEL 4.4 16/16] drm/amdgpu: Fix a use-after-free Sasha Levin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).