]> pilppa.org Git - linux-2.6-omap-h63xx.git/blobdiff - drivers/parisc/ccio-dma.c
softlockup: print a module list on being stuck
[linux-2.6-omap-h63xx.git] / drivers / parisc / ccio-dma.c
index d08b284de196b2e807518ac656d678e585f9560c..b30e38f3a50d736d95d591594c04f9aeae7c62ea 100644 (file)
@@ -43,6 +43,7 @@
 #include <linux/proc_fs.h>
 #include <linux/seq_file.h>
 #include <linux/scatterlist.h>
+#include <linux/iommu-helper.h>
 
 #include <asm/byteorder.h>
 #include <asm/cache.h>         /* for L1_CACHE_BYTES */
@@ -302,13 +303,17 @@ static int ioc_count;
 */
 #define CCIO_SEARCH_LOOP(ioc, res_idx, mask, size)  \
        for(; res_ptr < res_end; ++res_ptr) { \
-               if(0 == (*res_ptr & mask)) { \
-                       *res_ptr |= mask; \
-                       res_idx = (unsigned int)((unsigned long)res_ptr - (unsigned long)ioc->res_map); \
-                       ioc->res_hint = res_idx + (size >> 3); \
-                       goto resource_found; \
-               } \
-       }
+               int ret;\
+               unsigned int idx;\
+               idx = (unsigned int)((unsigned long)res_ptr - (unsigned long)ioc->res_map); \
+               ret = iommu_is_span_boundary(idx << 3, pages_needed, 0, boundary_size);\
+               if ((0 == (*res_ptr & mask)) && !ret) { \
+                       *res_ptr |= mask; \
+                       res_idx = idx;\
+                       ioc->res_hint = res_idx + (size >> 3); \
+                       goto resource_found; \
+               } \
+       }
 
 #define CCIO_FIND_FREE_MAPPING(ioa, res_idx, mask, size) \
        u##size *res_ptr = (u##size *)&((ioc)->res_map[ioa->res_hint & ~((size >> 3) - 1)]); \
@@ -341,10 +346,11 @@ static int ioc_count;
  * of available pages for the requested size.
  */
 static int
-ccio_alloc_range(struct ioc *ioc, size_t size)
+ccio_alloc_range(struct ioc *ioc, struct device *dev, size_t size)
 {
        unsigned int pages_needed = size >> IOVP_SHIFT;
        unsigned int res_idx;
+       unsigned long boundary_size;
 #ifdef CCIO_SEARCH_TIME
        unsigned long cr_start = mfctl(16);
 #endif
@@ -353,13 +359,16 @@ ccio_alloc_range(struct ioc *ioc, size_t size)
        BUG_ON((pages_needed * IOVP_SIZE) > DMA_CHUNK_SIZE);
      
        DBG_RES("%s() size: %d pages_needed %d\n", 
-               __FUNCTION__, size, pages_needed);
+               __func__, size, pages_needed);
 
        /*
        ** "seek and ye shall find"...praying never hurts either...
        ** ggg sacrifices another 710 to the computer gods.
        */
 
