Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp96062imm; Tue, 22 May 2018 14:42:10 -0700 (PDT) X-Google-Smtp-Source: AB8JxZqLpfYXL8ZAM9BEHfd+H0PkjKfu6IqZeJ7xCPNOP7aRAmxZclv9OWbyPnWNgawyEVnsX2Is X-Received: by 2002:a62:3f81:: with SMTP id z1-v6mr175327pfj.216.1527025330026; Tue, 22 May 2018 14:42:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527025329; cv=none; d=google.com; s=arc-20160816; b=ZxyVXCG8SJkEnkJHZ241la1zzcvf9PHlPRqLyaGAkY7SQqCwNjjZwQwXcrbP8D+3FO 1lL3Bb9YrIUxSUZFYYr9fODDtF+HKncup5gcAIZyllIPYPupcJpTmXXI0auTzSugMsA+ jr8aKhjDzB5CgipHzuMEZxn6eJ8B6cLt1AqYtcM3m6K/YN1mdw88QiETP7sWnIThm1H1 8DMLnHY1EbKD6fPtf8ngDwaEFHvATAUkmX7+UUaeIZG7r/oFeUXVOLzduQ5m7zzIMqdT mqriU02mh+iJYVAtzeU35nbNxnZxe+Wp4BFwKdQDLyWGvLzCk8Nv8BOi4kysLnnvCwta fn7Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :from:references:to:subject:cc:arc-authentication-results; bh=v/ns1vRR7Z75aM2PDr1IEevjcTyplu37tJhs7rZgz1U=; b=wTc8SKlToTHwKGI4fug71RLwzX0R+mCMLGRB2x++mnv1NHpSCb/iYXyghiKU8T6+6F KsG3xBPJyicKqXwjFAGvPzSP/Rh4Q+bjL42QoVcdK7VDYadXNJQ97hEYHuepKeS3yrB9 ihXJW6wmlE5ZVATDNrbcFkgjLW47u07v/f0ScHxaqW7ouqeyxHy94ATCHE/fCvOfsZHw 5eLfG1WVYR8W9XzuHMRzMg7RDd53K0lWSv/6Ubt7Un7YneaF2ca8AYTH9z8MfoDtccYD AzPSBKSoszphFS3b42KpwtmxDUfhtbK3x2DssylTzRlP7Oh7fTbfy4hFFq7yDBr3JEAY QvIA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l7-v6si8248987pgu.429.2018.05.22.14.41.55; Tue, 22 May 2018 14:42:09 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753085AbeEVVla (ORCPT + 99 others); Tue, 22 May 2018 17:41:30 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:36942 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752960AbeEVVl2 (ORCPT ); Tue, 22 May 2018 17:41:28 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4MLcXrE055929 for ; Tue, 22 May 2018 17:41:28 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2j4pd1wf36-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 22 May 2018 17:41:28 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 22 May 2018 17:41:26 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 22 May 2018 17:41:22 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4MLfKMR30212266 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 22 May 2018 21:41:20 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 49B31B2065; Tue, 22 May 2018 18:43:10 -0400 (EDT) Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 105D4B205F; Tue, 22 May 2018 18:43:09 -0400 (EDT) Received: from oc8043147753.ibm.com (unknown [9.60.75.218]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 22 May 2018 18:43:08 -0400 (EDT) Cc: akrowiak@linux.vnet.ibm.com, Halil Pasic , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org, freude@de.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, borntraeger@de.ibm.com, kwankhede@nvidia.com, bjsdjshi@linux.vnet.ibm.com, pbonzini@redhat.com, alex.williamson@redhat.com, pmorel@linux.vnet.ibm.com, alifm@linux.vnet.ibm.com, mjrosato@linux.vnet.ibm.com, jjherne@linux.vnet.ibm.com, thuth@redhat.com, pasic@linux.vnet.ibm.com, berrange@redhat.com, fiuczy@linux.vnet.ibm.com, buendgen@de.ibm.com Subject: Re: [PATCH v5 05/13] s390: vfio-ap: register matrix device with VFIO mdev framework To: Cornelia Huck References: <1525705912-12815-1-git-send-email-akrowiak@linux.vnet.ibm.com> <1525705912-12815-6-git-send-email-akrowiak@linux.vnet.ibm.com> <5471b194-d7ca-c9c6-132e-fa9539fe44f0@linux.ibm.com> <4688078d-3e13-5201-582f-52576b25defa@linux.vnet.ibm.com> <20180517094454.6afae7ba.cohuck@redhat.com> <20180522101940.166445f8.cohuck@redhat.com> From: Tony Krowiak Date: Tue, 22 May 2018 17:41:19 -0400 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.0 MIME-Version: 1.0 In-Reply-To: <20180522101940.166445f8.cohuck@redhat.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Content-Language: en-US X-TM-AS-GCONF: 00 x-cbid: 18052221-0024-0000-0000-0000036004F4 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009068; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000261; SDB=6.01036186; UDB=6.00530060; IPR=6.00815315; MB=3.00021246; MTD=3.00000008; XFM=3.00000015; UTC=2018-05-22 21:41:25 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18052221-0025-0000-0000-0000482109A0 Message-Id: <0ccac0ff-82d0-4adc-26a5-c64caf0f7a80@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-22_06:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1805220219 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 05/22/2018 04:19 AM, Cornelia Huck wrote: > On Mon, 21 May 2018 11:13:58 -0400 > Tony Krowiak wrote: > >> On 05/17/2018 03:44 AM, Cornelia Huck wrote: >>> On Mon, 14 May 2018 15:42:18 -0400 >>> Tony Krowiak wrote: >>> >>>> On 05/11/2018 01:18 PM, Halil Pasic wrote: >>>>> On 05/07/2018 05:11 PM, Tony Krowiak wrote: >>>>>> Registers the matrix device created by the VFIO AP device >>>>>> driver with the VFIO mediated device framework. >>>>>> Registering the matrix device will create the sysfs >>>>>> structures needed to create mediated matrix devices >>>>>> each of which will be used to configure the AP matrix >>>>>> for a guest and connect it to the VFIO AP device driver. >>>>>> +static int vfio_ap_mdev_create(struct kobject *kobj, struct >>>>>> mdev_device *mdev) >>>>>> +{ >>>>>> + struct ap_matrix *ap_matrix = to_ap_matrix(mdev_parent_dev(mdev)); >>>>>> + >>>>>> + ap_matrix->available_instances--; >>>>>> + >>>>>> + return 0; >>>>>> +} >>>>>> + >>>>>> +static int vfio_ap_mdev_remove(struct mdev_device *mdev) >>>>>> +{ >>>>>> + struct ap_matrix *ap_matrix = to_ap_matrix(mdev_parent_dev(mdev)); >>>>>> + >>>>>> + ap_matrix->available_instances++; >>>>>> + >>>>>> + return 0; >>>>>> +} >>>>>> + >>>>> The above functions seem to be called with the lock of this >>>>> auto-generated >>>>> mdev parent device held. That's why we don't have to care about >>>>> synchronization >>>>> ourselves, right? >>>> I would assume as much. The comments for the 'struct mdev_parent_ops' in >>>> include/linux/mdev.h do not mention anything about synchronization, nor >>>> did I >>>> see any locking or synchronization in the vfio_ccw implementation after >>>> which >>>> I modeled my code, so frankly it is something I did not consider. >>>> >>>>> A small comment in the code could be helpful for mdev non-experts. >>>>> Hell, I would >>>>> even consider documenting it for all mdev -- took me some time to >>>>> figure out. >>>> You may want to bring this up with the VFIO mdev maintainers, but I'd be >>>> happy to >>>> include a comment in the functions in question if you think it important. >>> Important note: There's currently a patch on list that removes the mdev >>> parent mutex, and it seems there was never intended to be any >>> serialization in that place by the mdev core. (Look for "vfio/mdev: >>> Check globally for duplicate devices".) >> The patch on the list holds the mdev_list_lock during create and remove >> of an mdev device, so it looks like no synchronization is necessary on the >> part of the vendor code in the create/remove callbacks; does that sound >> about right? > v1/v2 did that; v3/v4 hold the list lock only while the device is added > to the mdev list. v4 also adds a note regarding locking to the > documentation. I'll add some synchronization to the read/update of available instances. >