Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2172976ybt; Fri, 3 Jul 2020 02:42:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw6mIL3Kxsi1ainMe7v2dkU58vKnjVpvxJGc+phV0EA02mDkl9oWoUPtk4h0Tv3cOvDZkvQ X-Received: by 2002:a17:906:1357:: with SMTP id x23mr33147241ejb.148.1593769360230; Fri, 03 Jul 2020 02:42:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593769360; cv=none; d=google.com; s=arc-20160816; b=CnqAq+EauKcrsq5TXY0MH3FzWJBRZr8KFgsovSs5X/WvKts4mdBBS8wByBSxVcXnJc xXBicPHColSzNDIjs9NEWc9RKOUmRr83mWIBsg/TvKfMAYJEVtSBXHAuQY6Jm9wyzENO YHXf+H9EAD29EmeKUWpJuY74R0rQW3WzjQqBxy9fq80ILm+UN4vzGlhavMWYZtPgB8jd 7V0DyLHtCSzsbOEDWrjUBx3AhSAXdLToDJdjJXgAYPz6jrLk5owPBbSXADN23yb46Uo2 lVXxDC4cHoleV8k10gbNYJTFQD7RV7ATA7qSrKzEId+gis9hDk9zo51N+NX2bf8iWY9i XGWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=DdinKhU6Vgfi2yzkEzkWpZ1cEblZoAeY2Qj+FjvvzvE=; b=HoGYlfGt5VlTzZClv7CI8aEbTWzDE5i/83ws/sNj8ho9HalBaPSAoT9G+CUYv1lNbm 5M/zBpGCosUbZr2DdgweLPoGL9E9PMROnEm3KAATPSUBdW3+bq0Iw4Un/dKVM/lD+laL uqy8ir+i4VmeNumegkuvRkeRyl6MKaxl692ucWSzf9tK3zJVVlGS8DrMLKbZZOnZGeGG ks9K5VUqO9bgokqal5gq7vCh1Rai+UV7Qx63NeDhQp59GwJkc96KC6eQrOhtqU2OT4r6 sOEoH2NNcQFDdPoDk0v43XPeIZuwx6SHEPkrM6B/9N4EbgfpFCD1A272RkyBHyLxAVW+ jQ1g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=aCP0cShj; 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 r6si2764450ejd.213.2020.07.03.02.42.17; Fri, 03 Jul 2020 02:42:40 -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=aCP0cShj; 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 S1726148AbgGCJkz (ORCPT + 99 others); Fri, 3 Jul 2020 05:40:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725786AbgGCJky (ORCPT ); Fri, 3 Jul 2020 05:40:54 -0400 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C5EAC08C5C1 for ; Fri, 3 Jul 2020 02:40:54 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id j18so31419686wmi.3 for ; Fri, 03 Jul 2020 02:40:54 -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:content-transfer-encoding; bh=DdinKhU6Vgfi2yzkEzkWpZ1cEblZoAeY2Qj+FjvvzvE=; b=aCP0cShjbrykQvr0g1Vb+DEj00lwAxg0T78dsiIDjyKDfQDVu3sax35VsD+5BopxBx Xk1fdV5P6jRSIY3aeIF3Auv39STfQHSfFib4ytai0iieU4CPbdF4Idi+KfDPU565e6/t JK60Gs6fQ2v3r7hZrbrjVy3+FWxGjTx1n1jQ0= 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:content-transfer-encoding; bh=DdinKhU6Vgfi2yzkEzkWpZ1cEblZoAeY2Qj+FjvvzvE=; b=FS2w5ceQqMCaAUKpb6bbdGcIhiRU12P4gvsqGFaETMqG+Nl3FkFhxQDsFJ9fKibuVE YSpalWACtcjNTpbjZFpzhwEt0IYNdd1CMCTNLIa3n2xUuqnypTzVaGArsGEUK2J9v2wl kLYwV4ztB1rSORNV+/BkwDZfniv2qWW7AQs0mqalH7ye8Q2HJerPt4xopEvxYIEk6Qs0 xwWRYzud7C3xtTu4gXkzYfyUkklNhPUIEYTYMI/uGdT4squ4nFGzeWvrRoCqZO+o8duY 0s0GUXAK34cam30YIHiDcnfm0+PX15X6AmPsvbscg74+bTtcNVbbr54Pk7EqwXvfXTBa 6o9g== X-Gm-Message-State: AOAM532xrgiTnfYSRkAXujJxuLGYBzm4Yy0UHVeiSCOUbWiQdmQth7aF 2TrmCi0jszTym6xtG3Sy87GN21jt9bo4Q82DTONMbg== X-Received: by 2002:a1c:bb43:: with SMTP id l64mr36903087wmf.151.1593769253122; Fri, 03 Jul 2020 02:40:53 -0700 (PDT) MIME-Version: 1.0 References: <20200703071913.2358882-1-yuhsuan@chromium.org> <8d21fc0c-b43e-75a0-d5d4-ed4872ec92cb@collabora.com> In-Reply-To: From: Yu-Hsuan Hsu Date: Fri, 3 Jul 2020 17:40:42 +0800 Message-ID: Subject: Re: [PATCH v2] ASoC: cros_ec_codec: Log results when EC commands fail To: Enric Balletbo i Serra Cc: ALSA development , Takashi Iwai , Liam Girdwood , Linux Kernel Mailing List , Tzung-Bi Shih , Mark Brown , Guenter Roeck , Benson Leung , Cheng-Yi Chiang Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Enric Balletbo i Serra =E6=96=BC 2020=E5=B9= =B47=E6=9C=883=E6=97=A5 =E9=80=B1=E4=BA=94 =E4=B8=8B=E5=8D=885:19=E5=AF=AB= =E9=81=93=EF=BC=9A > > Hi Yu-Hsuan, > > On 3/7/20 10:48, Yu-Hsuan Hsu wrote: > > Enric Balletbo i Serra =E6=96=BC 2020=E5= =B9=B47=E6=9C=883=E6=97=A5 =E9=80=B1=E4=BA=94 =E4=B8=8B=E5=8D=884:38=E5=AF= =AB=E9=81=93=EF=BC=9A > >> > >> Hi Yu-Hsuan, > >> > >> Thank you for your patch > >> > >> On 3/7/20 9:19, Yu-Hsuan Hsu wrote: > >>> Log results of failed EC commands to identify a problem more easily. > >>> > >>> Replace cros_ec_cmd_xfer_status with cros_ec_cmd_xfer because the res= ult > >>> has already been checked in this function. The wrapper is not needed. > >>> > >> > >> Nack, we did an effort to remove all public users of cros_ec_cmd_xfer(= ) in > >> favour of cros_ec_cmd_xfer_status() and you are reintroducing again. Y= ou can do > >> the same but using cros_ec_cmd_xfer_status(). In fact, your patch will= not build > >> on top of the upcoming changes. > > Thanks! But I have a question about implementing it. Does it look like > > the one below? > > ret =3D cros_ec_cmd_xfer_status(ec_dev, msg); > > if (ret < 0) { > > In this case will already print an error. > > What are you trying to achieve? > > If the only reason is of this patch is print a message you should either,= or > enable dynamic printk and enable dev_dbg or event better use the kernel t= race > functionality. There is no need to be more verbose. > > Example: > $ echo 1 > /sys/kernel/debug/tracing/events/cros_ec/enable > $ cat /sys/kernel/debug/tracing/trace > > 369.416372: cros_ec_request_start: version: 0, command: EC_CMD_USB_PD= _POWER_INFO > 369.420528: cros_ec_request_done: version: 0, command: > EC_CMD_USB_PD_POWER_INFO, ec result: EC_RES_SUCCESS, retval: 16 > > Cheers, > Enric > Thank Enric, The situation is that some users encountered errors on ChromeBook. From their feedback reports, we only get the message like 'cros-ec-codec GOOG0013:00: ASoC: Failed to set DAI format: -71'. We know that -71 is -EPROTO but it is not clear enough for us to find out the root cause. That's why we want the detail of the result. Because the situation happens on users' side, it is not possible for them to enable kernel trace (ChromeOS does not allow users to touch kernel). The other way we thought is changing dev_dbg to dev_err in cros_ec_cmd_xfer_status. But we are not sure whether it is also an error for other usages. > > if (ret =3D=3D -EPROTO) > > dev_err(..., msg->result) > > goto error; > > } > > I'm not sure whether it makes sense to check ret =3D=3D -EPROTO here. > > > >> > >>> Signed-off-by: Yu-Hsuan Hsu > >>> --- > >>> sound/soc/codecs/cros_ec_codec.c | 9 ++++++++- > >>> 1 file changed, 8 insertions(+), 1 deletion(-) > >>> > >>> diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros= _ec_codec.c > >>> index 8d45c628e988e..a4ab62f59efa6 100644 > >>> --- a/sound/soc/codecs/cros_ec_codec.c > >>> +++ b/sound/soc/codecs/cros_ec_codec.c > >>> @@ -90,10 +90,17 @@ static int send_ec_host_command(struct cros_ec_de= vice *ec_dev, uint32_t cmd, > >>> if (outsize) > >>> memcpy(msg->data, out, outsize); > >>> > >>> - ret =3D cros_ec_cmd_xfer_status(ec_dev, msg); > >>> + ret =3D cros_ec_cmd_xfer(ec_dev, msg); > >>> if (ret < 0) > >>> goto error; > >>> > >>> + if (msg->result !=3D EC_RES_SUCCESS) { > >>> + dev_err(ec_dev->dev, "Command %d failed: %d\n", cmd, > >>> + msg->result); > >>> + ret =3D -EPROTO; > >>> + goto error; > >>> + } > >>> + > >>> if (insize) > >>> memcpy(in, msg->data, insize); > >>> > >>>