OSDN Git Service

iommu/mediatek: Enlarge the validate PA range for 4GB mode
authorYong Wu <yong.wu@mediatek.com>
Mon, 21 Aug 2017 11:00:20 +0000 (19:00 +0800)
committerJoerg Roedel <jroedel@suse.de>
Tue, 22 Aug 2017 14:38:00 +0000 (16:38 +0200)
commit30e2fccf9512380b5cdceffe04d776f5e6de6b49
treeae798165f6d76231b31ef6c5c62f49bc8d39a17e
parent6254b64f570622d4ebb7af00d46229bfc7346212
iommu/mediatek: Enlarge the validate PA range for 4GB mode

This patch is for 4GB mode, mainly for 4 issues:
1) Fix a 4GB bug:
   if the dram base is 0x4000_0000, the dram size is 0xc000_0000.
   then the code just meet a corner case because max_pfn is
   0x10_0000.
   data->enable_4GB = !!(max_pfn > (0xffffffffUL >> PAGE_SHIFT));
   It's true at the case above. That is unexpected.
2) In mt2712, there is a new register for the 4GB PA range(0x118)
   we should enlarge the max PA range, or the HW will report
   error.
   The dram range is from 0x1_0000_0000 to 0x1_ffff_ffff in the 4GB
   mode, we cut out the bit[32:30] of the SA(Start address) and
   EA(End address) into this REG_MMU_VLD_PA_RNG(0x118).
3) In mt2712, the register(0x13c) is extended for 4GB mode.
   bit[7:6] indicate the valid PA[32:33]. Thus, we don't mask the
   value and print it directly for debug.
4) if 4GB is enabled, the dram PA range is from 0x1_0000_0000 to
   0x1_ffff_ffff. Thus, the PA from iova_to_pa should also '|' BIT(32)

Signed-off-by: Honghui Zhang <honghui.zhang@mediatek.com>
Signed-off-by: Yong Wu <yong.wu@mediatek.com>
Signed-off-by: Joerg Roedel <jroedel@suse.de>
drivers/iommu/mtk_iommu.c