Skip to contentSkip to conversation

linux-next: manual merge of the drm-rust tree with the rust tree

PATCH Mark Brown 2 participants 2 messages Dec 2

Subsystems (4)
lore
Share & tools
lore

Mark Brown

author maintainer
#0 lore raw

Hi all,

Today's linux-next merge of the drm-rust tree got a conflict in:

drivers/gpu/drm/tyr/regs.rs

between commit:

b34220a599aab ("rust: bitfield: add conversions to Bounded of matching width")

from the rust tree and commit:

63be871b54a4f ("drm/tyr: replace lossless as casts with From and FromSafeCast")

from the drm-rust tree.

I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts.

drivers/gpu/drm/tyr/regs.rs +0 -0
diff --combined drivers/gpu/drm/tyr/regs.rs
index 0392869adc5ab,76892a9112275..0000000000000
@@@ -32,6 -32,18 +32,18 @@@ pub(crate) fn join_u64(lo: u32, hi: u32
      (u64::from(lo)) | ((u64::from(hi)) << 32)
  }
  
+ /// Split a 64-bit value into its low and high 32-bit halves.
+ pub(crate) fn split_u64(value: u64) -> (u32, u32) {
+     // CAST: The upper 32 bits are dropped on purpose. They are returned in `hi`.
+     #[expect(clippy::as_conversions)]
+     let lo = value as u32;
+     // CAST: After the shift, the value fits in 32 bits.
+     #[expect(clippy::as_conversions)]
+     let hi = (value >> 32) as u32;
+ 
+     (lo, hi)
+ }
+ 
  /// Read a logical 64-bit value from split 32-bit registers without tearing.
  pub(crate) fn read_u64_no_tearing(lo_read: impl Fn() -> u32, hi_read: impl Fn() -> u32) -> u64 {
      loop {
@@@ -251,7 -263,9 +263,9 @@@ pub(crate) mod gpu_control 
      }
  
      impl From<GpuCommand> for Bounded<u32, 8> {
+         #[expect(clippy::as_conversions)]
          fn from(cmd: GpuCommand) -> Self {
+             // CAST: `GpuCommand` is `#[repr(u8)]`, so the cast is lossless.
              (cmd as u8).into()
          }
      }
@@@ -279,7 -293,9 +293,9 @@@
      }
  
      impl From<ResetMode> for Bounded<u32, 4> {
+         #[expect(clippy::as_conversions)]
          fn from(mode: ResetMode) -> Self {
+             // CAST: `ResetMode` is `#[repr(u8)]`, so the cast is lossless.
              Bounded::try_new(mode as u32).unwrap()
          }
      }
@@@ -313,7 -329,9 +329,9 @@@
      }
  
      impl From<FlushMode> for Bounded<u32, 4> {
+         #[expect(clippy::as_conversions)]
          fn from(mode: FlushMode) -> Self {
+             // CAST: `FlushMode` is `#[repr(u8)]`, so the cast is lossless.
              Bounded::try_new(mode as u32).unwrap()
          }
      }
@@@ -434,7 -452,9 +452,9 @@@
      }
  
      impl From<ExceptionType> for Bounded<u32, 8> {
+         #[expect(clippy::as_conversions)]
          fn from(exc: ExceptionType) -> Self {
+             // CAST: `ExceptionType` is `#[repr(u8)]`, so the cast is lossless.
              (exc as u8).into()
          }
      }
@@@ -465,7 -485,9 +485,9 @@@
      }
  
      impl From<AccessType> for Bounded<u32, 2> {
+         #[expect(clippy::as_conversions)]
          fn from(access: AccessType) -> Self {
+             // CAST: `AccessType` is `#[repr(u8)]`, so the cast is lossless.
              Bounded::try_new(access as u32).unwrap()
          }
      }
