|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [PATCH v1 16/16] drivers/vuart: hook simple MMIO-based UART to vUART framework
From: Denis Mukhin <dmukhin@xxxxxxxx>
Add new emulation flag DOMAIN_EMU_UART_MMIO and add it to domain_has_vuart().
Add needed shims for vuart framework integration to MMIO-based UART emulator.
Remove domain_vuart_{init,free}() and use generic vuart_{init,exit}() calls.
No functional change intended.
Signed-off-by: Denis Mukhin <dmukhin@xxxxxxxx>
---
xen/arch/arm/domain.c | 7 +++++--
xen/common/domain.c | 3 +++
xen/drivers/vuart/vuart-mmio.c | 36 ++++++++++++++++++++++++++++++++--
xen/include/xen/domain-emu.h | 1 +
xen/include/xen/vuart.h | 20 -------------------
5 files changed, 43 insertions(+), 24 deletions(-)
diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
index 3579d10d7e1d..5d7006241be0 100644
--- a/xen/arch/arm/domain.c
+++ b/xen/arch/arm/domain.c
@@ -780,7 +780,10 @@ int arch_domain_create(struct domain *d,
* Only use it for the hardware domain because the linux kernel may not
* support multi-platform.
*/
- if ( is_hardware_domain(d) && (rc = domain_vuart_init(d)) )
+ if ( is_hardware_domain(d) && IS_ENABLED(CONFIG_HAS_VUART_MMIO) )
+ d->emulation_flags |= DOMAIN_EMU_UART_MMIO;
+
+ if ( domain_has_vuart(d) && (rc = vuart_init(d, NULL)) != 0 )
goto fail;
if ( (rc = domain_vpci_init(d)) != 0 )
@@ -849,7 +852,7 @@ void arch_domain_destroy(struct domain *d)
iommu_domain_destroy(d);
p2m_final_teardown(d);
domain_vgic_free(d);
- domain_vuart_free(d);
+ vuart_exit(d);
free_xenheap_page(d->shared_info);
#ifdef CONFIG_ACPI
free_xenheap_pages(d->arch.efi_acpi_table,
diff --git a/xen/common/domain.c b/xen/common/domain.c
index 071fee81fe2c..fc0ceb266d88 100644
--- a/xen/common/domain.c
+++ b/xen/common/domain.c
@@ -2443,6 +2443,9 @@ bool domain_has_vuart(const struct domain *d)
if ( IS_ENABLED(CONFIG_HAS_VUART_PL011) )
mask |= DOMAIN_EMU_UART_PL011;
+ if ( IS_ENABLED(CONFIG_HAS_VUART_MMIO) )
+ mask |= DOMAIN_EMU_UART_MMIO;
+
return !!(d->emulation_flags & mask);
}
diff --git a/xen/drivers/vuart/vuart-mmio.c b/xen/drivers/vuart/vuart-mmio.c
index 66fac6c994ce..1888e44e3d94 100644
--- a/xen/drivers/vuart/vuart-mmio.c
+++ b/xen/drivers/vuart/vuart-mmio.c
@@ -49,7 +49,7 @@ static const struct mmio_handler_ops vuart_mmio_handler = {
.write = vuart_mmio_write,
};
-int domain_vuart_init(struct domain *d)
+static int cf_check vuart_mmio_init(struct domain *d, struct vuart_params
*params)
{
const struct vuart_info *info;
struct vuart *vdev;
@@ -86,7 +86,7 @@ int domain_vuart_init(struct domain *d)
return 0;
}
-void domain_vuart_free(struct domain *d)
+static void cf_check vuart_mmio_exit(struct domain *d)
{
struct vuart *vdev = d->arch.vuart;
@@ -147,6 +147,38 @@ static int vuart_mmio_write(struct vcpu *v, mmio_info_t
*info,
return 1;
}
+static void cf_check vuart_mmio_dump(const struct domain *d)
+{
+ struct vuart *vdev = d->arch.vuart;
+
+ if ( !vdev )
+ return;
+
+ /* Allow printing state in case of a deadlock. */
+ if ( !spin_trylock(&vdev->lock) )
+ return;
+
+ printk("Virtual MMIO UART@%"PRIpaddr" owner %pd\n",
+ vdev->info->base_addr, d);
+ printk(" RX FIFO size %u idx %u\n",
+ VUART_BUF_SIZE, vdev->idx);
+ printk(" status 0x%lx 0x%lx\n",
+ vdev->info->status_off, vdev->info->status);
+
+ spin_unlock(&vdev->lock);
+}
+
+static const struct vuart_ops vuart_mmio_ops = {
+ .add_fwnode = NULL,
+ .init = vuart_mmio_init,
+ .exit = vuart_mmio_exit,
+ .dump = vuart_mmio_dump,
+ /* Physical console focus is not supported */
+ .putchar = NULL,
+};
+
+VUART_REGISTER(mmio, &vuart_mmio_ops);
+
/*
* Local variables:
* mode: C
diff --git a/xen/include/xen/domain-emu.h b/xen/include/xen/domain-emu.h
index 1d3a6c80fadd..9ef607666842 100644
--- a/xen/include/xen/domain-emu.h
+++ b/xen/include/xen/domain-emu.h
@@ -18,6 +18,7 @@
#define DOMAIN_EMU_PCI (1U << 10)
#define DOMAIN_EMU_UART_PL011 (1U << 15)
+#define DOMAIN_EMU_UART_MMIO (1U << 16)
#endif /* XEN_DOMAIN_EMU_H */
diff --git a/xen/include/xen/vuart.h b/xen/include/xen/vuart.h
index 1f4b47575359..4c923025b4eb 100644
--- a/xen/include/xen/vuart.h
+++ b/xen/include/xen/vuart.h
@@ -60,26 +60,6 @@ static inline int vuart_putchar(struct domain *d, char c)
#endif /* CONFIG_HAS_VUART */
-#ifdef CONFIG_HAS_VUART_MMIO
-
-int domain_vuart_init(struct domain *d);
-void domain_vuart_free(struct domain *d);
-
-#else
-
-static inline int domain_vuart_init(struct domain *d)
-{
- /*
- * The vUART is unconditionally inialized for the hw domain. So we
- * can't return an error.
- */
- return 0;
-}
-
-static inline void domain_vuart_free(struct domain *d) {};
-
-#endif /* CONFIG_HAS_VUART_MMIO */
-
#endif /* XEN_VUART_H */
/*
--
2.34.1
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |