Message ID | 20200110115415.75683-5-andre.przywara@arm.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | net: axienet: Error handling, SGMII and 64-bit DMA fixes | expand |
> -----Original Message----- > From: Andre Przywara <andre.przywara@arm.com> > Sent: Friday, January 10, 2020 5:24 PM > To: David S . Miller <davem@davemloft.net>; Radhey Shyam Pandey > <radheys@xilinx.com> > Cc: Michal Simek <michals@xilinx.com>; Robert Hancock > <hancock@sedsystems.ca>; netdev@vger.kernel.org; linux-arm- > kernel@lists.infradead.org; linux-kernel@vger.kernel.org > Subject: [PATCH 04/14] net: axienet: Improve DMA error handling > > Since 0 is a valid DMA address, we cannot use the physical address to > check whether a TX descriptor is valid and is holding a DMA mapping. > > Use the "cntrl" member of the descriptor to make this decision, as it > contains at least the length of the buffer, so 0 points to an > uninitialised buffer. > > Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Radhey Shyam Pandey <radhey.shyam.pandey@xilinx.com> > --- > drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 4 ++-- > 1 file changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c > b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c > index 7e90044cf2d9..ec5d01adc1d5 100644 > --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c > +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c > @@ -570,7 +570,7 @@ static void axienet_start_xmit_done(struct > net_device *ndev) > DMA_TO_DEVICE); > if (cur_p->skb) > dev_consume_skb_irq(cur_p->skb); > - /*cur_p->phys = 0;*/ > + cur_p->cntrl = 0; > cur_p->app0 = 0; > cur_p->app1 = 0; > cur_p->app2 = 0; > @@ -1557,7 +1557,7 @@ static void axienet_dma_err_handler(unsigned > long data) > > for (i = 0; i < lp->tx_bd_num; i++) { > cur_p = &lp->tx_bd_v[i]; > - if (cur_p->phys) > + if (cur_p->cntrl) > dma_unmap_single(ndev->dev.parent, cur_p->phys, > (cur_p->cntrl & > > XAXIDMA_BD_CTRL_LENGTH_MASK), > -- > 2.17.1
diff --git a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c index 7e90044cf2d9..ec5d01adc1d5 100644 --- a/drivers/net/ethernet/xilinx/xilinx_axienet_main.c +++ b/drivers/net/ethernet/xilinx/xilinx_axienet_main.c @@ -570,7 +570,7 @@ static void axienet_start_xmit_done(struct net_device *ndev) DMA_TO_DEVICE); if (cur_p->skb) dev_consume_skb_irq(cur_p->skb); - /*cur_p->phys = 0;*/ + cur_p->cntrl = 0; cur_p->app0 = 0; cur_p->app1 = 0; cur_p->app2 = 0; @@ -1557,7 +1557,7 @@ static void axienet_dma_err_handler(unsigned long data) for (i = 0; i < lp->tx_bd_num; i++) { cur_p = &lp->tx_bd_v[i]; - if (cur_p->phys) + if (cur_p->cntrl) dma_unmap_single(ndev->dev.parent, cur_p->phys, (cur_p->cntrl & XAXIDMA_BD_CTRL_LENGTH_MASK),
Since 0 is a valid DMA address, we cannot use the physical address to check whether a TX descriptor is valid and is holding a DMA mapping. Use the "cntrl" member of the descriptor to make this decision, as it contains at least the length of the buffer, so 0 points to an uninitialised buffer. Signed-off-by: Andre Przywara <andre.przywara@arm.com> --- drivers/net/ethernet/xilinx/xilinx_axienet_main.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)