Received: by 2002:ac0:a5a6:0:0:0:0:0 with SMTP id m35-v6csp2173498imm; Thu, 20 Sep 2018 08:51:14 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda90CP/C5rfi3gmM66uVjDmAUHx0F4Up8gdUBVyDM2ydghvJu0/rtb1mv/hCQVLamC0vs7l X-Received: by 2002:a17:902:a613:: with SMTP id u19-v6mr40394006plq.234.1537458674650; Thu, 20 Sep 2018 08:51:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1537458674; cv=none; d=google.com; s=arc-20160816; b=BfYn+cn1DTbSEDU7JBM0I4vVEhfDzTGbzwxb6nLXwW95rb8s1DX2/MUR/SNXCFfHgh DN0yFc5/VeDPg5up4qCe78fwwpwnrgJSlk1XuHOh/yn9X1UzCOSmqwHQVxE7eVz3to4U dsLzg7nnmclZFIqT3fFLgvGYjAx9XAGuxL+5jeOgNyLHykM7Rh1VRF/XUMKdLiCkX1A8 OQaQatOSP28o6rjwPb4jEYcbM/EWbaAiihzc6boNGBEgHbjC+gCY2lQiggEoTgCFQggr oE12HW5VZ3JyJP/b3alxZSEMzEeOc+JzY7eu0Kj1ae1C4PQikiG0agVx9HdyNMlVKjAB TI6Q== 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; bh=ffnQMTOEwkUu5xq5eSLgfoTctqfOsq0w18sJ2mQZnN8=; b=k2tSmZy9btWFq1Xz7VCYo1XY5fC/V/U9yt9kshbfCGoxG9cq8e7CnPwamX5J9mL3sX ItmjGRIN5AZxir5OwniZooOgiFE0ohzmXqJGh3Vw1A9vi0Hnp24XCJ+9sBxHzmogc6kh WwUQ4W1oICqfxVuGWvIdHihnRhTg9PSX6kAFcn/oru6sZzrKgIF8X2TlGGdpUPUXLL1a RlanZ+Z/zKklLI8LjLIt/RszHDQrnDg+CICaLG2NkFXGjyDZDc0/QQYpHy2Zqjv8j+yr PVzyXUF6Id8uxtAcYCFacpjTu7FF3tbQ/iJcj0TaQ4YuHNPs1O+BxMrcGJD0N1xQYd97 A0Pg== 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 h16-v6si23594661plr.343.2018.09.20.08.50.57; Thu, 20 Sep 2018 08:51:14 -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 S1733282AbeITVe5 (ORCPT + 99 others); Thu, 20 Sep 2018 17:34:57 -0400 Received: from mx1.redhat.com ([209.132.183.28]:54136 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731135AbeITVe5 (ORCPT ); Thu, 20 Sep 2018 17:34:57 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id C8587317C412; Thu, 20 Sep 2018 15:50:50 +0000 (UTC) Received: from gondolin (dhcp-192-222.str.redhat.com [10.33.192.222]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A19418A4C; Thu, 20 Sep 2018 15:50:44 +0000 (UTC) Date: Thu, 20 Sep 2018 17:50:41 +0200 From: Cornelia Huck To: Tony Krowiak Cc: 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, frankja@linux.ibm.com, Tony Krowiak Subject: Re: [PATCH v10 05/26] s390: vfio-ap: register matrix device with VFIO mdev framework Message-ID: <20180920175041.57ad867e.cohuck@redhat.com> In-Reply-To: <1536781396-13601-6-git-send-email-akrowiak@linux.vnet.ibm.com> References: <1536781396-13601-1-git-send-email-akrowiak@linux.vnet.ibm.com> <1536781396-13601-6-git-send-email-akrowiak@linux.vnet.ibm.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.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.41]); Thu, 20 Sep 2018 15:50:51 +0000 (UTC) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 12 Sep 2018 15:42:55 -0400 Tony Krowiak wrote: > From: Tony Krowiak > > 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. > > Registering the matrix device with the VFIO mediated device > framework will create the following sysfs structures: > > /sys/devices/vfio_ap/matrix/ > ...... [mdev_supported_types] > ......... [vfio_ap-passthrough] > ............ create > > To create a mediated device for the AP matrix device, write a UUID > to the create file: > > uuidgen > create > > A symbolic link to the mediated device's directory will be created in the > devices subdirectory named after the generated $uuid: > > /sys/devices/vfio_ap/matrix/ > ...... [mdev_supported_types] > ......... [vfio_ap-passthrough] > ............ [devices] > ............... [$uuid] > > A symbolic link to the mediated device will also be created > in the vfio_ap matrix's directory: > > /sys/devices/vfio_ap/matrix/[$uuid] > > Signed-off-by: Tony Krowiak > Reviewed-by: Halil Pasic > Tested-by: Michael Mueller > Tested-by: Farhan Ali > Signed-off-by: Christian Borntraeger > --- > MAINTAINERS | 1 + > drivers/s390/crypto/Makefile | 2 +- > drivers/s390/crypto/vfio_ap_drv.c | 19 +++++ > drivers/s390/crypto/vfio_ap_ops.c | 126 +++++++++++++++++++++++++++++++++ > drivers/s390/crypto/vfio_ap_private.h | 49 +++++++++++++ > include/uapi/linux/vfio.h | 1 + > 6 files changed, 197 insertions(+), 1 deletions(-) > create mode 100644 drivers/s390/crypto/vfio_ap_ops.c (...) > diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c > index 3e635f0..75f8bdc 100644 > --- a/drivers/s390/crypto/vfio_ap_drv.c > +++ b/drivers/s390/crypto/vfio_ap_drv.c > @@ -76,6 +76,16 @@ static int vfio_ap_matrix_dev_create(void) > goto matrix_alloc_err; > } > > + /* Test if PQAP(QCI) instruction is available */ /* Fill in config info via PQAP(QCI), if available */ ? > + if (test_facility(12)) { > + ret = ap_qci(&matrix_dev->info); > + if (ret) > + goto matrix_alloc_err; > + } > + > + mutex_init(&matrix_dev->lock); > + INIT_LIST_HEAD(&matrix_dev->mdev_list); > + > matrix_dev->device.type = &vfio_ap_dev_type; > dev_set_name(&matrix_dev->device, "%s", VFIO_AP_DEV_NAME); > matrix_dev->device.parent = root_device; (...) > diff --git a/drivers/s390/crypto/vfio_ap_private.h b/drivers/s390/crypto/vfio_ap_private.h > index 6141420..a2eab78 100644 > --- a/drivers/s390/crypto/vfio_ap_private.h > +++ b/drivers/s390/crypto/vfio_ap_private.h > @@ -3,6 +3,7 @@ > * Private data and functions for adjunct processor VFIO matrix driver. > * > * Author(s): Tony Krowiak > + * Halil Pasic > * > * Copyright IBM Corp. 2018 > */ > @@ -24,11 +25,59 @@ > /** > * ap_matrix_dev - the AP matrix device structure > * @device: generic device structure associated with the AP matrix device > + * @available_instances: number of mediated matrix devices that can be created > + * @info: the struct containing the output from the PQAP(TAPQ) instruction Hm, isn't that rather PQAP(QCI)? > + * mdev_list: the list of mediated matrix devices created > + * lock: mutex for locking the AP matrix device. This lock will be > + * taken every time we fiddle with state managed by the vfio_ap > + * driver, be it using @mdev_list or writing the state of a > + * single ap_matrix_mdev device. It's quite coarse but we don't > + * expect much contention. > */ > struct ap_matrix_dev { > struct device device; > + atomic_t available_instances; > + struct ap_config_info info; > + struct list_head mdev_list; > + struct mutex lock; > }; Otherwise: Reviewed-by: Cornelia Huck