Skip to content

Commit

Permalink
Revert "pcie-brcmstb: Remove brcm_to_*, add pcie_to_dma40"
Browse files Browse the repository at this point in the history
This reverts commit 4f8cad8.
  • Loading branch information
pelwell authored and popcornmix committed May 20, 2020
1 parent b13d166 commit 346454c
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 60 deletions.
25 changes: 8 additions & 17 deletions drivers/pci/controller/pcie-brcmstb-bounce.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <linux/slab.h>
#include <linux/page-flags.h>
#include <linux/device.h>
#include <linux/dma-direct.h>
#include <linux/dma-mapping.h>
#include <linux/dmapool.h>
#include <linux/list.h>
Expand Down Expand Up @@ -76,7 +75,6 @@ struct dmabounce_pool {

struct dmabounce_device_info {
struct device *dev;
dma_addr_t phys_offset;
dma_addr_t threshold;
struct list_head safe_buffers;
struct dmabounce_pool pool;
Expand All @@ -93,11 +91,6 @@ struct dmabounce_device_info {

static struct dmabounce_device_info *g_dmabounce_device_info;

dma_addr_t pcie_to_dma40(dma_addr_t addr)
{
return addr - g_dmabounce_device_info->phys_offset;
}

extern int bcm2711_dma40_memcpy_init(void);
extern void bcm2711_dma40_memcpy(dma_addr_t dst, dma_addr_t src, size_t size);

Expand Down Expand Up @@ -252,7 +245,7 @@ alloc_safe_buffer(struct dmabounce_device_info *device_info,

if (!buf->safe) {
dev_warn(dev,
"%s: could not alloc dma memory (size=%zu)\n",
"%s: could not alloc dma memory (size=%d)\n",
__func__, size);
kfree(buf);
return NULL;
Expand Down Expand Up @@ -327,8 +320,7 @@ map_single(struct device *dev, struct safe_buffer *buf, size_t size,

if ((dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL) &&
!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
bcm2711_dma40_memcpy(pcie_to_dma40(buf->safe_dma_addr),
pcie_to_dma40(buf->unsafe_dma_addr),
bcm2711_dma40_memcpy(buf->safe_dma_addr, buf->unsafe_dma_addr,
size);

return buf->safe_dma_addr;
Expand All @@ -346,8 +338,7 @@ unmap_single(struct device *dev, struct safe_buffer *buf, size_t size,
dev_dbg(dev, "unmap: %llx->%llx\n", (u64)buf->safe_dma_addr,
(u64)buf->unsafe_dma_addr);

bcm2711_dma40_memcpy(pcie_to_dma40(buf->unsafe_dma_addr),
pcie_to_dma40(buf->safe_dma_addr),
bcm2711_dma40_memcpy(buf->unsafe_dma_addr, buf->safe_dma_addr,
size);
}
return buf->unsafe_dma_addr;
Expand Down Expand Up @@ -386,6 +377,7 @@ dmabounce_map_page(struct device *dev, struct page *page, unsigned long offset,

dma_addr = map_single(dev, buf, size, dir, attrs);
}

return dma_addr;
}

Expand Down Expand Up @@ -475,7 +467,7 @@ static const struct dma_map_ops dmabounce_ops = {

int brcm_pcie_bounce_init(struct device *dev,
unsigned long buffer_size,
phys_addr_t phys_threshold)
dma_addr_t threshold)
{
struct dmabounce_device_info *device_info;
int ret;
Expand Down Expand Up @@ -504,8 +496,7 @@ int brcm_pcie_bounce_init(struct device *dev,
}

device_info->dev = dev;
device_info->phys_offset = __phys_to_dma(dev, 0);
device_info->threshold = phys_threshold + device_info->phys_offset;
device_info->threshold = threshold;
INIT_LIST_HEAD(&device_info->safe_buffers);
rwlock_init(&device_info->lock);

Expand All @@ -519,8 +510,8 @@ int brcm_pcie_bounce_init(struct device *dev,

g_dmabounce_device_info = device_info;

dev_info(dev, "dmabounce: initialised - %ld kB, threshold %padx (%padx)\n",
buffer_size / 1024, &phys_threshold, &device_info->threshold);
dev_info(dev, "dmabounce: initialised - %ld kB, threshold %pad\n",
buffer_size / 1024, &threshold);

return 0;

Expand Down
4 changes: 2 additions & 2 deletions drivers/pci/controller/pcie-brcmstb-bounce.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
#if defined(CONFIG_ARM) || defined(CONFIG_ARM64)

int brcm_pcie_bounce_init(struct device *dev, unsigned long buffer_size,
phys_addr_t threshold);
dma_addr_t threshold);
int brcm_pcie_bounce_uninit(struct device *dev);
int brcm_pcie_bounce_register_dev(struct device *dev);

#else

static inline int brcm_pcie_bounce_init(struct device *dev,
unsigned long buffer_size,
phys_addr_t threshold)
dma_addr_t threshold)
{
return 0;
}
Expand Down
21 changes: 6 additions & 15 deletions drivers/pci/controller/pcie-brcmstb-bounce64.c
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,6 @@ struct dmabounce_pool {

struct dmabounce_device_info {
struct device *dev;
dma_addr_t phys_offset;
dma_addr_t threshold;
struct list_head safe_buffers;
struct dmabounce_pool pool;
Expand All @@ -94,11 +93,6 @@ struct dmabounce_device_info {

static struct dmabounce_device_info *g_dmabounce_device_info;

dma_addr_t pcie_to_dma40(dma_addr_t addr)
{
return addr - g_dmabounce_device_info->phys_offset;
}

extern int bcm2711_dma40_memcpy_init(void);
extern void bcm2711_dma40_memcpy(dma_addr_t dst, dma_addr_t src, size_t size);

Expand Down Expand Up @@ -328,8 +322,7 @@ map_single(struct device *dev, struct safe_buffer *buf, size_t size,

if ((dir == DMA_TO_DEVICE || dir == DMA_BIDIRECTIONAL) &&
!(attrs & DMA_ATTR_SKIP_CPU_SYNC))
bcm2711_dma40_memcpy(pcie_to_dma40(buf->safe_dma_addr),
pcie_to_dma40(buf->unsafe_dma_addr),
bcm2711_dma40_memcpy(buf->safe_dma_addr, buf->unsafe_dma_addr,
size);

return buf->safe_dma_addr;
Expand All @@ -347,8 +340,7 @@ unmap_single(struct device *dev, struct safe_buffer *buf, size_t size,
dev_dbg(dev, "unmap: %llx->%llx\n", (u64)buf->safe_dma_addr,
(u64)buf->unsafe_dma_addr);

bcm2711_dma40_memcpy(pcie_to_dma40(buf->unsafe_dma_addr),
pcie_to_dma40(buf->safe_dma_addr),
bcm2711_dma40_memcpy(buf->unsafe_dma_addr, buf->safe_dma_addr,
size);
}
return buf->unsafe_dma_addr;
Expand Down Expand Up @@ -482,7 +474,7 @@ static const struct dma_map_ops dmabounce_ops = {

int brcm_pcie_bounce_init(struct device *dev,
unsigned long buffer_size,
phys_addr_t phys_threshold)
dma_addr_t threshold)
{
struct dmabounce_device_info *device_info;
int ret;
Expand Down Expand Up @@ -511,8 +503,7 @@ int brcm_pcie_bounce_init(struct device *dev,
}

device_info->dev = dev;
device_info->phys_offset = __phys_to_dma(dev, 0);
device_info->threshold = phys_threshold + device_info->phys_offset;
device_info->threshold = threshold;
INIT_LIST_HEAD(&device_info->safe_buffers);
rwlock_init(&device_info->lock);

Expand All @@ -526,8 +517,8 @@ int brcm_pcie_bounce_init(struct device *dev,

g_dmabounce_device_info = device_info;

dev_info(dev, "dmabounce: initialised - %ld kB, threshold %padx (%padx)\n",
buffer_size / 1024, &phys_threshold, &device_info->threshold);
dev_info(dev, "dmabounce: initialised - %ld kB, threshold %pad\n",
buffer_size / 1024, &threshold);

return 0;

Expand Down
Loading

0 comments on commit 346454c

Please sign in to comment.