arch/x86: Fix MSI MAP destination

When Zephyr runs directly on actual hardware, it will be always
directing MSI messages to BSP (BootStrap Processor). This was fine until
Zephyr could be ran on virtualizor that may NOT run it on BSP.

So directing MSI messages on current processor. If Zephyr runs on actual
hardware, it will be BSP since such setup is always made at boot time by
the BSP. On other use case it will be whatever is relevant at that time.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2022-02-04 10:28:13 +01:00 committed by Anas Nashif
parent 0affb29572
commit 0c9ce49d2a

View file

@ -17,6 +17,7 @@
#include <device.h>
#include <drivers/pcie/msi.h>
#include <drivers/interrupt_controller/sysapic.h>
#include <arch/x86/cpuid.h>
#endif
/* PCI Express Extended Configuration Mechanism (MMIO) */
@ -181,10 +182,15 @@ static bool get_vtd(void)
/* these functions are explained in include/drivers/pcie/msi.h */
#define MSI_MAP_DESTINATION_ID_SHIFT 12
#define MSI_RH BIT(3)
uint32_t pcie_msi_map(unsigned int irq,
msi_vector_t *vector,
uint8_t n_vector)
{
uint32_t dest_id;
ARG_UNUSED(irq);
#if defined(CONFIG_INTEL_VTD_ICTL)
@ -192,7 +198,14 @@ uint32_t pcie_msi_map(unsigned int irq,
return vtd_remap_msi(vtd, vector, n_vector);
}
#endif
return 0xFEE00000U; /* standard delivery to BSP local APIC */
dest_id = z_x86_cpuid_get_current_physical_apic_id() <<
MSI_MAP_DESTINATION_ID_SHIFT;
/* Directing to current physical CPU (may not be BSP)
* Destination ID - RH 1 - DM 0
*/
return 0xFEE00000U | dest_id | MSI_RH;
}
uint16_t pcie_msi_mdr(unsigned int irq,