summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Hsu <hsuvictor@google.com>2021-11-26 13:06:54 +0800
committerVictor Hsu <hsuvictor@google.com>2021-12-13 13:39:14 +0800
commit84364e386a0abebdf85e149073ec8e040b05800a (patch)
treedf2ef1081254b82e50c824347e04cfd71efb2be1
parent5cfb486d3f2b5f46683495ae82c1060da8118be4 (diff)
downloadcnss2-84364e386a0abebdf85e149073ec8e040b05800a.tar.gz
wcn6740: Change DMA allocation methods in mhi & cnss2
PCI rc driver hooks the op of dma_alloc_attrs() for S2MPU To solve the allocation failure problem, change to use dma_direct_alloc() instead. Bug: 204280094 Signed-off-by: Victor Hsu <hsuvictor@google.com> Change-Id: I86bdb8529d3fd2d3711ec8acbee76702ec9a4c06
-rw-r--r--cnss2/pci.c16
-rw-r--r--mhi/core/boot.c22
2 files changed, 37 insertions, 1 deletions
diff --git a/cnss2/pci.c b/cnss2/pci.c
index c0853e6..4b764b1 100644
--- a/cnss2/pci.c
+++ b/cnss2/pci.c
@@ -13,6 +13,9 @@
#include <linux/suspend.h>
#include <linux/memblock.h>
#include <linux/completion.h>
+#ifdef CONFIG_WCN_GOOGLE
+#include <linux/dma-direct.h>
+#endif
#include "main.h"
#include "bus.h"
@@ -3590,10 +3593,15 @@ int cnss_pci_alloc_fw_mem(struct cnss_pci_data *pci_priv)
for (i = 0; i < plat_priv->fw_mem_seg_len; i++) {
if (!fw_mem[i].va && fw_mem[i].size) {
fw_mem[i].va =
+#ifdef CONFIG_WCN_GOOGLE
+ dma_direct_alloc(dev, fw_mem[i].size,
+ &fw_mem[i].pa, GFP_KERNEL,
+ fw_mem[i].attrs);
+#else
dma_alloc_attrs(dev, fw_mem[i].size,
&fw_mem[i].pa, GFP_KERNEL,
fw_mem[i].attrs);
-
+#endif
if (!fw_mem[i].va) {
cnss_pr_err("Failed to allocate memory for FW, size: 0x%zx, type: %u\n",
fw_mem[i].size, fw_mem[i].type);
@@ -3618,9 +3626,15 @@ static void cnss_pci_free_fw_mem(struct cnss_pci_data *pci_priv)
cnss_pr_dbg("Freeing memory for FW, va: 0x%pK, pa: %pa, size: 0x%zx, type: %u\n",
fw_mem[i].va, &fw_mem[i].pa,
fw_mem[i].size, fw_mem[i].type);
+#ifdef CONFIG_WCN_GOOGLE
+ dma_direct_free(dev, fw_mem[i].size,
+ fw_mem[i].va, fw_mem[i].pa,
+ fw_mem[i].attrs);
+#else
dma_free_attrs(dev, fw_mem[i].size,
fw_mem[i].va, fw_mem[i].pa,
fw_mem[i].attrs);
+#endif
fw_mem[i].va = NULL;
fw_mem[i].pa = 0;
fw_mem[i].size = 0;
diff --git a/mhi/core/boot.c b/mhi/core/boot.c
index c623a2e..b6d7623 100644
--- a/mhi/core/boot.c
+++ b/mhi/core/boot.c
@@ -20,6 +20,9 @@
#include <linux/random.h>
#include <linux/slab.h>
#include <linux/wait.h>
+#ifdef CONFIG_WCN_GOOGLE
+#include <linux/dma-direct.h>
+#endif
#include "internal.h"
/* Setup RDDM vector table for RDDM transfer and program RXVEC */
@@ -315,8 +318,14 @@ void mhi_free_bhie_table(struct mhi_controller *mhi_cntrl,
return;
for (i = 0; i < (*image_info)->entries; i++, mhi_buf++)
+#ifdef CONFIG_WCN_GOOGLE
+ dma_direct_free(mhi_cntrl->cntrl_dev, mhi_buf->len, mhi_buf->buf,
+ mhi_buf->dma_addr, DMA_ATTR_FORCE_CONTIGUOUS);
+
+#else
dma_free_attrs(mhi_cntrl->cntrl_dev, mhi_buf->len, mhi_buf->buf,
mhi_buf->dma_addr, DMA_ATTR_FORCE_CONTIGUOUS);
+#endif
kfree((*image_info)->mhi_buf);
kfree(*image_info);
@@ -361,9 +370,16 @@ int mhi_alloc_bhie_table(struct mhi_controller *mhi_cntrl,
vec_size = sizeof(struct bhi_vec_entry) * i;
mhi_buf->len = vec_size;
+#ifdef CONFIG_WCN_GOOGLE
+ mhi_buf->buf = dma_direct_alloc(mhi_cntrl->cntrl_dev, vec_size,
+ &mhi_buf->dma_addr, GFP_KERNEL,
+ DMA_ATTR_FORCE_CONTIGUOUS);
+#else
+
mhi_buf->buf = dma_alloc_attrs(mhi_cntrl->cntrl_dev, vec_size,
&mhi_buf->dma_addr, GFP_KERNEL,
DMA_ATTR_FORCE_CONTIGUOUS);
+#endif
if (!mhi_buf->buf)
goto error_alloc_segment;
@@ -381,8 +397,14 @@ int mhi_alloc_bhie_table(struct mhi_controller *mhi_cntrl,
error_alloc_segment:
for (--i, --mhi_buf; i >= 0; i--, mhi_buf--)
+#ifdef CONFIG_WCN_GOOGLE
+ dma_direct_free(mhi_cntrl->cntrl_dev, mhi_buf->len, mhi_buf->buf,
+ mhi_buf->dma_addr, DMA_ATTR_FORCE_CONTIGUOUS);
+
+#else
dma_free_attrs(mhi_cntrl->cntrl_dev, mhi_buf->len, mhi_buf->buf,
mhi_buf->dma_addr, DMA_ATTR_FORCE_CONTIGUOUS);
+#endif
error_alloc_mhi_buf:
kfree(img_info);