linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] pci_alloc_consistent in an interrupt context
@ 2002-06-13 19:28 Eugene Surovegin
  2002-06-13 20:58 ` Tom Rini
  0 siblings, 1 reply; 28+ messages in thread
From: Eugene Surovegin @ 2002-06-13 19:28 UTC (permalink / raw)
  To: linuxppc-embedded

[-- Attachment #1: Type: text/plain, Size: 245 bytes --]

Hi!

This is the patch which allows pci_alloc_consistent (and consistent_alloc)
to be called from an interrupt context.
It's the required behavior according to Documentation/DMA-mapping.txt.

Thanks,

  Eugene Surovegin <mailto:ebs@innocent.com>

[-- Attachment #2: consistent_alloc.patch --]
[-- Type: application/octet-stream, Size: 3292 bytes --]

diff -ur a/arch/ppc/kernel/pci-dma.c b/arch/ppc/kernel/pci-dma.c
--- a/arch/ppc/kernel/pci-dma.c	Sat Jan 19 00:07:14 2002
+++ b/arch/ppc/kernel/pci-dma.c	Wed Jun 12 19:06:12 2002
@@ -33,7 +33,9 @@
 
 	if (ret != NULL) {
 		memset(ret, 0, size);
+#ifndef CONFIG_NOT_COHERENT_CACHE
 		*dma_handle = virt_to_bus(ret);
+#endif
 	}
 	return ret;
 }
diff -ur a/arch/ppc/mm/cachemap.c b/arch/ppc/mm/cachemap.c
--- a/arch/ppc/mm/cachemap.c	Wed Jun 12 20:40:03 2002
+++ b/arch/ppc/mm/cachemap.c	Thu Jun 13 11:47:41 2002
@@ -69,10 +69,7 @@
 	phys_addr_t pa;
 	struct vm_struct *area;
 	void	 *ret;
-
-	if (in_interrupt())
-		BUG();
-
+	
 	/* Only allocate page size areas.
 	*/
 	size = PAGE_ALIGN(size);
@@ -92,7 +89,7 @@
 
 	/* Allocate some common virtual space to map the new pages.
 	*/
-	area = get_vm_area(size, VM_ALLOC);
+	area = get_vm_area(size, VM_ALLOC, GFP_ATOMIC);
 	if (area == 0) {
 		free_pages(page, order);
 		return NULL;
@@ -123,8 +119,6 @@
  */
 void consistent_free(void *vaddr)
 {
-	if (in_interrupt())
-		BUG();
 	vfree(vaddr);
 }
 
diff -ur a/arch/ppc/mm/pgtable.c b/arch/ppc/mm/pgtable.c
--- a/arch/ppc/mm/pgtable.c	Sat Apr  6 13:06:49 2002
+++ b/arch/ppc/mm/pgtable.c	Thu Jun 13 11:41:02 2002
@@ -172,7 +172,7 @@
 	
 	if (mem_init_done) {
 		struct vm_struct *area;
-		area = get_vm_area(size, VM_IOREMAP);
+		area = get_vm_area(size, VM_IOREMAP, GFP_KERNEL);
 		if (area == 0)
 			return NULL;
 		v = VMALLOC_VMADDR(area->addr);
diff -ur a/drivers/pcmcia/hd64465_ss.c b/drivers/pcmcia/hd64465_ss.c
--- a/drivers/pcmcia/hd64465_ss.c	Wed Jul 11 07:27:34 2001
+++ b/drivers/pcmcia/hd64465_ss.c	Thu Jun 13 11:46:00 2002
@@ -918,7 +918,7 @@
 	for (i=0 ; i<MAX_WIN ; i++)
 	    sp->mem_maps[i].map = i;
 	
-	if ((sp->io_vma = get_vm_area(HS_IO_MAP_SIZE, VM_IOREMAP)) == 0)
+	if ((sp->io_vma = get_vm_area(HS_IO_MAP_SIZE, VM_IOREMAP, GFP_KERNEL)) == 0)
 	    return -ENOMEM;
 
 	hd64465_register_irq_demux(sp->irq, hs_irq_demux, sp);
diff -ur a/include/linux/vmalloc.h b/include/linux/vmalloc.h
--- a/include/linux/vmalloc.h	Fri Jan  5 23:26:19 2001
+++ b/include/linux/vmalloc.h	Thu Jun 13 11:41:02 2002
@@ -18,7 +18,8 @@
 	struct vm_struct * next;
 };
 
-extern struct vm_struct * get_vm_area (unsigned long size, unsigned long flags);
+extern struct vm_struct * get_vm_area (unsigned long size, unsigned long flags,
+				       int gfp_mask);
 extern void vfree(void * addr);
 extern void * __vmalloc (unsigned long size, int gfp_mask, pgprot_t prot);
 extern long vread(char *buf, char *addr, unsigned long count);
diff -ur a/mm/vmalloc.c b/mm/vmalloc.c
--- a/mm/vmalloc.c	Thu Jan 10 05:28:35 2002
+++ b/mm/vmalloc.c	Thu Jun 13 11:41:03 2002
@@ -168,12 +168,12 @@
 	return ret;
 }
 
-struct vm_struct * get_vm_area(unsigned long size, unsigned long flags)
+struct vm_struct * get_vm_area(unsigned long size, unsigned long flags, int gfp_mask)
 {
 	unsigned long addr;
 	struct vm_struct **p, *tmp, *area;
 
-	area = (struct vm_struct *) kmalloc(sizeof(*area), GFP_KERNEL);
+	area = (struct vm_struct *) kmalloc(sizeof(*area), gfp_mask);
 	if (!area)
 		return NULL;
 	size += PAGE_SIZE;
@@ -236,7 +236,7 @@
 		BUG();
 		return NULL;
 	}
-	area = get_vm_area(size, VM_ALLOC);
+	area = get_vm_area(size, VM_ALLOC, GFP_KERNEL);
 	if (!area)
 		return NULL;
 	addr = area->addr;

^ permalink raw reply	[flat|nested] 28+ messages in thread

end of thread, other threads:[~2002-06-15  6:40 UTC | newest]

Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2002-06-13 19:28 [PATCH] pci_alloc_consistent in an interrupt context Eugene Surovegin
2002-06-13 20:58 ` Tom Rini
2002-06-13 21:47   ` Dan Malek
2002-06-13 21:56     ` Tom Rini
2002-06-14  0:24       ` David Gibson
2002-06-14  0:38         ` Tom Rini
2002-06-14  0:45           ` David Gibson
2002-06-14  0:51             ` Tom Rini
2002-06-14  5:14               ` David Gibson
2002-06-14 14:59                 ` Tom Rini
2002-06-15  6:40                   ` David Gibson
2002-06-14  1:25         ` Eugene Surovegin
2002-06-14  1:33           ` David Gibson
2002-06-14  1:57             ` Eugene Surovegin
2002-06-14  2:06               ` David Gibson
2002-06-14  2:15                 ` Tom Rini
2002-06-14  3:58                   ` David Gibson
2002-06-14  4:42                     ` Tom Rini
2002-06-14  2:08             ` Dan Malek
2002-06-14  1:57       ` Dan Malek
2002-06-13 22:23     ` Eugene Surovegin
2002-06-13 23:34       ` Paul Mackerras
2002-06-14  2:17         ` Dan Malek
2002-06-14  2:29         ` Eugene Surovegin
2002-06-13 23:37       ` Paul Mackerras
2002-06-14  2:15       ` Dan Malek
2002-06-14  2:21         ` Eugene Surovegin
2002-06-13 23:07     ` [PATCH] pci_alloc_consistent in an interrupt context, part 2 Eugene Surovegin

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).