From nobody Sun Feb 8 16:05:00 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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.129.124]) by mx.zohomail.com with SMTPS id 164268683508636.200056784910885; Thu, 20 Jan 2022 05:53:55 -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-509-HQvE4whuNF-Rn9O8W-wP4w-1; Thu, 20 Jan 2022 08:53:44 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 26E601091DA8; Thu, 20 Jan 2022 13:53:38 +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 00C097BB48; Thu, 20 Jan 2022 13:53:38 +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 BD5391818480; Thu, 20 Jan 2022 13:53:37 +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 20KDrVl6009263 for ; Thu, 20 Jan 2022 08:53:31 -0500 Received: by smtp.corp.redhat.com (Postfix) id E9417141DEE7; Thu, 20 Jan 2022 13:53:30 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E58E4141DEE5 for ; Thu, 20 Jan 2022 13:53:30 +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 CD00D85A5AA for ; Thu, 20 Jan 2022 13:53:30 +0000 (UTC) Received: from mail-ot1-f45.google.com (mail-ot1-f45.google.com [209.85.210.45]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-640-zu-i3SQRPvKHoa3enRp-yQ-1; Thu, 20 Jan 2022 08:53:29 -0500 Received: by mail-ot1-f45.google.com with SMTP id t4-20020a05683022e400b00591aaf48277so7580878otc.13 for ; Thu, 20 Jan 2022 05:53:28 -0800 (PST) Received: from rekt.COMFAST ([191.8.61.226]) by smtp.gmail.com with ESMTPSA id a26sm1574102oiy.26.2022.01.20.05.53.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 05:53:27 -0800 (PST) X-MC-Unique: HQvE4whuNF-Rn9O8W-wP4w-1 X-MC-Unique: zu-i3SQRPvKHoa3enRp-yQ-1 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=Hu8wSrK8HGWfscDGbWvMZpjzCsyLkn73GN5EKyge0yg=; b=10PTUqUbgCNiqpby69HJJjgSGyRHlMtOEkQuKqPOWpw9ojy5iDzW/X5hE/KeG3iFy9 EiRMMcDgNQ1ZFG/Z+GzzRvJxa8odDvOm53TndPvkLrsUTh90yKEI1jj+v0jC5p3PFe3M ZbteUbc2pTGHJ6bh1OgY5WcSZkeffUDPPe0g7yW0q7eAUAsow6ldZi+7ZhIyfUEmKYmo vAnFJk/F6jvpxhkzfIw8Rq4BzO0MuNnxjmxpuI0RfXU9oqCDKQeX/+uiWUQvKOEC4iOK AF6fN46XfWutBvFdgFkt4eHqIB1kt0FxYJMk3yeF5b5yxAwHba0l4dKcU/sSOB95a2U6 gChg== X-Gm-Message-State: AOAM531CKwq9EpWNVmghT8XuXbw7Shcp42ZXhKWIkJQjF1uXIrGzLivj aacL1qqyeq+2XPXevujWFFa1AhnJnOA= X-Google-Smtp-Source: ABdhPJwjgSwvvXfgTT/Ct/0crtlQsxSjxgN9/3aUCEzyTJdWWqowrkUrsRdA2UfT5yzA3bSPwWLEig== X-Received: by 2002:a05:6830:18d7:: with SMTP id v23mr3697579ote.133.1642686808060; Thu, 20 Jan 2022 05:53:28 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 22/33] qemu_domain_address.c: change pnv-phb3 minimal downstream slot Date: Thu, 20 Jan 2022 10:52:25 -0300 Message-Id: <20220120135236.719924-23-danielhb413@gmail.com> In-Reply-To: <20220120135236.719924-1-danielhb413@gmail.com> References: <20220120135236.719924-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: fbarrat@linux.ibm.com, 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.16 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: 1642686837203100001 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 7ffdfa6478..5d65049c34 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