Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2643271pxj; Mon, 31 May 2021 07:14:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwJYNWbplbyd0rTZsi6t5aCeUztYY/bFSjSXKNJ1+TGIU6dxgNe3tEaOj09raSM2Byh0xIr X-Received: by 2002:a02:3304:: with SMTP id c4mr20983226jae.68.1622470469473; Mon, 31 May 2021 07:14:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622470469; cv=none; d=google.com; s=arc-20160816; b=iOTJlaRYmUYhSlCGbZEyisJ45D9GmGWiYdp9DbOYXZ0AQ0Vg/GlM9iZz/IYkcnibRm SO1TSz+fcUTyi/DhUepFhNvPxr1bzCq5GIgZie0LIDGCUNZAhKi1TGK6uLeJJ6C2FcGx RtG4MCfarYK+KTlBf9h6FoMQVJQQcLpSUf7iRyvjfMu4S+HubKkxHYFHndiVlTOkwTDQ blDWChM+RW7i0tEKo2XHp+D035tSRp3f4pz/fJmMA+5rV3GP/ZYgUgncFD0sSzKkQW2F 4GFdH9fFVIPWMWi4hdlXMxymxjpcwb9SMsPzO4+mh4VZP03meA8uFjA9U2O5f+xQI7V8 8tKw== 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=esaeSs/0OxSBz9ebmfdFnc0wi7QbF2I1lzjBcZzFVdg=; b=f3a5DzB32sSi+f13H2L4SPawTiCDasIvXB9bfyOjbcfyIDqqL2QfrOTKn452hAZj/r J66YcClO7yNg8sje5hZNdfckJ3h1nIeq4EPOxH3RuJg3eqvE0s/E+CNKY9MWNHuyREay gDJBKZov7OI+gfGD29zIl5P+02zhPMYPzcFqMFWNfLUXsF0DHp14aiIso5LaUKm6Z8z2 mjDHdxTZoLwBRZuoTWyNSGdB/KR5TG+fmnV3AfC50dmguLHZdrYQnpqbJ/fD0mD3fG48 r+jpR2E+rEjmYVLLphbczwHp8OR452XV66LgcD3PZu++QzFJ/ygMe7I/E+TmrRP1ZQD4 8yQQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b="eh//u7Oy"; 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 j2si15684134jak.119.2021.05.31.07.14.15; Mon, 31 May 2021 07:14:29 -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="eh//u7Oy"; 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 S233202AbhEaOM2 (ORCPT + 99 others); Mon, 31 May 2021 10:12:28 -0400 Received: from mail.kernel.org ([198.145.29.99]:49834 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232767AbhEaNpV (ORCPT ); Mon, 31 May 2021 09:45:21 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 464B2613F2; Mon, 31 May 2021 13:29:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1622467789; bh=TD042Atec4F9ZBJai4TbAhVmwzi2hnS8ajipd8FJQ0E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eh//u7OyQxtd6X7nUzYU7m/K4JiD6stTsOzjTo80eDyAfc39H/FSHEWvPcjT46SbB 8yH1vw38wmcQ6EmSg3KIgABH1b2vinBqFljub9zst2Mpbig31o2Q/hK3f7ov6DGAgk 9E6tiG9uwBKZpXiSFkHz7mb2xLkymfswKvDrAevM= 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 4.14 45/79] platform/x86: hp_accel: Avoid invoking _INI to speed up resume Date: Mon, 31 May 2021 15:14:30 +0200 Message-Id: <20210531130637.455710083@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210531130636.002722319@linuxfoundation.org> References: <20210531130636.002722319@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 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 7b12abe86b94..9c3c83ef445b 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; @@ -367,6 +370,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; @@ -414,11 +418,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