diff options
author | John Garry <john.garry@huawei.com> | 2019-07-30 09:29:54 -0400 |
---|---|---|
committer | Wei Xu <xuwei5@hisilicon.com> | 2019-08-13 02:54:24 -0400 |
commit | b884e2de2afc68ce30f7093747378ef972dde253 (patch) | |
tree | 5cf0eb6a522222635889487bcdc4550b033563ee | |
parent | 0a27142bd1ee259e24a0be2b0133e5ca5df8da91 (diff) |
lib: logic_pio: Add logic_pio_unregister_range()
Add a function to unregister a logical PIO range.
Logical PIO space can still be leaked when unregistering certain
LOGIC_PIO_CPU_MMIO regions, but this acceptable for now since there are no
callers to unregister LOGIC_PIO_CPU_MMIO regions, and the logical PIO
region allocation scheme would need significant work to improve this.
Cc: stable@vger.kernel.org
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Wei Xu <xuwei5@hisilicon.com>
-rw-r--r-- | include/linux/logic_pio.h | 1 | ||||
-rw-r--r-- | lib/logic_pio.c | 14 |
2 files changed, 15 insertions, 0 deletions
diff --git a/include/linux/logic_pio.h b/include/linux/logic_pio.h index cbd9d8495690..88e1e6304a71 100644 --- a/include/linux/logic_pio.h +++ b/include/linux/logic_pio.h | |||
@@ -117,6 +117,7 @@ struct logic_pio_hwaddr *find_io_range_by_fwnode(struct fwnode_handle *fwnode); | |||
117 | unsigned long logic_pio_trans_hwaddr(struct fwnode_handle *fwnode, | 117 | unsigned long logic_pio_trans_hwaddr(struct fwnode_handle *fwnode, |
118 | resource_size_t hw_addr, resource_size_t size); | 118 | resource_size_t hw_addr, resource_size_t size); |
119 | int logic_pio_register_range(struct logic_pio_hwaddr *newrange); | 119 | int logic_pio_register_range(struct logic_pio_hwaddr *newrange); |
120 | void logic_pio_unregister_range(struct logic_pio_hwaddr *range); | ||
120 | resource_size_t logic_pio_to_hwaddr(unsigned long pio); | 121 | resource_size_t logic_pio_to_hwaddr(unsigned long pio); |
121 | unsigned long logic_pio_trans_cpuaddr(resource_size_t hw_addr); | 122 | unsigned long logic_pio_trans_cpuaddr(resource_size_t hw_addr); |
122 | 123 | ||
diff --git a/lib/logic_pio.c b/lib/logic_pio.c index d0165c88f705..905027574e5d 100644 --- a/lib/logic_pio.c +++ b/lib/logic_pio.c | |||
@@ -99,6 +99,20 @@ end_register: | |||
99 | } | 99 | } |
100 | 100 | ||
101 | /** | 101 | /** |
102 | * logic_pio_unregister_range - unregister a logical PIO range for a host | ||
103 | * @range: pointer to the IO range which has been already registered. | ||
104 | * | ||
105 | * Unregister a previously-registered IO range node. | ||
106 | */ | ||
107 | void logic_pio_unregister_range(struct logic_pio_hwaddr *range) | ||
108 | { | ||
109 | mutex_lock(&io_range_mutex); | ||
110 | list_del_rcu(&range->list); | ||
111 | mutex_unlock(&io_range_mutex); | ||
112 | synchronize_rcu(); | ||
113 | } | ||
114 | |||
115 | /** | ||
102 | * find_io_range_by_fwnode - find logical PIO range for given FW node | 116 | * find_io_range_by_fwnode - find logical PIO range for given FW node |
103 | * @fwnode: FW node handle associated with logical PIO range | 117 | * @fwnode: FW node handle associated with logical PIO range |
104 | * | 118 | * |