qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Thomas Huth <thuth@redhat.com>
To: qemu-devel@nongnu.org
Cc: "Peter Maydell" <peter.maydell@linaro.org>,
	"Matthew Rosato" <mjrosato@linux.ibm.com>,
	"Cédric Le Goater" <clg@redhat.com>,
	"Eric Farman" <farman@linux.ibm.com>
Subject: [PULL 01/11] s390x/pci: avoid double enable/disable of aif
Date: Fri, 19 Jan 2024 16:24:57 +0100	[thread overview]
Message-ID: <20240119152507.55182-2-thuth@redhat.com> (raw)
In-Reply-To: <20240119152507.55182-1-thuth@redhat.com>

From: Matthew Rosato <mjrosato@linux.ibm.com>

Use a flag to keep track of whether AIF is currently enabled.  This can be
used to avoid enabling/disabling AIF multiple times as well as to determine
whether or not it should be disabled during reset processing.

Fixes: d0bc7091c2 ("s390x/pci: enable adapter event notification for interpreted devices")
Reported-by: Cédric Le Goater <clg@redhat.com>
Reviewed-by: Eric Farman <farman@linux.ibm.com>
Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
Message-ID: <20240118185151.265329-2-mjrosato@linux.ibm.com>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
---
 include/hw/s390x/s390-pci-bus.h |  1 +
 hw/s390x/s390-pci-kvm.c         | 25 +++++++++++++++++++++++--
 2 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/include/hw/s390x/s390-pci-bus.h b/include/hw/s390x/s390-pci-bus.h
index b1bdbeaeb5..435e788867 100644
--- a/include/hw/s390x/s390-pci-bus.h
+++ b/include/hw/s390x/s390-pci-bus.h
@@ -361,6 +361,7 @@ struct S390PCIBusDevice {
     bool unplug_requested;
     bool interp;
     bool forwarding_assist;
+    bool aif;
     QTAILQ_ENTRY(S390PCIBusDevice) link;
 };
 
diff --git a/hw/s390x/s390-pci-kvm.c b/hw/s390x/s390-pci-kvm.c
index ff41e4106d..1ee510436c 100644
--- a/hw/s390x/s390-pci-kvm.c
+++ b/hw/s390x/s390-pci-kvm.c
@@ -27,6 +27,7 @@ bool s390_pci_kvm_interp_allowed(void)
 
 int s390_pci_kvm_aif_enable(S390PCIBusDevice *pbdev, ZpciFib *fib, bool assist)
 {
+    int rc;
     struct kvm_s390_zpci_op args = {
         .fh = pbdev->fh,
         .op = KVM_S390_ZPCIOP_REG_AEN,
@@ -38,15 +39,35 @@ int s390_pci_kvm_aif_enable(S390PCIBusDevice *pbdev, ZpciFib *fib, bool assist)
         .u.reg_aen.flags = (assist) ? 0 : KVM_S390_ZPCIOP_REGAEN_HOST
     };
 
-    return kvm_vm_ioctl(kvm_state, KVM_S390_ZPCI_OP, &args);
+    if (pbdev->aif) {
+        return -EINVAL;
+    }
+
+    rc = kvm_vm_ioctl(kvm_state, KVM_S390_ZPCI_OP, &args);
+    if (rc == 0) {
+        pbdev->aif = true;
+    }
+
+    return rc;
 }
 
 int s390_pci_kvm_aif_disable(S390PCIBusDevice *pbdev)
 {
+    int rc;
+
     struct kvm_s390_zpci_op args = {
         .fh = pbdev->fh,
         .op = KVM_S390_ZPCIOP_DEREG_AEN
     };
 
-    return kvm_vm_ioctl(kvm_state, KVM_S390_ZPCI_OP, &args);
+    if (!pbdev->aif) {
+        return -EINVAL;
+    }
+
+    rc = kvm_vm_ioctl(kvm_state, KVM_S390_ZPCI_OP, &args);
+    if (rc == 0) {
+        pbdev->aif = false;
+    }
+
+    return rc;
 }
-- 
2.43.0



  reply	other threads:[~2024-01-19 15:27 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-19 15:24 [PULL 00/11] s390x fixes, removal of deprecated options, netbsd VM fix Thomas Huth
2024-01-19 15:24 ` Thomas Huth [this message]
2024-01-19 15:24 ` [PULL 02/11] s390x/pci: refresh fh before disabling aif Thomas Huth
2024-01-19 15:24 ` [PULL 03/11] s390x/pci: drive ISM reset from subsystem reset Thomas Huth
2024-01-19 15:25 ` [PULL 04/11] qemu-options: Remove the deprecated -no-hpet option Thomas Huth
2024-01-19 15:25 ` [PULL 05/11] qemu-options: Remove the deprecated -no-acpi option Thomas Huth
2024-01-19 15:25 ` [PULL 06/11] qemu-options: Remove the deprecated -async-teardown option Thomas Huth
2024-01-19 15:25 ` [PULL 07/11] qemu-options: Remove the deprecated -chroot option Thomas Huth
2024-01-19 15:25 ` [PULL 08/11] qapi: Remove deprecated 'singlestep' member of StatusInfo Thomas Huth
2024-01-19 15:25 ` [PULL 09/11] hmp: Remove deprecated 'singlestep' command Thomas Huth
2024-01-19 15:25 ` [PULL 10/11] cli: Remove deprecated '-singlestep' command line option Thomas Huth
2024-01-19 15:25 ` [PULL 11/11] tests/vm/netbsd: Remove missing py311-expat package Thomas Huth
2024-01-22  8:48 ` [PULL 00/11] s390x fixes, removal of deprecated options, netbsd VM fix Peter Maydell

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=20240119152507.55182-2-thuth@redhat.com \
    --to=thuth@redhat.com \
    --cc=clg@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=mjrosato@linux.ibm.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.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;
as well as URLs for NNTP newsgroup(s).