Re: [PATCH kvm-unit-tests v4] arm: Add PL031 test

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 





On 25.07.19 15:25, Andrew Jones wrote:
On Thu, Jul 25, 2019 at 03:09:49PM +0200, Alexander Graf wrote:
This patch adds a unit test for the PL031 RTC that is used in the virt machine.
It just pokes basic functionality. I've mostly written it to familiarize myself
with the device, but I suppose having the test around does not hurt, as it also
exercises the GIC SPI interrupt path.

Signed-off-by: Alexander Graf <graf@xxxxxxxxxx>
Reviewed-by: Andrew Jones <drjones@xxxxxxxxxx>

---

v1 -> v2:

   - Use FDT to find base, irq and existence
   - Put isb after timer read
   - Use dist_base for gicv3

v2 -> v3

   - Enable compilation on 32bit ARM target
   - Use ioremap

v3 -> v4:

   - Use dt_pbus_translate_node()
   - Make irq_triggered volatile
---
  arm/Makefile.common |   1 +
  arm/pl031.c         | 260 ++++++++++++++++++++++++++++++++++++++++++++
  lib/arm/asm/gic.h   |   1 +
  3 files changed, 262 insertions(+)
  create mode 100644 arm/pl031.c

Thanks for the new version. I have a new nit (below), but my r-b stands
with or without making another change.

[...]

+static int rtc_fdt_init(void)
+{
+	const struct fdt_property *prop;
+	const void *fdt = dt_fdt();
+	struct dt_pbus_reg base;
+	int node, len;
+	u32 *data;
+
+	node = fdt_node_offset_by_compatible(fdt, -1, "arm,pl031");
+	if (node < 0)
+		return -1;
+
+	prop = fdt_get_property(fdt, node, "interrupts", &len);
+	assert(prop && len == (3 * sizeof(u32)));
+	data = (u32 *)prop->data;
+	assert(data[0] == 0); /* SPI */
+	pl031_irq = SPI(fdt32_to_cpu(data[1]));
+
+	assert(!dt_pbus_translate_node(node, 0, &base));

We prefer to do something like

  ret = dt_pbus_translate_node(node, 0, &base);
  assert(!ret);

than the above, just in case we ever compiled with assert() defined as a
no-op. But the probability of doing that is pretty close to zero.

Yeah, but before someone wastes an hour of debugging on this later, let's fix it right away. Thanks for catching it! :)


Alex
_______________________________________________
kvmarm mailing list
kvmarm@xxxxxxxxxxxxxxxxxxxxx
https://lists.cs.columbia.edu/mailman/listinfo/kvmarm



[Index of Archives]     [Linux KVM]     [Spice Development]     [Libvirt]     [Libvirt Users]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux