From patchwork Mon Apr 29 16:59:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 163045 Delivered-To: patch@linaro.org Received: by 2002:a92:7e86:0:0:0:0:0 with SMTP id q6csp2129583ill; Mon, 29 Apr 2019 10:01:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwSEi9/IldF6H0wACCGL83mVSrz1S8+hVD0OkX2sJS68QV7y82V0MV0oZ0yNIMI5KMJV7XD X-Received: by 2002:a5d:6352:: with SMTP id b18mr27194865wrw.24.1556557293097; Mon, 29 Apr 2019 10:01:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556557293; cv=none; d=google.com; s=arc-20160816; b=wB+ImOGMCNj5LWdqN4THrXngvkWhDSNykBIf4Cyq+LG/CQJyN3D70we0diXdQJ2nIE I6YJIViuyi8F6j5OBDQP/yb6CrzHeFVBbObce5gZPulIhMe5c1i07/pHtqC2UUmr5yb+ 0kdtD30FuDEgP1h+1trqWtgXAn1g+2AiJNSqIzLAmmVVKdT0OBHSg7ZE+u+EsDr/HyDS hDXnLKpjRjvOILwxm/FNDD/qSbCGJZiC2sP/46Q0rX0LW4XT4Eon2moNi9yPKh9FRp3Z /K/ywt9NXKh2zceVWM8wGvrtsGGJjY7zs3KGcb69QlHGrezTQ9y9pY/x3sgMmpAMd7O+ txiw== 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:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=7gNx0IkPrqecANacnRtmZJpa8hlM9XJ8QCX31q2yhf0=; b=zk5Arqks8UuFG6FqRIb5aiCEKQ/bIhc/WM65L18UV9P16aSwABh+b0E/JkR5uNcnd9 pa0ruOwX7BlyapFFj/LbVgqakhX285x5/GZ1NDBtMsOCRuEml8pperIBMHn6HT0rnkxf tYuCV+HocNd1NwOnXtrvGBO0uaFSibLWNk+p+PYrTKUmyhn79dWuHnoaNMiq8ncR6OnW e0P6/wCjZUUv34cW0mki0UMLu5eA+7RZKR2rlaE2x5gRb9dpbz+OfaOoDn12c/6FOuCq zg4/CUlreCVDPRrvjGGWf0ThhtdErrMf7m4YpzFc6I35LEPlsoQyk0C5LOUPgCxl0s1i IZHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=lUc1o1dT; 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 n19si32629wmh.169.2019.04.29.10.01.32 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 29 Apr 2019 10:01:33 -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=lUc1o1dT; 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 ([127.0.0.1]:60604 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hL9el-0004La-VZ for patch@linaro.org; Mon, 29 Apr 2019 13:01:32 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34096) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hL9eB-0004DV-OY for qemu-devel@nongnu.org; Mon, 29 Apr 2019 13:00:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hL9e7-0006Pp-CZ for qemu-devel@nongnu.org; Mon, 29 Apr 2019 13:00:54 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]:55625) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hL9e4-00068o-1P for qemu-devel@nongnu.org; Mon, 29 Apr 2019 13:00:49 -0400 Received: by mail-wm1-x32d.google.com with SMTP id o25so147888wmf.5 for ; Mon, 29 Apr 2019 10:00:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=7gNx0IkPrqecANacnRtmZJpa8hlM9XJ8QCX31q2yhf0=; b=lUc1o1dTXpXImCMu1rUH/Jlu4+DceyeuNsD/QJSYgBKop5HN5/f5i3mBr7l8AsdAiX obzjxGVg7KvqDb949nGkv9zO6K9sFTKtSux8O1Fr/WeHcwCbMOFGZhOuQGLHmFFbV76R y+f9/VMoscRpd0HJm3k37Q8gV4A9Frh7337VDgZnymRgyCRd047eQzTI9FcFZLoT/w4h 3q15Z6SRyO0VBoOlpSb7T3wfcNYRswwstnx/VzTebhdy6WLH1F25hbmgsqnK5PWV+Dzp mwui6Wa3Tyg/X3eTTgU6EhV028vSIhXxy2FXnlA2MOLSBUqZkvJyFxvqq+q/bAbKoU6P IcTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7gNx0IkPrqecANacnRtmZJpa8hlM9XJ8QCX31q2yhf0=; b=VyDXjRu8VRxyFExB8ykOKuk06Cug3iONNJB22iiDFkNKHQmrNl4AsprDuDSb3gRqQb 4t14svbzZMm6psjHAC9Ly4dz1v3O4CH2EqB9k/0eAwDC65PXXzZip6nNdu7jip214aV5 xZ9J7HNrgCFfAPzSpHvZDeQPnNWK5M2OfMtc4B9Jf5xhoKPya3FD//VtA7ElR+Ivsg2+ NsI/H9joea8puMqUi7i7zvNsq7481igW2hvadvDUBMay1GsO070Sx4GA535EjSdkn2aH 5lLtRwUCtRXWC4HXURSk8wDLvs9Z3ExBcNPkO3zYgDPMdIcqWiE2IAnqhfDUTHchzTO5 kv1Q== X-Gm-Message-State: APjAAAW7nLXBsnVQN9jyQfqIhQ1ldkIjUmH+OMLqgA8zt0+ZhYo+WK0Q NW8Yqr9eqSqwmNI2Y4C+5KsQtBijckE= X-Received: by 2002:a1c:4c09:: with SMTP id z9mr22225wmf.87.1556557234291; Mon, 29 Apr 2019 10:00:34 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [81.2.115.148]) by smtp.gmail.com with ESMTPSA id a13sm36896wmj.39.2019.04.29.10.00.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 29 Apr 2019 10:00:33 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Date: Mon, 29 Apr 2019 17:59:49 +0100 Message-Id: <20190429170030.11323-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190429170030.11323-1-peter.maydell@linaro.org> References: <20190429170030.11323-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::32d Subject: [Qemu-devel] [PULL 01/42] hw/arm/smmuv3: Remove SMMUNotifierNode X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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" From: Eric Auger The SMMUNotifierNode struct is not necessary and brings extra complexity so let's remove it. We now directly track the SMMUDevices which have registered IOMMU MR notifiers. This is inspired from the same transformation on intel-iommu done in commit b4a4ba0d68f50f218ee3957b6638dbee32a5eeef ("intel-iommu: remove IntelIOMMUNotifierNode") Signed-off-by: Eric Auger Reviewed-by: Peter Xu Message-id: 20190409160219.19026-1-eric.auger@redhat.com Signed-off-by: Peter Maydell --- include/hw/arm/smmu-common.h | 8 ++------ hw/arm/smmu-common.c | 6 +++--- hw/arm/smmuv3.c | 28 +++++++--------------------- 3 files changed, 12 insertions(+), 30 deletions(-) -- 2.20.1 diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h index b07cadd0ef9..2c7fbf42025 100644 --- a/include/hw/arm/smmu-common.h +++ b/include/hw/arm/smmu-common.h @@ -80,13 +80,9 @@ typedef struct SMMUDevice { AddressSpace as; uint32_t cfg_cache_hits; uint32_t cfg_cache_misses; + QLIST_ENTRY(SMMUDevice) next; } SMMUDevice; -typedef struct SMMUNotifierNode { - SMMUDevice *sdev; - QLIST_ENTRY(SMMUNotifierNode) next; -} SMMUNotifierNode; - typedef struct SMMUPciBus { PCIBus *bus; SMMUDevice *pbdev[0]; /* Parent array is sparse, so dynamically alloc */ @@ -108,7 +104,7 @@ typedef struct SMMUState { GHashTable *iotlb; SMMUPciBus *smmu_pcibus_by_bus_num[SMMU_PCI_BUS_MAX]; PCIBus *pci_bus; - QLIST_HEAD(, SMMUNotifierNode) notifiers_list; + QLIST_HEAD(, SMMUDevice) devices_with_notifiers; uint8_t bus_num; PCIBus *primary_bus; } SMMUState; diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c index bbf4b8721a3..e94be6db6c1 100644 --- a/hw/arm/smmu-common.c +++ b/hw/arm/smmu-common.c @@ -412,10 +412,10 @@ inline void smmu_inv_notifiers_mr(IOMMUMemoryRegion *mr) /* Unmap all notifiers of all mr's */ void smmu_inv_notifiers_all(SMMUState *s) { - SMMUNotifierNode *node; + SMMUDevice *sdev; - QLIST_FOREACH(node, &s->notifiers_list, next) { - smmu_inv_notifiers_mr(&node->sdev->iommu); + QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) { + smmu_inv_notifiers_mr(&sdev->iommu); } } diff --git a/hw/arm/smmuv3.c b/hw/arm/smmuv3.c index 8c4e99fecc6..fd8ec7860ee 100644 --- a/hw/arm/smmuv3.c +++ b/hw/arm/smmuv3.c @@ -828,10 +828,10 @@ static void smmuv3_notify_iova(IOMMUMemoryRegion *mr, /* invalidate an asid/iova tuple in all mr's */ static void smmuv3_inv_notifiers_iova(SMMUState *s, int asid, dma_addr_t iova) { - SMMUNotifierNode *node; + SMMUDevice *sdev; - QLIST_FOREACH(node, &s->notifiers_list, next) { - IOMMUMemoryRegion *mr = &node->sdev->iommu; + QLIST_FOREACH(sdev, &s->devices_with_notifiers, next) { + IOMMUMemoryRegion *mr = &sdev->iommu; IOMMUNotifier *n; trace_smmuv3_inv_notifiers_iova(mr->parent_obj.name, asid, iova); @@ -1472,8 +1472,6 @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, SMMUDevice *sdev = container_of(iommu, SMMUDevice, iommu); SMMUv3State *s3 = sdev->smmu; SMMUState *s = &(s3->smmu_state); - SMMUNotifierNode *node = NULL; - SMMUNotifierNode *next_node = NULL; if (new & IOMMU_NOTIFIER_MAP) { int bus_num = pci_bus_num(sdev->bus); @@ -1485,22 +1483,10 @@ static void smmuv3_notify_flag_changed(IOMMUMemoryRegion *iommu, if (old == IOMMU_NOTIFIER_NONE) { trace_smmuv3_notify_flag_add(iommu->parent_obj.name); - node = g_malloc0(sizeof(*node)); - node->sdev = sdev; - QLIST_INSERT_HEAD(&s->notifiers_list, node, next); - return; - } - - /* update notifier node with new flags */ - QLIST_FOREACH_SAFE(node, &s->notifiers_list, next, next_node) { - if (node->sdev == sdev) { - if (new == IOMMU_NOTIFIER_NONE) { - trace_smmuv3_notify_flag_del(iommu->parent_obj.name); - QLIST_REMOVE(node, next); - g_free(node); - } - return; - } + QLIST_INSERT_HEAD(&s->devices_with_notifiers, sdev, next); + } else if (new == IOMMU_NOTIFIER_NONE) { + trace_smmuv3_notify_flag_del(iommu->parent_obj.name); + QLIST_REMOVE(sdev, next); } }