]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/parisc/kernel/pci-dma.c
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-2.6
[linux-2.6-omap-h63xx.git] / arch / parisc / kernel / pci-dma.c
index 0c3aecb85a5ccb344ffe8d0f391f6ebaebbf17a6..ccd61b9567a6e8f837426961ec1c4de231c517f2 100644 (file)
 #include <linux/mm.h>
 #include <linux/pci.h>
 #include <linux/proc_fs.h>
+#include <linux/seq_file.h>
 #include <linux/slab.h>
 #include <linux/string.h>
 #include <linux/types.h>
+#include <linux/scatterlist.h>
 
 #include <asm/cacheflush.h>
 #include <asm/dma.h>    /* for DMA_CHUNK_SIZE */
@@ -34,7 +36,6 @@
 #include <asm/tlbflush.h>      /* for purge_tlb_*() macros */
 
 static struct proc_dir_entry * proc_gsc_root __read_mostly = NULL;
-static int pcxl_proc_info(char *buffer, char **start, off_t offset, int length);
 static unsigned long pcxl_used_bytes __read_mostly = 0;
 static unsigned long pcxl_used_pages __read_mostly = 0;
 
@@ -330,6 +331,54 @@ pcxl_free_range(unsigned long vaddr, size_t size)
        dump_resmap();
 }
 
+static int proc_pcxl_dma_show(struct seq_file *m, void *v)
+{
+#if 0
+       u_long i = 0;
+       unsigned long *res_ptr = (u_long *)pcxl_res_map;
+#endif
+       unsigned long total_pages = pcxl_res_size << 3;   /* 8 bits per byte */
+
+       seq_printf(m, "\nDMA Mapping Area size    : %d bytes (%ld pages)\n",
+               PCXL_DMA_MAP_SIZE, total_pages);
+
+       seq_printf(m, "Resource bitmap : %d bytes\n", pcxl_res_size);
+
+       seq_puts(m,  "            total:    free:    used:   % used:\n");
+       seq_printf(m, "blocks  %8d %8ld %8ld %8ld%%\n", pcxl_res_size,
+               pcxl_res_size - pcxl_used_bytes, pcxl_used_bytes,
+               (pcxl_used_bytes * 100) / pcxl_res_size);
+
+       seq_printf(m, "pages   %8ld %8ld %8ld %8ld%%\n", total_pages,
+               total_pages - pcxl_used_pages, pcxl_used_pages,
+               (pcxl_used_pages * 100 / total_pages));
+
+#if 0
+       seq_puts(m, "\nResource bitmap:");
+
+       for(; i < (pcxl_res_size / sizeof(u_long)); ++i, ++res_ptr) {
+               if ((i & 7) == 0)
+                   seq_puts(m,"\n   ");
+               seq_printf(m, "%s %08lx", buf, *res_ptr);
+       }
+#endif
+       seq_putc(m, '\n');
+       return 0;
+}
+
+static int proc_pcxl_dma_open(struct inode *inode, struct file *file)
+{
+       return single_open(file, proc_pcxl_dma_show, NULL);
+}
+
+static const struct file_operations proc_pcxl_dma_ops = {
+       .owner          = THIS_MODULE,
+       .open           = proc_pcxl_dma_open,
+       .read           = seq_read,
+       .llseek         = seq_lseek,
+       .release        = single_release,
+};
+
 static int __init
 pcxl_dma_init(void)
 {
@@ -348,8 +397,8 @@ pcxl_dma_init(void)
                        "pcxl_dma_init: Unable to create gsc /proc dir entry\n");
        else {
                struct proc_dir_entry* ent;
-               ent = create_proc_info_entry("pcxl_dma", 0,
-                               proc_gsc_root, pcxl_proc_info);
+               ent = proc_create("pcxl_dma", 0, proc_gsc_root,
+                                 &proc_pcxl_dma_ops);
                if (!ent)
                        printk(KERN_WARNING
                                "pci-dma.c: Unable to create pcxl_dma /proc entry.\n");
@@ -520,11 +569,10 @@ static void *fail_alloc_consistent(struct device *dev, size_t size,
 static void *pa11_dma_alloc_noncoherent(struct device *dev, size_t size,
                                          dma_addr_t *dma_handle, gfp_t flag)
 {
-       void *addr = NULL;
+       void *addr;
 
-       /* rely on kmalloc to be cacheline aligned */
-       addr = kmalloc(size, flag);
-       if(addr)
+       addr = (void *)__get_free_pages(flag, get_order(size));
+       if (addr)
                *dma_handle = (dma_addr_t)virt_to_phys(addr);
 
        return addr;
@@ -533,7 +581,7 @@ static void *pa11_dma_alloc_noncoherent(struct device *dev, size_t size,
 static void pa11_dma_free_noncoherent(struct device *dev, size_t size,
                                        void *vaddr, dma_addr_t iova)
 {
-       kfree(vaddr);
+       free_pages((unsigned long)vaddr, get_order(size));
        return;
 }
 
@@ -551,40 +599,3 @@ struct hppa_dma_ops pcx_dma_ops = {
        .dma_sync_sg_for_cpu =          pa11_dma_sync_sg_for_cpu,
        .dma_sync_sg_for_device =       pa11_dma_sync_sg_for_device,
 };
-
-
-static int pcxl_proc_info(char *buf, char **start, off_t offset, int len)
-{
-#if 0
-       u_long i = 0;
-       unsigned long *res_ptr = (u_long *)pcxl_res_map;
-#endif
-       unsigned long total_pages = pcxl_res_size << 3;   /* 8 bits per byte */
-
-       sprintf(buf, "\nDMA Mapping Area size    : %d bytes (%ld pages)\n",
-               PCXL_DMA_MAP_SIZE, total_pages);
-       
-       sprintf(buf, "%sResource bitmap : %d bytes\n", buf, pcxl_res_size);
-
-       strcat(buf,  "            total:    free:    used:   % used:\n");
-       sprintf(buf, "%sblocks  %8d %8ld %8ld %8ld%%\n", buf, pcxl_res_size,
-               pcxl_res_size - pcxl_used_bytes, pcxl_used_bytes,
-               (pcxl_used_bytes * 100) / pcxl_res_size);
-
-       sprintf(buf, "%spages   %8ld %8ld %8ld %8ld%%\n", buf, total_pages,
-               total_pages - pcxl_used_pages, pcxl_used_pages,
-               (pcxl_used_pages * 100 / total_pages));
-
-#if 0
-       strcat(buf, "\nResource bitmap:");
-
-       for(; i < (pcxl_res_size / sizeof(u_long)); ++i, ++res_ptr) {
-               if ((i & 7) == 0)
-                   strcat(buf,"\n   ");
-               sprintf(buf, "%s %08lx", buf, *res_ptr);
-       }
-#endif
-       strcat(buf, "\n");
-       return strlen(buf);
-}
-