Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp931247img; Fri, 22 Mar 2019 11:40:50 -0700 (PDT) X-Google-Smtp-Source: APXvYqwK1fpZfQ+F9pxinhDMk2qJN29QbuMxW+RhIHJMdaowJrLp1iRBSNLYfGN1y1k7ckwfGdeV X-Received: by 2002:aa7:8d01:: with SMTP id j1mr10936373pfe.122.1553280050856; Fri, 22 Mar 2019 11:40:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553280050; cv=none; d=google.com; s=arc-20160816; b=jik9uBcSGxy4vN+M9KNEU/cvqLIN1PxH0jLe7FXeaFtn3ZCYuuH8mqTvayu+VNvQTY n4ly8fMeuC3WAtF5NzoQP2qZIPtiddjP5wKk2RYcVyGvdwsTVKWecTw3UJA6oN4Y/8wl CYTHsbLNxb933w18+3lo4wAe/vIMySBAxZkKrHqr2m0GiHLqJIw3uhuldC0QjVhIyjG4 Lm6eTA6KeXv6YL5Ec07XR/gBXcFAX9vhEpp2aleTVXSHw5IZkCFcooCwiW8bwBltsZGL FG4vub4rocPKPKBKPbJia5F98obS0uM4akQumw6bUtC1OGsdTqn+eUfQbJF6Z/Nxx6Kj IKFA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=vSYM/lE/KT01QaZoImFD4qe2O3y+6F5gGaiZ9Y7krzg=; b=0yPTRXLA6gJkfRPJO5HoOQBla3eOepyWZVkR8qB+QnLjpLC8E766fQKhvfSgy/Hmj+ oSj8zpkKrw0m1H4mfjj0X7cC/5aAxsuj254m+QROWSlblgJRGngD34RIamEl8Y4rUH1+ wFEolcR8N+yjindXsbHhy3kUsqVAE9zb0xNSamwdRHlZTtMoDlFsVQnVunGpvP7Szo4s dl4rBOfIXzGr7rOtexY8HQ6zp9xnvoGTu1poKnDaBYk78YWdfwgAxAtCvNXACE2EmUzz 4XKQdj2imrzY1zrGjNZS6C6atBYGL5kOL8my+yEkDbANScaEpqX7saJHccfwgaUIlSuq lD1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=j30RP5CJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id n14si7043462pgv.520.2019.03.22.11.40.32; Fri, 22 Mar 2019 11:40:50 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=j30RP5CJ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727568AbfCVSjw (ORCPT + 99 others); Fri, 22 Mar 2019 14:39:52 -0400 Received: from mail-lj1-f193.google.com ([209.85.208.193]:39824 "EHLO mail-lj1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727704AbfCVSjv (ORCPT ); Fri, 22 Mar 2019 14:39:51 -0400 Received: by mail-lj1-f193.google.com with SMTP id l7so2886764ljg.6 for ; Fri, 22 Mar 2019 11:39:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=vSYM/lE/KT01QaZoImFD4qe2O3y+6F5gGaiZ9Y7krzg=; b=j30RP5CJiEC9HQuoBvVR7YhB1WTHVLaZW2cXcLIdivbsjOCbtxAukzY0FXuleFTqIX Dykbi1SdnIJoAobJCMqDkEx9Lsdxym9Hdgo8dgOg4BGJECeKQm/xSCpBDGl4pBm+Cs+8 D+PUtlrzPzZWRj5W5G85nCHbXkbK/Y1ZCEVO4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=vSYM/lE/KT01QaZoImFD4qe2O3y+6F5gGaiZ9Y7krzg=; b=UQ/5tR7azqjiZbNxYteYyo7bri+kVddYFt9MgMi9IZAjZvRu0BBXV3JN5Yo7AE6bWb dmqgPXffv8oMR621VrMwJL5oFFzLxNqyIh59eENPB66AyS9SsazIZ9r4nUFHU7OZ50gO TSOaAuzsvJI0M1xf+96w7AapagkLGYwUXzdmzBg1Nt+HmcPb07qhZa2HITpbLnznpzSw PIy9Mvgo6F9fx7/Cm1a+YsEYJkgrt5meHxyrvQ4NzbxAC9LjilvicF31YpZaQzQfb5WQ ZMTtnToG9Uzn+wFabpcc31wAOnaCwfT7MSjVTdy8OxTA8y4Nb/gAYkDVPakergf1DYkP padg== X-Gm-Message-State: APjAAAUe2mNUuc3Cd9cxcFVh9DVKrLlAO9qa8CAzpMTtZPzC+hKJdEkx WsDHN8csXft0P7hSDPA8bG7p7mSMLXY= X-Received: by 2002:a2e:9597:: with SMTP id w23mr1034537ljh.111.1553279988340; Fri, 22 Mar 2019 11:39:48 -0700 (PDT) Received: from mail-lf1-f51.google.com (mail-lf1-f51.google.com. [209.85.167.51]) by smtp.gmail.com with ESMTPSA id x76sm1828435ljb.17.2019.03.22.11.39.47 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Mar 2019 11:39:47 -0700 (PDT) Received: by mail-lf1-f51.google.com with SMTP id v14so2154150lfi.0 for ; Fri, 22 Mar 2019 11:39:47 -0700 (PDT) X-Received: by 2002:a19:7105:: with SMTP id m5mr5971597lfc.154.1553279987372; Fri, 22 Mar 2019 11:39:47 -0700 (PDT) MIME-Version: 1.0 References: <20190320212030.43682-1-evgreen@chromium.org> <20190320212030.43682-3-evgreen@chromium.org> In-Reply-To: From: Evan Green Date: Fri, 22 Mar 2019 11:39:10 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/2] platform/chrome: Add support for v1 of host sleep event To: Guenter Roeck Cc: Benson Leung , Enric Balletbo i Serra , Furquan Shaikh , Rajat Jain , linux-kernel , Guenter Roeck , Lee Jones Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Mar 21, 2019 at 8:15 AM Guenter Roeck wrote: > > On Wed, Mar 20, 2019 at 2:21 PM Evan Green wrote: > > > > Add support in code for the new forms of the host sleep event. > > Detects the presence of this version of the command at runtime, > > and use whichever form the EC supports. At this time, always > > request the default timeout, and only report the failing response > > via a WARN(). Future versions could accept the sleep parameter > > from outside the driver, and return the response information to > > usermode or elsewhere. > > > > Signed-off-by: Evan Green > > > > --- > > > > drivers/mfd/cros_ec.c | 37 +++++++++++++++++++++---- > > drivers/platform/chrome/cros_ec_proto.c | 9 ++++++ > > include/linux/mfd/cros_ec.h | 2 ++ > > 3 files changed, 43 insertions(+), 5 deletions(-) > > > > diff --git a/drivers/mfd/cros_ec.c b/drivers/mfd/cros_ec.c > > index 6acfe036d522..5305ea706aa9 100644 > > --- a/drivers/mfd/cros_ec.c > > +++ b/drivers/mfd/cros_ec.c > > @@ -75,20 +75,47 @@ static irqreturn_t ec_irq_thread(int irq, void *data) > > > > static int cros_ec_sleep_event(struct cros_ec_device *ec_dev, u8 sleep_event) > > { > > + int ret; > > struct { > > struct cros_ec_command msg; > > - struct ec_params_host_sleep_event req; > > + union { > > + struct ec_params_host_sleep_event req0; > > + struct ec_params_host_sleep_event_v1 req1; > > + struct ec_response_host_sleep_event_v1 resp1; > > + } u; > > } __packed buf; > > > > memset(&buf, 0, sizeof(buf)); > > > > - buf.req.sleep_event = sleep_event; > > + if (ec_dev->host_sleep_v1) { > > + buf.u.req1.sleep_event = sleep_event; > > + buf.u.req1.u.suspend_params.sleep_timeout_ms = > > + EC_HOST_SLEEP_TIMEOUT_DEFAULT; > > + > > + buf.msg.outsize = sizeof(buf.u.req1); > > + buf.msg.insize = sizeof(buf.u.resp1); > > + buf.msg.version = 1; > > + > > + } else { > > + buf.u.req0.sleep_event = sleep_event; > > + buf.msg.outsize = sizeof(buf.u.req0); > > + buf.msg.version = 0; > > Unnecessary assignment (already 0). Ok. > > + } > > > > buf.msg.command = EC_CMD_HOST_SLEEP_EVENT; > > - buf.msg.version = 0; > > - buf.msg.outsize = sizeof(buf.req); > > > > - return cros_ec_cmd_xfer(ec_dev, &buf.msg); > > + ret = cros_ec_cmd_xfer(ec_dev, &buf.msg); > > + > > + /* For now, report failure to transition to S0ix with a warning. */ > > + if (ret >= 0 && ec_dev->host_sleep_v1 && > > + (sleep_event == HOST_SLEEP_EVENT_S0IX_RESUME)) > > + WARN(buf.u.resp1.u.resume_response.sleep_transitions & > > Is WARN really appropriate here, or would dev_warn() do ? I think we want to be pretty loud here. This represents a failure to enter suspend as detected by the EC. > > > + EC_HOST_RESUME_SLEEP_TIMEOUT, > > + "EC detected sleep transition timeout. Total slp_s0 transitions: %d", > > + buf.u.resp1.u.resume_response.sleep_transitions & > > + EC_HOST_RESUME_SLEEP_TRANSITIONS_MASK); > > + > > + return ret; > > } > > > > int cros_ec_register(struct cros_ec_device *ec_dev) > > diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platform/chrome/cros_ec_proto.c > > index 97a068dff192..78ceab659a36 100644 > > --- a/drivers/platform/chrome/cros_ec_proto.c > > +++ b/drivers/platform/chrome/cros_ec_proto.c > > @@ -414,6 +414,15 @@ int cros_ec_query_all(struct cros_ec_device *ec_dev) > > else > > ec_dev->mkbp_event_supported = 1; > > > > + /* Probe if host sleep v1 is supported for S0ix failure detection. */ > > + ret = cros_ec_get_host_command_version_mask(ec_dev, > > + EC_CMD_HOST_SLEEP_EVENT, > > + &ver_mask); > > + if (ret < 0 || !(ver_mask & EC_VER_MASK(1))) > > + ec_dev->host_sleep_v1 = 0; > > + else > > + ec_dev->host_sleep_v1 = 1; > > This is a boolean. > ec_dev->host_sleep_v1 = (ret >= 0 && (ver_mask & EC_VER_MASK(1))); Ok.