Skip to contentSkip to conversation

WIP: MIPS: implement dma mapping functions

RFC In review Antony Pavlov 3 participants 16 messages Jan 9, 2020 – Feb 28, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover WIP: MIPS: implement dma mapping functions

Implementing dma mapping function on MIPS makes it possible to use e1000 and rtl8169 PCI network cards.

At the moment e1000 works under qemu. However additional dma mapping functions testing on real hardware is necessary.

Antony Pavlov (4):
WIP: MIPS: implement dma mapping functions
net: e1000: make it work on MIPS
net: rtl8169: make it work on big-endian system
MIPS: qemu-malta_defconfig: enable e1000 network driver

Peter Mamonov (1):
WIP: MIPS: configure ebase according CONFIG_MMU

 arch/mips/boot/main_entry.c            |  5 ++++
 arch/mips/configs/qemu-malta_defconfig |  1 +
 arch/mips/include/asm/dma-mapping.h    |  2 +-
 arch/mips/lib/dma-default.c            | 22 +++++++++++++++--
 drivers/net/e1000/e1000.h              |  2 ++
 drivers/net/e1000/main.c               |  8 +++---
 drivers/net/rtl8169.c                  | 34 +++++++++++++-------------
 7 files changed, 50 insertions(+), 24 deletions(-)
Signature · 7 lines
2.24.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

RFC 1/5 WIP: MIPS: configure ebase according CONFIG_MMU

From: Peter Mamonov <[email protected]>

---
 arch/mips/boot/main_entry.c | 5 +++++
 1 file changed, 5 insertions(+)
arch/mips/boot/main_entry.c +5 -0
index 2c18bc81c3..41350aad18 100644
@@ -34,7 +34,11 @@ static void trap_init(void)
 
 	unsigned long ebase;
 
+#ifdef CONFIG_MMU
+	ebase = CKSEG0;
+#else
 	ebase = CKSEG1;
+#endif
 
 	/*
 	 * Copy the generic exception handlers to their final destination.
@@ -56,6 +60,7 @@ static void trap_init(void)
 	/* FIXME: handle tlb */
 	memcpy((void *)(ebase), &except_vec3_generic, 0x80);
 
+	write_c0_ebase(ebase);
 	/* unset BOOT EXCEPTION VECTOR bit */
 	write_c0_status(read_c0_status() & ~ST0_BEV);
 }
Signature · 7 lines
2.24.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

Re: [RFC 1/5] WIP: MIPS: configure ebase according CONFIG_MMU

Hi,

Quoted 25 lines · Antony Pavlov

From: Peter Mamonov <[email protected]>

---
  arch/mips/boot/main_entry.c | 5 +++++
  1 file changed, 5 insertions(+)
arch/mips/boot/main_entry.c +4 -0
index 2c18bc81c3..41350aad18 100644
@@ -34,7 +34,11 @@ static void trap_init(void)
 
  	unsigned long ebase;
 
+#ifdef CONFIG_MMU
+	ebase = CKSEG0;
+#else
  	ebase = CKSEG1;
+#endif
 
  	/*
  	 * Copy the generic exception handlers to their final destination.

arch/mips/boot/main_entry.c static void trap_init(void) · line 63

Quoted 4 lines
arch/mips/boot/main_entry.c +1 -0
@@ -56,6 +60,7 @@ static void trap_init(void)
  	/* FIXME: handle tlb */
  	memcpy((void *)(ebase), &except_vec3_generic, 0x80);
 
+	write_c0_ebase(ebase);

The spec says:
"The reset state of bits 31..12 of the EBase register initialize the exception base register to 0x8000.0000, providing backward compatibility with Release 1 implementations.
....
If the write-gate bit is not implemented, bits 31..30 of the EBase register are fixed with the value 0b10,and the addi-tion of the base address and the exception offset is done inhibiting a carry between bit 29 and bit 30 of the final excep-tion address. The combination of these two restrictions forces the final exception address to be in the kseg0 or kseg1 unmapped virtual address segments. For cache error exceptions, bit 29 is forced to a 1 in the ultimate exception base address so that this exception always runs in the kseg1 unmapped, uncached virtual address segment."

So, in case of MMU the reset value stay unchanged = KSEG0 (cached), but the cpu will jump to KSEG1 (uncached) in case of cache related exception any way. In case of CONFIG_MMU=n, we force to work with KSEG1 (uncached) for all types of exceptions.

So, if I see it correctly, this fix is needed anyway and not DMA related. Correct? Can you please add this to commit message, to let no MIPS reviewers understand what is here happening.

arch/mips/boot/main_entry.c static void trap_init(void) · line 66

Quoted 4 lines
arch/mips/boot/main_entry.c +0 -0
  	/* unset BOOT EXCEPTION VECTOR bit */
  	write_c0_status(read_c0_status() & ~ST0_BEV);
  }

Kind regards,
Oleksij Rempel

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
#3 lore raw

RFC 2/5 WIP: MIPS: implement dma mapping functions

In reply to Antony Pavlov

TODO: fix warnings

arch/mips/include/asm/dma-mapping.h: In function ‘dma_free_coherent’:
arch/mips/include/asm/dma-mapping.h:31:21: warning: passing argument 1 of ‘phys_to_virt’ makes integer from pointer without a cast [-Wint-conversion]

   free(phys_to_virt(vaddr));
                     ^~~~~
In file included from include/common.h:33:0,
                 from drivers/net/e1000/main.c:32:
arch/mips/include/asm/io.h:40:21: note: expected ‘long unsigned int’ but argument is of type ‘void *’
 static inline void *phys_to_virt(unsigned long address)
                     ^~~~~~~~~~~~
---
 arch/mips/include/asm/dma-mapping.h |  2 +-
 arch/mips/lib/dma-default.c         | 22 ++++++++++++++++++++--
 2 files changed, 21 insertions(+), 3 deletions(-)
arch/mips/include/asm/dma-mapping.h +1 -1
index c71a087038..5013e7b369 100644
@@ -28,7 +28,7 @@ static inline void dma_free_coherent(void *vaddr, dma_addr_t dma_handle,
 				     size_t size)
 {
 	if (IS_ENABLED(CONFIG_MMU))
-		free((void *)CKSEG0ADDR(vaddr));
+		free(phys_to_virt(vaddr));
 	else
 		free(vaddr);
 }
