Date: Wed, 21 Jun 2017 18:20:17 +0000 (UTC) From: Mark Johnston <markj@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r320196 - in head/sys: compat/linuxkpi/common/include/linux dev/mlx4/mlx4_core dev/mlx5/mlx5_core Message-ID: <201706211820.v5LIKHo5061797@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: markj Date: Wed Jun 21 18:20:17 2017 New Revision: 320196 URL: https://svnweb.freebsd.org/changeset/base/320196 Log: Update io-mapping.h in the LinuxKPI. Add io_mapping_init_wc() and add a third (unused) parameter to io_mapping_map_wc(). Reviewed by: hselasky MFC after: 1 week Differential Revision: https://reviews.freebsd.org/D11286 Modified: head/sys/compat/linuxkpi/common/include/linux/io-mapping.h head/sys/dev/mlx4/mlx4_core/mlx4_pd.c head/sys/dev/mlx5/mlx5_core/mlx5_uar.c Modified: head/sys/compat/linuxkpi/common/include/linux/io-mapping.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/io-mapping.h Wed Jun 21 18:19:27 2017 (r320195) +++ head/sys/compat/linuxkpi/common/include/linux/io-mapping.h Wed Jun 21 18:20:17 2017 (r320196) @@ -28,52 +28,85 @@ * * $FreeBSD$ */ -#ifndef _LINUX_IO_MAPPING_H_ + +#ifndef _LINUX_IO_MAPPING_H_ #define _LINUX_IO_MAPPING_H_ +#include <sys/types.h> +#include <machine/vm.h> + #include <linux/types.h> #include <linux/io.h> +#include <linux/slab.h> -struct io_mapping; +struct io_mapping { + unsigned long base; + unsigned long size; + void *mem; + vm_memattr_t attr; +}; static inline struct io_mapping * +io_mapping_init_wc(struct io_mapping *mapping, resource_size_t base, + unsigned long size) +{ + + mapping->base = base; + mapping->size = size; + mapping->mem = ioremap_wc(base, size); + mapping->attr = VM_MEMATTR_WRITE_COMBINING; + return (mapping); +} + +static inline struct io_mapping * io_mapping_create_wc(resource_size_t base, unsigned long size) { + struct io_mapping *mapping; - return ioremap_wc(base, size); + mapping = kmalloc(sizeof(*mapping), GFP_KERNEL); + if (mapping == NULL) + return (NULL); + return (io_mapping_init_wc(mapping, base, size)); } static inline void +io_mapping_fini(struct io_mapping *mapping) +{ + + iounmap(mapping->mem); +} + +static inline void io_mapping_free(struct io_mapping *mapping) { - iounmap(mapping); + io_mapping_fini(mapping->mem); + kfree(mapping); } static inline void * io_mapping_map_atomic_wc(struct io_mapping *mapping, unsigned long offset) { - return (((char *)mapping) + offset); + return ((char *)mapping->mem + offset); } static inline void io_mapping_unmap_atomic(void *vaddr) { - } static inline void * -io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset) +io_mapping_map_wc(struct io_mapping *mapping, unsigned long offset, + unsigned long size) { - return (((char *) mapping) + offset); + return ((char *)mapping->mem + offset); } static inline void io_mapping_unmap(void *vaddr) { - } -#endif /* _LINUX_IO_MAPPING_H_ */ +#endif /* _LINUX_IO_MAPPING_H_ */ Modified: head/sys/dev/mlx4/mlx4_core/mlx4_pd.c ============================================================================== --- head/sys/dev/mlx4/mlx4_core/mlx4_pd.c Wed Jun 21 18:19:27 2017 (r320195) +++ head/sys/dev/mlx4/mlx4_core/mlx4_pd.c Wed Jun 21 18:20:17 2017 (r320196) @@ -204,7 +204,7 @@ int mlx4_bf_alloc(struct mlx4_dev *dev, struct mlx4_bf goto free_uar; } - uar->bf_map = io_mapping_map_wc(priv->bf_mapping, uar->index << PAGE_SHIFT); + uar->bf_map = io_mapping_map_wc(priv->bf_mapping, uar->index << PAGE_SHIFT, PAGE_SIZE); if (!uar->bf_map) { err = -ENOMEM; goto unamp_uar; Modified: head/sys/dev/mlx5/mlx5_core/mlx5_uar.c ============================================================================== --- head/sys/dev/mlx5/mlx5_core/mlx5_uar.c Wed Jun 21 18:19:27 2017 (r320195) +++ head/sys/dev/mlx5/mlx5_core/mlx5_uar.c Wed Jun 21 18:20:17 2017 (r320196) @@ -189,7 +189,8 @@ int mlx5_alloc_map_uar(struct mlx5_core_dev *mdev, str if (mdev->priv.bf_mapping) uar->bf_map = io_mapping_map_wc(mdev->priv.bf_mapping, - uar->index << PAGE_SHIFT); + uar->index << PAGE_SHIFT, + PAGE_SIZE); return 0;
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201706211820.v5LIKHo5061797>