Received: by 2002:a05:7412:8521:b0:e2:908c:2ebd with SMTP id t33csp2224377rdf; Mon, 6 Nov 2023 08:04:24 -0800 (PST) X-Google-Smtp-Source: AGHT+IHlw7REwx0i5CxKpREIY/26ekKgCDz4p/yTU+1vd5QksUlEzkab7ktNPdOwFJ6DlYb60YvR X-Received: by 2002:a05:6830:349b:b0:6d3:1982:6f49 with SMTP id c27-20020a056830349b00b006d319826f49mr18252013otu.6.1699286663995; Mon, 06 Nov 2023 08:04:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699286663; cv=none; d=google.com; s=arc-20160816; b=U2ZBWBpy3GQJaujCilvlFwbvQZvpXP+eT/fnBreP8W53/03Zm8XZAIN44DEDpPazC4 KyjA7QHUuI4IuUmXS7rMuiYKDWPUDn5ZN6YvcljwGkCgqPtA7dmS1ktmNFv6x9I1DPNL bwR6Oan2LVz/vsNRF5hvnS32VoKwOvfQLBkDh3+fHgRs9JO0X21hX8/Cc6SnuawvBsO7 IBnmFZP/FoOQaTyVCV+YgiW4QC/Zkehs29u0fy/ANvUTjgm5gJxcdjU2yBqdJM2o4tYh yrCj9mdwXyH2EqkSIqk9FgxRiVYvtaIbcqI71JTVoaz7CyrkG83mXndUwzeQyuiGauvX z4eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to :organization:references:cc:to:from:content-language:subject :user-agent:mime-version:date:message-id:dkim-signature; bh=MGbbZNP/mdzm3S/5Ztp69aF9Y4qswVAtQclS9ietJKA=; fh=+rhJBm3naSW9kDydXTcpyvHV96mQrbUifVLl1LeGCeA=; b=HiIOjCv5pV43kV0J3XM15j6BIf1+jzUC2dWtX224cIydRSrLbRrW91Bfk5rIs/FSwS lpGHJ2UexJREF4ZQ26nuA8vMF+Qw5yTa0jx0KGSUbg4ERO53raWofIzwxXEkNJK4UFI0 iBGvyUhyNzoXcJ8T9UatfCkkHAX8v0J3li3uFK+Gf28pQApouYmy1M0Fm6Rk/mQoC590 NHZYGXOsGeKn0ullas1Z7or4sCNrU47IpOuN+V3PcfMYeBsyyUDb6XfJSxSeb/jUrXUy bNiMym33aS5Ry9h+FYk0L/sZWZXeD0hwTZABxNovJqVXkYft6q0g2PXQM5dUFBWAip99 T7Xg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=BDy1w+uF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from fry.vger.email (fry.vger.email. [2620:137:e000::3:8]) by mx.google.com with ESMTPS id s4-20020a056830124400b006c8f11041d1si3349473otp.112.2023.11.06.08.04.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 08:04:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) client-ip=2620:137:e000::3:8; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=BDy1w+uF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:8 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id C18A480B87E1; Mon, 6 Nov 2023 08:04:17 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232341AbjKFQEH (ORCPT + 99 others); Mon, 6 Nov 2023 11:04:07 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229518AbjKFQEG (ORCPT ); Mon, 6 Nov 2023 11:04:06 -0500 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F7A613E; Mon, 6 Nov 2023 08:04:03 -0800 (PST) Received: from pps.filterd (m0353724.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6FeF2u017483; Mon, 6 Nov 2023 16:04:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=message-id : date : mime-version : subject : from : to : cc : references : in-reply-to : content-type : content-transfer-encoding; s=pp1; bh=MGbbZNP/mdzm3S/5Ztp69aF9Y4qswVAtQclS9ietJKA=; b=BDy1w+uFOknc7t5DYyGqJGcHUTt6dv3FKCK/HR3bGpWQrSCuZ8jKax3vcPrMruTzgHmy acAzgCUG97l4NIjYh9M1Bh+oErIOOL+sA96962qwVqEfEaK9vHFqZ5AfwQxn33dQXl/w 0WkKJLEa0XwSPG9Io+U0x6hN5B+c+9zil1adB8w5dnDTdnu6TBd1ca/2rQuEdP5VaqLT M8rgKTqAEeY/5GapWj9HtEvI6fsfThbauiDb7ttsb/j5xKoFmL8eulBokAaqEHIa3sz/ wu5hvlpjRYWrgdkjTxzztOt8RJA776v0cqy6L53LinzHQWIzkPwTO//en9Etyag87oXe dA== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u7302rvg6-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Nov 2023 16:04:00 +0000 Received: from m0353724.ppops.net (m0353724.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 3A6FeiEY020142; Mon, 6 Nov 2023 16:03:53 GMT Received: from ppma12.dal12v.mail.ibm.com (dc.9e.1632.ip4.static.sl-reverse.com [50.22.158.220]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3u7302rvax-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Nov 2023 16:03:53 +0000 Received: from pps.filterd (ppma12.dal12v.mail.ibm.com [127.0.0.1]) by ppma12.dal12v.mail.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 3A6FZvQk012848; Mon, 6 Nov 2023 16:03:41 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma12.dal12v.mail.ibm.com (PPS) with ESMTPS id 3u609sjpge-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 06 Nov 2023 16:03:41 +0000 Received: from smtpav05.wdc07v.mail.ibm.com (smtpav05.wdc07v.mail.ibm.com [10.39.53.232]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 3A6G3e2615008032 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 6 Nov 2023 16:03:41 GMT Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D48A158063; Mon, 6 Nov 2023 16:03:40 +0000 (GMT) Received: from smtpav05.wdc07v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CB9EC58053; Mon, 6 Nov 2023 16:03:39 +0000 (GMT) Received: from [9.61.121.140] (unknown [9.61.121.140]) by smtpav05.wdc07v.mail.ibm.com (Postfix) with ESMTP; Mon, 6 Nov 2023 16:03:39 +0000 (GMT) Message-ID: Date: Mon, 6 Nov 2023 11:03:39 -0500 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH] s390/vfio-ap: fix sysfs status attribute for AP queue devices Content-Language: en-US From: Tony Krowiak To: linux-s390@vger.kernel.org, linux-kernel@vger.kernel.org, kvm@vger.kernel.org Cc: jjherne@linux.ibm.com, pasic@linux.ibm.com, borntraeger@linux.ibm.com, frankja@linux.ibm.com, imbrenda@linux.ibm.com, david@redhat.com, stable@vger.kernel.org References: <20231020204838.409521-1-akrowiak@linux.ibm.com> Organization: IBM In-Reply-To: <20231020204838.409521-1-akrowiak@linux.ibm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: dsx9XxmwV9OrZfFiJB7AK9_H2MfZQJl8 X-Proofpoint-GUID: v-z6IauqZ0fi2RxW9WwV0zFaK3ZLHkdN X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.987,Hydra:6.0.619,FMLib:17.11.176.26 definitions=2023-11-06_12,2023-11-02_03,2023-05-22_02 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 impostorscore=0 suspectscore=0 mlxscore=0 bulkscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 mlxlogscore=999 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2310240000 definitions=main-2311060129 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Mon, 06 Nov 2023 08:04:17 -0800 (PST) PING This patch is pretty straight forward, does anyone see a reason why this shouldn't be integrated? On 10/20/23 16:48, Tony Krowiak wrote: > The 'status' attribute for AP queue devices bound to the vfio_ap device > driver displays incorrect status when the mediated device is attached to a > guest, but the queue device is not passed through. In the current > implementation, the status displayed is 'in_use' which is not correct; it > should be 'assigned'. This can happen if one of the queue devices > associated with a given adapter is not bound to the vfio_ap device driver. > For example: > > Queues listed in /sys/bus/ap/drivers/vfio_ap: > 14.0005 > 14.0006 > 14.000d > 16.0006 > 16.000d > > Queues listed in /sys/devices/vfio_ap/matrix/$UUID/matrix > 14.0005 > 14.0006 > 14.000d > 16.0005 > 16.0006 > 16.000d > > Queues listed in /sys/devices/vfio_ap/matrix/$UUID/guest_matrix > 14.0005 > 14.0006 > 14.000d > > The reason no queues for adapter 0x16 are listed in the guest_matrix is > because queue 16.0005 is not bound to the vfio_ap device driver, so no > queue associated with the adapter is passed through to the guest; > therefore, each queue device for adapter 0x16 should display 'assigned' > instead of 'in_use', because those queues are not in use by a guest, but > only assigned to the mediated device. > > Let's check the AP configuration for the guest to determine whether a > queue device is passed through before displaying a status of 'in_use'. > > Signed-off-by: Tony Krowiak > Fixes: f139862b92cf ("s390/vfio-ap: add status attribute to AP queue device's sysfs dir") > Cc: stable@vger.kernel.org > --- > drivers/s390/crypto/vfio_ap_ops.c | 7 ++++++- > 1 file changed, 6 insertions(+), 1 deletion(-) > > diff --git a/drivers/s390/crypto/vfio_ap_ops.c b/drivers/s390/crypto/vfio_ap_ops.c > index 4db538a55192..871c14a6921f 100644 > --- a/drivers/s390/crypto/vfio_ap_ops.c > +++ b/drivers/s390/crypto/vfio_ap_ops.c > @@ -1976,6 +1976,7 @@ static ssize_t status_show(struct device *dev, > { > ssize_t nchars = 0; > struct vfio_ap_queue *q; > + unsigned long apid, apqi; > struct ap_matrix_mdev *matrix_mdev; > struct ap_device *apdev = to_ap_dev(dev); > > @@ -1984,7 +1985,11 @@ static ssize_t status_show(struct device *dev, > matrix_mdev = vfio_ap_mdev_for_queue(q); > > if (matrix_mdev) { > - if (matrix_mdev->kvm) > + apid = AP_QID_CARD(q->apqn); > + apqi = AP_QID_QUEUE(q->apqn); > + if (matrix_mdev->kvm && > + test_bit_inv(apid, matrix_mdev->shadow_apcb.apm) && > + test_bit_inv(apqi, matrix_mdev->shadow_apcb.aqm)) > nchars = scnprintf(buf, PAGE_SIZE, "%s\n", > AP_QUEUE_IN_USE); > else