Date: Tue, 4 Jan 2011 05:35:44 +0000 (UTC) From: Jeff Roberson <jeff@FreeBSD.org> To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r216950 - in projects/ofed/head/sys: conf ofed/drivers/infiniband/core ofed/drivers/infiniband/hw/mlx4 ofed/include/linux Message-ID: <201101040535.p045Zibf023832@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: jeff Date: Tue Jan 4 05:35:44 2011 New Revision: 216950 URL: http://svn.freebsd.org/changeset/base/216950 Log: - Enable write combining memory attribute support in mmap and ioremap. - Add the write-combine source file for mlx4 back to the build. - Set pages to dirty when releasing umem maps. Sponsored by: Isilon Systems, iX Systems, and Panasas. Modified: projects/ofed/head/sys/conf/files projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/wc.h projects/ofed/head/sys/ofed/include/linux/io-mapping.h projects/ofed/head/sys/ofed/include/linux/io.h projects/ofed/head/sys/ofed/include/linux/linux_compat.c projects/ofed/head/sys/ofed/include/linux/page.h Modified: projects/ofed/head/sys/conf/files ============================================================================== --- projects/ofed/head/sys/conf/files Tue Jan 4 05:35:19 2011 (r216949) +++ projects/ofed/head/sys/conf/files Tue Jan 4 05:35:44 2011 (r216950) @@ -2893,9 +2893,9 @@ ofed/drivers/infiniband/hw/mlx4/qp.c op ofed/drivers/infiniband/hw/mlx4/srq.c optional mlx4 \ no-depend obj-prefix "mlx4ib_" \ compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/" -#ofed/drivers/infiniband/hw/mlx4/wc.c optional mlx4 \ -# no-depend obj-prefix "mlx4ib_" \ -# compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/" +ofed/drivers/infiniband/hw/mlx4/wc.c optional mlx4 \ + no-depend obj-prefix "mlx4ib_" \ + compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/infiniband/hw/mlx4/" ofed/drivers/net/mlx4/alloc.c optional mlx4 \ no-depend obj-prefix "mlx4_" \ compile-with "${OFED_C_NOIMP} -I$S/ofed/drivers/net/mlx4/" Modified: projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c Tue Jan 4 05:35:19 2011 (r216949) +++ projects/ofed/head/sys/ofed/drivers/infiniband/core/umem.c Tue Jan 4 05:35:44 2011 (r216950) @@ -46,9 +46,9 @@ #include <vm/vm.h> #include <vm/vm_map.h> +#include <vm/vm_object.h> #include <vm/vm_pageout.h> - #include "uverbs.h" static int allow_weak_ordering; @@ -112,6 +112,7 @@ static void dma_unmap_sg_ia64(struct ib_ static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int dirty) { +#ifdef __linux__ struct ib_umem_chunk *chunk, *tmp; int i; @@ -119,17 +120,40 @@ static void __ib_umem_release(struct ib_ ib_dma_unmap_sg_attrs(dev, chunk->page_list, chunk->nents, DMA_BIDIRECTIONAL, &chunk->attrs); for (i = 0; i < chunk->nents; ++i) { -#ifdef __linux__ - /* XXX I need to set the proper page flags here too. */ struct page *page = sg_page(&chunk->page_list[i]); if (umem->writable && dirty) set_page_dirty_lock(page); put_page(page); -#endif } + kfree(chunk); + } +#else + struct ib_umem_chunk *chunk, *tmp; + vm_object_t object; + int i; + object = NULL; + list_for_each_entry_safe(chunk, tmp, &umem->chunk_list, list) { + ib_dma_unmap_sg_attrs(dev, chunk->page_list, + chunk->nents, DMA_BIDIRECTIONAL, &chunk->attrs); + for (i = 0; i < chunk->nents; ++i) { + struct page *page = sg_page(&chunk->page_list[i]); + if (umem->writable && dirty) { + if (object && object != page->object) + VM_OBJECT_UNLOCK(object); + if (object != page->object) { + object = page->object; + VM_OBJECT_LOCK(object); + } + vm_page_dirty(page); + } + } kfree(chunk); } + if (object) + VM_OBJECT_UNLOCK(object); + +#endif } /** @@ -469,7 +493,6 @@ void ib_umem_release(struct ib_umem *ume int error; __ib_umem_release(umem->context->device, umem, 1); - if (umem->context->closing) { kfree(umem); return; Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Tue Jan 4 05:35:19 2011 (r216949) +++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/main.c Tue Jan 4 05:35:44 2011 (r216950) @@ -522,7 +522,6 @@ static struct ib_ucontext *mlx4_ib_alloc resp.qp_tab_size = dev->dev->caps.num_qps; -#ifdef __linux__ if (mlx4_wc_enabled()) { resp.bf_reg_size = dev->dev->caps.bf_reg_size; resp.bf_regs_per_page = dev->dev->caps.bf_regs_per_page; @@ -530,10 +529,6 @@ static struct ib_ucontext *mlx4_ib_alloc resp.bf_reg_size = 0; resp.bf_regs_per_page = 0; } -#else - resp.bf_reg_size = 0; - resp.bf_regs_per_page = 0; -#endif context = kzalloc(sizeof *context, GFP_KERNEL); if (!context) Modified: projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/wc.h ============================================================================== --- projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/wc.h Tue Jan 4 05:35:19 2011 (r216949) +++ projects/ofed/head/sys/ofed/drivers/infiniband/hw/mlx4/wc.h Tue Jan 4 05:35:44 2011 (r216950) @@ -36,8 +36,6 @@ #include <asm/pgtable.h> int mlx4_wc_enabled(void); -#ifdef __linux__ pgprot_t pgprot_wc(pgprot_t _prot); -#endif #endif Modified: projects/ofed/head/sys/ofed/include/linux/io-mapping.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/io-mapping.h Tue Jan 4 05:35:19 2011 (r216949) +++ projects/ofed/head/sys/ofed/include/linux/io-mapping.h Tue Jan 4 05:35:44 2011 (r216950) @@ -37,11 +37,8 @@ struct io_mapping; static inline struct io_mapping * io_mapping_create_wc(resource_size_t base, unsigned long size) { - struct io_mapping *map; - map = ioremap(base, size); - /* XXX Set write combine. */ - return (map); + return ioremap_wc(base, size); } static inline void Modified: projects/ofed/head/sys/ofed/include/linux/io.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/io.h Tue Jan 4 05:35:19 2011 (r216949) +++ projects/ofed/head/sys/ofed/include/linux/io.h Tue Jan 4 05:35:44 2011 (r216950) @@ -29,6 +29,8 @@ #ifndef _LINUX_IO_H_ #define _LINUX_IO_H_ +#include <machine/vm.h> + static inline uint32_t __raw_readl(const volatile void *addr) { @@ -86,7 +88,12 @@ writew(uint16_t b, void *addr) *(volatile uint16_t *)addr = b; } -void *ioremap(vm_paddr_t phys_addr, unsigned long size); +void *_ioremap_attr(vm_paddr_t phys_addr, unsigned long size, int attr); +#define ioremap_nocache(addr, size) \ + _ioremap_attr((addr), (size), VM_MEMATTR_UNCACHED) +#define ioremap_wc(addr, size) \ + _ioremap_attr((addr), (size), VM_MEMATTR_WRITE_COMBINING) +#define ioremap ioremap_nocache void iounmap(void *addr); #define memset_io(a, b, c) memset((a), (b), (c)) Modified: projects/ofed/head/sys/ofed/include/linux/linux_compat.c ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/linux_compat.c Tue Jan 4 05:35:19 2011 (r216949) +++ projects/ofed/head/sys/ofed/include/linux/linux_compat.c Tue Jan 4 05:35:44 2011 (r216950) @@ -436,6 +436,8 @@ linux_dev_mmap_single(struct cdev *dev, PAGE_SIZE, nprot, *offset, curthread->td_ucred); if (*object == NULL) return (EINVAL); + if (vma.vm_page_prot != VM_MEMATTR_DEFAULT) + pmap_page_set_memattr(m, vma.vm_page_prot); } } else error = ENODEV; @@ -578,12 +580,12 @@ static struct iomaphd iomaphead[IOMAP_HA static struct mtx iomaplock; void * -ioremap(vm_paddr_t phys_addr, unsigned long size) +_ioremap_attr(vm_paddr_t phys_addr, unsigned long size, int attr) { struct iomap *iomap; void *addr; - addr = pmap_mapdev(phys_addr, size); + addr = pmap_mapdev_attr(phys_addr, size, attr); if (addr == NULL) return (NULL); iomap = kmalloc(sizeof(*iomap), GFP_KERNEL); Modified: projects/ofed/head/sys/ofed/include/linux/page.h ============================================================================== --- projects/ofed/head/sys/ofed/include/linux/page.h Tue Jan 4 05:35:19 2011 (r216949) +++ projects/ofed/head/sys/ofed/include/linux/page.h Tue Jan 4 05:35:44 2011 (r216950) @@ -39,9 +39,9 @@ #define virt_to_page(x) PHYS_TO_VM_PAGE(vtophys((x))) -#define clear_page(page) memset((page), 0, PAGE_SIZE) -#define pgprot_noncached(prot) VM_MEMATTR_UNCACHED -#define pgprot_wc(prot) VM_MEMATTR_WRITE_COMBINING +#define clear_page(page) memset((page), 0, PAGE_SIZE) +#define pgprot_noncached(prot) VM_MEMATTR_UNCACHED +#define pgprot_writecombine(prot) VM_MEMATTR_WRITE_COMBINING #undef PAGE_MASK #define PAGE_MASK (~(PAGE_SIZE-1))
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201101040535.p045Zibf023832>