[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: simple example of pci driver with dma
From: |
Yan Vugenfirer |
Subject: |
Re: simple example of pci driver with dma |
Date: |
Sun, 1 Nov 2020 11:38:08 +0200 |
Hi Shaked,
In the prob function, before you are trying to do any DMA operations with your
device, you should call pci_enable_device and then pci_set_master. Also you
might need to map the resources of your device.
Check PCI driver documentation:
https://lxr.missinglinkelectronics.com/linux/Documentation/PCI/pci.rst#L199
Best regards,
Yan.
> On 29 Oct 2020, at 10:32 PM, Shaked Matzner <shaked.m@neuroblade.ai> wrote:
>
> Hey Peter,
> Currently I have this test in the driver which allocates data, assign it to
> default value config source as the BASE address of dma, dest as the physical
> address which I got from dma_alloc_coherent, set the count and assign the
> command to raise interrupt and read,the piece of code used is something like
> this(this a test performed from the probe function of the driver)
> vaddr_to =
> dma_alloc_coherent(&(dev->dev), 4, &dma_handle_to, GFP_ATOMIC |GFP_KERNEL);
> *((volatile int*)vaddr_to) = 0xff;
> test->vaddr_to = vaddr_to;
> dev_info(&(dev->dev),
> "vaddr_to = %px\n", vaddr_to);
> dev_info(&(dev->dev),
> "dma_handle_to = %llx\n", (unsigned long long)dma_handle_to);
> iowrite32(DMA_BASE, mmio +
> IO_DMA_SRC);
> iowrite32((u32)dma_handle_to,
> mmio + IO_DMA_DST);
> iowrite32(SIZE, mmio +
> IO_DMA_CNT);
> iowrite32(DMA_CMD |
> DMA_FROM_DEV | DMA_IRQ, mmio + IO_DMA_CMD);
> Where and when should the pci_set_master hould be called?
> Thanks,
> Shaked Matzner
>
> From: Peter Maydell <peter.maydell@linaro.org>
> Sent: Thursday, October 29, 2020 5:46 PM
> To: Shaked Matzner <shaked.m@neuroblade.ai>
> Cc: qemu-devel@nongnu.org
> Subject: Re: simple example of pci driver with dma
>
>
> IRONSCALES couldn't recognize this email as this is the first time you
> received an email from this sender peter.maydell@linaro.org
>
> [EXTERNAL]
>
> On Thu, 29 Oct 2020 at 14:59, Shaked Matzner wrote:
> > however the value I get is still 255(0xff) and not 18(0x12) probably I've
> > missed something but when the interrupt is called the transfer to the RAM
> > address should be completed, however it seems like the dma_write_buffer
> > function from the device does not perform any transfer. What Am I missing?
>
> The usual mistake is forgetting in the guest code to program the
> PCI device to enable bus mastering by setting the Bus Master bit
> in the Command register in the PCI config space registers for
> the device. Unless you do that then all DMA attempts will fail
> (same as on real h/w). In the Linux kernel the function for this
> is pci_set_master(), I think.
>
> thanks
> -- PMM
>
> The contents of this email message and any attachments are intended solely
> for the addressee(s) and may contain confidential and/or privileged
> information and may be legally protected from disclosure. If you are not the
> intended recipient of this message or their agent, or if this message has
> been addressed to you in error, please immediately alert the sender by reply
> email and then delete this message and any attachments. If you are not the
> intended recipient, you are hereby notified that any use, dissemination,
> copying, or storage of this message or its attachments is strictly
> prohibited.
>
--------------------------------------------------
Daynix Computing LTD
Yan Vugenfirer, CEO
Email: yan@daynix.com
Phone (Israel): +972-54-4758084
Phone (USA): +1-7204776716
Phone (UK): +44-2070482938
Web: www.daynix.com
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Re: simple example of pci driver with dma,
Yan Vugenfirer <=