From patchwork Tue May 8 18:17:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 910406 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-tegra-owner@vger.kernel.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="us0QuPCv"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40gSRt6xbNz9s2t for ; Wed, 9 May 2018 04:19:06 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933055AbeEHSSw (ORCPT ); Tue, 8 May 2018 14:18:52 -0400 Received: from mail-lf0-f67.google.com ([209.85.215.67]:45916 "EHLO mail-lf0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932982AbeEHSRh (ORCPT ); Tue, 8 May 2018 14:17:37 -0400 Received: by mail-lf0-f67.google.com with SMTP id q2-v6so2048683lfc.12; Tue, 08 May 2018 11:17:36 -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=ids4fn/p4BO1AI1GZ13Grmwh+c9zghxWorEEi0dAgQo=; b=us0QuPCvz23hTZg63ACo8TwjP1tRBeX1BOgUbPrjILAuUDXjtTZyYcxWk7N7utPLXY kaC7GqtxRyno4FBD96uB6yvsXdzgJmfN/X5lPDyqDs1p+7gqfN69NqEN2LrFSvZlyMkc oM+R/SGbzGUSNhhaSlVRumrRfEQUm2bx1Y3xv3/KuPlCh2WdaAw7XYiJ7jfX8ckfkA5b e7X4KCkSPE7yFJ0+Twn1DDx8QZ6tdCcLW9NylnnmZvpoobP6TMggyVJ15Vz+5p/DUFr+ /+RsoUtgevkRa9ioG+2zv6qlGjIIw64kkOQ9KUBB9bQ3a3FY9w8ilSOr40e4K2dhax9D 2j0Q== 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=ids4fn/p4BO1AI1GZ13Grmwh+c9zghxWorEEi0dAgQo=; b=hmIxzWCGkTKxJsr4AGbnV0VX08AVS+77VNv4N2EUHj6YRMNO8PQezU2PhoJfqXSse+ Ch9vMqY7X2KgYZv8+UHmsgLvNUjVZ7pCI8YUNjIj548l0GA7wZryBLD9qm1AaIIYr6fy VT75Y3LhySi0mVB00526/ToZbevFxahAIOXHUaoEtpT/NAeXEV2uoOz5QUxOSpJToSXs sWxpnV8qbz+vq+oYNJLIyUdXw6QR5bkSX+1+2VpQgnkmdLHbxqgDq7XHQB8VJR6IihW7 kvSOH5YTwTEWJysTdXYwIjZZL4GlUAAVB0RYdTJ1lzPmY0K2SqsprBqcgZyr6qfHPOoK d6Mw== X-Gm-Message-State: ALQs6tBoT6wKVwmM97LxH6/UgDaKaqtpXap0D9+t9xNRmN2scouraFfR H5UnNvhzkCO+ZCGBQmOyonI= X-Google-Smtp-Source: AB8JxZr88zmYhDwiWx6ECJk38A7wfGPOR/HUpvs4D/ZjMQuglL/M6AkV2imSfvb3P8OMMj8LmQN3Rw== X-Received: by 2002:a19:1142:: with SMTP id g63-v6mr9682425lfi.6.1525803455942; Tue, 08 May 2018 11:17:35 -0700 (PDT) Received: from localhost.localdomain ([109.252.91.130]) by smtp.gmail.com with ESMTPSA id f64-v6sm2338699lfg.63.2018.05.08.11.17.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 11:17:35 -0700 (PDT) From: Dmitry Osipenko To: Joerg Roedel , Thierry Reding , Jonathan Hunter Cc: linux-tegra@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH v1 9/9] iommu/tegra: gart: Optimize mapping / unmapping performance Date: Tue, 8 May 2018 21:17:00 +0300 Message-Id: <20180508181700.5169-10-digetx@gmail.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180508181700.5169-1-digetx@gmail.com> References: <20180508181700.5169-1-digetx@gmail.com> Sender: linux-tegra-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-tegra@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% (depending on size of mapping) performance boost compared to a flushing after each 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 ebc105c201bd..26d8735d26e8 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c @@ -226,7 +226,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; } @@ -243,7 +242,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; } @@ -319,6 +317,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, @@ -334,6 +340,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 gart_iommu_check_device(struct gart_device *gart,