net: stmmac: return error if no DMA configuration is found
Subsystems (6)
PATCH 1/6 net: stmmac: return error if no DMA configuration is found
From: Niklas Cassel <[email protected]>
All drivers except pci glue layer calls stmmac_probe_config_dt. stmmac_probe_config_dt does a kzalloc dma_cfg.
pci glue layer does kzalloc dma_cfg explicitly, so all current drivers does a kzalloc dma_cfg.
Return an error if no DMA configuration is found, that way we can assume that the DMA configuration always exists.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +9 -9
@@ -1577,16 +1577,12 @@ static void stmmac_check_ether_addr(struct stmmac_priv *priv)*/ static int stmmac_init_dma_engine (struct stmmac_priv *priv) { -int pbl =DEFAULT_DMA_PBL , fixed_burst =0 , aal =0 ; -int mixed_burst =0 ;int atds =0 ;int ret =0 ; -if (priv->plat->dma_cfg) { - pbl = priv->plat->dma_cfg->pbl; - fixed_burst = priv->plat->dma_cfg->fixed_burst; - mixed_burst = priv->plat->dma_cfg->mixed_burst; - aal = priv->plat->dma_cfg->aal; +if (!priv->plat->dma_cfg) { +dev_err (priv->device,"DMA configuration not found\n" ); +return -EINVAL ; }if (priv->extend_desc && (priv->mode ==STMMAC_RING_MODE ))
@@ -1598,8 +1594,12 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)return ret; } - priv->hw->dma->init (priv->ioaddr, pbl, fixed_burst, mixed_burst, - aal, priv->dma_tx_phy, priv->dma_rx_phy, atds); + priv->hw->dma->init (priv->ioaddr, + priv->plat->dma_cfg->pbl, + priv->plat->dma_cfg->fixed_burst, + priv->plat->dma_cfg->mixed_burst, + priv->plat->dma_cfg->aal, + priv->dma_tx_phy, priv->dma_rx_phy, atds);if (priv->synopsys_id >=DWMAC_CORE_4_00 ) { priv->rx_tail_addr = priv->dma_rx_phy +
Signature · 1 line
2.1.4
PATCH 2/6 net: stmmac: simplify the common DMA init API
From: Niklas Cassel <[email protected]>
Use struct stmmac_dma_cfg *dma_cfg as an argument rather than using all the struct members as individual arguments.
--- drivers/net/ethernet/stmicro/stmmac/common.h | 4 ++-- drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c | 13 +++++++------ drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c | 7 ++++--- drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 14 ++++++++------ drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +----- 5 files changed, 22 insertions(+), 22 deletions(-)
drivers/net/ethernet/stmicro/stmmac/common.h +2 -2
@@ -411,8 +411,8 @@ extern const struct stmmac_desc_ops ndesc_ops;struct stmmac_dma_ops {/* DMA core initialization */ int (*reset)(void __iomem *ioaddr); -void (*init)(void __iomem *ioaddr,int pbl,int fb,int mb, -int aal,u32 dma_tx,u32 dma_rx,int atds); +void (*init)(void __iomem *ioaddr,struct stmmac_dma_cfg *dma_cfg, +u32 dma_tx,u32 dma_rx,int atds);/* Configure the AXI Bus Mode Register */ void (*axi)(void __iomem *ioaddr,struct stmmac_axi *axi);/* Dump DMA registers */
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c +7 -6
@@ -82,8 +82,9 @@ static void dwmac1000_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)writel (value, ioaddr +DMA_AXI_BUS_MODE ); } -static void dwmac1000_dma_init (void __iomem *ioaddr,int pbl,int fb,int mb, -int aal,u32 dma_tx,u32 dma_rx,int atds) +static void dwmac1000_dma_init (void __iomem *ioaddr, +struct stmmac_dma_cfg *dma_cfg, +u32 dma_tx,u32 dma_rx,int atds) {u32 value =readl (ioaddr +DMA_BUS_MODE );
@@ -99,20 +100,20 @@ static void dwmac1000_dma_init(void __iomem *ioaddr, int pbl, int fb, int mb,*/ value |=DMA_BUS_MODE_MAXPBL ; value &= ~DMA_BUS_MODE_PBL_MASK ; - value |= (pbl <<DMA_BUS_MODE_PBL_SHIFT ); + value |= (dma_cfg->pbl <<DMA_BUS_MODE_PBL_SHIFT );/* Set the Fixed burst mode */ -if (fb) +if (dma_cfg->fixed_burst) value |=DMA_BUS_MODE_FB ;/* Mixed Burst has no effect when fb is set */ -if (mb) +if (dma_cfg->mixed_burst) value |=DMA_BUS_MODE_MB ;if (atds) value |=DMA_BUS_MODE_ATDS ; -if (aal) +if (dma_cfg->aal) value |=DMA_BUS_MODE_AAL ;writel (value, ioaddr +DMA_BUS_MODE );
drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c +4 -3
@@ -32,11 +32,12 @@#include "dwmac100.h" #include "dwmac_dma.h" -static void dwmac100_dma_init (void __iomem *ioaddr,int pbl,int fb,int mb, -int aal,u32 dma_tx,u32 dma_rx,int atds) +static void dwmac100_dma_init (void __iomem *ioaddr, +struct stmmac_dma_cfg *dma_cfg, +u32 dma_tx,u32 dma_rx,int atds) {/* Enable Application Access by writing to DMA CSR0 */ -writel (DMA_BUS_MODE_DEFAULT | (pbl <<DMA_BUS_MODE_PBL_SHIFT ), +writel (DMA_BUS_MODE_DEFAULT | (dma_cfg->pbl <<DMA_BUS_MODE_PBL_SHIFT ), ioaddr +DMA_BUS_MODE );/* Mask interrupts by writing to CSR7 */
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +8 -6
@@ -97,27 +97,29 @@ static void dwmac4_dma_init_channel(void __iomem *ioaddr, int pbl,writel (dma_rx_phy, ioaddr +DMA_CHAN_RX_BASE_ADDR (channel)); } -static void dwmac4_dma_init (void __iomem *ioaddr,int pbl,int fb,int mb, -int aal,u32 dma_tx,u32 dma_rx,int atds) +static void dwmac4_dma_init (void __iomem *ioaddr, +struct stmmac_dma_cfg *dma_cfg, +u32 dma_tx,u32 dma_rx,int atds) {u32 value =readl (ioaddr +DMA_SYS_BUS_MODE );int i;/* Set the Fixed burst mode */ -if (fb) +if (dma_cfg->fixed_burst) value |=DMA_SYS_BUS_FB ;/* Mixed Burst has no effect when fb is set */ -if (mb) +if (dma_cfg->mixed_burst) value |=DMA_SYS_BUS_MB ; -if (aal) +if (dma_cfg->aal) value |=DMA_SYS_BUS_AAL ;writel (value, ioaddr +DMA_SYS_BUS_MODE );for (i =0 ; i <DMA_CHANNEL_NB_MAX ; i++) -dwmac4_dma_init_channel (ioaddr, pbl, dma_tx, dma_rx, i); +dwmac4_dma_init_channel (ioaddr, dma_cfg->pbl, + dma_tx, dma_rx, i); }static void _dwmac4_dump_dma_regs (void __iomem *ioaddr,u32 channel)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +1 -5
@@ -1594,11 +1594,7 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)return ret; } - priv->hw->dma->init (priv->ioaddr, - priv->plat->dma_cfg->pbl, - priv->plat->dma_cfg->fixed_burst, - priv->plat->dma_cfg->mixed_burst, - priv->plat->dma_cfg->aal, + priv->hw->dma->init (priv->ioaddr, priv->plat->dma_cfg, priv->dma_tx_phy, priv->dma_rx_phy, atds);if (priv->synopsys_id >=DWMAC_CORE_4_00 ) {
Signature · 1 line
2.1.4
PATCH 3/6 net: stmmac: stmmac_platform: fix parsing of DT binding
In reply to Niklas CasselFrom: Niklas Cassel <[email protected]>
commit 64c3b252e9fc ("net: stmmac: fixed the pbl setting with DT") changed the parsing of the DT binding.
Before 64c3b252e9fc, snps,fixed-burst and snps,mixed-burst were parsed regardless if the property snps,pbl existed or not.
After the commit, fixed burst and mixed burst are only parsed if snps,pbl exists. Now when snps,aal has been added, it too is only parsed if snps,pbl exists.
Since the DT binding does not specify that fixed burst, mixed burst or aal depend on snps,pbl being specified, undo changes introduced by 64c3b252e9fc.
The issue commit 64c3b252e9fc ("net: stmmac: fixed the pbl setting with DT") tries to address is solved in another way:
The databook specifies that all values other than
1, 2, 4, 8, 16, or 32 results in undefined behavior,
so snps,pbl = <0> is invalid.
If pbl is 0 after parsing, set pbl to DEFAULT_DMA_PBL. This handles the case where the property is omitted, and also handles the case where the property is specified without any data.
--- drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 3 +++ .../net/ethernet/stmicro/stmmac/stmmac_platform.c | 27 +++++++++++----------- 2 files changed, 16 insertions(+), 14 deletions(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +3 -0
@@ -1585,6 +1585,9 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)return -EINVAL ; } +if (!priv->plat->dma_cfg->pbl) + priv->plat->dma_cfg->pbl =DEFAULT_DMA_PBL ; +if (priv->extend_desc && (priv->mode ==STMMAC_RING_MODE )) atds =1 ;
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +13 -14
@@ -303,21 +303,20 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) plat->force_sf_dma_mode =1 ; } -if (of_find_property (np,"snps,pbl" ,NULL )) { - dma_cfg =devm_kzalloc (&pdev->dev,sizeof (*dma_cfg), -GFP_KERNEL ); -if (!dma_cfg) { -of_node_put (plat->phy_node); -return ERR_PTR (-ENOMEM ); - } - plat->dma_cfg = dma_cfg; -of_property_read_u32 (np,"snps,pbl" , &dma_cfg->pbl); - dma_cfg->aal =of_property_read_bool (np,"snps,aal" ); - dma_cfg->fixed_burst = -of_property_read_bool (np,"snps,fixed-burst" ); - dma_cfg->mixed_burst = -of_property_read_bool (np,"snps,mixed-burst" ); + dma_cfg =devm_kzalloc (&pdev->dev,sizeof (*dma_cfg), +GFP_KERNEL ); +if (!dma_cfg) { +of_node_put (plat->phy_node); +return ERR_PTR (-ENOMEM ); } + plat->dma_cfg = dma_cfg; + +of_property_read_u32 (np,"snps,pbl" , &dma_cfg->pbl); + + dma_cfg->aal =of_property_read_bool (np,"snps,aal" ); + dma_cfg->fixed_burst =of_property_read_bool (np,"snps,fixed-burst" ); + dma_cfg->mixed_burst =of_property_read_bool (np,"snps,mixed-burst" ); + plat->force_thresh_dma_mode =of_property_read_bool (np,"snps,force_thresh_dma_mode" );if (plat->force_thresh_dma_mode) { plat->force_sf_dma_mode =0 ;
Signature · 1 line
2.1.4
PATCH 4/6 net: stmmac: dwmac1000: fix define DMA_BUS_MODE_RPBL_MASK
In reply to Niklas CasselFrom: Niklas Cassel <[email protected]>
DMA_BUS_MODE_RPBL_MASK is really 6 bits,
just like DMA_BUS_MODE_PBL_MASK.
--- drivers/net/ethernet/stmicro/stmmac/dwmac1000.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/dwmac1000.h +1 -1
@@ -225,7 +225,7 @@ enum rx_tx_priority_ratio {#define DMA_BUS_MODE_FB 0x00010000/* Fixed burst */ #define DMA_BUS_MODE_MB 0x04000000/* Mixed burst */ -#define DMA_BUS_MODE_RPBL_MASK 0x003e0000/* Rx-Programmable Burst Len */ +#define DMA_BUS_MODE_RPBL_MASK 0x007e0000/* Rx-Programmable Burst Len */ #define DMA_BUS_MODE_RPBL_SHIFT 17#define DMA_BUS_MODE_USP 0x00800000#define DMA_BUS_MODE_MAXPBL 0x01000000
Signature · 1 line
2.1.4
PATCH 5/6 net: stmmac: add support for independent DMA pbl for tx/rx
In reply to Niklas CasselFrom: Niklas Cassel <[email protected]>
GMAC and newer supports independent programmable burst lengths for DMA tx/rx. Add new optional devicetree properties representing this.
To be backwards compatible, snps,pbl will still be valid, but snps,txpbl/snps,rxpbl will override the value in snps,pbl if set.
If the IP is synthesized to use the AXI interface, there is a register and a matching DT property inside the optional stmmac-axi-config DT node for controlling burst lengths, named snps,blen.
However, using this register, it is not possible to control tx and rx independently. Also, this register is not available if the IP was synthesized with, e.g., the AHB interface.
--- Documentation/devicetree/bindings/net/stmmac.txt | 6 +++++- Documentation/networking/stmmac.txt | 19 +++++++++++++------ drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c | 12 ++++++------ drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 12 +++++++----- drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 2 ++ include/linux/stmmac.h | 2 ++ 6 files changed, 35 insertions(+), 18 deletions(-)
Documentation/devicetree/bindings/net/stmmac.txt +5 -1
@@ -34,7 +34,11 @@ Optional properties: platforms. - tx-fifo-depth: See ethernet.txt file in the same directory - rx-fifo-depth: See ethernet.txt file in the same directory -- snps,pbl Programmable Burst Length +- snps,pbl Programmable Burst Length (tx and rx) +- snps,txpbl Tx Programmable Burst Length. Only for GMAC and newer. + If set, DMA tx will use this value rather than snps,pbl. +- snps,rxpbl Rx Programmable Burst Length. Only for GMAC and newer. + If set, DMA rx will use this value rather than snps,pbl. - snps,aal Address-Aligned Beats - snps,fixed-burst Program the DMA to use the fixed burst mode - snps,mixed-burst Program the DMA to use the mixed burst mode
Documentation/networking/stmmac.txt +13 -6
@@ -154,7 +154,8 @@ Where: o pbl: the Programmable Burst Length is maximum number of beats to be transferred in one DMA transaction. GMAC also enables the 4xPBL by default. - o fixed_burst/mixed_burst/burst_len + o txpbl/rxpbl: GMAC and newer supports independent DMA pbl for tx/rx. + o fixed_burst/mixed_burst/aal o clk_csr: fixed CSR Clock range selection. o has_gmac: uses the GMAC core. o enh_desc: if sets the MAC will use the enhanced descriptor structure.
@@ -206,16 +207,22 @@ tuned according to the HW capabilities. struct stmmac_dma_cfg { int pbl; + int txpbl; + int rxpbl; int fixed_burst; - int burst_len_supported; + int mixed_burst; + bool aal; }; Where: - o pbl: Programmable Burst Length + o pbl: Programmable Burst Length (tx and rx) + o txpbl: Transmit Programmable Burst Length. Only for GMAC and newer. + If set, DMA tx will use this value rather than pbl. + o rxpbl: Receive Programmable Burst Length. Only for GMAC and newer. + If set, DMA rx will use this value rather than pbl. o fixed_burst: program the DMA to use the fixed burst mode - o burst_len: this is the value we put in the register - supported values are provided as macros in - linux/stmmac.h header file. + o mixed_burst: program the DMA to use the mixed burst mode + o aal: Address-Aligned Beats ---
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c +6 -6
@@ -87,20 +87,20 @@ static void dwmac1000_dma_init(void __iomem *ioaddr, u32 dma_tx, u32 dma_rx, int atds) { u32 value = readl(ioaddr + DMA_BUS_MODE); +int txpbl = dma_cfg->txpbl ?: dma_cfg->pbl; +int rxpbl = dma_cfg->rxpbl ?: dma_cfg->pbl;/* * Set the DMA PBL (Programmable Burst Length) mode. * * Note: before stmmac core 3.50 this mode bit was 4xPBL, and * post 3.5 mode bit acts as 8*PBL. -* -* This configuration doesn't take care about the Separate PBL -* so only the bits: 13-8 are programmed with the PBL passed from the -* platform. */ value |=DMA_BUS_MODE_MAXPBL ; - value &= ~DMA_BUS_MODE_PBL_MASK ; - value |= (dma_cfg->pbl <<DMA_BUS_MODE_PBL_SHIFT ); + value |=DMA_BUS_MODE_USP ; + value &= ~(DMA_BUS_MODE_PBL_MASK |DMA_BUS_MODE_RPBL_MASK ); + value |= (txpbl <<DMA_BUS_MODE_PBL_SHIFT ); + value |= (rxpbl <<DMA_BUS_MODE_RPBL_SHIFT );/* Set the Fixed burst mode */ if (dma_cfg->fixed_burst)
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +7 -5
@@ -69,11 +69,14 @@ static void dwmac4_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)writel (value, ioaddr +DMA_SYS_BUS_MODE ); } -static void dwmac4_dma_init_channel (void __iomem *ioaddr,int pbl, +static void dwmac4_dma_init_channel (void __iomem *ioaddr, +struct stmmac_dma_cfg *dma_cfg,u32 dma_tx_phy,u32 dma_rx_phy,u32 channel) {u32 value; +int txpbl = dma_cfg->txpbl ?: dma_cfg->pbl; +int rxpbl = dma_cfg->rxpbl ?: dma_cfg->pbl;/* set PBL for each channels. Currently we affect same configuration * on each channel
@@ -83,11 +86,11 @@ static void dwmac4_dma_init_channel(void __iomem *ioaddr, int pbl,writel (value, ioaddr +DMA_CHAN_CONTROL (channel)); value =readl (ioaddr +DMA_CHAN_TX_CONTROL (channel)); - value = value | (pbl <<DMA_BUS_MODE_PBL_SHIFT ); + value = value | (txpbl <<DMA_BUS_MODE_PBL_SHIFT );writel (value, ioaddr +DMA_CHAN_TX_CONTROL (channel)); value =readl (ioaddr +DMA_CHAN_RX_CONTROL (channel)); - value = value | (pbl <<DMA_BUS_MODE_RPBL_SHIFT ); + value = value | (rxpbl <<DMA_BUS_MODE_RPBL_SHIFT );writel (value, ioaddr +DMA_CHAN_RX_CONTROL (channel));/* Mask interrupts by writing to CSR7 */
@@ -118,8 +121,7 @@ static void dwmac4_dma_init(void __iomem *ioaddr,writel (value, ioaddr +DMA_SYS_BUS_MODE );for (i =0 ; i <DMA_CHANNEL_NB_MAX ; i++) -dwmac4_dma_init_channel (ioaddr, dma_cfg->pbl, - dma_tx, dma_rx, i); +dwmac4_dma_init_channel (ioaddr, dma_cfg, dma_tx, dma_rx, i); }static void _dwmac4_dump_dma_regs (void __iomem *ioaddr,u32 channel)
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c +2 -0
@@ -312,6 +312,8 @@ stmmac_probe_config_dt(struct platform_device *pdev, const char **mac) plat->dma_cfg = dma_cfg;of_property_read_u32 (np,"snps,pbl" , &dma_cfg->pbl); +of_property_read_u32 (np,"snps,txpbl" , &dma_cfg->txpbl); +of_property_read_u32 (np,"snps,rxpbl" , &dma_cfg->rxpbl); dma_cfg->aal =of_property_read_bool (np,"snps,aal" ); dma_cfg->fixed_burst =of_property_read_bool (np,"snps,fixed-burst" );
include/linux/stmmac.h +2 -0
@@ -88,6 +88,8 @@ struct stmmac_mdio_bus_data {struct stmmac_dma_cfg {int pbl; +int txpbl; +int rxpbl;int fixed_burst;int mixed_burst;bool aal;
Signature · 1 line
2.1.4
David Miller
maintainerWhen you post a series of related changes as a patch set, you must provide a proper "[PATCH 0/N] ..." posting which explains what the series is doing at a high level, how it is doing it, and why it is doing it that way.
Please repost this entire series with a proper header posting included.
Thank you.