Received: by 2002:a05:7412:8d09:b0:fa:4c10:6cad with SMTP id bj9csp30901rdb; Mon, 15 Jan 2024 10:57:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGy7w53HQ+fHIKdKHY3o+nNyuMG/rLj2+2Gs1R4k+6uGdZ8w9DnF5JgT+RC8+S3LYAvat/ X-Received: by 2002:a17:90a:d913:b0:28e:1afb:fee6 with SMTP id c19-20020a17090ad91300b0028e1afbfee6mr1942664pjv.74.1705345034542; Mon, 15 Jan 2024 10:57:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705345034; cv=none; d=google.com; s=arc-20160816; b=DSPKMTqiG9dtMRsKeFPquA52ko7IjxfoY5UGW9T6qWduySHnrLlTiqH0ToECYt2inI 1va6k7NT/ZZ2MNYguH8RsRzI/w92iRXzuajKiNaeQQVJ4fG/uHjVVSOTqBy+rQGJ9bp3 nL6SSnvuu5vulYQZ+O5ktJD8Pwy6WC5jpAi/JD0qR7/3A7HHMFOYK5qmh4ZKm43gPp49 X+oDmIAnAlx2f7swYtgKTnDyHlaxD4s4xLnb+wpxxsgiPIdv/9yt4yYHN6ZoJSQIDRLK dThcZvOhSCgz7Xmzi2TWk5FqqTjTEcX2iQq2zuoEt1h3+Dd9gPZPYRVAeWJ23jyfxAPS SgyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=4WTuNJU7dggzhMxg+LKkTN4UTqO72KHYK9oF7xPUUCg=; fh=M0oRxUbO5PmdBwbCvdqALEcb6RJBVEJ1jCZynSfqY4Y=; b=f2uuQMNi/S+0Okpqj7B5NTVqYSqVp5T1kA0tZs8UDZ38jRkmr6J7KGSbCMfroyFOXJ rb2OSCqHA2wrcSUmdRJOOS4j0E1jtC7az3iH/88gQST8NSNNcG9DMtFKXyNko1zkY0ry UFBeXNS6VrDSnwX/0SLE+ASWs0zWhO7dpU4IQ+W3tHs0MTP354HAmLYDHWvEMESkoqXu N+G9fR4KHaN5iXx/fPw/QEy/L0LmzJbaYu4q298y4bnFlm5o7zmuUiy58lZcZF4ko+UK +YNazitg4YOihrFql7vnSHloFJHZzPli6VzOiyHvzT2OmShJXav5/xW33TJyoMVymv7G XkkA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=DRACd0HI; spf=pass (google.com: domain of linux-kernel+bounces-26416-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26416-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id jf22-20020a170903269600b001d4e20757dfsi9266752plb.177.2024.01.15.10.57.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 10:57:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-26416-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=DRACd0HI; spf=pass (google.com: domain of linux-kernel+bounces-26416-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-26416-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id B8B6B282585 for ; Mon, 15 Jan 2024 18:55:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E703319447; Mon, 15 Jan 2024 18:54:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="DRACd0HI" Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5CB0818C2F; Mon, 15 Jan 2024 18:54:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.ibm.com Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40FI1Ea2016044; Mon, 15 Jan 2024 18:54:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=4WTuNJU7dggzhMxg+LKkTN4UTqO72KHYK9oF7xPUUCg=; b=DRACd0HImjfPxGQR4oUs+OGXhN4G01JPZhrm3PYu2AtBunpDWA8/onRpDiocSgY/PV57 GmAYdsPCaPd/8VKBDBPzDiRFF8c1ZxaI6H7RQKiTxudgaDLi0HRmu9t6+1MkJOzU89OM ZMnVh69Q5Pn4Wa2Pv4frHC3vRxqciwPiJuQ3/FU6B/wuNUAW/o/+KDbUElCc2saY6p68 jxSD+8BkyCh76tAnm1D1Zh563/D3HKXuP2yvnO/xYY4CrEpJ0jOvTGrlvclzYSOKoiPS 7Id+cSec7WIhuc0gQ2KA6Tdsmdglyk550sZ9JvCUSeDXSbghFXdvrjZJAK+4WL2qFZVI 7w== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vn94a1fje-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jan 2024 18:54:49 +0000 Received: from m0360083.ppops.net (m0360083.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40FInRZW007475; Mon, 15 Jan 2024 18:54:48 GMT Received: from ppma21.wdc07v.mail.ibm.com (5b.69.3da9.ip4.static.sl-reverse.com [169.61.105.91]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vn94a1fhy-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jan 2024 18:54:48 +0000 Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40FHeEi6018627; Mon, 15 Jan 2024 18:54:47 GMT Received: from smtprelay07.wdc07v.mail.ibm.com ([172.16.1.74]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vm5una043-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 15 Jan 2024 18:54:47 +0000 Received: from smtpav04.dal12v.mail.ibm.com (smtpav04.dal12v.mail.ibm.com [10.241.53.103]) by smtprelay07.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40FIskGv27984620 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 15 Jan 2024 18:54:46 GMT Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 16C0B5805A; Mon, 15 Jan 2024 18:54:46 +0000 (GMT) Received: from smtpav04.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1EA2A58052; Mon, 15 Jan 2024 18:54:45 +0000 (GMT) Received: from li-2c1e724c-2c76-11b2-a85c-ae42eaf3cb3d.ibm.com.com (unknown [9.61.164.202]) by smtpav04.dal12v.mail.ibm.com (Postfix) with ESMTP; Mon, 15 Jan 2024 18:54:45 +0000 (GMT) From: Tony Krowiak To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: jjherne@linux.ibm.com, borntraeger@de.ibm.com, pasic@linux.ibm.com, pbonzini@redhat.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, alex.williamson@redhat.com, kwankhede@nvidia.com, agordeev@linux.ibm.com, gor@linux.ibm.com, Tony Krowiak Subject: [PATCH v4 3/6] s390/vfio-ap: let 'on_scan_complete' callback filter matrix and update guest's APCB Date: Mon, 15 Jan 2024 13:54:33 -0500 Message-ID: <20240115185441.31526-4-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240115185441.31526-1-akrowiak@linux.ibm.com> References: <20240115185441.31526-1-akrowiak@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: 6ePKe-RCQwp5ce62VQYtqc7CVwyKQB_A X-Proofpoint-GUID: jEjOyPbi8AgNUqHonmDNRZSBd4RiJDMc X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.997,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2024-01-15_13,2024-01-15_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 malwarescore=0 suspectscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 mlxlogscore=999 impostorscore=0 mlxscore=0 clxscore=1015 priorityscore=1501 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401150139 From: Tony Krowiak When adapters and/or domains are added to the host's AP configuration, this may result in multiple queue devices getting created and probed by the vfio_ap device driver. For each queue device probed, the matrix of adapters and domains assigned to a matrix mdev will be filtered to update the guest's APCB. If any adapters or domains get added to or removed from the APCB, the guest's AP configuration will be dynamically updated (i.e., hot plug/unplug). To dynamically update the guest's configuration, its VCPUs must be taken out of SIE for the period of time it takes to make the update. This is disruptive to the guest's operation and if there are many queues probed due to a change in the host's AP configuration, this could be troublesome. The problem is exacerbated by the fact that the 'on_scan_complete' callback also filters the mdev's matrix and updates the guest's AP configuration. In order to reduce the potential amount of disruption to the guest that may result from a change to the host's AP configuration, let's bypass the filtering of the matrix and updating of the guest's AP configuration in the probe callback - if due to a host config change - and defer it until the 'on_scan_complete' callback is invoked after the AP bus finishes its device scan operation. This way the filtering and updating will be performed only once regardless of the number of queues added. Signed-off-by: Tony Krowiak Reviewed-by: Halil Pasic --- drivers/s390/crypto/vfio_ap_ops.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c index e825e13847fe..e45d0bf7b126 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -2101,9 +2101,22 @@ int vfio_ap_mdev_probe_queue(struct ap_device *apdev) if (matrix_mdev) { vfio_ap_mdev_link_queue(matrix_mdev, q); + /* + * If we're in the process of handling the adding of adapters or + * domains to the host's AP configuration, then let the + * vfio_ap device driver's on_scan_complete callback filter the + * matrix and update the guest's AP configuration after all of + * the new queue devices are probed. + */ + if (!bitmap_empty(matrix_mdev->apm_add, AP_DEVICES) || + !bitmap_empty(matrix_mdev->aqm_add, AP_DOMAINS)) + goto done; + if (vfio_ap_mdev_filter_matrix(matrix_mdev)) vfio_ap_mdev_update_guest_apcb(matrix_mdev); } + +done: dev_set_drvdata(&apdev->device, q); release_update_locks_for_mdev(matrix_mdev); -- 2.43.0