Whamcloud - gitweb
* 5852 vibnal highmem fix to always use page_to_phys() when calculating
authoreeb <eeb>
Tue, 5 Apr 2005 17:54:32 +0000 (17:54 +0000)
committereeb <eeb>
Tue, 5 Apr 2005 17:54:32 +0000 (17:54 +0000)
    physical memory addresses, but conditionally supress sign extension if
    page_to_phys() returns a 32 bit address.

*   removed confusing (and obsolete) use of vmalloc_to_page() in vibnal's
    kibnal_kvaddr_to_page().

*   removed some unused variables in  vibnal

lnet/autoconf/lustre-lnet.m4
lnet/klnds/viblnd/viblnd.h
lnet/klnds/viblnd/viblnd_cb.c

index 8a937e3..d5d28c6 100644 (file)
@@ -368,9 +368,9 @@ else
        EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 fi
 if test -n "$VIBNAL"; then
-       AC_MSG_CHECKING([if Voltaire still uses void * sg addresses])
        EXTRA_KCFLAGS_save="$EXTRA_KCFLAGS"
        EXTRA_KCFLAGS="$EXTRA_KCFLAGS $VIBCPPFLAGS"
+       AC_MSG_CHECKING([if Voltaire still uses void * sg addresses])
        LB_LINUX_TRY_COMPILE([
                #include <linux/list.h>
                #include <asm/byteorder.h>
@@ -395,6 +395,27 @@ if test -n "$VIBNAL"; then
        ],[
                AC_MSG_RESULT([no])
        ])
+       AC_MSG_CHECKING([if page_to_phys() must avoid sign extension])
+       LB_LINUX_TRY_COMPILE([
+               #include <linux/kernel.h>
+               #include <linux/mm.h>
+               #include <linux/unistd.h>
+               #include <asm/system.h>
+               #include <asm/io.h>
+       ],[
+               struct page p;
+
+               switch (42) {
+               case 0:
+               case (sizeof(typeof(page_to_phys(&p))) < 8):
+                       break;
+               }
+       ],[
+               AC_MSG_RESULT([yes])
+               VIBCPPFLAGS="$VIBCPPFLAGS -DIBNAL_32BIT_PAGE2PHYS=1"
+       ],[
+               AC_MSG_RESULT([no])
+       ])
        EXTRA_KCFLAGS="$EXTRA_KCFLAGS_save"
 fi
 AC_SUBST(VIBCPPFLAGS)
index ff28bd6..f25775e 100644 (file)
@@ -531,7 +531,18 @@ kibnal_queue_tx_locked (kib_tx_t *tx, kib_conn_t *conn)
 static inline __u64
 kibnal_page2phys (struct page *p)
 {
-        return ((__u64)(p - mem_map)) << PAGE_SHIFT;
+#if IBNAL_32BIT_PAGE2PHYS
+        CLASSERT (sizeof(typeof(page_to_phys(p))) == 4);
+        CLASSERT (sizeof(unsigned long) == 4);
+        /* page_to_phys returns a 32 bit physical address.  This must be a 32
+         * bit machine with <= 4G memory and we must ensure we don't sign
+         * extend when converting to 64 bits. */
+        return (unsigned long)page_to_phys(p);
+#else
+        CLASSERT (sizeof(typeof(page_to_phys(p))) == 8);
+        /* page_to_phys returns a 64 bit physical address :) */
+        return page_to_phys(p);
+#endif
 }
 
 #if IBNAL_VOIDSTAR_SGADDR
index c6d8bf8..1642b98 100644 (file)
@@ -516,7 +516,6 @@ kibnal_append_rdfrag(kib_rdma_desc_t *rd, int active, struct page *page,
         vv_r_key_t       r_key;
         __u64            addr;
         __u64            frag_addr;
-        void            *ptr;
         vv_mem_reg_h_t   mem_h;
         vv_return_t      vvrc;
 
@@ -569,18 +568,22 @@ kibnal_kvaddr_to_page (unsigned long vaddr)
         struct page *page;
 
         if (vaddr >= VMALLOC_START &&
-            vaddr < VMALLOC_END)
+            vaddr < VMALLOC_END) {
                 page = vmalloc_to_page ((void *)vaddr);
+                LASSERT (page != NULL);
+                return page;
+        }
 #if CONFIG_HIGHMEM
-        else if (vaddr >= PKMAP_BASE &&
-                 vaddr < (PKMAP_BASE + LAST_PKMAP * PAGE_SIZE))
-                page = vmalloc_to_page ((void *)vaddr);
-        /* in 2.4 ^ just walks the page tables */
+        if (vaddr >= PKMAP_BASE &&
+            vaddr < (PKMAP_BASE + LAST_PKMAP * PAGE_SIZE)) {
+                /* No highmem pages only used for bulk (kiov) I/O */
+                CERROR("find page for address in highmem\n");
+                LBUG();
+        }
 #endif
-        else
-                page = virt_to_page (vaddr);
-
-        return VALID_PAGE(page) ? page : NULL;
+        page = virt_to_page (vaddr);
+        LASSERT (page != NULL);
+        return page;
 }
 
 int
@@ -872,7 +875,6 @@ kibnal_check_sends (kib_conn_t *conn)
         kib_tx_t       *tx;
         vv_return_t     vvrc;                        
         int             rc;
-        int             i;
         int             done;
 
         /* Don't send anything until after the connection is established */