drivers/virtualization: Fix ivshmem PCIE reg bar lookup on ivshmem-plain

This is a fix for ACRN targets. Qemu ivshmem original specs do not
states that, if ivshmem-plain is selected, bar0 (the register bar) will
not be present. It just says that bar2 will only be sufficient.
And that is what happens on qemu: whether ivshmem-plain or
ivshmem-doorbell is selected, bar0 is always present no matter what.

This does not seem to be the case in ACRN which does not expose the
bar0 if ivshmem-plain is selected.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
This commit is contained in:
Tomasz Bursztyka 2021-02-05 08:17:49 +01:00 committed by Anas Nashif
commit e69c357e78

View file

@ -95,8 +95,12 @@ static void register_signal(const struct device *dev,
}
#else
static const struct ivshmem_reg no_reg;
#define ivshmem_configure_interrupts(...) true
#define register_signal(...)
#endif /* CONFIG_IVSHMEM_DOORBELL */
static bool ivshmem_check_on_bdf(pcie_bdf_t bdf)
@ -142,15 +146,21 @@ static bool ivshmem_configure(const struct device *dev)
struct pcie_mbar mbar_regs, mbar_mem;
if (!pcie_get_mbar(data->bdf, IVSHMEM_PCIE_REG_BAR_IDX, &mbar_regs)) {
#ifdef CONFIG_IVSHMEM_DOORBELL
LOG_ERR("ivshmem regs bar not found");
return false;
#else
LOG_DBG("ivshmem regs bar not found");
device_map(DEVICE_MMIO_RAM_PTR(dev), (uintptr_t)&no_reg,
sizeof(struct ivshmem_reg), K_MEM_CACHE_NONE);
#endif /* CONFIG_IVSHMEM_DOORBELL */
} else {
pcie_set_cmd(data->bdf, PCIE_CONF_CMDSTAT_MEM, true);
device_map(DEVICE_MMIO_RAM_PTR(dev), mbar_regs.phys_addr,
mbar_regs.size, K_MEM_CACHE_NONE);
}
pcie_set_cmd(data->bdf, PCIE_CONF_CMDSTAT_MEM, true);
device_map(DEVICE_MMIO_RAM_PTR(dev), mbar_regs.phys_addr,
mbar_regs.size, K_MEM_CACHE_NONE);
if (!pcie_get_mbar(data->bdf, IVSHMEM_PCIE_SHMEM_BAR_IDX, &mbar_mem)) {
LOG_ERR("ivshmem mem bar not found");
return false;