Skip to content

feat(loongarch64): add 8-CPU support for LS3A6000 - #399

Open
weifenjihe wants to merge 2 commits into
syswonder:devfrom
weifenjihe:fixLArelease
Open

weifenjihe wants to merge 2 commits into
syswonder:devfrom
weifenjihe:fixLArelease

Conversation

@weifenjihe

Copy link
Copy Markdown
Contributor

Summary

Add 8 logical CPU support for the Loongson 3A6000 platform.

The main changes include:

  • Increase the LS3A6000 CPU count from 4 to 8.
  • Reserve per-CPU data for all eight logical CPUs.
  • Use IOCSR instructions for IPI and mailbox delivery.
  • Add support for the two-node EXTIOI topology:
    • CPUs 0–3 belong to EXTIOI node 0.
    • CPUs 4–7 belong to EXTIOI node 1.
  • Calculate the EXTIOI status register address from the physical CPU ID.
  • Initialize the interrupt enable, pin routing, node map, and core routing registers for both EXTIOI nodes.
  • Reset virtual IPI and EXTIOI state only for CPUs assigned to the affected zone.

With the corresponding DTS and zone JSON configurations, the eight logical CPUs can be assigned as follows:

Zone Physical CPUs
Root zone CPU0, CPU1
Zone 1 CPU2, CPU3
Zone 2 CPU4, CPU5
Zone 3 CPU6, CPU7

This allows the root zone and three non-root Linux zones to start sequentially with two logical CPUs each.

Motivation

The Loongson 3A6000 provides four physical cores with two hardware threads per core, exposing eight logical CPUs.

The existing LS3A6000 implementation only declared four CPUs and reserved per-CPU storage for four CPU instances. Its EXTIOI implementation also assumed a single interrupt-controller node and directly addressed only CPUs 0–3.

On the 8-CPU LS3A6000 configuration, CPUs 4–7 are associated with the second EXTIOI node. Continuing to calculate their interrupt status addresses from the first node can access unrelated EXTIOI registers. For example, treating CPU4 as the fifth CPU in node 0 reaches the node 0 routing area instead of the CPU4 status registers in node 1.

The existing MMIO-based IPI and mailbox access was also replaced with IOCSR instructions so that inter-processor notifications can be delivered using the target logical CPU ID.

Zone reset handling was changed as well. Resetting one zone now clears only the virtual IPI and EXTIOI state of the CPUs assigned to that zone. This prevents a zone restart from clearing pending interrupts belonging to another running zone.

Verification

The changes were verified on a Loongson 3A6000 system exposing eight logical CPUs.

The following CPU assignment was used:

  • Root zone: CPU0 and CPU1
  • Zone 1: CPU2 and CPU3
  • Zone 2: CPU4 and CPU5
  • Zone 3: CPU6 and CPU7

The root zone and the three non-root Linux zones can be started sequentially with two logical CPUs assigned to each zone.

Risks and Limitations

Each zone still requires a matching DTS and JSON configuration.

The following settings must remain consistent:

  • The CPU IDs assigned in the zone JSON file.
  • The CPU nodes enabled in the guest DTS.
  • The guest memory range in the DTS.
  • The physical and guest memory regions in the zone JSON file.
  • Kernel, DTB, and entry addresses.
  • Device ownership and MMIO regions.

For the demonstrated four-zone configuration, the CPU assignments are:

root:  0,1
zone1: 2,3
zone2: 4,5
zone3: 6,7

Changing the number of zones or their CPU allocation requires updating the corresponding DTS and JSON files.

The EXTIOI implementation assumes the LS3A6000 topology used by the tested system:

  • Four logical CPUs per EXTIOI node.
  • A node register-space stride of 0x10000.
  • Node 0 manages CPUs 0–3.
  • Node 1 manages CPUs 4–7.

Other LoongArch platforms with a different EXTIOI topology require separate validation and may need platform-specific topology information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request loongarch64

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant