From: Robin Murphy <robin.murphy@arm.com>
To: Dmitry Osipenko <digetx@gmail.com>,
Joerg Roedel <joro@8bytes.org>,
Thierry Reding <thierry.reding@gmail.com>,
Jonathan Hunter <jonathanh@nvidia.com>
Cc: linux-tegra@vger.kernel.org, iommu@lists.linux-foundation.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v1 8/9] iommu: Introduce iotlb_sync_map callback
Date: Fri, 11 May 2018 14:02:04 +0100 [thread overview]
Message-ID: <da823a61-5bda-042b-c61f-d0d98f9b6e6f@arm.com> (raw)
In-Reply-To: <20180508181700.5169-9-digetx@gmail.com>
On 08/05/18 19:16, Dmitry Osipenko wrote:
> 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.
This looks like a reasonable compromise - for users of
IO_PGTABLE_QUIRK_TLBI_ON_MAP we can leave the implicit add_flush() in
place for each individual map call, but at least move the sync() out to
this callback, which should still be beneficial overall.
Modulo one possible nit below,
Reviewed-by: Robin Murphy <robin.murphy@arm.com>
> Signed-off-by: Dmitry Osipenko <digetx@gmail.com>
> ---
> 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);
Is it worth trying to skip this in the error case when we're just going
to undo it immediately?
Robin.
> +
> /* 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);
>
next prev parent reply other threads:[~2018-05-11 13:02 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-05-08 18:16 [PATCH v1 0/9] Tegra GART driver clean up and optimization Dmitry Osipenko
2018-05-08 18:16 ` [PATCH v1 1/9] memory: tegra: Provide facility for integration with the GART driver Dmitry Osipenko
2018-05-08 18:16 ` [PATCH v1 2/9] iommu/tegra: gart: Provide access to Memory Controller driver Dmitry Osipenko
2018-05-08 18:16 ` [PATCH v1 3/9] iommu/tegra: gart: Remove code related to module unloading Dmitry Osipenko
2018-05-08 18:16 ` [PATCH v1 4/9] iommu/tegra: gart: Remove pr_fmt and clean up includes Dmitry Osipenko
2018-05-08 18:16 ` [PATCH v1 5/9] iommu/tegra: gart: Clean up driver probe failure unwinding Dmitry Osipenko
2018-05-08 18:16 ` [PATCH v1 6/9] iommu/tegra: gart: Ignore devices without IOMMU phandle in DT Dmitry Osipenko
2018-05-11 11:34 ` Robin Murphy
2018-05-11 15:34 ` Dmitry Osipenko
2018-05-08 18:16 ` [PATCH v1 7/9] iommu/tegra: gart: Provide single domain and group for all devices Dmitry Osipenko
2018-05-11 11:12 ` Dmitry Osipenko
2018-05-11 12:32 ` Robin Murphy
2018-05-11 20:05 ` Dmitry Osipenko
2018-05-14 18:18 ` Robin Murphy
2018-05-16 13:43 ` Dmitry Osipenko
2018-05-08 18:16 ` [PATCH v1 8/9] iommu: Introduce iotlb_sync_map callback Dmitry Osipenko
2018-05-11 13:02 ` Robin Murphy [this message]
2018-05-11 19:58 ` Dmitry Osipenko
2018-05-08 18:17 ` [PATCH v1 9/9] iommu/tegra: gart: Optimize mapping / unmapping performance Dmitry Osipenko
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=da823a61-5bda-042b-c61f-d0d98f9b6e6f@arm.com \
--to=robin.murphy@arm.com \
--cc=digetx@gmail.com \
--cc=iommu@lists.linux-foundation.org \
--cc=jonathanh@nvidia.com \
--cc=joro@8bytes.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-tegra@vger.kernel.org \
--cc=thierry.reding@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®