arch/mips/lib/dma-default.c +20 -2
index fbe627c24c..40caf6f91b 100644
@@ -8,9 +8,11 @@
 
 #if defined(CONFIG_CPU_MIPS32) || \
 	defined(CONFIG_CPU_MIPS64)
-static inline void __dma_sync_mips(unsigned long addr, size_t size,
+static inline void __dma_sync_mips(dma_addr_t _addr, size_t size,
 				   enum dma_data_direction direction)
 {
+	void *addr = phys_to_virt(_addr);
+
 	switch (direction) {
 	case DMA_TO_DEVICE:
 		dma_flush_range(addr, addr + size);
@@ -29,7 +31,7 @@ static inline void __dma_sync_mips(unsigned long addr, size_t size,
 	}
 }
 #else
-static inline void __dma_sync_mips(void *addr, size_t size,
+static inline void __dma_sync_mips(dma_addr_t addr, size_t size,
 	enum dma_data_direction direction)
 {
 }
@@ -46,3 +48,19 @@ void dma_sync_single_for_device(dma_addr_t address, size_t size,
 {
 	__dma_sync_mips(address, size, dir);
 }
+
+dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
+			  enum dma_data_direction dir)
+{
+	unsigned long addr = virt_to_phys(ptr);
+
+	dma_sync_single_for_device(addr, size, dir);
+
+	return addr;
+}
+
+void dma_unmap_single(struct device_d *dev, dma_addr_t addr, size_t size,
+		      enum dma_data_direction dir)
+{
+	dma_sync_single_for_cpu(addr, size, dir);
+}
Signature · 7 lines
2.24.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw
Quoted 60 lines · Antony Pavlov

TODO: fix warnings

arch/mips/include/asm/dma-mapping.h: In function ‘dma_free_coherent’:
arch/mips/include/asm/dma-mapping.h:31:21: warning: passing argument 1 of ‘phys_to_virt’ makes integer from pointer without a cast [-Wint-conversion]

    free(phys_to_virt(vaddr));
                      ^~~~~
In file included from include/common.h:33:0,
                  from drivers/net/e1000/main.c:32:
arch/mips/include/asm/io.h:40:21: note: expected ‘long unsigned int’ but argument is of type ‘void *’
  static inline void *phys_to_virt(unsigned long address)
                      ^~~~~~~~~~~~
---
  arch/mips/include/asm/dma-mapping.h |  2 +-
  arch/mips/lib/dma-default.c         | 22 ++++++++++++++++++++--
  2 files changed, 21 insertions(+), 3 deletions(-)
arch/mips/include/asm/dma-mapping.h +1 -1
index c71a087038..5013e7b369 100644
@@ -28,7 +28,7 @@ static inline void dma_free_coherent(void *vaddr, dma_addr_t dma_handle,
  				     size_t size)
  {
  	if (IS_ENABLED(CONFIG_MMU))
-		free((void *)CKSEG0ADDR(vaddr));
+		free(phys_to_virt(vaddr));
  	else
  		free(vaddr);
  }
arch/mips/lib/dma-default.c +4 -2
index fbe627c24c..40caf6f91b 100644
@@ -8,9 +8,11 @@
 
  #if defined(CONFIG_CPU_MIPS32) || \
  	defined(CONFIG_CPU_MIPS64)
-static inline void __dma_sync_mips(unsigned long addr, size_t size,
+static inline void __dma_sync_mips(dma_addr_t _addr, size_t size,
  				   enum dma_data_direction direction)
  {
+	void *addr = phys_to_virt(_addr);
+
  	switch (direction) {
  	case DMA_TO_DEVICE:
  		dma_flush_range(addr, addr + size);
@@ -29,7 +31,7 @@ static inline void __dma_sync_mips(unsigned long addr, size_t size,
  	}
  }
  #else
-static inline void __dma_sync_mips(void *addr, size_t size,
+static inline void __dma_sync_mips(dma_addr_t addr, size_t size,
  	enum dma_data_direction direction)
  {
  }

arch/mips/lib/dma-default.c void dma_sync_single_for_device(dma_addr_t address, size_t size, · line 57

Quoted 10 lines
arch/mips/lib/dma-default.c +7 -0
@@ -46,3 +48,19 @@ void dma_sync_single_for_device(dma_addr_t address, size_t size,
  {
  	__dma_sync_mips(address, size, dir);
  }
+
+dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
+			  enum dma_data_direction dir)
+{
+	unsigned long addr = virt_to_phys(ptr);
+
+	dma_sync_single_for_device(addr, size, dir);

Hm.. i was thinking Hit Invalidate D instruction works with Virtual addresses. Are you sure we need to use virt_to_phys() here?

arch/mips/lib/dma-default.c void dma_sync_single_for_device(dma_addr_t address, size_t size, · line 66

Quoted 10 lines
arch/mips/lib/dma-default.c +9 -0
+
+	return addr;
+}
+
+void dma_unmap_single(struct device_d *dev, dma_addr_t addr, size_t size,
+		      enum dma_data_direction dir)
+{
+	dma_sync_single_for_cpu(addr, size, dir);
+}

Kind regards,
Oleksij Rempel

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
#5 lore raw
Quoted 66 lines · On Mon, 13 Jan 2020 09:26:36 +0100 Oleksij Rempel <[email protected]>…
Quoted 65 lines · Antony Pavlov

TODO: fix warnings

arch/mips/include/asm/dma-mapping.h: In function ‘dma_free_coherent’:
arch/mips/include/asm/dma-mapping.h:31:21: warning: passing argument 1 of ‘phys_to_virt’ makes integer from pointer without a cast [-Wint-conversion]

    free(phys_to_virt(vaddr));
                      ^~~~~
In file included from include/common.h:33:0,
                  from drivers/net/e1000/main.c:32:
arch/mips/include/asm/io.h:40:21: note: expected ‘long unsigned int’ but argument is of type ‘void *’
  static inline void *phys_to_virt(unsigned long address)
                      ^~~~~~~~~~~~
---
  arch/mips/include/asm/dma-mapping.h |  2 +-
  arch/mips/lib/dma-default.c         | 22 ++++++++++++++++++++--
  2 files changed, 21 insertions(+), 3 deletions(-)
arch/mips/include/asm/dma-mapping.h +1 -1
index c71a087038..5013e7b369 100644
@@ -28,7 +28,7 @@ static inline void dma_free_coherent(void *vaddr, dma_addr_t dma_handle,
  				     size_t size)
  {
  	if (IS_ENABLED(CONFIG_MMU))
-		free((void *)CKSEG0ADDR(vaddr));
+		free(phys_to_virt(vaddr));
  	else
  		free(vaddr);
  }
arch/mips/lib/dma-default.c +6 -2
index fbe627c24c..40caf6f91b 100644
@@ -8,9 +8,11 @@
 
  #if defined(CONFIG_CPU_MIPS32) || \
  	defined(CONFIG_CPU_MIPS64)
-static inline void __dma_sync_mips(unsigned long addr, size_t size,
+static inline void __dma_sync_mips(dma_addr_t _addr, size_t size,
  				   enum dma_data_direction direction)
  {
+	void *addr = phys_to_virt(_addr);
+
  	switch (direction) {
  	case DMA_TO_DEVICE:
  		dma_flush_range(addr, addr + size);
@@ -29,7 +31,7 @@ static inline void __dma_sync_mips(unsigned long addr, size_t size,
  	}
  }
  #else
-static inline void __dma_sync_mips(void *addr, size_t size,
+static inline void __dma_sync_mips(dma_addr_t addr, size_t size,
  	enum dma_data_direction direction)
  {
  }
@@ -46,3 +48,19 @@ void dma_sync_single_for_device(dma_addr_t address, size_t size,
  {
  	__dma_sync_mips(address, size, dir);
  }
+
+dma_addr_t dma_map_single(struct device_d *dev, void *ptr, size_t size,
Quoted 8 lines

arch/mips/lib/dma-default.c void dma_sync_single_for_device(dma_addr_t address, size_t size, · line 57

Quoted 5 lines
arch/mips/lib/dma-default.c +5 -0
+			  enum dma_data_direction dir)
+{
+	unsigned long addr = virt_to_phys(ptr);
+
+	dma_sync_single_for_device(addr, size, dir);

Hm.. i was thinking Hit Invalidate D instruction works with Virtual addresses. Are you sure we need to use virt_to_phys() here?

dma_sync_single_for_device() is a barebox-wide function (see include/dma.h). The dma_sync_single_for_device() 1st argument type is dma_addr_t (physical address). So virt_to_phys() conversion is necessary here.

Quoted 19 lines

arch/mips/lib/dma-default.c void dma_sync_single_for_device(dma_addr_t address, size_t size, · line 66

Quoted 10 lines
arch/mips/lib/dma-default.c +9 -0
+
+	return addr;
+}
+
+void dma_unmap_single(struct device_d *dev, dma_addr_t addr, size_t size,
+		      enum dma_data_direction dir)
+{
+	dma_sync_single_for_cpu(addr, size, dir);
+}

Kind regards,
Oleksij Rempel

Signature · 4 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 |
Signature · 7 lines
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#6 lore raw

RFC 3/5 net: e1000: make it work on MIPS

In reply to Antony Pavlov
---
 drivers/net/e1000/e1000.h | 2 ++
 drivers/net/e1000/main.c  | 8 ++++----
 2 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/e1000/e1000.h +2 -0
index 52ad3d4cdb..d26e6dcc02 100644
@@ -2180,7 +2180,9 @@ struct e1000_hw {
 	struct mii_bus miibus;
 
 	struct e1000_tx_desc *tx_base;
+	dma_addr_t tx_base_phys;
 	struct e1000_rx_desc *rx_base;
+	dma_addr_t rx_base_phys;
 	unsigned char *packet;
 	dma_addr_t packet_dma;
 
drivers/net/e1000/main.c +4 -4
index f67c5d867b..69b1516640 100644
@@ -3232,7 +3232,7 @@ 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;
+	const unsigned long tx_base = (unsigned long)hw->tx_base_phys;
 
 	e1000_write_reg(hw, E1000_TDBAL, lower_32_bits(tx_base));
 	e1000_write_reg(hw, E1000_TDBAH, upper_32_bits(tx_base));
@@ -3351,7 +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;
+	const unsigned long rx_base = (unsigned long)hw->rx_base_phys;
 
 	hw->rx_tail = 0;
 	/* make sure receives are disabled while setting up the descriptors */
@@ -3564,8 +3564,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	hw = xzalloc(sizeof(*hw));
 
-	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->tx_base = dma_alloc_coherent(16 * sizeof(*hw->tx_base), &hw->tx_base_phys);
+	hw->rx_base = dma_alloc_coherent(16 * sizeof(*hw->rx_base), &hw->rx_base_phys);
 
 	edev = &hw->edev;
 
Signature · 7 lines
2.24.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Reviewed-by on v1 3/5
#7 lore raw

Re: [RFC 3/5] net: e1000: make it work on MIPS

Hm... how was it working before? We was just lucky to have physical address equal to virtual. I would say, it is not really MIPS only fix.

Quoted 44 lines · Antony Pavlov
---
  drivers/net/e1000/e1000.h | 2 ++
  drivers/net/e1000/main.c  | 8 ++++----
  2 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/e1000/e1000.h +2 -0
index 52ad3d4cdb..d26e6dcc02 100644
@@ -2180,7 +2180,9 @@ struct e1000_hw {
  	struct mii_bus miibus;
 
  	struct e1000_tx_desc *tx_base;
+	dma_addr_t tx_base_phys;
  	struct e1000_rx_desc *rx_base;
+	dma_addr_t rx_base_phys;
  	unsigned char *packet;
  	dma_addr_t packet_dma;
 
drivers/net/e1000/main.c +2 -2
index f67c5d867b..69b1516640 100644
@@ -3232,7 +3232,7 @@ 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;
+	const unsigned long tx_base = (unsigned long)hw->tx_base_phys;
 
  	e1000_write_reg(hw, E1000_TDBAL, lower_32_bits(tx_base));
  	e1000_write_reg(hw, E1000_TDBAH, upper_32_bits(tx_base));
@@ -3351,7 +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;
+	const unsigned long rx_base = (unsigned long)hw->rx_base_phys;
 
  	hw->rx_tail = 0;
  	/* make sure receives are disabled while setting up the descriptors */

drivers/net/e1000/main.c static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *id) · line 3571

Quoted 10 lines
drivers/net/e1000/main.c +2 -2
@@ -3564,8 +3564,8 @@ static int e1000_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
  	hw = xzalloc(sizeof(*hw));
 
-	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->tx_base = dma_alloc_coherent(16 * sizeof(*hw->tx_base), &hw->tx_base_phys);
+	hw->rx_base = dma_alloc_coherent(16 * sizeof(*hw->rx_base), &hw->rx_base_phys);
 
  	edev = &hw->edev;
 

Kind regards,
Oleksij Rempel

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
#8 lore raw

Re: [RFC 3/5] net: e1000: make it work on MIPS

Am Montag, den 13.01.2020, 08:29 +0100 schrieb Oleksij Rempel:

Quoted 2 lines

Hm... how was it working before? We was just lucky to have physical address equal to virtual. I would say, it is not really MIPS only fix.

Yes, drivers using DMA_ADDRESS_BROKEN don't work on any architecture/SoC that doesn't have a 1:1 CPU to DMA address mapping. The name of that define might give a slight hint to that fact. ;)

Regards,
Lucas

Quoted 62 lines
Quoted 59 lines · Antony Pavlov
---
  drivers/net/e1000/e1000.h | 2 ++
  drivers/net/e1000/main.c  | 8 ++++----
  2 files changed, 6 insertions(+), 4 deletions(-)
drivers/net/e1000/e1000.h +2 -0
index 52ad3d4cdb..d26e6dcc02 100644
@@ -2180,7 +2180,9 @@ struct e1000_hw {
  	struct mii_bus miibus;
 
  	struct e1000_tx_desc *tx_base;
+	dma_addr_t tx_base_phys;
  	struct e1000_rx_desc *rx_base;
+	dma_addr_t rx_base_phys;
  	unsigned char *packet;
  	dma_addr_t packet_dma;
 
drivers/net/e1000/main.c +1 -1
index f67c5d867b..69b1516640 100644
@@ -3232,7 +3232,7 @@ 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;
+	const unsigned long tx_base = (unsigned long)hw->tx_base_phys;
 
  	e1000_write_reg(hw, E1000_TDBAL, lower_32_bits(tx_base));
  	e1000_write_reg(hw, E1000_TDBAH, upper_32_bits(tx_base));
drivers/net/e1000/main.c +1 -1
@@ -3351,7 +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;
+	const unsigned long rx_base = (unsigned long)hw->rx_base_phys;
 
  	hw->rx_tail = 0;

/* make sure receives are disabled while setting up the
descriptors */

drivers/net/e1000/main.c +1 -2
@@ -3564,8 +3564,8 @@ static int e1000_probe(struct pci_dev *pdev,
 const struct pci_device_id *id)
 
  	hw = xzalloc(sizeof(*hw));
 
-	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->tx_base = dma_alloc_coherent(16 * sizeof(*hw->tx_base),

&hw->tx_base_phys);

drivers/net/e1000/main.c +1 -0
+	hw->rx_base = dma_alloc_coherent(16 * sizeof(*hw->rx_base),

&hw->rx_base_phys);

Quoted 7 lines
Quoted 3 lines
  	edev = &hw->edev;

Kind regards,
Oleksij Rempel

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#9 lore raw

RFC 4/5 net: rtl8169: make it work on big-endian system

In reply to Antony Pavlov
---
 drivers/net/rtl8169.c | 34 +++++++++++++++++-----------------
 1 file changed, 17 insertions(+), 17 deletions(-)
drivers/net/rtl8169.c +17 -17
index 80997dc89f..3762cb6354 100644
@@ -230,13 +230,13 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv)
 	for (i = 0; i < NUM_RX_DESC; i++) {
 		if (i == (NUM_RX_DESC - 1))
 			priv->rx_desc[i].status =
-				BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE;
+				cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE);
 		else
 			priv->rx_desc[i].status =
-				BD_STAT_OWN | PKT_BUF_SIZE;
+				cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
 
 		priv->rx_desc[i].buf_addr =
-				virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE);
+				cpu_to_le32(virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE));
 	}
 }
 
@@ -358,21 +358,21 @@ static int rtl8169_eth_send(struct eth_device *edev, void *packet,
 
 	priv->tx_desc[entry].buf_Haddr = 0;
 	priv->tx_desc[entry].buf_addr =
-		virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE);
+		cpu_to_le32(virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE));
 
 	if (entry != (NUM_TX_DESC - 1)) {
 		priv->tx_desc[entry].status =
-			BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
-			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+			cpu_to_le32(BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
+			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
 	} else {
 		priv->tx_desc[entry].status =
-			BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
-			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+			cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
+			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
 	}
 
 	RTL_W8(priv, TxPoll, 0x40);
 
-	while (priv->tx_desc[entry].status & BD_STAT_OWN)
+	while (le32_to_cpu(priv->tx_desc[entry].status) & BD_STAT_OWN)
 		;
 
 	dma_sync_single_for_cpu((unsigned long)priv->tx_buf + entry *
@@ -391,9 +391,9 @@ static int rtl8169_eth_rx(struct eth_device *edev)
 
 	entry = priv->cur_rx % NUM_RX_DESC;
 
-	if ((priv->rx_desc[entry].status & BD_STAT_OWN) == 0) {
-		if (!(priv->rx_desc[entry].status & BD_STAT_RX_RES)) {
-			pkt_size = (priv->rx_desc[entry].status & 0x1fff) - 4;
+	if ((le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_OWN) == 0) {
+		if (!(le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_RX_RES)) {
+			pkt_size = (le32_to_cpu(priv->rx_desc[entry].status) & 0x1fff) - 4;
 
 			dma_sync_single_for_cpu((unsigned long)priv->rx_buf
 						+ entry * PKT_BUF_SIZE,
@@ -407,14 +407,14 @@ static int rtl8169_eth_rx(struct eth_device *edev)
 						   pkt_size, DMA_FROM_DEVICE);
 
 			if (entry == NUM_RX_DESC - 1)
-				priv->rx_desc[entry].status = BD_STAT_OWN |
-					BD_STAT_EOR | PKT_BUF_SIZE;
+				priv->rx_desc[entry].status = cpu_to_le32(BD_STAT_OWN |
+					BD_STAT_EOR | PKT_BUF_SIZE);
 			else
 				priv->rx_desc[entry].status =
-					BD_STAT_OWN | PKT_BUF_SIZE;
+					cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
 			priv->rx_desc[entry].buf_addr =
-				virt_to_phys(priv->rx_buf +
-				             entry * PKT_BUF_SIZE);
+				cpu_to_le32(virt_to_phys(priv->rx_buf +
+				             entry * PKT_BUF_SIZE));
 		} else {
 			dev_err(&edev->dev, "rx error\n");
 		}
Signature · 7 lines
2.24.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Reviewed-by on v1 4/5
#10 lore raw

Re: [RFC 4/5] net: rtl8169: make it work on big-endian system

This porch is changing only endianes conversation for some HW registers and DMA desrciptors. Looks fine for me:

Quoted 78 lines · Antony Pavlov
---
  drivers/net/rtl8169.c | 34 +++++++++++++++++-----------------
  1 file changed, 17 insertions(+), 17 deletions(-)
drivers/net/rtl8169.c +14 -14
index 80997dc89f..3762cb6354 100644
@@ -230,13 +230,13 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv)
  	for (i = 0; i < NUM_RX_DESC; i++) {
  		if (i == (NUM_RX_DESC - 1))
  			priv->rx_desc[i].status =
-				BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE;
+				cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE);
  		else
  			priv->rx_desc[i].status =
-				BD_STAT_OWN | PKT_BUF_SIZE;
+				cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
 
  		priv->rx_desc[i].buf_addr =
-				virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE);
+				cpu_to_le32(virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE));
  	}
  }
 
@@ -358,21 +358,21 @@ static int rtl8169_eth_send(struct eth_device *edev, void *packet,
 
  	priv->tx_desc[entry].buf_Haddr = 0;
  	priv->tx_desc[entry].buf_addr =
-		virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE);
+		cpu_to_le32(virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE));
 
  	if (entry != (NUM_TX_DESC - 1)) {
  		priv->tx_desc[entry].status =
-			BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
-			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+			cpu_to_le32(BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
+			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
  	} else {
  		priv->tx_desc[entry].status =
-			BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
-			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+			cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
+			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
  	}
 
  	RTL_W8(priv, TxPoll, 0x40);
 
-	while (priv->tx_desc[entry].status & BD_STAT_OWN)
+	while (le32_to_cpu(priv->tx_desc[entry].status) & BD_STAT_OWN)
  		;
 
  	dma_sync_single_for_cpu((unsigned long)priv->tx_buf + entry *
@@ -391,9 +391,9 @@ static int rtl8169_eth_rx(struct eth_device *edev)
 
  	entry = priv->cur_rx % NUM_RX_DESC;
 
-	if ((priv->rx_desc[entry].status & BD_STAT_OWN) == 0) {
-		if (!(priv->rx_desc[entry].status & BD_STAT_RX_RES)) {
-			pkt_size = (priv->rx_desc[entry].status & 0x1fff) - 4;
+	if ((le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_OWN) == 0) {
+		if (!(le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_RX_RES)) {
+			pkt_size = (le32_to_cpu(priv->rx_desc[entry].status) & 0x1fff) - 4;
 
  			dma_sync_single_for_cpu((unsigned long)priv->rx_buf
  						+ entry * PKT_BUF_SIZE,
@@ -407,14 +407,14 @@ static int rtl8169_eth_rx(struct eth_device *edev)
  						   pkt_size, DMA_FROM_DEVICE);
 
  			if (entry == NUM_RX_DESC - 1)
-				priv->rx_desc[entry].status = BD_STAT_OWN |
-					BD_STAT_EOR | PKT_BUF_SIZE;
+				priv->rx_desc[entry].status = cpu_to_le32(BD_STAT_OWN |
+					BD_STAT_EOR | PKT_BUF_SIZE);
  			else
  				priv->rx_desc[entry].status =

drivers/net/rtl8169.c static int rtl8169_eth_rx(struct eth_device *edev) · line 420

Quoted 10 lines
drivers/net/rtl8169.c +3 -3
-					BD_STAT_OWN | PKT_BUF_SIZE;
+					cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
  			priv->rx_desc[entry].buf_addr =
-				virt_to_phys(priv->rx_buf +
-				             entry * PKT_BUF_SIZE);
+				cpu_to_le32(virt_to_phys(priv->rx_buf +
+				             entry * PKT_BUF_SIZE));
  		} else {
  			dev_err(&edev->dev, "rx error\n");
  		}

Kind regards,
Oleksij Rempel

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
#11 lore raw

Re: [RFC 4/5] net: rtl8169: make it work on big-endian system

In reply to Antony Pavlov

Hi Antony,

do you wont to resent this patches as not RFC?

Quoted 78 lines · Antony Pavlov
---
  drivers/net/rtl8169.c | 34 +++++++++++++++++-----------------
  1 file changed, 17 insertions(+), 17 deletions(-)
drivers/net/rtl8169.c +14 -14
index 80997dc89f..3762cb6354 100644
@@ -230,13 +230,13 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv)
  	for (i = 0; i < NUM_RX_DESC; i++) {
  		if (i == (NUM_RX_DESC - 1))
  			priv->rx_desc[i].status =
-				BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE;
+				cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE);
  		else
  			priv->rx_desc[i].status =
-				BD_STAT_OWN | PKT_BUF_SIZE;
+				cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
 
  		priv->rx_desc[i].buf_addr =
-				virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE);
+				cpu_to_le32(virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE));
  	}
  }
 
@@ -358,21 +358,21 @@ static int rtl8169_eth_send(struct eth_device *edev, void *packet,
 
  	priv->tx_desc[entry].buf_Haddr = 0;
  	priv->tx_desc[entry].buf_addr =
-		virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE);
+		cpu_to_le32(virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE));
 
  	if (entry != (NUM_TX_DESC - 1)) {
  		priv->tx_desc[entry].status =
-			BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
-			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+			cpu_to_le32(BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
+			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
  	} else {
  		priv->tx_desc[entry].status =
-			BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
-			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+			cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
+			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
  	}
 
  	RTL_W8(priv, TxPoll, 0x40);
 
-	while (priv->tx_desc[entry].status & BD_STAT_OWN)
+	while (le32_to_cpu(priv->tx_desc[entry].status) & BD_STAT_OWN)
  		;
 
  	dma_sync_single_for_cpu((unsigned long)priv->tx_buf + entry *
@@ -391,9 +391,9 @@ static int rtl8169_eth_rx(struct eth_device *edev)
 
  	entry = priv->cur_rx % NUM_RX_DESC;
 
-	if ((priv->rx_desc[entry].status & BD_STAT_OWN) == 0) {
-		if (!(priv->rx_desc[entry].status & BD_STAT_RX_RES)) {
-			pkt_size = (priv->rx_desc[entry].status & 0x1fff) - 4;
+	if ((le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_OWN) == 0) {
+		if (!(le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_RX_RES)) {
+			pkt_size = (le32_to_cpu(priv->rx_desc[entry].status) & 0x1fff) - 4;
 
  			dma_sync_single_for_cpu((unsigned long)priv->rx_buf
  						+ entry * PKT_BUF_SIZE,
@@ -407,14 +407,14 @@ static int rtl8169_eth_rx(struct eth_device *edev)
  						   pkt_size, DMA_FROM_DEVICE);
 
  			if (entry == NUM_RX_DESC - 1)
-				priv->rx_desc[entry].status = BD_STAT_OWN |
-					BD_STAT_EOR | PKT_BUF_SIZE;
+				priv->rx_desc[entry].status = cpu_to_le32(BD_STAT_OWN |
+					BD_STAT_EOR | PKT_BUF_SIZE);
  			else
  				priv->rx_desc[entry].status =

drivers/net/rtl8169.c static int rtl8169_eth_rx(struct eth_device *edev) · line 420

Quoted 10 lines
drivers/net/rtl8169.c +3 -3
-					BD_STAT_OWN | PKT_BUF_SIZE;
+					cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
  			priv->rx_desc[entry].buf_addr =
-				virt_to_phys(priv->rx_buf +
-				             entry * PKT_BUF_SIZE);
+				cpu_to_le32(virt_to_phys(priv->rx_buf +
+				             entry * PKT_BUF_SIZE));
  		} else {
  			dev_err(&edev->dev, "rx error\n");
  		}

Kind regards,
Oleksij Rempel

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
#12 lore raw

Re: [RFC 4/5] net: rtl8169: make it work on big-endian system

Quoted 3 lines · On Tue, 4 Feb 2020 15:03:53 +0100 Oleksij Rempel <[email protected]>…

Hi Antony,

do you wont to resent this patches as not RFC?

Hi!

I want to test PCI-related patches on ARM before resending (especially 'net: e1000: make it work on MIPS').

Is there any qemu configuration to test ARM barebox with PCI support?

Signature · 2 lines
Best regards,
  Antony Pavlov
Quoted 85 lines · Antony Pavlov
Quoted 83 lines
---
  drivers/net/rtl8169.c | 34 +++++++++++++++++-----------------
  1 file changed, 17 insertions(+), 17 deletions(-)
drivers/net/rtl8169.c +16 -17
index 80997dc89f..3762cb6354 100644
@@ -230,13 +230,13 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv)
  	for (i = 0; i < NUM_RX_DESC; i++) {
  		if (i == (NUM_RX_DESC - 1))
  			priv->rx_desc[i].status =
-				BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE;
+				cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE);
  		else
  			priv->rx_desc[i].status =
-				BD_STAT_OWN | PKT_BUF_SIZE;
+				cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
 
  		priv->rx_desc[i].buf_addr =
-				virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE);
+				cpu_to_le32(virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE));
  	}
  }
 
@@ -358,21 +358,21 @@ static int rtl8169_eth_send(struct eth_device *edev, void *packet,
 
  	priv->tx_desc[entry].buf_Haddr = 0;
  	priv->tx_desc[entry].buf_addr =
-		virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE);
+		cpu_to_le32(virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE));
 
  	if (entry != (NUM_TX_DESC - 1)) {
  		priv->tx_desc[entry].status =
-			BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
-			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+			cpu_to_le32(BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
+			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
  	} else {
  		priv->tx_desc[entry].status =
-			BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
-			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+			cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
+			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
  	}
 
  	RTL_W8(priv, TxPoll, 0x40);
 
-	while (priv->tx_desc[entry].status & BD_STAT_OWN)
+	while (le32_to_cpu(priv->tx_desc[entry].status) & BD_STAT_OWN)
  		;
 
  	dma_sync_single_for_cpu((unsigned long)priv->tx_buf + entry *
@@ -391,9 +391,9 @@ static int rtl8169_eth_rx(struct eth_device *edev)
 
  	entry = priv->cur_rx % NUM_RX_DESC;
 
-	if ((priv->rx_desc[entry].status & BD_STAT_OWN) == 0) {
-		if (!(priv->rx_desc[entry].status & BD_STAT_RX_RES)) {
-			pkt_size = (priv->rx_desc[entry].status & 0x1fff) - 4;
+	if ((le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_OWN) == 0) {
+		if (!(le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_RX_RES)) {
+			pkt_size = (le32_to_cpu(priv->rx_desc[entry].status) & 0x1fff) - 4;
 
  			dma_sync_single_for_cpu((unsigned long)priv->rx_buf
  						+ entry * PKT_BUF_SIZE,
@@ -407,14 +407,14 @@ static int rtl8169_eth_rx(struct eth_device *edev)
  						   pkt_size, DMA_FROM_DEVICE);
 
  			if (entry == NUM_RX_DESC - 1)
-				priv->rx_desc[entry].status = BD_STAT_OWN |
-					BD_STAT_EOR | PKT_BUF_SIZE;
+				priv->rx_desc[entry].status = cpu_to_le32(BD_STAT_OWN |
+					BD_STAT_EOR | PKT_BUF_SIZE);
  			else
  				priv->rx_desc[entry].status =
-					BD_STAT_OWN | PKT_BUF_SIZE;
+					cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
  			priv->rx_desc[entry].buf_addr =
-				virt_to_phys(priv->rx_buf +
-				             entry * PKT_BUF_SIZE);
+				cpu_to_le32(virt_to_phys(priv->rx_buf +
Quoted 14 lines

drivers/net/rtl8169.c static int rtl8169_eth_rx(struct eth_device *edev) · line 420

Quoted 5 lines
drivers/net/rtl8169.c +1 -0
+				             entry * PKT_BUF_SIZE));
  		} else {
  			dev_err(&edev->dev, "rx error\n");
  		}

Kind regards,
Oleksij Rempel

Signature · 4 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

#13 lore raw

Re: [RFC 4/5] net: rtl8169: make it work on big-endian system

Hi,

Quoted 5 lines · Antony Pavlov
Quoted 2 lines · On Tue, 4 Feb 2020 15:03:53 +0100 Oleksij Rempel <[email protected]>…

Hi Antony,

Quoted 8 lines
Quoted 1 line

do you wont to resent this patches as not RFC?

Hi!

I want to test PCI-related patches on ARM before resending (especially 'net: e1000: make it work on MIPS').

Is there any qemu configuration to test ARM barebox with PCI support?

yes. vexpress.
Here is a script to run vexpress on qemu build in distrokit:
https://git.pengutronix.de/cgit/DistroKit/tree/configs/platform-v7a/run

Quoted 106 lines
Signature · 2 lines
Best regards,
  Antony Pavlov
Quoted 99 lines · Antony Pavlov
Quoted 78 lines
---
  drivers/net/rtl8169.c | 34 +++++++++++++++++-----------------
  1 file changed, 17 insertions(+), 17 deletions(-)
drivers/net/rtl8169.c +14 -14
index 80997dc89f..3762cb6354 100644
@@ -230,13 +230,13 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv)
  	for (i = 0; i < NUM_RX_DESC; i++) {
  		if (i == (NUM_RX_DESC - 1))
  			priv->rx_desc[i].status =
-				BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE;
+				cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE);
  		else
  			priv->rx_desc[i].status =
-				BD_STAT_OWN | PKT_BUF_SIZE;
+				cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
 
  		priv->rx_desc[i].buf_addr =
-				virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE);
+				cpu_to_le32(virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE));
  	}
  }
 
@@ -358,21 +358,21 @@ static int rtl8169_eth_send(struct eth_device *edev, void *packet,
 
  	priv->tx_desc[entry].buf_Haddr = 0;
  	priv->tx_desc[entry].buf_addr =
-		virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE);
+		cpu_to_le32(virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE));
 
  	if (entry != (NUM_TX_DESC - 1)) {
  		priv->tx_desc[entry].status =
-			BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
-			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+			cpu_to_le32(BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
+			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
  	} else {
  		priv->tx_desc[entry].status =
-			BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
-			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+			cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
+			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
  	}
 
  	RTL_W8(priv, TxPoll, 0x40);
 
-	while (priv->tx_desc[entry].status & BD_STAT_OWN)
+	while (le32_to_cpu(priv->tx_desc[entry].status) & BD_STAT_OWN)
  		;
 
  	dma_sync_single_for_cpu((unsigned long)priv->tx_buf + entry *
@@ -391,9 +391,9 @@ static int rtl8169_eth_rx(struct eth_device *edev)
 
  	entry = priv->cur_rx % NUM_RX_DESC;
 
-	if ((priv->rx_desc[entry].status & BD_STAT_OWN) == 0) {
-		if (!(priv->rx_desc[entry].status & BD_STAT_RX_RES)) {
-			pkt_size = (priv->rx_desc[entry].status & 0x1fff) - 4;
+	if ((le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_OWN) == 0) {
+		if (!(le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_RX_RES)) {
+			pkt_size = (le32_to_cpu(priv->rx_desc[entry].status) & 0x1fff) - 4;
 
  			dma_sync_single_for_cpu((unsigned long)priv->rx_buf
  						+ entry * PKT_BUF_SIZE,
@@ -407,14 +407,14 @@ static int rtl8169_eth_rx(struct eth_device *edev)
  						   pkt_size, DMA_FROM_DEVICE);
 
  			if (entry == NUM_RX_DESC - 1)
-				priv->rx_desc[entry].status = BD_STAT_OWN |
-					BD_STAT_EOR | PKT_BUF_SIZE;
+				priv->rx_desc[entry].status = cpu_to_le32(BD_STAT_OWN |
+					BD_STAT_EOR | PKT_BUF_SIZE);
  			else
  				priv->rx_desc[entry].status =

drivers/net/rtl8169.c static int rtl8169_eth_rx(struct eth_device *edev) · line 420

Quoted 10 lines
drivers/net/rtl8169.c +3 -3
-					BD_STAT_OWN | PKT_BUF_SIZE;
+					cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
  			priv->rx_desc[entry].buf_addr =
-				virt_to_phys(priv->rx_buf +
-				             entry * PKT_BUF_SIZE);
+				cpu_to_le32(virt_to_phys(priv->rx_buf +
+				             entry * PKT_BUF_SIZE));
  		} else {
  			dev_err(&edev->dev, "rx error\n");
  		}

Kind regards,
Oleksij Rempel

Signature · 4 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 |
Signature · 9 lines
Pengutronix e.K.                           |                             |
Steuerwalder Str. 21                       | http://www.pengutronix.de/  |
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
#14 lore raw

Re: [RFC 4/5] net: rtl8169: make it work on big-endian system

In reply to Oleksij Rempel
Quoted 3 lines · On Tue, 4 Feb 2020 15:03:53 +0100 Oleksij Rempel <[email protected]>…

Hi Antony,

do you wont to resent this patches as not RFC?

It looks like some additional testing is necessary.

There is an alignment issue on MIPS.
We can't just pass cache line size unaligned address to dma_sync_single_for_device(). Some workaround is necessary, e.g.

drivers/net/rtl8169.c +2 -2
@@ -220,10 +220,10 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv)
 
        priv->tx_desc = dma_alloc_coherent(NUM_TX_DESC *
                                sizeof(struct bufdesc), &priv->tx_desc_phys);
-       priv->tx_buf = malloc(NUM_TX_DESC * PKT_BUF_SIZE);
+       priv->tx_buf = dma_alloc_coherent(NUM_TX_DESC * PKT_BUF_SIZE, DMA_ADDRESS_BROKEN);
        priv->rx_desc = dma_alloc_coherent(NUM_RX_DESC *
                                sizeof(struct bufdesc), &priv->rx_desc_phys);
-       priv->rx_buf = malloc(NUM_RX_DESC * PKT_BUF_SIZE);
+       priv->rx_buf = dma_alloc_coherent(NUM_RX_DESC * PKT_BUF_SIZE, DMA_ADDRESS_BROKEN);
        dma_sync_single_for_device((unsigned long)priv->rx_buf,
                                   NUM_RX_DESC * PKT_BUF_SIZE, DMA_FROM_DEVICE);
 
Quoted 99 lines · Antony Pavlov
Quoted 78 lines
---
  drivers/net/rtl8169.c | 34 +++++++++++++++++-----------------
  1 file changed, 17 insertions(+), 17 deletions(-)
drivers/net/rtl8169.c +14 -14
index 80997dc89f..3762cb6354 100644
@@ -230,13 +230,13 @@ static void rtl8169_init_ring(struct rtl8169_priv *priv)
  	for (i = 0; i < NUM_RX_DESC; i++) {
  		if (i == (NUM_RX_DESC - 1))
  			priv->rx_desc[i].status =
-				BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE;
+				cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | PKT_BUF_SIZE);
  		else
  			priv->rx_desc[i].status =
-				BD_STAT_OWN | PKT_BUF_SIZE;
+				cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
 
  		priv->rx_desc[i].buf_addr =
-				virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE);
+				cpu_to_le32(virt_to_phys(priv->rx_buf + i * PKT_BUF_SIZE));
  	}
  }
 
@@ -358,21 +358,21 @@ static int rtl8169_eth_send(struct eth_device *edev, void *packet,
 
  	priv->tx_desc[entry].buf_Haddr = 0;
  	priv->tx_desc[entry].buf_addr =
-		virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE);
+		cpu_to_le32(virt_to_phys(priv->tx_buf + entry * PKT_BUF_SIZE));
 
  	if (entry != (NUM_TX_DESC - 1)) {
  		priv->tx_desc[entry].status =
-			BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
-			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+			cpu_to_le32(BD_STAT_OWN | BD_STAT_FS | BD_STAT_LS |
+			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
  	} else {
  		priv->tx_desc[entry].status =
-			BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
-			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN);
+			cpu_to_le32(BD_STAT_OWN | BD_STAT_EOR | BD_STAT_FS | BD_STAT_LS |
+			((packet_length > ETH_ZLEN) ? packet_length : ETH_ZLEN));
  	}
 
  	RTL_W8(priv, TxPoll, 0x40);
 
-	while (priv->tx_desc[entry].status & BD_STAT_OWN)
+	while (le32_to_cpu(priv->tx_desc[entry].status) & BD_STAT_OWN)
  		;
 
  	dma_sync_single_for_cpu((unsigned long)priv->tx_buf + entry *
@@ -391,9 +391,9 @@ static int rtl8169_eth_rx(struct eth_device *edev)
 
  	entry = priv->cur_rx % NUM_RX_DESC;
 
-	if ((priv->rx_desc[entry].status & BD_STAT_OWN) == 0) {
-		if (!(priv->rx_desc[entry].status & BD_STAT_RX_RES)) {
-			pkt_size = (priv->rx_desc[entry].status & 0x1fff) - 4;
+	if ((le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_OWN) == 0) {
+		if (!(le32_to_cpu(priv->rx_desc[entry].status) & BD_STAT_RX_RES)) {
+			pkt_size = (le32_to_cpu(priv->rx_desc[entry].status) & 0x1fff) - 4;
 
  			dma_sync_single_for_cpu((unsigned long)priv->rx_buf
  						+ entry * PKT_BUF_SIZE,
@@ -407,14 +407,14 @@ static int rtl8169_eth_rx(struct eth_device *edev)
  						   pkt_size, DMA_FROM_DEVICE);
 
  			if (entry == NUM_RX_DESC - 1)
-				priv->rx_desc[entry].status = BD_STAT_OWN |
-					BD_STAT_EOR | PKT_BUF_SIZE;
+				priv->rx_desc[entry].status = cpu_to_le32(BD_STAT_OWN |
+					BD_STAT_EOR | PKT_BUF_SIZE);
  			else
  				priv->rx_desc[entry].status =

drivers/net/rtl8169.c static int rtl8169_eth_rx(struct eth_device *edev) · line 420

Quoted 10 lines
drivers/net/rtl8169.c +3 -3
-					BD_STAT_OWN | PKT_BUF_SIZE;
+					cpu_to_le32(BD_STAT_OWN | PKT_BUF_SIZE);
  			priv->rx_desc[entry].buf_addr =
-				virt_to_phys(priv->rx_buf +
-				             entry * PKT_BUF_SIZE);
+				cpu_to_le32(virt_to_phys(priv->rx_buf +
+				             entry * PKT_BUF_SIZE));
  		} else {
  			dev_err(&edev->dev, "rx error\n");
  		}

Kind regards,
Oleksij Rempel

Signature · 4 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 |
Signature · 7 lines
Best regards,
  Antony Pavlov

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#15 lore raw

RFC 5/5 MIPS: qemu-malta_defconfig: enable e1000 network driver

In reply to Antony Pavlov
---
 arch/mips/configs/qemu-malta_defconfig | 1 +
 1 file changed, 1 insertion(+)
arch/mips/configs/qemu-malta_defconfig +1 -0
index 2465c0260d..1625d68874 100644
@@ -59,6 +59,7 @@ CONFIG_NET_NFS=y
 CONFIG_NET_NETCONSOLE=y
 CONFIG_OFDEVICE=y
 CONFIG_OF_BAREBOX_DRIVERS=y
+CONFIG_DRIVER_NET_E1000=y
 CONFIG_DRIVER_NET_RTL8139=y
 # CONFIG_SPI is not set
 CONFIG_I2C=y
Signature · 7 lines
2.24.0


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox