From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Tony Krowiak <akrowiak@linux.ibm.com>,
Halil Pasic <pasic@linux.ibm.com>,
Harald Freudenberger <freude@linux.ibm.com>,
Alexander Gordeev <agordeev@linux.ibm.com>,
Sasha Levin <sashal@kernel.org>,
jjherne@linux.ibm.com, hca@linux.ibm.com, gor@linux.ibm.com,
linux-s390@vger.kernel.org
Subject: [PATCH AUTOSEL 6.1 02/14] s390/vfio-ap: fix sysfs status attribute for AP queue devices
Date: Mon, 15 Jan 2024 20:06:04 -0500 [thread overview]
Message-ID: <20240116010642.218876-2-sashal@kernel.org> (raw)
In-Reply-To: <20240116010642.218876-1-sashal@kernel.org>
From: Tony Krowiak <akrowiak@linux.ibm.com>
[ Upstream commit a0d8f4eeb7c4ffaee21702bcc91a09b3988c5b7a ]
The 'status' attribute for AP queue devices bound to the vfio_ap device
driver displays incorrect status when the mediated device is attached to a
guest, but the queue device is not passed through. In the current
implementation, the status displayed is 'in_use' which is not correct; it
should be 'assigned'. This can happen if one of the queue devices
associated with a given adapter is not bound to the vfio_ap device driver.
For example:
Queues listed in /sys/bus/ap/drivers/vfio_ap:
14.0005
14.0006
14.000d
16.0006
16.000d
Queues listed in /sys/devices/vfio_ap/matrix/$UUID/matrix
14.0005
14.0006
14.000d
16.0005
16.0006
16.000d
Queues listed in /sys/devices/vfio_ap/matrix/$UUID/guest_matrix
14.0005
14.0006
14.000d
The reason no queues for adapter 0x16 are listed in the guest_matrix is
because queue 16.0005 is not bound to the vfio_ap device driver, so no
queue associated with the adapter is passed through to the guest;
therefore, each queue device for adapter 0x16 should display 'assigned'
instead of 'in_use', because those queues are not in use by a guest, but
only assigned to the mediated device.
Let's check the AP configuration for the guest to determine whether a
queue device is passed through before displaying a status of 'in_use'.
Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
Acked-by: Halil Pasic <pasic@linux.ibm.com>
Acked-by: Harald Freudenberger <freude@linux.ibm.com>
Link: https://lore.kernel.org/r/20231108201135.351419-1-akrowiak@linux.ibm.com
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
drivers/s390/crypto/vfio_ap_ops.c | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
index 934515959ebf..37d8430df32b 100644
--- a/drivers/s390/crypto/vfio_ap_ops.c
+++ b/drivers/s390/crypto/vfio_ap_ops.c
@@ -1749,6 +1749,7 @@ static ssize_t status_show(struct device *dev,
{
ssize_t nchars = 0;
struct vfio_ap_queue *q;
+ unsigned long apid, apqi;
struct ap_matrix_mdev *matrix_mdev;
struct ap_device *apdev = to_ap_dev(dev);
@@ -1756,8 +1757,21 @@ static ssize_t status_show(struct device *dev,
q = dev_get_drvdata(&apdev->device);
matrix_mdev = vfio_ap_mdev_for_queue(q);
+ /* If the queue is assigned to the matrix mediated device, then
+ * determine whether it is passed through to a guest; otherwise,
+ * indicate that it is unassigned.
+ */
if (matrix_mdev) {
- if (matrix_mdev->kvm)
+ apid = AP_QID_CARD(q->apqn);
+ apqi = AP_QID_QUEUE(q->apqn);
+ /*
+ * If the queue is passed through to the guest, then indicate
+ * that it is in use; otherwise, indicate that it is
+ * merely assigned to a matrix mediated device.
+ */
+ if (matrix_mdev->kvm &&
+ test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) &&
+ test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm))
nchars = scnprintf(buf, PAGE_SIZE, "%s\n",
AP_QUEUE_IN_USE);
else
--
2.43.0
next prev parent reply other threads:[~2024-01-16 1:06 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-16 1:06 [PATCH AUTOSEL 6.1 01/14] arch: consolidate arch_irq_work_raise prototypes Sasha Levin
2024-01-16 1:06 ` Sasha Levin [this message]
2024-01-16 1:06 ` [PATCH AUTOSEL 6.1 03/14] Hexagon: Make pfn accessors statics inlines Sasha Levin
2024-01-16 1:06 ` [PATCH AUTOSEL 6.1 04/14] s390/ptrace: handle setting of fpc register correctly Sasha Levin
2024-01-16 1:06 ` [PATCH AUTOSEL 6.1 05/14] KVM: s390: fix setting of fpc register Sasha Levin
2024-01-16 1:06 ` [PATCH AUTOSEL 6.1 06/14] arm64: Fix circular header dependency Sasha Levin
2024-01-16 1:06 ` [PATCH AUTOSEL 6.1 07/14] SUNRPC: Fix a suspicious RCU usage warning Sasha Levin
2024-01-16 1:06 ` [PATCH AUTOSEL 6.1 08/14] ext4: enable dioread_nolock as default for bs < ps case Sasha Levin
2024-01-16 20:47 ` Pavel Machek
2024-01-24 5:56 ` Ojaswin Mujoo
2024-01-16 1:06 ` [PATCH AUTOSEL 6.1 09/14] smb: client: Fix minor whitespace errors and warnings Sasha Levin
2024-01-16 20:48 ` Pavel Machek
2024-01-16 1:06 ` [PATCH AUTOSEL 6.1 10/14] ecryptfs: Reject casefold directory inodes Sasha Levin
2024-01-16 1:06 ` [PATCH AUTOSEL 6.1 11/14] ext4: fix inconsistent between segment fstrim and full fstrim Sasha Levin
2024-01-16 1:06 ` [PATCH AUTOSEL 6.1 12/14] ext4: unify the type of flexbg_size to unsigned int Sasha Levin
2024-01-16 1:06 ` [PATCH AUTOSEL 6.1 13/14] ext4: remove unnecessary check from alloc_flex_gd() Sasha Levin
2024-01-16 1:06 ` [PATCH AUTOSEL 6.1 14/14] ext4: avoid online resizing failures due to oversized flex bg 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=20240116010642.218876-2-sashal@kernel.org \
--to=sashal@kernel.org \
--cc=agordeev@linux.ibm.com \
--cc=akrowiak@linux.ibm.com \
--cc=freude@linux.ibm.com \
--cc=gor@linux.ibm.com \
--cc=hca@linux.ibm.com \
--cc=jjherne@linux.ibm.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-s390@vger.kernel.org \
--cc=pasic@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