Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

RDMA/umem: Avoid partial declaration of non-static function

The RDMA/umem uses generic RB-trees macros to generate various ib_umem
access functions. The generation is performed with INTERVAL_TREE_DEFINE
macro, which allows one of two modes: declare all functions as static or
declare none of the function to be static.

The second mode of operation produces the following sparse errors:
drivers/infiniband/core/umem_rbtree.c:69:1:
warning: symbol 'rbt_ib_umem_iter_first' was not declared.
Should it be static?
drivers/infiniband/core/umem_rbtree.c:69:1:
warning: symbol 'rbt_ib_umem_iter_next' was not declared.
Should it be static?

Code relocation together with declaration of such functions to be
"static" solves the issue.

Because there is no need to have separate file for two functions,
let's consolidate umem_rtree.c and umem_odp.c into one file.

Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>

authored by

Leon Romanovsky and committed by
Doug Ledford
fec99ede 26beb85f

+73 -114
+1 -1
drivers/infiniband/core/Makefile
··· 14 14 security.o nldev.o 15 15 16 16 ib_core-$(CONFIG_INFINIBAND_USER_MEM) += umem.o 17 - ib_core-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o umem_rbtree.o 17 + ib_core-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o 18 18 ib_core-$(CONFIG_CGROUP_RDMA) += cgroup.o 19 19 20 20 ib_cm-y := cm.o
+72
drivers/infiniband/core/umem_odp.c
··· 39 39 #include <linux/export.h> 40 40 #include <linux/vmalloc.h> 41 41 #include <linux/hugetlb.h> 42 + #include <linux/interval_tree_generic.h> 42 43 43 44 #include <rdma/ib_verbs.h> 44 45 #include <rdma/ib_umem.h> 45 46 #include <rdma/ib_umem_odp.h> 47 + 48 + /* 49 + * The ib_umem list keeps track of memory regions for which the HW 50 + * device request to receive notification when the related memory 51 + * mapping is changed. 52 + * 53 + * ib_umem_lock protects the list. 54 + */ 55 + 56 + static u64 node_start(struct umem_odp_node *n) 57 + { 58 + struct ib_umem_odp *umem_odp = 59 + container_of(n, struct ib_umem_odp, interval_tree); 60 + 61 + return ib_umem_start(umem_odp->umem); 62 + } 63 + 64 + /* Note that the representation of the intervals in the interval tree 65 + * considers the ending point as contained in the interval, while the 66 + * function ib_umem_end returns the first address which is not contained 67 + * in the umem. 68 + */ 69 + static u64 node_last(struct umem_odp_node *n) 70 + { 71 + struct ib_umem_odp *umem_odp = 72 + container_of(n, struct ib_umem_odp, interval_tree); 73 + 74 + return ib_umem_end(umem_odp->umem) - 1; 75 + } 76 + 77 + INTERVAL_TREE_DEFINE(struct umem_odp_node, rb, u64, __subtree_last, 78 + node_start, node_last, static, rbt_ib_umem) 46 79 47 80 static void ib_umem_notifier_start_account(struct ib_umem *item) 48 81 { ··· 787 754 mutex_unlock(&umem->odp_data->umem_mutex); 788 755 } 789 756 EXPORT_SYMBOL(ib_umem_odp_unmap_dma_pages); 757 + 758 + /* @last is not a part of the interval. See comment for function 759 + * node_last. 760 + */ 761 + int rbt_ib_umem_for_each_in_range(struct rb_root_cached *root, 762 + u64 start, u64 last, 763 + umem_call_back cb, 764 + void *cookie) 765 + { 766 + int ret_val = 0; 767 + struct umem_odp_node *node, *next; 768 + struct ib_umem_odp *umem; 769 + 770 + if (unlikely(start == last)) 771 + return ret_val; 772 + 773 + for (node = rbt_ib_umem_iter_first(root, start, last - 1); 774 + node; node = next) { 775 + next = rbt_ib_umem_iter_next(node, start, last - 1); 776 + umem = container_of(node, struct ib_umem_odp, interval_tree); 777 + ret_val = cb(umem->umem, start, last, cookie) || ret_val; 778 + } 779 + 780 + return ret_val; 781 + } 782 + EXPORT_SYMBOL(rbt_ib_umem_for_each_in_range); 783 + 784 + struct ib_umem_odp *rbt_ib_umem_lookup(struct rb_root_cached *root, 785 + u64 addr, u64 length) 786 + { 787 + struct umem_odp_node *node; 788 + 789 + node = rbt_ib_umem_iter_first(root, addr, addr + length - 1); 790 + if (node) 791 + return container_of(node, struct ib_umem_odp, interval_tree); 792 + return NULL; 793 + 794 + } 795 + EXPORT_SYMBOL(rbt_ib_umem_lookup);
-109
drivers/infiniband/core/umem_rbtree.c
··· 1 - /* 2 - * Copyright (c) 2014 Mellanox Technologies. All rights reserved. 3 - * 4 - * This software is available to you under a choice of one of two 5 - * licenses. You may choose to be licensed under the terms of the GNU 6 - * General Public License (GPL) Version 2, available from the file 7 - * COPYING in the main directory of this source tree, or the 8 - * OpenIB.org BSD license below: 9 - * 10 - * Redistribution and use in source and binary forms, with or 11 - * without modification, are permitted provided that the following 12 - * conditions are met: 13 - * 14 - * - Redistributions of source code must retain the above 15 - * copyright notice, this list of conditions and the following 16 - * disclaimer. 17 - * 18 - * - Redistributions in binary form must reproduce the above 19 - * copyright notice, this list of conditions and the following 20 - * disclaimer in the documentation and/or other materials 21 - * provided with the distribution. 22 - * 23 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 26 - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS 27 - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN 28 - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 29 - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 30 - * SOFTWARE. 31 - */ 32 - 33 - #include <linux/kernel.h> 34 - #include <linux/module.h> 35 - #include <linux/interval_tree_generic.h> 36 - #include <linux/sched.h> 37 - #include <linux/gfp.h> 38 - #include <rdma/ib_umem_odp.h> 39 - 40 - /* 41 - * The ib_umem list keeps track of memory regions for which the HW 42 - * device request to receive notification when the related memory 43 - * mapping is changed. 44 - * 45 - * ib_umem_lock protects the list. 46 - */ 47 - 48 - static inline u64 node_start(struct umem_odp_node *n) 49 - { 50 - struct ib_umem_odp *umem_odp = 51 - container_of(n, struct ib_umem_odp, interval_tree); 52 - 53 - return ib_umem_start(umem_odp->umem); 54 - } 55 - 56 - /* Note that the representation of the intervals in the interval tree 57 - * considers the ending point as contained in the interval, while the 58 - * function ib_umem_end returns the first address which is not contained 59 - * in the umem. 60 - */ 61 - static inline u64 node_last(struct umem_odp_node *n) 62 - { 63 - struct ib_umem_odp *umem_odp = 64 - container_of(n, struct ib_umem_odp, interval_tree); 65 - 66 - return ib_umem_end(umem_odp->umem) - 1; 67 - } 68 - 69 - INTERVAL_TREE_DEFINE(struct umem_odp_node, rb, u64, __subtree_last, 70 - node_start, node_last, , rbt_ib_umem) 71 - 72 - /* @last is not a part of the interval. See comment for function 73 - * node_last. 74 - */ 75 - int rbt_ib_umem_for_each_in_range(struct rb_root_cached *root, 76 - u64 start, u64 last, 77 - umem_call_back cb, 78 - void *cookie) 79 - { 80 - int ret_val = 0; 81 - struct umem_odp_node *node, *next; 82 - struct ib_umem_odp *umem; 83 - 84 - if (unlikely(start == last)) 85 - return ret_val; 86 - 87 - for (node = rbt_ib_umem_iter_first(root, start, last - 1); 88 - node; node = next) { 89 - next = rbt_ib_umem_iter_next(node, start, last - 1); 90 - umem = container_of(node, struct ib_umem_odp, interval_tree); 91 - ret_val = cb(umem->umem, start, last, cookie) || ret_val; 92 - } 93 - 94 - return ret_val; 95 - } 96 - EXPORT_SYMBOL(rbt_ib_umem_for_each_in_range); 97 - 98 - struct ib_umem_odp *rbt_ib_umem_lookup(struct rb_root_cached *root, 99 - u64 addr, u64 length) 100 - { 101 - struct umem_odp_node *node; 102 - 103 - node = rbt_ib_umem_iter_first(root, addr, addr + length - 1); 104 - if (node) 105 - return container_of(node, struct ib_umem_odp, interval_tree); 106 - return NULL; 107 - 108 - } 109 - EXPORT_SYMBOL(rbt_ib_umem_lookup);
-4
include/rdma/ib_umem_odp.h
··· 111 111 void ib_umem_odp_unmap_dma_pages(struct ib_umem *umem, u64 start_offset, 112 112 u64 bound); 113 113 114 - void rbt_ib_umem_insert(struct umem_odp_node *node, 115 - struct rb_root_cached *root); 116 - void rbt_ib_umem_remove(struct umem_odp_node *node, 117 - struct rb_root_cached *root); 118 114 typedef int (*umem_call_back)(struct ib_umem *item, u64 start, u64 end, 119 115 void *cookie); 120 116 /*