mirror of
https://github.com/torvalds/linux.git
synced 2026-04-28 19:42:31 -04:00
Pull drm updates from Dave Airlie:
"Highlights:
- amdgpu support for lots of new IP blocks which means newer GPUs
- xe has a lot of SR-IOV and SVM improvements
- lots of intel display refactoring across i915/xe
- msm has more support for gen8 platforms
- Given up on kgdb/kms integration, it's too hard on modern hw
core:
- drop kgdb support
- replace system workqueue with percpu
- account for property blobs in memcg
- MAINTAINERS updates for xe + buddy
rust:
- Fix documentation for Registration constructors
- Use pin_init::zeroed() for fops initialization
- Annotate DRM helpers with __rust_helper
- Improve safety documentation for gem::Object::new()
- Update AlwaysRefCounted imports
- mm: Prevent integer overflow in page_align()
atomic:
- add drm_device pointer to drm_private_obj
- introduce gamma/degamma LUT size check
buddy:
- fix free_trees memory leak
- prevent BUG_ON
bridge:
- introduce drm_bridge_unplug/enter/exit
- add connector argument to .hpd_notify
- lots of recounting conversions
- convert rockchip inno hdmi to bridge
- lontium-lt9611uxc: switch to HDMI audio helpers
- dw-hdmi-qp: add support for HPD-less setups
- Algoltek AG6311 support
panels:
- edp: CSW MNE007QB3-1, AUO B140HAN06.4, AUO B140QAX01.H
- st75751: add SPI support
- Sitronix ST7920, Samsung LTL106HL02
- LG LH546WF1-ED01, HannStar HSD156J
- BOE NV130WUM-T08
- Innolux G150XGE-L05
- Anbernic RG-DS
dma-buf:
- improve sg_table debugging
- add tracepoints
- call clear_page instead of memset
- start to introduce cgroup memory accounting in heaps
- remove sysfs stats
dma-fence:
- add new helpers
dp:
- mst: avoid oob access with vcpi=0
hdmi:
- limit infoframes exposure to userspace
gem:
- reduce page table overhead with THP
- fix leak in drm_gem_get_unmapped_area
gpuvm:
- API sanitation for rust bindings
sched:
- introduce new helpers
panic:
- report invalid panic modes
- add kunit tests
i915/xe display:
- Expose sharpness only if num_scalers is >= 2
- Add initial Xe3P_LPD for NVL
- BMG FBC support
- Add MTL+ platforms to support dpll framework
_ fix DIMM_S DRM decoding on ICL
- Return to using AUX interrupts
- PSR/Panel replay refactoring
- use consolidation HDMI tables
- Xe3_LPD CD2X dividier changes
xe:
- vfio: add vfio_pci for intel GPU
- multi queue support
- dynamic pagemaps and multi-device SVM
- expose temp attribs in hwmon
- NO_COMPRESSION bo flag
- expose MERT OA unit
- sysfs survivability refactor
- SRIOV PF: add MERT support
- enable SR-IOV VF migration
- Enable I2C/NVM on Crescent Island
- Xe3p page reclaimation support
- introduce SRIOV scheduler groups
- add SoC remappt support in system controller
- insert compiler barriers in GuC code
- define NVL GuC firmware
- handle GT resume failure
- fix drm scheduler layering violations
- enable GSC loading and PXP for PTL
- disable GuC Power DCC strategy on PTL
- unregister drm device on probe error
i915:
- move to kernel standard fault injection
- bump recommended GuC version for DG2 and MTL
amdgpu:
- SMUIO 15.x, PSP 15.x support
- IH 6.1.1/7.1 support
- MMHUB 3.4/4.2 support
- GC 11.5.4/12.1 support
- SDMA 6.1.4/7.1/7.11.4 support
- JPEG 5.3 support
- UserQ updates
- GC 9 gfx queue reset support
- TTM memory ops parallelization
- convert legacy logging to new helpers
- DC analog fixes
amdkfd:
- GC 11.5.4/12.1 suppport
- SDMA 6.1.4/7.1 support
- per context support
- increase kfd process hash table
- Reserved SDMA rework
radeon:
- convert legacy logging to new helpers
- use devm for i2c adapters
msm:
- GPU
- Document a612/RGMU dt bindings
- UBWC 6.0 support (for A840 / Kaanapali)
- a225 support
- DPU:
- Switch to use virtual planes by default
- Fix DSI CMD panels on DPU 3.x
- Rewrite format handling to remove intermediate representation
- Fix watchdog on DPU 8.x+
- Fix TE / Vsync source setting on DPU 8.x+
- Add 3D_Mux on SC7280
- Kaanapali platform support
- Fix UBWC register programming
- Make RM reserve DSPP-enabled mixers for CRTCs with LMs
- Gamma correction support
- DP:
- Enable support for eDP 1.4+ link rate tables
- Fix MDSS1 DP indices on SA8775P, making them to work
- Fix msm_dp_ctrl_config_msa() to work with LLVM 20
- DSI:
- Document QCS8300 as compatible with SA8775P
- Kaanapali platform support
- DSI PHY:
- switch to divider_determine_rate()
- MDP5:
- Drop support for MSM8998, SDM660 and SDM630 (switch over to DPU)
- MDSS:
- Kaanapali platform support
- Fixed UBWC register programming
nova-core:
- Prepare for Turing support. This includes parsing and handling
Turing-specific firmware headers and sections as well as a Turing
Falcon HAL implementation
- Get rid of the Result<impl PinInit<T, E>> anti-pattern
- Relocate initializer-specific code into the appropriate initializer
- Use CStr::from_bytes_until_nul() to remove custom helpers
- Improve handling of unexpected firmware values
- Clean up redundant debug prints
- Replace c_str!() with native Rust C-string literals
- Update nova-core task list
nova:
- Align GEM object size to system page size
tyr:
- Use generated uAPI bindings for GpuInfo
- Replace manual sleeps with read_poll_timeout()
- Replace c_str!() with native Rust C-string literals
- Suppress warnings for unread fields
- Fix incorrect register name in print statement
nouveau:
- fix big page table support races in PTE management
- improve reclocking on tegra 186+
amdxdna:
- fix suspend race conditions
- improve handling of zero tail pointers
- fix cu_idx overwritten during command setup
- enable hardware context priority
- remove NPU2 support
- update message buffer allocation requirements
- update firmware version check
ast:
- support imported cursor buffers
- big endian fixes
etnaviv:
- add PPU flop reset support
imagination:
- add AM62P support
- introduce hw version checks
ivpu:
- implement warm boot flow
panfrost:
- add bo sync ioctl
- add GPU_PM_RT support for RZ/G3E SoC
panthor:
- add bo sync ioctl
- enable timestamp propagation
- scheduler robustness improvements
- VM termination fixes
- huge page support
rockchip:
- RK3368 HDMI Support
- get rid of atomic_check fixups
- RK3506 support
- RK3576/RK3588 improved HPD handling
rz-du:
- RZ/V2H(P) MIPI-DSI Support
v3d:
- fix DMA segment size
- convert to new logging helpers
mediatek:
- move DP training to hotplug thread
- convert logging to new helpers
- add support for HS speed DSI
- Genio 510/700/1200-EVK, Radxa NIO-12L HDMI support
atmel-hlcdc:
- switch to drmm resource
- support nomodeset
- use newer helpers
hisilicon:
- fix various DP bugs
renesas:
- fix kernel panic on reboot
exynos:
- fix vidi_connection_ioctl using wrong device
- fix vidi_connection deref user ptr
- fix concurrency regression with vidi_context
vkms:
- add configfs support for display configuration
* tag 'drm-next-2026-02-11' of https://gitlab.freedesktop.org/drm/kernel: (1610 commits)
drm/xe/pm: Disable D3Cold for BMG only on specific platforms
drm/xe: Fix kerneldoc for xe_tlb_inval_job_alloc_dep
drm/xe: Fix kerneldoc for xe_gt_tlb_inval_init_early
drm/xe: Fix kerneldoc for xe_migrate_exec_queue
drm/xe/query: Fix topology query pointer advance
drm/xe/guc: Fix kernel-doc warning in GuC scheduler ABI header
drm/xe/guc: Fix CFI violation in debugfs access.
accel/amdxdna: Move RPM resume into job run function
accel/amdxdna: Fix incorrect DPM level after suspend/resume
nouveau/vmm: start tracking if the LPT PTE is valid. (v6)
nouveau/vmm: increase size of vmm pte tracker struct to u32 (v2)
nouveau/vmm: rewrite pte tracker using a struct and bitfields.
accel/amdxdna: Fix incorrect error code returned for failed chain command
accel/amdxdna: Remove hardware context status
drm/bridge: imx8qxp-pixel-combiner: Fix bailout for imx8qxp_pc_bridge_probe()
drm/panel: ilitek-ili9882t: Remove duplicate initializers in tianma_il79900a_dsc
drm/i915/display: fix the pixel normalization handling for xe3p_lpd
drm/exynos: vidi: use ctx->lock to protect struct vidi_context member variables related to memory alloc/free
drm/exynos: vidi: fix to avoid directly dereferencing user pointer
drm/exynos: vidi: use priv->vidi_dev for ctx lookup in vidi_connection_ioctl()
...
265 lines
9.9 KiB
Rust
265 lines
9.9 KiB
Rust
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
use kernel::{
|
|
device,
|
|
dma::{
|
|
DataDirection,
|
|
DmaAddress, //
|
|
},
|
|
kvec,
|
|
prelude::*,
|
|
scatterlist::{
|
|
Owned,
|
|
SGTable, //
|
|
},
|
|
};
|
|
|
|
use crate::{
|
|
dma::DmaObject,
|
|
firmware::riscv::RiscvFirmware,
|
|
gpu::{
|
|
Architecture,
|
|
Chipset, //
|
|
},
|
|
gsp::GSP_PAGE_SIZE,
|
|
num::FromSafeCast,
|
|
};
|
|
|
|
/// Ad-hoc and temporary module to extract sections from ELF images.
|
|
///
|
|
/// Some firmware images are currently packaged as ELF files, where sections names are used as keys
|
|
/// to specific and related bits of data. Future firmware versions are scheduled to move away from
|
|
/// that scheme before nova-core becomes stable, which means this module will eventually be
|
|
/// removed.
|
|
mod elf {
|
|
use kernel::{
|
|
bindings,
|
|
prelude::*,
|
|
transmute::FromBytes, //
|
|
};
|
|
|
|
/// Newtype to provide a [`FromBytes`] implementation.
|
|
#[repr(transparent)]
|
|
struct Elf64Hdr(bindings::elf64_hdr);
|
|
// SAFETY: all bit patterns are valid for this type, and it doesn't use interior mutability.
|
|
unsafe impl FromBytes for Elf64Hdr {}
|
|
|
|
#[repr(transparent)]
|
|
struct Elf64SHdr(bindings::elf64_shdr);
|
|
// SAFETY: all bit patterns are valid for this type, and it doesn't use interior mutability.
|
|
unsafe impl FromBytes for Elf64SHdr {}
|
|
|
|
/// Tries to extract section with name `name` from the ELF64 image `elf`, and returns it.
|
|
pub(super) fn elf64_section<'a, 'b>(elf: &'a [u8], name: &'b str) -> Option<&'a [u8]> {
|
|
let hdr = &elf
|
|
.get(0..size_of::<bindings::elf64_hdr>())
|
|
.and_then(Elf64Hdr::from_bytes)?
|
|
.0;
|
|
|
|
// Get all the section headers.
|
|
let mut shdr = {
|
|
let shdr_num = usize::from(hdr.e_shnum);
|
|
let shdr_start = usize::try_from(hdr.e_shoff).ok()?;
|
|
let shdr_end = shdr_num
|
|
.checked_mul(size_of::<Elf64SHdr>())
|
|
.and_then(|v| v.checked_add(shdr_start))?;
|
|
|
|
elf.get(shdr_start..shdr_end)
|
|
.map(|slice| slice.chunks_exact(size_of::<Elf64SHdr>()))?
|
|
};
|
|
|
|
// Get the strings table.
|
|
let strhdr = shdr
|
|
.clone()
|
|
.nth(usize::from(hdr.e_shstrndx))
|
|
.and_then(Elf64SHdr::from_bytes)?;
|
|
|
|
// Find the section which name matches `name` and return it.
|
|
shdr.find(|&sh| {
|
|
let Some(hdr) = Elf64SHdr::from_bytes(sh) else {
|
|
return false;
|
|
};
|
|
|
|
let Some(name_idx) = strhdr
|
|
.0
|
|
.sh_offset
|
|
.checked_add(u64::from(hdr.0.sh_name))
|
|
.and_then(|idx| usize::try_from(idx).ok())
|
|
else {
|
|
return false;
|
|
};
|
|
|
|
// Get the start of the name.
|
|
elf.get(name_idx..)
|
|
.and_then(|nstr| CStr::from_bytes_until_nul(nstr).ok())
|
|
// Convert into str.
|
|
.and_then(|c_str| c_str.to_str().ok())
|
|
// Check that the name matches.
|
|
.map(|str| str == name)
|
|
.unwrap_or(false)
|
|
})
|
|
// Return the slice containing the section.
|
|
.and_then(|sh| {
|
|
let hdr = Elf64SHdr::from_bytes(sh)?;
|
|
let start = usize::try_from(hdr.0.sh_offset).ok()?;
|
|
let end = usize::try_from(hdr.0.sh_size)
|
|
.ok()
|
|
.and_then(|sh_size| start.checked_add(sh_size))?;
|
|
|
|
elf.get(start..end)
|
|
})
|
|
}
|
|
}
|
|
|
|
/// GSP firmware with 3-level radix page tables for the GSP bootloader.
|
|
///
|
|
/// The bootloader expects firmware to be mapped starting at address 0 in GSP's virtual address
|
|
/// space:
|
|
///
|
|
/// ```text
|
|
/// Level 0: 1 page, 1 entry -> points to first level 1 page
|
|
/// Level 1: Multiple pages/entries -> each entry points to a level 2 page
|
|
/// Level 2: Multiple pages/entries -> each entry points to a firmware page
|
|
/// ```
|
|
///
|
|
/// Each page is 4KB, each entry is 8 bytes (64-bit DMA address).
|
|
/// Also known as "Radix3" firmware.
|
|
#[pin_data]
|
|
pub(crate) struct GspFirmware {
|
|
/// The GSP firmware inside a [`VVec`], device-mapped via a SG table.
|
|
#[pin]
|
|
fw: SGTable<Owned<VVec<u8>>>,
|
|
/// Level 2 page table whose entries contain DMA addresses of firmware pages.
|
|
#[pin]
|
|
level2: SGTable<Owned<VVec<u8>>>,
|
|
/// Level 1 page table whose entries contain DMA addresses of level 2 pages.
|
|
#[pin]
|
|
level1: SGTable<Owned<VVec<u8>>>,
|
|
/// Level 0 page table (single 4KB page) with one entry: DMA address of first level 1 page.
|
|
level0: DmaObject,
|
|
/// Size in bytes of the firmware contained in [`Self::fw`].
|
|
pub(crate) size: usize,
|
|
/// Device-mapped GSP signatures matching the GPU's [`Chipset`].
|
|
pub(crate) signatures: DmaObject,
|
|
/// GSP bootloader, verifies the GSP firmware before loading and running it.
|
|
pub(crate) bootloader: RiscvFirmware,
|
|
}
|
|
|
|
impl GspFirmware {
|
|
/// Loads the GSP firmware binaries, map them into `dev`'s address-space, and creates the page
|
|
/// tables expected by the GSP bootloader to load it.
|
|
pub(crate) fn new<'a>(
|
|
dev: &'a device::Device<device::Bound>,
|
|
chipset: Chipset,
|
|
ver: &'a str,
|
|
) -> impl PinInit<Self, Error> + 'a {
|
|
pin_init::pin_init_scope(move || {
|
|
let firmware = super::request_firmware(dev, chipset, "gsp", ver)?;
|
|
|
|
let fw_section = elf::elf64_section(firmware.data(), ".fwimage").ok_or(EINVAL)?;
|
|
|
|
let size = fw_section.len();
|
|
|
|
// Move the firmware into a vmalloc'd vector and map it into the device address
|
|
// space.
|
|
let fw_vvec = VVec::with_capacity(fw_section.len(), GFP_KERNEL)
|
|
.and_then(|mut v| {
|
|
v.extend_from_slice(fw_section, GFP_KERNEL)?;
|
|
Ok(v)
|
|
})
|
|
.map_err(|_| ENOMEM)?;
|
|
|
|
Ok(try_pin_init!(Self {
|
|
fw <- SGTable::new(dev, fw_vvec, DataDirection::ToDevice, GFP_KERNEL),
|
|
level2 <- {
|
|
// Allocate the level 2 page table, map the firmware onto it, and map it into
|
|
// the device address space.
|
|
VVec::<u8>::with_capacity(
|
|
fw.iter().count() * core::mem::size_of::<u64>(),
|
|
GFP_KERNEL,
|
|
)
|
|
.map_err(|_| ENOMEM)
|
|
.and_then(|level2| map_into_lvl(&fw, level2))
|
|
.map(|level2| SGTable::new(dev, level2, DataDirection::ToDevice, GFP_KERNEL))?
|
|
},
|
|
level1 <- {
|
|
// Allocate the level 1 page table, map the level 2 page table onto it, and map
|
|
// it into the device address space.
|
|
VVec::<u8>::with_capacity(
|
|
level2.iter().count() * core::mem::size_of::<u64>(),
|
|
GFP_KERNEL,
|
|
)
|
|
.map_err(|_| ENOMEM)
|
|
.and_then(|level1| map_into_lvl(&level2, level1))
|
|
.map(|level1| SGTable::new(dev, level1, DataDirection::ToDevice, GFP_KERNEL))?
|
|
},
|
|
level0: {
|
|
// Allocate the level 0 page table as a device-visible DMA object, and map the
|
|
// level 1 page table onto it.
|
|
|
|
// Level 0 page table data.
|
|
let mut level0_data = kvec![0u8; GSP_PAGE_SIZE]?;
|
|
|
|
// Fill level 1 page entry.
|
|
let level1_entry = level1.iter().next().ok_or(EINVAL)?;
|
|
let level1_entry_addr = level1_entry.dma_address();
|
|
let dst = &mut level0_data[..size_of_val(&level1_entry_addr)];
|
|
dst.copy_from_slice(&level1_entry_addr.to_le_bytes());
|
|
|
|
// Turn the level0 page table into a [`DmaObject`].
|
|
DmaObject::from_data(dev, &level0_data)?
|
|
},
|
|
size,
|
|
signatures: {
|
|
let sigs_section = match chipset.arch() {
|
|
Architecture::Turing
|
|
if matches!(chipset, Chipset::TU116 | Chipset::TU117) =>
|
|
{
|
|
".fwsignature_tu11x"
|
|
}
|
|
Architecture::Turing => ".fwsignature_tu10x",
|
|
// GA100 uses the same firmware as Turing
|
|
Architecture::Ampere if chipset == Chipset::GA100 => ".fwsignature_tu10x",
|
|
Architecture::Ampere => ".fwsignature_ga10x",
|
|
Architecture::Ada => ".fwsignature_ad10x",
|
|
};
|
|
|
|
elf::elf64_section(firmware.data(), sigs_section)
|
|
.ok_or(EINVAL)
|
|
.and_then(|data| DmaObject::from_data(dev, data))?
|
|
},
|
|
bootloader: {
|
|
let bl = super::request_firmware(dev, chipset, "bootloader", ver)?;
|
|
|
|
RiscvFirmware::new(dev, &bl)?
|
|
},
|
|
}))
|
|
})
|
|
}
|
|
|
|
/// Returns the DMA handle of the radix3 level 0 page table.
|
|
pub(crate) fn radix3_dma_handle(&self) -> DmaAddress {
|
|
self.level0.dma_handle()
|
|
}
|
|
}
|
|
|
|
/// Build a page table from a scatter-gather list.
|
|
///
|
|
/// Takes each DMA-mapped region from `sg_table` and writes page table entries
|
|
/// for all 4KB pages within that region. For example, a 16KB SG entry becomes
|
|
/// 4 consecutive page table entries.
|
|
fn map_into_lvl(sg_table: &SGTable<Owned<VVec<u8>>>, mut dst: VVec<u8>) -> Result<VVec<u8>> {
|
|
for sg_entry in sg_table.iter() {
|
|
// Number of pages we need to map.
|
|
let num_pages = usize::from_safe_cast(sg_entry.dma_len()).div_ceil(GSP_PAGE_SIZE);
|
|
|
|
for i in 0..num_pages {
|
|
let entry = sg_entry.dma_address()
|
|
+ (u64::from_safe_cast(i) * u64::from_safe_cast(GSP_PAGE_SIZE));
|
|
dst.extend_from_slice(&entry.to_le_bytes(), GFP_KERNEL)?;
|
|
}
|
|
}
|
|
|
|
Ok(dst)
|
|
}
|