Skip to contentSkip to conversation

mark virt_to_bus/bus_to_virt as __deprecated on i386

PATCH In review Adrian Bunk 4 participants 7 messages Apr 18, 2006 – Apr 19, 2006 2 messages not in the archive

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mark virt_to_bus/bus_to_virt as __deprecated on i386

virt_to_bus/bus_to_virt are long deprecated, mark them as __deprecated on i386.

Without such warnings people will never update their code and fix Andrew's all*config PPC64 builds.

And yes, some of the drivers affected are maintained.

As an example, the only usage of bus_to_virt() in the infiniband code was added in 2.6.17-rc1 (sic).

This patch increases the number of warnings shown during builds, but it seems worth including it at least in -mm for making people aware of this issue.

---

This patch was already sent on:
- 6 Jan 2006
- 13 Dec 2005
- 23 Nov 2005
- 18 Nov 2005
- 12 Nov 2005

include/asm-i386/io.h renamed from include/asm-i386/io.h.old +8 -2
@@ -144,8 +144,14 @@
  *
  * Allow them on x86 for legacy drivers, though.
  */
-#define virt_to_bus virt_to_phys
-#define bus_to_virt phys_to_virt
+static inline unsigned long __deprecated virt_to_bus(volatile void * address)
+{
+	return __pa(address);
+}
+static inline void * __deprecated bus_to_virt(unsigned long address)
+{
+	return __va(address);
+}
 
 /*
  * readX/writeX() are used to access memory mapped devices. On some
#1 lore raw

Adrian> As an example, the only usage of bus_to_virt() in the Adrian> infiniband code was added in 2.6.17-rc1 (sic).

Ugh, the pathscale guys snuck that one past me in the ipath merge. I'll see what I can do about it...

- R.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#3 lore raw
Quoted 5 lines · Muli Ben-Yehuda
Quoted 2 lines · Adrian Bunk

virt_to_bus/bus_to_virt are long deprecated, mark them as __deprecated on i386.

You should probably update Documentation/ while you're at it.

Which file under Documentation/ are you referring to?

Quoted 3 lines

Also, IIRC Xen uses virt_to_phys to return guest physical addresses and virt_to_bus to return machine physical addresses, so the difference is useful at least in some scenarios.

Solving this should be easy.

And this still doesn't make it right for architecture independent drivers to use virt_to_bus/bus_to_virt.

Quoted 2 lines

Cheers,
Muli

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed
#4 lore raw
Quoted 9 lines · Adrian Bunk
Quoted 5 lines · Muli Ben-Yehuda
Quoted 2 lines · Adrian Bunk

virt_to_bus/bus_to_virt are long deprecated, mark them as __deprecated on i386.

You should probably update Documentation/ while you're at it.

Which file under Documentation/ are you referring to?

Quoted 8 lines
Quoted 3 lines

Also, IIRC Xen uses virt_to_phys to return guest physical addresses and virt_to_bus to return machine physical addresses, so the difference is useful at least in some scenarios.

Solving this should be easy.

And this still doesn't make it right for architecture independent drivers to use virt_to_bus/bus_to_virt.

Then what would you use to return the proper bus address to put into a DMA scatter list and, conversely, how would you convert those bus addresses into something a virtual mode CPU could access? These macros used to be the link that made such driver coding architecture independent. You cannot just claim that one can't make such conversions anymore. The CPU uses virtual addresses and the DMA uses physical (bus) addresses. Do we throw away DMA altogether?

Quoted 14 lines
Quoted 3 lines

Cheers,
Muli

cu
Adrian

--

"Is there not promise of rain?" Ling Tan asked suddenly out
of the darkness. There had been need of rain for many days.
"Only a promise," Lao Er said.
Pearl S. Buck - Dragon Seed

Quoted 6 lines

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

Cheers,
Dick Johnson
Penguin : Linux version 2.6.15.4 on an i686 machine (5589.53 BogoMips). Warning : 98.36% of all statistics are fiction, book release in April. _


****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

#5 lore raw
Quoted 20 lines · linux-os (Dick Johnson)
Quoted 9 lines · Adrian Bunk
Quoted 5 lines · Muli Ben-Yehuda
Quoted 2 lines · Adrian Bunk

virt_to_bus/bus_to_virt are long deprecated, mark them as __deprecated on i386.

You should probably update Documentation/ while you're at it.

Which file under Documentation/ are you referring to?

Quoted 8 lines
Quoted 3 lines

Also, IIRC Xen uses virt_to_phys to return guest physical addresses and virt_to_bus to return machine physical addresses, so the difference is useful at least in some scenarios.

Solving this should be easy.

And this still doesn't make it right for architecture independent drivers to use virt_to_bus/bus_to_virt.

Quoted 8 lines

Then what would you use to return the proper bus address to put into a DMA scatter list and, conversely, how would you convert those bus addresses into something a virtual mode CPU could access? These macros used to be the link that made such driver coding architecture independent. You cannot just claim that one can't make such conversions anymore. The CPU uses virtual addresses and the DMA uses physical (bus) addresses. Do we throw away DMA altogether?

since a long time the kernel has proper dma mapping API's for this, in 2.4 it's pci specific in 2.6 it's generic and bus agnostic.

#6 lore raw

Re: [2.6 patch] mark virt_to_bus/bus_to_virt as __deprecated oni386

Quoted 30 lines · Arjan van de Ven
Quoted 20 lines · linux-os (Dick Johnson)
Quoted 9 lines · Adrian Bunk
Quoted 5 lines · Muli Ben-Yehuda
Quoted 2 lines · Adrian Bunk

virt_to_bus/bus_to_virt are long deprecated, mark them as __deprecated on i386.

You should probably update Documentation/ while you're at it.

Which file under Documentation/ are you referring to?

Quoted 8 lines
Quoted 3 lines

Also, IIRC Xen uses virt_to_phys to return guest physical addresses and virt_to_bus to return machine physical addresses, so the difference is useful at least in some scenarios.

Solving this should be easy.

And this still doesn't make it right for architecture independent drivers to use virt_to_bus/bus_to_virt.

Quoted 8 lines

Then what would you use to return the proper bus address to put into a DMA scatter list and, conversely, how would you convert those bus addresses into something a virtual mode CPU could access? These macros used to be the link that made such driver coding architecture independent. You cannot just claim that one can't make such conversions anymore. The CPU uses virtual addresses and the DMA uses physical (bus) addresses. Do we throw away DMA altogether?

Quoted 3 lines

since a long time the kernel has proper dma mapping API's for this, in 2.4 it's pci specific in 2.6 it's generic and bus agnostic.

Yeah. Somebody finally let you put a NULL in place of the PCI structure pointer so you didn't have to write a lot of dummy code. Now, on ix86 devices, instead of |= PAGE_OFFSET or inverse, one needs to add all that PCI code. Go figure. Bloatware.

Cheers,
Dick Johnson
Penguin : Linux version 2.6.15.4 on an i686 machine (5589.53 BogoMips). Warning : 98.36% of all statistics are fiction, book release in April. _


****************************************************************
The information transmitted in this message is confidential and may be privileged. Any review, retransmission, dissemination, or other use of this information by persons or entities other than the intended recipient is prohibited. If you are not the intended recipient, please notify Analogic Corporation immediately - by replying to this message or by sending an email to [email protected] - and destroy all copies of this information, including any attachments, without reading or disclosing them.

Thank you.

A message that is not in the archive (sent off-list or not yet received): [email protected]

#8 lore raw
Quoted 6 lines · Muli Ben-Yehuda
Quoted 1 line · Adrian Bunk

Which file under Documentation/ are you referring to?

virt_to_bus() and bus_to_virt() appear in several files, in particular DMA-mapping.txt and IO-mapping.txt.

DMA-mapping.txt exlicitely states it's planned with virt_to_bus/bus_to_virt, and IO-mapping.txt starts with:

<-- snip -->

[ NOTE: The virt_to_bus() and bus_to_virt() functions have been
superseded by the functionality provided by the PCI DMA interface (see Documentation/DMA-mapping.txt). They continue to be documented below for historical purposes, but new code must not use them. --davidm 00/12/12 ]

<-- snip -->

Patches to update Documentation/ are always welcome, but these two files already explicitely mention virt_to_bus/bus_to_virt, as deprecated, so I still don't see any urgent action required.

Quoted 2 lines

Cheers,
Muli

cu
Adrian

Signature · 4 lines
       "Is there not promise of rain?" Ling Tan asked suddenly out
        of the darkness. There had been need of rain for many days.
       "Only a promise," Lao Er said.
                                       Pearl S. Buck - Dragon Seed