Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1234721 > unrolled thread
| Started by | Tomasz Figa <tfiga@chromium.org> |
|---|---|
| First post | 2015-09-29 07:30 +0200 |
| Last post | 2015-09-29 14:00 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
[RFC PATCH 1/3] iommu: Add support for out of band flushing Tomasz Figa <tfiga@chromium.org> - 2015-09-29 07:30 +0200
Re: [RFC PATCH 1/3] iommu: Add support for out of band flushing Thierry Reding <thierry.reding@gmail.com> - 2015-09-29 11:40 +0200
Re: [RFC PATCH 1/3] iommu: Add support for out of band flushing Tomasz Figa <tfiga@chromium.org> - 2015-09-29 14:00 +0200
| From | Tomasz Figa <tfiga@chromium.org> |
|---|---|
| Date | 2015-09-29 07:30 +0200 |
| Subject | [RFC PATCH 1/3] iommu: Add support for out of band flushing |
| Message-ID | <qdVEe-5sa-13@gated-at.bofh.it> |
This patch adds a new "flush" callback to iommu_ops, which is supposed
to perform any necessary flushes within given IOMMU domain to make any
changes to mappings of given area [iova; iova + size) be reflected to
IOMMU clients.
The purpose is to let IOMMU drivers skip page-by-page flushes and
replace it with one flush of full address range on devices which support
it.
Signed-off-by: Tomasz Figa <tfiga@chromium.org>
---
drivers/iommu/iommu.c | 33 ++++++++++++++++++++++++++++++---
include/linux/iommu.h | 2 ++
2 files changed, 32 insertions(+), 3 deletions(-)
diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 049df49..d6bb8fe 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -1286,8 +1286,15 @@ static size_t iommu_pgsize(struct iommu_domain *domain,
return pgsize;
}
-int iommu_map(struct iommu_domain *domain, unsigned long iova,
- phys_addr_t paddr, size_t size, int prot)
+static void iommu_flush(struct iommu_domain *domain, unsigned long iova,
+ size_t size)
+{
+ if (domain->ops->flush)
+ domain->ops->flush(domain, iova, size);
+}
+
+static int __iommu_map(struct iommu_domain *domain, unsigned long iova,
+ phys_addr_t paddr, size_t size, int prot)
{
unsigned long orig_iova = iova;
unsigned int min_pagesz;
@@ -1340,6 +1347,20 @@ int iommu_map(struct iommu_domain *domain, unsigned long iova,
return ret;
}
+
+int iommu_map(struct iommu_domain *domain, unsigned long iova,
+ phys_addr_t paddr, size_t size, int prot)
+{
+ int ret;
+
+ ret = __iommu_map(domain, iova, paddr, size, prot);
+ if (ret)
+ return ret;
+
+ iommu_flush(domain, iova, size);
+
+ return 0;
+}
EXPORT_SYMBOL_GPL(iommu_map);
size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)
@@ -1389,6 +1410,7 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size)
unmapped += unmapped_page;
}
+ iommu_flush(domain, orig_iova, unmapped);
trace_unmap(orig_iova, size, unmapped);
return unmapped;
}
@@ -1419,19 +1441,24 @@ size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova,
if (!IS_ALIGNED(s->offset, min_pagesz))
goto out_err;
- ret = iommu_map(domain, iova + mapped, phys, s->length, prot);
+ ret = __iommu_map(domain, iova + mapped, phys, s->length, prot);
if (ret)
goto out_err;
mapped += s->length;
}
+ iommu_flush(domain, iova, mapped);
+
return mapped;
out_err:
/* undo mappings already done */
iommu_unmap(domain, iova, mapped);
+ /* flush in case part of our mapping already got cached */
+ iommu_flush(domain, iova, mapped);
+
return 0;
}
diff --git a/include/linux/iommu.h b/include/linux/iommu.h
index f9c1b6d..18e59a9 100644
--- a/include/linux/iommu.h
+++ b/include/linux/iommu.h
@@ -164,6 +164,8 @@ struct iommu_ops {
size_t size);
size_t (*map_sg)(struct iommu_domain *domain, unsigned long iova,
struct scatterlist *sg, unsigned int nents, int prot);
+ void (*flush)(struct iommu_domain *domain, unsigned long iova,
+ size_t size);
phys_addr_t (*iova_to_phys)(struct iommu_domain *domain, dma_addr_t iova);
int (*add_device)(struct device *dev);
void (*remove_device)(struct device *dev);
--
2.6.0.rc2.230.g3dd15c0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | Thierry Reding <thierry.reding@gmail.com> |
|---|---|
| Date | 2015-09-29 11:40 +0200 |
| Message-ID | <qdZya-2xz-5@gated-at.bofh.it> |
| In reply to | #1234721 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Sep 29, 2015 at 02:25:24PM +0900, Tomasz Figa wrote: > This patch adds a new "flush" callback to iommu_ops, which is supposed > to perform any necessary flushes within given IOMMU domain to make any > changes to mappings of given area [iova; iova + size) be reflected to > IOMMU clients. > > The purpose is to let IOMMU drivers skip page-by-page flushes and > replace it with one flush of full address range on devices which support > it. > > Signed-off-by: Tomasz Figa <tfiga@chromium.org> > --- > drivers/iommu/iommu.c | 33 ++++++++++++++++++++++++++++++--- > include/linux/iommu.h | 2 ++ > 2 files changed, 32 insertions(+), 3 deletions(-) I seem to remember that Rob Clark had proposed something like this back before it was decided to introduce the ->map_sg() callback instead. I can't find a reference to the discussion, so perhaps I'm misremembering but adding Rob Clark in case he has any recollection of why the outcome was what it was. > diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c [...] > @@ -1389,6 +1410,7 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size) > unmapped += unmapped_page; > } > > + iommu_flush(domain, orig_iova, unmapped); > trace_unmap(orig_iova, size, unmapped); > return unmapped; > } > @@ -1419,19 +1441,24 @@ size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova, > if (!IS_ALIGNED(s->offset, min_pagesz)) > goto out_err; > > - ret = iommu_map(domain, iova + mapped, phys, s->length, prot); > + ret = __iommu_map(domain, iova + mapped, phys, s->length, prot); > if (ret) > goto out_err; > > mapped += s->length; > } > > + iommu_flush(domain, iova, mapped); > + > return mapped; > > out_err: > /* undo mappings already done */ > iommu_unmap(domain, iova, mapped); > > + /* flush in case part of our mapping already got cached */ > + iommu_flush(domain, iova, mapped); > + > return 0; > > } iommu_unmap() already does an iommu_flush(), so why flush again after iommu_unmap()? Thierry
[toc] | [prev] | [next] | [standalone]
| From | Tomasz Figa <tfiga@chromium.org> |
|---|---|
| Date | 2015-09-29 14:00 +0200 |
| Message-ID | <qe1JD-5BG-7@gated-at.bofh.it> |
| In reply to | #1234913 |
On Tue, Sep 29, 2015 at 6:32 PM, Thierry Reding <thierry.reding@gmail.com> wrote: > On Tue, Sep 29, 2015 at 02:25:24PM +0900, Tomasz Figa wrote: >> This patch adds a new "flush" callback to iommu_ops, which is supposed >> to perform any necessary flushes within given IOMMU domain to make any >> changes to mappings of given area [iova; iova + size) be reflected to >> IOMMU clients. >> >> The purpose is to let IOMMU drivers skip page-by-page flushes and >> replace it with one flush of full address range on devices which support >> it. >> >> Signed-off-by: Tomasz Figa <tfiga@chromium.org> >> --- >> drivers/iommu/iommu.c | 33 ++++++++++++++++++++++++++++++--- >> include/linux/iommu.h | 2 ++ >> 2 files changed, 32 insertions(+), 3 deletions(-) > > I seem to remember that Rob Clark had proposed something like this back > before it was decided to introduce the ->map_sg() callback instead. I > can't find a reference to the discussion, so perhaps I'm misremembering > but adding Rob Clark in case he has any recollection of why the outcome > was what it was. Oops, I was supposed to add Rob, but forgot in the end. Thanks for remembering. >> diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c > [...] >> @@ -1389,6 +1410,7 @@ size_t iommu_unmap(struct iommu_domain *domain, unsigned long iova, size_t size) >> unmapped += unmapped_page; >> } >> >> + iommu_flush(domain, orig_iova, unmapped); >> trace_unmap(orig_iova, size, unmapped); >> return unmapped; >> } >> @@ -1419,19 +1441,24 @@ size_t default_iommu_map_sg(struct iommu_domain *domain, unsigned long iova, >> if (!IS_ALIGNED(s->offset, min_pagesz)) >> goto out_err; >> >> - ret = iommu_map(domain, iova + mapped, phys, s->length, prot); >> + ret = __iommu_map(domain, iova + mapped, phys, s->length, prot); >> if (ret) >> goto out_err; >> >> mapped += s->length; >> } >> >> + iommu_flush(domain, iova, mapped); >> + >> return mapped; >> >> out_err: >> /* undo mappings already done */ >> iommu_unmap(domain, iova, mapped); >> >> + /* flush in case part of our mapping already got cached */ >> + iommu_flush(domain, iova, mapped); >> + >> return 0; >> >> } > > iommu_unmap() already does an iommu_flush(), so why flush again after > iommu_unmap()? Right, my mistake. This should be removed. Thanks for catching. Best regards, Tomasz -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web