From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 F32804E432E; Wed, 7 Oct 2026 19:25:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791401148; cv=none; b=HSIlFVDFe24AJbe9xBvpQr7RPjdGEJy37OCMEdn6F+gx9OiakZ4UE0gz0dSAQVkgY1p36xETVa6r7vnY3I05BEwHBaZOwE95FhXx7U+d5gWKBhLik3L3VjSYnzkiPZ/dROWBbU533Z3gkZLfKuA2MvsfpvVw+bwvkxqOWJrNwss= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791401148; c=relaxed/simple; bh=V09RjvzolNHWRszOqYf7WLNZkg/MCRYg5KvXw/oqMPY=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=gAh03UBpZRjBheemxFu3NgkqvsV9JpNPB+EHe84km2yZwed8OBMigp1qI+RvT4JDYqPVcWNjhQLHqwxkYXbqkohTpFVqNqqH2yIbYSv9LK+WNxW/PMC3lGrnuRJfz0C0XIR4tLrKhieVktgA205QKvcPGif+1sbwGifhQrzadc0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=SavFRQCw; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="SavFRQCw" Received: by smtp.kernel.org (Postfix) with ESMTPS id CCD54C2BCFA; Wed, 7 Oct 2026 19:25:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1791401147; bh=V09RjvzolNHWRszOqYf7WLNZkg/MCRYg5KvXw/oqMPY=; h=From:Date:Subject:References:In-Reply-To:To:Cc:Reply-To:From; b=SavFRQCwQ/fXVAbZ1+nyCjpeXpD7DtBK+2v9RpsJo1JJYeYHmjtxgvf/TCtEtXMUe mtAnHhvWJ4RaH+DW0qYCbYY1mXAQLmeWitlFAkk0fU3qHk+ftyzgckoGHbMIyblg39 Qm8MoMueYB3v/vU+spcaZr418N6H9+Rsh4Ib6ipgEur0SDg949/Kd4mFnedjnSTznK unqLwTD4LBaACoFVY2piLD1d1kLtA3hnx9HwIfecycMMCl26R4KhD8efUjwrnBUSmE OR6UeQFN1utHz2fZ6pr/d31itoiVmVGSsyKcWC89QwEORgHiTP44F89gQlRVkA5M9p XmIPNlAJRLBbA== Received: from aws-us-west-2-korg-lkml-1.web.codeaurora.org (localhost.localdomain [127.0.0.1]) by smtp.lore.kernel.org (Postfix) with ESMTP id BB77DCA6002; Wed, 7 Oct 2026 19:25:47 +0000 (UTC) From: Dave Marquardt via B4 Relay Date: Wed, 07 Oct 2026 14:25:52 -0500 Subject: [PATCH v13 08/11] scsi: ibmvfc: add interrupt routine for asynchronous sub CRQ Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20261007-ibmvfc-fpin-support-v13-8-b816abfa4fcc@linux.ibm.com> References: <20261007-ibmvfc-fpin-support-v13-0-b816abfa4fcc@linux.ibm.com> In-Reply-To: <20261007-ibmvfc-fpin-support-v13-0-b816abfa4fcc@linux.ibm.com> To: Madhavan Srinivasan , Michael Ellerman , Nicholas Piggin , "Christophe Leroy (CS GROUP)" , "James E.J. Bottomley" , "Martin K. Petersen" , Tyrel Datwyler Cc: linux-scsi@vger.kernel.org, linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org, Dave Marquardt X-Mailer: b4 0.16.0 X-Developer-Signature: v=1; a=ed25519-sha256; t=1791401146; l=3347; i=davemarq@linux.ibm.com; s=20260216; h=from:subject:message-id; bh=PHOqpk1WAAZzLwxgoVZ8eInjwKojHQ8iHX81s4h6paQ=; b=OdQ/o+gg/b+/vKdfX5waKve4FiUgZDzJK8JiQbrbxRSnjrTK3z76iXxbA+C54LxlQHY+6jUAK PjuGWJBuQUyC7OdHddHKt1PYAb9LLQRYWFLUkgXlx8+PkbYbJlgDe6V X-Developer-Key: i=davemarq@linux.ibm.com; a=ed25519; pk=vy0/nfobrje6EqZxuyw6a3ZstytG8WK2vf5Y3xtGrEg= X-Endpoint-Received: by B4 Relay for davemarq@linux.ibm.com/20260216 with auth_id=689 X-Original-From: Dave Marquardt Reply-To: davemarq@linux.ibm.com 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. Add ibmvfc_next_async_scrq() to traverse the async sub-CRQ ring directly via msgs.async_scrq[], returning a typed struct ibmvfc_async_sub_crq * without the cast that would be needed when going through ibmvfc_next_scrq(). ibmvfc_drain_async_subq() holds the host lock and per-queue q_lock while processing. It loops over available entries via ibmvfc_next_async_scrq(), wrapping each in a struct ibmvfc_async_crq_event and dispatching 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 | 66 +++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) diff --git a/drivers/scsi/ibmvscsi/ibmvfc-core.c b/drivers/scsi/ibmvscsi/ibmvfc-core.c index 6db9df91e9e6..32bc00a4be7e 100644 --- a/drivers/scsi/ibmvscsi/ibmvfc-core.c +++ b/drivers/scsi/ibmvscsi/ibmvfc-core.c @@ -4374,6 +4374,72 @@ static struct ibmvfc_crq *ibmvfc_next_scrq(struct ibmvfc_queue *scrq) return crq; } +static struct ibmvfc_async_sub_crq *ibmvfc_next_async_scrq(struct ibmvfc_queue *scrq) +{ + struct ibmvfc_async_sub_crq *crq; + + crq = &scrq->msgs.async_scrq[scrq->cur]; + if (crq->valid & 0x80) { + if (++scrq->cur == scrq->size) + scrq->cur = 0; + rmb(); + } else + crq = NULL; + + return crq; +} + +static void ibmvfc_drain_async_subq(struct ibmvfc_queue *scrq) +{ + struct ibmvfc_host *vhost = scrq->vhost; + struct ibmvfc_async_crq_event ae = { + .type = IBMVFC_ASYNC_CRQ_SUB, + }; + struct ibmvfc_async_sub_crq *crq; + unsigned long flags; + int done = 0; + + spin_lock_irqsave(&vhost->host->host_lock, flags); + spin_lock(scrq->q_lock); + while (!done) { + while ((crq = ibmvfc_next_async_scrq(scrq)) != NULL) { + ae.subq = *crq; + ibmvfc_handle_async(&ae, scrq->vhost); + crq->valid = 0; + wmb(); /* complete write */ + } + + ibmvfc_toggle_scrq_irq(scrq, 1); + crq = ibmvfc_next_async_scrq(scrq); + if (crq != NULL) { + ae.subq = *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