openwrt/target/linux/brcm2708/patches-4.14/950-0424-vchiq_2835_arm-Implement-a-DMA-pool-for-small-bulk-t.patch

127 lines
4.1 KiB
Diff
Raw Normal View History

brcm2708: add kernel 4.14 support Patch generation process: - rebase rpi/rpi-4.14.y on v4.14.89 from linux-stable - git format-patch v4.14.89 Patches skipped during rebase: - lan78xx: Read MAC address from DT if present - lan78xx: Enable LEDs and auto-negotiation - Revert "softirq: Let ksoftirqd do its job" - sc16is7xx: Fix for multi-channel stall - lan78xx: Ignore DT MAC address if already valid - lan78xx: Simple patch to prevent some crashes - tcp_write_queue_purge clears all the SKBs in the write queue - Revert "lan78xx: Simple patch to prevent some crashes" - lan78xx: Connect phy early - Arm: mm: ftrace: Only set text back to ro after kernel has been marked ro - Revert "Revert "softirq: Let ksoftirqd do its job"" - ASoC: cs4265: SOC_SINGLE register value error fix - Revert "ASoC: cs4265: SOC_SINGLE register value error fix" - Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends" - Revert "Revert "net: pskb_trim_rcsum() and CHECKSUM_COMPLETE are friends"" Patches dropped after rebase: - net: Add non-mainline source for rtl8192cu wlan - net: Fix rtl8192cu build errors on other platforms - brcm: adds support for BCM43341 wifi - brcmfmac: Mute expected startup 'errors' - ARM64: Fix build break for RTL8187/RTL8192CU wifi - ARM64: Enable RTL8187/RTL8192CU wifi in build config - This is the driver for Sony CXD2880 DVB-T2/T tuner + demodulator - brcmfmac: add CLM download support - brcmfmac: request_firmware_direct is quieter - Sets the BCDC priority to constant 0 - brcmfmac: Disable ARP offloading when promiscuous - brcmfmac: Avoid possible out-of-bounds read - brcmfmac: Delete redundant length check - net: rtl8192cu: Normalize indentation - net: rtl8192cu: Fix implicit fallthrough warnings - Revert "Sets the BCDC priority to constant 0" - media: cxd2880: Bump to match 4.18.y version - media: cxd2880-spi: Bump to match 4.18.y version - Revert "mm: alloc_contig: re-allow CMA to compact FS pages" - Revert "Revert "mm: alloc_contig: re-allow CMA to compact FS pages"" - cxd2880: CXD2880_SPI_DRV should select DVB_CXD2880 with MEDIA_SUBDRV_AUTOSELECT - 950-0421-HID-hid-bigbenff-driver-for-BigBen-Interactive-PS3OF.patch - 950-0453-Add-hid-bigbenff-to-list-of-have_special_driver-for-.patch Make I2C built-in instead of modular as in upstream defconfig; also the easiest way to get MFD_ARIZONA enabled, which is required by kmod-sound-soc-rpi-cirrus. Add missing compatible strings from 4.9/960-add-rasbperrypi-compatible.patch, using upstream names for compute modules. Add extra patch to enable the LEDs on lan78xx. Compile-tested: bcm2708, bcm2709, bcm2710 (with CONFIG_ALL_KMODS=y) Runtime-tested: bcm2708, bcm2710 Signed-off-by: Stijn Tintel <stijn@linux-ipv6.be>
2018-11-10 11:03:18 +00:00
From 88acd92a7cbcb8a6ae299b88554abbc9bedbae0a Mon Sep 17 00:00:00 2001
From: detule <ogjoneski@gmail.com>
Date: Tue, 2 Oct 2018 04:10:08 -0400
Subject: [PATCH 424/454] vchiq_2835_arm: Implement a DMA pool for small bulk
transfers (#2699)
During a bulk transfer we request a DMA allocation to hold the
scatter-gather list. Most of the time, this allocation is small
(<< PAGE_SIZE), however it can be requested at a high enough frequency
to cause fragmentation and/or stress the CMA allocator (think time
spent in compaction here, or during allocations elsewhere).
Implement a pool to serve up small DMA allocations, falling back
to a coherent allocation if the request is greater than
VCHIQ_DMA_POOL_SIZE.
Signed-off-by: Oliver Gjoneski <ogjoneski@gmail.com>
---
.../interface/vchiq_arm/vchiq_2835_arm.c | 40 +++++++++++++++----
1 file changed, 33 insertions(+), 7 deletions(-)
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -37,6 +37,7 @@
#include <linux/interrupt.h>
#include <linux/pagemap.h>
#include <linux/dma-mapping.h>
+#include <linux/dmapool.h>
#include <linux/io.h>
#include <linux/platform_device.h>
#include <linux/uaccess.h>
@@ -59,6 +60,8 @@
#define BELL0 0x00
#define BELL2 0x08
+#define VCHIQ_DMA_POOL_SIZE PAGE_SIZE
+
typedef struct vchiq_2835_state_struct {
int inited;
VCHIQ_ARM_STATE_T arm_state;
@@ -68,6 +71,7 @@ struct vchiq_pagelist_info {
PAGELIST_T *pagelist;
size_t pagelist_buffer_size;
dma_addr_t dma_addr;
+ bool is_from_pool;
enum dma_data_direction dma_dir;
unsigned int num_pages;
unsigned int pages_need_release;
@@ -78,6 +82,7 @@ struct vchiq_pagelist_info {
static void __iomem *g_regs;
static unsigned int g_cache_line_size = sizeof(CACHE_LINE_SIZE);
+static struct dma_pool *g_dma_pool;
static unsigned int g_fragments_size;
static char *g_fragments_base;
static char *g_free_fragments;
@@ -193,6 +198,14 @@ int vchiq_platform_init(struct platform_
}
g_dev = dev;
+ g_dma_pool = dmam_pool_create("vchiq_scatter_pool", dev,
+ VCHIQ_DMA_POOL_SIZE, g_cache_line_size,
+ 0);
+ if (!g_dma_pool) {
+ dev_err(dev, "failed to create dma pool");
+ return -ENOMEM;
+ }
+
vchiq_log_info(vchiq_arm_log_level,
"vchiq_init - done (slots %pK, phys %pad)",
vchiq_slot_zero, &slot_phys);
@@ -377,9 +390,14 @@ cleanup_pagelistinfo(struct vchiq_pageli
for (i = 0; i < pagelistinfo->num_pages; i++)
put_page(pagelistinfo->pages[i]);
}
-
- dma_free_coherent(g_dev, pagelistinfo->pagelist_buffer_size,
- pagelistinfo->pagelist, pagelistinfo->dma_addr);
+ if (pagelistinfo->is_from_pool) {
+ dma_pool_free(g_dma_pool, pagelistinfo->pagelist,
+ pagelistinfo->dma_addr);
+ } else {
+ dma_free_coherent(g_dev, pagelistinfo->pagelist_buffer_size,
+ pagelistinfo->pagelist,
+ pagelistinfo->dma_addr);
+ }
}
/* There is a potential problem with partial cache lines (pages?)
@@ -400,6 +418,7 @@ create_pagelist(char __user *buf, size_t
u32 *addrs;
unsigned int num_pages, offset, i, k;
int actual_pages;
+ bool is_from_pool;
size_t pagelist_size;
struct scatterlist *scatterlist, *sg;
int dma_buffers;
@@ -417,10 +436,16 @@ create_pagelist(char __user *buf, size_t
/* Allocate enough storage to hold the page pointers and the page
** list
*/
- pagelist = dma_zalloc_coherent(g_dev,
- pagelist_size,
- &dma_addr,
- GFP_KERNEL);
+ if (pagelist_size > VCHIQ_DMA_POOL_SIZE) {
+ pagelist = dma_zalloc_coherent(g_dev,
+ pagelist_size,
+ &dma_addr,
+ GFP_KERNEL);
+ is_from_pool = false;
+ } else {
+ pagelist = dma_pool_zalloc(g_dma_pool, GFP_KERNEL, &dma_addr);
+ is_from_pool = true;
+ }
vchiq_log_trace(vchiq_arm_log_level, "create_pagelist - %pK",
pagelist);
@@ -441,6 +466,7 @@ create_pagelist(char __user *buf, size_t
pagelistinfo->pagelist = pagelist;
pagelistinfo->pagelist_buffer_size = pagelist_size;
pagelistinfo->dma_addr = dma_addr;
+ pagelistinfo->is_from_pool = is_from_pool;
pagelistinfo->dma_dir = (type == PAGELIST_WRITE) ?
DMA_TO_DEVICE : DMA_FROM_DEVICE;
pagelistinfo->num_pages = num_pages;