From nobody Fri Sep 25 15:13:48 2026 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 DDA643C4B8E; Fri, 25 Sep 2026 04:48:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311710; cv=none; b=Usix2wEYL3BlRt2iRf2NUZ1cDt96wcHrBzbWJSMn4zbYzzo+/RDF9yaLwYOZYtf+icflWKmptbxkNFJlw1Gc1dg32pKzkVmeqoFC++Kz32y++DGWtBbLhiRIpb45xNGsc+6UGlXB/ldYor+AveWQXYU/zaZ5GLiimG1KEkmXFn0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311710; c=relaxed/simple; bh=uyvnMpQAHJaBQ6DkGdidSoyZQ2PA/9DGwRg0DwZSma8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=l+lCK2FN7Np2+8iwDGHX0ohn1j9ZL72onYVKzUASw46BNLkyLmnTAnYhZnbILQKCiXg4p2ednTnPnAV0MUWbgvOYCH02EZPe2TtzJNx1/g03RO/d528RYqRk4bTEdMlI5tAzFvSXgXZJH/MDl9fcIqZLE/khYYc/yJBQY1INcxo= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=hIVmE1VC; arc=none smtp.client-ip=148.163.156.1 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="hIVmE1VC" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4aKdV061566; Fri, 25 Sep 2026 04:48:23 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=7LHvZ+fwN6je3uxuu 7gw0xpGsCqTv27Dq/zDhA/7oFo=; b=hIVmE1VCCyYM2Iggt+Xwce6I5MML/tMcZ 9v3T53w+dCYorPlg+PTs8RwASr48Bx0YwPi4aKFUFSYzR+vnx+THonq+kOdq8RiH asO5VjDhYMdxuwoBfuSL9S3sZqh7nLFQScxCetH3LPZpHz7nHikgzDGZ/RIvumaM 8SyPNSwjuCSHnIVzgBhP6MVB5mU752RA0pEsLKj/9Qbivlxw+BuIgtUEYZA3cTLK U6OWwl47lh+qzCvI6KldGrftE6XKVjUGPgGOMDswEvkXzen2eae+ydQILf0q4YtN hWOECk2i8rmPvpJ2oTlTwy4PjcPIUncfZSSmk+QLbN9oOTCnNDTUg== 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 4gskgsn45e-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:23 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4lXlC3244919; Fri, 25 Sep 2026 04:48:22 GMT Received: from smtprelay06.dal12v.mail.ibm.com ([172.16.1.8]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gvbu90xq0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:22 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay06.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68P4mLWg25297484 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Sep 2026 04:48:21 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 00C2C58051; Fri, 25 Sep 2026 04:48:21 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0AAA45805A; Fri, 25 Sep 2026 04:48:20 +0000 (GMT) Received: from li-4c4c4544-0054-3910-8039-c3c04f423534.ibm.com.com (unknown [9.61.142.241]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 25 Sep 2026 04:48:19 +0000 (GMT) From: Tyrel Datwyler To: james.bottomley@hansenpartnership.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, brking@linux.ibm.com, davemarq@linux.ibm.com, Tyrel Datwyler Subject: [PATCH v11 01/11] scsi: ibmvfc: fix IRQ leak and guard deregister on channel reg failure Date: Thu, 24 Sep 2026 21:48:50 -0700 Message-ID: <20260925044900.414340-2-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260925044900.414340-1-tyreld@linux.ibm.com> References: <20260925044900.414340-1-tyreld@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: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=V/XoQuni c=1 sm=1 tr=0 ts=6ab5fd17 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=acainBHvso6FeXtkDgYA:9 X-Proofpoint-ORIG-GUID: Ve6OsW7uUbWBUmRZB8EQ4whU-6oHGzyJ X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX7RRWCHuJKhv+ XalXzbjwtlx3swoFPFM8lj/XcYFwj1YyZ9mJREZkrLzkXo0unZ844VfL/trr5i0p2Mnn+u1sdIm hxp4FkbqdbMIYHhtPqxyQWSz8AVZZs7yTejDbait82LeaPhVbXuhGfUqIPICVmoFeykxI3Mcov8 MtTVoCGDF8WFvlVyufhrylXZd0kUd6RbX3RdXwd3On73IafKcpjUQG2yOx/kQvk587nSHTZz+KJ jfEMeRjZ3H/TzK3uD/Ndk+Wz0v/ADNE3hVfJQpfin3mQPtwBbDL+tHibohvhX3zVHNMgWs3XpNl Am7wfzp7zrVxseVGzMiC/lvCtFUyHdHkq1NgGgm/BsRiXPHxvPE8ETWQrpAVvpks//vXliqnscI /XsdgV1YFoB2qhRu1wOQDRcw7wMafvIF8c26hOm0JM7gSBcArKAHuxm49XgG1XdWCy3Vu7/pFhX hS+JHjfGZnvZo4yD5EQ== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX+kR0OcNrxatm 0PwzbWd/IkfXbRA8j3I1mvwB8Rth2LF1FQ259I8GUKMq0XzB7qOi7M+LJA1uz0eqxjkEu1sA9il 6ZRYNfIlVoepzE7mfn2Q90nJLnCzmLE= X-Proofpoint-GUID: Ve6OsW7uUbWBUmRZB8EQ4whU-6oHGzyJ X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-25_02,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609250018 Content-Type: text/plain; charset="utf-8" From: Dave Marquardt If request_irq() fails during ibmvfc_register_channel(), the error path disposes of the IRQ mapping via irq_dispose_mapping() but leaves scrq->irq populated with the stale virq number. A subsequent call to ibmvfc_deregister_channel() during teardown or reset cleanup then unconditionally invokes free_irq() and irq_dispose_mapping() on the stale IRQ descriptor, triggering kernel warnings. Fix this by: 1. Explicitly setting scrq->irq to 0 after irq_dispose_mapping() in the ibmvfc_register_channel() error path. 2. Guarding free_irq() and irq_dispose_mapping() with a check for scrq->irq in ibmvfc_deregister_channel() so unmapped or unregistered queues are safely skipped. Signed-off-by: Dave Marquardt Acked-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc-core.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ib= mvfc-core.c index 3534ac45e9b8..c4dc48ef1ec8 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c @@ -6436,6 +6436,7 @@ static int ibmvfc_register_channel(struct ibmvfc_host= *vhost, if (rc) { dev_err(dev, "Couldn't register sub-crq[%d] irq\n", index); irq_dispose_mapping(scrq->irq); + scrq->irq =3D 0; goto irq_failed; } =20 @@ -6464,9 +6465,11 @@ static void ibmvfc_deregister_channel(struct ibmvfc_= host *vhost, =20 ENTER; =20 - free_irq(scrq->irq, scrq); - irq_dispose_mapping(scrq->irq); - scrq->irq =3D 0; + if (scrq->irq) { + free_irq(scrq->irq, scrq); + irq_dispose_mapping(scrq->irq); + scrq->irq =3D 0; + } =20 do { rc =3D plpar_hcall_norets(H_FREE_SUB_CRQ, vdev->unit_address, --=20 2.55.0 From nobody Fri Sep 25 15:13:48 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 7F25C3C76A0; Fri, 25 Sep 2026 04:48:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311713; cv=none; b=DFlyj2HM0FF4IiczTuJpuJCr/uNe06KHTnAUYox2g3G0jEiVFoCKfn6OyQn3iQBqhFZjfBZMt/behXFVr8l3U/xeq//ilWvKtx8VnF7M4ZYwvt0fg1qr3ECjx84v0rEYxuPe4zdTyD+ge6TRwS/cXDI8fKoA/0ypE3hptiaYdHI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311713; c=relaxed/simple; bh=V0dX9CB+nTtB3omTikvKzQWBtwYrL8TDG5ypN7LuzgY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=TUACTAwAxI01ugXjI/zeq2nUbU3dSr+0FwF6XT1CAPXOh3oHXRuVOqm3FghDA30E8tLptAvPqgmhkhL0p6BIXVIGk0iU8bvEvs73kP5aJnUStI4RzAyC3wLXNH+SCxe/G11O0rLWYsNhf31u2hW6ZKcxTjWoDJBeX5Lx6bYC4lU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=jzFMXd84; arc=none smtp.client-ip=148.163.158.5 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="jzFMXd84" Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4aZbE3084274; Fri, 25 Sep 2026 04:48:24 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=fR0+7jE6kMlV3eplY tArXSLtg09Ia45aSRhA6aj8evI=; b=jzFMXd84kVhSrogi0kzXSJu1rVfmYKkf7 fuqJ5PFvJjNhRUFbtaRLHXeuJaSpv3jshYga45GyBDsEIdXJKmiIow5o9WAm8LZc onMTMxhnd1Y2JAaOFQ4yuCr8dYfCFGkJVnrko27BnrmkM7NmbBzTtN0Uq4bkDREN /5UBFUNJODCPRkr3TZSoOvCdh8p1YB8vzyjRlFoT2Tc5VEKzqcNPG1RFJ7IM1veb WewHUY5c/moZYVzd0LEuAm7VP7fsUxa1ylDFAIso+WODaKGlwRqU1HlNPadnftrF kJEWnXVb6akqcMQvbT2gxQ/I2/U8hbXlVUmPIR4l7g11oKsqnO4iA== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4gskgqv81u-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:23 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4lYHl3288207; Fri, 25 Sep 2026 04:48:23 GMT Received: from smtprelay07.dal12v.mail.ibm.com ([172.16.1.9]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gvbe2125p-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:23 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay07.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68P4mMBs29295284 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Sep 2026 04:48:22 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3251D5805C; Fri, 25 Sep 2026 04:48:22 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 28F7A58051; Fri, 25 Sep 2026 04:48:21 +0000 (GMT) Received: from li-4c4c4544-0054-3910-8039-c3c04f423534.ibm.com.com (unknown [9.61.142.241]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 25 Sep 2026 04:48:21 +0000 (GMT) From: Tyrel Datwyler To: james.bottomley@hansenpartnership.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, brking@linux.ibm.com, davemarq@linux.ibm.com, Tyrel Datwyler Subject: [PATCH v11 02/11] scsi: ibmvfc: fix potential clobbering of rc after failed irq setup Date: Thu, 24 Sep 2026 21:48:51 -0700 Message-ID: <20260925044900.414340-3-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260925044900.414340-1-tyreld@linux.ibm.com> References: <20260925044900.414340-1-tyreld@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: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=G+OJgNk5 c=1 sm=1 tr=0 ts=6ab5fd17 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=V8glGbnc2Ofi9Qvn3v5h:22 a=VnNF1IyMAAAA:8 a=MVjHE8Z1wCOhovhPjBEA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfXwWVI9nSgrV3R ybKAy0VJX/jcdDMloxn+215SzgeBXO8KlYWcV9xxranCeZEIuaQfX3ShUstdSnGRmxHFt/jJfJ+ 5cUGO6F3Bidph7JfaViqmSwLHGdENXAsVYw9R0qldCHjAmdOTPRQBtp8TwfJwQRBxT6kEqe1qRn 8jy3aEW12OnE8Zdrkti1S5Kys1/qB0MGWlWu+o1E78GY0FjdzJNGLhFuggGRraJ2AC0y/F05wmh nOOOm4PziIcr8xEjVtCg8T0rfk9Vc4Q531tJtUT3gNJou8s59vo/MuKV3KzWBlHk+OuHKLlCRKh Fs5Fdf+Stt+eleKo63XACnYL3xz2rvVzgsGbAQJO7u0jMbv/udyvaJG2goFB4ma6YSaT7c+t3P9 HRhTmq+buq/+/24x/BNbQKd74WyQyxJdwmWHf+OqAJYL21onPWPvqKxmQjlWcgKbj72yD+Qn1Tg GQ9ZDbkk3Oih3k07ZMQ== X-Proofpoint-ORIG-GUID: LVSMEdt15z1Tlt6eAMsZnh3JHMy4uIId X-Proofpoint-GUID: LVSMEdt15z1Tlt6eAMsZnh3JHMy4uIId X-Proofpoint-Spam-Info: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX0fUEWCiLILzj dMZBfoY1FxjuZrwZKCjvkyuUwgyHbPDaJjSOAY1CQA7rvkePz2+59uks+cRD93/6WrOgl2fubqK 5yWQypd2mcUSp0p/BHIEEPcD7gVGYEo= X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-25_02,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 phishscore=0 lowpriorityscore=0 impostorscore=0 bulkscore=0 priorityscore=1501 clxscore=1015 spamscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609250018 Content-Type: text/plain; charset="utf-8" Fix a variable-shadowing bug in ibmvfc_register_channel() where the irq_failed cleanup loop reused rc for the H_FREE_SUB_CRQ hcall result, clobbering the error code returned to the caller. Introduce hcall_rc for the cleanup loop instead. Signed-off-by: Dave Marquardt Signed-off-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc-core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ib= mvfc-core.c index c4dc48ef1ec8..17c49a0ed4f4 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c @@ -6392,6 +6392,7 @@ static int ibmvfc_register_channel(struct ibmvfc_host= *vhost, struct vio_dev *vdev =3D to_vio_dev(dev); struct ibmvfc_queue *scrq =3D &channels->scrqs[index]; int rc =3D -ENOMEM; + int hcall_rc; =20 ENTER; =20 @@ -6447,8 +6448,8 @@ static int ibmvfc_register_channel(struct ibmvfc_host= *vhost, =20 irq_failed: do { - rc =3D plpar_hcall_norets(H_FREE_SUB_CRQ, vdev->unit_address, scrq->cook= ie); - } while (rc =3D=3D H_BUSY || H_IS_LONG_BUSY(rc)); + hcall_rc =3D plpar_hcall_norets(H_FREE_SUB_CRQ, vdev->unit_address, scrq= ->cookie); + } while (hcall_rc =3D=3D H_BUSY || H_IS_LONG_BUSY(hcall_rc)); reg_failed: LEAVE; return rc; --=20 2.55.0 From nobody Fri Sep 25 15:13:48 2026 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 CFA2A3C5837; Fri, 25 Sep 2026 04:48:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311714; cv=none; b=sGMDtwEVDE44rv7zzvg9j8YKrNxF6A9FO7hJ1xaPaW2nswPXetW9fEj6vg4S+0GKDtFRDDGUeRLhGR3AyabwyUsqyB/O4FVSifvuv8OyHyMNacrsx/Yr8//5lMsC0vziSCF9wK/0zQdYE0MX/k2oijgFemW4vxw2DI0G2KNgQUs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311714; c=relaxed/simple; bh=VPhYZdCBB4vGTu5HP5U8xHbbo03j2Yw11Gza8lYJink=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Nda3HO2tyqk68FLGiaSGcf4V9Hqt1HZgzNWWNGf7GNyiwwzmrAyccLRFoxeApTHwIaBChAwuhDqhhA8crRX2arFmtEr1y6Prk8CJPA9QlOjFaa8tifzRnrGJXOVjhBf9fqoTW2Xy1qYsnQZvP2oU8dNrRy6ObGOIlbDvUQQlsRw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=PYX4IPIo; arc=none smtp.client-ip=148.163.156.1 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="PYX4IPIo" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4b8QJ076615; Fri, 25 Sep 2026 04:48:25 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=VGliTUt2VZf0S+j9D 1+NV5t5iw5NLYoH1kkUDfqGUPM=; b=PYX4IPIoWdgtiQr0R+bHp+6GNSFqaXEl9 CRgncpXqS8hzkzrCKBCZfF5H9upzpriUM05hsAm3fIjQS8V0+Ksmgc8/aqCWgbza SNehaf0O37jGQg4win0ELcyW/74isM4PHFx371TAEgTaWWzIrrDxd7jh1SZ62WaF jf2HUobz6DYPdgSSN6k3BYgqOEOYS1aYc26UlS77xGJGVsXRt0difr0Vml1P8paw Qs7YfWN3y1cDPaEGw+cd9Pcm5XVtoeusP4jAkfSBeVPgB7uO9l3v+EPvSLx2JMjd xE50Lga4s6aTBlSpNaszbH9yBr8k7bizFzH/2c/rbXJV4bhOleRvQ== 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 4gskg2w990-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:25 +0000 (GMT) Received: from pps.filterd (ppma22.wdc07v.mail.ibm.com [127.0.0.1]) by ppma22.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4la8Z3244947; Fri, 25 Sep 2026 04:48:24 GMT Received: from smtprelay01.wdc07v.mail.ibm.com ([172.16.1.68]) by ppma22.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gvbu90xq2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:24 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay01.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68P4mNhQ36766018 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Sep 2026 04:48:23 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3D55F5805A; Fri, 25 Sep 2026 04:48:23 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5A0C45805F; Fri, 25 Sep 2026 04:48:22 +0000 (GMT) Received: from li-4c4c4544-0054-3910-8039-c3c04f423534.ibm.com.com (unknown [9.61.142.241]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 25 Sep 2026 04:48:22 +0000 (GMT) From: Tyrel Datwyler To: james.bottomley@hansenpartnership.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, brking@linux.ibm.com, davemarq@linux.ibm.com, Tyrel Datwyler Subject: [PATCH v11 03/11] scsi: ibmvfc: fix potential NULL pointer dereference on failed queue allocation Date: Thu, 24 Sep 2026 21:48:52 -0700 Message-ID: <20260925044900.414340-4-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260925044900.414340-1-tyreld@linux.ibm.com> References: <20260925044900.414340-1-tyreld@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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: AGuLjM2lwAWBFp4rINdpnm81ljR8xn07 X-Authority-Analysis: v=2.4 cv=I43w19gg c=1 sm=1 tr=0 ts=6ab5fd19 cx=c_pps a=5BHTudwdYE3Te8bg5FgnPg==:117 a=5BHTudwdYE3Te8bg5FgnPg==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=FYxBZ7uDKvT38RkufYwA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX2R7uihcWRROP rgubU3qBJBIWvmxMY4wbKbQgFuZvmOkwV28FoipmruAACYA6POAx2pHonUlZJPWwizoHb/W87X2 pxh0AjnbuPSegxP1NyTXheq4Sb3BiW4Jt5GeskuM5RAbGbTF5vDD44kFhFBFscXT8Zksk4gbNLj WJd3ynYUlufLTpq+CJO1wRvHVjrv96x7hgyOoiDPlB5CT5vyrs0TqbldjK9NkpQNW+kNK/2EDXE tfbFXs9BBhrC5eS8sC3nGgWPuJuzcjiavH2Sbe/Cn9p6I/THbDt3bRjo283ZdNulEC8ihYgHYYz oTo1vhwPSTeA0mHbGDStzGblP0R9fqEjsf43wrlCZl8JLSD2nl2E/vvnUN+aWRfVL1qwTh4ejgf W5zyz5HAd9q02RPe/2pL8eSrIlTQPd5mifziRr95jh6qrgtKynQBPg09pyvo4xUzsm4iNu+SBQS 6KYRBpi9GPKaER9RU7Q== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX4uNEkhv9Obf+ Dkl+z6okshNs3uXlGnEDwXEnQNL5rlsUBZNDvZIUZehBuJoAYw6WJh2rQoxZOlz1mPGRk/1IRDi 4iFsBH6KkkNFemfJygTXVQK4hXHkPx0= X-Proofpoint-GUID: AGuLjM2lwAWBFp4rINdpnm81ljR8xn07 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-25_02,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 adultscore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609250018 Content-Type: text/plain; charset="utf-8" Guard the memset() in ibmvfc_deregister_channel() behind a check of scrq->msgs.handle to prevent a NULL dereference when the function is called on a queue that was never allocated, such as async_sub_crq when multi-queue is disabled or initialization failed before ibmvfc_alloc_queue() was reached. Signed-off-by: Dave Marquardt Signed-off-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc-core.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ib= mvfc-core.c index 17c49a0ed4f4..ef76f8c194eb 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c @@ -6481,8 +6481,10 @@ static void ibmvfc_deregister_channel(struct ibmvfc_= host *vhost, dev_err(dev, "Failed to free sub-crq[%d]: rc=3D%ld\n", index, rc); =20 /* Clean out the queue */ - memset(scrq->msgs.crq, 0, PAGE_SIZE); - scrq->cur =3D 0; + if (scrq->msgs.handle) { + memset(scrq->msgs.crq, 0, PAGE_SIZE); + scrq->cur =3D 0; + } =20 LEAVE; } --=20 2.55.0 From nobody Fri Sep 25 15:13:48 2026 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 5E7963C5DC3; Fri, 25 Sep 2026 04:48:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311719; cv=none; b=mUCNdTccl8wgXOSQGmAaSlwg1N8ywR9fdGB/8xpRr1+fw8tVxR0rhJbKNTzhOI1O3GvJqg2lMzTHuoJfcBAL5slOvN02FRoowMoMeH6VnI7I44i9jFCohThLg3yH0DWl4u9wbZiYG9LeH5Rl3OPjQ/m1tPYlntPq8cZDb1kp1sY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311719; c=relaxed/simple; bh=COtYuS8eeek19EUYT3kAmf3Ykh4VUQjm0eVQebD4JTQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=N1vkdHeCldyNH/J05E99dRqQQxG9fmDCDs3MtXos8cW75F3OURDpMNoYR87BJiVByt4AZN4JaueChyLG8MFYRbelTqasMJ1UT/1YKMt4NA0L7aHQMLEmstQ/69Mj7PMeyPbt2p0hfDkVRmJDibcucryhSq+c7tvNENhZGzkA4NU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=szDqA4ds; arc=none smtp.client-ip=148.163.156.1 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="szDqA4ds" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4a4qT061049; Fri, 25 Sep 2026 04:48:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=5cgkTWGEm8v59Yg6t BWvZe5JCgKXu17LilWfJq0+s0Y=; b=szDqA4dsHCm80CzWuxOdp9gBRaQZXKLLT hceITfG8QcDhizMRzguLPknZMWKMqliox1QMPTmJfpECObMJfDPTipXNL113qrLb j5iqP/pIEjAqEbLvt97+aFA/bKoEFrr7sB8BPrwiClqDzPuNIr/4BNp69FOeiWet ShPSfYE8dmQG9NVrK4MTPpvnqrybQ9BkoCPHH/fedWVBo2Ljn2fZ6jvzC/GCT/de NZjUxK867BDtUju6n540NsXtqOspYZ6emAUC6pqqV6ddcE95yf5hJ9ibpOLP7V7c 5QHUByNgu9aZ/j5siOnEcXAYUndFLdg18ZbqwHVM1nvCIuzjqXkvQ== 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 4gskgsn45k-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:26 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4liaB3248950; Fri, 25 Sep 2026 04:48:26 GMT Received: from smtprelay02.wdc07v.mail.ibm.com ([172.16.1.69]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gvbt30y1v-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:26 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay02.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68P4mOGS15991536 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Sep 2026 04:48:24 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 63E3D5805A; Fri, 25 Sep 2026 04:48:24 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6776E5805C; Fri, 25 Sep 2026 04:48:23 +0000 (GMT) Received: from li-4c4c4544-0054-3910-8039-c3c04f423534.ibm.com.com (unknown [9.61.142.241]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 25 Sep 2026 04:48:23 +0000 (GMT) From: Tyrel Datwyler To: james.bottomley@hansenpartnership.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, brking@linux.ibm.com, davemarq@linux.ibm.com, Tyrel Datwyler Subject: [PATCH v11 04/11] scsi: ibmvfc: add basic FPIN support Date: Thu, 24 Sep 2026 21:48:53 -0700 Message-ID: <20260925044900.414340-5-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260925044900.414340-1-tyreld@linux.ibm.com> References: <20260925044900.414340-1-tyreld@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: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=V/XoQuni c=1 sm=1 tr=0 ts=6ab5fd1b cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=spueyG-pivhLj-E1BzsA:9 X-Proofpoint-ORIG-GUID: 5OYHUA2ctLyLkQV4rQ5Cz-JDy7S1BMnB X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX+CMGHlWo3tpL 6SeftVrc1Alo4I0gS6/ZuN6D3/JzZhNucM/sggnsnGMhtwnYIw3SDjRPddpx4GD3oE3/QFJy5fQ +CjKRbwvGDyCf7aghjGuBt4cc/VmceD9A74BYCPQe28zlSMA9ELms/Lr+RQ/S4UpaNwZcbFYRTt cH3MwDmsWy4IKMqb9ZIbqNOyk7HVuFAPjPkMBEAqq3ijeroYnSJqiKQepR4slN8z9EVrx8zOEKM Os6slk6L6wPeR96qHIRMze9bSEKH+5/S1kxFu1X+v7KrmimMz62B9Ny4SQ/G8Xe6gjqFazDeLPh ZKPAVmdam2K/JKM+39sYDsNqFFSIUediQ9m+tzrVnOtFYpnl7VZfe8vOKy0yl8VIeb/Ml8ZJZCf Zfekd0nBuXc0vRGc5yGtwdiEAJd+6gykPusDIp1QIPHkUTN/BlodFsryGw+0RWkFci+ZwHYQRQJ 2z07it0TFKraSfvaWxA== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX8IFULyojR2dF t4eVQFEmy+m20hmkzWODriXElXk1CIQHMCet4lAS8mDktq7vFkLMdrxSuQfbNKhhZAEE0k7R5YH QHQXaupb4kCUtZ1mf6JUkGekr2qE6NM= X-Proofpoint-GUID: 5OYHUA2ctLyLkQV4rQ5Cz-JDy7S1BMnB X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-25_02,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609250018 Content-Type: text/plain; charset="utf-8" From: Dave Marquardt Implement support for a basic level of Fabric Performance Impact Notifications (FPIN) in the ibmvfc driver to enable monitoring of fabric congestion and link integrity events. Add async event handler for IBMVFC_AE_FPIN events that offloads FPIN processing to a dedicated workqueue. Convert VIOS FPIN messages to standard fc_els_fpin structures and pass them to fc_host_fpin_rcv() for processing by the FC transport layer. Introduce common FPIN conversion routines that will be reused for full and extended FPIN support in subsequent patches. Add KUnit test infrastructure to validate FPIN event handling and statistics updates. Add ibmvfc_handle_async() support for IBMVFC_AE_FPIN events, a dedicated workqueue for FPIN processing, FPIN message conversion to fc_els_fpin format, handling of link congestion, port congestion, port cleared, port degraded, and congestion cleared events, and a KUnit test module for FPIN functionality. Signed-off-by: Dave Marquardt Signed-off-by: Tyrel Datwyler --- drivers/scsi/Kconfig | 10 + drivers/scsi/ibmvscsi/Makefile | 1 + drivers/scsi/ibmvscsi/ibmvfc-core.c | 295 ++++++++++++++++++++++++++- drivers/scsi/ibmvscsi/ibmvfc.h | 17 ++ drivers/scsi/ibmvscsi/ibmvfc_kunit.c | 149 ++++++++++++++ 5 files changed, 469 insertions(+), 3 deletions(-) create mode 100644 drivers/scsi/ibmvscsi/ibmvfc_kunit.c diff --git a/drivers/scsi/Kconfig b/drivers/scsi/Kconfig index 1eec66195cf4..320c37c4ab36 100644 --- a/drivers/scsi/Kconfig +++ b/drivers/scsi/Kconfig @@ -760,6 +760,16 @@ config SCSI_IBMVFC To compile this driver as a module, choose M here: the module will be called ibmvfc. =20 +config SCSI_IBMVFC_KUNIT_TEST + tristate "KUnit tests for the IBM POWER Virtual FC Client" if !KUNIT_ALL_= TESTS + depends on SCSI_IBMVFC && KUNIT + default KUNIT_ALL_TESTS + help + Compile IBM POWER Virtual FC client KUnit tests. These tests + specifically test FPIN functionality. To compile this driver + as a module, choose M here: the module will be called + ibmvfc_kunit. + config SCSI_IBMVFC_TRACE bool "enable driver internal trace" depends on SCSI_IBMVFC diff --git a/drivers/scsi/ibmvscsi/Makefile b/drivers/scsi/ibmvscsi/Makefile index 9408c7f4cdee..a227bc633f3a 100644 --- a/drivers/scsi/ibmvscsi/Makefile +++ b/drivers/scsi/ibmvscsi/Makefile @@ -3,3 +3,4 @@ ibmvfc-objs :=3D ibmvfc-core.o ibmvfc-nvme.o =20 obj-$(CONFIG_SCSI_IBMVSCSI) +=3D ibmvscsi.o obj-$(CONFIG_SCSI_IBMVFC) +=3D ibmvfc.o +obj-$(CONFIG_SCSI_IBMVFC_KUNIT_TEST) +=3D ibmvfc_kunit.o diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ib= mvfc-core.c index ef76f8c194eb..5966f2fd3fc2 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c @@ -31,6 +31,9 @@ #include #include #include +#include +#include +#include #include "ibmvfc.h" =20 static unsigned int init_timeout =3D IBMVFC_INIT_TIMEOUT; @@ -1433,6 +1436,7 @@ void ibmvfc_release_tgt(struct kref *kref) struct ibmvfc_target *tgt =3D container_of(kref, struct ibmvfc_target, kr= ef); mempool_free(tgt, tgt->vhost->tgt_pool); } +EXPORT_SYMBOL_IF_KUNIT(ibmvfc_release_tgt); =20 /** * ibmvfc_get_starget_node_name - Get SCSI target's node name @@ -3213,6 +3217,7 @@ static const struct ibmvfc_async_desc ae_desc [] =3D { { "Halt", IBMVFC_AE_HALT, IBMVFC_DEFAULT_LOG_LEVEL }, { "Resume", IBMVFC_AE_RESUME, IBMVFC_DEFAULT_LOG_LEVEL }, { "Adapter Failed", IBMVFC_AE_ADAPTER_FAILED, IBMVFC_DEFAULT_LOG_LEVEL }, + { "FPIN", IBMVFC_AE_FPIN, IBMVFC_DEFAULT_LOG_LEVEL }, }; =20 static const struct ibmvfc_async_desc unknown_ae =3D { @@ -3261,16 +3266,259 @@ static const char *ibmvfc_get_link_state(enum ibmv= fc_ae_link_state state) return ""; } =20 +#define IBMVFC_FPIN_CONGN_DESC_SZ (sizeof(struct fc_els_fpin) + sizeof(str= uct fc_fn_congn_desc)) +#define IBMVFC_FPIN_LI_DESC_SZ (sizeof(struct fc_els_fpin) + \ + struct_size_t(struct fc_fn_li_desc, pname_list, 1)) +#define IBMVFC_FPIN_PEER_CONGN_DESC_SZ (sizeof(struct fc_els_fpin) + \ + struct_size_t(struct fc_fn_peer_congn_desc, pname_list, 1)) + +/** + * ibmvfc_fpin_size_helper(): compute fpin structure size based on fpin st= atus + * @fpin_status: status value + * + * Return: + * 0: invalid fpin_status + * other: valid size + */ +static size_t ibmvfc_fpin_size_helper(u8 fpin_status) +{ + size_t size =3D 0; + + switch (fpin_status) { + case IBMVFC_AE_FPIN_LINK_CONGESTED: + case IBMVFC_AE_FPIN_CONGESTION_CLEARED: + size =3D IBMVFC_FPIN_CONGN_DESC_SZ; + break; + case IBMVFC_AE_FPIN_PORT_CONGESTED: + case IBMVFC_AE_FPIN_PORT_CLEARED: + size =3D IBMVFC_FPIN_PEER_CONGN_DESC_SZ; + break; + case IBMVFC_AE_FPIN_PORT_DEGRADED: + size =3D IBMVFC_FPIN_LI_DESC_SZ; + break; + default: + break; + } + + return size; +} + +/** + * ibmvfc_common_fpin_to_desc(): allocate and populate a struct fc_els_fpi= n struct + * containing a descriptor. + * + * Allocate a struct fc_els_fpin containing a descriptor and populate + * based on data from *ibmvfc_fpin. + * + * Return: + * NULL - unable to allocate structure + * non-NULL - pointer to populated struct fc_els_fpin + */ +static struct fc_els_fpin * +ibmvfc_common_fpin_to_desc(u8 fpin_status, __be64 wwpn, __be16 type, __be1= 6 modifier, + __be32 threshold, __be32 event_count) +{ + struct fc_fn_peer_congn_desc *pdesc; + struct fc_fn_congn_desc *cdesc; + struct fc_fn_li_desc *ldesc; + struct fc_els_fpin *fpin; + size_t size; + + size =3D ibmvfc_fpin_size_helper(fpin_status); + if (!size) + return NULL; + + fpin =3D kzalloc(size, GFP_KERNEL); + if (!fpin) + return NULL; + + fpin->fpin_cmd =3D ELS_FPIN; + + switch (fpin_status) { + case IBMVFC_AE_FPIN_CONGESTION_CLEARED: + case IBMVFC_AE_FPIN_LINK_CONGESTED: + fpin->desc_len =3D cpu_to_be32(sizeof(struct fc_fn_congn_desc)); + cdesc =3D (struct fc_fn_congn_desc *)fpin->fpin_desc; + cdesc->desc_tag =3D cpu_to_be32(ELS_DTAG_CONGESTION); + cdesc->desc_len =3D cpu_to_be32(FC_TLV_DESC_LENGTH_FROM_SZ(*cdesc)); + cdesc->event_type =3D type; + cdesc->event_modifier =3D modifier; + cdesc->event_period =3D cpu_to_be32(IBMVFC_FPIN_DEFAULT_EVENT_PERIOD); + cdesc->severity =3D FPIN_CONGN_SEVERITY_WARNING; + break; + case IBMVFC_AE_FPIN_PORT_CONGESTED: + case IBMVFC_AE_FPIN_PORT_CLEARED: + fpin->desc_len =3D + cpu_to_be32(struct_size_t(struct fc_fn_peer_congn_desc, pname_list, 1)); + pdesc =3D (struct fc_fn_peer_congn_desc *)fpin->fpin_desc; + pdesc->desc_tag =3D cpu_to_be32(ELS_DTAG_PEER_CONGEST); + pdesc->desc_len =3D cpu_to_be32(struct_size_t(struct fc_fn_peer_congn_de= sc, + pname_list, 1) - FC_TLV_DESC_HDR_SZ); + pdesc->event_type =3D type; + pdesc->event_modifier =3D modifier; + pdesc->event_period =3D cpu_to_be32(IBMVFC_FPIN_DEFAULT_EVENT_PERIOD); + pdesc->attached_wwpn =3D wwpn; + pdesc->pname_count =3D cpu_to_be32(1); + pdesc->pname_list[0] =3D wwpn; + break; + case IBMVFC_AE_FPIN_PORT_DEGRADED: + fpin->desc_len =3D cpu_to_be32(struct_size_t(struct fc_fn_li_desc, pname= _list, 1)); + ldesc =3D (struct fc_fn_li_desc *)fpin->fpin_desc; + ldesc->desc_tag =3D cpu_to_be32(ELS_DTAG_LNK_INTEGRITY); + ldesc->desc_len =3D cpu_to_be32(struct_size_t(struct fc_fn_li_desc, + pname_list, 1) - FC_TLV_DESC_HDR_SZ); + ldesc->event_type =3D type; + ldesc->event_modifier =3D modifier; + ldesc->event_threshold =3D threshold; + ldesc->event_count =3D event_count; + ldesc->attached_wwpn =3D wwpn; + ldesc->pname_count =3D cpu_to_be32(1); + ldesc->pname_list[0] =3D wwpn; + break; + default: + /* This should be caught above. */ + kfree(fpin); + fpin =3D NULL; + break; + } + + return fpin; +} + +/** + * ibmvfc_basic_fpin_to_desc(): allocate and populate a struct fc_els_fpin= struct + * containing a descriptor. + * @ibmvfc_fpin: Pointer to async crq + * + * Allocate a struct fc_els_fpin containing a descriptor and populate + * based on data from *ibmvfc_fpin. + * + * Return: + * NULL - unable to allocate structure + * non-NULL - pointer to populated struct fc_els_fpin + */ +static struct fc_els_fpin * +ibmvfc_basic_fpin_to_desc(struct ibmvfc_async_crq *crq, u64 wwpn) +{ + __be16 type; + + switch (crq->fpin_status) { + case IBMVFC_AE_FPIN_LINK_CONGESTED: + case IBMVFC_AE_FPIN_PORT_CONGESTED: + type =3D cpu_to_be16(FPIN_CONGN_DEVICE_SPEC); + break; + case IBMVFC_AE_FPIN_PORT_CLEARED: + case IBMVFC_AE_FPIN_CONGESTION_CLEARED: + type =3D cpu_to_be16(FPIN_CONGN_CLEAR); + break; + case IBMVFC_AE_FPIN_PORT_DEGRADED: + type =3D cpu_to_be16(FPIN_LI_UNKNOWN); + break; + default: + return NULL; + } + + return ibmvfc_common_fpin_to_desc(crq->fpin_status, cpu_to_be64(wwpn), + type, cpu_to_be16(0), + cpu_to_be32(IBMVFC_FPIN_DEFAULT_EVENT_THRESHOLD), + cpu_to_be32(1)); +} + +/** + * ibmvfc_find_target - Search for a target in a target list + * @target_list: list head of targets to search + * @scsi_id: SCSI ID to match (0 to skip this check) + * @wwpn: WWPN to match (0 to skip this check) + * @node_name: Node name to match (0 to skip this check) + * + * Returns: + * Pointer to matching target, or NULL if not found + **/ +static struct ibmvfc_target *ibmvfc_find_target(struct list_head *target_l= ist, + __be64 scsi_id, __be64 wwpn, + __be64 node_name) +{ + struct ibmvfc_target *tgt; + + list_for_each_entry(tgt, target_list, queue) { + if (scsi_id && cpu_to_be64(tgt->scsi_id) !=3D scsi_id) + continue; + if (wwpn && cpu_to_be64(tgt->ids.port_name) !=3D wwpn) + continue; + if (node_name && cpu_to_be64(tgt->ids.node_name) !=3D node_name) + continue; + if (!tgt->rport && !tgt->nvme_remote_port) + continue; + return tgt; + } + + return NULL; +} + +/** + * ibmvfc_process_async_work - Process IBMVFC_AE_FPIN async CRQ from work = queue + * @work: pointer to work_struct + */ +static void ibmvfc_process_async_work(struct work_struct *work) +{ + struct ibmvfc_async_work *aw; + struct ibmvfc_async_crq *crq; + struct ibmvfc_target *tgt; + struct ibmvfc_host *vhost; + struct fc_els_fpin *fpin; + unsigned long flags; + + aw =3D container_of_const(work, struct ibmvfc_async_work, async_work_s); + vhost =3D aw->vhost; + crq =3D &aw->crq; + + if (!crq->scsi_id && !crq->wwpn && !crq->node_name) + goto free; + + spin_lock_irqsave(vhost->host->host_lock, flags); + tgt =3D ibmvfc_find_target(&vhost->scsi_scrqs.targets, crq->scsi_id, + crq->wwpn, crq->node_name); + if (!tgt) { + /* Target not found in scsi_scrqs, search nvme_scrqs */ + tgt =3D ibmvfc_find_target(&vhost->nvme_scrqs.targets, + crq->scsi_id, crq->wwpn, + crq->node_name); + } + + if (tgt) { + kref_get(&tgt->kref); + spin_unlock_irqrestore(vhost->host->host_lock, flags); + } else { + spin_unlock_irqrestore(vhost->host->host_lock, flags); + dev_err_ratelimited(vhost->dev, "Invalid target for FPIN\n"); + goto free; + } + + fpin =3D ibmvfc_basic_fpin_to_desc(crq, tgt->wwpn); + if (fpin) { + fc_host_fpin_rcv(tgt->vhost->host, + sizeof(*fpin) + be32_to_cpu(fpin->desc_len), + (char *)fpin, 0); + kfree(fpin); + } else + dev_err_ratelimited(vhost->dev, "FPIN event received, unable to process\= n"); + + kref_put(&tgt->kref, ibmvfc_release_tgt); + free: + kfree(aw); +} + /** * ibmvfc_handle_async - Handle an async event from the adapter * @crq: crq to process * @vhost: ibmvfc host struct * **/ -static void ibmvfc_handle_async(struct ibmvfc_async_crq *crq, - struct ibmvfc_host *vhost) +VISIBLE_IF_KUNIT void ibmvfc_handle_async(struct ibmvfc_async_crq *crq, + struct ibmvfc_host *vhost) { const struct ibmvfc_async_desc *desc =3D ibmvfc_get_ae_desc(be64_to_cpu(c= rq->event)); + struct ibmvfc_async_work *aw; struct ibmvfc_target *tgt; =20 ibmvfc_log(vhost, desc->log_level, "%s event received. scsi_id: %llx, wwp= n: %llx," @@ -3361,11 +3609,25 @@ static void ibmvfc_handle_async(struct ibmvfc_async= _crq *crq, case IBMVFC_AE_HALT: ibmvfc_link_down(vhost, IBMVFC_HALTED); break; + case IBMVFC_AE_FPIN: + if (vhost->state =3D=3D IBMVFC_HOST_OFFLINE) + break; + aw =3D kzalloc(sizeof(struct ibmvfc_async_work), GFP_ATOMIC); + if (aw) { + INIT_WORK(&aw->async_work_s, ibmvfc_process_async_work); + aw->vhost =3D vhost; + aw->crq =3D *crq; + queue_work(vhost->fpin_workq, &aw->async_work_s); + } else + dev_err_ratelimited(vhost->dev, + "can't offload async CRQ to work queue\n"); + break; default: dev_err(vhost->dev, "Unknown async event received: %lld\n", crq->event); break; } } +EXPORT_SYMBOL_IF_KUNIT(ibmvfc_handle_async); =20 /** * ibmvfc_handle_crq - Handles and frees received events in the CRQ @@ -6881,9 +7143,15 @@ static int ibmvfc_probe(struct vio_dev *vdev, const = struct vio_device_id *id) INIT_WORK(&vhost->rport_add_work_q, ibmvfc_rport_add_thread); mutex_init(&vhost->passthru_mutex); =20 - if ((rc =3D ibmvfc_alloc_mem(vhost))) + vhost->fpin_workq =3D alloc_workqueue("%s-fpin-workq-%u", WQ_UNBOUND, 1, + IBMVFC_NAME, shost->host_no); + if (vhost->fpin_workq =3D=3D NULL) goto free_scsi_host; =20 + rc =3D ibmvfc_alloc_mem(vhost); + if (rc) + goto free_workq; + vhost->work_thread =3D kthread_run(ibmvfc_work, vhost, "%s_%d", IBMVFC_NA= ME, shost->host_no); =20 @@ -6929,6 +7197,9 @@ static int ibmvfc_probe(struct vio_dev *vdev, const s= truct vio_device_id *id) kthread_stop(vhost->work_thread); free_host_mem: ibmvfc_free_mem(vhost); +free_workq: + destroy_workqueue(vhost->fpin_workq); + vhost->fpin_workq =3D NULL; free_scsi_host: scsi_host_put(shost); out: @@ -6959,6 +7230,8 @@ static void ibmvfc_remove(struct vio_dev *vdev) ibmvfc_wait_while_resetting(vhost); kthread_stop(vhost->work_thread); flush_work(&vhost->rport_add_work_q); + destroy_workqueue(vhost->fpin_workq); + vhost->fpin_workq =3D NULL; fc_remove_host(vhost->host); scsi_remove_host(vhost->host); =20 @@ -7121,5 +7394,21 @@ static void __exit ibmvfc_module_exit(void) fc_release_transport(ibmvfc_transport_template); } =20 +#if IS_ENABLED(CONFIG_KUNIT) +VISIBLE_IF_KUNIT struct ibmvfc_host *ibmvfc_get_first_vhost(void) +{ + struct ibmvfc_host *vhost =3D NULL; + + spin_lock(&ibmvfc_driver_lock); + if (!list_empty(&ibmvfc_head)) + vhost =3D list_first_entry(&ibmvfc_head, struct ibmvfc_host, queue); + if (vhost) + scsi_host_get(vhost->host); + spin_unlock(&ibmvfc_driver_lock); + return vhost; +} +EXPORT_SYMBOL_IF_KUNIT(ibmvfc_get_first_vhost); +#endif + module_init(ibmvfc_module_init); module_exit(ibmvfc_module_exit); diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h index ca80ceffe53a..d7a30e7a4a28 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.h +++ b/drivers/scsi/ibmvscsi/ibmvfc.h @@ -750,8 +750,12 @@ enum ibmvfc_ae_fpin_status { IBMVFC_AE_FPIN_PORT_CONGESTED =3D 0x2, IBMVFC_AE_FPIN_PORT_CLEARED =3D 0x3, IBMVFC_AE_FPIN_PORT_DEGRADED =3D 0x4, + IBMVFC_AE_FPIN_CONGESTION_CLEARED =3D 0x5, }; =20 +#define IBMVFC_FPIN_DEFAULT_EVENT_PERIOD (5*60*MSEC_PER_SEC) /* 5 minutes = */ +#define IBMVFC_FPIN_DEFAULT_EVENT_THRESHOLD (5*60*MSEC_PER_SEC/2) /* 2.5 m= inutes */ + struct ibmvfc_async_crq { volatile u8 valid; u8 link_state; @@ -781,6 +785,12 @@ struct ibmvfc_async_sub_crq { } id; } __packed __aligned(8); =20 +struct ibmvfc_async_work { + struct ibmvfc_host *vhost; + struct ibmvfc_async_crq crq; + struct work_struct async_work_s; +}; + union ibmvfc_iu { struct ibmvfc_mad_common mad_common; struct ibmvfc_npiv_login_mad npiv_login; @@ -1022,6 +1032,7 @@ struct ibmvfc_host { wait_queue_head_t work_wait_q; struct nvme_fc_local_port *nvme_local_port; struct completion nvme_delete_done; + struct workqueue_struct *fpin_workq; }; =20 struct ibmvfc_event *__ibmvfc_get_event(struct ibmvfc_queue *queue, int re= served); @@ -1088,4 +1099,10 @@ static inline struct ibmvfc_host *ibmvfc_channels_to= _vhost(struct ibmvfc_channel #define ibmvfc_remove_trace_file(kobj, attr) do { } while (0) #endif =20 +#if IS_ENABLED(CONFIG_KUNIT) +#include +VISIBLE_IF_KUNIT void ibmvfc_handle_async(struct ibmvfc_async_crq *crq, st= ruct ibmvfc_host *vhost); +VISIBLE_IF_KUNIT struct ibmvfc_host *ibmvfc_get_first_vhost(void); +#endif + #endif diff --git a/drivers/scsi/ibmvscsi/ibmvfc_kunit.c b/drivers/scsi/ibmvscsi/i= bmvfc_kunit.c new file mode 100644 index 000000000000..ec52285b0aa2 --- /dev/null +++ b/drivers/scsi/ibmvscsi/ibmvfc_kunit.c @@ -0,0 +1,149 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +#include +#include +#include +#include +#include +#include +#include +#include "ibmvfc.h" + +MODULE_IMPORT_NS("EXPORTED_FOR_KUNIT_TESTING"); + +/** + * ibmvfc_async_fpin_event_test - unit test for IBMVFC_AE_FPIN parts of + * ibmvfc_handle_async + * @test: pointer to kunit structure + * + * Tests + * - error returns from ibmvfc_handle_async + * - statistics updates + * + * Return: void + */ +static void ibmvfc_async_fpin_test(struct kunit *test) +{ + u64 post[IBMVFC_AE_FPIN_CONGESTION_CLEARED + 1]; + u64 pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED + 1]; + struct ibmvfc_async_crq ae[IBMVFC_AE_FPIN_CONGESTION_CLEARED + 1]; + enum ibmvfc_ae_fpin_status fs; + struct fc_host_attrs *fc_host; + struct ibmvfc_target *tgt; + struct ibmvfc_host *vhost; + struct fc_rport *rport; + unsigned long flags; + + vhost =3D ibmvfc_get_first_vhost(); + if (!vhost) + kunit_skip(test, "No ibmvfc devices available"); + + spin_lock_irqsave(vhost->host->host_lock, flags); + if (vhost->scsi_scrqs.num_targets < 1) { + spin_unlock_irqrestore(vhost->host->host_lock, flags); + scsi_host_put(vhost->host); + kunit_skip(test, "No targets"); + } + tgt =3D list_first_entry(&vhost->scsi_scrqs.targets, struct ibmvfc_target= , queue); + if (!tgt->rport) { + spin_unlock_irqrestore(vhost->host->host_lock, flags); + scsi_host_put(vhost->host); + kunit_skip(test, "No rport"); + } + rport =3D tgt->rport; + get_device(&rport->dev); + kref_get(&tgt->kref); + spin_unlock_irqrestore(vhost->host->host_lock, flags); + + fc_host =3D shost_to_fc_host(vhost->host); + + pre[IBMVFC_AE_FPIN_LINK_CONGESTED] =3D READ_ONCE(fc_host->fpin_stats.cn_d= evice_specific); + pre[IBMVFC_AE_FPIN_PORT_CONGESTED] =3D READ_ONCE(rport->fpin_stats.cn_dev= ice_specific); + pre[IBMVFC_AE_FPIN_PORT_CLEARED] =3D READ_ONCE(rport->fpin_stats.cn_clear= ); + pre[IBMVFC_AE_FPIN_PORT_DEGRADED] =3D READ_ONCE(rport->fpin_stats.li_fail= ure_unknown); + pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED] =3D READ_ONCE(fc_host->fpin_stats.= cn_clear); + + for (fs =3D IBMVFC_AE_FPIN_LINK_CONGESTED; fs <=3D IBMVFC_AE_FPIN_CONGEST= ION_CLEARED; fs++) { + ae[fs].valid =3D 0x80; + ae[fs].link_state =3D IBMVFC_AE_LS_LINK_UP; + ae[fs].fpin_status =3D fs; + ae[fs].event =3D cpu_to_be64(IBMVFC_AE_FPIN); + ae[fs].scsi_id =3D cpu_to_be64(tgt->scsi_id); + ae[fs].wwpn =3D cpu_to_be64(tgt->wwpn); + ae[fs].node_name =3D cpu_to_be64(tgt->ids.node_name); + ibmvfc_handle_async(&ae[fs], vhost); + ae[fs].valid =3D 0; + wmb(); /* ensure valid bit clear is visible before checking stats */ + } + flush_workqueue(vhost->fpin_workq); + + post[IBMVFC_AE_FPIN_LINK_CONGESTED] =3D READ_ONCE(fc_host->fpin_stats.cn_= device_specific); + post[IBMVFC_AE_FPIN_PORT_CONGESTED] =3D READ_ONCE(rport->fpin_stats.cn_de= vice_specific); + post[IBMVFC_AE_FPIN_PORT_CLEARED] =3D READ_ONCE(rport->fpin_stats.cn_clea= r); + post[IBMVFC_AE_FPIN_PORT_DEGRADED] =3D READ_ONCE(rport->fpin_stats.li_fai= lure_unknown); + post[IBMVFC_AE_FPIN_CONGESTION_CLEARED] =3D READ_ONCE(fc_host->fpin_stats= .cn_clear); + + KUNIT_EXPECT_GE(test, post[IBMVFC_AE_FPIN_LINK_CONGESTED], + pre[IBMVFC_AE_FPIN_LINK_CONGESTED]+1); + KUNIT_EXPECT_GE(test, post[IBMVFC_AE_FPIN_PORT_CONGESTED], + pre[IBMVFC_AE_FPIN_PORT_CONGESTED]+1); + KUNIT_EXPECT_GE(test, post[IBMVFC_AE_FPIN_PORT_CLEARED], + pre[IBMVFC_AE_FPIN_PORT_CLEARED]+1); + KUNIT_EXPECT_GE(test, post[IBMVFC_AE_FPIN_PORT_DEGRADED], + pre[IBMVFC_AE_FPIN_PORT_DEGRADED]+1); + KUNIT_EXPECT_GE(test, post[IBMVFC_AE_FPIN_CONGESTION_CLEARED], + pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED]+1); + + /* bad path */ + pre[IBMVFC_AE_FPIN_LINK_CONGESTED] =3D READ_ONCE(fc_host->fpin_stats.cn_d= evice_specific); + pre[IBMVFC_AE_FPIN_PORT_CONGESTED] =3D READ_ONCE(rport->fpin_stats.cn_dev= ice_specific); + pre[IBMVFC_AE_FPIN_PORT_CLEARED] =3D READ_ONCE(rport->fpin_stats.cn_clear= ); + pre[IBMVFC_AE_FPIN_PORT_DEGRADED] =3D READ_ONCE(rport->fpin_stats.li_fail= ure_unknown); + pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED] =3D READ_ONCE(fc_host->fpin_stats.= cn_clear); + + ae[0].valid =3D 0x80; + ae[0].link_state =3D IBMVFC_AE_LS_LINK_UP; + ae[0].fpin_status =3D 0; /* bad value */ + ae[0].event =3D cpu_to_be64(IBMVFC_AE_FPIN); + ae[0].scsi_id =3D cpu_to_be64(tgt->scsi_id); + ae[0].wwpn =3D cpu_to_be64(tgt->wwpn); + ae[0].node_name =3D cpu_to_be64(tgt->ids.node_name); + ibmvfc_handle_async(&ae[0], vhost); + ae[0].valid =3D 0; + wmb(); /* ensure valid bit clear is visible before checking stats */ + flush_workqueue(vhost->fpin_workq); + + post[IBMVFC_AE_FPIN_LINK_CONGESTED] =3D READ_ONCE(fc_host->fpin_stats.cn_= device_specific); + post[IBMVFC_AE_FPIN_PORT_CONGESTED] =3D READ_ONCE(rport->fpin_stats.cn_de= vice_specific); + post[IBMVFC_AE_FPIN_PORT_CLEARED] =3D READ_ONCE(rport->fpin_stats.cn_clea= r); + post[IBMVFC_AE_FPIN_PORT_DEGRADED] =3D READ_ONCE(rport->fpin_stats.li_fai= lure_unknown); + post[IBMVFC_AE_FPIN_CONGESTION_CLEARED] =3D READ_ONCE(fc_host->fpin_stats= .cn_clear); + + KUNIT_EXPECT_EQ(test, pre[IBMVFC_AE_FPIN_LINK_CONGESTED], + post[IBMVFC_AE_FPIN_LINK_CONGESTED]); + KUNIT_EXPECT_EQ(test, pre[IBMVFC_AE_FPIN_PORT_CONGESTED], + post[IBMVFC_AE_FPIN_PORT_CONGESTED]); + KUNIT_EXPECT_EQ(test, pre[IBMVFC_AE_FPIN_PORT_CLEARED], + post[IBMVFC_AE_FPIN_PORT_CLEARED]); + KUNIT_EXPECT_EQ(test, pre[IBMVFC_AE_FPIN_PORT_DEGRADED], + post[IBMVFC_AE_FPIN_PORT_DEGRADED]); + KUNIT_EXPECT_EQ(test, pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED], + post[IBMVFC_AE_FPIN_CONGESTION_CLEARED]); + + kref_put(&tgt->kref, ibmvfc_release_tgt); + put_device(&rport->dev); +} + +static struct kunit_case ibmvfc_fpin_test_cases[] =3D { + KUNIT_CASE(ibmvfc_async_fpin_test), + {}, +}; + +static struct kunit_suite ibmvfc_fpin_test_suite =3D { + .name =3D "ibmvfc-fpin-test", + .test_cases =3D ibmvfc_fpin_test_cases, +}; +kunit_test_init_section_suite(ibmvfc_fpin_test_suite); + +MODULE_LICENSE("GPL"); +MODULE_AUTHOR("Dave Marquardt "); +MODULE_DESCRIPTION("Test module for IBM Virtual Fibre Channel Driver"); --=20 2.55.0 From nobody Fri Sep 25 15:13:48 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 7C6FA3C8713; Fri, 25 Sep 2026 04:48:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311718; cv=none; b=CrFXtPjpvvzmGIF3oonT83Ahv4ss//g7T4r/qUcK8JEc5uZ3TGs/Yxv3GuxW7ENFoPiJHp4Ok2OGDEmapY5wdDThgOpNstm7Gb42p7UYRYm3UXFQJ4Ii67Xg4BKnDubHH9dXGsK2b7q7zoO3PCFnflijAVgRm6Ewt7IYQElZZbk= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311718; c=relaxed/simple; bh=PH6V7bAicDH1pGwY/b+5OT2fvDlLgxjT+vWdVIHF04w=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Je8ZvObP64SWZ/UrONT4SIJPbT/gGIaUeaVyQogDkqAfOAwusvXod+CRYmGkBwaAdxHuX5/2Sf1a4/fiR48Plp8KvwMhgsEMBnaMyD8A8ddcrQS145aP9/jjBgv1PCwd3vqvCr0XV/S4ULy3G1WVO6sVCthRV98F2uIAvdBW0pQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=TGPh8iWc; arc=none smtp.client-ip=148.163.158.5 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="TGPh8iWc" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4aAjU102480; Fri, 25 Sep 2026 04:48:27 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=deka9Xo4cRWIHTBhm gHmdNv86gonKFqC5tTXiJJBAiY=; b=TGPh8iWcISO5bO0sRXcx5T1zHySyM9bKO M33gHmL0NPzOT73U4HZCMDzyc9psqhe47Al5CdPQHth3oDqEIRWuluOn46483C9p 13myXXCc3q38ASDLP2TxEppjWGiFnykuy2HWrNz3+lVW9GTcoZM+5+49DJJfh8Kx aialmJ5fj8btEjtkNlNc8Ce87X/zo7YSrCxGicCcV/dSH717b6dwCCVrK80q5yhD 2shBq1YHNyjz0HVWKEi2/SMKhp8Ygux3WYZSS78yTuOT1Y6beJ6Ybi7lOFvDDYH4 DB2zzvzTfJJIfovgrqE4t/3++kZvhprd/VrBT81WKhjLdoN5nARCA== 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 4gskdvm9yb-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:27 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4lY4m3248902; Fri, 25 Sep 2026 04:48:26 GMT Received: from smtprelay02.dal12v.mail.ibm.com ([172.16.1.4]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gvbt30y1w-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:26 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay02.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68P4mPwQ42664312 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Sep 2026 04:48:25 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 692605805C; Fri, 25 Sep 2026 04:48:25 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8CF3D58051; Fri, 25 Sep 2026 04:48:24 +0000 (GMT) Received: from li-4c4c4544-0054-3910-8039-c3c04f423534.ibm.com.com (unknown [9.61.142.241]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 25 Sep 2026 04:48:24 +0000 (GMT) From: Tyrel Datwyler To: james.bottomley@hansenpartnership.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, brking@linux.ibm.com, davemarq@linux.ibm.com, Tyrel Datwyler Subject: [PATCH v11 05/11] scsi: ibmvfc: add NOOP command support Date: Thu, 24 Sep 2026 21:48:54 -0700 Message-ID: <20260925044900.414340-6-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260925044900.414340-1-tyreld@linux.ibm.com> References: <20260925044900.414340-1-tyreld@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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Ty9QOxgbPDjQJ16K3Zx1jqXE2jI6WwmO X-Proofpoint-Spam-Info: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfXxPuBP1U+k9FP Ij26fUOPax8u6KosQ1CATms3AdEbTvgHUcpoROFbVBw1P7flg8v7EZ21WKSTjtUEXi/JWogj0sR 66+Y4n/JMbpjMBpdRYVe8vEQwb778x4= X-Authority-Analysis: v=2.4 cv=FLiOVOos c=1 sm=1 tr=0 ts=6ab5fd1b cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=dMUBAgKGejxRm0SXrm0A:9 X-Proofpoint-GUID: Ty9QOxgbPDjQJ16K3Zx1jqXE2jI6WwmO X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfXzIpqG2MLpcO/ HwWZSElYMa+Fu4Avehwo7ys32uUj7JXSUpOh8NAdNMJgEeiGtWLH454RXb4Jp0URjxkBgCrzn1Z x/m8EQ/AsXn/3yHUJLApt7yIpyfzxknmSz9HBagZIaA4FAtBOPljpk7nUoPxICHKfs6QyL/MPeP WiHAO5y20YSRHmXd4aQHXdtfzl32BvmNmxjMO3sTFIRZN075mom/bSCB8eLum46ecfbXnlPelTj 94Prc+YUvMJGZaB0ChHljcnpPs6Xs8jsmFp8Zs42gC3Amjbpmkf3HLL2gujyUg3vEK2tZ/DfAV8 d2KMqrVlDlsbvS/3mzuno7P/uZEsYAtI3h8IGEsWnyICip0F8DuamCw7xkcSXhruRM8jrPbLgr7 afMGUlhr57I+dEYOA8FkPsyAP2QfN46gVYMy0/nxpgNdHy4fZGv5n83vDCodqSiWFgph7rPvznY 8Y1OEMIGpvVs63ycMKg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-25_02,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 phishscore=0 spamscore=0 clxscore=1015 suspectscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609250018 Content-Type: text/plain; charset="utf-8" From: Dave Marquardt Add support for handling IBMVFC_NOOP format CRQ messages from the VIOS partner. Advertise the client's ability to handle NOOP commands by setting the IBMVFC_CAN_USE_NOOP_CMD capability in ibmvfc_set_login_info(). Handle and ignore IBMVFC_NOOP format messages in both ibmvfc_handle_crq() and ibmvfc_handle_scrq(). In both handlers, log a rate-limited error if a NOOP is received while in the IBMVFC_ACTIVE state without the partner having advertised IBMVFC_SUPPORT_NOOP_CMD. In ibmvfc_handle_scrq(), also fix a typo ("Got and invalid" -> "Got an invalid"), add a missing return on invalid message types, and guard against null event pointers before processing CRQ responses. Signed-off-by: Dave Marquardt Acked-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc-core.c | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ib= mvfc-core.c index 5966f2fd3fc2..f465efadc02c 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c @@ -1578,7 +1578,9 @@ static void ibmvfc_set_login_info(struct ibmvfc_host = *vhost) login_info->flags |=3D cpu_to_be16(IBMVFC_CLIENT_MIGRATED); =20 login_info->max_cmds =3D cpu_to_be32(max_cmds); - login_info->capabilities =3D cpu_to_be64(IBMVFC_CAN_MIGRATE | IBMVFC_CAN_= SEND_VF_WWPN); + login_info->capabilities =3D + cpu_to_be64(IBMVFC_CAN_MIGRATE | IBMVFC_CAN_SEND_VF_WWPN | + IBMVFC_CAN_USE_NOOP_CMD); =20 if (vhost->mq_enabled || vhost->using_channels) { login_info->capabilities |=3D cpu_to_be64(IBMVFC_CAN_USE_CHANNELS); @@ -3695,6 +3697,14 @@ static void ibmvfc_handle_crq(struct ibmvfc_crq *crq= , struct ibmvfc_host *vhost, if (crq->format =3D=3D IBMVFC_ASYNC_EVENT) return; =20 + if (crq->format =3D=3D IBMVFC_NOOP) { + if (vhost->state =3D=3D IBMVFC_ACTIVE && + !ibmvfc_check_caps(vhost, IBMVFC_SUPPORT_NOOP_CMD)) + dev_err_ratelimited(vhost->dev, + "Received unexpected NOOP command from partner\n"); + return; + } + /* The only kind of payload CRQs we should get are responses to * things we send. Make sure this response is to something we * actually sent @@ -4225,7 +4235,20 @@ static void ibmvfc_handle_scrq(struct ibmvfc_crq *cr= q, struct ibmvfc_host *vhost case IBMVFC_CRQ_XPORT_EVENT: return; default: - dev_err(vhost->dev, "Got and invalid message type 0x%02x\n", crq->valid); + dev_err(vhost->dev, "Got an invalid message type 0x%02x\n", crq->valid); + return; + } + + if (crq->format =3D=3D IBMVFC_NOOP) { + if (vhost->state =3D=3D IBMVFC_ACTIVE && + !ibmvfc_check_caps(vhost, IBMVFC_SUPPORT_NOOP_CMD)) + dev_err_ratelimited(vhost->dev, + "Received unexpected NOOP command from partner\n"); + return; + } + + if (unlikely(!evt)) { + dev_err(vhost->dev, "Received null event\n"); return; } =20 --=20 2.55.0 From nobody Fri Sep 25 15:13:48 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 800D93C6A38; Fri, 25 Sep 2026 04:48:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311719; cv=none; b=fPYqslZbeetKGJIghwqwbK2hsXZRdzgSm8VDhDPik6t/K7gYyz5TCALVgOJzu+KVRZUBkbLIwT2KmHvXDP9rLo4xmyIv+aZDxz6VmYqc1qjYIKzZdYGSLjQX2L8nQ2u05RXdQ+qnd2/pyd8d1Sb9sQjsUd98YhwH/VGR+bBb+vQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311719; c=relaxed/simple; bh=ewDOe6FZN80E1VRmwjI0MNfk3sj8b/lpHg6nogBXgwM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NeWV8ZYyKwIhdyrwBFXkhzifdjTrZQDTwvHqMFZm/LlxTJRRp9eH5jfrehewZIVP+4tvayZGoalOhF9LQMfAwT+m9zI4I0nyTK52PnE6brGVdBIOXce73SE/2NNiORvzICZkXBoRhqWUWqA4PFjJQSL0w4X7Y93syszofKlnAYA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=hFQB2LJO; arc=none smtp.client-ip=148.163.158.5 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="hFQB2LJO" Received: from pps.filterd (m0360072.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4amAt103433; Fri, 25 Sep 2026 04:48:28 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=JUKiUsRnWKd0DWGYi zm+NwQe/3rOK2AG/MaGniTV4XI=; b=hFQB2LJOq2MiR/pmHWkzAemxkAk6uhgcY TJ91fJjmbSqlnVJibIHPwhxTLjdep3WoMUEmLeY2TT2mGm/A5P2uEn+LTghscxLe BmPDdcLjV4XSwySJsEybanLTlSbEESDQn9EiMLJu8eTE4L8Hpbj12JWi+tviELPb qkp9klGz1kzE0QZf5nfZmRGJCiPRgFu5PAtbRZJLp/8xk+bYzLv/s52p0hrLALMU ftazz12M8JYcmHYd0t9yduzXnjSbl/bTd1EHCY8kJcBNXcYth3pSEOAxms5L/N4S Od7XJQlJNVkddgL3AyAsyRLCAuEp4gAzHNuAEZhDmJ+opkJDmF25w== 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 4gskdvm9yc-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:28 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4ldFJ3248931; Fri, 25 Sep 2026 04:48:27 GMT Received: from smtprelay03.dal12v.mail.ibm.com ([172.16.1.5]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gvbt30y1y-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:27 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay03.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68P4mQpf12780250 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Sep 2026 04:48:26 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7491A5805C; Fri, 25 Sep 2026 04:48:26 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 94D885805E; Fri, 25 Sep 2026 04:48:25 +0000 (GMT) Received: from li-4c4c4544-0054-3910-8039-c3c04f423534.ibm.com.com (unknown [9.61.142.241]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 25 Sep 2026 04:48:25 +0000 (GMT) From: Tyrel Datwyler To: james.bottomley@hansenpartnership.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, brking@linux.ibm.com, davemarq@linux.ibm.com, Tyrel Datwyler Subject: [PATCH v11 06/11] scsi: ibmvfc: add FPIN extended flag and async sub-CRQ queue handle Date: Thu, 24 Sep 2026 21:48:55 -0700 Message-ID: <20260925044900.414340-7-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260925044900.414340-1-tyreld@linux.ibm.com> References: <20260925044900.414340-1-tyreld@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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: lnc10Cjde8nyzNGxCIAZTOnu050SalQr X-Proofpoint-Spam-Info: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX61V7lRRy1yP3 gK85jnm+3NW0lz0Z01ux/F2x5f2yHSuZzs1E4hkUzk+6aEzICaHJGF2Z9oUaTbdrbGEG71K0Rzo 3GkmQ0g3m5ry0cqqqbiSha+6iawWZLc= X-Authority-Analysis: v=2.4 cv=FLiOVOos c=1 sm=1 tr=0 ts=6ab5fd1c cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=RzCfie-kr_QcCd8fBx8p:22 a=VnNF1IyMAAAA:8 a=_ck89SwLLagabBJyydIA:9 X-Proofpoint-GUID: lnc10Cjde8nyzNGxCIAZTOnu050SalQr X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfXwPv8AJ6XuE7G SYCpDeyyt1sE6cuOSXFMbz98NWO53Tg53pPlt27LYRX0P3tmP6OsIf263HCAtwtRirZVxPq6Y54 6gwYYqqD7h7x5gCLxikxp9OpUqXxYJOkRBKFS0OrI/Y82PEpFYY1ivdaZMx1L3LvPW4VDS6XWh5 X4ZV3XPP4C80DTv8Kw7qdYCPrMkLuKul8UIT9aBeR4Ho46lBM962sj7VgeSLI32VhJxfSVv4zvp Qh8DxSIwoO1Iv2qV5AcRkI8L6pL/KPTUwSbskkOugupPsNhyTUfkzeUQwf3wSPRuwtU0dCegf3j jts7rIvKGOVYqpVX2xVK9aJxig/YkFp3HZ/FUPkq8qKxaePJRvOYnqOz+HXb3u5PFx6cCodsxpj zNO8hIS9ejBeQKP3MJUffibfTzv8QNbRefY3itCqPDqETE5GYB28fqbCVO4emmSjXSEEnfu4E7e ix8O+BEDu40QGDD1hgg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-25_02,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 impostorscore=0 phishscore=0 spamscore=0 clxscore=1015 suspectscore=0 bulkscore=0 lowpriorityscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609250018 Content-Type: text/plain; charset="utf-8" From: Dave Marquardt Add IBMVFC_ASYNC_IS_FPIN_EXT flag bit (0x02) to ibmvfc_async_sub_crq.flags to distinguish extended FPIN events from standard ones. Add async_scrqs field of type ibmvfc_channels to ibmvfc_host to hold the channel set for the asynchronous sub-CRQ, alongside the existing scsi_scrqs and nvme_scrqs channels. This uses the same ibmvfc_channels infrastructure as the SCSI and NVMe channel queues. Add IBMVFC_ASYNC_SUB_CRQ_FMT to enum ibmvfc_msg_fmt and a corresponding async_scrq pointer to union ibmvfc_msgs to support the new async sub-CRQ message format. Signed-off-by: Dave Marquardt Signed-off-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h index d7a30e7a4a28..df2f312fd7b9 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.h +++ b/drivers/scsi/ibmvscsi/ibmvfc.h @@ -773,6 +773,7 @@ struct ibmvfc_async_sub_crq { volatile u8 valid; u8 flags; #define IBMVFC_ASYNC_ID_IS_ASSOC_ID 0x01 +#define IBMVFC_ASYNC_IS_FPIN_EXT 0x02 u8 link_state; u8 fpin_status; __be16 event; @@ -893,6 +894,7 @@ enum ibmvfc_msg_fmt { IBMVFC_CRQ_FMT =3D 0, IBMVFC_ASYNC_FMT, IBMVFC_SUB_CRQ_FMT, + IBMVFC_ASYNC_SUB_CRQ_FMT, }; =20 union ibmvfc_msgs { @@ -900,6 +902,7 @@ union ibmvfc_msgs { struct ibmvfc_crq *crq; struct ibmvfc_async_crq *async; struct ibmvfc_sub_crq *scrq; + struct ibmvfc_async_sub_crq *async_scrq; }; =20 struct ibmvfc_queue { @@ -992,6 +995,7 @@ struct ibmvfc_host { struct ibmvfc_queue async_crq; struct ibmvfc_channels scsi_scrqs; struct ibmvfc_channels nvme_scrqs; + struct ibmvfc_channels async_scrqs; struct ibmvfc_npiv_login login_info; union ibmvfc_npiv_login_data *login_buf; dma_addr_t login_buf_dma; --=20 2.55.0 From nobody Fri Sep 25 15:13:48 2026 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 EEE843C553F; Fri, 25 Sep 2026 04:48:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311725; cv=none; b=dc7xGCMM2Q/h5bijoFVJckzPW6kWvh7DLMxqEEby7TNPTWI4YOHgl51MuE9ugDHPDBbFPzeBb32i1k9Qcw6039CHr8USqv6psD4Drbck49zSLD3TccruQ59snhpv1u41q7yAbZ81U58CddTPv4aic9qBOJAGNw+z+VTFbBgzS4g= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311725; c=relaxed/simple; bh=Bxcmksss1K9pGrP95Fi17Huov/unuDptl4Ay3W/gQvA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=k1iENug639wo6JyUMZ/su4A/a2H6lI1Cz1WQFKMcIuGMiUBGNeNvL3SCCIXN605QqB70dTHxDRprr8QDls1PbrQSUFD5yIcqCL/08c5FJA10cv13vHf032EmTK3Rqs2oIGworydmmjFuGlZdfGCNk7DC22dQUuNpiezpb4s2Rco= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=menJaJr/; arc=none smtp.client-ip=148.163.156.1 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="menJaJr/" Received: from pps.filterd (m0356517.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4acWP061841; Fri, 25 Sep 2026 04:48:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=mXUFq1xU489RYZkbw yBqpNpOUsxwyXL49xsjDcnujhs=; b=menJaJr/6nqj/J6UQq5g4yiXFvCmzyriv 1U+ZDLuZVKVwFiCVSNtGOqbXc518tTUDQ/EQ1gwo6ceJy6gmrU/ojQmIUGue/J5p XbPlXpeQuUZjSp5N7I4kHp5GiaSkD6y7eLKuiBrzQN5+/SenndEgqJsSBRUdpxBP woKGqdkTdrvqgFhKO+f8OZh+Xx0DusPLm4DCSCHJI0p9jPm+ursWRZ4T/DDqglxt B6W14s9rVAnR7rPq/TG8hUYw/n4Z7CuxGV6RfgdULOeUJBwClk505KactiGdkSPi xmehTMSkOR76hKV6AdrYSIGBNyihGhW4plakEFvFPv+retEkNUMYg== 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 4gskgsn45r-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:29 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4liaC3248950; Fri, 25 Sep 2026 04:48:28 GMT Received: from smtprelay04.dal12v.mail.ibm.com ([172.16.1.6]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gvbt30y20-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:28 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay04.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68P4mRvR12976760 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Sep 2026 04:48:27 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B2885805A; Fri, 25 Sep 2026 04:48:27 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9FA555805C; Fri, 25 Sep 2026 04:48:26 +0000 (GMT) Received: from li-4c4c4544-0054-3910-8039-c3c04f423534.ibm.com.com (unknown [9.61.142.241]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 25 Sep 2026 04:48:26 +0000 (GMT) From: Tyrel Datwyler To: james.bottomley@hansenpartnership.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, brking@linux.ibm.com, davemarq@linux.ibm.com, Tyrel Datwyler Subject: [PATCH v11 07/11] scsi: ibmvfc: extend async event handlers for async sub-CRQ events Date: Thu, 24 Sep 2026 21:48:56 -0700 Message-ID: <20260925044900.414340-8-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260925044900.414340-1-tyreld@linux.ibm.com> References: <20260925044900.414340-1-tyreld@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: quoted-printable X-TM-AS-GCONF: 00 X-Authority-Analysis: v=2.4 cv=V/XoQuni c=1 sm=1 tr=0 ts=6ab5fd1d cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=U7nrCbtTmkRpXpFmAIza:22 a=VnNF1IyMAAAA:8 a=iW4PeHjXF5vBxW_ITg0A:9 X-Proofpoint-ORIG-GUID: Xd3cPpU3bPAOZXbe8Mi5bb2k8MLdUSpg X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfXwADyCR6q+umV Z7QjKn6VrrusG2TwPB662zr/78Y9ynVNkSsfHHCTAMg4TS9EtNEys3BgZl0C9YNx/ocdsoj7+Oa RN43edlTrQ5JgXEiV8jEF4Ia7hWS47YZe3R5Hf/3UGAS4vrreDVFmjyIiiSOoOdiuQlbCtO9jc9 EoJJA2WzYuKlnIOoYXwANNSmFCH6pTW8coeNXEnMPsLW5/oLIZgO/7VOvCxsP4f78FobHr6n1Z3 BrN85c3brRvhG/TdxkkG2Bnr8sOlg+i0oIsOrDy2+aPRdIoNbKITAiHww1LKorSvyjGEcynCOEx O6pgjgKInHmSC1sDKob0y2o+0+yq0pPf5mm6suWu9poaRU7apmxl3CtownSc/42KCAJ+1bhW4Vx t/B1H060eNGqHYGhJg86qNoxRkMoSq0PyhpDkQL3k/yePTLm4cW9d1jyeLXHuo9YrfPlN+znUSv 3ijedUzbylqPgV8F33A== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX8iyLBWXdqBey Q8rRT+Rtv/2JypdsJr4HQmXn5sEqQh8zqs7Z0DemtuSuyJRh1p0rtA8cHBrlA+RBioZ9rnYpCRY CsKx6fEKovg5LT7DLtD4g4DRXkddrh0= X-Proofpoint-GUID: Xd3cPpU3bPAOZXbe8Mi5bb2k8MLdUSpg X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-25_02,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 bulkscore=0 adultscore=0 lowpriorityscore=0 impostorscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609250018 Content-Type: text/plain; charset="utf-8" From: Dave Marquardt Refactor async event handling to support both traditional async CRQs and new asynchronous sub-queue CRQs. Introduce struct ibmvfc_async_crq_event, a tagged union that wraps either an ibmvfc_async_crq (main CRQ) or an ibmvfc_async_sub_crq (async sub-CRQ), with an enum ibmvfc_async_crq_type discriminator. Replace the ibmvfc_async_work bare union and is_subq bool with a single event field of this type. Modify ibmvfc_handle_async() to accept a struct ibmvfc_async_crq_event * instead of a void * plus a bool flag. Update ibmvfc_process_async_work() to dispatch based on event.type. Add ibmvfc_full_fpin_to_desc() to convert full FPIN messages from async sub-queue format to fc_els_fpin structures. Update FPIN processing logic to extract WWPN, node_name, and scsi_id from the appropriate union member based on event type. Update KUnit tests to use struct ibmvfc_async_crq_event arrays at call sites. Signed-off-by: Dave Marquardt Signed-off-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc-core.c | 163 +++++++++++++++++++++------ drivers/scsi/ibmvscsi/ibmvfc.h | 18 ++- drivers/scsi/ibmvscsi/ibmvfc_kunit.c | 161 +++++++++++++++++++++++--- 3 files changed, 285 insertions(+), 57 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ib= mvfc-core.c index f465efadc02c..321bb2f7219e 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c @@ -3426,6 +3426,45 @@ ibmvfc_basic_fpin_to_desc(struct ibmvfc_async_crq *c= rq, u64 wwpn) cpu_to_be32(1)); } =20 +/** + * ibmvfc_full_fpin_to_desc(): allocate and populate a struct fc_els_fpin = struct + * containing a descriptor. + * @ibmvfc_fpin: Pointer to async subq FPIN data + * + * Allocate a struct fc_els_fpin containing a descriptor and populate + * based on data from *ibmvfc_fpin. + * + * Return: + * NULL - unable to allocate structure + * non-NULL - pointer to populated struct fc_els_fpin + */ +static struct fc_els_fpin * +ibmvfc_full_fpin_to_desc(struct ibmvfc_async_sub_crq *ibmvfc_fpin) +{ + __be16 type; + + switch (ibmvfc_fpin->fpin_status) { + case IBMVFC_AE_FPIN_LINK_CONGESTED: + case IBMVFC_AE_FPIN_PORT_CONGESTED: + type =3D cpu_to_be16(FPIN_CONGN_DEVICE_SPEC); + break; + case IBMVFC_AE_FPIN_PORT_CLEARED: + case IBMVFC_AE_FPIN_CONGESTION_CLEARED: + type =3D cpu_to_be16(FPIN_CONGN_CLEAR); + break; + case IBMVFC_AE_FPIN_PORT_DEGRADED: + type =3D cpu_to_be16(FPIN_LI_UNKNOWN); + break; + default: + return NULL; + } + + return ibmvfc_common_fpin_to_desc(ibmvfc_fpin->fpin_status, ibmvfc_fpin->= wwpn, + type, cpu_to_be16(0), + cpu_to_be32(IBMVFC_FPIN_DEFAULT_EVENT_THRESHOLD), + cpu_to_be32(1)); +} + /** * ibmvfc_find_target - Search for a target in a target list * @target_list: list head of targets to search @@ -3463,28 +3502,40 @@ static struct ibmvfc_target *ibmvfc_find_target(str= uct list_head *target_list, */ static void ibmvfc_process_async_work(struct work_struct *work) { + struct ibmvfc_async_sub_crq *subq =3D NULL; struct ibmvfc_async_work *aw; - struct ibmvfc_async_crq *crq; + struct ibmvfc_async_crq *crq =3D NULL; struct ibmvfc_target *tgt; struct ibmvfc_host *vhost; - struct fc_els_fpin *fpin; + struct fc_els_fpin *fpin =3D NULL; unsigned long flags; + __be64 node_name; + __be64 scsi_id; + __be64 wwpn; =20 aw =3D container_of_const(work, struct ibmvfc_async_work, async_work_s); vhost =3D aw->vhost; - crq =3D &aw->crq; + if (aw->event.type =3D=3D IBMVFC_ASYNC_CRQ_SUB) { + subq =3D &aw->event.subq; + scsi_id =3D 0; + wwpn =3D subq->wwpn; + node_name =3D (subq->flags & IBMVFC_ASYNC_ID_IS_ASSOC_ID) ? 0 : subq->id= .node_name; + } else { + crq =3D &aw->event.async_crq; + scsi_id =3D crq->scsi_id; + wwpn =3D crq->wwpn; + node_name =3D crq->node_name; + } =20 - if (!crq->scsi_id && !crq->wwpn && !crq->node_name) + if (!scsi_id && !wwpn && !node_name) goto free; =20 spin_lock_irqsave(vhost->host->host_lock, flags); - tgt =3D ibmvfc_find_target(&vhost->scsi_scrqs.targets, crq->scsi_id, - crq->wwpn, crq->node_name); + tgt =3D ibmvfc_find_target(&vhost->scsi_scrqs.targets, scsi_id, wwpn, nod= e_name); + if (!tgt) { /* Target not found in scsi_scrqs, search nvme_scrqs */ - tgt =3D ibmvfc_find_target(&vhost->nvme_scrqs.targets, - crq->scsi_id, crq->wwpn, - crq->node_name); + tgt =3D ibmvfc_find_target(&vhost->nvme_scrqs.targets, scsi_id, wwpn, no= de_name); } =20 if (tgt) { @@ -3496,7 +3547,11 @@ static void ibmvfc_process_async_work(struct work_st= ruct *work) goto free; } =20 - fpin =3D ibmvfc_basic_fpin_to_desc(crq, tgt->wwpn); + if (crq) + fpin =3D ibmvfc_basic_fpin_to_desc(crq, tgt->wwpn); + else + fpin =3D ibmvfc_full_fpin_to_desc(subq); + if (fpin) { fc_host_fpin_rcv(tgt->vhost->host, sizeof(*fpin) + be32_to_cpu(fpin->desc_len), @@ -3512,25 +3567,51 @@ static void ibmvfc_process_async_work(struct work_s= truct *work) =20 /** * ibmvfc_handle_async - Handle an async event from the adapter - * @crq: crq to process + * @ae: tagged union wrapping either an ibmvfc_async_crq (main CRQ) or an + * ibmvfc_async_sub_crq (async sub-CRQ); the type field identifies which * @vhost: ibmvfc host struct * **/ -VISIBLE_IF_KUNIT void ibmvfc_handle_async(struct ibmvfc_async_crq *crq, +VISIBLE_IF_KUNIT void ibmvfc_handle_async(struct ibmvfc_async_crq_event *a= e, struct ibmvfc_host *vhost) { - const struct ibmvfc_async_desc *desc =3D ibmvfc_get_ae_desc(be64_to_cpu(c= rq->event)); + struct ibmvfc_async_crq *async_crq =3D NULL; + struct ibmvfc_async_sub_crq *subq =3D NULL; + const struct ibmvfc_async_desc *desc; struct ibmvfc_async_work *aw; struct ibmvfc_target *tgt; - - ibmvfc_log(vhost, desc->log_level, "%s event received. scsi_id: %llx, wwp= n: %llx," - " node_name: %llx%s\n", desc->desc, be64_to_cpu(crq->scsi_id), - be64_to_cpu(crq->wwpn), be64_to_cpu(crq->node_name), - ibmvfc_get_link_state(crq->link_state)); - - switch (be64_to_cpu(crq->event)) { + __be64 node_name; + __be64 scsi_id; + u8 link_state; + __be64 wwpn; + u64 event; + + if (ae->type =3D=3D IBMVFC_ASYNC_CRQ_SUB) { + subq =3D &ae->subq; + event =3D be16_to_cpu(subq->event); + link_state =3D subq->link_state; + scsi_id =3D 0; + wwpn =3D subq->wwpn; + node_name =3D subq->flags & IBMVFC_ASYNC_ID_IS_ASSOC_ID ? 0 : subq->id.n= ode_name; + } else { + async_crq =3D &ae->async_crq; + event =3D be64_to_cpu(async_crq->event); + link_state =3D async_crq->link_state; + scsi_id =3D async_crq->scsi_id; + wwpn =3D async_crq->wwpn; + node_name =3D async_crq->node_name; + } + + desc =3D ibmvfc_get_ae_desc(event); + ibmvfc_log(vhost, desc->log_level, + "%s event received. scsi_id: %llx, wwpn: %llx, node_name: %llx, event= %llx%s\n", + desc->desc, be64_to_cpu(scsi_id), + be64_to_cpu(wwpn), be64_to_cpu(node_name), event, + ibmvfc_get_link_state(link_state)); + + switch (event) { case IBMVFC_AE_RESUME: - switch (crq->link_state) { + switch (link_state) { case IBMVFC_AE_LS_LINK_DOWN: ibmvfc_link_down(vhost, IBMVFC_LINK_DOWN); break; @@ -3569,33 +3650,33 @@ VISIBLE_IF_KUNIT void ibmvfc_handle_async(struct ib= mvfc_async_crq *crq, case IBMVFC_AE_ELS_PRLO: case IBMVFC_AE_ELS_PLOGI: list_for_each_entry(tgt, &vhost->scsi_scrqs.targets, queue) { - if (!crq->scsi_id && !crq->wwpn && !crq->node_name) + if (!scsi_id && !wwpn && !node_name) break; - if (crq->scsi_id && cpu_to_be64(tgt->scsi_id) !=3D crq->scsi_id) + if (scsi_id && cpu_to_be64(tgt->scsi_id) !=3D scsi_id) continue; - if (crq->wwpn && cpu_to_be64(tgt->ids.port_name) !=3D crq->wwpn) + if (wwpn && cpu_to_be64(tgt->ids.port_name) !=3D wwpn) continue; - if (crq->node_name && cpu_to_be64(tgt->ids.node_name) !=3D crq->node_na= me) + if (node_name && cpu_to_be64(tgt->ids.node_name) !=3D node_name) continue; - if (tgt->need_login && be64_to_cpu(crq->event) =3D=3D IBMVFC_AE_ELS_LOG= O) + if (tgt->need_login && event =3D=3D IBMVFC_AE_ELS_LOGO) tgt->logo_rcvd =3D 1; - if (!tgt->need_login || be64_to_cpu(crq->event) =3D=3D IBMVFC_AE_ELS_PL= OGI) { + if (!tgt->need_login || event =3D=3D IBMVFC_AE_ELS_PLOGI) { ibmvfc_del_tgt(tgt); ibmvfc_reinit_host(vhost); } } list_for_each_entry(tgt, &vhost->nvme_scrqs.targets, queue) { - if (!crq->scsi_id && !crq->wwpn && !crq->node_name) + if (!scsi_id && !wwpn && !node_name) break; - if (crq->scsi_id && cpu_to_be64(tgt->scsi_id) !=3D crq->scsi_id) + if (scsi_id && cpu_to_be64(tgt->scsi_id) !=3D scsi_id) continue; - if (crq->wwpn && cpu_to_be64(tgt->ids.port_name) !=3D crq->wwpn) + if (wwpn && cpu_to_be64(tgt->ids.port_name) !=3D wwpn) continue; - if (crq->node_name && cpu_to_be64(tgt->ids.node_name) !=3D crq->node_na= me) + if (node_name && cpu_to_be64(tgt->ids.node_name) !=3D node_name) continue; - if (tgt->need_login && be64_to_cpu(crq->event) =3D=3D IBMVFC_AE_ELS_LOG= O) + if (tgt->need_login && event =3D=3D IBMVFC_AE_ELS_LOGO) tgt->logo_rcvd =3D 1; - if (!tgt->need_login || be64_to_cpu(crq->event) =3D=3D IBMVFC_AE_ELS_PL= OGI) { + if (!tgt->need_login || event =3D=3D IBMVFC_AE_ELS_PLOGI) { ibmvfc_del_tgt(tgt); ibmvfc_reinit_host(vhost); } @@ -3618,14 +3699,14 @@ VISIBLE_IF_KUNIT void ibmvfc_handle_async(struct ib= mvfc_async_crq *crq, if (aw) { INIT_WORK(&aw->async_work_s, ibmvfc_process_async_work); aw->vhost =3D vhost; - aw->crq =3D *crq; + aw->event =3D *ae; queue_work(vhost->fpin_workq, &aw->async_work_s); } else dev_err_ratelimited(vhost->dev, "can't offload async CRQ to work queue\n"); break; default: - dev_err(vhost->dev, "Unknown async event received: %lld\n", crq->event); + dev_err(vhost->dev, "Unknown async event received: %llu\n", event); break; } } @@ -4166,7 +4247,11 @@ static void ibmvfc_tasklet(void *data) while (!done) { /* Pull all the valid messages off the async CRQ */ while ((async =3D ibmvfc_next_async_crq(vhost)) !=3D NULL) { - ibmvfc_handle_async(async, vhost); + struct ibmvfc_async_crq_event ae =3D { + .type =3D IBMVFC_ASYNC_CRQ_MAIN, + .async_crq =3D *async, + }; + ibmvfc_handle_async(&ae, vhost); async->valid =3D 0; wmb(); } @@ -4180,8 +4265,12 @@ static void ibmvfc_tasklet(void *data) =20 vio_enable_interrupts(vdev); if ((async =3D ibmvfc_next_async_crq(vhost)) !=3D NULL) { + struct ibmvfc_async_crq_event ae =3D { + .type =3D IBMVFC_ASYNC_CRQ_MAIN, + .async_crq =3D *async, + }; vio_disable_interrupts(vdev); - ibmvfc_handle_async(async, vhost); + ibmvfc_handle_async(&ae, vhost); async->valid =3D 0; wmb(); } else if ((crq =3D ibmvfc_next_crq(vhost)) !=3D NULL) { diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h index df2f312fd7b9..ebbcb911f639 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.h +++ b/drivers/scsi/ibmvscsi/ibmvfc.h @@ -786,9 +786,22 @@ struct ibmvfc_async_sub_crq { } id; } __packed __aligned(8); =20 +enum ibmvfc_async_crq_type { + IBMVFC_ASYNC_CRQ_MAIN =3D 0, + IBMVFC_ASYNC_CRQ_SUB, +}; + +struct ibmvfc_async_crq_event { + enum ibmvfc_async_crq_type type; + union { + struct ibmvfc_async_crq async_crq; + struct ibmvfc_async_sub_crq subq; + }; +}; + struct ibmvfc_async_work { struct ibmvfc_host *vhost; - struct ibmvfc_async_crq crq; + struct ibmvfc_async_crq_event event; struct work_struct async_work_s; }; =20 @@ -1105,7 +1118,8 @@ static inline struct ibmvfc_host *ibmvfc_channels_to_= vhost(struct ibmvfc_channel =20 #if IS_ENABLED(CONFIG_KUNIT) #include -VISIBLE_IF_KUNIT void ibmvfc_handle_async(struct ibmvfc_async_crq *crq, st= ruct ibmvfc_host *vhost); +VISIBLE_IF_KUNIT void ibmvfc_handle_async(struct ibmvfc_async_crq_event *e= vent, + struct ibmvfc_host *vhost); VISIBLE_IF_KUNIT struct ibmvfc_host *ibmvfc_get_first_vhost(void); #endif =20 diff --git a/drivers/scsi/ibmvscsi/ibmvfc_kunit.c b/drivers/scsi/ibmvscsi/i= bmvfc_kunit.c index ec52285b0aa2..6cd9e701ba54 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc_kunit.c +++ b/drivers/scsi/ibmvscsi/ibmvfc_kunit.c @@ -3,7 +3,6 @@ #include #include #include -#include #include #include #include "ibmvfc.h" @@ -25,7 +24,9 @@ static void ibmvfc_async_fpin_test(struct kunit *test) { u64 post[IBMVFC_AE_FPIN_CONGESTION_CLEARED + 1]; u64 pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED + 1]; - struct ibmvfc_async_crq ae[IBMVFC_AE_FPIN_CONGESTION_CLEARED + 1]; + struct ibmvfc_async_crq_event ae[IBMVFC_AE_FPIN_CONGESTION_CLEARED + 1] = =3D { + [0 ... IBMVFC_AE_FPIN_CONGESTION_CLEARED] =3D { .type =3D IBMVFC_ASYNC_C= RQ_MAIN }, + }; enum ibmvfc_ae_fpin_status fs; struct fc_host_attrs *fc_host; struct ibmvfc_target *tgt; @@ -63,15 +64,15 @@ static void ibmvfc_async_fpin_test(struct kunit *test) pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED] =3D READ_ONCE(fc_host->fpin_stats.= cn_clear); =20 for (fs =3D IBMVFC_AE_FPIN_LINK_CONGESTED; fs <=3D IBMVFC_AE_FPIN_CONGEST= ION_CLEARED; fs++) { - ae[fs].valid =3D 0x80; - ae[fs].link_state =3D IBMVFC_AE_LS_LINK_UP; - ae[fs].fpin_status =3D fs; - ae[fs].event =3D cpu_to_be64(IBMVFC_AE_FPIN); - ae[fs].scsi_id =3D cpu_to_be64(tgt->scsi_id); - ae[fs].wwpn =3D cpu_to_be64(tgt->wwpn); - ae[fs].node_name =3D cpu_to_be64(tgt->ids.node_name); + ae[fs].async_crq.valid =3D 0x80; + ae[fs].async_crq.link_state =3D IBMVFC_AE_LS_LINK_UP; + ae[fs].async_crq.fpin_status =3D fs; + ae[fs].async_crq.event =3D cpu_to_be64(IBMVFC_AE_FPIN); + ae[fs].async_crq.scsi_id =3D cpu_to_be64(tgt->scsi_id); + ae[fs].async_crq.wwpn =3D cpu_to_be64(tgt->wwpn); + ae[fs].async_crq.node_name =3D cpu_to_be64(tgt->ids.node_name); ibmvfc_handle_async(&ae[fs], vhost); - ae[fs].valid =3D 0; + ae[fs].async_crq.valid =3D 0; wmb(); /* ensure valid bit clear is visible before checking stats */ } flush_workqueue(vhost->fpin_workq); @@ -100,15 +101,15 @@ static void ibmvfc_async_fpin_test(struct kunit *test) pre[IBMVFC_AE_FPIN_PORT_DEGRADED] =3D READ_ONCE(rport->fpin_stats.li_fail= ure_unknown); pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED] =3D READ_ONCE(fc_host->fpin_stats.= cn_clear); =20 - ae[0].valid =3D 0x80; - ae[0].link_state =3D IBMVFC_AE_LS_LINK_UP; - ae[0].fpin_status =3D 0; /* bad value */ - ae[0].event =3D cpu_to_be64(IBMVFC_AE_FPIN); - ae[0].scsi_id =3D cpu_to_be64(tgt->scsi_id); - ae[0].wwpn =3D cpu_to_be64(tgt->wwpn); - ae[0].node_name =3D cpu_to_be64(tgt->ids.node_name); + ae[0].async_crq.valid =3D 0x80; + ae[0].async_crq.link_state =3D IBMVFC_AE_LS_LINK_UP; + ae[0].async_crq.fpin_status =3D 0; /* bad value */ + ae[0].async_crq.event =3D cpu_to_be64(IBMVFC_AE_FPIN); + ae[0].async_crq.scsi_id =3D cpu_to_be64(tgt->scsi_id); + ae[0].async_crq.wwpn =3D cpu_to_be64(tgt->wwpn); + ae[0].async_crq.node_name =3D cpu_to_be64(tgt->ids.node_name); ibmvfc_handle_async(&ae[0], vhost); - ae[0].valid =3D 0; + ae[0].async_crq.valid =3D 0; wmb(); /* ensure valid bit clear is visible before checking stats */ flush_workqueue(vhost->fpin_workq); =20 @@ -133,8 +134,132 @@ static void ibmvfc_async_fpin_test(struct kunit *test) put_device(&rport->dev); } =20 +/** + * ibmvfc_full_fpin_test - unit test for IBMVFC_AE_FPIN parts of ibmvfc_ha= ndle_async + * @test: pointer to kunit structure + * + * Tests + * - error returns from ibmvfc_handle_async + * - statistics updates + * + * Return: void + */ +static void ibmvfc_full_fpin_test(struct kunit *test) +{ + u64 post[IBMVFC_AE_FPIN_CONGESTION_CLEARED + 1]; + u64 pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED + 1]; + struct ibmvfc_async_crq_event ae[IBMVFC_AE_FPIN_CONGESTION_CLEARED + 1] = =3D { + [0 ... IBMVFC_AE_FPIN_CONGESTION_CLEARED] =3D { .type =3D IBMVFC_ASYNC_C= RQ_SUB }, + }; + enum ibmvfc_ae_fpin_status fs; + struct fc_host_attrs *fc_host; + struct ibmvfc_target *tgt; + struct ibmvfc_host *vhost; + struct fc_rport *rport; + unsigned long flags; + + vhost =3D ibmvfc_get_first_vhost(); + if (!vhost) + kunit_skip(test, "No ibmvfc devices available"); + + spin_lock_irqsave(vhost->host->host_lock, flags); + if (vhost->scsi_scrqs.num_targets < 1) { + spin_unlock_irqrestore(vhost->host->host_lock, flags); + scsi_host_put(vhost->host); + kunit_skip(test, "No targets"); + } + tgt =3D list_first_entry(&vhost->scsi_scrqs.targets, struct ibmvfc_target= , queue); + if (!tgt->rport) { + spin_unlock_irqrestore(vhost->host->host_lock, flags); + scsi_host_put(vhost->host); + kunit_skip(test, "No rport"); + } + rport =3D tgt->rport; + get_device(&rport->dev); + kref_get(&tgt->kref); + spin_unlock_irqrestore(vhost->host->host_lock, flags); + + fc_host =3D shost_to_fc_host(vhost->host); + + pre[IBMVFC_AE_FPIN_LINK_CONGESTED] =3D READ_ONCE(fc_host->fpin_stats.cn_d= evice_specific); + pre[IBMVFC_AE_FPIN_PORT_CONGESTED] =3D READ_ONCE(rport->fpin_stats.cn_dev= ice_specific); + pre[IBMVFC_AE_FPIN_PORT_CLEARED] =3D READ_ONCE(rport->fpin_stats.cn_clear= ); + pre[IBMVFC_AE_FPIN_PORT_DEGRADED] =3D READ_ONCE(rport->fpin_stats.li_fail= ure_unknown); + pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED] =3D READ_ONCE(fc_host->fpin_stats.= cn_clear); + + for (fs =3D IBMVFC_AE_FPIN_LINK_CONGESTED; fs <=3D IBMVFC_AE_FPIN_CONGEST= ION_CLEARED; fs++) { + ae[fs].subq.valid =3D 0x80; + ae[fs].subq.link_state =3D IBMVFC_AE_LS_LINK_UP; + ae[fs].subq.fpin_status =3D fs; + ae[fs].subq.event =3D cpu_to_be16(IBMVFC_AE_FPIN); + ae[fs].subq.wwpn =3D cpu_to_be64(tgt->wwpn); + ae[fs].subq.id.node_name =3D cpu_to_be64(tgt->ids.node_name); + ibmvfc_handle_async(&ae[fs], vhost); + ae[fs].subq.valid =3D 0; + wmb(); /* ensure valid bit clear is visible before checking stats */ + } + flush_workqueue(vhost->fpin_workq); + + post[IBMVFC_AE_FPIN_LINK_CONGESTED] =3D READ_ONCE(fc_host->fpin_stats.cn_= device_specific); + post[IBMVFC_AE_FPIN_PORT_CONGESTED] =3D READ_ONCE(rport->fpin_stats.cn_de= vice_specific); + post[IBMVFC_AE_FPIN_PORT_CLEARED] =3D READ_ONCE(rport->fpin_stats.cn_clea= r); + post[IBMVFC_AE_FPIN_PORT_DEGRADED] =3D READ_ONCE(rport->fpin_stats.li_fai= lure_unknown); + post[IBMVFC_AE_FPIN_CONGESTION_CLEARED] =3D READ_ONCE(fc_host->fpin_stats= .cn_clear); + + KUNIT_EXPECT_GE(test, post[IBMVFC_AE_FPIN_LINK_CONGESTED], + pre[IBMVFC_AE_FPIN_LINK_CONGESTED]+1); + KUNIT_EXPECT_GE(test, post[IBMVFC_AE_FPIN_PORT_CONGESTED], + pre[IBMVFC_AE_FPIN_PORT_CONGESTED]+1); + KUNIT_EXPECT_GE(test, post[IBMVFC_AE_FPIN_PORT_CLEARED], + pre[IBMVFC_AE_FPIN_PORT_CLEARED]+1); + KUNIT_EXPECT_GE(test, post[IBMVFC_AE_FPIN_PORT_DEGRADED], + pre[IBMVFC_AE_FPIN_PORT_DEGRADED]+1); + KUNIT_EXPECT_GE(test, post[IBMVFC_AE_FPIN_CONGESTION_CLEARED], + pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED]+1); + + /* bad path */ + pre[IBMVFC_AE_FPIN_LINK_CONGESTED] =3D READ_ONCE(fc_host->fpin_stats.cn_d= evice_specific); + pre[IBMVFC_AE_FPIN_PORT_CONGESTED] =3D READ_ONCE(rport->fpin_stats.cn_dev= ice_specific); + pre[IBMVFC_AE_FPIN_PORT_CLEARED] =3D READ_ONCE(rport->fpin_stats.cn_clear= ); + pre[IBMVFC_AE_FPIN_PORT_DEGRADED] =3D READ_ONCE(rport->fpin_stats.li_fail= ure_unknown); + pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED] =3D READ_ONCE(fc_host->fpin_stats.= cn_clear); + + ae[0].subq.valid =3D 0x80; + ae[0].subq.link_state =3D IBMVFC_AE_LS_LINK_UP; + ae[0].subq.fpin_status =3D 0; /* bad value */ + ae[0].subq.event =3D cpu_to_be16(IBMVFC_AE_FPIN); + ae[0].subq.wwpn =3D cpu_to_be64(tgt->wwpn); + ae[0].subq.id.node_name =3D cpu_to_be64(tgt->ids.node_name); + ibmvfc_handle_async(&ae[0], vhost); + ae[0].subq.valid =3D 0; + wmb(); /* ensure valid bit clear is visible before checking stats */ + flush_workqueue(vhost->fpin_workq); + + post[IBMVFC_AE_FPIN_LINK_CONGESTED] =3D READ_ONCE(fc_host->fpin_stats.cn_= device_specific); + post[IBMVFC_AE_FPIN_PORT_CONGESTED] =3D READ_ONCE(rport->fpin_stats.cn_de= vice_specific); + post[IBMVFC_AE_FPIN_PORT_CLEARED] =3D READ_ONCE(rport->fpin_stats.cn_clea= r); + post[IBMVFC_AE_FPIN_PORT_DEGRADED] =3D READ_ONCE(rport->fpin_stats.li_fai= lure_unknown); + post[IBMVFC_AE_FPIN_CONGESTION_CLEARED] =3D READ_ONCE(fc_host->fpin_stats= .cn_clear); + + KUNIT_EXPECT_EQ(test, pre[IBMVFC_AE_FPIN_LINK_CONGESTED], + post[IBMVFC_AE_FPIN_LINK_CONGESTED]); + KUNIT_EXPECT_EQ(test, pre[IBMVFC_AE_FPIN_PORT_CONGESTED], + post[IBMVFC_AE_FPIN_PORT_CONGESTED]); + KUNIT_EXPECT_EQ(test, pre[IBMVFC_AE_FPIN_PORT_CLEARED], + post[IBMVFC_AE_FPIN_PORT_CLEARED]); + KUNIT_EXPECT_EQ(test, pre[IBMVFC_AE_FPIN_PORT_DEGRADED], + post[IBMVFC_AE_FPIN_PORT_DEGRADED]); + KUNIT_EXPECT_EQ(test, pre[IBMVFC_AE_FPIN_CONGESTION_CLEARED], + post[IBMVFC_AE_FPIN_CONGESTION_CLEARED]); + + put_device(&rport->dev); + kref_put(&tgt->kref, ibmvfc_release_tgt); + scsi_host_put(vhost->host); +} + static struct kunit_case ibmvfc_fpin_test_cases[] =3D { KUNIT_CASE(ibmvfc_async_fpin_test), + KUNIT_CASE(ibmvfc_full_fpin_test), {}, }; =20 --=20 2.55.0 From nobody Fri Sep 25 15:13:48 2026 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 9496D3C818D; Fri, 25 Sep 2026 04:48:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311725; cv=none; b=AB9br6KbZ1eTqg3KXQh3S80lcFBVieAejULpth7/kajymZk14laBAOzt8vdfOmCpA6bJ2XRwKc8aQUbvRWKRw6GWxeW7wRWLCxtjP5Df1BAnybh4J92IfHU8dH7los8QGUNiXglm8rtlUbEMqysQtkOTmNEx6O3UcA11xNAxPc4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311725; c=relaxed/simple; bh=rAnTVZBJakG52WLsuWLBsWFW5B+VSG6CKvfiDdh+x64=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tArG/QdawPVyFgExNLxUtt1KTmu99FiZYafDwmfl3/3xwRzL715GoW/JCtSHC6NMBf6yE2pOZBhNIEmHhZpEq9AFo7r6nYAKsLlLJpZR2qjjVGaKnmhp7tgMNaBYhxorlXEcfMaP3END7LV3+YpG6CUgqnNpjNZMyAeM2HqD1sA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=cztjSUyd; arc=none smtp.client-ip=148.163.156.1 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="cztjSUyd" Received: from pps.filterd (m0353729.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4aOIu2393772; Fri, 25 Sep 2026 04:48:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=x0YcKBRgZN6dyN1Bo xGupBY4J52MP3XNvWFFfqScVng=; b=cztjSUyd4qcj7xRtn5SKg/nPMWXJv6BmU Bxpij1PXMuWA8lsVjf8OOIPgG+Sr/ZR3TCaIIb9HGzpWrFkR0G5uc9ZhFiFsHDPp CZgD4MAIJ8QnILxEURt3IZQ32E6pchx5Evox5tHhiWXpR6s7g10fucdTY2035lBz VxPbKS92jEd+XMNkBUwus7jwXWtCwAmzaIj0c4dxh9OcMY+csyu6FykfB+QtiK7i CpM6jru6np/EF25ORKn7qai4jIHEUXCBpufc6WHMvras0bJZSVIy4VlpplDe/UXe o1oLqm3NfpuxtHrV41C0I4gBmXTD3neBn7u4jjQCX+ylYMofiqOoA== Received: from ppma13.dal12v.mail.ibm.com (dd.9e.1632.ip4.static.sl-reverse.com [50.22.158.221]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4gske2568k-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:30 +0000 (GMT) Received: from pps.filterd (ppma13.dal12v.mail.ibm.com [127.0.0.1]) by ppma13.dal12v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4lYIV1959518; Fri, 25 Sep 2026 04:48:29 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma13.dal12v.mail.ibm.com (PPS) with ESMTPS id 4gvu7ed91m-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:29 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay05.dal12v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68P4mS5p7733868 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Sep 2026 04:48:28 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A8D6458051; Fri, 25 Sep 2026 04:48:28 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B47635805C; Fri, 25 Sep 2026 04:48:27 +0000 (GMT) Received: from li-4c4c4544-0054-3910-8039-c3c04f423534.ibm.com.com (unknown [9.61.142.241]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 25 Sep 2026 04:48:27 +0000 (GMT) From: Tyrel Datwyler To: james.bottomley@hansenpartnership.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, brking@linux.ibm.com, davemarq@linux.ibm.com, Tyrel Datwyler Subject: [PATCH v11 08/11] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Date: Thu, 24 Sep 2026 21:48:57 -0700 Message-ID: <20260925044900.414340-9-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260925044900.414340-1-tyreld@linux.ibm.com> References: <20260925044900.414340-1-tyreld@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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: _0pQjgQPQX4DhgM9g74M-1h3fQQlH_5Q X-Authority-Analysis: v=2.4 cv=EOCTQFZC c=1 sm=1 tr=0 ts=6ab5fd1e cx=c_pps a=AfN7/Ok6k8XGzOShvHwTGQ==:117 a=AfN7/Ok6k8XGzOShvHwTGQ==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=uAbxVGIbfxUO_5tXvNgY:22 a=VnNF1IyMAAAA:8 a=w-kvVH-zZ2E7PihfXZYA:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX5yeTQZNKhXrY gn+RQzT0yw1CEj1s9g/knaUlNoI8Lzzfa+SeBEvTjUxOAp13cksfsyflh44ybTleLav+F/Zd9Ag vMwbqOGyjpJYmzHxa2UxDmlhxdvz0Sc= X-Proofpoint-GUID: _0pQjgQPQX4DhgM9g74M-1h3fQQlH_5Q X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX5P6R28GjWVCc XXNXKq4DFxRuw2OKhcMyjy7Am2bZQTQM5IOFRUpOxw40Bc3hNoDLwk3dweNgFSvlrml7yKOxlIz 4JjYtTBNrYqE91TgFWTG5gnoqqdMBb/oKnUMevZ6Ou68+t/k4nxfyU1Etc7QbNfOxVgSSfotT1M K5DDYll9ReyhpORHI53aKgNp8ag7pVV3h1XblxrQJFkqq0uM6e+aOkgSTT3O19cQ8jNw0xfCbTh 55RDX7PjA93zHAlQmD4VVYij3ZwLJ7UT25FS2KpxOMGjDchp0UOWGHWnPZ5KcxZfgEMusFfpjfr iThb49trYcCDzaLuIi8mWaaw24cN7fR3ZyFwFKB7bmjUKhn+M74xQS6iVeq2QGtbQ2KfdyJL8ae BerWBXhssHWfrAuUSUIRLyq3nkN/4Awf9kiq21REAB5RpsXKrug+amIgaJfjeAY2ljdm8i9Gy83 9K3Zk0lxm4/C54zyaVg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-25_02,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 phishscore=0 priorityscore=1501 clxscore=1015 spamscore=0 adultscore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609250018 Content-Type: text/plain; charset="utf-8" From: Dave Marquardt Add ibmvfc_interrupt_async_subq(), an IRQ handler dedicated to asynchronous sub-CRQ events from the adapter. The handler disables the sub-CRQ IRQ and then calls ibmvfc_drain_async_subq() to consume all pending entries before re-enabling interrupts. ibmvfc_drain_async_subq() holds the per-queue q_lock while processing. It loops over available CRQ entries via ibmvfc_next_scrq(), wrapping each in a typed struct ibmvfc_async_crq_event and dispatching it to ibmvfc_handle_async(), then clears the valid bit and issues a write barrier. After draining, it re-enables the sub-CRQ IRQ and performs one final check for a newly arrived entry to close the IRQ-enable race; if one is found it is processed before exiting the loop. Signed-off-by: Dave Marquardt Signed-off-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc-core.c | 54 +++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ib= mvfc-core.c index 321bb2f7219e..b354bfb1a9b6 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c @@ -4377,6 +4377,60 @@ static struct ibmvfc_crq *ibmvfc_next_scrq(struct ib= mvfc_queue *scrq) return crq; } =20 +static void ibmvfc_drain_async_subq(struct ibmvfc_queue *scrq) +{ + struct ibmvfc_host *vhost =3D scrq->vhost; + unsigned long flags; + struct ibmvfc_crq *crq; + int done =3D 0; + + spin_lock_irqsave(vhost->host->host_lock, flags); + spin_lock(scrq->q_lock); + while (!done) { + while ((crq =3D ibmvfc_next_scrq(scrq)) !=3D NULL) { + struct ibmvfc_async_crq_event ae =3D { + .type =3D IBMVFC_ASYNC_CRQ_SUB, + .subq =3D *(struct ibmvfc_async_sub_crq *)crq, + }; + ibmvfc_handle_async(&ae, scrq->vhost); + crq->valid =3D 0; + wmb(); /* complete write */ + } + + ibmvfc_toggle_scrq_irq(scrq, 1); + crq =3D ibmvfc_next_scrq(scrq); + if (crq !=3D NULL) { + struct ibmvfc_async_crq_event ae =3D { + .type =3D IBMVFC_ASYNC_CRQ_SUB, + .subq =3D *(struct ibmvfc_async_sub_crq *)crq, + }; + ibmvfc_toggle_scrq_irq(scrq, 0); + ibmvfc_handle_async(&ae, scrq->vhost); + crq->valid =3D 0; + wmb(); /* complete write */ + } else + done =3D 1; + } + spin_unlock(scrq->q_lock); + spin_unlock_irqrestore(vhost->host->host_lock, flags); +} + +/** + * ibmvfc_interrupt_async_subq - Handle an async event from the adapter + * @irq: interrupt request + * @scrq_instance: async subq + * + **/ +static irqreturn_t __maybe_unused ibmvfc_interrupt_async_subq(int irq, voi= d *scrq_instance) +{ + struct ibmvfc_queue *scrq =3D (struct ibmvfc_queue *)scrq_instance; + + ibmvfc_toggle_scrq_irq(scrq, 0); + ibmvfc_drain_async_subq(scrq); + + return IRQ_HANDLED; +} + static void ibmvfc_drain_sub_crq(struct ibmvfc_queue *scrq) { struct ibmvfc_crq *crq; --=20 2.55.0 From nobody Fri Sep 25 15:13:48 2026 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 EEDE53C4B93; Fri, 25 Sep 2026 04:48:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311725; cv=none; b=O21P+lgL6kO4PiaSwa/lO+P1RKQTkOM+xUApmWRsOYWT2AEFhJtfZefmcr9YyefqBQ//x++0Q/CbK+DzeIiAkjsc5tzQJZFiAbeldJZRzgBkhqI0hzHhop6tv+Nv6CYA16jrhj74TsuZHQCh5YXwv94QvJVQUvnOiTGVleuTlvw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311725; c=relaxed/simple; bh=X2EvCM9deXy63/aaKSEPfq4PaLkr2oxZA6VGcAY3nXM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=PSmZLWXEQi3MRAMYwf5Oq/YUuirgzFracWUCa+7nucNQQcnQrLP0HAk92kRAxIDikE/Am7Mb82pNLcikQifhSU1DjQWGAYtJcR3YjqEmIIFWEI1RRfqBMR1l3cVBW9oxGR1nZVG9C9GIdw3Oh7KoGg4igS2cMb+H0vUPTDCw0H0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=kAPXQaLy; arc=none smtp.client-ip=148.163.156.1 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="kAPXQaLy" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4bCMo076861; Fri, 25 Sep 2026 04:48:32 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=lHva3qHyfiorkR5sl QhUiG5gLBTSsam5DbS2KoBYTBQ=; b=kAPXQaLy0zVchWTKuvhB2ZhDQw8amICX9 mhRRvzohSkGNdynOHlga8zLbeJIktptdfFPKgAbvd7A6TXUPPJoHBgw0qB3mZdEE irNWpTgW/j0e2gA6ShPEVifAjlEQ+t/8gH7msZdopOE1ePqtsUE7uuIuky7fbXTp TybDfceSEBKWAZLXbpW+nv30cc8LSgFM7jADK4MBolYIrlfWd6Blc/C7NiHG4cSf B3ZIIg6HijsZutttXBTnXEmfx+UvMrVUdZGJzFa3fWn32T+11hp5FKF5U8n12aD9 E3vnXIO2IcyXqpSAfIX8zHA5OZYgQuHSMEKDJ2KDJUGUNcc5SmoKA== 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 4gskg2w99a-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:32 +0000 (GMT) Received: from pps.filterd (ppma21.wdc07v.mail.ibm.com [127.0.0.1]) by ppma21.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4lY4n3248902; Fri, 25 Sep 2026 04:48:31 GMT Received: from smtprelay03.wdc07v.mail.ibm.com ([172.16.1.70]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gvbt30y23-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:31 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay03.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68P4lkl030737130 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Sep 2026 04:47:46 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C64115805E; Fri, 25 Sep 2026 04:48:29 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCD605805C; Fri, 25 Sep 2026 04:48:28 +0000 (GMT) Received: from li-4c4c4544-0054-3910-8039-c3c04f423534.ibm.com.com (unknown [9.61.142.241]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 25 Sep 2026 04:48:28 +0000 (GMT) From: Tyrel Datwyler To: james.bottomley@hansenpartnership.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, brking@linux.ibm.com, davemarq@linux.ibm.com, Tyrel Datwyler Subject: [PATCH v11 09/11] scsi: ibmvfc: extend channel reg/dereg helpers for async sub-CRQ Date: Thu, 24 Sep 2026 21:48:58 -0700 Message-ID: <20260925044900.414340-10-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260925044900.414340-1-tyreld@linux.ibm.com> References: <20260925044900.414340-1-tyreld@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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: f3y3407mbuzHLIPBdVtScFPhtXuh8OqU X-Authority-Analysis: v=2.4 cv=I43w19gg c=1 sm=1 tr=0 ts=6ab5fd20 cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=-ETtxkXC2bfW1udaLu8A:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX8gGkaDLsV0rK ck96TzGE/g9qcNmG50uJZ1EsQJdET3ILCQ1scY/S04bIrDjZ5qejr2M/uCL+WNJwQ3RgJFFzo9k /fpGpojGS89ghyg33/XfXOfsNUoIAoaA49z1d/VUaxK+rbKt6GNog8WbdVGh8pL1hHY10xHfOll 2XGBzyzgKWub5y49RIbYI/CzidNocFen4SoR00g8oG7vbMZZX2VpcLzwa3ji9ujlyRozjhenkqb 1t/2AwvbvNHU/hRO0vfJMc+AQyAK01V9RC672TtAjGg5VAIUz0MgaOqdcr+cjV4HkVk3nxtHx5N 7M7LeNt4sYd6t2WwRQHG3aYaWv67Jr6GwmT2M8L1eh4XXODRjHIMT6IqBSwqc3yaS6rA+F+QUq4 bxVHdY9hzarS29g99M4ND6tthgE6K2H2HzIadbKWlTjIL4b/y4mzAWpz2dtIRyAY7wC1Yhci+Co 6+Uefp2x7ULNKN1ftkw== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX/iAY/FqP74SK ooVxiFN8lBPUP20jsIamwWyIQvRN7Few5FaERfSeENZhUxmrDtJZuHebxDjyjoSvI+DOkWyxkuQ YTIlb956Qk0/KtZU9+V5VJBwZrIuM7w= X-Proofpoint-GUID: f3y3407mbuzHLIPBdVtScFPhtXuh8OqU X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-25_02,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 adultscore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609250018 Content-Type: text/plain; charset="utf-8" From: Dave Marquardt ibmvfc_register_channel() and ibmvfc_deregister_channel() previously only handled SCSI and NVMe sub-CRQ channels identified by the channel protocol (IBMVFC_PROTO_SCSI, IBMVFC_PROTO_NVME). The async sub-CRQ had no registration path through these helpers, requiring separate handling. Add a new IBMVFC_PROTO_ASYNC protocol value to enum ibmvfc_protocol. Extend both functions to handle IBMVFC_PROTO_ASYNC channels: the IRQ is named "ibmvfc--async" and the handler is set to ibmvfc_interrupt_async_subq rather than the per-protocol ibmvfc_interrupt_mq handler. Remove the __maybe_unused annotation from ibmvfc_interrupt_async_subq now that it is referenced in ibmvfc_register_channel(). Error messages in both paths are updated to include the channel protocol to distinguish async sub-CRQ failures from SCSI/NVMe sub-CRQ failures. Kernel-doc headers are added to both functions. Signed-off-by: Dave Marquardt Signed-off-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc-core.c | 46 +++++++++++++++++++++++++---- drivers/scsi/ibmvscsi/ibmvfc.h | 1 + 2 files changed, 42 insertions(+), 5 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ib= mvfc-core.c index b354bfb1a9b6..b967c82e9943 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c @@ -4421,7 +4421,7 @@ static void ibmvfc_drain_async_subq(struct ibmvfc_que= ue *scrq) * @scrq_instance: async subq * **/ -static irqreturn_t __maybe_unused ibmvfc_interrupt_async_subq(int irq, voi= d *scrq_instance) +static irqreturn_t ibmvfc_interrupt_async_subq(int irq, void *scrq_instanc= e) { struct ibmvfc_queue *scrq =3D (struct ibmvfc_queue *)scrq_instance; =20 @@ -6812,6 +6812,21 @@ static int ibmvfc_init_crq(struct ibmvfc_host *vhost) return retrc; } =20 +/** + * ibmvfc_register_channel - Register a sub-CRQ channel with the hypervisor + * @vhost: ibmvfc host struct + * @channels: ibmvfc channels struct containing the channel array and prot= ocol + * @index: index into the channels array for the queue to register, or + * a negative value to register the async sub-CRQ + * + * Register a sub-CRQ with the hypervisor via h_reg_sub_crq, map its hardw= are + * IRQ to a Linux IRQ, and bind an interrupt handler to it. The handler is + * selected based on the channel protocol (SCSI or NVMe) for normal queues= , or + * set to the async sub-CRQ handler when @index is negative. + * + * Return value: + * 0 on success / non-zero on failure + **/ static int ibmvfc_register_channel(struct ibmvfc_host *vhost, struct ibmvfc_channels *channels, int index) @@ -6839,7 +6854,8 @@ static int ibmvfc_register_channel(struct ibmvfc_host= *vhost, =20 if (!scrq->irq) { rc =3D -EINVAL; - dev_err(dev, "Error mapping sub-crq[%d] irq\n", index); + dev_err(dev, "Error mapping protocol (%d) sub-crq[%d] irq\n", + channels->protocol, index); goto irq_failed; } =20 @@ -6854,6 +6870,11 @@ static int ibmvfc_register_channel(struct ibmvfc_hos= t *vhost, vdev->unit_address, index); scrq->handler =3D ibmvfc_interrupt_mq; break; + case IBMVFC_PROTO_ASYNC: + snprintf(scrq->name, sizeof(scrq->name), "ibmvfc-%x-async%d", + vdev->unit_address, index); + scrq->handler =3D ibmvfc_interrupt_async_subq; + break; default: dev_err(dev, "Unknown channel protocol (%d)\n", channels->protocol); @@ -6863,7 +6884,8 @@ static int ibmvfc_register_channel(struct ibmvfc_host= *vhost, rc =3D request_irq(scrq->irq, scrq->handler, 0, scrq->name, scrq); =20 if (rc) { - dev_err(dev, "Couldn't register sub-crq[%d] irq\n", index); + dev_err(dev, "Couldn't register protocol (%d) sub-crq[%d] irq\n", + channels->protocol, index); irq_dispose_mapping(scrq->irq); scrq->irq =3D 0; goto irq_failed; @@ -6883,6 +6905,18 @@ static int ibmvfc_register_channel(struct ibmvfc_hos= t *vhost, return rc; } =20 +/** + * ibmvfc_deregister_channel - Deregister a sub-CRQ channel with the hyper= visor + * @vhost: ibmvfc host struct + * @channels: ibmvfc channels struct containing the sub-CRQ array + * @index: index into the sub-CRQ array, or -1 to deregister the + * asynchronous sub-CRQ + * + * Frees the IRQ, disposes of the IRQ mapping, and calls H_FREE_SUB_CRQ to + * release the sub-CRQ with the hypervisor. On success the queue message + * buffer is zeroed and the current index is reset. If H_FREE_SUB_CRQ fail= s, + * an error is logged but the channel resources are cleaned up regardless. + */ static void ibmvfc_deregister_channel(struct ibmvfc_host *vhost, struct ibmvfc_channels *channels, int index) @@ -6905,8 +6939,10 @@ static void ibmvfc_deregister_channel(struct ibmvfc_= host *vhost, scrq->cookie); } while (rc =3D=3D H_BUSY || H_IS_LONG_BUSY(rc)); =20 - if (rc) - dev_err(dev, "Failed to free sub-crq[%d]: rc=3D%ld\n", index, rc); + if (rc) { + dev_err(dev, "Failed to free protocol (%d) sub-crq[%d]: rc=3D%ld\n", + channels->protocol, index, rc); + } =20 /* Clean out the queue */ if (scrq->msgs.handle) { diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h index ebbcb911f639..1cb6f20b0626 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.h +++ b/drivers/scsi/ibmvscsi/ibmvfc.h @@ -839,6 +839,7 @@ enum ibmvfc_target_action { enum ibmvfc_protocol { IBMVFC_PROTO_SCSI =3D 0, IBMVFC_PROTO_NVME =3D 1, + IBMVFC_PROTO_ASYNC =3D 2, }; =20 struct ibmvfc_target { --=20 2.55.0 From nobody Fri Sep 25 15:13:48 2026 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) (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 A9D363C552B; Fri, 25 Sep 2026 04:48:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.158.5 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311724; cv=none; b=lEFAHB8ziKHxu+jwDYsXaBrk0U6/73dCofnaUjqzNqrnV2nBkZMCx8Hg01nAk0LOKIJXxJ4jG42ZrW+eAE3N4LjxUwKB+ZSblvuJ4m+9oaH/vLIu1U5KP//xg2W9iUXls+HDx23IMAK4R7eAUNjKTgYnNHMGOjQTGPTbzzT25y8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311724; c=relaxed/simple; bh=t6r4pf/YsMaDxUAdIRNhB+IIMqmvjY3Pdre48Vtpqog=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EStiB+P+j75jucvyi8J2F7uEC9CvwT7GR0pMe1U8Ta/qu5s+84T+JqpY30QepQpW7C5uO+wYoleYksZ2CMS2D+XTXz4n7HTwjaLOvGGtEb6Feo5RukdzWT3f3Qowsp+yxYpD0105PYb1C7T5OSdZ1bmNWFYGh8zkFsBuwzHahA8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=Y/39kOCI; arc=none smtp.client-ip=148.163.158.5 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="Y/39kOCI" Received: from pps.filterd (m0356516.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4ahgE4105127; Fri, 25 Sep 2026 04:48:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=+j7nTqNEwZtgxCCRu 7SnVrHZbKR8QZSzP8ucB+kUa5k=; b=Y/39kOCId0nA3Cevp6OYXBQep11aqLtoj Ze1e9UxogCfTtOPBeh3ijZMFPTPvvua/6qBo+cOZ2deOzhWXPfvdU2O3vVCi97nW Fm+BR7hDrYhthtNSQBseLyoKm6z711dHff6gHtb0BoCZBhqrpS5mh7YANHAOvkMY OBq69goJ+xw+nOZleMWzBdeTf1KIZmfqGvkPqpbTxbY9OnLmcbjq2mmZM2pP1/8m D/khRK5mzgMBh2XFw0/bHJL/66sEddPKNbQOIjqCSk1hbd6GdpsYJxQQG/D7WvBw GQDi0t8W48F1nwz66XzsF+PxPgvEMM2y9HIgSQ5EXWcnSKzFYnyTQ== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4gske1vcwy-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:32 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4lgvk3288275; Fri, 25 Sep 2026 04:48:32 GMT Received: from smtprelay04.wdc07v.mail.ibm.com ([172.16.1.71]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gvbe21260-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:32 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay04.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68P4mVu054985034 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Sep 2026 04:48:31 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D560A5805F; Fri, 25 Sep 2026 04:48:30 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F3E8258051; Fri, 25 Sep 2026 04:48:29 +0000 (GMT) Received: from li-4c4c4544-0054-3910-8039-c3c04f423534.ibm.com.com (unknown [9.61.142.241]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 25 Sep 2026 04:48:29 +0000 (GMT) From: Tyrel Datwyler To: james.bottomley@hansenpartnership.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, brking@linux.ibm.com, davemarq@linux.ibm.com, Tyrel Datwyler Subject: [PATCH v11 10/11] scsi: ibmvfc: register and use asynchronous sub CRQ for events Date: Thu, 24 Sep 2026 21:48:59 -0700 Message-ID: <20260925044900.414340-11-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260925044900.414340-1-tyreld@linux.ibm.com> References: <20260925044900.414340-1-tyreld@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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: gDGEQOqyz8ctLBAQtzMRCwwbvdd5OyB1 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX+ra64T9Pa0q+ ynu3L84TfF8jpUwfyps+fxccbrCvIuctDQOYE5rrhy4XlUoBuAaAtjfTLDKrdwtxy+vLMlC6sdP TmWDGFqPmMI+dKEwFHVKNvQ8oK6L/JSMXv/6+mOKnWOcdgEUcUnF9V1xkEj3kFqc4vg+GrP24ax 0FgG6Mf8PvZty7o7deCxUVeghVc+22UqvR8xkBL+lwedVZiP5uCTRZhst4WwxgKxoAzOU0aHHO1 yBHZ8fIRLG17Q0h+NOEnt4WdfDYGnX2TkLOHahjN+WbzrAI9tJuoLkCAQHob5uxVRJpLXjV4xNq C0U26rLAP1V/r642S7beQL0UrdUKYDFXQJxg4GFZdni+fWTkBf2QKMHfl0hcZb1tojCEI4gY53h ehgzaFjhFQgATMOUKNURx+/rZR/o6iCU9GiqE1s1XOfVi63iorwq6AWnJN3++LS8kheCmsegjHc 5SMAJDVJ7PqoXR4qGcA== X-Authority-Analysis: v=2.4 cv=O/KsLx9W c=1 sm=1 tr=0 ts=6ab5fd21 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=QSdlH_gVqe-hz-qPZfMA:9 X-Proofpoint-Spam-Info: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfXyvgY+O7SKKji HuewNrqIu7SdG4eFNY8o4FBuUnkPvfnnQXW9BRgDe2BvFDsTnnkMTE+5qevolMD5i6Zu18OD/Wk H+UY/JtFUr+Oa+6KlfRYD2DZfjcBZgg= X-Proofpoint-GUID: gDGEQOqyz8ctLBAQtzMRCwwbvdd5OyB1 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-25_02,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 clxscore=1015 malwarescore=0 phishscore=0 impostorscore=0 suspectscore=0 bulkscore=0 priorityscore=1501 lowpriorityscore=0 adultscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609250018 Content-Type: text/plain; charset="utf-8" From: Dave Marquardt Wire the async sub-CRQ into the sub-CRQ lifecycle so it is allocated, registered, and freed alongside the SCSI channel queues. In ibmvfc_probe(), initialize vhost->async_scrqs with desired_queues=3D1, max_queues=3D1, and protocol=3DIBMVFC_PROTO_ASYNC. Add ibmvfc_release_chann= els() as a helper to free a channels array and its queue buffers. In ibmvfc_init_sub_crqs(), allocate the async sub-CRQ via ibmvfc_alloc_channels() before allocating the SCSI channels. Register it with the VIOS via ibmvfc_reg_sub_crqs(). Either failure disables multi-queue and aborts init. In ibmvfc_alloc_channels(), select IBMVFC_ASYNC_SUB_CRQ_FMT for async protocol channels instead of IBMVFC_SUB_CRQ_FMT, so the queue is sized for ibmvfc_async_sub_crq entries. In ibmvfc_release_sub_crqs(), ibmvfc_reenable_crq_queue(), and ibmvfc_reset_crq(), deregister and re-register the async sub-CRQ alongside the SCSI channel queues. In ibmvfc_channel_setup_done(), capture the async sub-CRQ handle returned by the VIOS in the channel setup response and store it in vhost->async_scrqs.scrqs[0].vios_cookie. Pass the async sub-CRQ cookie to the VIOS in ibmvfc_channel_setup() via async_sub_crq_handle. In ibmvfc_set_login_info(), advertise IBMVFC_USE_ASYNC_SUBQ, IBMVFC_CAN_HANDLE_FPIN, and IBMVFC_YES_SCSI capabilities whenever multi-queue channels are enabled. IBMVFC_YES_SCSI was previously only set for NVMe-enabled configurations; move it to the common multi-queue path so it is always advertised when channels are in use. Signed-off-by: Dave Marquardt Signed-off-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc-core.c | 82 ++++++++++++++++++++--------- 1 file changed, 58 insertions(+), 24 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ib= mvfc-core.c index b967c82e9943..a7bdae2c8571 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c @@ -964,6 +964,7 @@ static int ibmvfc_reenable_crq_queue(struct ibmvfc_host= *vhost) struct vio_dev *vdev =3D to_vio_dev(vhost->dev); unsigned long flags; =20 + ibmvfc_dereg_sub_crqs(vhost, &vhost->async_scrqs); ibmvfc_dereg_sub_crqs(vhost, &vhost->scsi_scrqs); ibmvfc_dereg_sub_crqs(vhost, &vhost->nvme_scrqs); =20 @@ -986,6 +987,7 @@ static int ibmvfc_reenable_crq_queue(struct ibmvfc_host= *vhost) spin_unlock(vhost->crq.q_lock); spin_unlock_irqrestore(vhost->host->host_lock, flags); =20 + ibmvfc_reg_sub_crqs(vhost, &vhost->scsi_scrqs); ibmvfc_reg_sub_crqs(vhost, &vhost->scsi_scrqs); ibmvfc_reg_sub_crqs(vhost, &vhost->nvme_scrqs); =20 @@ -1006,6 +1008,7 @@ static int ibmvfc_reset_crq(struct ibmvfc_host *vhost) struct vio_dev *vdev =3D to_vio_dev(vhost->dev); struct ibmvfc_queue *crq =3D &vhost->crq; =20 + ibmvfc_dereg_sub_crqs(vhost, &vhost->async_scrqs); ibmvfc_dereg_sub_crqs(vhost, &vhost->scsi_scrqs); ibmvfc_dereg_sub_crqs(vhost, &vhost->nvme_scrqs); =20 @@ -1042,6 +1045,7 @@ static int ibmvfc_reset_crq(struct ibmvfc_host *vhost) spin_unlock(vhost->crq.q_lock); spin_unlock_irqrestore(vhost->host->host_lock, flags); =20 + ibmvfc_reg_sub_crqs(vhost, &vhost->async_scrqs); ibmvfc_reg_sub_crqs(vhost, &vhost->scsi_scrqs); ibmvfc_reg_sub_crqs(vhost, &vhost->nvme_scrqs); =20 @@ -1584,9 +1588,11 @@ static void ibmvfc_set_login_info(struct ibmvfc_host= *vhost) =20 if (vhost->mq_enabled || vhost->using_channels) { login_info->capabilities |=3D cpu_to_be64(IBMVFC_CAN_USE_CHANNELS); + login_info->capabilities |=3D cpu_to_be64(IBMVFC_USE_ASYNC_SUBQ); + login_info->capabilities |=3D cpu_to_be64(IBMVFC_CAN_HANDLE_FPIN); + login_info->capabilities |=3D cpu_to_be64(IBMVFC_YES_SCSI); if (vhost->nvme_enabled) { login_info->capabilities |=3D cpu_to_be64(IBMVFC_YES_NVMEOF); - login_info->capabilities |=3D cpu_to_be64(IBMVFC_YES_SCSI); login_info->capabilities |=3D cpu_to_be64(IBMVFC_CAN_USE_WWPN_ALL); } } @@ -5783,6 +5789,7 @@ static void ibmvfc_channel_setup_done(struct ibmvfc_e= vent *evt) { struct ibmvfc_host *vhost =3D evt->vhost; struct ibmvfc_channel_setup *setup =3D vhost->channel_setup_buf; + struct ibmvfc_channels *async =3D &vhost->async_scrqs; struct ibmvfc_channels *scsi =3D &vhost->scsi_scrqs; struct ibmvfc_channels *nvme =3D &vhost->nvme_scrqs; u32 mad_status =3D be16_to_cpu(evt->xfer_iu->channel_setup.common.status); @@ -5813,6 +5820,7 @@ static void ibmvfc_channel_setup_done(struct ibmvfc_e= vent *evt) for (i =3D 0; i < nvme->active_queues; i++) nvme->scrqs[i].vios_cookie =3D be64_to_cpu(setup->channel_handles[scsi->active_queues + i]); + async->scrqs[0].vios_cookie =3D be64_to_cpu(setup->async_sub_crq_handle); =20 ibmvfc_dbg(vhost, "Using %u SCSI channels\n", scsi->active_queues); @@ -5847,6 +5855,7 @@ static void ibmvfc_channel_setup(struct ibmvfc_host *= vhost) struct ibmvfc_event *evt =3D ibmvfc_get_reserved_event(&vhost->crq); struct ibmvfc_channels *scsi =3D &vhost->scsi_scrqs; struct ibmvfc_channels *nvme =3D &vhost->nvme_scrqs; + struct ibmvfc_channels *async =3D &vhost->async_scrqs; unsigned int scsi_channels =3D min(scsi->desired_queues, vhost->max_vios_scsi_channels); unsigned int nvme_channels =3D @@ -5872,6 +5881,7 @@ static void ibmvfc_channel_setup(struct ibmvfc_host *= vhost) for (i =3D 0; i < nvme_channels; i++) setup_buf->channel_handles[scsi_channels + i] =3D cpu_to_be64(nvme->scrqs[i].cookie); + setup_buf->async_sub_crq_handle =3D cpu_to_be64(async->scrqs[0].cookie); } =20 ibmvfc_init_event(evt, ibmvfc_channel_setup_done, IBMVFC_MAD_FORMAT); @@ -6719,6 +6729,9 @@ static int ibmvfc_alloc_queue(struct ibmvfc_host *vho= st, queue->evt_depth =3D scsi_qdepth; queue->reserved_depth =3D IBMVFC_NUM_INTERNAL_SUBQ_REQ; break; + case IBMVFC_ASYNC_SUB_CRQ_FMT: + fmt_size =3D sizeof(*queue->msgs.async_scrq); + break; default: dev_warn(dev, "Unknown command/response queue message format: %d\n", fmt= ); return -EINVAL; @@ -6993,6 +7006,7 @@ static int ibmvfc_alloc_channels(struct ibmvfc_host *= vhost, struct ibmvfc_channels *channels) { struct ibmvfc_queue *scrq; + enum ibmvfc_msg_fmt fmt; int i, j; int rc =3D 0; =20 @@ -7000,9 +7014,10 @@ static int ibmvfc_alloc_channels(struct ibmvfc_host = *vhost, if (!channels->scrqs) return -ENOMEM; =20 + fmt =3D (channels->protocol !=3D IBMVFC_PROTO_ASYNC) ? IBMVFC_SUB_CRQ_FMT= : IBMVFC_ASYNC_SUB_CRQ_FMT; for (i =3D 0; i < channels->max_queues; i++) { scrq =3D &channels->scrqs[i]; - rc =3D ibmvfc_alloc_queue(vhost, scrq, IBMVFC_SUB_CRQ_FMT); + rc =3D ibmvfc_alloc_queue(vhost, scrq, fmt); if (rc) { for (j =3D i; j > 0; j--) { scrq =3D &channels->scrqs[j - 1]; @@ -7018,17 +7033,39 @@ static int ibmvfc_alloc_channels(struct ibmvfc_host= *vhost, return rc; } =20 +static void ibmvfc_release_channels(struct ibmvfc_host *vhost, + struct ibmvfc_channels *channels) +{ + struct ibmvfc_queue *scrq; + int i; + + if (channels->scrqs) { + for (i =3D 0; i < channels->max_queues; i++) { + scrq =3D &channels->scrqs[i]; + ibmvfc_free_queue(vhost, scrq); + } + + kfree(channels->scrqs); + channels->scrqs =3D NULL; + channels->active_queues =3D 0; + } +} + static void ibmvfc_init_sub_crqs(struct ibmvfc_host *vhost) { + ENTER; if (!vhost->mq_enabled) return; =20 - if (ibmvfc_alloc_channels(vhost, &vhost->scsi_scrqs)) { - vhost->do_enquiry =3D 0; - vhost->mq_enabled =3D 0; - return; - } + /* register async_sub_crq channel */ + if (ibmvfc_alloc_channels(vhost, &vhost->async_scrqs)) + goto out; + + ibmvfc_reg_sub_crqs(vhost, &vhost->async_scrqs); + + if (ibmvfc_alloc_channels(vhost, &vhost->scsi_scrqs)) + goto deregister_async_sub_crq; =20 ibmvfc_reg_sub_crqs(vhost, &vhost->scsi_scrqs); =20 @@ -7040,29 +7077,23 @@ static void ibmvfc_init_sub_crqs(struct ibmvfc_host= *vhost) } =20 LEAVE; -} - -static void ibmvfc_release_channels(struct ibmvfc_host *vhost, - struct ibmvfc_channels *channels) -{ - struct ibmvfc_queue *scrq; - int i; - - if (channels->scrqs) { - for (i =3D 0; i < channels->max_queues; i++) { - scrq =3D &channels->scrqs[i]; - ibmvfc_free_queue(vhost, scrq); - } + return; =20 - kfree(channels->scrqs); - channels->scrqs =3D NULL; - channels->active_queues =3D 0; - } +deregister_async_sub_crq: + ibmvfc_dereg_sub_crqs(vhost, &vhost->async_scrqs); + ibmvfc_release_channels(vhost, &vhost->async_scrqs); +out: + vhost->do_enquiry =3D 0; + vhost->mq_enabled =3D 0; + return; } =20 static void ibmvfc_release_sub_crqs(struct ibmvfc_host *vhost) { ENTER; + ibmvfc_dereg_sub_crqs(vhost, &vhost->async_scrqs); + ibmvfc_release_channels(vhost, &vhost->async_scrqs); + if (!vhost->scsi_scrqs.scrqs) return; =20 @@ -7328,6 +7359,9 @@ static int ibmvfc_probe(struct vio_dev *vdev, const s= truct vio_device_id *id) vhost->task_set =3D 1; =20 vhost->mq_enabled =3D mq_enabled; + vhost->async_scrqs.desired_queues =3D 1; + vhost->async_scrqs.max_queues =3D 1; + vhost->async_scrqs.protocol =3D IBMVFC_PROTO_ASYNC; vhost->scsi_scrqs.desired_queues =3D min(shost->nr_hw_queues, nr_scsi_cha= nnels); vhost->scsi_scrqs.max_queues =3D shost->nr_hw_queues; vhost->scsi_scrqs.protocol =3D IBMVFC_PROTO_SCSI; --=20 2.55.0 From nobody Fri Sep 25 15:13:48 2026 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 948CB3C6A38; Fri, 25 Sep 2026 04:48:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=148.163.156.1 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311726; cv=none; b=MqNkxgAXIXMDTKAg0AfUH1n5+EJo72Jpk6p5MSRdKrP7dX31rkNqtWm92rFeAj9A2I5XCHdpM+IRadPmh8gAqKPAJ7L8AG5H5t859SePHJFLwd6pCmS9CNE2qwIIHc1/H5D/e7nsWBIkAl+AjXWy7sF6BsqsVIg1+XacfSUbV+s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790311726; c=relaxed/simple; bh=iTz1p6vZkysxRECXnGuhIElZrCOt/9Vr5HGHjYNTPnA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UfrOIdxpxYqAvXHO2+7ryt1XnZCZU5wOUxQYs1GoyNr2afXUlmgKHfaiROpzABThdHBGkCbiRa62AXR7/F8cq+knJyKRJxYCoaAmTRLBtxeo6TpH324UAoIv3jfucSbxekeRmwDsyIac9hT1Kpc0hAipocqq92V/aYgplY2QBQE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.ibm.com; spf=pass smtp.mailfrom=linux.ibm.com; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b=kMuj8GlK; arc=none smtp.client-ip=148.163.156.1 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ibm.com header.i=@ibm.com header.b="kMuj8GlK" Received: from pps.filterd (m0360083.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4aO4e075187; Fri, 25 Sep 2026 04:48:35 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=cc :content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=pp1; bh=SfdbwNWYObttj2TTE T3jT0frGW0tAS0A2Bd1ClRJd2I=; b=kMuj8GlKNFVS5fLwdO4sesKY8zwS0SLBt kOrG5c5MrkJfCSVl5r8JGBsoWsnvlEGO0Ly/hB8o+tzzdSu6BYEoPr1t5f4BV0DQ NOYGDoZAybApGqSdJoEYxRPnbsa04WOi6b+55nFYJ7umME87UO80xDwYlNnV5Aej ibuDV/TTl/tEPiIfNLdrQ6vGQHgVoVIKc2nALw/F2HrIqo/os4mFUlMz6ookgCUh 3ezKVE5DpQbl9XCMsQTOS0HIai2kSAJp052cU88zc1RLhhj/QhhiW3O84ngFuW7w ku/Yt/HQCUp1ioCcK1sTSjrAM7usshsYWWAOsV8Lj9gNy36jA7J1w== Received: from ppma23.wdc07v.mail.ibm.com (5d.69.3da9.ip4.static.sl-reverse.com [169.61.105.93]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 4gskg2w99d-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:34 +0000 (GMT) Received: from pps.filterd (ppma23.wdc07v.mail.ibm.com [127.0.0.1]) by ppma23.wdc07v.mail.ibm.com (8.18.1.11/8.18.1.11) with ESMTP id 68P4lYHr3288207; Fri, 25 Sep 2026 04:48:33 GMT Received: from smtprelay06.wdc07v.mail.ibm.com ([172.16.1.73]) by ppma23.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gvbe21261-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 25 Sep 2026 04:48:33 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (smtpav02.dal12v.mail.ibm.com [10.241.53.101]) by smtprelay06.wdc07v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 68P4mWS412845734 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 25 Sep 2026 04:48:32 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EA8305805A; Fri, 25 Sep 2026 04:48:31 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0E47B58051; Fri, 25 Sep 2026 04:48:31 +0000 (GMT) Received: from li-4c4c4544-0054-3910-8039-c3c04f423534.ibm.com.com (unknown [9.61.142.241]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 25 Sep 2026 04:48:30 +0000 (GMT) From: Tyrel Datwyler To: james.bottomley@hansenpartnership.com, martin.petersen@oracle.com Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, brking@linux.ibm.com, davemarq@linux.ibm.com, Tyrel Datwyler Subject: [PATCH v11 11/11] scsi: ibmvfc: handle extended FPIN events Date: Thu, 24 Sep 2026 21:49:00 -0700 Message-ID: <20260925044900.414340-12-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260925044900.414340-1-tyreld@linux.ibm.com> References: <20260925044900.414340-1-tyreld@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: quoted-printable X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: XeLiPTpOfmBBan1wNo1TaogvvX1mvpwY X-Authority-Analysis: v=2.4 cv=I43w19gg c=1 sm=1 tr=0 ts=6ab5fd22 cx=c_pps a=3Bg1Hr4SwmMryq2xdFQyZA==:117 a=3Bg1Hr4SwmMryq2xdFQyZA==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=iQ6ETzBq9ecOQQE5vZCe:22 a=VnNF1IyMAAAA:8 a=YunXX2DFvQEblV2KXBkA:9 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfXwFIddiK0dRNy dnJuNuxuV5HsOqMaLvTNX6ukIbsJFkr78VBOI8MqIXRzYeft/ne4QNfAF8oh+8rEeXZhaPUOu1m 3IPTX962DZcLMffM6ywtwu+KBLnwtzo7wQK0DetHY3mv9g3njCd2MpcEEYGo8gyGtmn6PJvWmoK 18SCaE/xTJ6iGLwh/085fLwOH+38PnOEH1JjkegS/5I/pivb/AHkmGQ4mHwidERmz3yGiDqEHZl I+LtlV1AfDMk+lgutRqqX8KtCnPnFFySHk2klMLrJE1KSVyIUSFt1UQQ9ILNF/xgNwLMLZWzKHh xuuARLv/n2gC4FvrqJYlThWySSfH0fm68HwyTC3LFt6oa5av3dY0GgI1ocPl3BcYebIbL5+kJh1 VcDPp5ivEtzqBI+UKaCzGeuUbVszjZSAyp4IMzwDhXnY/50fnvbvoTHl8NgikkJlFdsF8sPPrRA ISxOIVokllw34DuohOg== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTI1MDAxOCBTYWx0ZWRfX7eex5Y4Sj/Pc E+/cChDCMhs9RqxT/FicfploO9lMXCEeZuxth3hL0vA9uXUf2bODR6CuAse/oZhviGIMv1NDK5K woIblTHMUm3LRbqKxxfn291MH9DAo+Q= X-Proofpoint-GUID: XeLiPTpOfmBBan1wNo1TaogvvX1mvpwY X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-09-25_02,2026-09-21_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 clxscore=1015 adultscore=0 suspectscore=0 impostorscore=0 lowpriorityscore=0 bulkscore=0 phishscore=0 priorityscore=1501 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609250018 Content-Type: text/plain; charset="utf-8" From: Dave Marquardt Implement support for extended FPIN messages received via the asynchronous sub-queue, completing full FPIN functionality. Extended FPIN messages provide more detailed information about fabric events compared to basic FPIN messages, including specific event types, modifiers, thresholds, and event counts. Add ibmvfc_ext_fpin_to_desc() to convert extended FPIN messages from async sub-queue format to fc_els_fpin structures with complete descriptor information. Update ibmvfc_process_async_work() and ibmvfc_handle_async() to zero node_name and dispatch to ibmvfc_ext_fpin_to_desc() when the IBMVFC_ASYNC_IS_FPIN_EXT flag is set. Set the IBMVFC_CAN_HANDLE_FPIN_EXT capability bit during login to inform VIOS that the client can process extended FPIN messages. Also add the IBMVFC_SUPPORT_FPIN_EXT response capability bit definition used to gate extended FPIN processing. Add KUnit tests to exercise extended FPIN event handling across all FPIN status and event type combinations. struct ibmvfc_async_subq_fpin uses volatile on its valid and wwpn fields, consistent with the existing ibmvfc_crq, ibmvfc_async_crq, and ibmvfc_async_sub_crq structs in ibmvfc.h, all of which mark their hardware-owned ring-buffer fields volatile to prevent the compiler from caching or eliminating reads of memory written directly by the VIOS. Signed-off-by: Dave Marquardt Signed-off-by: Tyrel Datwyler --- drivers/scsi/ibmvscsi/ibmvfc-core.c | 67 ++++++++++++- drivers/scsi/ibmvscsi/ibmvfc.h | 30 ++++++ drivers/scsi/ibmvscsi/ibmvfc_kunit.c | 135 +++++++++++++++++++++++++++ 3 files changed, 228 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ib= mvfc-core.c index a7bdae2c8571..a765b3c2b942 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c @@ -1591,6 +1591,7 @@ static void ibmvfc_set_login_info(struct ibmvfc_host = *vhost) login_info->capabilities |=3D cpu_to_be64(IBMVFC_USE_ASYNC_SUBQ); login_info->capabilities |=3D cpu_to_be64(IBMVFC_CAN_HANDLE_FPIN); login_info->capabilities |=3D cpu_to_be64(IBMVFC_YES_SCSI); + login_info->capabilities |=3D cpu_to_be64(IBMVFC_CAN_HANDLE_FPIN_EXT); if (vhost->nvme_enabled) { login_info->capabilities |=3D cpu_to_be64(IBMVFC_YES_NVMEOF); login_info->capabilities |=3D cpu_to_be64(IBMVFC_CAN_USE_WWPN_ALL); @@ -3471,6 +3472,41 @@ ibmvfc_full_fpin_to_desc(struct ibmvfc_async_sub_crq= *ibmvfc_fpin) cpu_to_be32(1)); } =20 +/** + * ibmvfc_ext_fpin_to_desc(): allocate and populate a struct fc_els_fpin s= truct + * containing a descriptor. + * @ibmvfc_fpin: Pointer to async subq FPIN data + * + * Allocate a struct fc_els_fpin containing a descriptor and populate + * based on data from *ibmvfc_fpin. + * + * Return: + * NULL - unable to allocate structure + * non-NULL - pointer to populated struct fc_els_fpin + */ +static struct fc_els_fpin * +ibmvfc_ext_fpin_to_desc(struct ibmvfc_async_subq_fpin *ibmvfc_fpin) +{ + u8 flags =3D ibmvfc_fpin->fpin_data.flags; + __be32 threshold =3D cpu_to_be32(IBMVFC_FPIN_DEFAULT_EVENT_THRESHOLD); + __be16 modifier =3D 0; + __be32 count =3D cpu_to_be32(1); + __be16 type =3D 0; + + if (flags & IBMVFC_FPIN_EVENT_TYPE_VALID) + type =3D ibmvfc_fpin->fpin_data.event_type; + if (flags & IBMVFC_FPIN_MODIFIER_VALID) + modifier =3D ibmvfc_fpin->fpin_data.event_type_modifier; + if (flags & IBMVFC_FPIN_THRESHOLD_VALID) + threshold =3D ibmvfc_fpin->fpin_data.event_threshold; + if (flags & IBMVFC_FPIN_EVENT_COUNT_VALID) + count =3D ibmvfc_fpin->fpin_data.event_data.event_count; + + return ibmvfc_common_fpin_to_desc(ibmvfc_fpin->fpin_status, + ibmvfc_fpin->wwpn, type, + modifier, threshold, count); +} + /** * ibmvfc_find_target - Search for a target in a target list * @target_list: list head of targets to search @@ -3509,6 +3545,7 @@ static struct ibmvfc_target *ibmvfc_find_target(struc= t list_head *target_list, static void ibmvfc_process_async_work(struct work_struct *work) { struct ibmvfc_async_sub_crq *subq =3D NULL; + struct ibmvfc_async_subq_fpin *sqfpin; struct ibmvfc_async_work *aw; struct ibmvfc_async_crq *crq =3D NULL; struct ibmvfc_target *tgt; @@ -3525,7 +3562,10 @@ static void ibmvfc_process_async_work(struct work_st= ruct *work) subq =3D &aw->event.subq; scsi_id =3D 0; wwpn =3D subq->wwpn; - node_name =3D (subq->flags & IBMVFC_ASYNC_ID_IS_ASSOC_ID) ? 0 : subq->id= .node_name; + if (subq->flags & (IBMVFC_ASYNC_IS_FPIN_EXT | IBMVFC_ASYNC_ID_IS_ASSOC_I= D)) + node_name =3D 0; + else + node_name =3D subq->id.node_name; } else { crq =3D &aw->event.async_crq; scsi_id =3D crq->scsi_id; @@ -3555,8 +3595,24 @@ static void ibmvfc_process_async_work(struct work_st= ruct *work) =20 if (crq) fpin =3D ibmvfc_basic_fpin_to_desc(crq, tgt->wwpn); - else - fpin =3D ibmvfc_full_fpin_to_desc(subq); + else { + static_assert(sizeof(struct ibmvfc_async_subq_fpin) =3D=3D + sizeof(struct ibmvfc_async_sub_crq)); + static_assert(offsetof(struct ibmvfc_async_subq_fpin, fpin_data) =3D=3D + offsetof(struct ibmvfc_async_sub_crq, nport_id)); + sqfpin =3D (struct ibmvfc_async_subq_fpin *)subq; + if ((subq->flags & IBMVFC_ASYNC_IS_FPIN_EXT) =3D=3D 0) { + fpin =3D ibmvfc_full_fpin_to_desc(subq); + } else if (!(sqfpin->fpin_data.flags & IBMVFC_FPIN_EVENT_TYPE_VALID)) { + dev_err_ratelimited(vhost->dev, + "Invalid extended FPIN event received\n"); + } else if (!ibmvfc_check_caps(vhost, IBMVFC_SUPPORT_FPIN_EXT)) { + dev_err_ratelimited(vhost->dev, + "Unexpected extended FPIN event received\n"); + } else { + fpin =3D ibmvfc_ext_fpin_to_desc(sqfpin); + } + } =20 if (fpin) { fc_host_fpin_rcv(tgt->vhost->host, @@ -3598,7 +3654,10 @@ VISIBLE_IF_KUNIT void ibmvfc_handle_async(struct ibm= vfc_async_crq_event *ae, link_state =3D subq->link_state; scsi_id =3D 0; wwpn =3D subq->wwpn; - node_name =3D subq->flags & IBMVFC_ASYNC_ID_IS_ASSOC_ID ? 0 : subq->id.n= ode_name; + if (subq->flags & (IBMVFC_ASYNC_IS_FPIN_EXT | IBMVFC_ASYNC_ID_IS_ASSOC_I= D)) + node_name =3D 0; + else + node_name =3D subq->id.node_name; } else { async_crq =3D &ae->async_crq; event =3D be64_to_cpu(async_crq->event); diff --git a/drivers/scsi/ibmvscsi/ibmvfc.h b/drivers/scsi/ibmvscsi/ibmvfc.h index 1cb6f20b0626..2d73df686897 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc.h +++ b/drivers/scsi/ibmvscsi/ibmvfc.h @@ -210,6 +210,7 @@ struct ibmvfc_npiv_login { #define IBMVFC_CAN_USE_WWPN_ALL 0x080 #define IBMVFC_USE_ASYNC_SUBQ 0x100 #define IBMVFC_CAN_USE_NOOP_CMD 0x200 +#define IBMVFC_CAN_HANDLE_FPIN_EXT 0x800 __be64 node_name; struct srp_direct_buf async; u8 partition_name[IBMVFC_MAX_NAME]; @@ -261,6 +262,7 @@ struct ibmvfc_npiv_login_resp { #define IBMVFC_SUPPORT_WWPN_ALL 0x0400 #define IBMVFC_ASYNC_SUBQ 0x0800 #define IBMVFC_SUPPORT_NOOP_CMD 0x1000 +#define IBMVFC_SUPPORT_FPIN_EXT 0x2000 __be32 max_cmds; __be32 scsi_id_sz; __be64 max_dma_len; @@ -786,6 +788,34 @@ struct ibmvfc_async_sub_crq { } id; } __packed __aligned(8); =20 +struct ibmvfc_fpin_data { +#define IBMVFC_FPIN_EVENT_TYPE_VALID 0x01 +#define IBMVFC_FPIN_MODIFIER_VALID 0x02 +#define IBMVFC_FPIN_THRESHOLD_VALID 0x04 +#define IBMVFC_FPIN_SEVERITY_VALID 0x08 +#define IBMVFC_FPIN_EVENT_COUNT_VALID 0x10 + u8 flags; + u8 reserved[3]; + __be16 event_type; + __be16 event_type_modifier; + __be32 event_threshold; + union { + u8 severity; + __be32 event_count; + } event_data; +} __packed __aligned(8); + +struct ibmvfc_async_subq_fpin { + volatile u8 valid; + u8 flags; + u8 link_state; + u8 fpin_status; + __be16 event; + __be16 pad; + volatile __be64 wwpn; + struct ibmvfc_fpin_data fpin_data; +} __packed __aligned(8); + enum ibmvfc_async_crq_type { IBMVFC_ASYNC_CRQ_MAIN =3D 0, IBMVFC_ASYNC_CRQ_SUB, diff --git a/drivers/scsi/ibmvscsi/ibmvfc_kunit.c b/drivers/scsi/ibmvscsi/i= bmvfc_kunit.c index 6cd9e701ba54..c60251dc00c5 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc_kunit.c +++ b/drivers/scsi/ibmvscsi/ibmvfc_kunit.c @@ -3,6 +3,7 @@ #include #include #include +#include #include #include #include "ibmvfc.h" @@ -257,9 +258,143 @@ static void ibmvfc_full_fpin_test(struct kunit *test) scsi_host_put(vhost->host); } =20 +#define IBMVFC_TEST_FPIN_EXT(fs, ev, stat, crq) { \ + struct ibmvfc_async_crq_event ae =3D { .type =3D IBMVFC_ASYNC_CRQ_SUB }; \ + (crq).valid =3D 0x80; \ + (crq).flags =3D IBMVFC_ASYNC_IS_FPIN_EXT; \ + (crq).link_state =3D IBMVFC_AE_LS_LINK_UP; \ + (crq).fpin_status =3D (fs); \ + (crq).event =3D cpu_to_be16(IBMVFC_AE_FPIN); \ + (crq).wwpn =3D cpu_to_be64(tgt->wwpn); \ + (crq).fpin_data.flags =3D IBMVFC_FPIN_EVENT_TYPE_VALID; \ + (crq).fpin_data.event_type =3D cpu_to_be16((ev)); \ + ae.subq =3D *(struct ibmvfc_async_sub_crq *)&(crq); \ + pre =3D READ_ONCE(rport->fpin_stats.stat); \ + ibmvfc_handle_async(&ae, vhost); \ + flush_workqueue(vhost->fpin_workq); \ + post =3D READ_ONCE(rport->fpin_stats.stat); \ +} + +/** + * ibmvfc_extended_fpin_test - unit test for extended FPIN events + * @test: pointer to kunit structure + * + * Note: This test exercises extended FPIN code paths but does not check + * that statistics are correctly updated. + * + * Return: void + */ +static void ibmvfc_extended_fpin_test(struct kunit *test) +{ + enum ibmvfc_ae_fpin_status fs; + struct ibmvfc_async_subq_fpin crq[IBMVFC_AE_FPIN_CONGESTION_CLEARED+1] = =3D {}; + struct ibmvfc_async_subq_fpin + crqcn[IBMVFC_AE_FPIN_PORT_CONGESTED][FPIN_CONGN_DEVICE_SPEC+1] =3D {}; + struct ibmvfc_async_subq_fpin crqportdg[FPIN_LI_DEVICE_SPEC+1] =3D {}; + struct ibmvfc_target *tgt; + struct ibmvfc_host *vhost; + struct fc_rport *rport; + LIST_HEAD(evt_doneq); + unsigned long flags; + u64 pre, post; + + vhost =3D ibmvfc_get_first_vhost(); + if (!vhost) + kunit_skip(test, "No ibmvfc devices available"); + + spin_lock_irqsave(vhost->host->host_lock, flags); + if (vhost->scsi_scrqs.num_targets < 1) { + spin_unlock_irqrestore(vhost->host->host_lock, flags); + scsi_host_put(vhost->host); + kunit_skip(test, "No targets"); + } + tgt =3D list_first_entry(&vhost->scsi_scrqs.targets, struct ibmvfc_target= , queue); + if (!tgt->rport) { + spin_unlock_irqrestore(vhost->host->host_lock, flags); + scsi_host_put(vhost->host); + kunit_skip(test, "No rport"); + } + rport =3D tgt->rport; + get_device(&rport->dev); + kref_get(&tgt->kref); + spin_unlock_irqrestore(vhost->host->host_lock, flags); + + for (fs =3D IBMVFC_AE_FPIN_LINK_CONGESTED; fs <=3D IBMVFC_AE_FPIN_CONGEST= ION_CLEARED; fs++) { + switch (fs) { + case IBMVFC_AE_FPIN_PORT_CLEARED: + case IBMVFC_AE_FPIN_CONGESTION_CLEARED: { + struct ibmvfc_async_crq_event ae =3D { .type =3D IBMVFC_ASYNC_CRQ_SUB }; + + crq[fs].valid =3D 0x80; + crq[fs].flags =3D IBMVFC_ASYNC_IS_FPIN_EXT; + crq[fs].link_state =3D IBMVFC_AE_LS_LINK_UP; + crq[fs].fpin_status =3D fs; + crq[fs].event =3D cpu_to_be16(IBMVFC_AE_FPIN); + crq[fs].wwpn =3D cpu_to_be64(tgt->wwpn); + crq[fs].fpin_data.flags =3D IBMVFC_FPIN_EVENT_TYPE_VALID; + crq[fs].fpin_data.event_type =3D cpu_to_be16(FPIN_CONGN_CLEAR); + ae.subq =3D *(struct ibmvfc_async_sub_crq *)&crq[fs]; + pre =3D READ_ONCE(rport->fpin_stats.cn_clear); + ibmvfc_handle_async(&ae, vhost); + flush_workqueue(vhost->fpin_workq); + post =3D READ_ONCE(rport->fpin_stats.cn_clear); + break; + } + case IBMVFC_AE_FPIN_LINK_CONGESTED: + case IBMVFC_AE_FPIN_PORT_CONGESTED: + IBMVFC_TEST_FPIN_EXT(fs, FPIN_CONGN_CLEAR, cn_clear, + crqcn[fs-1][FPIN_CONGN_CLEAR]); + IBMVFC_TEST_FPIN_EXT(fs, FPIN_CONGN_LOST_CREDIT, + cn_lost_credit, + crqcn[fs-1][FPIN_CONGN_LOST_CREDIT]); + IBMVFC_TEST_FPIN_EXT(fs, FPIN_CONGN_CREDIT_STALL, + cn_credit_stall, + crqcn[fs-1][FPIN_CONGN_CREDIT_STALL]); + IBMVFC_TEST_FPIN_EXT(fs, FPIN_CONGN_OVERSUBSCRIPTION, + cn_oversubscription, + crqcn[fs-1][FPIN_CONGN_OVERSUBSCRIPTION]); + IBMVFC_TEST_FPIN_EXT(fs, FPIN_CONGN_DEVICE_SPEC, + cn_device_specific, + crqcn[fs-1][FPIN_CONGN_DEVICE_SPEC]); + break; + case IBMVFC_AE_FPIN_PORT_DEGRADED: + IBMVFC_TEST_FPIN_EXT(fs, FPIN_LI_UNKNOWN, + li_failure_unknown, + crqportdg[FPIN_LI_UNKNOWN]); + IBMVFC_TEST_FPIN_EXT(fs, FPIN_LI_LINK_FAILURE, + li_link_failure_count, + crqportdg[FPIN_LI_LINK_FAILURE]); + IBMVFC_TEST_FPIN_EXT(fs, FPIN_LI_LOSS_OF_SYNC, + li_loss_of_sync_count, + crqportdg[FPIN_LI_LOSS_OF_SYNC]); + IBMVFC_TEST_FPIN_EXT(fs, FPIN_LI_LOSS_OF_SIG, + li_loss_of_signals_count, + crqportdg[FPIN_LI_LOSS_OF_SIG]); + IBMVFC_TEST_FPIN_EXT(fs, FPIN_LI_PRIM_SEQ_ERR, + li_prim_seq_err_count, + crqportdg[FPIN_LI_PRIM_SEQ_ERR]); + IBMVFC_TEST_FPIN_EXT(fs, FPIN_LI_INVALID_TX_WD, + li_invalid_tx_word_count, + crqportdg[FPIN_LI_INVALID_TX_WD]); + IBMVFC_TEST_FPIN_EXT(fs, FPIN_LI_INVALID_CRC, + li_invalid_crc_count, + crqportdg[FPIN_LI_INVALID_CRC]); + IBMVFC_TEST_FPIN_EXT(fs, FPIN_LI_DEVICE_SPEC, + li_device_specific, + crqportdg[FPIN_LI_DEVICE_SPEC]); + break; + } + } + + put_device(&rport->dev); + kref_put(&tgt->kref, ibmvfc_release_tgt); + scsi_host_put(vhost->host); +} + static struct kunit_case ibmvfc_fpin_test_cases[] =3D { KUNIT_CASE(ibmvfc_async_fpin_test), KUNIT_CASE(ibmvfc_full_fpin_test), + KUNIT_CASE(ibmvfc_extended_fpin_test), {}, }; =20 --=20 2.55.0