Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rasdaemon: Add error decoding for MCA_CTL_SMU extended bits #144

Closed

Conversation

nchatrad
Copy link
Contributor

Enable error decoding support for the newly added extended error bit descriptions from MCA_CTL_SMU.
b'0:11 can be decoded from existing array smca_smu2_mce_desc. Define a function to append the newly defined b'58:62 to the smca_smu2_mce_desc. This reduces the maintaining Reserved bits from b'12:57 in the code.

Enable error decoding support for the newly added extended
error bit descriptions from MCA_CTL_SMU.
b'0:11 can be decoded from existing array smca_smu2_mce_desc.
Define a function to append the newly defined b'58:62 to the
smca_smu2_mce_desc. This reduces the maintaining Reserved bits
from b'12:57 in the code.

Signed-off-by: Sathya Priya Kumar <[email protected]>
smca_smu2_mce_desc[i] = "Reserved";

smca_smu2_mce_desc[i] = smca_smu2_ext_mce_desc[j];
}
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (i = 12, j = 0; i < smu2_bits || j < 5; i++, j++) {
for ( ; i < 58; i++)

It sounds a very bad idea to use a loop like that with magic numbers (12, 5, 58), as it makes:

  • the table obfuscated, as one needs to read this init function to understand the value;
  • error prone, as new patches for the table require checking such init code;
  • less maintainable, as one needs to update not only the table but also this logic.

Instead, just let the compiler initialize "Reserved" at compile-time using designated initializers [1] like:

#define SMA_SMU2_MCE_SIZE 62

static const char * const smca_smu2_mce_desc[SMA_SMU2_MCE_SIZE] = {
       // Set a default value
	[0 ...SMA_SMU2_MCE_SIZE - 1] = "Reserved",
	// Initialize the fields that aren't reserved below here

[1] https://gcc.gnu.org/onlinedocs/gcc-3.3.1/gcc/Designated-Inits.html

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please track the changes in PR #167. This PR #144 can be closed.

@mchehab
Copy link
Owner

mchehab commented Jul 16, 2024

As requested, closing this, as PR#167 brings a new version.

@mchehab mchehab closed this Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants