From nobody Sun May 19 20:47:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642538649; cv=none; d=zohomail.com; s=zohoarc; b=EC/1lI9NToV6Fic2nwnNn7wRXv08KA8HLhpzqeoINdpf/C+Wh2nPNKJYgEot3BpQAgT97JjN+2Cz6hIPOc05ZNI1Y3TTMIy284uJtLaiggwEZthLdQe0mNlg5S03e9lQ/L5nmUREX7dKsqty18cTBPCudxOokzDSNIcvMaUjWfI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642538649; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=SxRgbq9ttrQRFvO5NnZwXwJjSMKQhw7d9CQ3Zqbmj3w=; b=U5v1Vpb6j8LGHzvYcEsZ/PGY8qnZjHfdIg0LzMRiqx/fNQ/NUZGki/s6haIsjeXB42nhcco4hrQ2NcnsAL/HZeeSLLghlGYXN2S5huPiD4rDsN2ZuyqAkLBNwM45JCOzZNmM0Zm9Lt6B5wCFHc8DZEvxfrG2w71umqkxVvLKlNk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642538649452720.04862728419; Tue, 18 Jan 2022 12:44:09 -0800 (PST) Received: from localhost ([::1]:56148 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9vKq-0008Gb-1B for importer@patchew.org; Tue, 18 Jan 2022 15:44:08 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45802) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9vFw-0005TE-KC for qemu-devel@nongnu.org; Tue, 18 Jan 2022 15:39:04 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:31485) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9vFu-0003GF-U1 for qemu-devel@nongnu.org; Tue, 18 Jan 2022 15:39:04 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-523-91xF0JdfMrWuOPKsPkM-Lw-1; Tue, 18 Jan 2022 15:38:59 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id C972619251A0; Tue, 18 Jan 2022 20:38:57 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.194.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6705745D9A; Tue, 18 Jan 2022 20:38:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642538342; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=SxRgbq9ttrQRFvO5NnZwXwJjSMKQhw7d9CQ3Zqbmj3w=; b=LrkUMiz4qk/7FNg5wT0uI/SiV/6F/XxXu8tUj9CY1I7hFqUG17/1OOjxGNNcea8l9erq3s CMV3x/F4F8gk9m6A9qnJPMboyrNzufr7+kk8013Bifps5PIqntvKoEmj2SrpwcttM72kbh WHm640PPCaA5OSSiSJqeo1iwOIfVZjY= X-MC-Unique: 91xF0JdfMrWuOPKsPkM-Lw-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, thuth@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org, peter.maydell@linaro.org, mst@redhat.com, david@gibson.dropbear.id.au, clg@kaod.org, eesposit@redhat.com Subject: [PATCH v2 1/6] tests/qtest/vhost-user-test.c: Use vhostforce=on Date: Tue, 18 Jan 2022 21:38:28 +0100 Message-Id: <20220118203833.316741-2-eric.auger@redhat.com> In-Reply-To: <20220118203833.316741-1-eric.auger@redhat.com> References: <20220118203833.316741-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eric.auger@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jean-philippe@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642538650457100003 Content-Type: text/plain; charset="utf-8" -netdev vhost-user,vhostforce is deprecated and vhostforce=3Don should be used instead. Signed-off-by: Eric Auger Reviewed-by: Thomas Huth Reviewed-by: Alex Benn=C3=A9e --- tests/qtest/vhost-user-test.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/qtest/vhost-user-test.c b/tests/qtest/vhost-user-test.c index 3d6337fb5c..6e79935c47 100644 --- a/tests/qtest/vhost-user-test.c +++ b/tests/qtest/vhost-user-test.c @@ -42,7 +42,7 @@ #define QEMU_CMD_MEMFD " -m %d -object memory-backend-memfd,id=3Dmem,size= =3D%dM," \ " -numa node,memdev=3Dmem" #define QEMU_CMD_CHR " -chardev socket,id=3D%s,path=3D%s%s" -#define QEMU_CMD_NETDEV " -netdev vhost-user,id=3Dhs0,chardev=3D%s,vhostfo= rce" +#define QEMU_CMD_NETDEV " -netdev vhost-user,id=3Dhs0,chardev=3D%s,vhostfo= rce=3Don" =20 #define HUGETLBFS_MAGIC 0x958458f6 =20 --=20 2.26.3 From nobody Sun May 19 20:47:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642538669; cv=none; d=zohomail.com; s=zohoarc; b=S4yYDXUQLKGfTuhy2AF+H0/2yVcBcbDD9eIN3+E/rGysQ69qTfRLTy0LHpH9Z29VKHhfzOO2urZ1WjjRegHq9lUGyd6gEpCC3SkXU4lsMM3NPRCFJxeNc2eZpaRYKQBPoVDN4Uxv7DICs4b5XYVa2uQVeL9gumkhlc8NvTSiWo4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642538669; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=fENC+O3UhoRJJhdlv001UiHe5IQNH33OXw44Tup2W2k=; b=HoMyk0X38WFFSJddi7+7VkLa4Yz+MCXaOHOqJ46hx0Cwx2i8ttNWAmXCK0sqOdDQ85WaxxIjMcMPMjXgExDmVy74+h3xPrAFhBNfuXP0aoDlD/5BVOPDucfhZlFOAuBkfbf/hzChMY8To15YEBQ6iNXIgfHraNVLhA7QEvC33cA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642538669910536.6188375157797; Tue, 18 Jan 2022 12:44:29 -0800 (PST) Received: from localhost ([::1]:57562 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9vL9-0000p5-K2 for importer@patchew.org; Tue, 18 Jan 2022 15:44:27 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45862) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9vG4-0005p8-4K for qemu-devel@nongnu.org; Tue, 18 Jan 2022 15:39:15 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24612) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9vG2-0003H5-5Q for qemu-devel@nongnu.org; Tue, 18 Jan 2022 15:39:11 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-477-m7jHkEr4MgaUMUn4R-S9HA-1; Tue, 18 Jan 2022 15:39:08 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 680901091DA1; Tue, 18 Jan 2022 20:39:06 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.194.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 30F722B88B; Tue, 18 Jan 2022 20:38:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642538349; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=fENC+O3UhoRJJhdlv001UiHe5IQNH33OXw44Tup2W2k=; b=XAgeSqKdVfLpk2I+vDQ2yrDpElDQeNEqPARD7y7TQHHZ7WBsbP+E2kmVFyM1m6AlmY/arJ tZzg2Uxi35XF7flGXXFYt/CLVF4kNRq/WjyE+LabQ4EHBc9bjySY3Vtc8h3KeyAnRnAekZ f2pOURTGilP4B63iwzbJ/4L0TK8xv6I= X-MC-Unique: m7jHkEr4MgaUMUn4R-S9HA-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, thuth@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org, peter.maydell@linaro.org, mst@redhat.com, david@gibson.dropbear.id.au, clg@kaod.org, eesposit@redhat.com Subject: [PATCH v2 2/6] tests/qtest/libqos/pci: Introduce pio_limit Date: Tue, 18 Jan 2022 21:38:29 +0100 Message-Id: <20220118203833.316741-3-eric.auger@redhat.com> In-Reply-To: <20220118203833.316741-1-eric.auger@redhat.com> References: <20220118203833.316741-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eric.auger@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jean-philippe@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642538673118100001 Content-Type: text/plain; charset="utf-8" At the moment the IO space limit is hardcoded to QPCI_PIO_LIMIT =3D 0x10000. When accesses are performed to a bar, the base address of this latter is compared against the limit to decide whether we perform an IO or a memory access. On ARM, we cannot keep this PIO limit as the arm-virt machine uses [0x3eff0000, 0x3f000000 ] for the IO space map and we are mandated to allocate at 0x0. Add a new flag in QPCIBar indicating whether it is an IO bar or a memory bar. This flag is set on QPCIBar allocation and provisionned based on the BAR configuration. Then the new flag is used in access functions and in iomap() function. Signed-off-by: Eric Auger Reviewed-by: Thomas Huth Reviewed-by: Alex Benn=C3=A9e --- tests/qtest/libqos/pci-pc.c | 1 + tests/qtest/libqos/pci-spapr.c | 1 + tests/qtest/libqos/pci.c | 78 ++++++++++++++++++++++------------ tests/qtest/libqos/pci.h | 5 +-- 4 files changed, 54 insertions(+), 31 deletions(-) diff --git a/tests/qtest/libqos/pci-pc.c b/tests/qtest/libqos/pci-pc.c index f97844289f..8051a0881a 100644 --- a/tests/qtest/libqos/pci-pc.c +++ b/tests/qtest/libqos/pci-pc.c @@ -150,6 +150,7 @@ void qpci_init_pc(QPCIBusPC *qpci, QTestState *qts, QGu= estAllocator *alloc) =20 qpci->bus.qts =3D qts; qpci->bus.pio_alloc_ptr =3D 0xc000; + qpci->bus.pio_limit =3D 0x10000; qpci->bus.mmio_alloc_ptr =3D 0xE0000000; qpci->bus.mmio_limit =3D 0x100000000ULL; =20 diff --git a/tests/qtest/libqos/pci-spapr.c b/tests/qtest/libqos/pci-spapr.c index 262226985f..870ffdd8b5 100644 --- a/tests/qtest/libqos/pci-spapr.c +++ b/tests/qtest/libqos/pci-spapr.c @@ -197,6 +197,7 @@ void qpci_init_spapr(QPCIBusSPAPR *qpci, QTestState *qt= s, =20 qpci->bus.qts =3D qts; qpci->bus.pio_alloc_ptr =3D 0xc000; + qpci->bus.pio_limit =3D 0x10000; qpci->bus.mmio_alloc_ptr =3D qpci->mmio32.pci_base; qpci->bus.mmio_limit =3D qpci->mmio32.pci_base + qpci->mmio32.size; =20 diff --git a/tests/qtest/libqos/pci.c b/tests/qtest/libqos/pci.c index 3a9076ae58..b23d72346b 100644 --- a/tests/qtest/libqos/pci.c +++ b/tests/qtest/libqos/pci.c @@ -398,44 +398,56 @@ void qpci_config_writel(QPCIDevice *dev, uint8_t offs= et, uint32_t value) =20 uint8_t qpci_io_readb(QPCIDevice *dev, QPCIBar token, uint64_t off) { - if (token.addr < QPCI_PIO_LIMIT) { - return dev->bus->pio_readb(dev->bus, token.addr + off); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + return bus->pio_readb(bus, token.addr + off); } else { uint8_t val; - dev->bus->memread(dev->bus, token.addr + off, &val, sizeof(val)); + + bus->memread(dev->bus, token.addr + off, &val, sizeof(val)); return val; } } =20 uint16_t qpci_io_readw(QPCIDevice *dev, QPCIBar token, uint64_t off) { - if (token.addr < QPCI_PIO_LIMIT) { - return dev->bus->pio_readw(dev->bus, token.addr + off); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + return bus->pio_readw(bus, token.addr + off); } else { uint16_t val; - dev->bus->memread(dev->bus, token.addr + off, &val, sizeof(val)); + + bus->memread(bus, token.addr + off, &val, sizeof(val)); return le16_to_cpu(val); } } =20 uint32_t qpci_io_readl(QPCIDevice *dev, QPCIBar token, uint64_t off) { - if (token.addr < QPCI_PIO_LIMIT) { - return dev->bus->pio_readl(dev->bus, token.addr + off); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + return bus->pio_readl(bus, token.addr + off); } else { uint32_t val; - dev->bus->memread(dev->bus, token.addr + off, &val, sizeof(val)); + + bus->memread(dev->bus, token.addr + off, &val, sizeof(val)); return le32_to_cpu(val); } } =20 uint64_t qpci_io_readq(QPCIDevice *dev, QPCIBar token, uint64_t off) { - if (token.addr < QPCI_PIO_LIMIT) { - return dev->bus->pio_readq(dev->bus, token.addr + off); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + return bus->pio_readq(bus, token.addr + off); } else { uint64_t val; - dev->bus->memread(dev->bus, token.addr + off, &val, sizeof(val)); + + bus->memread(bus, token.addr + off, &val, sizeof(val)); return le64_to_cpu(val); } } @@ -443,57 +455,65 @@ uint64_t qpci_io_readq(QPCIDevice *dev, QPCIBar token= , uint64_t off) void qpci_io_writeb(QPCIDevice *dev, QPCIBar token, uint64_t off, uint8_t value) { - if (token.addr < QPCI_PIO_LIMIT) { - dev->bus->pio_writeb(dev->bus, token.addr + off, value); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + bus->pio_writeb(bus, token.addr + off, value); } else { - dev->bus->memwrite(dev->bus, token.addr + off, &value, sizeof(valu= e)); + bus->memwrite(bus, token.addr + off, &value, sizeof(value)); } } =20 void qpci_io_writew(QPCIDevice *dev, QPCIBar token, uint64_t off, uint16_t value) { - if (token.addr < QPCI_PIO_LIMIT) { - dev->bus->pio_writew(dev->bus, token.addr + off, value); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + bus->pio_writew(bus, token.addr + off, value); } else { value =3D cpu_to_le16(value); - dev->bus->memwrite(dev->bus, token.addr + off, &value, sizeof(valu= e)); + bus->memwrite(bus, token.addr + off, &value, sizeof(value)); } } =20 void qpci_io_writel(QPCIDevice *dev, QPCIBar token, uint64_t off, uint32_t value) { - if (token.addr < QPCI_PIO_LIMIT) { - dev->bus->pio_writel(dev->bus, token.addr + off, value); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + bus->pio_writel(bus, token.addr + off, value); } else { value =3D cpu_to_le32(value); - dev->bus->memwrite(dev->bus, token.addr + off, &value, sizeof(valu= e)); + bus->memwrite(bus, token.addr + off, &value, sizeof(value)); } } =20 void qpci_io_writeq(QPCIDevice *dev, QPCIBar token, uint64_t off, uint64_t value) { - if (token.addr < QPCI_PIO_LIMIT) { - dev->bus->pio_writeq(dev->bus, token.addr + off, value); + QPCIBus *bus =3D dev->bus; + + if (token.is_io) { + bus->pio_writeq(bus, token.addr + off, value); } else { value =3D cpu_to_le64(value); - dev->bus->memwrite(dev->bus, token.addr + off, &value, sizeof(valu= e)); + bus->memwrite(bus, token.addr + off, &value, sizeof(value)); } } =20 void qpci_memread(QPCIDevice *dev, QPCIBar token, uint64_t off, void *buf, size_t len) { - g_assert(token.addr >=3D QPCI_PIO_LIMIT); + g_assert(!token.is_io); dev->bus->memread(dev->bus, token.addr + off, buf, len); } =20 void qpci_memwrite(QPCIDevice *dev, QPCIBar token, uint64_t off, const void *buf, size_t len) { - g_assert(token.addr >=3D QPCI_PIO_LIMIT); + g_assert(!token.is_io); dev->bus->memwrite(dev->bus, token.addr + off, buf, len); } =20 @@ -534,9 +554,10 @@ QPCIBar qpci_iomap(QPCIDevice *dev, int barno, uint64_= t *sizeptr) loc =3D QEMU_ALIGN_UP(bus->pio_alloc_ptr, size); =20 g_assert(loc >=3D bus->pio_alloc_ptr); - g_assert(loc + size <=3D QPCI_PIO_LIMIT); /* Keep PIO below 64kiB = */ + g_assert(loc + size <=3D bus->pio_limit); =20 bus->pio_alloc_ptr =3D loc + size; + bar.is_io =3D true; =20 qpci_config_writel(dev, bar_reg, loc | PCI_BASE_ADDRESS_SPACE_IO); } else { @@ -547,6 +568,7 @@ QPCIBar qpci_iomap(QPCIDevice *dev, int barno, uint64_t= *sizeptr) g_assert(loc + size <=3D bus->mmio_limit); =20 bus->mmio_alloc_ptr =3D loc + size; + bar.is_io =3D false; =20 qpci_config_writel(dev, bar_reg, loc); } @@ -562,7 +584,7 @@ void qpci_iounmap(QPCIDevice *dev, QPCIBar bar) =20 QPCIBar qpci_legacy_iomap(QPCIDevice *dev, uint16_t addr) { - QPCIBar bar =3D { .addr =3D addr }; + QPCIBar bar =3D { .addr =3D addr, .is_io =3D true }; return bar; } =20 diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h index becb800f9e..44f6806fe4 100644 --- a/tests/qtest/libqos/pci.h +++ b/tests/qtest/libqos/pci.h @@ -16,8 +16,6 @@ #include "libqtest.h" #include "qgraph.h" =20 -#define QPCI_PIO_LIMIT 0x10000 - #define QPCI_DEVFN(dev, fn) (((dev) << 3) | (fn)) =20 typedef struct QPCIDevice QPCIDevice; @@ -51,7 +49,7 @@ struct QPCIBus { uint8_t offset, uint32_t value); =20 QTestState *qts; - uint16_t pio_alloc_ptr; + uint64_t pio_alloc_ptr, pio_limit; uint64_t mmio_alloc_ptr, mmio_limit; bool has_buggy_msi; /* TRUE for spapr, FALSE for pci */ =20 @@ -59,6 +57,7 @@ struct QPCIBus { =20 struct QPCIBar { uint64_t addr; + bool is_io; }; =20 struct QPCIDevice --=20 2.26.3 From nobody Sun May 19 20:47:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642538940; cv=none; d=zohomail.com; s=zohoarc; b=GMP4goUV4/72BbxOAC1qlya8F4ApuHqHmW4nuehc703cBfD1v7/4tex9ASq5pESysEi9Bg9VvmNcWrSyZeQmyHPq1TAZTvu2tTc4WnZKNsbv5pRbC9axqvAW6Dj6jhYGR6dfzbKo7AKIQLynXAorKZ1Uf+dRSsnRPDHXIdgEzzI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642538940; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=KCL4s1oWVVgFbaSzYuwDwQsNuFYm6/osfpXc/Qc+HkY=; b=dHv380Zs7sWSOzaAzGi1/k3Y32b65VYr+IswKWHo7SLK5/rqpk8sMjinCFDg/AJq/HTlZoqZSRgfjEex6H2Qk5n8OTXtsNWGcW7g8smKDc7zMlx6ha+MSDCdgwhLvC6pfdpTI+wl4nD36FvkkjMlXf16llXxOYXyCfVtEcURqPs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642538940805167.5369062678086; Tue, 18 Jan 2022 12:49:00 -0800 (PST) Received: from localhost ([::1]:38156 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9vPX-0006qW-MD for importer@patchew.org; Tue, 18 Jan 2022 15:48:59 -0500 Received: from eggs.gnu.org ([209.51.188.92]:45922) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9vG9-0005yA-AT for qemu-devel@nongnu.org; Tue, 18 Jan 2022 15:39:17 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:59007) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9vG7-0003Hg-EQ for qemu-devel@nongnu.org; Tue, 18 Jan 2022 15:39:17 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-100-QEtLclgZMC-bkisJv_OiQQ-1; Tue, 18 Jan 2022 15:39:11 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E7D9985EE67; Tue, 18 Jan 2022 20:39:09 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.194.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id E77295DB83; Tue, 18 Jan 2022 20:39:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642538352; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=KCL4s1oWVVgFbaSzYuwDwQsNuFYm6/osfpXc/Qc+HkY=; b=BAOef4kpUzRpZJchPki5iOSljgMEiOxelmzczqNXk5WoLIOpYa2Eq0NbbPkz+JD3fzH4xm zmUzG1CLwUKC92DrP8tsDlSfxTHg2v8zW7OlCuYtSvsMkk+WWv0MReeSiCr9fCaIYa74zb IUJVFgmEJhIiRWNACiyTOk7MUiVZeGs= X-MC-Unique: QEtLclgZMC-bkisJv_OiQQ-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, thuth@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org, peter.maydell@linaro.org, mst@redhat.com, david@gibson.dropbear.id.au, clg@kaod.org, eesposit@redhat.com Subject: [PATCH v2 3/6] tests/qtest/libqos: Skip hotplug tests if pci root bus is not hotpluggable Date: Tue, 18 Jan 2022 21:38:30 +0100 Message-Id: <20220118203833.316741-4-eric.auger@redhat.com> In-Reply-To: <20220118203833.316741-1-eric.auger@redhat.com> References: <20220118203833.316741-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eric.auger@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.133.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jean-philippe@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642538941292100001 Content-Type: text/plain; charset="utf-8" ARM does not not support hotplug on pcie.0. Add a flag on the bus which tells if devices can be hotplugged and skip hotplug tests if the bus cannot be hotplugged. This is a temporary solution to enable the other pci tests on aarch64. Signed-off-by: Eric Auger Acked-by: Thomas Huth Reviewed-by: Alex Benn=C3=A9e --- v1 ->v2: - reword g_test_skip msg into "pci bus does not support hotplug" --- tests/qtest/e1000e-test.c | 6 ++++++ tests/qtest/libqos/pci.h | 1 + tests/qtest/vhost-user-blk-test.c | 10 ++++++++++ tests/qtest/virtio-blk-test.c | 5 +++++ tests/qtest/virtio-net-test.c | 5 +++++ tests/qtest/virtio-rng-test.c | 5 +++++ 6 files changed, 32 insertions(+) diff --git a/tests/qtest/e1000e-test.c b/tests/qtest/e1000e-test.c index 0273fe4c15..48f3dbb0fd 100644 --- a/tests/qtest/e1000e-test.c +++ b/tests/qtest/e1000e-test.c @@ -235,6 +235,12 @@ static void test_e1000e_multiple_transfers(void *obj, = void *data, static void test_e1000e_hotplug(void *obj, void *data, QGuestAllocator * a= lloc) { QTestState *qts =3D global_qtest; /* TODO: get rid of global_qtest he= re */ + QE1000E_PCI *dev =3D obj; + + if (dev->pci_dev.bus->not_hotpluggable) { + g_test_skip("pci bus does not support hotplug"); + return; + } =20 qtest_qmp_device_add(qts, "e1000e", "e1000e_net", "{'addr': '0x06'}"); qpci_unplug_acpi_device_test(qts, "e1000e_net", 0x06); diff --git a/tests/qtest/libqos/pci.h b/tests/qtest/libqos/pci.h index 44f6806fe4..6a28b40522 100644 --- a/tests/qtest/libqos/pci.h +++ b/tests/qtest/libqos/pci.h @@ -52,6 +52,7 @@ struct QPCIBus { uint64_t pio_alloc_ptr, pio_limit; uint64_t mmio_alloc_ptr, mmio_limit; bool has_buggy_msi; /* TRUE for spapr, FALSE for pci */ + bool not_hotpluggable; /* TRUE if devices cannot be hotplugged */ =20 }; =20 diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index 62e670f39b..1316aae0fa 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -676,6 +676,11 @@ static void pci_hotplug(void *obj, void *data, QGuestA= llocator *t_alloc) QVirtioPCIDevice *dev; QTestState *qts =3D dev1->pdev->bus->qts; =20 + if (dev1->pdev->bus->not_hotpluggable) { + g_test_skip("pci bus does not support hotplug"); + return; + } + /* plug secondary disk */ qtest_qmp_device_add(qts, "vhost-user-blk-pci", "drv1", "{'addr': %s, 'chardev': 'char2'}", @@ -703,6 +708,11 @@ static void multiqueue(void *obj, void *data, QGuestAl= locator *t_alloc) uint64_t features; uint16_t num_queues; =20 + if (pdev1->pdev->bus->not_hotpluggable) { + g_test_skip("bus pci.0 does not support hotplug"); + return; + } + /* * The primary device has 1 queue and VIRTIO_BLK_F_MQ is not enabled. = The * VIRTIO specification allows VIRTIO_BLK_F_MQ to be enabled when ther= e is diff --git a/tests/qtest/virtio-blk-test.c b/tests/qtest/virtio-blk-test.c index 2a23698211..acb44c9fb8 100644 --- a/tests/qtest/virtio-blk-test.c +++ b/tests/qtest/virtio-blk-test.c @@ -701,6 +701,11 @@ static void pci_hotplug(void *obj, void *data, QGuestA= llocator *t_alloc) QVirtioPCIDevice *dev; QTestState *qts =3D dev1->pdev->bus->qts; =20 + if (dev1->pdev->bus->not_hotpluggable) { + g_test_skip("pci bus does not support hotplug"); + return; + } + /* plug secondary disk */ qtest_qmp_device_add(qts, "virtio-blk-pci", "drv1", "{'addr': %s, 'drive': 'drive1'}", diff --git a/tests/qtest/virtio-net-test.c b/tests/qtest/virtio-net-test.c index 8bf74e516c..af3027144f 100644 --- a/tests/qtest/virtio-net-test.c +++ b/tests/qtest/virtio-net-test.c @@ -174,6 +174,11 @@ static void hotplug(void *obj, void *data, QGuestAlloc= ator *t_alloc) QTestState *qts =3D dev->pdev->bus->qts; const char *arch =3D qtest_get_arch(); =20 + if (dev->pdev->bus->not_hotpluggable) { + g_test_skip("pci bus does not support hotplug"); + return; + } + qtest_qmp_device_add(qts, "virtio-net-pci", "net1", "{'addr': %s}", stringify(PCI_SLOT_HP)); =20 diff --git a/tests/qtest/virtio-rng-test.c b/tests/qtest/virtio-rng-test.c index e6b8cd8e0c..5ce444ad72 100644 --- a/tests/qtest/virtio-rng-test.c +++ b/tests/qtest/virtio-rng-test.c @@ -20,6 +20,11 @@ static void rng_hotplug(void *obj, void *data, QGuestAll= ocator *alloc) QVirtioPCIDevice *dev =3D obj; QTestState *qts =3D dev->pdev->bus->qts; =20 + if (dev->pdev->bus->not_hotpluggable) { + g_test_skip("pci bus does not support hotplug"); + return; + } + const char *arch =3D qtest_get_arch(); =20 qtest_qmp_device_add(qts, "virtio-rng-pci", "rng1", --=20 2.26.3 From nobody Sun May 19 20:47:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642538927; cv=none; d=zohomail.com; s=zohoarc; b=Q7OAZZo9m2uMYFf6Jph9AQEnvdgfCp+Aey1hwp5S9USMDxMH4PXLzKf0+X3/w+X8gyXqIUucI/oZWVV1k/FHOGI1KLDzUrZl8NqtVPtp7W2r016dYD/GEKolu3j9x333XjSVMWVGlV2FG1YSy7gX+1XdxtzcTR5KXTxzPGsGxy0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642538927; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=gccVtjqdXPcWela0w8NV10LOW8M/f5w43auUyaYbmCg=; b=EHH54txMPSp3BD2ob2Zovk0BMzgCP6WrF7rFM2GxOZQCcz7rvJhkmFOhOSmzgOeZ9tgxH+7f/xx/UTlUB2Yh5KtjsC4QcOT9LWSCtXE1HABm2dfzmsRgdF6m6WPfzGy9EoQTDreXrXGksYufovcmJrvZw/vaeubnqS6Qb0s6Fe8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642538927652467.64747395417703; Tue, 18 Jan 2022 12:48:47 -0800 (PST) Received: from localhost ([::1]:36894 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9vPK-00061i-Bk for importer@patchew.org; Tue, 18 Jan 2022 15:48:46 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46050) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9vGL-0006c9-FZ for qemu-devel@nongnu.org; Tue, 18 Jan 2022 15:39:29 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:41342) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9vGJ-0003JK-Ja for qemu-devel@nongnu.org; Tue, 18 Jan 2022 15:39:29 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-185-L_buEKNCMz6E-bnCAWnXBw-1; Tue, 18 Jan 2022 15:39:23 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 526CA1091DA0; Tue, 18 Jan 2022 20:39:22 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.194.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4F4C85DB8B; Tue, 18 Jan 2022 20:39:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642538366; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=gccVtjqdXPcWela0w8NV10LOW8M/f5w43auUyaYbmCg=; b=Y3ls1X0uIT9IeAvciH2+SXOqogWELAqqoN8QZdVBxiZEvR2AJVAJQKIXuqxV95gsc+QvUd jSoY+50dip6dAvnmGV8Eqr4u4cSENXbRsZi2YitWbLJ0TW6xLKXY777fIEKQ1jgYCDHdML TICgKmmTYAkW0Gt1qj/Lq9s5T5Qe9Ao= X-MC-Unique: L_buEKNCMz6E-bnCAWnXBw-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, thuth@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org, peter.maydell@linaro.org, mst@redhat.com, david@gibson.dropbear.id.au, clg@kaod.org, eesposit@redhat.com Subject: [PATCH v2 4/6] tests/qtest/vhost-user-blk-test: Setup MSIx to avoid error on aarch64 Date: Tue, 18 Jan 2022 21:38:31 +0100 Message-Id: <20220118203833.316741-5-eric.auger@redhat.com> In-Reply-To: <20220118203833.316741-1-eric.auger@redhat.com> References: <20220118203833.316741-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eric.auger@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jean-philippe@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642538928268100001 Content-Type: text/plain; charset="utf-8" When run on ARM, basic and indirect tests currently fail with the following error: ERROR:../tests/qtest/libqos/virtio.c:224:qvirtio_wait_used_elem: assertion failed (got_desc_idx =3D=3D desc_idx): (50331648 =3D=3D 0) Bail out! ERROR:../tests/qtest/libqos/virtio.c:224: qvirtio_wait_used_elem: assertion failed (got_desc_idx =3D=3D desc_idx): (50331648 =3D=3D 0) Setting up and enabling MSIX fixes the issue. Also remove the useless libqos/libqos-pc.h header inclusion. Signed-off-by: Eric Auger Acked-by: Thomas Huth --- tests/qtest/vhost-user-blk-test.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index 1316aae0fa..2606428df3 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -19,7 +19,6 @@ #include "standard-headers/linux/virtio_pci.h" #include "libqos/qgraph.h" #include "libqos/vhost-user-blk.h" -#include "libqos/libqos-pc.h" =20 #define TEST_IMAGE_SIZE (64 * 1024 * 1024) #define QVIRTIO_BLK_TIMEOUT_US (30 * 1000 * 1000) @@ -224,6 +223,10 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGue= stAllocator *alloc) char *data; QTestState *qts =3D global_qtest; QVirtQueue *vq; + QVirtioPCIDevice *vpcidev =3D container_of(dev, QVirtioPCIDevice, vdev= ); + + qpci_msix_enable(vpcidev->pdev); + qvirtio_pci_set_msix_configuration_vector(vpcidev, alloc, 0); =20 features =3D qvirtio_get_features(dev); features =3D features & ~(QVIRTIO_F_BAD_FEATURE | @@ -236,9 +239,12 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGue= stAllocator *alloc) g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); =20 vq =3D qvirtqueue_setup(dev, alloc, 0); + qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, alloc, 1); =20 qvirtio_set_driver_ok(dev); =20 + qvirtio_wait_queue_isr(qts, dev, vq, QVIRTIO_BLK_TIMEOUT_US); + /* Write and read with 3 descriptor layout */ /* Write request */ req.type =3D VIRTIO_BLK_T_OUT; @@ -468,6 +474,10 @@ static void indirect(void *obj, void *u_data, QGuestAl= locator *t_alloc) uint8_t status; char *data; QTestState *qts =3D global_qtest; + QVirtioPCIDevice *vpcidev =3D container_of(dev, QVirtioPCIDevice, vdev= ); + + qpci_msix_enable(vpcidev->pdev); + qvirtio_pci_set_msix_configuration_vector(vpcidev, t_alloc, 0); =20 features =3D qvirtio_get_features(dev); g_assert_cmphex(features & (1u << VIRTIO_RING_F_INDIRECT_DESC), !=3D, = 0); @@ -480,8 +490,12 @@ static void indirect(void *obj, void *u_data, QGuestAl= locator *t_alloc) g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); =20 vq =3D qvirtqueue_setup(dev, t_alloc, 0); + qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, t_alloc, 1); + qvirtio_set_driver_ok(dev); =20 + qvirtio_wait_queue_isr(qts, dev, vq, QVIRTIO_BLK_TIMEOUT_US); + /* Write request */ req.type =3D VIRTIO_BLK_T_OUT; req.ioprio =3D 1; --=20 2.26.3 From nobody Sun May 19 20:47:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642539078; cv=none; d=zohomail.com; s=zohoarc; b=jLgFWCKpfug5C9cPhAnyZMNDr8wO7CnCcEnkGI4JsKRTVawfwX7XQ4NE5SwylLrZIhU+AI0pg+BA13K/K5aiv6c9XTK02q5MK9254vCLln1z1dPULo1nD6Jd6ONX1DsxYMqYXy7xsLIzG/scKhCYNrSEloMlg340bKL7/BnUPwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642539078; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tNydDTYaWN8bVxhXPpl3ShPmt922xSEsE9g+zjMcyqY=; b=AL6JLSOxnFcgftnv2wvaKwyo42uDihE0Nb5d75nh54JcaVGAXxDzRL+Eo3gvkjSdCQg8UNhjAhhQXj7gfQdHdjZaGq2PKB1JK+srHQ+o1iw+HYMatWoLndRXF03GxIDvEh9Gf/qvUKzf3l6P0aJnSnOUJzoqY21o7jnsrLEvjJM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642539078525575.5634424093543; Tue, 18 Jan 2022 12:51:18 -0800 (PST) Received: from localhost ([::1]:44988 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9vRl-00034E-Ex for importer@patchew.org; Tue, 18 Jan 2022 15:51:17 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46100) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9vGU-0006jz-Pz for qemu-devel@nongnu.org; Tue, 18 Jan 2022 15:39:38 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:24253) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9vGT-0003LB-5g for qemu-devel@nongnu.org; Tue, 18 Jan 2022 15:39:38 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-453-QBjAVd-5OpKUnQ-CMtiyCA-1; Tue, 18 Jan 2022 15:39:31 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AD57485EE61; Tue, 18 Jan 2022 20:39:29 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.194.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id AD9D045D95; Tue, 18 Jan 2022 20:39:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642538374; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=tNydDTYaWN8bVxhXPpl3ShPmt922xSEsE9g+zjMcyqY=; b=WGecIQIgHkcnedNpeFCSjpxFlsPUf22+jQUJh4FgTtIZ04jLz5skKi4XVhL++K+2HuCZ3P OEn2HVkrHroEVI4vRXynf0/zMszwIEArMdKH5FCQBjU0LNXrdrext32sPSamyqw6UVHuQW ILBeUYSBdar85Iyevdu6bkNJDYafQdw= X-MC-Unique: QBjAVd-5OpKUnQ-CMtiyCA-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, thuth@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org, peter.maydell@linaro.org, mst@redhat.com, david@gibson.dropbear.id.au, clg@kaod.org, eesposit@redhat.com Subject: [PATCH v2 5/6] tests/qtest/vhost-user-blk-test: Factorize vq setup code Date: Tue, 18 Jan 2022 21:38:32 +0100 Message-Id: <20220118203833.316741-6-eric.auger@redhat.com> In-Reply-To: <20220118203833.316741-1-eric.auger@redhat.com> References: <20220118203833.316741-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eric.auger@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jean-philippe@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642539080739100001 Content-Type: text/plain; charset="utf-8" The vq setup code is repeated several times and can be easily factorized. Signed-off-by: Eric Auger Reviewed-by: Thomas Huth --- tests/qtest/vhost-user-blk-test.c | 33 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/tests/qtest/vhost-user-blk-test.c b/tests/qtest/vhost-user-blk= -test.c index 2606428df3..9567f3dc42 100644 --- a/tests/qtest/vhost-user-blk-test.c +++ b/tests/qtest/vhost-user-blk-test.c @@ -211,6 +211,19 @@ static void test_invalid_discard_write_zeroes(QVirtioD= evice *dev, guest_free(alloc, req_addr); } =20 +static QVirtQueue *setup_vq(QVirtioDevice *dev, QGuestAllocator *alloc) +{ + QVirtioPCIDevice *vpcidev =3D container_of(dev, QVirtioPCIDevice, vdev= ); + QVirtQueue *vq; + + qpci_msix_enable(vpcidev->pdev); + qvirtio_pci_set_msix_configuration_vector(vpcidev, alloc, 0); + + vq =3D qvirtqueue_setup(dev, alloc, 0); + qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, alloc, 1); + return vq; +} + /* Returns the request virtqueue so the caller can perform further tests */ static QVirtQueue *test_basic(QVirtioDevice *dev, QGuestAllocator *alloc) { @@ -223,10 +236,6 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGue= stAllocator *alloc) char *data; QTestState *qts =3D global_qtest; QVirtQueue *vq; - QVirtioPCIDevice *vpcidev =3D container_of(dev, QVirtioPCIDevice, vdev= ); - - qpci_msix_enable(vpcidev->pdev); - qvirtio_pci_set_msix_configuration_vector(vpcidev, alloc, 0); =20 features =3D qvirtio_get_features(dev); features =3D features & ~(QVIRTIO_F_BAD_FEATURE | @@ -238,8 +247,7 @@ static QVirtQueue *test_basic(QVirtioDevice *dev, QGues= tAllocator *alloc) capacity =3D qvirtio_config_readq(dev, 0); g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); =20 - vq =3D qvirtqueue_setup(dev, alloc, 0); - qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, alloc, 1); + vq =3D setup_vq(dev, alloc); =20 qvirtio_set_driver_ok(dev); =20 @@ -474,10 +482,6 @@ static void indirect(void *obj, void *u_data, QGuestAl= locator *t_alloc) uint8_t status; char *data; QTestState *qts =3D global_qtest; - QVirtioPCIDevice *vpcidev =3D container_of(dev, QVirtioPCIDevice, vdev= ); - - qpci_msix_enable(vpcidev->pdev); - qvirtio_pci_set_msix_configuration_vector(vpcidev, t_alloc, 0); =20 features =3D qvirtio_get_features(dev); g_assert_cmphex(features & (1u << VIRTIO_RING_F_INDIRECT_DESC), !=3D, = 0); @@ -489,8 +493,7 @@ static void indirect(void *obj, void *u_data, QGuestAll= ocator *t_alloc) capacity =3D qvirtio_config_readq(dev, 0); g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); =20 - vq =3D qvirtqueue_setup(dev, t_alloc, 0); - qvirtqueue_pci_msix_setup(vpcidev, (QVirtQueuePCI *)vq, t_alloc, 1); + vq =3D setup_vq(dev, t_alloc); =20 qvirtio_set_driver_ok(dev); =20 @@ -576,9 +579,6 @@ static void idx(void *obj, void *u_data, QGuestAllocato= r *t_alloc) return; } =20 - qpci_msix_enable(pdev->pdev); - qvirtio_pci_set_msix_configuration_vector(pdev, t_alloc, 0); - features =3D qvirtio_get_features(dev); features =3D features & ~(QVIRTIO_F_BAD_FEATURE | (1u << VIRTIO_RING_F_INDIRECT_DESC) | @@ -589,8 +589,7 @@ static void idx(void *obj, void *u_data, QGuestAllocato= r *t_alloc) capacity =3D qvirtio_config_readq(dev, 0); g_assert_cmpint(capacity, =3D=3D, TEST_IMAGE_SIZE / 512); =20 - vq =3D qvirtqueue_setup(dev, t_alloc, 0); - qvirtqueue_pci_msix_setup(pdev, (QVirtQueuePCI *)vq, t_alloc, 1); + vq =3D setup_vq(dev, t_alloc); =20 qvirtio_set_driver_ok(dev); =20 --=20 2.26.3 From nobody Sun May 19 20:47:24 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1642538799; cv=none; d=zohomail.com; s=zohoarc; b=YcN1jPs8Y1jt0fLSWuTQC1ZiFWQT8FDGz/3Xz/aCv3Xp4qF2Y4vlNy1zQ/NFcbYhXfIg2ODfBx8tYXj6cuhHMf+MWhCrIpqWVD/K8T3aHXa0jfh4PhvGHWX5VYFZ33lKbfkd4OOXlu6vklf5cgMryWLd9dc+jbF/5hNGBQ8ufMY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642538799; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=urOsnqKe9Kh2tuvXB4TKoo+Jr9uPfxqsgPkKqjgzbj0=; b=WWJbo15VyjgYQ1AFzNUDgk+gK/1KZ59YrHHcEBMrRhy3DDzzLku2l3OkrEPcKlu6nbNpSXhuv1eLtT7EEAS3xlMVY9YsirAwT/b1TzmIYj+yK23OkxEoAfWsIVHvHmTaszHFJOvU3gNjOKaPt2+5M+Q/yJff0uBB/WQK8a2/+rc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1642538799087574.631762843946; Tue, 18 Jan 2022 12:46:39 -0800 (PST) Received: from localhost ([::1]:59414 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1n9vNG-00022F-2J for importer@patchew.org; Tue, 18 Jan 2022 15:46:38 -0500 Received: from eggs.gnu.org ([209.51.188.92]:46136) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9vGX-0006mS-KV for qemu-devel@nongnu.org; Tue, 18 Jan 2022 15:39:42 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]:51921) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1n9vGV-0003Ly-FK for qemu-devel@nongnu.org; Tue, 18 Jan 2022 15:39:41 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-523-OyTDv0vaPIWkqBxhz7jt3A-1; Tue, 18 Jan 2022 15:39:35 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5164B1091DA1; Tue, 18 Jan 2022 20:39:34 +0000 (UTC) Received: from laptop.redhat.com (unknown [10.39.194.124]) by smtp.corp.redhat.com (Postfix) with ESMTP id 14CFA5DB83; Tue, 18 Jan 2022 20:39:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642538378; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=urOsnqKe9Kh2tuvXB4TKoo+Jr9uPfxqsgPkKqjgzbj0=; b=Ad0HnHJGvfv09AKqk/Ufh4UalLxxiYGP86y2knmjb1xvN2PGdTS5MeSAmMwrPc0dgi4TD2 Hhta4cwS1TKqAs8e7VdG3Tgyu2c1XpIpHRU/by1Qqyrg+ZnTiEjGkHIFHkul+WDMBITMYL HxjR0jbv+5X0+KWypYZkTYkWvnx+Xtw= X-MC-Unique: OyTDv0vaPIWkqBxhz7jt3A-1 From: Eric Auger To: eric.auger.pro@gmail.com, eric.auger@redhat.com, thuth@redhat.com, pbonzini@redhat.com, lvivier@redhat.com, qemu-arm@nongnu.org, qemu-devel@nongnu.org, peter.maydell@linaro.org, mst@redhat.com, david@gibson.dropbear.id.au, clg@kaod.org, eesposit@redhat.com Subject: [PATCH v2 6/6] tests/qtest/libqos: Add generic pci host bridge in arm-virt machine Date: Tue, 18 Jan 2022 21:38:33 +0100 Message-Id: <20220118203833.316741-7-eric.auger@redhat.com> In-Reply-To: <20220118203833.316741-1-eric.auger@redhat.com> References: <20220118203833.316741-1-eric.auger@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eric.auger@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=eric.auger@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -34 X-Spam_score: -3.5 X-Spam_bar: --- X-Spam_report: (-3.5 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.7, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jean-philippe@linaro.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1642538800740100001 Content-Type: text/plain; charset="utf-8" Up to now the virt-machine node contains a virtio-mmio node. However no driver produces any PCI interface node. Hence, PCI tests cannot be run with aarch64 binary. Add a GPEX driver node that produces a pci interface node. This latter then can be consumed by all the pci tests. One of the first motivation was to be able to run the virtio-iommu-pci tests. We still face an issue with pci hotplug tests as hotplug cannot happen on the pcie root bus and require a generic root port. This will be addressed later on. Signed-off-by: Eric Auger --- v1 -> v2: - copyright updated to 2022 - QPCIBusARM renamed into QGenericPCIBus - QGenericPCIHost declarations and definitions moved in the same place as the generic pci implementation - rename pci-arm.c/h in generic-pcihost.c/h and remove any ref to ARM there - remove qos_node_produces_opts, qpci_new_arm, qpci_free_arm - ecam_alloc_ptr now is a field of QGenericPCIBus and not QPCIBus - new libqos_init to create generic-pcihost driver that contains pci-bus-generic - QGenericPCIHost moved in the same place as the generic pci bindings --- tests/qtest/libqos/arm-virt-machine.c | 18 +- tests/qtest/libqos/generic-pcihost.c | 231 ++++++++++++++++++++++++++ tests/qtest/libqos/generic-pcihost.h | 54 ++++++ tests/qtest/libqos/meson.build | 1 + 4 files changed, 300 insertions(+), 4 deletions(-) create mode 100644 tests/qtest/libqos/generic-pcihost.c create mode 100644 tests/qtest/libqos/generic-pcihost.h diff --git a/tests/qtest/libqos/arm-virt-machine.c b/tests/qtest/libqos/arm= -virt-machine.c index e0f5932284..a2cc1790b5 100644 --- a/tests/qtest/libqos/arm-virt-machine.c +++ b/tests/qtest/libqos/arm-virt-machine.c @@ -22,6 +22,8 @@ #include "malloc.h" #include "qgraph.h" #include "virtio-mmio.h" +#include "generic-pcihost.h" +#include "hw/pci/pci_regs.h" =20 #define ARM_PAGE_SIZE 4096 #define VIRTIO_MMIO_BASE_ADDR 0x0A003E00 @@ -35,6 +37,7 @@ struct QVirtMachine { QOSGraphObject obj; QGuestAllocator alloc; QVirtioMMIODevice virtio_mmio; + QGenericPCIHost bridge; }; =20 static void virt_destructor(QOSGraphObject *obj) @@ -57,11 +60,13 @@ static void *virt_get_driver(void *object, const char *= interface) static QOSGraphObject *virt_get_device(void *obj, const char *device) { QVirtMachine *machine =3D obj; - if (!g_strcmp0(device, "virtio-mmio")) { + if (!g_strcmp0(device, "generic-pcihost")) { + return &machine->bridge.obj; + } else if (!g_strcmp0(device, "virtio-mmio")) { return &machine->virtio_mmio.obj; } =20 - fprintf(stderr, "%s not present in arm/virtio\n", device); + fprintf(stderr, "%s not present in arm/virt\n", device); g_assert_not_reached(); } =20 @@ -76,16 +81,21 @@ static void *qos_create_machine_arm_virt(QTestState *qt= s) qvirtio_mmio_init_device(&machine->virtio_mmio, qts, VIRTIO_MMIO_BASE_= ADDR, VIRTIO_MMIO_SIZE); =20 + qos_create_generic_pcihost(&machine->bridge, qts, &machine->alloc); + machine->obj.get_device =3D virt_get_device; machine->obj.get_driver =3D virt_get_driver; machine->obj.destructor =3D virt_destructor; return machine; } =20 -static void virtio_mmio_register_nodes(void) +static void virt_machine_register_nodes(void) { qos_node_create_machine("arm/virt", qos_create_machine_arm_virt); qos_node_contains("arm/virt", "virtio-mmio", NULL); + + qos_node_create_machine("aarch64/virt", qos_create_machine_arm_virt); + qos_node_contains("aarch64/virt", "generic-pcihost", NULL); } =20 -libqos_init(virtio_mmio_register_nodes); +libqos_init(virt_machine_register_nodes); diff --git a/tests/qtest/libqos/generic-pcihost.c b/tests/qtest/libqos/gene= ric-pcihost.c new file mode 100644 index 0000000000..704bbc3473 --- /dev/null +++ b/tests/qtest/libqos/generic-pcihost.c @@ -0,0 +1,231 @@ +/* + * libqos PCI bindings for generic PCI + * + * Copyright Red Hat Inc., 2022 + * + * Authors: + * Eric Auger + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#include "qemu/osdep.h" +#include "libqtest.h" +#include "generic-pcihost.h" +#include "qapi/qmp/qdict.h" +#include "hw/pci/pci_regs.h" + +#include "qemu/module.h" + +/* QGenericPCIHost */ + +QOSGraphObject *generic_pcihost_get_device(void *obj, const char *device) +{ + QGenericPCIHost *host =3D obj; + if (!g_strcmp0(device, "pci-bus-generic")) { + return &host->pci.obj; + } + fprintf(stderr, "%s not present in generic-pcihost\n", device); + g_assert_not_reached(); +} + +void qos_create_generic_pcihost(QGenericPCIHost *host, + QTestState *qts, + QGuestAllocator *alloc) +{ + host->obj.get_device =3D generic_pcihost_get_device; + qpci_init_generic(&host->pci, qts, alloc, false); +} + +static uint8_t qpci_generic_pio_readb(QPCIBus *bus, uint32_t addr) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + return qtest_readb(bus->qts, s->gpex_pio_base + addr); +} + +static void qpci_generic_pio_writeb(QPCIBus *bus, uint32_t addr, uint8_t v= al) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + qtest_writeb(bus->qts, s->gpex_pio_base + addr, val); +} + +static uint16_t qpci_generic_pio_readw(QPCIBus *bus, uint32_t addr) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + return qtest_readw(bus->qts, s->gpex_pio_base + addr); +} + +static void qpci_generic_pio_writew(QPCIBus *bus, uint32_t addr, uint16_t = val) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + qtest_writew(bus->qts, s->gpex_pio_base + addr, val); +} + +static uint32_t qpci_generic_pio_readl(QPCIBus *bus, uint32_t addr) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + return qtest_readl(bus->qts, s->gpex_pio_base + addr); +} + +static void qpci_generic_pio_writel(QPCIBus *bus, uint32_t addr, uint32_t = val) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + qtest_writel(bus->qts, s->gpex_pio_base + addr, val); +} + +static uint64_t qpci_generic_pio_readq(QPCIBus *bus, uint32_t addr) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + return qtest_readq(bus->qts, s->gpex_pio_base + addr); +} + +static void qpci_generic_pio_writeq(QPCIBus *bus, uint32_t addr, uint64_t = val) +{ + QGenericPCIBus *s =3D container_of(bus, QGenericPCIBus, bus); + + qtest_writeq(bus->qts, s->gpex_pio_base + addr, val); +} + +static void qpci_generic_memread(QPCIBus *bus, uint32_t addr, void *buf, s= ize_t len) +{ + qtest_memread(bus->qts, addr, buf, len); +} + +static void qpci_generic_memwrite(QPCIBus *bus, uint32_t addr, + const void *buf, size_t len) +{ + qtest_memwrite(bus->qts, addr, buf, len); +} + +static uint8_t qpci_generic_config_readb(QPCIBus *bus, int devfn, uint8_t = offset) +{ + QGenericPCIBus *gbus =3D container_of(bus, QGenericPCIBus, bus); + uint64_t addr =3D gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | = offset); + uint8_t val; + + qtest_memread(bus->qts, addr, &val, 1); + return val; +} + +static uint16_t qpci_generic_config_readw(QPCIBus *bus, int devfn, uint8_t= offset) +{ + QGenericPCIBus *gbus =3D container_of(bus, QGenericPCIBus, bus); + uint64_t addr =3D gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | = offset); + uint16_t val; + + qtest_memread(bus->qts, addr, &val, 2); + return val; +} + +static uint32_t qpci_generic_config_readl(QPCIBus *bus, int devfn, uint8_t= offset) +{ + QGenericPCIBus *gbus =3D container_of(bus, QGenericPCIBus, bus); + uint64_t addr =3D gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | = offset); + uint32_t val; + + qtest_memread(bus->qts, addr, &val, 4); + return val; +} + +static void +qpci_generic_config_writeb(QPCIBus *bus, int devfn, uint8_t offset, uint8_= t value) +{ + QGenericPCIBus *gbus =3D container_of(bus, QGenericPCIBus, bus); + uint64_t addr =3D gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | = offset); + uint32_t val =3D value; + + qtest_memwrite(bus->qts, addr, &val, 1); +} + +static void +qpci_generic_config_writew(QPCIBus *bus, int devfn, uint8_t offset, uint16= _t value) +{ + QGenericPCIBus *gbus =3D container_of(bus, QGenericPCIBus, bus); + uint64_t addr =3D gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | = offset); + uint32_t val =3D value; + + qtest_memwrite(bus->qts, addr, &val, 2); +} + +static void +qpci_generic_config_writel(QPCIBus *bus, int devfn, uint8_t offset, uint32= _t value) +{ + QGenericPCIBus *gbus =3D container_of(bus, QGenericPCIBus, bus); + uint64_t addr =3D gbus->ecam_alloc_ptr + ((0 << 20) | (devfn << 12) | = offset); + uint32_t val =3D value; + + qtest_memwrite(bus->qts, addr, &val, 4); +} + +static void *qpci_generic_get_driver(void *obj, const char *interface) +{ + QGenericPCIBus *qpci =3D obj; + if (!g_strcmp0(interface, "pci-bus")) { + return &qpci->bus; + } + fprintf(stderr, "%s not present in pci-bus-generic\n", interface); + g_assert_not_reached(); +} + +void qpci_init_generic(QGenericPCIBus *qpci, QTestState *qts, + QGuestAllocator *alloc, bool hotpluggable) +{ + assert(qts); + + qpci->gpex_pio_base =3D 0x3eff0000; + qpci->bus.not_hotpluggable =3D !hotpluggable; + qpci->bus.has_buggy_msi =3D false; + + qpci->bus.pio_readb =3D qpci_generic_pio_readb; + qpci->bus.pio_readw =3D qpci_generic_pio_readw; + qpci->bus.pio_readl =3D qpci_generic_pio_readl; + qpci->bus.pio_readq =3D qpci_generic_pio_readq; + + qpci->bus.pio_writeb =3D qpci_generic_pio_writeb; + qpci->bus.pio_writew =3D qpci_generic_pio_writew; + qpci->bus.pio_writel =3D qpci_generic_pio_writel; + qpci->bus.pio_writeq =3D qpci_generic_pio_writeq; + + qpci->bus.memread =3D qpci_generic_memread; + qpci->bus.memwrite =3D qpci_generic_memwrite; + + qpci->bus.config_readb =3D qpci_generic_config_readb; + qpci->bus.config_readw =3D qpci_generic_config_readw; + qpci->bus.config_readl =3D qpci_generic_config_readl; + + qpci->bus.config_writeb =3D qpci_generic_config_writeb; + qpci->bus.config_writew =3D qpci_generic_config_writew; + qpci->bus.config_writel =3D qpci_generic_config_writel; + + qpci->bus.qts =3D qts; + qpci->bus.pio_alloc_ptr =3D 0x0000; + qpci->bus.pio_limit =3D 0x10000; + qpci->bus.mmio_alloc_ptr =3D 0x10000000; + qpci->bus.mmio_limit =3D 0x2eff0000; + qpci->ecam_alloc_ptr =3D 0x4010000000; + + qpci->obj.get_driver =3D qpci_generic_get_driver; +} + +static void qpci_generic_register_nodes(void) +{ + qos_node_create_driver("pci-bus-generic", NULL); + qos_node_produces("pci-bus-generic", "pci-bus"); +} + +static void qpci_generic_pci_register_nodes(void) +{ + qos_node_create_driver("generic-pcihost", NULL); + qos_node_contains("generic-pcihost", "pci-bus-generic", NULL); +} + +libqos_init(qpci_generic_register_nodes); +libqos_init(qpci_generic_pci_register_nodes); diff --git a/tests/qtest/libqos/generic-pcihost.h b/tests/qtest/libqos/gene= ric-pcihost.h new file mode 100644 index 0000000000..c693c769df --- /dev/null +++ b/tests/qtest/libqos/generic-pcihost.h @@ -0,0 +1,54 @@ +/* + * libqos Generic PCI bindings and generic pci host bridge + * + * Copyright Red Hat Inc., 2022 + * + * Authors: + * Eric Auger + * + * This work is licensed under the terms of the GNU GPL, version 2 or late= r. + * See the COPYING file in the top-level directory. + */ + +#ifndef LIBQOS_GENERIC_PCIHOST_H +#define LIBQOS_GENERIC_PCIHOST_H + +#include "pci.h" +#include "malloc.h" +#include "qgraph.h" + +typedef struct QGenericPCIBus { + QOSGraphObject obj; + QPCIBus bus; + uint64_t gpex_pio_base; + uint64_t ecam_alloc_ptr; +} QGenericPCIBus; + +/* + * qpci_init_generic(): + * @ret: A valid QGenericPCIBus * pointer + * @qts: The %QTestState + * @alloc: A previously initialized @alloc providing memory for @qts + * @bool: devices can be hotplugged on this bus + * + * This function initializes an already allocated + * QGenericPCIBus object. + */ +void qpci_init_generic(QGenericPCIBus *ret, QTestState *qts, + QGuestAllocator *alloc, bool hotpluggable); + +/* QGenericPCIHost */ + +typedef struct QGenericPCIHost QGenericPCIHost; + +struct QGenericPCIHost { + QOSGraphObject obj; + QGenericPCIBus pci; +}; + +QOSGraphObject *generic_pcihost_get_device(void *obj, const char *device); +void qos_create_generic_pcihost(QGenericPCIHost *host, + QTestState *qts, + QGuestAllocator *alloc); + +#endif diff --git a/tests/qtest/libqos/meson.build b/tests/qtest/libqos/meson.build index e988d15791..8c8ee15553 100644 --- a/tests/qtest/libqos/meson.build +++ b/tests/qtest/libqos/meson.build @@ -42,6 +42,7 @@ libqos_srcs =3D files('../libqtest.c', 'virtio-scsi.c', 'virtio-serial.c', 'virtio-iommu.c', + 'generic-pcihost.c', =20 # qgraph machines: 'aarch64-xlnx-zcu102-machine.c', --=20 2.26.3