All of lore.kernel.org
 help / color / mirror / Atom feed
* Configure DMA atributes?
@ 2013-08-12 17:55 ` Peter Senna Tschudin
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Senna Tschudin @ 2013-08-12 17:55 UTC (permalink / raw)
  To: kernelnewbies

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Configure DMA atributes?
@ 2013-08-12 17:55 ` Peter Senna Tschudin
  0 siblings, 0 replies; 6+ messages in thread
From: Peter Senna Tschudin @ 2013-08-12 17:55 UTC (permalink / raw)
  To: kernelnewbies

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Configure DMA atributes?
  2013-08-12 17:55 ` Peter Senna Tschudin
@ 2013-08-14  6:31   ` Gareth Davies
  -1 siblings, 0 replies; 6+ messages in thread
From: Gareth Davies @ 2013-08-14  6:31 UTC (permalink / raw)
  To: kernelnewbies

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Configure DMA atributes?
@ 2013-08-14  6:31   ` Gareth Davies
  0 siblings, 0 replies; 6+ messages in thread
From: Gareth Davies @ 2013-08-14  6:31 UTC (permalink / raw)
  To: kernelnewbies

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Configure DMA atributes?
  2013-08-12 17:55 ` Peter Senna Tschudin
@ 2013-08-14  7:18   ` Luis R. Rodriguez
  -1 siblings, 0 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2013-08-14  7:18 UTC (permalink / raw)
  To: kernelnewbies

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Configure DMA atributes?
@ 2013-08-14  7:18   ` Luis R. Rodriguez
  0 siblings, 0 replies; 6+ messages in thread
From: Luis R. Rodriguez @ 2013-08-14  7:18 UTC (permalink / raw)
  To: kernelnewbies

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

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-08-14  7:18 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-08-12 17:55 Configure DMA atributes? Peter Senna Tschudin
2013-08-12 17:55 ` Peter Senna Tschudin
2013-08-14  6:31 ` Gareth Davies
2013-08-14  6:31   ` Gareth Davies
2013-08-14  7:18 ` Luis R. Rodriguez
2013-08-14  7:18   ` Luis R. Rodriguez

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.