From nobody Thu May 2 16:16:47 2024 Delivered-To: importer2@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1622135291; cv=none; d=zohomail.com; s=zohoarc; b=F8Pd+y7U396W3v9cTGZTb7jDJ+IKn1uoGI3ezbYQvKjRY5nb9ICCo8x3qP28DXRtzJJ66KKjew4H7EeeuL+RuKAC+SCoNAp3Rsd6+DJgLnElE8WQQE8pBUyOHizFGuAiyYwej0PJMH4UGRFTiv3Fkykn4V7+eub+g53nWEduJlA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1622135291; h=Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=ArafUyBOO0IbbliGHou7RgvFNKoK+/JCxXXfof6UKWA=; b=m4Ja3vIVfVnX9cL/DQ/dfLotCjckCyojdSqIf+gyG60mNN8EzFsr07Of3EV5HoqaP9xKAIcRSkIQWm8nNx9Dg6Rh7ES0H/aHh0o5GoyxQZzmoKcjISCDxOMv1pnrKk5Fg8shUCMGebAkMT5utsn/JjC+L0gnp3YJyGL0TNag0L4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer2=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1622135291781634.1702647451993; Thu, 27 May 2021 10:08:11 -0700 (PDT) Received: from localhost ([::1]:35314 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lmJUQ-00059R-Qv for importer2@patchew.org; Thu, 27 May 2021 13:08:10 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48576) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lmJTC-0002wh-AV for qemu-devel@nongnu.org; Thu, 27 May 2021 13:06:54 -0400 Received: from out4-smtp.messagingengine.com ([66.111.4.28]:49591) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lmJT9-0005X6-8x for qemu-devel@nongnu.org; Thu, 27 May 2021 13:06:54 -0400 Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.nyi.internal (Postfix) with ESMTP id 409525C00FD; Thu, 27 May 2021 13:06:49 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Thu, 27 May 2021 13:06:49 -0400 Received: from localhost (unknown [101.224.192.115]) by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 27 May 2021 13:06:47 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=zhan9.net; h= from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; s=fm3; bh=ArafUyBOO0IbbliGHou7RgvFNK oK+/JCxXXfof6UKWA=; b=sO8R39X3z2QV3XoODAQlTop9df3au2W4iPWYo/DnNF htR9sRM1prsZcOC1+49UKT+M58zUmZn9xhFWaMOLW/tufBKfNuUdSibV259xYXnj MW/OXWSG+ysYOWy3kw4prO3V51cUzSmlyATBUpo7wBCcHoXoHIVwuy3e5hd0FYJR vm4UeUXFSl5+TG7Lj8ciPyfhgd/4JwQkNU6gMEdxXnJBeo+AJ018aNHRBRRFtZjF bEiQCwDeYWKJyGA6fpaAh4KoqiFQ540OgZ3jB6S2tenT3eoHkND6+tIPwsRWqzks uH8QUqMTyXzgH1TzjpkFlF9PsblI8nr/dfYGF7vghe+A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:date:from :message-id:mime-version:subject:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm2; bh=ArafUyBOO0IbbliGH ou7RgvFNKoK+/JCxXXfof6UKWA=; b=myYz1a9yYKd177Rr5qJm48V2GuxfJ6XgQ LJ60Irmf0N01PiXoHsT1h4Ake7nrR+JEJMpwPEojh3iKHJ5DrrKUnhJi4DVwC5l+ uqgjTF9nTdDCUBWUf4QLgJ26SH4pxpWa7pjde02l5pfprcUn8xcQoC5DdI0HpmlR PA3Uoj0d5Y5v0rQ4y7j8IDykfLB25p7oQswKxsdpWobxar4ddXc/DaVea0FOAz0B 1Msp614odCWRCA77f57AAXkRDY7ePeM1Q16BUwF04Npoj/UoWCap01NdmzabWZqv mewvB/FFavE3R3wFkOsdWeZ3qlAkCAx6dmO7ZgA4PZ1zdzGaz5wsQ== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgeduledrvdekhedguddtlecutefuodetggdotefrod ftvfcurfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfgh necuuegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffoggfgsedtkeertd ertddtnecuhfhrohhmpefjrghoiihhohhnghcukghhrghnghcuoehhrghoiihhohhnghes iihhrghnledrnhgvtheqnecuggftrfgrthhtvghrnheptdejhfejkefhtdegteefleettd ekveelfedvteehleeggefhvdefgffhuddttedunecukfhppedutddurddvvdegrdduledv rdduudehnecuvehluhhsthgvrhfuihiivgepudenucfrrghrrghmpehmrghilhhfrhhomh ephhgrohiihhhonhhgseiihhgrnhelrdhnvght X-ME-Proxy: From: Haozhong Zhang To: qemu-devel@nongnu.org Subject: [PATCH] xio3130_downstream: Set the maximum link width and speed Date: Fri, 28 May 2021 01:06:30 +0800 Message-Id: <20210527170630.43458-1-haozhong@zhan9.net> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 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+importer2=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=66.111.4.28; envelope-from=haozhong@zhan9.net; helo=out4-smtp.messagingengine.com X-Spam_score_int: -27 X-Spam_score: -2.8 X-Spam_bar: -- X-Spam_report: (-2.8 / 5.0 requ) BAYES_00=-1.9, 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_PASS=-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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Haozhong Zhang , Haozhong Zhang , mst@redhat.com Errors-To: qemu-devel-bounces+importer2=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The current implementation leaves 0 in the maximum link width (MLW) and speed (MLS) fields of the PCI_EXP_LNKCAP register of a xio3130 downstream port device. As a consequence, when that downstream port negotiates the link width and speed with its downstream device, 0 will be used and filled in the MLW and MLS fields of the PCI_EXP_LNKSTA register of that downstream port. Normally, such 0 MLS and MLW in PCI_EXP_LNKSTA register only make the guest lspci output looks weird (like "speed unknown" and "x0 width"). However, it also fails the hot-plug of device to the xio3130 downstream port. The guest Linux kernel complains: pcieport 0000:01:00.0: pciehp: Slot(0): Cannot train link: status 0x2000 because the pciehp_hpc driver expects a read of valid (non-zero) MLW from PCI_EXP_LNKSTA register of that downstream port. This patch addresses the above issue by setting MLW and MLS in PCI_EXP_LNKCAP of the xio3130 downstream port to values defined in its data manual, i.e., x1 and 2.5 GT respectively. Signed-off-by: Haozhong Zhang --- hw/pci-bridge/xio3130_downstream.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/pci-bridge/xio3130_downstream.c b/hw/pci-bridge/xio3130_dow= nstream.c index 04aae72cd6..fbf9868ad7 100644 --- a/hw/pci-bridge/xio3130_downstream.c +++ b/hw/pci-bridge/xio3130_downstream.c @@ -87,6 +87,13 @@ static void xio3130_downstream_realize(PCIDevice *d, Err= or **errp) goto err_bridge; } =20 + /* + * Following two fields must be set before calling pcie_cap_init() whi= ch + * will fill them to MLS and MLW of PCI_EXP_LNKCAP register. + */ + s->speed =3D QEMU_PCI_EXP_LNK_2_5GT; + s->width =3D QEMU_PCI_EXP_LNK_X1; + rc =3D pcie_cap_init(d, XIO3130_EXP_OFFSET, PCI_EXP_TYPE_DOWNSTREAM, p->port, errp); if (rc < 0) { --=20 2.31.1