From patchwork Fri Jun 10 22:37:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 12878139 Received: from mail-pg1-f172.google.com (mail-pg1-f172.google.com [209.85.215.172]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E9DB33EF for ; Fri, 10 Jun 2022 22:37:05 +0000 (UTC) Received: by mail-pg1-f172.google.com with SMTP id 184so406061pga.12 for ; Fri, 10 Jun 2022 15:37:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yxTKmB4sS7h/Z8phwbcD4zVGK1WAkBqCaZbZvLiMaQQ=; b=JPjWwckYKoPNyw4OGC/s9T6MO0IxTzrYasVilPoGlmghW6HDPVAOuNYObADGOB9Iwu 1EtXhpICWFvpSljq3f0LQ0r6QM8El7TcmeZ+3cDOxYwLle4z0X6bVTTx5m3dmeAMc3bi Ahu9V1zZOI9gw/uTGQ1omzyo2BpmNRwXlY+DQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=yxTKmB4sS7h/Z8phwbcD4zVGK1WAkBqCaZbZvLiMaQQ=; b=RjvXI9DuZ/SlrzhAac7fDVvEeVICNZUQZmegbZGpGcvwLLIFjWo4wpsKeThZEJLkaM Bee0X2UNMiPlYggq+UE9l2va8Nx8JEXPk8RKcsfx3AyqfmOY7DjY3rhJLsIDOB9Jiam6 NuWot8okYxmzBZ9Ur5kIBL9eElyvkymZflnYz6x5KeNKjTG/bLuITnuyfwixhHkdHhvZ Ag0cpxKsnQWvhdPjBdnNuxsm5je3N2fY5u//HL6nhRj5/sJsd84EJJzFjldemXEWfNtS 4SZQr4lQp+nDuWsQleDsPGSByDqZ3jCTBp18S4axUQPGV1neinXQ0WeR6Hx1fRHlLSqV MOaA== X-Gm-Message-State: AOAM533hS/QJB/i8Tp7fH08YhAK+fGEf6413PVDpDtcazPg+y0SmzEjS LIfqzEdmhYjgcAZwG3a+IZA1Tg== X-Google-Smtp-Source: ABdhPJx/ZXGR3bi/YwVT9Age17Wwy/fmmJFNXDASE+FWIwHXX+kq0zGSMGIhVx42BFl8+NTio4fNig== X-Received: by 2002:a62:d045:0:b0:51b:fcf6:3add with SMTP id p66-20020a62d045000000b0051bfcf63addmr34225735pfg.68.1654900624752; Fri, 10 Jun 2022 15:37:04 -0700 (PDT) Received: from smtp.gmail.com ([2620:15c:202:201:290:ebca:2e9e:1570]) by smtp.gmail.com with ESMTPSA id o6-20020aa79786000000b0050dc76281e0sm48359pfp.186.2022.06.10.15.37.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Jun 2022 15:37:04 -0700 (PDT) From: Stephen Boyd To: Benson Leung Cc: linux-kernel@vger.kernel.org, patches@lists.linux.dev, Guenter Roeck , chrome-platform@lists.linux.dev, Evan Green , Rajat Jain , Matthias Kaehlcke , Hsin-Yi Wang Subject: [PATCH] platform/chrome: cros_ec: Always expose last resume result Date: Fri, 10 Jun 2022 15:37:02 -0700 Message-Id: <20220610223703.3387691-1-swboyd@chromium.org> X-Mailer: git-send-email 2.36.1.476.g0c4daa206d-goog Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The last resume result exposing logic in cros_ec_sleep_event() incorrectly requires S0ix support, which doesn't work on ARM based systems where S0ix doesn't exist. That's because cros_ec_sleep_event() only reports the last resume result when the EC indicates the last sleep event was an S0ix resume. On ARM systems, the last sleep event is always S3 resume, but the EC can still detect sleep hang events in case some other part of the AP is blocking sleep. Always expose the last resume result if the EC supports it so that this works on all devices regardless of S0ix support. This fixes sleep hang detection on ARM based chromebooks like Trogdor. Cc: Evan Green Cc: Rajat Jain Cc: Matthias Kaehlcke Cc: Hsin-Yi Wang Fixes: 7235560ac77a ("platform/chrome: Add support for v1 of host sleep event") Signed-off-by: Stephen Boyd --- I originally was going to check for S3 only with !ARCH_X86 but I can't convince myself that it's any use to limit the check to s0ix in general. This approach assumes the last resume result is valid if the command is supported, regardless of whether or not the AP supports s0ix or not. This seems to be the case at least on ARM, and looking at the EC convinces me that CONFIG_POWER_SLEEP_FAILURE_DETECTION is only enabled on x86 devices that have s0ix. drivers/platform/chrome/cros_ec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) base-commit: f2906aa863381afb0015a9eb7fefad885d4e5a56 diff --git a/drivers/platform/chrome/cros_ec.c b/drivers/platform/chrome/cros_ec.c index b3e94cdf7d1a..881d3ad09be0 100644 --- a/drivers/platform/chrome/cros_ec.c +++ b/drivers/platform/chrome/cros_ec.c @@ -135,10 +135,10 @@ static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event) buf.msg.command = EC_CMD_HOST_SLEEP_EVENT; ret = cros_ec_cmd_xfer_status(ec_dev, &buf.msg); - - /* For now, report failure to transition to S0ix with a warning. */ + /* Report failure to transition to system wide suspend with a warning. */ if (ret >= 0 && ec_dev->host_sleep_v1 && - (sleep_event == HOST_SLEEP_EVENT_S0IX_RESUME)) { + (sleep_event == HOST_SLEEP_EVENT_S0IX_SUSPEND || + sleep_event == HOST_SLEEP_EVENT_S3_RESUME)) { ec_dev->last_resume_result = buf.u.resp1.resume_response.sleep_transitions;