Skip to content

Commit 287a215

Browse files
yaroslavrospopcornmix
authored andcommitted
Ported pcie-brcmstb bounce buffer implementation to ARM64. (#3144)
Ported pcie-brcmstb bounce buffer implementation to ARM64. This enables full 4G RAM usage on Raspberry Pi in 64-bit mode. Signed-off-by: Yaroslav Rosomakho <[email protected]>
1 parent 2b72f24 commit 287a215

File tree

5 files changed

+610
-25
lines changed

5 files changed

+610
-25
lines changed

arch/arm64/mm/dma-mapping.c

+29
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,35 @@ void arch_dma_prep_coherent(struct page *page, size_t size)
3131
}
3232

3333
#ifdef CONFIG_IOMMU_DMA
34+
static int __swiotlb_get_sgtable_page(struct sg_table *sgt,
35+
struct page *page, size_t size)
36+
{
37+
int ret = sg_alloc_table(sgt, 1, GFP_KERNEL);
38+
39+
if (!ret)
40+
sg_set_page(sgt->sgl, page, PAGE_ALIGN(size), 0);
41+
42+
return ret;
43+
}
44+
45+
static int __swiotlb_mmap_pfn(struct vm_area_struct *vma,
46+
unsigned long pfn, size_t size)
47+
{
48+
int ret = -ENXIO;
49+
unsigned long nr_vma_pages = vma_pages(vma);
50+
unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
51+
unsigned long off = vma->vm_pgoff;
52+
53+
if (off < nr_pages && nr_vma_pages <= (nr_pages - off)) {
54+
ret = remap_pfn_range(vma, vma->vm_start,
55+
pfn + off,
56+
vma->vm_end - vma->vm_start,
57+
vma->vm_page_prot);
58+
}
59+
60+
return ret;
61+
}
62+
3463
void arch_teardown_dma_ops(struct device *dev)
3564
{
3665
dev->dma_ops = NULL;

drivers/pci/controller/Makefile

+3
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o
3131
ifdef CONFIG_ARM
3232
obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb-bounce.o
3333
endif
34+
ifdef CONFIG_ARM64
35+
obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb-bounce64.o
36+
endif
3437

3538
obj-$(CONFIG_VMD) += vmd.o
3639
# pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW

drivers/pci/controller/pcie-brcmstb-bounce.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
#ifndef _PCIE_BRCMSTB_BOUNCE_H
77
#define _PCIE_BRCMSTB_BOUNCE_H
88

9-
#ifdef CONFIG_ARM
9+
#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)
1010

1111
int brcm_pcie_bounce_init(struct device *dev, unsigned long buffer_size,
1212
dma_addr_t threshold);

0 commit comments

Comments
 (0)