Skip to content

Fix Linux graphics cards all reporting the same VRAM - #3555

Merged
dbwiddis merged 5 commits into
oshi:masterfrom
Krillsson:fix/lspci-slot-capture
Jul 31, 2026
Merged

dbwiddis merged 5 commits into
oshi:masterfrom
Krillsson:fix/lspci-slot-capture

Conversation

@Krillsson

@Krillsson Krillsson commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

On a Linux host with more than one graphics card, every card reports the same VRAM, DRM device path, driver and GPU metrics, and getVRam() is always 0. There are bugs inside LinuxGraphicsCard#getGraphicsCardsFromLspci that are causing this behavior:

1. The wrong lspci output format is requested

getGraphicsCardsFromLspci runs lspci -vnnm. The -vm selects lspci's obsolete machine-readable format, which is discouraged from being used by the documentation. While the code was most certainly written against output of the new format -vmm. The old format labels the slot: field Device: to stay backwards compatible. Meaning "Device:" will appear twice in the output. However the code looks for ":Slot"

Sample output:

Bad -vm
Device:	01:00.0
Class:	VGA compatible controller [0300]
Vendor:	NVIDIA Corporation [10de]
Device:	GP107GL [Quadro P400] [1cb3]
SVendor:	Dell [1028]
SDevice:	GP107GL [Quadro P400] [11be]
Rev:	a1
IOMMUGroup:	1
Good -vmm
Slot:	01:00.0
Class:	VGA compatible controller [0300]
Vendor:	NVIDIA Corporation [10de]
Device:	GP107GL [Quadro P400] [1cb3]
SVendor:	Dell [1028]
SDevice:	GP107GL [Quadro P400] [11be]
Rev:	a1
IOMMUGroup:	1

2. The slot is discarded even when present.

"Slot:" precedes "Class:" within a record, and the "Class:" branch resets lookupDevice = null, wiping the value parsed one line earlier. lookupDevice remains null, which skips the VRAM lookup later down in the method.

3. The class filter substring-matches VGA

However on my server, I have a device with the value "Class: Non-VGA unclassified device [0000]". And this gets added to the mix. That's why I introduced the isDisplayClass method, which first sees if the PCI device base class is 0x03. There is a "The PCI Code and ID Assignment Specification" document that specifies these.

I verified my changes by including a local build of OSHI into my project and ran it on my server.

GraphQL output before
{
  "data": {
    "system": {
      "gpus": [
        {
          "id": "0xa135",
          "name": "100 Series/C230 Series Chipset Family Integrated Sensor Hub",
          "vendor": "Intel Corporation (0x8086)",
          "versionInfo": "Rev:\t31",
          "vRamBytes": "0",
          "metrics": {
            "id": "0xa135",
            "name": "100 Series/C230 Series Chipset Family Integrated Sensor Hub",
            "coreLoad": 0,
            "vramUsedBytes": "60817408",
            "vramTotalBytes": "0",
            "temperature": 45,
            "fanPercent": 37,
            "powerDraw": -1,
            "coreClockMhz": "139",
            "memoryClockMhz": "405"
          }
        },
        {
          "id": "0x1cb3",
          "name": "GP107GL [Quadro P400]",
          "vendor": "NVIDIA Corporation (0x10de)",
          "versionInfo": "Rev:\ta1",
          "vRamBytes": "0",
          "metrics": {
            "id": "0x1cb3",
            "name": "GP107GL [Quadro P400]",
            "coreLoad": 0,
            "vramUsedBytes": "60817408",
            "vramTotalBytes": "0",
            "temperature": 45,
            "fanPercent": 37,
            "powerDraw": -1,
            "coreClockMhz": "139",
            "memoryClockMhz": "405"
          }
        },
        {
          "id": "0x2000",
          "name": "ASPEED Graphics Family",
          "vendor": "ASPEED Technology, Inc. (0x1a03)",
          "versionInfo": "Rev:\t30",
          "vRamBytes": "0",
          "metrics": {
            "id": "0x2000",
            "name": "ASPEED Graphics Family",
            "coreLoad": 0,
            "vramUsedBytes": "60817408",
            "vramTotalBytes": "0",
            "temperature": 45,
            "fanPercent": 37,
            "powerDraw": -1,
            "coreClockMhz": "139",
            "memoryClockMhz": "405"
          }
        }
      ]
    }
  }
}
GraphQL output after
{
  "data": {
    "system": {
      "gpus": [
        {
          "id": "0x1cb3",
          "name": "GP107GL [Quadro P400]",
          "vendor": "NVIDIA Corporation (0x10de)",
          "versionInfo": "Rev:\ta1",
          "vRamBytes": "301989888",
          "metrics": {
            "id": "0x1cb3",
            "name": "GP107GL [Quadro P400]",
            "coreLoad": 0,
            "vramUsedBytes": "60817408",
            "vramTotalBytes": "301989888",
            "temperature": 43,
            "fanPercent": 34,
            "powerDraw": -1,
            "coreClockMhz": "139",
            "memoryClockMhz": "405"
          }
        },
        {
          "id": "0x2000",
          "name": "ASPEED Graphics Family",
          "vendor": "ASPEED Technology, Inc. (0x1a03)",
          "versionInfo": "Rev:\t30",
          "vRamBytes": "0",
          "metrics": {
            "id": "0x2000",
            "name": "ASPEED Graphics Family",
            "coreLoad": 0,
            "vramUsedBytes": "-1",
            "vramTotalBytes": "0",
            "temperature": -1,
            "fanPercent": -1,
            "powerDraw": -1,
            "coreClockMhz": "-1",
            "memoryClockMhz": "-1"
          }
        }
      ]
    }
  }
}

