From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796387541; b=BHWVcoku2//L+584uel48V8brIyLjhowPOWXiwEIRn5yb/mateW8x9WArmZhDTBw3v6g +JukikCA+tHGri6Vts9TWVhDCw8k9GCr7H+NbiCYOD7xcv+w7S5V+RbwIoGkRsGswKxp3 NuRmMuvPi2qjozZpWBMKoAQFAbEkKUkpGbo2a8Fyo5U/rjQx/f86DIs7qdDMHtS/jJhMy IR8xy91nsThUzlA8VLZD8NjC4Rdn2Ro9Y80cuP3wvbFLEXZ0rvcnRNe0j0mGtfI8RoqO7 h5DjAfRJH9+mUsf0BOGDY9iylR2+GD13fzoH/sysfVJ3IsY2GyEqp5chdZDOxS4EGfQ== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796387541; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:User-Agent:X-stable:X-Patchwork-Hint: MIME-Version:Content-Transfer-Encoding; bh=PdkUmMikXULphpP7DgXCJpNA7cpMDlFZYR3v6dslMgo=; b=o/vViV+ImJSGupo20/wm0ugwplMQhSS8OUv37uyDgCRASjutU+fZbDOkOrC5oZi78gvm uZ4CSxm77YH+VTFqA2ZPS/3bbKriFQOHzFejC+jyifNdSvzJA+2+TjGGXNkMg3GTbtoMU B1b/GpK570sNOzvwDytB8eurBxprh/YlwbiklH3sIJ29TelCrh5kCzUFcMHQXbg7xlqfX o66UsmiBeS6dXYjmPErJMqtLTYZBlRyF0N15jgzOsmd/b5UgaU1tG2ZBl9UwtiPUu4aQD 3AbQVHo/vrP5L+f34cJGqysMx2bTasI/W5AKyMyLFxhDoiEO6PR7obwLi8WXoZVeiNA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JwZJFRgr; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9CD38606A322; Fri, 4 Dec 2026 12:32:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.a=rsa-sha256 header.s=korg header.b=JwZJFRgr Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B7CA1F000C2; Fri, 4 Dec 2026 12:32:20 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1796387541; bh=PdkUmMikXULphpP7DgXCJpNA7cpMDlFZYR3v6dslMgo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JwZJFRgr/jkrY7Wkd1mR1hHZglNU6Wwj99q91qaGjG9H9WsyPLIUhnGxgVwc2LN+e 0MjaF1iy6c3rukDR2IrCtdXbg1BNQzq944OP9wSH7pgcgA2GlaonSx1Xdpi67Wk7C7 gTeY210Vms503ZH+vgy0iOY6G00IVraQvPAhsf5U= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Adrian Hunter , Frank Li , Alexandre Belloni , Sasha Levin Subject: [PATCH 6.1 0289/1059] i3c: mipi-i3c-hci: Process multiple IBIs per interrupt Date: Fri, 4 Dec 2026 18:57:00 +0900 Message-ID: <20261204100651.764108805@linuxfoundation.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261204100643.980430235@linuxfoundation.org> References: <20261204100643.980430235@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore X-Mailing-List: patches@lists.linux.dev List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 6.1-stable review patch. If anyone has any objections, please let me know. ------------------ From: Adrian Hunter [ Upstream commit 5fbd0790af9484c251341e3ba2ebbb2887c570c8 ] INTR_IBI_READY indicates that one or more IBI Status Descriptors are present in the IBI ring. After clearing interrupt status, the interrupt handler processes only a single IBI even though additional IBIs may already be queued. The controller does not reassert INTR_IBI_READY solely because entries remain in the ring after interrupt status has been cleared. Consequently, the remaining IBIs are not processed until some later interrupt occurs, and can accumulate if IBIs arrive more often than the interrupt handler runs. Process all IBIs that are pending when the handler runs: capture the IBI enqueue pointer up front and continue until the dequeue pointer reaches that position. Fixes: 9ad9a52cce28 ("i3c/master: introduce the mipi-i3c-hci driver") Signed-off-by: Adrian Hunter Reviewed-by: Frank Li Link: https://patch.msgid.link/20260920151248.46936-10-adrian.hunter@intel.com Signed-off-by: Alexandre Belloni [ sashal: kept the branch's DBG() macro and its spinlock-protected dequeue pointer update, writing the fresh locked read back through *op1_val instead of a local. ] Signed-off-by: Sasha Levin --- drivers/i3c/master/mipi-i3c-hci/dma.c | 40 +++++++++++++++++---------- 1 file changed, 26 insertions(+), 14 deletions(-) diff --git a/drivers/i3c/master/mipi-i3c-hci/dma.c b/drivers/i3c/master/mipi-i3c-hci/dma.c index d1d92be403253..80dfd30f90116 100644 --- a/drivers/i3c/master/mipi-i3c-hci/dma.c +++ b/drivers/i3c/master/mipi-i3c-hci/dma.c @@ -594,24 +594,23 @@ static void hci_dma_recycle_ibi_slot(struct i3c_hci *hci, i3c_generic_ibi_recycle_slot(dev_ibi->pool, slot); } -static void hci_dma_process_ibi(struct i3c_hci *hci, struct hci_rh_data *rh) +static bool hci_dma_process_ibi(struct i3c_hci *hci, struct hci_rh_data *rh, + u32 *op1_val, unsigned int enq_ptr) { struct i3c_dev_desc *dev; struct i3c_hci_dev_data *dev_data; struct hci_dma_dev_ibi_data *dev_ibi; struct i3c_ibi_slot *slot; - u32 op1_val, op2_val, ibi_status_error; - unsigned int ptr, enq_ptr, deq_ptr; + u32 ibi_status_error; + unsigned int ptr, deq_ptr; unsigned int ibi_size, ibi_chunks, ibi_data_offset, first_part; int ibi_addr, last_ptr; void *ring_ibi_data; dma_addr_t ring_ibi_data_dma; - op1_val = rh_reg_read(RING_OPERATION1); - deq_ptr = FIELD_GET(RING_OP1_IBI_DEQ_PTR, op1_val); - - op2_val = rh_reg_read(RING_OPERATION2); - enq_ptr = FIELD_GET(RING_OP2_IBI_ENQ_PTR, op2_val); + deq_ptr = FIELD_GET(RING_OP1_IBI_DEQ_PTR, *op1_val); + if (deq_ptr == enq_ptr) + return false; ibi_status_error = 0; ibi_addr = -1; @@ -659,7 +658,7 @@ static void hci_dma_process_ibi(struct i3c_hci *hci, struct hci_rh_data *rh) if (last_ptr == -1) { /* this IBI sequence is not yet complete */ DBG("no LAST_STATUS available (e=%d d=%d)", enq_ptr, deq_ptr); - return; + return false; } deq_ptr = last_ptr + 1; deq_ptr %= rh->ibi_status_entries; @@ -732,10 +731,10 @@ static void hci_dma_process_ibi(struct i3c_hci *hci, struct hci_rh_data *rh) done: /* take care to update the ibi dequeue pointer atomically */ spin_lock(&rh->lock); - op1_val = rh_reg_read(RING_OPERATION1); - op1_val &= ~RING_OP1_IBI_DEQ_PTR; - op1_val |= FIELD_PREP(RING_OP1_IBI_DEQ_PTR, deq_ptr); - rh_reg_write(RING_OPERATION1, op1_val); + *op1_val = rh_reg_read(RING_OPERATION1); + *op1_val &= ~RING_OP1_IBI_DEQ_PTR; + *op1_val |= FIELD_PREP(RING_OP1_IBI_DEQ_PTR, deq_ptr); + rh_reg_write(RING_OPERATION1, *op1_val); spin_unlock(&rh->lock); /* update the chunk pointer */ @@ -744,6 +743,19 @@ static void hci_dma_process_ibi(struct i3c_hci *hci, struct hci_rh_data *rh) /* and tell the hardware about freed chunks */ rh_reg_write(CHUNK_CONTROL, rh_reg_read(CHUNK_CONTROL) + ibi_chunks); + + return true; +} + +static void hci_dma_drain_ibi_ring(struct i3c_hci *hci, struct hci_rh_data *rh) +{ + u32 op1_val = rh_reg_read(RING_OPERATION1); + u32 op2_val = rh_reg_read(RING_OPERATION2); + unsigned int enq_ptr = FIELD_GET(RING_OP2_IBI_ENQ_PTR, op2_val); + + /* Loop is bounded by enq_ptr. Further IBIs will re-assert INTR_IBI_READY */ + while (hci_dma_process_ibi(hci, rh, &op1_val, enq_ptr)) + ; } static bool hci_dma_irq_handler(struct i3c_hci *hci, unsigned int mask) @@ -768,7 +780,7 @@ static bool hci_dma_irq_handler(struct i3c_hci *hci, unsigned int mask) rh_reg_write(INTR_STATUS, status); if (status & INTR_IBI_READY) - hci_dma_process_ibi(hci, rh); + hci_dma_drain_ibi_ring(hci, rh); if (status & (INTR_TRANSFER_COMPLETION | INTR_TRANSFER_ERR)) hci_dma_xfer_done(hci, rh); if (status & INTR_RING_OP) -- 2.53.0