+       boundary_size = ALIGN((unsigned long long)dma_get_seg_boundary(dev) + 1,
+                             1ULL << IOVP_SHIFT) >> IOVP_SHIFT;
+
        if (pages_needed <= 8) {
                /*
                 * LAN traffic will not thrash the TLB IFF the same NIC
@@ -386,16 +395,16 @@ ccio_alloc_range(struct ioc *ioc, size_t size)
 #endif
        } else {
                panic("%s: %s() Too many pages to map. pages_needed: %u\n",
-                      __FILE__,  __FUNCTION__, pages_needed);
+                      __FILE__,  __func__, pages_needed);
        }
 
        panic("%s: %s() I/O MMU is out of mapping resources.\n", __FILE__,
-             __FUNCTION__);
+             __func__);
        
 resource_found:
        
        DBG_RES("%s() res_idx %d res_hint: %d\n",
-               __FUNCTION__, res_idx, ioc->res_hint);
+               __func__, res_idx, ioc->res_hint);
 
 #ifdef CCIO_SEARCH_TIME
        {
@@ -441,7 +450,7 @@ ccio_free_range(struct ioc *ioc, dma_addr_t iova, unsigned long pages_mapped)
        BUG_ON(pages_mapped > BITS_PER_LONG);
 
        DBG_RES("%s():  res_idx: %d pages_mapped %d\n", 
-               __FUNCTION__, res_idx, pages_mapped);
+               __func__, res_idx, pages_mapped);
 
 #ifdef CCIO_MAP_STATS
        ioc->used_pages -= pages_mapped;
@@ -465,7 +474,7 @@ ccio_free_range(struct ioc *ioc, dma_addr_t iova, unsigned long pages_mapped)
 #endif
        } else {
                panic("%s:%s() Too many pages to unmap.\n", __FILE__,
-                     __FUNCTION__);
+                     __func__);
        }
 }
 
@@ -760,13 +769,13 @@ ccio_map_single(struct device *dev, void *addr, size_t size,
        ioc->msingle_pages += size >> IOVP_SHIFT;
 #endif
 
-       idx = ccio_alloc_range(ioc, size);
+       idx = ccio_alloc_range(ioc, dev, size);
        iovp = (dma_addr_t)MKIOVP(idx);
 
        pdir_start = &(ioc->pdir_base[idx]);
 
        DBG_RUN("%s() 0x%p -> 0x%lx size: %0x%x\n",
-               __FUNCTION__, addr, (long)iovp | offset, size);
+               __func__, addr, (long)iovp | offset, size);
 
        /* If not cacheline aligned, force SAFE_DMA on the whole mess */
        if((size % L1_CACHE_BYTES) || ((unsigned long)addr % L1_CACHE_BYTES))
@@ -811,7 +820,7 @@ ccio_unmap_single(struct device *dev, dma_addr_t iova, size_t size,
        ioc = GET_IOC(dev);
 
        DBG_RUN("%s() iovp 0x%lx/%x\n",
-               __FUNCTION__, (long)iova, size);
+               __func__, (long)iova, size);
 
        iova ^= offset;        /* clear offset bits */
        size += offset;
@@ -913,7 +922,7 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
        BUG_ON(!dev);
        ioc = GET_IOC(dev);
        
-       DBG_RUN_SG("%s() START %d entries\n", __FUNCTION__, nents);
+       DBG_RUN_SG("%s() START %d entries\n", __func__, nents);
 
        /* Fast path single entry scatterlists. */
        if (nents == 1) {
@@ -957,7 +966,7 @@ ccio_map_sg(struct device *dev, struct scatterlist *sglist, int nents,
 
        BUG_ON(coalesced != filled);
 
-       DBG_RUN_SG("%s() DONE %d mappings\n", __FUNCTION__, filled);
+       DBG_RUN_SG("%s() DONE %d mappings\n", __func__, filled);
 
        for (i = 0; i < filled; i++)
                current_len += sg_dma_len(sglist + i);
@@ -986,7 +995,7 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
        ioc = GET_IOC(dev);
 
        DBG_RUN_SG("%s() START %d entries,  %08lx,%x\n",
-               __FUNCTION__, nents, sg_virt_addr(sglist), sglist->length);
+               __func__, nents, sg_virt_addr(sglist), sglist->length);
 
 #ifdef CCIO_MAP_STATS
        ioc->usg_calls++;
@@ -1002,7 +1011,7 @@ ccio_unmap_sg(struct device *dev, struct scatterlist *sglist, int nents,
                ++sglist;
        }
 
-       DBG_RUN_SG("%s() DONE (nents %d)\n", __FUNCTION__, nents);
+       DBG_RUN_SG("%s() DONE (nents %d)\n", __func__, nents);
 }
 
 static struct hppa_dma_ops ccio_ops = {
@@ -1216,7 +1225,7 @@ static int
 ccio_get_iotlb_size(struct parisc_device *dev)
 {
        if (dev->spa_shift == 0) {
-               panic("%s() : Can't determine I/O TLB size.\n", __FUNCTION__);
+               panic("%s() : Can't determine I/O TLB size.\n", __func__);
        }
        return (1 << dev->spa_shift);
 }
@@ -1306,7 +1315,7 @@ ccio_ioc_init(struct ioc *ioc)
        BUG_ON((1 << get_order(ioc->pdir_size)) != (ioc->pdir_size >> PAGE_SHIFT));
 
        DBG_INIT("%s() hpa 0x%p mem %luMB IOV %dMB (%d bits)\n",
-                       __FUNCTION__, ioc->ioc_regs,
+                       __func__, ioc->ioc_regs,
                        (unsigned long) num_physpages >> (20 - PAGE_SHIFT),
                        iova_space_size>>20,
                        iov_order + PAGE_SHIFT);
@@ -1314,7 +1323,7 @@ ccio_ioc_init(struct ioc *ioc)
        ioc->pdir_base = (u64 *)__get_free_pages(GFP_KERNEL, 
                                                 get_order(ioc->pdir_size));
        if(NULL == ioc->pdir_base) {
-               panic("%s() could not allocate I/O Page Table\n", __FUNCTION__);
+               panic("%s() could not allocate I/O Page Table\n", __func__);
        }
        memset(ioc->pdir_base, 0, ioc->pdir_size);
 
@@ -1323,12 +1332,12 @@ ccio_ioc_init(struct ioc *ioc)
 
        /* resource map size dictated by pdir_size */
        ioc->res_size = (ioc->pdir_size / sizeof(u64)) >> 3;
-       DBG_INIT("%s() res_size 0x%x\n", __FUNCTION__, ioc->res_size);
+       DBG_INIT("%s() res_size 0x%x\n", __func__, ioc->res_size);
        
        ioc->res_map = (u8 *)__get_free_pages(GFP_KERNEL, 
                                              get_order(ioc->res_size));
        if(NULL == ioc->res_map) {
-               panic("%s() could not allocate resource map\n", __FUNCTION__);
+               panic("%s() could not allocate resource map\n", __func__);
        }
        memset(ioc->res_map, 0, ioc->res_size);
 
@@ -1400,7 +1409,7 @@ ccio_init_resource(struct resource *res, char *name, void __iomem *ioaddr)
        result = insert_resource(&iomem_resource, res);
        if (result < 0) {
                printk(KERN_ERR "%s() failed to claim CCIO bus address space (%08lx,%08lx)\n", 
-                       __FUNCTION__, res->start, res->end);
+                       __func__, res->start, res->end);
        }
 }
 
