From: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org> To: will.deacon-5wv7dgnIgG8@public.gmane.org, iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Cc: laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org, linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org Subject: [PATCH v2 3/3] iommu/io-pgtable: Avoid redundant TLB syncs Date: Thu, 17 Dec 2015 20:50:59 +0000 [thread overview] Message-ID: <eb7458ed51b800f035976e879530ab1e90d02858.1450383740.git.robin.murphy@arm.com> (raw) In-Reply-To: <cover.1450383740.git.robin.murphy-5wv7dgnIgG8@public.gmane.org> In certain unmapping situations it is quite possible to end up issuing back-to-back TLB synchronisations, which at best is a waste of time and effort, and at worst causes some hardware to get rather confused. Whilst the pagetable implementations, or the IOMMU drivers, or both, could keep track of things to avoid this happening, it seems to make the most sense to prevent code duplication and add some simple state tracking in the common interface between the two. Signed-off-by: Robin Murphy <robin.murphy-5wv7dgnIgG8@public.gmane.org> --- drivers/iommu/io-pgtable.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/io-pgtable.h b/drivers/iommu/io-pgtable.h index 95c5565..d06219b 100644 --- a/drivers/iommu/io-pgtable.h +++ b/drivers/iommu/io-pgtable.h @@ -132,12 +132,14 @@ void free_io_pgtable_ops(struct io_pgtable_ops *ops); * @fmt: The page table format. * @cookie: An opaque token provided by the IOMMU driver and passed back to * any callback routines. + * @sync_flag: Private flag for optimising out redundant syncs. * @cfg: A copy of the page table configuration. * @ops: The page table operations in use for this set of page tables. */ struct io_pgtable { enum io_pgtable_fmt fmt; void *cookie; + bool sync_flag; struct io_pgtable_cfg cfg; struct io_pgtable_ops ops; }; @@ -147,17 +149,22 @@ struct io_pgtable { static inline void io_pgtable_tlb_flush_all(struct io_pgtable *iop) { iop->cfg.tlb->tlb_flush_all(iop->cookie); + iop->sync_flag = true; } static inline void io_pgtable_tlb_add_flush(struct io_pgtable *iop, unsigned long iova, size_t size, size_t granule, bool leaf) { iop->cfg.tlb->tlb_add_flush(iova, size, granule, leaf, iop->cookie); + iop->sync_flag = true; } static inline void io_pgtable_tlb_sync(struct io_pgtable *iop) { - iop->cfg.tlb->tlb_sync(iop->cookie); + if (iop->sync_flag) { + iop->cfg.tlb->tlb_sync(iop->cookie); + iop->sync_flag = false; + } } /** -- 1.9.1
WARNING: multiple messages have this Message-ID (diff)
From: robin.murphy@arm.com (Robin Murphy) To: linux-arm-kernel@lists.infradead.org Subject: [PATCH v2 3/3] iommu/io-pgtable: Avoid redundant TLB syncs Date: Thu, 17 Dec 2015 20:50:59 +0000 [thread overview] Message-ID: <eb7458ed51b800f035976e879530ab1e90d02858.1450383740.git.robin.murphy@arm.com> (raw) In-Reply-To: <cover.1450383740.git.robin.murphy@arm.com> In certain unmapping situations it is quite possible to end up issuing back-to-back TLB synchronisations, which at best is a waste of time and effort, and at worst causes some hardware to get rather confused. Whilst the pagetable implementations, or the IOMMU drivers, or both, could keep track of things to avoid this happening, it seems to make the most sense to prevent code duplication and add some simple state tracking in the common interface between the two. Signed-off-by: Robin Murphy <robin.murphy@arm.com> --- drivers/iommu/io-pgtable.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/io-pgtable.h b/drivers/iommu/io-pgtable.h index 95c5565..d06219b 100644 --- a/drivers/iommu/io-pgtable.h +++ b/drivers/iommu/io-pgtable.h @@ -132,12 +132,14 @@ void free_io_pgtable_ops(struct io_pgtable_ops *ops); * @fmt: The page table format. * @cookie: An opaque token provided by the IOMMU driver and passed back to * any callback routines. + * @sync_flag: Private flag for optimising out redundant syncs. * @cfg: A copy of the page table configuration. * @ops: The page table operations in use for this set of page tables. */ struct io_pgtable { enum io_pgtable_fmt fmt; void *cookie; + bool sync_flag; struct io_pgtable_cfg cfg; struct io_pgtable_ops ops; }; @@ -147,17 +149,22 @@ struct io_pgtable { static inline void io_pgtable_tlb_flush_all(struct io_pgtable *iop) { iop->cfg.tlb->tlb_flush_all(iop->cookie); + iop->sync_flag = true; } static inline void io_pgtable_tlb_add_flush(struct io_pgtable *iop, unsigned long iova, size_t size, size_t granule, bool leaf) { iop->cfg.tlb->tlb_add_flush(iova, size, granule, leaf, iop->cookie); + iop->sync_flag = true; } static inline void io_pgtable_tlb_sync(struct io_pgtable *iop) { - iop->cfg.tlb->tlb_sync(iop->cookie); + if (iop->sync_flag) { + iop->cfg.tlb->tlb_sync(iop->cookie); + iop->sync_flag = false; + } } /** -- 1.9.1
next prev parent reply other threads:[~2015-12-17 20:50 UTC|newest] Thread overview: 28+ messages / expand[flat|nested] mbox.gz Atom feed top 2015-12-17 20:50 [PATCH v2 0/3] io-pgtable ARM short descriptor format Robin Murphy 2015-12-17 20:50 ` Robin Murphy [not found] ` <cover.1450383740.git.robin.murphy-5wv7dgnIgG8@public.gmane.org> 2015-12-17 20:50 ` [PATCH v2 1/3] iommu/io-pgtable: Add ARMv7 short descriptor support Robin Murphy 2015-12-17 20:50 ` Robin Murphy 2016-01-14 13:05 ` Yong Wu 2016-01-14 13:05 ` Yong Wu 2016-01-15 15:13 ` Robin Murphy 2016-01-15 15:13 ` Robin Murphy [not found] ` <56990CAC.5020606-5wv7dgnIgG8@public.gmane.org> 2016-01-18 6:28 ` Yong Wu 2016-01-18 6:28 ` Yong Wu 2016-01-18 7:22 ` Yong Wu 2016-01-18 7:22 ` Yong Wu 2015-12-17 20:50 ` [PATCH v2 2/3] iommu/io-pgtable: Add helper functions for TLB ops Robin Murphy 2015-12-17 20:50 ` Robin Murphy [not found] ` <a2a13711c528af068e932ce6af4c3be50bef5812.1450383740.git.robin.murphy-5wv7dgnIgG8@public.gmane.org> 2016-01-12 18:28 ` Will Deacon 2016-01-12 18:28 ` Will Deacon 2016-01-15 23:24 ` Laurent Pinchart 2016-01-15 23:24 ` Laurent Pinchart 2015-12-17 20:50 ` Robin Murphy [this message] 2015-12-17 20:50 ` [PATCH v2 3/3] iommu/io-pgtable: Avoid redundant TLB syncs Robin Murphy [not found] ` <eb7458ed51b800f035976e879530ab1e90d02858.1450383740.git.robin.murphy-5wv7dgnIgG8@public.gmane.org> 2016-01-12 18:27 ` Will Deacon 2016-01-12 18:27 ` Will Deacon [not found] ` <20160112182754.GC22186-5wv7dgnIgG8@public.gmane.org> 2016-01-13 11:18 ` Robin Murphy 2016-01-13 11:18 ` Robin Murphy [not found] ` <56963297.7090605-5wv7dgnIgG8@public.gmane.org> 2016-01-13 11:22 ` Robin Murphy 2016-01-13 11:22 ` Robin Murphy 2016-01-15 23:26 ` Laurent Pinchart 2016-01-15 23:26 ` Laurent Pinchart
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=eb7458ed51b800f035976e879530ab1e90d02858.1450383740.git.robin.murphy@arm.com \ --to=robin.murphy-5wv7dgnigg8@public.gmane.org \ --cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \ --cc=laurent.pinchart+renesas-ryLnwIuWjnjg/C1BVhZhaw@public.gmane.org \ --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \ --cc=will.deacon-5wv7dgnIgG8@public.gmane.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.