Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1285389imm; Tue, 22 May 2018 01:21:24 -0700 (PDT) X-Google-Smtp-Source: AB8JxZq8b5IvID8LU9mOD8l8QU0yuuCExqedp4SEDJlrhukOBicaNnrzHTpWj5PUim1y4t/lZy5A X-Received: by 2002:a63:42c4:: with SMTP id p187-v6mr18584782pga.345.1526977284898; Tue, 22 May 2018 01:21:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526977284; cv=none; d=google.com; s=arc-20160816; b=yqWcYW+4lpC6d2ZXHbetX7rDO3E/pMRnho07U6snU2Lv19lVPGGNWgSZRA4oNQo3FI fACiAZY8oz5LKqCrbpXpshyD+jWaJ58rTOJXgTSXLlxXVXlehnTXLJf0UWNk8QB0uGTP x7YI6H037ELMHduzPgXjN0JI6/T7DzwEUzpKmUTKnkz8tolwike7lL2rVitARgNVVy+Q vVCLimuWkzPwnQ3gFt0pgE/JEluCJrWOl9ObrQavoZTIT3mRhSQUwRbSyGch607gvT6/ lnoDDW+COu472juvVNIRvN41EKDE20FBZcbiAZO4tlXSPJzs8EoDEHnv4iNK9HwfWZal /VYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:arc-authentication-results; bh=h28S0oQO7wnkFVTdfi06OMOatHfLl4DK3758Ze9uWds=; b=wdDKE4Vx+WYGoq/emY74EZSD9UDa4NFUkuT6NdvGomri9HHFv/uWFuTWpzp3669S2q wbkQiOW3wwq+cAr4svoMMUHSeiH7kOpO8Z41DwOkeQQ7tNfXZ1cntFYz6wA2LalOQN4O AYUYXP81g1/aVyN/gZBxX1AckJnR+GkWMsQ5UHoZsFaeXZUIU6uWu0gNvuJcC5jlA60X +vNI4ENAOL8Rn3hSTDB7heDLBDJmw8j24rvRJC+yBmWGCp1cyvfTcfTvpshwz/Q/klI9 QMAwh4YCCgI8rM4rOoItzMQDKCP0Pz89sEpzniSbO3u7EjeMg+K+raMAjI1lcKd4piJl d+Vw== 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=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f127-v6si9814419pgc.503.2018.05.22.01.21.09; Tue, 22 May 2018 01:21:24 -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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751602AbeEVITu (ORCPT + 99 others); Tue, 22 May 2018 04:19:50 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:48874 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751269AbeEVITq (ORCPT ); Tue, 22 May 2018 04:19:46 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AC0D7BB414; Tue, 22 May 2018 08:19:45 +0000 (UTC) Received: from gondolin (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id AC653215CDA7; Tue, 22 May 2018 08:19:42 +0000 (UTC) Date: Tue, 22 May 2018 10:19:40 +0200 From: Cornelia Huck To: Tony Krowiak Cc: 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 Message-ID: <20180522101940.166445f8.cohuck@redhat.com> In-Reply-To: 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> Organization: Red Hat GmbH MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 22 May 2018 08:19:45 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 22 May 2018 08:19:45 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'cohuck@redhat.com' RCPT:'' Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.