Re: [PATCH v5 5/5] x86/CPU/AMD: Print the reason for the last reset

From: Mario Limonciello
Date: Wed Apr 30 2025 - 15:18:08 EST


On 4/30/2025 2:10 PM, Borislav Petkov wrote:
On Wed, Apr 30, 2025 at 02:05:44PM -0500, Mario Limonciello wrote:
On 4/30/2025 2:03 PM, Borislav Petkov wrote:
On Tue, Apr 22, 2025 at 06:48:30PM -0500, Mario Limonciello wrote:
+ /* Iterate on each bit in the 'value' mask: */
+ while (true) {
+ bit = find_next_bit(&value, BITS_PER_LONG, bit + 1);
+
+ /* Reached the end of the word, no more bits: */
+ if (bit >= BITS_PER_LONG) {
+ if (!nr_reasons)
+ pr_info("x86/amd: Previous system reset reason [0x%08lx]: Unknown\n", value);
+ break;
+ }
+
+ if (!s5_reset_reason_txt[bit])
+ continue;
+
+ nr_reasons++;
+ pr_info("x86/amd: Previous system reset reason [0x%08lx]: %s\n",
+ value, s5_reset_reason_txt[bit]);
+ }

What happened to that simpler idea:

https://lore.kernel.org/r/20250411125050.GEZ_kQKtYBfEMDQuXU@fat_crate.local


This one was more advantageous in that if multiple bits were set for any
reason we could get messages for all of them printed.

I don't understand - you dump an array element for every bit now too...


Well with that approach once you got a known bit set you broke the loop and would print a message for that known bit. But if you have two bits set you either need another loop or you only get one message print.