All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matthew Rosato <mjrosato@linux.ibm.com>
To: "Cédric Le Goater" <clg@redhat.com>, qemu-s390x@nongnu.org
Cc: farman@linux.ibm.com, thuth@redhat.com, frankja@linux.ibm.com,
	pasic@linux.ibm.com, borntraeger@linux.ibm.com,
	richard.henderson@linaro.org, david@redhat.com,
	iii@linux.ibm.com, qemu-devel@nongnu.org
Subject: Re: [PATCH 2/3] s390x/pci: refresh fh before disabling aif
Date: Wed, 17 Jan 2024 10:17:34 -0500	[thread overview]
Message-ID: <1c8ff2bf-ec92-4c54-8fa6-6432acdfc644@linux.ibm.com> (raw)
In-Reply-To: <2c8ce63b-f8b1-4b98-97e5-4416d4d622cf@redhat.com>

On 1/17/24 5:40 AM, Cédric Le Goater wrote:
> On 1/16/24 23:31, Matthew Rosato wrote:
>> Typically we refresh the host fh during CLP enable, however it's possible
>> that the device goes through multiple reset events before the guest
>> performs another CLP enable.  Let's handle this for now by refreshing the
>> host handle from vfio before disabling aif.
>>
>> Fixes: 03451953c7 ("s390x/pci: reset ISM passthrough devices on shutdown and system reset")
>> Reported-by: Cédric Le Goater <clg@redhat.com>
>> Signed-off-by: Matthew Rosato <mjrosato@linux.ibm.com>
>> ---
>>   hw/s390x/s390-pci-kvm.c | 11 ++++++++++-
>>   1 file changed, 10 insertions(+), 1 deletion(-)
>>
>> diff --git a/hw/s390x/s390-pci-kvm.c b/hw/s390x/s390-pci-kvm.c
>> index f7e10cfa72..9eef4fc3ec 100644
>> --- a/hw/s390x/s390-pci-kvm.c
>> +++ b/hw/s390x/s390-pci-kvm.c
>> @@ -18,6 +18,7 @@
>>   #include "hw/s390x/s390-pci-bus.h"
>>   #include "hw/s390x/s390-pci-kvm.h"
>>   #include "hw/s390x/s390-pci-inst.h"
>> +#include "hw/s390x/s390-pci-vfio.h"
>>   #include "cpu_models.h"
>>     bool s390_pci_kvm_interp_allowed(void)
>> @@ -64,9 +65,17 @@ int s390_pci_kvm_aif_disable(S390PCIBusDevice *pbdev)
>>           return -EINVAL;
>>       }
>>   +    /*
>> +     * The device may have already been reset but we still want to relinquish
>> +     * the guest ISC, so always be sure to use an up-to-date host fh.
>> +     */
>> +    if (!s390_pci_get_host_fh(pbdev, &args.fh)) {
>> +        return -EPERM;
>> +    }
> 
> The callers of s390_pci_kvm_aif_disable() all test the original host
> function with :
> 
>    if (pbdev->interp && (pbdev->fh & FH_MASK_ENABLE))
> 
> This change possibly fetches a new one. Shouldn't we move the test
> also in s390_pci_kvm_aif_disable() ?
> 
> 

Those codepaths are actually testing the enablement bit of the guest-visible function handle, not the host function handle.  Basically asking "was the guest using this device".  These handles (host and guest) are sync'd during guest CLP enable (necessary for interpretation to work) but will become disjoint once we reset the device until the next guest CLP ENABLE.  They can also become disjoint once the guest does a CLP DISABLE.
What this change is doing is basically making sure we disable AIF on the hostdev, but does NOT replace pbdev->fh.  The guest-visible function handle will get sync'd again when the guest does a new CLP ENABLE after reset.



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

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-16 22:31 [PATCH 0/3] s390x/pci: fix ISM reset Matthew Rosato
2024-01-16 22:31 ` [PATCH 1/3] s390x/pci: avoid double enable/disable of aif Matthew Rosato
2024-01-17  1:57   ` Eric Farman
2024-01-17 15:06     ` Matthew Rosato
2024-01-17 10:54   ` Cédric Le Goater
2024-01-17 15:11     ` Matthew Rosato
2024-01-16 22:31 ` [PATCH 2/3] s390x/pci: refresh fh before disabling aif Matthew Rosato
2024-01-17  2:01   ` Eric Farman
2024-01-17 10:31   ` Cédric Le Goater
2024-01-17 15:07     ` Matthew Rosato
2024-01-17 10:40   ` Cédric Le Goater
2024-01-17 15:17     ` Matthew Rosato [this message]
2024-01-16 22:31 ` [PATCH 3/3] s390x/pci: drive ISM reset from subsystem reset Matthew Rosato
2024-01-17  3:01   ` Eric Farman
2024-01-17 15:07     ` Matthew Rosato
2024-01-17 11:01   ` Cédric Le Goater
2024-01-17 15:19     ` Matthew Rosato
2024-01-17 21:11       ` Matthew Rosato
2024-01-18  7:02         ` Cédric Le Goater
2024-01-18  6:03 ` [PATCH 0/3] s390x/pci: fix ISM reset Michael Tokarev
2024-01-18  7:19   ` Thomas Huth
2024-01-18  7:37     ` Michael Tokarev

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=1c8ff2bf-ec92-4c54-8fa6-6432acdfc644@linux.ibm.com \
    --to=mjrosato@linux.ibm.com \
    --cc=borntraeger@linux.ibm.com \
    --cc=clg@redhat.com \
    --cc=david@redhat.com \
    --cc=farman@linux.ibm.com \
    --cc=frankja@linux.ibm.com \
    --cc=iii@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-s390x@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=thuth@redhat.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.