From: Finn Thain <fthain@telegraphics.com.au>
To: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
Michael Ellerman <mpe@ellerman.id.au>,
Geert Uytterhoeven <geert@linux-m68k.org>
Cc: linux-m68k@vger.kernel.org, linuxppc-dev@lists.ozlabs.org,
linux-kernel@vger.kernel.org
Subject: [PATCH RESEND 07/10] via-cuda: Use spinlock_irq_save/restore instead of enable/disable_irq
Date: Sat, 31 Dec 2016 19:56:26 -0500 (EST) [thread overview]
Message-ID: <d85eed17fa9eb5095df100d435575ed996ee2984.1483055859.git.fthain@telegraphics.com.au> (raw)
In-Reply-To: <cover.1483055859.git.fthain@telegraphics.com.au>
The cuda_start() function uses spinlock_irq_save/restore for mutual
exclusion. Let's have cuda_poll() do the same when polling the VIA
interrupt.
The benefit to disabling local irqs when the interrupt is being polled
is that the interrupt handler now has the same timing properties
regardless of whether it is invoked normally or from cuda_poll().
This driver was written back when local irqs remained enabled during
execution of interrupt handlers and cuda_poll() was probably trying
to achieve the same effect by use of enable/disable_irq.
Tested-by: Stan Johnson <userm57@yahoo.com>
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
---
I wondered whether the use of enable/disable_irq was an attempt to reduce
interrupt latency given that VIA register accesses are slow. But if the
interrupt has not yet fired, only one VIA access will take place, which
imposes neglible latency anyway. If the interrupt has fired, we should
execute the handler under the usual context, i.e. local irqs disabled.
---
drivers/macintosh/via-cuda.c | 16 +++++-----------
1 file changed, 5 insertions(+), 11 deletions(-)
diff --git a/drivers/macintosh/via-cuda.c b/drivers/macintosh/via-cuda.c
index 3212695..e3763cb 100644
--- a/drivers/macintosh/via-cuda.c
+++ b/drivers/macintosh/via-cuda.c
@@ -459,14 +459,7 @@ cuda_start(void)
void
cuda_poll(void)
{
- /* cuda_interrupt only takes a normal lock, we disable
- * interrupts here to avoid re-entering and thus deadlocking.
- */
- if (cuda_irq)
- disable_irq(cuda_irq);
- cuda_interrupt(0, NULL);
- if (cuda_irq)
- enable_irq(cuda_irq);
+ cuda_interrupt(0, NULL);
}
EXPORT_SYMBOL(cuda_poll);
@@ -475,13 +468,14 @@ EXPORT_SYMBOL(cuda_poll);
static irqreturn_t
cuda_interrupt(int irq, void *arg)
{
+ unsigned long flags;
u8 status;
struct adb_request *req = NULL;
unsigned char ibuf[16];
int ibuf_len = 0;
int complete = 0;
- spin_lock(&cuda_lock);
+ spin_lock_irqsave(&cuda_lock, flags);
/* On powermacs, this handler is registered for the VIA IRQ. But they use
* just the shift register IRQ -- other VIA interrupt sources are disabled.
@@ -494,7 +488,7 @@ cuda_interrupt(int irq, void *arg)
#endif
{
if ((in_8(&via[IFR]) & SR_INT) == 0) {
- spin_unlock(&cuda_lock);
+ spin_unlock_irqrestore(&cuda_lock, flags);
return IRQ_NONE;
} else {
out_8(&via[IFR], SR_INT);
@@ -616,7 +610,7 @@ cuda_interrupt(int irq, void *arg)
default:
pr_err("cuda_interrupt: unknown cuda_state %d?\n", cuda_state);
}
- spin_unlock(&cuda_lock);
+ spin_unlock_irqrestore(&cuda_lock, flags);
if (complete && req) {
void (*done)(struct adb_request *) = req->done;
mb();
--
2.10.2
next prev parent reply other threads:[~2017-01-01 0:56 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-01 0:56 [PATCH RESEND 00/10] Replace via-maciisi with via-cuda driver Finn Thain
2017-01-01 0:56 ` [PATCH RESEND 03/10] via-cuda: Add TREQ, TIP and TACK signal helpers Finn Thain
2017-01-01 0:56 ` [PATCH RESEND 04/10] via-cuda: Prevent read buffer overflow Finn Thain
2017-01-01 0:56 ` [PATCH RESEND 05/10] via-cuda: Fix re-initialization of reply_ptr and reading_reply Finn Thain
2017-01-01 0:56 ` [PATCH RESEND 08/10] via-cuda: Initialize data_index early and increment consistently Finn Thain
2017-01-01 0:56 ` [PATCH RESEND 02/10] via-cuda: Remove redundant temporary variable Finn Thain
2017-01-01 0:56 ` [PATCH RESEND 10/10] m68k/mac: Replace via-maciisi driver with via-cuda driver Finn Thain
2017-01-02 10:26 ` Geert Uytterhoeven
2017-01-03 0:33 ` Finn Thain
2017-01-01 0:56 ` Finn Thain [this message]
2017-01-01 0:56 ` [PATCH RESEND 06/10] via-cuda: Avoid TREQ race condition Finn Thain
2017-01-01 0:56 ` [PATCH RESEND 09/10] via-cuda: Add support for Egret system controller Finn Thain
2017-01-01 0:56 ` [PATCH RESEND 01/10] via-cuda: Cleanup printk calls Finn Thain
2017-02-09 13:17 ` [RESEND,01/10] " Michael Ellerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=d85eed17fa9eb5095df100d435575ed996ee2984.1483055859.git.fthain@telegraphics.com.au \
--to=fthain@telegraphics.com.au \
--cc=benh@kernel.crashing.org \
--cc=geert@linux-m68k.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-m68k@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox