@@ -86,8 +86,12 @@ DEFINE_SPINLOCK(ap_queues_lock);
8686/* Default permissions (ioctl, card and domain masking) */
8787struct ap_perms ap_perms ;
8888EXPORT_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 */
9397static 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
15611565done :
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
16551659done :
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
0 commit comments