Skip to content

Commit 76e8d5d

Browse files
committed
Remove bonw15 nvidia quirk (handled by system76-driver)
1 parent 0b1bf8d commit 76e8d5d

File tree

1 file changed

+15
-51
lines changed

1 file changed

+15
-51
lines changed

src/graphics.rs

Lines changed: 15 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,9 @@
44

55
use crate::pci::PciBus;
66
use serde::{Deserialize, Serialize};
7-
use std::{
8-
fs,
9-
io::{self, Write},
10-
process::ExitStatus,
11-
};
7+
use std::{fs, io, process::ExitStatus};
128
use sysfs_class::{PciDevice, SysClass};
139

14-
const MODPROBE_PATH: &str = "/etc/modprobe.d/system76-power.conf";
15-
static MODPROBE_NO_GC6: &[u8] = br"# Automatically generated by system76-power
16-
options nvidia NVreg_DynamicPowerManagement=0x01
17-
";
18-
1910
const EXTERNAL_DISPLAY_REQUIRES_NVIDIA: &[&str] = &[
2011
"addw1",
2112
"addw2",
@@ -78,8 +69,8 @@ pub enum GraphicsDeviceError {
7869
}
7970

8071
pub struct GraphicsDevice {
81-
id: String,
82-
devid: u16,
72+
id: String,
73+
devid: u16,
8374
functions: Vec<PciDevice>,
8475
}
8576

@@ -90,14 +81,10 @@ impl GraphicsDevice {
9081
}
9182

9283
#[must_use]
93-
pub fn exists(&self) -> bool {
94-
self.functions.iter().any(|func| func.path().exists())
95-
}
84+
pub fn exists(&self) -> bool { self.functions.iter().any(|func| func.path().exists()) }
9685

9786
#[must_use]
98-
pub const fn device(&self) -> u16 {
99-
self.devid
100-
}
87+
pub const fn device(&self) -> u16 { self.devid }
10188

10289
pub unsafe fn unbind(&self) -> Result<(), GraphicsDeviceError> {
10390
for func in &self.functions {
@@ -134,7 +121,7 @@ impl GraphicsDevice {
134121
Ok(driver) => {
135122
log::error!("{}: in use by {}", func.id(), driver.id());
136123
return Err(GraphicsDeviceError::DeviceInUse {
137-
func: func.id().to_owned(),
124+
func: func.id().to_owned(),
138125
driver: driver.id().to_owned(),
139126
});
140127
}
@@ -166,12 +153,12 @@ impl GraphicsDevice {
166153
// supported-gpus.json
167154
#[derive(Serialize, Deserialize, Debug)]
168155
struct NvidiaDevice {
169-
devid: String,
170-
subdeviceid: Option<String>,
171-
subvendorid: Option<String>,
172-
name: String,
156+
devid: String,
157+
subdeviceid: Option<String>,
158+
subvendorid: Option<String>,
159+
name: String,
173160
legacybranch: Option<String>,
174-
features: Vec<String>,
161+
features: Vec<String>,
175162
}
176163

177164
#[derive(Serialize, Deserialize, Debug)]
@@ -180,11 +167,11 @@ struct SupportedGpus {
180167
}
181168

182169
pub struct Graphics {
183-
pub bus: PciBus,
184-
pub amd: Vec<GraphicsDevice>,
185-
pub intel: Vec<GraphicsDevice>,
170+
pub bus: PciBus,
171+
pub amd: Vec<GraphicsDevice>,
172+
pub intel: Vec<GraphicsDevice>,
186173
pub nvidia: Vec<GraphicsDevice>,
187-
pub other: Vec<GraphicsDevice>,
174+
pub other: Vec<GraphicsDevice>,
188175
}
189176

190177
impl Graphics {
@@ -255,29 +242,6 @@ impl Graphics {
255242
}
256243
}
257244

258-
let bonw15_hack = {
259-
let dmi_vendor = fs::read_to_string("/sys/class/dmi/id/sys_vendor").unwrap_or_default();
260-
let dmi_model =
261-
fs::read_to_string("/sys/class/dmi/id/product_version").unwrap_or_default();
262-
match (dmi_vendor.trim(), dmi_model.trim()) {
263-
("System76", "bonw15") => true,
264-
("System76", "bonw15-b") => true,
265-
_ => false,
266-
}
267-
};
268-
269-
if bonw15_hack {
270-
log::info!("Creating {}", MODPROBE_PATH);
271-
272-
let mut file = fs::OpenOptions::new()
273-
.create(true)
274-
.truncate(true)
275-
.write(true)
276-
.open(MODPROBE_PATH)?;
277-
278-
file.write_all(MODPROBE_NO_GC6).and_then(|()| file.sync_all())?;
279-
}
280-
281245
Ok(Self { bus, amd, intel, nvidia, other })
282246
}
283247

0 commit comments

Comments
 (0)