* [RFC 1/5] WIP: MIPS: configure ebase according CONFIG_MMU
2020-01-09 7:28 [RFC 0/5] WIP: MIPS: implement dma mapping functions Antony Pavlov
@ 2020-01-09 7:28 ` Antony Pavlov
2020-01-13 6:48 ` Oleksij Rempel
2020-01-09 7:28 ` [RFC 2/5] WIP: MIPS: implement dma mapping functions Antony Pavlov
` (3 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Antony Pavlov @ 2020-01-09 7:28 UTC (permalink / raw)
To: barebox; +Cc: Oleksij Rempel, Peter Mamonov
From: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
arch/mips/boot/main_entry.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/arch/mips/boot/main_entry.c b/arch/mips/boot/main_entry.c
index 2c18bc81c3..41350aad18 100644
--- a/arch/mips/boot/main_entry.c
+++ b/arch/mips/boot/main_entry.c
@@ -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);
}
--
2.24.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC 1/5] WIP: MIPS: configure ebase according CONFIG_MMU
2020-01-09 7:28 ` [RFC 1/5] WIP: MIPS: configure ebase according CONFIG_MMU Antony Pavlov
@ 2020-01-13 6:48 ` Oleksij Rempel
0 siblings, 0 replies; 16+ messages in thread
From: Oleksij Rempel @ 2020-01-13 6:48 UTC (permalink / raw)
To: Antony Pavlov, barebox; +Cc: Peter Mamonov
Hi,
On 09.01.20 08:28, Antony Pavlov wrote:
> From: Peter Mamonov <pmamonov@gmail.com>
>
> Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
> arch/mips/boot/main_entry.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/arch/mips/boot/main_entry.c b/arch/mips/boot/main_entry.c
> index 2c18bc81c3..41350aad18 100644
> --- a/arch/mips/boot/main_entry.c
> +++ b/arch/mips/boot/main_entry.c
> @@ -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);
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.
> /* unset BOOT EXCEPTION VECTOR bit */
> write_c0_status(read_c0_status() & ~ST0_BEV);
> }
>
Kind regards,
Oleksij Rempel
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFC 2/5] WIP: MIPS: implement dma mapping functions
2020-01-09 7:28 [RFC 0/5] WIP: MIPS: implement dma mapping functions Antony Pavlov
2020-01-09 7:28 ` [RFC 1/5] WIP: MIPS: configure ebase according CONFIG_MMU Antony Pavlov
@ 2020-01-09 7:28 ` Antony Pavlov
2020-01-13 8:26 ` Oleksij Rempel
2020-01-09 7:28 ` [RFC 3/5] net: e1000: make it work on MIPS Antony Pavlov
` (2 subsequent siblings)
4 siblings, 1 reply; 16+ messages in thread
From: Antony Pavlov @ 2020-01-09 7:28 UTC (permalink / raw)
To: barebox; +Cc: Oleksij Rempel, Peter Mamonov
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)
^~~~~~~~~~~~
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
---
arch/mips/include/asm/dma-mapping.h | 2 +-
arch/mips/lib/dma-default.c | 22 ++++++++++++++++++++--
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
index c71a087038..5013e7b369 100644
--- a/arch/mips/include/asm/dma-mapping.h
+++ b/arch/mips/include/asm/dma-mapping.h
@@ -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);
}
diff --git a/arch/mips/lib/dma-default.c b/arch/mips/lib/dma-default.c
index fbe627c24c..40caf6f91b 100644
--- a/arch/mips/lib/dma-default.c
+++ b/arch/mips/lib/dma-default.c
@@ -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);
+}
--
2.24.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC 2/5] WIP: MIPS: implement dma mapping functions
2020-01-09 7:28 ` [RFC 2/5] WIP: MIPS: implement dma mapping functions Antony Pavlov
@ 2020-01-13 8:26 ` Oleksij Rempel
2020-01-14 21:03 ` Antony Pavlov
0 siblings, 1 reply; 16+ messages in thread
From: Oleksij Rempel @ 2020-01-13 8:26 UTC (permalink / raw)
To: Antony Pavlov, barebox; +Cc: Peter Mamonov
On 09.01.20 08:28, Antony Pavlov wrote:
> 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)
> ^~~~~~~~~~~~
>
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
> ---
> arch/mips/include/asm/dma-mapping.h | 2 +-
> arch/mips/lib/dma-default.c | 22 ++++++++++++++++++++--
> 2 files changed, 21 insertions(+), 3 deletions(-)
>
> diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
> index c71a087038..5013e7b369 100644
> --- a/arch/mips/include/asm/dma-mapping.h
> +++ b/arch/mips/include/asm/dma-mapping.h
> @@ -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);
> }
> diff --git a/arch/mips/lib/dma-default.c b/arch/mips/lib/dma-default.c
> index fbe627c24c..40caf6f91b 100644
> --- a/arch/mips/lib/dma-default.c
> +++ b/arch/mips/lib/dma-default.c
> @@ -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);
Hm.. i was thinking Hit Invalidate D instruction works with Virtual addresses. Are you
sure we need to use virt_to_phys() here?
> +
> + 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
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC 2/5] WIP: MIPS: implement dma mapping functions
2020-01-13 8:26 ` Oleksij Rempel
@ 2020-01-14 21:03 ` Antony Pavlov
0 siblings, 0 replies; 16+ messages in thread
From: Antony Pavlov @ 2020-01-14 21:03 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: barebox, Peter Mamonov
On Mon, 13 Jan 2020 09:26:36 +0100
Oleksij Rempel <o.rempel@pengutronix.de> wrote:
> On 09.01.20 08:28, Antony Pavlov wrote:
> > 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)
> > ^~~~~~~~~~~~
> >
> > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > Signed-off-by: Peter Mamonov <pmamonov@gmail.com>
> > ---
> > arch/mips/include/asm/dma-mapping.h | 2 +-
> > arch/mips/lib/dma-default.c | 22 ++++++++++++++++++++--
> > 2 files changed, 21 insertions(+), 3 deletions(-)
> >
> > diff --git a/arch/mips/include/asm/dma-mapping.h b/arch/mips/include/asm/dma-mapping.h
> > index c71a087038..5013e7b369 100644
> > --- a/arch/mips/include/asm/dma-mapping.h
> > +++ b/arch/mips/include/asm/dma-mapping.h
> > @@ -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);
> > }
> > diff --git a/arch/mips/lib/dma-default.c b/arch/mips/lib/dma-default.c
> > index fbe627c24c..40caf6f91b 100644
> > --- a/arch/mips/lib/dma-default.c
> > +++ b/arch/mips/lib/dma-default.c
> > @@ -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);
>
> 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.
> > +
> > + 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
>
> --
> 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 |
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFC 3/5] net: e1000: make it work on MIPS
2020-01-09 7:28 [RFC 0/5] WIP: MIPS: implement dma mapping functions Antony Pavlov
2020-01-09 7:28 ` [RFC 1/5] WIP: MIPS: configure ebase according CONFIG_MMU Antony Pavlov
2020-01-09 7:28 ` [RFC 2/5] WIP: MIPS: implement dma mapping functions Antony Pavlov
@ 2020-01-09 7:28 ` Antony Pavlov
2020-01-13 7:29 ` Oleksij Rempel
2020-01-09 7:28 ` [RFC 4/5] net: rtl8169: make it work on big-endian system Antony Pavlov
2020-01-09 7:28 ` [RFC 5/5] MIPS: qemu-malta_defconfig: enable e1000 network driver Antony Pavlov
4 siblings, 1 reply; 16+ messages in thread
From: Antony Pavlov @ 2020-01-09 7:28 UTC (permalink / raw)
To: barebox; +Cc: Oleksij Rempel, Peter Mamonov
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/net/e1000/e1000.h | 2 ++
drivers/net/e1000/main.c | 8 ++++----
2 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
index 52ad3d4cdb..d26e6dcc02 100644
--- a/drivers/net/e1000/e1000.h
+++ b/drivers/net/e1000/e1000.h
@@ -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;
diff --git a/drivers/net/e1000/main.c b/drivers/net/e1000/main.c
index f67c5d867b..69b1516640 100644
--- a/drivers/net/e1000/main.c
+++ b/drivers/net/e1000/main.c
@@ -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;
--
2.24.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC 3/5] net: e1000: make it work on MIPS
2020-01-09 7:28 ` [RFC 3/5] net: e1000: make it work on MIPS Antony Pavlov
@ 2020-01-13 7:29 ` Oleksij Rempel
2020-01-13 19:06 ` Lucas Stach
0 siblings, 1 reply; 16+ messages in thread
From: Oleksij Rempel @ 2020-01-13 7:29 UTC (permalink / raw)
To: Antony Pavlov, barebox; +Cc: Peter Mamonov
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.
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
On 09.01.20 08:28, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
> drivers/net/e1000/e1000.h | 2 ++
> drivers/net/e1000/main.c | 8 ++++----
> 2 files changed, 6 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
> index 52ad3d4cdb..d26e6dcc02 100644
> --- a/drivers/net/e1000/e1000.h
> +++ b/drivers/net/e1000/e1000.h
> @@ -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;
>
> diff --git a/drivers/net/e1000/main.c b/drivers/net/e1000/main.c
> index f67c5d867b..69b1516640 100644
> --- a/drivers/net/e1000/main.c
> +++ b/drivers/net/e1000/main.c
> @@ -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;
>
>
Kind regards,
Oleksij Rempel
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC 3/5] net: e1000: make it work on MIPS
2020-01-13 7:29 ` Oleksij Rempel
@ 2020-01-13 19:06 ` Lucas Stach
0 siblings, 0 replies; 16+ messages in thread
From: Lucas Stach @ 2020-01-13 19:06 UTC (permalink / raw)
To: Oleksij Rempel, Antony Pavlov, barebox; +Cc: Peter Mamonov
Am Montag, den 13.01.2020, 08:29 +0100 schrieb Oleksij Rempel:
> 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
> Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
>
> On 09.01.20 08:28, Antony Pavlov wrote:
> > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > ---
> > drivers/net/e1000/e1000.h | 2 ++
> > drivers/net/e1000/main.c | 8 ++++----
> > 2 files changed, 6 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/net/e1000/e1000.h b/drivers/net/e1000/e1000.h
> > index 52ad3d4cdb..d26e6dcc02 100644
> > --- a/drivers/net/e1000/e1000.h
> > +++ b/drivers/net/e1000/e1000.h
> > @@ -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;
> >
> > diff --git a/drivers/net/e1000/main.c b/drivers/net/e1000/main.c
> > index f67c5d867b..69b1516640 100644
> > --- a/drivers/net/e1000/main.c
> > +++ b/drivers/net/e1000/main.c
> > @@ -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;
> >
> >
>
> Kind regards,
> Oleksij Rempel
>
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFC 4/5] net: rtl8169: make it work on big-endian system
2020-01-09 7:28 [RFC 0/5] WIP: MIPS: implement dma mapping functions Antony Pavlov
` (2 preceding siblings ...)
2020-01-09 7:28 ` [RFC 3/5] net: e1000: make it work on MIPS Antony Pavlov
@ 2020-01-09 7:28 ` Antony Pavlov
2020-01-13 7:21 ` Oleksij Rempel
2020-02-04 14:03 ` Oleksij Rempel
2020-01-09 7:28 ` [RFC 5/5] MIPS: qemu-malta_defconfig: enable e1000 network driver Antony Pavlov
4 siblings, 2 replies; 16+ messages in thread
From: Antony Pavlov @ 2020-01-09 7:28 UTC (permalink / raw)
To: barebox; +Cc: Oleksij Rempel, Peter Mamonov
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
drivers/net/rtl8169.c | 34 +++++++++++++++++-----------------
1 file changed, 17 insertions(+), 17 deletions(-)
diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
index 80997dc89f..3762cb6354 100644
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -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");
}
--
2.24.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC 4/5] net: rtl8169: make it work on big-endian system
2020-01-09 7:28 ` [RFC 4/5] net: rtl8169: make it work on big-endian system Antony Pavlov
@ 2020-01-13 7:21 ` Oleksij Rempel
2020-02-04 14:03 ` Oleksij Rempel
1 sibling, 0 replies; 16+ messages in thread
From: Oleksij Rempel @ 2020-01-13 7:21 UTC (permalink / raw)
To: Antony Pavlov, barebox; +Cc: Peter Mamonov
This porch is changing only endianes conversation for some HW registers and DMA
desrciptors. Looks fine for me:
Reviewed-by: Oleksij Rempel <o.rempel@pengutronix.de>
On 09.01.20 08:28, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
> drivers/net/rtl8169.c | 34 +++++++++++++++++-----------------
> 1 file changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
> index 80997dc89f..3762cb6354 100644
> --- a/drivers/net/rtl8169.c
> +++ b/drivers/net/rtl8169.c
> @@ -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");
> }
>
Kind regards,
Oleksij Rempel
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC 4/5] net: rtl8169: make it work on big-endian system
2020-01-09 7:28 ` [RFC 4/5] net: rtl8169: make it work on big-endian system Antony Pavlov
2020-01-13 7:21 ` Oleksij Rempel
@ 2020-02-04 14:03 ` Oleksij Rempel
2020-02-09 6:30 ` Antony Pavlov
2020-02-28 5:38 ` Antony Pavlov
1 sibling, 2 replies; 16+ messages in thread
From: Oleksij Rempel @ 2020-02-04 14:03 UTC (permalink / raw)
To: Antony Pavlov, barebox; +Cc: Peter Mamonov
Hi Antony,
do you wont to resent this patches as not RFC?
On 09.01.20 08:28, Antony Pavlov wrote:
> Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> ---
> drivers/net/rtl8169.c | 34 +++++++++++++++++-----------------
> 1 file changed, 17 insertions(+), 17 deletions(-)
>
> diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
> index 80997dc89f..3762cb6354 100644
> --- a/drivers/net/rtl8169.c
> +++ b/drivers/net/rtl8169.c
> @@ -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");
> }
>
Kind regards,
Oleksij Rempel
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC 4/5] net: rtl8169: make it work on big-endian system
2020-02-04 14:03 ` Oleksij Rempel
@ 2020-02-09 6:30 ` Antony Pavlov
2020-02-09 8:17 ` Oleksij Rempel
2020-02-28 5:38 ` Antony Pavlov
1 sibling, 1 reply; 16+ messages in thread
From: Antony Pavlov @ 2020-02-09 6:30 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: barebox, Peter Mamonov
On Tue, 4 Feb 2020 15:03:53 +0100
Oleksij Rempel <o.rempel@pengutronix.de> wrote:
> 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?
--
Best regards,
Antony Pavlov
>
> On 09.01.20 08:28, Antony Pavlov wrote:
> > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > ---
> > drivers/net/rtl8169.c | 34 +++++++++++++++++-----------------
> > 1 file changed, 17 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
> > index 80997dc89f..3762cb6354 100644
> > --- a/drivers/net/rtl8169.c
> > +++ b/drivers/net/rtl8169.c
> > @@ -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");
> > }
> >
>
> Kind regards,
> Oleksij Rempel
>
> --
> 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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC 4/5] net: rtl8169: make it work on big-endian system
2020-02-09 6:30 ` Antony Pavlov
@ 2020-02-09 8:17 ` Oleksij Rempel
0 siblings, 0 replies; 16+ messages in thread
From: Oleksij Rempel @ 2020-02-09 8:17 UTC (permalink / raw)
To: Antony Pavlov; +Cc: barebox, Peter Mamonov
Hi,
On Sun, Feb 09, 2020 at 09:30:13AM +0300, Antony Pavlov wrote:
> On Tue, 4 Feb 2020 15:03:53 +0100
> Oleksij Rempel <o.rempel@pengutronix.de> wrote:
>
> > 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?
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
> --
> Best regards,
> Antony Pavlov
>
> >
> > On 09.01.20 08:28, Antony Pavlov wrote:
> > > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > > ---
> > > drivers/net/rtl8169.c | 34 +++++++++++++++++-----------------
> > > 1 file changed, 17 insertions(+), 17 deletions(-)
> > >
> > > diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
> > > index 80997dc89f..3762cb6354 100644
> > > --- a/drivers/net/rtl8169.c
> > > +++ b/drivers/net/rtl8169.c
> > > @@ -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");
> > > }
> > >
> >
> > Kind regards,
> > Oleksij Rempel
> >
> > --
> > 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 |
>
>
>
--
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
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* Re: [RFC 4/5] net: rtl8169: make it work on big-endian system
2020-02-04 14:03 ` Oleksij Rempel
2020-02-09 6:30 ` Antony Pavlov
@ 2020-02-28 5:38 ` Antony Pavlov
1 sibling, 0 replies; 16+ messages in thread
From: Antony Pavlov @ 2020-02-28 5:38 UTC (permalink / raw)
To: Oleksij Rempel; +Cc: barebox, Peter Mamonov
On Tue, 4 Feb 2020 15:03:53 +0100
Oleksij Rempel <o.rempel@pengutronix.de> wrote:
> 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.
--- a/drivers/net/rtl8169.c
+++ b/drivers/net/rtl8169.c
@@ -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);
>
> On 09.01.20 08:28, Antony Pavlov wrote:
> > Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
> > ---
> > drivers/net/rtl8169.c | 34 +++++++++++++++++-----------------
> > 1 file changed, 17 insertions(+), 17 deletions(-)
> >
> > diff --git a/drivers/net/rtl8169.c b/drivers/net/rtl8169.c
> > index 80997dc89f..3762cb6354 100644
> > --- a/drivers/net/rtl8169.c
> > +++ b/drivers/net/rtl8169.c
> > @@ -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");
> > }
> >
>
> Kind regards,
> Oleksij Rempel
>
> --
> 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 |
--
Best regards,
Antony Pavlov
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread
* [RFC 5/5] MIPS: qemu-malta_defconfig: enable e1000 network driver
2020-01-09 7:28 [RFC 0/5] WIP: MIPS: implement dma mapping functions Antony Pavlov
` (3 preceding siblings ...)
2020-01-09 7:28 ` [RFC 4/5] net: rtl8169: make it work on big-endian system Antony Pavlov
@ 2020-01-09 7:28 ` Antony Pavlov
4 siblings, 0 replies; 16+ messages in thread
From: Antony Pavlov @ 2020-01-09 7:28 UTC (permalink / raw)
To: barebox; +Cc: Oleksij Rempel, Peter Mamonov
Signed-off-by: Antony Pavlov <antonynpavlov@gmail.com>
---
arch/mips/configs/qemu-malta_defconfig | 1 +
1 file changed, 1 insertion(+)
diff --git a/arch/mips/configs/qemu-malta_defconfig b/arch/mips/configs/qemu-malta_defconfig
index 2465c0260d..1625d68874 100644
--- a/arch/mips/configs/qemu-malta_defconfig
+++ b/arch/mips/configs/qemu-malta_defconfig
@@ -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
--
2.24.0
_______________________________________________
barebox mailing list
barebox@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/barebox
^ permalink raw reply [flat|nested] 16+ messages in thread