From patchwork Thu Oct 19 21:17:57 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: 735646 Delivered-To: patch@linaro.org Received: by 2002:adf:cf01:0:b0:32c:eacc:7fa with SMTP id o1csp1751074wrj; Thu, 19 Oct 2023 14:29:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IH6gee6cMmCO9feHJ6stTFcMTukm8Fj4T71yWzQyQTtpcV73WI8bKBH6L+nRufCh44zO746 X-Received: by 2002:a05:6214:246b:b0:66d:36fb:474d with SMTP id im11-20020a056214246b00b0066d36fb474dmr123714qvb.1.1697750956065; Thu, 19 Oct 2023 14:29:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1697750956; cv=none; d=google.com; s=arc-20160816; b=L+LNfqKOUGVjdy/NjDHqkjdwLVxZKmY0cd8kKeepoRseCd1JzcPSk9niY7v4fUSXXW mSOwckV/PPjxmEpWhgEjcJY2iemooSXBII9XuqDI/oJCuGkTXW/+ZU9rX/MgPYhn/kSN rU415hAuEaRoLpTl/fcEKetqhLfSF2M7oJDUEmGAgFs1oYwGfKY/i3BNm8eDTU3Si2WH g61naqdPBeaorwDAZRJECOAJVf7xt0FJ8imBQpanK43nsBoqfa1wBpK7NMNGkebz+BVf NrEqiuckYk+rHg0DMvCFI6bThGUQxf7wAJ9YzTaJEx3iNsbCgR5bt9OEQWUyvVzFzj0A 05cw== 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=GRoMhCaNSLoeo2bCOvsej90/UgtOEEDsrN+Oqu3oygw=; fh=0n9Ul5Af6CQEypHJkwrx20ZftP3RDkV5SLmcw1OKgCo=; b=fe94Dork/bt1YCadN0IeOmaK+VZJRbxkZkcnTnpYenaRa7RZ7J6QDLLxa14c8mu+kJ yhmCdNpcLq+Na/sfkkSl7lsucnlxfcbBUVxiUAF7NsrS1N890wxEz6+C6GF447yM2VB5 T4Rq/OCWL4XVOzVD8bunEhyDElYyPXrgLMu8MV2USK5So1VYML8bmDTimcNCQhS+aX0g UJdCqSqRO//9NAvS4GMhCLJ68ygxLt7VGLBQhCC6XELplwudNFzCL4M9OGTMUDNauIAj 8CUrcwFdyFkvOdgz2UHgnFcKEaO1DUrGnzcqikNLMUjRiEy2CGGER11pJ29pjkvfxJ2u aMog== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eEzuygD1; 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 y9-20020a05620a25c900b0077437335298si237752qko.765.2023.10.19.14.29.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 19 Oct 2023 14:29:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=eEzuygD1; 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 1qtaSs-0001vA-5S; Thu, 19 Oct 2023 17:21:58 -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 1qtaSq-0001pF-F4 for qemu-devel@nongnu.org; Thu, 19 Oct 2023 17:21:56 -0400 Received: from mail-lj1-x236.google.com ([2a00:1450:4864:20::236]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qtaSo-0007ee-3R for qemu-devel@nongnu.org; Thu, 19 Oct 2023 17:21:56 -0400 Received: by mail-lj1-x236.google.com with SMTP id 38308e7fff4ca-2c50ec238aeso1847231fa.0 for ; Thu, 19 Oct 2023 14:21:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1697750512; x=1698355312; 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=GRoMhCaNSLoeo2bCOvsej90/UgtOEEDsrN+Oqu3oygw=; b=eEzuygD14V4Bjz6l9jkbHWxWoZOs3s/R3M//pTleJmFON0ATvt5w1b8WSgZ5QwxOnt XYVXVa4XmRJwM2QiOKrMbiO63+YRtUPYlYMmFES7RR/vVSgWKpzEmvliIPNy8cDlr6sn +XDrBGmZPy5YaoR9KWjCn+uAPVF41b7Ck3IhK2cTzR0jj7B3/bZUBIXwU3M5RBPy0s5k YijqI1+/yHcCJWYaly2asA76BHh/Prfu8w8KaUX/XZlQZmvQH79lI4dCKX3MG+IL4u2m 3fr8QKIGN4d4zEJVLEWTI8FEe/2LG9f57xjWqpQVXiukivPJs2HBKomTxbv/GhUY2hkY 0kGA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1697750512; x=1698355312; 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=GRoMhCaNSLoeo2bCOvsej90/UgtOEEDsrN+Oqu3oygw=; b=qseGNqmnUUe/3PkKCgO1L9/oDMf4cSw8JgjvDDqDTJxoN8qAJr7EMEntl9GYUKwqob xC7bOzibWKm+Oq26tIthxHweGdCjDZUqfwlG5IfwN6xAZt+BKHKu/FJlZBD9q8Pyd+jb kjFE92rNUNe6d3K285ykfl3LB3wKoQdHhvhLq+LBJjWxDQfeKDfsTgi4mUJ2ocWE14qM 6lUVSmnN6LeK7zQ5S1kSkUecRrqK33XgmE9Zrj0318AboGiVbz7kdS/VLlwe05yfGCPv Iep8XnKx1/2NQMzJWO24JBM5/XJcIR4/My2B9QVcfd7xHPckZIOWQY64DeWTZp3NkdhO NUbg== X-Gm-Message-State: AOJu0Yx6oICFn2+mjSWanZo3nG5zl5et+wO2ytCg79QkXYUsVZkBzsRp GNG8ysjI6DJjHP1cYiDT7ek8i3MPM0qS1WD2x62KkA== X-Received: by 2002:a2e:9c8c:0:b0:2c5:70f:614a with SMTP id x12-20020a2e9c8c000000b002c5070f614amr99024lji.17.1697750512157; Thu, 19 Oct 2023 14:21:52 -0700 (PDT) Received: from m1x-phil.lan (176-131-216-177.abo.bbox.fr. [176.131.216.177]) by smtp.gmail.com with ESMTPSA id m29-20020a05600c3b1d00b003fe61c33df5sm5415202wms.3.2023.10.19.14.21.50 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 19 Oct 2023 14:21:51 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-ppc@nongnu.org, qemu-s390x@nongnu.org, qemu-block@nongnu.org, qemu-arm@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , "Michael S . Tsirkin" , Peter Xu , Jason Wang , Marcel Apfelbaum , Paolo Bonzini , Richard Henderson , Eduardo Habkost Subject: [PULL 32/46] hw/i386/intel_iommu: Do not use SysBus API to map local MMIO region Date: Thu, 19 Oct 2023 23:17:57 +0200 Message-ID: <20231019211814.30576-33-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231019211814.30576-1-philmd@linaro.org> References: <20231019211814.30576-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::236; envelope-from=philmd@linaro.org; helo=mail-lj1-x236.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 Message-Id: <20231018141151.87466-3-philmd@linaro.org> --- 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);