Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2661844pxj; Mon, 31 May 2021 07:41:03 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyGUzATSYMuaE46GjiAEZcs9aHDizZVbb5oRbxZWRy0AAICMrONHSdGbdvo4UbvmWZZdQGM X-Received: by 2002:a05:6e02:541:: with SMTP id i1mr10951736ils.67.1622472063654; Mon, 31 May 2021 07:41:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622472063; cv=none; d=google.com; s=arc-20160816; b=CwSP5oJ7iFX3r7cRx7rHqjw4BDWQdPDmXUGwPIleRPOaCt4fv0qbPnsAvs/WQUf2xe j0h7c8gukgjay7VJqZFtMpbWG1RyCHzF7EQCSoPwTm9Sl3tXGohU0TtpPL4nDDL2lIOo 3ThfgObQ/6erAuIBtK/AdaFDJIDLp8scKqBCd8J2Uz14IygEwmWm2+bVytSOvqEogx29 MsdPJ+d+/Hev56TcU7Lo+MC08i8KrYRgg1k6DSK0DTR0fXfKXy3q03LqWirvIRi4odrI tU2LvcvmpaHkKyLWjYvBWToripkmirJIYTwDa2N46qadMbi93/tkchFQdYizoBfky9mN KeDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=x2ea2eQV/0Wz1kAgIZguZE/AxfNImAonFUY/6Zm2jkg=; b=uhzkPT0FMFWDS7vaWi1R8eC1blFK7iGxt49YFRyrogOlf2JSbtoJ6F8ReBVUEoi3aB YfS+0wY96Q2U3OEe7zEefI0o3k8rmsoQdrx4snZpgBWbFu9dV+0m37+YwvFr8LCQXMxU CsuAiVXZmUo8I1/U6V29c5uRp3PMQVKi5Fym0cVHy//JllmAuMR6wG1VjilolhNsuOa8 3V3QmIiPgIR+opfV91b5n76g+6xQN2PcK8P1WTRHtkXbyrnTMVTXFZPunnY3Qb3uOWeK pffEdAh2TsbguV+JZRxaydw3j/2GN6DcBAs1m0QWJZnY5oO0+8HMvjP5Sn7PUA2IWF89 xOlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JiD9VlMh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id p14si16385139ils.62.2021.05.31.07.40.50; Mon, 31 May 2021 07:41:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JiD9VlMh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233607AbhEaOlc (ORCPT + 99 others); Mon, 31 May 2021 10:41:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:60840 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230339AbhEaN6b (ORCPT ); Mon, 31 May 2021 09:58:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 7548261440; Mon, 31 May 2021 13:35:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622468135; bh=Pv3bP2PMj6YOQykP7mK1HxW1+69TEd2XZ+M7eh5YLp0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JiD9VlMh/wMM7ktt2+fhN9M71biNbpS1gAOb3fhy6b/C+qtGpD+0YpEvnE/ZGz3B0 rvD253ucD3a2cMivr907xT0VJvBemwb+18q378bsNREsQ5LJ2cE6MWpDlhTwzxgeBM z5lkSt4A2gSwm6CDdPnaZq5/fTCNBLqhnfWaFM0A= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kai-Heng Feng , =?UTF-8?q?=C3=89ric=20Piel?= , Hans de Goede , Sasha Levin Subject: [PATCH 5.10 130/252] platform/x86: hp_accel: Avoid invoking _INI to speed up resume Date: Mon, 31 May 2021 15:13:15 +0200 Message-Id: <20210531130702.430082836@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130657.971257589@linuxfoundation.org> References: <20210531130657.971257589@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Kai-Heng Feng [ 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 Acked-by: Éric Piel Link: https://lore.kernel.org/r/20210430060736.590321-1-kai.heng.feng@canonical.com Signed-off-by: Hans de Goede Signed-off-by: Sasha Levin --- 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 c394c0b08519..7ac788fae1b8 100644 --- a/drivers/misc/lis3lv02d/lis3lv02d.h +++ b/drivers/misc/lis3lv02d/lis3lv02d.h @@ -271,6 +271,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 799cbe2ffcf3..8c0867bda828 100644 --- a/drivers/platform/x86/hp_accel.c +++ b/drivers/platform/x86/hp_accel.c @@ -88,6 +88,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; @@ -356,6 +359,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; @@ -403,11 +407,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