@@ -1542,8 +1551,7 @@ static int __init ccio_probe(struct parisc_device *dev)
 {
        int i;
        struct ioc *ioc, **ioc_p = &ioc_list;
-       struct proc_dir_entry *info_entry, *bitmap_entry;
-       
+
        ioc = kzalloc(sizeof(struct ioc), GFP_KERNEL);
        if (ioc == NULL) {
                printk(KERN_ERR MODULE_NAME ": memory allocation failure\n");
@@ -1571,13 +1579,10 @@ static int __init ccio_probe(struct parisc_device *dev)
        HBA_DATA(dev->dev.platform_data)->iommu = ioc;
        
        if (ioc_count == 0) {
-               info_entry = create_proc_entry(MODULE_NAME, 0, proc_runway_root);
-               if (info_entry)
-                       info_entry->proc_fops = &ccio_proc_info_fops;
-
-               bitmap_entry = create_proc_entry(MODULE_NAME"-bitmap", 0, proc_runway_root);
-               if (bitmap_entry)
-                       bitmap_entry->proc_fops = &ccio_proc_bitmap_fops;
+               proc_create(MODULE_NAME, 0, proc_runway_root,
+                           &ccio_proc_info_fops);
+               proc_create(MODULE_NAME"-bitmap", 0, proc_runway_root,
+                           &ccio_proc_bitmap_fops);
        }
 
        ioc_count++;