Received: by 2002:ac0:a594:0:0:0:0:0 with SMTP id m20-v6csp1051560imm; Fri, 11 May 2018 10:19:18 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpcaUMxPGeBvASgf3MOgyqUC8hoy0AFpEEX9PXxfLpG8zPjP6IbHx4bYPrspIQk2VSY7UMP X-Received: by 2002:a63:62c6:: with SMTP id w189-v6mr5189821pgb.164.1526059158128; Fri, 11 May 2018 10:19:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1526059158; cv=none; d=google.com; s=arc-20160816; b=TN3dY1dKcqOi97ZhYnHGnojKMqQ738q2hDacrVQrzkAi5YaIHtXEEHKmXa+Vbv/DPo Dtdutxut/d6hIjc8ji4WVXLaWCg0kw+iepXy7lJ/QoMDiTuTTbeG4lmfnTN3Ozt+CC6j jN4pGw2T40+IYUtkZU/2wd5BTb8xc59MuPLvTphKBpi19OUSRSvz/jandRkz2e+3K5qt 0pPiHzbVOUKf4HsMuy85KSF00Xl9N9T8zGn6ykxOoyS4vdX88yoEW+fkca/MjmGrnl+j sbolj1TzEX/PTauFEweuwyh5nXNcdid9kjMzfXfBM66fz9Wvk22GqRPNuUfMeOMX8mtV L4rg== 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-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date:from :references:cc:to:subject:arc-authentication-results; bh=LVhuWLZWJ4jWPZcFOGl98iM2u+4qRZ08LzgUJ62ZEKw=; b=uO1T5WojJRf9yh75vXn5mT6vLPQkvjAEnuP3w1/wNWyO/Tz2kBNWhwmnIUe8rJf5dp qNKIkA8T5eeAvlUGqIWH98Pr1V+3EXq+X5/JaXvT4KSxahf9idv8rEJWWBvkiUDegU/1 kIG/Axa7kLrH+fEQJbSrBbx9HhPpqKtgDt1X97QeR3jOj80s4S7e1vrSMpl2YmHLN9Oc aC7H2i/oAg/DAxpdXuggJIuxmWOHT2RsjR0p1tP8KPxd5zNQbCjgpVGwgkrY8h7n5bq2 bRkPfrOYdbbYNaEims8gr/DFQwx2Po0NfmOljP1bU0JUaCycOBW9QSrRFnNkGbbYBcc4 R+Cw== 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 m23-v6si2870249pgc.523.2018.05.11.10.19.01; Fri, 11 May 2018 10:19:18 -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 S1751321AbeEKRSs (ORCPT + 99 others); Fri, 11 May 2018 13:18:48 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47602 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750711AbeEKRSq (ORCPT ); Fri, 11 May 2018 13:18:46 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w4BHFbAV140803 for ; Fri, 11 May 2018 13:18:46 -0400 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0b-001b2d01.pphosted.com with ESMTP id 2hwfdn038k-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Fri, 11 May 2018 13:18:46 -0400 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 May 2018 18:18:44 +0100 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 11 May 2018 18:18:41 +0100 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w4BHIeNR1114562; Fri, 11 May 2018 17:18:40 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5EAAA52041; Fri, 11 May 2018 17:08:55 +0100 (BST) Received: from oc3836556865.ibm.com (unknown [9.152.224.46]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 3C76D5203F; Fri, 11 May 2018 17:08:54 +0100 (BST) Subject: Re: [PATCH v5 05/13] s390: vfio-ap: register matrix device with VFIO mdev framework To: Tony Krowiak , linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: freude@de.ibm.com, schwidefsky@de.ibm.com, heiko.carstens@de.ibm.com, borntraeger@de.ibm.com, cohuck@redhat.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 References: <1525705912-12815-1-git-send-email-akrowiak@linux.vnet.ibm.com> <1525705912-12815-6-git-send-email-akrowiak@linux.vnet.ibm.com> From: Halil Pasic Date: Fri, 11 May 2018 19:18:38 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.7.0 MIME-Version: 1.0 In-Reply-To: <1525705912-12815-6-git-send-email-akrowiak@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18051117-0040-0000-0000-000004589718 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18051117-0041-0000-0000-000020FCADC8 Message-Id: <5471b194-d7ca-c9c6-132e-fa9539fe44f0@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-05-11_08:,, 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-1805110161 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. > [..] > diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c > new file mode 100644 > index 0000000..d7d36fb > --- /dev/null > +++ b/drivers/s390/crypto/vfio_ap_ops.c > @@ -0,0 +1,106 @@ > +// SPDX-License-Identifier: GPL-2.0+ > +/* > + * Adjunct processor matrix VFIO device driver callbacks. > + * > + * Copyright IBM Corp. 2017 > + * Author(s): Tony Krowiak > + * > + */ > +#include > +#include > +#include > +#include > +#include > + > +#include "vfio_ap_private.h" > + > +#define VFOP_AP_MDEV_TYPE_HWVIRT "passthrough" > +#define VFIO_AP_MDEV_NAME_HWVIRT "VFIO AP Passthrough Device" > + > +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? 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. [..] > +int vfio_ap_mdev_register(struct ap_matrix *ap_matrix) > +{ > + int ret; > + > + ret = mdev_register_device(&ap_matrix->device, &vfio_ap_matrix_ops); > + if (ret) > + return ret; > + > + ap_matrix->available_instances = AP_MATRIX_MAX_AVAILABLE_INSTANCES; > + > + return 0; > +} > + > +void vfio_ap_mdev_unregister(struct ap_matrix *ap_matrix) > +{ > + ap_matrix->available_instances--; What is this for? I don't understand. Regards, Halil > + mdev_unregister_device(&ap_matrix->device); > +}