gpu: nova-core: gsp: remove useless conversion
Subsystems (4)
Danilo Krummrich
maintainerPATCH 1/2 gpu: nova-core: gsp: remove useless conversion
Meanwhile nova-core depends on CONFIG_64BIT and a raw DmaAddress is always a u64, hence remove the now actually useless conversion.
--- drivers/gpu/nova-core/firmware/gsp.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/gpu/nova-core/firmware/gsp.rs +1 -2
@@ -202,8 +202,7 @@ pub(crate) fn new<'a, 'b>(let mut level0_data =kvec! [0u8 ;GSP_PAGE_SIZE ]?;// Fill level 1 page entry. -#[allow(clippy::useless_conversion)] -let level1_entry = u64::from (level1.iter ().next ().unwrap ().dma_address ()); +let level1_entry = level1.iter ().next ().unwrap ().dma_address ();let dst = &mut level0_data[..size_of_val (&level1_entry)]; dst.copy_from_slice (&level1_entry.to_le_bytes ());
base-commit: 299eb32863e584cfff7c6b667c3e92ae7d4d2bf9
Signature · 1 line
2.51.0
Danilo Krummrich
maintainerPATCH 2/2 gpu: nova-core: gsp: do not unwrap() SGEntry
Don't use unwrap() to extract an Option<SGEntry>, instead handle the error condition gracefully.
--- drivers/gpu/nova-core/firmware/gsp.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
drivers/gpu/nova-core/firmware/gsp.rs +4 -3
@@ -202,9 +202,10 @@ pub(crate) fn new<'a, 'b>(let mut level0_data =kvec! [0u8 ;GSP_PAGE_SIZE ]?;// Fill level 1 page entry. -let level1_entry = level1.iter ().next ().unwrap ().dma_address (); -let dst = &mut level0_data[..size_of_val (&level1_entry)]; - dst.copy_from_slice (&level1_entry.to_le_bytes ()); +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)?
Signature · 1 line
2.51.0
Re: [PATCH 2/2] gpu: nova-core: gsp: do not unwrap() SGEntry
Quoted 9 lines · Danilo Krummrich
Don't use
unwrap()to extract an Option<SGEntry>, instead handle the error condition gracefully.Fixes a841614e607c ("gpu: nova-core: firmware: process and prepare the GSP firmware")Signed-off-by Danilo Krummrich <[email protected]>--- drivers/gpu/nova-core/firmware/gsp.rs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-)
Looks good!
thanks,
John Hubbard
Quoted 18 lines
drivers/gpu/nova-core/firmware/gsp.rs +4
-3@@ -202,9 +202,10 @@ pub(crate) fn new<'a, 'b>(let mut level0_data =kvec! [0u8 ;GSP_PAGE_SIZE ]?;// Fill level 1 page entry. -let level1_entry = level1.iter ().next ().unwrap ().dma_address (); -let dst = &mut level0_data[..size_of_val (&level1_entry)]; - dst.copy_from_slice (&level1_entry.to_le_bytes ()); +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)?
Quoted 3 lines · Danilo Krummrich
Meanwhile nova-core depends on
CONFIG_64BITand a raw DmaAddress is always a u64, hence remove the now actually useless conversion.
Because I'm already here and have at least mild OCD, I'll suggest saying it like this:
"Because nova-core depends on CONFIG_64BIT and a raw DmaAddress is always a u64, we can remove the now actually useless conversion."
Quoted 4 lines
Signed-off-by Danilo Krummrich <[email protected]>--- drivers/gpu/nova-core/firmware/gsp.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
Either way, it's clearly correct, so:
thanks,
John Hubbard
Quoted 17 lines
drivers/gpu/nova-core/firmware/gsp.rs +1
-2@@ -202,8 +202,7 @@ pub(crate) fn new<'a, 'b>(let mut level0_data =kvec! [0u8 ;GSP_PAGE_SIZE ]?;// Fill level 1 page entry. -#[allow(clippy::useless_conversion)] -let level1_entry = u64::from (level1.iter ().next ().unwrap ().dma_address ()); +let level1_entry = level1.iter ().next ().unwrap ().dma_address ();let dst = &mut level0_data[..size_of_val (&level1_entry)]; dst.copy_from_slice (&level1_entry.to_le_bytes ());base-commit:
299eb32863e584cfff7c6b667c3e92ae7d4d2bf9
Alexandre Courbot
maintainerQuoted 4 lines · Danilo Krummrich
Meanwhile nova-core depends on
CONFIG_64BITand a raw DmaAddress is always a u64, hence remove the now actually useless conversion.Signed-off-by Danilo Krummrich <[email protected]>
Thanks - staging both for being applied to drm-rust-next after -rc1 is released.
Alexandre Courbot
maintainerQuoted 8 lines · Alexandre Courbot
Quoted 4 lines · Danilo Krummrich
Meanwhile nova-core depends on
CONFIG_64BITand a raw DmaAddress is always a u64, hence remove the now actually useless conversion.Signed-off-by Danilo Krummrich <[email protected]>Thanks - staging both for being applied to drm-rust-next after -rc1 is released.
Both patches pushed to drm-rust-next, thank you!