From patchwork Tue May 8 18:16:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Osipenko X-Patchwork-Id: 910407 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="MlwILbe0"; dkim-atps=neutral Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 40gSSC6BGKz9s2t for ; Wed, 9 May 2018 04:19:23 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751723AbeEHSTW (ORCPT ); Tue, 8 May 2018 14:19:22 -0400 Received: from mail-lf0-f65.google.com ([209.85.215.65]:44258 "EHLO mail-lf0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933537AbeEHSRg (ORCPT ); Tue, 8 May 2018 14:17:36 -0400 Received: by mail-lf0-f65.google.com with SMTP id h197-v6so47197622lfg.11; Tue, 08 May 2018 11:17:35 -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=wAvrFMQXHYcT8NHG+wXBOWYBJhYOY7OpKAFVGL/miMQ=; b=MlwILbe0ihbV7B3xX7HSytI8MvVzbcZWoqE/FSMLeRJJcu9NtsBSk2XV5f1ITGCSO5 vokMPSuDzd8J1BRGg5tjL4HBA56wBx+iKru06ZLbjg7iDVzYA2IKZ/QvRhiF+oLTYtMu 5htNYS1lEXCldNJAGfLWQf/oA6u62+hPhk0uYzgghlq+2vetxkt4e9Ov4izGm3nXiKGZ SfAgOmEaxRynrvQKJReQc7Q19rLekvbvGA+6ImLrbpbtMc1HNINTe3hb834MfcxkN3Te wCPOwM7r6voptFmnYw8OQAoeuwZ9OXePGXqh0UquRtU2OeL+2J/MaIrUPXntMCOdtknR cMHw== 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=wAvrFMQXHYcT8NHG+wXBOWYBJhYOY7OpKAFVGL/miMQ=; b=PJihCpAFPIiCgCkiIkGm0M3iSTEPgizLXmKXzw1jeen6LmehU4thCNadfLXQkTWh1W vtUIjkpqoefd7Z6aqxlgbxeJ31jifY4KbMKkIeqvid30WEaQUo1BUZXTy8e/dZKOhz5L AVIQDc1DHJY4ovavBjXV8crlfUtSy1v9WmpRJTUORn//nCuSSmCApc6KzuZj2P3ayfRC 6JCWaa6orVAVlL/Wiw6pDvzyjTG22MbfP/EHv9oH0ti2I5OJYJiAvfhGJQeDXhZfmfwo ieimkqAeOp9td2v3+pMIMHOn29EjVeS7yhT4A++zY6LrtTd3McYQY7Nf+tvwbWInTeNn Wn9g== X-Gm-Message-State: ALKqPwe9UilpRjhO4agmvo1p0jgMiqaJBxRK7qoKUPLjCBPoo7ezwdbE aQ+a254NGM1c1wVpKnMzMdw= X-Google-Smtp-Source: AB8JxZrYGtoSzwh4pPkUpCS30sW5cgw8PlrTdwtbvcRSn554CRueaEuoR+DYm8frfVt9s4x5PEwOTw== X-Received: by 2002:a19:4310:: with SMTP id q16-v6mr330535lfa.74.1525803455003; 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.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 08 May 2018 11:17:34 -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 8/9] iommu: Introduce iotlb_sync_map callback Date: Tue, 8 May 2018 21:16:59 +0300 Message-Id: <20180508181700.5169-9-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 Introduce iotlb_sync_map() callback that is invoked in the end of iommu_map(). This new callback allows IOMMU drivers to avoid syncing on mapping of each contiguous chunk and sync only when 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 d2aa23202bb9..39b2ee66aa96 100644 --- a/drivers/iommu/iommu.c +++ b/drivers/iommu/iommu.c @@ -1508,13 +1508,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; @@ -1543,7 +1544,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; @@ -1552,6 +1553,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 19938ee6eb31..5224aa376377 100644 --- a/include/linux/iommu.h +++ b/include/linux/iommu.h @@ -206,6 +206,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);