From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Andrew Morton <akpm@osdl.org>
Cc: Linus Torvalds <torvalds@osdl.org>,
Linux Kernel list <linux-kernel@vger.kernel.org>
Subject: [PATCH] ppc64: Fix a sleeping with spinlock bug in ioremap
Date: Fri, 27 Feb 2004 13:25:37 +1100 [thread overview]
Message-ID: <1077848737.22397.159.camel@gaston> (raw)
Hi !
ppc64 uses it's own range allocator for ioremap (in order to allocate
things in a different space than normal vmalloc). This is historic
stuff, we may get rid of it, but in the meantime, here's a patch
turning the spinlock in there into a semaphore so it doesn't blow
up when doing kmalloc's
===== arch/ppc64/mm/imalloc.c 1.3 vs edited =====
--- 1.3/arch/ppc64/mm/imalloc.c Mon Jan 19 17:28:15 2004
+++ edited/arch/ppc64/mm/imalloc.c Fri Feb 27 13:05:06 2004
@@ -9,13 +9,13 @@
#include <linux/slab.h>
#include <linux/vmalloc.h>
-#include <linux/spinlock.h>
#include <asm/uaccess.h>
#include <asm/pgalloc.h>
#include <asm/pgtable.h>
+#include <asm/semaphore.h>
-rwlock_t imlist_lock = RW_LOCK_UNLOCKED;
+static DECLARE_MUTEX(imlist_sem);
struct vm_struct * imlist = NULL;
static int get_free_im_addr(unsigned long size, unsigned long *im_addr)
@@ -223,7 +223,7 @@
struct vm_struct *area;
unsigned long addr;
- write_lock(&imlist_lock);
+ down(&imlist_sem);
if (get_free_im_addr(size, &addr)) {
printk(KERN_ERR "%s() cannot obtain addr for size 0x%lx\n",
__FUNCTION__, size);
@@ -238,7 +238,7 @@
__FUNCTION__, addr, size);
}
next_im_done:
- write_unlock(&imlist_lock);
+ up(&imlist_sem);
return area;
}
@@ -247,9 +247,9 @@
{
struct vm_struct *area;
- write_lock(&imlist_lock);
+ down(&imlist_sem);
area = __im_get_area(v_addr, size, criteria);
- write_unlock(&imlist_lock);
+ up(&imlist_sem);
return area;
}
@@ -264,17 +264,17 @@
printk(KERN_ERR "Trying to %s bad address (%p)\n", __FUNCTION__, addr);
return ret_size;
}
- write_lock(&imlist_lock);
+ down(&imlist_sem);
for (p = &imlist ; (tmp = *p) ; p = &tmp->next) {
if (tmp->addr == addr) {
ret_size = tmp->size;
*p = tmp->next;
kfree(tmp);
- write_unlock(&imlist_lock);
+ up(&imlist_sem);
return ret_size;
}
}
- write_unlock(&imlist_lock);
+ up(&imlist_sem);
printk(KERN_ERR "Trying to %s nonexistent area (%p)\n", __FUNCTION__,
addr);
return ret_size;
reply other threads:[~2004-02-27 2:34 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=1077848737.22397.159.camel@gaston \
--to=benh@kernel.crashing.org \
--cc=akpm@osdl.org \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@osdl.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