[feat]: add LG200 DRM device discovery - #28
Open
guohuan78 wants to merge 1 commit into
Open
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces an LG200 “discovery-only” layer that enumerates Loongson LG200 DRM devices via sysfs and exposes a small C API for device listing and optional utilization/memory stats, plus a CLI/tool and a synthetic sysfs test to validate discovery without hardware.
Changes:
- Add
Lg200DeviceEnumerate()/Lg200DeviceReadStats()C API and Linux sysfs-backed implementation. - Add
lg200_infotool for runtime inspection of discovered devices and optional stats. - Add a synthetic
/sys/class/drm-like test harness (lg200_resource_test) and wire up LG200 platform/test CMake.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| platforms/lg200/hal/src/resource.cpp | Implements sysfs-based DRM discovery and optional stats reads for LG200. |
| platforms/lg200/hal/include/xsched/lg200/hal.h | Defines the public LG200 C API structs and function declarations. |
| platforms/lg200/hal/include/xsched/lg200/hal/resource.h | Declares internal C++ discovery helper returning a std::vector. |
| platforms/lg200/tools/lg200_info.cpp | Adds a CLI utility to enumerate devices and print optional stats. |
| platforms/lg200/test/lg200_resource_test.cpp | Adds a synthetic sysfs/DRM layout test for discovery + stats behavior. |
| platforms/lg200/test/CMakeLists.txt | Builds and links the LG200 synthetic resource test on Linux. |
| platforms/lg200/CMakeLists.txt | Adds the LG200 HAL library, CLI tool, install rules, and test subdir hook. |
| platforms/lg200/README.md | Documents build steps and the LG200 discovery/statistics API behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+175
to
+179
| const std::string vendor = ReadTextFile(device_path / "vendor"); | ||
| const std::string driver = ReadUeventValue(device_path, "DRIVER"); | ||
| const std::string pci_id = ReadUeventValue(device_path, "PCI_ID"); | ||
| const std::string model = pci_id.empty() ? card_name : pci_id; | ||
| if (!IsLg200Candidate(vendor, driver, model)) continue; |
Comment on lines
+31
to
+33
| // Enumerate DRM cards owned by the loonggpu kernel driver. Passing devices as | ||
| // NULL queries the required count. If the supplied array is too small, count | ||
| // is updated to the required size and kXSchedErrorInvalidValue is returned. |
Comment on lines
+26
to
+27
| - `Lg200DeviceEnumerate()` enumerates `cardN` nodes whose driver name starts | ||
| with `loonggpu` or whose product identity contains `LG200`. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/sys/class/drmusing theloonggpudriver identity;lg200_infofor runtime inspection;Scope
This PR contains device information retrieval only. It intentionally does not add an LG200
HwQueue,HwCommand, callback wrapper, scheduler policy, benchmark, model, or application demo.Generic application work can continue to use XSched's existing
HwCommandCreateCallbackAPI. Hardware-specific KCD queue deactivation is being prepared as a separate Level-2 follow-up after this discovery layer is reviewed.Build and test
cmake -S . -B build-lg200 \ -DPLATFORM_LG200=ON \ -DPLATFORM_OPENCL=ON \ -DBUILD_TEST=ON cmake --build build-lg200 --target lg200_info lg200_resource_test ./build-lg200/platforms/lg200/test/lg200_resource_testValidation
hallg200,lg200_info, andlg200_resource_testbuild with-Wall -Wextra -Werror;hal.hcompiles as C11;git diff --checkpasses.Validation run: https://github.com/guohuan78/xsched/actions/runs/30079872796
Runtime behavior
Lg200DeviceEnumerate()accepts theloonggpudriver name (or an explicit LG200 product identity) rather than treating the Loongson PCI vendor id alone as proof of a GPU. Statistics are optional: unavailable utilization is returned as-1.0, and unavailable memory counters as zero.