From 2e4ce27f6b05e745475528bdd37e57aceafefdda Mon Sep 17 00:00:00 2001 From: Luke D Jones Date: Wed, 10 Mar 2021 13:55:58 +1300 Subject: [PATCH] Hotfix: try to handle module remove gracefully Try to handle module remove more gracefully if in-use when the display manager is shutting down --- CHANGELOG.md | 6 ++++++ Cargo.lock | 2 +- daemon/Cargo.toml | 4 ++-- daemon/src/ctrl_gfx/gfx.rs | 42 +++++++++++++++++++++++++------------- 4 files changed, 37 insertions(+), 17 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c5afc92..7ffe01d0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +# [3.1.3] - 2021-03-10 +### Changed +- Hotfix: gracefully handle removing modules in use caused by display-manager not + fully shutdown at the time of trying to remove modules. It will now retry every + 250ms per module + # [3.1.2] - 2021-03-10 ### Changed - Test and create /etc/X11/xorg.conf.d/ if it doesn't exist diff --git a/Cargo.lock b/Cargo.lock index 0e6e699b..aaad17f3 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -187,7 +187,7 @@ dependencies = [ [[package]] name = "daemon" -version = "3.1.2" +version = "3.1.3" dependencies = [ "env_logger", "intel-pstate", diff --git a/daemon/Cargo.toml b/daemon/Cargo.toml index d85b10c3..60c1121d 100644 --- a/daemon/Cargo.toml +++ b/daemon/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "daemon" -version = "3.1.2" +version = "3.1.3" license = "MPL-2.0" readme = "README.md" authors = ["Luke "] @@ -40,4 +40,4 @@ toml = "^0.5" sysfs-class = "^0.1.2" # used for backlight control and baord ID rog_fan_curve = { version = "0.1", features = ["serde"] } # cpu power management -intel-pstate = "^0.2" \ No newline at end of file +intel-pstate = "^0.2" diff --git a/daemon/src/ctrl_gfx/gfx.rs b/daemon/src/ctrl_gfx/gfx.rs index 3db36edd..8aea6cf4 100644 --- a/daemon/src/ctrl_gfx/gfx.rs +++ b/daemon/src/ctrl_gfx/gfx.rs @@ -271,23 +271,37 @@ impl CtrlGraphics { } cmd.arg(driver); - let output = cmd - .output() - .map_err(|err| RogError::Command(format!("{:?}", cmd), err))?; - if !output.status.success() { - if output.stderr.ends_with("is not currently loaded\n".as_bytes()) { - return Ok(()) + let mut count = 0; + const MAX_TRIES: i32 = 6; + loop { + if count > MAX_TRIES { + let msg = format!("{} {} failed for unknown reason", action, driver); + error!("{}", msg); + return Ok(()) //Err(RogError::Modprobe(msg)); } - if output.stderr.ends_with("Permission denied\n".as_bytes()) { - let msg = format!("{} {} failed: {:?}", action, driver, String::from_utf8_lossy(&output.stderr)); - warn!("{}", msg); - warn!("It may be safe to ignore the above error, run `lsmod |grep nvidia` to confirm modules loaded"); - return Ok(()) + + let output = cmd + .output() + .map_err(|err| RogError::Command(format!("{:?}", cmd), err))?; + if !output.status.success() { + if output.stderr.ends_with("is not currently loaded\n".as_bytes()) { + return Ok(()) + } + if output.stderr.ends_with("Permission denied\n".as_bytes()) { + let msg = format!("{} {} failed: {:?}", action, driver, String::from_utf8_lossy(&output.stderr)); + warn!("{}", msg); + warn!("It may be safe to ignore the above error, run `lsmod |grep nvidia` to confirm modules loaded"); + return Ok(()) + } + if count == MAX_TRIES { + let msg = format!("{} {} failed: {:?}", action, driver, String::from_utf8_lossy(&output.stderr)); + return Err(RogError::Modprobe(msg)); + } } - let msg = format!("{} {} failed: {:?}", action, driver, String::from_utf8_lossy(&output.stderr)); - return Err(RogError::Modprobe(msg)); + + count += 1; + std::thread::sleep(std::time::Duration::from_millis(250)); } - Ok(()) } fn do_display_manager_action(action: &str) -> Result<(), RogError> {