mirror of
https://github.com/torvalds/linux.git
synced 2025-12-07 20:06:24 +00:00
Pull drm updates from Dave Airlie:
"Highlights:
- Intel xe enable Panthor Lake, started adding WildCat Lake
- amdgpu has a bunch of reset improvments along with the usual IP
updates
- msm got VM_BIND support which is important for vulkan sparse memory
- more drm_panic users
- gpusvm common code to handle a bunch of core SVM work outside
drivers.
Detail summary:
Changes outside drm subdirectory:
- 'shrink_shmem_memory()' for better shmem/hibernate interaction
- Rust support infrastructure:
- make ETIMEDOUT available
- add size constants up to SZ_2G
- add DMA coherent allocation bindings
- mtd driver for Intel GPU non-volatile storage
- i2c designware quirk for Intel xe
core:
- atomic helpers: tune enable/disable sequences
- add task info to wedge API
- refactor EDID quirks
- connector: move HDR sink to drm_display_info
- fourcc: half-float and 32-bit float formats
- mode_config: pass format info to simplify
dma-buf:
- heaps: Give CMA heap a stable name
ci:
- add device tree validation and kunit
displayport:
- change AUX DPCD access probe address
- add quirk for DPCD probe
- add panel replay definitions
- backlight control helpers
fbdev:
- make CONFIG_FIRMWARE_EDID available on all arches
fence:
- fix UAF issues
format-helper:
- improve tests
gpusvm:
- introduce devmem only flag for allocation
- add timeslicing support to GPU SVM
ttm:
- improve eviction
sched:
- tracing improvements
- kunit improvements
- memory leak fixes
- reset handling improvements
color mgmt:
- add hardware gamma LUT handling helpers
bridge:
- add destroy hook
- switch to reference counted drm_bridge allocations
- tc358767: convert to devm_drm_bridge_alloc
- improve CEC handling
panel:
- switch to reference counter drm_panel allocations
- fwnode panel lookup
- Huiling hl055fhv028c support
- Raspberry Pi 7" 720x1280 support
- edp: KDC KD116N3730A05, N160JCE-ELL CMN, N116BCJ-EAK
- simple: AUO P238HAN01
- st7701: Winstar wf40eswaa6mnn0
- visionox: rm69299-shift
- Renesas R61307, Renesas R69328 support
- DJN HX83112B
hdmi:
- add CEC handling
- YUV420 output support
xe:
- WildCat Lake support
- Enable PanthorLake by default
- mark BMG as SRIOV capable
- update firmware recommendations
- Expose media OA units
- aux-bux support for non-volatile memory
- MTD intel-dg driver for non-volatile memory
- Expose fan control and voltage regulator in sysfs
- restructure migration for multi-device
- Restore GuC submit UAF fix
- make GEM shrinker drm managed
- SRIOV VF Post-migration recovery of GGTT nodes
- W/A additions/reworks
- Prefetch support for svm ranges
- Don't allocate managed BO for each policy change
- HWMON fixes for BMG
- Create LRC BO without VM
- PCI ID updates
- make SLPC debugfs files optional
- rework eviction rejection of bound external BOs
- consolidate PAT programming logic for pre/post Xe2
- init changes for flicker-free boot
- Enable GuC Dynamic Inhibit Context switch
i915:
- drm_panic support for i915/xe
- initial flip queue off by default for LNL/PNL
- Wildcat Lake Display support
- Support for DSC fractional link bpp
- Support for simultaneous Panel Replay and Adaptive sync
- Support for PTL+ double buffer LUT
- initial PIPEDMC event handling
- drm_panel_follower support
- DPLL interface renames
- allocate struct intel_display dynamically
- flip queue preperation
- abstract DRAM detection better
- avoid GuC scheduling stalls
- remove DG1 force probe requirement
- fix MEI interrupt handler on RT kernels
- use backlight control helpers for eDP
- more shared display code refactoring
amdgpu:
- add userq slot to INFO ioctl
- SR-IOV hibernation support
- Suspend improvements
- Backlight improvements
- Use scaling for non-native eDP modes
- cleaner shader updates for GC 9.x
- Remove fence slab
- SDMA fw checks for userq support
- RAS updates
- DMCUB updates
- DP tunneling fixes
- Display idle D3 support
- Per queue reset improvements
- initial smartmux support
amdkfd:
- enable KFD on loongarch
- mtype fix for ext coherent system memory
radeon:
- CS validation additional GL extensions
- drop console lock during suspend/resume
- bump driver version
msm:
- VM BIND support
- CI: infrastructure updates
- UBWC single source of truth
- decouple GPU and KMS support
- DP: rework I/O accessors
- DPU: SM8750 support
- DSI: SM8750 support
- GPU: X1-45 support and speedbin support for X1-85
- MDSS: SM8750 support
nova:
- register! macro improvements
- DMA object abstraction
- VBIOS parser + fwsec lookup
- sysmem flush page support
- falcon: generic falcon boot code and HAL
- FWSEC-FRTS: fb setup and load/execute
ivpu:
- Add Wildcat Lake support
- Add turbo flag
ast:
- improve hardware generations implementation
imx:
- IMX8qxq Display Controller support
lima:
- Rockchip RK3528 GPU support
nouveau:
- fence handling cleanup
panfrost:
- MT8370 support
- bo labeling
- 64-bit register access
qaic:
- add RAS support
rockchip:
- convert inno_hdmi to a bridge
rz-du:
- add RZ/V2H(P) support
- MIPI-DSI DCS support
sitronix:
- ST7567 support
sun4i:
- add H616 support
tidss:
- add TI AM62L support
- AM65x OLDI bridge support
bochs:
- drm panic support
vkms:
- YUV and R* format support
- use faux device
vmwgfx:
- fence improvements
hyperv:
- move out of simple
- add drm_panic support"
* tag 'drm-next-2025-07-30' of https://gitlab.freedesktop.org/drm/kernel: (1479 commits)
drm/tidss: oldi: convert to devm_drm_bridge_alloc() API
drm/tidss: encoder: convert to devm_drm_bridge_alloc()
drm/amdgpu: move reset support type checks into the caller
drm/amdgpu/sdma7: re-emit unprocessed state on ring reset
drm/amdgpu/sdma6: re-emit unprocessed state on ring reset
drm/amdgpu/sdma5.2: re-emit unprocessed state on ring reset
drm/amdgpu/sdma5: re-emit unprocessed state on ring reset
drm/amdgpu/gfx12: re-emit unprocessed state on ring reset
drm/amdgpu/gfx11: re-emit unprocessed state on ring reset
drm/amdgpu/gfx10: re-emit unprocessed state on ring reset
drm/amdgpu/gfx9.4.3: re-emit unprocessed state on kcq reset
drm/amdgpu/gfx9: re-emit unprocessed state on kcq reset
drm/amdgpu: Add WARN_ON to the resource clear function
drm/amd/pm: Use cached metrics data on SMUv13.0.6
drm/amd/pm: Use cached data for min/max clocks
gpu: nova-core: fix bounds check in PmuLookupTableEntry::new
drm/amdgpu: Replace HQD terminology with slots naming
drm/amdgpu: Add user queue instance count in HW IP info
drm/amd/amdgpu: Add helper functions for isp buffers
drm/amd/amdgpu: Initialize swnode for ISP MFD device
...
313 lines
8.7 KiB
Rust
313 lines
8.7 KiB
Rust
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
use kernel::{device, devres::Devres, error::code::*, pci, prelude::*, sync::Arc};
|
|
|
|
use crate::driver::Bar0;
|
|
use crate::falcon::{gsp::Gsp, sec2::Sec2, Falcon};
|
|
use crate::fb::FbLayout;
|
|
use crate::fb::SysmemFlush;
|
|
use crate::firmware::fwsec::{FwsecCommand, FwsecFirmware};
|
|
use crate::firmware::{Firmware, FIRMWARE_VERSION};
|
|
use crate::gfw;
|
|
use crate::regs;
|
|
use crate::util;
|
|
use crate::vbios::Vbios;
|
|
use core::fmt;
|
|
|
|
macro_rules! define_chipset {
|
|
({ $($variant:ident = $value:expr),* $(,)* }) =>
|
|
{
|
|
/// Enum representation of the GPU chipset.
|
|
#[derive(fmt::Debug, Copy, Clone, PartialOrd, Ord, PartialEq, Eq)]
|
|
pub(crate) enum Chipset {
|
|
$($variant = $value),*,
|
|
}
|
|
|
|
impl Chipset {
|
|
pub(crate) const ALL: &'static [Chipset] = &[
|
|
$( Chipset::$variant, )*
|
|
];
|
|
|
|
pub(crate) const NAMES: [&'static str; Self::ALL.len()] = [
|
|
$( util::const_bytes_to_str(
|
|
util::to_lowercase_bytes::<{ stringify!($variant).len() }>(
|
|
stringify!($variant)
|
|
).as_slice()
|
|
), )*
|
|
];
|
|
}
|
|
|
|
// TODO[FPRI]: replace with something like derive(FromPrimitive)
|
|
impl TryFrom<u32> for Chipset {
|
|
type Error = kernel::error::Error;
|
|
|
|
fn try_from(value: u32) -> Result<Self, Self::Error> {
|
|
match value {
|
|
$( $value => Ok(Chipset::$variant), )*
|
|
_ => Err(ENODEV),
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
define_chipset!({
|
|
// Turing
|
|
TU102 = 0x162,
|
|
TU104 = 0x164,
|
|
TU106 = 0x166,
|
|
TU117 = 0x167,
|
|
TU116 = 0x168,
|
|
// Ampere
|
|
GA100 = 0x170,
|
|
GA102 = 0x172,
|
|
GA103 = 0x173,
|
|
GA104 = 0x174,
|
|
GA106 = 0x176,
|
|
GA107 = 0x177,
|
|
// Ada
|
|
AD102 = 0x192,
|
|
AD103 = 0x193,
|
|
AD104 = 0x194,
|
|
AD106 = 0x196,
|
|
AD107 = 0x197,
|
|
});
|
|
|
|
impl Chipset {
|
|
pub(crate) fn arch(&self) -> Architecture {
|
|
match self {
|
|
Self::TU102 | Self::TU104 | Self::TU106 | Self::TU117 | Self::TU116 => {
|
|
Architecture::Turing
|
|
}
|
|
Self::GA100 | Self::GA102 | Self::GA103 | Self::GA104 | Self::GA106 | Self::GA107 => {
|
|
Architecture::Ampere
|
|
}
|
|
Self::AD102 | Self::AD103 | Self::AD104 | Self::AD106 | Self::AD107 => {
|
|
Architecture::Ada
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// TODO
|
|
//
|
|
// The resulting strings are used to generate firmware paths, hence the
|
|
// generated strings have to be stable.
|
|
//
|
|
// Hence, replace with something like strum_macros derive(Display).
|
|
//
|
|
// For now, redirect to fmt::Debug for convenience.
|
|
impl fmt::Display for Chipset {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
write!(f, "{self:?}")
|
|
}
|
|
}
|
|
|
|
/// Enum representation of the GPU generation.
|
|
#[derive(fmt::Debug)]
|
|
pub(crate) enum Architecture {
|
|
Turing = 0x16,
|
|
Ampere = 0x17,
|
|
Ada = 0x19,
|
|
}
|
|
|
|
impl TryFrom<u8> for Architecture {
|
|
type Error = Error;
|
|
|
|
fn try_from(value: u8) -> Result<Self> {
|
|
match value {
|
|
0x16 => Ok(Self::Turing),
|
|
0x17 => Ok(Self::Ampere),
|
|
0x19 => Ok(Self::Ada),
|
|
_ => Err(ENODEV),
|
|
}
|
|
}
|
|
}
|
|
|
|
pub(crate) struct Revision {
|
|
major: u8,
|
|
minor: u8,
|
|
}
|
|
|
|
impl Revision {
|
|
fn from_boot0(boot0: regs::NV_PMC_BOOT_0) -> Self {
|
|
Self {
|
|
major: boot0.major_revision(),
|
|
minor: boot0.minor_revision(),
|
|
}
|
|
}
|
|
}
|
|
|
|
impl fmt::Display for Revision {
|
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
|
write!(f, "{:x}.{:x}", self.major, self.minor)
|
|
}
|
|
}
|
|
|
|
/// Structure holding the metadata of the GPU.
|
|
pub(crate) struct Spec {
|
|
chipset: Chipset,
|
|
/// The revision of the chipset.
|
|
revision: Revision,
|
|
}
|
|
|
|
impl Spec {
|
|
fn new(bar: &Bar0) -> Result<Spec> {
|
|
let boot0 = regs::NV_PMC_BOOT_0::read(bar);
|
|
|
|
Ok(Self {
|
|
chipset: boot0.chipset()?,
|
|
revision: Revision::from_boot0(boot0),
|
|
})
|
|
}
|
|
}
|
|
|
|
/// Structure holding the resources required to operate the GPU.
|
|
#[pin_data(PinnedDrop)]
|
|
pub(crate) struct Gpu {
|
|
spec: Spec,
|
|
/// MMIO mapping of PCI BAR 0
|
|
bar: Arc<Devres<Bar0>>,
|
|
fw: Firmware,
|
|
/// System memory page required for flushing all pending GPU-side memory writes done through
|
|
/// PCIE into system memory, via sysmembar (A GPU-initiated HW memory-barrier operation).
|
|
sysmem_flush: SysmemFlush,
|
|
}
|
|
|
|
#[pinned_drop]
|
|
impl PinnedDrop for Gpu {
|
|
fn drop(self: Pin<&mut Self>) {
|
|
// Unregister the sysmem flush page before we release it.
|
|
self.bar
|
|
.try_access_with(|b| self.sysmem_flush.unregister(b));
|
|
}
|
|
}
|
|
|
|
impl Gpu {
|
|
/// Helper function to load and run the FWSEC-FRTS firmware and confirm that it has properly
|
|
/// created the WPR2 region.
|
|
///
|
|
/// TODO: this needs to be moved into a larger type responsible for booting the whole GSP
|
|
/// (`GspBooter`?).
|
|
fn run_fwsec_frts(
|
|
dev: &device::Device<device::Bound>,
|
|
falcon: &Falcon<Gsp>,
|
|
bar: &Bar0,
|
|
bios: &Vbios,
|
|
fb_layout: &FbLayout,
|
|
) -> Result<()> {
|
|
// Check that the WPR2 region does not already exists - if it does, we cannot run
|
|
// FWSEC-FRTS until the GPU is reset.
|
|
if regs::NV_PFB_PRI_MMU_WPR2_ADDR_HI::read(bar).higher_bound() != 0 {
|
|
dev_err!(
|
|
dev,
|
|
"WPR2 region already exists - GPU needs to be reset to proceed\n"
|
|
);
|
|
return Err(EBUSY);
|
|
}
|
|
|
|
let fwsec_frts = FwsecFirmware::new(
|
|
dev,
|
|
falcon,
|
|
bar,
|
|
bios,
|
|
FwsecCommand::Frts {
|
|
frts_addr: fb_layout.frts.start,
|
|
frts_size: fb_layout.frts.end - fb_layout.frts.start,
|
|
},
|
|
)?;
|
|
|
|
// Run FWSEC-FRTS to create the WPR2 region.
|
|
fwsec_frts.run(dev, falcon, bar)?;
|
|
|
|
// SCRATCH_E contains the error code for FWSEC-FRTS.
|
|
let frts_status = regs::NV_PBUS_SW_SCRATCH_0E::read(bar).frts_err_code();
|
|
if frts_status != 0 {
|
|
dev_err!(
|
|
dev,
|
|
"FWSEC-FRTS returned with error code {:#x}",
|
|
frts_status
|
|
);
|
|
|
|
return Err(EIO);
|
|
}
|
|
|
|
// Check that the WPR2 region has been created as we requested.
|
|
let (wpr2_lo, wpr2_hi) = (
|
|
regs::NV_PFB_PRI_MMU_WPR2_ADDR_LO::read(bar).lower_bound(),
|
|
regs::NV_PFB_PRI_MMU_WPR2_ADDR_HI::read(bar).higher_bound(),
|
|
);
|
|
|
|
match (wpr2_lo, wpr2_hi) {
|
|
(_, 0) => {
|
|
dev_err!(dev, "WPR2 region not created after running FWSEC-FRTS\n");
|
|
|
|
Err(EIO)
|
|
}
|
|
(wpr2_lo, _) if wpr2_lo != fb_layout.frts.start => {
|
|
dev_err!(
|
|
dev,
|
|
"WPR2 region created at unexpected address {:#x}; expected {:#x}\n",
|
|
wpr2_lo,
|
|
fb_layout.frts.start,
|
|
);
|
|
|
|
Err(EIO)
|
|
}
|
|
(wpr2_lo, wpr2_hi) => {
|
|
dev_dbg!(dev, "WPR2: {:#x}-{:#x}\n", wpr2_lo, wpr2_hi);
|
|
dev_dbg!(dev, "GPU instance built\n");
|
|
|
|
Ok(())
|
|
}
|
|
}
|
|
}
|
|
|
|
pub(crate) fn new(
|
|
pdev: &pci::Device<device::Bound>,
|
|
devres_bar: Arc<Devres<Bar0>>,
|
|
) -> Result<impl PinInit<Self>> {
|
|
let bar = devres_bar.access(pdev.as_ref())?;
|
|
let spec = Spec::new(bar)?;
|
|
let fw = Firmware::new(pdev.as_ref(), spec.chipset, FIRMWARE_VERSION)?;
|
|
|
|
dev_info!(
|
|
pdev.as_ref(),
|
|
"NVIDIA (Chipset: {}, Architecture: {:?}, Revision: {})\n",
|
|
spec.chipset,
|
|
spec.chipset.arch(),
|
|
spec.revision
|
|
);
|
|
|
|
// We must wait for GFW_BOOT completion before doing any significant setup on the GPU.
|
|
gfw::wait_gfw_boot_completion(bar)
|
|
.inspect_err(|_| dev_err!(pdev.as_ref(), "GFW boot did not complete"))?;
|
|
|
|
let sysmem_flush = SysmemFlush::register(pdev.as_ref(), bar, spec.chipset)?;
|
|
|
|
let gsp_falcon = Falcon::<Gsp>::new(
|
|
pdev.as_ref(),
|
|
spec.chipset,
|
|
bar,
|
|
spec.chipset > Chipset::GA100,
|
|
)?;
|
|
gsp_falcon.clear_swgen0_intr(bar);
|
|
|
|
let _sec2_falcon = Falcon::<Sec2>::new(pdev.as_ref(), spec.chipset, bar, true)?;
|
|
|
|
let fb_layout = FbLayout::new(spec.chipset, bar)?;
|
|
dev_dbg!(pdev.as_ref(), "{:#x?}\n", fb_layout);
|
|
|
|
let bios = Vbios::new(pdev, bar)?;
|
|
|
|
Self::run_fwsec_frts(pdev.as_ref(), &gsp_falcon, bar, &bios, &fb_layout)?;
|
|
|
|
Ok(pin_init!(Self {
|
|
spec,
|
|
bar: devres_bar,
|
|
fw,
|
|
sysmem_flush,
|
|
}))
|
|
}
|
|
}
|