Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp104381ybm; Tue, 26 May 2020 11:54:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwR3hbRLjtVqp+IkUvu2F0nUFEZtv6e/LqgrugCFjaCh35Nbc/9FuAbur06wUGnHyy4HMdx X-Received: by 2002:a17:906:94d5:: with SMTP id d21mr2298914ejy.342.1590519251830; Tue, 26 May 2020 11:54:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590519251; cv=none; d=google.com; s=arc-20160816; b=O1GRNqBdDWWIeASpqKB3uEPeAPeOTx22hBOrOxs2lTjalPhcF4ujLHMDNnUhH5b4iB bIcBNOaU/zLfUQZf+zqp/jHNslRw+hXSuOq5ftessGCEVtkrooamV/oEYBKNc8aLFwEw nOWXUPgCPsKX0r9SLC5T6vv2RWJIVE5+QCot42VBmuyd3IWSiPBXJ5Dsz53Aw2siF0Bd eOKPFoeEos4GT2igE4lEmLse3CJIbL5NMmVeQW87B+MysP7ThDEPxXd/b4PgvNSRNsiY uPJ0WxDOEmzP8D/ejO8SPaRF2A2bcAoiFVjdVM6Kf79nsp8JMQxQ4YcBM5seYoFVi7tH pv9w== 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=1Rp4xUS5EnFClzPQU/icIoCaObz0RQ1rswzJUiz+J1Y=; b=IAbQzxuTZ1bzOXhCuJ8rNV2tHDSwMpJt8PMsB4sm7AQpRtE6SqW122NBcfIZ82/Wuh o4l2WIjJD8aA5aYs5Fmp7BJX2hViuP9YkrS1A4cNen7PsBC1QjFNv4yPyiY+0JAXdYnJ BPd3BS/+GNKeJIs5LeFbSdO8gn0UjIEVg44mUKuNd9WyUDXPBNVbgsUo7GJjfh2M/Jku 0gIosp+fGTdshmqv+k0eimwQecb/bJwr7k4XkiVl4VJQvyKYhR3xr4cBDR/oPa9qluN3 b6XG1fjBdtWkdt9zf10O29tjuw9OpxopUiw0yjH6+mGMSqHOPEeYLdusvHQ9MTc7EJoh HVwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=I16pik1U; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id u27si390771edb.377.2020.05.26.11.53.48; Tue, 26 May 2020 11:54:11 -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=@chromium.org header.s=google header.b=I16pik1U; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389015AbgEZSuA (ORCPT + 99 others); Tue, 26 May 2020 14:50:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388499AbgEZSuA (ORCPT ); Tue, 26 May 2020 14:50:00 -0400 Received: from mail-io1-xd42.google.com (mail-io1-xd42.google.com [IPv6:2607:f8b0:4864:20::d42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38FCAC03E96D for ; Tue, 26 May 2020 11:50:00 -0700 (PDT) Received: by mail-io1-xd42.google.com with SMTP id y5so394023iob.12 for ; Tue, 26 May 2020 11:50:00 -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=1Rp4xUS5EnFClzPQU/icIoCaObz0RQ1rswzJUiz+J1Y=; b=I16pik1UbGr3xSB2i671ggj6Kbtdvzlr6yyHptVNN6aJaICT/Pe2GMVrHJAO1yd75H B4IgdCJyLXDoxFQ28zQbJS9fiQU742HXjdeawwsU/G9h3N5h+FZDGPeFdj6uqnbLrRYl BwDYak/5EoP5slDNTN7Z6ATQDGUnZvC6SS4gE= 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=1Rp4xUS5EnFClzPQU/icIoCaObz0RQ1rswzJUiz+J1Y=; b=B5ogFe99ioRBrS6E+4z1n0w/w05qz5s+I3bVkLCXRW4/OKp1OuaB1Ve6rq2AiWTJ/V onxOSw5cIEaKep4SpUcbNWUGIUM/TMaiDsIbieo0g07bd+5iu87UzkLdW3HAq/aB5anj ux/+RM+HIbsOW63rEQbHkHuyDTNvfs46xnqtPEWtwPc9CO8K+Aq1HfvkSpi+QjKn5U2j pqo2Tg5KlHX8m1D9upTgJtl5rkB8fHizdXY/u5LYYHAXnj4g0YJD6405omF5OQ4wBxjz wekosMfp9YBk4wk1hksc0FRlwFe/PbMNoLBD5x4jT2skM0F7203vzQmMkb9dlR8PN36s cFGA== X-Gm-Message-State: AOAM530C/YGQkP4gEM1+WeS/41DwwyB+kVeQBAbVnfp3Z9qE+1NHb3Rj gKZ4H5Mq6P/hf5eZFWIIAULMtOInJUyXQQ5/wltlbbM/wsk= X-Received: by 2002:a02:6d0a:: with SMTP id m10mr2285354jac.133.1590518999430; Tue, 26 May 2020 11:49:59 -0700 (PDT) MIME-Version: 1.0 References: <20200521052832.66620-1-gwendal@chromium.org> In-Reply-To: From: Gwendal Grignou Date: Tue, 26 May 2020 11:49:48 -0700 Message-ID: Subject: Re: [PATCH] platform: cros_ec_debugfs: control uptime information request To: Enric Balletbo i Serra Cc: Guenter Roeck , Benson Leung , Tim Wawrzynczak , linux-kernel 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, May 21, 2020 at 2:21 AM Enric Balletbo i Serra wrote: > > Hi Gwendal, > > Thank you for your patch. > > On 21/5/20 7:28, Gwendal Grignou wrote: > > When EC does not support uptime command (EC_CMD_GET_UPTIME_INFO), > > return -EPROTO to read of /sys/kernel/debug/cros_ec/uptime without > > calling the EC after the first try. > > > > The EC console log will not contain EC_CMD_GET_UPTIME_INFO anymore. > > > > Oh, what you mean with this? Uptime is only exposed via sysfs or I am missing > something. I was checking the ec console log (via /sys/kernel/debug/cros_ec/console_log) to check the EC was not receiving and erroring on the command (pixelbook) > > > Signed-off-by: Gwendal Grignou > > --- > > drivers/platform/chrome/cros_ec_debugfs.c | 12 ++++++++++++ > > 1 file changed, 12 insertions(+) > > > > diff --git a/drivers/platform/chrome/cros_ec_debugfs.c b/drivers/platform/chrome/cros_ec_debugfs.c > > index 6ae484989d1f5..70a29afb6d9e7 100644 > > --- a/drivers/platform/chrome/cros_ec_debugfs.c > > +++ b/drivers/platform/chrome/cros_ec_debugfs.c > > @@ -49,6 +49,8 @@ struct cros_ec_debugfs { > > struct delayed_work log_poll_work; > > /* EC panicinfo */ > > struct debugfs_blob_wrapper panicinfo_blob; > > + /* EC uptime */ > > + bool uptime_supported; > > Ideally, if uptime can be supported or not we should only expose uptime when is > supported, so the sysfs entry should only be created when is supported, similar > to what we do with the console_log. See cros_ec_create_console_log() > > If doing this doesn't break userspace, I'd prefer doing in that way. Good point, sending a v2. Gwendal. > > Thanks, > Enric > > > > }; > > > > /* > > @@ -256,12 +258,19 @@ static ssize_t cros_ec_uptime_read(struct file *file, char __user *user_buf, > > char read_buf[32]; > > int ret; > > > > + if (!debug_info->uptime_supported) > > + return -EPROTO; > > + > > resp = (struct ec_response_uptime_info *)&msg.resp; > > > > msg.cmd.command = EC_CMD_GET_UPTIME_INFO; > > msg.cmd.insize = sizeof(*resp); > > > > ret = cros_ec_cmd_xfer_status(ec_dev, &msg.cmd); > > + if (ret == -EPROTO && msg.cmd.result == EC_RES_INVALID_COMMAND) { > > + debug_info->uptime_supported = false; > > + return ret; > > + } > > if (ret < 0) > > return ret; > > > > @@ -434,6 +443,9 @@ static int cros_ec_debugfs_probe(struct platform_device *pd) > > debug_info->ec = ec; > > debug_info->dir = debugfs_create_dir(name, NULL); > > > > + /* Give uptime a chance to run. */ > > + debug_info->uptime_supported = true; > > + > > ret = cros_ec_create_panicinfo(debug_info); > > if (ret) > > goto remove_debugfs; > >