From patchwork Thu Oct 19 07:15:59 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: 735516 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1378263wro; Thu, 19 Oct 2023 00:18:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEkLd6HQ2R+OTQUidxdyufb/Uer1z3Zgi6UN9bV1qOerI4dIThqpIG0MJNjpFl4n5azB9X8 X-Received: by 2002:a05:620a:424f:b0:774:179d:6576 with SMTP id w15-20020a05620a424f00b00774179d6576mr1407826qko.50.1697699933344; Thu, 19 Oct 2023 00:18:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699933; cv=none; d=google.com; s=arc-20160816; b=TQ0mBj+iE/UH+IgGuFzCIYhdf7xMPgfFB9hFTuZtbx6oiOAJurU4zXEj3yL1KsuiRC ITpFDyjY5Pk7brW7NLEIYyJhsqKSqmCiWurVvyIaqKX0+o0FUCcOhFL1UQrgdqGUV/cV mFFLfXc7d1H6hzBiBflnnxR3TTmtS6GY2hf71SzAL40BI5y+ULxbiin3vSfrtfRGseju peITREzei01MN4X235ov6o4AegKUr8PmPG319m7kqq64e59MFzQYrLgFd/D3TM8T77HK GtEnOxJXZWOfznudOb3Q0D/Wwp2jvON/gCopK8I8Z+3gyJQzaHY2o3M6lUGkRDcI0yww mybg== 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=VOvC+JkvU7gWETYwa7wI+/RczFUNZ/p1uyKYV90ynnc=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=ZkU0jgsVWRsmm6gQETL/vfiJJh5LN8ZgJWoKg6dAzsKKo0Celu3XRNHkegRKx7xIyv /WUc4gHfOz09tHFYK9urDMiFaYuWsb4cfaI3V3SKWgiO59WjAmprJ/xuTetKOeclVz/G koGx5oQ/dNt2PCRqRr3vgLpdUqWWV9pZ7UfrwQo5plxNLUc9ZDuJ3+19rUuMFdZmz4Iy 4lKRGuMRb8Le+k6egEwyEblS3j0/40mBlzrU+JQcj/o9ofyoK5QDrQfgzwhs0Ea2P2oH 9kk3va0pQwGFLwhKJfDxQ38y/q0jIrsBgIvae0ze9ujcv+W95sGsw0Ud7XE+uMGza4Bz 4IUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FX42EUgY; 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 h13-20020a05620a284d00b0077736eb9fc4si1167174qkp.4.2023.10.19.00.18.53 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:18:53 -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=FX42EUgY; 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 1qtNGj-0004ps-DC; Thu, 19 Oct 2023 03:16:33 -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 1qtNGh-0004pL-Ak for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:16:31 -0400 Received: from mail-wm1-x334.google.com ([2a00:1450:4864:20::334]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNGf-00039b-OT for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:16:31 -0400 Received: by mail-wm1-x334.google.com with SMTP id 5b1f17b1804b1-4083f61322fso10557825e9.1 for ; Thu, 19 Oct 2023 00:16:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699788; x=1698304588; 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=VOvC+JkvU7gWETYwa7wI+/RczFUNZ/p1uyKYV90ynnc=; b=FX42EUgYGnz64T4a6ETBEonvlxQ+wSJEokfTz2/Ct03NP74jOP04yLpc0Vqi9x8RVg GJAcR6izmRcWU+h8ApoN9KvziRmhi47x18Uiso75cXAt+1VqYydGu2b17Q6GB9Letp/O 8AxOyTVrOsAuTvAp+FHRF/IbWMfFWNkS10mGPtlJF3N3CDWqpkBqmRGZ5nwoYQBqW08m N9io0GOvDGB2bJ7YhqiT/urbPMiyW72zLO3nQWFxA/b7dkecNbbI4o6WswephuEBBNqe v0SFiR2cQc1/BkdeUZdpX1ryn7rgiAEzK73O5tVvtv/Zl2VpNvv/7PbSrjMTGtj2/pDL V4/Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699788; x=1698304588; 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=VOvC+JkvU7gWETYwa7wI+/RczFUNZ/p1uyKYV90ynnc=; b=dYRLrCUp6qph+dnVNhClV3iqhE7w2h5yKHiF0lR7DWz9EYwHvvsH7ACv/tock2rRh3 eiseQ/8+lKJEpIBHsVk7i0xUOL5EqSKIZSNeCQeU1oVJSXr8KnYLD7ckwEYSy1FMD1H1 V0Qon+gzoIgbyFKj4hhOJzk/a9sVrfvM9s4PQzSMCtn4/uriC87eTzaXWdNzX0jGPGMO l/XsdllnfpdCjjJunaV8e72IUT6lg5ow/xY19GR1LU+pO5D7lEgax+ZCsWqPPTeJtsIZ 343pcCyQ1wf+SCbqMAxMo7rUI6RmWK3OgucG8BjuQISPVP0yXxLXJvCddp4Az8os6Agn Nu9Q== X-Gm-Message-State: AOJu0YzcagEBwWMxo4m+CtwL8sdW7C19QYXKzEkwEG/qPVw4uDSdgr1I FENUgrGLldADeHt0J7EwLn7ZbVCOGQRKgH0cn6MYvQ== X-Received: by 2002:a05:600c:358b:b0:403:cc79:44f3 with SMTP id p11-20020a05600c358b00b00403cc7944f3mr1168643wmq.19.1697699788230; Thu, 19 Oct 2023 00:16:28 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id h19-20020a05600c315300b004064741f855sm3609993wmo.47.2023.10.19.00.16.23 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:16:27 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 01/12] hw/i386/amd_iommu: Do not use SysBus API to map local MMIO region Date: Thu, 19 Oct 2023 09:15:59 +0200 Message-ID: <20231019071611.98885-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::334; envelope-from=philmd@linaro.org; helo=mail-wm1-x334.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 There is no point in exposing an internal MMIO region via SysBus and directly mapping it in the very same device. Just map it without using the SysBus API. Transformation done using the following coccinelle script: @@ expression sbdev; expression index; expression addr; expression subregion; @@ - sysbus_init_mmio(sbdev, subregion); ... when != sbdev - sysbus_mmio_map(sbdev, index, addr); + memory_region_add_subregion(get_system_memory(), addr, subregion); Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Reviewed-by: Zhao Liu --- hw/i386/amd_iommu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c index 8d0f2f99dd..7965415b47 100644 --- a/hw/i386/amd_iommu.c +++ b/hw/i386/amd_iommu.c @@ -1579,9 +1579,8 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp) /* set up MMIO */ memory_region_init_io(&s->mmio, OBJECT(s), &mmio_mem_ops, s, "amdvi-mmio", AMDVI_MMIO_SIZE); - - sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->mmio); - sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, AMDVI_BASE_ADDR); + memory_region_add_subregion(get_system_memory(), AMDVI_BASE_ADDR, + &s->mmio); pci_setup_iommu(bus, amdvi_host_dma_iommu, s); amdvi_init(s); } From patchwork Thu Oct 19 07:16:00 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: 735525 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1378539wro; Thu, 19 Oct 2023 00:19:48 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHVoyKGb+KO09/DosFRDT5HPPRSxH+yHe3hAfYgIKZDbtOtIUdlod9v+syUUgg86p3I43HF X-Received: by 2002:ac8:5bcf:0:b0:418:1272:7c6e with SMTP id b15-20020ac85bcf000000b0041812727c6emr1508164qtb.7.1697699988606; Thu, 19 Oct 2023 00:19:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699988; cv=none; d=google.com; s=arc-20160816; b=autyboZ0tg/2FfZcR1doveYxeMDgYqgtP/W3cZfYu/Ad9e/UI+kqkTaiINLh91a/fc Vq1v1WKeP4uTXXYDf07To4tmwYsi1XKubxexHKiDsDmae50W/SphEdeGp6PsfqXMT+kz flYITgLANxesnpHo9BrTWVE8Q/gPwK42UlO4MQ+WOp95nvjoMm58eCIe50qMp96MrvQ9 /VTe6s0lCuyuxaZH3uTV1tOhwSpAm0qLsDeQPtgwUrsk+Reqi9UQKaqFiXCKWKfGubfs L229FzDmSKMFdU9CvqXhA+yZ4oko+DkrbZRF/b7Xuz+SpcyyGz9a+kvI92JT0LHSYF6H ZTlA== 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=31IMAee+VZo6+j+lZFd22FV62NKoWHWg3TvBlA119f8=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=LCV45oe3nmaXs8xlG48Wgnri3zOfBLlviCshw5SZ67lqPzKFkpGEVeIHU2AcGRYs66 hRQvKLhm3hdUAIDNPhJkGqC/gAFaWoGs6fkdGQOVeaiByqWMRz9ttuBSXImX1l4dkvLW d/F4ShxcU+OzHCYPXDJCLFpOHgxvLSq1YfNvRpZqr4C/EBYEw0lIgdc8eJfyAhhmdxZ6 SGKz69YkTeeUl4lrJ3eNrwfKqwOkWHCfkF+8wkfuXFIZ+epWv+cJNpKm6s0aIwpEd04Z a2VjVnWHE+SoA17/xExteFAWM1t/nS/BqWKWCE0ehaaFZuYNG6VCI97ec+KFxvSgovaf fXDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JiiiZJX2; 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 h14-20020ac85e0e000000b0041983f51b2esi1149456qtx.67.2023.10.19.00.19.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:19:48 -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=JiiiZJX2; 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 1qtNGu-0004s3-4R; Thu, 19 Oct 2023 03:16:44 -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 1qtNGt-0004rZ-25 for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:16:43 -0400 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNGq-0003Ao-Do for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:16:42 -0400 Received: by mail-wr1-x42c.google.com with SMTP id ffacd0b85a97d-32db8924201so3002238f8f.1 for ; Thu, 19 Oct 2023 00:16:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699799; x=1698304599; 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=31IMAee+VZo6+j+lZFd22FV62NKoWHWg3TvBlA119f8=; b=JiiiZJX2Ul0XFeys+tTH56OyMyqLueNy/2tqHDb0lNtj0AWpJiGsUTR1k3CXGVtbwV UUbQDwMxmtDknDnLBgaWXp+ByJ3RM3C750Bp1pFu1oWWbvmgrCGLxfCi4KmvaOam3iGK bsI8rxL/6a9kSuTNyCNY9eYarRW038iqRyfFn2Kq/cT+tYsaz5Iqkphu0yiG22EmyM8+ hWs9p8Sio9fur8zvbrEEP0rIMc6V/GytAkHJZuJMK5nbWgGP9eP0twgyigFWKjxgmvcY c1Vpxcai1SPM825bZO94Dk58PbbWiIG4wW128/oAXEVh/+E5sOAby8BN/sl5R5KLtAw3 CHPw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699799; x=1698304599; 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=31IMAee+VZo6+j+lZFd22FV62NKoWHWg3TvBlA119f8=; b=d4oGaHtqChv+kHwLp3oxkN3KenJ6Vb0kTMn+jqGWucAyoWhve8c2u6xnjghQR4udK9 /dsKsGwVlq2GM2B/mI+EfMkO8oW668jUby/KTDcP4jQLl6VB6in7xmRQcEBhEg1psO14 3E1wjQBXQyu3hA8GIKTQgXXMftBEc1uwlkS6ze86/uUhOmPSEYsvrJCew4cuTlQQ5HLP RVrlGpooQJ1Do+hyaw1+uGN5B2ki/VnwVKIouHrBwm+DsNFqb8S/3jKodzonTfTLkavE 1HOL8pkU8G/a/6cVllK3Ht5Re+6QxLeIz+ru0Sm3WGpweU9O0FSFTa9UdEFzAf+jQ5xJ WGRg== X-Gm-Message-State: AOJu0Yzk4W+gHfUpWy+XtISNRdX9rrU/EOfY2LEZp2kIBcQZzEaUuM0W yFlFmW268JccaU87POsUiEfP+bizFCQdIiOwkW+AzA== X-Received: by 2002:adf:f682:0:b0:32d:8cfd:5780 with SMTP id v2-20020adff682000000b0032d8cfd5780mr918954wrp.27.1697699798766; Thu, 19 Oct 2023 00:16:38 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id i3-20020a5d6303000000b0032db4e660d9sm3755308wru.56.2023.10.19.00.16.33 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:16:38 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 02/12] hw/i386/intel_iommu: Do not use SysBus API to map local MMIO region Date: Thu, 19 Oct 2023 09:16:00 +0200 Message-ID: <20231019071611.98885-3-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42c; envelope-from=philmd@linaro.org; helo=mail-wr1-x42c.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 no point in exposing an internal MMIO region via SysBus and directly mapping it in the very same device. Just map it without using the SysBus API. Transformation done using the following coccinelle script: @@ expression sbdev; expression index; expression addr; expression subregion; @@ - sysbus_init_mmio(sbdev, subregion); ... when != sbdev - sysbus_mmio_map(sbdev, index, addr); + memory_region_add_subregion(get_system_memory(), addr, subregion); Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin Reviewed-by: Zhao Liu --- hw/i386/intel_iommu.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/hw/i386/intel_iommu.c b/hw/i386/intel_iommu.c index 2c832ab68b..e4f6cedcb1 100644 --- a/hw/i386/intel_iommu.c +++ b/hw/i386/intel_iommu.c @@ -4134,6 +4134,8 @@ static void vtd_realize(DeviceState *dev, Error **errp) qemu_mutex_init(&s->iommu_lock); memory_region_init_io(&s->csrmem, OBJECT(s), &vtd_mem_ops, s, "intel_iommu", DMAR_REG_SIZE); + memory_region_add_subregion(get_system_memory(), + Q35_HOST_BRIDGE_IOMMU_ADDR, &s->csrmem); /* Create the shared memory regions by all devices */ memory_region_init(&s->mr_nodmar, OBJECT(s), "vtd-nodmar", @@ -4148,15 +4150,12 @@ static void vtd_realize(DeviceState *dev, Error **errp) memory_region_add_subregion_overlap(&s->mr_nodmar, VTD_INTERRUPT_ADDR_FIRST, &s->mr_ir, 1); - - sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->csrmem); /* No corresponding destroy */ s->iotlb = g_hash_table_new_full(vtd_iotlb_hash, vtd_iotlb_equal, g_free, g_free); s->vtd_address_spaces = g_hash_table_new_full(vtd_as_hash, vtd_as_equal, g_free, g_free); vtd_init(s); - sysbus_mmio_map(SYS_BUS_DEVICE(s), 0, Q35_HOST_BRIDGE_IOMMU_ADDR); pci_setup_iommu(bus, vtd_host_dma_iommu, dev); /* Pseudo address space under root PCI bus. */ x86ms->ioapic_as = vtd_host_dma_iommu(bus, s, Q35_PSEUDO_DEVFN_IOAPIC); From patchwork Thu Oct 19 07:16:01 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: 735517 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1378292wro; Thu, 19 Oct 2023 00:18:57 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHjwxQF74fs0awShwQ+iplrtFjyPS+Y7rE2C+PqxJ79/oMilI+9Wm3x2xlmXq3iiWWnV7d1 X-Received: by 2002:a05:622a:1801:b0:401:e0b4:a93f with SMTP id t1-20020a05622a180100b00401e0b4a93fmr1548845qtc.41.1697699937581; Thu, 19 Oct 2023 00:18:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699937; cv=none; d=google.com; s=arc-20160816; b=EMwh7MxnWfiz97bTRXqUVYIAIkPnAAW3g+0B99OxL72QmSsic/ucpyWXmE7Z5VHhza rV6Wjvxg87m80gS62qiOCNtS4nIV2ohbpVkz4fv/6wyZjfDtpDhfW4jY3MGMs+SL97FO lLXad6+4hjU4yj0fgvoViuki0zhsQQElFRHovdI6KF/2YhUGDVtlmDyrWZVU02OxaDzO Z/XBipEacUzMNgkfy35C5QyWMLNO3esP/oxDresbK8odW8PcCr2CWMhINO0gixVWFcYy 1BU8QSPBX1PhCG6gUsXPhPmj96HPyU5kx/aXXZix1Y9MlZ/ke5rgyQd8QA9aFUoAnuqt eoJQ== 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=OG/eTeWn+OzUtyx8iBSPb0Amcuu5LlJ9K/x3TvIXfKM=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=CQ4cQhQY+nUXkbFPdWzS61gTv5WDICOcnzVgZmsbfcGOVWPiGRaI4BjOFmUeD1q5I0 r/lDbgUhpCaJtEQLt6DgB7D0ypSs+0T8HATk7k6pE/z09QbUHyDvU1ScAcVCPUdDFzJ5 ef6qhCGJXb3HBhkRAQ8LkAGdc55Z9yNvjoNgjd2nyXXVucmGwABD0tZlUCJ8oVRDGu8r QIQaUv3OPlhQ5TVn00QIcUChYrv0Hto0FhbOm8mXtgSrCHFp30tQ8oLNoDCHJsF7P0Z0 rvUkEerFqOfguCt2jgkGQp7fGN7KlIN6o1elXLlaF4udz5GpVU/4Rkr5s0pp4G7UYOEf Uw2A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LMTy28il; 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 21-20020ac85955000000b0041972592457si1124452qtz.356.2023.10.19.00.18.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:18: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=LMTy28il; 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 1qtNHE-0005B5-SS; Thu, 19 Oct 2023 03:17:04 -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 1qtNH3-0004zQ-Kp for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:16:56 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNH0-0003CS-OP for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:16:53 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-4083f61312eso10967625e9.3 for ; Thu, 19 Oct 2023 00:16:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699809; x=1698304609; 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=OG/eTeWn+OzUtyx8iBSPb0Amcuu5LlJ9K/x3TvIXfKM=; b=LMTy28ilQ4PoOMyTvYA2M5rnGT0R0/HVQydI9FutXMXoovWq4qcPQPdg1iHItGy+jq MoSI+taehZIBbjJEipGErf0Dnj5diwcPRzKeKg3vQs1S5MTw3LO2Hk6bDCqhleQMUX+C 3Du3VQmlb7LZHow6U0p/xe6FC/AYRtbz2P9g2SrHxuNEGj7fW0DX5mHtNewToNZErJYG abL+XtOh2VCBGFKdd2AKZp/b5jQsz9NX0Sgy7tWUbMgtSx3vs6QT5Xu1BEF3Y465YQdy c56HjY18zGk7QQyn3dZFVPRJvSZPGtpC1H+P5yMLHWNjn/1V2eHNvqVs2RCVJHGs17jd afnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699809; x=1698304609; 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=OG/eTeWn+OzUtyx8iBSPb0Amcuu5LlJ9K/x3TvIXfKM=; b=U0a/xiu/e9Vyuitwic6hSczBHflMqY9uXK2UCvvIDHo+Kj7XBWgnZX6QpPJTIUFUyv s+XMj39vqTSJ2Ghk5MH+usTZHXAaQs/6u2v1xXEDQuxkhjdTC2MAoMildUM+IZejptFV UslpMXZM/ggTPyD7rgsswCEya2vAVb85FUQ3rNxShcgvZqmQtJkAoBLfOQb7N/yLwCC8 jms1/KRbHGkseCkY6bkmlYbt1a0ZS30+MVD8WrqFUtg0z1NJ+2JFZJVQSGgtdYE4Q2nc tIIz5bappq2iBHfnqJ24+Gl5lXTy5SHhfp/KtRfVexPfF/N0F/C+6JLQVwCFQJRCnaOF OG1w== X-Gm-Message-State: AOJu0Yx3q4eF3Ey7AB8k7QKv7LlCDj8tRX/PoVK0PWvgYokx26sVLC5T RfgyXyqyKdmuKI4NU05E+hQgJWOd0+do9CflDMyjJw== X-Received: by 2002:a05:600c:3587:b0:408:3a67:f6f5 with SMTP id p7-20020a05600c358700b004083a67f6f5mr1130034wmq.18.1697699808913; Thu, 19 Oct 2023 00:16:48 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id g14-20020a05600c310e00b0040813e14b49sm3620516wmo.30.2023.10.19.00.16.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:16:48 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 03/12] hw/misc/allwinner-dramc: Move sysbus_mmio_map call from init -> realize Date: Thu, 19 Oct 2023 09:16:01 +0200 Message-ID: <20231019071611.98885-4-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=philmd@linaro.org; helo=mail-wm1-x32f.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 In order to make the next commit trivial, move the sysbus_init_mmio() call in allwinner_r40_dramc_init() just before the corresponding sysbus_mmio_map_overlap() call in allwinner_r40_dramc_realize(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- hw/misc/allwinner-r40-dramc.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/hw/misc/allwinner-r40-dramc.c b/hw/misc/allwinner-r40-dramc.c index 6944f84455..2cc0254a55 100644 --- a/hw/misc/allwinner-r40-dramc.c +++ b/hw/misc/allwinner-r40-dramc.c @@ -414,6 +414,7 @@ static void allwinner_r40_dramc_reset(DeviceState *dev) static void allwinner_r40_dramc_realize(DeviceState *dev, Error **errp) { AwR40DramCtlState *s = AW_R40_DRAMC(dev); + SysBusDevice *sbd = SYS_BUS_DEVICE(dev); if (!get_match_ddr(s->ram_size)) { error_report("%s: ram-size %u MiB is not supported", @@ -421,8 +422,12 @@ static void allwinner_r40_dramc_realize(DeviceState *dev, Error **errp) exit(1); } - /* detect_cells */ - sysbus_mmio_map_overlap(SYS_BUS_DEVICE(s), 3, s->ram_addr, 10); + /* R40 support max 2G memory but we only support up to 1G now. index 3 */ + memory_region_init_io(&s->detect_cells, OBJECT(s), + &allwinner_r40_detect_ops, s, + "DRAMCELLS", 1 * GiB); + sysbus_init_mmio(sbd, &s->detect_cells); + sysbus_mmio_map_overlap(sbd, 3, s->ram_addr, 10); memory_region_set_enabled(&s->detect_cells, false); /* @@ -458,12 +463,6 @@ static void allwinner_r40_dramc_init(Object *obj) &allwinner_r40_dramphy_ops, s, "DRAMPHY", 4 * KiB); sysbus_init_mmio(sbd, &s->dramphy_iomem); - - /* R40 support max 2G memory but we only support up to 1G now. index 3 */ - memory_region_init_io(&s->detect_cells, OBJECT(s), - &allwinner_r40_detect_ops, s, - "DRAMCELLS", 1 * GiB); - sysbus_init_mmio(sbd, &s->detect_cells); } static Property allwinner_r40_dramc_properties[] = { From patchwork Thu Oct 19 07:16:02 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: 735514 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1377951wro; Thu, 19 Oct 2023 00:17:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHxK7KlVv/WhUtZgjqBF0eriSmvgneTCz5o2KGnrsW6sk1MipJz6QqdK5hoIHFja684dnKo X-Received: by 2002:ac8:5d87:0:b0:41c:c4e7:c1fc with SMTP id d7-20020ac85d87000000b0041cc4e7c1fcmr1645669qtx.21.1697699876264; Thu, 19 Oct 2023 00:17:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699876; cv=none; d=google.com; s=arc-20160816; b=FgId9kmQB495XGwpBK2zGLMb2g55OUsCjAqBu7tdxX5d8A0E6ZEh1sia3A1yKa2bB2 vXILBUq0+VgWW/A8BF580lA2U+vstqXfOjVwjvlOJu/TktU1oUGxwrFg/83l2ovuaS3f O+D12yZoYlov87Bo7Gxjy0Kj+lXMTjkcyJaZbUweYLhzbouAmWAQhiXvfjS+fN+Qxdud Vrxn1YMEtKAF2bN3YUg/7xrTtpzE5ii/re4FeRFDU0qZvFT2UJUy6Lu8cGcQSJltpsAb kt7Mxn0Qw3YFzohIfOhNJ1rwTLXKXcCdofIN2hMRSOmuXQs4G43SJA3cQN2GFxq6keLG mgbg== 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=XTgBuZGYkLbr0wmI8JEwCdSLvjSRDlVIxUJmeWPbI+s=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=vXKjBzA6zv8X3DB6k0VpZgpq/3Qzr9ZKLFFBH0dAll/YFpS5KCLmzMhujmjLrC7nG+ X0m3xP1sdDbUFeH0cNs3qAV4rFwxSU9dBQRqOVpJgnVnd3ycVzQ6xM4pH996WCTjgXxg s/+TWwtRXQJnji0uGZdlpF15NROBYC7QIDZs6GD32E4eavU6ZMdhFBUoxipGBrsXmN3r 0WllaYS+EceQ/u6kAntOsnid0hXal/gKlwV6RqMcGZ98znuFbEDXq4VrDCUJ7HTcwHnD 8dISHbH32BbhF6MxcA9ug8MzLSTEwg7kz6CX1rs5fJ5Z/+e2R8dRSguhlmmYZZ4zFVZA dnGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=B1DK3B28; 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 o13-20020a05622a044d00b004181075e931si1162900qtx.154.2023.10.19.00.17.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:17:56 -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=B1DK3B28; 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 1qtNHG-0005Hy-J4; Thu, 19 Oct 2023 03:17:06 -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 1qtNHD-00058V-W3 for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:04 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNHB-0003DN-Hb for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:03 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-3296b3f03e5so6181803f8f.2 for ; Thu, 19 Oct 2023 00:17:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699819; x=1698304619; 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=XTgBuZGYkLbr0wmI8JEwCdSLvjSRDlVIxUJmeWPbI+s=; b=B1DK3B28ACzOYr/ul6k4jg9R9rhDsxVWWLnD6Ozk1ob/zB34o75Oc7uiKVy7yINQs5 p0QHL0AU895qGkyE1o7UwSsulk+qNS3CwIXfHs+1w/V7o6Pahd2LXM5CI/sk1kXVp9Rz qQMtDQgPZ6AlElGR1Xia3Okn5/lfRfwDeYRjug8zBvpb4AbHefBB5Vlmd5u3wexXLYI4 XKaVplk2upg57RdOsQGfH8aE1jN5XF40U80jTuRUtUksz+0xPmu+pAr+TxhIzzj6GHeR 4n7RhONKRSllMuJeNypDwM7ofBbZYvstyqujn+cuKv83yukoN7YaDIobkyiVbuKjA4Ol hbcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699819; x=1698304619; 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=XTgBuZGYkLbr0wmI8JEwCdSLvjSRDlVIxUJmeWPbI+s=; b=W5ER8dntl2+9uoagkNzMExa72gyAi1r5OJ5+Yu5bl3w79Jqyi/JKaAwFtUpiB8ff2Z R65nUroh5AR9SLLP1OSiHZvHhGBToVVLGAjxa+eBmUwnCDlGivZJzbe4UgBB51H/NHNW 1JkEYir/EEXoBMv6I/5v4MzPmQTSP8+qWqRpZQ1pATVmYf3gnZEai23eopBuUqxCpVby M676EPWuJr6ip4jOzv4ktEraNn+uiult0i2/Wd8TLva4r1FfuUL/B5SDWxPvxcO/MPTO n+JdrebcIAmMas+V4CxLGo/plte9zqkZXBHb+935/lgCQP4t/CobPQ9zUZcKKaP1xvZt Yuyg== X-Gm-Message-State: AOJu0YxsfyVOt8TKPUr4rmgSImE/+guDgdxcRfEtVENQIKTmOa6ZscCU cUCY+LOOkswYyzYim1MgsDCzQaDvB3nhyKCJc9N10A== X-Received: by 2002:a5d:5082:0:b0:32d:9ce0:35ae with SMTP id a2-20020a5d5082000000b0032d9ce035aemr788960wrt.52.1697699819245; Thu, 19 Oct 2023 00:16:59 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id d14-20020a056000114e00b003232380ffd5sm3732348wrx.106.2023.10.19.00.16.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:16:58 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 04/12] hw/misc/allwinner-dramc: Do not use SysBus API to map local MMIO region Date: Thu, 19 Oct 2023 09:16:02 +0200 Message-ID: <20231019071611.98885-5-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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 no point in exposing an internal MMIO region via SysBus and directly mapping it in the very same device. Just map it without using the SysBus API. Transformation done using the following coccinelle script: @@ expression sbdev; expression index; expression addr; expression subregion; @@ - sysbus_init_mmio(sbdev, subregion); ... when != sbdev - sysbus_mmio_map(sbdev, index, addr); + memory_region_add_subregion(get_system_memory(), + addr, subregion); @@ expression priority; @@ - sysbus_init_mmio(sbdev, subregion); ... when != sbdev - sysbus_mmio_map_overlap(sbdev, index, addr, priority); + memory_region_add_subregion_overlap(get_system_memory(), + addr, + subregion, priority); Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- hw/misc/allwinner-r40-dramc.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/hw/misc/allwinner-r40-dramc.c b/hw/misc/allwinner-r40-dramc.c index 2cc0254a55..3d81ddb2e1 100644 --- a/hw/misc/allwinner-r40-dramc.c +++ b/hw/misc/allwinner-r40-dramc.c @@ -414,7 +414,6 @@ static void allwinner_r40_dramc_reset(DeviceState *dev) static void allwinner_r40_dramc_realize(DeviceState *dev, Error **errp) { AwR40DramCtlState *s = AW_R40_DRAMC(dev); - SysBusDevice *sbd = SYS_BUS_DEVICE(dev); if (!get_match_ddr(s->ram_size)) { error_report("%s: ram-size %u MiB is not supported", @@ -422,23 +421,23 @@ static void allwinner_r40_dramc_realize(DeviceState *dev, Error **errp) exit(1); } - /* R40 support max 2G memory but we only support up to 1G now. index 3 */ + /* R40 support max 2G memory but we only support up to 1G now. */ memory_region_init_io(&s->detect_cells, OBJECT(s), &allwinner_r40_detect_ops, s, "DRAMCELLS", 1 * GiB); - sysbus_init_mmio(sbd, &s->detect_cells); - sysbus_mmio_map_overlap(sbd, 3, s->ram_addr, 10); + memory_region_add_subregion_overlap(get_system_memory(), s->ram_addr, + &s->detect_cells, 10); memory_region_set_enabled(&s->detect_cells, false); /* * We only support DRAM size up to 1G now, so prepare a high memory page - * after 1G for dualrank detect. index = 4 + * after 1G for dualrank detect. */ memory_region_init_io(&s->dram_high, OBJECT(s), &allwinner_r40_dualrank_detect_ops, s, "DRAMHIGH", KiB); - sysbus_init_mmio(SYS_BUS_DEVICE(s), &s->dram_high); - sysbus_mmio_map(SYS_BUS_DEVICE(s), 4, s->ram_addr + GiB); + memory_region_add_subregion(get_system_memory(), s->ram_addr + GiB, + &s->dram_high); } static void allwinner_r40_dramc_init(Object *obj) From patchwork Thu Oct 19 07:16:03 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: 735519 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1378352wro; Thu, 19 Oct 2023 00:19:06 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG3QTMP8sjtPIZjzRnorS1fIkHkiEQ9oL8s7v6gQuciaAyU9d2qgUWcUzC7+K/rPaBYzdIE X-Received: by 2002:ac8:7d41:0:b0:403:a9aa:571f with SMTP id h1-20020ac87d41000000b00403a9aa571fmr1776249qtb.16.1697699946405; Thu, 19 Oct 2023 00:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699946; cv=none; d=google.com; s=arc-20160816; b=WlTqJCY5Y/XhTQsq3l05oVc8ciBSUNkx1tJXr/YW9v5hEOqEsr/B0+Op1nqfrJRQrO q0s76FPfnmviHlC1MnlrL0iEThnBt5q9Zx7m4WzpZvUD6VIKwcZ0vjd4xLXsY9G+qzrQ k6EgiRrugmeY3fBjvU2+MuTHRx62LxgQASp6d5aQXZJ+liz8xMPCifqk4fk3Vszc46Ot hW0mzBJQ5pA82GL82h8AaB+Z8lBEgiwk5MV3Tht8rl0+aaHmA9te9AqjtDnTGtk890R2 Tn91YBsMhCd/TNRFQx+8ypzPZln+iOkywjgVO1Gm4c2Pt8JZDhUdg/AJMt62JEJmBQkk Alkg== 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=cFAMYwhnq3nxNfGtfJVokxRT7cRevtvOipnlNAGOBcc=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=aNHEdlY6BSx+LXgdY/Ixy8dElLJQsnfL5TQnbiDpzkKrb/dt8lST8ASomeCD9qh7QN sOJftigZNcB2S9FpQPUFBIV67hyIIsOMfvznuAJ97ffcN8Veot9zsGrYiSK9oelKJJZX EQ6pjY81pvKcygdE5GVDEK2Py1to+hzuqTWvL9NDWa/CD2BrvaU2Ps3LFTxlWTO905Sc DVF+6ewJP4SsBtlNfihqGLaleX7nLHorQ/2wFPUdTm57dncwJNE4L4v2WiAEVy+In5tV MCdzUaYwJzyKdCMjf2E10qFBfIWNIDz5MG/pDmFskONu703mJ4pY15FpT9vPT5laWH38 fazQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=bjkZDZs7; 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 c19-20020a05622a025300b0041991869095si1122621qtx.330.2023.10.19.00.19.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:19:06 -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=bjkZDZs7; 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 1qtNHr-0005vn-Ri; Thu, 19 Oct 2023 03:17: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 1qtNHP-0005Ru-UJ for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:15 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNHM-0003Ea-7R for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:15 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-4079ed65582so21175955e9.1 for ; Thu, 19 Oct 2023 00:17:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699829; x=1698304629; 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=cFAMYwhnq3nxNfGtfJVokxRT7cRevtvOipnlNAGOBcc=; b=bjkZDZs70Lg43rIIKd5RgCJWeMkiMo3ANIdC+/B0KaAlclb8eo2s3gec8sksInwrBi YJC78nlu4kzRTiN+D9rVzXfT800qzg0dGG7w5lMIAnihnKsLaMXoKVbvj7+r+lVDK+wS YBewy57shKO+fgPM5ABC+CmWOToL/KAiEov9lk2oV+uHNaSkoHXodnzyzQ1aV+r1uGrn 1uIjP7F1vyoS/On/gTe6tWkX66EkQhFRDYv2H0pJJxWdlgBKZGU8tsW3lrZx7yEFyQxZ IHzslQZRmI0npS5qmVAdRnzUhFqEcx+I1NvHcQVI6Evn+vTVePzCrSVfOHXW0ATWNbd7 lv2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699829; x=1698304629; 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=cFAMYwhnq3nxNfGtfJVokxRT7cRevtvOipnlNAGOBcc=; b=NwvVf81IUWJHKfSYYMBJaA9tbZ6tygu7cF33aIwonNd5nMo2Nl70nbNF9XgO4lUhlz gLB7crZl/1fYuAvdh0EvmcjW1h46JYmswYlG1BpmP8zxB39Z7Dt9mPzakqddDLxzsErY ZcEbVqPghWhGuzDoLA6OwUxV6uJobBB4Ccyz2JYgV3FJyXCq59KN2vlsWSriUNhNCNXb QZqJW4nkKtlVzkaLO4XvdntvQxr289Ce761xtDAeZKpq7hVGMPBNE993bBu9j4X3Gy/d HsL8E2vn65AJ41nhZHQ/5vOfos0CfCaPEkPkIBYud+r3uCDXVCT8+Po86U/QjzLEppKv QPWg== X-Gm-Message-State: AOJu0Yxot1nLr54GChYNovwBsMe8CzGG+PH0+w4iwAjtHev9v0EDu2P1 pjRIU2yVPeY+rQQwlTtsgGzqdlyoIVSpxqFCJ8VSSg== X-Received: by 2002:adf:e605:0:b0:32d:8401:404a with SMTP id p5-20020adfe605000000b0032d8401404amr986009wrm.10.1697699829535; Thu, 19 Oct 2023 00:17:09 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id b3-20020adff243000000b003258934a4bcsm3776251wrp.42.2023.10.19.00.17.04 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:17:09 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 05/12] hw/pci-host/bonito: Do not use SysBus API to map local MMIO region Date: Thu, 19 Oct 2023 09:16:03 +0200 Message-ID: <20231019071611.98885-6-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=philmd@linaro.org; helo=mail-wm1-x329.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 There is no point in exposing an internal MMIO region via SysBus and directly mapping it in the very same device. Just map it without using the SysBus API. Transformation done using the following coccinelle script: @@ expression sbdev; expression index; expression addr; expression subregion; @@ - sysbus_init_mmio(sbdev, subregion); ... when != sbdev - sysbus_mmio_map(sbdev, index, addr); + memory_region_add_subregion(get_system_memory(), addr, subregion); and manually adding the local 'host_mem' variable to avoid multiple calls to get_system_memory(). Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- hw/pci-host/bonito.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/hw/pci-host/bonito.c b/hw/pci-host/bonito.c index ee6cb85e97..96bd028671 100644 --- a/hw/pci-host/bonito.c +++ b/hw/pci-host/bonito.c @@ -654,10 +654,10 @@ static void bonito_host_realize(DeviceState *dev, Error **errp) static void bonito_pci_realize(PCIDevice *dev, Error **errp) { PCIBonitoState *s = PCI_BONITO(dev); - SysBusDevice *sysbus = SYS_BUS_DEVICE(s->pcihost); PCIHostState *phb = PCI_HOST_BRIDGE(s->pcihost); BonitoState *bs = s->pcihost; MemoryRegion *pcimem_alias = g_new(MemoryRegion, 1); + MemoryRegion *host_mem = get_system_memory(); /* * Bonito North Bridge, built on FPGA, @@ -668,48 +668,48 @@ static void bonito_pci_realize(PCIDevice *dev, Error **errp) /* set the north bridge register mapping */ memory_region_init_io(&s->iomem, OBJECT(s), &bonito_ops, s, "north-bridge-register", BONITO_INTERNAL_REG_SIZE); - sysbus_init_mmio(sysbus, &s->iomem); - sysbus_mmio_map(sysbus, 0, BONITO_INTERNAL_REG_BASE); + memory_region_add_subregion(host_mem, BONITO_INTERNAL_REG_BASE, + &s->iomem); /* set the north bridge pci configure mapping */ memory_region_init_io(&phb->conf_mem, OBJECT(s), &bonito_pciconf_ops, s, "north-bridge-pci-config", BONITO_PCICONFIG_SIZE); - sysbus_init_mmio(sysbus, &phb->conf_mem); - sysbus_mmio_map(sysbus, 1, BONITO_PCICONFIG_BASE); + memory_region_add_subregion(host_mem, BONITO_PCICONFIG_BASE, + &phb->conf_mem); /* set the south bridge pci configure mapping */ memory_region_init_io(&phb->data_mem, OBJECT(s), &bonito_spciconf_ops, s, "south-bridge-pci-config", BONITO_SPCICONFIG_SIZE); - sysbus_init_mmio(sysbus, &phb->data_mem); - sysbus_mmio_map(sysbus, 2, BONITO_SPCICONFIG_BASE); + memory_region_add_subregion(host_mem, BONITO_SPCICONFIG_BASE, + &phb->data_mem); create_unimplemented_device("bonito", BONITO_REG_BASE, BONITO_REG_SIZE); memory_region_init_io(&s->iomem_ldma, OBJECT(s), &bonito_ldma_ops, s, "ldma", 0x100); - sysbus_init_mmio(sysbus, &s->iomem_ldma); - sysbus_mmio_map(sysbus, 3, 0x1fe00200); + memory_region_add_subregion(host_mem, 0x1fe00200, + &s->iomem_ldma); /* PCI copier */ memory_region_init_io(&s->iomem_cop, OBJECT(s), &bonito_cop_ops, s, "cop", 0x100); - sysbus_init_mmio(sysbus, &s->iomem_cop); - sysbus_mmio_map(sysbus, 4, 0x1fe00300); + memory_region_add_subregion(host_mem, 0x1fe00300, + &s->iomem_cop); create_unimplemented_device("ROMCS", BONITO_FLASH_BASE, 60 * MiB); /* Map PCI IO Space 0x1fd0 0000 - 0x1fd1 0000 */ memory_region_init_alias(&s->bonito_pciio, OBJECT(s), "isa_mmio", get_system_io(), 0, BONITO_PCIIO_SIZE); - sysbus_init_mmio(sysbus, &s->bonito_pciio); - sysbus_mmio_map(sysbus, 5, BONITO_PCIIO_BASE); + memory_region_add_subregion(host_mem, BONITO_PCIIO_BASE, + &s->bonito_pciio); /* add pci local io mapping */ memory_region_init_alias(&s->bonito_localio, OBJECT(s), "IOCS[0]", get_system_io(), 0, 256 * KiB); - sysbus_init_mmio(sysbus, &s->bonito_localio); - sysbus_mmio_map(sysbus, 6, BONITO_DEV_BASE); + memory_region_add_subregion(host_mem, BONITO_DEV_BASE, + &s->bonito_localio); create_unimplemented_device("IOCS[1]", BONITO_DEV_BASE + 1 * 256 * KiB, 256 * KiB); create_unimplemented_device("IOCS[2]", BONITO_DEV_BASE + 2 * 256 * KiB, @@ -719,7 +719,7 @@ static void bonito_pci_realize(PCIDevice *dev, Error **errp) memory_region_init_alias(pcimem_alias, NULL, "pci.mem.alias", &bs->pci_mem, 0, BONITO_PCIHI_SIZE); - memory_region_add_subregion(get_system_memory(), + memory_region_add_subregion(host_mem, BONITO_PCIHI_BASE, pcimem_alias); create_unimplemented_device("PCI_2", (hwaddr)BONITO_PCIHI_BASE + BONITO_PCIHI_SIZE, From patchwork Thu Oct 19 07:16:04 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: 735515 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1378188wro; Thu, 19 Oct 2023 00:18:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE/tggi8bXCNwUWhPa7YtlTHPHXaeBRsdO+t6iwHGhFxVnjJ7QFQJGjFu/qKWcE3G2GRR5i X-Received: by 2002:a05:6214:cca:b0:66d:20f5:23cb with SMTP id 10-20020a0562140cca00b0066d20f523cbmr1698705qvx.5.1697699918136; Thu, 19 Oct 2023 00:18:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699918; cv=none; d=google.com; s=arc-20160816; b=rhUmXYZFa3ifWTbVIUrl5F3l/cdm2ohy8swq3ATmzV8lxa3xAj4P0VR2Cq5r0HKBGW FcBDXLRMZbSIkvUYe8ItCVizXvSFtHQZaIDN1VS6C3JjVQlKS6IAm7c3bq0MmPaE9S4F f8uJnzTPRDnx3raeNg/KEFBNSH6dXa1gYLNkv9fsvfkK8AoTAlya6FI8UFwUqE7owzxz f9o3xoqkITucxSnYC5+XNIpayn1fCqqoR/HLqbB2zNsF4HfxwzYwxSUcJ44zFqKOXtUe Qeh33OZF8i0z7zlfcBzYc7ftkNkHBSpbAe8qfq/xFmRr6QzlK32YcOA6xfmAzpLQfDqc 0StA== 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=U89S9kSKuyZ/3CV61Or9NVPwfS9oQzSn+IyXDgGKbBI=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=Y0FBrQnWkLAefnHJcSYpfDLvdAriWpMISzQ2hIJfwNCbpIA8p2iz48FNaZSR17lqof xk19OKdE9L1tn3W+KJk82qJwLJ99izR/tzH75CZRwE3p211VtQgngt2IWWXEvt+waYmc 2POoVvbpYnSwKGR4iuHquVin9uax99N6GcGE+6UvwM0wQMh9yOzAvYmZk8xWjk1h/zEw nBnafeqHvGZALavyN+uV2cHn2cYreq7OQ2Q9uSvI+Y8AYc3Nm03mwHA2L9lTN7XwWQiL 66pdVLDJhfxMuorbwNqzjlYe4CaHtt8uluvsTTY5Yy+s3iNcDHF5V0R/8Rc4TzMn6EEq IlMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=lxAwCtZg; 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 oo25-20020a056214451900b0065ae2cc68f3si1203660qvb.387.2023.10.19.00.18.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:18:38 -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=lxAwCtZg; 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 1qtNIF-0006PC-96; Thu, 19 Oct 2023 03:18:11 -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 1qtNHW-0005bz-W3 for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:23 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNHV-0003HV-3J for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:22 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-32db188e254so3105832f8f.0 for ; Thu, 19 Oct 2023 00:17:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699839; x=1698304639; 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=U89S9kSKuyZ/3CV61Or9NVPwfS9oQzSn+IyXDgGKbBI=; b=lxAwCtZgYcfK3pY1DoFeS/QZcZxNGrAS1zjJY2p0FJ1W8ebdFmEoAE1/4gEpHYt9JM q1IAkUbTr+ATcY+/acJLhPNOW8cf7xygf4KpKxBp0M7DSUM/u3G7dJ2LqUKRSTpbTxFe tO8aA2bryf/+UOL6aF8y8fKuO4LzQGJu2nZPLuDRmU0KsKDCB8JSUQBg+xJ/KVjoFcte 3O3DVa0SRtxKzwkRih/9uEV4UzeIINs/q+7CRxWl5j/af2YO6BvDPPVxYtVKuIoqjJYB Urxk05P7l3pYFhWMmXUw+/Ot8pZmI3ciyeiyblfrfoztv86X9GIwyCwtPmj7E0TLfpNH H7OQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699839; x=1698304639; 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=U89S9kSKuyZ/3CV61Or9NVPwfS9oQzSn+IyXDgGKbBI=; b=v2iXbpPGInPSar5NxLHWpoxBhcf1saJqlR40/esx7fO9m3bDmgPfY+VxMS/IHKhz3A OlnyR8OtvhKTp7XJ++seHaaccs+aBnnkOb3QgzZaNbY/+fnxnBsMgjE6dx2+HxiAZjRK UPUfbA5dLqHE/qNfHSDX3PXs4YM6h333qF4mdoM0w81G4sjbCl0rtEpfTTGsiF9ARcJ4 M8oDcCCfTcCiN++MwsB3Ay7VD3cDpZt0udN1yr786SGgQhBgkVPh5JTfjf5WD+5tTT4w It0zySg9SZS8ikAh6nhNh9ADCgJal0fkvOsZFMu3nNyTNV1hjfFp1aJiJGEv0XGtoXs1 BD9A== X-Gm-Message-State: AOJu0YyQcNv6IlAT4WvHX0/6WS59F4WMlAUkxAy9nFbD9RoedZXZeBBY lnlxY5WyzRU6//fJaRB4DNXgzRnzOgm6RuCvzNHNIw== X-Received: by 2002:adf:f50d:0:b0:32d:b114:fc96 with SMTP id q13-20020adff50d000000b0032db114fc96mr790162wro.37.1697699839316; Thu, 19 Oct 2023 00:17:19 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id e11-20020adffd0b000000b0032dbf26e7aesm3754965wrr.65.2023.10.19.00.17.15 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:17:18 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 06/12] hw/acpi: Realize ACPI_GED sysbus device before accessing it Date: Thu, 19 Oct 2023 09:16:04 +0200 Message-ID: <20231019071611.98885-7-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=philmd@linaro.org; helo=mail-wr1-x42d.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 sysbus_mmio_map() should not be called on unrealized device. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Reviewed-by: Michael S. Tsirkin --- hw/arm/virt.c | 3 +-- hw/i386/microvm.c | 2 +- hw/loongarch/virt.c | 2 +- 3 files changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 15e74249f9..02c7a7ff3c 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -647,13 +647,12 @@ static inline DeviceState *create_acpi_ged(VirtMachineState *vms) dev = qdev_new(TYPE_ACPI_GED); qdev_prop_set_uint32(dev, "ged-event", event); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_ACPI_GED].base); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, vms->memmap[VIRT_PCDIMM_ACPI].base); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(vms->gic, irq)); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - return dev; } diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c index b9c93039e2..ca55aecc3b 100644 --- a/hw/i386/microvm.c +++ b/hw/i386/microvm.c @@ -206,12 +206,12 @@ static void microvm_devices_init(MicrovmMachineState *mms) if (x86_machine_is_acpi_enabled(x86ms)) { DeviceState *dev = qdev_new(TYPE_ACPI_GED); qdev_prop_set_uint32(dev, "ged-event", ACPI_GED_PWR_DOWN_EVT); + sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal); sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, GED_MMIO_BASE); /* sysbus_mmio_map(SYS_BUS_DEVICE(dev), 1, GED_MMIO_BASE_MEMHP); */ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 2, GED_MMIO_BASE_REGS); sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, x86ms->gsi[GED_MMIO_IRQ]); - sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal); x86ms->acpi_dev = HOTPLUG_HANDLER(dev); } diff --git a/hw/loongarch/virt.c b/hw/loongarch/virt.c index 2952fe452e..4b7dc67a2d 100644 --- a/hw/loongarch/virt.c +++ b/hw/loongarch/virt.c @@ -412,6 +412,7 @@ static DeviceState *create_acpi_ged(DeviceState *pch_pic, LoongArchMachineState } dev = qdev_new(TYPE_ACPI_GED); qdev_prop_set_uint32(dev, "ged-event", event); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); /* ged event */ sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, VIRT_GED_EVT_ADDR); @@ -422,7 +423,6 @@ static DeviceState *create_acpi_ged(DeviceState *pch_pic, LoongArchMachineState sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(pch_pic, VIRT_SCI_IRQ - VIRT_GSI_BASE)); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); return dev; } From patchwork Thu Oct 19 07:16:05 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: 735526 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1378546wro; Thu, 19 Oct 2023 00:19:49 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEnLkAWmIdtnMta3iuzETV1Ukj7h2tcBfI8+bBNHIml2wnjFNpjYerp14ANqeZFUsPyAQn9 X-Received: by 2002:a05:6214:2385:b0:65d:6a5:1a3f with SMTP id fw5-20020a056214238500b0065d06a51a3fmr1486179qvb.43.1697699989618; Thu, 19 Oct 2023 00:19:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699989; cv=none; d=google.com; s=arc-20160816; b=w/OeoMRZxh9WsmnG6xN0SpnpiQl8vAvrMHmGhqAjOi6uITArFNs+iEMDt0UU6WEvIt lOS/CEbGNoDewWPuN5nvRMAd83G9TKceNp5y8UFu8l5W6IhnCtDlS3B/DY+H5df3luVL rWVRHt66TYHUbbCVi1Mp6aWwlKOYCDTudZ1Wus6uE2FnWFlnosbwOTjKGVrMVJgHfweN 5R1pluauW4e2Uo772IytfdkZ3FQ5lVlOASEUy+/zYuyTZg0d3FgOZg4zq54fAfjhcAb0 bu4nHi5ZJiRzJT1Aw2i9HUx2JHJyVCBrhftIRyrb6iXPC+NQWGQ4ssa2AMPcJppVgp9v UVnw== 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=fHmBGLBbzcVN7N0Yqtsp1sIeIJxOxMcSEmxWkKW9TOQ=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=ok2/KA+g/TFnrMyRHCd3YNQjoBZPRneTXcq1V6d86Qqi3nqPIg1Ev5FUcBvtH7U8MS LnOUL2XJNyM7OKYcehSLuGkkwxfYVCP9iGzOqVq95EgqhYnf14SCwf8dypv/WySQxJmH 8B2rNPTPjeoJ2V5nckvAwz8YpFyjcprTi4+UPfzbWNJWUSpggXZ4sltP4t8EX3Pwr/kq YqMxSg1fE3Kt1WAGvEBbroVA6jtfxibvSzQvftZYMRJShVtJ6DR4U7KOcET+9cQKSgnw aDWszSn/IgbLYCgOgkCS5CV5lHdadAo5flwZSzvH41fhUhkGkH52LUQm4ntqt3458N/h KVYQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=MD9Ap+wC; 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 dn15-20020a056214094f00b0066d04196c29si1147394qvb.141.2023.10.19.00.19.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:19:49 -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=MD9Ap+wC; 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 1qtNIu-0007Sl-2O; Thu, 19 Oct 2023 03:18:48 -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 1qtNHj-0005vP-AW for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:37 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNHg-0003J5-Bh for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:34 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-40839652b97so15423025e9.3 for ; Thu, 19 Oct 2023 00:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699850; x=1698304650; 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=fHmBGLBbzcVN7N0Yqtsp1sIeIJxOxMcSEmxWkKW9TOQ=; b=MD9Ap+wCuXyISoKoAZvrgqqrD5fv6eebi5aVPiOYU/wGM2yvcJ+Z8+9Qqi6iEWtx5H WomqtbfuDOQJvogQoA6wCc/DXIjdNr/NKrpOJ6HSfidwWVIcqa0SLjWzO0xiK5iGAUFh /VAV0ioefxIMy8UZ5+clEKUbqEBp1kOlsrWgXlmOujRsxJiR9cZ3XnA4oTCKKAiM+tdJ +3qu7/+VdGVIFtKeHO/XSOGjDsQMF8l4PUM//LB+4sPLMr8Quu8OFxKpbRvvYh3Q9eQO V1zVeosjJfFu/hHep0st1QsRCt+er+WdqLrAbweigKAmTePrvDcmnqPEG4p1KD+1ObOg jdcQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699850; x=1698304650; 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=fHmBGLBbzcVN7N0Yqtsp1sIeIJxOxMcSEmxWkKW9TOQ=; b=OOik9K68wm5eJdtRuF0W63CsbU3BVeW12iB/v3kE1+broWNEn7F34iA3sy825YFhsU YiUu2qnRawlAAW9LlTGvOl19KVqm/Pg8wuahZ54ocXqUgrbPN7Jv6aEM4s5aa2qqlNXE /qCCsDUvBmb1GhZZPYsjZx/V6otInjIKaypdf9eKfSARKkazi+t8L7rCtOCtNtSsgoJr 2cap0iiFIwKDP9koQYlIf2NFdVYoVvv87G7HSYGiFuVnrfJwYNKXGYqXsNSSmVLO3fQ9 zN4PV/qZGJdk5IN6zfBLvtebMZ1iDOeAIi7GEwQU0JGZRXnOjZY9p+dzXx1jkvRkz+Wu M8sw== X-Gm-Message-State: AOJu0YzMEbYQd38bROlBcHJXlZNrRt+JnlLZjzs1Bofq0/3nBONl8vOO 2h6HmhKdFWRlEPQqDQkQyqZWXMn4HtqImCgYpMj2oQ== X-Received: by 2002:adf:fe8f:0:b0:32d:ba78:d60e with SMTP id l15-20020adffe8f000000b0032dba78d60emr849091wrr.65.1697699849994; Thu, 19 Oct 2023 00:17:29 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id f5-20020a5d50c5000000b003140f47224csm3796543wrt.15.2023.10.19.00.17.25 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:17:29 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 07/12] hw/arm/virt: Realize ARM_GICV2M sysbus device before accessing it Date: Thu, 19 Oct 2023 09:16:05 +0200 Message-ID: <20231019071611.98885-8-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=philmd@linaro.org; helo=mail-wm1-x336.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 sysbus_mmio_map() should not be called on unrealized device. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- hw/arm/virt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 02c7a7ff3c..5b08a98f07 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -690,10 +690,10 @@ static void create_v2m(VirtMachineState *vms) DeviceState *dev; dev = qdev_new("arm-gicv2m"); - sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_GIC_V2M].base); qdev_prop_set_uint32(dev, "base-spi", irq); qdev_prop_set_uint32(dev, "num-spi", NUM_GICV2M_SPIS); sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_GIC_V2M].base); for (i = 0; i < NUM_GICV2M_SPIS; i++) { sysbus_connect_irq(SYS_BUS_DEVICE(dev), i, From patchwork Thu Oct 19 07:16:06 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: 735524 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1378489wro; Thu, 19 Oct 2023 00:19:39 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqKf/DFZPxhhRj6Rbn0ir7dMLIFXn7IxFuWctjkveffmWgKjUufq/I3iUrBImigCJ8aX2k X-Received: by 2002:a05:620a:9d0:b0:76c:d5ac:66d7 with SMTP id y16-20020a05620a09d000b0076cd5ac66d7mr1206274qky.43.1697699979149; Thu, 19 Oct 2023 00:19:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699979; cv=none; d=google.com; s=arc-20160816; b=vkRT9/6ffiGyJsATpy2FhHEeFXFOU9MQGc57a2aWC9ovp3KmHpdqK+fPg5A7ZyUXhi aR2qt/vPvh3KXQt1ptAhaKmb3wCJJbh2UOEn4dTuprS+tmfK+l7Re67+vrjyw2SDz2O3 qy8NJc6SNIq31ZtwR2BDPn5S0FVckOYVlAfTLzEyVJq2Ze+9/RCzfmW88vDJwMHw4X+a 4V1fOfcp9cgHSTmJoLZWfvZtrvAHKfLErseFoeYZdHuiJPWSD8J8JXPN8MCIKB1MN6Q9 BgFhMPxVCGVzIkuqQp/Jbs5Ln5kY03X5QkY+rFSpkgftcKUzRpbv5ZZxb2g+G9HgCcUZ 823g== 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=+HC0X9fTzvHDBaGKX3SssvMlymhei2jKRNiniE4txSs=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=JJiaEhkSczbYcXYyzrvFDE/uzCWcrhTje/tGUpxONdBYTWQPjINfo5TaRwJ7w1nhYj o2asksVKBBio4PfBhQEoeyM/6Mk1c/xiELxbmOP4vfVZo4mIGx15DwYnwHb8qACjjtoQ yRNXelDp6Ze6gBAmEIAOz38rp1s+YanKtB+tAWqjRP7NfDtyLNkTkH5bFNfrCajleDrt /aEH971d61zrKfNR0nHUa1BOJpEpFPnaCaDYTwDZdfo42GaZiGfqM7b0kAheI/dWchAK WGCXJSAk5hGWArif9L/yqxX8Zi1LLh8ckK1y0imE0+6N2+c2oIfiTQ0G+8ek8yUtngR0 clvw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LmmhiZIP; 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 j15-20020a05620a288f00b0077762436ea5si1148020qkp.758.2023.10.19.00.19.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:19:39 -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=LmmhiZIP; 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 1qtNIs-00079L-Oc; Thu, 19 Oct 2023 03:18: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 1qtNHs-0005yt-VY for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:47 -0400 Received: from mail-wr1-x42f.google.com ([2a00:1450:4864:20::42f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNHq-0003KD-Fl for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:44 -0400 Received: by mail-wr1-x42f.google.com with SMTP id ffacd0b85a97d-32d834ec222so6642494f8f.0 for ; Thu, 19 Oct 2023 00:17:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699859; x=1698304659; 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=+HC0X9fTzvHDBaGKX3SssvMlymhei2jKRNiniE4txSs=; b=LmmhiZIP3SB4h9gPr9iOZ3/9T5jtEatvnLI7nUOux5gKefeXUfCo99zFl2mvHToNpe yc77PjqinmEvFBa6dJKVXGAwuVMfp1++KhGwJX1m/Repkz7ZElgVLPw1O4MKwYiuHzLH KGjhb+SsKhJE0lfl0orp5ZqBhQEWmSOSJn1RDItjg6S1eSuU1FNr1GCGEyvL9HIxLw5Z QU4o+oEg6+2mNEmtyUoNV1bDWqVdV6J7HGcNVvuTB/zOZbVP5a1exv05x13vgGHZ/fnH kcWERlnTxkVwY/WFcmLRiWl7jcuOdMqkeTLBbQt9fp2UAH+Nk2PPZFDRd/yuUU3eQqFr pBNQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699859; x=1698304659; 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=+HC0X9fTzvHDBaGKX3SssvMlymhei2jKRNiniE4txSs=; b=iFNhJKFF7rrKd1yps5xIFIWta9dePil7l9HG9aQQWnPCpfkC4DQWxL4avlSqKbTluq akrnC0km6WgsjY9TFqFNDtPCpt0ih6+arITsMoSVBbCbItbywarmO3BSv4CV6dwbBf7z TPhSzHGmIoLnpDMkmsiauYBllNpSwcdy2De02xn+E0IKv/yi+9u7sNxVQxntgR63RQLX L/QS8SDtQ/4OMHgUElo4MOa5a04DUB33s3zAXOCdaKFtnLag6h28EyBTymx8yXIyfOTz HBzSEdfkzja7eP09VSFmj6FbLDAjGOaLrauGqdemgL06YeLJCu1XNCE+Qps2A60jfwv1 LC+Q== X-Gm-Message-State: AOJu0YyN8gg2vv1aj/9O8O/+/uR8eeZVCIr+MeXGwRMjYtl3olpceIE2 9vO9mRPQ+k5yAllZg4Give/dOV1Mf/0wY1aa3LFvDg== X-Received: by 2002:adf:ed0e:0:b0:327:e073:d5fe with SMTP id a14-20020adfed0e000000b00327e073d5femr854081wro.38.1697699859542; Thu, 19 Oct 2023 00:17:39 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id a15-20020a056000100f00b0032d9337e7d1sm3775457wrx.11.2023.10.19.00.17.35 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:17:39 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 08/12] hw/isa: Realize ISA BUS sysbus device before accessing it Date: Thu, 19 Oct 2023 09:16:06 +0200 Message-ID: <20231019071611.98885-9-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::42f; envelope-from=philmd@linaro.org; helo=mail-wr1-x42f.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 qbus_new() should not be called on unrealized device. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Michael S. Tsirkin --- hw/isa/isa-bus.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/isa/isa-bus.c b/hw/isa/isa-bus.c index a289eccfb1..f1e0f14007 100644 --- a/hw/isa/isa-bus.c +++ b/hw/isa/isa-bus.c @@ -52,18 +52,25 @@ static const TypeInfo isa_bus_info = { ISABus *isa_bus_new(DeviceState *dev, MemoryRegion* address_space, MemoryRegion *address_space_io, Error **errp) { + DeviceState *bridge = NULL; + if (isabus) { error_setg(errp, "Can't create a second ISA bus"); return NULL; } if (!dev) { - dev = qdev_new("isabus-bridge"); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + bridge = qdev_new("isabus-bridge"); + dev = bridge; } isabus = ISA_BUS(qbus_new(TYPE_ISA_BUS, dev, NULL)); isabus->address_space = address_space; isabus->address_space_io = address_space_io; + + if (bridge) { + sysbus_realize_and_unref(SYS_BUS_DEVICE(bridge), &error_fatal); + } + return isabus; } From patchwork Thu Oct 19 07:16:07 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: 735521 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1378433wro; Thu, 19 Oct 2023 00:19:28 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGw/NKCd5dS1BgZtv9LyotNrUjO6FM6Sn7yanQ/B18IaH1xdSK2smnqrrhK0H8UcEPO90Y0 X-Received: by 2002:a05:620a:c93:b0:777:258e:f7a5 with SMTP id q19-20020a05620a0c9300b00777258ef7a5mr1251291qki.23.1697699968668; Thu, 19 Oct 2023 00:19:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699968; cv=none; d=google.com; s=arc-20160816; b=0hiYQXBpJlzvt9ftCtQsy8mkvCSHlLD2/PYnbaC4MdmFGiO+Z6m7c6I1IrBSfn/+4r kcex9dvPh78hOwzpPxLxFAj+yvgKJoKNBhEeJXPP9fN597VD8Lhwwu82uciUsnZGPGk8 wZiBc1Lhy+9DXHXri7MRUSNkbMkuyVKVVlyjPpK44YS9EMGVHypppLAZN/gFZzmQbldh v5VOC9WIWQLSwW8dMduEa0ENHHmjd9A6BZ6lJvcPML2v+xRFkD0DGFZLCApyxd+J+3VA 9N2nFf48haxvkU0+eXCpy/kstWFOLgiMUAA68wQejz+V+2r+mHYqPgozvEmrDTVcZfnA f62g== 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=tjy4VY50gso0Sthhkiy2414qiUoINUMpVZWnAj6oAWs=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=j8Xv4/XCXutCwgK62X5bujP3/iGXl+J7m/yfXdIRQez2Ybeb12yGiXFM0BGMp/+gze 2bSpYth+xfG4b/HHD+zWY8xg7J4LCFyatMpeVq8vKUZePtktMAj9ExUw63qA2lPeLTCj o2GuHSQbcsGm9S8/hJvsvurDs+d+/0g9SWNY2mTYzXZeYOOgllerRekeYm0Vz5fqgxf/ GPQkXQjhuTQJJWv+CoNCixfxHQoScYSs8SFtJ6uFvApWK7KsNmIy+SJE/CyxSI+JVo4v VrdRJaLeQx6OfUDiWBOIDgsFrjhaR3fzPjE/yFElPP8uszBxXXuZrfwA1MQ7bFiPOJuZ PiPA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wYp3ovF0; 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 vu7-20020a05620a560700b0077428fc4619si1123301qkn.640.2023.10.19.00.19.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:19:28 -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=wYp3ovF0; 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 1qtNIw-0007pT-2M; Thu, 19 Oct 2023 03:18:50 -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 1qtNI3-0006Ce-Vf for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:58 -0400 Received: from mail-lj1-x230.google.com ([2a00:1450:4864:20::230]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNI1-0003LL-HN for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:17:55 -0400 Received: by mail-lj1-x230.google.com with SMTP id 38308e7fff4ca-2c503da4fd6so88911981fa.1 for ; Thu, 19 Oct 2023 00:17:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699871; x=1698304671; 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=tjy4VY50gso0Sthhkiy2414qiUoINUMpVZWnAj6oAWs=; b=wYp3ovF097Nwnp2LC2J5uFnGlBk+1uRWZlFJkFCx4RMAMiXC3HNxfLnrtP8ci5hFAd GXL+It4pxeKlGD3o5b/FVoZ1+RMoKLI3/Uirhz3sbHW4oYsYPyLi/GTJysGHBSmkJzFk gyKrMWg73i5bHnv/+tKzMzEteUkMJKKvYJngqyx0QcLsVsWKHAKzjguPY7bu25LddIeg qytnhG3sUaVuV5Ri4pSro5mniaUVjm0kxsqS5Lnn5frTwFmwvwlpJwKkmRJmbkL2if/S aFfucJkv/+S22Vb+ut8QyHXeO0UrcnNPNRgY8OJvtsBO2xRbWJswwqT95cu8Q4RASKkw H0Pg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699871; x=1698304671; 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=tjy4VY50gso0Sthhkiy2414qiUoINUMpVZWnAj6oAWs=; b=cO7nRENxuU1Z96mvjeYgacou7r/SmO1JINFxMKpJGGptqeTuutf6UL5PdN9E2a0UU1 7zrTSQVYDe4O+irtj0aN5dqAd9Um4lCzTwb7tA08GAXVNDoGuQcVz2Ut0UVwQqqwJp31 FKWn5i1NwjF+VonZG42JImgRUBRKlzs4eLeKwnLh59rk7a8RJa64SqaqhZI9jCJKHHKp g8mUtm0MJxpk+6GKOsP4INByGK16lAIcQPbdi3Y/Ce5ensJ0d+oz6TM2edRekxKYk1EF Ck5acpK8re03SLnQbHveRB1xOax/GZW8GWD6mGlTa3/4Y3tlHdamTIhUO9DVvuaiLVmJ WPDw== X-Gm-Message-State: AOJu0YwQNCD0hLhEmL37yyKf4p/nGcgKHnxFcIsAqBbPBiXwhNsslCgX fRIfZQnNaVd8Icsksw++NTMouWRI8GtTgm4ETNw69Q== X-Received: by 2002:a19:5f57:0:b0:502:fdca:2eab with SMTP id a23-20020a195f57000000b00502fdca2eabmr812219lfj.37.1697699870247; Thu, 19 Oct 2023 00:17:50 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id l13-20020a5d480d000000b0032d9523de65sm3741200wrq.48.2023.10.19.00.17.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:17:49 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 09/12] hw/s390x/css-bridge: Realize sysbus device before accessing it Date: Thu, 19 Oct 2023 09:16:07 +0200 Message-ID: <20231019071611.98885-10-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::230; envelope-from=philmd@linaro.org; helo=mail-lj1-x230.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 qbus_new() should not be called on unrealized device. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Reviewed-by: Eric Farman --- hw/s390x/css-bridge.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/hw/s390x/css-bridge.c b/hw/s390x/css-bridge.c index 4017081d49..15d26efc95 100644 --- a/hw/s390x/css-bridge.c +++ b/hw/s390x/css-bridge.c @@ -95,7 +95,6 @@ static const TypeInfo virtual_css_bus_info = { VirtualCssBus *virtual_css_bus_init(void) { - VirtualCssBus *cbus; BusState *bus; DeviceState *dev; @@ -103,19 +102,19 @@ VirtualCssBus *virtual_css_bus_init(void) dev = qdev_new(TYPE_VIRTUAL_CSS_BRIDGE); object_property_add_child(qdev_get_machine(), TYPE_VIRTUAL_CSS_BRIDGE, OBJECT(dev)); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); /* Create bus on bridge device */ bus = qbus_new(TYPE_VIRTUAL_CSS_BUS, dev, "virtual-css"); - cbus = VIRTUAL_CSS_BUS(bus); /* Enable hotplugging */ qbus_set_hotplug_handler(bus, OBJECT(dev)); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + css_register_io_adapters(CSS_IO_ADAPTER_VIRTIO, true, false, 0, &error_abort); - return cbus; + return VIRTUAL_CSS_BUS(bus); } /***************** Virtual-css Bus Bridge Device ********************/ From patchwork Thu Oct 19 07:16:08 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: 735523 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1378460wro; Thu, 19 Oct 2023 00:19:35 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHmqXo1SGPXWX5TGfOgaPMKMlb8PFrllaWsRk3g9R/YfqQ4rNEnoyn8AqDAS+FvbNtw2wIx X-Received: by 2002:a05:6214:2aa6:b0:66d:38e3:4ff7 with SMTP id js6-20020a0562142aa600b0066d38e34ff7mr1766303qvb.10.1697699975346; Thu, 19 Oct 2023 00:19:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699975; cv=none; d=google.com; s=arc-20160816; b=hR3vG47uilvIYCftl8zOPS2Y7R13iV40k+XKLmA86pJj4weX2QUX2uZ293nc9pYxeD pd/EC4GGBVhkU+k4Jjwmo064LxfZ/9IQIPdTnRZjrDwsjgoMNmkZJ5SucQeHFtKEP2cI vuDQOcO822Zn/2Db1qj2133Q42ytCSa+Yj+GEHbl9GVzrIhjV42RRdde04YuFMbU7ir2 0NnGZCzA6W22mIANZVvY0NBh2VTfBztKU8PeDq0s0wHjb04wMTwO56VYkLyuEvvQMjv3 29Vj9QmIJ+s9AdXZ6Vk2GczcvmgJIjxdwTfHhtyEClWYAcNc08/Beerk2QAY4hSeTAAc /Fuw== 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=4aBA8vBsW5oLOBkcrZ5u16EetaBIuQ3o+kIaSqCZQsA=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=pJBZRLh6b4cIT/iy5WqYZ2DoOMUEUr004q6xskMr3ZzZKDqQq8kFlNcNpwEeVIVqmX dt4sgxN6ORcfY5uRErhq+iiGK9WVbY52FtbDo1XPn1wQ316397K7UivhJlABODdD6gzR 0jEp1puaDKUiymlRcDRLiUQ0yQk3U1jkoFPPlSQ8l0XFaxRihU6+EHavndEt5tG9e1Rf jXQmXXW+V0qn+ep7V4KUgEG1Q6HnIXGpP57n3OJcQr1MHTnHpvTxQN23Cntk7IAwSN1Z 9CukrwSbkLYOe/NLAyQVlrWobb1iq4VycvnOMHr5iCVdwrdN5EzSTiAxllXd/B7zSD0f bVnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T9M48cD9; 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 gv7-20020a056214262700b0066d03d2058asi1230961qvb.430.2023.10.19.00.19.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:19:35 -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=T9M48cD9; 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 1qtNIt-0007Ii-A9; Thu, 19 Oct 2023 03:18:47 -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 1qtNIC-0006Up-W1 for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:18:06 -0400 Received: from mail-wm1-x32e.google.com ([2a00:1450:4864:20::32e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNIA-0003Zj-CT for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:18:04 -0400 Received: by mail-wm1-x32e.google.com with SMTP id 5b1f17b1804b1-4084b0223ccso460265e9.2 for ; Thu, 19 Oct 2023 00:18:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699880; x=1698304680; 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=4aBA8vBsW5oLOBkcrZ5u16EetaBIuQ3o+kIaSqCZQsA=; b=T9M48cD9JiFxkMgu8cmwQRS6cx2LxmKubgnGyTIh/91/SsJIqG2i+M4fI6mXejGovU TUzrZjYpTTTM2a42ZeOoEqhV139aiC6n0eddNKsDmbuySh5hn92W8cf2xgIL2YpIMMMT CJCLXQMw4NgYoTr+G4XxLP+yMg6+bqqUqJzB+WzQiq2csshB8AYz28syQ0CqJeoJhH/k Er4twCO2bh7aDfsBdKk5U9ansovplN7a2EMJIWveLTP8rkasajbOtHw5hnLLHuREPiLw zuZs1k72OTc30QgP6HGgV5hEYHzcpiEs5Jbp2uK6SzW18niXL+CqICTwiIK1srYNYUf1 TYDw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699880; x=1698304680; 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=4aBA8vBsW5oLOBkcrZ5u16EetaBIuQ3o+kIaSqCZQsA=; b=oOyybOCI4BgCYRXA5ZMRTy9Rx5COe8Ng3X6AMMR3WmiZdV9GoX2neoHXTE+TrpeeF5 uaVZTH0InuJ/y3eXTOSvTf3kP/Qn4Hnz7VO81kyxx8ccqrbkWIB297E2WY08SmUtWJY8 0YMXuiD+xyjxbZm9X1mFOhPxPA/9xW9NM1rhwXXQdU7VQ+NPNVD5eJjLH8Yylq90Zr/O vU//3qnGZKAJI/w0lAvXV7VlPDlXRJ9T+Uqnv2dMQMhUpWspllX4a2LzR/mARFHh6eN2 XC3lOnVTH2sbiQpqQ20mIqChZPw+q6OK57lI7NJjjofwHnGVs6P07RWMI2eGInz0IkgZ vb4g== X-Gm-Message-State: AOJu0YyefLiByIanzMueCPtjTi5Qmn37RX8jIWxZgWsVI+/IeQGqmmWq OTUSMqRxr5rQscVNIhAeB/q/27UZcIcws7+r8ckyMQ== X-Received: by 2002:a05:600c:474b:b0:408:3d91:8251 with SMTP id w11-20020a05600c474b00b004083d918251mr988772wmo.5.1697699880555; Thu, 19 Oct 2023 00:18:00 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id 1-20020a05600c028100b004077219aed5sm3574562wmk.6.2023.10.19.00.17.56 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:18:00 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 10/12] hw/qdev: Ensure parent device is not realized before adding bus Date: Thu, 19 Oct 2023 09:16:08 +0200 Message-ID: <20231019071611.98885-11-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32e; envelope-from=philmd@linaro.org; helo=mail-wm1-x32e.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 qbus_new() should not be called on realized device. Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth --- hw/core/bus.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/core/bus.c b/hw/core/bus.c index c7831b5293..c92d07667b 100644 --- a/hw/core/bus.c +++ b/hw/core/bus.c @@ -21,6 +21,7 @@ #include "hw/qdev-properties.h" #include "qemu/ctype.h" #include "qemu/module.h" +#include "qemu/error-report.h" #include "qapi/error.h" void qbus_set_hotplug_handler(BusState *bus, Object *handler) @@ -163,6 +164,12 @@ BusState *qbus_new(const char *typename, DeviceState *parent, const char *name) { BusState *bus; + if (parent->realized) { + error_report("qbus_new(type:%s parent:%s, name:%s) but parent realized", + typename, object_get_typename(OBJECT(parent)), name); + abort(); + } + bus = BUS(object_new(typename)); qbus_init_internal(bus, parent, name); From patchwork Thu Oct 19 07:16:09 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: 735522 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1378441wro; Thu, 19 Oct 2023 00:19:30 -0700 (PDT) X-Google-Smtp-Source: AGHT+IE2Itr9HZWR7vLZ5Q3zgh1ca8nnYZFRsPJXPrjKFDpSdREIUfsuD1+o5yOefD1y2kAc/gWn X-Received: by 2002:ac8:5792:0:b0:411:616a:4bde with SMTP id v18-20020ac85792000000b00411616a4bdemr1687583qta.18.1697699969854; Thu, 19 Oct 2023 00:19:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699969; cv=none; d=google.com; s=arc-20160816; b=AYk5M1gB6Cd46XZtABn4gUZyb/4NIRvrT4712cToCEM1SszgwS3yr1c5CfMQyLS1ac HfiFtMM6qpMUuEuMK9MXSRaO/PzKimZn9X4Zx1KjnvZaLU/MPXqcOqEP3mtReOxj793O LbSvYJNYtMAkhR4x7QDyRkqpOiLf8OPnX6wdy0vex5mDzbyscGtLQ3d/kQ5Ckgh9QANh LUREW3Chbgj5vQwJCg5WGM+YA9NKRtDmSrlJrOSeKOdUCVnUuHyV08XyjQZGaBFoMjYn vdjn0w1sy0qkOxQCh3vjSFt0zqVEiPmnwghQ5yyW/rLbshu+Ia6ADkZ9fzazCJgaAQp9 mW0g== 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=FOncUjOO3yMCwvbdhDakCobkCJgYZJVQZiN+TzHHG2s=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=DtX/r4oHbECzq0KphHQlJ0Jz4bu/gK7TZuWwafHclyVzq7PC59fqQrXWQ0Bi9p537B mo0fUQf4nMix/f/V8HvpWpyNcKpFBdcP03SOftLeES8LheT136CcTM2i+9RlMKBgLIZW k6pX2I0qp7J9v7o60Ap/R6UZ422FYUlJqFqxMuRdpzxiODUbpIGqDpBT/Bshmv6CaabF nWEDG6m0ayzHdMxTk0Ukjtcg1zkoKQTJ4IrJZh9iqPgx12n3NsSJrSLVXDyMHdcR95vH hbbZFhzy/WvdGc+7ze+Xgg0aRgOIDrSJZhaoPEBjbs0FNiaNJUgst0jptxwfzjaDWLj1 ZdiQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=hbaqSxf7; 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 q3-20020a05622a030300b0041957318f5bsi1137090qtw.275.2023.10.19.00.19.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:19:29 -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=hbaqSxf7; 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 1qtNIx-00083j-Pe; Thu, 19 Oct 2023 03:18:51 -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 1qtNIN-0006aV-B2 for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:18:22 -0400 Received: from mail-lf1-x134.google.com ([2a00:1450:4864:20::134]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNIL-0003bV-A1 for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:18:15 -0400 Received: by mail-lf1-x134.google.com with SMTP id 2adb3069b0e04-507a29c7eefso6972333e87.1 for ; Thu, 19 Oct 2023 00:18:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699891; x=1698304691; 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=FOncUjOO3yMCwvbdhDakCobkCJgYZJVQZiN+TzHHG2s=; b=hbaqSxf7DxiBTz8M0isdUZq2zoH4UJ4v2ufU/jB/idSIidRMSVez5eFDQX9CZ87EIR wiGQs1QYoxRYt6CN6gno+SsmBAolfmnW9Xm6gOhu9pvLj6tKsxk1H/ZUQO0UJaxXwN1y WL40oyLBJhFI2DLlSuJT0uDcXV1OrMG2NH44FgjUKlHmlj1kB+WWWCficl0AQmtZwd9R 3jj94LFrygDDBdulRwf65xAorfHU/N/kgugCBxGSooVz+AyGhHR6UhLgrKh+768CR8pL 0VmaHBRurVEG/51gf2yxZWxF2aeokl65M21jUNWlMz2j1M2y5FCnXamxV7dUqlTMca5T suow== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699891; x=1698304691; 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=FOncUjOO3yMCwvbdhDakCobkCJgYZJVQZiN+TzHHG2s=; b=cuURaCpbA6bn52BVMu8h+ZDoA6BPLli6Rf68sm6muQrudjg2XBhagWFfMHcds5D2k8 0Cl5mCGPzKErGmxFPGutsDCrd1mmkDfmkIdBJMUgtIN62CMqSdAeSfRQO13YRY/PhXvf FSAg8ex9JJLBXuHwioWVjnNLRWTpAyaa924CHuFjVuhTO3tgvdITcDVbvVRusuxyV/7d NtBaMN4HYhRAcp84DrS9WdkhqC29RkoPNZODAz3RmETmFqRvM4m/uqILxfpBCdCMy0H/ Bmj08dd/EyCaoLqYaPnFOvZPpWdxMKo+u0q+kRnyCByeDZRN0VILIBd3AiQOwelDlsde xGCQ== X-Gm-Message-State: AOJu0YyKSBzO/1qKLYpV9GywDJlWVq32yt3KojkQCDNGisAZlnBfpOXg kdtGZ99DkiKQxn+rl3sTUEtqxVb4AvEuVDRpd8LSGg== X-Received: by 2002:a19:f013:0:b0:4ff:7046:984a with SMTP id p19-20020a19f013000000b004ff7046984amr730479lfc.7.1697699891125; Thu, 19 Oct 2023 00:18:11 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id y18-20020a5d4712000000b0031984b370f2sm3765991wrq.47.2023.10.19.00.18.06 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:18:10 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 11/12] hw/sysbus: Ensure device is not realized before adding MMIO region Date: Thu, 19 Oct 2023 09:16:09 +0200 Message-ID: <20231019071611.98885-12-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::134; envelope-from=philmd@linaro.org; helo=mail-lf1-x134.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 sysbus_init_mmio() should not be called on realized device. Reviewed-by: Thomas Huth Signed-off-by: Philippe Mathieu-Daudé --- hw/core/sysbus.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 35f902b582..8f53cb926b 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -20,6 +20,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" #include "qemu/module.h" +#include "qemu/error-report.h" #include "hw/sysbus.h" #include "monitor/monitor.h" #include "exec/address-spaces.h" @@ -192,6 +193,11 @@ void sysbus_init_mmio(SysBusDevice *dev, MemoryRegion *memory) int n; assert(dev->num_mmio < QDEV_MAX_MMIO); + if (DEVICE(dev)->realized) { + error_report("sysbus_init_mmio(type:%s) but object is realized", + object_get_typename(OBJECT(dev))); + abort(); + } n = dev->num_mmio++; dev->mmio[n].addr = -1; dev->mmio[n].memory = memory; From patchwork Thu Oct 19 07:16:10 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: 735520 Delivered-To: patch@linaro.org Received: by 2002:adf:f0cd:0:b0:32d:baff:b0ca with SMTP id x13csp1378414wro; Thu, 19 Oct 2023 00:19:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG7LS7TTPD9NXDf6sIFRsn7d5SJfNM1PN3DI2SNSo02EkWeE/+VryrI2DDY6T0BSXFQmA4a X-Received: by 2002:a05:6214:d0b:b0:66d:3165:f978 with SMTP id 11-20020a0562140d0b00b0066d3165f978mr1752966qvh.6.1697699964235; Thu, 19 Oct 2023 00:19:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697699964; cv=none; d=google.com; s=arc-20160816; b=lR9b7H+ojbIw+qhHXztL0wZAY2TLnt/KzUqtEbhiHh2sKaOy+k2eRunHbUdmQvhSQh O3yoOVBMxUDJ653JJfzd7a2Era9vY21cetWrhwh9mKkTlPXH93uxdgJ7qmEbslZQfFok Ztxg/eVsVESvSY/D2upHHOON58z2QffzIPGolhS6SGMXc2SeP9BvqI66AGTNaDS5lxYB Gw+vvig/UldhSm6pEUCCJPqDqH23BZtYYzTWlss2vjM4laEleoKU3yGg2VP4S0amjuQ6 ElfbbjHzIOAD8+B9ltwxFA047+Mcn5edthabKPniZ54vvubnxMV1gGs7FkOW6PdcerCJ 4Qsw== 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=/IJC5PGwxG+6/kpGRlXi5TZPdjjr+EIEQtYpUJNBvhI=; fh=6jYKO1R8PvzdW4tN+W/XYlQifBf+lht0eG+bQc5OUAg=; b=iSlBDw9h5LXp9uDyRJukSt8nwdV4d8EpiHfo1jltRuAfKmLXU1bPXfRh5Kz720n0hP ut/7+p8Zwy1qKlw9X8ToXKIOtiBgQQV5iTY+njwKVdYKxF6fydAxEePChfzoV9lKIv+3 +ziXwcHAcGBU90fxASgWmAdj6gP7Y46fBZKdU4Bwdk3JOXlFKzzwewR5m54Q2SLg5xO3 auU6Dn4KgW3bMatjK02wRCzP9NvmhNSZbaKm3APebMJ8Y2w7S9eZz4AyVDAxKbj8vFi+ vREBvqW3wM6TYvenR3fVCUKERBa7hrmZdbZp88Yg11kkWS6qAEjxLSHsQXC/LjyNWLtP vdcg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O7AFaUsL; 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 ke20-20020a056214301400b0064f4b37f21dsi1216382qvb.118.2023.10.19.00.19.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 00:19:24 -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=O7AFaUsL; 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 1qtNIw-0007qG-59; Thu, 19 Oct 2023 03:18:50 -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 1qtNIb-0006jT-Cc for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:18:31 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtNIU-0003i8-V1 for qemu-devel@nongnu.org; Thu, 19 Oct 2023 03:18:28 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-32d9cb5e0fcso5126699f8f.0 for ; Thu, 19 Oct 2023 00:18:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697699900; x=1698304700; 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=/IJC5PGwxG+6/kpGRlXi5TZPdjjr+EIEQtYpUJNBvhI=; b=O7AFaUsLh4aXgI0OTcXu4FKqiuhXJGwAHFFr9pJj+D2C3MMdgzvEOjNfo/1xVJSyk5 HR0G8zdZD6IOZWP96aucfi/lyZzD5f7tHpMXhIPiSYu+mdzsTccJdWa0hvoZr8Ofpx6c FKYmSSIfcI74QjgWEvCop+nCBbq0cGldD6ARgKvgc1CWGrkkxEgDwCVEQwlUVo6qRG1S dtACVohE6hOEdS0x9E9TNlbavmuGIqxMn9KtpNO2+202suEclODE9PdgWSGkK+ezyW0L 3IubmfOYKGcAxjvo+CH6WWWpxia0T9PVhEGHGoiCqK6olnGQF9313CkQMu/f/qOuflEH 5Egg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697699900; x=1698304700; 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=/IJC5PGwxG+6/kpGRlXi5TZPdjjr+EIEQtYpUJNBvhI=; b=N8RBX7DQutTLprM+mrvVr1YETxOR9v/wbhYwDJXs5Co/UVGLr9ro0js1js9jWTWCW9 r/Fc9GDr7zzkA9P8xMUlGz5XPp3gt94JjIxowVlyYADbPFhUEhOOCba85hUnBXFRtIs7 OKW9tIJzWAf96/gGM/+aB57VAJoH5gED8KpOq6TN7JFDNFkDM/ATI92Ls+ZZ0bmExryb mQUOXyCGu5Xc55/C2oyZf7k2TcP8Ue68LOCm35kSWHEsiKJ8K/7gJ6rNuPon0dCALeet 6qRga5jF6aOCxgRqFPepHUgz9SEowSQGewi2pLMaVJujUXU9RCTp201DlEY2xj6uamYK uA2w== X-Gm-Message-State: AOJu0Yy616Pq/YX2sIaxIfvOhEwBAWDqvEJiOygTJw4C3bSP5LpeyUU+ n1ZQ5sWvZ0TrH8lVkZXM1MqOXhM3/EQiDO7LTqLusQ== X-Received: by 2002:a05:6000:71e:b0:32d:c0cd:cc15 with SMTP id bs30-20020a056000071e00b0032dc0cdcc15mr967834wrb.46.1697699900693; Thu, 19 Oct 2023 00:18:20 -0700 (PDT) Received: from localhost.localdomain (92.red-88-28-12.dynamicip.rima-tde.net. [88.28.12.92]) by smtp.gmail.com with ESMTPSA id v14-20020a5d4a4e000000b0032196c508e3sm3729859wrs.53.2023.10.19.00.18.16 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 00:18:20 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: =?utf-8?q?Daniel_P=2E_Berrang=C3=A9?= , Ilya Leoshkevich , Halil Pasic , Huacai Chen , Beniamino Galvani , Thomas Huth , Jiaxun Yang , Marcel Apfelbaum , qemu-arm@nongnu.org, Mark Cave-Ayland , Eric Farman , Paolo Bonzini , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , qemu-s390x@nongnu.org, Strahinja Jankovic , Richard Henderson , Markus Armbruster , Song Gao , Eduardo Habkost , Peter Xu , Sergio Lopez , Christian Borntraeger , David Hildenbrand , Peter Maydell , "Michael S. Tsirkin" , Jason Wang Subject: [PATCH v2 12/12] hw/sysbus: Ensure device is realized before mapping it Date: Thu, 19 Oct 2023 09:16:10 +0200 Message-ID: <20231019071611.98885-13-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019071611.98885-1-philmd@linaro.org> References: <20231019071611.98885-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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 sysbus_mmio_map() should not be called on unrealized device. Reviewed-by: Thomas Huth Signed-off-by: Philippe Mathieu-Daudé --- hw/core/sysbus.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index 8f53cb926b..a46828a808 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -133,6 +133,13 @@ static void sysbus_mmio_map_common(SysBusDevice *dev, int n, hwaddr addr, { assert(n >= 0 && n < dev->num_mmio); + if (!DEVICE(dev)->realized) { + error_report("sysbus_mmio_map(type:%s, index:%d, addr:0x%"HWADDR_PRIx"," + " prio:%d) but object is not realized", + object_get_typename(OBJECT(dev)), n, addr, priority); + abort(); + } + if (dev->mmio[n].addr == addr) { /* ??? region already mapped here. */ return;