From patchwork Fri Jun 30 12:03:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Johan Hovold X-Patchwork-Id: 114708 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp10324468vqr; Fri, 30 Jun 2023 05:32:58 -0700 (PDT) X-Google-Smtp-Source: APBJJlG1Plxux610n8bOhtlvf07W4vA5ErL9ghmkny7UTfZbPc4qvgatXMD0Vi1imHqb+Q54TR8B X-Received: by 2002:a05:6a21:585:b0:12d:7376:2b45 with SMTP id lw5-20020a056a21058500b0012d73762b45mr1015119pzb.39.1688128378456; Fri, 30 Jun 2023 05:32:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1688128378; cv=none; d=google.com; s=arc-20160816; b=nUX/TtAi95I0hcebZYVwVmUytQipcwN1HMkNNmAdi6mU8ebS46N9y8dfu9PQGrMWhO nymPKFV/NlIU1ZavrZoMM+txmMfAM03PRGWYsxw0pPUWm6BK6CDv/7lmDMozXyQWCfov XY1tXXWeVvzxa6u43syYfrywKIuU3B3WT3VQsHibaYlYi8K0pQIdoXXtrJbRtRGrn51h 3QTqwLyT4W03u/8vnP2a1tgbGA4cqqIddSTPKGoqtOH3OdmfPauAXxOisizdFr9rHfZ0 WMMRgHgh4uC1I63D9RMf9dZZXPkFGfPPe60fjoAkeeCdIIcJi0YqKYfBr1Zsm/NnaNX/ 9xTQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=/LWvO2uAEVSd4st/7gRBY3DDwgQDmHwWgSgakiRzJ04=; fh=WKr6jFqwYbxMMFmOaFt4XnPL3YIMcXCo24uZCmlE7Pc=; b=JEtXCEDCsX9gUFHJpTJmpNIeyrNGP/6uaHLFN4Lt4xDC/N/ojbfeK0XYqcKL0MYZs1 FKsUHru/P+UriOsbdh7ySqG08CDx5tBpgSUm+Hzk09k6WcNeif0mMiu3Nk4GYdDiD59m w3+XjSUBdFKe3ZBZcYG6POybPWkwPQAKHnWjj9qbscgMnJ37kYegSa85R5pnPtT/Cpak sj/sHQu8kfkNmCa2WFfMYpbDUx1exR1Sf9Dlg/eGLB39PksZ5oqPiIS2ACl8d9Vjk6Dw AKnFk6W0dIav4sbL3Yf7QG7GSvu8by+c2hQLBQWnDHRxGKG1rARoTIxWspqleENvJctt EV1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DdCvdQpj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id w4-20020a656944000000b0055b602e0b55si1435510pgq.831.2023.06.30.05.32.45; Fri, 30 Jun 2023 05:32:58 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=DdCvdQpj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232958AbjF3MEX (ORCPT + 99 others); Fri, 30 Jun 2023 08:04:23 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229742AbjF3MEV (ORCPT ); Fri, 30 Jun 2023 08:04:21 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D5BC2171E; Fri, 30 Jun 2023 05:04:17 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 08A686173A; Fri, 30 Jun 2023 12:04:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 69047C433C9; Fri, 30 Jun 2023 12:04:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1688126656; bh=g9hLiJat+dtXzcd2zhhtjEUxB1SI6RvzzK4VEH1nhEk=; h=From:To:Cc:Subject:Date:From; b=DdCvdQpjcPzzD6bDojCti8fnagXcQHzzXrDxTUGCqSFt0f/t1aN6GClYYPMBch45A 0noIXvsZXuuHLmISup9G88yZhpXWLHVXSSqFrLIK2PMboCGZ8QeoDuLHdpZqoLvQOe w7ecouI1oH7frM1NgbzO/712nY13RxowM3MUtlPivxxTTRrfvOdy5OlQkqeDU2DSzU bMTEAFVaQKAviE93HsMG2nmosKPGwEIZE9ZOFXjC5U1QXIyMBtWEm8lgo6Nw7uxvFq 5Lvb7gxZJAP+sKZfcElMNlZjxT4Gl39kaLeGXaiMkiVq7RPSGrVeNqLt/+gLOzDLcE wjloORClBpiVA== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1qFCrO-0001if-C8; Fri, 30 Jun 2023 14:04:22 +0200 From: Johan Hovold To: Mark Brown Cc: Liam Girdwood , Jaroslav Kysela , Takashi Iwai , alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Johan Hovold , stable@vger.kernel.org, Srinivas Kandagatla , Steev Klimaszewski Subject: [PATCH] ASoC: codecs: wcd938x: fix codec initialisation race Date: Fri, 30 Jun 2023 14:03:18 +0200 Message-Id: <20230630120318.6571-1-johan+linaro@kernel.org> X-Mailer: git-send-email 2.39.3 MIME-Version: 1.0 X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1770130902997505588?= X-GMAIL-MSGID: =?utf-8?q?1770130902997505588?= Make sure to resume the codec and soundwire device before trying to read the codec variant and configure the device during component probe. This specifically avoids interpreting (a masked and shifted) -EBUSY errno as the variant: wcd938x_codec audio-codec: ASoC: error at soc_component_read_no_lock on audio-codec for register: [0x000034b0] -16 when the soundwire device happens to be suspended, which in turn prevents some headphone controls from being registered. Fixes: 8d78602aa87a ("ASoC: codecs: wcd938x: add basic driver") Cc: stable@vger.kernel.org # 5.14 Cc: Srinivas Kandagatla Reported-by: Steev Klimaszewski Signed-off-by: Johan Hovold --- sound/soc/codecs/wcd938x.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/sound/soc/codecs/wcd938x.c b/sound/soc/codecs/wcd938x.c index e7d6a02cdec0..e3ae4fb2c4db 100644 --- a/sound/soc/codecs/wcd938x.c +++ b/sound/soc/codecs/wcd938x.c @@ -3085,6 +3085,10 @@ static int wcd938x_soc_codec_probe(struct snd_soc_component *component) snd_soc_component_init_regmap(component, wcd938x->regmap); + ret = pm_runtime_resume_and_get(dev); + if (ret < 0) + return ret; + wcd938x->variant = snd_soc_component_read_field(component, WCD938X_DIGITAL_EFUSE_REG_0, WCD938X_ID_MASK); @@ -3098,6 +3102,8 @@ static int wcd938x_soc_codec_probe(struct snd_soc_component *component) (WCD938X_DIGITAL_INTR_LEVEL_0 + i), 0); } + pm_runtime_put(dev); + wcd938x->hphr_pdm_wd_int = regmap_irq_get_virq(wcd938x->irq_chip, WCD938X_IRQ_HPHR_PDM_WD_INT); wcd938x->hphl_pdm_wd_int = regmap_irq_get_virq(wcd938x->irq_chip,