From nobody Thu Dec 18 14:44:51 2025 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=1652699195; cv=none; d=zohomail.com; s=zohoarc; b=i2M2XZ8ghjb22synFbD5FoxREfiheWt6Z73N1Z2lFvCuyWdLHYLy+aQ5YWtZT02NMr1LR8l6ieoUYQO6XqFRefX2ZI16KlBn05ogCiLmSXutDaLC2CswoWZouRxhuU3JSY/acL6fLU6gY/6lzqIRZDsOtEucm4YRjF095VCc6Mw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1652699195; 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=l2T1w60jofo7fZUHG6FeDh5etrrEXvop8IS0FXVDyV0=; b=XTkcry5JA661eBDaRlabvB57ganysOBkXnw/GIYGDUGc19FnwQdKKGtXPQU0QkGsoANTxjYwT7JXg+0zA7qcjfzVDXY6OgLF38EbAu3OFxcM9cPtZHrE++WHxcTW137ql9EBaUEAElWgC2mzr3M6/4WjFWA4OorbydM3brIJABA= 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 165269919510834.61612074102948; Mon, 16 May 2022 04:06:35 -0700 (PDT) Received: from localhost ([::1]:55506 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nqYYb-0005Kh-V1 for importer@patchew.org; Mon, 16 May 2022 07:06:34 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:48080) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY5X-0006Ds-0F for qemu-devel@nongnu.org; Mon, 16 May 2022 06:36:31 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:38121) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nqY5U-0005Ds-Mp for qemu-devel@nongnu.org; Mon, 16 May 2022 06:36:30 -0400 Received: from mail-wm1-f72.google.com (mail-wm1-f72.google.com [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-414-DWXr_jOAMTKa9TDRxaAJhg-1; Mon, 16 May 2022 06:36:27 -0400 Received: by mail-wm1-f72.google.com with SMTP id z23-20020a05600c221700b003942fd37764so10134411wml.8 for ; Mon, 16 May 2022 03:36:26 -0700 (PDT) Received: from redhat.com ([2.55.141.66]) by smtp.gmail.com with ESMTPSA id k20-20020adfb354000000b0020d110bc39esm522882wrd.64.2022.05.16.03.36.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 16 May 2022 03:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1652697388; 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=l2T1w60jofo7fZUHG6FeDh5etrrEXvop8IS0FXVDyV0=; b=gLItSC/yULcJ9Lnun9Qwd9x0AbO6nMUyt2f1zevJeg7mh7qlLNHauIGU9G4nU3bgatYI2d hAyZdnuxTJ0UxAX0VNWQYqNwOamhMqf2Wm+yrc6Ee/teAc4PzvKStPexICCZE6Wag3zIDT 9pPnptb1NxEaxkLbRAYeHhXJbKBr1EY= X-MC-Unique: DWXr_jOAMTKa9TDRxaAJhg-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=l2T1w60jofo7fZUHG6FeDh5etrrEXvop8IS0FXVDyV0=; b=xNK68TNwnAU3oaY/TARwjXLEZ1+uy8AtF00JMSWuNJEMHNG+iFjmstYFxDCqubdQwc 1zZ5JxhaJJ0PmPbVQjMce8f5aVr/7tLUSnDnvs4G+vEoU20EveR6m0pnXAkrWpfI7zrN jbcx3L13mnBpDhHUUZbLpw+xypECEJFXwiOtJYarMq0r7V6FK6qkKNMinnRAUQoNZFm+ X8qNmGaywK6CYnjQGHF2+0MsPsQqEw8fieGyKHrO1L7legl/mzszb0GlJ68GXyVBv3uk HNPUUqbqOAI8d5zRTWgr8OK3IDMM+T/IGZF7UZhMXJ3KWY6zmpqjSNSwVJ8/Qf1NaQ/G C65A== X-Gm-Message-State: AOAM531MGvbivlOhr1Pvsy4S3pcVgKj4dPaSL9nHeo0ZPlERrp2lpDVM SwMnPDgYiFArNpRCWql4Kh5GIHeDnTuSq+tR9x+LpC8xbzTp8VhvEa8cuU9zVIg8Ie4Jue3cpW7 NJrxbheDDIAGOrEHCKJL1R2yQLb46VA/KYmXoc2073BYy40TOqLNFkFJzLCEA X-Received: by 2002:adf:ef46:0:b0:20a:e153:1f4e with SMTP id c6-20020adfef46000000b0020ae1531f4emr13601307wrp.352.1652697385669; Mon, 16 May 2022 03:36:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwo4OGjW0DSWaZ+JamI4DmX0wL9bziMn9+LhtFoCZAl39YU3gBEQBmyglE+XqKEeMa9fC9Pig== X-Received: by 2002:adf:ef46:0:b0:20a:e153:1f4e with SMTP id c6-20020adfef46000000b0020ae1531f4emr13601286wrp.352.1652697385381; Mon, 16 May 2022 03:36:25 -0700 (PDT) Date: Mon, 16 May 2022 06:36:22 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Ben Widawsky , Jonathan Cameron , Alex =?utf-8?Q?Benn=C3=A9e?= , Marcel Apfelbaum Subject: [PULL 14/91] hw/pci/cxl: Create a CXL bus type Message-ID: <20220516095448.507876-15-mst@redhat.com> References: <20220516095448.507876-1-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Disposition: inline Content-Transfer-Encoding: quoted-printable In-Reply-To: <20220516095448.507876-1-mst@redhat.com> 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: -28 X-Spam_score: -2.9 X-Spam_bar: -- X-Spam_report: (-2.9 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.082, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 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" X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1652699196120100001 From: Ben Widawsky The easiest way to differentiate a CXL bus, and a PCIE bus is using a flag. A CXL bus, in hardware, is backward compatible with PCIE, and therefore the code tries pretty hard to keep them in sync as much as possible. The other way to implement this would be to try to cast the bus to the correct type. This is less code and useful for debugging via simply looking at the flags. Signed-off-by: Ben Widawsky Signed-off-by: Jonathan Cameron Reviewed-by: Alex Benn=C3=A9e Message-Id: <20220429144110.25167-13-Jonathan.Cameron@huawei.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- include/hw/pci/pci_bus.h | 7 +++++++ hw/pci-bridge/pci_expander_bridge.c | 9 ++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/include/hw/pci/pci_bus.h b/include/hw/pci/pci_bus.h index 347440d42c..eb94e7e85c 100644 --- a/include/hw/pci/pci_bus.h +++ b/include/hw/pci/pci_bus.h @@ -24,6 +24,8 @@ enum PCIBusFlags { PCI_BUS_IS_ROOT =3D 0x0001, /* PCIe extended configuration space is accessible on this bus */ PCI_BUS_EXTENDED_CONFIG_SPACE =3D 0x0002, + /* This is a CXL Type BUS */ + PCI_BUS_CXL =3D 0x0004, }; =20 struct PCIBus { @@ -53,6 +55,11 @@ struct PCIBus { Notifier machine_done; }; =20 +static inline bool pci_bus_is_cxl(PCIBus *bus) +{ + return !!(bus->flags & PCI_BUS_CXL); +} + static inline bool pci_bus_is_root(PCIBus *bus) { return !!(bus->flags & PCI_BUS_IS_ROOT); diff --git a/hw/pci-bridge/pci_expander_bridge.c b/hw/pci-bridge/pci_expand= er_bridge.c index d4514227a8..a6caa1e7b5 100644 --- a/hw/pci-bridge/pci_expander_bridge.c +++ b/hw/pci-bridge/pci_expander_bridge.c @@ -24,7 +24,7 @@ #include "hw/boards.h" #include "qom/object.h" =20 -enum BusType { PCI, PCIE }; +enum BusType { PCI, PCIE, CXL }; =20 #define TYPE_PXB_BUS "pxb-bus" typedef struct PXBBus PXBBus; @@ -35,6 +35,10 @@ DECLARE_INSTANCE_CHECKER(PXBBus, PXB_BUS, DECLARE_INSTANCE_CHECKER(PXBBus, PXB_PCIE_BUS, TYPE_PXB_PCIE_BUS) =20 +#define TYPE_PXB_CXL_BUS "pxb-cxl-bus" +DECLARE_INSTANCE_CHECKER(PXBBus, PXB_CXL_BUS, + TYPE_PXB_CXL_BUS) + struct PXBBus { /*< private >*/ PCIBus parent_obj; @@ -251,6 +255,9 @@ static void pxb_dev_realize_common(PCIDevice *dev, enum= BusType type, ds =3D qdev_new(TYPE_PXB_HOST); if (type =3D=3D PCIE) { bus =3D pci_root_bus_new(ds, dev_name, NULL, NULL, 0, TYPE_PXB_PCI= E_BUS); + } else if (type =3D=3D CXL) { + bus =3D pci_root_bus_new(ds, dev_name, NULL, NULL, 0, TYPE_PXB_CXL= _BUS); + bus->flags |=3D PCI_BUS_CXL; } else { bus =3D pci_root_bus_new(ds, "pxb-internal", NULL, NULL, 0, TYPE_P= XB_BUS); bds =3D qdev_new("pci-bridge"); --=20 MST