Skip to content

Commit a681226

Browse files
Jason J. Hernehcahca
authored andcommitted
s390/vfio-ap: handle hardware checkstop state on queue reset operation
Update vfio_ap_mdev_reset_queue() to handle an unexpected checkstop (hardware error) the same as the deconfigured case. This prevents unexpected and unhelpful warnings in the event of a hardware error. We also stop lying about a queue's reset response code. This was originally done so we could force vfio_ap_mdev_filter_matrix to pass a deconfigured device through to the guest for the hotplug scenario. vfio_ap_mdev_filter_matrix is instead modified to allow passthrough for all queues with reset state normal, deconfigured, or checkstopped. In the checkstopped case we choose to pass the device through and let the error state be reflected at the guest level. Signed-off-by: "Jason J. Herne" <jjherne@linux.ibm.com> Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com> Link: https://lore.kernel.org/r/20240215153144.14747-1-jjherne@linux.ibm.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
1 parent e22033f commit a681226

1 file changed

Lines changed: 18 additions & 17 deletions

File tree

drivers/s390/crypto/vfio_ap_ops.c

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,21 @@ static bool vfio_ap_mdev_filter_cdoms(struct ap_matrix_mdev *matrix_mdev)
659659
AP_DOMAINS);
660660
}
661661

662+
static bool _queue_passable(struct vfio_ap_queue *q)
663+
{
664+
if (!q)
665+
return false;
666+
667+
switch (q->reset_status.response_code) {
668+
case AP_RESPONSE_NORMAL:
669+
case AP_RESPONSE_DECONFIGURED:
670+
case AP_RESPONSE_CHECKSTOPPED:
671+
return true;
672+
default:
673+
return false;
674+
}
675+
}
676+
662677
/*
663678
* vfio_ap_mdev_filter_matrix - filter the APQNs assigned to the matrix mdev
664679
* to ensure no queue devices are passed through to
@@ -687,7 +702,6 @@ static bool vfio_ap_mdev_filter_matrix(struct ap_matrix_mdev *matrix_mdev,
687702
unsigned long apid, apqi, apqn;
688703
DECLARE_BITMAP(prev_shadow_apm, AP_DEVICES);
689704
DECLARE_BITMAP(prev_shadow_aqm, AP_DOMAINS);
690-
struct vfio_ap_queue *q;
691705

692706
bitmap_copy(prev_shadow_apm, matrix_mdev->shadow_apcb.apm, AP_DEVICES);
693707
bitmap_copy(prev_shadow_aqm, matrix_mdev->shadow_apcb.aqm, AP_DOMAINS);
@@ -716,8 +730,7 @@ static bool vfio_ap_mdev_filter_matrix(struct ap_matrix_mdev *matrix_mdev,
716730
* hardware device.
717731
*/
718732
apqn = AP_MKQID(apid, apqi);
719-
q = vfio_ap_mdev_get_queue(matrix_mdev, apqn);
720-
if (!q || q->reset_status.response_code) {
733+
if (!_queue_passable(vfio_ap_mdev_get_queue(matrix_mdev, apqn))) {
721734
clear_bit_inv(apid, matrix_mdev->shadow_apcb.apm);
722735

723736
/*
@@ -1691,6 +1704,7 @@ static int apq_status_check(int apqn, struct ap_queue_status *status)
16911704
switch (status->response_code) {
16921705
case AP_RESPONSE_NORMAL:
16931706
case AP_RESPONSE_DECONFIGURED:
1707+
case AP_RESPONSE_CHECKSTOPPED:
16941708
return 0;
16951709
case AP_RESPONSE_RESET_IN_PROGRESS:
16961710
case AP_RESPONSE_BUSY:
@@ -1747,14 +1761,6 @@ static void apq_reset_check(struct work_struct *reset_work)
17471761
memcpy(&q->reset_status, &status, sizeof(status));
17481762
continue;
17491763
}
1750-
/*
1751-
* When an AP adapter is deconfigured, the
1752-
* associated queues are reset, so let's set the
1753-
* status response code to 0 so the queue may be
1754-
* passed through (i.e., not filtered)
1755-
*/
1756-
if (status.response_code == AP_RESPONSE_DECONFIGURED)
1757-
q->reset_status.response_code = 0;
17581764
if (q->saved_isc != VFIO_AP_ISC_INVALID)
17591765
vfio_ap_free_aqic_resources(q);
17601766
break;
@@ -1781,12 +1787,7 @@ static void vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q)
17811787
queue_work(system_long_wq, &q->reset_work);
17821788
break;
17831789
case AP_RESPONSE_DECONFIGURED:
1784-
/*
1785-
* When an AP adapter is deconfigured, the associated
1786-
* queues are reset, so let's set the status response code to 0
1787-
* so the queue may be passed through (i.e., not filtered).
1788-
*/
1789-
q->reset_status.response_code = 0;
1790+
case AP_RESPONSE_CHECKSTOPPED:
17901791
vfio_ap_free_aqic_resources(q);
17911792
break;
17921793
default:

0 commit comments

Comments
 (0)