Re: [PATCH] RAS/AMD/ATL: Add MI300 DRAM to Normalized address translation support

From: Borislav Petkov
Date: Thu Feb 01 2024 - 10:06:12 EST


On Thu, Feb 01, 2024 at 09:35:13AM -0500, Yazen Ghannam wrote:
> It's an operation on the bits within a value rather than between two values.
>
> BTW, I looked up "internal" in a thesaurus, and nothing seemed much better to me.
>
> Maybe something like "xor_bits_in_value()"? This has the verb-first style too.

Ah, ok, easy:

---
diff --git a/drivers/ras/amd/atl/umc.c b/drivers/ras/amd/atl/umc.c
index 67dc186a1226..7e310d1dfcfc 100644
--- a/drivers/ras/amd/atl/umc.c
+++ b/drivers/ras/amd/atl/umc.c
@@ -49,7 +49,8 @@ static u8 get_coh_st_inst_id_mi300(struct atl_err *err)
return i;
}

-static u16 internal_bitwise_xor(u16 val)
+/* XOR the bits in @val. */
+static u16 bitwise_xor_bits(u16 val)
{
u16 tmp = 0;
u8 i;
@@ -181,8 +182,8 @@ static unsigned long convert_dram_to_norm_addr_mi300(unsigned long addr)
if (!addr_hash.bank[i].xor_enable)
continue;

- temp = internal_bitwise_xor(col & addr_hash.bank[i].col_xor);
- temp ^= internal_bitwise_xor(row & addr_hash.bank[i].row_xor);
+ temp = bitwise_xor_bits(col & addr_hash.bank[i].col_xor);
+ temp ^= bitwise_xor_bits(row & addr_hash.bank[i].row_xor);
bank ^= temp << i;
}

@@ -191,9 +192,9 @@ static unsigned long convert_dram_to_norm_addr_mi300(unsigned long addr)
/* Bits SID[1:0] act as Bank[6:5] for PC hash, so apply them here. */
bank |= sid << 5;

- temp = internal_bitwise_xor(col & addr_hash.pc.col_xor);
- temp ^= internal_bitwise_xor(row & addr_hash.pc.row_xor);
- temp ^= internal_bitwise_xor(bank & addr_hash.bank_xor);
+ temp = bitwise_xor_bits(col & addr_hash.pc.col_xor);
+ temp ^= bitwise_xor_bits(row & addr_hash.pc.row_xor);
+ temp ^= bitwise_xor_bits(bank & addr_hash.bank_xor);
pc ^= temp;

/* Drop SID bits for the sake of debug printing later. */


--
Regards/Gruss,
Boris.

https://people.kernel.org/tglx/notes-about-netiquette