Message ID | 20230717191654.1303285-1-samuel.holland@sifive.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:c923:0:b0:3e4:2afc:c1 with SMTP id j3csp1307596vqt; Mon, 17 Jul 2023 12:40:09 -0700 (PDT) X-Google-Smtp-Source: APBJJlGkMLQ2+rKfCIfM2aky1Wv9hqS2sUq1qpsmU2dvdFMccCffQsBbcry6c4iq4CKtnL/FTDwV X-Received: by 2002:aca:e154:0:b0:3a0:ff3a:72e2 with SMTP id y81-20020acae154000000b003a0ff3a72e2mr10518665oig.35.1689622809149; Mon, 17 Jul 2023 12:40:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689622809; cv=none; d=google.com; s=arc-20160816; b=tUrD6PE3lhNjnofAH2Xh/IpZmgvXheybf5BzowUntCK6+YqbEF/+Aw/Zk9oCTVj99g DT4/qf/bNPSRnZ7O4WnhIPrXwMi5xtSVXhg/Sb7sZRVQJv2j1U3I7OJI0ryh1WKP6svy 9brTVkkJXjwSQsSTq23w+o6Rdy58bZnl3DtHwplwam3pIgWy+vOedL3/4llLYZupk1hh q3JBvcL0UUXLOxnyDu8luJ4AXMQseIzGF/6tofNXhM57oDnJGV0muLMpVqtcc5pRH7e3 kH0wEIbWPkRDHKOcLUv+8pNGDqZGFC7jfOiDXRTnzL/Y9AsCAiSB3YLRMs9ECBFGPKiD 063g== 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=eJ6YReQN52ePsFxQCiGniW4yULFrXJ1nTk50bawBDOU=; fh=YWEUotPxKOdhAyC7YjMgQyJCb+Tv6pkKV9OYgyTOxaw=; b=LucXzdkzxj/piVfHM+J+Eyw75yVtAG0dEkV7re7uPzmFslGOZV7W3gdODtjvIWSUWz olGLl1P6yM96lF5Ge70MmGMdX1AI+bnNtrtfeQ863TulTiXrSJ4aj272eYw21yW12Jdf 4HugyUYKZ3Se/cgBQXLK0hXiyvJ2j7v+Bj3DlHgAoJBzUyG7tfMgrFeLml8+Eo8vHy1R QO6NiDN0qyWrv5ROa2jINqLJztU/Qbu8yOWWHRpxVuJw5yMtQ8NNl66lYdSGVqA7E+SB 39hBUXQXxEvYzryA9sHV8UyFQ+YYAIErYr1Mn/1MlKT0Ej5h8xn9TMl51YL6yPkfGeRl lbDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@sifive.com header.s=google header.b=QIYXFB0r; 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=sifive.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k25-20020a6568d9000000b0055727399652si255172pgt.577.2023.07.17.12.39.55; Mon, 17 Jul 2023 12:40:09 -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=@sifive.com header.s=google header.b=QIYXFB0r; 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=sifive.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229891AbjGQTRC (ORCPT <rfc822;hadasmailinglist@gmail.com> + 99 others); Mon, 17 Jul 2023 15:17:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229540AbjGQTRB (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 17 Jul 2023 15:17:01 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4EC0116 for <linux-kernel@vger.kernel.org>; Mon, 17 Jul 2023 12:16:59 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1b89cfb4571so39252535ad.3 for <linux-kernel@vger.kernel.org>; Mon, 17 Jul 2023 12:16:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sifive.com; s=google; t=1689621419; x=1692213419; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=eJ6YReQN52ePsFxQCiGniW4yULFrXJ1nTk50bawBDOU=; b=QIYXFB0r9Zt37S8ztvgFWTvQOKTaEqO1T7XgB4RZwHDwOzuIiLH0BMTQDA0Fg8oFNX J0We84AOKGsuh7y7YSF0SCTEHJX6ElIex/HCYPrNn1MnDY0RUNDJzEU57GMRxZe0UPO/ jQYkb6PhJz7gHgq/2oVqS0rZ2W/TNJSnQFDWage3vtju27KayjWF2gIYFFhtB0lJNoF3 2Xflp5+2yU7R3y3jEcKO1wEcP5FO1u53JX80Y8PirHZqKe3Mz4DG2ErZax3ieDJmeP64 3/f//R6vGRrthNgOf8OtkAVjpiG2M5jFLrFpH9cPedzjt72ZcMK2tiTBSmXBRPo2s9W4 KC3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689621419; x=1692213419; 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=eJ6YReQN52ePsFxQCiGniW4yULFrXJ1nTk50bawBDOU=; b=fJSF/kuwuJUOVMR6ph6fu4Kk016g9tW+7iBz7czzLCgYvPgrUW7vf2aazsvIIetkGu AYvOk0UW6pjPgHfEwFbrfW5RWhJB81w2gF36wx1VdvFqfNXlGwtcF0YC0SEZ8/8t5UXM XtZnkwAkDooKDl3KbNTqlz8kN7Y667oamTipYjB1hazxYsHQyHeOQcT4KJ9JX5si/yWz ihkyxKzxGMZcN0OLYrCButzGE6rqRC6X0CupeDyV30ZfCg6WyXYPUIAky/q05skwtf88 Z7IhG1QODsQF8CLKS1kW5HTWjtCKaNEvd3EB/T2wBGDtun6op5Q/6ZINAUKB2iN7lOby wgeg== X-Gm-Message-State: ABy/qLYeeZwjx6y/xoJaEHuHpVj7+O5cdsmu1YJQ2ztBItSk38gW5aVI 076w3u49qdGMJEAl2Et7q8birmQkeuobsBoWc1+SCg== X-Received: by 2002:a17:902:ea01:b0:1bb:3e35:6416 with SMTP id s1-20020a170902ea0100b001bb3e356416mr1250281plg.56.1689621419409; Mon, 17 Jul 2023 12:16:59 -0700 (PDT) Received: from sw06.internal.sifive.com ([64.62.193.194]) by smtp.gmail.com with ESMTPSA id g24-20020a170902869800b001b9df8f14d7sm210296plo.267.2023.07.17.12.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 12:16:59 -0700 (PDT) From: Samuel Holland <samuel.holland@sifive.com> To: Mark Brown <broonie@kernel.org> Cc: Samuel Holland <samuel.holland@sifive.com>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Laxman Dewangan <ldewangan@nvidia.com>, "Rafael J. Wysocki" <rafael@kernel.org>, linux-kernel@vger.kernel.org Subject: [PATCH] regmap-irq: Set IRQCHIP_MASK_ON_SUSPEND if no wake_base Date: Mon, 17 Jul 2023 12:16:54 -0700 Message-Id: <20230717191654.1303285-1-samuel.holland@sifive.com> X-Mailer: git-send-email 2.40.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, 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: INBOX X-GMAIL-THRID: 1771697433800121072 X-GMAIL-MSGID: 1771697927015206225 |
Series |
regmap-irq: Set IRQCHIP_MASK_ON_SUSPEND if no wake_base
|
|
Commit Message
Samuel Holland
July 17, 2023, 7:16 p.m. UTC
If hardware provides no way to control which IRQs are wakeup enabled,
then software needs to mask non-wakeup-enabled IRQs when going to sleep.
Fixes: 55ac85e942c6 ("regmap: irq: enable wake support by default")
Signed-off-by: Samuel Holland <samuel.holland@sifive.com>
---
drivers/base/regmap/regmap-irq.c | 2 ++
1 file changed, 2 insertions(+)
Comments
On Jul 17, 2023, at 2:22 PM, Mark Brown <broonie@kernel.org> wrote: > > On Mon, Jul 17, 2023 at 12:16:54PM -0700, Samuel Holland wrote: > >> If hardware provides no way to control which IRQs are wakeup enabled, >> then software needs to mask non-wakeup-enabled IRQs when going to sleep. > > This isn't an unambigiously clear statement, especially for MFDs where > there might be a desire to have some function on the device be able to > wake the system (eg, headset button press on an audio CODEC or a RTC on > a PMIC) even if there's no control within the device... > >> Fixes: 55ac85e942c6 ("regmap: irq: enable wake support by default") > > ...as the commit log does hint at. If there's a problem I think we need > some finer grained control here. The current problem is that if wakeup is enabled for any IRQ in the chip (say, the PMIC's power button), then we enable wakeup for the parent IRQ, and now suddenly all (enabled) IRQs on the PMIC are also inadvertently wakeup-enabled. But I realize this patch does not actually solve the issue, for a couple of reasons: 1) regmap-irq does not implement .irq_mask, just .irq_disable. 2) The __disable_irq() call in suspend_device_irq() should be sufficient, except that we fail the irq_settings_is_nested_thread() check in suspend_device_irqs(). So maybe the real issue is that commit 3c646f2c6aa9 ("genirq: Don't suspend nested_thread irqs over system suspend") missed the case where the child IRQ should be suspended, but the parent IRQ should not. If that is fixed, then suspend_device_irq() should do the right thing without any changes to the regmap-irq code. Sorry for the noise.
On Mon, Jul 17, 2023 at 02:54:18PM -0500, Samuel Holland wrote: > The current problem is that if wakeup is enabled for any IRQ in the chip > (say, the PMIC's power button), then we enable wakeup for the parent IRQ, > and now suddenly all (enabled) IRQs on the PMIC are also inadvertently > wakeup-enabled. Yeah, I can see the issue. > But I realize this patch does not actually solve the issue, for a couple > of reasons: > 1) regmap-irq does not implement .irq_mask, just .irq_disable. It's possible we're doing the wrong thing here? It's been a decade or something since I wrote this code. > 2) The __disable_irq() call in suspend_device_irq() should be sufficient, > except that we fail the irq_settings_is_nested_thread() check in > suspend_device_irqs(). > So maybe the real issue is that commit 3c646f2c6aa9 ("genirq: Don't > suspend nested_thread irqs over system suspend") missed the case where > the child IRQ should be suspended, but the parent IRQ should not. > If that is fixed, then suspend_device_irq() should do the right thing > without any changes to the regmap-irq code. > Sorry for the noise. No worries, I can see the logic and it feels like there might be something to look at here, I'm just not sure that's it.
diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c index ced0dcf86e0b..d7e076cff6e1 100644 --- a/drivers/base/regmap/regmap-irq.c +++ b/drivers/base/regmap/regmap-irq.c @@ -728,6 +728,8 @@ int regmap_add_irq_chip_fwnode(struct fwnode_handle *fwnode, d->irq_chip = regmap_irq_chip; d->irq_chip.name = chip->name; + if (!chip->wake_base) + d->irq_chip.flags |= IRQCHIP_MASK_ON_SUSPEND; d->irq = irq; d->map = map; d->chip = chip;