From nobody Wed Dec 17 13:39:24 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0A5B9C77B72 for ; Thu, 20 Apr 2023 10:18:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234762AbjDTKSN (ORCPT ); Thu, 20 Apr 2023 06:18:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59108 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234392AbjDTKRl (ORCPT ); Thu, 20 Apr 2023 06:17:41 -0400 Received: from mail-ed1-x52d.google.com (mail-ed1-x52d.google.com [IPv6:2a00:1450:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55B9359D6 for ; Thu, 20 Apr 2023 03:16:28 -0700 (PDT) Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-50685f1b6e0so833040a12.0 for ; Thu, 20 Apr 2023 03:16:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1681985787; x=1684577787; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Lh0gzMHKjXIEM7BMaBHJPBXLjPSxY0yCOjmfp2sB3bs=; b=ZY7V2Fz3NbWwq9aEj2mVn5PnKntw3UCQb4JlfiHhYV0ddMHpN+M8YLIYbeYsE+Ffsj HAguHowzIfVychuICmyTnPXqrCiMPohkRBiwJ5gFErVFL2Xe0YgYfZ2mlihhIgNvguNc WJSMsNFB4dEITw8ED4WVadG5Cg82WotrYQZV/esEjZnrq6uR8DvqTnNdmacy7mSZlxCQ dRkhmaqjCEYdd+QWFyqkEGUu1o9bCaNIUC0WDAMjx/nnqTAN2Q4k+sRXaFL1FpwbKdMl TEgTNFQY/B73e3xmmRB2a+UxETkMTtLGmrlFCrgs70IhUoPQd7MKs9vDEzegWoAtzQjv ynxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1681985787; x=1684577787; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Lh0gzMHKjXIEM7BMaBHJPBXLjPSxY0yCOjmfp2sB3bs=; b=Q3w0js2lKTlG1KS9ccYLG7GheirTVOuy1GPK2RuuLk85pEIWeqIPTKMJLF43G0WmR4 cZPKRCLyJyytZ/t23I5iNVQlHBl9dkFWEkmPKPQbjjcTSRJYh2Cw3wT9OmcfuFlRh5r0 G30fkNoc5Y+CXhXH3Kn/pcvYvIgoYEdS5rBoGoVOvWavdeOHTZhH5Al/3x3AMvIBTIjA K7sNbcCYt7B6N4ejnILKiQ+WEYMkhv/E7donZl71P6iADIxv2cR5b3593M72QsMhhT/l L4A6+9lSriW/SHsCRhhjhHQCPKnRZK/RglyYUTZ2wkuNl5j5hy8zhMIusuQQj2tRcU83 jpFg== X-Gm-Message-State: AAQBX9cBLMzXPqdBIHqRgsM6Oc6e3ROkSCPkReZtYDQPglC4KOfLRttA ngqLnBd4g7V2bJaD+nE6lsPydw== X-Google-Smtp-Source: AKy350arZDGHMInHp8GuNY+Ano5ThS/SGyaLKa8v0e+z5Ka6cwm3FR2IPMhl6ymmgxoP66sw2zHKgg== X-Received: by 2002:aa7:d547:0:b0:506:98e8:7e58 with SMTP id u7-20020aa7d547000000b0050698e87e58mr999102edr.34.1681985786794; Thu, 20 Apr 2023 03:16:26 -0700 (PDT) Received: from krzk-bin.. ([2a02:810d:15c0:828:bcb8:77e6:8f45:4771]) by smtp.gmail.com with ESMTPSA id l22-20020aa7c3d6000000b00506be898998sm588954edr.29.2023.04.20.03.16.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Apr 2023 03:16:26 -0700 (PDT) From: Krzysztof Kozlowski To: Vinod Koul , Bard Liao , Pierre-Louis Bossart , Sanyog Kale , Andy Gross , Bjorn Andersson , Konrad Dybcio , Liam Girdwood , Mark Brown , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org Cc: Krzysztof Kozlowski , Patrick Lai Subject: [PATCH 3/6] ASoC: codecs: wcd938x: Check for enumeration before using TX device Date: Thu, 20 Apr 2023 12:16:14 +0200 Message-Id: <20230420101617.142225-4-krzysztof.kozlowski@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230420101617.142225-1-krzysztof.kozlowski@linaro.org> References: <20230420101617.142225-1-krzysztof.kozlowski@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Qualcomm WCD938x Soundwire codecs come as two Soundwire devices - TX and RX - on two Soundwire buses. In DTS they are represented as three device nodes: Soundwire TX, Soundwire RX and the platform codec node (binding to this driver). Probing (and Soundwire enumeration) of all devices can happen in any order, but only the Soundwire TX WCD938x device is used for accessing actual WCD938x registers. It is possible that component bind() in the platform driver will be called too early, before the Soundwire TX device is fully enumerated. This might work or might not, but we cannot handle it correctly from the codec driver. It's job for Soundwire master to bring up devices in correct order. At least add some simple warning, so such condition will not be undetected. Signed-off-by: Krzysztof Kozlowski --- Cc: Patrick Lai --- sound/soc/codecs/wcd938x.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c index 212667a7249c..e8e07e120fa1 100644 --- a/sound/soc/codecs/wcd938x.c +++ b/sound/soc/codecs/wcd938x.c @@ -77,6 +77,8 @@ #define WCD938X_MBHC_MOISTURE_RREF R_24_KOHM #define WCD_MBHC_HS_V_MAX 1600 =20 +#define WCD938X_ENUM_TIMEOUT_MS 500 + #define WCD938X_EAR_PA_GAIN_TLV(xname, reg, shift, max, invert, tlv_array)= \ { .iface =3D SNDRV_CTL_ELEM_IFACE_MIXER, .name =3D xname, \ .access =3D SNDRV_CTL_ELEM_ACCESS_TLV_READ |\ @@ -4425,6 +4427,15 @@ static int wcd938x_bind(struct device *dev) wcd938x->sdw_priv[AIF1_PB]->slave_irq =3D wcd938x->virq; wcd938x->sdw_priv[AIF1_CAP]->slave_irq =3D wcd938x->virq; =20 + /* + * Before any TX slave regmap usage, be sure the TX slave is actually + * enumerated. + */ + ret =3D wait_for_completion_timeout(&wcd938x->tx_sdw_dev->enumeration_com= plete, + msecs_to_jiffies(WCD938X_ENUM_TIMEOUT_MS)); + if (!ret) + dev_warn(dev, "Enumeration timeout in bind, possible failures in accessi= ng registers\n"); + ret =3D wcd938x_set_micbias_data(wcd938x); if (ret < 0) { dev_err(dev, "%s: bad micbias pdata\n", __func__); --=20 2.34.1