You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
openwrt/target/linux/layerscape/patches-5.4/701-net-0360-sdk_dpaa-sdk_f...

298 lines
9.9 KiB
Diff

From 6dbf409f09fd85d738652c7867a5822f682d5682 Mon Sep 17 00:00:00 2001
From: Camelia Groza <camelia.groza@nxp.com>
Date: Thu, 12 Dec 2019 14:15:05 +0200
Subject: [PATCH] sdk_dpaa: sdk_fman: ls1043a errata: detect based on DTB
property
Detect if the platform is vulnerable to the A010022 erratum based on device
tree properties instead of the SoC family.
Signed-off-by: Camelia Groza <camelia.groza@nxp.com>
---
drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c | 31 +---------------------
drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h | 14 +++++-----
.../net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c | 25 ++++++++---------
.../inc/integrations/LS1043/dpaa_integration_ext.h | 3 +++
.../sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h | 10 +++++++
.../freescale/sdk_fman/src/wrapper/lnxwrp_fm.c | 17 ++++++++++++
6 files changed, 51 insertions(+), 49 deletions(-)
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
@@ -1,4 +1,5 @@
/* Copyright 2008-2013 Freescale Semiconductor Inc.
+ * Copyright 2019 NXP
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -105,11 +106,6 @@ static const char rtx[][3] = {
[TX] = "TX"
};
-#ifndef CONFIG_PPC
-bool dpaa_errata_a010022;
-EXPORT_SYMBOL(dpaa_errata_a010022);
-#endif
-
/* BM */
#define DPAA_ETH_MAX_PAD (L1_CACHE_BYTES * 8)
@@ -1133,26 +1129,6 @@ static struct platform_driver dpa_driver
.remove = dpa_remove
};
-#ifndef CONFIG_PPC
-static bool __init __cold soc_has_errata_a010022(void)
-{
-#ifdef CONFIG_SOC_BUS
- const struct soc_device_attribute soc_msi_matches[] = {
- { .family = "QorIQ LS1043A",
- .data = NULL },
- { },
- };
-
- if (soc_device_match(soc_msi_matches))
- return true;
-
- return false;
-#else
- return true; /* cannot identify SoC */
-#endif
-}
-#endif
-
static int __init __cold dpa_load(void)
{
int _errno;
@@ -1168,11 +1144,6 @@ static int __init __cold dpa_load(void)
dpa_max_frm = fm_get_max_frm();
dpa_num_cpus = num_possible_cpus();
-#ifndef CONFIG_PPC
- /* Detect if the current SoC requires the 4K alignment workaround */
- dpaa_errata_a010022 = soc_has_errata_a010022();
-#endif
-
#ifdef CONFIG_FSL_DPAA_DBG_LOOP
memset(dpa_loop_netdevs, 0, sizeof(dpa_loop_netdevs));
#endif
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.h
@@ -1,4 +1,5 @@
/* Copyright 2008-2012 Freescale Semiconductor Inc.
+ * Copyright 2019 NXP
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -98,15 +99,15 @@ struct dpa_buffer_layout_s {
* space to account for further alignments.
*/
#define DPA_MAX_FRM_SIZE 9600
-#ifdef CONFIG_PPC
+#ifndef FM_ERRATUM_A010022
#define DPA_BP_RAW_SIZE \
((DPA_MAX_FRM_SIZE + DPA_MAX_FD_OFFSET + \
sizeof(struct skb_shared_info) + 128) & ~(SMP_CACHE_BYTES - 1))
-#else /* CONFIG_PPC */
-#define DPA_BP_RAW_SIZE ((unlikely(dpaa_errata_a010022)) ? 2048 : \
+#else /* FM_ERRATUM_A010022 */
+#define DPA_BP_RAW_SIZE ((unlikely(fm_has_errata_a010022())) ? 2048 : \
((DPA_MAX_FRM_SIZE + DPA_MAX_FD_OFFSET + \
sizeof(struct skb_shared_info) + 128) & ~(SMP_CACHE_BYTES - 1)))
-#endif /* CONFIG_PPC */
+#endif /* FM_ERRATUM_A010022 */
#endif /* CONFIG_FSL_DPAA_ETH_JUMBO_FRAME */
/* This is what FMan is ever allowed to use.
@@ -659,8 +660,7 @@ static inline void _dpa_bp_free_pf(void
* on egress.
*/
-#ifndef CONFIG_PPC
-extern bool dpaa_errata_a010022; /* SoC affected by A010022 errata */
+#ifdef FM_ERRATUM_A010022
#define CROSS_4K(start, size) \
(((uintptr_t)(start) + (size)) > \
(((uintptr_t)(start) + 0x1000) & ~0xFFF))
@@ -668,6 +668,6 @@ extern bool dpaa_errata_a010022; /* SoC
* we reserve 256 bytes instead to guarantee 256 data alignment.
*/
#define DPAA_A010022_HEADROOM 256
-#endif /* !CONFIG_PPC */
+#endif /* FM_ERRATUM_A010022 */
#endif /* __DPA_H */
--- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
+++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth_sg.c
@@ -1,4 +1,5 @@
/* Copyright 2012 Freescale Semiconductor Inc.
+ * Copyright 2019 NXP
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -100,8 +101,8 @@ static int _dpa_bp_add_8_bufs(const stru
* We only need enough space to store a pointer, but allocate
* an entire cacheline for performance reasons.
*/
-#ifndef CONFIG_PPC
- if (unlikely(dpaa_errata_a010022)) {
+#ifdef FM_ERRATUM_A010022
+ if (unlikely(fm_has_errata_a010022())) {
struct page *new_page = alloc_page(GFP_ATOMIC);
if (unlikely(!new_page))
goto netdev_alloc_failed;
@@ -764,7 +765,7 @@ int __hot skb_to_contig_fd(struct dpa_pr
}
EXPORT_SYMBOL(skb_to_contig_fd);
-#ifndef CONFIG_PPC
+#ifdef FM_ERRATUM_A010022
/* Verify the conditions that trigger the A010022 errata:
* - 4K memory address boundary crossings when the data/SG fragments aren't
* aligned to 256 bytes
@@ -940,8 +941,8 @@ int __hot skb_to_sg_fd(struct dpa_priv_s
/* Get a page frag to store the SGTable, or a full page if the errata
* is in place and we need to avoid crossing a 4k boundary.
*/
-#ifndef CONFIG_PPC
- if (unlikely(dpaa_errata_a010022)) {
+#ifdef FM_ERRATUM_A010022
+ if (unlikely(fm_has_errata_a010022())) {
struct page *new_page = alloc_page(GFP_ATOMIC);
if (unlikely(!new_page))
@@ -1120,8 +1121,8 @@ int __hot dpa_tx_extended(struct sk_buff
clear_fd(&fd);
-#ifndef CONFIG_PPC
- if (unlikely(dpaa_errata_a010022) && a010022_check_skb(skb, priv))
+#ifdef FM_ERRATUM_A010022
+ if (unlikely(fm_has_errata_a010022()) && a010022_check_skb(skb, priv))
skb_need_wa = true;
#endif
@@ -1193,12 +1194,12 @@ int __hot dpa_tx_extended(struct sk_buff
* more fragments than we support. In this case,
* we have no choice but to linearize it ourselves.
*/
-#ifndef CONFIG_PPC
+#ifdef FM_ERRATUM_A010022
/* No point in linearizing the skb now if we are going
* to realign and linearize it again further down due
* to the A010022 errata
*/
- if (unlikely(dpaa_errata_a010022))
+ if (unlikely(fm_has_errata_a010022()))
skb_need_wa = true;
else
#endif
@@ -1208,15 +1209,15 @@ int __hot dpa_tx_extended(struct sk_buff
/* Common out-of-memory error path */
goto enomem;
-#ifndef CONFIG_PPC
+#ifdef FM_ERRATUM_A010022
/* Verify the skb a second time if it has been updated since
* the previous check
*/
- if (unlikely(dpaa_errata_a010022) && skb_changed &&
+ if (unlikely(fm_has_errata_a010022()) && skb_changed &&
a010022_check_skb(skb, priv))
skb_need_wa = true;
- if (unlikely(dpaa_errata_a010022) && skb_need_wa) {
+ if (unlikely(fm_has_errata_a010022()) && skb_need_wa) {
nskb = a010022_realign_skb(skb, priv);
if (!nskb)
goto skb_to_fd_failed;
--- a/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/dpaa_integration_ext.h
+++ b/drivers/net/ethernet/freescale/sdk_fman/inc/integrations/LS1043/dpaa_integration_ext.h
@@ -1,5 +1,6 @@
/*
* Copyright 2012 Freescale Semiconductor Inc.
+ * Copyright 2019 NXP
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -270,6 +271,8 @@ typedef enum
#define FM_AID_MODE_NO_TNUM_SW005 /* refer to pdm TKT068794 - only support of port_id on aid */
#define FM_ERROR_VSP_NO_MATCH_SW006 /* refer to pdm TKT174304 - no match between errorQ and VSP */
+#define FM_ERRATUM_A010022
+
/*****************************************************************************
RMan INTEGRATION-SPECIFIC DEFINITIONS
******************************************************************************/
--- a/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
+++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
@@ -1,5 +1,6 @@
/*
* Copyright 2008-2012 Freescale Semiconductor Inc.
+ * Copyright 2019 NXP
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -489,6 +490,15 @@ int fm_get_max_frm(void);
int fm_get_rx_extra_headroom(void);
/**************************************************************************//**
+ @Function fm_has_errata_a010022
+
+ @Description Detect if the SoC is vulnerable to the A010022 errata
+*//***************************************************************************/
+#ifdef FM_ERRATUM_A010022
+bool fm_has_errata_a010022(void);
+#endif
+
+/**************************************************************************//**
@Function fm_port_set_rate_limit
@Description Configure Shaper parameter on FM-port device (Tx port).
--- a/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
+++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
@@ -1,5 +1,6 @@
/*
* Copyright 2008-2012 Freescale Semiconductor Inc.
+ * Copyright 2019 NXP
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
@@ -155,6 +156,10 @@ static int fsl_fm_pfc_quanta[] = {
static t_LnxWrpFm lnxWrpFm;
+#ifdef FM_ERRATUM_A010022
+static bool fm_has_err_a010022;
+#endif
+
int fm_get_max_frm()
{
return fsl_fm_max_frm;
@@ -167,6 +172,14 @@ int fm_get_rx_extra_headroom()
}
EXPORT_SYMBOL(fm_get_rx_extra_headroom);
+#ifdef FM_ERRATUM_A010022
+bool fm_has_errata_a010022(void)
+{
+ return fm_has_err_a010022;
+}
+EXPORT_SYMBOL(fm_has_errata_a010022);
+#endif
+
static int __init fm_set_max_frm(char *str)
{
int ret = 0;
@@ -749,6 +762,10 @@ static t_LnxWrpFmDev * ReadFmDevTreeNode
p_LnxWrpFmDev->defPcd = e_NO_PCD;
}
+#ifdef FM_ERRATUM_A010022
+ fm_has_err_a010022 = of_property_read_bool(fm_node, "fsl,erratum-a010022");
+#endif
+
of_node_put(fm_node);
p_LnxWrpFmDev->hcCh =