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] [thread-next>] [day] [month] [year] [list]
Date:   Tue,  4 Dec 2018 19:15:50 +0100
From:   Bartosz Golaszewski <brgl@...ev.pl>
To:     Mark Brown <broonie@...nel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        "Rafael J . Wysocki" <rafael@...nel.org>
Cc:     linux-kernel@...r.kernel.org,
        Bartosz Golaszewski <bgolaszewski@...libre.com>
Subject: [PATCH 1/1] regmap: irq: handle HW using separate mask bits for edges

From: Bartosz Golaszewski <bgolaszewski@...libre.com>

Some interrupt controllers use separate bits for controlling rising
and falling edge interrupts in the mask register.

Let's reuse the existing type fields in struct regmap_irq to make
regmap_irq_chip available to such HW.

If the type_base and mask_base offsets are the same - assume there
are separate bits for falling and rising edge interrupts and use
the value previously written to the type buffer by the set_type()
callback instead of the entire mask specified for this interrupt
so that we only enable the requested edge interrupts.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@...libre.com>
---
 drivers/base/regmap/regmap-irq.c | 18 +++++++++++++++++-
 1 file changed, 17 insertions(+), 1 deletion(-)

diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
index 429ca8ed7e51..109ae353c526 100644
--- a/drivers/base/regmap/regmap-irq.c
+++ b/drivers/base/regmap/regmap-irq.c
@@ -194,8 +194,24 @@ static void regmap_irq_enable(struct irq_data *data)
 	struct regmap_irq_chip_data *d = irq_data_get_irq_chip_data(data);
 	struct regmap *map = d->map;
 	const struct regmap_irq *irq_data = irq_to_regmap_irq(d, data->hwirq);
+	unsigned int mask;
 
-	d->mask_buf[irq_data->reg_offset / map->reg_stride] &= ~irq_data->mask;
+	/*
+	 * If the type_base and mask_base addresses are the same, then
+	 * the underlying hardware uses separate mask bits for rising and
+	 * falling edge interrupts, but we want to make them into a single
+	 * virtual interrupt with configurable edge.
+	 *
+	 * Instead of using the regular mask bits for this interrupt, use
+	 * the value previously written to the type buffer at the
+	 * corresponding offset in regmap_irq_set_type().
+	 */
+	if (unlikely(d->chip->type_base == d->chip->mask_base))
+		mask = d->type_buf[irq_data->reg_offset / map->reg_stride];
+	else
+		mask = irq_data->mask;
+
+	d->mask_buf[irq_data->reg_offset / map->reg_stride] &= ~mask;
 }
 
 static void regmap_irq_disable(struct irq_data *data)
-- 
2.19.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