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 's390-6.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux

Pull s390 fixes from Alexander Gordeev:

- clear 'Search boot program' flag when 'bootprog' sysfs file is
written to override a value set from Hardware Management Console

- fix cyclic dead-lock in zpci_zdev_put() and zpci_scan_devices()
functions when triggering PCI device recovery using sysfs

- annotate the expected lock context imbalance in zpci_release_device()
function to fix a sparse complaint

- fix the logic to fallback to the return address register value in the
topmost frame when stack tracing uses a back chain

* tag 's390-6.19-3' of git://git.kernel.org/pub/scm/linux/kernel/git/s390/linux:
s390/stacktrace: Do not fallback to RA register
s390/pci: Annotate lock context imbalance in zpci_release_device()
s390/pci: Fix cyclic dead-lock in zpci_zdev_put() and zpci_scan_devices()
s390/ipl: Clear SBP flag when bootprog is set

+131 -57
+1
.clang-format
··· 748 748 - 'ynl_attr_for_each_nested' 749 749 - 'ynl_attr_for_each_payload' 750 750 - 'zorro_for_each_dev' 751 + - 'zpci_bus_for_each' 751 752 752 753 IncludeBlocks: Preserve 753 754 IncludeCategories:
+1
arch/s390/include/uapi/asm/ipl.h
··· 15 15 #define IPL_PL_FLAG_IPLPS 0x80 16 16 #define IPL_PL_FLAG_SIPL 0x40 17 17 #define IPL_PL_FLAG_IPLSR 0x20 18 + #define IPL_PL_FLAG_SBP 0x10 18 19 19 20 /* IPL Parameter Block header */ 20 21 struct ipl_pb_hdr {
+36 -12
arch/s390/kernel/ipl.c
··· 262 262 sys_##_prefix##_##_name##_show, \ 263 263 sys_##_prefix##_##_name##_store) 264 264 265 + #define DEFINE_IPL_ATTR_BOOTPROG_RW(_prefix, _name, _fmt_out, _fmt_in, _hdr, _value) \ 266 + IPL_ATTR_SHOW_FN(_prefix, _name, _fmt_out, (unsigned long long) _value) \ 267 + static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \ 268 + struct kobj_attribute *attr, \ 269 + const char *buf, size_t len) \ 270 + { \ 271 + unsigned long long value; \ 272 + if (sscanf(buf, _fmt_in, &value) != 1) \ 273 + return -EINVAL; \ 274 + (_value) = value; \ 275 + (_hdr).flags &= ~IPL_PL_FLAG_SBP; \ 276 + return len; \ 277 + } \ 278 + static struct kobj_attribute sys_##_prefix##_##_name##_attr = \ 279 + __ATTR(_name, 0644, \ 280 + sys_##_prefix##_##_name##_show, \ 281 + sys_##_prefix##_##_name##_store) 282 + 265 283 #define DEFINE_IPL_ATTR_STR_RW(_prefix, _name, _fmt_out, _fmt_in, _value)\ 266 284 IPL_ATTR_SHOW_FN(_prefix, _name, _fmt_out, _value) \ 267 285 static ssize_t sys_##_prefix##_##_name##_store(struct kobject *kobj, \ ··· 836 818 reipl_block_fcp->fcp.wwpn); 837 819 DEFINE_IPL_ATTR_RW(reipl_fcp, lun, "0x%016llx\n", "%llx\n", 838 820 reipl_block_fcp->fcp.lun); 839 - DEFINE_IPL_ATTR_RW(reipl_fcp, bootprog, "%lld\n", "%lld\n", 840 - reipl_block_fcp->fcp.bootprog); 841 821 DEFINE_IPL_ATTR_RW(reipl_fcp, br_lba, "%lld\n", "%lld\n", 842 822 reipl_block_fcp->fcp.br_lba); 843 823 DEFINE_IPL_ATTR_RW(reipl_fcp, device, "0.0.%04llx\n", "0.0.%llx\n", 844 824 reipl_block_fcp->fcp.devno); 825 + DEFINE_IPL_ATTR_BOOTPROG_RW(reipl_fcp, bootprog, "%lld\n", "%lld\n", 826 + reipl_block_fcp->hdr, 827 + reipl_block_fcp->fcp.bootprog); 845 828 846 829 static void reipl_get_ascii_loadparm(char *loadparm, 847 830 struct ipl_parameter_block *ibp) ··· 961 942 reipl_block_nvme->nvme.fid); 962 943 DEFINE_IPL_ATTR_RW(reipl_nvme, nsid, "0x%08llx\n", "%llx\n", 963 944 reipl_block_nvme->nvme.nsid); 964 - DEFINE_IPL_ATTR_RW(reipl_nvme, bootprog, "%lld\n", "%lld\n", 965 - reipl_block_nvme->nvme.bootprog); 966 945 DEFINE_IPL_ATTR_RW(reipl_nvme, br_lba, "%lld\n", "%lld\n", 967 946 reipl_block_nvme->nvme.br_lba); 947 + DEFINE_IPL_ATTR_BOOTPROG_RW(reipl_nvme, bootprog, "%lld\n", "%lld\n", 948 + reipl_block_nvme->hdr, 949 + reipl_block_nvme->nvme.bootprog); 968 950 969 951 static struct attribute *reipl_nvme_attrs[] = { 970 952 &sys_reipl_nvme_fid_attr.attr, ··· 1058 1038 }; 1059 1039 1060 1040 DEFINE_IPL_CCW_ATTR_RW(reipl_eckd, device, reipl_block_eckd->eckd); 1061 - DEFINE_IPL_ATTR_RW(reipl_eckd, bootprog, "%lld\n", "%lld\n", 1062 - reipl_block_eckd->eckd.bootprog); 1041 + DEFINE_IPL_ATTR_BOOTPROG_RW(reipl_eckd, bootprog, "%lld\n", "%lld\n", 1042 + reipl_block_eckd->hdr, 1043 + reipl_block_eckd->eckd.bootprog); 1063 1044 1064 1045 static struct attribute *reipl_eckd_attrs[] = { 1065 1046 &sys_reipl_eckd_device_attr.attr, ··· 1588 1567 dump_block_fcp->fcp.wwpn); 1589 1568 DEFINE_IPL_ATTR_RW(dump_fcp, lun, "0x%016llx\n", "%llx\n", 1590 1569 dump_block_fcp->fcp.lun); 1591 - DEFINE_IPL_ATTR_RW(dump_fcp, bootprog, "%lld\n", "%lld\n", 1592 - dump_block_fcp->fcp.bootprog); 1593 1570 DEFINE_IPL_ATTR_RW(dump_fcp, br_lba, "%lld\n", "%lld\n", 1594 1571 dump_block_fcp->fcp.br_lba); 1595 1572 DEFINE_IPL_ATTR_RW(dump_fcp, device, "0.0.%04llx\n", "0.0.%llx\n", 1596 1573 dump_block_fcp->fcp.devno); 1574 + DEFINE_IPL_ATTR_BOOTPROG_RW(dump_fcp, bootprog, "%lld\n", "%lld\n", 1575 + dump_block_fcp->hdr, 1576 + dump_block_fcp->fcp.bootprog); 1597 1577 1598 1578 DEFINE_IPL_ATTR_SCP_DATA_RW(dump_fcp, dump_block_fcp->hdr, 1599 1579 dump_block_fcp->fcp, ··· 1626 1604 dump_block_nvme->nvme.fid); 1627 1605 DEFINE_IPL_ATTR_RW(dump_nvme, nsid, "0x%08llx\n", "%llx\n", 1628 1606 dump_block_nvme->nvme.nsid); 1629 - DEFINE_IPL_ATTR_RW(dump_nvme, bootprog, "%lld\n", "%llx\n", 1630 - dump_block_nvme->nvme.bootprog); 1631 1607 DEFINE_IPL_ATTR_RW(dump_nvme, br_lba, "%lld\n", "%llx\n", 1632 1608 dump_block_nvme->nvme.br_lba); 1609 + DEFINE_IPL_ATTR_BOOTPROG_RW(dump_nvme, bootprog, "%lld\n", "%llx\n", 1610 + dump_block_nvme->hdr, 1611 + dump_block_nvme->nvme.bootprog); 1633 1612 1634 1613 DEFINE_IPL_ATTR_SCP_DATA_RW(dump_nvme, dump_block_nvme->hdr, 1635 1614 dump_block_nvme->nvme, ··· 1658 1635 1659 1636 /* ECKD dump device attributes */ 1660 1637 DEFINE_IPL_CCW_ATTR_RW(dump_eckd, device, dump_block_eckd->eckd); 1661 - DEFINE_IPL_ATTR_RW(dump_eckd, bootprog, "%lld\n", "%llx\n", 1662 - dump_block_eckd->eckd.bootprog); 1638 + DEFINE_IPL_ATTR_BOOTPROG_RW(dump_eckd, bootprog, "%lld\n", "%llx\n", 1639 + dump_block_eckd->hdr, 1640 + dump_block_eckd->eckd.bootprog); 1663 1641 1664 1642 IPL_ATTR_BR_CHR_SHOW_FN(dump, dump_block_eckd->eckd); 1665 1643 IPL_ATTR_BR_CHR_STORE_FN(dump, dump_block_eckd->eckd);
+2 -16
arch/s390/kernel/stacktrace.c
··· 104 104 struct stack_frame_vdso_wrapper __user *sf_vdso; 105 105 struct stack_frame_user __user *sf; 106 106 unsigned long ip, sp; 107 - bool first = true; 108 107 109 108 if (!current->mm) 110 109 return; ··· 132 133 if (__get_user(ip, &sf->gprs[8])) 133 134 break; 134 135 } 135 - /* Sanity check: ABI requires SP to be 8 byte aligned. */ 136 - if (sp & 0x7) 136 + /* Validate SP and RA (ABI requires SP to be 8 byte aligned). */ 137 + if (sp & 0x7 || ip_invalid(ip)) 137 138 break; 138 - if (ip_invalid(ip)) { 139 - /* 140 - * If the instruction address is invalid, and this 141 - * is the first stack frame, assume r14 has not 142 - * been written to the stack yet. Otherwise exit. 143 - */ 144 - if (!first) 145 - break; 146 - ip = regs->gprs[14]; 147 - if (ip_invalid(ip)) 148 - break; 149 - } 150 139 if (!store_ip(consume_entry, cookie, entry, perf, ip)) 151 140 break; 152 - first = false; 153 141 } 154 142 pagefault_enable(); 155 143 }
+6 -1
arch/s390/pci/pci.c
··· 961 961 } 962 962 963 963 void zpci_release_device(struct kref *kref) 964 + __releases(&zpci_list_lock) 964 965 { 965 966 struct zpci_dev *zdev = container_of(kref, struct zpci_dev, kref); 966 967 ··· 1149 1148 1150 1149 int zpci_scan_devices(void) 1151 1150 { 1151 + struct zpci_bus *zbus; 1152 1152 LIST_HEAD(scan_list); 1153 1153 int rc; 1154 1154 ··· 1158 1156 return rc; 1159 1157 1160 1158 zpci_add_devices(&scan_list); 1161 - zpci_bus_scan_busses(); 1159 + zpci_bus_for_each(zbus) { 1160 + zpci_bus_scan_bus(zbus); 1161 + cond_resched(); 1162 + } 1162 1163 return 0; 1163 1164 } 1164 1165
+71 -27
arch/s390/pci/pci_bus.c
··· 153 153 return ret; 154 154 } 155 155 156 - /* zpci_bus_scan_busses - Scan all registered busses 157 - * 158 - * Scan all available zbusses 159 - * 160 - */ 161 - void zpci_bus_scan_busses(void) 162 - { 163 - struct zpci_bus *zbus = NULL; 164 - 165 - mutex_lock(&zbus_list_lock); 166 - list_for_each_entry(zbus, &zbus_list, bus_next) { 167 - zpci_bus_scan_bus(zbus); 168 - cond_resched(); 169 - } 170 - mutex_unlock(&zbus_list_lock); 171 - } 172 - 173 156 static bool zpci_bus_is_multifunction_root(struct zpci_dev *zdev) 174 157 { 175 158 return !s390_pci_no_rid && zdev->rid_available && ··· 205 222 return -ENOMEM; 206 223 } 207 224 208 - static void zpci_bus_release(struct kref *kref) 225 + /** 226 + * zpci_bus_release - Un-initialize resources associated with the zbus and 227 + * free memory 228 + * @kref: refcount * that is part of struct zpci_bus 229 + * 230 + * MUST be called with `zbus_list_lock` held, but the lock is released during 231 + * run of the function. 232 + */ 233 + static inline void zpci_bus_release(struct kref *kref) 234 + __releases(&zbus_list_lock) 209 235 { 210 236 struct zpci_bus *zbus = container_of(kref, struct zpci_bus, kref); 237 + 238 + lockdep_assert_held(&zbus_list_lock); 239 + 240 + list_del(&zbus->bus_next); 241 + mutex_unlock(&zbus_list_lock); 242 + 243 + /* 244 + * At this point no-one should see this object, or be able to get a new 245 + * reference to it. 246 + */ 211 247 212 248 if (zbus->bus) { 213 249 pci_lock_rescan_remove(); ··· 239 237 pci_unlock_rescan_remove(); 240 238 } 241 239 242 - mutex_lock(&zbus_list_lock); 243 - list_del(&zbus->bus_next); 244 - mutex_unlock(&zbus_list_lock); 245 240 zpci_remove_parent_msi_domain(zbus); 246 241 kfree(zbus); 247 242 } 248 243 249 - static void zpci_bus_put(struct zpci_bus *zbus) 244 + static inline void __zpci_bus_get(struct zpci_bus *zbus) 250 245 { 251 - kref_put(&zbus->kref, zpci_bus_release); 246 + lockdep_assert_held(&zbus_list_lock); 247 + kref_get(&zbus->kref); 248 + } 249 + 250 + static inline void zpci_bus_put(struct zpci_bus *zbus) 251 + { 252 + kref_put_mutex(&zbus->kref, zpci_bus_release, &zbus_list_lock); 252 253 } 253 254 254 255 static struct zpci_bus *zpci_bus_get(int topo, bool topo_is_tid) ··· 263 258 if (!zbus->multifunction) 264 259 continue; 265 260 if (topo_is_tid == zbus->topo_is_tid && topo == zbus->topo) { 266 - kref_get(&zbus->kref); 261 + __zpci_bus_get(zbus); 267 262 goto out_unlock; 268 263 } 269 264 } ··· 271 266 out_unlock: 272 267 mutex_unlock(&zbus_list_lock); 273 268 return zbus; 269 + } 270 + 271 + /** 272 + * zpci_bus_get_next - get the next zbus object from given position in the list 273 + * @pos: current position/cursor in the global zbus list 274 + * 275 + * Acquires and releases references as the cursor iterates (might also free/ 276 + * release the cursor). Is tolerant of concurrent operations on the list. 277 + * 278 + * To begin the iteration, set *@pos to %NULL before calling the function. 279 + * 280 + * *@pos is set to %NULL in cases where either the list is empty, or *@pos is 281 + * the last element in the list. 282 + * 283 + * Context: Process context. May sleep. 284 + */ 285 + void zpci_bus_get_next(struct zpci_bus **pos) 286 + { 287 + struct zpci_bus *curp = *pos, *next = NULL; 288 + 289 + mutex_lock(&zbus_list_lock); 290 + if (curp) 291 + next = list_next_entry(curp, bus_next); 292 + else 293 + next = list_first_entry(&zbus_list, typeof(*curp), bus_next); 294 + 295 + if (list_entry_is_head(next, &zbus_list, bus_next)) 296 + next = NULL; 297 + 298 + if (next) 299 + __zpci_bus_get(next); 300 + 301 + *pos = next; 302 + mutex_unlock(&zbus_list_lock); 303 + 304 + /* zpci_bus_put() might drop refcount to 0 and locks zbus_list_lock */ 305 + if (curp) 306 + zpci_bus_put(curp); 274 307 } 275 308 276 309 static struct zpci_bus *zpci_bus_alloc(int topo, bool topo_is_tid) ··· 322 279 zbus->topo = topo; 323 280 zbus->topo_is_tid = topo_is_tid; 324 281 INIT_LIST_HEAD(&zbus->bus_next); 325 - mutex_lock(&zbus_list_lock); 326 - list_add_tail(&zbus->bus_next, &zbus_list); 327 - mutex_unlock(&zbus_list_lock); 328 282 329 283 kref_init(&zbus->kref); 330 284 INIT_LIST_HEAD(&zbus->resources); ··· 330 290 zbus->bus_resource.end = ZPCI_BUS_NR; 331 291 zbus->bus_resource.flags = IORESOURCE_BUS; 332 292 pci_add_resource(&zbus->resources, &zbus->bus_resource); 293 + 294 + mutex_lock(&zbus_list_lock); 295 + list_add_tail(&zbus->bus_next, &zbus_list); 296 + mutex_unlock(&zbus_list_lock); 333 297 334 298 return zbus; 335 299 }
+14 -1
arch/s390/pci/pci_bus.h
··· 15 15 void zpci_bus_device_unregister(struct zpci_dev *zdev); 16 16 17 17 int zpci_bus_scan_bus(struct zpci_bus *zbus); 18 - void zpci_bus_scan_busses(void); 18 + void zpci_bus_get_next(struct zpci_bus **pos); 19 + 20 + /** 21 + * zpci_bus_for_each - iterate over all the registered zbus objects 22 + * @pos: a struct zpci_bus * as cursor 23 + * 24 + * Acquires and releases references as the cursor iterates over the registered 25 + * objects. Is tolerant against concurrent removals of objects. 26 + * 27 + * Context: Process context. May sleep. 28 + */ 29 + #define zpci_bus_for_each(pos) \ 30 + for ((pos) = NULL, zpci_bus_get_next(&(pos)); (pos) != NULL; \ 31 + zpci_bus_get_next(&(pos))) 19 32 20 33 int zpci_bus_scan_device(struct zpci_dev *zdev); 21 34 void zpci_bus_remove_device(struct zpci_dev *zdev, bool set_error);