E1000 driver AArch64 related fixes
Subsystems (2)
cover E1000 driver AArch64 related fixes
Everyone:
This series contains various fixes/changes I made in order to get E1000 driver to work on AArch64/i.MX8MQ as well as generic code improvement patches. Hopefully each patch is self-explanatory.
Feedback is welcome!
Thanks,
Andrey Smirnov
Andrey Smirnov (16):
ARM: Select HAS_DMA for AArch64
include: Import io-64-nonatomic-*.h from Linux net/e1000: Don't use coherent memory for Rx buffer net/e1000: Convert e1000_transmit to use dma_map_single() net/e1000: Fix debug print warning
net/e1000: Fix incorrect "Rx ready" check
net/e1000: Get rid of pointer arithmetic in e1000_poll net/e1000: Improve Rx descriptor handling in e1000_poll() net/e1000: Remove pointer arithmetic in e1000_transmit() net/e1000: Improve Tx descriptor handling in e1000_transmit net/e1000: Make use of readl_poll_timeout() in e1000_transmit() net/e1000: Rename fill_rx() to e1000_fill_rx() net/e1000: Remove pointer arithmetic from e1000_fill_rx() net/e1000: Consolidate next index calculation code net/e1000: Improve RX buffer handling in e1000_fill_rx() net/e1000: Do not hardcode TDBAH and RDBAH to 0
arch/arm/cpu/Kconfig | 1 + drivers/net/e1000/e1000.h | 1 + drivers/net/e1000/eeprom.c | 3 +- drivers/net/e1000/main.c | 113 ++++++++++++++++++-------------- include/io-64-nonatomic-hi-lo.h | 32 +++++++++ include/io-64-nonatomic-lo-hi.h | 32 +++++++++ 6 files changed, 131 insertions(+), 51 deletions(-) create mode 100644 include/io-64-nonatomic-hi-lo.h create mode 100644 include/io-64-nonatomic-lo-hi.h
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 1/16 ARM: Select HAS_DMA for AArch64
AArch64 implements all of the DMA API functions, so it should select HAS_DMA to allow building drivers that depend on that.
--- arch/arm/cpu/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/cpu/Kconfig +1 -0
@@ -13,6 +13,7 @@ config CPU_64 bool select PHYS_ADDR_T_64BIT select HAVE_PBL_IMAGE + select HAS_DMA # Select CPU types depending on the architecture selected. This selects # which CPUs we support in the kernel image, and the compiler instruction
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 2/16 include: Import io-64-nonatomic-*.h from Linux
In reply to Andrey SmirnovImport io-64-nonatomic-*.h from Linux to be able to use various non-atomic 64-bit I/O accessors.
--- include/io-64-nonatomic-hi-lo.h | 32 ++++++++++++++++++++++++++++++++ include/io-64-nonatomic-lo-hi.h | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 include/io-64-nonatomic-hi-lo.h create mode 100644 include/io-64-nonatomic-lo-hi.h
include/io-64-nonatomic-hi-lo.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_IO_64_NONATOMIC_HI_LO_H_ +#define _LINUX_IO_64_NONATOMIC_HI_LO_H_ + +#include <io.h> + +static inline __u64 hi_lo_readq (const volatile void __iomem *addr) +{ +const volatile u32 __iomem *p = addr; +u32 low, high; + + high =readl (p +1 ); + low =readl (p); + +return low + ((u64 )high <<32 ); +} + +static inline void hi_lo_writeq (__u64 val,volatile void __iomem *addr) +{ +writel (val >>32 , addr +4 ); +writel (val, addr); +} + +#ifndef readq +#define readq hi_lo_readq +#endif + +#ifndef writeq +#define writeq hi_lo_writeq +#endif + +#endif /* _LINUX_IO_64_NONATOMIC_HI_LO_H_ */
include/io-64-nonatomic-lo-hi.h new file +32 -0
@@ -0,0 +1,32 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _LINUX_IO_64_NONATOMIC_LO_HI_H_ +#define _LINUX_IO_64_NONATOMIC_LO_HI_H_ + +#include <io.h> + +static inline __u64 lo_hi_readq (const volatile void __iomem *addr) +{ +const volatile u32 __iomem *p = addr; +u32 low, high; + + low =readl (p); + high =readl (p +1 ); + +return low + ((u64 )high <<32 ); +} + +static inline void lo_hi_writeq (__u64 val,volatile void __iomem *addr) +{ +writel (val, addr); +writel (val >>32 , addr +4 ); +} + +#ifndef readq +#define readq lo_hi_readq +#endif + +#ifndef writeq +#define writeq lo_hi_writeq +#endif + +#endif /* _LINUX_IO_64_NONATOMIC_LO_HI_H_ */
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 3/16 net/e1000: Don't use coherent memory for Rx buffer
In reply to Andrey SmirnovIn order to avoid issues on AArch64, convert the driver to use regular memory and add appropriate DMA sync calls. Drop needless (uchar *) cast while at it.
--- drivers/net/e1000/e1000.h | 1 + drivers/net/e1000/main.c | 18 ++++++++++++++---- 2 files changed, 15 insertions(+), 4 deletions(-)
drivers/net/e1000/e1000.h +1 -0
@@ -2182,6 +2182,7 @@ struct e1000_hw {struct e1000_tx_desc *tx_base;struct e1000_rx_desc *rx_base;unsigned char *packet; +dma_addr_t packet_dma;int tx_tail;int rx_tail, rx_last;
drivers/net/e1000/main.c +14 -4
@@ -3215,7 +3215,7 @@ static void fill_rx(struct e1000_hw *hw)for (i =0 ; i <4 ; i++) *bla++ =0 ; - rd->buffer_addr =cpu_to_le64 ((unsigned long )hw->packet); + rd->buffer_addr =cpu_to_le64 (hw->packet_dma);e1000_write_reg (hw,E1000_RDT , hw->rx_tail); }
@@ -3406,9 +3406,11 @@ static int e1000_poll(struct eth_device *edev) len =le32_to_cpu (rd->length); -dma_sync_single_for_cpu ((unsigned long )hw->packet, len,DMA_FROM_DEVICE ); +dma_sync_single_for_cpu (hw->packet_dma, len,DMA_FROM_DEVICE ); -net_receive (edev, (uchar *)hw->packet, len); +net_receive (edev, hw->packet, len); + +dma_sync_single_for_device (hw->packet_dma, len,DMA_FROM_DEVICE );fill_rx (hw);return 1 ; }
@@ -3561,7 +3563,6 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *id) hw->tx_base =dma_alloc_coherent (16 *sizeof (*hw->tx_base),DMA_ADDRESS_BROKEN ); hw->rx_base =dma_alloc_coherent (16 *sizeof (*hw->rx_base),DMA_ADDRESS_BROKEN ); - hw->packet =dma_alloc_coherent (4096 ,DMA_ADDRESS_BROKEN ); edev = &hw->edev;
@@ -3570,6 +3571,15 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *id) pdev->dev.priv = hw; edev->priv = hw; + hw->packet =dma_alloc (PAGE_SIZE ); +if (!hw->packet) +return -ENOMEM ; + + hw->packet_dma =dma_map_single (hw->dev, hw->packet,PAGE_SIZE , +DMA_FROM_DEVICE ); +if (dma_mapping_error (hw->dev, hw->packet_dma)) +return -EFAULT ; + hw->hw_addr =pci_iomap (pdev,0 );/* MAC and Phy settings */
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 4/16 net/e1000: Convert e1000_transmit to use dma_map_single()
In reply to Andrey SmirnovConvert e1000_transmit to use dma_map_single()/dma_unmap_single(), which is more apporpirate in this case, since it will account for phys/virtual address difference as well as allow us to check for DMA mapping failure.
--- drivers/net/e1000/main.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/net/e1000/main.c +12 -9
@@ -36,11 +36,6 @@ tested on both gig copper and gig fiber boards#include <dma.h> #include "e1000.h" -static u32 inline virt_to_bus (struct pci_dev *pdev,void *adr) -{ -return (u32 )adr; -} -#define PCI_VENDOR_ID_INTEL 0x8086
@@ -3420,15 +3415,20 @@ static int e1000_transmit(struct eth_device *edev, void *txpacket, int length)struct e1000_hw *hw = edev->priv;volatile struct e1000_tx_desc *txp;uint64_t to; +dma_addr_t dma; +int ret =0 ; txp = hw->tx_base + hw->tx_tail; hw->tx_tail = (hw->tx_tail +1 ) %8 ; - txp->buffer_addr =cpu_to_le64 (virt_to_bus (hw->pdev, txpacket)); txp->lower.data =cpu_to_le32 (hw->txd_cmd | length); txp->upper.data =0 ; -dma_sync_single_for_device ((unsigned long )txpacket, length,DMA_TO_DEVICE ); + dma =dma_map_single (hw->dev, txpacket, length,DMA_TO_DEVICE ); +if (dma_mapping_error (hw->dev, dma)) +return -EFAULT ; + + txp->buffer_addr =cpu_to_le64 (dma);e1000_write_reg (hw,E1000_TDT , hw->tx_tail);
@@ -3440,11 +3440,14 @@ static int e1000_transmit(struct eth_device *edev, void *txpacket, int length)break ;if (is_timeout (to,MSECOND )) {dev_dbg (hw->dev,"e1000: tx timeout\n" ); -return -ETIMEDOUT ; + ret = -ETIMEDOUT ; +break ; } } -return 0 ; +dma_unmap_single (hw->dev, dma, length,DMA_TO_DEVICE ); + +return ret; }static void e1000_disable (struct eth_device *edev)
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 5/16 net/e1000: Fix debug print warning
In reply to Andrey SmirnovCast eeprom->word_size to int, so it would match its printf specifier to avoid getting errors when building on AArch64.
--- drivers/net/e1000/eeprom.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/net/e1000/eeprom.c +2 -1
@@ -1000,7 +1000,8 @@ int32_t e1000_read_eeprom(struct e1000_hw *hw, uint16_t offset, (words > eeprom->word_size - offset) || (words == 0)) {dev_dbg (hw->dev,"\"words\" parameter out of bounds." -"Words = %d, size = %d\n" , offset, eeprom->word_size); +"Words = %d, size = %d\n" , offset, + (int )eeprom->word_size);return -E1000_ERR_EEPROM ; }
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 6/16 net/e1000: Fix incorrect "Rx ready" check
In reply to Andrey SmirnovDue to wrong placement of parenthesis in
if (!(le32_to_cpu(rd->status)) & E1000_RXD_STAT_DD) return 0;
instead of checking that E1000_RXD_STAT_DD is not set, the condition ends up checking that "status" is 0.
Change the code to invert the condition tested and get rid of ! entirely.
--- drivers/net/e1000/main.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-)
drivers/net/e1000/main.c +11 -8
@@ -3396,18 +3396,21 @@ static int e1000_poll(struct eth_device *edev) rd = hw->rx_base + hw->rx_last; -if (!(le32_to_cpu (rd->status)) &E1000_RXD_STAT_DD ) -return 0 ; +if (le32_to_cpu (rd->status) &E1000_RXD_STAT_DD ) { + len =le32_to_cpu (rd->length); - len =le32_to_cpu (rd->length); +dma_sync_single_for_cpu (hw->packet_dma, len, +DMA_FROM_DEVICE ); -dma_sync_single_for_cpu (hw->packet_dma, len,DMA_FROM_DEVICE ); +net_receive (edev, hw->packet, len); -net_receive (edev, hw->packet, len); +dma_sync_single_for_device (hw->packet_dma, len, +DMA_FROM_DEVICE ); +fill_rx (hw); +return 1 ; + } -dma_sync_single_for_device (hw->packet_dma, len,DMA_FROM_DEVICE ); -fill_rx (hw); -return 1 ; +return 0 ; }static int e1000_transmit (struct eth_device *edev,void *txpacket,int length)
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 7/16 net/e1000: Get rid of pointer arithmetic in e1000_poll
In reply to Andrey SmirnovInstead of relying on reles of pointer arithmetic (implicit multiplication by the size of pointer type), change the code to retreive address of an array elemet to clarify the intent.
--- drivers/net/e1000/main.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/net/e1000/main.c +1 -3
@@ -3391,11 +3391,9 @@ static void e1000_configure_rx(struct e1000_hw *hw)static int e1000_poll (struct eth_device *edev) {struct e1000_hw *hw = edev->priv; -volatile struct e1000_rx_desc *rd; +volatile struct e1000_rx_desc *rd = &hw->rx_base[hw->rx_last];uint32_t len; - rd = hw->rx_base + hw->rx_last; -if (le32_to_cpu (rd->status) &E1000_RXD_STAT_DD ) { len =le32_to_cpu (rd->length);
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 8/16 net/e1000: Improve Rx descriptor handling in e1000_poll()
In reply to Andrey SmirnovDrop explicit volatile specifier as well as endianness conversion by changing the code to use appropriate read*() IO accessors.
While at it if fix incorrect width used for "status" (8 vs 32) and "len" (16 vs 32).
--- drivers/net/e1000/main.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/net/e1000/main.c +3 -4
@@ -3391,11 +3391,10 @@ static void e1000_configure_rx(struct e1000_hw *hw)static int e1000_poll (struct eth_device *edev) {struct e1000_hw *hw = edev->priv; -volatile struct e1000_rx_desc *rd = &hw->rx_base[hw->rx_last]; -uint32_t len; +struct e1000_rx_desc *rd = &hw->rx_base[hw->rx_last]; -if (le32_to_cpu (rd->status) &E1000_RXD_STAT_DD ) { - len =le32_to_cpu (rd->length); +if (readb (&rd->status) &E1000_RXD_STAT_DD ) { +const uint16_t len =readw (&rd->length);dma_sync_single_for_cpu (hw->packet_dma, len,DMA_FROM_DEVICE );
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 9/16 net/e1000: Remove pointer arithmetic in e1000_transmit()
In reply to Andrey SmirnovInstead of relying on reles of pointer arithmetic (implicit multiplication by the size of pointer type), change the code to retreive address of an array elemet to clarify the intent.
--- drivers/net/e1000/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/e1000/main.c +1 -2
@@ -3413,12 +3413,11 @@ static int e1000_poll(struct eth_device *edev)static int e1000_transmit (struct eth_device *edev,void *txpacket,int length) {struct e1000_hw *hw = edev->priv; -volatile struct e1000_tx_desc *txp; +volatile struct e1000_tx_desc *txp = &hw->tx_base[hw->tx_tail];uint64_t to;dma_addr_t dma;int ret =0 ; - txp = hw->tx_base + hw->tx_tail; hw->tx_tail = (hw->tx_tail +1 ) %8 ; txp->lower.data =cpu_to_le32 (hw->txd_cmd | length);
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 10/16 net/e1000: Improve Tx descriptor handling in e1000_transmit
In reply to Andrey SmirnovDrop explicit "volatile" specifier for struct e1000_tx_desc as well as explicit endiannes fix, by using little endian IO accessors (readl, writel, etc.)
--- drivers/net/e1000/main.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/net/e1000/main.c +6 -6
@@ -35,6 +35,7 @@ tested on both gig copper and gig fiber boards#include <linux/pci.h> #include <dma.h> #include "e1000.h" +#include <io-64-nonatomic-lo-hi.h> #define PCI_VENDOR_ID_INTEL 0x8086
@@ -3413,29 +3414,28 @@ static int e1000_poll(struct eth_device *edev)static int e1000_transmit (struct eth_device *edev,void *txpacket,int length) {struct e1000_hw *hw = edev->priv; -volatile struct e1000_tx_desc *txp = &hw->tx_base[hw->tx_tail]; +struct e1000_tx_desc *txp = &hw->tx_base[hw->tx_tail];uint64_t to;dma_addr_t dma;int ret =0 ; hw->tx_tail = (hw->tx_tail +1 ) %8 ; - txp->lower.data =cpu_to_le32 (hw->txd_cmd | length); - txp->upper.data =0 ; +writel (hw->txd_cmd | length, &txp->lower.data); +writel (0 , &txp->upper.data); dma =dma_map_single (hw->dev, txpacket, length,DMA_TO_DEVICE );if (dma_mapping_error (hw->dev, dma))return -EFAULT ; - txp->buffer_addr =cpu_to_le64 (dma); - +writeq (dma, &txp->buffer_addr);e1000_write_reg (hw,E1000_TDT , hw->tx_tail);e1000_write_flush (hw); to =get_time_ns ();while (1 ) { -if (le32_to_cpu (txp->upper.data) &E1000_TXD_STAT_DD ) +if (readl (&txp->upper.data) &E1000_TXD_STAT_DD )break ;if (is_timeout (to,MSECOND )) {dev_dbg (hw->dev,"e1000: tx timeout\n" );
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 11/16 net/e1000: Make use of readl_poll_timeout() in e1000_transmit()
In reply to Andrey SmirnovSimplify code of e1000_transmit() with readl_poll_timeout().
--- drivers/net/e1000/main.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-)
drivers/net/e1000/main.c +8 -12
@@ -33,6 +33,7 @@ tested on both gig copper and gig fiber boards#include <init.h> #include <malloc.h> #include <linux/pci.h> +#include <linux/iopoll.h> #include <dma.h> #include "e1000.h" #include <io-64-nonatomic-lo-hi.h>
@@ -3415,9 +3416,9 @@ static int e1000_transmit(struct eth_device *edev, void *txpacket, int length) {struct e1000_hw *hw = edev->priv;struct e1000_tx_desc *txp = &hw->tx_base[hw->tx_tail]; -uint64_t to;dma_addr_t dma; -int ret =0 ; +uint32_t stat; +int ret; hw->tx_tail = (hw->tx_tail +1 ) %8 ;
@@ -3433,16 +3434,11 @@ static int e1000_transmit(struct eth_device *edev, void *txpacket, int length)e1000_write_flush (hw); - to =get_time_ns (); -while (1 ) { -if (readl (&txp->upper.data) &E1000_TXD_STAT_DD ) -break ; -if (is_timeout (to,MSECOND )) { -dev_dbg (hw->dev,"e1000: tx timeout\n" ); - ret = -ETIMEDOUT ; -break ; - } - } + ret =readl_poll_timeout (&txp->upper.data, + stat, stat &E1000_TXD_STAT_DD , +MSECOND /USECOND ); +if (ret) +dev_dbg (hw->dev,"e1000: tx timeout\n" );dma_unmap_single (hw->dev, dma, length,DMA_TO_DEVICE );
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 12/16 net/e1000: Rename fill_rx() to e1000_fill_rx()
In reply to Andrey SmirnovRename fill_rx() to e1000_fill_rx() to match the naming convention of other functions in the file.
--- drivers/net/e1000/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-)
drivers/net/e1000/main.c +3 -3
@@ -3198,7 +3198,7 @@ static int e1000_sw_init(struct eth_device *edev)return E1000_SUCCESS ; } -static void fill_rx (struct e1000_hw *hw) +static void e1000_fill_rx (struct e1000_hw *hw) {volatile struct e1000_rx_desc *rd;volatile u32 *bla;
@@ -3387,7 +3387,7 @@ static void e1000_configure_rx(struct e1000_hw *hw)e1000_write_reg (hw,E1000_RCTL , rctl); -fill_rx (hw); +e1000_fill_rx (hw); }static int e1000_poll (struct eth_device *edev)
@@ -3405,7 +3405,7 @@ static int e1000_poll(struct eth_device *edev)dma_sync_single_for_device (hw->packet_dma, len,DMA_FROM_DEVICE ); -fill_rx (hw); +e1000_fill_rx (hw);return 1 ; }
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 13/16 net/e1000: Remove pointer arithmetic from e1000_fill_rx()
In reply to Andrey SmirnovInstead of relying on reles of pointer arithmetic (implicit multiplication by the size of pointer type), change the code to retreive address of an array elemet to clarify the intent.
--- drivers/net/e1000/main.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/net/e1000/main.c +1 -2
@@ -3200,12 +3200,11 @@ static int e1000_sw_init(struct eth_device *edev)static void e1000_fill_rx (struct e1000_hw *hw) { -volatile struct e1000_rx_desc *rd; +volatile struct e1000_rx_desc *rd = &hw->rx_base[hw->rx_tail];volatile u32 *bla;int i; hw->rx_last = hw->rx_tail; - rd = hw->rx_base + hw->rx_tail; hw->rx_tail = (hw->rx_tail +1 ) %8 ; bla = (void *)rd;
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 14/16 net/e1000: Consolidate next index calculation code
In reply to Andrey SmirnovConsolidate next index calculation code into a helper function and convert the code to make use of it.
--- drivers/net/e1000/main.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/net/e1000/main.c +7 -2
@@ -3198,6 +3198,11 @@ static int e1000_sw_init(struct eth_device *edev)return E1000_SUCCESS ; } +static int e1000_bd_next_index (int index) +{ +return (index +1 ) %8 ; +} +static void e1000_fill_rx (struct e1000_hw *hw) {volatile struct e1000_rx_desc *rd = &hw->rx_base[hw->rx_tail];
@@ -3205,7 +3210,7 @@ static void e1000_fill_rx(struct e1000_hw *hw)int i; hw->rx_last = hw->rx_tail; - hw->rx_tail = (hw->rx_tail +1 ) %8 ; + hw->rx_tail =e1000_bd_next_index (hw->rx_tail); bla = (void *)rd;for (i =0 ; i <4 ; i++)
@@ -3419,7 +3424,7 @@ static int e1000_transmit(struct eth_device *edev, void *txpacket, int length)uint32_t stat;int ret; - hw->tx_tail = (hw->tx_tail +1 ) %8 ; + hw->tx_tail =e1000_bd_next_index (hw->tx_tail);writel (hw->txd_cmd | length, &txp->lower.data);writel (0 , &txp->upper.data);
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 15/16 net/e1000: Improve RX buffer handling in e1000_fill_rx()
In reply to Andrey SmirnovDrop explicit "volatile" specifier for struct e1000_rx_desc, "bla" variable as well as explicit endiannes fix, by using little endian IO accessors (readl, writel, etc.)
--- drivers/net/e1000/main.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/net/e1000/main.c +7 -8
@@ -3205,18 +3205,17 @@ static int e1000_bd_next_index(int index)static void e1000_fill_rx (struct e1000_hw *hw) { -volatile struct e1000_rx_desc *rd = &hw->rx_base[hw->rx_tail]; -volatile u32 *bla; -int i; +struct e1000_rx_desc *rd = &hw->rx_base[hw->rx_tail]; hw->rx_last = hw->rx_tail; hw->rx_tail =e1000_bd_next_index (hw->rx_tail); - bla = (void *)rd; -for (i =0 ; i <4 ; i++) - *bla++ =0 ; - - rd->buffer_addr =cpu_to_le64 (hw->packet_dma); +writeq (hw->packet_dma, &rd->buffer_addr); +writew (0 , &rd->length); +writew (0 , &rd->csum); +writeb (0 , &rd->status); +writeb (0 , &rd->errors); +writew (0 , &rd->special);e1000_write_reg (hw,E1000_RDT , hw->rx_tail); }
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
PATCH 16/16 net/e1000: Do not hardcode TDBAH and RDBAH to 0
In reply to Andrey SmirnovWhile there currently no user of e1000 driver that places those rings beyond 4GiB boundary, there's also no real reason not to initialize those registers properly.
--- drivers/net/e1000/main.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
drivers/net/e1000/main.c +6 -4
@@ -3232,9 +3232,10 @@ static void e1000_configure_tx(struct e1000_hw *hw)unsigned long tctl;unsigned long tipg, tarc;uint32_t ipgr1, ipgr2; +const unsigned long tx_base = (unsigned long )hw->tx_base; -e1000_write_reg (hw,E1000_TDBAL , (unsigned long )hw->tx_base); -e1000_write_reg (hw,E1000_TDBAH ,0 ); +e1000_write_reg (hw,E1000_TDBAL ,lower_32_bits (tx_base)); +e1000_write_reg (hw,E1000_TDBAH ,upper_32_bits (tx_base));e1000_write_reg (hw,E1000_TDLEN ,128 );
@@ -3350,6 +3351,7 @@ static void e1000_setup_rctl(struct e1000_hw *hw)static void e1000_configure_rx (struct e1000_hw *hw) {unsigned long rctl, ctrl_ext; +const unsigned long rx_base = (unsigned long )hw->rx_base; hw->rx_tail =0 ;/* make sure receives are disabled while setting up the descriptors */
@@ -3371,8 +3373,8 @@ static void e1000_configure_rx(struct e1000_hw *hw)e1000_write_flush (hw); }/* Setup the Base and Length of the Rx Descriptor Ring */ -e1000_write_reg (hw,E1000_RDBAL , (unsigned long )hw->rx_base); -e1000_write_reg (hw,E1000_RDBAH ,0 ); +e1000_write_reg (hw,E1000_RDBAL ,lower_32_bits (rx_base)); +e1000_write_reg (hw,E1000_RDBAH ,upper_32_bits (rx_base));e1000_write_reg (hw,E1000_RDLEN ,128 );
Signature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Sascha Hauer
AppliedQuoted 10 lines · Andrey Smirnov
Everyone:
This series contains various fixes/changes I made in order to get E1000 driver to work on AArch64/i.MX8MQ as well as generic code improvement patches. Hopefully each patch is self-explanatory.
Feedback is welcome!
Thanks,
Andrey Smirnov
Applied, thanks
Sascha
Quoted 38 lines
Andrey Smirnov (16):
ARM: SelectHAS_DMAfor AArch64
include: Import io-64-nonatomic-*.h from Linux net/e1000: Don't use coherent memory for Rx buffer net/e1000: Converte1000_transmitto usedma_map_single()net/e1000: Fix debug print warning
net/e1000: Fix incorrect "Rx ready" check
net/e1000: Get rid of pointer arithmetic ine1000_pollnet/e1000: Improve Rx descriptor handling ine1000_poll()net/e1000: Remove pointer arithmetic ine1000_transmit()net/e1000: Improve Tx descriptor handling ine1000_transmitnet/e1000: Make use ofreadl_poll_timeout()ine1000_transmit()net/e1000: Renamefill_rx()toe1000_fill_rx()net/e1000: Remove pointer arithmetic frome1000_fill_rx()net/e1000: Consolidate next index calculation code net/e1000: Improve RX buffer handling ine1000_fill_rx()net/e1000: Do not hardcode TDBAH and RDBAH to 0arch/arm/cpu/Kconfig | 1 + drivers/net/e1000/e1000.h | 1 + drivers/net/e1000/eeprom.c | 3 +- drivers/net/e1000/main.c | 113 ++++++++++++++++++-------------- include/io-64-nonatomic-hi-lo.h | 32 +++++++++ include/io-64-nonatomic-lo-hi.h | 32 +++++++++ 6 files changed, 131 insertions(+), 51 deletions(-) create mode 100644 include/io-64-nonatomic-hi-lo.h create mode 100644 include/io-64-nonatomic-lo-hi.hSignature · 7 lines
2.20.1 _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K. | | Industrial Linux Solutions | http://www.pengutronix.de/ | Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 | _______________________________________________ barebox mailing list [email protected] http://lists.infradead.org/mailman/listinfo/barebox