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

Creates C-State, P-State and CPC objects under processor for X64 arch #6484

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

abdattar
Copy link
Contributor

@abdattar abdattar commented Nov 29, 2024

Description

This PR creates below ACPI objects for processor device for X64 arch
C-State: Creates _CST and _CSD objects.
P-State: Create _PCT, _PSS objects plus _PPC method
_PSD object for domain dependency
_CPC continue performance control object
Update AML library to generate _CST, _CSD, _PCT and _PSS node.
Generates _STA method based on configuration data.

  • Breaking change?
    • Breaking change - Does this PR cause a break in build or boot behavior?
    • Examples: Does it add a new library class or move a module to a different repo.
  • Impacts security?
    • Security - Does this PR have a direct security impact?
    • Examples: Crypto algorithm change or buffer overflow fix.
  • Includes tests?
    • Tests - Does this PR include any explicit test code?
    • Examples: Unit tests or integration tests.

How This Was Tested

Tested on AMD Platform

Integration Instructions

N/A

DynamicTablesPkg/Include/AcpiObjects.h Outdated Show resolved Hide resolved
DynamicTablesPkg/Include/AcpiObjects.h Outdated Show resolved Hide resolved
DynamicTablesPkg/Include/AcpiObjects.h Outdated Show resolved Hide resolved
DynamicTablesPkg/Include/ArchCommonNameSpaceObjects.h Outdated Show resolved Hide resolved
@abdattar abdattar force-pushed the CpuObjects branch 2 times, most recently from 2817556 to a13b8af Compare December 9, 2024 07:05
Abdul Lateef Attar added 7 commits December 9, 2024 09:02
Add _CSD version and number of entries definition.
These were introduced in the ACPI 3.0 specification.
Reference: ACPI 6.5 specification, section 8.4.1.2,
Table 8.3: C-State Dependency Package Values.

Signed-off-by: Abdul Lateef Attar <[email protected]>
Introduces functions to create C-State and P-State objects.
Includes code generation functions for _CST, _CSD, _PCT, and _PSS
ACPI processor objects.

Signed-off-by: Abdul Lateef Attar <[email protected]>
Introduces configuration manager objects for C-State and P-State.
These objects are used to parse and store the configuration data
for C-State and P-State tables.

Signed-off-by: Abdul Lateef Attar <[email protected]>
Add ACPI processor _CST, _CSD, _PCT, and _PSS objects for
X64 CPU SSDT table creation.

Also, add the _PPC method.

Signed-off-by: Abdul Lateef Attar <[email protected]>
Introduce _PSD and _CPC ACPI objects for X64 platforms.

Signed-off-by: Abdul Lateef Attar <[email protected]>
Adds _STA device status bit definations.
Reference: ACPI 6.5 specification, section 6.3.7

Signed-off-by: Abdul Lateef Attar <[email protected]>
Implement the _STA method for the CPU object based on
the value provided by the configuration manager.

Signed-off-by: Abdul Lateef Attar <[email protected]>
@abdattar
Copy link
Contributor Author

abdattar commented Dec 9, 2024

Hi @pierregondois,
I have addressed the review comments. Could you please review it again?
Thanks,
Abdul

