CPU type: phytium: update phytium CPU type support#1948
Conversation
This patch provides three methods for reading cpu type for Phytium Socs, with priority from high to low as follows: - read socid by arm-smccc - read system register of SYS_AIDR_EL1 - read system register of MPIDR_EL1 Mainline: NA Signed-off-by: Feng Jun <fengjun@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn> Signed-off-by: Wang Chenlu <wangchenlu2236@phytium.com.cn>
This patch adjusts the machanism of obtaining the CPU type for Phytium Socs. It can directly return current CPU type when external interface calls the function. Mainline: Open-Source Signed-off-by: Feng Jun <fengjun@phytium.com.cn> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn> Signed-off-by: Wang Chenlu <wangchenlu2236@phytium.com.cn>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Reviewer's GuideAdds a Phytium SoC type detection/initialization framework on arm64 and wires it into early boot so other code can query a global Phytium SoC type symbol. Sequence diagram for Phytium SoC type initialization during arm64 bootsequenceDiagram
participant Kernel as setup_arch
participant Phytium as phyt_soc_type_init
participant Detector as phyt_read_soc_type
participant SMCCC as arm_smccc_smc
Kernel->>Phytium: phyt_soc_type_init()
Phytium->>Detector: phyt_read_soc_type()
Detector->>Detector: is_phytium_soc()
alt [is_phytium_soc]
Detector->>SMCCC: arm_smccc_smc(FUNC_ID_GET_CPU_VERSION,...)
alt [res.a0 == SMCCC_SUCCESS]
Detector->>Detector: do_smccc_res(res)
else [res.a0 == SMCCC_FAILURE]
Detector->>Detector: do_read_sysreg()
else [other]
Detector->>Detector: do_read_mpidr()
end
else [not Phytium]
Detector-->>Detector: return UNKNOWN_SOC
end
Detector-->>Phytium: enum phyt_soc_type
Phytium->>Phytium: set phyt_soc_type_t
Phytium-->>Kernel: return
Flow diagram for Phytium SoC type detection strategyflowchart TD
A[Start phyt_read_soc_type] --> B[is_phytium_soc]
B -->|false| Z[UNKNOWN_SOC]
B -->|true| C["arm_smccc_smc(FUNC_ID_GET_CPU_VERSION,...)"]
C --> D[Check res.a0]
D -->|SMCCC_SUCCESS| E[do_smccc_res]
E --> F{ctype != UNKNOWN_SOC}
F -->|true| Y[Detected SoC]
F -->|false| G[do_read_sysreg]
D -->|SMCCC_FAILURE| G
G --> H{ctype != UNKNOWN_SOC}
H -->|true| Y
H -->|false| I[do_read_mpidr]
D -->|other| I
I --> Y
Y --> Z[Return enum phyt_soc_type]
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
|
Hi @wangchenlu2236. Thanks for your PR. I'm waiting for a deepin-community member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
There was a problem hiding this comment.
Hey - I've left some high level feedback:
- In phyt_soc_type_init(), the large switch just reassigns the same enum value and can be simplified to a single
phyt_soc_type_t = ctype;, which reduces boilerplate and makes future enum additions simpler. - The multiple
is_*helpers (e.g. is_pd2408, is_ps23064, etc.) all duplicate the same pattern of equality checks; consider either a single helper that compares against an argument or using direct comparisons at call sites to avoid proliferating near-identical functions. - SMCCC_FAILURE is defined as -1 while arm_smccc_res fields are unsigned long, so relying on equality against -1 may be brittle; using explicit SMCCC return codes or checking ranges/bit patterns instead would make the error handling more robust.
Prompt for AI Agents
Please address the comments from this code review:
## Overall Comments
- In phyt_soc_type_init(), the large switch just reassigns the same enum value and can be simplified to a single `phyt_soc_type_t = ctype;`, which reduces boilerplate and makes future enum additions simpler.
- The multiple `is_*` helpers (e.g. is_pd2408, is_ps23064, etc.) all duplicate the same pattern of equality checks; consider either a single helper that compares against an argument or using direct comparisons at call sites to avoid proliferating near-identical functions.
- SMCCC_FAILURE is defined as -1 while arm_smccc_res fields are unsigned long, so relying on equality against -1 may be brittle; using explicit SMCCC return codes or checking ranges/bit patterns instead would make the error handling more robust.Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.
These patches updates the support for phytium CPU type.
1.arm64: phytium: Add support of reading cpu type for Phytium Socs
2.arm64: phytium: Update the method to obtain CPU type for Phytium SoCs
Summary by Sourcery
Add centralized detection and initialization of Phytium SoC CPU types on arm64 at boot.
New Features: