diff --git a/audio/ihdad/src/main.rs b/audio/ihdad/src/main.rs index bab7c5b6df..e86cc832a4 100755 --- a/audio/ihdad/src/main.rs +++ b/audio/ihdad/src/main.rs @@ -82,17 +82,10 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File { let all_pci_features = pcid_handle.fetch_all_features().expect("ihdad: failed to fetch pci features"); log::debug!("PCI FEATURES: {:?}", all_pci_features); - let (has_msi, mut msi_enabled) = all_pci_features.iter().map(|(feature, status)| (feature.is_msi(), status.is_enabled())).find(|&(f, _)| f).unwrap_or((false, false)); - let (has_msix, mut msix_enabled) = all_pci_features.iter().map(|(feature, status)| (feature.is_msix(), status.is_enabled())).find(|&(f, _)| f).unwrap_or((false, false)); + let has_msi = all_pci_features.iter().any(|feature| feature.is_msi()); + let has_msix = all_pci_features.iter().any(|feature| feature.is_msix()); - if has_msi && !msi_enabled && !has_msix { - msi_enabled = true; - } - if has_msix && !msix_enabled { - msix_enabled = true; - } - - if msi_enabled && !msix_enabled { + if has_msi && !has_msix { let capability = match pcid_handle.feature_info(PciFeature::Msi).expect("ihdad: failed to retrieve the MSI capability structure from pcid") { PciFeatureInfo::Msi(s) => s, PciFeatureInfo::MsiX(_) => panic!(), diff --git a/net/rtl8139d/src/main.rs b/net/rtl8139d/src/main.rs index b04e5a7829..fc51f4653b 100644 --- a/net/rtl8139d/src/main.rs +++ b/net/rtl8139d/src/main.rs @@ -101,17 +101,10 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File { let all_pci_features = pcid_handle.fetch_all_features().expect("rtl8139d: failed to fetch pci features"); log::info!("PCI FEATURES: {:?}", all_pci_features); - let (has_msi, mut msi_enabled) = all_pci_features.iter().map(|(feature, status)| (feature.is_msi(), status.is_enabled())).find(|&(f, _)| f).unwrap_or((false, false)); - let (has_msix, mut msix_enabled) = all_pci_features.iter().map(|(feature, status)| (feature.is_msix(), status.is_enabled())).find(|&(f, _)| f).unwrap_or((false, false)); + let has_msi = all_pci_features.iter().any(|feature| feature.is_msi()); + let has_msix = all_pci_features.iter().any(|feature| feature.is_msix()); - if has_msi && !msi_enabled && !has_msix { - msi_enabled = true; - } - if has_msix && !msix_enabled { - msix_enabled = true; - } - - if msi_enabled && !msix_enabled { + if has_msi && !has_msix { let capability = match pcid_handle.feature_info(PciFeature::Msi).expect("rtl8139d: failed to retrieve the MSI capability structure from pcid") { PciFeatureInfo::Msi(s) => s, PciFeatureInfo::MsiX(_) => panic!(), @@ -135,7 +128,7 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File { log::info!("Enabled MSI"); interrupt_handle - } else if msix_enabled { + } else if has_msix { let capability = match pcid_handle.feature_info(PciFeature::MsiX).expect("rtl8139d: failed to retrieve the MSI-X capability structure from pcid") { PciFeatureInfo::Msi(_) => panic!(), PciFeatureInfo::MsiX(s) => s, diff --git a/net/rtl8168d/src/main.rs b/net/rtl8168d/src/main.rs index e2d594948e..d13cc10d80 100644 --- a/net/rtl8168d/src/main.rs +++ b/net/rtl8168d/src/main.rs @@ -96,17 +96,10 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File { let all_pci_features = pcid_handle.fetch_all_features().expect("rtl8168d: failed to fetch pci features"); log::info!("PCI FEATURES: {:?}", all_pci_features); - let (has_msi, mut msi_enabled) = all_pci_features.iter().map(|(feature, status)| (feature.is_msi(), status.is_enabled())).find(|&(f, _)| f).unwrap_or((false, false)); - let (has_msix, mut msix_enabled) = all_pci_features.iter().map(|(feature, status)| (feature.is_msix(), status.is_enabled())).find(|&(f, _)| f).unwrap_or((false, false)); + let has_msi = all_pci_features.iter().any(|feature| feature.is_msi()); + let has_msix = all_pci_features.iter().any(|feature| feature.is_msix()); - if has_msi && !msi_enabled && !has_msix { - msi_enabled = true; - } - if has_msix && !msix_enabled { - msix_enabled = true; - } - - if msi_enabled && !msix_enabled { + if has_msi && !has_msix { let capability = match pcid_handle.feature_info(PciFeature::Msi).expect("rtl8168d: failed to retrieve the MSI capability structure from pcid") { PciFeatureInfo::Msi(s) => s, PciFeatureInfo::MsiX(_) => panic!(), @@ -130,7 +123,7 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle) -> File { log::info!("Enabled MSI"); interrupt_handle - } else if msix_enabled { + } else if has_msix { let capability = match pcid_handle.feature_info(PciFeature::MsiX).expect("rtl8168d: failed to retrieve the MSI-X capability structure from pcid") { PciFeatureInfo::Msi(_) => panic!(), PciFeatureInfo::MsiX(s) => s, diff --git a/pcid/src/driver_handler.rs b/pcid/src/driver_handler.rs index 741e374fe4..210cf9eefe 100644 --- a/pcid/src/driver_handler.rs +++ b/pcid/src/driver_handler.rs @@ -118,13 +118,8 @@ impl DriverHandler { self.capabilities .iter() .filter_map(|capability| match capability { - PciCapability::Msi(msi) => { - Some((PciFeature::Msi, FeatureStatus::enabled(msi.enabled()))) - } - PciCapability::MsiX(msix) => Some(( - PciFeature::MsiX, - FeatureStatus::enabled(msix.msix_enabled()), - )), + PciCapability::Msi(_) => Some(PciFeature::Msi), + PciCapability::MsiX(_) => Some(PciFeature::MsiX), _ => None, }) .collect(), diff --git a/pcid/src/driver_interface/mod.rs b/pcid/src/driver_interface/mod.rs index 32e324ec4e..d7c1cdf16a 100644 --- a/pcid/src/driver_interface/mod.rs +++ b/pcid/src/driver_interface/mod.rs @@ -212,7 +212,7 @@ pub enum PcidServerResponseError { pub enum PcidClientResponse { Capabilities(Vec), Config(SubdriverArguments), - AllFeatures(Vec<(PciFeature, FeatureStatus)>), + AllFeatures(Vec), FeatureEnabled(PciFeature), FeatureStatus(PciFeature, FeatureStatus), Error(PcidServerResponseError), @@ -287,7 +287,7 @@ impl PcidServerHandle { } // FIXME turn into struct with bool fields - pub fn fetch_all_features(&mut self) -> Result> { + pub fn fetch_all_features(&mut self) -> Result> { self.send(&PcidClientRequest::RequestFeatures)?; match self.recv()? { PcidClientResponse::AllFeatures(a) => Ok(a), diff --git a/storage/nvmed/src/main.rs b/storage/nvmed/src/main.rs index 3ca9b0e22c..dd9c1682c8 100644 --- a/storage/nvmed/src/main.rs +++ b/storage/nvmed/src/main.rs @@ -76,8 +76,8 @@ fn get_int_method( let features = pcid_handle.fetch_all_features().unwrap(); - let has_msi = features.iter().any(|(feature, _)| feature.is_msi()); - let has_msix = features.iter().any(|(feature, _)| feature.is_msix()); + let has_msi = features.iter().any(|feature| feature.is_msi()); + let has_msix = features.iter().any(|feature| feature.is_msix()); // TODO: Allocate more than one vector when possible and useful. if has_msix { diff --git a/virtio-core/src/arch/x86.rs b/virtio-core/src/arch/x86.rs index 23fdbbf3a0..be993050c5 100644 --- a/virtio-core/src/arch/x86.rs +++ b/virtio-core/src/arch/x86.rs @@ -20,9 +20,7 @@ pub fn probe_legacy_port_transport( // Setup interrupts. let all_pci_features = pcid_handle.fetch_all_features()?; - let has_msix = all_pci_features - .iter() - .any(|(feature, _)| feature.is_msix()); + let has_msix = all_pci_features.iter().any(|feature| feature.is_msix()); // According to the virtio specification, the device REQUIRED to support MSI-X. assert!(has_msix, "virtio: device does not support MSI-X"); diff --git a/virtio-core/src/arch/x86_64.rs b/virtio-core/src/arch/x86_64.rs index fa0de00c6c..7b95c4fe84 100644 --- a/virtio-core/src/arch/x86_64.rs +++ b/virtio-core/src/arch/x86_64.rs @@ -61,9 +61,7 @@ pub fn probe_legacy_port_transport( // Setup interrupts. let all_pci_features = pcid_handle.fetch_all_features()?; - let has_msix = all_pci_features - .iter() - .any(|(feature, _)| feature.is_msix()); + let has_msix = all_pci_features.iter().any(|feature| feature.is_msix()); // According to the virtio specification, the device REQUIRED to support MSI-X. assert!(has_msix, "virtio: device does not support MSI-X"); diff --git a/virtio-core/src/probe.rs b/virtio-core/src/probe.rs index aebd065d04..e61898f848 100644 --- a/virtio-core/src/probe.rs +++ b/virtio-core/src/probe.rs @@ -123,7 +123,8 @@ pub fn probe_device(pcid_handle: &mut PcidServerHandle) -> Result // SAFETY: The capability type is `Notify`, so its safe to access // the `notify_multiplier` field. let multiplier = unsafe { - (&*(raw_capability.data.as_ptr() as *const PciCapability as *const PciCapabilityNotify)) + (&*(raw_capability.data.as_ptr() as *const PciCapability + as *const PciCapabilityNotify)) .notify_off_multiplier() }; notify_addr = Some((address, multiplier)); @@ -161,9 +162,7 @@ pub fn probe_device(pcid_handle: &mut PcidServerHandle) -> Result // Setup interrupts. let all_pci_features = pcid_handle.fetch_all_features()?; - let has_msix = all_pci_features - .iter() - .any(|(feature, _)| feature.is_msix()); + let has_msix = all_pci_features.iter().any(|feature| feature.is_msix()); // According to the virtio specification, the device REQUIRED to support MSI-X. assert!(has_msix, "virtio: device does not support MSI-X"); diff --git a/xhcid/src/main.rs b/xhcid/src/main.rs index 6a10660160..047e16e148 100644 --- a/xhcid/src/main.rs +++ b/xhcid/src/main.rs @@ -91,17 +91,10 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle, bar0_address: usize) -> (O let all_pci_features = pcid_handle.fetch_all_features().expect("xhcid: failed to fetch pci features"); log::debug!("XHCI PCI FEATURES: {:?}", all_pci_features); - let (has_msi, mut msi_enabled) = all_pci_features.iter().map(|(feature, status)| (feature.is_msi(), status.is_enabled())).find(|&(f, _)| f).unwrap_or((false, false)); - let (has_msix, mut msix_enabled) = all_pci_features.iter().map(|(feature, status)| (feature.is_msix(), status.is_enabled())).find(|&(f, _)| f).unwrap_or((false, false)); + let has_msi = all_pci_features.iter().any(|feature| feature.is_msi()); + let has_msix = all_pci_features.iter().any(|feature| feature.is_msix()); - if has_msi && !msi_enabled && !has_msix { - msi_enabled = true; - } - if has_msix && !msix_enabled { - msix_enabled = true; - } - - if msi_enabled && !msix_enabled { + if has_msi && !has_msix { let mut capability = match pcid_handle.feature_info(PciFeature::Msi).expect("xhcid: failed to retrieve the MSI capability structure from pcid") { PciFeatureInfo::Msi(s) => s, PciFeatureInfo::MsiX(_) => panic!(), @@ -125,7 +118,7 @@ fn get_int_method(pcid_handle: &mut PcidServerHandle, bar0_address: usize) -> (O log::debug!("Enabled MSI"); (Some(interrupt_handle), InterruptMethod::Msi) - } else if msix_enabled { + } else if has_msix { let capability = match pcid_handle.feature_info(PciFeature::MsiX).expect("xhcid: failed to retrieve the MSI-X capability structure from pcid") { PciFeatureInfo::Msi(_) => panic!(), PciFeatureInfo::MsiX(s) => s,