/** A structure that describes a
processor power state control package Info.

Cf. ACPI 6.1, s8.4.1.1 _CST (Processor Power State Control).
Copy link
Contributor

Choose a reason for hiding this comment

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

Please move to 6.5 spec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

/// Worst case latency for entering and exiting the C-State, in milliseconds.
UINT16 Latency;

/// Power consumption in the C-State.
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT: is it possible to add that this is in mW ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

EFIAPI
AmlCreatePssNode (
IN AML_PSS_INFO *PssInfo,
IN UINT32 NumPackages,
Copy link
Contributor

Choose a reason for hiding this comment

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

IIRC, PssInfo is an array of NumPackages elements. Is it possible to mention it in the parameter description.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

goto error_handler;
}

for (Index = 0; Index < NumPackages; Index++) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think you need to iterate over the different PssInfo elements, it seems you are using the first entry for all the iterations.
I.e. use PssInfo[Index].XXX in the loop.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

AML_OBJECT_NODE_HANDLE PssMainPackage;
UINT32 Index;

if ((PssInfo == NULL) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be possible to forbid calling the function with NumPackages == 0 ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

Status // Integer (DWORD)
})
Cf. ACPI 6.4, s8.4.5.2 _PSS (Processor Supported Performance States).
Copy link
Contributor

Choose a reason for hiding this comment

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

Should update to 6.5 spec (maybe same comment at other places)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

/** Create _PSS node
Generates and optionally appends the following node:
Name (_PSS, Package()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think the description of what is generated is incorrect: each PState is in a package and _PSS returns a package of PState, so it should be as in the spec:

Package {
  PState [0]  // Package - Performance state 0
  ....
  PState [n]  // Package - Performance state n
}

Each Pstate sub-Package contains the elements described below:

Package {
  CoreFrequency,        // Integer (DWORD)
  Power,                      // Integer (DWORD)
  Latency,                    // Integer (DWORD)
  BusMasterLatency,   // Integer (DWORD)
  Control,                    // Integer (DWORD)
  Status,                      // Integer (DWORD)
}

I think some comments for AmlCreatePssNode() can be applied to AmlCreateCsdNode() and AmlCreateCstNode(). Is it possible to check please ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack, agree will update the description.

}

for (Index = 0; Index < NumEntries; Index++) {
if ((CsdInfo[Index].NumEntries != EFI_ACPI_6_4_AML_CSD_NUM_ENTRIES) ||
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be 6.5 spec

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

@@ -19,6 +19,15 @@
//
#pragma pack(1)

///
/// _STA bit definitions ACPI 6.5 s6.3.7
Copy link
Contributor

Choose a reason for hiding this comment

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

Not here, but typo in the commit message: definations -> definitions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ack

/** Optional field: Reference Token for the Cst info of this processor.
i.e. a token referencing a CM_ARCH_COMMON_CST_INFO object.
*/
CM_OBJECT_TOKEN CstToken;
Copy link
Contributor

Choose a reason for hiding this comment

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

I think these should be token identifying a CM_ARCH_COMMON_OBJ_REF structure instead.

Indeed, it is likely that most of the CPUs on the platform will have the same set of C-States or P-States (or other). So instead of having all functions returning the same set of values for each CPU, it would be better to factorize these values in one object. For instance, all CPUs on the platform could implement the _CST method as:

Scope (\_SB) {
	Name (CST0, Package() {
		0, // Count
		Package() {
			Register,
			Type,
			Latency,
			Power
		},
	} // Name CST0
}

// and for each CPU:
Scope(\_PR.CPU0) {
  Method(_CST,0) {
	  Return(\_SB.CST0)
  }
}

Scope(\_PR.CPU1) {
  Method(_CST,0) {
	  Return(\_SB.CST0)
  }
}

Scope(\_PR.CPU2) {
  Method(_CST,0) {
	  Return(\_SB.CST0)
  }
}
...

This seems to be also how platform vendors have implemented their _PSS, _PCT methods.

Please check the GenerateLpiStates() and CreateAmlLpiMethod() functions

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Didnt opted the factorization for below reason.

  1. to generate the code similar to what ACPI spec says and close to the acpi spec examples.
  2. There are possibilities(hypothetical scenario) that each processor might support different set of C-State and P-State.
    Also different processor might have different values(in package) to put the processor into different C-State.

Copy link
Contributor

Choose a reason for hiding this comment

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

Using a CM_ARCH_COMMON_OBJ_REF would still allow CPUs to have different C-States/P-states. However they would have to be written only once. Each CPU can then aggregate these C/P-states how they desire.

Please have a look at the Lpi-States configuration at [1]. The Juno platform has an asymmetric topology, so for most platforms Lpi-States configuration would be simpler to configure (and so would it be for the C/P-States).

[1] https://github.com/tianocore/edk2-platforms/blob/master/Platform/ARM/JunoPkg/ConfigurationManager/ConfigurationManagerDxe/ConfigurationManager.c

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.

2 participants