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() } };