Message ID | 20230516164629.1.Ibf79e94b3442eecc0054d2b478779cc512d967fc@changeid |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp572403vqo; Tue, 16 May 2023 10:00:18 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7HOojameNJ+Oo8PcKMF1xdLotQ3WEfW2e2y5knIIeuYVXcJMVA5Lx7XdiOzB8CdWAYPX/j X-Received: by 2002:a05:6a00:807:b0:647:b071:20c4 with SMTP id m7-20020a056a00080700b00647b07120c4mr34587214pfk.1.1684256418311; Tue, 16 May 2023 10:00:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684256418; cv=none; d=google.com; s=arc-20160816; b=VBhXt87o+TW2kkwEdGSDeeVbiAU26+49PI+xk2+kDC4J9uRr4Qk5JjDNjCLk1yIUFV mRyi1bYMciow5NB96tXssqlm9hecdoQfXpqe9UkiVSmIwCMizRisUl8xLTpqDTKkSoKA BmF15iaBJ/azQFNIn/TFykNqlZHIZoxLjDru7UcY0WrSmQ8Ld64QMHDPZkHbeviWriJu 1udkFfDDzATF7Snf6E8buQ68EVAuekL+KvU9TPszNuYviXmNay9f3MVaewAsfUyjtaqa ALjV7QosNDn8SbpLu388ALK9T3uuW4xg7VjiTBxUtqM/TEkjqezsE6DJNWzhCDaPWqrP pEoQ== 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=4kqAFNzMiB3ZwK/e/ItswkNJsgBlTz31zqehRMdz+Ac=; b=s/IFXXYpBlyHS7b96fEF0EcNRi/yvUS9zp7AFuo5WkqxBEOrEfQIwKuwwbr2tj86i/ EfXOqdGuYCo1TvcDBywFc2iU3zZ9rsZfHIbMFcFEOrkHLw09GC84eFFoC++lEPCqj6Zb D2LsVPcxKSQVUgMNaDjevPb29kl//slCSf4a5HLWOc9pLsKLRkvmlYzvLVjVxtCO91mY OmXCtKKrS1rR5QnjNmcUdktfKgaMp42h5WCIMAmnbkdviKaeft1PSAY3aMTq44W1CgWe 3+xnIxxNVCglKre48CZG1+CCvP8dvvPooP+rjIzZUIdL520YDnPiUnXHBJfdFpvt2wxz bg/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=XgquwqvL; 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=chromium.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y24-20020a63b518000000b0051322a8d2aesi18110317pge.110.2023.05.16.10.00.05; Tue, 16 May 2023 10:00:18 -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=@chromium.org header.s=google header.b=XgquwqvL; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230409AbjEPQrd (ORCPT <rfc822;peekingduck44@gmail.com> + 99 others); Tue, 16 May 2023 12:47:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52088 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230203AbjEPQra (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 16 May 2023 12:47:30 -0400 Received: from mail-il1-x129.google.com (mail-il1-x129.google.com [IPv6:2607:f8b0:4864:20::129]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ADD9F3A9C for <linux-kernel@vger.kernel.org>; Tue, 16 May 2023 09:47:26 -0700 (PDT) Received: by mail-il1-x129.google.com with SMTP id e9e14a558f8ab-32c83c66b1cso100472045ab.1 for <linux-kernel@vger.kernel.org>; Tue, 16 May 2023 09:47:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1684255646; x=1686847646; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=4kqAFNzMiB3ZwK/e/ItswkNJsgBlTz31zqehRMdz+Ac=; b=XgquwqvLNbDkiRPVfnqU1n76gnw4qQo6lUMlezqCtFltOedMPmcnAvkXvPdCFuhylm mclF0gih61PAmtXrLslY7axZG74QEeWuxP6yd+uBQ9qpJ3TcBrCgQEUGRtruX3Z6NyYF QeubN5hMQlbLVmVTqFEZ3V9Vn3hUIwcTtEkLw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1684255646; x=1686847646; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4kqAFNzMiB3ZwK/e/ItswkNJsgBlTz31zqehRMdz+Ac=; b=hxiBAkFIwxaoeW9PVqBi7CzEPUf9CCNRvlcswe2lSV/tDx2jL5WXWXTjrSRJon1mYA uXTZ+p4s23lqY/m1EyS5vi5jdNcwvZh3M8apzJGlxsdOiN44WxZxkF5gdgggV8F5Wfcs 0vkiHxQDNcn96/gM1+p1Imzh74Ato/nqTnxCwaXggOn607SuNcHQfDz/bBsYy+rZ1/XI kHPwP/gvIgQJN6Q1njP3cUQISUgGGt9c6diys210vM/bRYSLX19zy58v5EluiYAMPh/1 CjQYJtk8GnTbXGZ5t+C1WDonuzvv6tgkq5WH2lQnz/kZpYlDdQh7tXWhLqmWt1k2z/yg r03w== X-Gm-Message-State: AC+VfDxEzYM/eFHE+AjTiKN0vaml67I1DQgWH9BlAg2/UC7pXsBZVvp1 Qc7QgBpsHiWkTdaAECmcW3z/bg== X-Received: by 2002:a92:ca91:0:b0:335:ebb8:1138 with SMTP id t17-20020a92ca91000000b00335ebb81138mr12869924ilo.22.1684255646089; Tue, 16 May 2023 09:47:26 -0700 (PDT) Received: from localhost (30.23.70.34.bc.googleusercontent.com. [34.70.23.30]) by smtp.gmail.com with UTF8SMTPSA id c41-20020a023f69000000b004141e72be1asm7771265jaf.175.2023.05.16.09.47.25 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 16 May 2023 09:47:25 -0700 (PDT) From: Matthias Kaehlcke <mka@chromium.org> To: Oder Chiou <oder_chiou@realtek.com>, Liam Girdwood <lgirdwood@gmail.com>, Mark Brown <broonie@kernel.org>, Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com> Cc: Douglas Anderson <dianders@chromium.org>, linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Stephen Boyd <swboyd@chromium.org>, Matthias Kaehlcke <mka@chromium.org>, stable@kernel.org Subject: [PATCH] SoC: rt5682: Disable jack detection interrupt during suspend Date: Tue, 16 May 2023 16:46:30 +0000 Message-ID: <20230516164629.1.Ibf79e94b3442eecc0054d2b478779cc512d967fc@changeid> X-Mailer: git-send-email 2.40.1.606.ga4b1b128d6-goog MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766070857725120330?= X-GMAIL-MSGID: =?utf-8?q?1766070857725120330?= |
Series |
SoC: rt5682: Disable jack detection interrupt during suspend
|
|
Commit Message
Matthias Kaehlcke
May 16, 2023, 4:46 p.m. UTC
The rt5682 driver switches its regmap to cache-only when the
device suspends and back to regular mode on resume. When the
jack detect interrupt fires rt5682_irq() schedules the jack
detect work. This can result in invalid reads from the regmap
in cache-only mode if the work runs before the device has
resumed:
[ 56.245502] rt5682 9-001a: ASoC: error at soc_component_read_no_lock on rt5682.9-001a for register: [0x000000f0] -16
Disable the jack detection interrupt during suspend and
re-enable it on resume. The driver already schedules the
jack detection work on resume, so any state change during
suspend is still handled.
This is essentially the same as commit f7d00a9be147 ("SoC:
rt5682s: Disable jack detection interrupt during suspend")
for the rt5682s.
Cc: stable@kernel.org
Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
sound/soc/codecs/rt5682-i2c.c | 4 +++-
sound/soc/codecs/rt5682.c | 6 ++++++
sound/soc/codecs/rt5682.h | 1 +
3 files changed, 10 insertions(+), 1 deletion(-)
Comments
Hi, On Tue, May 16, 2023 at 9:47 AM Matthias Kaehlcke <mka@chromium.org> wrote: > > The rt5682 driver switches its regmap to cache-only when the > device suspends and back to regular mode on resume. When the > jack detect interrupt fires rt5682_irq() schedules the jack > detect work. This can result in invalid reads from the regmap > in cache-only mode if the work runs before the device has > resumed: > > [ 56.245502] rt5682 9-001a: ASoC: error at soc_component_read_no_lock on rt5682.9-001a for register: [0x000000f0] -16 > > Disable the jack detection interrupt during suspend and > re-enable it on resume. The driver already schedules the > jack detection work on resume, so any state change during > suspend is still handled. > > This is essentially the same as commit f7d00a9be147 ("SoC: > rt5682s: Disable jack detection interrupt during suspend") > for the rt5682s. > > Cc: stable@kernel.org > Signed-off-by: Matthias Kaehlcke <mka@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org>
Quoting Matthias Kaehlcke (2023-05-16 09:46:30) > The rt5682 driver switches its regmap to cache-only when the > device suspends and back to regular mode on resume. When the > jack detect interrupt fires rt5682_irq() schedules the jack > detect work. This can result in invalid reads from the regmap > in cache-only mode if the work runs before the device has > resumed: I was wondering why we can't resume the device before device irqs are enabled (and similarly suspend it after irqs are disabled). It looks like snd_soc_component_driver is not an actual 'struct driver' instance so it reimplements PM hooks like suspend and resume for the components and the suspend hooks run from snd_soc_suspend() at the struct dev_pm_ops::suspend() path. Adding a noirq variant looks like it isn't worth it. > > [ 56.245502] rt5682 9-001a: ASoC: error at soc_component_read_no_lock on rt5682.9-001a for register: [0x000000f0] -16 > > Disable the jack detection interrupt during suspend and > re-enable it on resume. The driver already schedules the > jack detection work on resume, so any state change during > suspend is still handled. > > This is essentially the same as commit f7d00a9be147 ("SoC: > rt5682s: Disable jack detection interrupt during suspend") > for the rt5682s. > > Cc: stable@kernel.org > Signed-off-by: Matthias Kaehlcke <mka@chromium.org> > --- Reviewed-by: Stephen Boyd <swboyd@chromium.org> > diff --git a/sound/soc/codecs/rt5682-i2c.c b/sound/soc/codecs/rt5682-i2c.c > index 2935c1bb81f3..5bc46b041786 100644 > --- a/sound/soc/codecs/rt5682-i2c.c > +++ b/sound/soc/codecs/rt5682-i2c.c > @@ -267,7 +267,9 @@ static int rt5682_i2c_probe(struct i2c_client *i2c) > ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, > rt5682_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING > | IRQF_ONESHOT, "rt5682", rt5682); > - if (ret) > + if (!ret) > + rt5682->irq = i2c->irq; > + else > dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret); Not in this patch, but s/reguest/request/
On Tue, May 16, 2023 at 04:46:30PM +0000, Matthias Kaehlcke wrote: > The rt5682 driver switches its regmap to cache-only when the > device suspends and back to regular mode on resume. When the > jack detect interrupt fires rt5682_irq() schedules the jack > detect work. This can result in invalid reads from the regmap Please submit patches using subject lines reflecting the style for the subsystem, this makes it easier for people to identify relevant patches. Look at what existing commits in the area you're changing are doing and make sure your subject lines visually resemble what they're doing. There's no need to resubmit to fix this alone.
On Tue, 16 May 2023 16:46:30 +0000, Matthias Kaehlcke wrote: > The rt5682 driver switches its regmap to cache-only when the > device suspends and back to regular mode on resume. When the > jack detect interrupt fires rt5682_irq() schedules the jack > detect work. This can result in invalid reads from the regmap > in cache-only mode if the work runs before the device has > resumed: > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound.git for-next Thanks! [1/1] SoC: rt5682: Disable jack detection interrupt during suspend commit: 8b271370e963370703819bd9795a54d658071bed All being well this means that it will be integrated into the linux-next tree (usually sometime in the next 24 hours) and sent to Linus during the next merge window (or sooner if it is a bug fix), however if problems are discovered then the patch may be dropped or reverted. You may get further e-mails resulting from automated or manual testing and review of the tree, please engage with people reporting problems and send followup patches addressing any issues that are reported if needed. If any updates are required or you are submitting further changes they should be sent as incremental updates against current git, existing patches will not be replaced. Please add any relevant lists and maintainers to the CCs when replying to this mail. Thanks, Mark
diff --git a/sound/soc/codecs/rt5682-i2c.c b/sound/soc/codecs/rt5682-i2c.c index 2935c1bb81f3..5bc46b041786 100644 --- a/sound/soc/codecs/rt5682-i2c.c +++ b/sound/soc/codecs/rt5682-i2c.c @@ -267,7 +267,9 @@ static int rt5682_i2c_probe(struct i2c_client *i2c) ret = devm_request_threaded_irq(&i2c->dev, i2c->irq, NULL, rt5682_irq, IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_ONESHOT, "rt5682", rt5682); - if (ret) + if (!ret) + rt5682->irq = i2c->irq; + else dev_err(&i2c->dev, "Failed to reguest IRQ: %d\n", ret); } diff --git a/sound/soc/codecs/rt5682.c b/sound/soc/codecs/rt5682.c index f6c798b65c08..5d992543b791 100644 --- a/sound/soc/codecs/rt5682.c +++ b/sound/soc/codecs/rt5682.c @@ -2959,6 +2959,9 @@ static int rt5682_suspend(struct snd_soc_component *component) if (rt5682->is_sdw) return 0; + if (rt5682->irq) + disable_irq(rt5682->irq); + cancel_delayed_work_sync(&rt5682->jack_detect_work); cancel_delayed_work_sync(&rt5682->jd_check_work); if (rt5682->hs_jack && (rt5682->jack_type & SND_JACK_HEADSET) == SND_JACK_HEADSET) { @@ -3027,6 +3030,9 @@ static int rt5682_resume(struct snd_soc_component *component) mod_delayed_work(system_power_efficient_wq, &rt5682->jack_detect_work, msecs_to_jiffies(0)); + if (rt5682->irq) + enable_irq(rt5682->irq); + return 0; } #else diff --git a/sound/soc/codecs/rt5682.h b/sound/soc/codecs/rt5682.h index d568c6993c33..e8efd8a84a6c 100644 --- a/sound/soc/codecs/rt5682.h +++ b/sound/soc/codecs/rt5682.h @@ -1462,6 +1462,7 @@ struct rt5682_priv { int pll_out[RT5682_PLLS]; int jack_type; + int irq; int irq_work_delay_time; };