Skip to content

Commit 43ad65e

Browse files
author
Danilo Krummrich
committed
gpu: nova-core: consider clippy::cast_lossless
Fix all warnings caused by `clippy::cast_lossless`, which is going to be enabled by [1]. Cc: Alexandre Courbot <[email protected]> Cc: Miguel Ojeda <[email protected]> Link: https://lore.kernel.org/r/[email protected] [1] Reviewed-by: Alexandre Courbot <[email protected]> Tested-by: Alexandre Courbot <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Danilo Krummrich <[email protected]>
1 parent 1b8233b commit 43ad65e

File tree

7 files changed

+14
-14
lines changed

7 files changed

+14
-14
lines changed

drivers/gpu/nova-core/falcon.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ impl<E: FalconEngine + 'static> Falcon<E> {
428428
fw.dma_handle_with_offset(load_offsets.src_start as usize)?,
429429
),
430430
};
431-
if dma_start % DMA_LEN as bindings::dma_addr_t > 0 {
431+
if dma_start % bindings::dma_addr_t::from(DMA_LEN) > 0 {
432432
dev_err!(
433433
self.dev,
434434
"DMA transfer start addresses must be a multiple of {}",

drivers/gpu/nova-core/falcon/hal/ga102.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ fn program_brom_ga102<E: FalconEngine>(bar: &Bar0, params: &FalconBromParams) ->
7878
.set_value(params.pkc_data_offset)
7979
.write(bar, E::BASE);
8080
regs::NV_PFALCON2_FALCON_BROM_ENGIDMASK::default()
81-
.set_value(params.engine_id_mask as u32)
81+
.set_value(u32::from(params.engine_id_mask))
8282
.write(bar, E::BASE);
8383
regs::NV_PFALCON2_FALCON_BROM_CURR_UCODE_ID::default()
8484
.set_ucode_id(params.ucode_id)

drivers/gpu/nova-core/fb/hal/ga100.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ use crate::regs;
1111
use super::tu102::FLUSH_SYSMEM_ADDR_SHIFT;
1212

1313
pub(super) fn read_sysmem_flush_page_ga100(bar: &Bar0) -> u64 {
14-
(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR::read(bar).adr_39_08() as u64) << FLUSH_SYSMEM_ADDR_SHIFT
15-
| (regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR_HI::read(bar).adr_63_40() as u64)
14+
u64::from(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR::read(bar).adr_39_08()) << FLUSH_SYSMEM_ADDR_SHIFT
15+
| u64::from(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR_HI::read(bar).adr_63_40())
1616
<< FLUSH_SYSMEM_ADDR_SHIFT_HI
1717
}
1818

drivers/gpu/nova-core/fb/hal/tu102.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use kernel::prelude::*;
1010
pub(super) const FLUSH_SYSMEM_ADDR_SHIFT: u32 = 8;
1111

1212
pub(super) fn read_sysmem_flush_page_gm107(bar: &Bar0) -> u64 {
13-
(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR::read(bar).adr_39_08() as u64) << FLUSH_SYSMEM_ADDR_SHIFT
13+
u64::from(regs::NV_PFB_NISO_FLUSH_SYSMEM_ADDR::read(bar).adr_39_08()) << FLUSH_SYSMEM_ADDR_SHIFT
1414
}
1515

1616
pub(super) fn write_sysmem_flush_page_gm107(bar: &Bar0, addr: u64) -> Result {

drivers/gpu/nova-core/firmware/fwsec.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,7 @@ impl FwsecFirmware {
346346
let desc = bios.fwsec_image().header(dev)?;
347347
let ucode_signed = if desc.signature_count != 0 {
348348
let sig_base_img = (desc.imem_load_size + desc.pkc_data_offset) as usize;
349-
let desc_sig_versions = desc.signature_versions as u32;
349+
let desc_sig_versions = u32::from(desc.signature_versions);
350350
let reg_fuse_version =
351351
falcon.signature_reg_fuse_version(bar, desc.engine_id_mask, desc.ucode_id)?;
352352
dev_dbg!(

drivers/gpu/nova-core/regs.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ register!(NV_PFB_PRI_MMU_LOCAL_MEMORY_RANGE @ 0x00100ce0 {
6868
impl NV_PFB_PRI_MMU_LOCAL_MEMORY_RANGE {
6969
/// Returns the usable framebuffer size, in bytes.
7070
pub(crate) fn usable_fb_size(self) -> u64 {
71-
let size = ((self.lower_mag() as u64) << (self.lower_scale() as u64))
71+
let size = (u64::from(self.lower_mag()) << u64::from(self.lower_scale()))
7272
* kernel::sizes::SZ_1M as u64;
7373

7474
if self.ecc_mode_enabled() {
@@ -87,7 +87,7 @@ register!(NV_PFB_PRI_MMU_WPR2_ADDR_LO@0x001fa824 {
8787
impl NV_PFB_PRI_MMU_WPR2_ADDR_LO {
8888
/// Returns the lower (inclusive) bound of the WPR2 region.
8989
pub(crate) fn lower_bound(self) -> u64 {
90-
(self.lo_val() as u64) << 12
90+
u64::from(self.lo_val()) << 12
9191
}
9292
}
9393

@@ -100,7 +100,7 @@ impl NV_PFB_PRI_MMU_WPR2_ADDR_HI {
100100
///
101101
/// A value of zero means the WPR2 region is not set.
102102
pub(crate) fn higher_bound(self) -> u64 {
103-
(self.hi_val() as u64) << 12
103+
u64::from(self.hi_val()) << 12
104104
}
105105
}
106106

@@ -158,7 +158,7 @@ impl NV_PDISP_VGA_WORKSPACE_BASE {
158158
/// Returns the base address of the VGA workspace, or `None` if none exists.
159159
pub(crate) fn vga_workspace_addr(self) -> Option<u64> {
160160
if self.status_valid() {
161-
Some((self.addr() as u64) << 16)
161+
Some(u64::from(self.addr()) << 16)
162162
} else {
163163
None
164164
}

drivers/gpu/nova-core/vbios.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -494,10 +494,10 @@ impl PciRomHeader {
494494
if data.len() >= 30 {
495495
// Read size_of_block at offset 0x1A.
496496
size_of_block = Some(
497-
(data[29] as u32) << 24
498-
| (data[28] as u32) << 16
499-
| (data[27] as u32) << 8
500-
| (data[26] as u32),
497+
u32::from(data[29]) << 24
498+
| u32::from(data[28]) << 16
499+
| u32::from(data[27]) << 8
500+
| u32::from(data[26]),
501501
);
502502
}
503503

0 commit comments

Comments
 (0)