* [Qemu-devel] qtest and pci mmio?
@ 2014-05-07 16:06 Gerd Hoffmann
2014-05-07 16:41 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Gerd Hoffmann @ 2014-05-07 16:06 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 298 bytes --]
Hi,
Trying to add something real to the new ehci test. Having trouble
accessing the ehci mmio registers. uhci io registers are working fine.
Current patch attached, which just does a register dump to stderr. uhci
looks sane. ehci shouldn't be all zeros. Anyone has a clue?
thanks,
Gerd
[-- Attachment #2: 0001-wip-ehci-uhci-test.patch --]
[-- Type: text/x-patch, Size: 4774 bytes --]
>From a4cc34ec95c50f43d328e1a453712b011df9ad00 Mon Sep 17 00:00:00 2001
From: Gerd Hoffmann <kraxel@redhat.com>
Date: Wed, 7 May 2014 16:39:11 +0200
Subject: [PATCH] [wip] ehci/uhci test
---
tests/Makefile | 4 ++-
tests/usb-hcd-ehci-test.c | 79 ++++++++++++++++++++++++++++++++++++++++++++---
2 files changed, 78 insertions(+), 5 deletions(-)
diff --git a/tests/Makefile b/tests/Makefile
index 14ecf05..f37ef47 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -152,6 +152,8 @@ gcov-files-i386-y += hw/pci-bridge/ioh3420.c
check-qtest-i386-y += tests/usb-hcd-ehci-test$(EXESUF)
gcov-files-i386-y += hw/usb/hcd-ehci.c
gcov-files-i386-y += hw/usb/hcd-uhci.c
+gcov-files-i386-y += hw/usb/dev-hid.c
+gcov-files-i386-y += hw/usb/dev-storage.c
check-qtest-x86_64-y = $(check-qtest-i386-y)
gcov-files-i386-y += i386-softmmu/hw/timer/mc146818rtc.c
gcov-files-x86_64-y = $(subst i386-softmmu/,x86_64-softmmu/,$(gcov-files-i386-y))
@@ -307,7 +309,7 @@ tests/ac97-test$(EXESUF): tests/ac97-test.o
tests/es1370-test$(EXESUF): tests/es1370-test.o
tests/intel-hda-test$(EXESUF): tests/intel-hda-test.o
tests/ioh3420-test$(EXESUF): tests/ioh3420-test.o
-tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o
+tests/usb-hcd-ehci-test$(EXESUF): tests/usb-hcd-ehci-test.o $(libqos-pc-obj-y)
tests/qemu-iotests/socket_scm_helper$(EXESUF): tests/qemu-iotests/socket_scm_helper.o
# QTest rules
diff --git a/tests/usb-hcd-ehci-test.c b/tests/usb-hcd-ehci-test.c
index bc56ba7..ce38795 100644
--- a/tests/usb-hcd-ehci-test.c
+++ b/tests/usb-hcd-ehci-test.c
@@ -9,12 +9,79 @@
#include <glib.h>
#include <string.h>
+#include <stdio.h>
#include "libqtest.h"
+#include "libqos/pci-pc.h"
#include "qemu/osdep.h"
-/* Tests only initialization so far. TODO: Replace with functional tests */
-static void pci_nop(void)
+static QPCIBus *pcibus;
+static QPCIDevice *uhci1;
+static QPCIDevice *uhci2;
+static QPCIDevice *uhci3;
+static QPCIDevice *ehci1;
+
+static void *uhci1_io;
+static void *uhci2_io;
+static void *uhci3_io;
+static void *ehci1_mmio;
+
+static void pci_init(void)
{
+ if (pcibus) {
+ return;
+ }
+ pcibus = qpci_init_pc();
+ g_assert(pcibus != NULL);
+
+ uhci1 = qpci_device_find(pcibus, QPCI_DEVFN(0x1d, 0));
+ g_assert(uhci1 != NULL);
+ uhci2 = qpci_device_find(pcibus, QPCI_DEVFN(0x1d, 1));
+ g_assert(uhci2 != NULL);
+ uhci3 = qpci_device_find(pcibus, QPCI_DEVFN(0x1d, 2));
+ g_assert(uhci3 != NULL);
+ ehci1 = qpci_device_find(pcibus, QPCI_DEVFN(0x1d, 7));
+ g_assert(ehci1 != NULL);
+
+ qpci_device_enable(uhci1);
+ qpci_device_enable(uhci2);
+ qpci_device_enable(uhci3);
+ qpci_device_enable(ehci1);
+
+ uhci1_io = qpci_iomap(uhci1, 4);
+ uhci2_io = qpci_iomap(uhci2, 4);
+ uhci3_io = qpci_iomap(uhci3, 4);
+ ehci1_mmio = qpci_iomap(ehci1, 0);
+
+#if 1
+ fprintf(stderr, "%s: uhci1 %p\n", __func__, uhci1_io);
+ fprintf(stderr, "%s: uhci2 %p\n", __func__, uhci2_io);
+ fprintf(stderr, "%s: uhci3 %p\n", __func__, uhci3_io);
+ fprintf(stderr, "%s: ehci1 %p\n", __func__, ehci1_mmio);
+ fprintf(stderr, "\n");
+#endif
+}
+
+static void pci_portsc_1(void)
+{
+ int i;
+
+ g_assert(pcibus != NULL);
+
+#if 1
+ for (i = 0; i < 0x14; i += 2) {
+ fprintf(stderr, "%s: uhci1 0x%02x: 0x%04x\n", __func__, i,
+ qpci_io_readw(uhci1, uhci1_io + i));
+ }
+ fprintf(stderr, "\n");
+
+ for (i = 0; i < 0x60; i += 4) {
+ fprintf(stderr, "%s: ehci1 0x%02x: 0x%08x\n", __func__, i,
+ qpci_io_readl(ehci1, ehci1_mmio + i));
+ }
+ fprintf(stderr, "\n");
+
+ g_assert(false);
+#endif
}
int main(int argc, char **argv)
@@ -22,7 +89,8 @@ int main(int argc, char **argv)
int ret;
g_test_init(&argc, &argv, NULL);
- qtest_add_func("/ehci/pci/nop", pci_nop);
+ qtest_add_func("/ehci/pci/init", pci_init);
+ qtest_add_func("/ehci/pci/portsc_1", pci_portsc_1);
qtest_start("-machine q35 -device ich9-usb-ehci1,bus=pcie.0,addr=1d.7,"
"multifunction=on,id=ich9-ehci-1 "
@@ -31,7 +99,10 @@ int main(int argc, char **argv)
"-device ich9-usb-uhci2,bus=pcie.0,addr=1d.1,"
"multifunction=on,masterbus=ich9-ehci-1.0,firstport=2 "
"-device ich9-usb-uhci3,bus=pcie.0,addr=1d.2,"
- "multifunction=on,masterbus=ich9-ehci-1.0,firstport=4");
+ "multifunction=on,masterbus=ich9-ehci-1.0,firstport=4 "
+ "-drive if=none,id=usbcdrom,media=cdrom "
+ "-device usb-tablet,bus=ich9-ehci-1.0,port=1,usb_version=1 "
+ "-device usb-storage,bus=ich9-ehci-1.0,port=2,drive=usbcdrom ");
ret = g_test_run();
qtest_end();
--
1.8.3.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Qemu-devel] qtest and pci mmio?
2014-05-07 16:06 [Qemu-devel] qtest and pci mmio? Gerd Hoffmann
@ 2014-05-07 16:41 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2014-05-07 16:41 UTC (permalink / raw)
To: Gerd Hoffmann, qemu-devel
Il 07/05/2014 18:06, Gerd Hoffmann ha scritto:
> Hi,
>
> Trying to add something real to the new ehci test. Having trouble
> accessing the ehci mmio registers. uhci io registers are working fine.
> Current patch attached, which just does a register dump to stderr. uhci
> looks sane. ehci shouldn't be all zeros. Anyone has a clue?
>
> thanks,
> Gerd
>
diff --git a/tests/libqos/pci.c b/tests/libqos/pci.c
index 7e0907b..c9a0b91 100644
--- a/tests/libqos/pci.c
+++ b/tests/libqos/pci.c
@@ -103,7 +103,7 @@ void qpci_config_writew(QPCIDevice *dev, uint8_t offset, uint16_t value)
void qpci_config_writel(QPCIDevice *dev, uint8_t offset, uint32_t value)
{
- dev->bus->config_writew(dev->bus, dev->devfn, offset, value);
+ dev->bus->config_writel(dev->bus, dev->devfn, offset, value);
}
This should help. :)
Re. how to find it, I modified the -qtest-log option to use /dev/tty instead of
/dev/null (there was a patch to add a QTEST_LOG environment variable...), and
the BAR sizing looked a bit suspicious:
[R +0.023561] outl 0xcf8 0x8000ef10
[S +0.023567] OK
[R +0.023584] outw 0xcfc 0xffff
[S +0.024013] OK
[R +0.024036] outl 0xcf8 0x8000ef10
[S +0.024043] OK
[R +0.024061] inl 0xcfc
[S +0.024068] OK 0xf000
[R +0.024086] outl 0xcf8 0x8000ef10
[S +0.024093] OK
[R +0.024110] outw 0xcfc 0x0
[S +0.024519] OK
Paolo
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-05-07 16:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-05-07 16:06 [Qemu-devel] qtest and pci mmio? Gerd Hoffmann
2014-05-07 16:41 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).