Skip to contentSkip to conversation

gpu: host1x: Always return syncpoint value when waiting

PATCH New Mikko Perttunen 1 participant 2 messages Feb 7, 2022

Subsystems (3)
lore
Share & tools
lore

Mikko Perttunen

author maintainer
#0 lore raw

PATCH 1/2 gpu: host1x: Always return syncpoint value when waiting

The new TegraDRM UAPI uses syncpoint waiting with timeout set to zero to indicate reading the syncpoint value. To support that we need to return the syncpoint value always when waiting.

Fixes 44e961381354 ("drm/tegra: Implement syncpoint wait UAPI")
---
 drivers/gpu/host1x/syncpt.c | 19 ++-----------------
 1 file changed, 2 insertions(+), 17 deletions(-)
drivers/gpu/host1x/syncpt.c +2 -17
index e08e331e46ae..fb4036a32095 100644
@@ -227,27 +227,12 @@ int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout,
 	void *ref;
 	struct host1x_waitlist *waiter;
 	int err = 0, check_count = 0;
-	u32 val;
 
 	if (value)
-		*value = 0;
-
-	/* first check cache */
-	if (host1x_syncpt_is_expired(sp, thresh)) {
-		if (value)
-			*value = host1x_syncpt_load(sp);
+		*value = host1x_syncpt_load(sp);
 
+	if (host1x_syncpt_is_expired(sp, thresh))
 		return 0;
-	}
-
-	/* try to read from register */
-	val = host1x_hw_syncpt_load(sp->host, sp);
-	if (host1x_syncpt_is_expired(sp, thresh)) {
-		if (value)
-			*value = val;
-
-		goto done;
-	}
 
 	if (!timeout) {
 		err = -EAGAIN;
Signature · 1 line
2.35.0
author maintainer
#1 lore raw

PATCH 2/2 gpu: host1x: Fix refcount leak in buffer cache

The recently introduced buffer cache is causing cached BOs to leak, as cache entries are dropped when a BO's refcount goes to zero but the cache itself keeps a reference to each cache BO, causing a circular reference.

Fix this by not taking a reference to the cached BOs within the cache itself.

Fixes 1f39b1dfa53c ("drm/tegra: Implement buffer object cache")

---
NOTE

As is, applying this patch reveals a BO refcounting issue in the DC driver. A fix for that bug should be applied before applying this patch. I believe Thierry will be posting a fix for that shortly.

---
 drivers/gpu/host1x/bus.c | 3 ---
 1 file changed, 3 deletions(-)
drivers/gpu/host1x/bus.c +0 -3
index bdee16a0bb8e..66ba04501c94 100644
@@ -938,9 +938,6 @@ struct host1x_bo_mapping *host1x_bo_pin(struct device *dev, struct host1x_bo *bo
 		mapping->cache = cache;
 
 		list_add_tail(&mapping->entry, &cache->mappings);
-
-		/* bump reference count to track the copy in the cache */
-		kref_get(&mapping->ref);
 	}
 
 unlock:
Signature · 1 line
2.35.0