From patchwork Fri Oct 30 18:05:02 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Philippe Brucker X-Patchwork-Id: 320026 Delivered-To: patch@linaro.org Received: by 2002:a92:7b12:0:0:0:0:0 with SMTP id w18csp1640119ilc; Fri, 30 Oct 2020 11:08:32 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzHZMs35mD4be/nHs8VDOM40d+4FOKlIS+kxSfGC22H/wYRumDx7McFrlR/fAei68yxduzt X-Received: by 2002:a05:620a:16b6:: with SMTP id s22mr3257550qkj.422.1604081312449; Fri, 30 Oct 2020 11:08:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604081312; cv=none; d=google.com; s=arc-20160816; b=cGrv18MNsmHGGrNz9y1Ve8vHtSRINZumRrwqZS9FSfeVcDCthbi6mwDunrxjFdbhvR 8Vg1nQDIyqgAUqpQPOS4Eez1fwZbn0jnZE2TVmbkh0mj2irr4yzdH9vlbi7/oE+WSqDx QGQwCC263xs6C8YsbMIu6KVnZ7FZYK/eZvvCFvo8texdGecr7X/KUjeFucWIVHPgBkN7 rUz+jM1PUi2sNUYFj3m8ixoZDlYveWEBlq1ffY+qlyTrvybltpupiIoJoAW3P8GNNd0l BbCypTBGJ0S9hvUHp6rQv8cagzKV9BFntdiiIP6SICnD+uvRb6BehY51FFis8SZN8cOf pS3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc: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:to:from :dkim-signature; bh=Mw5vfUgd3GO54+QgLOqJSliaESKLNNhHaEh4i2r3qrc=; b=qJVMNBZJEQAVqLbkiE2f0Q0Y9EYAOP37aUyVljF2O9ckX0VCVp/YxX+YFB0NeLoG+g FB3sXRUnDp8Tuv8Yc6PelRQzxjMi3B6DaGKE3SNC2B7J9WDFnJM6Hxxxnxww0McY4EpO 6walsEAME5q2sGG7JVxPmbfH5TBVFI5hjDRaBx2qXNWHGti9N71EZx7Sg2aTyBbvsvpo JzW6T5Z/TrKL6goVEVmzVWGu6mYU9n42ibY77rWjKEdRfxjMiYHz1CEBxFXvVK5ocoQ1 tdmS3IsOMA1k6xzgLBOjgqvfbqcQkVKoucdm+cuXBMdRQtG1zJnx+9pf8Pe8aHmddkYd hzxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vU4qTx3G; 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=fail (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 b11si3756463qkk.219.2020.10.30.11.08.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 30 Oct 2020 11:08:32 -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=fail header.i=@linaro.org header.s=google header.b=vU4qTx3G; 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=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:45762 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kYYpD-0008WM-VT for patch@linaro.org; Fri, 30 Oct 2020 14:08:32 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44842) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kYYmp-00058l-Kj for qemu-devel@nongnu.org; Fri, 30 Oct 2020 14:06:05 -0400 Received: from mail-wm1-x343.google.com ([2a00:1450:4864:20::343]:36204) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1kYYmd-0004p4-E4 for qemu-devel@nongnu.org; Fri, 30 Oct 2020 14:06:01 -0400 Received: by mail-wm1-x343.google.com with SMTP id e2so3756362wme.1 for ; Fri, 30 Oct 2020 11:05:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Mw5vfUgd3GO54+QgLOqJSliaESKLNNhHaEh4i2r3qrc=; b=vU4qTx3GvdgOkCNTIIx8G8HEwOfAcbWYzevJTZmgD3BOBeKslRw82JU1nDk02rEF+k ZYa5ClthndZBW++m6t8gDMRjsco/Zxyp/gt1ZRXF5cFikHjy8cz+Yk8FH9StNOHRlQrs fVX4MWIFxDgMi9tUOXfgF2xe+C8mBErSZnIOJ3axK1WGM4BwsyEYOlojI8xojTxFQ02J 36EnOS3JX+rQbbbn/1528tC0zu21tLo2NqEp6k4/Ncwg7UDmQlcg0VbyJFzscTglU38k /qW5KQnwZwDfcOkjnL/EERo9EwxW93GohF/a8QQSbgRmp1EDXkSdjSRP8J9GRC4CKkLL YZ3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Mw5vfUgd3GO54+QgLOqJSliaESKLNNhHaEh4i2r3qrc=; b=gePScHTyP8XtJvjlPKAthhummKu0ULCAihhtdTmeWCFBdYN7tb2216AXnYMV1n6oER jUKN7fjAO1a28aGMhz2XJUu5x6iLtc2tQBMC+tJxUGy+m/BJb6gwWmoJVohLnpnokFXD RUy2g5KR6J8t9UJu7yOtyHygHgs1hkDDWMhKz05+TmFt3lzCR3uOXAdz5WQXxBEFG9HT m0ml6iVAuudjoycl6jYbvq8+WgyCxJW54hmKnWcme49pLPNbgD3iPnkYGMl/T7RtbPjh 7G4sHq0qAZMf2YONNo+rX4xRN5BcCW7bIXfjW0ju/ZrmwO4PT4OUvROg+wka904Zi9Vf H24w== X-Gm-Message-State: AOAM530NHaEao2iop8d71Ia2d/OCeAvpuHyDPpCRr7LdJhks2OdNVGQf LyTi9a+SRx3g9qnaSdDB3o+pAw== X-Received: by 2002:a7b:c00b:: with SMTP id c11mr4036924wmb.96.1604081148980; Fri, 30 Oct 2020 11:05:48 -0700 (PDT) Received: from localhost.localdomain ([2001:1715:4e26:a7e0:116c:c27a:3e7f:5eaf]) by smtp.gmail.com with ESMTPSA id u3sm10044438wro.33.2020.10.30.11.05.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 30 Oct 2020 11:05:48 -0700 (PDT) From: Jean-Philippe Brucker To: eric.auger@redhat.com, alex.williamson@redhat.com Subject: [PATCH v11 02/10] virtio-iommu: Store memory region in endpoint struct Date: Fri, 30 Oct 2020 19:05:02 +0100 Message-Id: <20201030180510.747225-3-jean-philippe@linaro.org> X-Mailer: git-send-email 2.29.1 In-Reply-To: <20201030180510.747225-1-jean-philippe@linaro.org> References: <20201030180510.747225-1-jean-philippe@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::343; envelope-from=jean-philippe@linaro.org; helo=mail-wm1-x343.google.com X-detected-operating-system: by eggs.gnu.org: No matching host in p0f cache. That's all we know. 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.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jean-Philippe Brucker , mst@redhat.com, qemu-devel@nongnu.org, peterx@redhat.com, pbonzini@redhat.com, bbhushan2@marvell.com Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Store the memory region associated to each endpoint into the endpoint structure, to allow efficient memory notification on map/unmap. Acked-by: Eric Auger Signed-off-by: Jean-Philippe Brucker --- hw/virtio/virtio-iommu.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) -- 2.29.1 diff --git a/hw/virtio/virtio-iommu.c b/hw/virtio/virtio-iommu.c index 4c8f3909b7d..a5c2d69aad6 100644 --- a/hw/virtio/virtio-iommu.c +++ b/hw/virtio/virtio-iommu.c @@ -49,6 +49,7 @@ typedef struct VirtIOIOMMUDomain { typedef struct VirtIOIOMMUEndpoint { uint32_t id; VirtIOIOMMUDomain *domain; + IOMMUMemoryRegion *iommu_mr; QLIST_ENTRY(VirtIOIOMMUEndpoint) next; } VirtIOIOMMUEndpoint; @@ -137,16 +138,19 @@ static VirtIOIOMMUEndpoint *virtio_iommu_get_endpoint(VirtIOIOMMU *s, uint32_t ep_id) { VirtIOIOMMUEndpoint *ep; + IOMMUMemoryRegion *mr; ep = g_tree_lookup(s->endpoints, GUINT_TO_POINTER(ep_id)); if (ep) { return ep; } - if (!virtio_iommu_mr(s, ep_id)) { + mr = virtio_iommu_mr(s, ep_id); + if (!mr) { return NULL; } ep = g_malloc0(sizeof(*ep)); ep->id = ep_id; + ep->iommu_mr = mr; trace_virtio_iommu_get_endpoint(ep_id); g_tree_insert(s->endpoints, GUINT_TO_POINTER(ep_id), ep); return ep; @@ -910,9 +914,14 @@ static gboolean reconstruct_endpoints(gpointer key, gpointer value, VirtIOIOMMU *s = (VirtIOIOMMU *)data; VirtIOIOMMUDomain *d = (VirtIOIOMMUDomain *)value; VirtIOIOMMUEndpoint *iter; + IOMMUMemoryRegion *mr; QLIST_FOREACH(iter, &d->endpoint_list, next) { + mr = virtio_iommu_mr(s, iter->id); + assert(mr); + iter->domain = d; + iter->iommu_mr = mr; g_tree_insert(s->endpoints, GUINT_TO_POINTER(iter->id), iter); } return false; /* continue the domain traversal */