DMA (Bus Master) on x86 - driver questions

DMA (Bus Master) on x86 - driver questions

Post by Rober » Thu, 18 Jul 1996 04:00:00



DMA (Bus master) on x86 questions
--------------------------------
Could I trouble you to e-mail your response?

I am porting a WAN PCI card driver from AIX to Solaris 2.5. The card
is capable of true bus master, i.e. I don't need to use System's
DMA engine. The questions I have are:
1. How do I allocate memory (<= 4k) such that it fits in one
   physical page? Is ddi_iopb_alloc() ok to use for that?
2. How do I get the physical address from kernel virtual address?
   Can I use
        ddi_dma_addr_setup(dip, NULL, (caddr_t)KvAddr,
                Size, DDI_DMA_WRITE, DDI_DMA_DONTWAIT, NULL,
        and
        ddi_dma_htoc(DmaHandle, 0, &DmaCookie);
        ?
   When I try this, ddi_dma_htoc() fails.

Any pointers will be appreciated.

- Nick Shah

/* Process Environment Only */
PCHAR
FpmAllocDmaMemory(PFPM_BOARD_BLK BoardBlk, ULONG Size)
{
        int rc;
        caddr_t Ptr;

        rc = ddi_iopb_alloc(BoardBlk->dip, NULL, Size, &Ptr);
        if (rc != DDI_SUCCESS) {
                FpmDisplay("AllocDmaMem: failed for size = 0x%x\n",
                        Size);
                Ptr = NULL;
        }
        return(Ptr);

Quote:}

ULONG
FpmMapVirtToPhys(PFPM_BOARD_BLK BoardBlk, ULONG KvAddr, ULONG   Size)
{
        INT32   rc;
        ddi_dma_cookie_t DmaCookie;

        rc = ddi_dma_addr_setup(BoardBlk->dip, NULL, (caddr_t)KvAddr,
                Size, DDI_DMA_WRITE, DDI_DMA_DONTWAIT, NULL,
                NULL,   /* &dma_lim, */
                &BoardBlk->DmaHandle);
        if (rc != DDI_DMA_MAPPED) {
                FpmDisplay("dma_addr_setup returned %d\n", rc);
                return(0);
        }

        rc = ddi_dma_htoc(BoardBlk->DmaHandle, 0, &DmaCookie);
        if (rc != DDI_SUCCESS) {
                FpmDisplay("dma_htoc failed for Kv %x, Size 0x%x\n",
                KvAddr, Size);
                return(0);
        }

        /* dma_htoc fails */

        FpmDisplay("dma_htoc Kv %x Kvaddr, Pv %x, Size 0x%x\n",
                DmaCookie.dmac_address, DmaCookie.dmac_size);

        return(DmaCookie.dmac_address);

Quote:}

 
 
 

1. DMA Setup for a Bus-Master Card in Solaris 2.1 for x86

Hi $DeviceDriverWriters,

I've a question regarding DMA setup in the driver for a bus-mastering
adapter. I'm very new to Solaris.

I'm making all the calls in right order.

Call ddi_dmae_alloc(dip, my_card_channel_num) to allocate dma channel.

Call ddi_dmae_getlim() to get the limit structure.

        Change dlim_sgllen to 1 (no scatter gather DMA).

Allocate a buffer "my_buffer" of length "my_len".

call ddi_dma_addr_setup(my_buffer, my_len), dma_handle returned.

call ddi_dma_nextwin(dma_handle, NULL, &dma_win), dma_win returned.

call ddi_dma_nextseg(dma_win, NULL, &dma_seg), dma_seg returned.

call ddi_dma_segtocookie(dma_seg, &off, &len, &dma_cookie).

Question :
        Now since I'm using a Bus Master adapter, do I STILL need to call
        ddi_dmae_prog (dma_cookie) to program the DMA ? I guess not. So, I
        proceed to next step.

        verification : I have to use dma_cookie.dmac_address to program my
        adapter's DMA engine ?

call ddi_dmae_enable(dip, my_card_channel_num) to enable the DMA channel.

Now at this point I've a dma_cookie , and I've enabled my_card_channel_num.
Also, I've programmed my adapter's DMA engine with dma_cookie.dmac_address.

I also enable all the right bits on my adapter (enable INTRS, DMAs, etc,
etc.).

When I test my adapter's DMA, the DMA never happens ?

Whats wrong ? I cant understand !

All I know is that I've mapped my buffer (which is in virtual memory) to a
DMA mapped space in the kernel's physical memory, and used this address to
program my DMA engine. Then why is it not working ?

Also, I'm supposed to read and write into my virtual buffer ("my_buffer")
and NOT dma_cookie.dmac_address ! My adapter's DMA test is that it is first
writing into the DMA address and then reading it back.

Please help me. I'm stuck !

Thanks in advance.

NT
A

2. Different IRQ Problems I think

3. Driver programming for DMA bus master device (intel)

4. eepro100.c & Intel integrated MBs

5. Bus-Master DMA error: missing interrupt

6. seq num generation

7. Modular IDE Build Failing Without Modular Generic PCI bus-master DMA support

8. Help with ppp routing

9. Bus-Mastered DMA support for Triton Chipset?

10. Bus-master DMA vs Cache

11. RS6000, Bus Master DMA and Cache Consistency

12. DMA and PCI bus mastering

13. Bus-Mastered DMA support for Triton Chipset?