From 4fe7733cadd5e8dbbaea719255a929e66124753f Mon Sep 17 00:00:00 2001 From: Jeremy Soller Date: Wed, 7 Sep 2022 16:14:56 -0600 Subject: [PATCH] ided: Use pause instruction instead of yield_now when waiting for status --- ided/src/ide.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/ided/src/ide.rs b/ided/src/ide.rs index f5e82589c2..73fbe20d3b 100644 --- a/ided/src/ide.rs +++ b/ided/src/ide.rs @@ -1,6 +1,5 @@ use std::{ sync::{Arc, Mutex}, - thread, }; use syscall::{ error::{Error, Result, EIO}, @@ -9,6 +8,18 @@ use syscall::{ use crate::ata::AtaCommand; +#[cfg(target_arch = "aarch64")] +#[inline(always)] +pub(crate) unsafe fn pause() { std::arch::aarch64::__yield(); } + +#[cfg(target_arch = "x86")] +#[inline(always)] +pub(crate) unsafe fn pause() { std::arch::x86::_mm_pause(); } + +#[cfg(target_arch = "x86_64")] +#[inline(always)] +pub(crate) unsafe fn pause() { std::arch::x86_64::_mm_pause(); } + pub struct Channel { pub data8: Pio, pub data32: Pio, @@ -70,7 +81,7 @@ impl Channel { } while self.status.readf(0x80) { - thread::yield_now(); + unsafe { pause(); } } if check {