From nobody Sat Feb 7 15:29:54 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1643143845420584.1260588822298; Tue, 25 Jan 2022 12:50:45 -0800 (PST) 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-28-xHAGfXaLNxCZrlhj2tYHUg-1; Tue, 25 Jan 2022 15:50:41 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B00F41091DA1; Tue, 25 Jan 2022 20:50:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 529DC5DF3F; Tue, 25 Jan 2022 20:50:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 215DF181844E; Tue, 25 Jan 2022 20:50:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20PKoZYk025141 for ; Tue, 25 Jan 2022 15:50:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 0D6E5141DEE5; Tue, 25 Jan 2022 20:50:34 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast09.extmail.prod.ext.rdu2.redhat.com [10.11.55.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0520E141DC5E for ; Tue, 25 Jan 2022 20:50:04 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5CA7C2B69A14 for ; Tue, 25 Jan 2022 20:49:52 +0000 (UTC) Received: from mail-oi1-f180.google.com (mail-oi1-f180.google.com [209.85.167.180]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-628-V9bCa6vpO6mqAn7mMogk0A-2; Tue, 25 Jan 2022 15:49:45 -0500 Received: by mail-oi1-f180.google.com with SMTP id s185so16679170oie.3 for ; Tue, 25 Jan 2022 12:49:45 -0800 (PST) Received: from rekt.COMFAST ([191.8.61.226]) by smtp.gmail.com with ESMTPSA id ay32sm1368569oob.16.2022.01.25.12.49.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Jan 2022 12:49:44 -0800 (PST) X-MC-Unique: xHAGfXaLNxCZrlhj2tYHUg-1 X-MC-Unique: V9bCa6vpO6mqAn7mMogk0A-2 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=eeEqPxvb+KKtCdopj8XzWzk41XBJ18u/MJ/P2ppUisg=; b=eKVipkgOszpvMsgJwKtnGX8N8JSbFgI7oU9jULHHNNxmxs5ZH+13eqHfzKFt/y7k5B khCKkAJ4dhYBxNeNNnMOKWlocG6fALiPoIKdQoEh4zx1BaGMbXEn9U340AsxNSgg0s4F ahVmdyCJ3sWBiddWPzmOe7/YncWjkq9JjQQ5Aes+12iUiZu6sDCj9EuYzuCTPsrOxh4c 3RweTU1CydDkipguTwEVbq14jIQQ7Im4fAvL9VSG+VSrHE7yvLTXqVoJk294MtMNEPQv NShNVqyTk1m4wMbLTo+0n+mjRnb3VNGf2rYr9vAGUxSEDzRps7CHheOgfczYepVYLaeF S6ng== X-Gm-Message-State: AOAM531ozkzHkJyHHR4WXZ0xwgPwnUbo+eby6sVP1sQciDxP8jisL/Mh Q7tyZ0CYsOujDCGr5GlJAsLhR5g1zJQ= X-Google-Smtp-Source: ABdhPJxAHF21HkW8TRh3e2gIKd3KGMQOkpHLUy4ozPnOltRKvP/EFM3zDGnZwtTl3cbNrUSaJrSJGw== X-Received: by 2002:aca:4b0e:: with SMTP id y14mr1620891oia.297.1643143785075; Tue, 25 Jan 2022 12:49:45 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v2 19/29] qemu_domain_address.c: change pnv-phb3 minimal downstream slot Date: Tue, 25 Jan 2022 17:48:52 -0300 Message-Id: <20220125204902.772350-20-danielhb413@gmail.com> In-Reply-To: <20220125204902.772350-1-danielhb413@gmail.com> References: <20220125204902.772350-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 X-loop: libvir-list@redhat.com Cc: danielhb413@gmail.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZM-MESSAGEID: 1643143847435100001 Content-Type: text/plain; charset="utf-8" The PowerNV PHB3 bus has minimal slot zero. In fact, at this moment, the root complex accepts only a single device, at slot 0x0, due to firmware limitations. The single device restriction is subject to change in upstream QEMU and it's not worth adding this limitation to Libvirt. However, the minimal slot presents a problem. When setting a pnv-phb3-root-port address with slot=3D0x0, Libvirt changes it to 0x1. This happens because the pnv-phb3 controller is a PCIE_ROOT model, and this model is being set with 'bus->minSlot=3D1' in domain_addr.c, virDomainPCIAddressBusSetModel(). This means that the root-port is launched with 'addr=3D0x1' in the QEMU command line and it's not usable by the domain. It is not worth to create a new controller model, replicating all the already existing logic for PCIE_ROOT controllers, just to have a similar PCIE_ROOT bus with minSlots=3D0. Changing the existing PCIE_ROOT min slot t= o 0 doesn't make sense either - we would change existing behavior of existing devices. This patch works around this situation by adding a verification in qemuDomainPCIAddressSetCreate() to change the minBus values of the pnv-phb3 devices right before virDomainDeviceInfoIterate(). This is enough to allow for a root port to be added in slot 0 of a pnv-phb3 bus while not being intrusive with existing devices. Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_domain_address.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index e7a9e6adda..7d60d277e8 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1628,6 +1628,17 @@ qemuDomainCollectPCIAddressExtension(virDomainDef *d= ef G_GNUC_UNUSED, return virDomainPCIAddressExtensionReserveAddr(addrs, addr); } =20 +static void +qemuDomainTunePowerNVPhbBuses(virDomainPCIAddressSet *addrs) +{ + size_t i; + + for (i =3D 0; i < addrs->nbuses; i++) { + if (addrs->buses[i].model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_PCIE_= ROOT) + addrs->buses[i].minSlot =3D 0; + } +} + static virDomainPCIAddressSet * qemuDomainPCIAddressSetCreate(virDomainDef *def, virQEMUCaps *qemuCaps, @@ -1720,6 +1731,9 @@ qemuDomainPCIAddressSetCreate(virDomainDef *def, virDomainControllerModelPCITypeToString(defaultModel), i= ); } =20 + if (qemuDomainIsPowerNV(def)) + qemuDomainTunePowerNVPhbBuses(addrs); + if (virDomainDeviceInfoIterate(def, qemuDomainCollectPCIAddress, addrs= ) < 0) goto error; =20 --=20 2.34.1