From: eeb Date: Tue, 5 Apr 2005 17:54:32 +0000 (+0000) Subject: * 5852 vibnal highmem fix to always use page_to_phys() when calculating X-Git-Tag: v1_7_100~1480 X-Git-Url: https://git.whamcloud.com/?p=fs%2Flustre-release.git;a=commitdiff_plain;h=b3864b28775eb232c20f2649e25433e92444f1e7 * 5852 vibnal highmem fix to always use page_to_phys() when calculating 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 --- diff --git a/lnet/autoconf/lustre-lnet.m4 b/lnet/autoconf/lustre-lnet.m4 index 8a937e3..d5d28c6 100644 --- a/lnet/autoconf/lustre-lnet.m4 +++ b/lnet/autoconf/lustre-lnet.m4 @@ -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 #include @@ -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 + #include + #include + #include + #include + ],[ + 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) diff --git a/lnet/klnds/viblnd/viblnd.h b/lnet/klnds/viblnd/viblnd.h index ff28bd6..f25775e 100644 --- a/lnet/klnds/viblnd/viblnd.h +++ b/lnet/klnds/viblnd/viblnd.h @@ -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 diff --git a/lnet/klnds/viblnd/viblnd_cb.c b/lnet/klnds/viblnd/viblnd_cb.c index c6d8bf8..1642b98 100644 --- a/lnet/klnds/viblnd/viblnd_cb.c +++ b/lnet/klnds/viblnd/viblnd_cb.c @@ -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 */