Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp691334ybt; Wed, 8 Jul 2020 09:18:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyY2exdC044Xdva4Xtb4QiRCcEyf8YL1nhTxz5LqPS5LNjEeowrL31f1TGhfRM5jzWO8uVR X-Received: by 2002:a17:906:3acd:: with SMTP id z13mr35286637ejd.69.1594225103885; Wed, 08 Jul 2020 09:18:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1594225103; cv=none; d=google.com; s=arc-20160816; b=F/p9RpaURoBb2j4N8ZKAa82QgZ11t5FhouULnVHyRJT6ao/e1G5XqlrTfoFR951Qi4 xDouqj5eTqc69j5NMyVLRx7Obq++CnPm5BcECGAm+e8uYA27FCrw5RAUi01SeM4P3ReH 7QGDe4NOUmyxaFK7MT56EqmbLdYAtYv1lmsw1i0Ml8Ldeh5jMlwkXTw2uWBjfJI2Dx69 PQlKid7es5ZVQFQdiBFi53HH7HIM9x2+jFY6A7vyA2I6927vSOS7wEnTmVBtoErPcl22 QnopyKR42HThhWYfnQFVr6mVkngzFReMNfDKRZpgQiVWbB1e83kPpdVthfjHbVMn3p0I 6zvg== 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=5kAcxP8yp944C33ROLXVPNzrfs8jnGeNlhJxbTbvZzg=; b=NkxNHU1FPgBhtr1RFM6lxHsLD7vlvEE8gkbHwMHhMGtpucxCO3aJKPOMBWs32thwtC 9o95abfTZboxTuYsqVe5h266VuWUMOdTWVsSMU/b9TwUBh9LwZr0cPj/10Er9WvGIPny /S2V4dC/sy61fQkBYOtg6S0wCucAxYxUHFci0kA4BZiejr/95V7dyI+BwxLWHi+Y6T2d /cRP96H6bK7vl9Pnw5s1KMK1RuIQgRnvoLTO12rrdt1kp0sF5Rzm4gqSTNo9fQ2Cg3bM VUKoUiUjlL0FgpHvpGdpV8A+uoAnY8M9HcoSsE1vCWmnOr2tU4M0sr9+lKSFrUYAxInN MwzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=iia7mGZt; 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 ha20si157599ejb.683.2020.07.08.09.18.00; Wed, 08 Jul 2020 09:18:23 -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=iia7mGZt; 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 S1730349AbgGHQRV (ORCPT + 99 others); Wed, 8 Jul 2020 12:17:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730302AbgGHQRU (ORCPT ); Wed, 8 Jul 2020 12:17:20 -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 3C64BC061A0B for ; Wed, 8 Jul 2020 09:17:20 -0700 (PDT) Received: by mail-wm1-x343.google.com with SMTP id l2so3859422wmf.0 for ; Wed, 08 Jul 2020 09:17:20 -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=5kAcxP8yp944C33ROLXVPNzrfs8jnGeNlhJxbTbvZzg=; b=iia7mGZtpCQgy3YOdSOK6NvhZ9DV6sfk80EaAKaVG0F7rSN//EzGF6YidC4viD2yjE vI0mdKXKht4KbaakdleqqsPz/hS2gZSsGgDVnh/cvbATz0aI2VTNG78Gs7H5UbxJtXqG 3MF9+QrQHlQNccapi8P93wGOJT2bpczaay6MI= 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=5kAcxP8yp944C33ROLXVPNzrfs8jnGeNlhJxbTbvZzg=; b=ZmA2YOoxpEjVWTfrbv8eNgWcB6KqWM8vNgD8gm8Nrdo7AhyJLQE1jT/OOMuaBRKpUl 3H547IZvF8lxPg0SWeVJsQbZV6I9yo8NUWZnc9CFg8mDmsUnxR8k5CCJ9Us73CLzqYOw OdPwJCYa8VddO3g/EKM3sVdmK9AxdD2kDT5tG8d785h1Yh3oMyqOhYpmoH4S5gk2+KAQ 8MeXacLzkLEqMmRLkgtILbuh7X9lyYkfErlDUVJLh162uy55BT33Iy0hoMl7fkmaP5BJ yDMcegcac2oV+mxpXk0E249yvyS/fe5Mr2m1Knz8iOmSDlC3FFUwDSsF/PSoOGjdq6/G ft7Q== X-Gm-Message-State: AOAM531C1+J8OPChWCHbwHeX2Tmhakj3nsw7UCugyt98z+GxWRHUo197 DkpTfjzYJdp0DeYkKhojkgmW3AeowtNb1filzftBww== X-Received: by 2002:a1c:e088:: with SMTP id x130mr9669890wmg.14.1594225038874; Wed, 08 Jul 2020 09:17:18 -0700 (PDT) MIME-Version: 1.0 References: <20200708071117.3070707-1-yuhsuan@chromium.org> In-Reply-To: From: Yu-Hsuan Hsu Date: Thu, 9 Jul 2020 00:17:07 +0800 Message-ID: Subject: Re: [PATCH] ASoC: cros_ec_codec: Reset I2S RX when probing To: Guenter Roeck Cc: Enric Balletbo i Serra , linux-kernel , Benson Leung , Guenter Roeck , Cheng-Yi Chiang , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Tzung-Bi Shih , Gwendal Grignou , Lee Jones , Yicheng Li , ALSA development 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 Guenter Roeck =E6=96=BC 2020=E5=B9=B47=E6=9C=888=E6=97= =A5 =E9=80=B1=E4=B8=89 =E4=B8=8B=E5=8D=889:28=E5=AF=AB=E9=81=93=EF=BC=9A > > On Wed, Jul 8, 2020 at 3:16 AM Enric Balletbo i Serra > wrote: > > > > Hi Yu-Hsuan, > > > > Thank you for your patch. > > > > On 8/7/20 9:11, Yu-Hsuan Hsu wrote: > > > It is not guaranteed that I2S RX is disabled when the kernel booting. > > > For example, if the kernel crashes while it is enabled, it will keep > > > enabled until the next time EC reboots. Reset I2S RX when probing to > > > fix this issue. > > > > > > Signed-off-by: Yu-Hsuan Hsu > > > --- > > > include/linux/platform_data/cros_ec_commands.h | 1 + > > > sound/soc/codecs/cros_ec_codec.c | 7 +++++++ > > > 2 files changed, 8 insertions(+) > > > > > > diff --git a/include/linux/platform_data/cros_ec_commands.h b/include= /linux/platform_data/cros_ec_commands.h > > > index 69210881ebac8..11ce917ca924c 100644 > > > --- a/include/linux/platform_data/cros_ec_commands.h > > > +++ b/include/linux/platform_data/cros_ec_commands.h > > > @@ -4598,6 +4598,7 @@ enum ec_codec_i2s_rx_subcmd { > > > EC_CODEC_I2S_RX_SET_SAMPLE_DEPTH =3D 0x2, > > > EC_CODEC_I2S_RX_SET_DAIFMT =3D 0x3, > > > EC_CODEC_I2S_RX_SET_BCLK =3D 0x4, > > > + EC_CODEC_I2S_RX_RESET =3D 0x5, > > > > Is this a new command not available in the firmware that is already in = the field? > > > > > > > EC_CODEC_I2S_RX_SUBCMD_COUNT, > > > }; > > > > > > diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cros= _ec_codec.c > > > index 8d45c628e988e..5495214e73e68 100644 > > > --- a/sound/soc/codecs/cros_ec_codec.c > > > +++ b/sound/soc/codecs/cros_ec_codec.c > > > @@ -1034,6 +1034,13 @@ static int cros_ec_codec_platform_probe(struct= platform_device *pdev) > > > } > > > priv->ec_capabilities =3D r.capabilities; > > > > > > + /* Reset EC codec I2S RX. */ > > > + p.cmd =3D EC_CODEC_I2S_RX_RESET; > > > + ret =3D send_ec_host_command(priv->ec_device, EC_CMD_EC_CODEC_I= 2S_RX, > > > + (uint8_t *)&p, sizeof(p), NULL, 0); > > > + if (ret) > > > + dev_err(dev, "failed to EC_CODEC_I2S_RESET: %d\n", ret)= ; > > > + > > > > With an old firmware I suspect this message will appear on every boot, = right? > > So, to solve the issue and get rid of this error you're forced to upgra= de the > > firmware. Is that true? > > > > It might possibly make more sense to fail this silently and to send > EC_CODEC_I2S_RX_DISABLE as backup if it is not supported (-ENOTSUPP > can possibly be used as trigger if the call returns it). > > Also, I don't accept dev_err() if the error is ignored for patches in > my scope of responsibility. > > Guenter Thanks for the suggestion. Our plan is to upstream this patch first. And then we will merge it into the kernel after the firmware is updated. Is it feasible? (I'm not sure whether there is the better way if I want to update EC and the kernel at the same time.) I think calling EC_CODEC_I2S_RX_DISABLE does not make sense because it checks the value of i2s_rx_enabled first. If i2s_rx_enabled is false, it will skip the function. However, we don't need to reset while the i2s_rx_enabled is already false. In addition, since it is a sub-command, it will return EC_RES_INVALID_PARAM but not ENOTSUPP if the command is not supported. And then EC_RES_INVALID_PARAM will turn into -EPROTO finally so it's difficult to do other operators basing on the return value. Thanks, Yu-Hsuan > > > > platform_set_drvdata(pdev, priv); > > > > > > ret =3D devm_snd_soc_register_component(dev, &i2s_rx_component_= driver, > > >