Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp2009298imm; Sat, 18 Aug 2018 09:00:44 -0700 (PDT) X-Google-Smtp-Source: AA+uWPw8YSkfAfF7XFowyhwNqCgw5ij1C94neS5mWnyD6/a0n0Vj5mj0RXC5G/NxYLa/ktZ4RcN0 X-Received: by 2002:a63:db4f:: with SMTP id x15-v6mr36481397pgi.214.1534608043980; Sat, 18 Aug 2018 09:00:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1534608043; cv=none; d=google.com; s=arc-20160816; b=jsrVZHJmOJV4diSoN3ErZglaWmcNcwMCGNeKyGBfPK2rolAUtyKH6Z1r3eHJE/0KsA L+ErqpWmLrvJHz7+ZuAGU+zBq8YNOLxaC01LkobqGx4NIT4O70rn9TYphorA6Wf1D4N0 wZZbDh3NV65Jq4ofbPgokL4n4OK3nwGHjXv8nWkj9LDOwiNOA3jE7ZxvO9Uk7jj13z+S 5C9/QbLYy1ZBqyM/LPmvkZuzuqd2thke3vbYamYxHFsDROTfSznRalFNnbkSNqme8QEM ED371b/2NoXAmkACqgm7SvfWerjUfJ9QoK7pDI1clwWwFk80oWhxmA/gxT0bUELxabfK 8dIQ== 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=Xr0PWg85YE0T+Ax2Rf8OzonZmno3FCtecBrtNlrITHQ=; b=qv8nNvk0RcQCKHOXZQ+at2CubFAOzZRpJuraf3A2aBRmnEej7wT6jELM4meQPIHP8F 1+Jn+pyWvb5f619Z2Cyx8pmFCHUBrW/5iotkVSTyvU9cpe3TOAt/Wg1AS4/cmWZDWPPo kh/709aopjNKxbB41R1Wpv9gxlRF2xaN8k/n0B0FjASSqiHMElBkshxuYCLGjYt/EuxJ zNb82nDEdkFYlsTElUcCTCK3TJwVYNKeFaPP42q8kX6PPJFXsY8MLHdqx2Rs1abohma3 oZO2Xgi5hUtPtITLqClj6ZW049vNIXUYJKSb8H2kl57B1UbeZGu4iRPK5gXfqv3Ry/HQ +AdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=bLCieMg9; 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 w19-v6si4713179pfn.160.2018.08.18.09.00.28; Sat, 18 Aug 2018 09:00:43 -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=bLCieMg9; 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 S1726758AbeHRTFh (ORCPT + 99 others); Sat, 18 Aug 2018 15:05:37 -0400 Received: from mail-ed1-f67.google.com ([209.85.208.67]:38724 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726404AbeHRTDv (ORCPT ); Sat, 18 Aug 2018 15:03:51 -0400 Received: by mail-ed1-f67.google.com with SMTP id t2-v6so6112113edr.5; Sat, 18 Aug 2018 08:55:42 -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=Xr0PWg85YE0T+Ax2Rf8OzonZmno3FCtecBrtNlrITHQ=; b=bLCieMg9UTOgyYx1lWeiLDWCtNoiNMFINZSXiB3EE64Zj+1TrrhKeEK8BTNuO/w2rk 9kW8gElrRbkjZiayl4nIwKVCoJhA9rvgDAm9IBT4A60OnU/L0XBn8B9211tOr/7KNlRo 07E++iQx3Vo09f0TSEKMK4ErgKOXyuYvEhHbcnSdgJAU0rJwjCSEW25O9/sLGLa9fE8A daKfzwwEBB/1HtJc56sd47Oc9K8AqCUlhdeCdplwGy4P1g668+ZxZoYUEogUVaoXEnjA unbD2BQLfxbSIsjzjLSzoPkVTCAEEfWZx3TIWXC952vRqOlVkvqSWKxgjVF2Iarx5uBz vRLg== 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=Xr0PWg85YE0T+Ax2Rf8OzonZmno3FCtecBrtNlrITHQ=; b=N/6SWCyN1yE2inFF9bF390WF0me2Wwsvdsy28JP/MtCERUSVa+YhhLB9Wavh/y2TaP CEqlJBGpBa3d/tUqQ2f3yP2wH/IzGIUXC3qJQYw+hwnAC6+06zdZPwpvC4Hht57+tbcm 9eF3utxu1fq6hZItuW3ulLrQgc2OYXNJdTmcPO71iyR+SBoAqQgF94vP314Di4vJ8Gn1 ELpiC5UH7pEro+npbjkMC0RPRB0/LFeJ4fN4qPMCtaR6DeErqRll0cxAYU6nDScw13sp mNsi0SWTAoXefhKSBO7pNhRaW6gBBwplmEY5K83NUYPOTB7VdGNtXIawZMycvXskZG80 sc9Q== X-Gm-Message-State: AOUpUlE3vXZwTttgh+Wkkl3K6c1Ncf60fHeqUNHcckFpqaQT5AYeeo3W ieMB04Owwd7OBM74i6MYGso= X-Received: by 2002:a50:925c:: with SMTP id j28-v6mr48739296eda.209.1534607741597; Sat, 18 Aug 2018 08:55:41 -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.40 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sat, 18 Aug 2018 08:55:41 -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 04/19] iommu: Introduce iotlb_sync_map callback Date: Sat, 18 Aug 2018 18:54:15 +0300 Message-Id: <20180818155430.5586-5-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 Introduce iotlb_sync_map() callback that is invoked in the end of iommu_map(). This new callback allows IOMMU drivers to avoid syncing after mapping of each contiguous chunk and sync only when the whole mapping is completed, optimizing performance of the mapping operation. Signed-off-by: Dmitry Osipenko Reviewed-by: Robin Murphy --- drivers/iommu/iommu.c | 8 ++++++-- include/linux/iommu.h | 1 + 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c index 8c15c5980299..8979b16caf61 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1545,13 +1545,14 @@ static size_t iommu_pgsize(struct iommu_domain *domain, int iommu_map(struct iommu_domain *domain, unsigned long iova, phys_addr_t paddr, size_t size, int prot) { + const struct iommu_ops *ops = domain->ops; unsigned long orig_iova = iova; unsigned int min_pagesz; size_t orig_size = size; phys_addr_t orig_paddr = paddr; int ret = 0; - if (unlikely(domain->ops->map == NULL || + if (unlikely(ops->map == NULL || domain->pgsize_bitmap == 0UL)) return -ENODEV; @@ -1580,7 +1581,7 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova, pr_debug("mapping: iova 0x%lx pa %pa pgsize 0x%zx\n", iova, &paddr, pgsize); - ret = domain->ops->map(domain, iova, paddr, pgsize, prot); + ret = ops->map(domain, iova, paddr, pgsize, prot); if (ret) break; @@ -1589,6 +1590,9 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova, size -= pgsize; } + if (ops->iotlb_sync_map) + ops->iotlb_sync_map(domain); + /* unroll mapping in case something went wrong */ if (ret) iommu_unmap(domain, orig_iova, orig_size - size); diff --git a/include/linux/iommu.h b/include/linux/iommu.h index 87994c265bf5..4c488eb69752 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -202,6 +202,7 @@ struct iommu_ops { void (*flush_iotlb_all)(struct iommu_domain *domain); void (*iotlb_range_add)(struct iommu_domain *domain, unsigned long iova, size_t size); + void (*iotlb_sync_map)(struct iommu_domain *domain); void (*iotlb_sync)(struct iommu_domain *domain); phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova); int (*add_device)(struct device *dev); -- 2.18.0