I can also add that the WindowsGraphicsCard seem to behave correctly.

Summary by CodeRabbit

Bug Fixes

  • Improved Linux graphics card detection and reporting.
  • More accurately reports VRAM, DRM devices, GPU metrics, and PCI slot associations.
  • Improved compatibility with varied hardware and PCI controller formats.
  • Filters out non-graphics and unclassified PCI devices to prevent incorrect results.
  • Prevented graphics information from being incorrectly attributed to another card when matching hardware details are unavailable.

Copilot AI review requested due to automatic review settings July 30, 2026 13:11
@coderabbitai

coderabbitai Bot commented Jul 30, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Linux graphics-card discovery now uses extended lspci output. The parser detects display controllers by PCI class, preserves PCI slot correlation, and prevents incorrect DRM fallback. Tests cover parsing, filtering, state reset, and lookup behavior.

Changes

Linux graphics parsing

Layer / File(s) Summary
Enhanced lspci parsing
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java
Uses lspci -vnnmm, detects display controllers by numeric class code or text prefix, preserves PCI slots, resets card state, and returns empty metadata for unmatched slots.
Parsing validation and release note
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java, CHANGELOG.md
Adds coverage for slot-specific lookups, class filtering, numeric and textual detection, state reset, malformed records, and unmatched DRM slots. Records the fix in the changelog.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Sequence Diagram(s)

sequenceDiagram
  participant lspci
  participant LinuxGraphicsCard
  participant findDrmInfo
  lspci->>LinuxGraphicsCard: provide extended machine-readable records
  LinuxGraphicsCard->>LinuxGraphicsCard: classify display controller and capture PCI slot
  LinuxGraphicsCard->>findDrmInfo: request DRM data for PCI slot
  findDrmInfo-->>LinuxGraphicsCard: return matching or empty metadata
Loading

Possibly related PRs

  • oshi/oshi#3202: Both PRs modify Linux graphics-card lspci parsing and VRAM/DRM lookup behavior.
  • oshi/oshi#3514: Both PRs modify and test the same Linux graphics-card parsing and DRM lookup code.

Suggested reviewers: copilot, dbwiddis

Poem

A rabbit checks each PCI slot,
While lspci lists each graphics plot.
Display classes guide the way,
And stale slots no longer stay.
VRAM and DRM match each card.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly identifies the main fix: preventing Linux graphics cards from incorrectly reporting the same VRAM.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@codecov

codecov Bot commented Jul 30, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.33333% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.33%. Comparing base (ea3c16f) to head (0e6ad99).
⚠️ Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
...dware/common/platform/linux/LinuxGraphicsCard.java 83.33% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #3555      +/-   ##
============================================
- Coverage     79.34%   79.33%   -0.01%     
+ Complexity     4019     4018       -1     
============================================
  Files           706      706              
  Lines         24256    24264       +8     
  Branches       4053     4057       +4     
