linux/drivers/gpu/nova-core
Danilo Krummrich 5c5a41a754 gpu: nova-core: depend on CONFIG_64BIT
If built on architectures with CONFIG_ARCH_DMA_ADDR_T_64BIT=y nova-core
produces that following build failures:

    error[E0308]: mismatched types
      --> drivers/gpu/nova-core/fb.rs:49:59
       |
    49 |         hal::fb_hal(chipset).write_sysmem_flush_page(bar, page.dma_handle())?;
       |                              -----------------------      ^^^^^^^^^^^^^^^^^ expected `u64`, found `u32`
       |                              |
       |                              arguments to this method are incorrect
       |
    note: method defined here
      --> drivers/gpu/nova-core/fb/hal.rs:19:8
       |
    19 |     fn write_sysmem_flush_page(&self, bar: &Bar0, addr: u64) -> Result;
       |        ^^^^^^^^^^^^^^^^^^^^^^^
    help: you can convert a `u32` to a `u64`
       |
    49 |         hal::fb_hal(chipset).write_sysmem_flush_page(bar, page.dma_handle().into())?;
       |                                                                            +++++++

    error[E0308]: mismatched types
      --> drivers/gpu/nova-core/fb.rs:65:47
       |
    65 |         if hal.read_sysmem_flush_page(bar) == self.page.dma_handle() {
       |            -------------------------------    ^^^^^^^^^^^^^^^^^^^^^^ expected `u64`, found `u32`
       |            |
       |            expected because this is `u64`
       |
    help: you can convert a `u32` to a `u64`
       |
    65 |         if hal.read_sysmem_flush_page(bar) == self.page.dma_handle().into() {
       |                                                                     +++++++

    error: this arithmetic operation will overflow
       --> drivers/gpu/nova-core/falcon.rs:469:23
        |
    469 |             .set_base((dma_start >> 40) as u16)
        |                       ^^^^^^^^^^^^^^^^^ attempt to shift right by `40_i32`, which would overflow
        |
        = note: `#[deny(arithmetic_overflow)]` on by default

This is due to the code making assumptions on the width of dma_addr_t to
be 64 bit.

While this could technically be handled, it is rather painful to deal
with, as the following example illustrates:

	pub(super) fn read_sysmem_flush_page_ga100(bar: &Bar0) -> DmaAddress {
	    let addr = u64::from(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR::read(bar).adr_39_08())
	        << FLUSH_SYSMEM_ADDR_SHIFT
	        | u64::from(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR_HI::read(bar).adr_63_40())
	            << FLUSH_SYSMEM_ADDR_SHIFT_HI;

	    addr.try_into().unwrap_or_else(|_| {
	        kernel::warn_on!(true);

	        0
	    })
	}

At the same time there's not much value for nova-core to support 32-bit,
given that the supported GPU architectures are Turing and later, hence
depend on CONFIG_64BIT.

Cc: John Hubbard <jhubbard@nvidia.com>
Reported-by: Miguel Ojeda <ojeda@kernel.org>
Closes: https://lore.kernel.org/lkml/20250828160247.37492-1-ojeda@kernel.org/
Fixes: 6554ad65b5 ("gpu: nova-core: register sysmem flush page")
Fixes: 69f5cd67ce ("gpu: nova-core: add falcon register definitions and base code")
Reviewed-by: Alexandre Courbot <acourbot@nvidia.com>
Reviewed-by: John Hubbard <jhubbard@nvidia.com>
Link: https://lore.kernel.org/r/20250828223954.351348-1-dakr@kernel.org
Signed-off-by: Danilo Krummrich <dakr@kernel.org>
2025-09-01 11:06:37 +02:00
..
falcon gpu: nova-core: replace Duration with Delta 2025-06-25 20:13:32 +02:00
fb gpu: nova-core: consider clippy::cast_lossless 2025-06-25 01:17:22 +02:00
firmware gpu: nova-core: consider clippy::cast_lossless 2025-06-25 01:17:22 +02:00
regs Rust changes for v6.17 2025-08-03 13:49:10 -07:00
dma.rs gpu: nova-core: update and annotate TODO list 2025-06-23 22:05:41 +02:00
driver.rs Rust changes for v6.17 2025-08-03 13:49:10 -07:00
falcon.rs gpu: nova-core: Clarify falcon code 2025-07-09 00:17:29 +02:00
fb.rs gpu: nova-core: Clarify sysmembar operations 2025-07-09 00:15:52 +02:00
firmware.rs Rust changes for v6.17 2025-08-03 13:49:10 -07:00
gfw.rs gpu: nova-core: Add code comments related to devinit 2025-07-09 00:07:34 +02:00
gpu.rs drm for 6.17-rc1 2025-07-30 19:26:49 -07:00
Kconfig gpu: nova-core: depend on CONFIG_64BIT 2025-09-01 11:06:37 +02:00
Makefile
nova_core.rs Rust changes for v6.17 2025-08-03 13:49:10 -07:00
regs.rs Rust changes for v6.17 2025-08-03 13:49:10 -07:00
util.rs Rust changes for v6.17 2025-08-03 13:49:10 -07:00
vbios.rs gpu: nova-core: fix bounds check in PmuLookupTableEntry::new 2025-07-17 14:10:58 +09:00