]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - arch/parisc/kernel/pci-dma.c
[PARISC] fix null ptr deref in unwind.c
[linux-2.6-omap-h63xx.git] / arch / parisc / kernel / pci-dma.c
index 844c2877a2e386a34169bc2e97b9bc42f866f950..23c1388df1f55c5e2a34459ace9e08f336dad2df 100644 (file)
@@ -21,6 +21,7 @@
 #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 <asm/page.h>  /* get_order */
 #include <asm/pgalloc.h>
 #include <asm/uaccess.h>
+#include <asm/tlbflush.h>      /* for purge_tlb_*() macros */
 
-
-static struct proc_dir_entry * proc_gsc_root = NULL;
-static int pcxl_proc_info(char *buffer, char **start, off_t offset, int length);
-static unsigned long pcxl_used_bytes = 0;
-static unsigned long pcxl_used_pages = 0;
+static struct proc_dir_entry * proc_gsc_root __read_mostly = NULL;
+static unsigned long pcxl_used_bytes __read_mostly = 0;
+static unsigned long pcxl_used_pages __read_mostly = 0;
 
 extern unsigned long pcxl_dma_start; /* Start of pcxl dma mapping area */
 static spinlock_t   pcxl_res_lock;
@@ -114,7 +114,7 @@ static inline int map_pmd_uncached(pmd_t * pmd, unsigned long vaddr,
        if (end > PGDIR_SIZE)
                end = PGDIR_SIZE;
        do {
-               pte_t * pte = pte_alloc_kernel(&init_mm, pmd, vaddr);
+               pte_t * pte = pte_alloc_kernel(pmd, vaddr);
                if (!pte)
                        return -ENOMEM;
                if (map_pte_uncached(pte, orig_vaddr, end - vaddr, paddr_ptr))
@@ -330,21 +330,80 @@ 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)
 {
-    if (pcxl_dma_start == 0)
-       return 0;
+       if (pcxl_dma_start == 0)
+               return 0;
 
-    spin_lock_init(&pcxl_res_lock);
-    pcxl_res_size = PCXL_DMA_MAP_SIZE >> (PAGE_SHIFT + 3);
-    pcxl_res_hint = 0;
-    pcxl_res_map = (char *)__get_free_pages(GFP_KERNEL,
+       spin_lock_init(&pcxl_res_lock);
+       pcxl_res_size = PCXL_DMA_MAP_SIZE >> (PAGE_SHIFT + 3);
+       pcxl_res_hint = 0;
+       pcxl_res_map = (char *)__get_free_pages(GFP_KERNEL,
                                            get_order(pcxl_res_size));
-    memset(pcxl_res_map, 0, pcxl_res_size);
-    proc_gsc_root = proc_mkdir("gsc", 0);
-    create_proc_info_entry("dino", 0, proc_gsc_root, pcxl_proc_info);
-    return 0;
+       memset(pcxl_res_map, 0, pcxl_res_size);
+       proc_gsc_root = proc_mkdir("gsc", NULL);
+       if (!proc_gsc_root)
+               printk(KERN_WARNING
+                       "pcxl_dma_init: Unable to create gsc /proc dir entry\n");
+       else {
+               struct proc_dir_entry* ent;
+               ent = create_proc_entry("pcxl_dma", 0, proc_gsc_root);
+               if (ent)
+                       ent->proc_fops = &proc_pcxl_dma_ops;
+               else
+                       printk(KERN_WARNING
+                               "pci-dma.c: Unable to create pcxl_dma /proc entry.\n");
+       }
+       return 0;
 }
 
 __initcall(pcxl_dma_init);
@@ -541,38 +600,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)
-{
-       u_long i = 0;
-       unsigned long *res_ptr = (u_long *)pcxl_res_map;
-       unsigned long total_pages = pcxl_res_size << 3;        /* 8 bits per byte */
-
-       sprintf(buf, "\nDMA Mapping Area size    : %d bytes (%d pages)\n",
-               PCXL_DMA_MAP_SIZE,
-               (pcxl_res_size << 3) ); /* 1 bit per page */
-       
-       sprintf(buf, "%sResource bitmap : %d bytes (%d pages)\n", 
-               buf, pcxl_res_size, pcxl_res_size << 3);   /* 8 bits per byte */
-
-       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));
-       
-       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);
-       }
-       strcat(buf, "\n");
-       return strlen(buf);
-}
-