Message ID | 20230216222214.138671-2-aidanmacdonald.0x0@gmail.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:eb09:0:0:0:0:0 with SMTP id s9csp563152wrn; Thu, 16 Feb 2023 14:33:14 -0800 (PST) X-Google-Smtp-Source: AK7set8QX1vAOpJl7wIcBrQDaUb0T3VbTMhVqKGZwGctMHqLH97S9+77yT6qcHtdhWw4fe+NYgta X-Received: by 2002:a05:6a20:ae2f:b0:be:c73d:d847 with SMTP id dp47-20020a056a20ae2f00b000bec73dd847mr5059227pzb.28.1676586794408; Thu, 16 Feb 2023 14:33:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1676586794; cv=none; d=google.com; s=arc-20160816; b=MhIAr5yNRwUnMb/mVymv8QMmxJgtl1IQsxvKJoFtUOp65kmlh5btgaKffSqZcEOm0/ DmUHQM16VuOpyrJwW6cWBmfmVYjCqHpN2l37xWb0PH6z/GpUTCd2k9kE96Ue6P92rhHL yimguW97ylkoVWzJ+pUZ83nal+08bMLRt5+vEqWtbefoIjJSEnzIo+sZ4Ng1YFqd4bWr 5RujtYK816fdB7Z9fLRCAvNFgtMNWWmz8Ru5OBvqVAFBkHbscb5JbiWRW4ti6s3K/Lfo O1UjQpW4Mc5a9AynGTQnFGJkrlRqTneapDLZo/AM6d6SOOUcwWrz9cgQDUnHvSHv2TlH /yVw== 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=gxhw9+oUu19wOC1+A4ZrVTxRyv+NLoeQFK80oVeop4s=; b=QUpmeXIccdsvm1R0jP7ROEJSgnAu6NnGuEZ+wNkkvItw/1yYDv45U43P7GKAzPwRTM N2B5xTT0/+btB2274GCWs/3EpGMubKPYlKP5Zj6ltxbeA5ACytYXM0MQEY5TYYmQQKB+ V0ByawEqq+pF+zDS/DNyjFU4e9J+2zWNjdVZYwI7IIAFDfRfCdJom5eMpCDGKtZsUCwi qsjbJOYx83ONBBoYrxHwJzGK+4C1OBCh6I1+11O5mYQu/6I4JccFP2Z7HUpWH4oWhXEX mKB+e+uVY8x2fRUuINLA+Kdp45hm+ECzGpMBKRJvxj9sHcZoBg8WPQv5AXyt035B+ZCg 1RYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=iMFdSryN; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k2-20020a633d02000000b004e2e673f492si2953032pga.530.2023.02.16.14.33.01; Thu, 16 Feb 2023 14:33:14 -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=@gmail.com header.s=20210112 header.b=iMFdSryN; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbjBPWWp (ORCPT <rfc822;aimixsaka@gmail.com> + 99 others); Thu, 16 Feb 2023 17:22:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230268AbjBPWWn (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 16 Feb 2023 17:22:43 -0500 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CB2884BE9F; Thu, 16 Feb 2023 14:22:42 -0800 (PST) Received: by mail-wm1-x331.google.com with SMTP id z12-20020a1c4c0c000000b003e21e018039so975903wmf.3; Thu, 16 Feb 2023 14:22:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gxhw9+oUu19wOC1+A4ZrVTxRyv+NLoeQFK80oVeop4s=; b=iMFdSryN/WfsKpTkbgLLnFLI2GjaPgj6aSHCpT3zK8GEyFw3bmU69EVAekRV1jHjLt 2kEBOZ/q43QhBQSSepQL5hYnqlenJNeyD9mL8alR7SvEmYD09KSIplylrmiBJamTFhHs 0TVIO1Wvc1tut2djcgu7NOnyTY13B4GhY35FjZtBaa5vo45ZlGq2GWuI5I49eUPffb+6 qgjef5kn1Oi9idnALkk517TzmTFQX58S5ZvXDySCGK3FlZm1nEmrLHZuliXrZUa4+pBt +iDSlt1/qDRw8VaHk/aLkI8ombAohCbkNVNuf2cleFzyEVgPRpe5OIpjhVoEg6OOs0yv E2sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gxhw9+oUu19wOC1+A4ZrVTxRyv+NLoeQFK80oVeop4s=; b=dcW9xLjfRXWje8bDYGPBqKNL/W6a7OMX4t7+YFzxkR37NSQKUq3rajEiKucpn8JWxq +nV7BQvepCFstaIQx0To3SndoUUfFkyNv68kEYA3ykj5vWsIhD+Dafk1U6R+UrF6LCTj VAiX+Jmlj2l8gDsc3C590Zg9qsoD0UMojou+FttaOWDUgEW9UkukyzPSnsaUxMMoRBy1 1xDuUSpXQy5YBdISBgwPehdyn9pwt4CGTeB6XjggRWfrdWxuq9x7n2AQXRNN7fCqEpKl a6AhPlvoxaPOK++BXoM+c3D1duHMFM5Ez5M+FDyGPoeqodW9MXFAwqSZVvYgfg/ypmVr O6gA== X-Gm-Message-State: AO0yUKU4jJ+mmujLEWG6t3IsRTkvtBLtxvM8VZnpE6zbeRohRXraJ+X7 hzzxBGwI1Elms3cQpyyzh0Y= X-Received: by 2002:a05:600c:188a:b0:3e2:589:2512 with SMTP id x10-20020a05600c188a00b003e205892512mr5090655wmp.21.1676586161234; Thu, 16 Feb 2023 14:22:41 -0800 (PST) Received: from localhost (94.197.187.145.threembb.co.uk. [94.197.187.145]) by smtp.gmail.com with ESMTPSA id d21-20020a05600c34d500b003daffc2ecdesm6794420wmq.13.2023.02.16.14.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Feb 2023 14:22:41 -0800 (PST) From: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> To: agross@kernel.org, andersson@kernel.org, lee@kernel.org Cc: konrad.dybcio@linaro.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 1/4] mfd: qcom-pm8008: Fix swapped mask/unmask in irq chip Date: Thu, 16 Feb 2023 22:22:11 +0000 Message-Id: <20230216222214.138671-2-aidanmacdonald.0x0@gmail.com> In-Reply-To: <20230216222214.138671-1-aidanmacdonald.0x0@gmail.com> References: <20230216222214.138671-1-aidanmacdonald.0x0@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS 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?1758028674385954962?= X-GMAIL-MSGID: =?utf-8?q?1758028674385954962?= |
Series |
regmap-irq fixes for qcom-pm8008
|
|
Commit Message
Aidan MacDonald
Feb. 16, 2023, 10:22 p.m. UTC
The usual behavior of mask registers is writing a '1' bit to
disable (mask) an interrupt; similarly, writing a '1' bit to
an unmask register enables (unmasks) an interrupt.
Due to a longstanding issue in regmap-irq, mask and unmask
registers were inverted when both kinds of registers were
present on the same chip, ie. regmap-irq actually wrote '1's
to the mask register to enable an IRQ and '1's to the unmask
register to disable an IRQ.
This was fixed by commit e8ffb12e7f06 ("regmap-irq: Fix
inverted handling of unmask registers") but the fix is opt-in
via mask_unmask_non_inverted = true because it requires manual
changes for each affected driver. The new behavior will become
the default once all drivers have been updated.
The PM8008 appears to rely on the inverted behavior. It has
separate set & clear registers for a register called INT_EN,
which presumably enables interrupts by writing '1's. Opt in
to the new non-inverted behavior & swap mask_base/unmask_base.
Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com>
---
drivers/mfd/qcom-pm8008.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Comments
On Thu, 16 Feb 2023, Aidan MacDonald wrote: > The usual behavior of mask registers is writing a '1' bit to > disable (mask) an interrupt; similarly, writing a '1' bit to > an unmask register enables (unmasks) an interrupt. > > Due to a longstanding issue in regmap-irq, mask and unmask > registers were inverted when both kinds of registers were > present on the same chip, ie. regmap-irq actually wrote '1's > to the mask register to enable an IRQ and '1's to the unmask > register to disable an IRQ. > > This was fixed by commit e8ffb12e7f06 ("regmap-irq: Fix > inverted handling of unmask registers") but the fix is opt-in > via mask_unmask_non_inverted = true because it requires manual > changes for each affected driver. The new behavior will become > the default once all drivers have been updated. > > The PM8008 appears to rely on the inverted behavior. It has > separate set & clear registers for a register called INT_EN, > which presumably enables interrupts by writing '1's. Opt in > to the new non-inverted behavior & swap mask_base/unmask_base. > > Signed-off-by: Aidan MacDonald <aidanmacdonald.0x0@gmail.com> > --- > drivers/mfd/qcom-pm8008.c | 5 +++-- > 1 file changed, 3 insertions(+), 2 deletions(-) Applied, thanks
diff --git a/drivers/mfd/qcom-pm8008.c b/drivers/mfd/qcom-pm8008.c index 9f3c4a01b4c1..39fd2a792e73 100644 --- a/drivers/mfd/qcom-pm8008.c +++ b/drivers/mfd/qcom-pm8008.c @@ -45,8 +45,8 @@ enum { #define PM8008_GPIO2_ADDR PM8008_PERIPH_3_BASE #define PM8008_STATUS_BASE (PM8008_PERIPH_0_BASE | INT_LATCHED_STS_OFFSET) -#define PM8008_MASK_BASE (PM8008_PERIPH_0_BASE | INT_EN_SET_OFFSET) -#define PM8008_UNMASK_BASE (PM8008_PERIPH_0_BASE | INT_EN_CLR_OFFSET) +#define PM8008_MASK_BASE (PM8008_PERIPH_0_BASE | INT_EN_CLR_OFFSET) +#define PM8008_UNMASK_BASE (PM8008_PERIPH_0_BASE | INT_EN_SET_OFFSET) #define PM8008_TYPE_BASE (PM8008_PERIPH_0_BASE | INT_SET_TYPE_OFFSET) #define PM8008_ACK_BASE (PM8008_PERIPH_0_BASE | INT_LATCHED_CLR_OFFSET) #define PM8008_POLARITY_HI_BASE (PM8008_PERIPH_0_BASE | INT_POL_HIGH_OFFSET) @@ -131,6 +131,7 @@ static struct regmap_irq_chip pm8008_irq_chip = { .status_base = PM8008_STATUS_BASE, .mask_base = PM8008_MASK_BASE, .unmask_base = PM8008_UNMASK_BASE, + .mask_unmask_non_inverted = true, .type_base = PM8008_TYPE_BASE, .ack_base = PM8008_ACK_BASE, .virt_reg_base = pm8008_virt_regs,