@@ -961,12 +961,34 @@ static int add_base_and_hole(struct addr_ctx *ctx)
return 0;
}
+static int dehash_addr_df2(struct addr_ctx *ctx)
+{
+ u8 hashed_bit = (ctx->ret_addr >> 12) ^
+ (ctx->ret_addr >> 18) ^
+ (ctx->ret_addr >> 21) ^
+ (ctx->ret_addr >> 30) ^
+ ctx->cs_id;
+
+ hashed_bit &= BIT(0);
+
+ if (hashed_bit != ((ctx->ret_addr >> ctx->intlv_addr_bit) & BIT(0)))
+ ctx->ret_addr ^= BIT(ctx->intlv_addr_bit);
+
+ return 0;
+}
+
+static int dehash_addr(struct addr_ctx *ctx)
+{
+ if (!ctx->hash_enabled)
+ return 0;
+
+ return dehash_addr_df2(ctx);
+}
+
int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr)
{
u64 dram_limit_addr;
- u8 hashed_bit;
-
struct addr_ctx ctx;
memset(&ctx, 0, sizeof(ctx));
@@ -996,19 +1018,8 @@ int umc_normaddr_to_sysaddr(u64 norm_addr, u16 nid, u8 umc, u64 *sys_addr)
if (add_base_and_hole(&ctx))
goto out_err;
- if (ctx.hash_enabled) {
- /* Save some parentheses and grab ls-bit at the end. */
- hashed_bit = (ctx.ret_addr >> 12) ^
- (ctx.ret_addr >> 18) ^
- (ctx.ret_addr >> 21) ^
- (ctx.ret_addr >> 30) ^
- ctx.cs_id;
-
- hashed_bit &= BIT(0);
-
- if (hashed_bit != ((ctx.ret_addr >> ctx.intlv_addr_bit) & BIT(0)))
- ctx.ret_addr ^= BIT(ctx.intlv_addr_bit);
- }
+ if (dehash_addr(&ctx))
+ goto out_err;
/* Is calculated system address is above DRAM limit address? */
if (ctx.ret_addr > dram_limit_addr)