lkml.org 
[lkml]   [2018]   [Mar]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
Date
SubjectRe: [PATCH] regmap: irq: fix ack-invert
On Tue, Feb 27, 2018 at 8:05 AM, Tim Harvey <tharvey@gateworks.com> wrote:
> When acking irqs we need to take into account the ack-invert case. Without
> this chips that require 0's to ACK interrupts will never clear the interrupt.
>
> I am working on an mfd driver that will use ack-invert and discovered
> this issue. The only user of ack_invert currently appears to be the
> motorola-cpcap driver. I'm not clear why that driver doesn't appear affected
> so I'm cc'ing those involved with that driver for review and testing.
>
> Cc: Benjamin Gaignard <benjamin.gaignard@linaro.org>
> Cc: Lee Jones <lee.jones@linaro.org>
> Cc: Tony Lindgren <tony@atomide.com>
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
> ---
> drivers/base/regmap/regmap-irq.c | 17 +++++++++++++----
> 1 file changed, 13 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/base/regmap/regmap-irq.c b/drivers/base/regmap/regmap-irq.c
> index 429ca8e..abfed41 100644
> --- a/drivers/base/regmap/regmap-irq.c
> +++ b/drivers/base/regmap/regmap-irq.c
> @@ -355,16 +355,25 @@ static irqreturn_t regmap_irq_thread(int irq, void *d)
> * doing a write per register.
> */
> for (i = 0; i < data->chip->num_regs; i++) {
> - data->status_buf[i] &= ~data->mask_buf[i];
> -
> - if (data->status_buf[i] && (chip->ack_base || chip->use_ack)) {
> + if ( (data->status_buf[i] & ~data->mask_buf[i]) &&
> + (chip->ack_base || chip->use_ack) ) {
> reg = chip->ack_base +
> (i * map->reg_stride * data->irq_reg_stride);
> - ret = regmap_write(map, reg, data->status_buf[i]);
> + /* some chips ack by write 0 */
> + if (chip->ack_invert)
> + ret = regmap_write(map, reg,
> + ~data->status_buf[i] &
> + ~data->mask_buf[i]);
> +
> + else
> + ret = regmap_write(map, reg,
> + data->status_buf[i] &
> + ~data->mask_buf[i]);
> if (ret != 0)
> dev_err(map->dev, "Failed to ack 0x%x: %d\n",
> reg, ret);
> }
> + data->status_buf[i] &= ~data->mask_buf[i];
> }
>
> for (i = 0; i < chip->num_irqs; i++) {
> --
> 2.7.4
>

This still needs some work. For the mask_invert=true and
ack_invert=true case which is the case for the driver I'm writing it
ends up setting bits that didn't even fire. I will revisit on Monday
with a patch that uses update_bits to ensure only the correct bits are
set or cleared on an ack regardless of akc_invert.

Regards,

Tim

\
 
 \ /
  Last update: 2018-03-03 18:01    [W:0.085 / U:0.112 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site