From: Linh Dang <dang.linh@gmail.com>
To: Paul Mackerras <paulus@samba.org>
Cc: Linux Kernel <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH][PPC32[NEWBIE] enhancement to virt_to_bus/bus_to_virt (try 2)
Date: Thu, 2 Dec 2004 11:28:53 -0500 [thread overview]
Message-ID: <3b2b320041202082812ee4709@mail.gmail.com> (raw)
In-Reply-To: <3b2b32004120206497a471367@mail.gmail.com>
In 2.6.9 on non-APUS ppc32 platforms, virt_to_bus() will just subtract
KERNELBASE from the the virtual address. bus_to_virt() will perform
the reverse operation.
This patch will make virt_to_bus():
- perform the current operation if the virtual address is between
KERNELBASE and ioremap_bot.
- use iopa() (as on APUS platform) otherwise.
The patch will make bus_to_virt():
- perform the current operation if the bus address is between
PCI_DRAM_OFFSET and (ioremap_bot - KERNELBASE + PCI_DRAM_OFFSET).
- use mm_ptov() (as on APUS platform) otherwise.
The patch also changes virt_to_phys()/phys_to_virt() in a similar way.
-- Linh Dang
--- include/asm-ppc/io.h~2.6.9 2004-11-12 14:24:46.000000000 -0500
+++ include/asm-ppc/io.h 2004-12-02 11:20:21.000000000 -0500
@@ -6,10 +6,11 @@
#include <linux/types.h>
#include <asm/page.h>
#include <asm/byteorder.h>
#include <asm/mmu.h>
+#include <asm/pgtable.h>
#define SIO_CONFIG_RA 0x398
#define SIO_CONFIG_RD 0x399
#define SLOW_DOWN_IO
@@ -222,49 +223,56 @@ extern void io_block_mapping(unsigned lo
* have to be modified [mapped] appropriately.
*/
extern inline unsigned long virt_to_bus(volatile void * address)
{
#ifndef CONFIG_APUS
- if (address == (void *)0)
+ if (unlikely(address == (void *)0))
return 0;
+ if (likely((address >= (void*) KERNELBASE) &&
+ (address < ((void*) ioremap_bot))))
return (unsigned long)address - KERNELBASE + PCI_DRAM_OFFSET;
-#else
- return iopa ((unsigned long) address);
+ else
#endif
+ return iopa ((unsigned long) address);
}
extern inline void * bus_to_virt(unsigned long address)
{
#ifndef CONFIG_APUS
- if (address == 0)
+ if (unlikely (address == 0))
return NULL;
+ if (likely((address >= PCI_DRAM_OFFSET) &&
+ (address < (ioremap_bot - KERNELBASE + PCI_DRAM_OFFSET))))
return (void *)(address - PCI_DRAM_OFFSET + KERNELBASE);
-#else
- return (void*) mm_ptov (address);
+ else
#endif
+ return (void*) mm_ptov (address);
}
/*
* Change virtual addresses to physical addresses and vv, for
* addresses in the area where the kernel has the RAM mapped.
*/
extern inline unsigned long virt_to_phys(volatile void * address)
{
#ifndef CONFIG_APUS
+ if (likely((address >= (void*) KERNELBASE) &&
+ (address < ((void*) ioremap_bot))))
return (unsigned long) address - KERNELBASE;
-#else
- return iopa ((unsigned long) address);
+ else
#endif
+ return iopa ((unsigned long) address);
}
extern inline void * phys_to_virt(unsigned long address)
{
#ifndef CONFIG_APUS
+ if (likely(address < (ioremap_bot - KERNELBASE)))
return (void *) (address + KERNELBASE);
-#else
- return (void*) mm_ptov (address);
+ else
#endif
+ return (void*) mm_ptov (address);
}
/*
* Change "struct page" to physical address.
*/
next prev parent reply other threads:[~2004-12-02 16:30 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-12-02 14:49 [PATCH][PPC32] enhancement to virt_to_bus/bus_to_virt (resent with spell-checked subject line) Linh Dang
2004-12-02 16:28 ` Linh Dang [this message]
2004-12-02 20:31 ` [PATCH][PPC32[NEWBIE] enhancement to virt_to_bus/bus_to_virt (try 2) Paul Mackerras
2004-12-03 14:46 ` Linh Dang
2004-12-05 10:11 ` Eugene Surovegin
2004-12-05 19:18 ` Linh Dang
2004-12-05 20:52 ` Eugene Surovegin
2004-12-05 21:12 ` Paul Mackerras
2004-12-06 1:31 ` Linh Dang
2004-12-06 1:56 ` Linh Dang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=3b2b320041202082812ee4709@mail.gmail.com \
--to=dang.linh@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=paulus@samba.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox