Skip to content

Commit 2b83878

Browse files
committed
xtensa: make __pa work with uncached KSEG addresses
When __pa is applied to virtual address in uncached KSEG region the result is incorrect. Fix it by checking if the original address is in the uncached KSEG and adjusting the result. It looks better than masking off bits because pfn_valid would correctly work with new __pa results and it may be made working in noMMU case, once we get definition for uncached memory view. This is required for the dma_common_mmap and DMA debug code to work correctly: they both indirectly use __pa with coherent DMA addresses. In case of DMA debug the visible effect is false reports that an address mapped for DMA is accessed by CPU. Cc: [email protected] Tested-by: Boris Brezillon <[email protected]> Reviewed-by: Boris Brezillon <[email protected]> Signed-off-by: Max Filippov <[email protected]>
1 parent c02ed2e commit 2b83878

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arch/xtensa/include/asm/page.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,8 +164,21 @@ void copy_user_highpage(struct page *to, struct page *from,
164164

165165
#define ARCH_PFN_OFFSET (PHYS_OFFSET >> PAGE_SHIFT)
166166

167+
#ifdef CONFIG_MMU
168+
static inline unsigned long ___pa(unsigned long va)
169+
{
170+
unsigned long off = va - PAGE_OFFSET;
171+
172+
if (off >= XCHAL_KSEG_SIZE)
173+
off -= XCHAL_KSEG_SIZE;
174+
175+
return off + PHYS_OFFSET;
176+
}
177+
#define __pa(x) ___pa((unsigned long)(x))
178+
#else
167179
#define __pa(x) \
168180
((unsigned long) (x) - PAGE_OFFSET + PHYS_OFFSET)
181+
#endif
169182
#define __va(x) \
170183
((void *)((unsigned long) (x) - PHYS_OFFSET + PAGE_OFFSET))
171184
#define pfn_valid(pfn) \

0 commit comments

Comments
 (0)