diff mbox

[U-Boot,v2,07/10] net: pcnet: use pci_virt_to_mem to obtain buffer addresses

Message ID 1359821166-32352-8-git-send-email-juhosg@openwrt.org
State Superseded
Delegated to: Daniel Schwierzeck
Headers show

Commit Message

Gabor Juhos Feb. 2, 2013, 4:06 p.m. UTC
The pcnet driver uses the pci_phys_to_mem function
to get the memory address of the DMA buffers. This
This assumes an 1:1 mapping between the PCI and
physical memory which is not true on all platforms.

On MIPS platform U-Boot is running within a mapped
memory region, and the pci_phys_to_mem macro can't
be used to obtain the memory address of the buffers.

Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
---
Changes since v1:
 - rebased against mips/testing

Changes since RFC: ---

---
Note:

This is only tested with the qemu-malta target. The change
might break real platforms, however I have no suitable board
to test it.

-Gabor
---
 drivers/net/pcnet.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Daniel Schwierzeck Feb. 2, 2013, 7:42 p.m. UTC | #1
2013/2/2 Gabor Juhos <juhosg@openwrt.org>:
> The pcnet driver uses the pci_phys_to_mem function
> to get the memory address of the DMA buffers. This
> This assumes an 1:1 mapping between the PCI and
> physical memory which is not true on all platforms.
>
> On MIPS platform U-Boot is running within a mapped
> memory region, and the pci_phys_to_mem macro can't
> be used to obtain the memory address of the buffers.
>
> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
> Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
> ---
> Changes since v1:
>  - rebased against mips/testing
>
> Changes since RFC: ---
>
> ---
> Note:
>
> This is only tested with the qemu-malta target. The change
> might break real platforms, however I have no suitable board
> to test it.

the consumers of pcnet and NE2000 are qemu-mips, R7780MP and SHMIN.
Nobuhiro, could you comment this change?

>
> -Gabor
> ---
>  drivers/net/pcnet.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
> index c028a44..45a66fb 100644
> --- a/drivers/net/pcnet.c
> +++ b/drivers/net/pcnet.c
> @@ -146,7 +146,7 @@ static int pcnet_recv (struct eth_device *dev);
>  static void pcnet_halt (struct eth_device *dev);
>  static int pcnet_probe (struct eth_device *dev, bd_t * bis, int dev_num);
>
> -#define PCI_TO_MEM(d,a) pci_phys_to_mem((pci_dev_t)d->priv, (u_long)(a))
> +#define PCI_TO_MEM(d, a) pci_virt_to_mem((pci_dev_t)d->priv, (a))
>  #define PCI_TO_MEM_LE(d,a) (u32)(cpu_to_le32(PCI_TO_MEM(d,a)))
>
>  static struct pci_device_id supported[] = {
> --
> 1.7.10
>
Nobuhiro Iwamatsu Feb. 5, 2013, 1:29 a.m. UTC | #2
Hi, all.

>> This is only tested with the qemu-malta target. The change
>> might break real platforms, however I have no suitable board
>> to test it.
>
> the consumers of pcnet and NE2000 are qemu-mips, R7780MP and SHMIN.
> Nobuhiro, could you comment this change?

This patch appears to have nothing to do with NE2000.
I think that this is pcnet only.

Best regards,
  Nobuhiro

On Sun, Feb 3, 2013 at 4:42 AM, Daniel Schwierzeck
<daniel.schwierzeck@gmail.com> wrote:
> 2013/2/2 Gabor Juhos <juhosg@openwrt.org>:
>> The pcnet driver uses the pci_phys_to_mem function
>> to get the memory address of the DMA buffers. This
>> This assumes an 1:1 mapping between the PCI and
>> physical memory which is not true on all platforms.
>>
>> On MIPS platform U-Boot is running within a mapped
>> memory region, and the pci_phys_to_mem macro can't
>> be used to obtain the memory address of the buffers.
>>
>> Signed-off-by: Gabor Juhos <juhosg@openwrt.org>
>> Cc: Daniel Schwierzeck <daniel.schwierzeck@googlemail.com>
>> ---
>> Changes since v1:
>>  - rebased against mips/testing
>>
>> Changes since RFC: ---
>>
>> ---
>> Note:
>>
>> This is only tested with the qemu-malta target. The change
>> might break real platforms, however I have no suitable board
>> to test it.
>
> the consumers of pcnet and NE2000 are qemu-mips, R7780MP and SHMIN.
> Nobuhiro, could you comment this change?
>
>>
>> -Gabor
>> ---
>>  drivers/net/pcnet.c |    2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
>> index c028a44..45a66fb 100644
>> --- a/drivers/net/pcnet.c
>> +++ b/drivers/net/pcnet.c
>> @@ -146,7 +146,7 @@ static int pcnet_recv (struct eth_device *dev);
>>  static void pcnet_halt (struct eth_device *dev);
>>  static int pcnet_probe (struct eth_device *dev, bd_t * bis, int dev_num);
>>
>> -#define PCI_TO_MEM(d,a) pci_phys_to_mem((pci_dev_t)d->priv, (u_long)(a))
>> +#define PCI_TO_MEM(d, a) pci_virt_to_mem((pci_dev_t)d->priv, (a))
>>  #define PCI_TO_MEM_LE(d,a) (u32)(cpu_to_le32(PCI_TO_MEM(d,a)))
>>
>>  static struct pci_device_id supported[] = {
>> --
>> 1.7.10
>>
>
> --
> Best regards,
> Daniel
diff mbox

Patch

diff --git a/drivers/net/pcnet.c b/drivers/net/pcnet.c
index c028a44..45a66fb 100644
--- a/drivers/net/pcnet.c
+++ b/drivers/net/pcnet.c
@@ -146,7 +146,7 @@  static int pcnet_recv (struct eth_device *dev);
 static void pcnet_halt (struct eth_device *dev);
 static int pcnet_probe (struct eth_device *dev, bd_t * bis, int dev_num);
 
-#define PCI_TO_MEM(d,a) pci_phys_to_mem((pci_dev_t)d->priv, (u_long)(a))
+#define PCI_TO_MEM(d, a) pci_virt_to_mem((pci_dev_t)d->priv, (a))
 #define PCI_TO_MEM_LE(d,a) (u32)(cpu_to_le32(PCI_TO_MEM(d,a)))
 
 static struct pci_device_id supported[] = {