Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp173355imm; Tue, 14 Aug 2018 16:32:20 -0700 (PDT) X-Google-Smtp-Source: AA+uWPwpu8Sesat7d0Qhoaa7T0SQcskxxzUMNKfNLnxHf8Y61SNnq60NiWJFOKzEqKZBti1BAOPW X-Received: by 2002:a17:902:ac96:: with SMTP id h22-v6mr22277751plr.17.1534289540021; Tue, 14 Aug 2018 16:32:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534289539; cv=none; d=google.com; s=arc-20160816; b=eMrSx0CdBt0uTYxSVEma+qUBXJ8QIVtnoTLVufR5BOseuwXO1zwzJF/EE9IYbQB+iR f1VYhndb6EMJz+QAN4/uFehciDvYEubocg6HhCoRf9xZiQhXNE+Qej/c9kCezmMmwNDn rpgvxPmv8oMdZo5BEWLncO8hR1KbjVZCNFMb4dP5OYppInZDQ7owx+ElyXuKigUj+kt2 /cifYB/h/a/1Xc3X0BQrERoaTqPyFoLG6ydokyBZ+xiK5rFhodyjc6JeTh+9D80GUFfP +UQrGryGuRh23qgTT906XPAIOfBzIrDjDZeR0mwhD2Aup0/wXeRgKvoPBvTc5fKgelqI 17tw== 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:cc:to:subject:arc-authentication-results; bh=QUSVkSCu69ptEXBEQE+Sh7tsH+T7ttUO0pE5NbNVvTA=; b=ezuIhnngmDYpjZNY/1WCbxUbm7ih3KC4ZMj5hsMdDv1uzxMH7l4yXaLIkT6/DWbzPL cS/FdglPEJP6EqR3Cm0KiwAadOSHDnOBjqpQsAWjT0MRi3qMQ8K2OF+bcq2OZoc2Txlq G6jg70GUcMmnNYdUd47kM0sMJVp8nz2aFwP1WoYX5v7dcmaKPm03KGnMLK7pmLlK/aEU 7jz+Hzs97vFPisCmoXFMWm9Kxd+0996V+6AXZYV6fyi0V4wTvSS7uqZJByOsL4nUs4pT 3wsYDueeeMYtGb4L4SiTLMPlJtDnUplx+7Zw4kNCPeLEdBxlIImji5nGfqFvLGHsCeOI IDkw== 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 v71-v6si25121988pfj.354.2018.08.14.16.32.04; Tue, 14 Aug 2018 16:32:19 -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 S1732463AbeHOCUp (ORCPT + 99 others); Tue, 14 Aug 2018 22:20:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45782 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1729286AbeHOCUp (ORCPT ); Tue, 14 Aug 2018 22:20:45 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w7ENSkek057005 for ; Tue, 14 Aug 2018 19:31:14 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2kv5y8xq5u-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 14 Aug 2018 19:31:14 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 14 Aug 2018 19:31:14 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 14 Aug 2018 19:31:10 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w7ENV8nW60751986 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Tue, 14 Aug 2018 23:31:08 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E32B3AE05F; Tue, 14 Aug 2018 19:30:56 -0400 (EDT) Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 154E7AE05C; Tue, 14 Aug 2018 19:30:55 -0400 (EDT) Received: from oc8043147753.ibm.com (unknown [9.85.204.74]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP; Tue, 14 Aug 2018 19:30:54 -0400 (EDT) Subject: Re: [PATCH v9 08/22] s390: vfio-ap: base implementation of VFIO AP device driver To: Cornelia Huck , 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 References: <1534196899-16987-1-git-send-email-akrowiak@linux.vnet.ibm.com> <1534196899-16987-9-git-send-email-akrowiak@linux.vnet.ibm.com> <20180814124220.355f2ffa.cohuck@redhat.com> From: Tony Krowiak Date: Tue, 14 Aug 2018 19:30:41 -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: <20180814124220.355f2ffa.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: 18081423-0040-0000-0000-0000045EF84A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00009545; HX=3.00000242; KW=3.00000007; PH=3.00000004; SC=3.00000266; SDB=6.01073598; UDB=6.00553191; IPR=6.00853556; MB=3.00022720; MTD=3.00000008; XFM=3.00000015; UTC=2018-08-14 23:31:13 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18081423-0041-0000-0000-000008660197 Message-Id: <9537c702-d51c-aa26-3cb1-6aa0526e6fd2@linux.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2018-08-14_10:,, 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 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808140234 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 08/14/2018 06:42 AM, Cornelia Huck wrote: > On Mon, 13 Aug 2018 17:48:05 -0400 > Tony Krowiak wrote: > > >> diff --git a/drivers/s390/crypto/vfio_ap_drv.c b/drivers/s390/crypto/vfio_ap_drv.c >> new file mode 100644 >> index 0000000..5069580 >> --- /dev/null >> +++ b/drivers/s390/crypto/vfio_ap_drv.c >> @@ -0,0 +1,118 @@ >> +// SPDX-License-Identifier: GPL-2.0+ >> +/* >> + * VFIO based AP device driver >> + * >> + * Copyright IBM Corp. 2018 >> + * >> + * Author(s): Tony Krowiak >> + */ >> + >> +#include >> +#include >> +#include >> +#include >> +#include "vfio_ap_private.h" >> + >> +#define VFIO_AP_ROOT_NAME "vfio_ap" >> +#define VFIO_AP_DEV_TYPE_NAME "ap_matrix" >> +#define VFIO_AP_DEV_NAME "matrix" >> + >> +MODULE_AUTHOR("IBM Corporation"); >> +MODULE_DESCRIPTION("VFIO AP device driver, Copyright IBM Corp. 2018"); >> +MODULE_LICENSE("GPL v2"); >> + >> +static struct ap_driver vfio_ap_drv; >> + >> +static struct device_type vfio_ap_dev_type = { >> + .name = VFIO_AP_DEV_TYPE_NAME, >> +}; >> + >> +struct ap_matrix_dev matrix_dev; > Please don't add new statically allocated devices, but allocate it > dynamically (see the comment in device_add()). Okay, I'll dynamically allocate it. > >> + >> +/* Only type 10 adapters (CEX4 and later) are supported >> + * by the AP matrix device driver >> + */ >> +static struct ap_device_id ap_queue_ids[] = { >> + { .dev_type = AP_DEVICE_TYPE_CEX4, >> + .match_flags = AP_DEVICE_ID_MATCH_QUEUE_TYPE }, >> + { .dev_type = AP_DEVICE_TYPE_CEX5, >> + .match_flags = AP_DEVICE_ID_MATCH_QUEUE_TYPE }, >> + { .dev_type = AP_DEVICE_TYPE_CEX6, >> + .match_flags = AP_DEVICE_ID_MATCH_QUEUE_TYPE }, >> + { /* end of sibling */ }, >> +}; >> + >> +MODULE_DEVICE_TABLE(vfio_ap, ap_queue_ids); >> + >> +static int vfio_ap_queue_dev_probe(struct ap_device *apdev) >> +{ >> + return 0; >> +} >> + >> +static void vfio_ap_queue_dev_remove(struct ap_device *apdev) >> +{ >> + /* Nothing to do yet */ >> +} > You need a release callback as well. Will do. > >> + >> +static int vfio_ap_matrix_dev_init(void) >> +{ >> + int ret; >> + struct device *root_device; >> + >> + root_device = root_device_register(VFIO_AP_ROOT_NAME); >> + if (IS_ERR(root_device)) { >> + ret = PTR_ERR(root_device); >> + return ret; >> + } >> + >> + matrix_dev.device.type = &vfio_ap_dev_type; >> + dev_set_name(&matrix_dev.device, "%s", VFIO_AP_DEV_NAME); >> + matrix_dev.device.type = &vfio_ap_dev_type; >> + matrix_dev.device.parent = root_device; >> + matrix_dev.device.driver = &vfio_ap_drv.driver; >> + >> + ret = device_register(&matrix_dev.device); >> + if (ret) { >> + root_device_unregister(root_device); > And this needs a put_device() for the matrix device. (It is getting > ugly with a statically allocated device.) Will do. > >> + return ret; >> + } >> + >> + return 0; >> +} >> + >> +static void vfio_ap_matrix_dev_destroy(void) >> +{ >> + device_unregister(&matrix_dev.device); > This one already does a put_device(). Didn't the driver core complain? The driver core did not complain. > >> + root_device_unregister(matrix_dev.device.parent); >> +}