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

char/mspec: remove SGI SN2 support

The SGI SN2 support is about to be removed, so drop the bits specific to
it from this driver.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://lkml.kernel.org/r/20190813072514.23299-10-hch@lst.de
Signed-off-by: Tony Luck <tony.luck@intel.com>

authored by

Christoph Hellwig and committed by
Tony Luck
0fef2532 9c860e4c

+11 -144
+11 -144
drivers/char/mspec.c
··· 9 9 * 10 10 * This driver exports the SN special memory (mspec) facility to user 11 11 * processes. 12 - * There are three types of memory made available thru this driver: 13 - * fetchops, uncached and cached. 14 - * 15 - * Fetchops are atomic memory operations that are implemented in the 16 - * memory controller on SGI SN hardware. 12 + * There are two types of memory made available thru this driver: 13 + * uncached and cached. 17 14 * 18 15 * Uncached are used for memory write combining feature of the ia64 19 16 * cpu. ··· 43 46 #include <linux/atomic.h> 44 47 #include <asm/tlbflush.h> 45 48 #include <asm/uncached.h> 46 - #include <asm/sn/addrs.h> 47 - #include <asm/sn/arch.h> 48 - #include <asm/sn/mspec.h> 49 - #include <asm/sn/sn_cpuid.h> 50 - #include <asm/sn/io.h> 51 - #include <asm/sn/bte.h> 52 - #include <asm/sn/shubio.h> 53 49 54 50 55 - #define FETCHOP_ID "SGI Fetchop," 56 51 #define CACHED_ID "Cached," 57 52 #define UNCACHED_ID "Uncached" 58 53 #define REVISION "4.0" ··· 54 65 * Page types allocated by the device. 55 66 */ 56 67 enum mspec_page_type { 57 - MSPEC_FETCHOP = 1, 58 - MSPEC_CACHED, 68 + MSPEC_CACHED = 2, 59 69 MSPEC_UNCACHED 60 70 }; 61 - 62 - #ifdef CONFIG_SGI_SN 63 - static int is_sn2; 64 - #else 65 - #define is_sn2 0 66 - #endif 67 71 68 72 /* 69 73 * One of these structures is allocated when an mspec region is mmaped. The ··· 77 95 unsigned long vm_end; /* Original (unsplit) end. */ 78 96 unsigned long maddr[0]; /* Array of MSPEC addresses. */ 79 97 }; 80 - 81 - /* used on shub2 to clear FOP cache in the HUB */ 82 - static unsigned long scratch_page[MAX_NUMNODES]; 83 - #define SH2_AMO_CACHE_ENTRIES 4 84 - 85 - static inline int 86 - mspec_zero_block(unsigned long addr, int len) 87 - { 88 - int status; 89 - 90 - if (is_sn2) { 91 - if (is_shub2()) { 92 - int nid; 93 - void *p; 94 - int i; 95 - 96 - nid = nasid_to_cnodeid(get_node_number(__pa(addr))); 97 - p = (void *)TO_AMO(scratch_page[nid]); 98 - 99 - for (i=0; i < SH2_AMO_CACHE_ENTRIES; i++) { 100 - FETCHOP_LOAD_OP(p, FETCHOP_LOAD); 101 - p += FETCHOP_VAR_SIZE; 102 - } 103 - } 104 - 105 - status = bte_copy(0, addr & ~__IA64_UNCACHED_OFFSET, len, 106 - BTE_WACQUIRE | BTE_ZERO_FILL, NULL); 107 - } else { 108 - memset((char *) addr, 0, len); 109 - status = 0; 110 - } 111 - return status; 112 - } 113 98 114 99 /* 115 100 * mspec_open ··· 122 173 */ 123 174 my_page = vdata->maddr[index]; 124 175 vdata->maddr[index] = 0; 125 - if (!mspec_zero_block(my_page, PAGE_SIZE)) 126 - uncached_free_page(my_page, 1); 127 - else 128 - printk(KERN_WARNING "mspec_close(): " 129 - "failed to zero page %ld\n", my_page); 176 + memset((char *)my_page, 0, PAGE_SIZE); 177 + uncached_free_page(my_page, 1); 130 178 } 131 179 132 180 kvfree(vdata); ··· 159 213 spin_unlock(&vdata->lock); 160 214 } 161 215 162 - if (vdata->type == MSPEC_FETCHOP) 163 - paddr = TO_AMO(maddr); 164 - else 165 - paddr = maddr & ~__IA64_UNCACHED_OFFSET; 166 - 216 + paddr = maddr & ~__IA64_UNCACHED_OFFSET; 167 217 pfn = paddr >> PAGE_SHIFT; 168 218 169 219 return vmf_insert_pfn(vmf->vma, vmf->address, pfn); ··· 211 269 vma->vm_private_data = vdata; 212 270 213 271 vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP; 214 - if (vdata->type == MSPEC_FETCHOP || vdata->type == MSPEC_UNCACHED) 272 + if (vdata->type == MSPEC_UNCACHED) 215 273 vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot); 216 274 vma->vm_ops = &mspec_vm_ops; 217 275 218 276 return 0; 219 - } 220 - 221 - static int 222 - fetchop_mmap(struct file *file, struct vm_area_struct *vma) 223 - { 224 - return mspec_mmap(file, vma, MSPEC_FETCHOP); 225 277 } 226 278 227 279 static int ··· 229 293 { 230 294 return mspec_mmap(file, vma, MSPEC_UNCACHED); 231 295 } 232 - 233 - static const struct file_operations fetchop_fops = { 234 - .owner = THIS_MODULE, 235 - .mmap = fetchop_mmap, 236 - .llseek = noop_llseek, 237 - }; 238 - 239 - static struct miscdevice fetchop_miscdev = { 240 - .minor = MISC_DYNAMIC_MINOR, 241 - .name = "sgi_fetchop", 242 - .fops = &fetchop_fops 243 - }; 244 296 245 297 static const struct file_operations cached_fops = { 246 298 .owner = THIS_MODULE, ··· 263 339 mspec_init(void) 264 340 { 265 341 int ret; 266 - int nid; 267 342 268 - /* 269 - * The fetchop device only works on SN2 hardware, uncached and cached 270 - * memory drivers should both be valid on all ia64 hardware 271 - */ 272 - #ifdef CONFIG_SGI_SN 273 - if (ia64_platform_is("sn2")) { 274 - is_sn2 = 1; 275 - if (is_shub2()) { 276 - ret = -ENOMEM; 277 - for_each_node_state(nid, N_ONLINE) { 278 - int actual_nid; 279 - int nasid; 280 - unsigned long phys; 281 - 282 - scratch_page[nid] = uncached_alloc_page(nid, 1); 283 - if (scratch_page[nid] == 0) 284 - goto free_scratch_pages; 285 - phys = __pa(scratch_page[nid]); 286 - nasid = get_node_number(phys); 287 - actual_nid = nasid_to_cnodeid(nasid); 288 - if (actual_nid != nid) 289 - goto free_scratch_pages; 290 - } 291 - } 292 - 293 - ret = misc_register(&fetchop_miscdev); 294 - if (ret) { 295 - printk(KERN_ERR 296 - "%s: failed to register device %i\n", 297 - FETCHOP_ID, ret); 298 - goto free_scratch_pages; 299 - } 300 - } 301 - #endif 302 343 ret = misc_register(&cached_miscdev); 303 344 if (ret) { 304 345 printk(KERN_ERR "%s: failed to register device %i\n", 305 346 CACHED_ID, ret); 306 - if (is_sn2) 307 - misc_deregister(&fetchop_miscdev); 308 - goto free_scratch_pages; 347 + return ret; 309 348 } 310 349 ret = misc_register(&uncached_miscdev); 311 350 if (ret) { 312 351 printk(KERN_ERR "%s: failed to register device %i\n", 313 352 UNCACHED_ID, ret); 314 353 misc_deregister(&cached_miscdev); 315 - if (is_sn2) 316 - misc_deregister(&fetchop_miscdev); 317 - goto free_scratch_pages; 354 + return ret; 318 355 } 319 356 320 - printk(KERN_INFO "%s %s initialized devices: %s %s %s\n", 321 - MSPEC_BASENAME, REVISION, is_sn2 ? FETCHOP_ID : "", 322 - CACHED_ID, UNCACHED_ID); 357 + printk(KERN_INFO "%s %s initialized devices: %s %s\n", 358 + MSPEC_BASENAME, REVISION, CACHED_ID, UNCACHED_ID); 323 359 324 360 return 0; 325 - 326 - free_scratch_pages: 327 - for_each_node(nid) { 328 - if (scratch_page[nid] != 0) 329 - uncached_free_page(scratch_page[nid], 1); 330 - } 331 - return ret; 332 361 } 333 362 334 363 static void __exit 335 364 mspec_exit(void) 336 365 { 337 - int nid; 338 - 339 366 misc_deregister(&uncached_miscdev); 340 367 misc_deregister(&cached_miscdev); 341 - if (is_sn2) { 342 - misc_deregister(&fetchop_miscdev); 343 - 344 - for_each_node(nid) { 345 - if (scratch_page[nid] != 0) 346 - uncached_free_page(scratch_page[nid], 1); 347 - } 348 - } 349 368 } 350 369 351 370 module_init(mspec_init);