Skip to contentSkip to conversation

gpu: nova-core: Use bar1_resource_index() in NovaCoreApi::bar1_size()

PATCH Applied Alistair Popple 3 participants 3 messages Oct 1 – Oct 5

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpu: nova-core: Use bar1_resource_index() in NovaCoreApi::bar1_size()

bar1_size() reports the length of PCI resource 1 as the size of BAR1. That is only correct when BAR0 is a 32-bit BAR. On Blackwell, and on some Ampere GA100 and Hopper SKUs, BAR0 is 64-bit and takes resource slots 0 and 1, pushing BAR1 to slot 2. Slot 1 is then the upper half of BAR0 rather than a BAR of its own, so NOVA_GETPARAM_VRAM_BAR_SIZE reports the wrong size on those GPUs.

Probe handles this with the new bar1_resource_index(), which it uses to map BAR1, so use the same lookup here.

Fixes 7edc491f6fca ("drm: nova: Use nova-core to read VRAM_BAR_SIZE parameter")

---

Danilo,

Not sure how you want to take this, you could either take it as a standalone patch or fold it into my series as the pre-requisite change that introduced bar1_resource_index() 159427b21352 ("gpu: nova-core: mm:
Add BAR1 user interface") comes before my series in drm-rust-next.

- Alistair

---
 drivers/gpu/nova-core/api.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/nova-core/api.rs +3 -1
index f02c6c7c7e51..cc1d936b002c 100644
@@ -44,7 +44,9 @@ pub fn spec(&self) -> &Spec {
     /// Returns the size of the PCIe BAR used for accessing VRAM, typically
     /// BAR1.
     pub fn bar1_size(&self) -> Result<u64> {
-        self.pdev.resource_len(1)
+        let bar1 = crate::driver::bar1_resource_index(self.pdev)?;
+
+        self.pdev.resource_len(bar1)
     }
 }
 
Signature · 1 line
2.54.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 32 lines · Alistair Popple

bar1_size() reports the length of PCI resource 1 as the size of BAR1. That is only correct when BAR0 is a 32-bit BAR. On Blackwell, and on some Ampere GA100 and Hopper SKUs, BAR0 is 64-bit and takes resource slots 0 and 1, pushing BAR1 to slot 2. Slot 1 is then the upper half of BAR0 rather than a BAR of its own, so NOVA_GETPARAM_VRAM_BAR_SIZE reports the wrong size on those GPUs.

Probe handles this with the new bar1_resource_index(), which it uses to map BAR1, so use the same lookup here.

Fixes 7edc491f6fca ("drm: nova: Use nova-core to read VRAM_BAR_SIZE parameter")

---

Danilo,

Not sure how you want to take this, you could either take it as a standalone patch or fold it into my series as the pre-requisite change that introduced bar1_resource_index() 159427b21352 ("gpu: nova-core: mm:
Add BAR1 user interface") comes before my series in drm-rust-next.

- Alistair

---
 drivers/gpu/nova-core/api.rs | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/nova-core/api.rs +0 -0
index f02c6c7c7e51..cc1d936b002c 100644

drivers/gpu/nova-core/api.rs pub fn spec(&self) -> &Spec { · line 49

Quoted 7 lines
drivers/gpu/nova-core/api.rs +3 -1
@@ -44,7 +44,9 @@ pub fn spec(&self) -> &Spec {
     /// Returns the size of the PCIe BAR used for accessing VRAM, typically
     /// BAR1.
     pub fn bar1_size(&self) -> Result<u64> {
-        self.pdev.resource_len(1)
+        let bar1 = crate::driver::bar1_resource_index(self.pdev)?;
+
+        self.pdev.resource_len(bar1)

I guess at some point we will want an iterator on pci::Device that returns a BarInfo type or something? Zhi has some similar logic in his SR-IOV series (method vf_bars of [1]) and this seems to be a common mistake code makes when iterating BARs.

Just an idea for a future patch, this one is of course correct.

[1] https://lore.kernel.org/all/[email protected]/

maintainer Applied
#2 lore raw
In reply to Alistair Popple
Quoted 1 line · Alistair Popple

[PATCH] gpu: nova-core: Use bar1_resource_index() in NovaCoreApi::bar1_size()

Applied, thanks!

Branch: drm-rust-next
Tree: https://gitlab.freedesktop.org/drm/rust/kernel.git

[1/1] gpu: nova-core: Use bar1_resource_index() in NovaCoreApi::bar1_size()
commit: e56059016a87

[ Import the driver module. - Danilo ]

The patch will appear in the next linux-next integration (typically within 24 hours on weekdays).

The patch is queued up for the upcoming merge window for the next major kernel release.