Skip to content

Instantly share code, notes, and snippets.

@Hoernchen
Created September 27, 2024 16:00
Show Gist options
  • Save Hoernchen/1f16736d1829ffe121b176fb187b5f0f to your computer and use it in GitHub Desktop.
Save Hoernchen/1f16736d1829ffe121b176fb187b5f0f to your computer and use it in GitHub Desktop.
litex sdr pi5
diff --git a/software/kernel/main.c b/software/kernel/main.c
index 4e048e0..c9ca635 100644
--- a/software/kernel/main.c
+++ b/software/kernel/main.c
@@ -33,6 +33,7 @@
#include <linux/cdev.h>
#include <linux/platform_device.h>
#include <linux/version.h>
+#include <linux/of_device.h>
#if defined(__arm__) || defined(__aarch64__)
#include <linux/dma-direct.h>
@@ -180,7 +181,7 @@ static int litepcie_dma_init(struct litepcie_device *s)
/* check */
if (!dmachan->writer_addr[j]
|| !dmachan->reader_addr[j]) {
- dev_err(&s->dev->dev, "Failed to allocate dma buffers\n");
+ dev_err(&s->dev->dev, "Failed to allocate dma buffers %px %px sz %x\n", dmachan->writer_addr[j], dmachan->reader_addr[j], DMA_BUFFER_SIZE);
return -ENOMEM;
}
}
@@ -1063,7 +1064,9 @@ static int litepcie_pci_probe(struct pci_dev *dev, const struct pci_device_id *i
#if LINUX_VERSION_CODE < KERNEL_VERSION(5, 18, 0)
ret = pci_set_dma_mask(dev, DMA_BIT_MASK(DMA_ADDR_WIDTH));
#else
+ of_dma_configure(&dev->dev, NULL, true);
ret = dma_set_mask(&dev->dev, DMA_BIT_MASK(DMA_ADDR_WIDTH));
+ ret |= dma_set_coherent_mask(&dev->dev, DMA_BIT_MASK(DMA_ADDR_WIDTH));
#endif
if (ret) {
dev_err(&dev->dev, "Failed to set DMA mask\n");
(END)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment