public inbox for linux-s390@vger.kernel.org
 help / color / mirror / Atom feed
From: Pierre Morel <pmorel@linux.ibm.com>
To: linux-s390@vger.kernel.org
Subject: Re: [PATCH 3/5] vfio: ccw: Set subchannel state STANDBY on open
Date: Wed, 21 Nov 2018 18:13:25 +0000	[thread overview]
Message-ID: <cfb16c56-58f9-22a6-3eab-d83650940e87@linux.ibm.com> (raw)
In-Reply-To: <20181121174846.2ea0033c.cohuck@redhat.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2959 bytes --]

On 21/11/2018 17:48, Cornelia Huck wrote:
> On Wed, 17 Oct 2018 11:18:41 +0200
> Pierre Morel <pmorel@linux.ibm.com> wrote:
> 
>> The subchannel enablement and the according setting to the
>> VFIO_CCW_STATE_STANDBY state should only be done when all
>> parts of the VFIO mediated device have been initialized
>> i.e. after the mediated device has been successfully opened.
>>
>> Let's stay in VFIO_CCW_STATE_NOT_OPER until the mediated
>> device has been opened.
>>
>> When the mediated device is closed,  disable the sub channel
>> by calling vfio_ccw_sch_quiesce().
>>
>> Signed-off-by: Pierre Morel <pmorel@linux.ibm.com>
>> ---
>>   drivers/s390/cio/vfio_ccw_drv.c | 10 +---------
>>   drivers/s390/cio/vfio_ccw_ops.c | 23 +++++++++++++++++++++--
>>   2 files changed, 22 insertions(+), 11 deletions(-)
> 
> (...)
> 
>> diff --git a/drivers/s390/cio/vfio_ccw_ops.c b/drivers/s390/cio/vfio_ccw_ops.c
>> index f673e10..87a8f8c 100644
>> --- a/drivers/s390/cio/vfio_ccw_ops.c
>> +++ b/drivers/s390/cio/vfio_ccw_ops.c
>> @@ -146,11 +146,29 @@ static int vfio_ccw_mdev_open(struct mdev_device *mdev)
>>   	struct vfio_ccw_private *private =
>>   		dev_get_drvdata(mdev_parent_dev(mdev));
>>   	unsigned long events = VFIO_IOMMU_NOTIFY_DMA_UNMAP;
>> +	struct subchannel *sch = private->sch;
>> +	int ret;
>>   
>>   	private->nb.notifier_call = vfio_ccw_mdev_notifier;
>>   
>> -	return vfio_register_notifier(mdev_dev(mdev), VFIO_IOMMU_NOTIFY,
>> -				      &events, &private->nb);
>> +	ret = vfio_register_notifier(mdev_dev(mdev), VFIO_IOMMU_NOTIFY,
>> +				     &events, &private->nb);
>> +	if (ret)
>> +		return ret;
>> +
>> +	spin_lock_irq(private->sch->lock);
>> +	if (cio_enable_subchannel(sch, (u32)(unsigned long)sch))
>> +		goto error;
>> +
>> +	private->state = VFIO_CCW_STATE_STANDBY;
>> +	spin_unlock_irq(sch->lock);
>> +	return 0;
>> +
>> +error:
>> +	spin_unlock_irq(sch->lock);
>> +	vfio_unregister_notifier(mdev_dev(mdev), VFIO_IOMMU_NOTIFY,
>> +				 &private->nb);
>> +	return -EFAULT;
> 
> This -EFAULT looks a bit odd. Wouldn't it make more sense to relay the
> return code of cio_enable_subchannel() here?

It looks odd.

It took me a long time to go through the code to see what happens with 
these error codes and why.

... for at the end agree with your conclusion that returning the 
cio_enable_subchannel() code is the best solution.

The QEMU code currently do not make use of the return value but we open 
us possibilities for retries or analyze.

Thanks.
Regards,

Pierre

> 
>>   }
>>   
>>   static void vfio_ccw_mdev_release(struct mdev_device *mdev)
>> @@ -158,6 +176,7 @@ static void vfio_ccw_mdev_release(struct mdev_device *mdev)
>>   	struct vfio_ccw_private *private =
>>   		dev_get_drvdata(mdev_parent_dev(mdev));
>>   
>> +	vfio_ccw_sch_quiesce(private->sch);
>>   	vfio_unregister_notifier(mdev_dev(mdev), VFIO_IOMMU_NOTIFY,
>>   				 &private->nb);
>>   }
> 


-- 
Pierre Morel
Linux/KVM/QEMU in B�blingen - Germany

       reply	other threads:[~2018-11-21 18:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20181121174846.2ea0033c.cohuck@redhat.com>
2018-11-21 18:13 ` Pierre Morel [this message]
2018-10-17  9:18 [PATCH 3/5] vfio: ccw: Set subchannel state STANDBY on open Pierre Morel

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=cfb16c56-58f9-22a6-3eab-d83650940e87@linux.ibm.com \
    --to=pmorel@linux.ibm.com \
    --cc=linux-s390@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