Lines Matching +full:cpu +full:- +full:map

1 // SPDX-License-Identifier: GPL-2.0
3 * arch/sh/kernel/cpu/sh4/sq.c
5 * General management API for SH-4 integrated Store Queues
7 * Copyright (C) 2001 - 2006 Paul Mundt
11 #include <linux/cpu.h>
23 #include <cpu/sq.h>
50 * sq_flush_range - Flush (prefetch) a specific SQ range
62 for (len >>= 5; len--; sq += 8) in sq_flush_range()
70 static inline void sq_mapping_list_add(struct sq_mapping *map) in sq_mapping_list_add() argument
78 p = &tmp->next; in sq_mapping_list_add()
80 map->next = tmp; in sq_mapping_list_add()
81 *p = map; in sq_mapping_list_add()
86 static inline void sq_mapping_list_del(struct sq_mapping *map) in sq_mapping_list_del() argument
92 for (p = &sq_mapping_list; (tmp = *p); p = &tmp->next) in sq_mapping_list_del()
93 if (tmp == map) { in sq_mapping_list_del()
94 *p = tmp->next; in sq_mapping_list_del()
101 static int __sq_remap(struct sq_mapping *map, pgprot_t prot) in __sq_remap() argument
106 vma = __get_vm_area_caller(map->size, VM_IOREMAP, map->sq_addr, in __sq_remap()
109 return -ENOMEM; in __sq_remap()
111 vma->phys_addr = map->addr; in __sq_remap()
113 if (ioremap_page_range((unsigned long)vma->addr, in __sq_remap()
114 (unsigned long)vma->addr + map->size, in __sq_remap()
115 vma->phys_addr, prot)) { in __sq_remap()
116 vunmap(vma->addr); in __sq_remap()
117 return -EAGAIN; in __sq_remap()
125 __raw_writel(((map->addr >> 26) << 2) & 0x1c, SQ_QACR0); in __sq_remap()
126 __raw_writel(((map->addr >> 26) << 2) & 0x1c, SQ_QACR1); in __sq_remap()
133 * sq_remap - Map a physical address through the Store Queues
146 struct sq_mapping *map; in sq_remap() local
152 end = phys + size - 1; in sq_remap()
154 return -EINVAL; in sq_remap()
157 return -EINVAL; in sq_remap()
160 size = PAGE_ALIGN(end + 1) - phys; in sq_remap()
162 map = kmem_cache_alloc(sq_cache, GFP_KERNEL); in sq_remap()
163 if (unlikely(!map)) in sq_remap()
164 return -ENOMEM; in sq_remap()
166 map->addr = phys; in sq_remap()
167 map->size = size; in sq_remap()
168 map->name = name; in sq_remap()
171 get_order(map->size)); in sq_remap()
173 ret = -ENOSPC; in sq_remap()
177 map->sq_addr = P4SEG_STORE_QUE + (page << PAGE_SHIFT); in sq_remap()
179 ret = __sq_remap(map, prot); in sq_remap()
183 psz = (size + (PAGE_SIZE - 1)) >> PAGE_SHIFT; in sq_remap()
185 likely(map->name) ? map->name : "???", in sq_remap()
187 map->sq_addr, map->addr); in sq_remap()
189 sq_mapping_list_add(map); in sq_remap()
191 return map->sq_addr; in sq_remap()
194 kmem_cache_free(sq_cache, map); in sq_remap()
200 * sq_unmap - Unmap a Store Queue allocation
201 * @vaddr: Pre-allocated Store Queue mapping.
203 * Unmaps the store queue allocation @map that was previously created by
209 struct sq_mapping **p, *map; in sq_unmap() local
212 for (p = &sq_mapping_list; (map = *p); p = &map->next) in sq_unmap()
213 if (map->sq_addr == vaddr) in sq_unmap()
216 if (unlikely(!map)) { in sq_unmap()
222 page = (map->sq_addr - P4SEG_STORE_QUE) >> PAGE_SHIFT; in sq_unmap()
223 bitmap_release_region(sq_bitmap, page, get_order(map->size)); in sq_unmap()
232 vma = remove_vm_area((void *)(map->sq_addr & PAGE_MASK)); in sq_unmap()
235 __func__, map->sq_addr); in sq_unmap()
241 sq_mapping_list_del(map); in sq_unmap()
243 kmem_cache_free(sq_cache, map); in sq_unmap()
249 * there is any other easy way to add things on a per-cpu basis without
251 * links in sysfs by hand back in to the per-cpu directories.
272 if (likely(sattr->show)) in sq_sysfs_show()
273 return sattr->show(buf); in sq_sysfs_show()
275 return -EIO; in sq_sysfs_show()
283 if (likely(sattr->store)) in sq_sysfs_store()
284 return sattr->store(buf, count); in sq_sysfs_store()
286 return -EIO; in sq_sysfs_store()
294 for (list = &sq_mapping_list; (entry = *list); list = &entry->next) in mapping_show()
295 p += sprintf(p, "%08lx-%08lx [%08lx]: %s\n", in mapping_show()
296 entry->sq_addr, entry->sq_addr + entry->size, in mapping_show()
297 entry->addr, entry->name); in mapping_show()
299 return p - buf; in mapping_show()
308 return -EIO; in mapping_store()
341 unsigned int cpu = dev->id; in sq_dev_add() local
345 sq_kobject[cpu] = kzalloc(sizeof(struct kobject), GFP_KERNEL); in sq_dev_add()
346 if (unlikely(!sq_kobject[cpu])) in sq_dev_add()
347 return -ENOMEM; in sq_dev_add()
349 kobj = sq_kobject[cpu]; in sq_dev_add()
350 error = kobject_init_and_add(kobj, &ktype_percpu_entry, &dev->kobj, in sq_dev_add()
359 unsigned int cpu = dev->id; in sq_dev_remove() local
360 struct kobject *kobj = sq_kobject[cpu]; in sq_dev_remove()
375 int ret = -ENOMEM; in sq_api_init()
411 MODULE_AUTHOR("Paul Mundt <lethal@linux-sh.org>, M. R. Brown <mrbrown@0xd6.org>");
412 MODULE_DESCRIPTION("Simple API for SH-4 integrated Store Queues");