linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Marek Szyprowski <m.szyprowski@samsung.com>
To: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	iommu@lists.linux-foundation.org,
	linux-samsung-soc@vger.kernel.org, Joerg Roedel <joro@8bytes.org>
Cc: Marek Szyprowski <m.szyprowski@samsung.com>,
	Inki Dae <inki.dae@samsung.com>, Kukjin Kim <kgene@kernel.org>,
	Krzysztof Kozlowski <krzk@kernel.org>,
	Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Mark Brown <broonie@kernel.org>,
	"Luis R. Rodriguez" <mcgrof@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Tomeu Vizoso <tomeu.vizoso@collabora.com>,
	Lukas Wunner <lukas@wunner.de>, Kevin Hilman <khilman@kernel.org>,
	Tobias Jakobi <tjakobi@math.uni-bielefeld.de>,
	Tomasz Figa <tomasz.figa@gmail.com>
Subject: [PATCH v6 4/7] iommu/exynos: Set master device once on boot
Date: Tue, 08 Nov 2016 14:29:21 +0100	[thread overview]
Message-ID: <1478611764-6473-5-git-send-email-m.szyprowski@samsung.com> (raw)
In-Reply-To: <1478611764-6473-1-git-send-email-m.szyprowski@samsung.com>

To avoid possible races, set master device pointer in each SYSMMU
controller once on boot. Suspend/resume callbacks now properly relies on
the configured iommu domain to enable or disable SYSMMU controller.
While changing the code, also update the sleep debug messages and make
them conditional.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 drivers/iommu/exynos-iommu.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/iommu/exynos-iommu.c b/drivers/iommu/exynos-iommu.c
index f45b274..28e570b 100644
--- a/drivers/iommu/exynos-iommu.c
+++ b/drivers/iommu/exynos-iommu.c
@@ -600,10 +600,12 @@ static int exynos_sysmmu_suspend(struct device *dev)
 	struct sysmmu_drvdata *data = dev_get_drvdata(dev);
 	struct device *master = data->master;
 
-	dev_dbg(dev, "suspend\n");
 	if (master) {
-		__sysmmu_disable(data);
 		pm_runtime_put(dev);
+		if (data->domain) {
+			dev_dbg(data->sysmmu, "saving state\n");
+			__sysmmu_disable(data);
+		}
 	}
 	return 0;
 }
@@ -613,10 +615,12 @@ static int exynos_sysmmu_resume(struct device *dev)
 	struct sysmmu_drvdata *data = dev_get_drvdata(dev);
 	struct device *master = data->master;
 
-	dev_dbg(dev, "resume\n");
 	if (master) {
 		pm_runtime_get_sync(dev);
-		__sysmmu_enable(data);
+		if (data->domain) {
+			dev_dbg(data->sysmmu, "restoring state\n");
+			__sysmmu_enable(data);
+		}
 	}
 	return 0;
 }
@@ -730,7 +734,6 @@ static void exynos_iommu_domain_free(struct iommu_domain *iommu_domain)
 		__sysmmu_disable(data);
 		data->pgtable = 0;
 		data->domain = NULL;
-		data->master = NULL;
 		list_del_init(&data->domain_node);
 	}
 
@@ -772,7 +775,6 @@ static void exynos_iommu_detach_device(struct iommu_domain *iommu_domain,
 	spin_lock_irqsave(&domain->lock, flags);
 	list_for_each_entry_safe(data, next, &domain->clients, domain_node) {
 		__sysmmu_disable(data);
-		data->master = NULL;
 		data->pgtable = 0;
 		data->domain = NULL;
 		list_del_init(&data->domain_node);
@@ -806,7 +808,6 @@ static int exynos_iommu_attach_device(struct iommu_domain *iommu_domain,
 		data->domain = domain;
 		pm_runtime_get_sync(data->sysmmu);
 		__sysmmu_enable(data);
-		data->master = dev;
 
 		spin_lock_irqsave(&domain->lock, flags);
 		list_add_tail(&data->domain_node, &domain->clients);
@@ -1192,6 +1193,7 @@ static int exynos_iommu_of_xlate(struct device *dev,
 	}
 
 	list_add_tail(&data->owner_node, &owner->controllers);
+	data->master = dev;
 	return 0;
 }
 
-- 
1.9.1

  parent reply	other threads:[~2016-11-08 13:32 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20161108133014eucas1p2a5dd3306a464ee840e26532f6c405b66@eucas1p2.samsung.com>
2016-11-08 13:29 ` [PATCH v6 0/7] Exynos IOMMU: proper runtime PM support (use device dependencies) Marek Szyprowski
     [not found]   ` <CGME20161108133014eucas1p211e2f31b0091d22014c2a5940c3da1dd@eucas1p2.samsung.com>
2016-11-08 13:29     ` [PATCH v6 1/7] iommu/exynos: Remove excessive, useless debug Marek Szyprowski
     [not found]   ` <CGME20161108133015eucas1p234c8c7076bcda5020ae8b78e87a0203d@eucas1p2.samsung.com>
2016-11-08 13:29     ` [PATCH v6 2/7] iommu/exynos: Remove dead code Marek Szyprowski
     [not found]   ` <CGME20161108133016eucas1p27a25afd3a49bfc1e3e41c5a32e022f07@eucas1p2.samsung.com>
2016-11-08 13:29     ` [PATCH v6 3/7] iommu/exynos: Simplify internal enable/disable functions Marek Szyprowski
2016-11-10 16:40       ` Joerg Roedel
     [not found]   ` <CGME20161108133017eucas1p29e9dc833d57d4f7951d053dab8ba6bef@eucas1p2.samsung.com>
2016-11-08 13:29     ` Marek Szyprowski [this message]
     [not found]   ` <CGME20161108133017eucas1p28233851f230060cf91d31298bcf69e07@eucas1p2.samsung.com>
2016-11-08 13:29     ` [PATCH v6 5/7] iommu/exynos: Rework and fix internal locking Marek Szyprowski
     [not found]   ` <CGME20161108133018eucas1p27180e82ae25189bda573766251491e66@eucas1p2.samsung.com>
2016-11-08 13:29     ` [PATCH v6 6/7] iommu/exynos: Add runtime pm support Marek Szyprowski
     [not found]   ` <CGME20161108133019eucas1p1be275492ba670030324a164320866008@eucas1p1.samsung.com>
2016-11-08 13:29     ` [PATCH v6 7/7] iommu/exynos: Use device dependency links to control runtime pm Marek Szyprowski
2016-11-09 23:31       ` Luis R. Rodriguez
2016-11-09 23:42         ` Rafael J. Wysocki

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=1478611764-6473-5-git-send-email-m.szyprowski@samsung.com \
    --to=m.szyprowski@samsung.com \
    --cc=b.zolnierkie@samsung.com \
    --cc=broonie@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=inki.dae@samsung.com \
    --cc=iommu@lists.linux-foundation.org \
    --cc=joro@8bytes.org \
    --cc=kgene@kernel.org \
    --cc=khilman@kernel.org \
    --cc=krzk@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=mcgrof@kernel.org \
    --cc=rjw@rjwysocki.net \
    --cc=tjakobi@math.uni-bielefeld.de \
    --cc=tomasz.figa@gmail.com \
    --cc=tomeu.vizoso@collabora.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;
as well as URLs for NNTP newsgroup(s).