lede/package/kernel/mac80211/patches/ath11k/314-002-ath11k-fix-ce-dp-address-alignment.patch

130 lines
4.7 KiB
Diff

From: Karthikeyan Periyasamy <periyasa@codeaurora.org>
Date: Thu, 3 Jun 2021 15:07:12 +0530
Subject: [PATCH] ath11k: fix CE and DP address alignment
srng dma address and virtual address should be aligned with byte instead
of pointer type. Alignment should be based on dma address instead
of virtual address. Also CE dma allocations are freed with unaligned
address instead of aligned address. so corrected all address alignment.
Signed-off-by: Karthikeyan Periyasamy <periyasa@codeaurora.org>
---
--- a/drivers/net/wireless/ath/ath11k/ce.c
+++ b/drivers/net/wireless/ath/ath11k/ce.c
@@ -559,6 +559,7 @@ ath11k_ce_alloc_ring(struct ath11k_base
{
struct ath11k_ce_ring *ce_ring;
dma_addr_t base_addr;
+ unsigned long off;
ce_ring = kzalloc(struct_size(ce_ring, skb, nentries), GFP_KERNEL);
if (ce_ring == NULL)
@@ -581,12 +582,13 @@ ath11k_ce_alloc_ring(struct ath11k_base
ce_ring->base_addr_ce_space_unaligned = base_addr;
- ce_ring->base_addr_owner_space = PTR_ALIGN(
- ce_ring->base_addr_owner_space_unaligned,
- CE_DESC_RING_ALIGN);
- ce_ring->base_addr_ce_space = ALIGN(
- ce_ring->base_addr_ce_space_unaligned,
+ ce_ring->base_addr_ce_space = (dma_addr_t) ALIGN(
+ (unsigned long)ce_ring->base_addr_ce_space_unaligned,
CE_DESC_RING_ALIGN);
+ off = (unsigned long)ce_ring->base_addr_ce_space -
+ (unsigned long)ce_ring->base_addr_ce_space_unaligned;
+ ce_ring->base_addr_owner_space = (void *)
+ ((unsigned long)ce_ring->base_addr_owner_space_unaligned + off);
return ce_ring;
}
@@ -935,8 +937,8 @@ void ath11k_ce_free_pipes(struct ath11k_
dma_free_coherent(ab->dev,
pipe->src_ring->nentries * desc_sz +
CE_DESC_RING_ALIGN,
- pipe->src_ring->base_addr_owner_space,
- pipe->src_ring->base_addr_ce_space);
+ pipe->src_ring->base_addr_owner_space_unaligned,
+ pipe->src_ring->base_addr_ce_space_unaligned);
kfree(pipe->src_ring);
pipe->src_ring = NULL;
}
@@ -946,8 +948,8 @@ void ath11k_ce_free_pipes(struct ath11k_
dma_free_coherent(ab->dev,
pipe->dest_ring->nentries * desc_sz +
CE_DESC_RING_ALIGN,
- pipe->dest_ring->base_addr_owner_space,
- pipe->dest_ring->base_addr_ce_space);
+ pipe->src_ring->base_addr_owner_space_unaligned,
+ pipe->src_ring->base_addr_ce_space_unaligned);
kfree(pipe->dest_ring);
pipe->dest_ring = NULL;
}
@@ -958,8 +960,8 @@ void ath11k_ce_free_pipes(struct ath11k_
dma_free_coherent(ab->dev,
pipe->status_ring->nentries * desc_sz +
CE_DESC_RING_ALIGN,
- pipe->status_ring->base_addr_owner_space,
- pipe->status_ring->base_addr_ce_space);
+ pipe->src_ring->base_addr_owner_space_unaligned,
+ pipe->src_ring->base_addr_ce_space_unaligned);
kfree(pipe->status_ring);
pipe->status_ring = NULL;
}
--- a/drivers/net/wireless/ath/ath11k/ce.h
+++ b/drivers/net/wireless/ath/ath11k/ce.h
@@ -129,7 +129,7 @@ struct ath11k_ce_ring {
/* Host address space */
void *base_addr_owner_space_unaligned;
/* CE address space */
- u32 base_addr_ce_space_unaligned;
+ dma_addr_t base_addr_ce_space_unaligned;
/* Actual start of descriptors.
* Aligned to descriptor-size boundary.
@@ -139,7 +139,7 @@ struct ath11k_ce_ring {
void *base_addr_owner_space;
/* CE address space */
- u32 base_addr_ce_space;
+ dma_addr_t base_addr_ce_space;
/* HAL ring id */
u32 hal_ring_id;
--- a/drivers/net/wireless/ath/ath11k/dp.c
+++ b/drivers/net/wireless/ath/ath11k/dp.c
@@ -222,6 +222,7 @@ int ath11k_dp_srng_setup(struct ath11k_b
int entry_sz = ath11k_hal_srng_get_entrysize(ab, type);
int max_entries = ath11k_hal_srng_get_max_entries(ab, type);
int ret;
+ unsigned long off;
if (max_entries < 0 || entry_sz < 0)
return -EINVAL;
@@ -236,9 +237,10 @@ int ath11k_dp_srng_setup(struct ath11k_b
if (!ring->vaddr_unaligned)
return -ENOMEM;
- ring->vaddr = PTR_ALIGN(ring->vaddr_unaligned, HAL_RING_BASE_ALIGN);
- ring->paddr = ring->paddr_unaligned + ((unsigned long)ring->vaddr -
- (unsigned long)ring->vaddr_unaligned);
+ ring->paddr = (dma_addr_t) ALIGN((unsigned long)ring->paddr_unaligned,
+ HAL_RING_BASE_ALIGN);
+ off = (unsigned long)ring->paddr - (unsigned long)ring->paddr_unaligned;
+ ring->vaddr = (u32 *) ((unsigned long)ring->vaddr_unaligned + off);
params.ring_base_vaddr = ring->vaddr;
params.ring_base_paddr = ring->paddr;
--- a/drivers/net/wireless/ath/ath11k/hal.h
+++ b/drivers/net/wireless/ath/ath11k/hal.h
@@ -19,7 +19,7 @@ struct ath11k_base;
#define HAL_NUM_MPDU_LINKS_PER_QUEUE_DESC 12
#define HAL_MAX_AVAIL_BLK_RES 3
-#define HAL_RING_BASE_ALIGN 8
+#define HAL_RING_BASE_ALIGN 32
#define HAL_WBM_IDLE_SCATTER_BUF_SIZE_MAX 32704
/* TODO: Check with hw team on the supported scatter buf size */