forked from LiBwrt/openwrt-6.x
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5efab21
commit 2a2356f
Showing
19 changed files
with
801 additions
and
103 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
229 changes: 229 additions & 0 deletions
229
package/kernel/qca-nss-dp/patches/0012-01-WiP-syn-gmac-use-standard-DMA-api.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,229 @@ | ||
From 5ad8cf24897ff903112967a9662cb13ed4cbbf57 Mon Sep 17 00:00:00 2001 | ||
From: hzy <[email protected]> | ||
Date: Mon, 22 Apr 2024 21:47:58 +0800 | ||
Subject: [PATCH 1/2] WiP: syn-gmac: use standard DMA api | ||
|
||
Signed-off-by: hzy <[email protected]> | ||
--- | ||
hal/dp_ops/syn_gmac_dp/syn_dp_cfg_rx.c | 14 ++++++-- | ||
hal/dp_ops/syn_gmac_dp/syn_dp_cfg_tx.c | 2 ++ | ||
hal/dp_ops/syn_gmac_dp/syn_dp_rx.c | 47 +++++++++++++------------- | ||
hal/dp_ops/syn_gmac_dp/syn_dp_tx.c | 23 ++++--------- | ||
4 files changed, 42 insertions(+), 44 deletions(-) | ||
|
||
--- a/hal/dp_ops/syn_gmac_dp/syn_dp_cfg_rx.c | ||
+++ b/hal/dp_ops/syn_gmac_dp/syn_dp_cfg_rx.c | ||
@@ -26,6 +26,7 @@ static int syn_dp_cfg_rx_setup_desc_queu | ||
{ | ||
struct syn_dp_info_rx *rx_info = &dev_info->dp_info_rx; | ||
struct dma_desc_rx *first_desc = NULL; | ||
+ dma_addr_t dma_addr; | ||
struct net_device *netdev = rx_info->netdev; | ||
|
||
netdev_dbg(netdev, "Total size of memory required for Rx Descriptors in Ring Mode = %u\n", (uint32_t)((sizeof(struct dma_desc_rx) * SYN_DP_RX_DESC_SIZE))); | ||
@@ -33,13 +34,15 @@ static int syn_dp_cfg_rx_setup_desc_queu | ||
/* | ||
* Allocate cacheable descriptors for Rx | ||
*/ | ||
- first_desc = kzalloc(sizeof(struct dma_desc_rx) * SYN_DP_RX_DESC_SIZE, GFP_KERNEL); | ||
+ first_desc = dma_alloc_coherent(rx_info->dev, | ||
+ sizeof(struct dma_desc_rx) * SYN_DP_RX_DESC_SIZE, | ||
+ &dma_addr, GFP_KERNEL); | ||
if (!first_desc) { | ||
netdev_dbg(netdev, "Error in Rx Descriptor Memory allocation in Ring mode\n"); | ||
return -ENOMEM; | ||
} | ||
|
||
- dev_info->rx_desc_dma_addr = (dma_addr_t)virt_to_phys(first_desc); | ||
+ dev_info->rx_desc_dma_addr = dma_addr; | ||
rx_info->rx_desc = first_desc; | ||
syn_dp_gmac_rx_desc_init_ring(rx_info->rx_desc, SYN_DP_RX_DESC_SIZE); | ||
|
||
@@ -98,6 +101,10 @@ void syn_dp_cfg_rx_cleanup_rings(struct | ||
for (i = 0; i < rx_info->busy_rx_desc_cnt; i++) { | ||
rx_skb_index = (rx_skb_index + i) & SYN_DP_RX_DESC_MAX_INDEX; | ||
rxdesc = rx_info->rx_desc; | ||
+ | ||
+ dma_unmap_single(rx_info->dev, rxdesc->buffer1, | ||
+ rxdesc->length, DMA_FROM_DEVICE); | ||
+ | ||
skb = rx_info->rx_buf_pool[rx_skb_index].skb; | ||
if (unlikely(skb != NULL)) { | ||
dev_kfree_skb_any(skb); | ||
@@ -105,7 +112,8 @@ void syn_dp_cfg_rx_cleanup_rings(struct | ||
} | ||
} | ||
|
||
- kfree(rx_info->rx_desc); | ||
+ dma_free_coherent(rx_info->dev, (sizeof(struct dma_desc_rx) * SYN_DP_RX_DESC_SIZE), | ||
+ rx_info->rx_desc, dev_info->rx_desc_dma_addr); | ||
rx_info->rx_desc = NULL; | ||
dev_info->rx_desc_dma_addr = (dma_addr_t)0; | ||
} | ||
--- a/hal/dp_ops/syn_gmac_dp/syn_dp_cfg_tx.c | ||
+++ b/hal/dp_ops/syn_gmac_dp/syn_dp_cfg_tx.c | ||
@@ -91,6 +91,8 @@ void syn_dp_cfg_tx_cleanup_rings(struct | ||
tx_skb_index = syn_dp_tx_inc_index(tx_skb_index, i); | ||
txdesc = tx_info->tx_desc; | ||
|
||
+ dma_unmap_single(tx_info->dev, txdesc->buffer1, txdesc->length, DMA_TO_DEVICE); | ||
+ | ||
skb = tx_info->tx_buf_pool[tx_skb_index].skb; | ||
if (unlikely(skb != NULL)) { | ||
dev_kfree_skb_any(skb); | ||
--- a/hal/dp_ops/syn_gmac_dp/syn_dp_rx.c | ||
+++ b/hal/dp_ops/syn_gmac_dp/syn_dp_rx.c | ||
@@ -73,16 +73,6 @@ static inline void syn_dp_rx_refill_one_ | ||
*/ | ||
static inline void syn_dp_rx_inval_and_flush(struct syn_dp_info_rx *rx_info, uint32_t start, uint32_t end) | ||
{ | ||
- /* | ||
- * Batched flush and invalidation of the rx descriptors | ||
- */ | ||
- if (end > start) { | ||
- dmac_flush_range_no_dsb((void *)&rx_info->rx_desc[start], (void *)&rx_info->rx_desc[end] + sizeof(struct dma_desc_rx)); | ||
- } else { | ||
- dmac_flush_range_no_dsb((void *)&rx_info->rx_desc[start], (void *)&rx_info->rx_desc[SYN_DP_RX_DESC_MAX_INDEX] + sizeof(struct dma_desc_rx)); | ||
- dmac_flush_range_no_dsb((void *)&rx_info->rx_desc[0], (void *)&rx_info->rx_desc[end] + sizeof(struct dma_desc_rx)); | ||
- } | ||
- | ||
dsb(st); | ||
} | ||
|
||
@@ -124,15 +114,19 @@ int syn_dp_rx_refill_page_mode(struct sy | ||
break; | ||
} | ||
|
||
+ skb_fill_page_desc(skb, 0, pg, 0, PAGE_SIZE); | ||
+ | ||
/* | ||
* Get virtual address of allocated page. | ||
*/ | ||
page_addr = page_address(pg); | ||
- dma_addr = (dma_addr_t)virt_to_phys(page_addr); | ||
- | ||
- skb_fill_page_desc(skb, 0, pg, 0, PAGE_SIZE); | ||
+ dma_addr = dma_map_page(rx_info->dev, pg, 0, PAGE_SIZE, DMA_FROM_DEVICE); | ||
+ if (unlikely(dma_mapping_error(rx_info->dev, dma_addr))) { | ||
+ dev_kfree_skb(skb); | ||
+ netdev_dbg(netdev, "DMA mapping failed for empty buffer\n"); | ||
+ break; | ||
+ } | ||
|
||
- dmac_inv_range_no_dsb(page_addr, (page_addr + PAGE_SIZE)); | ||
rx_refill_idx = rx_info->rx_refill_idx; | ||
rx_desc = rx_info->rx_desc + rx_refill_idx; | ||
|
||
@@ -181,8 +175,15 @@ int syn_dp_rx_refill(struct syn_dp_info_ | ||
|
||
skb_reserve(skb, SYN_DP_SKB_HEADROOM + NET_IP_ALIGN); | ||
|
||
- dma_addr = (dma_addr_t)virt_to_phys(skb->data); | ||
- dmac_inv_range_no_dsb((void *)skb->data, (void *)(skb->data + inval_len)); | ||
+ dma_addr = dma_map_single(rx_info->dev, skb->data, | ||
+ inval_len, | ||
+ DMA_FROM_DEVICE); | ||
+ if (unlikely(dma_mapping_error(rx_info->dev, dma_addr))) { | ||
+ dev_kfree_skb(skb); | ||
+ netdev_dbg(netdev, "DMA mapping failed for empty buffer\n"); | ||
+ break; | ||
+ } | ||
+ | ||
rx_refill_idx = rx_info->rx_refill_idx; | ||
rx_desc = rx_info->rx_desc + rx_refill_idx; | ||
|
||
@@ -407,12 +408,6 @@ int syn_dp_rx(struct syn_dp_info_rx *rx_ | ||
* this code is executing. | ||
*/ | ||
end = syn_dp_rx_inc_index(rx_info->rx_idx, busy); | ||
- if (end > start) { | ||
- dmac_inv_range_no_dsb((void *)&rx_info->rx_desc[start], (void *)&rx_info->rx_desc[end] + sizeof(struct dma_desc_rx)); | ||
- } else { | ||
- dmac_inv_range_no_dsb((void *)&rx_info->rx_desc[start], (void *)&rx_info->rx_desc[SYN_DP_RX_DESC_MAX_INDEX] + sizeof(struct dma_desc_rx)); | ||
- dmac_inv_range_no_dsb((void *)&rx_info->rx_desc[0], (void *)&rx_info->rx_desc[end] + sizeof(struct dma_desc_rx)); | ||
- } | ||
|
||
dsb(st); | ||
|
||
@@ -439,8 +434,12 @@ int syn_dp_rx(struct syn_dp_info_rx *rx_ | ||
* speculative prefetch by CPU may have occurred. | ||
*/ | ||
frame_length = syn_dp_gmac_get_rx_desc_frame_length(status); | ||
- dmac_inv_range((void *)rx_buf->map_addr_virt, | ||
- (void *)(((uint8_t *)rx_buf->map_addr_virt) + frame_length)); | ||
+ if (likely(!rx_info->page_mode)) | ||
+ dma_unmap_single(rx_info->dev, rx_desc->buffer1, | ||
+ rx_info->alloc_buf_len, DMA_FROM_DEVICE); | ||
+ else | ||
+ dma_unmap_page(rx_info->dev, rx_desc->buffer1, | ||
+ PAGE_SIZE, DMA_FROM_DEVICE); | ||
prefetch((void *)rx_buf->map_addr_virt); | ||
|
||
rx_next_idx = syn_dp_rx_inc_index(rx_idx, 1); | ||
--- a/hal/dp_ops/syn_gmac_dp/syn_dp_tx.c | ||
+++ b/hal/dp_ops/syn_gmac_dp/syn_dp_tx.c | ||
@@ -104,9 +104,7 @@ static inline struct dma_desc_tx *syn_dp | ||
BUG_ON(!length); | ||
#endif | ||
|
||
- dma_addr = (dma_addr_t)virt_to_phys(frag_addr); | ||
- | ||
- dmac_clean_range_no_dsb(frag_addr, frag_addr + length); | ||
+ dma_addr = dma_map_single(tx_info->dev, frag_addr, length, DMA_TO_DEVICE); | ||
|
||
*total_length += length; | ||
tx_desc = syn_dp_tx_set_desc_sg(tx_info, dma_addr, length, DESC_OWN_BY_DMA); | ||
@@ -150,8 +148,7 @@ int syn_dp_tx_nr_frags(struct syn_dp_inf | ||
/* | ||
* Flush the dma for non-paged skb data | ||
*/ | ||
- dma_addr = (dma_addr_t)virt_to_phys(skb->data); | ||
- dmac_clean_range_no_dsb((void *)skb->data, (void *)(skb->data + length)); | ||
+ dma_addr = dma_map_single(tx_info->dev, skb->data, length, DMA_TO_DEVICE); | ||
|
||
total_len = length; | ||
|
||
@@ -256,12 +253,7 @@ int syn_dp_tx_frag_list(struct syn_dp_in | ||
return NETDEV_TX_BUSY; | ||
} | ||
|
||
- dma_addr = (dma_addr_t)virt_to_phys(skb->data); | ||
- | ||
- /* | ||
- * Flush the data area of the head skb | ||
- */ | ||
- dmac_clean_range_no_dsb((void *)skb->data, (void *)(skb->data + length)); | ||
+ dma_addr = dma_map_single(tx_info->dev, skb->data, length, DMA_TO_DEVICE); | ||
|
||
total_len = length; | ||
|
||
@@ -290,9 +282,7 @@ int syn_dp_tx_frag_list(struct syn_dp_in | ||
BUG_ON(!length); | ||
#endif | ||
|
||
- dma_addr = (dma_addr_t)virt_to_phys(iter_skb->data); | ||
- | ||
- dmac_clean_range_no_dsb((void *)iter_skb->data, (void *)(iter_skb->data + length)); | ||
+ dma_addr = dma_map_single(tx_info->dev, iter_skb->data, length, DMA_TO_DEVICE); | ||
|
||
total_len += length; | ||
|
||
@@ -445,6 +435,7 @@ int syn_dp_tx_complete(struct syn_dp_inf | ||
break; | ||
} | ||
|
||
+ dma_unmap_single(tx_info->dev, desc->buffer1, desc->length, DMA_TO_DEVICE); | ||
|
||
if (likely(status & DESC_TX_LAST)) { | ||
tx_skb_index = syn_dp_tx_comp_index_get(tx_info); | ||
@@ -571,9 +562,7 @@ int syn_dp_tx(struct syn_dp_info_tx *tx_ | ||
return NETDEV_TX_BUSY; | ||
} | ||
|
||
- dma_addr = (dma_addr_t)virt_to_phys(skb->data); | ||
- | ||
- dmac_clean_range_no_dsb((void *)skb->data, (void *)(skb->data + skb->len)); | ||
+ dma_addr = dma_map_single(tx_info->dev, skb->data, skb->len, DMA_TO_DEVICE); | ||
|
||
/* | ||
* Queue packet to the GMAC rings |
36 changes: 36 additions & 0 deletions
36
...ge/kernel/qca-nss-dp/patches/0012-02-ipq50xx-use-corrent-scm-function-to-write-tcsr.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
From ba430b1a512dc1972807a1dd5a8d31a78ac572ff Mon Sep 17 00:00:00 2001 | ||
From: hzy <[email protected]> | ||
Date: Mon, 22 Apr 2024 21:49:18 +0800 | ||
Subject: [PATCH 2/2] ipq50xx: use corrent scm function to write tcsr | ||
|
||
Signed-off-by: hzy <[email protected]> | ||
--- | ||
hal/soc_ops/ipq50xx/nss_ipq50xx.c | 9 ++------- | ||
1 file changed, 2 insertions(+), 7 deletions(-) | ||
|
||
--- a/hal/soc_ops/ipq50xx/nss_ipq50xx.c | ||
+++ b/hal/soc_ops/ipq50xx/nss_ipq50xx.c | ||
@@ -18,7 +18,7 @@ | ||
|
||
#include <linux/of.h> | ||
#include <linux/ioport.h> | ||
-#include <linux/qcom_scm.h> | ||
+#include <linux/firmware/qcom/qcom_scm.h> | ||
#include "nss_dp_hal.h" | ||
|
||
/* | ||
@@ -78,13 +78,8 @@ static void nss_dp_hal_tcsr_set(void) | ||
* If TZ is not enabled, we can write to the register directly. | ||
*/ | ||
if (qcom_scm_is_available()) { | ||
-#if (LINUX_VERSION_CODE < KERNEL_VERSION(5, 4, 0)) | ||
- err = qcom_scm_tcsr_reg_write((tcsr_base + TCSR_GMAC_AXI_CACHE_OVERRIDE_OFFSET), | ||
+ err = qcom_scm_io_writel((tcsr_base + TCSR_GMAC_AXI_CACHE_OVERRIDE_OFFSET), | ||
TCSR_GMAC_AXI_CACHE_OVERRIDE_VALUE); | ||
-#else | ||
- err = qti_scm_tcsr_reg_write((tcsr_base + TCSR_GMAC_AXI_CACHE_OVERRIDE_OFFSET), | ||
- TCSR_GMAC_AXI_CACHE_OVERRIDE_VALUE); | ||
-#endif | ||
if (err) { | ||
pr_err("%s: SCM TCSR write error: %d\n", __func__, err); | ||
} |
36 changes: 36 additions & 0 deletions
36
package/kernel/qca-nss-dp/patches/0013-nss_dp_main-support-fixed-link.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
From 309a1a330ccaa103a7648e944d97a0032116b338 Mon Sep 17 00:00:00 2001 | ||
From: hzy <[email protected]> | ||
Date: Mon, 22 Apr 2024 21:50:39 +0800 | ||
Subject: [PATCH] nss_dp_main: support fixed-link | ||
|
||
Signed-off-by: hzy <[email protected]> | ||
--- | ||
nss_dp_main.c | 15 ++++++++++++--- | ||
1 file changed, 12 insertions(+), 3 deletions(-) | ||
|
||
--- a/nss_dp_main.c | ||
+++ b/nss_dp_main.c | ||
@@ -634,11 +634,20 @@ static int32_t nss_dp_of_get_pdata(struc | ||
} | ||
|
||
dp_priv->phy_node = of_parse_phandle(np, "phy-handle", 0); | ||
- if (!dp_priv->phy_node) { | ||
- pr_err("%s: error parsing phy-handle\n", np->name); | ||
- return -EFAULT; | ||
+ if(!dp_priv->phy_node) { | ||
+ if(of_phy_is_fixed_link(np)) { | ||
+ int ret = of_phy_register_fixed_link(np); | ||
+ if(ret < 0) { | ||
+ pr_err("%s: fail to register fixed-link: %d\n", np->name, ret); | ||
+ return -EFAULT; | ||
+ } | ||
+ } | ||
+ dp_priv->phy_node = of_node_get(np); | ||
} | ||
|
||
+ if(!dp_priv->phy_node) | ||
+ pr_err("%s: no phy-handle or fixed-link found\n", np->name); | ||
+ | ||
if (of_property_read_u32(np, "qcom,mactype", &hal_pdata->mactype)) { | ||
pr_err("%s: error reading mactype\n", np->name); | ||
return -EFAULT; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
48 changes: 48 additions & 0 deletions
48
package/kernel/qca-ssdk/patches/104-init-replace-ioremap_nocache-with-ioremap.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
From 27360a6255db0b68353f6df30b6feea1db7d8539 Mon Sep 17 00:00:00 2001 | ||
From: hzy <[email protected]> | ||
Date: Mon, 22 Apr 2024 21:41:55 +0800 | ||
Subject: [PATCH] init: replace ioremap_nocache() with ioremap() | ||
|
||
Signed-off-by: hzy <[email protected]> | ||
--- | ||
src/init/ssdk_clk.c | 8 ++++---- | ||
1 file changed, 4 insertions(+), 4 deletions(-) | ||
|
||
--- a/src/init/ssdk_clk.c | ||
+++ b/src/init/ssdk_clk.c | ||
@@ -1183,7 +1183,7 @@ ssdk_mp_tcsr_get(a_uint32_t tcsr_offset, | ||
{ | ||
void __iomem *tcsr_base = NULL; | ||
|
||
- tcsr_base = ioremap_nocache(TCSR_ETH_ADDR, TCSR_ETH_SIZE); | ||
+ tcsr_base = ioremap(TCSR_ETH_ADDR, TCSR_ETH_SIZE); | ||
if (!tcsr_base) | ||
{ | ||
SSDK_ERROR("Failed to map tcsr eth address!\n"); | ||
@@ -1200,7 +1200,7 @@ ssdk_mp_tcsr_set(a_uint32_t tcsr_offset, | ||
{ | ||
void __iomem *tcsr_base = NULL; | ||
|
||
- tcsr_base = ioremap_nocache(TCSR_ETH_ADDR, TCSR_ETH_SIZE); | ||
+ tcsr_base = ioremap(TCSR_ETH_ADDR, TCSR_ETH_SIZE); | ||
if (!tcsr_base) | ||
{ | ||
SSDK_ERROR("Failed to map tcsr eth address!\n"); | ||
@@ -1248,7 +1248,7 @@ ssdk_mp_cmnblk_stable_check(void) | ||
a_uint32_t reg_val; | ||
int i, loops = 20; | ||
|
||
- pll_lock = ioremap_nocache(CMN_PLL_LOCKED_ADDR, CMN_PLL_LOCKED_SIZE); | ||
+ pll_lock = ioremap(CMN_PLL_LOCKED_ADDR, CMN_PLL_LOCKED_SIZE); | ||
if (!pll_lock) { | ||
SSDK_ERROR("Failed to map CMN PLL LOCK register!\n"); | ||
return A_FALSE; | ||
@@ -1305,7 +1305,7 @@ static void ssdk_cmnblk_pll_src_set(enum | ||
void __iomem *cmn_pll_src_base = NULL; | ||
a_uint32_t reg_val; | ||
|
||
- cmn_pll_src_base = ioremap_nocache(CMN_BLK_PLL_SRC_ADDR, CMN_BLK_SIZE); | ||
+ cmn_pll_src_base = ioremap(CMN_BLK_PLL_SRC_ADDR, CMN_BLK_SIZE); | ||
if (!cmn_pll_src_base) { | ||
SSDK_ERROR("Failed to map cmn pll source address!\n"); | ||
return; |
Oops, something went wrong.