pkt_sched: Change PSCHED_SHIFT from 10 to 6
[safe/jmp/linux-2.6] / drivers / misc / sgi-xp / xp_sn2.c
index 1fcfdeb..fb3ec9d 100644 (file)
@@ -12,6 +12,7 @@
  *      Architecture specific implementation of common functions.
  */
 
+#include <linux/module.h>
 #include <linux/device.h>
 #include <asm/sn/bte.h>
 #include <asm/sn/sn_sal.h>
@@ -62,7 +63,7 @@ xp_register_nofault_code_sn2(void)
        return xpSuccess;
 }
 
-void
+static void
 xp_unregister_nofault_code_sn2(void)
 {
        u64 func_addr = *(u64 *)xp_nofault_PIOR;
@@ -74,56 +75,97 @@ xp_unregister_nofault_code_sn2(void)
 }
 
 /*
+ * Convert a virtual memory address to a physical memory address.
+ */
+static unsigned long
+xp_pa_sn2(void *addr)
+{
+       return __pa(addr);
+}
+
+/*
  * Wrapper for bte_copy().
  *
- *     vdst - virtual address of the destination of the transfer.
- *     psrc - physical address of the source of the transfer.
+ *     dst_pa - physical address of the destination of the transfer.
+ *     src_pa - physical address of the source of the transfer.
  *     len - number of bytes to transfer from source to destination.
  *
  * Note: xp_remote_memcpy_sn2() should never be called while holding a spinlock.
  */
 static enum xp_retval
-xp_remote_memcpy_sn2(void *vdst, const void *psrc, size_t len)
+xp_remote_memcpy_sn2(unsigned long dst_pa, const unsigned long src_pa,
+                    size_t len)
 {
        bte_result_t ret;
-       u64 pdst = ia64_tpa(vdst);
-       /* >>> What are the rules governing the src and dst addresses passed in?
-        * >>> Currently we're assuming that dst is a virtual address and src
-        * >>> is a physical address, is this appropriate? Can we allow them to
-        * >>> be whatever and we make the change here without damaging the
-        * >>> addresses?
-        */
 
-       /*
-        * Ensure that the physically mapped memory is contiguous.
-        *
-        * We do this by ensuring that the memory is from region 7 only.
-        * If the need should arise to use memory from one of the other
-        * regions, then modify the BUG_ON() statement to ensure that the
-        * memory from that region is always physically contiguous.
-        */
-       BUG_ON(REGION_NUMBER(vdst) != RGN_KERNEL);
-
-       ret = bte_copy((u64)psrc, pdst, len, (BTE_NOTIFY | BTE_WACQUIRE), NULL);
+       ret = bte_copy(src_pa, dst_pa, len, (BTE_NOTIFY | BTE_WACQUIRE), NULL);
        if (ret == BTE_SUCCESS)
                return xpSuccess;
 
-       if (is_shub2())
-               dev_err(xp, "bte_copy() on shub2 failed, error=0x%x\n", ret);
-       else
-               dev_err(xp, "bte_copy() failed, error=%d\n", ret);
+       if (is_shub2()) {
+               dev_err(xp, "bte_copy() on shub2 failed, error=0x%x dst_pa="
+                       "0x%016lx src_pa=0x%016lx len=%ld\\n", ret, dst_pa,
+                       src_pa, len);
+       } else {
+               dev_err(xp, "bte_copy() failed, error=%d dst_pa=0x%016lx "
+                       "src_pa=0x%016lx len=%ld\\n", ret, dst_pa, src_pa, len);
+       }
 
        return xpBteCopyError;
 }
 
+static int
+xp_cpu_to_nasid_sn2(int cpuid)
+{
+       return cpuid_to_nasid(cpuid);
+}
+
+static enum xp_retval
+xp_expand_memprotect_sn2(unsigned long phys_addr, unsigned long size)
+{
+       u64 nasid_array = 0;
+       int ret;
+
+       ret = sn_change_memprotect(phys_addr, size, SN_MEMPROT_ACCESS_CLASS_1,
+                                  &nasid_array);
+       if (ret != 0) {
+               dev_err(xp, "sn_change_memprotect(,, "
+                       "SN_MEMPROT_ACCESS_CLASS_1,) failed ret=%d\n", ret);
+               return xpSalError;
+       }
+       return xpSuccess;
+}
+
+static enum xp_retval
+xp_restrict_memprotect_sn2(unsigned long phys_addr, unsigned long size)
+{
+       u64 nasid_array = 0;
+       int ret;
+
+       ret = sn_change_memprotect(phys_addr, size, SN_MEMPROT_ACCESS_CLASS_0,
+                                  &nasid_array);
+       if (ret != 0) {
+               dev_err(xp, "sn_change_memprotect(,, "
+                       "SN_MEMPROT_ACCESS_CLASS_0,) failed ret=%d\n", ret);
+               return xpSalError;
+       }
+       return xpSuccess;
+}
+
 enum xp_retval
 xp_init_sn2(void)
 {
        BUG_ON(!is_shub());
 
        xp_max_npartitions = XP_MAX_NPARTITIONS_SN2;
+       xp_partition_id = sn_partition_id;
+       xp_region_size = sn_region_size;
 
+       xp_pa = xp_pa_sn2;
        xp_remote_memcpy = xp_remote_memcpy_sn2;
+       xp_cpu_to_nasid = xp_cpu_to_nasid_sn2;
+       xp_expand_memprotect = xp_expand_memprotect_sn2;
+       xp_restrict_memprotect = xp_restrict_memprotect_sn2;
 
        return xp_register_nofault_code_sn2();
 }