Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

gpu: nova-core: gsp: simplify sequencer opcode parsing

The opcodes are already the right type in the C union, so we can use
them directly instead of converting them to a byte stream and back again
using `FromBytes`.

Reviewed-by: Lyude Paul <lyude@redhat.com>
Reviewed-by: Gary Guo <gary@garyguo.net>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/20260217-nova-misc-v3-3-b4e2d45eafbc@nvidia.com
Signed-off-by: Alexandre Courbot <acourbot@nvidia.com>

+5 -35
+5 -35
drivers/gpu/nova-core/gsp/fw.rs
··· 472 472 return Err(EINVAL); 473 473 } 474 474 // SAFETY: Opcode is verified to be `RegWrite`, so union contains valid `RegWritePayload`. 475 - let payload_bytes = unsafe { 476 - core::slice::from_raw_parts( 477 - core::ptr::addr_of!(self.0.payload.regWrite).cast::<u8>(), 478 - core::mem::size_of::<RegWritePayload>(), 479 - ) 480 - }; 481 - Ok(*RegWritePayload::from_bytes(payload_bytes).ok_or(EINVAL)?) 475 + Ok(RegWritePayload(unsafe { self.0.payload.regWrite })) 482 476 } 483 477 484 478 /// Returns the register modify payload by value. ··· 483 489 return Err(EINVAL); 484 490 } 485 491 // SAFETY: Opcode is verified to be `RegModify`, so union contains valid `RegModifyPayload`. 486 - let payload_bytes = unsafe { 487 - core::slice::from_raw_parts( 488 - core::ptr::addr_of!(self.0.payload.regModify).cast::<u8>(), 489 - core::mem::size_of::<RegModifyPayload>(), 490 - ) 491 - }; 492 - Ok(*RegModifyPayload::from_bytes(payload_bytes).ok_or(EINVAL)?) 492 + Ok(RegModifyPayload(unsafe { self.0.payload.regModify })) 493 493 } 494 494 495 495 /// Returns the register poll payload by value. ··· 494 506 return Err(EINVAL); 495 507 } 496 508 // SAFETY: Opcode is verified to be `RegPoll`, so union contains valid `RegPollPayload`. 497 - let payload_bytes = unsafe { 498 - core::slice::from_raw_parts( 499 - core::ptr::addr_of!(self.0.payload.regPoll).cast::<u8>(), 500 - core::mem::size_of::<RegPollPayload>(), 501 - ) 502 - }; 503 - Ok(*RegPollPayload::from_bytes(payload_bytes).ok_or(EINVAL)?) 509 + Ok(RegPollPayload(unsafe { self.0.payload.regPoll })) 504 510 } 505 511 506 512 /// Returns the delay payload by value. ··· 505 523 return Err(EINVAL); 506 524 } 507 525 // SAFETY: Opcode is verified to be `DelayUs`, so union contains valid `DelayUsPayload`. 508 - let payload_bytes = unsafe { 509 - core::slice::from_raw_parts( 510 - core::ptr::addr_of!(self.0.payload.delayUs).cast::<u8>(), 511 - core::mem::size_of::<DelayUsPayload>(), 512 - ) 513 - }; 514 - Ok(*DelayUsPayload::from_bytes(payload_bytes).ok_or(EINVAL)?) 526 + Ok(DelayUsPayload(unsafe { self.0.payload.delayUs })) 515 527 } 516 528 517 529 /// Returns the register store payload by value. ··· 516 540 return Err(EINVAL); 517 541 } 518 542 // SAFETY: Opcode is verified to be `RegStore`, so union contains valid `RegStorePayload`. 519 - let payload_bytes = unsafe { 520 - core::slice::from_raw_parts( 521 - core::ptr::addr_of!(self.0.payload.regStore).cast::<u8>(), 522 - core::mem::size_of::<RegStorePayload>(), 523 - ) 524 - }; 525 - Ok(*RegStorePayload::from_bytes(payload_bytes).ok_or(EINVAL)?) 543 + Ok(RegStorePayload(unsafe { self.0.payload.regStore })) 526 544 } 527 545 } 528 546