[U-Boot] [PATCH 2/2] e1000: fix PCI memory addressing
Wolfgang Denk
wd at denx.de
Sat Aug 22 15:17:18 CEST 2009
Dear Timur Tabi,
In message <4A8FEA69.9080408 at freescale.com> you wrote:
>
> > Configuring for MVBC_P board...
> > e1000.c: In function 'e1000_transmit':
> > e1000.c:5019: warning: passing argument 1 of 'virt_to_phys' discards
> > qualifiers from pointer target type
>
> I can't reproduce this problem.
...
> $ ${CROSS_COMPILE}gcc --version
> powerpc-linux-gnu-gcc (Sourcery G++ Lite 4.3-74) 4.3.2
I used ELDK 4.2 (gcc-4.2.2).
> If you look at the definition of virt_to_bus, you'll see that I added a
> pointer cast specifically to address this warning:
Well, are you aware how this simple statement gets expanded by the
preprocessor?
Out of
txp->buffer_addr = cpu_to_le64(virt_to_bus(hw->pdev, packet));
becomes:
txp->buffer_addr = (__builtin_constant_p((__u64)((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) ? ((__u64)( (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x00000000000000ffULL) << 56) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x000000000000ff00ULL) << 40) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x0000000000ff0000ULL) << 24) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x00000000ff000000ULL) << 8) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >>
16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x000000ff00000000ULL) >> 8) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x0000ff0000000000ULL) >> 24) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0x00ff000000000000ULL) >> 40) | (__u64)(((__u64)(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))) & (__u64)0xff00000000000000ULL) >> 56) )) : __fswab64(((pci_hose_phys_to_bus(pci_bus_to_hose(((((hw->pdev)) >> 16) & 0xff)), (virt_to_phys(((void *) (packet)))), (0x00000000))))));
I take my hat off to you if you manage to understand the consequences
and results of all this casting going on here.
> #define virt_to_bus(devno, v) pci_virt_to_mem(devno, (void *) (v))
Also, I have to admit that I really dislike such casts as they just
suppress compiler warnings which are usually valuable - I'd rather
see you fixing the original problem (i. e. the type
incompatibilities).
> If I remove the (void *) cast, I get this:
>
> e1000.c: In function 'e1000_transmit':
> e1000.c:5019: warning: passing argument 1 of 'virt_to_phys' discards
> qualifiers from pointer target type
>
> So somehow, you're compiler is ignoring the "(void *)".
I would not go so far to say it is ignoring it. Let's say this cast
is insufficient (or simply the wrong approach) to silence the compiler.
Best regards,
Wolfgang Denk
--
DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
"Maintain an awareness for contribution -- to your schedule, your
project, our company." - A Group of Employees
More information about the U-Boot
mailing list