Re: [U-Boot] [PATCH] pci: fix address range check in __pci_hose_phys_to_bus()

2015-11-18 Thread Ivan Mercier

Well done Marcel!
I didn't have much more time to investigate on it.
OK with nvidia jetson TK1 with i210 AND RTL8169.


On 18/11/2015 15:19, Bin Meng wrote:

On Wed, Nov 18, 2015 at 10:05 PM, Marcel Ziswiler
<marcel.ziswi...@toradex.com> wrote:

The address range check may overflow if the memory region is located at
the top of the 32-bit address space. This can e.g. be seen on TK1 if
using the E1000 gigabit Ethernet driver where start and size are both
0x8000 leading to the following messages:

Apalis TK1 # tftpboot $loadaddr test_file
Using e1000#0 device
TFTP from server 192.168.10.1; our IP address is 192.168.10.2
Filename 'test_file'.
Load address: 0x80408000
Loading: pci_hose_phys_to_bus: invalid physical address

This patch fixes this by changing the order of the addition vs.
subtraction in the range check just like already done in
__pci_hose_bus_to_phys().

Reported-by: Ivan Mercier <ivan.merc...@nexvision.fr>
Signed-off-by: Marcel Ziswiler <marcel.ziswi...@toradex.com>
---

  drivers/pci/pci_common.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/pci/pci_common.c b/drivers/pci/pci_common.c
index a64792f..2a14902 100644
--- a/drivers/pci/pci_common.c
+++ b/drivers/pci/pci_common.c
@@ -268,7 +268,7 @@ int __pci_hose_phys_to_bus(struct pci_controller *hose,
 bus_addr = phys_addr - res->phys_start + res->bus_start;

 if (bus_addr >= res->bus_start &&
-   bus_addr < res->bus_start + res->size) {
+   (bus_addr - res->bus_start) < res->size) {
 *ba = bus_addr;
 return 0;
 }
--

Reviewed-by: Bin Meng <bmeng...@gmail.com>



___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot


[U-Boot] Ethernet i210 (e1000 driver) on tegra K1

2015-10-30 Thread Ivan Mercier

Hi,

I'm using a ethernet controller intel i210 
(http://www.commell.com.tw/product/Surveillance/MPX-210.htm) on my 
nvidia tegra k1 jetson.


I not an expert with pci, but the only way to make it working in u-boot 
(upstream) is with the workaround below.


E1000 is very common, so finding a critical bug in this driver seems 
weird...

Do you think there is a bug in e1000.c or in tegra pci layer?


diff --git a/drivers/net/e1000.c b/drivers/net/e1000.c
index 2ba03ed..206884d 100644
--- a/drivers/net/e1000.c
+++ b/drivers/net/e1000.c
@@ -5186,7 +5186,7 @@ static int _e1000_transmit(struct e1000_hw *hw, 
void *txpacket, int length)

 txp = tx_base + tx_tail;
 tx_tail = (tx_tail + 1) % 8;

-txp->buffer_addr = cpu_to_le64(virt_to_bus(hw->pdev, nv_packet));
+txp->buffer_addr = cpu_to_le64((unsigned long) nv_packet);
 txp->lower.data = cpu_to_le32(hw->txd_cmd | length);
 txp->upper.data = 0;



thank you

--
Best regards / Bien cordialement

Ivan Mercier

___
U-Boot mailing list
U-Boot@lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot