KVM Archive on lore.kernel.org
 help / color / Atom feed
From: Harald Freudenberger <freude@linux.ibm.com>
To: Tony Krowiak <akrowiak@linux.ibm.com>,
	linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org,
	kvm@vger.kernel.org
Cc: borntraeger@de.ibm.com, cohuck@redhat.com, frankja@linux.ibm.com,
	david@redhat.com, mjrosato@linux.ibm.com, schwidefsky@de.ibm.com,
	heiko.carstens@de.ibm.com, pmorel@linux.ibm.com,
	pasic@linux.ibm.com, alex.williamson@redhat.com,
	kwankhede@nvidia.com
Subject: Re: [PATCH v4 2/7] s390: vfio-ap: wait for queue empty on queue reset
Date: Mon, 17 Jun 2019 10:47:37 +0200
Message-ID: <b7f2d9df-26d8-9915-5345-f17e6cd0ef93@linux.ibm.com> (raw)
In-Reply-To: <1560454780-20359-3-git-send-email-akrowiak@linux.ibm.com>

On 13.06.19 21:39, Tony Krowiak wrote:
> Refactors the AP queue reset function to wait until the queue is empty
> after the PQAP(ZAPQ) instruction is executed to zero out the queue as
> required by the AP architecture.
>
> Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
> ---
>  drivers/s390/crypto/vfio_ap_ops.c | 49 +++++++++++++++++++++++++++------------
>  1 file changed, 34 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c
> index bf2ab02b9a0b..60efd3d7896d 100644
> --- a/drivers/s390/crypto/vfio_ap_ops.c
> +++ b/drivers/s390/crypto/vfio_ap_ops.c
> @@ -1128,23 +1128,46 @@ static void vfio_ap_irq_disable_apqn(int apqn)
>  	}
>  }
>  
> -int vfio_ap_mdev_reset_queue(unsigned int apid, unsigned int apqi,
> -			     unsigned int retry)
> +static void vfio_ap_mdev_wait_for_qempty(ap_qid_t qid)
> +{
> +	struct ap_queue_status status;
> +	int retry = 5;
> +
> +	do {
> +		status = ap_tapq(qid, NULL);
> +		switch (status.response_code) {
> +		case AP_RESPONSE_NORMAL:
> +			if (status.queue_empty)
> +				return;
> +		case AP_RESPONSE_RESET_IN_PROGRESS:
> +		case AP_RESPONSE_BUSY:
> +			msleep(20);
> +			break;
> +		default:
> +			pr_warn("%s: tapq response %02x waiting for queue %04x.%02x empty\n",
> +				__func__, status.response_code,
> +				AP_QID_CARD(qid), AP_QID_QUEUE(qid));
The ap and zcrypt code uses %02x.%04x for displaying an APQN.
I would also recommend to handle 0x01 (AP_RESPONSE_Q_NOT_AVAIL) and
0x03 (AP_RESPONSE_DECONFIGURED) as this code may run when a APQN
is removed from the configuration of the LPAR. However, it's up to you if you
want to handle these with the default statement and issue an sysfs warning.
> +			return;
> +		}
> +	} while (--retry);
> +
> +	WARN_ON_ONCE(retry <= 0);
> +}
> +
> +int vfio_ap_mdev_reset_queue(unsigned int apid, unsigned int apqi)
>  {
>  	struct ap_queue_status status;
> -	int retry2 = 2;
>  	int apqn = AP_MKQID(apid, apqi);
> +	int retry = 5;
>  
>  	do {
>  		status = ap_zapq(apqn);
>  		switch (status.response_code) {
>  		case AP_RESPONSE_NORMAL:
> -			while (!status.queue_empty && retry2--) {
> -				msleep(20);
> -				status = ap_tapq(apqn, NULL);
> -			}
> -			WARN_ON_ONCE(retry <= 0);
> +			vfio_ap_mdev_wait_for_qempty(AP_MKQID(apid, apqi));
>  			return 0;
> +		case AP_RESPONSE_DECONFIGURED:
> +			return -ENODEV;
>  		case AP_RESPONSE_RESET_IN_PROGRESS:
>  		case AP_RESPONSE_BUSY:
>  			msleep(20);
> @@ -1169,14 +1192,10 @@ static int vfio_ap_mdev_reset_queues(struct mdev_device *mdev)
>  			     matrix_mdev->matrix.apm_max + 1) {
>  		for_each_set_bit_inv(apqi, matrix_mdev->matrix.aqm,
>  				     matrix_mdev->matrix.aqm_max + 1) {
> -			ret = vfio_ap_mdev_reset_queue(apid, apqi, 1);
> -			/*
> -			 * Regardless whether a queue turns out to be busy, or
> -			 * is not operational, we need to continue resetting
> -			 * the remaining queues.
> -			 */
> +			ret = vfio_ap_mdev_reset_queue(apid, apqi);
>  			if (ret)
>  				rc = ret;
> +
>  			vfio_ap_irq_disable_apqn(AP_MKQID(apid, apqi));
>  		}
>  	}
> @@ -1326,7 +1345,7 @@ void vfio_ap_mdev_remove_queue(struct ap_queue *queue)
>  	dev_set_drvdata(&queue->ap_dev.device, NULL);
>  	apid = AP_QID_CARD(q->apqn);
>  	apqi = AP_QID_QUEUE(q->apqn);
> -	vfio_ap_mdev_reset_queue(apid, apqi, 1);
> +	vfio_ap_mdev_reset_queue(apid, apqi);
>  	vfio_ap_irq_disable(q);
>  	kfree(q);
>  }


  reply index

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-13 19:39 [PATCH v4 0/7] s390: vfio-ap: dynamic configuration support Tony Krowiak
2019-06-13 19:39 ` [PATCH v4 1/7] s390: vfio-ap: Refactor vfio_ap driver probe and remove callbacks Tony Krowiak
2019-06-17  8:27   ` Harald Freudenberger
2019-06-17 14:24     ` Tony Krowiak
2019-06-18 16:14   ` Cornelia Huck
2019-06-19 12:31     ` Tony Krowiak
2019-06-13 19:39 ` [PATCH v4 2/7] s390: vfio-ap: wait for queue empty on queue reset Tony Krowiak
2019-06-17  8:47   ` Harald Freudenberger [this message]
2019-06-17 14:29     ` Tony Krowiak
2019-06-13 19:39 ` [PATCH v4 3/7] s390: zcrypt: driver callback to indicate resource in use Tony Krowiak
2019-06-17  9:28   ` Harald Freudenberger
2019-06-17 14:37     ` Tony Krowiak
2019-06-18 16:25   ` Cornelia Huck
2019-06-19 13:04     ` Tony Krowiak
2019-06-26 21:13       ` Tony Krowiak
2019-06-27  7:25         ` Cornelia Huck
2019-06-27 12:59           ` Tony Krowiak
2019-07-01 19:26       ` Cornelia Huck
2019-07-08 14:27         ` Tony Krowiak
2019-07-09 10:49           ` Cornelia Huck
2019-07-09 21:11             ` Tony Krowiak
2019-06-13 19:39 ` [PATCH v4 4/7] s390: vfio-ap: implement in-use callback for vfio_ap driver Tony Krowiak
2019-06-13 19:39 ` [PATCH v4 5/7] s390: vfio-ap: allow assignment of unavailable AP resources to mdev device Tony Krowiak
2019-06-17 10:05   ` Harald Freudenberger
2019-06-17 15:07     ` Tony Krowiak
2019-06-18  6:49       ` Harald Freudenberger
2019-06-19 13:39         ` Tony Krowiak
2019-06-13 19:39 ` [PATCH v4 6/7] s390: vfio-ap: allow hot plug/unplug of AP resources using " Tony Krowiak
2019-06-13 19:39 ` [PATCH v4 7/7] s390: vfio-ap: update documentation Tony Krowiak
2019-06-17 11:42   ` Harald Freudenberger
2019-06-17 15:21     ` Tony Krowiak
2019-07-09 15:30 ` [PATCH v4 0/7] s390: vfio-ap: dynamic configuration support Halil Pasic

Reply instructions:

You may reply publically 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=b7f2d9df-26d8-9915-5345-f17e6cd0ef93@linux.ibm.com \
    --to=freude@linux.ibm.com \
    --cc=akrowiak@linux.ibm.com \
    --cc=alex.williamson@redhat.com \
    --cc=borntraeger@de.ibm.com \
    --cc=cohuck@redhat.com \
    --cc=david@redhat.com \
    --cc=frankja@linux.ibm.com \
    --cc=heiko.carstens@de.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=kwankhede@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjrosato@linux.ibm.com \
    --cc=pasic@linux.ibm.com \
    --cc=pmorel@linux.ibm.com \
    --cc=schwidefsky@de.ibm.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

KVM Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/kvm/0 kvm/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 kvm kvm/ https://lore.kernel.org/kvm \
		kvm@vger.kernel.org kvm@archiver.kernel.org
	public-inbox-index kvm


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.kvm


AGPL code for this site: git clone https://public-inbox.org/ public-inbox