From mboxrd@z Thu Jan 1 00:00:00 1970 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 8FB523E49FC; Fri, 11 Sep 2026 05:48:51 +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=1789105736; cv=none; b=RgpRt6ql5jj0HSGtGeSsDqTgDcoO3d0SgHTzwvdI4S4V9IDgR7ag8z2GwSEjdqtgstZEqY6l/4YoSGP6375JXc4bPED1UyOQu6ay8jDuq0QPqKG2ezJpH0egHdj3FjviWToIngAocVRd+Ps+4y3jrdinPqCyEEKrGtbwaxoUNU8= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789105736; c=relaxed/simple; bh=p5vXNsatcsKu6BTWGdich00Ioopo731jxFYI9h8+j+I=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=d2gjHKBGqlJmVfNmha9ZjqtBpsx0FPDn4J0Rr/EDh3St+1EkdSN2JutItjlXFkXW/PnCqPJDr3wJtxhZalLxr4/WTzNtgokCPEvw2nf0SJBJc3Xxya2mDY0I2nzWilns6t/0iWCMXZPSwcBlofpNJdpsLHWFsiQI42zLGcSz/TI= 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=j0ekOoTI; 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="j0ekOoTI" 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 68B4VdkE649768; Fri, 11 Sep 2026 05:48:42 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=ni+/3gohnG3MAW9Q0 OSbSgTG99SHlk1/YroGK6/ZAyM=; b=j0ekOoTIo1nYAMfDwR3SoDkF6wNTOLTMx /WPwaugD0G3G7Qnd73yNvzBDHnBM9nLQXceXE3i/iZN+Y3y3RVegNwLbFOQvft1T iprhqNKiZ2dhrfMQsZ/Q3WO/CPgEtw0V4hYVnr+fZw5Fi1UMexeP1FfTrcsQI7W/ RdDJ/nYxsg2+JfLfi/li+y+xMNusfF1z9Fq52Pgl8IaewZrH31DrGy/AoJEHQs81 r0dUqUnq1pf/pc9HP0MCgfkFqYuGK1SYApakUzqyQAr6vprPQoLePR8swjNEFGdR KUuVyIqUhJbwWPZLo++nO+wrc3g/MJcASO++Bov2CuzockdY3Zo3A== 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 4gkd8s9f2x-1 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 05:48:42 +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 68B4K1cB1055905; Fri, 11 Sep 2026 05:48:41 GMT Received: from smtprelay05.dal12v.mail.ibm.com ([172.16.1.7]) by ppma21.wdc07v.mail.ibm.com (PPS) with ESMTPS id 4gkvvrchr5-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Fri, 11 Sep 2026 05:48:41 +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 68B5mekG25101046 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Fri, 11 Sep 2026 05:48:40 GMT Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6C9D45805C; Fri, 11 Sep 2026 05:48:40 +0000 (GMT) Received: from smtpav02.dal12v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CCEA658051; Fri, 11 Sep 2026 05:48:39 +0000 (GMT) Received: from li-4c4c4544-0054-3910-8039-c3c04f423534.ibm.com.com (unknown [9.61.103.123]) by smtpav02.dal12v.mail.ibm.com (Postfix) with ESMTP; Fri, 11 Sep 2026 05:48:39 +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 v10 5/9] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Date: Thu, 10 Sep 2026 22:48:28 -0700 Message-ID: <20260911054832.1311668-6-tyreld@linux.ibm.com> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260911054832.1311668-1-tyreld@linux.ibm.com> References: <20260911054832.1311668-1-tyreld@linux.ibm.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: WnmdxE_bVVe8hDInH5-725gmFTVI4Lbg X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwOTExMDA3NCBTYWx0ZWRfX26alpVCKcs+Y ZXyicQw2okKXH/0pgPt56sCw5a5iuMfT7d38+ymHr1T9Kq1BCVfu5pG9cee/Ae5cl1N3Zi5Ts88 3XsbscEFek3OC7rz2Xeql9PxeazsDu2bf+Rxp6lzqc6YLwcxzHh1usq+YL85+54u5mTaZqhUDpx rt9LJT4dtprh9/Nu4rk1EPHlxt8G+BLtWm+20er6kxTL0xB8B85XIVZsPq5y09ni0Y4IM/zUj7i JJl7dS+OyZpwWd/9IQVV//yNUE1a63qg0+m/RSbOAns0nqgI/kGSckD9b7NdcVfVYUJuVtYtciK M3QBb6yNXDGSffrRSK/eZB1m+T3/JSdLDghpA+Abx6JP6InNLgO6sgkNj4L4sSxPK9kO9i9+TX9 LawDUrqFGRbyxB3XF9ophto+him7P23BeREao3q68965JeuAMmDETgQJTN++K+dpLPmTJyJw7IF VJ0w8gASIak6qxY0Xnw== X-Proofpoint-Spam-Info: AW1haW4tMjYwOTExMDA3NCBTYWx0ZWRfX3DeekEi9BYrd Zw7BuAoSPDwVMFVEush0aaOaCgksDgoMPZfOHV5Ua7HmD/y+4ABZV9D9fdQ93UfQqA+unDnkUkw hm69rDMjTfmAB0CG2AfhJoYQPzaeQ/Y= X-Authority-Analysis: v=2.4 cv=MpXHeGae c=1 sm=1 tr=0 ts=6aa3963a cx=c_pps a=GFwsV6G8L6GxiO2Y/PsHdQ==:117 a=GFwsV6G8L6GxiO2Y/PsHdQ==:17 a=VdqzKS8jKosA:10 a=VkNPw1HP01LnGYTKEx00:22 a=RnoormkPH1_aCDwRdu11:22 a=Y2IxJ9c9Rs8Kov3niI8_:22 a=VnNF1IyMAAAA:8 a=xcGneSeZEGXdk-36SaIA:9 X-Proofpoint-GUID: WnmdxE_bVVe8hDInH5-725gmFTVI4Lbg 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-11_02,2026-09-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 suspectscore=0 priorityscore=1501 clxscore=1015 impostorscore=0 adultscore=0 spamscore=0 lowpriorityscore=0 bulkscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2609040000 definitions=main-2609110074 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. The handler is marked as __maybe_unused until a later patch when it is used. 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 [tyreld: added & operator to irqsave/restore calls] 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/ibmvfc-core.c index 9b66b45871b1..670f6b3a5476 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c @@ -4375,6 +4375,60 @@ static struct ibmvfc_crq *ibmvfc_next_scrq(struct ibmvfc_queue *scrq) return crq; } +static void ibmvfc_drain_async_subq(struct ibmvfc_queue *scrq) +{ + struct ibmvfc_host *vhost = scrq->vhost; + unsigned long flags; + struct ibmvfc_crq *crq; + int done = 0; + + spin_lock_irqsave(&vhost->host->host_lock, flags); + spin_lock(scrq->q_lock); + while (!done) { + while ((crq = ibmvfc_next_scrq(scrq)) != NULL) { + struct ibmvfc_async_crq_event ae = { + .type = IBMVFC_ASYNC_CRQ_SUB, + .subq = *(struct ibmvfc_async_sub_crq *)crq, + }; + ibmvfc_handle_async(&ae, scrq->vhost); + crq->valid = 0; + wmb(); /* complete write */ + } + + ibmvfc_toggle_scrq_irq(scrq, 1); + crq = ibmvfc_next_scrq(scrq); + if (crq != NULL) { + struct ibmvfc_async_crq_event ae = { + .type = IBMVFC_ASYNC_CRQ_SUB, + .subq = *(struct ibmvfc_async_sub_crq *)crq, + }; + ibmvfc_toggle_scrq_irq(scrq, 0); + ibmvfc_handle_async(&ae, scrq->vhost); + crq->valid = 0; + wmb(); /* complete write */ + } else + done = 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, void *scrq_instance) +{ + struct ibmvfc_queue *scrq = (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; -- 2.55.0