Skip to content

Commit

Permalink
Ported pcie-brcmstb bounce buffer implementation to ARM64. (#3144)
Browse files Browse the repository at this point in the history
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 <yaroslavros@gmail.com>
  • Loading branch information
yaroslavros authored and popcornmix committed May 20, 2020
1 parent 2c25141 commit 0c5396c
Show file tree
Hide file tree
Showing 5 changed files with 610 additions and 25 deletions.
29 changes: 29 additions & 0 deletions arch/arm64/mm/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,35 @@ void arch_dma_prep_coherent(struct page *page, size_t size)
}

#ifdef CONFIG_IOMMU_DMA
static int __swiotlb_get_sgtable_page(struct sg_table *sgt,
struct page *page, size_t size)
{
int ret = sg_alloc_table(sgt, 1, GFP_KERNEL);

if (!ret)
sg_set_page(sgt->sgl, page, PAGE_ALIGN(size), 0);

return ret;
}

static int __swiotlb_mmap_pfn(struct vm_area_struct *vma,
unsigned long pfn, size_t size)
{
int ret = -ENXIO;
unsigned long nr_vma_pages = vma_pages(vma);
unsigned long nr_pages = PAGE_ALIGN(size) >> PAGE_SHIFT;
unsigned long off = vma->vm_pgoff;

if (off < nr_pages && nr_vma_pages <= (nr_pages - off)) {
ret = remap_pfn_range(vma, vma->vm_start,
pfn + off,
vma->vm_end - vma->vm_start,
vma->vm_page_prot);
}

return ret;
}

void arch_teardown_dma_ops(struct device *dev)
{
dev->dma_ops = NULL;
Expand Down
3 changes: 3 additions & 0 deletions drivers/pci/controller/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@ obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb.o
ifdef CONFIG_ARM
obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb-bounce.o
endif
ifdef CONFIG_ARM64
obj-$(CONFIG_PCIE_BRCMSTB) += pcie-brcmstb-bounce64.o
endif

obj-$(CONFIG_VMD) += vmd.o
# pcie-hisi.o quirks are needed even without CONFIG_PCIE_DW
Expand Down
2 changes: 1 addition & 1 deletion drivers/pci/controller/pcie-brcmstb-bounce.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#ifndef _PCIE_BRCMSTB_BOUNCE_H
#define _PCIE_BRCMSTB_BOUNCE_H

#ifdef CONFIG_ARM
#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)

int brcm_pcie_bounce_init(struct device *dev, unsigned long buffer_size,
dma_addr_t threshold);
Expand Down
Loading

0 comments on commit 0c5396c

Please sign in to comment.