Skip to content

Commit 5148323

Browse files
committed
fixup! drm/asahi: Add the Asahi driver for Apple AGX GPUs
1 parent 42fb070 commit 5148323

7 files changed

Lines changed: 12 additions & 13 deletions

File tree

drivers/gpu/drm/asahi/debug.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub(crate) enum DebugFlags {
7575

7676
/// Update the cached global debug flags from the module parameter
7777
pub(crate) fn update_debug_flags() {
78-
let flags = *module_parameters::debug_flags.get();
78+
let flags = *module_parameters::debug_flags.value();
7979

8080
DEBUG_FLAGS.store(flags, Ordering::Relaxed);
8181
}

drivers/gpu/drm/asahi/driver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ impl platform::Driver for AsahiDriver {
158158
res.init_mmio()?;
159159

160160
// Start the coprocessor CPU, so UAT can initialize the handoff
161-
res.start_cpu()?;
161+
regs::Resources::start_cpu(pdev)?;
162162

163163
let node = pdev.as_ref().of_node().ok_or(EIO)?;
164164
let compat: KVec<u32> = node.get_property(c_str!("apple,firmware-compat"))?;

drivers/gpu/drm/asahi/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ impl SyncItem {
145145
let size = STRIDE * count as usize;
146146

147147
// SAFETY: We only read this once, so there are no TOCTOU issues.
148-
let mut reader = UserSlice::new(ptr as UserPtr, size).reader();
148+
let mut reader = UserSlice::new(UserPtr::from_addr(ptr as _), size).reader();
149149

150150
for i in 0..count {
151151
let mut sync: MaybeUninit<uapi::drm_asahi_sync> = MaybeUninit::uninit();

drivers/gpu/drm/asahi/initdata.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'a> InitDataBuilder::ver<'a> {
5454
fn hw_shared1(cfg: &'static hw::HwConfig) -> impl Init<raw::HwDataShared1> {
5555
init!(raw::HwDataShared1 {
5656
unk_a4: cfg.shared1_a4,
57-
..Zeroable::zeroed()
57+
..Zeroable::init_zeroed()
5858
})
5959
.chain(|ret| {
6060
for (i, val) in cfg.shared1_tab.iter().enumerate() {
@@ -96,7 +96,7 @@ impl<'a> InitDataBuilder::ver<'a> {
9696
unk_28: Array::new([0xff; 16]),
9797
g14: Default::default(),
9898
unk_508: cfg.shared2_unk_508,
99-
..Zeroable::zeroed()
99+
..Zeroable::init_zeroed()
100100
})
101101
.chain(|ret| {
102102
for (i, val) in cfg.shared2_tab.iter().enumerate() {
@@ -791,7 +791,7 @@ impl<'a> InitDataBuilder::ver<'a> {
791791
unk_11edc: 0,
792792
#[ver(V >= V13_0B4)]
793793
unk_11efc: 0,
794-
..Zeroable::zeroed()
794+
..Zeroable::init_zeroed()
795795
})
796796
.chain(|raw| {
797797
for (i, pz) in self.dyncfg.pwr.power_zones.iter().enumerate() {

drivers/gpu/drm/asahi/mmu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -859,7 +859,7 @@ impl Handoff {
859859
self.unk3.store(0, Ordering::Relaxed);
860860
fence(Ordering::SeqCst);
861861

862-
let start = Instant::now();
862+
let start = Instant::<Monotonic>::now();
863863
const TIMEOUT: Delta = Delta::from_millis(1000);
864864

865865
self.lock();

drivers/gpu/drm/asahi/queue/mod.rs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,6 @@ impl JobFence::ver {
154154
#[versions(AGX)]
155155
#[vtable]
156156
impl dma_fence::FenceOps for JobFence::ver {
157-
const USE_64BIT_SEQNO: bool = true;
158-
159157
fn get_driver_name<'a>(self: &'a FenceObject<Self>) -> &'a CStr {
160158
c_str!("asahi")
161159
}

drivers/gpu/drm/asahi/regs.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -201,12 +201,13 @@ impl Resources {
201201
}
202202

203203
/// Start the ASC coprocessor CPU.
204-
pub(crate) fn start_cpu(&self) -> Result {
205-
let res = self.asc.try_access().ok_or(ENXIO)?;
206-
let val = res.read32_relaxed(CPU_CONTROL);
204+
pub(crate) fn start_cpu(pdev: &platform::Device<Core>) -> Result {
205+
let asc_req = pdev.io_request_by_name(c_str!("asc")).ok_or(EINVAL)?;
206+
let asc_iomem = KBox::pin_init(asc_req.iomap_sized::<ASC_CTL_SIZE>(), GFP_KERNEL)?;
207+
let res = asc_iomem.access(pdev.as_ref())?;
207208

209+
let val = res.read32_relaxed(CPU_CONTROL);
208210
res.write32_relaxed(val | CPU_RUN, CPU_CONTROL);
209-
210211
Ok(())
211212
}
212213

0 commit comments

Comments
 (0)