[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20210225220623.30543-1-john.ogness@linutronix.de>
Date: Thu, 25 Feb 2021 23:06:23 +0100
From: John Ogness <john.ogness@...utronix.de>
To: Paul Mackerras <paulus@...ba.org>
Cc: Benjamin Herrenschmidt <benh@...nel.crashing.org>,
Michael Ellerman <mpe@...erman.id.au>,
Qinglang Miao <miaoqinglang@...wei.com>,
linuxppc-dev@...ts.ozlabs.org, linux-kernel@...r.kernel.org
Subject: [PATCH v1] powerpc: low_i2c: change @lock to raw_spinlock_t
i2c transfers are occurring with local interrupts disabled:
smp_core99_give_timebase()
local_irq_save();
smp_core99_cypress_tb_freeze()
pmac_i2c_xfer()
kw_i2c_xfer()
spin_lock_irqsave(&host->lock, flags)
This is a problem because with PREEMPT_RT a spinlock_t can sleep,
causing the system to hang. Convert the spinlock_t to the
non-sleeping raw_spinlock_t.
Signed-off-by: John Ogness <john.ogness@...utronix.de>
---
arch/powerpc/platforms/powermac/low_i2c.c | 16 ++++++++--------
1 file changed, 8 insertions(+), 8 deletions(-)
diff --git a/arch/powerpc/platforms/powermac/low_i2c.c b/arch/powerpc/platforms/powermac/low_i2c.c
index f77a59b5c2e1..ba89c95ef290 100644
--- a/arch/powerpc/platforms/powermac/low_i2c.c
+++ b/arch/powerpc/platforms/powermac/low_i2c.c
@@ -116,7 +116,7 @@ struct pmac_i2c_host_kw
int polled;
int result;
struct completion complete;
- spinlock_t lock;
+ raw_spinlock_t lock;
struct timer_list timeout_timer;
};
@@ -346,14 +346,14 @@ static irqreturn_t kw_i2c_irq(int irq, void *dev_id)
struct pmac_i2c_host_kw *host = dev_id;
unsigned long flags;
- spin_lock_irqsave(&host->lock, flags);
+ raw_spin_lock_irqsave(&host->lock, flags);
del_timer(&host->timeout_timer);
kw_i2c_handle_interrupt(host, kw_read_reg(reg_isr));
if (host->state != state_idle) {
host->timeout_timer.expires = jiffies + KW_POLL_TIMEOUT;
add_timer(&host->timeout_timer);
}
- spin_unlock_irqrestore(&host->lock, flags);
+ raw_spin_unlock_irqrestore(&host->lock, flags);
return IRQ_HANDLED;
}
@@ -362,7 +362,7 @@ static void kw_i2c_timeout(struct timer_list *t)
struct pmac_i2c_host_kw *host = from_timer(host, t, timeout_timer);
unsigned long flags;
- spin_lock_irqsave(&host->lock, flags);
+ raw_spin_lock_irqsave(&host->lock, flags);
/*
* If the timer is pending, that means we raced with the
@@ -377,7 +377,7 @@ static void kw_i2c_timeout(struct timer_list *t)
add_timer(&host->timeout_timer);
}
skip:
- spin_unlock_irqrestore(&host->lock, flags);
+ raw_spin_unlock_irqrestore(&host->lock, flags);
}
static int kw_i2c_open(struct pmac_i2c_bus *bus)
@@ -470,9 +470,9 @@ static int kw_i2c_xfer(struct pmac_i2c_bus *bus, u8 addrdir, int subsize,
unsigned long flags;
u8 isr = kw_i2c_wait_interrupt(host);
- spin_lock_irqsave(&host->lock, flags);
+ raw_spin_lock_irqsave(&host->lock, flags);
kw_i2c_handle_interrupt(host, isr);
- spin_unlock_irqrestore(&host->lock, flags);
+ raw_spin_unlock_irqrestore(&host->lock, flags);
}
}
@@ -508,7 +508,7 @@ static struct pmac_i2c_host_kw *__init kw_i2c_host_init(struct device_node *np)
}
mutex_init(&host->mutex);
init_completion(&host->complete);
- spin_lock_init(&host->lock);
+ raw_spin_lock_init(&host->lock);
timer_setup(&host->timeout_timer, kw_i2c_timeout, 0);
psteps = of_get_property(np, "AAPL,address-step", NULL);
--
2.20.1
Powered by blists - more mailing lists