include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit...
[safe/jmp/linux-2.6] / arch / ia64 / sn / kernel / bte.c
index b75814e..cad775a 100644 (file)
@@ -3,10 +3,9 @@
  * License.  See the file "COPYING" in the main directory of this archive
  * for more details.
  *
- * Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
+ * Copyright (c) 2000-2007 Silicon Graphics, Inc.  All Rights Reserved.
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <asm/sn/nodepda.h>
 #include <asm/sn/addrs.h>
@@ -20,6 +19,7 @@
 #include <linux/bootmem.h>
 #include <linux/string.h>
 #include <linux/sched.h>
+#include <linux/slab.h>
 
 #include <asm/sn/bte.h>
 
@@ -36,7 +36,7 @@ static struct bteinfo_s *bte_if_on_node(nasid_t nasid, int interface)
        nodepda_t *tmp_nodepda;
 
        if (nasid_to_cnodeid(nasid) == -1)
-               return (struct bteinfo_s *)NULL;;
+               return (struct bteinfo_s *)NULL;
 
        tmp_nodepda = NODEPDA(nasid_to_cnodeid(nasid));
        return &tmp_nodepda->bte_if[interface];
@@ -64,7 +64,7 @@ static inline void bte_start_transfer(struct bteinfo_s *bte, u64 len, u64 mode)
  * Use the block transfer engine to move kernel memory from src to dest
  * using the assigned mode.
  *
- * Paramaters:
+ * Parameters:
  *   src - physical address of the transfer source.
  *   dest - physical address of the transfer destination.
  *   len - number of bytes to transfer from source to dest.
@@ -87,7 +87,7 @@ bte_result_t bte_copy(u64 src, u64 dest, u64 len, u64 mode, void *notification)
        unsigned long irq_flags;
        unsigned long itc_end = 0;
        int nasid_to_try[MAX_NODES_TO_TRY];
-       int my_nasid = get_nasid();
+       int my_nasid = cpuid_to_nasid(raw_smp_processor_id());
        int bte_if_index, nasid_index;
        int bte_first, btes_per_node = BTES_PER_NODE;
 
@@ -98,14 +98,15 @@ bte_result_t bte_copy(u64 src, u64 dest, u64 len, u64 mode, void *notification)
                return BTE_SUCCESS;
        }
 
-       BUG_ON((len & L1_CACHE_MASK) ||
-                (src & L1_CACHE_MASK) || (dest & L1_CACHE_MASK));
-       BUG_ON(!(len < ((BTE_LEN_MASK + 1) << L1_CACHE_SHIFT)));
+       BUG_ON(len & L1_CACHE_MASK);
+       BUG_ON(src & L1_CACHE_MASK);
+       BUG_ON(dest & L1_CACHE_MASK);
+       BUG_ON(len > BTE_MAX_XFER);
 
        /*
         * Start with interface corresponding to cpu number
         */
-       bte_first = get_cpu() % btes_per_node;
+       bte_first = raw_smp_processor_id() % btes_per_node;
 
        if (mode & BTE_USE_DEST) {
                /* try remote then local */
@@ -137,6 +138,7 @@ retry_bteop:
                        bte = bte_if_on_node(nasid_to_try[nasid_index],bte_if_index);
 
                        if (bte == NULL) {
+                               nasid_index++;
                                continue;
                        }
 
@@ -185,18 +187,13 @@ retry_bteop:
 
        /* Initialize the notification to a known value. */
        *bte->most_rcnt_na = BTE_WORD_BUSY;
-       notif_phys_addr = TO_PHYS(ia64_tpa((unsigned long)bte->most_rcnt_na));
+       notif_phys_addr = (u64)bte->most_rcnt_na;
 
-       if (is_shub2()) {
-               src = SH2_TIO_PHYS_TO_DMA(src);
-               dest = SH2_TIO_PHYS_TO_DMA(dest);
-               notif_phys_addr = SH2_TIO_PHYS_TO_DMA(notif_phys_addr);
-       }
        /* Set the source and destination registers */
-       BTE_PRINTKV(("IBSA = 0x%lx)\n", (TO_PHYS(src))));
-       BTE_SRC_STORE(bte, TO_PHYS(src));
-       BTE_PRINTKV(("IBDA = 0x%lx)\n", (TO_PHYS(dest))));
-       BTE_DEST_STORE(bte, TO_PHYS(dest));
+       BTE_PRINTKV(("IBSA = 0x%lx)\n", src));
+       BTE_SRC_STORE(bte, src);
+       BTE_PRINTKV(("IBDA = 0x%lx)\n", dest));
+       BTE_DEST_STORE(bte, dest);
 
        /* Set the notification register */
        BTE_PRINTKV(("IBNA = 0x%lx)\n", notif_phys_addr));
@@ -232,7 +229,7 @@ retry_bteop:
                     BTE_LNSTAT_LOAD(bte), *bte->most_rcnt_na));
 
        if (transfer_stat & IBLS_ERROR) {
-               bte_status = transfer_stat & ~IBLS_ERROR;
+               bte_status = BTE_GET_ERROR_STATUS(transfer_stat);
        } else {
                bte_status = BTE_SUCCESS;
        }