@@@ -751,11 -773,11 +773,11 @@@
      #[repr(u8)]
      pub(crate) enum CoherencyMode {
          /// ACE-Lite coherency protocol.
-         AceLite = uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_ACE_LITE as u8,
+         AceLite = cv!(uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_ACE_LITE => u8),
          /// ACE coherency protocol.
-         Ace = uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_ACE as u8,
+         Ace = cv!(uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_ACE => u8),
          /// No coherency protocol.
-         None = uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_NONE as u8,
+         None = cv!(uapi::drm_panthor_gpu_coherency_DRM_PANTHOR_GPU_COHERENCY_NONE => u8),
      }
  
      impl TryFrom<Bounded<u32, 32>> for CoherencyMode {
@@@ -772,7 -794,9 +794,9 @@@
      }
  
      impl From<CoherencyMode> for Bounded<u32, 32> {
+         #[expect(clippy::as_conversions)]
          fn from(mode: CoherencyMode) -> Self {
+             // CAST: `CoherencyMode` is `#[repr(u8)]`, so the cast is lossless.
              (mode as u8).into()
          }
      }
@@@ -814,7 -838,9 +838,9 @@@
      }
  
      impl From<McuControlMode> for Bounded<u32, 2> {
+         #[expect(clippy::as_conversions)]
          fn from(mode: McuControlMode) -> Self {
+             // CAST: `McuControlMode` is `#[repr(u8)]`, so the cast is lossless.
              Bounded::try_new(mode as u32).unwrap()
          }
      }
@@@ -857,7 -883,9 +883,9 @@@
      }
  
      impl From<McuStatus> for Bounded<u32, 2> {
+         #[expect(clippy::as_conversions)]
          fn from(status: McuStatus) -> Self {
+             // CAST: `McuStatus` is `#[repr(u8)]`, so the cast is lossless.
              Bounded::try_new(status as u32).unwrap()
          }
      }
@@@ -1050,7 -1078,9 +1078,9 @@@ pub(crate) mod mmu_control 
          }
  
          impl From<AllocPolicySelect> for Bounded<u8, 2> {
+             #[expect(clippy::as_conversions)]
              fn from(val: AllocPolicySelect) -> Self {
+                 // CAST: `AllocPolicySelect` is `#[repr(u8)]`, so the cast is lossless.
                  Bounded::try_new(val as u8).unwrap()
              }
          }
@@@ -1095,7 -1125,9 +1125,9 @@@
          }
  
          impl From<Coherency> for Bounded<u8, 2> {
+             #[expect(clippy::as_conversions)]
              fn from(val: Coherency) -> Self {
+                 // CAST: `Coherency` is `#[repr(u8)]`, so the cast is lossless.
                  Bounded::try_new(val as u8).unwrap()
              }
          }
@@@ -1126,7 -1158,9 +1158,9 @@@
          }
  
          impl From<MemoryType> for Bounded<u8, 2> {
+             #[expect(clippy::as_conversions)]
              fn from(val: MemoryType) -> Self {
+                 // CAST: `MemoryType` is `#[repr(u8)]`, so the cast is lossless.
                  Bounded::try_new(val as u8).unwrap()
              }
          }
