Configure DMA atributes?
There are some PCI Ethernet drivers with code similar to: From: drivers/net/ethernet/realtek/8139cp.c /* Configure DMA attributes. */ if ((sizeof(dma_addr_t) > 4) && !pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(64)) && !pci_set_dma_mask(pdev, DMA_BIT_MASK(64))) { pci_using_dac = 1; } else { pci_using_dac = 0; rc = pci_set_dma_mask(pdev, DMA_BIT_MASK(32)); if (rc) { dev_err(&pdev->dev, "No usable DMA configuration, aborting\n"); goto err_out_res; } rc = pci_set_consistent_dma_mask(pdev, DMA_BIT_MASK(32)); if (rc) { dev_err(&pdev->dev, "No usable consistent DMA configuration, aborting\n"); goto err_out_res; } } What is this code supposed to do? I did tests inside two KVM virtual machines using rtl8139 virtual network interface. One VM configured for x86_64 and the other configured for i686. On both VMs this code makes no visible difference at all. I can remove the code completely, or leave only parts of it, the result is always the same. The 8139cp module is loaded successfully and the network works after loading the module. Nothing is shown on dmesg. If I comment the assignment to pci_using_dac, the compiler issues warnings, but it makes no visible difference to assign 1 or 0. If I had real hardware what could I brake by playing with this code? Thanks! -- Peter
On Mon, 12 Aug 2013 19:55:35 +0200, you wrote:
From: drivers/net/ethernet/realtek/8139cp.c
[snip]
If I comment the assignment to pci_using_dac, the compiler issues warnings, but it makes no visible difference to assign 1 or 0.
If I had real hardware what could I brake by playing with this code?
Does the following help: <URL:http://en.wikipedia.org/wiki/Conventional_PCI#Dual-cycle_address> On real hardware, when using a PCI bus, setting the PCIDAC flag in 8139cp.c is intended to signify that 64-bit addressing is being used. -- Gareth Davies, Lotwillow Ltd
On Mon, Aug 12, 2013 at 10:55 AM, Peter Senna Tschudin <peter.senna@gmail.com> wrote:
DMA_BIT_MASK(64)
That's the key here. From Documentation/DMA-API-HOWTO.txt : ------------------------------------------------------------------------------------------------ The standard 32-bit addressing device would do something like this: if (dma_set_mask(dev, DMA_BIT_MASK(32))) { printk(KERN_WARNING "mydev: No suitable DMA available.\n"); goto ignore_this_device; } Another common scenario is a 64-bit capable device. The approach here is to try for 64-bit addressing, but back down to a 32-bit mask that should not fail. The kernel may fail the 64-bit mask not because the platform is not capable of 64-bit addressing. Rather, it may fail in this case simply because 32-bit addressing is done more efficiently than 64-bit addressing. For example, Sparc64 PCI SAC addressing is more efficient than DAC addressing. ------------------------------------------------------------------------------------------------ Hope that helps. Luis
participants (3)
-
Gareth Davies -
Luis R. Rodriguez -
Peter Senna Tschudin