net: stmmac: Set DMA buffer size in HW
This is clearly a bug. We need to set the DMA buffer size in the HW otherwise corruption can occur when receiving packets. This is probably not occuring because of small MTU values and because HW has a default value internally (which currently is bigger than default buffer size). Signed-off-by: Jose Abreu <joabreu@synopsys.com> Cc: David S. Miller <davem@davemloft.net> Cc: Joao Pinto <jpinto@synopsys.com> Cc: Vitor Soares <soares@synopsys.com> Cc: Giuseppe Cavallaro <peppe.cavallaro@st.com> Cc: Alexandre Torgue <alexandre.torgue@st.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Родитель
24ac3a08e6
Коммит
4205c88eaf
|
@ -407,6 +407,16 @@ static void dwmac4_enable_tso(void __iomem *ioaddr, bool en, u32 chan)
|
|||
}
|
||||
}
|
||||
|
||||
static void dwmac4_set_bfsize(void __iomem *ioaddr, int bfsize, u32 chan)
|
||||
{
|
||||
u32 value = readl(ioaddr + DMA_CHAN_RX_CONTROL(chan));
|
||||
|
||||
value &= ~DMA_RBSZ_MASK;
|
||||
value |= (bfsize << DMA_RBSZ_SHIFT) & DMA_RBSZ_MASK;
|
||||
|
||||
writel(value, ioaddr + DMA_CHAN_RX_CONTROL(chan));
|
||||
}
|
||||
|
||||
const struct stmmac_dma_ops dwmac4_dma_ops = {
|
||||
.reset = dwmac4_dma_reset,
|
||||
.init = dwmac4_dma_init,
|
||||
|
@ -431,6 +441,7 @@ const struct stmmac_dma_ops dwmac4_dma_ops = {
|
|||
.set_rx_tail_ptr = dwmac4_set_rx_tail_ptr,
|
||||
.set_tx_tail_ptr = dwmac4_set_tx_tail_ptr,
|
||||
.enable_tso = dwmac4_enable_tso,
|
||||
.set_bfsize = dwmac4_set_bfsize,
|
||||
};
|
||||
|
||||
const struct stmmac_dma_ops dwmac410_dma_ops = {
|
||||
|
@ -457,4 +468,5 @@ const struct stmmac_dma_ops dwmac410_dma_ops = {
|
|||
.set_rx_tail_ptr = dwmac4_set_rx_tail_ptr,
|
||||
.set_tx_tail_ptr = dwmac4_set_tx_tail_ptr,
|
||||
.enable_tso = dwmac4_enable_tso,
|
||||
.set_bfsize = dwmac4_set_bfsize,
|
||||
};
|
||||
|
|
|
@ -120,6 +120,8 @@
|
|||
|
||||
/* DMA Rx Channel X Control register defines */
|
||||
#define DMA_CONTROL_SR BIT(0)
|
||||
#define DMA_RBSZ_MASK GENMASK(14, 1)
|
||||
#define DMA_RBSZ_SHIFT 1
|
||||
|
||||
/* Interrupt status per channel */
|
||||
#define DMA_CHAN_STATUS_REB GENMASK(21, 19)
|
||||
|
|
|
@ -183,6 +183,7 @@ struct stmmac_dma_ops {
|
|||
void (*set_rx_tail_ptr)(void __iomem *ioaddr, u32 tail_ptr, u32 chan);
|
||||
void (*set_tx_tail_ptr)(void __iomem *ioaddr, u32 tail_ptr, u32 chan);
|
||||
void (*enable_tso)(void __iomem *ioaddr, bool en, u32 chan);
|
||||
void (*set_bfsize)(void __iomem *ioaddr, int bfsize, u32 chan);
|
||||
};
|
||||
|
||||
#define stmmac_reset(__priv, __args...) \
|
||||
|
@ -235,6 +236,8 @@ struct stmmac_dma_ops {
|
|||
stmmac_do_void_callback(__priv, dma, set_tx_tail_ptr, __args)
|
||||
#define stmmac_enable_tso(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, enable_tso, __args)
|
||||
#define stmmac_set_dma_bfsize(__priv, __args...) \
|
||||
stmmac_do_void_callback(__priv, dma, set_bfsize, __args)
|
||||
|
||||
struct mac_device_info;
|
||||
struct net_device;
|
||||
|
|
|
@ -1804,6 +1804,8 @@ static void stmmac_dma_operation_mode(struct stmmac_priv *priv)
|
|||
|
||||
stmmac_dma_rx_mode(priv, priv->ioaddr, rxmode, chan,
|
||||
rxfifosz, qmode);
|
||||
stmmac_set_dma_bfsize(priv, priv->ioaddr, priv->dma_buf_sz,
|
||||
chan);
|
||||
}
|
||||
|
||||
for (chan = 0; chan < tx_channels_count; chan++) {
|
||||
|
|
Загрузка…
Ссылка в новой задаче