From: Sasha Levin <sashal@kernel.org>
To: stable@vger.kernel.org
Cc: Tony Krowiak <akrowiak@linux.ibm.com>,
Janosch Frank <frankja@linux.ibm.com>,
Viktor Mihajlovski <mihajlov@linux.ibm.com>,
Heiko Carstens <hca@linux.ibm.com>,
Sasha Levin <sashal@kernel.org>
Subject: [PATCH 6.1.y 1/2] s390/vfio-ap: wait for response code 05 to clear on queue reset
Date: Thu, 10 Sep 2026 21:12:59 -0400 [thread overview]
Message-ID: <20260911011300.4032478-1-sashal@kernel.org> (raw)
In-Reply-To: <2026090928-anguished-delighted-2103@gregkh>
From: Tony Krowiak <akrowiak@linux.ibm.com>
[ Upstream commit 411b0109daa52d1cc5be39635631e22a5590c5d8 ]
Response code 05, AP busy, is a valid response code for a ZAPQ or TAPQ.
Instead of returning error -EIO when a ZAPQ fails with response code 05,
let's wait until the queue is no longer busy and try the ZAPQ again.
Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
Acked-by: Janosch Frank <frankja@linux.ibm.com>
Tested-by: Viktor Mihajlovski <mihajlov@linux.ibm.com>
Link: https://lore.kernel.org/r/20230815184333.6554-4-akrowiak@linux.ibm.com
Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
[Backport to 6.1: keep the existing bounded queue-reset implementation
and handle AP_RESPONSE_BUSY through its reset-in-progress retry path.
Drop the apq_status_check() hunk because that helper is absent here; do
not introduce the newer reset helpers or their prerequisite refactors.
Prepare for 4400270ec034 ("s390/vfio-ap: fix stale pqap_hook pointer on
error in vfio_ap_mdev_set_kvm()") by changing the existing
vfio_ap_mdev_reset_queues() argument from a queue table to its matrix
mdev. Keep the same table traversal and error propagation. The adapter
and domain hot-unplug paths reset their detached queue tables directly
with the existing single-queue helper before unlinking, preserving the
reset order, retry count, and ignored aggregate return value. No new
functions are introduced.]
Stable-dep-of: 4400270ec034 ("s390/vfio-ap: fix stale pqap_hook pointer on error in vfio_ap_mdev_set_kvm()")
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/s390/crypto/vfio_ap_ops.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)
diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
index 11fe917fbd9d4..5016c157a3010 100644
--- a/drivers/s390/crypto/vfio_ap_ops.c
+++ b/drivers/s390/crypto/vfio_ap_ops.c
@@ -30,7 +30,7 @@
#define AP_QUEUE_UNASSIGNED "unassigned"
#define AP_QUEUE_IN_USE "in use"
-static int vfio_ap_mdev_reset_queues(struct ap_queue_table *qtable);
+static int vfio_ap_mdev_reset_queues(struct ap_matrix_mdev *matrix_mdev);
static struct vfio_ap_queue *vfio_ap_find_queue(int apqn);
static const struct vfio_device_ops vfio_ap_matrix_dev_ops;
static int vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q, unsigned int retry);
@@ -781,7 +781,7 @@ static void vfio_ap_mdev_remove(struct mdev_device *mdev)
mutex_lock(&matrix_dev->guests_lock);
mutex_lock(&matrix_dev->mdevs_lock);
- vfio_ap_mdev_reset_queues(&matrix_mdev->qtable);
+ vfio_ap_mdev_reset_queues(matrix_mdev);
vfio_ap_mdev_unlink_fr_queues(matrix_mdev);
list_del(&matrix_mdev->node);
mutex_unlock(&matrix_dev->mdevs_lock);
@@ -1048,7 +1048,8 @@ static void vfio_ap_mdev_hot_unplug_adapter(struct ap_matrix_mdev *matrix_mdev,
vfio_ap_mdev_update_guest_apcb(matrix_mdev);
}
- vfio_ap_mdev_reset_queues(qtable);
+ hash_for_each(qtable->queues, loop_cursor, q, mdev_qnode)
+ vfio_ap_mdev_reset_queue(q, 1);
hash_for_each(qtable->queues, loop_cursor, q, mdev_qnode) {
vfio_ap_unlink_mdev_fr_queue(q);
@@ -1231,7 +1232,8 @@ static void vfio_ap_mdev_hot_unplug_domain(struct ap_matrix_mdev *matrix_mdev,
vfio_ap_mdev_update_guest_apcb(matrix_mdev);
}
- vfio_ap_mdev_reset_queues(qtable);
+ hash_for_each(qtable->queues, loop_cursor, q, mdev_qnode)
+ vfio_ap_mdev_reset_queue(q, 1);
hash_for_each(qtable->queues, loop_cursor, q, mdev_qnode) {
vfio_ap_unlink_mdev_fr_queue(q);
@@ -1577,7 +1579,7 @@ static void vfio_ap_mdev_unset_kvm(struct ap_matrix_mdev *matrix_mdev)
get_update_locks_for_kvm(kvm);
kvm_arch_crypto_clear_masks(kvm);
- vfio_ap_mdev_reset_queues(&matrix_mdev->qtable);
+ vfio_ap_mdev_reset_queues(matrix_mdev);
kvm_put_kvm(kvm);
matrix_mdev->kvm = NULL;
@@ -1619,6 +1621,7 @@ static int vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q,
ret = 0;
break;
case AP_RESPONSE_RESET_IN_PROGRESS:
+ case AP_RESPONSE_BUSY:
if (retry--) {
msleep(20);
goto retry_zapq;
@@ -1659,8 +1662,9 @@ static int vfio_ap_mdev_reset_queue(struct vfio_ap_queue *q,
return ret;
}
-static int vfio_ap_mdev_reset_queues(struct ap_queue_table *qtable)
+static int vfio_ap_mdev_reset_queues(struct ap_matrix_mdev *matrix_mdev)
{
+ struct ap_queue_table *qtable = &matrix_mdev->qtable;
int ret, loop_cursor, rc = 0;
struct vfio_ap_queue *q;
@@ -1730,7 +1734,7 @@ static ssize_t vfio_ap_mdev_ioctl(struct vfio_device *vdev,
ret = vfio_ap_mdev_get_device_info(arg);
break;
case VFIO_DEVICE_RESET:
- ret = vfio_ap_mdev_reset_queues(&matrix_mdev->qtable);
+ ret = vfio_ap_mdev_reset_queues(matrix_mdev);
break;
default:
ret = -EOPNOTSUPP;
--
2.53.0
next prev parent reply other threads:[~2026-09-11 1:13 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-09 9:53 FAILED: patch "[PATCH] s390/vfio-ap: fix stale pqap_hook pointer on error in" failed to apply to 6.1-stable tree gregkh
2026-09-11 1:12 ` Sasha Levin [this message]
2026-09-11 1:13 ` [PATCH 6.1.y 2/2] s390/vfio-ap: fix stale pqap_hook pointer on error in vfio_ap_mdev_set_kvm() Sasha Levin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260911011300.4032478-1-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=akrowiak@linux.ibm.com \
--cc=frankja@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=mihajlov@linux.ibm.com \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox