Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

b43: use 8K buffers for 64-bit DMA to workaround hardware bug

Signed-off-by: Rafał Miłecki <zajec5@gmail.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>

authored by

Rafał Miłecki and committed by
John W. Linville
14a8083e 996bc370

+18 -9
+16 -8
drivers/net/wireless/b43/dma.c
··· 419 419 gfp_t flags = GFP_KERNEL; 420 420 421 421 /* The specs call for 4K buffers for 30- and 32-bit DMA with 4K 422 - * alignment and 8K buffers for 64-bit DMA with 8K alignment. Testing 423 - * has shown that 4K is sufficient for the latter as long as the buffer 424 - * does not cross an 8K boundary. 425 - * 422 + * alignment and 8K buffers for 64-bit DMA with 8K alignment. 423 + * In practice we could use smaller buffers for the latter, but the 424 + * alignment is really important because of the hardware bug. If bit 425 + * 0x00001000 is used in DMA address, some hardware (like BCM4331) 426 + * copies that bit into B43_DMA64_RXSTATUS and we get false values from 427 + * B43_DMA64_RXSTATDPTR. Let's just use 8K buffers even if we don't use 428 + * more than 256 slots for ring. 426 429 */ 430 + u16 ring_mem_size = (ring->type == B43_DMA_64BIT) ? 431 + B43_DMA64_RINGMEMSIZE : B43_DMA32_RINGMEMSIZE; 432 + 427 433 ring->descbase = dma_alloc_coherent(ring->dev->dev->dma_dev, 428 - B43_DMA_RINGMEMSIZE, 429 - &(ring->dmabase), flags); 434 + ring_mem_size, &(ring->dmabase), 435 + flags); 430 436 if (!ring->descbase) { 431 437 b43err(ring->dev->wl, "DMA ringmemory allocation failed\n"); 432 438 return -ENOMEM; 433 439 } 434 - memset(ring->descbase, 0, B43_DMA_RINGMEMSIZE); 440 + memset(ring->descbase, 0, ring_mem_size); 435 441 436 442 return 0; 437 443 } 438 444 439 445 static void free_ringmemory(struct b43_dmaring *ring) 440 446 { 441 - dma_free_coherent(ring->dev->dev->dma_dev, B43_DMA_RINGMEMSIZE, 447 + u16 ring_mem_size = (ring->type == B43_DMA_64BIT) ? 448 + B43_DMA64_RINGMEMSIZE : B43_DMA32_RINGMEMSIZE; 449 + dma_free_coherent(ring->dev->dev->dma_dev, ring_mem_size, 442 450 ring->descbase, ring->dmabase); 443 451 } 444 452
+2 -1
drivers/net/wireless/b43/dma.h
··· 161 161 } __packed; 162 162 163 163 /* Misc DMA constants */ 164 - #define B43_DMA_RINGMEMSIZE PAGE_SIZE 164 + #define B43_DMA32_RINGMEMSIZE 4096 165 + #define B43_DMA64_RINGMEMSIZE 8192 165 166 /* Offset of frame with actual data */ 166 167 #define B43_DMA0_RX_FW598_FO 38 167 168 #define B43_DMA0_RX_FW351_FO 30