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

s390/ap: Rename mutex ap_perms_mutex to ap_attr_mutex

The mutex ap_perms_mutex was already used not only for protection
of the struct ap_perms ap_perms variable but also for an consistent
update of the AP bus sysfs attributes apmask and aqmask.

So rename this mutex to ap_attr_mutex which better reflects the
current use. This is also a preparation for an upcoming patch which
will use this mutex to lock updates on a new sysfs attribute.

Signed-off-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Holger Dengler <dengler@linux.ibm.com>
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>

authored by

Harald Freudenberger and committed by
Heiko Carstens
8babcc2b d38a87d7

+52 -48
+22 -18
drivers/s390/crypto/ap_bus.c
··· 86 86 /* Default permissions (ioctl, card and domain masking) */ 87 87 struct ap_perms ap_perms; 88 88 EXPORT_SYMBOL(ap_perms); 89 - DEFINE_MUTEX(ap_perms_mutex); 90 - EXPORT_SYMBOL(ap_perms_mutex); 89 + /* 90 + * Mutex for consistent read and write of the ap_perms struct 91 + * and the ap bus sysfs attributes apmask and aqmask. 92 + */ 93 + DEFINE_MUTEX(ap_attr_mutex); 94 + EXPORT_SYMBOL(ap_attr_mutex); 91 95 92 96 /* # of bindings complete since init */ 93 97 static atomic64_t ap_bindings_complete_count = ATOMIC64_INIT(0); ··· 875 871 } 876 872 } 877 873 } else { 878 - mutex_lock(&ap_perms_mutex); 874 + mutex_lock(&ap_attr_mutex); 879 875 devres = test_bit_inv(card, ap_perms.apm) && 880 876 test_bit_inv(queue, ap_perms.aqm); 881 - mutex_unlock(&ap_perms_mutex); 877 + mutex_unlock(&ap_attr_mutex); 882 878 drvres = to_ap_drv(dev->driver)->flags 883 879 & AP_DRIVER_FLAG_DEFAULT; 884 880 if (!!devres != !!drvres) { ··· 906 902 * @card: the APID of the adapter card to check 907 903 * @queue: the APQI of the queue to check 908 904 * 909 - * Note: the ap_perms_mutex must be locked by the caller of this function. 905 + * Note: the ap_attr_mutex must be locked by the caller of this function. 910 906 * 911 907 * Return: an int specifying whether the AP adapter is reserved for the host (1) 912 908 * or not (0). ··· 948 944 * @apm: a bitmap specifying a set of APIDs comprising the APQNs to check 949 945 * @aqm: a bitmap specifying a set of APQIs comprising the APQNs to check 950 946 * 951 - * Note: the ap_perms_mutex must be locked by the caller of this function. 947 + * Note: the ap_attr_mutex must be locked by the caller of this function. 952 948 * 953 949 * Return: an int specifying whether each APQN is reserved for the host (1) or 954 950 * not (0) ··· 991 987 ap_drv->driver.name)) 992 988 goto out; 993 989 } else { 994 - mutex_lock(&ap_perms_mutex); 990 + mutex_lock(&ap_attr_mutex); 995 991 devres = test_bit_inv(card, ap_perms.apm) && 996 992 test_bit_inv(queue, ap_perms.aqm); 997 - mutex_unlock(&ap_perms_mutex); 993 + mutex_unlock(&ap_attr_mutex); 998 994 drvres = ap_drv->flags & AP_DRIVER_FLAG_DEFAULT; 999 995 if (!!devres != !!drvres) 1000 996 goto out; ··· 1487 1483 { 1488 1484 int rc; 1489 1485 1490 - if (mutex_lock_interruptible(&ap_perms_mutex)) 1486 + if (mutex_lock_interruptible(&ap_attr_mutex)) 1491 1487 return -ERESTARTSYS; 1492 1488 rc = sysfs_emit(buf, "0x%016lx%016lx%016lx%016lx\n", 1493 1489 ap_perms.apm[0], ap_perms.apm[1], 1494 1490 ap_perms.apm[2], ap_perms.apm[3]); 1495 - mutex_unlock(&ap_perms_mutex); 1491 + mutex_unlock(&ap_attr_mutex); 1496 1492 1497 1493 return rc; 1498 1494 } ··· 1551 1547 int rc, changes = 0; 1552 1548 DECLARE_BITMAP(newapm, AP_DEVICES); 1553 1549 1554 - if (mutex_lock_interruptible(&ap_perms_mutex)) 1550 + if (mutex_lock_interruptible(&ap_attr_mutex)) 1555 1551 return -ERESTARTSYS; 1556 1552 1557 1553 rc = ap_parse_bitmap_str(buf, ap_perms.apm, AP_DEVICES, newapm); ··· 1563 1559 rc = apmask_commit(newapm); 1564 1560 1565 1561 done: 1566 - mutex_unlock(&ap_perms_mutex); 1562 + mutex_unlock(&ap_attr_mutex); 1567 1563 if (rc) 1568 1564 return rc; 1569 1565 ··· 1581 1577 { 1582 1578 int rc; 1583 1579 1584 - if (mutex_lock_interruptible(&ap_perms_mutex)) 1580 + if (mutex_lock_interruptible(&ap_attr_mutex)) 1585 1581 return -ERESTARTSYS; 1586 1582 rc = sysfs_emit(buf, "0x%016lx%016lx%016lx%016lx\n", 1587 1583 ap_perms.aqm[0], ap_perms.aqm[1], 1588 1584 ap_perms.aqm[2], ap_perms.aqm[3]); 1589 - mutex_unlock(&ap_perms_mutex); 1585 + mutex_unlock(&ap_attr_mutex); 1590 1586 1591 1587 return rc; 1592 1588 } ··· 1645 1641 int rc, changes = 0; 1646 1642 DECLARE_BITMAP(newaqm, AP_DOMAINS); 1647 1643 1648 - if (mutex_lock_interruptible(&ap_perms_mutex)) 1644 + if (mutex_lock_interruptible(&ap_attr_mutex)) 1649 1645 return -ERESTARTSYS; 1650 1646 1651 1647 rc = ap_parse_bitmap_str(buf, ap_perms.aqm, AP_DOMAINS, newaqm); ··· 1657 1653 rc = aqmask_commit(newaqm); 1658 1654 1659 1655 done: 1660 - mutex_unlock(&ap_perms_mutex); 1656 + mutex_unlock(&ap_attr_mutex); 1661 1657 if (rc) 1662 1658 return rc; 1663 1659 ··· 2528 2524 if (apm_str) { 2529 2525 memset(&ap_perms.apm, 0, sizeof(ap_perms.apm)); 2530 2526 ap_parse_mask_str(apm_str, ap_perms.apm, AP_DEVICES, 2531 - &ap_perms_mutex); 2527 + &ap_attr_mutex); 2532 2528 } 2533 2529 2534 2530 /* aqm kernel parameter string */ 2535 2531 if (aqm_str) { 2536 2532 memset(&ap_perms.aqm, 0, sizeof(ap_perms.aqm)); 2537 2533 ap_parse_mask_str(aqm_str, ap_perms.aqm, AP_DOMAINS, 2538 - &ap_perms_mutex); 2534 + &ap_attr_mutex); 2539 2535 } 2540 2536 } 2541 2537
+1 -1
drivers/s390/crypto/ap_bus.h
··· 281 281 }; 282 282 283 283 extern struct ap_perms ap_perms; 284 - extern struct mutex ap_perms_mutex; 284 + extern struct mutex ap_attr_mutex; 285 285 286 286 /* 287 287 * Get ap_queue device for this qid.
+7 -7
drivers/s390/crypto/vfio_ap_ops.c
··· 968 968 * 969 969 * Return: One of the following values: 970 970 * o the error returned from the ap_apqn_in_matrix_owned_by_def_drv() function, 971 - * most likely -EBUSY indicating the ap_perms_mutex lock is already held. 971 + * most likely -EBUSY indicating the ap_attr_mutex lock is already held. 972 972 * o EADDRNOTAVAIL if an APQN assigned to @matrix_mdev is reserved for the 973 973 * zcrypt default driver. 974 974 * o EADDRINUSE if an APQN assigned to @matrix_mdev is assigned to another mdev ··· 1079 1079 DECLARE_BITMAP(apm_filtered, AP_DEVICES); 1080 1080 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); 1081 1081 1082 - mutex_lock(&ap_perms_mutex); 1082 + mutex_lock(&ap_attr_mutex); 1083 1083 get_update_locks_for_mdev(matrix_mdev); 1084 1084 1085 1085 ret = kstrtoul(buf, 0, &apid); ··· 1114 1114 ret = count; 1115 1115 done: 1116 1116 release_update_locks_for_mdev(matrix_mdev); 1117 - mutex_unlock(&ap_perms_mutex); 1117 + mutex_unlock(&ap_attr_mutex); 1118 1118 1119 1119 return ret; 1120 1120 } ··· 1303 1303 DECLARE_BITMAP(apm_filtered, AP_DEVICES); 1304 1304 struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev); 1305 1305 1306 - mutex_lock(&ap_perms_mutex); 1306 + mutex_lock(&ap_attr_mutex); 1307 1307 get_update_locks_for_mdev(matrix_mdev); 1308 1308 1309 1309 ret = kstrtoul(buf, 0, &apqi); ··· 1338 1338 ret = count; 1339 1339 done: 1340 1340 release_update_locks_for_mdev(matrix_mdev); 1341 - mutex_unlock(&ap_perms_mutex); 1341 + mutex_unlock(&ap_attr_mutex); 1342 1342 1343 1343 return ret; 1344 1344 } ··· 1718 1718 return -ENOMEM; 1719 1719 rest = newbuf; 1720 1720 1721 - mutex_lock(&ap_perms_mutex); 1721 + mutex_lock(&ap_attr_mutex); 1722 1722 get_update_locks_for_mdev(matrix_mdev); 1723 1723 1724 1724 /* Save old state */ ··· 1779 1779 } 1780 1780 out: 1781 1781 release_update_locks_for_mdev(matrix_mdev); 1782 - mutex_unlock(&ap_perms_mutex); 1782 + mutex_unlock(&ap_attr_mutex); 1783 1783 kfree(newbuf); 1784 1784 return rc; 1785 1785 }
+22 -22
drivers/s390/crypto/zcrypt_api.c
··· 162 162 struct zcdn_device *zcdndev = to_zcdn_dev(dev); 163 163 int i, n; 164 164 165 - if (mutex_lock_interruptible(&ap_perms_mutex)) 165 + if (mutex_lock_interruptible(&ap_attr_mutex)) 166 166 return -ERESTARTSYS; 167 167 168 168 n = sysfs_emit(buf, "0x"); ··· 170 170 n += sysfs_emit_at(buf, n, "%016lx", zcdndev->perms.ioctlm[i]); 171 171 n += sysfs_emit_at(buf, n, "\n"); 172 172 173 - mutex_unlock(&ap_perms_mutex); 173 + mutex_unlock(&ap_attr_mutex); 174 174 175 175 return n; 176 176 } ··· 183 183 struct zcdn_device *zcdndev = to_zcdn_dev(dev); 184 184 185 185 rc = ap_parse_mask_str(buf, zcdndev->perms.ioctlm, 186 - AP_IOCTLS, &ap_perms_mutex); 186 + AP_IOCTLS, &ap_attr_mutex); 187 187 if (rc) 188 188 return rc; 189 189 ··· 199 199 struct zcdn_device *zcdndev = to_zcdn_dev(dev); 200 200 int i, n; 201 201 202 - if (mutex_lock_interruptible(&ap_perms_mutex)) 202 + if (mutex_lock_interruptible(&ap_attr_mutex)) 203 203 return -ERESTARTSYS; 204 204 205 205 n = sysfs_emit(buf, "0x"); ··· 207 207 n += sysfs_emit_at(buf, n, "%016lx", zcdndev->perms.apm[i]); 208 208 n += sysfs_emit_at(buf, n, "\n"); 209 209 210 - mutex_unlock(&ap_perms_mutex); 210 + mutex_unlock(&ap_attr_mutex); 211 211 212 212 return n; 213 213 } ··· 220 220 struct zcdn_device *zcdndev = to_zcdn_dev(dev); 221 221 222 222 rc = ap_parse_mask_str(buf, zcdndev->perms.apm, 223 - AP_DEVICES, &ap_perms_mutex); 223 + AP_DEVICES, &ap_attr_mutex); 224 224 if (rc) 225 225 return rc; 226 226 ··· 236 236 struct zcdn_device *zcdndev = to_zcdn_dev(dev); 237 237 int i, n; 238 238 239 - if (mutex_lock_interruptible(&ap_perms_mutex)) 239 + if (mutex_lock_interruptible(&ap_attr_mutex)) 240 240 return -ERESTARTSYS; 241 241 242 242 n = sysfs_emit(buf, "0x"); ··· 244 244 n += sysfs_emit_at(buf, n, "%016lx", zcdndev->perms.aqm[i]); 245 245 n += sysfs_emit_at(buf, n, "\n"); 246 246 247 - mutex_unlock(&ap_perms_mutex); 247 + mutex_unlock(&ap_attr_mutex); 248 248 249 249 return n; 250 250 } ··· 257 257 struct zcdn_device *zcdndev = to_zcdn_dev(dev); 258 258 259 259 rc = ap_parse_mask_str(buf, zcdndev->perms.aqm, 260 - AP_DOMAINS, &ap_perms_mutex); 260 + AP_DOMAINS, &ap_attr_mutex); 261 261 if (rc) 262 262 return rc; 263 263 ··· 273 273 struct zcdn_device *zcdndev = to_zcdn_dev(dev); 274 274 int i, n; 275 275 276 - if (mutex_lock_interruptible(&ap_perms_mutex)) 276 + if (mutex_lock_interruptible(&ap_attr_mutex)) 277 277 return -ERESTARTSYS; 278 278 279 279 n = sysfs_emit(buf, "0x"); ··· 281 281 n += sysfs_emit_at(buf, n, "%016lx", zcdndev->perms.adm[i]); 282 282 n += sysfs_emit_at(buf, n, "\n"); 283 283 284 - mutex_unlock(&ap_perms_mutex); 284 + mutex_unlock(&ap_attr_mutex); 285 285 286 286 return n; 287 287 } ··· 294 294 struct zcdn_device *zcdndev = to_zcdn_dev(dev); 295 295 296 296 rc = ap_parse_mask_str(buf, zcdndev->perms.adm, 297 - AP_DOMAINS, &ap_perms_mutex); 297 + AP_DOMAINS, &ap_attr_mutex); 298 298 if (rc) 299 299 return rc; 300 300 ··· 370 370 int i, rc = 0; 371 371 struct zcdn_device *zcdndev; 372 372 373 - if (mutex_lock_interruptible(&ap_perms_mutex)) 373 + if (mutex_lock_interruptible(&ap_attr_mutex)) 374 374 return -ERESTARTSYS; 375 375 376 376 /* check if device node with this name already exists */ ··· 425 425 __func__, MAJOR(devt), MINOR(devt)); 426 426 427 427 unlockout: 428 - mutex_unlock(&ap_perms_mutex); 428 + mutex_unlock(&ap_attr_mutex); 429 429 return rc; 430 430 } 431 431 ··· 434 434 int rc = 0; 435 435 struct zcdn_device *zcdndev; 436 436 437 - if (mutex_lock_interruptible(&ap_perms_mutex)) 437 + if (mutex_lock_interruptible(&ap_attr_mutex)) 438 438 return -ERESTARTSYS; 439 439 440 440 /* try to find this zcdn device */ ··· 452 452 device_unregister(&zcdndev->device); 453 453 454 454 unlockout: 455 - mutex_unlock(&ap_perms_mutex); 455 + mutex_unlock(&ap_attr_mutex); 456 456 return rc; 457 457 } 458 458 ··· 462 462 dev_t devt; 463 463 struct zcdn_device *zcdndev; 464 464 465 - mutex_lock(&ap_perms_mutex); 465 + mutex_lock(&ap_attr_mutex); 466 466 for (i = 0; i < ZCRYPT_MAX_MINOR_NODES; i++) { 467 467 devt = MKDEV(MAJOR(zcrypt_devt), MINOR(zcrypt_devt) + i); 468 468 zcdndev = find_zcdndev_by_devt(devt); ··· 471 471 device_unregister(&zcdndev->device); 472 472 } 473 473 } 474 - mutex_unlock(&ap_perms_mutex); 474 + mutex_unlock(&ap_attr_mutex); 475 475 } 476 476 477 477 /* ··· 508 508 if (filp->f_inode->i_cdev == &zcrypt_cdev) { 509 509 struct zcdn_device *zcdndev; 510 510 511 - if (mutex_lock_interruptible(&ap_perms_mutex)) 511 + if (mutex_lock_interruptible(&ap_attr_mutex)) 512 512 return -ERESTARTSYS; 513 513 zcdndev = find_zcdndev_by_devt(filp->f_inode->i_rdev); 514 514 /* find returns a reference, no get_device() needed */ 515 - mutex_unlock(&ap_perms_mutex); 515 + mutex_unlock(&ap_attr_mutex); 516 516 if (zcdndev) 517 517 perms = &zcdndev->perms; 518 518 } ··· 532 532 if (filp->f_inode->i_cdev == &zcrypt_cdev) { 533 533 struct zcdn_device *zcdndev; 534 534 535 - mutex_lock(&ap_perms_mutex); 535 + mutex_lock(&ap_attr_mutex); 536 536 zcdndev = find_zcdndev_by_devt(filp->f_inode->i_rdev); 537 - mutex_unlock(&ap_perms_mutex); 537 + mutex_unlock(&ap_attr_mutex); 538 538 if (zcdndev) { 539 539 /* 2 puts here: one for find, one for open */ 540 540 put_device(&zcdndev->device);