From: John Hodge Date: Wed, 25 Dec 2013 00:45:32 +0000 (+0800) Subject: Modules/VirtIONet - Fix lockup on init if multiple packets are pending X-Git-Tag: rel0.15~42 X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=f068ee79d422decc6dc270e350e5f6eed4b8f080;p=tpg%2Facess2.git Modules/VirtIONet - Fix lockup on init if multiple packets are pending > Semaphore limit was 1, not NRXBUFS --- diff --git a/KernelLand/Modules/Network/VirtIONet/virtio-net.c b/KernelLand/Modules/Network/VirtIONet/virtio-net.c index c4ea418f..d10a0894 100644 --- a/KernelLand/Modules/Network/VirtIONet/virtio-net.c +++ b/KernelLand/Modules/Network/VirtIONet/virtio-net.c @@ -5,7 +5,7 @@ * virtio-net.c * - Driver Core */ -#define DEBUG 1 +#define DEBUG 0 #define VERSION VER2(1,0) #include #include @@ -101,7 +101,7 @@ void VirtIONet_AddCard(Uint16 IOBase, Uint IRQ) // Oops? } tVirtIONet_Dev *ndev = VirtIO_GetDataPtr(dev); - Semaphore_Init(&ndev->RXPacketSem, 0, 1, "VirtIONet", "RXSem"); + Semaphore_Init(&ndev->RXPacketSem, 0, NRXBUFS, "VirtIONet", "RXSem"); ndev->Features = VirtIO_GetFeatures(dev); Uint8 mac[6]; @@ -133,10 +133,12 @@ void VirtIONet_AddCard(Uint16 IOBase, Uint IRQ) for( int i = 0; i < NRXBUFS; i ++ ) { ndev->RXBuffers[i] = MM_AllocDMA(1, -1, NULL); + LOG("RxBuf %i/%i: %p", i, NRXBUFS, ndev->RXBuffers[i]); VirtIO_ReceiveBuffer(dev, 0, PAGE_SIZE, ndev->RXBuffers[i], NULL); } // Register with IPStack + LOG("Register"); // TODO: Save the returned pointer to do deregister later IPStack_Adapter_Add(&gVirtIONet_AdapterType, dev, mac); LEAVE('-'); @@ -145,6 +147,7 @@ void VirtIONet_AddCard(Uint16 IOBase, Uint IRQ) int VirtIONet_RXQueueCallback(tVirtIO_Dev *Dev, int ID, size_t UsedBytes, void *Handle) { tVirtIONet_Dev *NDev = VirtIO_GetDataPtr(Dev); + LOG("Signalling"); Semaphore_Signal(&NDev->RXPacketSem, 1); // 1: Don't pop the qdesc return 1;