Message ID | 20230310073911.3470892-1-alexander.stein@ew.tq-group.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp737018wrd; Thu, 9 Mar 2023 23:48:39 -0800 (PST) X-Google-Smtp-Source: AK7set/kHH61o0U7EqwQ7HVJaOl98l8UNmV3PzzEB5kAl0DD2Tdve3CZeloGseh0yC2MkK2++1rS X-Received: by 2002:a17:902:e5d2:b0:19a:75b8:f50c with SMTP id u18-20020a170902e5d200b0019a75b8f50cmr30797000plf.31.1678434518745; Thu, 09 Mar 2023 23:48:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1678434518; cv=none; d=google.com; s=arc-20160816; b=no3KW7nh5UffePigskxtf8jgH/ngzLhWF77ThIeLXrhA3Zu5sS8sJ7JuaQoUFpNRlu qBRewNOtVSXy/L2rAJmn1PYM404gf0M1VRSKfguLCM/Loj+kGAk1+KERdsAmDnLO/Y1m SMc6eKZSkCEKSFnuPwxiPuTcN1qQuuKzocq1MJbRANP1aQ2dOnatg2Fmncy9szoZhMEt LVFwomJyVAM8FJ4z+Wv9hPcp3cYGrJC1L7LfHLEX0bTktGFs1dIIKzfBb9SQDuczuw3K zYhmLU1D2ga6lhyKXQFb0jAS0xapETGkBirfWxWFLFAn0MtQiVdq1zQSlmaqnSioE/ol RJgw== 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:dkim-signature; bh=RVir8PNcQqVGvCKOviPPrwuzapNZGlD3K49gWLW3WRM=; b=r6xDOWnHXlitMiWWlsd13AStvvmcGUpH4i68NJEM9AopX6PnqVowU+pJXWxUJc8jw3 Rzpzl91uQdpuHToUCMB6nfrb3w3nPtir29WubLwooYrQgi6U4dPLuygwoDgEWMWzhmiB q3D715ffs5EBv4b9vlZFeVdqr58Y2jj2NUShCGZEWIyh6b8GkhkiR1vPM2qAL0BdAT5J GD2gPftgCjpaKaMDAJVqQrXZ5uU8dupsQg03yim5Zcga5SdbidIbVm45fuEbVtrQOHch qYDdiedh7EtXDVLTb9golyuM4BO2JnpzGEn8i8x3UFWuXEcJNZbc6JyraU8Ss+uaEFwr rN0Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tq-group.com header.s=key1 header.b=YKYxce8p; dkim=pass header.i=@tq-group.com header.s=key1 header.b=k5Lm6vTr; 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=tq-group.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id e13-20020a170902cf4d00b0019aa9ef4f47si1485486plg.443.2023.03.09.23.48.24; Thu, 09 Mar 2023 23:48:38 -0800 (PST) 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=@tq-group.com header.s=key1 header.b=YKYxce8p; dkim=pass header.i=@tq-group.com header.s=key1 header.b=k5Lm6vTr; 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=tq-group.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230171AbjCJHja (ORCPT <rfc822;carlos.wei.hk@gmail.com> + 99 others); Fri, 10 Mar 2023 02:39:30 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33234 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230199AbjCJHjW (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Fri, 10 Mar 2023 02:39:22 -0500 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AC61F2C2A for <linux-kernel@vger.kernel.org>; Thu, 9 Mar 2023 23:39:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1678433959; x=1709969959; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=RVir8PNcQqVGvCKOviPPrwuzapNZGlD3K49gWLW3WRM=; b=YKYxce8pmuvV3NLlVTWNvNQz0Izu8XMzHPq/jUiTDeykPd88eIvMmA7p eg8C4lbLRcUyN4eXvE8JKb3VHNiGNtVlFk/fofx0DqG9skQKhEfF8quPm 3rf+mSSmmRLywQEHvdwDERK97175UX3qAoJFMwy/s4kbT0TfzktES6KJQ pnmQOnEBvPpCI80dc7XH9JihwTNaSA1YL6zLVbQtTdBww+oQZOTFG18Yw nimxMMWr5SPrmeFCZVOOIj0p90yO+XKYMoOC/UnR3yxYy5p43DiGVVfc7 DakfiPwnmAfxEiBEqIAHx8D13+VS7WWYU1CS+E1HOHKx0V6PbwHK2KZWb A==; X-IronPort-AV: E=Sophos;i="5.98,249,1673910000"; d="scan'208";a="29596580" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 10 Mar 2023 08:39:17 +0100 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Fri, 10 Mar 2023 08:39:17 +0100 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Fri, 10 Mar 2023 08:39:17 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1678433957; x=1709969957; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=RVir8PNcQqVGvCKOviPPrwuzapNZGlD3K49gWLW3WRM=; b=k5Lm6vTrEVwK6Pr6smcQcDMz1ugMIjfmp36LKcwZI4gwSx2z+UjZp6/1 7lSsmcrQNutaVB50ftsuLrW9ago+5rXL4vUktb5IaeiS874j6x0/m8M7C EtdMF9nToxxcLAQ/evEdut3UuSQ4GiTSRtcAm/txOywdZ8DhSIWziq9+o JQHYI4cCMWhEAQNZpHQWxloS9Sgm7IemTNqXXF5skcAI4HbLbvCBEA+Wn 6vSnaSietokZfxhab+r5g4zmhdkvi5RurDJwrlvQEWhuLLEI4Nqmj9hLY B/9X6hkeyoBMn4O4j6+N1bV4UwqT7xXDP5VUTqdCmxLClKzUSV/XCng0o Q==; X-IronPort-AV: E=Sophos;i="5.98,249,1673910000"; d="scan'208";a="29596578" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 10 Mar 2023 08:39:17 +0100 Received: from steina-w.tq-net.de (unknown [10.123.53.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by vtuxmail01.tq-net.de (Postfix) with ESMTPSA id 16E92280056; Fri, 10 Mar 2023 08:39:17 +0100 (CET) From: Alexander Stein <alexander.stein@ew.tq-group.com> To: Mark Brown <broonie@kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, "Rafael J . Wysocki" <rafael@kernel.org> Cc: Alexander Stein <alexander.stein@ew.tq-group.com>, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] regmap: cache: Do not panic for REGCACHE_NONE regmap Date: Fri, 10 Mar 2023 08:39:10 +0100 Message-Id: <20230310073911.3470892-1-alexander.stein@ew.tq-group.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,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?1759966154037914904?= X-GMAIL-MSGID: =?utf-8?q?1759966154037914904?= |
Series |
[1/2] regmap: cache: Do not panic for REGCACHE_NONE regmap
|
|
Commit Message
Alexander Stein
March 10, 2023, 7:39 a.m. UTC
Most regcache operations do check for REGCACHE_NONE, before ensuring
doing BUG_ON(!map->cache_ops). The missing regcache_sync* functions
panic on REGCACHE_NONE regmaps instead. Add an early return for non-cached
ones.
Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com>
---
drivers/base/regmap/regcache.c | 6 ++++++
1 file changed, 6 insertions(+)
Comments
On Fri, Mar 10, 2023 at 08:39:10AM +0100, Alexander Stein wrote: > Most regcache operations do check for REGCACHE_NONE, before ensuring > doing BUG_ON(!map->cache_ops). The missing regcache_sync* functions > panic on REGCACHE_NONE regmaps instead. Add an early return for non-cached > ones. Why would we be trying to do a regcache_sync() on a device with no cache?
Hi Mark, Am Freitag, 10. März 2023, 14:02:13 CET schrieb Mark Brown: > * PGP Signed by an unknown key > > On Fri, Mar 10, 2023 at 08:39:10AM +0100, Alexander Stein wrote: > > Most regcache operations do check for REGCACHE_NONE, before ensuring > > doing BUG_ON(!map->cache_ops). The missing regcache_sync* functions > > panic on REGCACHE_NONE regmaps instead. Add an early return for non-cached > > ones. > > Why would we be trying to do a regcache_sync() on a device with > no cache? Indeed, that makes no sense. That's indicating a bug in a driver, but why do we need to panic the kernel in this case? On the other hand the same question applies to other regcache related functions currently checking for non-cached maps. There is no common behaviour: panic: * regcache_sync * regcache_sync_region returning -EINVAL: * regcache_drop_region returning -ENOSYS: * regcache_read returning success (0): * regcache_write early return (void return value): * regcache_exit Given all these possibilities I have no idea what's the right thing to do. Best regards, Alexander
On Fri, Mar 10, 2023 at 02:35:13PM +0100, Alexander Stein wrote: > Am Freitag, 10. März 2023, 14:02:13 CET schrieb Mark Brown: > > Why would we be trying to do a regcache_sync() on a device with > > no cache? > Indeed, that makes no sense. That's indicating a bug in a driver, but why do > we need to panic the kernel in this case? You're trying to change this to silently ignore the call which isn't going to make anything happy. > On the other hand the same question applies to other regcache related > functions currently checking for non-cached maps. There is no common > behaviour: > panic: > * regcache_sync > * regcache_sync_region These are only ever triggered from a client driver, nothing in regmap will ever sync the regmap without being explicitly asked to. > returning -ENOSYS: > * regcache_read > returning success (0): > * regcache_write > early return (void return value): > * regcache_exit These are all called transparently as part of the regmap core regardless of if there is a cache, users never directly read or write values to the cache.
diff --git a/drivers/base/regmap/regcache.c b/drivers/base/regmap/regcache.c index 362e043e26d8..b61763dbfc68 100644 --- a/drivers/base/regmap/regcache.c +++ b/drivers/base/regmap/regcache.c @@ -349,6 +349,9 @@ int regcache_sync(struct regmap *map) const char *name; bool bypass; + if (map->cache_type == REGCACHE_NONE) + return 0; + BUG_ON(!map->cache_ops); map->lock(map->lock_arg); @@ -418,6 +421,9 @@ int regcache_sync_region(struct regmap *map, unsigned int min, const char *name; bool bypass; + if (map->cache_type == REGCACHE_NONE) + return 0; + BUG_ON(!map->cache_ops); map->lock(map->lock_arg);