From patchwork Mon Jul 17 20:33:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13316576 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 5EE49C001DF for ; Mon, 17 Jul 2023 20:35:17 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 8922EDE5; Mon, 17 Jul 2023 22:34:25 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 8922EDE5 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689626115; bh=asnEKCSLQS/uNfyRgYl+ksnbJzzBRAv8Ur+NiRrtqSE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=lt/8cg4P4q5iGO3OTie4yU8y1xB+ySY31qZHT6P5QrZwAXaogpc76UX4MpHmnxxP4 ZM4K+iKlAHDaKbFewL3w/gvfSO8O7iBsxryq8AIS5rn1j5v0xUPKMDvtJwvG54ByLX qNw5ARjA/ajFXWVvoa+eARW7Vo3guYb4QJL/ttxY= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 62ABFF80567; Mon, 17 Jul 2023 22:33:32 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id C5E75F80567; Mon, 17 Jul 2023 22:33:31 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id 86F15F804DA; Mon, 17 Jul 2023 22:33:27 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id DCED6F8027B for ; Mon, 17 Jul 2023 22:33:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz DCED6F8027B Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=dfbHZzBN 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 3F92261233; Mon, 17 Jul 2023 20:33:16 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 12199C433C7; Mon, 17 Jul 2023 20:33:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689625995; bh=asnEKCSLQS/uNfyRgYl+ksnbJzzBRAv8Ur+NiRrtqSE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=dfbHZzBNjmAh2GPJQXl4+PaLzVLBTGWLswICTnQVJW216Oo8KlI66DrLdViLmyf2C 9rK28bfTGMx4Q0OHIrus77fko1PutrcwiMIHF41ViglSealy8zAZgcAwvU3SnTewYc oynzCKz+H5BOCykQKioEVO8XQlr6ea6iOYeG8yeFCCSUtoaWHfnZYYAzMpldeu/5Fd sPcKYDeBugl4TJ0gadfrRYF9R0wMV2mu822lsNUEbgr8dvQPF3RD39KWkCeriq7sU6 2o/nO4NJQCSZ2LUcDVwOlVZPDyzep9NAdPclZDWYNki1And5yKrvoTOUWjZHu9l683 g2XEA7uVOyktw== From: Mark Brown Date: Mon, 17 Jul 2023 21:33:03 +0100 Subject: [PATCH 1/3] regmap: Let users check if a register is cached MIME-Version: 1.0 Message-Id: <20230717-regmap-cache-check-v1-1-73ef688afae3@kernel.org> References: <20230717-regmap-cache-check-v1-0-73ef688afae3@kernel.org> In-Reply-To: <20230717-regmap-cache-check-v1-0-73ef688afae3@kernel.org> To: Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=1894; i=broonie@kernel.org; h=from:subject:message-id; bh=asnEKCSLQS/uNfyRgYl+ksnbJzzBRAv8Ur+NiRrtqSE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBktaWFmLfcJep5LqvVZiSrYHrXWYcDXZnPESyRi cO5BUNFXQKJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZLWlhQAKCRAk1otyXVSH 0IDsCACCdkNOcaAD2yxTysnsoFA5Go65pphKHCRH16FNb9l77a994IjWeN6pqJb/HoIhCx4v8qm NV9os3vvsXgvzc++6x42Fe0DnYKdlF4FWccBqddxjdYtGKxQFocxz6QxfDJMApOrf8jjgBQ2Lga LrrOASaENXQfKC1M7W/+MBpzvLhEzXi3Zlm9rtoGNce3EFxYe4XZBCWkT6LHlF/ggLDMk+4PjUo b5aVLhhWfO0rLd0ZodVPjM7S3IWWjsahQC0HiTZQB7QhVowINFH3+DFd7HjAPBQvLM/aQvw9lRx SR2v3OItdm7tkpng4SgeDNv76HdCJQIYiaYP0T5+q2VHcx5z X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Message-ID-Hash: EEDYM2UHAHB3VAEANGJNH536QL252LGW X-Message-ID-Hash: EEDYM2UHAHB3VAEANGJNH536QL252LGW X-MailFrom: broonie@kernel.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The HDA driver has a use case for checking if a register is cached which it bodges in awkwardly and unclearly. Provide an API which allows it to directly do what it's trying to do. Signed-off-by: Mark Brown --- drivers/base/regmap/regcache.c | 23 +++++++++++++++++++++++ include/linux/regmap.h | 1 + 2 files changed, 24 insertions(+) diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 28bc3ae9458a..4d25a906b688 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -561,6 +561,29 @@ void regcache_cache_bypass(struct regmap *map, bool enable) } EXPORT_SYMBOL_GPL(regcache_cache_bypass); +/** + * regcache_reg_cached - Check if a register is cached + * + * @map: map to check + * @reg: register to check + * + * Reports if a register is cached. + */ +bool regcache_reg_cached(struct regmap *map, unsigned int reg) +{ + unsigned int val; + int ret; + + map->lock(map->lock_arg); + + ret = regcache_read(map, reg, &val); + + map->unlock(map->lock_arg); + + return ret == 0; +} +EXPORT_SYMBOL_GPL(regcache_reg_cached); + void regcache_set_val(struct regmap *map, void *base, unsigned int idx, unsigned int val) { diff --git a/include/linux/regmap.h b/include/linux/regmap.h index 8fc0b3ebce44..c9182a47736e 100644 --- a/include/linux/regmap.h +++ b/include/linux/regmap.h @@ -1287,6 +1287,7 @@ int regcache_drop_region(struct regmap *map, unsigned int min, void regcache_cache_only(struct regmap *map, bool enable); void regcache_cache_bypass(struct regmap *map, bool enable); void regcache_mark_dirty(struct regmap *map); +bool regcache_reg_cached(struct regmap *map, unsigned int reg); bool regmap_check_range_table(struct regmap *map, unsigned int reg, const struct regmap_access_table *table); From patchwork Mon Jul 17 20:33:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13316577 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 37004C001B0 for ; Mon, 17 Jul 2023 20:35:15 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id 5D908DEB; Mon, 17 Jul 2023 22:34:17 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz 5D908DEB DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689626107; bh=b4IseGb2UCJOtvGxtD0s69we2S7StSFhtsSuvhYajGE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=pIzREkSsfT5e2e9tqpbBzbBdT6Mu8CjUncUS70jWKAv//tRWj6Uhl/ftsZKgthwWK jE9i5m2tduBhb/eeuhGFJfptKQrYTWy0X7imp5nxzHNariJ32WJ5dRd7rPsddUMmC2 xXxv15LRuXCZ8r4is5Rzkczq+RESC9UrGZQklMmM= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 68FA7F8055C; Mon, 17 Jul 2023 22:33:29 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 10CE0F8027B; Mon, 17 Jul 2023 22:33:29 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E3BC4F804DA; Mon, 17 Jul 2023 22:33:24 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id 2489FF8032D for ; Mon, 17 Jul 2023 22:33:18 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz 2489FF8032D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=bYUx7Tx+ 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 C0B566125C; Mon, 17 Jul 2023 20:33:17 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id DF7D3C433CC; Mon, 17 Jul 2023 20:33:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689625997; bh=b4IseGb2UCJOtvGxtD0s69we2S7StSFhtsSuvhYajGE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=bYUx7Tx+9t535IoOQV/4NtVlpxBG7M991N4cV4OqhNx4wRPhr5DGivfAiQryXF12n pJxVGPrmIzvL/TZwHM+ndvVkxwTe5qR8ln0ERy6uxlPeS1+ZUfJ47CwqIrddBzOT50 +IEERnG54L7UMOCXTeF10Ur06YR1yyKMDweQDUsnv0Ht3WcwzD5Nt0zkOmfbHK6Ybr s7L1jz8KoO6bU0+MLGZgJdjxjJ53yjtwb1G23Nhp66NYNgIGk2PGCgNawDN3M21BSh emIahnZHgmy9xiPaE6mt+7/4Ux4zJ+XyLR99spw0xiV8YekKvK9cDQXvsKOaVIiTNB oJJFlJLLGNJkA== From: Mark Brown Date: Mon, 17 Jul 2023 21:33:04 +0100 Subject: [PATCH 2/3] regmap: Provide test for regcache_reg_present() MIME-Version: 1.0 Message-Id: <20230717-regmap-cache-check-v1-2-73ef688afae3@kernel.org> References: <20230717-regmap-cache-check-v1-0-73ef688afae3@kernel.org> In-Reply-To: <20230717-regmap-cache-check-v1-0-73ef688afae3@kernel.org> To: Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=2145; i=broonie@kernel.org; h=from:subject:message-id; bh=b4IseGb2UCJOtvGxtD0s69we2S7StSFhtsSuvhYajGE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBktaWGL+nsYDeQ22H29T7708cuCbVpYatWsfswB LsgPmEyUSSJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZLWlhgAKCRAk1otyXVSH 0GQhB/9KWjFZlmAi+CPCw9ErcXaD+o+f0UjE/xjMg7gOp/EfCUE6G2TwovHElx9AmZ0pmW3Ua+H LLIazLhmOHiSHmoYSQ94ocWkaYUWes9LUSOfVeQsVinH+LHGFmCUy3dc1BrE+Va0wbXbohaCpO1 lQeW9sv+UBPQRB/4cPXPd3bvfBb+ov1+mQ8TST3PqLXkkYymkJCT8W+5hxGa2H4tk1hpFJVa5Tq 9RG4/ljJ8eZoNKAkwD9uwkMlSLpKsF4qy8V90N0wgZ+7rDLzT2zVzDGntkGFVsTdb7b4hqAuBZ0 aac6c469KmaIBHy4OBB2ADZpICLO6aiyVzMmDOOB6lLC7f0s X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Message-ID-Hash: DYDM6Z74DXKMC6AMJUNCDCK3BGG5KQVZ X-Message-ID-Hash: DYDM6Z74DXKMC6AMJUNCDCK3BGG5KQVZ X-MailFrom: broonie@kernel.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: Provide a KUnit test for the newly added API. Signed-off-by: Mark Brown --- drivers/base/regmap/regmap-kunit.c | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/base/regmap/regmap-kunit.c b/drivers/base/regmap/regmap-kunit.c index 24257aa9004d..8dd96a55d976 100644 --- a/drivers/base/regmap/regmap-kunit.c +++ b/drivers/base/regmap/regmap-kunit.c @@ -833,6 +833,45 @@ static void cache_drop(struct kunit *test) regmap_exit(map); } +static void cache_present(struct kunit *test) +{ + struct regcache_types *t = (struct regcache_types *)test->param_value; + struct regmap *map; + struct regmap_config config; + struct regmap_ram_data *data; + unsigned int val; + int i; + + config = test_regmap_config; + config.cache_type = t->type; + + map = gen_regmap(&config, &data); + KUNIT_ASSERT_FALSE(test, IS_ERR(map)); + if (IS_ERR(map)) + return; + + for (i = 0; i < BLOCK_TEST_SIZE; i++) + data->read[i] = false; + + /* No defaults so no registers cached. */ + for (i = 0; i < BLOCK_TEST_SIZE; i++) + KUNIT_ASSERT_FALSE(test, regcache_reg_cached(map, i)); + + /* We didn't trigger any reads */ + for (i = 0; i < BLOCK_TEST_SIZE; i++) + KUNIT_ASSERT_FALSE(test, data->read[i]); + + /* Fill the cache */ + for (i = 0; i < BLOCK_TEST_SIZE; i++) + KUNIT_EXPECT_EQ(test, 0, regmap_read(map, i, &val)); + + /* Now everything should be cached */ + for (i = 0; i < BLOCK_TEST_SIZE; i++) + KUNIT_ASSERT_TRUE(test, regcache_reg_cached(map, i)); + + regmap_exit(map); +} + struct raw_test_types { const char *name; @@ -1172,6 +1211,7 @@ static struct kunit_case regmap_test_cases[] = { KUNIT_CASE_PARAM(cache_sync_readonly, real_cache_types_gen_params), KUNIT_CASE_PARAM(cache_sync_patch, real_cache_types_gen_params), KUNIT_CASE_PARAM(cache_drop, sparse_cache_types_gen_params), + KUNIT_CASE_PARAM(cache_present, sparse_cache_types_gen_params), KUNIT_CASE_PARAM(raw_read_defaults_single, raw_test_types_gen_params), KUNIT_CASE_PARAM(raw_read_defaults, raw_test_types_gen_params), From patchwork Mon Jul 17 20:33:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Brown X-Patchwork-Id: 13316578 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 alsa0.perex.cz (alsa0.perex.cz [77.48.224.243]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 55ACAC001B0 for ; Mon, 17 Jul 2023 20:35:58 +0000 (UTC) Received: from alsa1.perex.cz (alsa1.perex.cz [207.180.221.201]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by alsa0.perex.cz (Postfix) with ESMTPS id DC173E0F; Mon, 17 Jul 2023 22:35:05 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa0.perex.cz DC173E0F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=alsa-project.org; s=default; t=1689626155; bh=cdhA/uWMGFYNLiuZXNgnxDS/KR9lMC2udWWSbRYPndE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=LitSL3HI6I/pjqi23Hu4kzGh7AIlhmlDqc3C6PBtGGrmBz69ZRQNepR7aLxr4Z4YI d3h98SaoBrr5L3WtsOC/ZMU/vhU4sAXDx8rjcboK5VMQGGG9MBUqDJ7ZOYufRCfnej G0eEyozaqJkpbBDGwpzoALLF54yXiIAjzIW2Qb9g= Received: by alsa1.perex.cz (Postfix, from userid 50401) id 9746CF8047D; Mon, 17 Jul 2023 22:35:05 +0200 (CEST) Received: from mailman-core.alsa-project.org (mailman-core.alsa-project.org [10.254.200.10]) by alsa1.perex.cz (Postfix) with ESMTP id 064DCF80494; Mon, 17 Jul 2023 22:35:05 +0200 (CEST) Received: by alsa1.perex.cz (Postfix, from userid 50401) id E51EAF80494; Mon, 17 Jul 2023 22:35:01 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by alsa1.perex.cz (Postfix) with ESMTPS id A4E70F8047D for ; Mon, 17 Jul 2023 22:33:20 +0200 (CEST) DKIM-Filter: OpenDKIM Filter v2.11.0 alsa1.perex.cz A4E70F8047D Authentication-Results: alsa1.perex.cz; dkim=pass (2048-bit key, unprotected) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20201202 header.b=gLZUVojg 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 96EA461233; Mon, 17 Jul 2023 20:33:19 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B94ECC433C8; Mon, 17 Jul 2023 20:33:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1689625999; bh=cdhA/uWMGFYNLiuZXNgnxDS/KR9lMC2udWWSbRYPndE=; h=From:Date:Subject:References:In-Reply-To:To:Cc:From; b=gLZUVojg4jKy4PTMuuRaJRkPy+KTOrIc2UqPsvLIftUTjRU0kvMiaTuoTgweG9Bht gDFKrXKBxBCs+bnehoD3lhqDPcmEDlSGL6Idg9YliOGb435aFLHWn5PHm8/uCb3Kpm LDaOJU5IrN8F5ERCzO4kozWw4HWr+CTKw9cPrimuqScteGzPG3tEnRkSJ+YGKLXLYF 8oV/pREqjmFcItdEBJncwBwbGTV6R7uYNsU0Mkp+/0bZfzDp9mXJptYkw//OTqgE0E RNPM3BrwctvGv3QNMKYhdq3dEbQCBp8UIOVb909e4fIhvossYCCIUNYtbLks91BjZ1 MGv+Am4MHzkGw== From: Mark Brown Date: Mon, 17 Jul 2023 21:33:05 +0100 Subject: [PATCH 3/3] ALSA: hda: Use regcache_reg_cached() rather than open coding MIME-Version: 1.0 Message-Id: <20230717-regmap-cache-check-v1-3-73ef688afae3@kernel.org> References: <20230717-regmap-cache-check-v1-0-73ef688afae3@kernel.org> In-Reply-To: <20230717-regmap-cache-check-v1-0-73ef688afae3@kernel.org> To: Jaroslav Kysela , Takashi Iwai Cc: alsa-devel@alsa-project.org, linux-kernel@vger.kernel.org, Mark Brown X-Mailer: b4 0.13-dev-099c9 X-Developer-Signature: v=1; a=openpgp-sha256; l=1479; i=broonie@kernel.org; h=from:subject:message-id; bh=cdhA/uWMGFYNLiuZXNgnxDS/KR9lMC2udWWSbRYPndE=; b=owEBbQGS/pANAwAKASTWi3JdVIfQAcsmYgBktaWHp8xs+otXp3Fz83pPngNJL1ch5h3eptyOK 9g68ULu8WKJATMEAAEKAB0WIQSt5miqZ1cYtZ/in+ok1otyXVSH0AUCZLWlhwAKCRAk1otyXVSH 0FCcB/4/yqh/MT+mdIfR75L/u63k+FCJNO88xJeft85zjt58cF6oIUCQASp6BHpO+VK0Mqo+gaj vG2O+pbUy5tqfb6sVSbE3smMne18FuwqkldckIQsIxAQsJmjZgroJDCXgjiFqmIpfURfXQE021y kBTCvDuGa4jfVy7zC5w8JYa6TabufjXiuWOZ04u9a+8ngQjVvPbJFxFEG3OMKpGdOx/mHIhyFj/ OjMt+3AN1u3TX69YaRBa+908Tpc7x20j2RZro3hA/wiZ8Ogw2Xj1C//ABatTJx3oh57QxhcfXqC oMyVfCXaeM3x8HbZiNxXDtBC/mob9h9QTvXJLImqCDortOj+ X-Developer-Key: i=broonie@kernel.org; a=openpgp; fpr=3F2568AAC26998F9E813A1C5C3F436CA30F5D8EB Message-ID-Hash: LCFWYOPFOARDWVOMP6SZLMUVGQIEWJ2P X-Message-ID-Hash: LCFWYOPFOARDWVOMP6SZLMUVGQIEWJ2P X-MailFrom: broonie@kernel.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-alsa-devel.alsa-project.org-0; header-match-alsa-devel.alsa-project.org-1; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.8 Precedence: list List-Id: "Alsa-devel mailing list for ALSA developers - http://www.alsa-project.org" Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: The HDA driver intentionally drops repeated writes to registers in some circumstances, beyond the suppression of noop writes that regmap does in regmap_update_bits(). It does this by checking if the register is cached before doing a regmap_update_bits(), now we have an API for querying this directly use it directly rather than trying a read in cache only mode making the code a little clearer. Signed-off-by: Mark Brown --- sound/hda/hdac_regmap.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sound/hda/hdac_regmap.c b/sound/hda/hdac_regmap.c index 9b1bcabd8414..97cee096a286 100644 --- a/sound/hda/hdac_regmap.c +++ b/sound/hda/hdac_regmap.c @@ -556,17 +556,14 @@ EXPORT_SYMBOL_GPL(snd_hdac_regmap_update_raw); static int reg_raw_update_once(struct hdac_device *codec, unsigned int reg, unsigned int mask, unsigned int val) { - unsigned int orig; - int err; + int err = 0; if (!codec->regmap) return reg_raw_update(codec, reg, mask, val); mutex_lock(&codec->regmap_lock); - regcache_cache_only(codec->regmap, true); - err = regmap_read(codec->regmap, reg, &orig); - regcache_cache_only(codec->regmap, false); - if (err < 0) + /* Discard any updates to already initialised registers. */ + if (!regcache_reg_cached(codec->regmap, reg)) err = regmap_update_bits(codec->regmap, reg, mask, val); mutex_unlock(&codec->regmap_lock); return err;