From patchwork Thu Mar 30 13: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: 668607 Delivered-To: patch@linaro.org Received: by 2002:a5d:4d08:0:0:0:0:0 with SMTP id z8csp931188wrt; Thu, 30 Mar 2023 06:19:45 -0700 (PDT) X-Google-Smtp-Source: AK7set9VUOqJr6yHI0UyLxytUpK3j35mvnuEgsWC/91177r7rE5WikoMjjElm8DsHiuAdPEWVGxw X-Received: by 2002:a05:622a:1450:b0:3d8:fd72:b4a3 with SMTP id v16-20020a05622a145000b003d8fd72b4a3mr38727930qtx.65.1680182384919; Thu, 30 Mar 2023 06:19:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680182384; cv=none; d=google.com; s=arc-20160816; b=uk4IL/DwWk2cKWqckIfazMrgCJfUWcvjTtt8y2XP9NPRpzaNXed7hwF0fiuekJVbhS X/Kljs9n7qdYzqVeac7ZxLiXyZyz47CjvKnqlg4ruXMzTngx/JcZJJljMZyGbxWaFDq4 lCsU2b9b1bng8V3zLsA2nTLy+MI/IciX4tmjRJbquhZrsnWPr0XriQ2mlg5ptiOCVo7U /8XRgfHBEEIjSV9cQ6+1gdbTjdsF+11gLZcBWcDXCVYsDhRHx5shCWljoExJKVCObr+Q LF4YawwS9Pors/IZklWwsImPbbym9/ljCwWwDvFuWZPNMJVznSuaQ8fDqcCjahsJrrGT J/QQ== 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=pAX9S025dEyrSFkAAp1TBAvo2BRP/u6bo3pCVnFlqbg=; b=CiF5tcJZwnqMV0EPn9WQYcznpIIagUlgoNs0NsqBvwEA0VRP4KQGZ1wF5K3ejCJW8G R+CaUE3rlQYHAtxV51PqPf33+QVQRFuA8T01OEQRwH9tZtHxP6xKEE5aRUw/r2tACTTj Iwb0lMoH8PvZrsSNGIkdxl3M7tMio6a9kat6/j4uzV55lz9KEaOp5qF+8Cl7EN7Dhw5c V2EhsU0WHX9X1nuJzOVkwgInF6P2iJLlEf86uEm01VI5N4pg0tROxnAV2S6WVjOP5Bhr WQ6XkdIRfE36O4qCMQR7oT+WbpVuT+38yYD/BQMIR197YpR8+bTvr/e9/PYPeNgKGoO+ i+5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="fQUQwf/c"; 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 r16-20020a374410000000b0070671b50913si22049351qka.702.2023.03.30.06.19.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 30 Mar 2023 06:19:44 -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="fQUQwf/c"; 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 1phsBb-0007z8-GU; Thu, 30 Mar 2023 09:19:29 -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 1phsBR-0007kG-RU for qemu-devel@nongnu.org; Thu, 30 Mar 2023 09:19:20 -0400 Received: from mail-wr1-x42a.google.com ([2a00:1450:4864:20::42a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1phsBP-00021J-LR for qemu-devel@nongnu.org; Thu, 30 Mar 2023 09:19:17 -0400 Received: by mail-wr1-x42a.google.com with SMTP id t4so13819112wra.7 for ; Thu, 30 Mar 2023 06:19:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1680182354; 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=pAX9S025dEyrSFkAAp1TBAvo2BRP/u6bo3pCVnFlqbg=; b=fQUQwf/cBK97OQOowkvhytsrjJOaPlu/0ZAvY6vLWyMhoRqELhgff/awGoeuDGCw9J NVisV+D2DtIvWmftlK8RTtkpACcST6gmtVb2iWswdFrajMS8Bx3mxEXXlO7VFksJPxFu xtPPRRAd5pZ0TkJPGmPm20nY9m3GEHGm50LksNEhMBDq+d6ELL1C9Xwfcbya0TAQyFCY iUv5ghAgk6TTEISciAZiTEH8yKqWFpwZbEXmB61AfXn51s1ogb6Zweddbnx+qo72SF1p 45Cz+BO0zUyDYayJqWuQLPK08ro28eH2oIKiIynKEaW0yBSscVVuAQW9/LijK/8iBZ+u mxvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680182354; 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=pAX9S025dEyrSFkAAp1TBAvo2BRP/u6bo3pCVnFlqbg=; b=oJYIzd953YvOyNCv7Hws/TpOVl3zN+SDsFKWpmKw1o9spUBcSjMozp5mmdW/nYV+ya qDvX2wpjtEu2r4LxOPzaJHP6OUS2N6rY5HlvcJaIh698s8TN956ynR4GnYMClvKKjbPC s2mtPeWA6e+AcqeLtrdfB72aiFGL6sigh0mvb8mrxwhQwa8ScMDMjKyc2qb6huKW87ZZ rrknjbqb6ATHp9Ft05cYvw2pMMDb5/D5UqsgwATUU8M2wFblM7ikWpPC8malFKw/PLkF E7iekrDPXC2uuLjIDdZIklYEOPLggBaDHfuPPixem+Bqo2avmI1YGhuHdFeJn+J3YAg/ 3l1w== X-Gm-Message-State: AAQBX9fROKXT5K06ufWC1517uKzf7LGndCTN79qV9Oim1L63y7belW5P g0oUPpgUPbUd9OhwF/EE7P5vZVe0COO2lCmNduc= X-Received: by 2002:adf:e484:0:b0:2ce:a938:ecc9 with SMTP id i4-20020adfe484000000b002cea938ecc9mr17937943wrm.69.1680182354124; Thu, 30 Mar 2023 06:19:14 -0700 (PDT) Received: from localhost.localdomain ([81.0.6.76]) by smtp.gmail.com with ESMTPSA id e7-20020a5d5307000000b002c5a1bd5280sm32869812wrv.95.2023.03.30.06.19.13 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 30 Mar 2023 06:19:13 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Titus Rwantare , Laurent Vivier , Jiaxun Yang , qemu-block@nongnu.org, Nathan Chancellor , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Aurelien Jarno Subject: [PULL 3/6] hw/mips/gt64xxx_pci: Don't endian-swap GT_PCI0_CFGADDR Date: Thu, 30 Mar 2023 15:18:53 +0200 Message-Id: <20230330131856.94210-4-philmd@linaro.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20230330131856.94210-1-philmd@linaro.org> References: <20230330131856.94210-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42a; envelope-from=philmd@linaro.org; helo=mail-wr1-x42a.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 From: Jiaxun Yang 145e2198d749 ("hw/mips/gt64xxx_pci: Endian-swap using PCI_HOST_BRIDGE MemoryRegionOps") converted CFGADDR/CFGDATA registers to use PCI_HOST_BRIDGE's accessor facility and enabled byte swap for both CFGADDR/CFGDATA register. However CFGADDR as a ISD internal register is not controlled by MByteSwap bit, it follows endian of all other ISD register, which means it ties to little endian. Move mapping of CFGADDR out of gt64120_update_pci_cfgdata_mapping to disable endian-swapping. Fixes: 145e2198d749 ("hw/mips/gt64xxx_pci: Endian-swap using PCI_HOST_BRIDGE MemoryRegionOps") Reported-by: Nathan Chancellor Signed-off-by: Jiaxun Yang Tested-by: Philippe Mathieu-Daudé Reviewed-by: Philippe Mathieu-Daudé Tested-by: Nathan Chancellor Message-Id: <20230223161958.48696-1-jiaxun.yang@flygoat.com> [PMD: !!! Note this only fixes little-endian hosts !!! ] Signed-off-by: Philippe Mathieu-Daudé --- hw/pci-host/gt64120.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/hw/pci-host/gt64120.c b/hw/pci-host/gt64120.c index f226d03420..82c15edb46 100644 --- a/hw/pci-host/gt64120.c +++ b/hw/pci-host/gt64120.c @@ -321,9 +321,6 @@ static void gt64120_isd_mapping(GT64120State *s) static void gt64120_update_pci_cfgdata_mapping(GT64120State *s) { /* Indexed on MByteSwap bit, see Table 158: PCI_0 Command, Offset: 0xc00 */ - static const MemoryRegionOps *pci_host_conf_ops[] = { - &pci_host_conf_be_ops, &pci_host_conf_le_ops - }; static const MemoryRegionOps *pci_host_data_ops[] = { &pci_host_data_be_ops, &pci_host_data_le_ops }; @@ -339,15 +336,6 @@ static void gt64120_update_pci_cfgdata_mapping(GT64120State *s) * - Table 16: 32-bit PCI Transaction Endianess * - Table 158: PCI_0 Command, Offset: 0xc00 */ - if (memory_region_is_mapped(&phb->conf_mem)) { - memory_region_del_subregion(&s->ISD_mem, &phb->conf_mem); - object_unparent(OBJECT(&phb->conf_mem)); - } - memory_region_init_io(&phb->conf_mem, OBJECT(phb), - pci_host_conf_ops[s->regs[GT_PCI0_CMD] & 1], - s, "pci-conf-idx", 4); - memory_region_add_subregion_overlap(&s->ISD_mem, GT_PCI0_CFGADDR << 2, - &phb->conf_mem, 1); if (memory_region_is_mapped(&phb->data_mem)) { memory_region_del_subregion(&s->ISD_mem, &phb->data_mem); @@ -1208,6 +1196,12 @@ static void gt64120_realize(DeviceState *dev, Error **errp) PCI_DEVFN(18, 0), TYPE_PCI_BUS); pci_create_simple(phb->bus, PCI_DEVFN(0, 0), "gt64120_pci"); + memory_region_init_io(&phb->conf_mem, OBJECT(phb), + &pci_host_conf_le_ops, + s, "pci-conf-idx", 4); + memory_region_add_subregion_overlap(&s->ISD_mem, GT_PCI0_CFGADDR << 2, + &phb->conf_mem, 1); + /* * The whole address space decoded by the GT-64120A doesn't generate