Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: axienet: Wrap DMA pointer writes to prepare for 64 bit

Newer versions of the Xilink DMA IP support busses with more than 32
address bits, by introducing an MSB word for the registers holding DMA
pointers (tail/current, RX/TX descriptor addresses).
On IP configured for more than 32 bits, it is also *required* to write
both words, to let the IP recognise this as a start condition for an
MM2S request, for instance.

Wrap the DMA pointer writes with a separate function, to add this
functionality later. For now we stick to the lower 32 bits.

Signed-off-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Andre Przywara and committed by
David S. Miller
6a00d0dd 2a9b65ea

+16 -10
+16 -10
drivers/net/ethernet/xilinx/xilinx_axienet_main.c
··· 147 147 iowrite32(value, lp->dma_regs + reg); 148 148 } 149 149 150 + static void axienet_dma_out_addr(struct axienet_local *lp, off_t reg, 151 + dma_addr_t addr) 152 + { 153 + axienet_dma_out32(lp, reg, lower_32_bits(addr)); 154 + } 155 + 150 156 /** 151 157 * axienet_dma_bd_release - Release buffer descriptor rings 152 158 * @ndev: Pointer to the net_device structure ··· 291 285 /* Populate the tail pointer and bring the Rx Axi DMA engine out of 292 286 * halted state. This will make the Rx side ready for reception. 293 287 */ 294 - axienet_dma_out32(lp, XAXIDMA_RX_CDESC_OFFSET, lp->rx_bd_p); 288 + axienet_dma_out_addr(lp, XAXIDMA_RX_CDESC_OFFSET, lp->rx_bd_p); 295 289 cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); 296 290 axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, 297 291 cr | XAXIDMA_CR_RUNSTOP_MASK); 298 - axienet_dma_out32(lp, XAXIDMA_RX_TDESC_OFFSET, lp->rx_bd_p + 299 - (sizeof(*lp->rx_bd_v) * (lp->rx_bd_num - 1))); 292 + axienet_dma_out_addr(lp, XAXIDMA_RX_TDESC_OFFSET, lp->rx_bd_p + 293 + (sizeof(*lp->rx_bd_v) * (lp->rx_bd_num - 1))); 300 294 301 295 /* Write to the RS (Run-stop) bit in the Tx channel control register. 302 296 * Tx channel is now ready to run. But only after we write to the 303 297 * tail pointer register that the Tx channel will start transmitting. 304 298 */ 305 - axienet_dma_out32(lp, XAXIDMA_TX_CDESC_OFFSET, lp->tx_bd_p); 299 + axienet_dma_out_addr(lp, XAXIDMA_TX_CDESC_OFFSET, lp->tx_bd_p); 306 300 cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); 307 301 axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, 308 302 cr | XAXIDMA_CR_RUNSTOP_MASK); ··· 763 757 764 758 tail_p = lp->tx_bd_p + sizeof(*lp->tx_bd_v) * lp->tx_bd_tail; 765 759 /* Start the transfer */ 766 - axienet_dma_out32(lp, XAXIDMA_TX_TDESC_OFFSET, tail_p); 760 + axienet_dma_out_addr(lp, XAXIDMA_TX_TDESC_OFFSET, tail_p); 767 761 if (++lp->tx_bd_tail >= lp->tx_bd_num) 768 762 lp->tx_bd_tail = 0; 769 763 ··· 855 849 ndev->stats.rx_bytes += size; 856 850 857 851 if (tail_p) 858 - axienet_dma_out32(lp, XAXIDMA_RX_TDESC_OFFSET, tail_p); 852 + axienet_dma_out_addr(lp, XAXIDMA_RX_TDESC_OFFSET, tail_p); 859 853 } 860 854 861 855 /** ··· 1677 1671 /* Populate the tail pointer and bring the Rx Axi DMA engine out of 1678 1672 * halted state. This will make the Rx side ready for reception. 1679 1673 */ 1680 - axienet_dma_out32(lp, XAXIDMA_RX_CDESC_OFFSET, lp->rx_bd_p); 1674 + axienet_dma_out_addr(lp, XAXIDMA_RX_CDESC_OFFSET, lp->rx_bd_p); 1681 1675 cr = axienet_dma_in32(lp, XAXIDMA_RX_CR_OFFSET); 1682 1676 axienet_dma_out32(lp, XAXIDMA_RX_CR_OFFSET, 1683 1677 cr | XAXIDMA_CR_RUNSTOP_MASK); 1684 - axienet_dma_out32(lp, XAXIDMA_RX_TDESC_OFFSET, lp->rx_bd_p + 1685 - (sizeof(*lp->rx_bd_v) * (lp->rx_bd_num - 1))); 1678 + axienet_dma_out_addr(lp, XAXIDMA_RX_TDESC_OFFSET, lp->rx_bd_p + 1679 + (sizeof(*lp->rx_bd_v) * (lp->rx_bd_num - 1))); 1686 1680 1687 1681 /* Write to the RS (Run-stop) bit in the Tx channel control register. 1688 1682 * Tx channel is now ready to run. But only after we write to the 1689 1683 * tail pointer register that the Tx channel will start transmitting 1690 1684 */ 1691 - axienet_dma_out32(lp, XAXIDMA_TX_CDESC_OFFSET, lp->tx_bd_p); 1685 + axienet_dma_out_addr(lp, XAXIDMA_TX_CDESC_OFFSET, lp->tx_bd_p); 1692 1686 cr = axienet_dma_in32(lp, XAXIDMA_TX_CR_OFFSET); 1693 1687 axienet_dma_out32(lp, XAXIDMA_TX_CR_OFFSET, 1694 1688 cr | XAXIDMA_CR_RUNSTOP_MASK);