Received: by 2002:a25:e74b:0:0:0:0:0 with SMTP id e72csp2206977ybh; Fri, 17 Jul 2020 11:51:57 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz22O2vGyGMlOHo6JRfdsbeq/rOUzUir7lcLcN9/GWtxZedesE8tpv8LO7d+6KzAoY5fVxC X-Received: by 2002:a17:906:1697:: with SMTP id s23mr10434095ejd.166.1595011917745; Fri, 17 Jul 2020 11:51:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1595011917; cv=none; d=google.com; s=arc-20160816; b=zC4Xoo7eFyvPLmw1+YKNeCLvsvuSEsWSjv69Vh5wGUh+CvSbti16N8lBAw/DmiKDXd PRnj+Jn4hFqbaAXoyzRIG0k6yQ2QQt2Ti6kAQVbnao9s7Et7G/ySTs1cfj37k2lrAFtm PtOB0OLA7mX2Dodc/TGjZlQi0v+OUad7NgMJoH29LVh7+jzYd0o4GDCgcGLnPdz/NFFx mkeh9rF7pYidcbp8M6+1htvvf3p037LmbsbVq/GO9Lz2qNcyKuCcDlUrBGz55O7DnQZ/ 6QMf360t3WQZFMTVAD3mqzxCd5XG3bT2FpIuqvnYNuyjYR6b8log9yCrXG43tIRE1auy BOEg== 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=W0XV4dFr3RYjtEBiF3D3e3s9h66bEDl3lyG1fgXEHCs=; b=nVz2jkBLJheGXZlz8d9sXFe6qKkGDYUJME6++R/BjTSxAn9gXG/HLXHiZlXyhnD3PL FY8nARmBzQlppocjde+mjkxQZloozxke2/SomYtRHDle4cC+yQuIgo3ZsieGwIcCSOj1 TcjyrHkDZ25/9xoLIlEO4lryYoMe/MW+l49FHCHSVTrLweIml1Nl4VjL4LxncSDKLkD4 54CHKWPH3H2P5YZeF7ia4009tI6fyskfINNRJBO7Ej9QY1iM64L1VM5p4SXYwSK0uClw Wf729zGI3dkF/c0mrnagirbuZFkGxcztDNNovGveGrLmiJkYX5434r2/oCko5zW1j5IH k61w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=DuaNck28; 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 pw26si5898186ejb.240.2020.07.17.11.51.33; Fri, 17 Jul 2020 11:51:57 -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=DuaNck28; 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 S1727863AbgGQSvV (ORCPT + 99 others); Fri, 17 Jul 2020 14:51:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgGQSvV (ORCPT ); Fri, 17 Jul 2020 14:51:21 -0400 Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC1BFC0619D2 for ; Fri, 17 Jul 2020 11:51:20 -0700 (PDT) Received: by mail-wr1-x442.google.com with SMTP id f18so12209896wrs.0 for ; Fri, 17 Jul 2020 11:51: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=W0XV4dFr3RYjtEBiF3D3e3s9h66bEDl3lyG1fgXEHCs=; b=DuaNck28/9ga/FaLy4maDgdZnfSieEs3loiDk9AN98/zgCO6TlbSYre/tqEVJ5gMK6 0uj1OJc6MkSjrHnxMYjTbaQssOWldOVQoUzOVlAFoL5Zm82up8qvzMa5SfSs56sfQDIr SUvdpXthtVQAyjeBLF/C543xgCX8KH0Ij357o= 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=W0XV4dFr3RYjtEBiF3D3e3s9h66bEDl3lyG1fgXEHCs=; b=uC6rKLHr9IsoyhXSIiQQ1MQo/Qh3HTray8TQb1Wq+SmiB96r5Hvn3Q/6arF53gA6K5 uCS3cjE12qms5FuQ6jVAU5v1cdeADXO7kJSes9UhKarZZGALYSxdxcWrA+AM5vZxZLvL cOpzBErNpnB+gIOhETp0/lW470+bEuBLw0Rml+0KhCFBfuLkAuQvk0QRCmzim6FnUErL Qic8akGTMl6ymLckfgo4AgucGJ0hELlzRko9dNGh81+zmojZyU1JrDkdd/vGG90s6UuO SJmILiyLeeUsFwC0jzVll7uLPSv5kumAfpGIdRhUlPB6AUxtQEPcXpXaMC2CyREaQ6H4 gxsw== X-Gm-Message-State: AOAM530x0TCk/zFUvOR+frf8MiZguBScEm/h1OOkWBfdOl+YV3aYM51A AZep+73nfOba1wBih7sSec80OQSORdP/jh8s5A9yRQ== X-Received: by 2002:a5d:6846:: with SMTP id o6mr11746430wrw.370.1595011879368; Fri, 17 Jul 2020 11:51:19 -0700 (PDT) MIME-Version: 1.0 References: <20200716170914.3623060-1-yuhsuan@chromium.org> In-Reply-To: From: Yu-Hsuan Hsu Date: Sat, 18 Jul 2020 02:51:08 +0800 Message-ID: Subject: Re: [PATCH v2] ASoC: cros_ec_codec: Reset I2S RX when probing To: Guenter Roeck Cc: Enric Balletbo i Serra , linux-kernel , Tzung-Bi Shih , Cheng-Yi Chiang , Guenter Roeck , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , Benson Leung , 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=8817=E6=97= =A5 =E9=80=B1=E4=BA=94 =E4=B8=8B=E5=8D=8810:32=E5=AF=AB=E9=81=93=EF=BC=9A > > On Thu, Jul 16, 2020 at 10:47 AM Enric Balletbo i Serra > wrote: > > > > Hi, > > > > On 16/7/20 19:23, Guenter Roeck wrote: > > > On Thu, Jul 16, 2020 at 10:09 AM 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 > > >> --- > > >> drivers/platform/chrome/cros_ec_proto.c | 7 ++++++- > > >> include/linux/platform_data/cros_ec_commands.h | 1 + > > >> sound/soc/codecs/cros_ec_codec.c | 9 +++++++++ > > >> 3 files changed, 16 insertions(+), 1 deletion(-) > > >> > > >> diff --git a/drivers/platform/chrome/cros_ec_proto.c b/drivers/platf= orm/chrome/cros_ec_proto.c > > >> index 3e745e0fe092c..2c60690d7147c 100644 > > >> --- a/drivers/platform/chrome/cros_ec_proto.c > > >> +++ b/drivers/platform/chrome/cros_ec_proto.c > > >> @@ -572,7 +572,12 @@ int cros_ec_cmd_xfer_status(struct cros_ec_devi= ce *ec_dev, > > >> return -ENOTSUPP; > > >> } else if (msg->result !=3D EC_RES_SUCCESS) { > > >> dev_dbg(ec_dev->dev, "Command result (err: %d)\n", m= sg->result); > > >> - return -EPROTO; > > >> + switch (msg->result) { > > >> + case EC_RES_INVALID_PARAM: > > >> + return -EINVAL; > > > > > > As we have learned, this may impact other callers of > > > cros_ec_cmd_xfer_status() which only accept -EPROTO as error return > > > value. In addition to that, the code is odd: > > > > > > if (msg->result =3D=3D EC_RES_INVALID_VERSION) { > > > ... > > > } else if (msg->result !=3D EC_RES_SUCCESS) { > > > switch (msg->result) { > > > .... > > > } > > > } > > > > > > > Ack, this is odd. > > > > > I really dislike the notion of changing error return values of > > > cros_ec_cmd_xfer_status() one by one. That can only cause ongoing > > > trouble with callers expecting specific error return codes (as we hav= e > > > already seen). > > > > > > > Hmm, that's a good point. Ok. > > > > Let's apply the Guenter's patch that maps the errors *and* fix the call= ers of > > cros_ec_cmd_xfer_status which only accept -EPROTO (there are few). > > > > Yu-Hsuan, can you take care of this and send a patch series with all th= e > > required patches? If not, I can work on this next week. > > > > I can look into it as well. Let me know - I don't want to duplicate work. > > Guenter Hi Guenter, Really thanks for your assistance! Could you help me on those patches? Since you wrote that patch, I think it should be the most efficient way to make them merged. Thanks, Yu-Hsuan > > > Thanks, > > Enric > > > > > Guenter > > > > > >> + default: > > >> + return -EPROTO; > > >> + } > > >> } > > >> > > >> return ret; > > >> diff --git a/include/linux/platform_data/cros_ec_commands.h b/includ= e/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, > > >> EC_CODEC_I2S_RX_SUBCMD_COUNT, > > >> }; > > >> > > >> diff --git a/sound/soc/codecs/cros_ec_codec.c b/sound/soc/codecs/cro= s_ec_codec.c > > >> index f23956cf4ed84..b5ff30b7f1aa8 100644 > > >> --- a/sound/soc/codecs/cros_ec_codec.c > > >> +++ b/sound/soc/codecs/cros_ec_codec.c > > >> @@ -1034,6 +1034,15 @@ static int cros_ec_codec_platform_probe(struc= t 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_CODE= C_I2S_RX, > > >> + (uint8_t *)&p, sizeof(p), NULL, 0= ); > > >> + if (ret =3D=3D -EINVAL) > > >> + dev_info(dev, "Missing reset command. Please update = your EC firmware.\n"); > > >> + else if (ret) > > >> + dev_err(dev, "failed to EC_CODEC_I2S_RESET: %d\n", r= et); > > >> + > > >> platform_set_drvdata(pdev, priv); > > >> > > >> ret =3D devm_snd_soc_register_component(dev, &i2s_rx_compone= nt_driver, > > >> -- > > >> 2.27.0.389.gc38d7665816-goog > > >>