Received: by 2002:a05:7412:e794:b0:fa:551:50a7 with SMTP id o20csp1689503rdd; Thu, 11 Jan 2024 06:40:44 -0800 (PST) X-Google-Smtp-Source: AGHT+IG8PTzGBC7zvZMtnuUQe7VE5ZlipajhSdpM+5Ai2rRmp4R+N6cC6IaWWYULUmX2IRM1XIA1 X-Received: by 2002:a25:918a:0:b0:dbe:3ddf:57ce with SMTP id w10-20020a25918a000000b00dbe3ddf57cemr1089640ybl.26.1704984044543; Thu, 11 Jan 2024 06:40:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1704984044; cv=none; d=google.com; s=arc-20160816; b=HArv89fbtxhPYxjhxGcXtNPlQNxq1GTbz2/f2p/Bqod5Q4YM0QPcStP3mjlFa8Qtyl +lFS1kn63b7r7JjVIoU8Jgho1g9zizR+A80+422GKuPC5x3qQ8RNdQfWYrdoHD3fynsk 6yzGDUOtoU2N6wD2DUe4xVCD9lZGsMi6ari9m3ob9fLz87Q4jHEd/MqaG1u9hpXUT0iK a7ju7PUHlsSJuoQWhHwdYjZ2ZT0Dxe+IdKaavUZKyfZTNelGqLwCYy1mzG07bOG4iFqW 9ENB+ZUwFs8jbQ/EOIfE2OYIGccHFRaJ9Tc9UGeoHMMHRjpYCq5ywdnEPsb+foCQiNkm mnXA== 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=41kSqjRA8LZoRNq2Fpx4NoqSL80yGNnpkuhMiftcsxI=; fh=9kM08SNvNCV/491z4P/0od8SLPJE1APHr0sNclRdvng=; b=vHIpU1xgVL1+SCliviPjyqCeXk56BbbC1LQJEdul8cADaDBuYcogaLT+tWTWgRIglM NsReEFrMRQQfz2/lJG/I0h3NuZjkkJF/Ign/VqNz/ncvooGb/kuL64OHu2FNxC48eXA9 E9W1IuhzM71IPo+LwHd6ibFt9Plz0oSGfOoJQ4Miu/xxXpOGrTgq+Ql/miri0j6JCza0 F4aax1vzQh84YeMBRamhd7YTFWl2nJw9odzx8AOWKOPp3FHF/LHR2ziDEGYiGHC0PzvY CN35VGKr+/uhYQsKyofAD6ewRBs5xf4q9JwVppcIy6bA5oQ9BqYotWxxOUhcJ6dDtuEV M/uw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=iAvJ+NRN; spf=pass (google.com: domain of linux-kernel+bounces-23721-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23721-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id d24-20020a67e418000000b00466dd99d43dsi120480vsf.344.2024.01.11.06.40.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 11 Jan 2024 06:40:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-23721-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=iAvJ+NRN; spf=pass (google.com: domain of linux-kernel+bounces-23721-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-23721-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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 451B71C20F43 for ; Thu, 11 Jan 2024 14:40:44 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 38E5F5025A; Thu, 11 Jan 2024 14:39:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="iAvJ+NRN" 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 B13BC4F89F; Thu, 11 Jan 2024 14:38:58 +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 (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 40BDqGNB010812; Thu, 11 Jan 2024 14:38:55 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=41kSqjRA8LZoRNq2Fpx4NoqSL80yGNnpkuhMiftcsxI=; b=iAvJ+NRNMyncaN6VG62ukxeNDYQ2iCAf0fWTE1dBF6x1l6QnpCOoqBiyet6WmOUA3326 qdD5DBy0AI/MUH45esjhhWAbyp+hnQx7zx9tCgj+lRKssUIFrODw2vys0nyEDgIY9rIO 58bQqb6ou2Y7T8Xag5iDdwptMaVNDEQ673tjg/NYb0dil1tgiGa43yERT3+UhsxCkv4N KsF4razYR3dsq4tRSKdvO+Hg75lhJrusyZ9m6g9I2MbJt6rW/L1ITKzYUHOKFUpK0fZI 28iqLGDAYH4hh4xUSjke7Q61hhNjxRwU9Px19Zzd6lF9GCYrkPcJ6ArvN7UC3WSrJHiZ hQ== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vjhkese3x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 14:38:55 +0000 Received: from m0356517.ppops.net (m0356517.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 40BEOLb6019557; Thu, 11 Jan 2024 14:38:54 GMT Received: from ppma22.wdc07v.mail.ibm.com (5c.69.3da9.ip4.static.sl-reverse.com [169.61.105.92]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3vjhkese3g-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 14:38:54 +0000 Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 40BERM4G022781; Thu, 11 Jan 2024 14:38:53 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 3vfhjyv4b1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 11 Jan 2024 14:38:53 +0000 Received: from smtpav06.dal12v.mail.ibm.com (smtpav06.dal12v.mail.ibm.com [10.241.53.105]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 40BEcpj447186234 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Thu, 11 Jan 2024 14:38:51 GMT Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AA4E458061; Thu, 11 Jan 2024 14:38:51 +0000 (GMT) Received: from smtpav06.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C032058059; Thu, 11 Jan 2024 14:38:50 +0000 (GMT) Received: from li-2c1e724c-2c76-11b2-a85c-ae42eaf3cb3d.ibm.com.com (unknown [9.61.174.181]) by smtpav06.dal12v.mail.ibm.com (Postfix) with ESMTP; Thu, 11 Jan 2024 14:38:50 +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 Subject: [PATCH v3 3/6] s390/vfio-ap: let 'on_scan_complete' callback filter matrix and update guest's APCB Date: Thu, 11 Jan 2024 09:38:37 -0500 Message-ID: <20240111143846.8801-4-akrowiak@linux.ibm.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240111143846.8801-1-akrowiak@linux.ibm.com> References: <20240111143846.8801-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-GUID: 1FCJHo1pQmaRllvcViiVeZpz2Eyuh1L1 X-Proofpoint-ORIG-GUID: 2dcJ6jI1VE2LU2Jb9BSFD7KO1zvJ5chT 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-11_07,2024-01-11_01,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxlogscore=999 priorityscore=1501 suspectscore=0 impostorscore=0 lowpriorityscore=0 malwarescore=0 spamscore=0 clxscore=1015 mlxscore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2311290000 definitions=main-2401110116 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 47232e19a50e..26bd4aca497a 100644 --- a/drivers/s390/crypto/vfio_ap_ops.c +++ b/drivers/s390/crypto/vfio_ap_ops.c @@ -2083,9 +2083,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