Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2218738ybt; Fri, 3 Jul 2020 03:59:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyt4xlXTNt1j8cexjvnUrH6EdTot7jeXk4ai6ee2o8RAY09Ux3HxrVnAkyDOfqfYnv/wV5y X-Received: by 2002:a17:906:b0d:: with SMTP id u13mr29808198ejg.342.1593773976970; Fri, 03 Jul 2020 03:59:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1593773976; cv=none; d=google.com; s=arc-20160816; b=BJ4DYjHjSjJCGnGGet35RB8onSPw1V2YTHUV07w6XgNthSinhQ5ccL6ybQ0xxtnGkV YOQL/GtudDQFlncFqV8Ax/EEzpKUVdYeYLM6vvS8SznfEjla+LKF1f/vhwaTsQTlq5zV wpmfMYM12uAdJf311acAVih0bDj1wl//5t9N/K///YKw2fWFBkI7o0xzRk84Y3MiWndI FqdyavnfslWkyW9uirwbf498qTY7Apre35x9rwER8BkYdNW7qx2+PXUKNwXB901SohLt kj5pbnzp5xUjEoF7uuO7oPowBeMk2b9ZScmqRSpfy4lBokwOTablvjNAikhtlRQlYdEz yzDA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=Mu+cjVYU2VEx59jkUsdJOekwQ4Jbxidq9UXtGE/k/oI=; b=NoeHI+mm+EXUWEH1SsX1CcrxrQSpzp1xZz3fJBx0TXkrUffwsm1jErGoz+qIu1rPKC c01rl2LMqjlcEsjVgfPVbP88uIj8ao0WTtYIiQZyNVw/He4+CwdhJ0lKonm/B9jHaK1L Di7mP5yiyTs0rHW4ni0Gyqwfa5aUj+KP4REB7Afo+5vfzPUDOjXFMFEIjilJBsGIWYD4 9EzyFwG7oQ61klKzDT3NJUTXXR8jtQ+ftwAN9SHQVTQlckZ2rkw27eexAr5rZbwCOcGD qxLcFik57EOQtc7QwHd+GB+7gK0+JgIW6/mMI8Vsk2TSGywcMDI9Rhc1BUBHAOR4VEJa 24kQ== ARC-Authentication-Results: i=1; mx.google.com; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l18si8523182edv.490.2020.07.03.03.59.13; Fri, 03 Jul 2020 03:59:36 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=collabora.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726152AbgGCK4n (ORCPT + 99 others); Fri, 3 Jul 2020 06:56:43 -0400 Received: from bhuna.collabora.co.uk ([46.235.227.227]:42538 "EHLO bhuna.collabora.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725915AbgGCK4m (ORCPT ); Fri, 3 Jul 2020 06:56:42 -0400 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: eballetbo) with ESMTPSA id 0C42F2A63F4 Subject: Re: [PATCH v2] ASoC: cros_ec_codec: Log results when EC commands fail To: Yu-Hsuan Hsu Cc: ALSA development , Takashi Iwai , Liam Girdwood , Linux Kernel Mailing List , Tzung-Bi Shih , Mark Brown , Guenter Roeck , Benson Leung , Cheng-Yi Chiang References: <20200703071913.2358882-1-yuhsuan@chromium.org> <8d21fc0c-b43e-75a0-d5d4-ed4872ec92cb@collabora.com> From: Enric Balletbo i Serra Message-ID: Date: Fri, 3 Jul 2020 12:56:37 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yu-Hsuan, On 3/7/20 11:40, Yu-Hsuan Hsu wrote: > Enric Balletbo i Serra 於 2020年7月3日 週五 下午5:19寫道: >> >> Hi Yu-Hsuan, >> >> On 3/7/20 10:48, Yu-Hsuan Hsu wrote: >>> Enric Balletbo i Serra 於 2020年7月3日 週五 下午4:38寫道: >>>> >>>> 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 result >>>>> 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. You 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 = 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 trace >> 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. And, aren't you able to reproduce the issue? > 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. If I am not mistaken this ends calling i2s_rx_set_daifmt() into the EC firmware, if the result is -EPROTO that means is not returning EC_RES_SUCCESS, so there are few options: if (i2s_rx_enabled) return EC_RES_BUSY; if (daifmt >= EC_CODEC_I2S_RX_DAIFMT_COUNT) return EC_RES_INVALID_PARAM; if (audio_codec_i2s_rx_set_daifmt(daifmt) != EC_SUCCESS) return EC_RES_ERROR; > 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). > Are you sure that when you know the error code you'll find the root cause (without adding more prints)? There is only three possibilities? You can't start adding prints just to debug a user issue because you don't allow to be more verbose. I understand that might help you but is not the way to go. You should really reproduce the issue yourself an use actual debug tools/prints./traces. Cheers, Enric > 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 == -EPROTO) >>> dev_err(..., msg->result) >>> goto error; >>> } >>> I'm not sure whether it makes sense to check ret == -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_device *ec_dev, uint32_t cmd, >>>>> if (outsize) >>>>> memcpy(msg->data, out, outsize); >>>>> >>>>> - ret = cros_ec_cmd_xfer_status(ec_dev, msg); >>>>> + ret = cros_ec_cmd_xfer(ec_dev, msg); >>>>> if (ret < 0) >>>>> goto error; >>>>> >>>>> + if (msg->result != EC_RES_SUCCESS) { >>>>> + dev_err(ec_dev->dev, "Command %d failed: %d\n", cmd, >>>>> + msg->result); >>>>> + ret = -EPROTO; >>>>> + goto error; >>>>> + } >>>>> + >>>>> if (insize) >>>>> memcpy(in, msg->data, insize); >>>>> >>>>>