From owner-svn-src-all@freebsd.org Wed Jun 21 18:20:19 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 33D2DD959DE; Wed, 21 Jun 2017 18:20:19 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0E88F77501; Wed, 21 Jun 2017 18:20:18 +0000 (UTC) (envelope-from markj@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v5LIKIFj061800; Wed, 21 Jun 2017 18:20:18 GMT (envelope-from markj@FreeBSD.org) Received: (from markj@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v5LIKHo5061797; Wed, 21 Jun 2017 18:20:17 GMT (envelope-from markj@FreeBSD.org) Message-Id: <201706211820.v5LIKHo5061797@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: markj set sender to markj@FreeBSD.org using -f From: Mark Johnston Date: Wed, 21 Jun 2017 18:20:17 +0000 (UTC) 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 X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Jun 2017 18:20:19 -0000 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 +#include + #include #include +#include -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;