From e95c46f86cc4170fec9177f27a9997dbcda64ed8 Mon Sep 17 00:00:00 2001 From: Srinivas Ramachandran Date: Tue, 10 Dec 2019 12:13:23 -0800 Subject: [PATCH] nvethernetrm: Zero initialize all descriptors Issue: Tx/Rx DMA initialization in OSI does not actually zero initialize all the descriptors. This inherently assumes that the OSD layer would already zero initialize the memory allocated for descriptors, which need not be the case for all OSD's as this requirement isn't called out. Fix: Instead of relying on OSD to zero initialize the descriptors, perform initialization in OSI during DMA init operation. It is one time cost at init, so no performance penalty in data path. Bug 2779959 Change-Id: I39431184980fceeb836eca872491ac8d7ee029ca Signed-off-by: Srinivas Ramachandran Reviewed-on: https://git-master.nvidia.com/r/2259541 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: Bhadram Varka GVS: Gerrit_Virtual_Submit Reviewed-by: Narayan Reddy Reviewed-by: Bharat Nihalani Reviewed-by: mobile promotions Tested-by: mobile promotions --- osi/dma/osi_dma_txrx.c | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/osi/dma/osi_dma_txrx.c b/osi/dma/osi_dma_txrx.c index 5bb0e1a..50d1a51 100644 --- a/osi/dma/osi_dma_txrx.c +++ b/osi/dma/osi_dma_txrx.c @@ -782,6 +782,12 @@ static int rx_dma_desc_initialization(struct osi_dma_priv_data *osi, rx_swcx = rx_ring->rx_swcx + i; rx_desc = rx_ring->rx_desc + i; + /* Zero initialize the descriptors first */ + rx_desc->rdes0 = 0; + rx_desc->rdes1 = 0; + rx_desc->rdes2 = 0; + rx_desc->rdes3 = 0; + tmp = L32(rx_swcx->buf_phy_addr); if (tmp < UINT_MAX) { rx_desc->rdes0 = (unsigned int)tmp; @@ -867,19 +873,20 @@ static void tx_dma_desc_init(struct osi_dma_priv_data *osi_dma) struct osi_tx_desc *tx_desc = OSI_NULL; struct osi_dma_chan_ops *ops = osi_dma->ops; unsigned int chan = 0; - unsigned int i; + unsigned int i, j; for (i = 0; i < osi_dma->num_dma_chans; i++) { chan = osi_dma->dma_chans[i]; - tx_ring = osi_dma->tx_ring[chan]; - tx_desc = tx_ring->tx_desc; - /* FIXME: does it require */ - tx_desc->tdes0 = 0; - tx_desc->tdes1 = 0; - tx_desc->tdes2 = 0; - tx_desc->tdes3 = 0; + for (j = 0; j < TX_DESC_CNT; j++) { + tx_desc = tx_ring->tx_desc + j; + + tx_desc->tdes0 = 0; + tx_desc->tdes1 = 0; + tx_desc->tdes2 = 0; + tx_desc->tdes3 = 0; + } tx_ring->cur_tx_idx = 0; tx_ring->clean_idx = 0;