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

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'powerpc-4.9-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux

Pull powerpc fixes from Michael Ellerman:
"Fixes marked for stable:
- Prevent unlikely crash in copro_calculate_slb() (Frederic Barrat)
- cxl: Prevent adapter reset if an active context exists (Vaibhav Jain)

Fixes for code merged this cycle:
- Fix boot on systems with uncompressed kernel image (Heiner Kallweit)
- Drop dump_numa_memory_topology() (Michael Ellerman)
- Fix numa topology console print (Aneesh Kumar K.V)
- Ignore the pkey system calls for now (Stephen Rothwell)"

* tag 'powerpc-4.9-3' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux:
powerpc: Ignore the pkey system calls for now
powerpc: Fix numa topology console print
powerpc/mm: Drop dump_numa_memory_topology()
cxl: Prevent adapter reset if an active context exists
powerpc/boot: Fix boot on systems with uncompressed kernel image
powerpc/mm: Prevent unlikely crash in copro_calculate_slb()

+148 -50
+5 -2
Documentation/ABI/testing/sysfs-class-cxl
··· 220 220 Date: October 2014 221 221 Contact: linuxppc-dev@lists.ozlabs.org 222 222 Description: write only 223 - Writing 1 will issue a PERST to card which may cause the card 224 - to reload the FPGA depending on load_image_on_perst. 223 + Writing 1 will issue a PERST to card provided there are no 224 + contexts active on any one of the card AFUs. This may cause 225 + the card to reload the FPGA depending on load_image_on_perst. 226 + Writing -1 will do a force PERST irrespective of any active 227 + contexts on the card AFUs. 225 228 Users: https://github.com/ibm-capi/libcxl 226 229 227 230 What: /sys/class/cxl/<card>/perst_reloads_same_image (not in a guest)
+16 -2
arch/powerpc/boot/main.c
··· 32 32 void *addr = 0; 33 33 struct elf_info ei; 34 34 long len; 35 + int uncompressed_image = 0; 35 36 36 - partial_decompress(vmlinuz_addr, vmlinuz_size, 37 + len = partial_decompress(vmlinuz_addr, vmlinuz_size, 37 38 elfheader, sizeof(elfheader), 0); 39 + /* assume uncompressed data if -1 is returned */ 40 + if (len == -1) { 41 + uncompressed_image = 1; 42 + memcpy(elfheader, vmlinuz_addr, sizeof(elfheader)); 43 + printf("No valid compressed data found, assume uncompressed data\n\r"); 44 + } 38 45 39 46 if (!parse_elf64(elfheader, &ei) && !parse_elf32(elfheader, &ei)) 40 47 fatal("Error: not a valid PPC32 or PPC64 ELF file!\n\r"); ··· 74 67 "device tree\n\r"); 75 68 } 76 69 70 + if (uncompressed_image) { 71 + memcpy(addr, vmlinuz_addr + ei.elfoffset, ei.loadsize); 72 + printf("0x%lx bytes of uncompressed data copied\n\r", 73 + ei.loadsize); 74 + goto out; 75 + } 76 + 77 77 /* Finally, decompress the kernel */ 78 78 printf("Decompressing (0x%p <- 0x%p:0x%p)...\n\r", addr, 79 79 vmlinuz_addr, vmlinuz_addr+vmlinuz_size); ··· 96 82 len, ei.loadsize); 97 83 98 84 printf("Done! Decompressed 0x%lx bytes\n\r", len); 99 - 85 + out: 100 86 flush_cache(addr, ei.loadsize); 101 87 102 88 return (struct addr_range){addr, ei.memsize};
+4
arch/powerpc/include/asm/unistd.h
··· 16 16 17 17 #define __NR__exit __NR_exit 18 18 19 + #define __IGNORE_pkey_mprotect 20 + #define __IGNORE_pkey_alloc 21 + #define __IGNORE_pkey_free 22 + 19 23 #ifndef __ASSEMBLY__ 20 24 21 25 #include <linux/types.h>
+2
arch/powerpc/mm/copro_fault.c
··· 106 106 switch (REGION_ID(ea)) { 107 107 case USER_REGION_ID: 108 108 pr_devel("%s: 0x%llx -- USER_REGION_ID\n", __func__, ea); 109 + if (mm == NULL) 110 + return 1; 109 111 psize = get_slice_psize(mm, ea); 110 112 ssize = user_segment_size(ea); 111 113 vsid = get_vsid(mm->context.id, ea, ssize);
+5 -41
arch/powerpc/mm/numa.c
··· 845 845 return; 846 846 847 847 for_each_online_node(node) { 848 - printk(KERN_DEBUG "Node %d CPUs:", node); 848 + pr_info("Node %d CPUs:", node); 849 849 850 850 count = 0; 851 851 /* ··· 856 856 if (cpumask_test_cpu(cpu, 857 857 node_to_cpumask_map[node])) { 858 858 if (count == 0) 859 - printk(" %u", cpu); 859 + pr_cont(" %u", cpu); 860 860 ++count; 861 861 } else { 862 862 if (count > 1) 863 - printk("-%u", cpu - 1); 863 + pr_cont("-%u", cpu - 1); 864 864 count = 0; 865 865 } 866 866 } 867 867 868 868 if (count > 1) 869 - printk("-%u", nr_cpu_ids - 1); 870 - printk("\n"); 871 - } 872 - } 873 - 874 - static void __init dump_numa_memory_topology(void) 875 - { 876 - unsigned int node; 877 - unsigned int count; 878 - 879 - if (min_common_depth == -1 || !numa_enabled) 880 - return; 881 - 882 - for_each_online_node(node) { 883 - unsigned long i; 884 - 885 - printk(KERN_DEBUG "Node %d Memory:", node); 886 - 887 - count = 0; 888 - 889 - for (i = 0; i < memblock_end_of_DRAM(); 890 - i += (1 << SECTION_SIZE_BITS)) { 891 - if (early_pfn_to_nid(i >> PAGE_SHIFT) == node) { 892 - if (count == 0) 893 - printk(" 0x%lx", i); 894 - ++count; 895 - } else { 896 - if (count > 0) 897 - printk("-0x%lx", i); 898 - count = 0; 899 - } 900 - } 901 - 902 - if (count > 0) 903 - printk("-0x%lx", i); 904 - printk("\n"); 869 + pr_cont("-%u", nr_cpu_ids - 1); 870 + pr_cont("\n"); 905 871 } 906 872 } 907 873 ··· 913 947 914 948 if (parse_numa_properties()) 915 949 setup_nonnuma(); 916 - else 917 - dump_numa_memory_topology(); 918 950 919 951 memblock_dump_all(); 920 952
+9
drivers/misc/cxl/api.c
··· 229 229 if (ctx->status == STARTED) 230 230 goto out; /* already started */ 231 231 232 + /* 233 + * Increment the mapped context count for adapter. This also checks 234 + * if adapter_context_lock is taken. 235 + */ 236 + rc = cxl_adapter_context_get(ctx->afu->adapter); 237 + if (rc) 238 + goto out; 239 + 232 240 if (task) { 233 241 ctx->pid = get_task_pid(task, PIDTYPE_PID); 234 242 ctx->glpid = get_task_pid(task->group_leader, PIDTYPE_PID); ··· 248 240 249 241 if ((rc = cxl_ops->attach_process(ctx, kernel, wed, 0))) { 250 242 put_pid(ctx->pid); 243 + cxl_adapter_context_put(ctx->afu->adapter); 251 244 cxl_ctx_put(); 252 245 goto out; 253 246 }
+3
drivers/misc/cxl/context.c
··· 238 238 put_pid(ctx->glpid); 239 239 240 240 cxl_ctx_put(); 241 + 242 + /* Decrease the attached context count on the adapter */ 243 + cxl_adapter_context_put(ctx->afu->adapter); 241 244 return 0; 242 245 } 243 246
+24
drivers/misc/cxl/cxl.h
··· 618 618 bool perst_select_user; 619 619 bool perst_same_image; 620 620 bool psl_timebase_synced; 621 + 622 + /* 623 + * number of contexts mapped on to this card. Possible values are: 624 + * >0: Number of contexts mapped and new one can be mapped. 625 + * 0: No active contexts and new ones can be mapped. 626 + * -1: No contexts mapped and new ones cannot be mapped. 627 + */ 628 + atomic_t contexts_num; 621 629 }; 622 630 623 631 int cxl_pci_alloc_one_irq(struct cxl *adapter); ··· 952 944 953 945 /* decode AFU error bits in the PSL register PSL_SERR_An */ 954 946 void cxl_afu_decode_psl_serr(struct cxl_afu *afu, u64 serr); 947 + 948 + /* 949 + * Increments the number of attached contexts on an adapter. 950 + * In case an adapter_context_lock is taken the return -EBUSY. 951 + */ 952 + int cxl_adapter_context_get(struct cxl *adapter); 953 + 954 + /* Decrements the number of attached contexts on an adapter */ 955 + void cxl_adapter_context_put(struct cxl *adapter); 956 + 957 + /* If no active contexts then prevents contexts from being attached */ 958 + int cxl_adapter_context_lock(struct cxl *adapter); 959 + 960 + /* Unlock the contexts-lock if taken. Warn and force unlock otherwise */ 961 + void cxl_adapter_context_unlock(struct cxl *adapter); 962 + 955 963 #endif
+11
drivers/misc/cxl/file.c
··· 205 205 ctx->pid = get_task_pid(current, PIDTYPE_PID); 206 206 ctx->glpid = get_task_pid(current->group_leader, PIDTYPE_PID); 207 207 208 + /* 209 + * Increment the mapped context count for adapter. This also checks 210 + * if adapter_context_lock is taken. 211 + */ 212 + rc = cxl_adapter_context_get(ctx->afu->adapter); 213 + if (rc) { 214 + afu_release_irqs(ctx, ctx); 215 + goto out; 216 + } 217 + 208 218 trace_cxl_attach(ctx, work.work_element_descriptor, work.num_interrupts, amr); 209 219 210 220 if ((rc = cxl_ops->attach_process(ctx, false, work.work_element_descriptor, 211 221 amr))) { 212 222 afu_release_irqs(ctx, ctx); 223 + cxl_adapter_context_put(ctx->afu->adapter); 213 224 goto out; 214 225 } 215 226
+3
drivers/misc/cxl/guest.c
··· 1152 1152 if ((rc = cxl_sysfs_adapter_add(adapter))) 1153 1153 goto err_put1; 1154 1154 1155 + /* release the context lock as the adapter is configured */ 1156 + cxl_adapter_context_unlock(adapter); 1157 + 1155 1158 return adapter; 1156 1159 1157 1160 err_put1:
+41 -1
drivers/misc/cxl/main.c
··· 243 243 if (dev_set_name(&adapter->dev, "card%i", adapter->adapter_num)) 244 244 goto err2; 245 245 246 - return adapter; 246 + /* start with context lock taken */ 247 + atomic_set(&adapter->contexts_num, -1); 247 248 249 + return adapter; 248 250 err2: 249 251 cxl_remove_adapter_nr(adapter); 250 252 err1: ··· 286 284 dev_warn(&afu->dev, "No supported programming modes available\n"); 287 285 /* We don't fail this so the user can inspect sysfs */ 288 286 return 0; 287 + } 288 + 289 + int cxl_adapter_context_get(struct cxl *adapter) 290 + { 291 + int rc; 292 + 293 + rc = atomic_inc_unless_negative(&adapter->contexts_num); 294 + return rc >= 0 ? 0 : -EBUSY; 295 + } 296 + 297 + void cxl_adapter_context_put(struct cxl *adapter) 298 + { 299 + atomic_dec_if_positive(&adapter->contexts_num); 300 + } 301 + 302 + int cxl_adapter_context_lock(struct cxl *adapter) 303 + { 304 + int rc; 305 + /* no active contexts -> contexts_num == 0 */ 306 + rc = atomic_cmpxchg(&adapter->contexts_num, 0, -1); 307 + return rc ? -EBUSY : 0; 308 + } 309 + 310 + void cxl_adapter_context_unlock(struct cxl *adapter) 311 + { 312 + int val = atomic_cmpxchg(&adapter->contexts_num, -1, 0); 313 + 314 + /* 315 + * contexts lock taken -> contexts_num == -1 316 + * If not true then show a warning and force reset the lock. 317 + * This will happen when context_unlock was requested without 318 + * doing a context_lock. 319 + */ 320 + if (val != -1) { 321 + atomic_set(&adapter->contexts_num, 0); 322 + WARN(1, "Adapter context unlocked with %d active contexts", 323 + val); 324 + } 289 325 } 290 326 291 327 static int __init init_cxl(void)
+2
drivers/misc/cxl/pci.c
··· 1487 1487 if ((rc = cxl_native_register_psl_err_irq(adapter))) 1488 1488 goto err; 1489 1489 1490 + /* Release the context lock as adapter is configured */ 1491 + cxl_adapter_context_unlock(adapter); 1490 1492 return 0; 1491 1493 1492 1494 err:
+23 -4
drivers/misc/cxl/sysfs.c
··· 75 75 int val; 76 76 77 77 rc = sscanf(buf, "%i", &val); 78 - if ((rc != 1) || (val != 1)) 78 + if ((rc != 1) || (val != 1 && val != -1)) 79 79 return -EINVAL; 80 80 81 - if ((rc = cxl_ops->adapter_reset(adapter))) 82 - return rc; 83 - return count; 81 + /* 82 + * See if we can lock the context mapping that's only allowed 83 + * when there are no contexts attached to the adapter. Once 84 + * taken this will also prevent any context from getting activated. 85 + */ 86 + if (val == 1) { 87 + rc = cxl_adapter_context_lock(adapter); 88 + if (rc) 89 + goto out; 90 + 91 + rc = cxl_ops->adapter_reset(adapter); 92 + /* In case reset failed release context lock */ 93 + if (rc) 94 + cxl_adapter_context_unlock(adapter); 95 + 96 + } else if (val == -1) { 97 + /* Perform a forced adapter reset */ 98 + rc = cxl_ops->adapter_reset(adapter); 99 + } 100 + 101 + out: 102 + return rc ? rc : count; 84 103 } 85 104 86 105 static ssize_t load_image_on_perst_show(struct device *device,