MIPS: Use CPHYSADDR to implement mips32 __pa
authorPaul Burton <paul.burton@imgtec.com>
Tue, 2 Aug 2016 10:40:57 +0000 (11:40 +0100)
committerRalf Baechle <ralf@linux-mips.org>
Tue, 2 Aug 2016 12:01:02 +0000 (14:01 +0200)
commit0d8d83d0447deb526c3125250eb391b5d76a3472
tree8302cb9bc4fb6b6d735116d857b329eff9e65345
parent5c315e3984291b5bbf1bb873040182ead0637160
MIPS: Use CPHYSADDR to implement mips32 __pa

Use CPHYSADDR to implement the __pa macro converting from a virtual to a
physical address for MIPS32, much as is already done for MIPS64 (though
without the complication of having both compatibility & XKPHYS
segments).

This allows for __pa to work regardless of whether the address being
translated is in kseg0 or kseg1, unlike the previous subtraction based
approach which only worked for addresses in kseg0. Working for kseg1
addresses is important if __pa is used on addresses allocated by
dma_alloc_coherent, where on systems with non-coherent I/O we provide
addresses in kseg1. If this address is then used with
dma_map_single_attrs then it is provided to virt_to_page, which in turn
calls virt_to_phys which is a wrapper around __pa. The result is that we
end up with a physical address 0x20000000 bytes (ie. the size of kseg0)
too high.

In addition to providing consistency with MIPS64 & fixing the kseg1 case
above this has the added bonus of generating smaller code for systems
implementing MIPS32r2 & beyond, where a single ext instruction can
extract the physical address rather than needing to load an immediate
into a temp register & subtract it. This results in ~1.3KB savings for a
boston_defconfig kernel adjusted to set CONFIG_32BIT=y.

This patch does not change the EVA case, which may or may not have
similar issues around handling both cached & uncached addresses but is
beyond the scope of this patch.

Signed-off-by: Paul Burton <paul.burton@imgtec.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: linux-mips@linux-mips.org
Cc: linux-kernel@vger.kernel.org
Patchwork: https://patchwork.linux-mips.org/patch/13836/
Signed-off-by: Ralf Baechle <ralf@linux-mips.org>
arch/mips/include/asm/page.h
This page took 0.027782 seconds and 5 git commands to generate.