Skip to content

Commit 162f419

Browse files
Manciukicbchalios
authored andcommitted
refactor(mmio): rename irq to gsi in MMIODeviceInfo
To have a more consistent naming, it's best to use GSI instead of IRQ, at least in places where it's meant just as an abstract index. Signed-off-by: Riccardo Mancini <[email protected]> Signed-off-by: Babis Chalios <[email protected]>
1 parent cf4d4cb commit 162f419

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/vmm/src/arch/aarch64/fdt.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ fn create_virtio_node(fdt: &mut FdtWriter, dev_info: &MMIODeviceInfo) -> Result<
379379
"interrupts",
380380
&[
381381
GIC_FDT_IRQ_TYPE_SPI,
382-
dev_info.irq.unwrap(),
382+
dev_info.gsi.unwrap(),
383383
IRQ_TYPE_EDGE_RISING,
384384
],
385385
)?;
@@ -400,7 +400,7 @@ fn create_serial_node(fdt: &mut FdtWriter, dev_info: &MMIODeviceInfo) -> Result<
400400
"interrupts",
401401
&[
402402
GIC_FDT_IRQ_TYPE_SPI,
403-
dev_info.irq.unwrap(),
403+
dev_info.gsi.unwrap(),
404404
IRQ_TYPE_EDGE_RISING,
405405
],
406406
)?;

src/vmm/src/device_manager/mmio.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,8 @@ pub struct MMIODeviceInfo {
7373
pub addr: u64,
7474
/// Mmio addr range length.
7575
pub len: u64,
76-
/// Used Irq line for the device.
77-
pub irq: Option<u32>,
76+
/// Used GSI (interrupt line) for the device.
77+
pub gsi: Option<u32>,
7878
}
7979

8080
#[cfg(target_arch = "x86_64")]
@@ -169,7 +169,7 @@ impl MMIODeviceManager {
169169
AllocPolicy::FirstMatch,
170170
)?,
171171
len: MMIO_LEN,
172-
irq: gsi,
172+
gsi,
173173
};
174174
Ok(device_info)
175175
}
@@ -183,7 +183,7 @@ impl MMIODeviceManager {
183183
) -> Result<(), MmioError> {
184184
// Our virtio devices are currently hardcoded to use a single IRQ.
185185
// Validate that requirement.
186-
let gsi = device.resources.irq.ok_or(MmioError::InvalidIrqConfig)?;
186+
let gsi = device.resources.gsi.ok_or(MmioError::InvalidIrqConfig)?;
187187
let identifier;
188188
{
189189
let mmio_device = device.inner.lock().expect("Poisoned lock");
@@ -226,7 +226,7 @@ impl MMIODeviceManager {
226226
.add_virtio_mmio_device(
227227
device_info.len,
228228
GuestAddress(device_info.addr),
229-
device_info.irq.unwrap(),
229+
device_info.gsi.unwrap(),
230230
None,
231231
)
232232
.map_err(MmioError::Cmdline)
@@ -255,7 +255,7 @@ impl MMIODeviceManager {
255255
device.resources.len,
256256
// We are sure that `irqs` has at least one element; allocate_mmio_resources makes
257257
// sure of it.
258-
device.resources.irq.unwrap(),
258+
device.resources.gsi.unwrap(),
259259
)?;
260260
}
261261
self.register_mmio_virtio(vm, device_id, device)?;
@@ -280,13 +280,13 @@ impl MMIODeviceManager {
280280
MMIODeviceInfo {
281281
addr: SERIAL_MEM_START,
282282
len: MMIO_LEN,
283-
irq: Some(gsi[0]),
283+
gsi: Some(gsi[0]),
284284
}
285285
};
286286

287287
vm.register_irq(
288288
serial.lock().expect("Poisoned lock").serial.interrupt_evt(),
289-
device_info.irq.unwrap(),
289+
device_info.gsi.unwrap(),
290290
)
291291
.map_err(MmioError::RegisterIrqFd)?;
292292

@@ -339,7 +339,7 @@ impl MMIODeviceManager {
339339
MMIODeviceInfo {
340340
addr: RTC_MEM_START,
341341
len: MMIO_LEN,
342-
irq: Some(gsi[0]),
342+
gsi: Some(gsi[0]),
343343
}
344344
};
345345

@@ -367,7 +367,7 @@ impl MMIODeviceManager {
367367
let device_info = MMIODeviceInfo {
368368
addr: BOOT_DEVICE_MEM_START,
369369
len: MMIO_LEN,
370-
irq: None,
370+
gsi: None,
371371
};
372372

373373
let device = MMIODevice {
@@ -496,7 +496,7 @@ pub(crate) mod tests {
496496
pub fn used_irqs_count(&self) -> usize {
497497
self.virtio_devices
498498
.iter()
499-
.filter(|(_, mmio_dev)| mmio_dev.resources.irq.is_some())
499+
.filter(|(_, mmio_dev)| mmio_dev.resources.gsi.is_some())
500500
.count()
501501
}
502502
}
@@ -612,15 +612,15 @@ pub(crate) mod tests {
612612
let dev = device_manager.get_virtio_device(0, "dummy").unwrap();
613613
assert_eq!(dev.resources.addr, arch::MEM_32BIT_DEVICES_START);
614614
assert_eq!(dev.resources.len, MMIO_LEN);
615-
assert_eq!(dev.resources.irq, Some(arch::GSI_LEGACY_START));
615+
assert_eq!(dev.resources.gsi, Some(arch::GSI_LEGACY_START));
616616

617617
device_manager
618618
.for_each_virtio_device(|virtio_type, device_id, mmio_device| {
619619
assert_eq!(*virtio_type, 0);
620620
assert_eq!(device_id, "dummy");
621621
assert_eq!(mmio_device.resources.addr, arch::MEM_32BIT_DEVICES_START);
622622
assert_eq!(mmio_device.resources.len, MMIO_LEN);
623-
assert_eq!(mmio_device.resources.irq, Some(arch::GSI_LEGACY_START));
623+
assert_eq!(mmio_device.resources.gsi, Some(arch::GSI_LEGACY_START));
624624
Ok::<(), ()>(())
625625
})
626626
.unwrap();
@@ -714,7 +714,7 @@ pub(crate) mod tests {
714714
crate::arch::GSI_LEGACY_START,
715715
device_manager.virtio_devices[&(type_id, id)]
716716
.resources
717-
.irq
717+
.gsi
718718
.unwrap()
719719
);
720720

@@ -751,7 +751,7 @@ pub(crate) mod tests {
751751
let device_info = device_manager
752752
.allocate_mmio_resources(&mut resource_allocator, 0)
753753
.unwrap();
754-
assert!(device_info.irq.is_none());
754+
assert!(device_info.gsi.is_none());
755755
}
756756

757757
#[test]
@@ -762,7 +762,7 @@ pub(crate) mod tests {
762762
let device_info = device_manager
763763
.allocate_mmio_resources(&mut resource_allocator, 1)
764764
.unwrap();
765-
assert_eq!(device_info.irq.unwrap(), crate::arch::GSI_LEGACY_START);
765+
assert_eq!(device_info.gsi.unwrap(), crate::arch::GSI_LEGACY_START);
766766
}
767767

768768
#[test]

0 commit comments

Comments
 (0)