Skip to content

Commit b24823e

Browse files
Alexandre Bouninetorvalds
authored andcommitted
rapidio/tsi721: fix queue wrapping bug in inbound doorbell handler
Fix a bug that causes a kernel panic when the number of received doorbells is larger than number of entries in the inbound doorbell queue (current default value = 512). Another possible indication for this bug is large number of spurious doorbells reported by tsi721 driver after reaching the queue size maximum. Signed-off-by: Alexandre Bounine <alexandre.bounine@idt.com> Cc: Chul Kim <chul.kim@idt.com> Cc: Matt Porter <mporter@kernel.crashing.org> Cc: <stable@vger.kernel.org> [3.2.x+] Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
1 parent e6ca7b8 commit b24823e

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

‎drivers/rapidio/devices/tsi721.c‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,13 +410,14 @@ static void tsi721_db_dpc(struct work_struct *work)
410410
*/
411411
mport = priv->mport;
412412

413-
wr_ptr = ioread32(priv->regs + TSI721_IDQ_WP(IDB_QUEUE));
414-
rd_ptr = ioread32(priv->regs + TSI721_IDQ_RP(IDB_QUEUE));
413+
wr_ptr = ioread32(priv->regs + TSI721_IDQ_WP(IDB_QUEUE)) % IDB_QSIZE;
414+
rd_ptr = ioread32(priv->regs + TSI721_IDQ_RP(IDB_QUEUE)) % IDB_QSIZE;
415415

416416
while (wr_ptr != rd_ptr) {
417417
idb_entry = (u64 *)(priv->idb_base +
418418
(TSI721_IDB_ENTRY_SIZE * rd_ptr));
419419
rd_ptr++;
420+
rd_ptr %= IDB_QSIZE;
420421
idb.msg = *idb_entry;
421422
*idb_entry = 0;
422423

0 commit comments

Comments
 (0)