lkml.org 
[lkml]   [2020]   [Apr]   [17]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
SubjectRe: [PATCH v7 04/15] s390/vfio-ap: implement in-use callback for vfio_ap driver
From
Date


On 2020-04-16 16:45, Tony Krowiak wrote:
>
>
> On 4/16/20 7:18 AM, Cornelia Huck wrote:
>> On Tue,  7 Apr 2020 15:20:04 -0400
>> Tony Krowiak <akrowiak@linux.ibm.com> wrote:
>>
>>> Let's implement the callback to indicate when an APQN
>>> is in use by the vfio_ap device driver. The callback is
>>> invoked whenever a change to the apmask or aqmask would
>>> result in one or more queue devices being removed from the driver. The
>>> vfio_ap device driver will indicate a resource is in use
>>> if the APQN of any of the queue devices to be removed are assigned to
>>> any of the matrix mdevs under the driver's control.
>>>
>>> Signed-off-by: Tony Krowiak <akrowiak@linux.ibm.com>
>>> ---
>>>   drivers/s390/crypto/vfio_ap_drv.c     |  1 +
>>>   drivers/s390/crypto/vfio_ap_ops.c     | 47 +++++++++++++++++----------
>>>   drivers/s390/crypto/vfio_ap_private.h |  2 ++
>>>   3 files changed, 33 insertions(+), 17 deletions(-)
>>> @@ -1369,3 +1371,14 @@ void vfio_ap_mdev_remove_queue(struct ap_queue
>>> *queue)
>>>       kfree(q);
>>>       mutex_unlock(&matrix_dev->lock);
>>>   }
>>> +
>>> +bool vfio_ap_mdev_resource_in_use(unsigned long *apm, unsigned long
>>> *aqm)
>>> +{
>>> +    bool in_use;
>>> +
>>> +    mutex_lock(&matrix_dev->lock);
>>> +    in_use = vfio_ap_mdev_verify_no_sharing(NULL, apm, aqm) ? true :
>>> false;
>> Maybe
>>
>> in_use = !!vfio_ap_mdev_verify_no_sharing(NULL, apm, aqm);
>>
>> ?
>
> To be honest, I find the !! expression very confusing. Every time I see
> it, I have
> to spend time thinking about what the result of !! is going to be. I think
> the statement should be left as-is because it more clearly expresses
> the intent.



In other places you use
"
ret = vfio_ap_mdev_verify_no_sharing(matrix_mdev);
if (ret)
goto share_err;
"
then why use a boolean here?

If you want to return a boolean and you do not want to use !! you can do:

...
ret = vfio_ap_mdev_verify_no_sharing(NULL, apm, aqm);
...
return (ret) ? false : true;

>
>>
>>> +    mutex_unlock(&matrix_dev->lock);
>>> +
>>> +    return in_use;
>>> +}
>

--
Pierre Morel
IBM Lab Boeblingen

\
 
 \ /
  Last update: 2020-04-17 13:25    [W:0.091 / U:0.548 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site