From mboxrd@z Thu Jan 1 00:00:00 1970 From: Alexander Gordeev Subject: [kvm-unit-tests PATCH v5 00/12] PCI bus support Date: Tue, 19 Jul 2016 14:52:57 +0200 Message-ID: Cc: Alexander Gordeev To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:35014 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753122AbcGSMxQ (ORCPT ); Tue, 19 Jul 2016 08:53:16 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A5F177F7C3 for ; Tue, 19 Jul 2016 12:53:15 +0000 (UTC) Sender: kvm-owner@vger.kernel.org List-ID: Hi Andrew, This is 5th version of PCI support. Changes since v4 are mainly addressing nits and a rework of pci_bar_addr() function. The biggest change - the PCI test succeeds on arm, aarch64, i386 and x86_64 (I am not posting pci-testdev enablement for x86 though). There are few changes (some of them to already Reviewed-by patches) worth a notice - here are the interdiffs commented: [08/12] pci: Add pci_print(); pci_print() function: - possibile devices with unimplemented gap BARs are printed correctly; - pci_bar_size() is called once; diff -u b/lib/pci.c b/lib/pci.c --- b/lib/pci.c +++ b/lib/pci.c @@ -146,14 +146,15 @@ return; for (i = 0; i < 6; i++) { - phys_addr_t start, end; + phys_addr_t size, start, end; uint32_t bar; - if (!pci_bar_is_valid(dev, i)) - break; + size = pci_bar_size(dev, i); + if (!size) + continue; start = pci_bar_get_addr(dev, i); - end = start + pci_bar_size(dev, i) - 1; + end = start + size - 1; if (pci_bar_is64(dev, i)) { printf("\tBAR#%d,%d [%" PRIx64 "-%" PRIx64 " ", [09/12] pci: Add generic ECAM host support; pci_probe() function: - possibile devices with unimplemented gap BARs are scanned correctly; @@ -276,7 +290,7 @@ + + size = pci_bar_size(dev, i); + if (!size) -+ break; ++ continue; + + bar = pci_bar_get(dev, i); + addr = pci_alloc_resource(bar, size); [11/12] pci: Add pci-testdev PCI bus test device; pci_testdev_one() function: - no-eventfd vs eventfd accesses (clarified by Paolo on qemu-devel list) are handled now; @@ -124,7 +124,11 @@ } } - return (int)ops->io_readl(&test->count) == nr_writes; + count = ops->io_readl(&test->count); + if (!count) + return true; + + return (int)count == nr_writes; } void pci_testdev_print(struct pci_test_dev_hdr *test, Alexander Gordeev (12): [01/12] pci: Fix coding style in generic PCI files [02/12] pci: x86: Rename pci_config_read() to pci_config_readl() [03/12] pci: x86: Add remaining PCI configuration space accessors [04/12] pci: Rework pci_bar_addr() [05/12] pci: Factor out pci_bar_get() [06/12] pci: Add pci_bar_set_addr() [07/12] pci: Add pci_dev_exists() [08/12] pci: Add pci_print() [09/12] pci: Add generic ECAM host support [10/12] arm/arm64: pci: Add PCI bus operation test [11/12] pci: Add pci-testdev PCI bus test device [12/12] arm/arm64: pci: Add pci-testdev PCI device operation test arm/Makefile.common | 6 +- arm/pci-test.c | 31 ++++ arm/run | 7 +- lib/arm/asm/pci.h | 11 ++ lib/arm64/asm/pci.h | 1 + lib/asm-generic/pci-host-bridge.h | 26 ++++ lib/pci-host-generic.c | 295 ++++++++++++++++++++++++++++++++++++++ lib/pci-host-generic.h | 46 ++++++ lib/pci-testdev.c | 188 ++++++++++++++++++++++++ lib/pci.c | 201 +++++++++++++++++++++++--- lib/pci.h | 34 ++++- lib/x86/asm/pci.h | 31 +++- x86/vmexit.c | 4 +- 13 files changed, 853 insertions(+), 28 deletions(-) create mode 100644 arm/pci-test.c create mode 100644 lib/arm/asm/pci.h create mode 100644 lib/arm64/asm/pci.h create mode 100644 lib/asm-generic/pci-host-bridge.h create mode 100644 lib/pci-host-generic.c create mode 100644 lib/pci-host-generic.h create mode 100644 lib/pci-testdev.c -- 1.8.3.1