Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2006785imm; Sat, 18 Aug 2018 08:57:42 -0700 (PDT) X-Google-Smtp-Source: AA+uWPzFDNLdVFkddMXLJJ6r0unIpc/pM9bD182I1MIVGB20Zz1POdroIzWnsmBeCdVr7d7uUY/m X-Received: by 2002:a17:902:d211:: with SMTP id t17-v6mr3479198ply.258.1534607862350; Sat, 18 Aug 2018 08:57:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534607862; cv=none; d=google.com; s=arc-20160816; b=x3gCDX0fAHzNgk9Vuxlb126TfoTibIsGKW6fMGx2o4Ck4CNRN0kxhjuDwBY4YPuM4f Q/CNG60vLYW/S6a0PO3EBcv5dj4KMKIZkt+S2TbWQ46LZ2QBAL+IwQd8eTJQ2EzHtPTH 6Km0lCoG58mbg05jJAGdMEhBT2Ijpbualy0V3RNXBgqeOHfHdYzb8TQeW5zs/pxMdk4L XmKfB5m81I2Vunl9Y1yB76IqkZSQlDwSsv/ttAd2kgY/vaxyrs7nElT8VZVp6EpT6ZTV 5yMkfwb95SDJNkMa/WaS5+MkHL2/iStqVUVp2HTPlLBiyOpBVoIbtGytBvKPhsny2MKH iyXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=5D0mfuAvSzidhSfd9PaUke0v52qdEd2FBljRpBUlI1I=; b=O6UQ82eLZCqCCBch9Ad3VAtKhR+MBEjQjwMQMQhEYThNaRYOJyWYbwypDjiEMGvCN2 eAmVFe1x2YJAqvauV+JOZOio8LGhemEw4O/6zlOCw5QxFeAHHma059ljCgK0NLq/TYUG BEopKCcj8t3J5M5bhsabES4UBLM/ItizAABrh++HNcE+TMrkr3rspJl9E00Gu37+mUbT ljV49oBWiwJ4wA9pHuN1/dNCPuSORBjSuWxNdI7Gc6KDBJI3J4YqXmtmQIPfqQNqlcS/ 8ebpXKyCd5wu5GGA75R/i7UOw7MzJqf0qAruARj8kH4AP5hRM7+TDN5rO14+M0c7cCMa fzJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aQNBJJ57; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d17-v6si4643793pgp.549.2018.08.18.08.57.26; Sat, 18 Aug 2018 08:57:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=aQNBJJ57; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726545AbeHRTDx (ORCPT + 99 others); Sat, 18 Aug 2018 15:03:53 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:33401 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726499AbeHRTDw (ORCPT ); Sat, 18 Aug 2018 15:03:52 -0400 Received: by mail-ed1-f66.google.com with SMTP id x5-v6so6115709edr.0; Sat, 18 Aug 2018 08:55:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=5D0mfuAvSzidhSfd9PaUke0v52qdEd2FBljRpBUlI1I=; b=aQNBJJ57sRpIOLbcS5zGx/zxsW2QtEfQ+NLeRj5IU/rgUbJPTaV5yrkAmcJb06iDYQ qvjq42Ad/vXarGiMsVyUa9GviHxJzr8D0sLTIEYHtGhInV4laAOLTJC5HIIjaGfyhaKE Glq83v8b5hkJErV73UP2cY4bPr0aXLpCB6UlD10V2yfnQPT+vLOevbtc76p+AGbJ6lZE 6n1ZVaT52vD2QCiJ9J/e+gJii6KjGK0CfVovNJaKA9aq+ButQCuSHvgiOFvNC4UIFb0d Mx5rTrCGcEpenGoizPZRiSj7k3Mi0N+Igu0oz5gK/ZB4g231tHhhPHlRvwOrKHG+ZiHp 1baw== 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; bh=5D0mfuAvSzidhSfd9PaUke0v52qdEd2FBljRpBUlI1I=; b=cvTy0d3+5DL0kTa4c0OHa6JUPrV/E+YzKG6kPPLh9P/S2H6msSgYJGJ4LKAImiWFm7 5grl4Sr21iYc7a/dn/ria1FuXnFuqs9W1Uczkxmozumf4oKVg9RlzKrer1AmkviUOxBV a52UoqcOz7lQE6vyba58rPcVyiivf2z++Jpjq2UUMXhQqJtzjzocXrqJL+O6ekB3OVaF 6e/tcdXNahqjoZ9ikjfYDB8N2IH2gF8pHyh9+qLWa8SXKnIJ9jI0tGsZKN8W6D17/lBe YyxbxYSEaWG0M65CgjLlJselEwKtY7twwssku519g0USNEclzZXH1kNesapeamcM+Be9 UHwA== X-Gm-Message-State: AOUpUlErX6n9altS60L3+pX+4VbepE2+55rKpZsSvTCpROc/PQ9U/mHf q6KO78MtgmcJu9i0AeK2XMs= X-Received: by 2002:a50:9622:: with SMTP id y31-v6mr46490090eda.141.1534607742818; Sat, 18 Aug 2018 08:55:42 -0700 (PDT) Received: from localhost.localdomain (109-252-90-13.nat.spd-mgts.ru. [109.252.90.13]) by smtp.gmail.com with ESMTPSA id v8-v6sm2784014edr.48.2018.08.18.08.55.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Aug 2018 08:55:42 -0700 (PDT) From: Dmitry Osipenko To: Joerg Roedel , Robin Murphy , Thierry Reding , Jonathan Hunter , Rob Herring Cc: iommu@lists.linux-foundation.org, devicetree@vger.kernel.org, linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v3 05/19] iommu/tegra: gart: Optimize mapping / unmapping performance Date: Sat, 18 Aug 2018 18:54:16 +0300 Message-Id: <20180818155430.5586-6-digetx@gmail.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180818155430.5586-1-digetx@gmail.com> References: <20180818155430.5586-1-digetx@gmail.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Currently GART writes one page entry at a time. More optimal would be to aggregate the writes and flush BUS buffer in the end, this gives map/unmap 10-40% performance boost (depending on size of mapping) in comparison to flushing after each page entry update. Signed-off-by: Dmitry Osipenko --- drivers/iommu/tegra-gart.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c index f6cf5cd5aaca..86a855c0d031 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c @@ -287,7 +287,6 @@ static int gart_iommu_map(struct iommu_domain *domain, unsigned long iova, } } gart_set_pte(gart, iova, GART_PTE(pfn)); - FLUSH_GART_REGS(gart); spin_unlock_irqrestore(&gart->pte_lock, flags); return 0; } @@ -304,7 +303,6 @@ static size_t gart_iommu_unmap(struct iommu_domain *domain, unsigned long iova, spin_lock_irqsave(&gart->pte_lock, flags); gart_set_pte(gart, iova, 0); - FLUSH_GART_REGS(gart); spin_unlock_irqrestore(&gart->pte_lock, flags); return bytes; } @@ -370,6 +368,14 @@ static int gart_iommu_of_xlate(struct device *dev, return 0; } +static void gart_iommu_sync(struct iommu_domain *domain) +{ + struct gart_domain *gart_domain = to_gart_domain(domain); + struct gart_device *gart = gart_domain->gart; + + FLUSH_GART_REGS(gart); +} + static const struct iommu_ops gart_iommu_ops = { .capable = gart_iommu_capable, .domain_alloc = gart_iommu_domain_alloc, @@ -384,6 +390,8 @@ static const struct iommu_ops gart_iommu_ops = { .iova_to_phys = gart_iommu_iova_to_phys, .pgsize_bitmap = GART_IOMMU_PGSIZES, .of_xlate = gart_iommu_of_xlate, + .iotlb_sync_map = gart_iommu_sync, + .iotlb_sync = gart_iommu_sync, }; static int tegra_gart_suspend(struct device *dev) -- 2.18.0