lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20241102150045.218510-3-fido_max@inbox.ru>
Date: Sat,  2 Nov 2024 18:00:43 +0300
From: Maxim Kochetkov <fido_max@...ox.ru>
To: Mark Brown <broonie@...nel.org>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	"Rafael J. Wysocki" <rafael@...nel.org>,
	linux-kernel@...r.kernel.org
Cc: Maxim Kochetkov <fido_max@...ox.ru>
Subject: [PATCH] regmap-irq: Introduce ack_after_handle option

Some interrupt controllers may have simple level interrupt detection
without enable/disable functionality. Mask/unmask simply disables
interrupt signaling to the upstream chip. If we try to ack these
interrupts before handling, we will get a false interrupt with empty
status. So the only one possible way to handle this interrupts is
to ack them after handling.

Signed-off-by: Maxim Kochetkov <fido_max@...ox.ru>
---
 drivers/base/regmap/regmap-irq.c | 8 +++++++-
 include/linux/regmap.h           | 2 ++
 2 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 7dcd2118b4d2..8ad6486fc3bd 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -479,7 +479,7 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
 	for (i = 0; i < data->chip->num_regs; i++) {
 		data->status_buf[i] &= ~data->mask_buf[i];
 
-		if (data->status_buf[i])
+		if (!chip->ack_after_handle && data->status_buf[i])
 			regmap_irq_ack(data, data->status_buf[i], i);
 	}
 
@@ -491,6 +491,12 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
 		}
 	}
 
+	if (chip->ack_after_handle)
+		for (i = 0; i < data->chip->num_regs; i++) {
+			if (data->status_buf[i])
+				regmap_irq_ack(data, data->status_buf[i], i);
+		}
+
 exit:
 	if (chip->handle_post_irq)
 		chip->handle_post_irq(chip->irq_drv_data);
diff --git a/include/linux/regmap.h b/include/linux/regmap.h
index 570aa9d797b4..a6c94d2ba548 100644
--- a/include/linux/regmap.h
+++ b/include/linux/regmap.h
@@ -1572,6 +1572,7 @@ struct regmap_irq_chip_data;
  * @use_ack:     Use @ack register even if it is zero.
  * @ack_invert:  Inverted ack register: cleared bits for ack.
  * @clear_ack:  Use this to set 1 and 0 or vice-versa to clear interrupts.
+ * @ack_after_handle: Use this to ack interrupts after handling.
  * @status_invert: Inverted status register: cleared bits are active interrupts.
  * @wake_invert: Inverted wake register: cleared bits are wake enabled.
  * @type_in_mask: Use the mask registers for controlling irq type. Use this if
@@ -1635,6 +1636,7 @@ struct regmap_irq_chip {
 	unsigned int use_ack:1;
 	unsigned int ack_invert:1;
 	unsigned int clear_ack:1;
+	unsigned int ack_after_handle:1;
 	unsigned int status_invert:1;
 	unsigned int wake_invert:1;
 	unsigned int type_in_mask:1;
-- 
2.45.2


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