@@@ -1150,6 -1184,20 +1184,6 @@@
              }
          }
  
 -        impl TryFrom<Bounded<u64, 8>> for MMU_MEMATTR_STAGE1 {
 -            type Error = Error;
 -
 -            fn try_from(val: Bounded<u64, 8>) -> Result<Self, Self::Error> {
 -                Ok(Self::from_raw(u8::from(val)))
 -            }
 -        }
 -
 -        impl From<MMU_MEMATTR_STAGE1> for Bounded<u64, 8> {
 -            fn from(val: MMU_MEMATTR_STAGE1) -> Self {
 -                Bounded::try_new(u64::from(val.into_raw())).unwrap()
 -            }
 -        }
 -
          register! {
              base: TyrRegisters;
  
@@@ -1158,14 -1206,14 +1192,14 @@@
              /// Each address space can configure up to 8 different memory attribute profiles.
              /// Each attribute profile follows the MMU_MEMATTR_STAGE1 layout.
              pub(crate) MEMATTR(u64)[MAX_AS, stride = STRIDE] @ 0x2408 {
 -                7:0     attribute0 ?=> MMU_MEMATTR_STAGE1;
 -                15:8    attribute1 ?=> MMU_MEMATTR_STAGE1;
 -                23:16   attribute2 ?=> MMU_MEMATTR_STAGE1;
 -                31:24   attribute3 ?=> MMU_MEMATTR_STAGE1;
 -                39:32   attribute4 ?=> MMU_MEMATTR_STAGE1;
 -                47:40   attribute5 ?=> MMU_MEMATTR_STAGE1;
 -                55:48   attribute6 ?=> MMU_MEMATTR_STAGE1;
 -                63:56   attribute7 ?=> MMU_MEMATTR_STAGE1;
 +                7:0     attribute0 => MMU_MEMATTR_STAGE1;
 +                15:8    attribute1 => MMU_MEMATTR_STAGE1;
 +                23:16   attribute2 => MMU_MEMATTR_STAGE1;
 +                31:24   attribute3 => MMU_MEMATTR_STAGE1;
 +                39:32   attribute4 => MMU_MEMATTR_STAGE1;
 +                47:40   attribute5 => MMU_MEMATTR_STAGE1;
 +                55:48   attribute6 => MMU_MEMATTR_STAGE1;
 +                63:56   attribute7 => MMU_MEMATTR_STAGE1;
              }
  
              // MEMATTR is a logical 64-bit register, but it is laid out in hardware as two
@@@ -1365,7 -1413,9 +1399,9 @@@
          }
  
          impl From<MmuCommand> for Bounded<u32, 8> {
+             #[expect(clippy::as_conversions)]
              fn from(cmd: MmuCommand) -> Self {
+                 // CAST: `MmuCommand` is `#[repr(u8)]`, so the cast is lossless.
                  (cmd as u8).into()
              }
          }
@@@ -1462,7 -1512,9 +1498,9 @@@
          }
  
          impl From<MmuExceptionType> for Bounded<u32, 8> {
+             #[expect(clippy::as_conversions)]
              fn from(exc: MmuExceptionType) -> Self {
+                 // CAST: `MmuExceptionType` is `#[repr(u8)]`, so the cast is lossless.
                  (exc as u8).into()
              }
          }
@@@ -1494,7 -1546,9 +1532,9 @@@
          }
  
          impl From<MmuAccessType> for Bounded<u32, 2> {
+             #[expect(clippy::as_conversions)]
              fn from(access: MmuAccessType) -> Self {
+                 // CAST: `MmuAccessType` is `#[repr(u8)]`, so the cast is lossless.
                  Bounded::try_new(access as u32).unwrap()
              }
          }
@@@ -1561,7 -1615,9 +1601,9 @@@
          }
  
          impl From<AddressSpaceMode> for Bounded<u64, 4> {
+             #[expect(clippy::as_conversions)]
              fn from(mode: AddressSpaceMode) -> Self {
+                 // CAST: `AddressSpaceMode` is `#[repr(u8)]`, so the cast is lossless.
                  Bounded::try_new(mode as u64).unwrap()
              }
          }
@@@ -1658,7 -1714,9 +1700,9 @@@
          }
  
          impl From<InaBits> for Bounded<u64, 5> {
+             #[expect(clippy::as_conversions)]
              fn from(bits: InaBits) -> Self {
+                 // CAST: `InaBits` is `#[repr(u8)]`, so the cast is lossless.
                  Bounded::try_new(bits as u64).unwrap()
              }
          }
@@@ -1689,7 -1747,9 +1733,9 @@@
          }
  
          impl From<PtwMemattr> for Bounded<u64, 2> {
+             #[expect(clippy::as_conversions)]
              fn from(attr: PtwMemattr) -> Self {
+                 // CAST: `PtwMemattr` is `#[repr(u8)]`, so the cast is lossless.
                  Bounded::try_new(attr as u64).unwrap()
              }
          }
@@@ -1721,7 -1781,9 +1767,9 @@@
          }
  
          impl From<PtwShareability> for Bounded<u64, 2> {
+             #[expect(clippy::as_conversions)]
              fn from(sh: PtwShareability) -> Self {
+                 // CAST: `PtwShareability` is `#[repr(u8)]`, so the cast is lossless.
                  Bounded::try_new(sh as u64).unwrap()
              }
          }
#1 lore raw
Quoted 2 lines · Mark Brown

I fixed it up (see below) and can carry the fix as necessary. This

Looks good, thanks!

Cheers,
Miguel