From patchwork Thu Jun 1 10:10:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 101862 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp199475vqr; Thu, 1 Jun 2023 03:29:40 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5vuKvboI/xI00PH895BVJRCaQN8muTIEETvu2VtwGnbUaw10mt7ZgkTcBlJ9tCXMw/TPqQ X-Received: by 2002:a17:902:ea0c:b0:1ac:84dd:6d1f with SMTP id s12-20020a170902ea0c00b001ac84dd6d1fmr9493900plg.1.1685615380055; Thu, 01 Jun 2023 03:29:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685615380; cv=none; d=google.com; s=arc-20160816; b=eRzAyBkIJpUdGuCPSkS1YB9ntiBo4kibeHSwaMozi1cHYM2JN3QEgUHOCNY6veAM3T bppz00wx4hTktmPJ5e3c63NApsr/zEXmStQWXcPOINhC7bSSsTL/djmdROmY0hXls9PE 0DQRwHmNB3PMHh2doiwzhcjURId3QfELQfVHUeT1LzErXihwDZxXWsB1Z7jKgClRgDAV QH3mc4XpdM0Px2mHwrs0WtFeFdWh9TCaivxy3C2XDV2Ny4EDJW72TvgOG0CEMFSgxcei bgG/hRjjJuY5vVWP4vzOne6xa0MRot5PAVEuiPmz84Bnz6wY4VzDv6noCLp3qtx98cO7 4vqg== 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=n57MVcye861vqpd+7cbgKBm9G0JBu/LE6whTKr7WxlI=; b=hcoldOUJW8BvBMPboSMadWb86vzRcspraQBH9hKliTdDoaU8XlQ32S4bZMsgQWD/x0 c64OYjGw7+HSa9jxEVGkbs0XLMRHaujZw+6zrQ7+pJWcA1WBxmfVLqvzOwpgcsY/ghzt TqkO6UA4co7T8b/sFiHqZkD2K2tVallh8fdp/17sd2rW70PZCzB3HsG0/wBsKzp/YSSW HaBqXrg0Z6d5A/sU9Y8vijldC62ICJQ6MvZZ8azOeoSuVW/YoiGSpbCLQ+ySfKGw1QcP cLXOc7eBIjcE9eokmpRAyaO/E4g+Hltxt+YzbBR8wt6Q9I4BBucUh6zStWqw/HolGGh7 KLIg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b=UNuynko4; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x16-20020a170902ec9000b001adec0d4391si2650503plg.48.2023.06.01.03.29.25; Thu, 01 Jun 2023 03:29:40 -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=@cirrus.com header.s=PODMain02222019 header.b=UNuynko4; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232935AbjFAKMj (ORCPT + 99 others); Thu, 1 Jun 2023 06:12:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233349AbjFAKLe (ORCPT ); Thu, 1 Jun 2023 06:11:34 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D8A12E48 for ; Thu, 1 Jun 2023 03:10:49 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3515qxE9012309; Thu, 1 Jun 2023 05:10:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=n57MVcye861vqpd+7cbgKBm9G0JBu/LE6whTKr7WxlI=; b=UNuynko4ERYwUnoyhTmu23SbFs+TOrLsUcnyHY2urE1DaxYQHLyQ/gqNu1SZ70ma+yYT Ah8tA7198JwlbhUkSmut63pmUZQZmo69dsL3IGhagO35M6mC2nHBdqjdEM5rcA3l4AUd a1hV+rjD8OizS5TCvCFYyLB3LI0lhKV+9DODTGZ1Up7ljXPOqBPhubLGV5rbcDZcuhu0 LDbHfKmvilWv1/qf5BBWCFw2iSmInRXzxzYsYegYrfpY0Wo3UjXln260Opq4x+GuaJbE gD8+51+oyLhd4Zng2s79MmF2Ur8DPLiXyqdp6OEOCeuS4rUQA5kb4gor+xGffY3N2iJZ 2g== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3quf90wqub-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 05:10:45 -0500 Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 1 Jun 2023 11:10:36 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 1 Jun 2023 11:10:36 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 110B745; Thu, 1 Jun 2023 10:10:36 +0000 (UTC) From: Charles Keepax To: CC: , , , Subject: [PATCH 1/2] regmap: regmap-irq: Move handle_post_irq to before pm_runtime_put Date: Thu, 1 Jun 2023 11:10:35 +0100 Message-ID: <20230601101036.1499612-1-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-Proofpoint-GUID: LnamJCVghHxhPaqopfmDgt0U0VSt30OO X-Proofpoint-ORIG-GUID: LnamJCVghHxhPaqopfmDgt0U0VSt30OO X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1767495832678345483?= X-GMAIL-MSGID: =?utf-8?q?1767495832678345483?= Typically handle_post_irq is going to be used to manage some additional chip specific hardware operations required on each IRQ, these are very likely to want the chip to be resumed. For example the current in tree user max77620 uses this to toggle a global mask bit, which would obviously want the device resumed. It is worth noting this device does not specify the runtime_pm flag in regmap_irq_chip, so there is no actual issue. Move the callback to before the pm_runtime_put, so it will be called whilst the device is still resumed. Signed-off-by: Charles Keepax --- drivers/base/regmap/regmap-irq.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index 330da5d6c8c3a..ced0dcf86e0bf 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -502,12 +502,12 @@ static irqreturn_t regmap_irq_thread(int irq, void *d) } exit: - if (chip->runtime_pm) - pm_runtime_put(map->dev); - if (chip->handle_post_irq) chip->handle_post_irq(chip->irq_drv_data); + if (chip->runtime_pm) + pm_runtime_put(map->dev); + if (handled) return IRQ_HANDLED; else From patchwork Thu Jun 1 10:10:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Charles Keepax X-Patchwork-Id: 101866 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp201139vqr; Thu, 1 Jun 2023 03:32:07 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4nEzDMVF0hyPS0xZtHZ1dyeoRRi3wrpu/ewgxbInvmHdEEMl914QXViEKrrPFgdaMhPu8E X-Received: by 2002:a05:6808:1496:b0:398:36a0:d0c with SMTP id e22-20020a056808149600b0039836a00d0cmr8261293oiw.33.1685615527193; Thu, 01 Jun 2023 03:32:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685615527; cv=none; d=google.com; s=arc-20160816; b=xcQrl3mz07HbS/QhRfCP+Ux2RbsFSkAHbDNsyiIOH/3kb6PR8LeuBzmEHeyY6C/9g+ LAilXBuVBHqCQrfvGUz9BiPvuXzu0491MxT9Shpf23GSux/quhcssq0lTW7tOx2xLnXV Wm5Gc4dshL11+tuScYTLaOzrUUrniB3Ev3v7/8sALemj4IBQSo52Z7Q5oeqU3c3QAMhz USQorbT7aiI9bmwtIcSaZ9ejtnnycb1GIKowCKKOtlvRX58tnEKFF/Bh5CzGZYdfTwS5 LjvmLSfUbsBmep1lkZVmMTyEiswajTyVB9v8ODIQ4A2Zs/UZRDuwrymtREkRXBadZhLE Ke+Q== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=CYjUlUokqgwvfm/eWCGzun35GxlTrPgpDxWqqtsJt6s=; b=03vqTsz9KjF+HaO7hXcDeqOEtjeO59gvBcQ9uIb1W2/9oRjjkHyIdOw1y8tkoAvGTR 07FA0FE+BQtiR20aSKLfru2JKR3WDQVMwLCKkXn7SwroAx0zNQRkfBz4CQ0d93ZYoR6e asJCy8GpaZ182BB8pC6nUJC//OHJAQfYcdAHzpMON5qaFlRhkwnRNI6+tiON2H0as5Q4 ISup7488dycwlEOcpBErUIMGoma3tsSoAYyhyGwq+I8vX3w4qax4mS1gINc48MplxoBl /AH9ggAAmTdSfs8pMKQDsnvzqke322JhXwvmYC7U39RfuddCnlefi0suHypH5hpWcdVa 5LoA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@cirrus.com header.s=PODMain02222019 header.b="GgoEvh/w"; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r1-20020aa79621000000b0064d2e108cecsi3792338pfg.104.2023.06.01.03.31.53; Thu, 01 Jun 2023 03:32:07 -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=@cirrus.com header.s=PODMain02222019 header.b="GgoEvh/w"; 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=REJECT sp=REJECT dis=NONE) header.from=cirrus.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233189AbjFAKMm (ORCPT + 99 others); Thu, 1 Jun 2023 06:12:42 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233350AbjFAKLe (ORCPT ); Thu, 1 Jun 2023 06:11:34 -0400 Received: from mx0b-001ae601.pphosted.com (mx0a-001ae601.pphosted.com [67.231.149.25]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F2372E49 for ; Thu, 1 Jun 2023 03:10:49 -0700 (PDT) Received: from pps.filterd (m0077473.ppops.net [127.0.0.1]) by mx0a-001ae601.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3515qxEA012309; Thu, 1 Jun 2023 05:10:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cirrus.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=PODMain02222019; bh=CYjUlUokqgwvfm/eWCGzun35GxlTrPgpDxWqqtsJt6s=; b=GgoEvh/wmZtSEQZhKxSaZL2ozjG1nRLbK9GW52YTtWXC5mHYD4XVu8xPYaEM3NRPyAn7 T7oDYvu8F6Z7IJjc7EBRoxZPoAth0ORCP7KoLDkQFu/cHjMba8eZxkyPiyLFjL8hKyNL bVNhv937OSmAlvA4seZJyJd0VOYlFtUGPQBYrEwvRF0Y36RmYGBeLZydpXm4zbEGEcQF YUH9NO3xQvx5VfMPG0cEB0X83yd7jl55ZiKNoqH88gbWp/MOM5xButF1blKkLsaVhVci Zo1Chnd8c6W7ox2sFaeDdEdvexWze03vVJNspI1pXaJb5IYdQ5zaLOmb3ATHM/HcR4GG zA== Received: from ediex01.ad.cirrus.com ([84.19.233.68]) by mx0a-001ae601.pphosted.com (PPS) with ESMTPS id 3quf90wqub-2 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 01 Jun 2023 05:10:46 -0500 Received: from ediex02.ad.cirrus.com (198.61.84.81) by ediex01.ad.cirrus.com (198.61.84.80) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1118.26; Thu, 1 Jun 2023 11:10:36 +0100 Received: from ediswmail.ad.cirrus.com (198.61.86.93) by anon-ediex02.ad.cirrus.com (198.61.84.81) with Microsoft SMTP Server id 15.2.1118.26 via Frontend Transport; Thu, 1 Jun 2023 11:10:36 +0100 Received: from algalon.ad.cirrus.com (algalon.ad.cirrus.com [198.90.251.122]) by ediswmail.ad.cirrus.com (Postfix) with ESMTP id 2119C475; Thu, 1 Jun 2023 10:10:36 +0000 (UTC) From: Charles Keepax To: CC: , , , Subject: [PATCH 2/2] regmap: Add missing cache_only checks Date: Thu, 1 Jun 2023 11:10:36 +0100 Message-ID: <20230601101036.1499612-2-ckeepax@opensource.cirrus.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20230601101036.1499612-1-ckeepax@opensource.cirrus.com> References: <20230601101036.1499612-1-ckeepax@opensource.cirrus.com> MIME-Version: 1.0 X-Proofpoint-GUID: Liq_mNh9AWkq98Wsc3QFSaKV-UhO6GYd X-Proofpoint-ORIG-GUID: Liq_mNh9AWkq98Wsc3QFSaKV-UhO6GYd X-Proofpoint-Spam-Reason: safe X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,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?1767495987031482605?= X-GMAIL-MSGID: =?utf-8?q?1767495987031482605?= The current behaviour around cache_only is slightly inconsistent, most paths will only check cache_only if cache_bypass is false, and will return -EBUSY if a read attempts to go to the hardware whilst cache_only is true. However, a couple of paths will not check cache_only at all. The most notable of these being regmap_raw_read which will check cache_only in the case it processes the transaction one register at a time, but not in the case it handles them as a block. In the typical case a device has been put into cache_only whilst powered down this can cause physical reads to happen whilst the device is unavailable. Add a check in regmap_raw_read and move the check in regmap_noinc_read, adding a check for cache_bypass, such that all paths are covered and consistent. Signed-off-by: Charles Keepax --- drivers/base/regmap/regmap.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index fa2d3fba6ac9d..627a767fa0470 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -2983,6 +2983,11 @@ int regmap_raw_read(struct regmap *map, unsigned int reg, void *val, size_t chunk_count, chunk_bytes; size_t chunk_regs = val_count; + if (!map->cache_bypass && map->cache_only) { + ret = -EBUSY; + goto out; + } + if (!map->read) { ret = -ENOTSUPP; goto out; @@ -3078,18 +3083,19 @@ int regmap_noinc_read(struct regmap *map, unsigned int reg, goto out_unlock; } + /* + * We have not defined the FIFO semantics for cache, as the + * cache is just one value deep. Should we return the last + * written value? Just avoid this by always reading the FIFO + * even when using cache. Cache only will not work. + */ + if (!map->cache_bypass && map->cache_only) { + ret = -EBUSY; + goto out_unlock; + } + /* Use the accelerated operation if we can */ if (map->bus->reg_noinc_read) { - /* - * We have not defined the FIFO semantics for cache, as the - * cache is just one value deep. Should we return the last - * written value? Just avoid this by always reading the FIFO - * even when using cache. Cache only will not work. - */ - if (map->cache_only) { - ret = -EBUSY; - goto out_unlock; - } ret = regmap_noinc_readwrite(map, reg, val, val_len, false); goto out_unlock; }