From: Manfred Spraul <manfred@colorfullife.com>
To: John Cherry <cherry@osdl.org>
Cc: Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: [PATCH] mwave locking (was: IA32 - 1 New warnings)
Date: Sun, 07 Sep 2003 15:18:25 +0200 [thread overview]
Message-ID: <3F5B3021.9090107@colorfullife.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 344 bytes --]
John wrote:
>drivers/char/mwave/mwavedd.c:331:2: warning: #warning "Sleeping on spinlock"
>
>
Interesting locking strategy:
A spinlock is placed on the stack and then
spin_lock_irqsave(&local_lock, flags).
Attached is a patch that removes that. Untested due to lack of hardware.
Anyone around such hardware (IBM Thinkpad?)
--
Manfred
[-- Attachment #2: patch-mwave --]
[-- Type: text/plain, Size: 2254 bytes --]
--- 2.6/drivers/char/mwave/mwavedd.c 2003-09-07 12:29:10.000000000 +0200
+++ build-2.6/drivers/char/mwave/mwavedd.c 2003-09-07 15:04:00.000000000 +0200
@@ -293,8 +293,6 @@
case IOCTL_MW_GET_IPC: {
unsigned int ipcnum = (unsigned int) ioarg;
- spinlock_t ipc_lock = SPIN_LOCK_UNLOCKED;
- unsigned long flags;
PRINTK_3(TRACE_MWAVE,
"mwavedd::mwave_ioctl IOCTL_MW_GET_IPC"
@@ -310,32 +308,29 @@
}
if (pDrvData->IPCs[ipcnum].bIsEnabled == TRUE) {
+ DECLARE_WAITQUEUE(wait, current);
+
PRINTK_2(TRACE_MWAVE,
"mwavedd::mwave_ioctl, thread for"
" ipc %x going to sleep\n",
ipcnum);
-
- spin_lock_irqsave(&ipc_lock, flags);
+ add_wait_queue(&pDrvData->IPCs[ipcnum].ipc_wait_queue, &wait);
+ pDrvData->IPCs[ipcnum].bIsHere = TRUE;
+ set_current_state(TASK_INTERRUPTIBLE);
/* check whether an event was signalled by */
/* the interrupt handler while we were gone */
if (pDrvData->IPCs[ipcnum].usIntCount == 1) { /* first int has occurred (race condition) */
pDrvData->IPCs[ipcnum].usIntCount = 2; /* first int has been handled */
- spin_unlock_irqrestore(&ipc_lock, flags);
PRINTK_2(TRACE_MWAVE,
"mwavedd::mwave_ioctl"
" IOCTL_MW_GET_IPC ipcnum %x"
" handling first int\n",
ipcnum);
} else { /* either 1st int has not yet occurred, or we have already handled the first int */
- pDrvData->IPCs[ipcnum].bIsHere = TRUE;
-#warning "Sleeping on spinlock"
- interruptible_sleep_on(&pDrvData->IPCs[ipcnum].ipc_wait_queue);
- pDrvData->IPCs[ipcnum].bIsHere = FALSE;
+ schedule();
if (pDrvData->IPCs[ipcnum].usIntCount == 1) {
- pDrvData->IPCs[ipcnum].
- usIntCount = 2;
+ pDrvData->IPCs[ipcnum].usIntCount = 2;
}
- spin_unlock_irqrestore(&ipc_lock, flags);
PRINTK_2(TRACE_MWAVE,
"mwavedd::mwave_ioctl"
" IOCTL_MW_GET_IPC ipcnum %x"
@@ -343,6 +338,9 @@
" application\n",
ipcnum);
}
+ pDrvData->IPCs[ipcnum].bIsHere = FALSE;
+ remove_wait_queue(&pDrvData->IPCs[ipcnum].ipc_wait_queue, &wait);
+ set_current_state(TASK_RUNNING);
PRINTK_2(TRACE_MWAVE,
"mwavedd::mwave_ioctl IOCTL_MW_GET_IPC,"
" returning thread for ipc %x"
next reply other threads:[~2003-09-07 13:18 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-09-07 13:18 Manfred Spraul [this message]
2003-09-07 13:43 ` [PATCH] mwave locking Jochen Hein
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=3F5B3021.9090107@colorfullife.com \
--to=manfred@colorfullife.com \
--cc=cherry@osdl.org \
--cc=linux-kernel@vger.kernel.org \
/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