From nobody Tue Nov 4 22:03:35 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1533566791538164.69441232275744; Mon, 6 Aug 2018 07:46:31 -0700 (PDT) Received: from localhost ([::1]:34412 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmgmA-0006KD-Cw for importer@patchew.org; Mon, 06 Aug 2018 10:46:26 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35577) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fmgav-0004wo-Qf for qemu-devel@nongnu.org; Mon, 06 Aug 2018 10:34:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fmgau-0000qI-P9 for qemu-devel@nongnu.org; Mon, 06 Aug 2018 10:34:49 -0400 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]:44105) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fmgau-0000ot-FB for qemu-devel@nongnu.org; Mon, 06 Aug 2018 10:34:48 -0400 Received: by mail-ed1-x541.google.com with SMTP id f23-v6so5237143edr.11 for ; Mon, 06 Aug 2018 07:34:48 -0700 (PDT) Received: from localhost.localdomain ([194.230.159.126]) by smtp.gmail.com with ESMTPSA id x13-v6sm14615157edx.17.2018.08.06.07.34.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 06 Aug 2018 07:34:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=pxMNQRSFekQOKOZqUhywyxaWBNdeGlqa3s+wZifR6ak=; b=hwZEl4inXCm8+/jzCIb2+tl5bN/BjfsXJJ+uppKeWsQe08YzlHotATQfoS/96wPYW6 7iXst9WrlWu/Z/84BwPJF6q7Jv2ZShwTDw1TIP7BFDw8CsPD3IPbg2pggWKdZ446N1xz 8H0QzGOZavtcFwRUtSLvH6s8zjyXHGjp6Yffu3DJYjVgdocH5xr0eRF/owFEMoaFe4ts Je6UVfUgKBWvOcCO/9tQaRhfDiuJJXG/GfOHSIBTkrPclQeOah/sUsgo1B7dCXHC5SOO Oj3sH2wC1vZok+xo6NwNk6GAMHC1tMc6wDHeF8kJHXvDOEnFZWDvRqNrv+l4A7xRp2hO 2PZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=pxMNQRSFekQOKOZqUhywyxaWBNdeGlqa3s+wZifR6ak=; b=tw6DRh0pW7ZkyW9k9Dzc0xUTMjgucqoG6wGlpvqDhleaXMRtN0XzlPJeJw5oBRLdQC 7mmVXzCMVX5B96FNRUiNwdiVLoUWxwNSh7yS4jIdSGQTqd6wTxI18pe7p7PwBCmu8of/ 3IW5w5yqD9sjvWRA4g6jMwelRbn99zNkRIjUyuGA+GcHG0t0zQ+4x+ePnykF1nMN7sbf XJGTQlGECQKqUjAoCWaDW00Z2v9c3YpVfy+BJgALM8W8kB349Cl4YS6j1UHAYBxxWG8D 4VB4BnzWPHAorZMHh8eKoiFbIPyMhd4q/sjkf8ReEekd6gEgZ7wlKN9YCSdHOkQKEbzT sbYw== X-Gm-Message-State: AOUpUlGYzgVP/3vC4IkNgiH31sat2tsPCsj3h6MomgXfTJp2flhDqYTa GkqmAlBpI/JSWXd/rQm5COo= X-Google-Smtp-Source: AAOMgpcMpW+wOH/YATJcEaY62oEw17cu83DK7x130lzjM1cAnXIeIFpQJjNP6Pp7stqSpFilCO8iNA== X-Received: by 2002:a50:8406:: with SMTP id 6-v6mr18400918edp.97.1533566087425; Mon, 06 Aug 2018 07:34:47 -0700 (PDT) From: Emanuele Giuseppe Esposito To: Paolo Bonzini Date: Mon, 6 Aug 2018 16:33:47 +0200 Message-Id: <20180806143412.27722-10-e.emanuelegiuseppe@gmail.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180806143412.27722-1-e.emanuelegiuseppe@gmail.com> References: <20180806143412.27722-1-e.emanuelegiuseppe@gmail.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::541 Subject: [Qemu-devel] [PATCH v2 09/34] tests/qgraph: pci-spapr driver and interface nodes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Stefan Hajnoczi , Emanuele Giuseppe Esposito , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDMRC_1 RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add pci-bus-spapr node, that produces pci-bus. Move QPCIBusSPAPR struct declaration in its header (since it will be needed by other drivers) and introduce a setter method for drivers that do not need to allocate but have to initialize QPCIBusSPAPR. Signed-off-by: Emanuele Giuseppe Esposito --- tests/Makefile.include | 2 +- tests/libqos/pci-spapr.c | 57 ++++++++++++++++++++++++---------------- tests/libqos/pci-spapr.h | 24 +++++++++++++++++ 3 files changed, 59 insertions(+), 24 deletions(-) diff --git a/tests/Makefile.include b/tests/Makefile.include index d826a09919..5ce905bd82 100644 --- a/tests/Makefile.include +++ b/tests/Makefile.include @@ -771,7 +771,7 @@ libqos-virtio-obj-y =3D $(libqos-spapr-obj-y) $(libqos-= pc-obj-y) tests/libqos/virt libqgraph-machines-obj-y =3D tests/libqos/x86_64_pc-machine.o libqgraph-machines-obj-y +=3D tests/libqos/raspi2-machine.o =20 -libqgraph-pci-obj-y =3D $(libqos-pc-obj-y) +libqgraph-pci-obj-y =3D $(libqos-pc-obj-y) $(libqos-spapr-obj-y) libqgraph-pci-obj-y +=3D $(libqgraph-machines-obj-y) libqgraph-pci-obj-y +=3D tests/libqos/sdhci.o =20 diff --git a/tests/libqos/pci-spapr.c b/tests/libqos/pci-spapr.c index 30b6d5b5a7..108db6c9b6 100644 --- a/tests/libqos/pci-spapr.c +++ b/tests/libqos/pci-spapr.c @@ -9,33 +9,13 @@ #include "libqtest.h" #include "libqos/pci-spapr.h" #include "libqos/rtas.h" +#include "libqos/qgraph.h" =20 #include "hw/pci/pci_regs.h" =20 #include "qemu-common.h" #include "qemu/host-utils.h" =20 - -/* From include/hw/pci-host/spapr.h */ - -typedef struct QPCIWindow { - uint64_t pci_base; /* window address in PCI space */ - uint64_t size; /* window size */ -} QPCIWindow; - -typedef struct QPCIBusSPAPR { - QPCIBus bus; - QGuestAllocator *alloc; - - uint64_t buid; - - uint64_t pio_cpu_base; - QPCIWindow pio; - - uint64_t mmio32_cpu_base; - QPCIWindow mmio32; -} QPCIBusSPAPR; - /* * PCI devices are always little-endian * SPAPR by default is big-endian @@ -160,12 +140,23 @@ static void qpci_spapr_config_writel(QPCIBus *bus, in= t devfn, uint8_t offset, #define SPAPR_PCI_MMIO32_WIN_SIZE 0x80000000 /* 2 GiB */ #define SPAPR_PCI_IO_WIN_SIZE 0x10000 =20 -QPCIBus *qpci_spapr_new(QTestState *qts, QGuestAllocator *alloc) +static void *qspapr_get_driver(void *obj, const char *interface) { - QPCIBusSPAPR *ret =3D g_new0(QPCIBusSPAPR, 1); + QPCIBusSPAPR *qpci =3D obj; + if (!g_strcmp0(interface, "pci-bus")) { + return &qpci->bus; + } + printf("%s not present in pci-bus-spapr", interface); + abort(); +} =20 +void qpci_init_spapr(QPCIBusSPAPR *ret, QTestState *qts, QGuestAllocator *= alloc) +{ assert(qts); =20 + /* tests cannot use spapr, needs to be fixed first */ + ret->bus.has_buggy_msi =3D TRUE; + ret->alloc =3D alloc; =20 ret->bus.pio_readb =3D qpci_spapr_pio_readb; @@ -208,12 +199,32 @@ QPCIBus *qpci_spapr_new(QTestState *qts, QGuestAlloca= tor *alloc) ret->bus.mmio_alloc_ptr =3D ret->mmio32.pci_base; ret->bus.mmio_limit =3D ret->mmio32.pci_base + ret->mmio32.size; =20 + ret->obj.get_driver =3D qspapr_get_driver; +} + +QPCIBus *qpci_spapr_new(QTestState *qts, QGuestAllocator *alloc) +{ + QPCIBusSPAPR *ret =3D g_new0(QPCIBusSPAPR, 1); + qpci_init_spapr(ret, qts, alloc); + return &ret->bus; } =20 void qpci_free_spapr(QPCIBus *bus) { + if (!bus) { + return; + } + QPCIBusSPAPR *s =3D container_of(bus, QPCIBusSPAPR, bus); =20 g_free(s); } + +static void qpci_spapr(void) +{ + qos_node_create_driver("pci-bus-spapr", NULL); + qos_node_produces("pci-bus-spapr", "pci-bus"); +} + +libqos_init(qpci_spapr); diff --git a/tests/libqos/pci-spapr.h b/tests/libqos/pci-spapr.h index d5305d16f8..74cd183c9a 100644 --- a/tests/libqos/pci-spapr.h +++ b/tests/libqos/pci-spapr.h @@ -10,7 +10,31 @@ =20 #include "libqos/malloc.h" #include "libqos/pci.h" +#include "libqos/qgraph.h" =20 +/* From include/hw/pci-host/spapr.h */ + +typedef struct QPCIWindow { + uint64_t pci_base; /* window address in PCI space */ + uint64_t size; /* window size */ +} QPCIWindow; + +typedef struct QPCIBusSPAPR { + QOSGraphObject obj; + QPCIBus bus; + QGuestAllocator *alloc; + + uint64_t buid; + + uint64_t pio_cpu_base; + QPCIWindow pio; + + uint64_t mmio32_cpu_base; + QPCIWindow mmio32; +} QPCIBusSPAPR; + +void qpci_init_spapr(QPCIBusSPAPR *ret, QTestState *qts, + QGuestAllocator *alloc); QPCIBus *qpci_spapr_new(QTestState *qts, QGuestAllocator *alloc); void qpci_free_spapr(QPCIBus *bus); =20 --=20 2.17.1