From nobody Sun Feb 8 16:44:59 2026 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=1730754566; cv=none; d=zohomail.com; s=zohoarc; b=mlHeBJ8BL6oYjDSCPkfReUu5h2UzqPyPWyPUIhC4RZIIM8MvF2EnNGHm1DZBPXlQ8VVGUEwDKv29ZZ0lTF2Ni5lbtlO3dTX8kgLhWq5v+ONQ+aZ9HYEbvZUJwvj2TRtYcl0doPbeRl79rnPuchSR9JkCQeDZwIH7OBffcRGstK8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730754566; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=mvlW1QwJWNe5kggYv414OUm4j2VpwLnaPYotmjUzdE0=; b=TQYh61v/evokNsJI+tDTpktci9UWPkCdONoDDvdDIfrTjnJqt1mbm9F+VUr6i29uQOALgOK5jU5uX27TRs3Ce/u7U8JweyiJcuABYn7o5cR5mc5ULM0f+JxvQ/lvT8T3H6E4o2RFLxCx+MtMm6i7hea4E8mpQH4jIL/IPwUDvOw= 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 1730754566864649.4074105687082; Mon, 4 Nov 2024 13:09:26 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1t84Hm-0005nG-6e; Mon, 04 Nov 2024 16:06:54 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Hj-0005dh-1l for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:51 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1t84Hf-0005L3-7E for qemu-devel@nongnu.org; Mon, 04 Nov 2024 16:06:49 -0500 Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-628-gesHf-jNM6i366OtGH7hbg-1; Mon, 04 Nov 2024 16:06:45 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d537292d7so3166616f8f.2 for ; Mon, 04 Nov 2024 13:06:45 -0800 (PST) Received: from redhat.com ([2.52.14.134]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-431bd9a99c8sm194245875e9.29.2024.11.04.13.06.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Nov 2024 13:06:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1730754406; 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: in-reply-to:in-reply-to:references:references; bh=mvlW1QwJWNe5kggYv414OUm4j2VpwLnaPYotmjUzdE0=; b=jAGx9GwSMsJoEgadMl7+/hr0HE+ewPONiLDU0qjtTMdQQ/lZSewndbW9bj3YTSOeicGl/8 PtfAO0WI+eki6vYJzL++fPpivFy6ii48rq26WY3i6lhE5hYLW2xC8aWjLHfO9qNEfwbXhU U8Cp9oviOrIKembO+KwU1dg/BQh5o/g= X-MC-Unique: gesHf-jNM6i366OtGH7hbg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1730754404; x=1731359204; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=mvlW1QwJWNe5kggYv414OUm4j2VpwLnaPYotmjUzdE0=; b=QK/vnNKiQFDB2qqdpWzSloWcgKWXCds1iW4EfWxDGY5zo06XFuj+TTh7nvV22MzlkZ e0pSSstjbmHfFjJoVibx6bIbyKR/2toIEn4pi7U67n+crVkdWDmg2N1ayQxYr1+4EeoD XB9bSK+PQfjZoEX2wzip8BtFzZo0xaGcl/FtVr6YAvVl0JYMmA0CJsVasqtsSKscERau xqol9lwfF8irhiHevPH2wIvlh88fPlJ/ZMbXgo9UT3SGcuGqmmp3cHiCQZairnf6w1SU HQu5ktkxkzraNCTKCq/SjklvZXy9adxPWFKLlyBLtbJKhACglj3Z112ZomsMtn378EgI FoRQ== X-Gm-Message-State: AOJu0YzoESRaD8q3GMcKY4apCzOoEs7yY4cIU3COTYOQN2By3ijBHDH4 5P6ugWq31+tfbqu0Rro4198J/HKdpK5jMhl41jecNOD3+taVwLXmpAae/YraL98NXxlTa6xknbU NJDZihX0NnybQxbeVj/dGF2fd9PR+CNbeMSJ663ZYx6vlh/MzVc71NDPCfmF20BSmASYdShnObO EqZ7WoNsxNycjEGVrcz49FKBFxKcOjsg== X-Received: by 2002:a5d:6d0f:0:b0:37d:9565:4db2 with SMTP id ffacd0b85a97d-381c7a469cemr15748905f8f.6.1730754403911; Mon, 04 Nov 2024 13:06:43 -0800 (PST) X-Google-Smtp-Source: AGHT+IGstg4UaqKvsdNO9OWD014KkMqczeSPGWw9EyX+mw7O04nA7SsF/pefVSpUxfbyUtd8Q+x1CA== X-Received: by 2002:a5d:6d0f:0:b0:37d:9565:4db2 with SMTP id ffacd0b85a97d-381c7a469cemr15748878f8f.6.1730754403453; Mon, 04 Nov 2024 13:06:43 -0800 (PST) Date: Mon, 4 Nov 2024 16:06:40 -0500 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Jonathan Cameron , Marcel Apfelbaum Subject: [PULL 18/65] hw/pcie: Provide a utility function for control of EP / SW USP link Message-ID: References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent 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=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -23 X-Spam_score: -2.4 X-Spam_bar: -- X-Spam_report: (-2.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.34, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=0.001, RCVD_IN_MSPIKE_WL=0.001, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED=0.001, RCVD_IN_VALIDITY_RPBL_BLOCKED=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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1730754567679116600 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Jonathan Cameron Whilst similar to existing PCIESlot link configuration a few registers need to be set differently so that the downstream device presents a 'configured' state that is then used to 'train' the upstream port on the link. Basically that means setting the status register to reflect it succeeding in training up to target settings. Signed-off-by: Jonathan Cameron Message-Id: <20240916173518.1843023-5-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pcie.h | 2 ++ hw/pci/pcie.c | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/hw/pci/pcie.h b/include/hw/pci/pcie.h index 5eddb90976..b8d59732bc 100644 --- a/include/hw/pci/pcie.h +++ b/include/hw/pci/pcie.h @@ -141,6 +141,8 @@ void pcie_acs_reset(PCIDevice *dev); void pcie_ari_init(PCIDevice *dev, uint16_t offset); void pcie_dev_ser_num_init(PCIDevice *dev, uint16_t offset, uint64_t ser_n= um); void pcie_ats_init(PCIDevice *dev, uint16_t offset, bool aligned); +void pcie_cap_fill_link_ep_usp(PCIDevice *dev, PCIExpLinkWidth width, + PCIExpLinkSpeed speed); =20 void pcie_cap_slot_pre_plug_cb(HotplugHandler *hotplug_dev, DeviceState *d= ev, Error **errp); diff --git a/hw/pci/pcie.c b/hw/pci/pcie.c index 1ac6d89dcf..2738dbb28d 100644 --- a/hw/pci/pcie.c +++ b/hw/pci/pcie.c @@ -154,6 +154,24 @@ static void pcie_cap_fill_lnk(uint8_t *exp_cap, PCIExp= LinkWidth width, } } =20 +void pcie_cap_fill_link_ep_usp(PCIDevice *dev, PCIExpLinkWidth width, + PCIExpLinkSpeed speed) +{ + uint8_t *exp_cap =3D dev->config + dev->exp.exp_cap; + + /* + * For an end point or USP need to set the current status as well + * as the capabilities. + */ + pci_long_test_and_clear_mask(exp_cap + PCI_EXP_LNKSTA, + PCI_EXP_LNKSTA_CLS | PCI_EXP_LNKSTA_NLW); + pci_long_test_and_set_mask(exp_cap + PCI_EXP_LNKSTA, + QEMU_PCI_EXP_LNKSTA_NLW(width) | + QEMU_PCI_EXP_LNKSTA_CLS(speed)); + + pcie_cap_fill_lnk(exp_cap, width, speed); +} + static void pcie_cap_fill_slot_lnk(PCIDevice *dev) { PCIESlot *s =3D (PCIESlot *)object_dynamic_cast(OBJECT(dev), TYPE_PCIE= _SLOT); --=20 MST