From patchwork Fri Aug 2 21:31:21 2024 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: 816278 Delivered-To: patch@linaro.org Received: by 2002:adf:e00d:0:b0:367:895a:4699 with SMTP id s13csp451127wrh; Fri, 2 Aug 2024 14:32:16 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV9WPpqKC6ZZHwSgAXcb9yA475tFAQVtUDm2+ZzBG3oA9v+yhXQWBJdeoC2o6oTVPqZHRGtuKNyVrBm0iuQZ+Sm X-Google-Smtp-Source: AGHT+IHlqrW3dliCefVB8utrQvbtn/DcKF+gQLlh2utpvcTNy7QSfySQ3gP216CBJzvDp524Wv8t X-Received: by 2002:a05:622a:93:b0:447:eef9:a750 with SMTP id d75a77b69052e-4518921c44dmr58857321cf.14.1722634336636; Fri, 02 Aug 2024 14:32:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722634336; cv=none; d=google.com; s=arc-20160816; b=Cuv+IGz9TqPvllZV5DZ/lG9MLNqdPhFfkgevUMe+95PZwpHsr14ZKtwOoEAHbTbNrq aLU3B1KhZHTMPCEQMN5vSffpTYOH7lnobOfwHoxBDUtCFW6jVwVwSAND2Svgz8pUBhEf Iw1KP1UiLDA2pP09jdlSVLce2K5OQzRfwGy8ZPtVjKUy6/YID+aegC2sOJrQWYfzSRor LsoKFA4qcJyukbnJ4bchJI7+zeT7FykuiyBlSq7ZPdIAZxA4a7oFpyzobIrGCuZO7DX6 PXScr7Odipmq6PVSlrWds5CEnFKc7AgyvNPcq1gHbVQs/cyUYLawq2m9YI6sTc/g87Dw kH7A== 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=4bGJmkWTOT3c/YDzrQKbOjU81hBSqBBa98tYGP+qJ3Y=; fh=eKZ8W1HrQFnAyEp2CtaDRdXkoCXKcVqaSNlSplY6/OQ=; b=EEmdS7jwWxT3fPu1ZSYT1AFpE7tn1wgXCoza8nTKEXl7rKa/QH7od0pmUQxtqJtw+d EgUHPpvgwrHZH6Lt8n3IYN2x33PBBSK7/mEkhe8+U50npduyCSZdh/zcFHkLHwBcQ5lb //iY+O4VdC0ZgCoPhOzxEBRY/2PLU6EfNLKOw9oxSbb3YTrt3VO61rev/CacLuHcir/d 9AtSUr7Bfx6DkKV8RcLidjLHrB21zIrfH4u7ghEyTlRV4G1/FeoKLrAiuHxhCkKSE7YE 1kjw9RcnJdDWcYrt/rDMNRKmQ00VdTzGZ6yqb5+8sej5psi//b1BAZTd2i1PFb5dqKLB Ol9w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gCxf7g+n; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d75a77b69052e-4518a7c0a63si37703781cf.762.2024.08.02.14.32.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Aug 2024 14:32:16 -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=gCxf7g+n; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZzsB-0005wZ-2L; Fri, 02 Aug 2024 17:31:39 -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 1sZzs7-0005mv-OZ for qemu-devel@nongnu.org; Fri, 02 Aug 2024 17:31:36 -0400 Received: from mail-ed1-x52d.google.com ([2a00:1450:4864:20::52d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZzs5-0003J6-6t for qemu-devel@nongnu.org; Fri, 02 Aug 2024 17:31:34 -0400 Received: by mail-ed1-x52d.google.com with SMTP id 4fb4d7f45d1cf-5a10835487fso11776371a12.1 for ; Fri, 02 Aug 2024 14:31:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722634291; x=1723239091; 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=4bGJmkWTOT3c/YDzrQKbOjU81hBSqBBa98tYGP+qJ3Y=; b=gCxf7g+np4tQxpAf62hxQX3FgQfH1OdoyrtwZAezKS9iLsdupg93FjRNWKS8KbriaP 7VFy4iS9tVVSW0dgcwjsrthXxCCxT2eFdPzu1OKP3ZVWOPm9L6rBQMGz9dT5KoOt6ffc FSWiiucSOn/jcyBpYNf3d6967FYO6AW3QDg3ae/++oPaS0z7WjSiFuIMeyEUz4Kj/CzR XBcCKPGBhpXkXHPxBxq/ZeJ5kDX0l25KhGcqaULZrwDva70rb8TbCczpFiKpjdlz+OUH 1V0cRktRXpziYLhM91XtV1pdgNPd0RhBW8TNl7ZlIS6X1mfcb4ErkvaaKA72MygQEQ0F zEug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722634291; x=1723239091; 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=4bGJmkWTOT3c/YDzrQKbOjU81hBSqBBa98tYGP+qJ3Y=; b=K14XWF3CpALruMrYecybsNLUFw/3OQWZzQtA8qSmntDGfBMpG951W4yMf5iPFFtrx9 jcbegJzuRit656czS6pbNo2n9ep3Jb6rnB5nUkxtwVTvP7R7gxwCv7EJMv7CbIs2jIVR Y3X+i6XBv4SIJvbGsHjy/fLc4+XAWfOMYF6K6jPtVqhz8OThT1Q63QdFGXCzupUcl8TV YB8mHcWiSdydaTCKfe9+ZgQsA24LqsWUgRc1jI80Gd3Ath1bSyawMwi5xgiPI200eSra 380QMpUYurY8JKP3wTuwlyugsbtj/JMRb79te7L9w0NEZdJK49NygNEdy9dcSLe8OyJS 37Jg== X-Gm-Message-State: AOJu0Yzc9IQVI3DDBZmlXWvt+YoJXQzgCBxjRycJxm4eeOsXkP8SX3vh CQLq0OXMCl/JwA6YzZ5HNoX5pG4nkNRzKIa9f5v72ZtrBA8eiMyajJiefv88mH8cZIp64crw64D 8 X-Received: by 2002:a17:907:2dac:b0:a6f:586b:6c2 with SMTP id a640c23a62f3a-a7dc510131cmr315701666b.60.1722634291324; Fri, 02 Aug 2024 14:31:31 -0700 (PDT) Received: from m1x-phil.lan (cvl92-h01-176-184-49-210.dsl.sta.abo.bbox.fr. [176.184.49.210]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9c0c578sm139991666b.73.2024.08.02.14.31.29 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 02 Aug 2024 14:31:30 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: BALATON Zoltan , "Michael S . Tsirkin" , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Aurelien Jarno Subject: [PATCH-for-9.1 v5 1/2] hw/pci-host/gt64120: Set PCI base address register write mask Date: Fri, 2 Aug 2024 23:31:21 +0200 Message-ID: <20240802213122.86852-2-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240802213122.86852-1-philmd@linaro.org> References: <20240802213122.86852-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::52d; envelope-from=philmd@linaro.org; helo=mail-ed1-x52d.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 booting Linux we see: PCI host bridge to bus 0000:00 pci_bus 0000:00: root bus resource [mem 0x10000000-0x17ffffff] pci_bus 0000:00: root bus resource [io 0x1000-0x1fffff] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff] pci 0000:00:00.0: [11ab:4620] type 00 class 0x060000 pci 0000:00:00.0: [Firmware Bug]: reg 0x14: invalid BAR (can't size) pci 0000:00:00.0: [Firmware Bug]: reg 0x18: invalid BAR (can't size) pci 0000:00:00.0: [Firmware Bug]: reg 0x1c: invalid BAR (can't size) pci 0000:00:00.0: [Firmware Bug]: reg 0x20: invalid BAR (can't size) pci 0000:00:00.0: [Firmware Bug]: reg 0x24: invalid BAR (can't size) This is due to missing base address register write mask. Add it to get: PCI host bridge to bus 0000:00 pci_bus 0000:00: root bus resource [mem 0x10000000-0x17ffffff] pci_bus 0000:00: root bus resource [io 0x1000-0x1fffff] pci_bus 0000:00: No busn resource found for root bus, will use [bus 00-ff] pci 0000:00:00.0: [11ab:4620] type 00 class 0x060000 pci 0000:00:00.0: reg 0x10: [mem 0x00000000-0x00000fff pref] pci 0000:00:00.0: reg 0x14: [mem 0x01000000-0x01000fff pref] pci 0000:00:00.0: reg 0x18: [mem 0x1c000000-0x1c000fff] pci 0000:00:00.0: reg 0x1c: [mem 0x1f000000-0x1f000fff] pci 0000:00:00.0: reg 0x20: [mem 0x1be00000-0x1be00fff] pci 0000:00:00.0: reg 0x24: [io 0x14000000-0x14000fff] Since this device is only used by MIPS machines which aren't versioned, we don't need to update migration compat machinery. Mention the datasheet referenced. Remove the "Malta assumptions ahead" comment since the reset values from the datasheet are used. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: BALATON Zoltan --- hw/pci-host/gt64120.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/hw/pci-host/gt64120.c b/hw/pci-host/gt64120.c index e02efc9e2e..573d2619ee 100644 --- a/hw/pci-host/gt64120.c +++ b/hw/pci-host/gt64120.c @@ -1,6 +1,8 @@ /* * QEMU GT64120 PCI host * + * (Datasheet GT-64120 Rev 1.4 from Sep 14, 1999) + * * Copyright (c) 2006,2007 Aurelien Jarno * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -1213,17 +1215,27 @@ static void gt64120_realize(DeviceState *dev, Error **errp) static void gt64120_pci_realize(PCIDevice *d, Error **errp) { - /* FIXME: Malta specific hw assumptions ahead */ + /* Values from chapter 17.16 "PCI Configuration" */ + pci_set_word(d->config + PCI_COMMAND, 0); pci_set_word(d->config + PCI_STATUS, PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MEDIUM); pci_config_set_prog_interface(d->config, 0); + + pci_set_long(d->wmask + PCI_BASE_ADDRESS_0, 0xfffff008); /* SCS[1:0] */ + pci_set_long(d->wmask + PCI_BASE_ADDRESS_1, 0xfffff008); /* SCS[3:2] */ + pci_set_long(d->wmask + PCI_BASE_ADDRESS_2, 0xfffff008); /* CS[2:0] */ + pci_set_long(d->wmask + PCI_BASE_ADDRESS_3, 0xfffff008); /* CS[3], BootCS */ + pci_set_long(d->wmask + PCI_BASE_ADDRESS_4, 0xfffff000); /* ISD MMIO */ + pci_set_long(d->wmask + PCI_BASE_ADDRESS_5, 0xfffff001); /* ISD I/O */ + pci_set_long(d->config + PCI_BASE_ADDRESS_0, 0x00000008); pci_set_long(d->config + PCI_BASE_ADDRESS_1, 0x01000008); pci_set_long(d->config + PCI_BASE_ADDRESS_2, 0x1c000000); pci_set_long(d->config + PCI_BASE_ADDRESS_3, 0x1f000000); pci_set_long(d->config + PCI_BASE_ADDRESS_4, 0x14000000); pci_set_long(d->config + PCI_BASE_ADDRESS_5, 0x14000001); + pci_set_byte(d->config + 0x3d, 0x01); } From patchwork Fri Aug 2 21:31:22 2024 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: 816277 Delivered-To: patch@linaro.org Received: by 2002:adf:e00d:0:b0:367:895a:4699 with SMTP id s13csp451095wrh; Fri, 2 Aug 2024 14:32:10 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCU3RGGklwj2KBEgVgmHgGracv0GRXzdqY0V01Z28/YUY9Mo9a5Zl78JhaKNU1W+qyumCi1B08+/V5SvZc1I3Bjt X-Google-Smtp-Source: AGHT+IEr9kg+vtVMEZiFj4teYwSbm+aJr5Q3XGNs2/2wK76Km1S6ux5zGCYveEwHMZxdlSOev6nJ X-Received: by 2002:a05:6358:4690:b0:1ac:549b:ce02 with SMTP id e5c5f4694b2df-1af3bb0877fmr719003855d.28.1722634330138; Fri, 02 Aug 2024 14:32:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1722634330; cv=none; d=google.com; s=arc-20160816; b=DiJrJdxUq8GujNUU1eY7Mw5oAavvNzlQiELe147SKwSAxdZ6ECkkU/Ic9tUJaP5lq2 ALs3NL5gvGibdy0gHEYNX414CAXFzdP3j2i9MKb1CnkN9qvJhQSyfAfHp0WwBBFppTqx wduxOhVfjO855wbkmy2DfNUviFlDQDaT001sfXBR/bCgMs+cmTyPofeOZtArZXjhX7ug D9KFxDW4TtVvCzP3DGOG1Au4YFz2s+VOmn4LFYFrKlHxvsNa/LxKEK9vUNlXEcbQ7D1p G/7VVleHgpSUINTmNLuMe6Yjl6D3Uyww3VEESfp8pSmQuAKxeUPCeFTVCyi5vw01rOOa BP3g== 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=u0NPDPj0IuFlNwdkUvZuUBMEuKlzPRqWqvQfGq6P0Mw=; fh=eKZ8W1HrQFnAyEp2CtaDRdXkoCXKcVqaSNlSplY6/OQ=; b=c0KQuix8VMHo8TelYpXXJ/XGlmt5pifGBEhP7LDNxykbHmKUg7ScIi8Fwwqmk/JUj0 6R7hCsO87UuZ66ONzlNXNWwM6FiiZbB6BmwEuKE8Yr9f8gGESfRrTKnaRFPu0NPNpj41 sGVktG2tXYYqY+aSXCeRwhTU7JUAwQWor0Hw9kd/7YbDTYGV6CicY9DFEgOSg1Yu/NOO WfOnl9QHj1OF1ZBH5NUCrmtzXBjiCE6ENGO3QvV1zO3r+Vl0MBs0OIuU5fEDA+T6ijhQ BEdVJ0cI+U7PK4y2F2LhFm04B/9EHIvcoUknbMe9myEAnupQw9sC0+tjaeRoweewbOfe jonw==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hlR1rTwM; 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; dara=neutral header.i=@linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 6a1803df08f44-6bb9c83f582si28018996d6.307.2024.08.02.14.32.09 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 02 Aug 2024 14:32: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=hlR1rTwM; 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; dara=neutral header.i=@linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sZzsI-0006ax-UK; Fri, 02 Aug 2024 17:31:46 -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 1sZzsC-0006BD-Su for qemu-devel@nongnu.org; Fri, 02 Aug 2024 17:31:40 -0400 Received: from mail-ej1-x62e.google.com ([2a00:1450:4864:20::62e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sZzsB-0003Jo-9u for qemu-devel@nongnu.org; Fri, 02 Aug 2024 17:31:40 -0400 Received: by mail-ej1-x62e.google.com with SMTP id a640c23a62f3a-a7aa4bf4d1eso225394866b.0 for ; Fri, 02 Aug 2024 14:31:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1722634297; x=1723239097; 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=u0NPDPj0IuFlNwdkUvZuUBMEuKlzPRqWqvQfGq6P0Mw=; b=hlR1rTwMuCjQ1vqIexsEobHqoFSkgl8W/83FOfM0baAhlj8TyFce7pQmUrd/iWZuqN m+vcXobzYcuO7sQpw1YTLeofWXNAab5iGYdaBVyNf+dlZ7Rh0IF9xyP/UO9QMsX/ufTK zh5tXcz6oOdNByASEY1u4P+GSWDNKMB+WuEOSqYFTuco6urCVrhtQcLiMWYCr+7SLS6Z j4v8pqXXQVWS0hGqHfGuVaAkrrgq2NOCy2ylWtxSBrSEa7JNLvLhxhBQGzsqzn5FCqB4 WTVllGTkFMtXHPE3xG23Glhd/FTJypxcu6ArhzodcvtfbJZPOruT35eoBbOkFAzpUg7q A3Bw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722634297; x=1723239097; 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=u0NPDPj0IuFlNwdkUvZuUBMEuKlzPRqWqvQfGq6P0Mw=; b=tbzvz1q6SlVRNtSTo2n4Rw5D9EICRPbOkSSO1l6Ig9U7gED+M3e5RKrn1+zVlE43lh LwhKrko5IVIlNrVP+yRLB+UdE0x9rsuJpEoOf2OdyFYgcEaL9IfA+/UkKBkB6RfUv9dG tllt+KyTsmvIuWoiaoQ6Yv6R0oG8fj987DxFDK0QSQw2+VvzWqWMbk9Kc6j1Xa+Dqrjv wmbiOZmRLVBb5GzMPG31Aih9tdwAvBb3rvPEA9FrOH/KvLQMMJ6AOSdijFYPysmThZwQ Z4SpOYLMGq5B2zuihn2rFoXuGKvS5+kzG/RH83Rv9UAZGBI+p0e8ghCUY9t8TyN4DK5a zVFQ== X-Gm-Message-State: AOJu0YwviF0OyWWoRGYRU1uyOWCdz2f3YPxFO6tFoU/WkJW5IV+WMOAs GjpHmWPLM8sVOWetrQdFCHkB6t+EudGbk3yYws7sZ7gDeEtLcraOjFEzHPpLEWj5/kNBu9vtIiU Z X-Received: by 2002:a17:907:72c5:b0:a7a:929f:c0d6 with SMTP id a640c23a62f3a-a7dc508005bmr388290466b.38.1722634297150; Fri, 02 Aug 2024 14:31:37 -0700 (PDT) Received: from m1x-phil.lan (cvl92-h01-176-184-49-210.dsl.sta.abo.bbox.fr. [176.184.49.210]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9d45400sm140676266b.141.2024.08.02.14.31.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Fri, 02 Aug 2024 14:31:36 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: BALATON Zoltan , "Michael S . Tsirkin" , =?utf-8?q?Philippe_Mathieu-Daud?= =?utf-8?q?=C3=A9?= , Aurelien Jarno Subject: [PATCH-for-9.1 v5 2/2] hw/pci-host/gt64120: Reset config registers during RESET phase Date: Fri, 2 Aug 2024 23:31:22 +0200 Message-ID: <20240802213122.86852-3-philmd@linaro.org> X-Mailer: git-send-email 2.45.2 In-Reply-To: <20240802213122.86852-1-philmd@linaro.org> References: <20240802213122.86852-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::62e; envelope-from=philmd@linaro.org; helo=mail-ej1-x62e.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 Reset config values in the device RESET phase, not only once when the device is realized, because otherwise the device can use unknown values at reset. Since we are adding a new reset method, use the preferred Resettable API (for a simple leaf device reset, a DeviceClass::reset method and a ResettableClass::reset_hold method are essentially identical). Reported-by: Michael S. Tsirkin Reviewed-by: BALATON Zoltan Signed-off-by: Philippe Mathieu-Daudé --- hw/pci-host/gt64120.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/hw/pci-host/gt64120.c b/hw/pci-host/gt64120.c index 573d2619ee..33607dfbec 100644 --- a/hw/pci-host/gt64120.c +++ b/hw/pci-host/gt64120.c @@ -1217,17 +1217,24 @@ static void gt64120_pci_realize(PCIDevice *d, Error **errp) { /* Values from chapter 17.16 "PCI Configuration" */ - pci_set_word(d->config + PCI_COMMAND, 0); - pci_set_word(d->config + PCI_STATUS, - PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MEDIUM); - pci_config_set_prog_interface(d->config, 0); - pci_set_long(d->wmask + PCI_BASE_ADDRESS_0, 0xfffff008); /* SCS[1:0] */ pci_set_long(d->wmask + PCI_BASE_ADDRESS_1, 0xfffff008); /* SCS[3:2] */ pci_set_long(d->wmask + PCI_BASE_ADDRESS_2, 0xfffff008); /* CS[2:0] */ pci_set_long(d->wmask + PCI_BASE_ADDRESS_3, 0xfffff008); /* CS[3], BootCS */ pci_set_long(d->wmask + PCI_BASE_ADDRESS_4, 0xfffff000); /* ISD MMIO */ pci_set_long(d->wmask + PCI_BASE_ADDRESS_5, 0xfffff001); /* ISD I/O */ +} + +static void gt64120_pci_reset_hold(Object *obj, ResetType type) +{ + PCIDevice *d = PCI_DEVICE(obj); + + /* Values from chapter 17.16 "PCI Configuration" */ + + pci_set_word(d->config + PCI_COMMAND, 0); + pci_set_word(d->config + PCI_STATUS, + PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MEDIUM); + pci_config_set_prog_interface(d->config, 0); pci_set_long(d->config + PCI_BASE_ADDRESS_0, 0x00000008); pci_set_long(d->config + PCI_BASE_ADDRESS_1, 0x01000008); @@ -1243,7 +1250,9 @@ static void gt64120_pci_class_init(ObjectClass *klass, void *data) { PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); DeviceClass *dc = DEVICE_CLASS(klass); + ResettableClass *rc = RESETTABLE_CLASS(klass); + rc->phases.hold = gt64120_pci_reset_hold; k->realize = gt64120_pci_realize; k->vendor_id = PCI_VENDOR_ID_MARVELL; k->device_id = PCI_DEVICE_ID_MARVELL_GT6412X;