From 7a3f292c8316239182f30fa8f3a5e5a14cca587c Mon Sep 17 00:00:00 2001 From: dzwdz Date: Wed, 17 Aug 2022 23:41:30 +0200 Subject: amd64/rtl8139: don't trust the card to have packets available on irq --- src/kernel/arch/amd64/driver/rtl8139.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/kernel/arch/amd64/driver') diff --git a/src/kernel/arch/amd64/driver/rtl8139.c b/src/kernel/arch/amd64/driver/rtl8139.c index 2438002..e50fb63 100644 --- a/src/kernel/arch/amd64/driver/rtl8139.c +++ b/src/kernel/arch/amd64/driver/rtl8139.c @@ -91,7 +91,9 @@ void rtl8139_irq(void) { } status &= 1; - do { + /* bit 0 of cmd - Rx Buffer Empty + * not a do while() because sometimes the bit is empty on IRQ. no clue why. */ + while (!(port_in8(iobase + CMD) & 1)) { if (blocked_on) { accept(blocked_on); blocked_on = blocked_on->postqueue_next; @@ -99,7 +101,7 @@ void rtl8139_irq(void) { rx_irq_enable(false); break; } - } while (!(port_in8(iobase + CMD) & 1)); /* bit 0 - Rx Buffer Empty */ + } //kprintf("rxpos %x cbr %x\n", rxpos, port_in16(iobase + CBR)); port_out16(iobase + INTRSTATUS, status); @@ -170,7 +172,7 @@ static void accept(struct vfs_request *req) { ret = try_rx(req->caller->pages, req->output.buf, req->output.len); if (ret == WAIT) { // TODO this is a pretty common pattern in drivers, try to make it unneeded - // TODO invalid assert, fails on nmap + // TODO those asserts should actually be regular panic checks assert(!req->postqueue_next); struct vfs_request **slot = &blocked_on; while (*slot) slot = &(*slot)->postqueue_next; -- cgit v1.2.3