Skip to content

Commit 8babcc2

Browse files
hfreudehcahca
authored andcommitted
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>
1 parent d38a87d commit 8babcc2

4 files changed

Lines changed: 52 additions & 48 deletions

File tree

drivers/s390/crypto/ap_bus.c

Lines changed: 22 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,12 @@ DEFINE_SPINLOCK(ap_queues_lock);
8686
/* Default permissions (ioctl, card and domain masking) */
8787
struct ap_perms ap_perms;
8888
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);
9195

9296
/* # of bindings complete since init */
9397
static atomic64_t ap_bindings_complete_count = ATOMIC64_INIT(0);
@@ -871,10 +875,10 @@ static int __ap_revise_reserved(struct device *dev, void *dummy)
871875
}
872876
}
873877
} else {
874-
mutex_lock(&ap_perms_mutex);
878+
mutex_lock(&ap_attr_mutex);
875879
devres = test_bit_inv(card, ap_perms.apm) &&
876880
test_bit_inv(queue, ap_perms.aqm);
877-
mutex_unlock(&ap_perms_mutex);
881+
mutex_unlock(&ap_attr_mutex);
878882
drvres = to_ap_drv(dev->driver)->flags
879883
& AP_DRIVER_FLAG_DEFAULT;
880884
if (!!devres != !!drvres) {
@@ -902,7 +906,7 @@ static void ap_bus_revise_bindings(void)
902906
* @card: the APID of the adapter card to check
903907
* @queue: the APQI of the queue to check
904908
*
905-
* Note: the ap_perms_mutex must be locked by the caller of this function.
909+
* Note: the ap_attr_mutex must be locked by the caller of this function.
906910
*
907911
* Return: an int specifying whether the AP adapter is reserved for the host (1)
908912
* or not (0).
@@ -944,7 +948,7 @@ EXPORT_SYMBOL(ap_owned_by_def_drv);
944948
* @apm: a bitmap specifying a set of APIDs comprising the APQNs to check
945949
* @aqm: a bitmap specifying a set of APQIs comprising the APQNs to check
946950
*
947-
* Note: the ap_perms_mutex must be locked by the caller of this function.
951+
* Note: the ap_attr_mutex must be locked by the caller of this function.
948952
*
949953
* Return: an int specifying whether each APQN is reserved for the host (1) or
950954
* not (0)
@@ -987,10 +991,10 @@ static int ap_device_probe(struct device *dev)
987991
ap_drv->driver.name))
988992
goto out;
989993
} else {
990-
mutex_lock(&ap_perms_mutex);
994+
mutex_lock(&ap_attr_mutex);
991995
devres = test_bit_inv(card, ap_perms.apm) &&
992996
test_bit_inv(queue, ap_perms.aqm);
993-
mutex_unlock(&ap_perms_mutex);
997+
mutex_unlock(&ap_attr_mutex);
994998
drvres = ap_drv->flags & AP_DRIVER_FLAG_DEFAULT;
995999
if (!!devres != !!drvres)
9961000
goto out;
@@ -1483,12 +1487,12 @@ static ssize_t apmask_show(const struct bus_type *bus, char *buf)
14831487
{
14841488
int rc;
14851489

1486-
if (mutex_lock_interruptible(&ap_perms_mutex))
1490+
if (mutex_lock_interruptible(&ap_attr_mutex))
14871491
return -ERESTARTSYS;
14881492
rc = sysfs_emit(buf, "0x%016lx%016lx%016lx%016lx\n",
14891493
ap_perms.apm[0], ap_perms.apm[1],
14901494
ap_perms.apm[2], ap_perms.apm[3]);
1491-
mutex_unlock(&ap_perms_mutex);
1495+
mutex_unlock(&ap_attr_mutex);
14921496

14931497
return rc;
14941498
}
@@ -1547,7 +1551,7 @@ static ssize_t apmask_store(const struct bus_type *bus, const char *buf,
15471551
int rc, changes = 0;
15481552
DECLARE_BITMAP(newapm, AP_DEVICES);
15491553

1550-
if (mutex_lock_interruptible(&ap_perms_mutex))
1554+
if (mutex_lock_interruptible(&ap_attr_mutex))
15511555
return -ERESTARTSYS;
15521556

15531557
rc = ap_parse_bitmap_str(buf, ap_perms.apm, AP_DEVICES, newapm);
@@ -1559,7 +1563,7 @@ static ssize_t apmask_store(const struct bus_type *bus, const char *buf,
15591563
rc = apmask_commit(newapm);
15601564

15611565
done:
1562-
mutex_unlock(&ap_perms_mutex);
1566+
mutex_unlock(&ap_attr_mutex);
15631567
if (rc)
15641568
return rc;
15651569

@@ -1577,12 +1581,12 @@ static ssize_t aqmask_show(const struct bus_type *bus, char *buf)
15771581
{
15781582
int rc;
15791583

1580-
if (mutex_lock_interruptible(&ap_perms_mutex))
1584+
if (mutex_lock_interruptible(&ap_attr_mutex))
15811585
return -ERESTARTSYS;
15821586
rc = sysfs_emit(buf, "0x%016lx%016lx%016lx%016lx\n",
15831587
ap_perms.aqm[0], ap_perms.aqm[1],
15841588
ap_perms.aqm[2], ap_perms.aqm[3]);
1585-
mutex_unlock(&ap_perms_mutex);
1589+
mutex_unlock(&ap_attr_mutex);
15861590

15871591
return rc;
15881592
}
@@ -1641,7 +1645,7 @@ static ssize_t aqmask_store(const struct bus_type *bus, const char *buf,
16411645
int rc, changes = 0;
16421646
DECLARE_BITMAP(newaqm, AP_DOMAINS);
16431647

1644-
if (mutex_lock_interruptible(&ap_perms_mutex))
1648+
if (mutex_lock_interruptible(&ap_attr_mutex))
16451649
return -ERESTARTSYS;
16461650

16471651
rc = ap_parse_bitmap_str(buf, ap_perms.aqm, AP_DOMAINS, newaqm);
@@ -1653,7 +1657,7 @@ static ssize_t aqmask_store(const struct bus_type *bus, const char *buf,
16531657
rc = aqmask_commit(newaqm);
16541658

16551659
done:
1656-
mutex_unlock(&ap_perms_mutex);
1660+
mutex_unlock(&ap_attr_mutex);
16571661
if (rc)
16581662
return rc;
16591663

@@ -2524,14 +2528,14 @@ static void __init ap_perms_init(void)
25242528
if (apm_str) {
25252529
memset(&ap_perms.apm, 0, sizeof(ap_perms.apm));
25262530
ap_parse_mask_str(apm_str, ap_perms.apm, AP_DEVICES,
2527-
&ap_perms_mutex);
2531+
&ap_attr_mutex);
25282532
}
25292533

25302534
/* aqm kernel parameter string */
25312535
if (aqm_str) {
25322536
memset(&ap_perms.aqm, 0, sizeof(ap_perms.aqm));
25332537
ap_parse_mask_str(aqm_str, ap_perms.aqm, AP_DOMAINS,
2534-
&ap_perms_mutex);
2538+
&ap_attr_mutex);
25352539
}
25362540
}
25372541

drivers/s390/crypto/ap_bus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ struct ap_perms {
281281
};
282282

283283
extern struct ap_perms ap_perms;
284-
extern struct mutex ap_perms_mutex;
284+
extern struct mutex ap_attr_mutex;
285285

286286
/*
287287
* Get ap_queue device for this qid.

drivers/s390/crypto/vfio_ap_ops.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -968,7 +968,7 @@ static int vfio_ap_mdev_verify_no_sharing(struct ap_matrix_mdev *assignee,
968968
*
969969
* Return: One of the following values:
970970
* 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.
972972
* o EADDRNOTAVAIL if an APQN assigned to @matrix_mdev is reserved for the
973973
* zcrypt default driver.
974974
* o EADDRINUSE if an APQN assigned to @matrix_mdev is assigned to another mdev
@@ -1079,7 +1079,7 @@ static ssize_t assign_adapter_store(struct device *dev,
10791079
DECLARE_BITMAP(apm_filtered, AP_DEVICES);
10801080
struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev);
10811081

1082-
mutex_lock(&ap_perms_mutex);
1082+
mutex_lock(&ap_attr_mutex);
10831083
get_update_locks_for_mdev(matrix_mdev);
10841084

10851085
ret = kstrtoul(buf, 0, &apid);
@@ -1114,7 +1114,7 @@ static ssize_t assign_adapter_store(struct device *dev,
11141114
ret = count;
11151115
done:
11161116
release_update_locks_for_mdev(matrix_mdev);
1117-
mutex_unlock(&ap_perms_mutex);
1117+
mutex_unlock(&ap_attr_mutex);
11181118

11191119
return ret;
11201120
}
@@ -1303,7 +1303,7 @@ static ssize_t assign_domain_store(struct device *dev,
13031303
DECLARE_BITMAP(apm_filtered, AP_DEVICES);
13041304
struct ap_matrix_mdev *matrix_mdev = dev_get_drvdata(dev);
13051305

1306-
mutex_lock(&ap_perms_mutex);
1306+
mutex_lock(&ap_attr_mutex);
13071307
get_update_locks_for_mdev(matrix_mdev);
13081308

13091309
ret = kstrtoul(buf, 0, &apqi);
@@ -1338,7 +1338,7 @@ static ssize_t assign_domain_store(struct device *dev,
13381338
ret = count;
13391339
done:
13401340
release_update_locks_for_mdev(matrix_mdev);
1341-
mutex_unlock(&ap_perms_mutex);
1341+
mutex_unlock(&ap_attr_mutex);
13421342

13431343
return ret;
13441344
}
@@ -1718,7 +1718,7 @@ static ssize_t ap_config_store(struct device *dev, struct device_attribute *attr
17181718
return -ENOMEM;
17191719
rest = newbuf;
17201720

1721-
mutex_lock(&ap_perms_mutex);
1721+
mutex_lock(&ap_attr_mutex);
17221722
get_update_locks_for_mdev(matrix_mdev);
17231723

17241724
/* Save old state */
@@ -1779,7 +1779,7 @@ static ssize_t ap_config_store(struct device *dev, struct device_attribute *attr
17791779
}
17801780
out:
17811781
release_update_locks_for_mdev(matrix_mdev);
1782-
mutex_unlock(&ap_perms_mutex);
1782+
mutex_unlock(&ap_attr_mutex);
17831783
kfree(newbuf);
17841784
return rc;
17851785
}

0 commit comments

Comments
 (0)