From patchwork Thu Oct 12 12:18:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 732469 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp916666wrv; Thu, 12 Oct 2023 05:20:05 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH/MlgbM/FH0KoXkyzOfdxL8u+Fdv5KI0D4hJ5sxMxqgOd7XoABmvgGUgQVvYfOf90Po8GH X-Received: by 2002:a05:6214:4188:b0:655:d7b5:4728 with SMTP id ld8-20020a056214418800b00655d7b54728mr22944924qvb.54.1697113204708; Thu, 12 Oct 2023 05:20:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697113204; cv=none; d=google.com; s=arc-20160816; b=TsZktFl59RPgQ++a0U1owhCxpW6opV9Nu8AOArEPu9dhy8EBGsmwR3XlSN+PbpdN3Y D+3ShhTqIjhP5hJnTNInzTZXKMRiZ0I1+KNYJMofVA2z6+sdZmsPxyEhM/GNuPIzb65n Ee8/X8F8czBjJupkkSkN/7ctN+azsHHGLMQCOcnqt3qt8D1jL8XaNHapVS0biIkRyNo6 JMYTsjyXX5tv3RcY7Y5jFq8ft0Fz0B8OHlN1HzX4XB4zoZFvkutwQB749xxXfpZ2Q4zv YyIUyYXPCCtOuTal/YCxPBBil6uY/ni5iYSiVVNrq2jw1NIZhNrgqsh/BPdYvtTKi/lN tlDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=gZd2RKyqgmNmX/QmPgvNjI61C3FFoLBUU4C4GM7tl24=; fh=uMYo3jOuXUsDthaXCE4/M6n3+voY5rtHQA7Grzg1cYU=; b=PrRVTmqNimk7zNOECW7NHfvXDnvSbkfRiB0f5PGJHa9zVJEquP7ldGHVvS8aIbndPg 7BV52cXGjEgwWGE9UrHGLvbdX7wxbFUnB9Vo6hmf8uqH6KEyzEYroRov+XsTc4AQ6ft1 v+d/d6/4hVR5VAc3VqC49/gT1vUQTcFwE+A9dRm7WszeHpWlWoG9jPLoW/IerU5Xc9fg s7044tzgucpj6wovQtAsWmqoDJgnx9lonbhYBQFm++ti/de3JAHLmlvtzw03+LGDlZME Mdxn0ALQtZHGfDYCits7Koi7pQFRe0D81Zyr41DvYMgEm5LCWKayZlzZG/PTsKIV8MJ5 Lvuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="eT3NCh/S"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bt12-20020ad455cc000000b0066d17fa0648si566125qvb.198.2023.10.12.05.20.04 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Oct 2023 05:20:04 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="eT3NCh/S"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqueq-0002jt-MY; Thu, 12 Oct 2023 08:19:16 -0400 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 1qquem-0002ia-86 for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:12 -0400 Received: from mail-ej1-x62b.google.com ([2a00:1450:4864:20::62b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qquek-0001kS-8o for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:11 -0400 Received: by mail-ej1-x62b.google.com with SMTP id a640c23a62f3a-9ba1eb73c27so147593666b.3 for ; Thu, 12 Oct 2023 05:19:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697113146; x=1697717946; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=gZd2RKyqgmNmX/QmPgvNjI61C3FFoLBUU4C4GM7tl24=; b=eT3NCh/ShKWaEteKgQ7VrDKNKDniFaguhQGzEutHeea4RYbG5ZgwLb6vWK4GYeL6FU iHtAzbOrFLnouIqy3ZwJaf+XqS9CvnNNBUb2VvIQuBnFRwuyuX8PMw6Mszfqih5VMfX8 Q0Hx5aNIzd+EjS4idcTim0sefSN8vq7C0gsvrTZez9YQ7XbppT8Sd90ZjuqRXPpticjm PninLPT8YBXm/X1ru3c6TW+j3U/5Mr2AVmPMdhxRE0ZpVuyQEP7oYDIqaYNMyE1pxlTw t+f9auV6KAonL1HumZci1qeeTH0aa4+tYt1aE7XdEx6aTjDx5UpX5uT9JxQC7BzSRXyj bGyA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697113146; x=1697717946; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=gZd2RKyqgmNmX/QmPgvNjI61C3FFoLBUU4C4GM7tl24=; b=NroX5KEfAoF8XOB+ZfYz1afjw+WqDjyAkKmJSx8bjK3ppfTBRwotVQjnTfmpZ0sww8 1HWVFWOoCIWlzUep3Sqt6IH3luqvEj5nsB9ZTS9/mDaulD+lHchK8fb2ip4ZIA2ikPZa 8qGZoeo1pZf++Np4kruVGurL0fSiuH2Djf3aRDs6FOIDWu8udiYHAWoVGPMSriklhdQ1 nx/Hi+yAY2MmOqhzPW55SwsIaNMKX01GMUzbKBZdvRpcBkr10sr7D15VVjKMGmNzU5WS tHlxHHBPctjkvFd6Et5hI+p7gojFp1l2b1Fc+S4mZGGweHvBIm+Wr4BWeUaboMQ5fXsJ IsBQ== X-Gm-Message-State: AOJu0Yzo10zl0LERZwsUMob5M/1ptmvAYv8LRQfeYWUcK5l0g3brl/vl blBqgDz45+dGZrySL10UZZ1Bnq/2JhEX7DwWhQdZ2g== X-Received: by 2002:a17:907:75f7:b0:9ae:658f:a80a with SMTP id jz23-20020a17090775f700b009ae658fa80amr20517353ejc.48.1697113146504; Thu, 12 Oct 2023 05:19:06 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-232.abo.bbox.fr. [176.131.211.232]) by smtp.gmail.com with ESMTPSA id i16-20020a1709064ed000b0099bd0b5a2bcsm11065610ejv.101.2023.10.12.05.19.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Oct 2023 05:19:05 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Andrey Smirnov , qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH 1/8] hw/pci-host/designware: Declare CPU QOM types using DEFINE_TYPES() macro Date: Thu, 12 Oct 2023 14:18:49 +0200 Message-ID: <20231012121857.31873-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012121857.31873-1-philmd@linaro.org> References: <20231012121857.31873-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62b; envelope-from=philmd@linaro.org; helo=mail-ej1-x62b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org When multiple QOM types are registered in the same file, it is simpler to use the the DEFINE_TYPES() macro. In particular because type array declared with such macro are easier to review. Remove a pointless structure declaration in "designware.h". Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Reviewed-by: Gustavo Romero --- include/hw/pci-host/designware.h | 2 -- hw/pci-host/designware.c | 39 ++++++++++++++------------------ 2 files changed, 17 insertions(+), 24 deletions(-) diff --git a/include/hw/pci-host/designware.h b/include/hw/pci-host/designware.h index 908f3d946b..c484e377a8 100644 --- a/include/hw/pci-host/designware.h +++ b/include/hw/pci-host/designware.h @@ -31,8 +31,6 @@ OBJECT_DECLARE_SIMPLE_TYPE(DesignwarePCIEHost, DESIGNWARE_PCIE_HOST) #define TYPE_DESIGNWARE_PCIE_ROOT "designware-pcie-root" OBJECT_DECLARE_SIMPLE_TYPE(DesignwarePCIERoot, DESIGNWARE_PCIE_ROOT) -struct DesignwarePCIERoot; - typedef struct DesignwarePCIEViewport { DesignwarePCIERoot *root; diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c index 6f5442f108..304eca1b5c 100644 --- a/hw/pci-host/designware.c +++ b/hw/pci-host/designware.c @@ -746,28 +746,23 @@ static void designware_pcie_host_init(Object *obj) qdev_prop_set_bit(DEVICE(root), "multifunction", false); } -static const TypeInfo designware_pcie_root_info = { - .name = TYPE_DESIGNWARE_PCIE_ROOT, - .parent = TYPE_PCI_BRIDGE, - .instance_size = sizeof(DesignwarePCIERoot), - .class_init = designware_pcie_root_class_init, - .interfaces = (InterfaceInfo[]) { - { INTERFACE_PCIE_DEVICE }, - { } +static const TypeInfo designware_pcie_types[] = { + { + .name = TYPE_DESIGNWARE_PCIE_HOST, + .parent = TYPE_PCI_HOST_BRIDGE, + .instance_size = sizeof(DesignwarePCIEHost), + .instance_init = designware_pcie_host_init, + .class_init = designware_pcie_host_class_init, + }, { + .name = TYPE_DESIGNWARE_PCIE_ROOT, + .parent = TYPE_PCI_BRIDGE, + .instance_size = sizeof(DesignwarePCIERoot), + .class_init = designware_pcie_root_class_init, + .interfaces = (InterfaceInfo[]) { + { INTERFACE_PCIE_DEVICE }, + { } + }, }, }; -static const TypeInfo designware_pcie_host_info = { - .name = TYPE_DESIGNWARE_PCIE_HOST, - .parent = TYPE_PCI_HOST_BRIDGE, - .instance_size = sizeof(DesignwarePCIEHost), - .instance_init = designware_pcie_host_init, - .class_init = designware_pcie_host_class_init, -}; - -static void designware_pcie_register(void) -{ - type_register_static(&designware_pcie_root_info); - type_register_static(&designware_pcie_host_info); -} -type_init(designware_pcie_register) +DEFINE_TYPES(designware_pcie_types) From patchwork Thu Oct 12 12:18:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 732475 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp917782wrv; Thu, 12 Oct 2023 05:22:22 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEGKu0loVokQZ9folL7d0Xaw37lnUw0Df/zYkRiIc2CPfpyketoQNBr9vt/TCJLZnQRkKOv X-Received: by 2002:a05:6102:5709:b0:457:a913:e89d with SMTP id dg9-20020a056102570900b00457a913e89dmr3309742vsb.12.1697113342120; Thu, 12 Oct 2023 05:22:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697113342; cv=none; d=google.com; s=arc-20160816; b=nl+/8D/TcJVeas4WK6sYuLmYy4LMh3xSieROTV3rM4M/mx8Aj5t0yl/Zp8jKvsvyVY 40sUQhvFJrOEybaKP9/bavYjATXzotvWHj4u0idZf1yIOXTnZdXlfh0ZovIQHvlHw8iB 9yiy843riL8aajlE/OOmS3vj3dNdR9zkkdP592tntxiN9db1o9xP/38fh/Db7zGaG3h2 4lNBBjFbOJoEt22ioJS3zT4BVHAFCxec96UDKRdI9kpXi89IuHbiUsgHMxZbY5thsKaB mHcQ+0muNGjKHisSNyZ+grjnraXBbl079w4BZ4tZ809lO0qjlEwVNJAnpONQhgOB7Kn4 Q4kg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Fa15t5TAOGLEwbp/XmPMZ/3+NPt1m11OvXKqtHI65yw=; fh=uMYo3jOuXUsDthaXCE4/M6n3+voY5rtHQA7Grzg1cYU=; b=I4GhKohQ3qoYxaOa4XJSu242I+c3YBUrdU36dCxiQzaZ1TPwPBHseFAfwPgcaaSP+c 0FWmSbvFTIJNT6pGxco/KZmiiFbV9iL86ZamI53hB1TvoVu95kMWLlftDF5vm7I/b2u7 elY3KhGfzGz2EKc0mpoikW8wH1oY20Zxzc2E2KGHBK5GQeO+J4JhkRuR/yJaKOgyzl0L ar5bhmlXRnZR1VNuwDz3MuEr79jCRzX3tr32jBcEiyHBxhlO59inssG2xbk35fXV9v5r lGMnmQT1jTOMNbZoDv2GqU9n5ez7z0YBNMYtjEsr6caFaxaRY8OLlfXs8gl2a1gHNXVT ecMg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XnsZHgGN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u6-20020a05622a010600b0041362f42bcasi10723481qtw.794.2023.10.12.05.22.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Oct 2023 05:22:22 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XnsZHgGN; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqueu-0002mo-1e; Thu, 12 Oct 2023 08:19:20 -0400 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 1qques-0002kd-BN for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:18 -0400 Received: from mail-ej1-x634.google.com ([2a00:1450:4864:20::634]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qqueq-0001nb-Ma for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:18 -0400 Received: by mail-ej1-x634.google.com with SMTP id a640c23a62f3a-9b974955474so137746666b.1 for ; Thu, 12 Oct 2023 05:19:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697113153; x=1697717953; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Fa15t5TAOGLEwbp/XmPMZ/3+NPt1m11OvXKqtHI65yw=; b=XnsZHgGNkyKCh07e/ewz9lrRPHD4E0mYFWZ+55zuQuS70PRDCJVOCpS9XGAOPWQ64w hyGH2wv4jsfP4imhfvfEReyipmghs6dJHoIQLByxOxQIaeDmwQDaplkJa51NI67FyvTX sSJODgqskAg35U4RoLE0OFbIum2JmOokY5q8Px31UbNFsf/0JyFQ5s7A/vPK1fpPfTHf ciQWPx8KArFAxiaS/215NhJpcGN16ilS8oxin6uwKeAH/HXH4Q63u/rGi/hf4AKhHf32 HkuOUleSs4My/i6fNh7xcYt3+ZJ+JMR8l81QHuh+EA6r5hnmPULI78YTFSXUmuyCW1Il PD2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697113153; x=1697717953; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Fa15t5TAOGLEwbp/XmPMZ/3+NPt1m11OvXKqtHI65yw=; b=C7gZdptBn/jxb9GhTqrh/tKNwEa+k+9B21cP2FA4XHWB/JWMYoV+zvFzC8VDRhOFe5 /17FdKS6jQFeCNxv6MRCmOfzQMA51UXC97APMu1x0SZnwJzxh6cV1wZBEJxYUPjaVf2I AmWGMzs8TZM7eJj+H4YEMPXbZhN9HNK7MPCtaBfX6Is2fPHmIDrU4aXIZBeR1CECAg3U AnIiDooDPHODkBTmL91XSEfbhIvxXOlaFV4/wlV+YwECx31+7VI+ZwkPDNsEhlBCXXTV 0uy+ge90VIllA3+NWXw0dVc2FpbtIX+4PgopzHK4U3LKxKDT7DOwiHymBi1UYvFjkqgV KM3Q== X-Gm-Message-State: AOJu0YxzNqOr4T5S0pYWJme3xVl40Ka5jj/mpd8mhtt1u7+/gkwHopAw +q4S77zNs4LEZZx9F65KH8leJpSpqRtNKSA3cBUeAQ== X-Received: by 2002:a17:907:6c14:b0:9ae:5c99:f2e2 with SMTP id rl20-20020a1709076c1400b009ae5c99f2e2mr18605504ejc.43.1697113153692; Thu, 12 Oct 2023 05:19:13 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-232.abo.bbox.fr. [176.131.211.232]) by smtp.gmail.com with ESMTPSA id x20-20020a170906299400b00997c1d125fasm11157488eje.170.2023.10.12.05.19.11 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Oct 2023 05:19:11 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Andrey Smirnov , qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH 2/8] hw/pci-host/designware: Initialize root function in host bridge realize Date: Thu, 12 Oct 2023 14:18:50 +0200 Message-ID: <20231012121857.31873-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012121857.31873-1-philmd@linaro.org> References: <20231012121857.31873-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::634; envelope-from=philmd@linaro.org; helo=mail-ej1-x634.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org There are no root function properties exposed by the host bridge, so using a 2-step QOM creation isn't really useful. Simplify by creating the root function when the host bridge is realized. Signed-off-by: Philippe Mathieu-Daudé --- hw/pci-host/designware.c | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c index 304eca1b5c..692e0731cd 100644 --- a/hw/pci-host/designware.c +++ b/hw/pci-host/designware.c @@ -707,6 +707,10 @@ static void designware_pcie_host_realize(DeviceState *dev, Error **errp) "pcie-bus-address-space"); pci_setup_iommu(pci->bus, designware_pcie_host_set_iommu, s); + object_initialize_child(OBJECT(dev), "root", &s->root, + TYPE_DESIGNWARE_PCIE_ROOT); + qdev_prop_set_int32(DEVICE(&s->root), "addr", PCI_DEVFN(0, 0)); + qdev_prop_set_bit(DEVICE(&s->root), "multifunction", false); qdev_realize(DEVICE(&s->root), BUS(pci->bus), &error_fatal); } @@ -736,22 +740,11 @@ static void designware_pcie_host_class_init(ObjectClass *klass, void *data) dc->vmsd = &vmstate_designware_pcie_host; } -static void designware_pcie_host_init(Object *obj) -{ - DesignwarePCIEHost *s = DESIGNWARE_PCIE_HOST(obj); - DesignwarePCIERoot *root = &s->root; - - object_initialize_child(obj, "root", root, TYPE_DESIGNWARE_PCIE_ROOT); - qdev_prop_set_int32(DEVICE(root), "addr", PCI_DEVFN(0, 0)); - qdev_prop_set_bit(DEVICE(root), "multifunction", false); -} - static const TypeInfo designware_pcie_types[] = { { .name = TYPE_DESIGNWARE_PCIE_HOST, .parent = TYPE_PCI_HOST_BRIDGE, .instance_size = sizeof(DesignwarePCIEHost), - .instance_init = designware_pcie_host_init, .class_init = designware_pcie_host_class_init, }, { .name = TYPE_DESIGNWARE_PCIE_ROOT, From patchwork Thu Oct 12 12:18:51 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 732474 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp917693wrv; Thu, 12 Oct 2023 05:22:10 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGGf5SzmRQU71MJ3ThlnTkZsWkarvzHtY9uxdKekqtDhvrz0Dv2N4veRwdxErmcw3H4y5qJ X-Received: by 2002:a81:6e88:0:b0:5a2:15bc:b32c with SMTP id j130-20020a816e88000000b005a215bcb32cmr26174677ywc.42.1697113330217; Thu, 12 Oct 2023 05:22:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697113330; cv=none; d=google.com; s=arc-20160816; b=cxY9lBXR348lveq5zb504+MlrMYHd5GqfUCCV843UM5RNBGEo2lk1X66LXHKKsea5k w1cd0tDFH5+UEPq407/6apWjg48un6TXo6SZhNjhtjduz0RGToNwIIt1gv5YPObzNSDU cFUUZPxsL7+S5hkqSk2f0L2gbGuwb13xwQqORqPqohkiteHFaUigcgyEWbUQ0K/dafxS gB77h8hiElbBEmxqT4otqtjcnLE058uAzvfio3zUJyP46RBwv0s14lNDewxbcsNWbkzg DG30ysMflmti21p/hqYPrXlF99C0TzzsGPFc5+bEGkzcGadMVnqE52lQFpxwkg0sgU3+ h49Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=x9j0wB4sagFap8UlCk3DGG3Emv5eeF0Xy9DDluHlDSM=; fh=uMYo3jOuXUsDthaXCE4/M6n3+voY5rtHQA7Grzg1cYU=; b=cyvhPEij1gYD2Qa98gMw5ELTXvobO5rrLUJWXDRNM56Ap6dxrsCsYlCmd7fvRojyFg qCqtjnu0KHAQqg2V2NrsPTU+7H3BrQA71kWoVo01/6IR0X7s7fnYrI1ylO22TbRDf6uV L/n9VDdV9lONOO6kEStvHHjFibYUznPKIj/9mFS/y9L9i59kBOEDThMWUKfwoKl/0ESJ 4zyWcQpq/HfRYBnL9n4wadS/9B5wUB5DZhdgjQtt/MHGRcdTj37mYse9fQwv9IG/Ob2a 6eM2vOYeJKLx2ALLLzKzsn3fOMRhwhtKLag0XttZrDm9RG/U2FFcoN33a/Dj+rwwL4nM K1ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Op3YQS6i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v12-20020a05620a0f0c00b00774373352b5si11364077qkl.769.2023.10.12.05.22.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Oct 2023 05:22:10 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Op3YQS6i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qquey-0002uE-Rk; Thu, 12 Oct 2023 08:19:24 -0400 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 1qquex-0002si-Tc for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:23 -0400 Received: from mail-ej1-x62c.google.com ([2a00:1450:4864:20::62c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qquew-0001ob-BQ for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:23 -0400 Received: by mail-ej1-x62c.google.com with SMTP id a640c23a62f3a-99357737980so148430666b.2 for ; Thu, 12 Oct 2023 05:19:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697113160; x=1697717960; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=x9j0wB4sagFap8UlCk3DGG3Emv5eeF0Xy9DDluHlDSM=; b=Op3YQS6ii/w+7k2SJnNHXrk/kAAJsSBVqntkgWO0CFTlGNUQT0P9OEIEy/6SO3hkht w4ywhxzzwqHrNXTSw97p10oxyAFjVjEuq8LLIU6+V/26THL0nGcetp8Btu2w5kCUYhfs JXqqeEeVpIBnjXI/7Bl07CfUEz6nglBWbGes11tLaHDhnqZZtx0N4RFX57G9r9PUAOZr kuIQ1WRMOOeGsM+0C6zN0BZBnbP14/jtO4n7aw9gv4eRIk1NN1nmpx+7w8eVKLnLP2/8 2m/CsuRMInH3mzUZwjB0GOK2rZJNl1A35aFQ6rqMjwbRs7+u10vysecr5dnvOPlOle7Q j1JQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697113160; x=1697717960; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=x9j0wB4sagFap8UlCk3DGG3Emv5eeF0Xy9DDluHlDSM=; b=SPjhFyzHuON6/SlwqpSuo7bEFFYSuhn8Oist28JzLjfshvEq+Z8POhgOWJzimJjyPG R7hCjjvrRnubs3dv5DIPdWpA3jyiyiTK29M1cfi2JxA+S8tqyjX7Jv3Ja9TNONWnFSHJ oYV2S0kfS6HlZvOMxeFyWzQP4Ipwd3fxb1CBNhmMPjYLFZcWiwHU7/8cnTi99mFfKfRd pyXdOEW6JYu4ZjIO+sZxxvCWEyIfy8FWoz3G9hmw+YXNGi9V8kOndmgNMEknh8wxv7c6 wvViizPjMjZSX1gRxL54c6zFEB3FlNrsqn/vydtzh/73cAXUHSc4Ihd4yTjrsP7wuUPB Ey1g== X-Gm-Message-State: AOJu0Yztuuf94OehB+WE9sOpTUEs776xtOs3MUVTqJ3Gfscx3+iO5z5V gRCJoddX6DM7PWy66NWpORl8wIX4pqA3X9xy4vJRug== X-Received: by 2002:a17:906:3288:b0:9a1:fb4c:3b6c with SMTP id 8-20020a170906328800b009a1fb4c3b6cmr21893209ejw.59.1697113160687; Thu, 12 Oct 2023 05:19:20 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-232.abo.bbox.fr. [176.131.211.232]) by smtp.gmail.com with ESMTPSA id f23-20020a170906139700b0098f99048053sm11226132ejc.148.2023.10.12.05.19.18 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Oct 2023 05:19:19 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Andrey Smirnov , qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH 3/8] hw/pci-host/designware: Add 'host_mem' variable for clarity Date: Thu, 12 Oct 2023 14:18:51 +0200 Message-ID: <20231012121857.31873-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012121857.31873-1-philmd@linaro.org> References: <20231012121857.31873-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62c; envelope-from=philmd@linaro.org; helo=mail-ej1-x62c.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org designware_pcie_root_realize() uses get_system_memory() as the "host side memory region", as opposed to the "PCI side" one. Introduce the 'host_mem' variable for clarity. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Peter Maydell Reviewed-by: Gustavo Romero --- hw/pci-host/designware.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c index 692e0731cd..bacb2bdb2d 100644 --- a/hw/pci-host/designware.c +++ b/hw/pci-host/designware.c @@ -393,6 +393,7 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp) { DesignwarePCIERoot *root = DESIGNWARE_PCIE_ROOT(dev); DesignwarePCIEHost *host = designware_pcie_root_to_host(root); + MemoryRegion *host_mem = get_system_memory(); MemoryRegion *address_space = &host->pci.memory; PCIBridge *br = PCI_BRIDGE(dev); DesignwarePCIEViewport *viewport; @@ -433,7 +434,7 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp) viewport->cr[0] = DESIGNWARE_PCIE_ATU_TYPE_MEM; source = &host->pci.address_space_root; - destination = get_system_memory(); + destination = host_mem; direction = "Inbound"; /* @@ -458,7 +459,7 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp) destination = &host->pci.memory; direction = "Outbound"; - source = get_system_memory(); + source = host_mem; /* * Configure MemoryRegion implementing CPU -> PCI memory From patchwork Thu Oct 12 12:18:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 732472 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp917617wrv; Thu, 12 Oct 2023 05:21:59 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFuScAmb8RDO7VZsLFHpTYz3yFVPApVImMAr0YNbwC7M1cvfV+NcW3MeXau5VHgrHQabD8l X-Received: by 2002:a05:6808:18:b0:3a8:ccf0:103f with SMTP id u24-20020a056808001800b003a8ccf0103fmr24513216oic.3.1697113319537; Thu, 12 Oct 2023 05:21:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697113319; cv=none; d=google.com; s=arc-20160816; b=Gip9w9JfaE1dvhFjW5uslkyv2+Kd5oqQwVPxTyX2eWlhm8OhdYvLWymAUWmSl9cbEf D/HYjhygmFSXvqXAUMVlqB/WBIXbamwlMFPOq06VztoLARbFAHKukeiP6sO+zJwJabFz bvrpqal1cZYy3LRXtlBRRmRrONlc+zyZ1LSJVjCXsovKN/4oHkgBWodV39JuNq0N7gR6 TH9P+pMhNldIovJl/yOd+9a9TnWFcVYZrQ0C4cOcTuPWAjK7Qcj87i+TsAchObZWpM3f 8kevJeTbfcjBJyqe7bYF+VTRKPBh9uC/DehauflFy52++u6BLmtsm97YWWvh/fTzdZpH 47+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xa2WXsDwKflmWK2k8quohK6TTrUH1twZfhC/r4NA1UE=; fh=uMYo3jOuXUsDthaXCE4/M6n3+voY5rtHQA7Grzg1cYU=; b=cYOKM+fvUQ90GV28WNkPYWmwjF1ezM6sIzKPVx+H+jU+z7qAQX1RF/07dpuHQrsufb KCtOri1erGwfTQj7/enEhaJCC9KbO8hGu+BMik1XProFOphZ7MSyH3lGRpvYo5f0yhAb AGqhmwh/HlvWCKRFJtEWIKEYwwixayChbtlpT/xqCTtsIaytq8qa+4BrUiXCCvEFjQX+ hSacsE45ZOY6fo1oBZxeQvfkP0J18Dc04fAhq1UaWlUEJ8qCL9bHv8BhCt+VZ7gyqGGi satt5SS9k0mkWwKAfK/Ukli9DXlUPXHxPvyPDk2JZV/LgFx5gJwx/lu4Ys3Yhpj3dyqM xo1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nLvXAOTh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t1-20020a0ce2c1000000b0066d0656ef0esi2405719qvl.615.2023.10.12.05.21.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Oct 2023 05:21:59 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nLvXAOTh; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qquf6-0003Dz-Fd; Thu, 12 Oct 2023 08:19:32 -0400 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 1qquf4-0003Cz-Lj for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:30 -0400 Received: from mail-ed1-x52e.google.com ([2a00:1450:4864:20::52e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qquf2-0001pi-CX for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:30 -0400 Received: by mail-ed1-x52e.google.com with SMTP id 4fb4d7f45d1cf-53db1fbee70so1579933a12.2 for ; Thu, 12 Oct 2023 05:19:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697113166; x=1697717966; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=xa2WXsDwKflmWK2k8quohK6TTrUH1twZfhC/r4NA1UE=; b=nLvXAOThsr3uR2a97tQKtPvjWU5llPjrq1nzOnGCKl7KH7fwtOhSdT94qupGpCjG0y 8c+v1cI7n38tjYOxCocAEHgf/k6EW0aT3oRM4Yn2STewLs9hXQ/lZFe3ioSlx9mW1I4R up6QG8M8zCaqmlyZkMllUtAbR6MG4HWD5m/WBA9ooygZ02Tuh9wAKMpXZGw/etkTByoV 71R5RMsRUWembW/3ou+a//5CntVsJuvcocvtbErCFJuNPrF85ul0C1K/3wG+QKxUDSob ObF7BNgLK5UrJXzIfGrBjplEbekqf/rOx7WsHoE1O5B91no482mHkob/YgGyAGPU9w0n UJqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697113166; x=1697717966; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=xa2WXsDwKflmWK2k8quohK6TTrUH1twZfhC/r4NA1UE=; b=uPyPLwu411Qtb2ySiuQG/eFNQyDLVMLut6oPsfWHGuGaROUX9wduGvTWrWbJ8eKoak tb1m17x28P9Sey8in6JxBRok5RhEqU5hFupovYDRNbp40OtSNkqQzpc/b3m0XqE/sQJ7 SO+Oqsh6v7vACeyZQqJbqrwwGh6qCKpqY//wI+jbrAPts0+WCZaj0hClsrbifsinKoSJ FHXk0goVPPpzAQWe8u3opvXUKAgA8J1m6vVLeku1GTtnMK54na9rUVAUX6XVwxMxoz+d Q1fiL/bwro3ov4H0lMJvl0rhkgXAShsS7RDtXjGJG9xd6a+uYjb0V8+6gpH3WPxXdFOH TJBA== X-Gm-Message-State: AOJu0YxmDaLCUWhVTTDYK11HggoxT82XzA+OnEhGazYSOAgWyhqU6cfe irRlay0F280bd/pBs6mPyzknh/X5vupvkAYLQYOIeA== X-Received: by 2002:a05:6402:1250:b0:533:e314:20dd with SMTP id l16-20020a056402125000b00533e31420ddmr20275891edw.13.1697113166626; Thu, 12 Oct 2023 05:19:26 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-232.abo.bbox.fr. [176.131.211.232]) by smtp.gmail.com with ESMTPSA id a23-20020a50ff17000000b005342fa19070sm10081874edu.89.2023.10.12.05.19.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Oct 2023 05:19:25 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Andrey Smirnov , qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH 4/8] hw/pci-host/designware: Hoist host controller in root function #0 Date: Thu, 12 Oct 2023 14:18:52 +0200 Message-ID: <20231012121857.31873-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012121857.31873-1-philmd@linaro.org> References: <20231012121857.31873-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52e; envelope-from=philmd@linaro.org; helo=mail-ed1-x52e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org There is always an unique root function for the host bridge controller. We create this function when the controller is realized, in designware_pcie_host_realize(). No need to call qdev_get_parent_bus() each time the root function want to resolve its host part. Hoist a pointer in its state. Set the pointer once when the function is realized. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Gustavo Romero --- include/hw/pci-host/designware.h | 1 + hw/pci-host/designware.c | 15 +++++---------- 2 files changed, 6 insertions(+), 10 deletions(-) diff --git a/include/hw/pci-host/designware.h b/include/hw/pci-host/designware.h index c484e377a8..9e2caa04e9 100644 --- a/include/hw/pci-host/designware.h +++ b/include/hw/pci-host/designware.h @@ -71,6 +71,7 @@ struct DesignwarePCIERoot { DesignwarePCIEViewport viewports[2][DESIGNWARE_PCIE_NUM_VIEWPORTS]; DesignwarePCIEMSI msi; + DesignwarePCIEHost *host; }; struct DesignwarePCIEHost { diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c index bacb2bdb2d..fb46493a05 100644 --- a/hw/pci-host/designware.c +++ b/hw/pci-host/designware.c @@ -57,13 +57,6 @@ #define DESIGNWARE_PCIE_IRQ_MSI 3 -static DesignwarePCIEHost * -designware_pcie_root_to_host(DesignwarePCIERoot *root) -{ - BusState *bus = qdev_get_parent_bus(DEVICE(root)); - return DESIGNWARE_PCIE_HOST(bus->parent); -} - static uint64_t designware_pcie_root_msi_read(void *opaque, hwaddr addr, unsigned size) { @@ -85,7 +78,7 @@ static void designware_pcie_root_msi_write(void *opaque, hwaddr addr, uint64_t val, unsigned len) { DesignwarePCIERoot *root = DESIGNWARE_PCIE_ROOT(opaque); - DesignwarePCIEHost *host = designware_pcie_root_to_host(root); + DesignwarePCIEHost *host = root->host; root->msi.intr[0].status |= BIT(val) & root->msi.intr[0].enable; @@ -300,7 +293,7 @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, uint32_t val, int len) { DesignwarePCIERoot *root = DESIGNWARE_PCIE_ROOT(d); - DesignwarePCIEHost *host = designware_pcie_root_to_host(root); + DesignwarePCIEHost *host = root->host; DesignwarePCIEViewport *viewport = designware_pcie_root_get_current_viewport(root); @@ -392,7 +385,8 @@ static char *designware_pcie_viewport_name(const char *direction, static void designware_pcie_root_realize(PCIDevice *dev, Error **errp) { DesignwarePCIERoot *root = DESIGNWARE_PCIE_ROOT(dev); - DesignwarePCIEHost *host = designware_pcie_root_to_host(root); + DesignwarePCIEHost *host = DESIGNWARE_PCIE_HOST( + qdev_get_parent_bus(DEVICE(dev))->parent); MemoryRegion *host_mem = get_system_memory(); MemoryRegion *address_space = &host->pci.memory; PCIBridge *br = PCI_BRIDGE(dev); @@ -406,6 +400,7 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp) size_t i; br->bus_name = "dw-pcie"; + root->host = host; pci_set_word(dev->config + PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); From patchwork Thu Oct 12 12:18:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 732467 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp916572wrv; Thu, 12 Oct 2023 05:19:51 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFqaMsssQzmqunhBpEAW5IRa4L1w9nQdtlCNE7127CUUf70LpeHwRxsM1UxsfRgGUEgzi9C X-Received: by 2002:a25:5143:0:b0:d81:89e9:9f4c with SMTP id f64-20020a255143000000b00d8189e99f4cmr19545371ybb.39.1697113191658; Thu, 12 Oct 2023 05:19:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697113191; cv=none; d=google.com; s=arc-20160816; b=GwuSqcsJFcHotxQNiGAysXrbvoEn/W4URFLILVXesABZcNNvVhLNm50fE/xPwGGdjq m6DAbKEG4Dmlnq71DQ3SfiaZFpQODrcW4u4hxmPyyFEkVIuLVh/64N+lMJ1imgXv2QKn JesOG4mfU3g4HZx+1QaHr584+M39mDeNYyRBEqkS4+8553Ud5PbJczQV5apv8uqZSZ7y hXiC7B+uW7zAQtStVdyatZa6VQ+q707fu3HHiTIoErNPbkVc+0igztfNPu3/nu4EBxe7 bawCfKUhDGkb6kLRysIVg5ilW6/LAJlXKMgN2pGXi19HFdL20HUXNgUGX+jTYbWhdLPm kupQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=R+a0EyKEUxgm0lXUaYS7q8xxVvw9rO8rB+Ai3q4Lewo=; fh=uMYo3jOuXUsDthaXCE4/M6n3+voY5rtHQA7Grzg1cYU=; b=huBZI308GdrNWNHFXp63ZoWHkVTV8ncrZOXjCjw7r1VBovJByK7mJIyHDTFovsX1YM uyulzEU1uVwrvhT2CJXX75mMdA/cxMr638NfUjFuu0qQE9GUgSzc9yXvixYoKfClsdhu H031ZMEizp7N775NncxOmfV8Mlt8nyQ+jc5D8cff+kor2nyBUNAF8iIML1kqQxDrJKI/ 3FTlg7r97oR8Y0J1el6UdpSJ5pAe4a6qUhHEon3P8Kubrys9HnHml9ddEiQEeVOkzTlV D5Frz4577CVyp7p7xsKtB1LKnpMYeao9I3OVqyrckIMy+kSv1XqnAAaQmEs6dx32ffNo hqPg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HRYzUdju; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ot8-20020a05620a818800b0076f39f669desi10887132qkn.51.2023.10.12.05.19.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Oct 2023 05:19:51 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HRYzUdju; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqufC-0003Lj-Ad; Thu, 12 Oct 2023 08:19:38 -0400 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 1qqufA-0003JR-DT for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:36 -0400 Received: from mail-ej1-x62d.google.com ([2a00:1450:4864:20::62d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qquf8-0001qf-PL for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:36 -0400 Received: by mail-ej1-x62d.google.com with SMTP id a640c23a62f3a-9b98a699f45so140132066b.3 for ; Thu, 12 Oct 2023 05:19:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697113173; x=1697717973; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=R+a0EyKEUxgm0lXUaYS7q8xxVvw9rO8rB+Ai3q4Lewo=; b=HRYzUdjuIzzshSApbyr6p80clJeH0G2TR9aLDH244d7GvCcTIH+nk1AKjkmuo7BXXT d/koBRIC3dMcx1KT6P0ECDXYd5S4aL1qcumb82bilXZj/QDhs454npNQKSeG2N/GYm8T aRm3AswaN2pYN2LFzUM2+vYOdYC7Hb1+BQO6oz9FjS9Mjfa3j0tEEIYw69r3FJx/zQwm j+XIUTzKGSEdrpx14brh9WYymhdCPcT6rg37hG4/LWPSvouzX2VfPMfkeyRSbiihJizg Gj6vTP1F3fW8ku7QB4s1aiOuGeyaUOG1F8I1C5sMA1xDvLnb7yklt5eWr5+gDRnLtbrF itGg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697113173; x=1697717973; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=R+a0EyKEUxgm0lXUaYS7q8xxVvw9rO8rB+Ai3q4Lewo=; b=iXaATBjjco0W7Qt9f3SJZgoOBn7eSCDaTUadfY0kFw2yrlC7XcdffZYKZskUbT25GW PZK69UuaLoKsON5xUsxOR+OKZT+F0hbSMtKnef+PuRCfuIC2K2+z5cw/h4dbR8gUw/B+ uTQbRzrMyUZ4cAjmXD0anJYVCfRtMKK3LRGvBCZ1ccnVYWPQEqQ3lf+aIjSB6twR1IbQ HS1wS3Umfe8mEKq5W3aqs72+/DHZ1zeE+oOFJ23vIO9niLp54JBxPkbLir27mTo0131h Utz29T1vR/EkioPuBCbouIVE4fc63Q5vF8F66jZhfLRbWS0tvIXZzIEbfS7FL318oJey ShDQ== X-Gm-Message-State: AOJu0YxvsEtx3j/0btN+/5R26hOt2x3iHTpytljjFbY+MNhxcb7WFq94 yM+oNhaaoMzmVRpGhF1ezR8iVZZAOyWqbs0YPX0qHA== X-Received: by 2002:a17:906:ef90:b0:9ae:673a:88b9 with SMTP id ze16-20020a170906ef9000b009ae673a88b9mr20120482ejb.22.1697113172897; Thu, 12 Oct 2023 05:19:32 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-232.abo.bbox.fr. [176.131.211.232]) by smtp.gmail.com with ESMTPSA id a6-20020a170906190600b009ad89697c86sm11081226eje.144.2023.10.12.05.19.31 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Oct 2023 05:19:32 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Andrey Smirnov , qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH 5/8] hw/pci-host/designware: Keep host reference in DesignwarePCIEViewport Date: Thu, 12 Oct 2023 14:18:53 +0200 Message-ID: <20231012121857.31873-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012121857.31873-1-philmd@linaro.org> References: <20231012121857.31873-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62d; envelope-from=philmd@linaro.org; helo=mail-ej1-x62d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The PCI root function is irrelevant for the ViewPort; only a reference to the host bridge is required. Since we can directly access the PCI bus, remove the pci_get_bus() call. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Gustavo Romero --- include/hw/pci-host/designware.h | 2 +- hw/pci-host/designware.c | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/include/hw/pci-host/designware.h b/include/hw/pci-host/designware.h index 9e2caa04e9..e1952ad324 100644 --- a/include/hw/pci-host/designware.h +++ b/include/hw/pci-host/designware.h @@ -32,7 +32,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(DesignwarePCIEHost, DESIGNWARE_PCIE_HOST) OBJECT_DECLARE_SIMPLE_TYPE(DesignwarePCIERoot, DESIGNWARE_PCIE_ROOT) typedef struct DesignwarePCIEViewport { - DesignwarePCIERoot *root; + DesignwarePCIEHost *host; MemoryRegion cfg; MemoryRegion mem; diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c index fb46493a05..d12a36b628 100644 --- a/hw/pci-host/designware.c +++ b/hw/pci-host/designware.c @@ -211,12 +211,11 @@ static uint64_t designware_pcie_root_data_access(void *opaque, hwaddr addr, uint64_t *val, unsigned len) { DesignwarePCIEViewport *viewport = opaque; - DesignwarePCIERoot *root = viewport->root; + PCIHostState *pci = PCI_HOST_BRIDGE(viewport->host); const uint8_t busnum = DESIGNWARE_PCIE_ATU_BUS(viewport->target); const uint8_t devfn = DESIGNWARE_PCIE_ATU_DEVFN(viewport->target); - PCIBus *pcibus = pci_get_bus(PCI_DEVICE(root)); - PCIDevice *pcidev = pci_find_device(pcibus, busnum, devfn); + PCIDevice *pcidev = pci_find_device(pci->bus, busnum, devfn); if (pcidev) { addr &= pci_config_size(pcidev) - 1; @@ -445,7 +444,7 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp) g_free(name); viewport = &root->viewports[DESIGNWARE_PCIE_VIEWPORT_OUTBOUND][i]; - viewport->root = root; + viewport->host = host; viewport->inbound = false; viewport->base = 0x0000000000000000ULL; viewport->target = 0x0000000000000000ULL; From patchwork Thu Oct 12 12:18:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 732468 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp916614wrv; Thu, 12 Oct 2023 05:19:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFJRF9lYSznlYozwbUunic84xUtCI1wo3MyISPHGSSfK8i0uOfjq6hgKbBEaob75UQkxhYB X-Received: by 2002:a05:620a:f0d:b0:76c:a9a1:a318 with SMTP id v13-20020a05620a0f0d00b0076ca9a1a318mr27933226qkl.6.1697113197528; Thu, 12 Oct 2023 05:19:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697113197; cv=none; d=google.com; s=arc-20160816; b=qFIsAK8u9pPL1oNPc2/UbRXKQJDA8vJI5tXt4uAUS7Yn+2Vj7pmHCg8RkPW8kZqXyE 3fdfuZ/4CzMRKY7QBoXT3xtKm+FNYIcxfLylnhiOVHkepJJWGTOo7jp9FkDZ9MhfkgaL 2XMBxTf00UYtEFhrcefQ083XtVqfkzOlWX6MGSsart+poTic5fFg6GtRafSVe3vba03R OeR0tTdUj8qJyqwpRs1K3/sTZbm+5nk/Sk+bIbDijHQaaWYkb80z/A8ZyB1iVOS5/M2Y 6aJ2KfP2n8aYNeXxSIGh/X5mrIAFfM7a3h+aPJ5ENyO//WlyxI4+JewGGUsQp8zrsRjy qNUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=4YRr81WGc0jZpkwI738+aZ2Qnn+FlQH2u0zMxI+6iKE=; fh=uMYo3jOuXUsDthaXCE4/M6n3+voY5rtHQA7Grzg1cYU=; b=M/Ol27D/zFkpCzlFFzVeVGn9aWxXAvkfxttNlsfgFM09HHRns8rVDzMw7lf2SzENzJ PlDRobM3cKf57FReEfPZ8C0rkdeSFBc1M6ZSKZ97NtlIlPhGVL5rTwaHV7+0VsauRQ0H ceFZvg/8dpIEeHRSP6GeH3xmyZMPYug5OmbbyDoOFEqqJEA0Tmw72AOTLzX3gkKWzfVJ /jKdbL4TRjIzFLUi1TsD6T0XunBAODpKebP1N2sKRV8cSF+AgTsyse3ojPCCveXF2om/ 7DwY0QCYkvXWbTm23XQnzsj0o8PF/rdhlgk5BGW+9Ac2Qzmy1xM2XqxBm2WauAQiqQcb 7PdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NlTVkg3M; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id az43-20020a05620a172b00b00774830a1570si11024752qkb.225.2023.10.12.05.19.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Oct 2023 05:19:57 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NlTVkg3M; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqufJ-0003NA-Mp; Thu, 12 Oct 2023 08:19:45 -0400 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 1qqufG-0003Mh-On for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:43 -0400 Received: from mail-ej1-x633.google.com ([2a00:1450:4864:20::633]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qqufE-0001rS-Si for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:42 -0400 Received: by mail-ej1-x633.google.com with SMTP id a640c23a62f3a-9adb9fa7200so182405066b.0 for ; Thu, 12 Oct 2023 05:19:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697113179; x=1697717979; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4YRr81WGc0jZpkwI738+aZ2Qnn+FlQH2u0zMxI+6iKE=; b=NlTVkg3M3GloTpmwFOjkDsXaLybBvajTFNjwiZD4DONPGoXn2JkqeZgpYFmYe3UtZH t7YQOEBpcRIW4Iy3rtUl8PVIRLq3eJhlAHgqlNS2J8DG2X5OYcpwMs+/cEtMv+oR6c9u PvGcKgDgyEtCVezQTiXMsDDayK5yY8AFLDLGIraSb8E7aSVXFUy+uKQHQ+8sC+xcbeEq nZrSL1aUWka8zzawWkPFYdz949i5JlZ7VL3FAk/5d57ZKHNgh+M8PighQ1XN4jLVRT1F ueyuuJvdQFiClobFeqy1cQUcmdCNMGktC/X9kfHrLimwa1WRRrnL4uDahKRIk8pi3DaZ bAGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697113179; x=1697717979; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4YRr81WGc0jZpkwI738+aZ2Qnn+FlQH2u0zMxI+6iKE=; b=kav/yydstTuZH+01UQ/LKirJyBjPejxw7IlWnWnkcx4ogNyoLym10zfDVmPcZ/EEvA zVwLOs/LXOtuS2+BKbYj7RvsfFYzjOQmqJXbuRSAsrsBIX6dZz5N6ozp9A5uINk6/wt1 V3KrBl6o4raOl4oife0xu7SyxnfrvhC8Wm2xJ0ru6bVo1fh310aMhcpC9W8Qm/HgrOjI lpMGEZzrOaF2aQffzGJfUy1JM+x7GJlYnZCqXTnpQ5ldodOEWEubVT9O6u2ZT+8F90DK xymTvp+wseBSdtLsvJlr1gYQtL3ZoxF+ONbcK2IW19QhEn+iDbJAheATCz6NGTmKnXAS hurg== X-Gm-Message-State: AOJu0YzMByEmqQSpHJxv2P1lJovzv7kOxQlbdMJBJ6WMy2P8T5csIq8P VM1FtGnqycfvIytqQNgsPLDIIWwC/AMs93YS1J4WRw== X-Received: by 2002:a17:907:7b84:b0:9a5:dc2b:6a5 with SMTP id ne4-20020a1709077b8400b009a5dc2b06a5mr15849000ejc.35.1697113179303; Thu, 12 Oct 2023 05:19:39 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-232.abo.bbox.fr. [176.131.211.232]) by smtp.gmail.com with ESMTPSA id gh18-20020a170906e09200b009786c8249d6sm11146880ejb.175.2023.10.12.05.19.37 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Oct 2023 05:19:38 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Andrey Smirnov , qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH 6/8] hw/pci-host/designware: Move viewports from root func to host bridge Date: Thu, 12 Oct 2023 14:18:54 +0200 Message-ID: <20231012121857.31873-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012121857.31873-1-philmd@linaro.org> References: <20231012121857.31873-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::633; envelope-from=philmd@linaro.org; helo=mail-ej1-x633.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org As mentioned in previous commit, the PCI root function is irrelevant for the ViewPorts. Move the fields to the host bridge state. This is a migration compatibility break for the machines using the i.MX7 SoC (currently the mcimx7d-sabre machine). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Gustavo Romero --- include/hw/pci-host/designware.h | 13 ++++----- hw/pci-host/designware.c | 47 ++++++++++++++++---------------- 2 files changed, 30 insertions(+), 30 deletions(-) diff --git a/include/hw/pci-host/designware.h b/include/hw/pci-host/designware.h index e1952ad324..702777ab17 100644 --- a/include/hw/pci-host/designware.h +++ b/include/hw/pci-host/designware.h @@ -63,13 +63,6 @@ typedef struct DesignwarePCIEMSI { struct DesignwarePCIERoot { PCIBridge parent_obj; - uint32_t atu_viewport; - -#define DESIGNWARE_PCIE_VIEWPORT_OUTBOUND 0 -#define DESIGNWARE_PCIE_VIEWPORT_INBOUND 1 -#define DESIGNWARE_PCIE_NUM_VIEWPORTS 4 - - DesignwarePCIEViewport viewports[2][DESIGNWARE_PCIE_NUM_VIEWPORTS]; DesignwarePCIEMSI msi; DesignwarePCIEHost *host; }; @@ -79,6 +72,12 @@ struct DesignwarePCIEHost { DesignwarePCIERoot root; + uint32_t atu_viewport; +#define DESIGNWARE_PCIE_VIEWPORT_OUTBOUND 0 +#define DESIGNWARE_PCIE_VIEWPORT_INBOUND 1 +#define DESIGNWARE_PCIE_NUM_VIEWPORTS 4 + DesignwarePCIEViewport viewports[2][DESIGNWARE_PCIE_NUM_VIEWPORTS]; + struct { AddressSpace address_space; MemoryRegion address_space_root; diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c index d12a36b628..2ef17137e2 100644 --- a/hw/pci-host/designware.c +++ b/hw/pci-host/designware.c @@ -109,20 +109,21 @@ static void designware_pcie_root_update_msi_mapping(DesignwarePCIERoot *root) } static DesignwarePCIEViewport * -designware_pcie_root_get_current_viewport(DesignwarePCIERoot *root) +designware_pcie_host_get_current_viewport(DesignwarePCIEHost *host) { - const unsigned int idx = root->atu_viewport & 0xF; + const unsigned int idx = host->atu_viewport & 0xF; const unsigned int dir = - !!(root->atu_viewport & DESIGNWARE_PCIE_ATU_REGION_INBOUND); - return &root->viewports[dir][idx]; + !!(host->atu_viewport & DESIGNWARE_PCIE_ATU_REGION_INBOUND); + return &host->viewports[dir][idx]; } static uint32_t designware_pcie_root_config_read(PCIDevice *d, uint32_t address, int len) { DesignwarePCIERoot *root = DESIGNWARE_PCIE_ROOT(d); + DesignwarePCIEHost *host = root->host; DesignwarePCIEViewport *viewport = - designware_pcie_root_get_current_viewport(root); + designware_pcie_host_get_current_viewport(host); uint32_t val; @@ -170,7 +171,7 @@ designware_pcie_root_config_read(PCIDevice *d, uint32_t address, int len) break; case DESIGNWARE_PCIE_ATU_VIEWPORT: - val = root->atu_viewport; + val = host->atu_viewport; break; case DESIGNWARE_PCIE_ATU_LOWER_BASE: @@ -294,7 +295,7 @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, DesignwarePCIERoot *root = DESIGNWARE_PCIE_ROOT(d); DesignwarePCIEHost *host = root->host; DesignwarePCIEViewport *viewport = - designware_pcie_root_get_current_viewport(root); + designware_pcie_host_get_current_viewport(host); switch (address) { case DESIGNWARE_PCIE_PORT_LINK_CONTROL: @@ -332,7 +333,7 @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, break; case DESIGNWARE_PCIE_ATU_VIEWPORT: - root->atu_viewport = val; + host->atu_viewport = val; break; case DESIGNWARE_PCIE_ATU_LOWER_BASE: @@ -420,7 +421,7 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp) const char *direction; char *name; - viewport = &root->viewports[DESIGNWARE_PCIE_VIEWPORT_INBOUND][i]; + viewport = &host->viewports[DESIGNWARE_PCIE_VIEWPORT_INBOUND][i]; viewport->inbound = true; viewport->base = 0x0000000000000000ULL; viewport->target = 0x0000000000000000ULL; @@ -443,7 +444,7 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp) memory_region_set_enabled(mem, false); g_free(name); - viewport = &root->viewports[DESIGNWARE_PCIE_VIEWPORT_OUTBOUND][i]; + viewport = &host->viewports[DESIGNWARE_PCIE_VIEWPORT_OUTBOUND][i]; viewport->host = host; viewport->inbound = false; viewport->base = 0x0000000000000000ULL; @@ -490,7 +491,7 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp) * NOTE: This will not work correctly for the case when first * configured inbound window is window 0 */ - viewport = &root->viewports[DESIGNWARE_PCIE_VIEWPORT_INBOUND][0]; + viewport = &host->viewports[DESIGNWARE_PCIE_VIEWPORT_INBOUND][0]; viewport->cr[1] = DESIGNWARE_PCIE_ATU_ENABLE; designware_pcie_update_viewport(root, viewport); @@ -563,18 +564,10 @@ static const VMStateDescription vmstate_designware_pcie_viewport = { static const VMStateDescription vmstate_designware_pcie_root = { .name = "designware-pcie-root", - .version_id = 1, - .minimum_version_id = 1, + .version_id = 2, + .minimum_version_id = 2, .fields = (VMStateField[]) { VMSTATE_PCI_DEVICE(parent_obj, PCIBridge), - VMSTATE_UINT32(atu_viewport, DesignwarePCIERoot), - VMSTATE_STRUCT_2DARRAY(viewports, - DesignwarePCIERoot, - 2, - DESIGNWARE_PCIE_NUM_VIEWPORTS, - 1, - vmstate_designware_pcie_viewport, - DesignwarePCIEViewport), VMSTATE_STRUCT(msi, DesignwarePCIERoot, 1, @@ -711,14 +704,22 @@ static void designware_pcie_host_realize(DeviceState *dev, Error **errp) static const VMStateDescription vmstate_designware_pcie_host = { .name = "designware-pcie-host", - .version_id = 1, - .minimum_version_id = 1, + .version_id = 2, + .minimum_version_id = 2, .fields = (VMStateField[]) { VMSTATE_STRUCT(root, DesignwarePCIEHost, 1, vmstate_designware_pcie_root, DesignwarePCIERoot), + VMSTATE_UINT32(atu_viewport, DesignwarePCIEHost), + VMSTATE_STRUCT_2DARRAY(viewports, + DesignwarePCIEHost, + 2, + DESIGNWARE_PCIE_NUM_VIEWPORTS, + 1, + vmstate_designware_pcie_viewport, + DesignwarePCIEViewport), VMSTATE_END_OF_LIST() } }; From patchwork Thu Oct 12 12:18:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 732473 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp917688wrv; Thu, 12 Oct 2023 05:22:09 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFjn0XgbvrJAdGgMSn+GRTuONQHO3Aj1TqWUyVnLR4/L6Tjua+7ebEElxhN768PKUEvhjt9 X-Received: by 2002:a05:6808:1441:b0:3af:583d:3c5d with SMTP id x1-20020a056808144100b003af583d3c5dmr31084855oiv.52.1697113329626; Thu, 12 Oct 2023 05:22:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697113329; cv=none; d=google.com; s=arc-20160816; b=LGytyFPb4DTN+4mudETFSD5VUOxzjprKnXJyWxeTdZEFMHaTgIKYoFLWQqdp1KrxPd d5kou3jWYAOhWGjEVt17rtQxNLQSQhjhBzpv2OUHD1XhYR8HNvpC3cT3Rz7syjgo7osi KId0/Wou4vQt5XRmF93a9LMaMbVrFS73Fq4Xx1kGV77Sh3hj+RSYNlFrY5EH7i2DcoIk UaS9FcAYrv/h70uj8JCmVZH06PFSZrsEVA3PM32Td+HIol1HDz394HZhqjDYQdcxK2ea z72i4vsgw5DTbzpkVU/M5wKSuRwuoWBKGuf8VV8jrG/ZoIr4BSXgLdwzKVa/sK6+ckU0 mZkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=lkSYPpqF0kOrJ1x/hHvfUb0VtYPx+2ipYoi3NSqd0/Q=; fh=uMYo3jOuXUsDthaXCE4/M6n3+voY5rtHQA7Grzg1cYU=; b=C0ZVInDbhnOXwxmSkp1MzGQfEeAr9C5+Pwexfclh3dgjTEK60j27C6zecWXlbaju/p Xl83N5wkTLv8iy588PMz38DXJVuk02gQi+ypAizff34WTOiUwPWTAjXn2J9eSJt9fu3Z FH/VLsZbcPXSr6lQ9McSEVKzKIHGYmRQLYwFUl7vGfiIRkBEk7kNwWN4SjaCs8KsYnoE qSGaCQxpdWWjWayoFiRwEa9Wc9mp2rGdn6D/cg+JwFXHAmSc1t/8mzqVKDi5Eo52S5vO s24DJz71Q27m6PIlQ+mEMgXdJcGEsnhN2do2LaLqHUVNVacBMpY8jIAzgMkvhaA79fdl Qpvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WnlVtpOE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d10-20020a0caa0a000000b0065d067f07d6si10795136qvb.318.2023.10.12.05.22.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Oct 2023 05:22:09 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=WnlVtpOE; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqufY-0003oc-22; Thu, 12 Oct 2023 08:20:00 -0400 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 1qqufQ-0003ZF-VU for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:54 -0400 Received: from mail-ej1-x629.google.com ([2a00:1450:4864:20::629]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qqufL-0001tp-Jk for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:52 -0400 Received: by mail-ej1-x629.google.com with SMTP id a640c23a62f3a-99c1c66876aso145620066b.2 for ; Thu, 12 Oct 2023 05:19:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697113185; x=1697717985; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=lkSYPpqF0kOrJ1x/hHvfUb0VtYPx+2ipYoi3NSqd0/Q=; b=WnlVtpOEWs64M4VcMT1MHLkXWDsv9vh2rNlJiiV31gy5Dtax7CbnxpI6kzzlL7yTFO gMTtUk3xLewJxWFUpfE8pX+ubIqf9Fd4fA+85zlOYprOhkmNrp3yhvas1TqqekE1QS+D h8cTeH/FMPSjb8cgwIRNgAzzUytKxln7SZ0HuakzSO+EOE12wIpufh2tvPl+Gp8YMuwY HNnOi3dfhPd/BWVd3G8pkWU4Y2njFwlPcF+KPgQB82E+Fv1WA8GKpL8oBtQ8ZMdssBix I7AoV/R0AQ2/c+DbacToGIozTU96Z/gyQo0BwD8l1wXxcLXcbI/TpmRkcMhCRDph8m4i zhCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697113185; x=1697717985; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lkSYPpqF0kOrJ1x/hHvfUb0VtYPx+2ipYoi3NSqd0/Q=; b=P/Qmd7Dt1YZ4Av9XjhZrH7JhBG1ezldQyRL63R6lW+56XH/gWH5WAix/ACvbZcAxs1 zBQgtFRcwREAgkKt50LK/KrFUt6ftla5Z+HHrI50LH7tmpqzCVR32zr0i+5tRkE6sZkd Shix2MtnB3se+6UXEgDpEdxAIoaJdutGDtS4dgkoGBdlc73U2s/sIII1bZXkIQniF5L1 j2I5/4V8751YwlY/LT+2TGlLBwsOGpCWUvx8qXgIe7P9BKn5IPE4hO3RNhsEMCksmRR2 SIn+HJumw7KUm0PFpuFnDorv/WHYT656ulMVCv3fJYRyXudyDBg9eDuhQ+4mdGxWrFcR wB0g== X-Gm-Message-State: AOJu0YxOtCVkbKwh+zAfxzBSLR+7GnToLmz/Hgq5/890NT86DW49tndo pyQAguOHbnSjmr+qoJ9qHGNd39zlyQBpx+BOrMoFcA== X-Received: by 2002:a17:906:10ce:b0:9a1:e233:e627 with SMTP id v14-20020a17090610ce00b009a1e233e627mr23525326ejv.42.1697113185506; Thu, 12 Oct 2023 05:19:45 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-232.abo.bbox.fr. [176.131.211.232]) by smtp.gmail.com with ESMTPSA id a6-20020a170906190600b009ad89697c86sm11081434eje.144.2023.10.12.05.19.43 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Oct 2023 05:19:44 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Andrey Smirnov , qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH 7/8] hw/pci-host/designware: Move MSI registers from root func to host bridge Date: Thu, 12 Oct 2023 14:18:55 +0200 Message-ID: <20231012121857.31873-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012121857.31873-1-philmd@linaro.org> References: <20231012121857.31873-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::629; envelope-from=philmd@linaro.org; helo=mail-ej1-x629.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org The MSI registers belong the the host bridge. Move the DesignwarePCIEMSI field to the host bridge state. This is a migration compatibility break for the machines using the i.MX7 SoC (currently the mcimx7d-sabre machine). Signed-off-by: Philippe Mathieu-Daudé --- include/hw/pci-host/designware.h | 2 +- hw/pci-host/designware.c | 79 ++++++++++++++++---------------- 2 files changed, 40 insertions(+), 41 deletions(-) diff --git a/include/hw/pci-host/designware.h b/include/hw/pci-host/designware.h index 702777ab17..fe8e8a9f24 100644 --- a/include/hw/pci-host/designware.h +++ b/include/hw/pci-host/designware.h @@ -63,7 +63,6 @@ typedef struct DesignwarePCIEMSI { struct DesignwarePCIERoot { PCIBridge parent_obj; - DesignwarePCIEMSI msi; DesignwarePCIEHost *host; }; @@ -71,6 +70,7 @@ struct DesignwarePCIEHost { PCIHostState parent_obj; DesignwarePCIERoot root; + DesignwarePCIEMSI msi; uint32_t atu_viewport; #define DESIGNWARE_PCIE_VIEWPORT_OUTBOUND 0 diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c index 2ef17137e2..6cb8655a75 100644 --- a/hw/pci-host/designware.c +++ b/hw/pci-host/designware.c @@ -57,7 +57,7 @@ #define DESIGNWARE_PCIE_IRQ_MSI 3 -static uint64_t designware_pcie_root_msi_read(void *opaque, hwaddr addr, +static uint64_t designware_pcie_host_msi_read(void *opaque, hwaddr addr, unsigned size) { /* @@ -74,22 +74,21 @@ static uint64_t designware_pcie_root_msi_read(void *opaque, hwaddr addr, return 0; } -static void designware_pcie_root_msi_write(void *opaque, hwaddr addr, +static void designware_pcie_host_msi_write(void *opaque, hwaddr addr, uint64_t val, unsigned len) { - DesignwarePCIERoot *root = DESIGNWARE_PCIE_ROOT(opaque); - DesignwarePCIEHost *host = root->host; + DesignwarePCIEHost *host = opaque; - root->msi.intr[0].status |= BIT(val) & root->msi.intr[0].enable; + host->msi.intr[0].status |= BIT(val) & host->msi.intr[0].enable; - if (root->msi.intr[0].status & ~root->msi.intr[0].mask) { + if (host->msi.intr[0].status & ~host->msi.intr[0].mask) { qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 1); } } static const MemoryRegionOps designware_pci_host_msi_ops = { - .read = designware_pcie_root_msi_read, - .write = designware_pcie_root_msi_write, + .read = designware_pcie_host_msi_read, + .write = designware_pcie_host_msi_write, .endianness = DEVICE_LITTLE_ENDIAN, .valid = { .min_access_size = 4, @@ -97,12 +96,12 @@ static const MemoryRegionOps designware_pci_host_msi_ops = { }, }; -static void designware_pcie_root_update_msi_mapping(DesignwarePCIERoot *root) +static void designware_pcie_host_update_msi_mapping(DesignwarePCIEHost *host) { - MemoryRegion *mem = &root->msi.iomem; - const uint64_t base = root->msi.base; - const bool enable = root->msi.intr[0].enable; + MemoryRegion *mem = &host->msi.iomem; + const uint64_t base = host->msi.base; + const bool enable = host->msi.intr[0].enable; memory_region_set_address(mem, base); memory_region_set_enabled(mem, enable); @@ -147,23 +146,23 @@ designware_pcie_root_config_read(PCIDevice *d, uint32_t address, int len) break; case DESIGNWARE_PCIE_MSI_ADDR_LO: - val = root->msi.base; + val = host->msi.base; break; case DESIGNWARE_PCIE_MSI_ADDR_HI: - val = root->msi.base >> 32; + val = host->msi.base >> 32; break; case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: - val = root->msi.intr[0].enable; + val = host->msi.intr[0].enable; break; case DESIGNWARE_PCIE_MSI_INTR0_MASK: - val = root->msi.intr[0].mask; + val = host->msi.intr[0].mask; break; case DESIGNWARE_PCIE_MSI_INTR0_STATUS: - val = root->msi.intr[0].status; + val = host->msi.intr[0].status; break; case DESIGNWARE_PCIE_PHY_DEBUG_R1: @@ -305,29 +304,29 @@ static void designware_pcie_root_config_write(PCIDevice *d, uint32_t address, break; case DESIGNWARE_PCIE_MSI_ADDR_LO: - root->msi.base &= 0xFFFFFFFF00000000ULL; - root->msi.base |= val; - designware_pcie_root_update_msi_mapping(root); + host->msi.base &= 0xFFFFFFFF00000000ULL; + host->msi.base |= val; + designware_pcie_host_update_msi_mapping(host); break; case DESIGNWARE_PCIE_MSI_ADDR_HI: - root->msi.base &= 0x00000000FFFFFFFFULL; - root->msi.base |= (uint64_t)val << 32; - designware_pcie_root_update_msi_mapping(root); + host->msi.base &= 0x00000000FFFFFFFFULL; + host->msi.base |= (uint64_t)val << 32; + designware_pcie_host_update_msi_mapping(host); break; case DESIGNWARE_PCIE_MSI_INTR0_ENABLE: - root->msi.intr[0].enable = val; - designware_pcie_root_update_msi_mapping(root); + host->msi.intr[0].enable = val; + designware_pcie_host_update_msi_mapping(host); break; case DESIGNWARE_PCIE_MSI_INTR0_MASK: - root->msi.intr[0].mask = val; + host->msi.intr[0].mask = val; break; case DESIGNWARE_PCIE_MSI_INTR0_STATUS: - root->msi.intr[0].status ^= val; - if (!root->msi.intr[0].status) { + host->msi.intr[0].status ^= val; + if (!host->msi.intr[0].status) { qemu_set_irq(host->pci.irqs[DESIGNWARE_PCIE_IRQ_MSI], 0); } break; @@ -495,7 +494,7 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp) viewport->cr[1] = DESIGNWARE_PCIE_ATU_ENABLE; designware_pcie_update_viewport(root, viewport); - memory_region_init_io(&root->msi.iomem, OBJECT(root), + memory_region_init_io(&host->msi.iomem, OBJECT(root), &designware_pci_host_msi_ops, root, "pcie-msi", 0x4); /* @@ -504,8 +503,8 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp) * in designware_pcie_root_update_msi_mapping() as a part of * initialization done by guest OS */ - memory_region_add_subregion(address_space, dummy_offset, &root->msi.iomem); - memory_region_set_enabled(&root->msi.iomem, false); + memory_region_add_subregion(address_space, dummy_offset, &host->msi.iomem); + memory_region_set_enabled(&host->msi.iomem, false); } static void designware_pcie_set_irq(void *opaque, int irq_num, int level) @@ -564,15 +563,10 @@ static const VMStateDescription vmstate_designware_pcie_viewport = { static const VMStateDescription vmstate_designware_pcie_root = { .name = "designware-pcie-root", - .version_id = 2, - .minimum_version_id = 2, + .version_id = 3, + .minimum_version_id = 3, .fields = (VMStateField[]) { VMSTATE_PCI_DEVICE(parent_obj, PCIBridge), - VMSTATE_STRUCT(msi, - DesignwarePCIERoot, - 1, - vmstate_designware_pcie_msi, - DesignwarePCIEMSI), VMSTATE_END_OF_LIST() } }; @@ -704,8 +698,8 @@ static void designware_pcie_host_realize(DeviceState *dev, Error **errp) static const VMStateDescription vmstate_designware_pcie_host = { .name = "designware-pcie-host", - .version_id = 2, - .minimum_version_id = 2, + .version_id = 3, + .minimum_version_id = 3, .fields = (VMStateField[]) { VMSTATE_STRUCT(root, DesignwarePCIEHost, @@ -720,6 +714,11 @@ static const VMStateDescription vmstate_designware_pcie_host = { 1, vmstate_designware_pcie_viewport, DesignwarePCIEViewport), + VMSTATE_STRUCT(msi, + DesignwarePCIEHost, + 1, + vmstate_designware_pcie_msi, + DesignwarePCIEMSI), VMSTATE_END_OF_LIST() } }; From patchwork Thu Oct 12 12:18:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 732470 Delivered-To: patch@linaro.org Received: by 2002:a5d:54d1:0:b0:31d:da82:a3b4 with SMTP id x17csp916917wrv; Thu, 12 Oct 2023 05:20:34 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHwFCg0WcNSG/muyGTYZJU0XPTR9rp7CqYoP59u72dJcEdDYTsuJe/OAtjnA7HUkNI9DADZ X-Received: by 2002:a05:620a:1a0d:b0:773:ca55:e836 with SMTP id bk13-20020a05620a1a0d00b00773ca55e836mr27392599qkb.8.1697113233976; Thu, 12 Oct 2023 05:20:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697113233; cv=none; d=google.com; s=arc-20160816; b=blGhpSP58xl9Hhv1hxNScoxD1hD3RfqeMYMYaGjEqAR0rlt6IsPRgDneWaDWnDHrVP j/3Esuyf9EQV5dF/dXqMubOdGT1UUoc1xNCOpahhkqSMmW8hK1qsJmNDyqFdntJFeBcx 9zpVZY6GAmLP+GJ78uRzJO5ew3oHwPYs674bvthrIkmjYOwEi9Q3e0WM+vQFcEqZAh4U YFLecKPeJaOPOJg2ZX86/Pg20ufpxIc0BjR/9Pn+2pmUJmLa/fpx++/gb+QO6mUfAMC1 7TbwRKQXPdaR+VWE8k3W1Aq/LCA9loejXelpjU+jOrAEbpjvO6bkVF5SfHxLAsnIPj4W S1Dg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=vwJ45+LzAe2ikUIZ7U1vT0BShidVUnLgV99Ux1OJYV8=; fh=uMYo3jOuXUsDthaXCE4/M6n3+voY5rtHQA7Grzg1cYU=; b=gOMqrFTObihR7cG3Kz1slekWz0mxUwW55ReEVQ6gu+0k57rzZwG2O3ezq+sBdB/+R9 jcl7tnVZ+Nu47z9IkwwPJvzeE9mOZ6c8VQKzX3g/DjPfw1eQx/VW8m5YrpK+Vig30pD6 dSuCESyhhxMcw1CZJfVsES7h/4zGbrPtHFptyRev732Hx51Ldn3/5nUIcq4Yy7XibIyX WZAACFJbny0NxofsqoClNmDKIaf59W4fFYzwjxfJrq6GyQJFS+GFPPKt/DwhA0MvaVTG ce0Rl2YQF3yRDX51uly4/MvH/MoyNLcfFL/Q1Y34gHdXSp8WUVk/gIKoDHXXO5DHaqlS T4eA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="T/GtfZCe"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s4-20020a05620a030400b007758878b8edsi10308999qkm.557.2023.10.12.05.20.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 12 Oct 2023 05:20:33 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="T/GtfZCe"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qqufW-0003nB-St; Thu, 12 Oct 2023 08:19:58 -0400 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 1qqufU-0003af-6R for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:57 -0400 Received: from mail-ed1-x531.google.com ([2a00:1450:4864:20::531]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qqufS-0001uJ-42 for qemu-devel@nongnu.org; Thu, 12 Oct 2023 08:19:55 -0400 Received: by mail-ed1-x531.google.com with SMTP id 4fb4d7f45d1cf-53e08b60febso1093460a12.1 for ; Thu, 12 Oct 2023 05:19:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697113191; x=1697717991; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=vwJ45+LzAe2ikUIZ7U1vT0BShidVUnLgV99Ux1OJYV8=; b=T/GtfZCe4cU2YZc80xbTcw1Fy8+WmbCOBpkvBdwjGz9ikp08ThDn8peZCEfY10tJGj uSbE11v8fPnIvMbMKBHMNUc9BH1fQscgoGvgMZTadULxKsKMyUBcJjtRTW7v3Pan55S/ m4whQzEsPMBvkPAeiXrTDiUvezycDvx6ejCIuqgJIgww+SV5IFW5BggjcJTQzpkY6MIm FwrpEZhut3paaMsAjHd4b/uZ06VWd9bErUQgsxzI0/3kHB+6VnOj39UDeYOOQIs6lPOV MIYdeA90rOz6znLpKLmI3BQYgL376i1WAL8DH2JAat5O/hDSr2H6/ccXs2akhTBG8FLc 4o5A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697113191; x=1697717991; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=vwJ45+LzAe2ikUIZ7U1vT0BShidVUnLgV99Ux1OJYV8=; b=Yh++Tshh3vO35iHbLWLWC00W9Fuhm0NnI9fGP9uLSIO3KE35E2IXr0OlGGqag3XouC 4mY4LFAdtkh8cumFlsNTZlbuAPP9u6pV3xKd2wH/yF+A99L3TQ01rbcVLBAewujEiqDg 0VSQJIrG2xZz2InSsqcTlyuPylzqv1dmAmSlBDxtvZFVKr7XYZFwsrQScf8PHf/Vpcdk 1M/1sV6exfHzhlhiOxNGTySQQOXdpotNsAL0wg982wGFRVd/HBHPW9DqBUm7cUSP1MgX 2cttmtgI3EfA+5fBPhcnp7BakyeVz17ts0bjzJrYxGK7fVcLvhB6TD9MskN0ZJbcnihG tIvQ== X-Gm-Message-State: AOJu0YwZqOQPBfV2kSL9MJBFk4tJvL1uS2WSE0rSxyNty5LXcPM0BNDR lFvgh6hXZSDhKWtM0kj2Ep5k0EUyxm3f7Vn1fhcUhQ== X-Received: by 2002:a05:6402:699:b0:522:3a89:a7bc with SMTP id f25-20020a056402069900b005223a89a7bcmr17242908edy.42.1697113191434; Thu, 12 Oct 2023 05:19:51 -0700 (PDT) Received: from m1x-phil.lan (176-131-211-232.abo.bbox.fr. [176.131.211.232]) by smtp.gmail.com with ESMTPSA id c25-20020aa7d619000000b0053622a35665sm9929836edr.66.2023.10.12.05.19.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 12 Oct 2023 05:19:50 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Andrey Smirnov , qemu-arm@nongnu.org, Peter Maydell , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= Subject: [PATCH 8/8] hw/pci-host/designware: Create ViewPorts during host bridge realization Date: Thu, 12 Oct 2023 14:18:56 +0200 Message-ID: <20231012121857.31873-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231012121857.31873-1-philmd@linaro.org> References: <20231012121857.31873-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::531; envelope-from=philmd@linaro.org; helo=mail-ed1-x531.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 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_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org ViewPorts are managed by the host bridge part, so create them when the host bridge is realized. The host bridge become the owner of the memory regions. The PCI root function realize() method now only contains PCI specific code. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Gustavo Romero --- hw/pci-host/designware.c | 207 +++++++++++++++++++-------------------- 1 file changed, 102 insertions(+), 105 deletions(-) diff --git a/hw/pci-host/designware.c b/hw/pci-host/designware.c index 6cb8655a75..e5dc9b4b8d 100644 --- a/hw/pci-host/designware.c +++ b/hw/pci-host/designware.c @@ -384,22 +384,10 @@ static char *designware_pcie_viewport_name(const char *direction, static void designware_pcie_root_realize(PCIDevice *dev, Error **errp) { DesignwarePCIERoot *root = DESIGNWARE_PCIE_ROOT(dev); - DesignwarePCIEHost *host = DESIGNWARE_PCIE_HOST( - qdev_get_parent_bus(DEVICE(dev))->parent); - MemoryRegion *host_mem = get_system_memory(); - MemoryRegion *address_space = &host->pci.memory; PCIBridge *br = PCI_BRIDGE(dev); - DesignwarePCIEViewport *viewport; - /* - * Dummy values used for initial configuration of MemoryRegions - * that belong to a given viewport - */ - const hwaddr dummy_offset = 0; - const uint64_t dummy_size = 4; - size_t i; br->bus_name = "dw-pcie"; - root->host = host; + root->host = DESIGNWARE_PCIE_HOST(qdev_get_parent_bus(DEVICE(dev))->parent); pci_set_word(dev->config + PCI_COMMAND, PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER); @@ -414,97 +402,6 @@ static void designware_pcie_root_realize(PCIDevice *dev, Error **errp) msi_nonbroken = true; msi_init(dev, 0x50, 32, true, true, &error_fatal); - - for (i = 0; i < DESIGNWARE_PCIE_NUM_VIEWPORTS; i++) { - MemoryRegion *source, *destination, *mem; - const char *direction; - char *name; - - viewport = &host->viewports[DESIGNWARE_PCIE_VIEWPORT_INBOUND][i]; - viewport->inbound = true; - viewport->base = 0x0000000000000000ULL; - viewport->target = 0x0000000000000000ULL; - viewport->limit = UINT32_MAX; - viewport->cr[0] = DESIGNWARE_PCIE_ATU_TYPE_MEM; - - source = &host->pci.address_space_root; - destination = host_mem; - direction = "Inbound"; - - /* - * Configure MemoryRegion implementing PCI -> CPU memory - * access - */ - mem = &viewport->mem; - name = designware_pcie_viewport_name(direction, i, "MEM"); - memory_region_init_alias(mem, OBJECT(root), name, destination, - dummy_offset, dummy_size); - memory_region_add_subregion_overlap(source, dummy_offset, mem, -1); - memory_region_set_enabled(mem, false); - g_free(name); - - viewport = &host->viewports[DESIGNWARE_PCIE_VIEWPORT_OUTBOUND][i]; - viewport->host = host; - viewport->inbound = false; - viewport->base = 0x0000000000000000ULL; - viewport->target = 0x0000000000000000ULL; - viewport->limit = UINT32_MAX; - viewport->cr[0] = DESIGNWARE_PCIE_ATU_TYPE_MEM; - - destination = &host->pci.memory; - direction = "Outbound"; - source = host_mem; - - /* - * Configure MemoryRegion implementing CPU -> PCI memory - * access - */ - mem = &viewport->mem; - name = designware_pcie_viewport_name(direction, i, "MEM"); - memory_region_init_alias(mem, OBJECT(root), name, destination, - dummy_offset, dummy_size); - memory_region_add_subregion(source, dummy_offset, mem); - memory_region_set_enabled(mem, false); - g_free(name); - - /* - * Configure MemoryRegion implementing access to configuration - * space - */ - mem = &viewport->cfg; - name = designware_pcie_viewport_name(direction, i, "CFG"); - memory_region_init_io(&viewport->cfg, OBJECT(root), - &designware_pci_host_conf_ops, - viewport, name, dummy_size); - memory_region_add_subregion(source, dummy_offset, mem); - memory_region_set_enabled(mem, false); - g_free(name); - } - - /* - * If no inbound iATU windows are configured, HW defaults to - * letting inbound TLPs to pass in. We emulate that by explicitly - * configuring first inbound window to cover all of target's - * address space. - * - * NOTE: This will not work correctly for the case when first - * configured inbound window is window 0 - */ - viewport = &host->viewports[DESIGNWARE_PCIE_VIEWPORT_INBOUND][0]; - viewport->cr[1] = DESIGNWARE_PCIE_ATU_ENABLE; - designware_pcie_update_viewport(root, viewport); - - memory_region_init_io(&host->msi.iomem, OBJECT(root), - &designware_pci_host_msi_ops, - root, "pcie-msi", 0x4); - /* - * We initially place MSI interrupt I/O region at address 0 and - * disable it. It'll be later moved to correct offset and enabled - * in designware_pcie_root_update_msi_mapping() as a part of - * initialization done by guest OS - */ - memory_region_add_subregion(address_space, dummy_offset, &host->msi.iomem); - memory_region_set_enabled(&host->msi.iomem, false); } static void designware_pcie_set_irq(void *opaque, int irq_num, int level) @@ -590,7 +487,7 @@ static void designware_pcie_root_class_init(ObjectClass *klass, void *data) dc->reset = pci_bridge_reset; /* * PCI-facing part of the host bridge, not usable without the - * host-facing part, which can't be device_add'ed, yet. + * host-facing part. */ dc->user_creatable = false; dc->vmsd = &vmstate_designware_pcie_root; @@ -650,8 +547,17 @@ static void designware_pcie_host_realize(DeviceState *dev, Error **errp) PCIHostState *pci = PCI_HOST_BRIDGE(dev); DesignwarePCIEHost *s = DESIGNWARE_PCIE_HOST(dev); SysBusDevice *sbd = SYS_BUS_DEVICE(dev); + MemoryRegion *host_mem = get_system_memory(); + DesignwarePCIEViewport *viewport; size_t i; + /* + * Dummy values used for initial configuration of MemoryRegions + * that belong to a given viewport + */ + const hwaddr dummy_offset = 0; + const uint64_t dummy_size = 4; + for (i = 0; i < ARRAY_SIZE(s->pci.irqs); i++) { sysbus_init_irq(sbd, &s->pci.irqs[i]); } @@ -694,6 +600,97 @@ static void designware_pcie_host_realize(DeviceState *dev, Error **errp) qdev_prop_set_int32(DEVICE(&s->root), "addr", PCI_DEVFN(0, 0)); qdev_prop_set_bit(DEVICE(&s->root), "multifunction", false); qdev_realize(DEVICE(&s->root), BUS(pci->bus), &error_fatal); + + memory_region_init_io(&s->msi.iomem, OBJECT(s), + &designware_pci_host_msi_ops, + s, "pcie-msi", 0x4); + /* + * We initially place MSI interrupt I/O region at address 0 and + * disable it. It'll be later moved to correct offset and enabled + * in designware_pcie_host_update_msi_mapping() as a part of + * initialization done by guest OS + */ + memory_region_add_subregion(&s->pci.memory, dummy_offset, &s->msi.iomem); + memory_region_set_enabled(&s->msi.iomem, false); + + for (i = 0; i < DESIGNWARE_PCIE_NUM_VIEWPORTS; i++) { + MemoryRegion *source, *destination, *mem; + const char *direction; + char *name; + + viewport = &s->viewports[DESIGNWARE_PCIE_VIEWPORT_INBOUND][i]; + viewport->inbound = true; + viewport->base = 0x0000000000000000ULL; + viewport->target = 0x0000000000000000ULL; + viewport->limit = UINT32_MAX; + viewport->cr[0] = DESIGNWARE_PCIE_ATU_TYPE_MEM; + + source = &s->pci.address_space_root; + destination = host_mem; + direction = "Inbound"; + + /* + * Configure MemoryRegion implementing PCI -> CPU memory + * access + */ + mem = &viewport->mem; + name = designware_pcie_viewport_name(direction, i, "MEM"); + memory_region_init_alias(mem, OBJECT(s), name, destination, + dummy_offset, dummy_size); + memory_region_add_subregion_overlap(source, dummy_offset, mem, -1); + memory_region_set_enabled(mem, false); + g_free(name); + + viewport = &s->viewports[DESIGNWARE_PCIE_VIEWPORT_OUTBOUND][i]; + viewport->host = s; + viewport->inbound = false; + viewport->base = 0x0000000000000000ULL; + viewport->target = 0x0000000000000000ULL; + viewport->limit = UINT32_MAX; + viewport->cr[0] = DESIGNWARE_PCIE_ATU_TYPE_MEM; + + destination = &s->pci.memory; + direction = "Outbound"; + source = host_mem; + + /* + * Configure MemoryRegion implementing CPU -> PCI memory + * access + */ + mem = &viewport->mem; + name = designware_pcie_viewport_name(direction, i, "MEM"); + memory_region_init_alias(mem, OBJECT(s), name, destination, + dummy_offset, dummy_size); + memory_region_add_subregion(source, dummy_offset, mem); + memory_region_set_enabled(mem, false); + g_free(name); + + /* + * Configure MemoryRegion implementing access to configuration + * space + */ + mem = &viewport->cfg; + name = designware_pcie_viewport_name(direction, i, "CFG"); + memory_region_init_io(&viewport->cfg, OBJECT(s), + &designware_pci_host_conf_ops, + viewport, name, dummy_size); + memory_region_add_subregion(source, dummy_offset, mem); + memory_region_set_enabled(mem, false); + g_free(name); + } + + /* + * If no inbound iATU windows are configured, HW defaults to + * letting inbound TLPs to pass in. We emulate that by explicitly + * configuring first inbound window to cover all of target's + * address space. + * + * NOTE: This will not work correctly for the case when first + * configured inbound window is window 0 + */ + viewport = &s->viewports[DESIGNWARE_PCIE_VIEWPORT_INBOUND][0]; + viewport->cr[1] = DESIGNWARE_PCIE_ATU_ENABLE; + designware_pcie_update_viewport(&s->root, viewport); } static const VMStateDescription vmstate_designware_pcie_host = {