From d35aa6f444a71454fc0ac6865c59fb7fd1582426 Mon Sep 17 00:00:00 2001 From: Faith Ekstrand Date: Wed, 23 Jul 2025 16:47:16 -0400 Subject: [PATCH] nil: Add support for Blackwell 8 and 16-bit modifiers Backport-to: 25.2 Reviewed-by: James Jones Part-of: (cherry picked from commit f1cb63a21d4b1a8f6903ecec2ebee4c02c129c68) --- .pick_status.json | 2 +- src/nouveau/nil/modifiers.rs | 24 ++++++++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index ca149705136..5bc0fac3786 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -894,7 +894,7 @@ "description": "nil: Add support for Blackwell 8 and 16-bit modifiers", "nominated": true, "nomination_type": 4, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/nouveau/nil/modifiers.rs b/src/nouveau/nil/modifiers.rs index 2e99f559362..74ac4cdabea 100644 --- a/src/nouveau/nil/modifiers.rs +++ b/src/nouveau/nil/modifiers.rs @@ -35,6 +35,8 @@ impl TryFrom for GOBKindVersion { pub enum SectorLayout { TegraK1 = 0, Desktop = 1, + Blackwell8Bpp = 2, + Blackwell16Bpp = 3, } impl TryFrom for SectorLayout { @@ -44,6 +46,8 @@ impl TryFrom for SectorLayout { match sector_layout { 0 => Ok(SectorLayout::TegraK1), 1 => Ok(SectorLayout::Desktop), + 2 => Ok(SectorLayout::Blackwell8Bpp), + 3 => Ok(SectorLayout::Blackwell16Bpp), _ => Err("Invalid gob/kind version"), } } @@ -55,7 +59,7 @@ struct GOBTypeModifierInfo { sector_layout: SectorLayout, } -const GOB_TYPE_MODIFIER_INFOS: [GOBTypeModifierInfo; 2] = [ +const GOB_TYPE_MODIFIER_INFOS: [GOBTypeModifierInfo; 4] = [ GOBTypeModifierInfo { gob_type: GOBType::FermiColor, gob_kind_version: GOBKindVersion::Fermi, @@ -66,6 +70,16 @@ const GOB_TYPE_MODIFIER_INFOS: [GOBTypeModifierInfo; 2] = [ gob_kind_version: GOBKindVersion::Turing, sector_layout: SectorLayout::Desktop, }, + GOBTypeModifierInfo { + gob_type: GOBType::Blackwell8Bit, + gob_kind_version: GOBKindVersion::Turing, + sector_layout: SectorLayout::Blackwell8Bpp, + }, + GOBTypeModifierInfo { + gob_type: GOBType::Blackwell16Bit, + gob_kind_version: GOBKindVersion::Turing, + sector_layout: SectorLayout::Blackwell16Bpp, + }, ]; impl GOBType { @@ -144,7 +158,7 @@ impl TryFrom for BlockLinearModifier { } else if !bv.get_bit(4) { Err("modifier is not block linear") } else if bv.get_bit_range_u64(5..12) != 0 - || bv.get_bit_range_u64(26..56) != 0 + || bv.get_bit_range_u64(28..56) != 0 { Err("unknown reserved bits") } else { @@ -167,7 +181,7 @@ impl BlockLinearModifier { bv.set_bit(4, true); // Must be 1, to indicate block-linear layout. bv.set_field(12..20, pte_kind); bv.set_field(20..22, gob_kind_version as u8); - bv.set_field(22..23, sector_layout as u8); + bv.set_field2(22..23, 26..28, sector_layout as u8); bv.set_field(23..26, compression_type as u8); bv.set_field(56..64, DRM_FORMAT_MOD_VENDOR_NVIDIA); BlockLinearModifier { drm_modifier } @@ -190,7 +204,9 @@ impl BlockLinearModifier { pub fn sector_layout(&self) -> SectorLayout { let bv = BitView::new(&self.drm_modifier); - bv.get_bit_range_u64(22..23).try_into().unwrap() + (bv.get_bit_range_u64(22..23) | (bv.get_bit_range_u64(26..28) << 1)) + .try_into() + .unwrap() } pub fn compression_type(&self) -> CompressionType {