From 3890840001a2c66fc61a8ee77696eab90f9df883 Mon Sep 17 00:00:00 2001 From: Admin Pupkin Date: Wed, 20 May 2026 17:55:36 +0300 Subject: [PATCH] base: Add IRQ affinity logging and CPU tracking to pcid (P49) Track the target CPU ID in InterruptVector, and log the interrupt type (MSI-X/MSI/Legacy) and CPU affinity at allocation time in pci_allocate_interrupt_vector. Add log_affinity() helper for drivers to call after setup. --- .../base/P49-irq-affinity-logging.patch | 46 +++++++++++++++++++ recipes/core/base/recipe.toml | 2 + 2 files changed, 48 insertions(+) create mode 100644 local/patches/base/P49-irq-affinity-logging.patch diff --git a/local/patches/base/P49-irq-affinity-logging.patch b/local/patches/base/P49-irq-affinity-logging.patch new file mode 100644 index 0000000000..c925243742 --- /dev/null +++ b/local/patches/base/P49-irq-affinity-logging.patch @@ -0,0 +1,46 @@ +diff --git a/drivers/pcid/src/driver_interface/irq_helpers.rs b/drivers/pcid/src/driver_interface/irq_helpers.rs +index 28ca077a..dadf6192 100644 +--- a/drivers/pcid/src/driver_interface/irq_helpers.rs ++++ b/drivers/pcid/src/driver_interface/irq_helpers.rs +@@ -233,0 +234 @@ pub struct InterruptVector { ++ cpu_id: usize, +@@ -251,0 +253,4 @@ impl InterruptVector { ++ pub fn cpu_id(&self) -> usize { ++ self.cpu_id ++ } ++ +@@ -260,0 +266,14 @@ impl InterruptVector { ++ ++ /// Log the IRQ affinity for this vector. ++ pub fn log_affinity(&self, driver: &str) { ++ let kind_str = match self.kind { ++ InterruptVectorKind::Legacy => "legacy", ++ InterruptVectorKind::Msi => "MSI", ++ InterruptVectorKind::MsiX { .. } => "MSI-X", ++ }; ++ log::info!( ++ "{driver}: IRQ affinity = {kind_str} on CPU {} vector {}", ++ self.cpu_id, ++ self.vector ++ ); ++ } +@@ -294,0 +314 @@ pub fn pci_allocate_interrupt_vector( ++ log::info!("{driver}: allocated MSI-X interrupt on CPU {bsp_cpu_id}"); +@@ -297,0 +318 @@ pub fn pci_allocate_interrupt_vector( ++ cpu_id: bsp_cpu_id, +@@ -300,0 +322,3 @@ pub fn pci_allocate_interrupt_vector( ++ let bsp_cpu_id = read_bsp_apic_id() ++ .unwrap_or_else(|err| panic!("{driver}: failed to read BSP APIC ID: {err}")); ++ log::info!("{driver}: allocated MSI interrupt on CPU {bsp_cpu_id}"); +@@ -303,0 +328 @@ pub fn pci_allocate_interrupt_vector( ++ cpu_id: bsp_cpu_id, +@@ -307,0 +333,2 @@ pub fn pci_allocate_interrupt_vector( ++ let bsp_cpu_id = read_bsp_apic_id().unwrap_or(0); ++ log::info!("{driver}: allocated legacy INTx interrupt on CPU {bsp_cpu_id}"); +@@ -310,0 +338 @@ pub fn pci_allocate_interrupt_vector( ++ cpu_id: bsp_cpu_id, +@@ -325,0 +354,2 @@ pub fn pci_allocate_interrupt_vector( ++ let bsp_cpu_id = read_bsp_apic_id().unwrap_or(0); ++ log::info!("{driver}: allocated legacy INTx interrupt on CPU {bsp_cpu_id}"); +@@ -328,0 +359 @@ pub fn pci_allocate_interrupt_vector( ++ cpu_id: bsp_cpu_id, diff --git a/recipes/core/base/recipe.toml b/recipes/core/base/recipe.toml index 46b1b34074..56a092478f 100644 --- a/recipes/core/base/recipe.toml +++ b/recipes/core/base/recipe.toml @@ -97,6 +97,8 @@ patches = [ "P47-thermald-backend.patch", # P48: Add ACPI fan device discovery and status exposure "P48-acpid-fan-support.patch", + # P49: Add IRQ affinity logging and CPU tracking to pcid + "P49-irq-affinity-logging.patch", ] [package]