[PATCH] Clean Up Absolute Address Macros
Rusty Russell
rusty at rustcorp.com.au
Wed Mar 24 17:30:48 EST 2004
[ Boots in iSeries, thanks Stephen ]
Name: Clean Up Absolute Address Macros
Author: Rusty Russell
Status: Compiled
The iSeries has an arch-specific mapping from physical <-> absolute
addresses. Fortunately this is only used in a few places. However,
the following arch-specific macros/functions are provided in addition
to the standard macros:
__a2p()
__a2v()
__p2a()
__p2v()
__v2a()
__v2p()
absolute_to_phys()
phys_to_absolute()
virt_to_absolute()
absolute_to_virt()
Reduce them to these, with slightly shorter names, and taking either
pointers or unsigned long (as per __va and __pa) rather than making
the caller cast:
abs_to_phys()
phys_to_abs()
And helper macros:
virt_to_abs()
abs_to_virt()
As is standard, virtual addresses are returned as void *, physical and
absolute as unsigned long.
Note that the change the iSeries_setup is a little subtle: ea is set
to __va(pa) above, so "phys_to_abs(pa)" is the same as
"virt_to_abs(ea)".
Also, REALADDR is renamed to ISERIES_HV_ADDR and used in a couple of
places where appropriate.
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/kernel/HvCall.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/HvCall.c
--- ppc64-linux-2.5/arch/ppc64/kernel/HvCall.c 2004-01-20 16:05:53.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/HvCall.c 2004-03-24 15:48:18.914384613 +1100
@@ -19,7 +19,7 @@ void HvCall_writeLogBuffer(const void *b
{
struct HvLpBufferList hv_buf;
u64 left_this_page;
- u64 cur = virt_to_absolute((unsigned long)buffer);
+ u64 cur = virt_to_abs(buffer);
while (len) {
hv_buf.addr = cur;
@@ -29,7 +29,7 @@ void HvCall_writeLogBuffer(const void *b
hv_buf.len = left_this_page;
len -= left_this_page;
HvCall2(HvCallBaseWriteLogBuffer,
- virt_to_absolute((unsigned long)&hv_buf),
+ virt_to_abs(&hv_buf),
left_this_page);
cur = (cur & PAGE_MASK) + PAGE_SIZE;
}
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/kernel/iSeries_VpdInfo.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/iSeries_VpdInfo.c
--- ppc64-linux-2.5/arch/ppc64/kernel/iSeries_VpdInfo.c 2004-03-17 14:12:38.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/iSeries_VpdInfo.c 2004-03-24 15:48:18.916384461 +1100
@@ -293,7 +293,8 @@ void iSeries_Get_Location_Code(struct iS
return;
}
BusVpdLen = HvCallPci_getBusVpd(ISERIES_BUS(DevNode),
- REALADDR(BusVpdPtr), BUS_VPDSIZE);
+ ISERIES_HV_ADDR(BusVpdPtr),
+ BUS_VPDSIZE);
if (BusVpdLen == 0) {
kfree(BusVpdPtr);
printk("PCI: Bus VPD Buffer zero length.\n");
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/kernel/iSeries_iommu.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/iSeries_iommu.c
--- ppc64-linux-2.5/arch/ppc64/kernel/iSeries_iommu.c 2004-03-08 12:04:43.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/iSeries_iommu.c 2004-03-24 15:48:18.917384384 +1100
@@ -76,7 +76,7 @@ static void tce_build_iSeries(struct iom
while (npages--) {
tce.te_word = 0;
- tce.te_bits.tb_rpn = (virt_to_absolute(uaddr)) >> PAGE_SHIFT;
+ tce.te_bits.tb_rpn = virt_to_abs(uaddr) >> PAGE_SHIFT;
if (tbl->it_type == TCE_VB) {
/* Virtual Bus */
@@ -130,7 +130,7 @@ void __init iommu_vio_init(void)
cb.itc_busno = 255; /* Bus 255 is the virtual bus */
cb.itc_virtbus = 0xff; /* Ask for virtual bus */
- cbp = virt_to_absolute((unsigned long)&cb);
+ cbp = virt_to_abs(&cb);
HvCallXm_getTceTableParms(cbp);
veth_iommu_table.it_size = cb.itc_size / 2;
@@ -209,7 +209,7 @@ static void iommu_table_getparms(struct
parms->itc_slotno = dn->LogicalSlot;
parms->itc_virtbus = 0;
- HvCallXm_getTceTableParms(REALADDR(parms));
+ HvCallXm_getTceTableParms(ISERIES_HV_ADDR(parms));
if (parms->itc_size == 0)
panic("PCI_DMA: parms->size is zero, parms is 0x%p", parms);
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/kernel/iSeries_pci.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/iSeries_pci.c
--- ppc64-linux-2.5/arch/ppc64/kernel/iSeries_pci.c 2004-03-23 17:07:56.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/iSeries_pci.c 2004-03-24 15:48:18.921384079 +1100
@@ -283,7 +283,7 @@ static void iSeries_Scan_PHBs_Slots(stru
*/
for (IdSel = 1; IdSel < MaxAgents; ++IdSel) {
HvRc = HvCallPci_getDeviceInfo(bus, SubBus, IdSel,
- REALADDR(DevInfo),
+ ISERIES_HV_ADDR(DevInfo),
sizeof(struct HvCallPci_DeviceInfo));
if (HvRc == 0) {
if (DevInfo->deviceType == HvCallPci_NodeDevice)
@@ -324,7 +324,7 @@ static void iSeries_Scan_EADs_Bridge(HvB
"PCI:Connect EADs: 0x%02X.%02X.%02X\n",
bus, SubBus, AgentId);
HvRc = HvCallPci_getBusUnitInfo(bus, SubBus, AgentId,
- REALADDR(BridgeInfo),
+ ISERIES_HV_ADDR(BridgeInfo),
sizeof(struct HvCallPci_BridgeInfo));
if (HvRc == 0) {
printk("bridge info: type %x subbus %x maxAgents %x maxsubbus %x logslot %x\n",
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/kernel/iSeries_setup.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/iSeries_setup.c
--- ppc64-linux-2.5/arch/ppc64/kernel/iSeries_setup.c 2004-03-23 17:07:56.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/iSeries_setup.c 2004-03-24 15:48:18.925383774 +1100
@@ -657,8 +657,7 @@ static void __init iSeries_bolt_kernel(u
HvCallHpt_setPp(slot, PP_RWXX);
} else
/* No HPTE exists, so create a new bolted one */
- iSeries_make_pte(va, (unsigned long)__v2a(ea),
- mode_rw);
+ iSeries_make_pte(va, phys_to_abs(pa), mode_rw);
}
}
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/kernel/mf.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/mf.c
--- ppc64-linux-2.5/arch/ppc64/kernel/mf.c 2004-03-17 14:12:38.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/mf.c 2004-03-24 15:48:18.928383546 +1100
@@ -763,14 +763,10 @@ void mf_getSrcHistory(char *buffer, int
ev->event.data.vsp_cmd.lp_index = HvLpConfig_getLpIndex();
ev->event.data.vsp_cmd.result_code = 0xFF;
ev->event.data.vsp_cmd.reserved = 0;
- ev->event.data.vsp_cmd.sub_data.page[0] =
- (0x8000000000000000ULL | virt_to_absolute((unsigned long)pages[0]));
- ev->event.data.vsp_cmd.sub_data.page[1] =
- (0x8000000000000000ULL | virt_to_absolute((unsigned long)pages[1]));
- ev->event.data.vsp_cmd.sub_data.page[2] =
- (0x8000000000000000ULL | virt_to_absolute((unsigned long)pages[2]));
- ev->event.data.vsp_cmd.sub_data.page[3] =
- (0x8000000000000000ULL | virt_to_absolute((unsigned long)pages[3]));
+ ev->event.data.vsp_cmd.sub_data.page[0] = ISERIES_HV_ADDR(pages[0]);
+ ev->event.data.vsp_cmd.sub_data.page[1] = ISERIES_HV_ADDR(pages[1]);
+ ev->event.data.vsp_cmd.sub_data.page[2] = ISERIES_HV_ADDR(pages[2]);
+ ev->event.data.vsp_cmd.sub_data.page[3] = ISERIES_HV_ADDR(pages[3]);
mb();
if (signal_event(ev) != 0)
return;
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/kernel/pSeries_iommu.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/pSeries_iommu.c
--- ppc64-linux-2.5/arch/ppc64/kernel/pSeries_iommu.c 2004-03-21 00:04:50.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/pSeries_iommu.c 2004-03-24 15:48:18.929383469 +1100
@@ -61,7 +61,7 @@ static void tce_build_pSeries(struct iom
while (npages--) {
/* can't move this out since we might cross LMB boundary */
- t.te_rpn = (virt_to_absolute(uaddr)) >> PAGE_SHIFT;
+ t.te_rpn = (virt_to_abs(uaddr)) >> PAGE_SHIFT;
tp->te_word = t.te_word;
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/kernel/pSeries_lpar.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/pSeries_lpar.c
--- ppc64-linux-2.5/arch/ppc64/kernel/pSeries_lpar.c 2004-03-17 14:12:38.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/pSeries_lpar.c 2004-03-24 15:48:18.931383317 +1100
@@ -36,6 +36,7 @@
#include <asm/tlb.h>
#include <asm/hvcall.h>
#include <asm/prom.h>
+#include <asm/abs_addr.h>
/* in pSeries_hvCall.S */
EXPORT_SYMBOL(plpar_hcall);
@@ -135,7 +136,7 @@ static void tce_build_pSeriesLP(struct i
union tce_entry tce;
tce.te_word = 0;
- tce.te_rpn = (virt_to_absolute(uaddr)) >> PAGE_SHIFT;
+ tce.te_rpn = (virt_to_abs(uaddr)) >> PAGE_SHIFT;
tce.te_rdwr = 1;
if (direction != PCI_DMA_TODEVICE)
tce.te_pciwr = 1;
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/kernel/pci_dma_direct.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/pci_dma_direct.c
--- ppc64-linux-2.5/arch/ppc64/kernel/pci_dma_direct.c 2004-02-12 14:47:54.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/pci_dma_direct.c 2004-03-24 15:48:18.933383164 +1100
@@ -37,7 +37,7 @@ static void *pci_direct_alloc_consistent
ret = (void *)__get_free_pages(GFP_ATOMIC, get_order(size));
if (ret != NULL) {
memset(ret, 0, size);
- *dma_handle = virt_to_absolute((unsigned long)ret);
+ *dma_handle = virt_to_abs(ret);
}
return ret;
}
@@ -51,7 +51,7 @@ static void pci_direct_free_consistent(s
static dma_addr_t pci_direct_map_single(struct pci_dev *hwdev, void *ptr,
size_t size, int direction)
{
- return virt_to_absolute((unsigned long)ptr);
+ return virt_to_abs(ptr);
}
static void pci_direct_unmap_single(struct pci_dev *hwdev, dma_addr_t dma_addr,
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/kernel/pmac_iommu.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/pmac_iommu.c
--- ppc64-linux-2.5/arch/ppc64/kernel/pmac_iommu.c 2004-03-17 14:12:38.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/pmac_iommu.c 2004-03-24 15:48:18.934383088 +1100
@@ -154,7 +154,7 @@ static void dart_build_pmac(struct iommu
* out of the loop.
*/
while (npages--) {
- rpn = (virt_to_absolute(uaddr)) >> PAGE_SHIFT;
+ rpn = virt_to_abs(uaddr) >> PAGE_SHIFT;
*(dp++) = DARTMAP_VALID | (rpn & DARTMAP_RPNMASK);
@@ -210,7 +210,7 @@ static int dart_init(struct device_node
if (tmp == 0)
panic("U3-DART: Cannot allocate spare page !");
dart_emptyval = DARTMAP_VALID |
- ((virt_to_absolute(tmp) >> PAGE_SHIFT) & DARTMAP_RPNMASK);
+ ((virt_to_abs(tmp) >> PAGE_SHIFT) & DARTMAP_RPNMASK);
/* Map in DART registers. FIXME: Use device node to get base address */
dart = ioremap(DART_BASE, 0x7000);
@@ -225,7 +225,7 @@ static int dart_init(struct device_node
(((dart_tablesize >> PAGE_SHIFT) & DARTCNTL_SIZE_MASK)
<< DARTCNTL_SIZE_SHIFT);
p = virt_to_page(dart_tablebase);
- dart_vbase = ioremap(virt_to_absolute(dart_tablebase), dart_tablesize);
+ dart_vbase = ioremap(virt_to_abs(dart_tablebase), dart_tablesize);
/* Fill initial table */
for (i = 0; i < dart_tablesize/4; i++)
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/kernel/prom.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/prom.c
--- ppc64-linux-2.5/arch/ppc64/kernel/prom.c 2004-03-23 17:07:56.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/prom.c 2004-03-24 15:48:18.942382478 +1100
@@ -900,7 +900,7 @@ prom_initialize_tce_table(void)
prom_panic(RELOC("ERROR, cannot find space for TCE table.\n"));
}
- vbase = absolute_to_virt(base);
+ vbase = (unsigned long)abs_to_virt(base);
/* Save away the TCE table attributes for later use. */
prom_tce_table[table].node = node;
@@ -1007,9 +1007,12 @@ prom_hold_cpus(unsigned long mem)
extern void __secondary_hold(void);
extern unsigned long __secondary_hold_spinloop;
extern unsigned long __secondary_hold_acknowledge;
- unsigned long *spinloop = __v2a(&__secondary_hold_spinloop);
- unsigned long *acknowledge = __v2a(&__secondary_hold_acknowledge);
- unsigned long secondary_hold = (unsigned long)__v2a(*PTRRELOC((unsigned long *)__secondary_hold));
+ unsigned long *spinloop
+ = (void *)virt_to_abs(&__secondary_hold_spinloop);
+ unsigned long *acknowledge
+ = (void *)virt_to_abs(&__secondary_hold_acknowledge);
+ unsigned long secondary_hold
+ = virt_to_abs(*PTRRELOC((unsigned long *)__secondary_hold));
struct systemcfg *_systemcfg = RELOC(systemcfg);
struct paca_struct *_xPaca = PTRRELOC(&paca[0]);
struct prom_t *_prom = PTRRELOC(&prom);
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/kernel/rtas.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/rtas.c
--- ppc64-linux-2.5/arch/ppc64/kernel/rtas.c 2004-03-23 17:07:56.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/rtas.c 2004-03-24 15:48:18.945382249 +1100
@@ -362,7 +362,7 @@ rtas_flash_firmware(void)
*/
rtas_firmware_flash_list.num_blocks = 0;
flist = (struct flash_block_list *)&rtas_firmware_flash_list;
- rtas_block_list = virt_to_absolute((unsigned long)flist);
+ rtas_block_list = virt_to_abs(flist);
if (rtas_block_list >= (4UL << 20)) {
printk(KERN_ALERT "FLASH: kernel bug...flash list header addr above 4GB\n");
return;
@@ -374,13 +374,13 @@ rtas_flash_firmware(void)
for (f = flist; f; f = next) {
/* Translate data addrs to absolute */
for (i = 0; i < f->num_blocks; i++) {
- f->blocks[i].data = (char *)virt_to_absolute((unsigned long)f->blocks[i].data);
+ f->blocks[i].data = (char *)virt_to_abs(f->blocks[i].data);
image_size += f->blocks[i].length;
}
next = f->next;
/* Don't translate NULL pointer for last entry */
- if(f->next)
- f->next = (struct flash_block_list *)virt_to_absolute((unsigned long)f->next);
+ if (f->next)
+ f->next = (struct flash_block_list *)virt_to_abs(f->next);
else
f->next = 0LL;
/* make num_blocks into the version/length field */
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/kernel/smp.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/smp.c
--- ppc64-linux-2.5/arch/ppc64/kernel/smp.c 2004-03-11 07:04:34.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/kernel/smp.c 2004-03-24 15:48:18.949381944 +1100
@@ -986,7 +986,7 @@ int __devinit __cpu_up(unsigned int cpu)
tmp = &stab_array[PAGE_SIZE * cpu];
memset(tmp, 0, PAGE_SIZE);
paca[cpu].xStab_data.virt = (unsigned long)tmp;
- paca[cpu].xStab_data.real = (unsigned long)__v2a(tmp);
+ paca[cpu].xStab_data.real = virt_to_abs(tmp);
}
/* The information for processor bringup must be written out
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/mm/hash_utils.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/mm/hash_utils.c
--- ppc64-linux-2.5/arch/ppc64/mm/hash_utils.c 2004-03-17 14:12:38.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/mm/hash_utils.c 2004-03-24 15:48:18.951381792 +1100
@@ -48,6 +48,8 @@
#include <asm/tlb.h>
#include <asm/cacheflush.h>
#include <asm/cputable.h>
+#include <asm/abs_addr.h>
+
/*
* Note: pte --> Linux PTE
* HPTE --> PowerPC Hashed Page Table Entry
@@ -107,11 +109,11 @@ static inline void create_pte_mapping(un
if (systemcfg->platform == PLATFORM_PSERIES_LPAR)
ret = pSeries_lpar_hpte_insert(hpteg, va,
- (unsigned long)__v2a(addr) >> PAGE_SHIFT,
+ virt_to_abs(addr) >> PAGE_SHIFT,
0, mode, 1, large);
else
ret = pSeries_hpte_insert(hpteg, va,
- (unsigned long)__v2a(addr) >> PAGE_SHIFT,
+ virt_to_abs(addr) >> PAGE_SHIFT,
0, mode, 1, large);
if (ret == -1) {
@@ -154,7 +156,7 @@ void __init htab_initialize(void)
ppc64_terminate_msg(0x20, "hpt space");
loop_forever();
}
- htab_data.htab = (HPTE *)__a2v(table);
+ htab_data.htab = abs_to_virt(table);
/* htab absolute addr + encoded htabsize */
_SDR1 = table + __ilog2(pteg_count) - 11;
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/arch/ppc64/mm/init.c ppc64-linux-2.5-absolute_cleanup/arch/ppc64/mm/init.c
--- ppc64-linux-2.5/arch/ppc64/mm/init.c 2004-03-17 14:12:38.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/arch/ppc64/mm/init.c 2004-03-24 15:48:18.954381563 +1100
@@ -60,6 +60,7 @@
#include <asm/sections.h>
#include <asm/system.h>
#include <asm/iommu.h>
+#include <asm/abs_addr.h>
struct mmu_context_queue_t mmu_context_queue;
@@ -153,7 +154,7 @@ static void map_io_page(unsigned long ea
pmdp = pmd_alloc(&ioremap_mm, pgdp, ea);
ptep = pte_alloc_kernel(&ioremap_mm, pmdp, ea);
- pa = absolute_to_phys(pa);
+ pa = abs_to_phys(pa);
set_pte(ptep, pfn_pte(pa >> PAGE_SHIFT, __pgprot(flags)));
spin_unlock(&ioremap_mm.page_table_lock);
} else {
@@ -539,7 +540,7 @@ void __init do_init_bootmem(void)
*/
bootmap_pages = bootmem_bootmap_pages(total_pages);
- start = (unsigned long)__a2p(lmb_alloc(bootmap_pages<<PAGE_SHIFT, PAGE_SIZE));
+ start = abs_to_phys(lmb_alloc(bootmap_pages<<PAGE_SHIFT, PAGE_SIZE));
BUG_ON(!start);
boot_mapsize = init_bootmem(start >> PAGE_SHIFT, total_pages);
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/drivers/net/iseries_veth.c ppc64-linux-2.5-absolute_cleanup/drivers/net/iseries_veth.c
--- ppc64-linux-2.5/drivers/net/iseries_veth.c 2004-03-23 17:07:56.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/drivers/net/iseries_veth.c 2004-03-24 17:25:15.583723109 +1100
@@ -71,6 +71,7 @@
#include <linux/mm.h>
#include <linux/ethtool.h>
#include <asm/iSeries/mf.h>
+#include <asm/iSeries/iSeries_pci.h>
#include <asm/uaccess.h>
#include <asm/iSeries/HvLpConfig.h>
@@ -137,11 +138,6 @@ MODULE_LICENSE("GPL");
static int VethModuleReopen = 1;
-static inline u64 veth_dma_addr(void *p)
-{
- return 0x8000000000000000LL | virt_to_absolute((unsigned long) p);
-}
-
static inline HvLpEvent_Rc
veth_signalevent(struct veth_lpar_connection *cnx, u16 subtype,
HvLpEvent_AckInd ackind, HvLpEvent_AckType acktype,
@@ -1178,13 +1174,13 @@ static inline void veth_build_dma_list(s
* really need to break it into PAGE_SIZE chunks, or can we do
* it just at the granularity of iSeries real->absolute
* mapping? */
- list[0].addr = veth_dma_addr(p);
+ list[0].addr = ISERIES_HV_ADDR(p);
list[0].size = min(length,
PAGE_SIZE - ((unsigned long)p & ~PAGE_MASK));
done = list[0].size;
while (done < length) {
- list[i].addr = veth_dma_addr(p + done);
+ list[i].addr = ISERIES_HV_ADDR(p + done);
list[i].size = min(done, PAGE_SIZE);
done += list[i].size;
i++;
@@ -1255,8 +1251,8 @@ static void veth_receive(struct veth_lpa
cnx->dst_inst,
HvLpDma_AddressType_RealAddress,
HvLpDma_AddressType_TceIndex,
- veth_dma_addr(&local_list),
- veth_dma_addr(&remote_list),
+ ISERIES_HV_ADDR(&local_list),
+ ISERIES_HV_ADDR(&remote_list),
length);
if (rc != HvLpDma_Rc_Good) {
dev_kfree_skb_irq(skb);
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/include/asm-ppc64/abs_addr.h ppc64-linux-2.5-absolute_cleanup/include/asm-ppc64/abs_addr.h
--- ppc64-linux-2.5/include/asm-ppc64/abs_addr.h 2002-03-25 21:14:52.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/include/asm-ppc64/abs_addr.h 2004-03-24 15:51:13.905358578 +1100
@@ -71,26 +71,22 @@ abs_chunk(unsigned long pchunk)
return PTRRELOC(_msChunks->abs)[pchunk];
}
-
-static inline unsigned long
-phys_to_absolute(unsigned long pa)
-{
- return chunk_to_addr(abs_chunk(addr_to_chunk(pa))) + chunk_offset(pa);
-}
+/* A macro so it can take pointers or unsigned long. */
+#define phys_to_abs(pa) \
+ ({ unsigned long _pa = (unsigned long)(pa); \
+ chunk_to_addr(abs_chunk(addr_to_chunk(_pa))) + chunk_offset(_pa); \
+ })
static inline unsigned long
physRpn_to_absRpn(unsigned long rpn)
{
unsigned long pa = rpn << PAGE_SHIFT;
- unsigned long aa = phys_to_absolute(pa);
+ unsigned long aa = phys_to_abs(pa);
return (aa >> PAGE_SHIFT);
}
-static inline unsigned long
-absolute_to_phys(unsigned long aa)
-{
- return lmb_abs_to_phys(aa);
-}
+/* A macro so it can take pointers or unsigned long. */
+#define abs_to_phys(aa) lmb_abs_to_phys((unsigned long)(aa))
#else /* !CONFIG_MSCHUNKS */
@@ -99,23 +95,14 @@ absolute_to_phys(unsigned long aa)
#define chunk_offset(addr) (0)
#define abs_chunk(pchunk) (pchunk)
-#define phys_to_absolute(pa) (pa)
+#define phys_to_abs(pa) (pa)
#define physRpn_to_absRpn(rpn) (rpn)
-#define absolute_to_phys(aa) (aa)
+#define abs_to_phys(aa) (aa)
#endif /* !CONFIG_MSCHUNKS */
-
-static inline unsigned long
-virt_to_absolute(unsigned long ea)
-{
- return phys_to_absolute(__pa(ea));
-}
-
-static inline unsigned long
-absolute_to_virt(unsigned long aa)
-{
- return (unsigned long)__va(absolute_to_phys(aa));
-}
+/* Convenience macros */
+#define virt_to_abs(va) phys_to_abs(__pa(va))
+#define abs_to_virt(aa) __va(abs_to_phys(aa))
#endif /* _ABS_ADDR_H */
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/include/asm-ppc64/iSeries/HvCallEvent.h ppc64-linux-2.5-absolute_cleanup/include/asm-ppc64/iSeries/HvCallEvent.h
--- ppc64-linux-2.5/include/asm-ppc64/iSeries/HvCallEvent.h 2004-01-20 16:05:55.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/include/asm-ppc64/iSeries/HvCallEvent.h 2004-03-24 15:48:18.958381258 +1100
@@ -100,7 +100,7 @@ static inline void HvCallEvent_setLpEven
{
u64 abs_addr;
- abs_addr = virt_to_absolute((unsigned long)eventStackAddr);
+ abs_addr = virt_to_abs(eventStackAddr);
HvCall3(HvCallEventSetLpEventStack, queueIndex, abs_addr,
eventStackSize);
// getPaca()->adjustHmtForNoOfSpinLocksHeld();
@@ -123,7 +123,7 @@ static inline HvLpEvent_Rc HvCallEvent_s
printk("HvCallEvent_signalLpEvent: *event = %016lx\n ",
(unsigned long)event);
#endif
- abs_addr = virt_to_absolute((unsigned long)event);
+ abs_addr = virt_to_abs(event);
retVal = (HvLpEvent_Rc)HvCall1(HvCallEventSignalLpEvent, abs_addr);
// getPaca()->adjustHmtForNoOfSpinLocksHeld();
return retVal;
@@ -164,7 +164,7 @@ static inline HvLpEvent_Rc HvCallEvent_a
u64 abs_addr;
HvLpEvent_Rc retVal;
- abs_addr = virt_to_absolute((unsigned long)event);
+ abs_addr = virt_to_abs(event);
retVal = (HvLpEvent_Rc)HvCall1(HvCallEventAckLpEvent, abs_addr);
// getPaca()->adjustHmtForNoOfSpinLocksHeld();
return retVal;
@@ -175,7 +175,7 @@ static inline HvLpEvent_Rc HvCallEvent_c
u64 abs_addr;
HvLpEvent_Rc retVal;
- abs_addr = virt_to_absolute((unsigned long)event);
+ abs_addr = virt_to_abs(event);
retVal = (HvLpEvent_Rc)HvCall1(HvCallEventCancelLpEvent, abs_addr);
// getPaca()->adjustHmtForNoOfSpinLocksHeld();
return retVal;
@@ -286,7 +286,7 @@ static inline HvLpDma_Rc HvCallEvent_dma
u64 abs_addr;
HvLpDma_Rc retVal;
- abs_addr = virt_to_absolute((unsigned long)local);
+ abs_addr = virt_to_abs(local);
retVal = (HvLpDma_Rc)HvCall4(HvCallEventDmaToSp, abs_addr, remote,
length, dir);
// getPaca()->adjustHmtForNoOfSpinLocksHeld();
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/include/asm-ppc64/iSeries/iSeries_pci.h ppc64-linux-2.5-absolute_cleanup/include/asm-ppc64/iSeries/iSeries_pci.h
--- ppc64-linux-2.5/include/asm-ppc64/iSeries/iSeries_pci.h 2004-03-01 15:13:25.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/include/asm-ppc64/iSeries/iSeries_pci.h 2004-03-24 15:48:18.960381105 +1100
@@ -31,6 +31,7 @@
/************************************************************************/
#include <asm/iSeries/HvCallPci.h>
+#include <asm/abs_addr.h>
struct pci_dev; /* For Forward Reference */
struct iSeries_Device_Node;
@@ -71,7 +72,7 @@ struct iSeries_Device_Node;
/* Converts Virtual Address to Real Address for Hypervisor calls */
/************************************************************************/
-#define REALADDR(virtaddr) (0x8000000000000000 | (virt_to_absolute((u64)virtaddr) ))
+#define ISERIES_HV_ADDR(virtaddr) (0x8000000000000000 | virt_to_abs(virtaddr))
/************************************************************************/
/* iSeries Device Information */
diff -urNp --exclude TAGS -X /home/rusty/current-dontdiff --minimal ppc64-linux-2.5/include/asm-ppc64/page.h ppc64-linux-2.5-absolute_cleanup/include/asm-ppc64/page.h
--- ppc64-linux-2.5/include/asm-ppc64/page.h 2004-03-08 12:04:44.000000000 +1100
+++ ppc64-linux-2.5-absolute_cleanup/include/asm-ppc64/page.h 2004-03-24 15:48:18.962380953 +1100
@@ -212,19 +212,6 @@ extern int page_is_ram(unsigned long phy
#define __va(x) ((void *)((unsigned long)(x) + KERNELBASE))
-/* Given that physical addresses do not map 1-1 to absolute addresses, we
- * use these macros to better specify exactly what we want to do.
- * The only restriction on their use is that the absolute address
- * macros cannot be used until after the LMB structure has been
- * initialized in prom.c. -Peter
- */
-#define __v2p(x) ((void *) __pa(x))
-#define __v2a(x) ((void *) phys_to_absolute(__pa(x)))
-#define __p2a(x) ((void *) phys_to_absolute(x))
-#define __p2v(x) ((void *) __va(x))
-#define __a2p(x) ((void *) absolute_to_phys(x))
-#define __a2v(x) ((void *) __va(absolute_to_phys(x)))
-
#ifdef CONFIG_DISCONTIGMEM
#define page_to_pfn(page) discontigmem_page_to_pfn(page)
#define pfn_to_page(pfn) discontigmem_pfn_to_page(pfn)
--
Anyone who quotes me in their signature is an idiot -- Rusty Russell
** Sent via the linuxppc64-dev mail list. See http://lists.linuxppc.org/
More information about the Linuxppc64-dev
mailing list