============================================
+ Hits          19245    19251       +6     
- Misses         2822     2824       +2     
  Partials       2189     2189              
Flag Coverage Δ
linux 36.79% <83.33%> (+0.04%) ⬆️
macos 37.67% <75.00%> (-0.03%) ⬇️
windows 44.60% <75.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java`:
- Line 202: Update the parser-input Javadoc associated with
getGraphicsCardsFromLspci to document lspci -vnnmm instead of lspci -vnnm,
matching the command passed by ExecutingCommand.runNative.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 15cd9f9b-c4cd-4fbf-861d-45313d971d18

📥 Commits

Reviewing files that changed from the base of the PR and between ea3c16f and 6b9679b.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java
📜 Review details
⏰ Context from checks skipped due to timeout. (7)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Analyze (java)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java
📚 Learning: 2026-07-30T00:35:22.638Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3547
File: oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdFirmware.java:82-82
Timestamp: 2026-07-30T00:35:22.638Z
Learning: In OSHI, treat changes as “API-breaking” only when they affect classes (or relevant API surface) annotated with `PublicAPI`. Public classes/members that are not annotated with `PublicAPI` should be reviewed as internal implementation details, even if they are public (e.g., classes like `oshi.hardware.common.platform.unix.BsdFirmware`). Also, respect intentional visibility decisions used for tests—e.g., methods like `BsdFirmware.parseDmesg(List<String>)` may be intentionally package-private to support tests within the same package; avoid widening visibility or altering signatures unless the related `PublicAPI` contract requires it.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java
🔇 Additional comments (3)
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java (1)

224-239: LGTM!

Also applies to: 270-273, 370-387

oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java (1)

15-15: LGTM!

Also applies to: 247-316

CHANGELOG.md (1)

11-11: LGTM!

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Updates the Linux graphics-card discovery path to correctly correlate each GPU with its own PCI slot, ensuring per-card VRAM, DRM device, driver, and metrics are reported accurately on multi-GPU systems.

Changes:

  • Switch lspci invocation to the stable machine-readable format that includes the Slot: field.
  • Preserve and propagate the per-record PCI slot through VRAM and DRM lookups, avoiding cross-GPU mixing.
  • Tighten GPU detection by identifying display controllers via PCI base class 0x03 instead of substring-matching "VGA".

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java Fixes slot parsing/propagation, updates lspci flags, and adds PCI-class-based display detection.
oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java Adds regression tests covering slot correlation, non-display filtering, and display-class detection.
CHANGELOG.md Adds an entry describing the Linux multi-GPU VRAM/metrics fix.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@dbwiddis dbwiddis left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for finding this bug and the detailed PR! A few suggestions inline.

In addition, this also surfaces a latent bug in findDrmInfo (LinuxGraphicsCard.java:435-436). (I can't comment there because it's out-of-diff.)

It was already broken; with the slot fix it's now broken differently. Happy to have this as a follow-up PR if you want to keep this one scoped, but should be a quick fix.

Before your fix, pciSlot was always null on the lspci path, so only the first card was reachable; that's the "all cards report the same DRM device, driver and metrics" symptom in your description.

Now that slots are correct, the matching return at line 432 is the common case.

But the final fallback if the slot doesn't match (line 436) may return some other result giving the same "same info for every card" result.

That's reachable for a GPU bound to vfio-pci for VM passthrough (class 0300 in lspci, no /sys/class/drm/cardN), or any display device with no driver bound.

Suggest gating the fallback on having had nothing to match on:

  if (pciSlot != null) {
      // We had a slot to match on and no DRM card claimed it, so this card has no DRM node (e.g. a GPU bound to
      // vfio-pci). Returning another card's path would attribute that card's driver and metrics to this one.
      return new Triplet<>("", "", "");
  }
  // No slot to match on: fall back to the first card with a driver symlink
  return firstWithDriver != null ? firstWithDriver : new Triplet<>("", "", "");

An empty triplet is well-handled downstream: LinuxGpuStats checks drmDevicePath.isEmpty() and resolveHwmonPath returns "", so every metric reports -1 (unavailable) rather than a different card's reading, and findNvmlDevice still falls back to nvmlFindDeviceByName when pciBusId is empty. It also matches the cards == null early return just above.

This does mean testFindDrmInfoFallsBackToFirstDriver needs splitting: it passes "99:00.0" against a tree holding only 0000:01:00.0 and asserts amdgpu, which is asserting the old behavior. testFindDrmInfoNullPciSlotFallback already covers row 1 and can stay as-is.

Comment on lines +274 to +288
List<String> mixed = Arrays.asList("Slot:\t00:11.0", "Class:\tSignal processing controller [1180]",
"Vendor:\tIntel Corporation [8086]", "Device:\tIntegrated Sensor Hub [a135]", "Rev:\t31", "",
"Slot:\t01:00.0", "Class:\tVGA compatible controller [0300]", "Vendor:\tNVIDIA Corporation [10de]",
"Device:\tGP107GL [Quadro P400] [1cb3]", "Rev:\ta1", "");

List<String> drmSlots = new ArrayList<>();
List<GraphicsCard> cards = LinuxGraphicsCard.getGraphicsCardsFromLspci(mixed, STUB_FACTORY, NO_VRAM, slot -> {
drmSlots.add(slot);
return new Triplet<>("", "", "");
});

assertThat(cards.size(), is(1));
assertThat(cards.get(0).getDeviceId(), is("0x1cb3"));
assertThat(drmSlots, is(Collections.singletonList("01:00.0")));
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This and testGetGraphicsCardsFromLspciIgnoresNonVgaUnclassifiedDevice (line 305) differ only in the non-display record's class — 1180 vs 0000 — and in whether they assert on the DRM slots list. The 0000 case is already covered directly by testIsDisplayClass.

Suggest one fixture carrying both non-display records, which also asserts neither reaches the DRM lookup. If you take this, delete testGetGraphicsCardsFromLspciIgnoresNonVgaUnclassifiedDevice (lines 303-316, including its preceding @Test).

Suggested change
List<String> mixed = Arrays.asList("Slot:\t00:11.0", "Class:\tSignal processing controller [1180]",
"Vendor:\tIntel Corporation [8086]", "Device:\tIntegrated Sensor Hub [a135]", "Rev:\t31", "",
"Slot:\t01:00.0", "Class:\tVGA compatible controller [0300]", "Vendor:\tNVIDIA Corporation [10de]",
"Device:\tGP107GL [Quadro P400] [1cb3]", "Rev:\ta1", "");
List<String> drmSlots = new ArrayList<>();
List<GraphicsCard> cards = LinuxGraphicsCard.getGraphicsCardsFromLspci(mixed, STUB_FACTORY, NO_VRAM, slot -> {
drmSlots.add(slot);
return new Triplet<>("", "", "");
});
assertThat(cards.size(), is(1));
assertThat(cards.get(0).getDeviceId(), is("0x1cb3"));
assertThat(drmSlots, is(Collections.singletonList("01:00.0")));
}
// PCI class 0x0000 renders as "Non-VGA unclassified device", which contains "VGA"; 0x1180 is a signal
// processing controller. Neither is a graphics card and neither may reach the DRM lookup.
List<String> mixed = Arrays.asList("Slot:\t00:13.0", "Class:\tNon-VGA unclassified device [0000]",
"Vendor:\tIntel Corporation [8086]",
"Device:\t100 Series/C230 Series Chipset Family Integrated Sensor Hub [a135]", "Rev:\t31", "",
"Slot:\t00:11.0", "Class:\tSignal processing controller [1180]", "Vendor:\tIntel Corporation [8086]",
"Device:\tIntegrated Sensor Hub [a135]", "Rev:\t31", "", "Slot:\t01:00.0",
"Class:\tVGA compatible controller [0300]", "Vendor:\tNVIDIA Corporation [10de]",
"Device:\tGP107GL [Quadro P400] [1cb3]", "Rev:\ta1", "");
List<String> drmSlots = new ArrayList<>();
List<GraphicsCard> cards = LinuxGraphicsCard.getGraphicsCardsFromLspci(mixed, STUB_FACTORY, NO_VRAM, slot -> {
drmSlots.add(slot);
return new Triplet<>("", "", "");
});
assertThat(cards.size(), is(1));
assertThat(cards.get(0).getDeviceId(), is("0x1cb3"));
assertThat(drmSlots, is(Collections.singletonList("01:00.0")));
}

Comment on lines +292 to +301
assertThat(LinuxGraphicsCard.isDisplayClass("VGA compatible controller [0300]"), is(true));
assertThat(LinuxGraphicsCard.isDisplayClass("3D controller [0302]"), is(true));
assertThat(LinuxGraphicsCard.isDisplayClass("Display controller [0380]"), is(true));
// Contains "VGA" but is PCI class 0x0000, not a graphics card
assertThat(LinuxGraphicsCard.isDisplayClass("Non-VGA unclassified device [0000]"), is(false));
assertThat(LinuxGraphicsCard.isDisplayClass("Signal processing controller [1180]"), is(false));
assertThat(LinuxGraphicsCard.isDisplayClass("Host bridge [0600]"), is(false));
// Without numeric class codes, fall back to the class name
assertThat(LinuxGraphicsCard.isDisplayClass("VGA compatible controller"), is(true));
assertThat(LinuxGraphicsCard.isDisplayClass("Non-VGA unclassified device"), is(false));

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Codecov flags 4 partials on this PR; two are the untested branches of pair != null && pair.getB().length() >= 2 at LinuxGraphicsCard.java:382. A few more cases close them, and 0301 documents the newly-included XGA subclass:

Suggested change
assertThat(LinuxGraphicsCard.isDisplayClass("VGA compatible controller [0300]"), is(true));
assertThat(LinuxGraphicsCard.isDisplayClass("3D controller [0302]"), is(true));
assertThat(LinuxGraphicsCard.isDisplayClass("Display controller [0380]"), is(true));
// Contains "VGA" but is PCI class 0x0000, not a graphics card
assertThat(LinuxGraphicsCard.isDisplayClass("Non-VGA unclassified device [0000]"), is(false));
assertThat(LinuxGraphicsCard.isDisplayClass("Signal processing controller [1180]"), is(false));
assertThat(LinuxGraphicsCard.isDisplayClass("Host bridge [0600]"), is(false));
// Without numeric class codes, fall back to the class name
assertThat(LinuxGraphicsCard.isDisplayClass("VGA compatible controller"), is(true));
assertThat(LinuxGraphicsCard.isDisplayClass("Non-VGA unclassified device"), is(false));
assertThat(LinuxGraphicsCard.isDisplayClass("VGA compatible controller [0300]"), is(true));
assertThat(LinuxGraphicsCard.isDisplayClass("XGA compatible controller [0301]"), is(true));
assertThat(LinuxGraphicsCard.isDisplayClass("3D controller [0302]"), is(true));
assertThat(LinuxGraphicsCard.isDisplayClass("Display controller [0380]"), is(true));
// Contains "VGA" but is PCI class 0x0000, not a graphics card
assertThat(LinuxGraphicsCard.isDisplayClass("Non-VGA unclassified device [0000]"), is(false));
assertThat(LinuxGraphicsCard.isDisplayClass("Signal processing controller [1180]"), is(false));
assertThat(LinuxGraphicsCard.isDisplayClass("Host bridge [0600]"), is(false));
// Without numeric class codes, fall back to the class name
assertThat(LinuxGraphicsCard.isDisplayClass("VGA compatible controller"), is(true));
assertThat(LinuxGraphicsCard.isDisplayClass("3D controller"), is(true));
assertThat(LinuxGraphicsCard.isDisplayClass("Non-VGA unclassified device"), is(false));
// A bracket group too short to hold a base class falls through to the name check
assertThat(LinuxGraphicsCard.isDisplayClass("Bogus controller [3]"), is(false));

Comment thread CHANGELOG.md Resolved
Comment on lines +270 to +273
if (split.length < 2) {
// Record boundary; the next record must supply its own Slot line
slot = null;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

See comment on the test: given the first line of the new record is guaranteed to be Slot this doesn't actually change behavior. Harmless but useless.

Co-authored-by: Daniel Widdis <[email protected]>
Copilot AI review requested due to automatic review settings July 31, 2026 08:54

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

Suppressed comments (1)

oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java:202

  • The Javadoc still says the input is from lspci -vnnm, but this method is now fed lspci -vnnmm output. This mismatch can confuse future changes/debugging (and the Slot: field behavior differs between formats).
        return getGraphicsCardsFromLspci(ExecutingCommand.runNative("lspci -vnnmm"), factory,

Copilot AI review requested due to automatic review settings July 31, 2026 09:33

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In
`@oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java`:
- Around line 431-436: Update the findDrmInfo Javadoc to reflect that an
unmatched non-null pciSlot returns empty DRM metadata rather than falling back
to the first card; document the first-card fallback only for the pciSlot == null
case.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 66952c2a-dcdc-49d8-a34a-1584e16c6a57

📥 Commits

Reviewing files that changed from the base of the PR and between cd65a39 and 0e6ad99.

📒 Files selected for processing (2)
  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java
  • oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java
📜 Review details
⏰ Context from checks skipped due to timeout. (8)
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Test JDK 25, ubuntu-latest (+ JNA==FFM)
  • GitHub Check: Analyze (java)
  • GitHub Check: Test JDK 26, ubuntu-latest
  • GitHub Check: Test JDK 21, ubuntu-latest
  • GitHub Check: Test JDK 25, windows-latest (+ JNA==FFM)
  • GitHub Check: Test JDK 25, macos-latest (+ JNA==FFM)
  • GitHub Check: Lint (Spotless, Checkstyle, ForbiddenAPIs, Javadoc)
🧰 Additional context used
🧠 Learnings (3)
📚 Learning: 2026-04-12T19:22:09.716Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3149
File: oshi-common/src/main/java/oshi/hardware/common/platform/mac/MacCentralProcessor.java:159-163
Timestamp: 2026-04-12T19:22:09.716Z
Learning: When reviewing OSHI hardware platform code that uses or implements `CentralProcessor`/`PhysicalProcessor.getEfficiency()`, remember the API’s counterintuitive semantics: a *higher* efficiency-class value indicates *greater performance* (lower efficiency). P-cores/“performance cores” should therefore have higher values (e.g., 1) than E-cores/“efficiency cores” (e.g., 0), as documented in the `CentralProcessor` Javadoc. Do not flag code as incorrect solely because ARM_P_CORES or Intel P-cores are assigned higher efficiency values.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java
📚 Learning: 2026-07-06T19:25:59.225Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3432
File: oshi-common/src/main/java/oshi/util/ExceptionUtil.java:26-56
Timestamp: 2026-07-06T19:25:59.225Z
Learning: In this repo’s SLF4J 1.x-compatible logging code, do not flag cases where a logger call uses SLF4J 1.6+ implicit-cause handling—e.g., `log.error("...{}", value, t)` (or similar with a single `{}` placeholder) where `t` is passed as the final/trailing argument. SLF4J will attach `t` as the log event’s cause with the full stack trace; this is equivalent to SLF4J 2.x’s fluent `atLevel(...).setCause(t).log(...)` and is intentionally used to preserve SLF4J 1.x runtime compatibility.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java
📚 Learning: 2026-07-30T00:35:22.638Z
Learnt from: dbwiddis
Repo: oshi/oshi PR: 3547
File: oshi-common/src/main/java/oshi/hardware/common/platform/unix/BsdFirmware.java:82-82
Timestamp: 2026-07-30T00:35:22.638Z
Learning: In OSHI, treat changes as “API-breaking” only when they affect classes (or relevant API surface) annotated with `PublicAPI`. Public classes/members that are not annotated with `PublicAPI` should be reviewed as internal implementation details, even if they are public (e.g., classes like `oshi.hardware.common.platform.unix.BsdFirmware`). Also, respect intentional visibility decisions used for tests—e.g., methods like `BsdFirmware.parseDmesg(List<String>)` may be intentionally package-private to support tests within the same package; avoid widening visibility or altering signatures unless the related `PublicAPI` contract requires it.

Applied to files:

  • oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java
🔇 Additional comments (2)
oshi-common/src/main/java/oshi/hardware/common/platform/linux/LinuxGraphicsCard.java (1)

202-280: LGTM!

Also applies to: 366-383

oshi-common/src/test/java/oshi/hardware/common/platform/linux/LinuxGraphicsCardTest.java (1)

36-44: LGTM!

Also applies to: 58-58, 72-72, 107-116, 180-180, 195-225, 228-344, 353-355, 364-364, 377-377, 388-388, 402-410, 435-435

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@dbwiddis
dbwiddis merged commit ef774f3 into oshi:master Jul 31, 2026
15 of 16 checks passed
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