@@ -252,7 +249,7 @@ EXPORT_SYMBOL(bte_copy);
  * use the block transfer engine to move kernel
  * memory from src to dest using the assigned mode.
  *
- * Paramaters:
+ * Parameters:
  *   src - physical address of the transfer source.
  *   dest - physical address of the transfer destination.
  *   len - number of bytes to transfer from source to dest.
@@ -260,7 +257,7 @@ EXPORT_SYMBOL(bte_copy);
  *          for IBCT0/1 in the SGI documentation.
  *
  * NOTE: If the source, dest, and len are all cache line aligned,
- * then it would be _FAR_ preferrable to use bte_copy instead.
+ * then it would be _FAR_ preferable to use bte_copy instead.
  */
 bte_result_t bte_unaligned_copy(u64 src, u64 dest, u64 len, u64 mode)
 {
@@ -282,8 +279,7 @@ bte_result_t bte_unaligned_copy(u64 src, u64 dest, u64 len, u64 mode)
        }
 
        /* temporary buffer used during unaligned transfers */
-       bteBlock_unaligned = kmalloc(len + 3 * L1_CACHE_BYTES,
-                                    GFP_KERNEL | GFP_DMA);
+       bteBlock_unaligned = kmalloc(len + 3 * L1_CACHE_BYTES, GFP_KERNEL);
        if (bteBlock_unaligned == NULL) {
                return BTEFAIL_NOTAVAIL;
        }
@@ -306,7 +302,7 @@ bte_result_t bte_unaligned_copy(u64 src, u64 dest, u64 len, u64 mode)
         * a standard bte copy.
         *
         * One nasty exception to the above rule is when the
-        * source and destination are not symetrically
+        * source and destination are not symmetrically
         * mis-aligned.  If the source offset from the first
         * cache line is different from the destination offset,
         * we make the first section be the entire transfer
@@ -343,7 +339,7 @@ bte_result_t bte_unaligned_copy(u64 src, u64 dest, u64 len, u64 mode)
 
                        if (footBcopyDest == (headBcopyDest + headBcopyLen)) {
                                /*
-                                * We have two contigous bcopy
+                                * We have two contiguous bcopy
                                 * blocks.  Merge them.
                                 */
                                headBcopyLen += footBcopyLen;
@@ -381,20 +377,19 @@ bte_result_t bte_unaligned_copy(u64 src, u64 dest, u64 len, u64 mode)
        } else {
 
                /*
-                * The transfer is not symetric, we will
+                * The transfer is not symmetric, we will
                 * allocate a buffer large enough for all the
                 * data, bte_copy into that buffer and then
                 * bcopy to the destination.
                 */
 
-               /* Add the leader from source */
-               headBteLen = len + (src & L1_CACHE_MASK);
-               /* Add the trailing bytes from footer. */
-               headBteLen += L1_CACHE_BYTES - (headBteLen & L1_CACHE_MASK);
-               headBteSource = src & ~L1_CACHE_MASK;
                headBcopySrcOffset = src & L1_CACHE_MASK;
                headBcopyDest = dest;
                headBcopyLen = len;
+
+               headBteSource = src - headBcopySrcOffset;
+               /* Add the leading and trailing bytes from source */
+               headBteLen = L1_CACHE_ALIGN(len + headBcopySrcOffset);
        }
 
        if (headBcopyLen > 0) {