Message ID | 20230523-regcache-maple-sync-lock-v1-1-530e4d68dfab@kernel.org |
---|---|
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 b10csp2458491vqo; Tue, 23 May 2023 15:36:32 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5Dh3t/t1nPuY1j9SZHBKBowDryZAvrx/5GoSm2DrsWKQD/fMcm2CqptkMxCjZkx31oMC1m X-Received: by 2002:a05:6a21:7899:b0:10b:cc13:5ac8 with SMTP id bf25-20020a056a21789900b0010bcc135ac8mr7525258pzc.27.1684881391981; Tue, 23 May 2023 15:36:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684881391; cv=none; d=google.com; s=arc-20160816; b=RjBUqXCHmOH1XxijKQKdsQ9L1ACF6a3iQbqxZXExOw1zg2UE8Lbt5EHoVRgcwYnZdS zRiGNywbOa4va9cVsOXCJigsqXzJqoNFbhIAU1f9IspIkIed+l2KaA5PFxKbpkCFkHHl UOfnBOOuTPyVR/AOC6vRxulWYljyeZ9JfillTUY6+osTIlx0P6b7tR4oWdWIOE9eHrAf +u6xGh7iYxgs49+VLhFEAR469bBMWPm7cVfTVqblEUPFKala1KMbH/hKXzXfey5DgP7x 4WAUuDqphEfQB8h8N3w06/PAyvcoCwoS+lFfB5DsvrLL6yUFL2ILutDGaMGE9gZO/qIo 8J/Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:content-transfer-encoding :mime-version:subject:date:from:dkim-signature; bh=tQNTXGgEwaf9pAe0llrt8I1eULaGFvObb+HbZIh3Wgw=; b=vmXS6zcP7N+XC7qvJ3SHJqN2tOkHzrH4zz+b/yw2q426nJYeC6nSza+JI/6QQHLtvY zbHiVzPlz9RkFNcjiF628R2qz7U5jjIw5apcW3hFzLQfVIZSmEgSC4/9rSVendZxeqit xXPoEUkkYzGzH0iwg5XPlEjlOEmnIgBG86NeN23boMhbVtk00JhUOQJVaMsEBmJuoFHL 0M6VVFOJJQnxjAcV5nr6fhh7xqAmDYi20jWXC4fohFsm6/ZqjmocwCG4NkXCVERIfqFr 9Tv/S1NCZkRaUqWT1RHIbtOOWwjBgjphf6FWr85fnnaWXaVrHLPrM//JMQBawdUejU9V i2Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=JR708gZp; 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 v3-20020a655c43000000b0053f0cdab80csi17203pgr.338.2023.05.23.15.36.17; Tue, 23 May 2023 15:36:31 -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=JR708gZp; 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 S238809AbjEWWSd (ORCPT <rfc822;ahmedalshaiji.dev@gmail.com> + 99 others); Tue, 23 May 2023 18:18:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55536 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S238702AbjEWWSb (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Tue, 23 May 2023 18:18:31 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8188B18B for <linux-kernel@vger.kernel.org>; Tue, 23 May 2023 15:18:28 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id D2CF6636A1 for <linux-kernel@vger.kernel.org>; Tue, 23 May 2023 22:18:27 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 55445C433D2; Tue, 23 May 2023 22:18:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1684880307; bh=veuGFlBxvJfC7X2QtcsRIS3sb0+f5+8pwpEBphVcea0=; h=From:Date:Subject:To:Cc:From; b=JR708gZp1IuCASbi+tDPkn5+t1JnIHoMs9mSTcig2R+T9CxxXkdHsf9XBy+XyjTMv yYwWMFkESn+z5kokf/CGwqfLEeIsN15IZBhIhmrFXtQ9gBrmiwb+43+q9nCPr0eYvF PTXJUdA/APWCtM7dK3DXD1X1sLP39HdwmrCRUrtsL1mZQTPDQW26H49PNClitjQ+WM tzXIciRH24k2j0G55oHXFX2pxazGzoc/q0Yvm8xc5aHKw54H7TUsjowK/GEjEyApLD PHp1WQs8I3B/t57U0PuaTX1DZBrBBP7WFFZsM7Pv7vgUPgd3B0RYQcBVp2lAkkEK3y joL3vYR+Z+10A== From: Mark Brown <broonie@kernel.org> Date: Tue, 23 May 2023 23:18:19 +0100 Subject: [PATCH] regmap: maple: Drop the RCU read lock while syncing registers MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20230523-regcache-maple-sync-lock-v1-1-530e4d68dfab@kernel.org> X-B4-Tracking: v=1; b=H4sIAKo7bWQC/x2NSwrDMAwFrxK0rsC1cQq9SulCVtTYJLWDDP0Qc vc4Wc6DebNCFU1S4d6toPJJNZXc4HrpgCPlUTANjcEa64y3DlVGJo6Cb1pmwfrPjHPhCf1NyPl +4N4EaHqgKhiUMsfj4Ft0OuZF5ZV+Z/Hx3LYdNbKb+IEAAAA= To: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Cc: linux-kernel@vger.kernel.org, alsa-devel@alsa-project.org, Mark Brown <broonie@kernel.org> X-Mailer: b4 0.13-dev-bfdf5 X-Developer-Signature: v=1; a=openpgp-sha256; l=1507; i=broonie@kernel.org; h=from:subject:message-id; bh=veuGFlBxvJfC7X2QtcsRIS3sb0+f5+8pwpEBphVcea0=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBkbTux4oldhXQTi6/rzUziSGq1Bbp/Z2NlJcHmVfx7 fiVpr36JATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZG07sQAKCRAk1otyXVSH0LrfB/ wLlMLGMlNDljolW7vhDGSgSVC1ef3/0xxRYT7v8CnysolmzHP09D4O5rX4blrw9D7+pL81KrAAc0Ht 4lHCGE18Z4FCHuKpEkul+vpL9FrhysJMxVh0QKwCXZ0bXuqU9xoPWAlI1sUQcG/Po8uJJLvXFg5tVF 3pBPGhev+JPpfl2wZqH+CR8R4l7NgSZ90syYXXAnYL1Q7uCaxbiA3nkpUAmahZCPNku9jlJw6NIPC4 3vHz4xm7SGYbsvnhiJ/P1taHJH+93gUh5qCRxUcWumlg2wpXu3Y2MeL/hNbnSY4cFjI5K/7d4HqeAm a5l6fPwiwaFf5V8hfh/7zgbxGqCfZh X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB 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: <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?1766726190144131295?= X-GMAIL-MSGID: =?utf-8?q?1766726190144131295?= |
Series |
regmap: maple: Drop the RCU read lock while syncing registers
|
|
Commit Message
Mark Brown
May 23, 2023, 10:18 p.m. UTC
Unfortunately the maple tree requires us to explicitly lock it so we need
to take the RCU read lock while iterating. When syncing this means that we
end up trying to write out register values while holding the RCU read lock
which triggers lockdep issues since that is an atomic context but most
buses can't be used in atomic context. Pause the iteration and drop the
lock for each register we check to avoid this.
Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
Signed-off-by: Mark Brown <broonie@kernel.org>
---
drivers/base/regmap/regcache-maple.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
---
base-commit: 44c026a73be8038f03dbdeef028b642880cf1511
change-id: 20230523-regcache-maple-sync-lock-57ea356dc60b
Best regards,
Comments
On 5/23/23 17:18, Mark Brown wrote: > Unfortunately the maple tree requires us to explicitly lock it so we need > to take the RCU read lock while iterating. When syncing this means that we > end up trying to write out register values while holding the RCU read lock > which triggers lockdep issues since that is an atomic context but most > buses can't be used in atomic context. Pause the iteration and drop the > lock for each register we check to avoid this. > > Reported-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> Closes: https://github.com/thesofproject/linux/issues/4371 Tested-by: Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com> > Signed-off-by: Mark Brown <broonie@kernel.org> > --- > drivers/base/regmap/regcache-maple.c | 5 ++++- > 1 file changed, 4 insertions(+), 1 deletion(-) > > diff --git a/drivers/base/regmap/regcache-maple.c b/drivers/base/regmap/regcache-maple.c > index 9b1b559107ef..c2e3a0f6c218 100644 > --- a/drivers/base/regmap/regcache-maple.c > +++ b/drivers/base/regmap/regcache-maple.c > @@ -203,15 +203,18 @@ static int regcache_maple_sync(struct regmap *map, unsigned int min, > > mas_for_each(&mas, entry, max) { > for (r = max(mas.index, lmin); r <= min(mas.last, lmax); r++) { > + mas_pause(&mas); > + rcu_read_unlock(); > ret = regcache_sync_val(map, r, entry[r - mas.index]); > if (ret != 0) > goto out; > + rcu_read_lock(); > } > } > > -out: > rcu_read_unlock(); > > +out: > map->cache_bypass = false; > > return ret; > > --- > base-commit: 44c026a73be8038f03dbdeef028b642880cf1511 > change-id: 20230523-regcache-maple-sync-lock-57ea356dc60b > > Best regards,
On Tue, 23 May 2023 23:18:19 +0100, Mark Brown wrote: > Unfortunately the maple tree requires us to explicitly lock it so we need > to take the RCU read lock while iterating. When syncing this means that we > end up trying to write out register values while holding the RCU read lock > which triggers lockdep issues since that is an atomic context but most > buses can't be used in atomic context. Pause the iteration and drop the > lock for each register we check to avoid this. > > [...] Applied to https://git.kernel.org/pub/scm/linux/kernel/git/broonie/regmap.git for-next Thanks! [1/1] regmap: maple: Drop the RCU read lock while syncing registers commit: 0cc6578048e0980d254aee345130cced4912f723 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/drivers/base/regmap/regcache-maple.c b/drivers/base/regmap/regcache-maple.c index 9b1b559107ef..c2e3a0f6c218 100644 --- a/drivers/base/regmap/regcache-maple.c +++ b/drivers/base/regmap/regcache-maple.c @@ -203,15 +203,18 @@ static int regcache_maple_sync(struct regmap *map, unsigned int min, mas_for_each(&mas, entry, max) { for (r = max(mas.index, lmin); r <= min(mas.last, lmax); r++) { + mas_pause(&mas); + rcu_read_unlock(); ret = regcache_sync_val(map, r, entry[r - mas.index]); if (ret != 0) goto out; + rcu_read_lock(); } } -out: rcu_read_unlock(); +out: map->cache_bypass = false; return ret;