Make DMA programmable burst length more configurable in the stmmac driver.
This is done by adding support for independent pbl for tx/rx through DT.
More fine grained tuning of pbl is possible thanks to a DT property saying
that we should NOT multiply pbl values by x8/x4 in hardware.
All new DT properties are optional, and created in a way that it will not
affect any existing DT configurations.
Changes since V1:
Created cover-letter.
Rebased patch set against next-20161205, since conflicting patches to
stmmac_platform.c has been merged since V1.
Changes since V2:
Moved default value initialization of pbl to stmmac_platform.c
and added a check for pbl != 0 in stmmac_main.c,
to catch a possble pbl == 0 from pci glue.
Niklas Cassel (6):
net: stmmac: return error if no DMA configuration is found
net: stmmac: simplify the common DMA init API
net: stmmac: stmmac_platform: fix parsing of DT binding
net: stmmac: dwmac1000: fix define DMA_BUS_MODE_RPBL_MASK
net: stmmac: add support for independent DMA pbl for tx/rx
net: smmac: allow configuring lower pbl values
Documentation/devicetree/bindings/net/stmmac.txt | 8 +++++-
Documentation/networking/stmmac.txt | 24 +++++++++++-----
drivers/net/ethernet/stmicro/stmmac/common.h | 4 +--
drivers/net/ethernet/stmicro/stmmac/dwmac1000.h | 2 +-
.../net/ethernet/stmicro/stmmac/dwmac1000_dma.c | 26 ++++++++++--------
drivers/net/ethernet/stmicro/stmmac/dwmac100_dma.c | 7 +++--
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 25 ++++++++++-------
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 14 ++++------
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 ++
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 32 ++++++++++++----------
include/linux/stmmac.h | 3 ++
11 files changed, 88 insertions(+), 59 deletions(-)
--
2.1.4
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Niklas Cassel <redacted>
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.
Signed-off-by: Niklas Cassel <redacted>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
@@ -101,20 +102,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);
@@ -32,11 +32,12 @@#include"dwmac100.h"#include"dwmac_dma.h"-staticvoiddwmac100_dma_init(void__iomem*ioaddr,intpbl,intfb,intmb,-intaal,u32dma_tx,u32dma_rx,intatds)+staticvoiddwmac100_dma_init(void__iomem*ioaddr,+structstmmac_dma_cfg*dma_cfg,+u32dma_tx,u32dma_rx,intatds){/* 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 */
@@ -99,27 +99,29 @@ static void dwmac4_dma_init_channel(void __iomem *ioaddr, int pbl,writel(dma_rx_phy,ioaddr+DMA_CHAN_RX_BASE_ADDR(channel));}-staticvoiddwmac4_dma_init(void__iomem*ioaddr,intpbl,intfb,intmb,-intaal,u32dma_tx,u32dma_rx,intatds)+staticvoiddwmac4_dma_init(void__iomem*ioaddr,+structstmmac_dma_cfg*dma_cfg,+u32dma_tx,u32dma_rx,intatds){u32value=readl(ioaddr+DMA_SYS_BUS_MODE);inti;/* 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);}staticvoid_dwmac4_dump_dma_regs(void__iomem*ioaddr,u32channel)
From: Niklas Cassel <redacted>
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.
Signed-off-by: Niklas Cassel <redacted>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +--
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 29 +++++++++++-----------
2 files changed, 17 insertions(+), 16 deletions(-)
From: Niklas Cassel <redacted>
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.
Signed-off-by: Niklas Cassel <redacted>
---
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(-)
@@ -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
@@ -153,7 +153,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.
@@ -205,16 +206,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 ---
@@ -71,11 +71,14 @@ static void dwmac4_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)writel(value,ioaddr+DMA_SYS_BUS_MODE);}-staticvoiddwmac4_dma_init_channel(void__iomem*ioaddr,intpbl,+staticvoiddwmac4_dma_init_channel(void__iomem*ioaddr,+structstmmac_dma_cfg*dma_cfg,u32dma_tx_phy,u32dma_rx_phy,u32channel){u32value;+inttxpbl=dma_cfg->txpbl?:dma_cfg->pbl;+intrxpbl=dma_cfg->rxpbl?:dma_cfg->pbl;/* set PBL for each channels. Currently we affect same configuration*oneachchannel
@@ -85,11 +88,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 */
From: Niklas Cassel <redacted>
The driver currently always sets the PBLx8/PBLx4 bit, which means that
the pbl values configured via the pbl/txpbl/rxpbl DT properties are
always multiplied by 8/4 in the hardware.
In order to allow the DT to configure lower pbl values, while at the
same time not changing behavior of any existing device trees using the
pbl/txpbl/rxpbl settings, add a property to disable the multiplication
of the pbl by 8/4 in the hardware.
Suggested-by: Rabin Vincent <redacted>
Signed-off-by: Niklas Cassel <redacted>
---
Documentation/devicetree/bindings/net/stmmac.txt | 2 ++
Documentation/networking/stmmac.txt | 5 ++++-
drivers/net/ethernet/stmicro/stmmac/dwmac1000_dma.c | 3 ++-
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 3 ++-
drivers/net/ethernet/stmicro/stmmac/stmmac_pci.c | 2 ++
drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c | 1 +
include/linux/stmmac.h | 1 +
7 files changed, 14 insertions(+), 3 deletions(-)
@@ -39,6 +39,8 @@ Optional properties: 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,no-pbl-x8 Don't multiply the pbl/txpbl/rxpbl values by 8.+ For core rev < 3.50, don't multiply the values by 4. - 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
@@ -152,8 +152,9 @@ Where: o dma_cfg: internal DMA parameters 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.+ GMAC also enables the 4xPBL by default. (8xPBL for GMAC 3.50 and newer) o txpbl/rxpbl: GMAC and newer supports independent DMA pbl for tx/rx.+ o pblx8: Enable 8xPBL (4xPBL for core rev < 3.50). Enabled by default. o fixed_burst/mixed_burst/aal o clk_csr: fixed CSR Clock range selection. o has_gmac: uses the GMAC core.
@@ -208,6 +209,7 @@ struct stmmac_dma_cfg { int pbl; int txpbl; int rxpbl;+ bool pblx8; int fixed_burst; int mixed_burst; bool aal;
@@ -219,6 +221,7 @@ Where: 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 pblx8: Enable 8xPBL (4xPBL for core rev < 3.50). Enabled by default. o fixed_burst: program the DMA to use the fixed burst mode o mixed_burst: program the DMA to use the mixed burst mode o aal: Address-Aligned Beats
Hi Niklas,
On 12/07/2016 03:20 PM, Niklas Cassel wrote:
From: Niklas Cassel <redacted>
Use struct stmmac_dma_cfg *dma_cfg as an argument rather
than using all the struct members as individual arguments.
Signed-off-by: Niklas Cassel <redacted>
Thanks for this patch. You can add my Acked-by.
Regards
Alex
@@ -101,20 +102,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);
@@ -32,11 +32,12 @@#include"dwmac100.h"#include"dwmac_dma.h"-staticvoiddwmac100_dma_init(void__iomem*ioaddr,intpbl,intfb,intmb,-intaal,u32dma_tx,u32dma_rx,intatds)+staticvoiddwmac100_dma_init(void__iomem*ioaddr,+structstmmac_dma_cfg*dma_cfg,+u32dma_tx,u32dma_rx,intatds){/* 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 */
@@ -99,27 +99,29 @@ static void dwmac4_dma_init_channel(void __iomem *ioaddr, int pbl,writel(dma_rx_phy,ioaddr+DMA_CHAN_RX_BASE_ADDR(channel));}-staticvoiddwmac4_dma_init(void__iomem*ioaddr,intpbl,intfb,intmb,-intaal,u32dma_tx,u32dma_rx,intatds)+staticvoiddwmac4_dma_init(void__iomem*ioaddr,+structstmmac_dma_cfg*dma_cfg,+u32dma_tx,u32dma_rx,intatds){u32value=readl(ioaddr+DMA_SYS_BUS_MODE);inti;/* 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);}staticvoid_dwmac4_dump_dma_regs(void__iomem*ioaddr,u32channel)
Hi Niklas
On 12/07/2016 03:20 PM, Niklas Cassel wrote:
quoted hunk
From: Niklas Cassel <redacted>
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.
Signed-off-by: Niklas Cassel <redacted>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +--
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 29 +++++++++++-----------
2 files changed, 17 insertions(+), 16 deletions(-)
Hi Niklas
On 12/07/2016 03:20 PM, Niklas Cassel wrote:
quoted
From: Niklas Cassel <redacted>
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.
Signed-off-by: Niklas Cassel <redacted>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +--
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 29 +++++++++++-----------
2 files changed, 17 insertions(+), 16 deletions(-)
@@ -1581,8 +1581,8 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)intatds=0;intret=0;-if(!priv->plat->dma_cfg){-dev_err(priv->device,"DMA configuration not found\n");+if(!priv->plat->dma_cfg||!priv->plat->dma_cfg->pbl){
How "priv->plat->dma_cfg->pbl" could be equal to 0 if you force it to DEFAULT_DMA_PBL in "stmmac_probe_config_dt" in case of DT doesn't set pbl value?
The PCI glue code does not call stmmac_probe_config_dt.
Also any glue driver could override the value set by stmmac_probe_config_dt
before calling stmmac_dvr_probe. So I guess if we want any trustworthy
sanity-checking, it actually has to be done in stmmac_main.c.
Hi Niklas
On 12/07/2016 03:20 PM, Niklas Cassel wrote:
quoted
From: Niklas Cassel <redacted>
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.
Signed-off-by: Niklas Cassel <redacted>
---
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 4 +--
.../net/ethernet/stmicro/stmmac/stmmac_platform.c | 29 +++++++++++-----------
2 files changed, 17 insertions(+), 16 deletions(-)
@@ -1581,8 +1581,8 @@ static int stmmac_init_dma_engine(struct stmmac_priv *priv)intatds=0;intret=0;-if(!priv->plat->dma_cfg){-dev_err(priv->device,"DMA configuration not found\n");+if(!priv->plat->dma_cfg||!priv->plat->dma_cfg->pbl){
How "priv->plat->dma_cfg->pbl" could be equal to 0 if you force it to DEFAULT_DMA_PBL in "stmmac_probe_config_dt" in case of DT doesn't set pbl value?
The PCI glue code does not call stmmac_probe_config_dt.
Also any glue driver could override the value set by stmmac_probe_config_dt
before calling stmmac_dvr_probe. So I guess if we want any trustworthy
sanity-checking, it actually has to be done in stmmac_main.c.
Ok I see, it is more safe. You can add my Acked-by.
Thanks
Alex
Hi Niklas
On 12/07/2016 03:20 PM, Niklas Cassel wrote:
From: Niklas Cassel <redacted>
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.
Signed-off-by: Niklas Cassel <redacted>
@@ -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
@@ -153,7 +153,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.
@@ -205,16 +206,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 ---
@@ -71,11 +71,14 @@ static void dwmac4_dma_axi(void __iomem *ioaddr, struct stmmac_axi *axi)writel(value,ioaddr+DMA_SYS_BUS_MODE);}-staticvoiddwmac4_dma_init_channel(void__iomem*ioaddr,intpbl,+staticvoiddwmac4_dma_init_channel(void__iomem*ioaddr,+structstmmac_dma_cfg*dma_cfg,u32dma_tx_phy,u32dma_rx_phy,u32channel){u32value;+inttxpbl=dma_cfg->txpbl?:dma_cfg->pbl;+intrxpbl=dma_cfg->rxpbl?:dma_cfg->pbl;/* set PBL for each channels. Currently we affect same configuration*oneachchannel
@@ -85,11 +88,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 */
Hi Niklas,
On 12/07/2016 03:20 PM, Niklas Cassel wrote:
From: Niklas Cassel <redacted>
The driver currently always sets the PBLx8/PBLx4 bit, which means that
the pbl values configured via the pbl/txpbl/rxpbl DT properties are
always multiplied by 8/4 in the hardware.
In order to allow the DT to configure lower pbl values, while at the
same time not changing behavior of any existing device trees using the
pbl/txpbl/rxpbl settings, add a property to disable the multiplication
of the pbl by 8/4 in the hardware.
Suggested-by: Rabin Vincent <redacted>
Signed-off-by: Niklas Cassel <redacted>
Thanks for this patch, you can add my Acked-by.
Thanks for the whole series.
Alex
@@ -39,6 +39,8 @@ Optional properties: 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,no-pbl-x8 Don't multiply the pbl/txpbl/rxpbl values by 8.+ For core rev < 3.50, don't multiply the values by 4. - 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
@@ -152,8 +152,9 @@ Where: o dma_cfg: internal DMA parameters 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.+ GMAC also enables the 4xPBL by default. (8xPBL for GMAC 3.50 and newer) o txpbl/rxpbl: GMAC and newer supports independent DMA pbl for tx/rx.+ o pblx8: Enable 8xPBL (4xPBL for core rev < 3.50). Enabled by default. o fixed_burst/mixed_burst/aal o clk_csr: fixed CSR Clock range selection. o has_gmac: uses the GMAC core.
@@ -208,6 +209,7 @@ struct stmmac_dma_cfg { int pbl; int txpbl; int rxpbl;+ bool pblx8; int fixed_burst; int mixed_burst; bool aal;
@@ -219,6 +221,7 @@ Where: 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 pblx8: Enable 8xPBL (4xPBL for core rev < 3.50). Enabled by default. o fixed_burst: program the DMA to use the fixed burst mode o mixed_burst: program the DMA to use the mixed burst mode o aal: Address-Aligned Beats
Hi Niklas,
On 12/07/2016 03:20 PM, Niklas Cassel wrote:
From: Niklas Cassel <redacted>
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.
Signed-off-by: Niklas Cassel <redacted>
From: Andreas Färber <afaerber@suse.de> Date: 2016-12-08 14:04:49
Hi,
In subject: s/smmac/stmmac/
Regards,
Andreas
--
SUSE Linux GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Felix Imendörffer, Jane Smithard, Graham Norton
HRB 21284 (AG Nürnberg)
Please simply state:
Acked-by: Alexandre Torgue <redacted>
in your reply and it will automatically appear when the patch is
applied. You don't have to ask the patch submitter or the person who
applies it to do it as you are doing here.
Typo in your email.
I would suggest that you put this into an editor macro or
similar in order to avoid such typos in the future. That's
what people do who review a lot of patches.
Typo in your email.
I would suggest that you put this into an editor macro or
similar in order to avoid such typos in the future. That's
what people do who review a lot of patches.
Make DMA programmable burst length more configurable in the stmmac driver.
This is done by adding support for independent pbl for tx/rx through DT.
More fine grained tuning of pbl is possible thanks to a DT property saying
that we should NOT multiply pbl values by x8/x4 in hardware.
All new DT properties are optional, and created in a way that it will not
affect any existing DT configurations.