mirror of
https://mirrors.bfsu.edu.cn/git/linux.git
synced 2024-12-12 21:44:06 +08:00
habanalabs: add RMWREG32_SHIFTED to set a val within a mask
This is similar to RMWREG32, but the given 'val' is already shifted according to the mask. This allows several 'ORed' vals and masks to be set at once The patch also fixes wrong usage of RMWREG32 by replacing it with RMWREG32_SHIFTED Signed-off-by: Dafna Hirschfeld <dhirschfeld@habana.ai> Reviewed-by: Oded Gabbay <ogabbay@kernel.org> Signed-off-by: Oded Gabbay <ogabbay@kernel.org>
This commit is contained in:
parent
56fb517775
commit
0abcae8b48
@ -2498,13 +2498,9 @@ void hl_wreg(struct hl_device *hdev, u32 reg, u32 val);
|
||||
#define WREG32_AND(reg, and) WREG32_P(reg, 0, and)
|
||||
#define WREG32_OR(reg, or) WREG32_P(reg, or, ~(or))
|
||||
|
||||
#define RMWREG32(reg, val, mask) \
|
||||
do { \
|
||||
u32 tmp_ = RREG32(reg); \
|
||||
tmp_ &= ~(mask); \
|
||||
tmp_ |= ((val) << __ffs(mask)); \
|
||||
WREG32(reg, tmp_); \
|
||||
} while (0)
|
||||
#define RMWREG32_SHIFTED(reg, val, mask) WREG32_P(reg, val, ~(mask))
|
||||
|
||||
#define RMWREG32(reg, val, mask) RMWREG32_SHIFTED(reg, (val) << __ffs(mask), mask)
|
||||
|
||||
#define RREG32_MASK(reg, mask) ((RREG32(reg) & mask) >> __ffs(mask))
|
||||
|
||||
|
@ -5052,7 +5052,7 @@ static int gaudi2_pci_mmu_init(struct hl_device *hdev)
|
||||
mmu_base = mmPMMU_HBW_MMU_BASE;
|
||||
stlb_base = mmPMMU_HBW_STLB_BASE;
|
||||
|
||||
RMWREG32(stlb_base + STLB_HOP_CONFIGURATION_OFFSET,
|
||||
RMWREG32_SHIFTED(stlb_base + STLB_HOP_CONFIGURATION_OFFSET,
|
||||
(0 << PMMU_HBW_STLB_HOP_CONFIGURATION_FIRST_HOP_SHIFT) |
|
||||
(5 << PMMU_HBW_STLB_HOP_CONFIGURATION_FIRST_LOOKUP_HOP_SMALL_P_SHIFT) |
|
||||
(4 << PMMU_HBW_STLB_HOP_CONFIGURATION_FIRST_LOOKUP_HOP_LARGE_P_SHIFT) |
|
||||
@ -5068,7 +5068,7 @@ static int gaudi2_pci_mmu_init(struct hl_device *hdev)
|
||||
|
||||
if (PAGE_SIZE == SZ_64K) {
|
||||
/* Set page sizes to 64K on hop5 and 16M on hop4 + enable 8 bit hops */
|
||||
RMWREG32(mmu_base + MMU_STATIC_MULTI_PAGE_SIZE_OFFSET,
|
||||
RMWREG32_SHIFTED(mmu_base + MMU_STATIC_MULTI_PAGE_SIZE_OFFSET,
|
||||
FIELD_PREP(DCORE0_HMMU0_MMU_STATIC_MULTI_PAGE_SIZE_HOP5_PAGE_SIZE_MASK, 4) |
|
||||
FIELD_PREP(DCORE0_HMMU0_MMU_STATIC_MULTI_PAGE_SIZE_HOP4_PAGE_SIZE_MASK, 3) |
|
||||
FIELD_PREP(
|
||||
@ -5116,7 +5116,7 @@ static int gaudi2_dcore_hmmu_init(struct hl_device *hdev, int dcore_id,
|
||||
RMWREG32(mmu_base + MMU_STATIC_MULTI_PAGE_SIZE_OFFSET, 5 /* 64MB */,
|
||||
MMU_STATIC_MULTI_PAGE_SIZE_HOP4_PAGE_SIZE_MASK);
|
||||
|
||||
RMWREG32(stlb_base + STLB_HOP_CONFIGURATION_OFFSET,
|
||||
RMWREG32_SHIFTED(stlb_base + STLB_HOP_CONFIGURATION_OFFSET,
|
||||
FIELD_PREP(DCORE0_HMMU0_STLB_HOP_CONFIGURATION_FIRST_HOP_MASK, 0) |
|
||||
FIELD_PREP(DCORE0_HMMU0_STLB_HOP_CONFIGURATION_FIRST_LOOKUP_HOP_SMALL_P_MASK, 3) |
|
||||
FIELD_PREP(DCORE0_HMMU0_STLB_HOP_CONFIGURATION_FIRST_LOOKUP_HOP_LARGE_P_MASK, 3) |
|
||||
|
Loading…
Reference in New Issue
Block a user