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