Skip to content

Commit 62aab08

Browse files
Tony Krowiakhcahca
authored andcommitted
s390/vfio-ap: store entire AP queue status word with the queue object
Store the entire AP queue status word returned from the ZAPQ command with the struct vfio_ap_queue object instead of just the response code field. The other information contained in the status word is need by the apq_reset_check function to display a proper message to indicate that the vfio_ap driver is waiting for the ZAPQ to complete because the queue is not empty or IRQs are still enabled. Signed-off-by: Tony Krowiak <[email protected]> Tested-by: Viktor Mihajlovski <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Heiko Carstens <[email protected]>
1 parent dd17483 commit 62aab08

File tree

2 files changed

+17
-14
lines changed

2 files changed

+17
-14
lines changed

drivers/s390/crypto/vfio_ap_ops.c

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ static bool vfio_ap_mdev_filter_matrix(unsigned long *apm, unsigned long *aqm,
674674
*/
675675
apqn = AP_MKQID(apid, apqi);
676676
q = vfio_ap_mdev_get_queue(matrix_mdev, apqn);
677-
if (!q || q->reset_rc) {
677+
if (!q || q->reset_status.response_code) {
678678
clear_bit_inv(apid,
679679
matrix_mdev->shadow_apcb.apm);
680680
break;
@@ -1628,6 +1628,7 @@ static int apq_reset_check(struct vfio_ap_queue *q)
16281628
int ret = -EBUSY, elapsed = 0;
16291629
struct ap_queue_status status;
16301630

1631+
memcpy(&status, &q->reset_status, sizeof(status));
16311632
while (true) {
16321633
msleep(AP_RESET_INTERVAL);
16331634
elapsed += AP_RESET_INTERVAL;
@@ -1643,20 +1644,20 @@ static int apq_reset_check(struct vfio_ap_queue *q)
16431644
status.queue_empty,
16441645
status.irq_enabled);
16451646
} else {
1646-
if (q->reset_rc == AP_RESPONSE_RESET_IN_PROGRESS ||
1647-
q->reset_rc == AP_RESPONSE_BUSY) {
1647+
if (q->reset_status.response_code == AP_RESPONSE_RESET_IN_PROGRESS ||
1648+
q->reset_status.response_code == AP_RESPONSE_BUSY) {
16481649
status = ap_zapq(q->apqn, 0);
1649-
q->reset_rc = status.response_code;
1650+
memcpy(&q->reset_status, &status, sizeof(status));
16501651
continue;
16511652
}
16521653
/*
1653-
* When an AP adapter is deconfigured, the associated
1654-
* queues are reset, so let's set the status response
1655-
* code to 0 so the queue may be passed through (i.e.,
1656-
* not filtered).
1654+
* When an AP adapter is deconfigured, the
1655+
* associated queues are reset, so let's set the
1656+
* status response code to 0 so the queue may be
1657+
* passed through (i.e., not filtered)
16571658
*/
1658-
if (q->reset_rc == AP_RESPONSE_DECONFIGURED)
1659-
q->reset_rc = 0;
1659+
if (status.response_code == AP_RESPONSE_DECONFIGURED)
1660+
q->reset_status.response_code = 0;
16601661
if (q->saved_isc != VFIO_AP_ISC_INVALID)
16611662
vfio_ap_free_aqic_resources(q);
16621663
break;
@@ -1673,7 +1674,7 @@ static int vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q)
16731674
if (!q)
16741675
return 0;
16751676
status = ap_zapq(q->apqn, 0);
1676-
q->reset_rc = status.response_code;
1677+
memcpy(&q->reset_status, &status, sizeof(status));
16771678
switch (status.response_code) {
16781679
case AP_RESPONSE_NORMAL:
16791680
case AP_RESPONSE_RESET_IN_PROGRESS:
@@ -1688,7 +1689,8 @@ static int vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q)
16881689
* so the queue may be passed through (i.e., not filtered) and
16891690
* return a value indicating the reset completed successfully.
16901691
*/
1691-
q->reset_rc = 0;
1692+
q->reset_status.response_code = 0;
1693+
ret = 0;
16921694
vfio_ap_free_aqic_resources(q);
16931695
break;
16941696
default:
@@ -2042,6 +2044,7 @@ int vfio_ap_mdev_probe_queue(struct ap_device *apdev)
20422044

20432045
q->apqn = to_ap_queue(&apdev->device)->qid;
20442046
q->saved_isc = VFIO_AP_ISC_INVALID;
2047+
memset(&q->reset_status, 0, sizeof(q->reset_status));
20452048
matrix_mdev = get_update_locks_by_apqn(q->apqn);
20462049

20472050
if (matrix_mdev) {

drivers/s390/crypto/vfio_ap_private.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ struct ap_matrix_mdev {
133133
* @apqn: the APQN of the AP queue device
134134
* @saved_isc: the guest ISC registered with the GIB interface
135135
* @mdev_qnode: allows the vfio_ap_queue struct to be added to a hashtable
136-
* @reset_rc: the status response code from the last reset of the queue
136+
* @reset_status: the status from the last reset of the queue
137137
*/
138138
struct vfio_ap_queue {
139139
struct ap_matrix_mdev *matrix_mdev;
@@ -142,7 +142,7 @@ struct vfio_ap_queue {
142142
#define VFIO_AP_ISC_INVALID 0xff
143143
unsigned char saved_isc;
144144
struct hlist_node mdev_qnode;
145-
unsigned int reset_rc;
145+
struct ap_queue_status reset_status;
146146
};
147147

148148
int vfio_ap_mdev_register(void);

0 commit comments

Comments
 (0)