* [PATCH] gpu: host1x: Do not use mapping cache for job submissions
@ 2022-03-24 10:30 ` Thierry Reding
0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2022-03-24 10:30 UTC (permalink / raw)
To: Thierry Reding; +Cc: linux-tegra, Jon Hunter, dri-devel, Mikko Perttunen
From: Thierry Reding <treding@nvidia.com>
Buffer mappings used in job submissions are usually small and not
rapidly reused as opposed to framebuffers (which are usually large and
rapidly reused, for example when page-flipping between double-buffered
framebuffers). Avoid going through the mapping cache for these buffers
since the cache would also lead to leaks if nobody is ever releasing
the cache's last reference. For DRM/KMS these last references are
dropped when the framebuffers are removed and therefore no longer
needed.
While at it, also add a note about the need to explicitly remove the
final reference to the mapping in the cache.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/gpu/host1x/job.c | 4 ++--
include/linux/host1x.h | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c
index 9424b3c08ab2..f81f3b9f7510 100644
--- a/drivers/gpu/host1x/job.c
+++ b/drivers/gpu/host1x/job.c
@@ -176,7 +176,7 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
goto unpin;
}
- map = host1x_bo_pin(dev, bo, direction, &client->cache);
+ map = host1x_bo_pin(dev, bo, direction, NULL);
if (IS_ERR(map)) {
host1x_bo_put(bo);
err = PTR_ERR(map);
@@ -226,7 +226,7 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
goto unpin;
}
- map = host1x_bo_pin(host->dev, g->bo, DMA_TO_DEVICE, &host->cache);
+ map = host1x_bo_pin(host->dev, g->bo, DMA_TO_DEVICE, NULL);
if (IS_ERR(map)) {
host1x_bo_put(g->bo);
err = PTR_ERR(map);
diff --git a/include/linux/host1x.h b/include/linux/host1x.h
index e8dc5bc41f79..46081afd0ca0 100644
--- a/include/linux/host1x.h
+++ b/include/linux/host1x.h
@@ -31,6 +31,11 @@ u64 host1x_get_dma_mask(struct host1x *host1x);
* struct host1x_bo_cache - host1x buffer object cache
* @mappings: list of mappings
* @lock: synchronizes accesses to the list of mappings
+ *
+ * Note that entries are not periodically evicted from this cache and instead need to be
+ * explicitly released. This is used primarily for DRM/KMS where the cache's reference is
+ * released when the last reference to a buffer object represented by a mapping in this
+ * cache is dropped.
*/
struct host1x_bo_cache {
struct list_head mappings;
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH] gpu: host1x: Do not use mapping cache for job submissions
@ 2022-03-24 10:30 ` Thierry Reding
0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2022-03-24 10:30 UTC (permalink / raw)
To: Thierry Reding; +Cc: Mikko Perttunen, Jon Hunter, dri-devel, linux-tegra
From: Thierry Reding <treding@nvidia.com>
Buffer mappings used in job submissions are usually small and not
rapidly reused as opposed to framebuffers (which are usually large and
rapidly reused, for example when page-flipping between double-buffered
framebuffers). Avoid going through the mapping cache for these buffers
since the cache would also lead to leaks if nobody is ever releasing
the cache's last reference. For DRM/KMS these last references are
dropped when the framebuffers are removed and therefore no longer
needed.
While at it, also add a note about the need to explicitly remove the
final reference to the mapping in the cache.
Signed-off-by: Thierry Reding <treding@nvidia.com>
---
drivers/gpu/host1x/job.c | 4 ++--
include/linux/host1x.h | 5 +++++
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/host1x/job.c b/drivers/gpu/host1x/job.c
index 9424b3c08ab2..f81f3b9f7510 100644
--- a/drivers/gpu/host1x/job.c
+++ b/drivers/gpu/host1x/job.c
@@ -176,7 +176,7 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
goto unpin;
}
- map = host1x_bo_pin(dev, bo, direction, &client->cache);
+ map = host1x_bo_pin(dev, bo, direction, NULL);
if (IS_ERR(map)) {
host1x_bo_put(bo);
err = PTR_ERR(map);
@@ -226,7 +226,7 @@ static unsigned int pin_job(struct host1x *host, struct host1x_job *job)
goto unpin;
}
- map = host1x_bo_pin(host->dev, g->bo, DMA_TO_DEVICE, &host->cache);
+ map = host1x_bo_pin(host->dev, g->bo, DMA_TO_DEVICE, NULL);
if (IS_ERR(map)) {
host1x_bo_put(g->bo);
err = PTR_ERR(map);
diff --git a/include/linux/host1x.h b/include/linux/host1x.h
index e8dc5bc41f79..46081afd0ca0 100644
--- a/include/linux/host1x.h
+++ b/include/linux/host1x.h
@@ -31,6 +31,11 @@ u64 host1x_get_dma_mask(struct host1x *host1x);
* struct host1x_bo_cache - host1x buffer object cache
* @mappings: list of mappings
* @lock: synchronizes accesses to the list of mappings
+ *
+ * Note that entries are not periodically evicted from this cache and instead need to be
+ * explicitly released. This is used primarily for DRM/KMS where the cache's reference is
+ * released when the last reference to a buffer object represented by a mapping in this
+ * cache is dropped.
*/
struct host1x_bo_cache {
struct list_head mappings;
--
2.35.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] gpu: host1x: Do not use mapping cache for job submissions
2022-03-24 10:30 ` Thierry Reding
@ 2022-04-04 12:33 ` Jon Hunter
-1 siblings, 0 replies; 5+ messages in thread
From: Jon Hunter @ 2022-04-04 12:33 UTC (permalink / raw)
To: Thierry Reding; +Cc: Mikko Perttunen, dri-devel, linux-tegra
On 24/03/2022 10:30, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Buffer mappings used in job submissions are usually small and not
> rapidly reused as opposed to framebuffers (which are usually large and
> rapidly reused, for example when page-flipping between double-buffered
> framebuffers). Avoid going through the mapping cache for these buffers
> since the cache would also lead to leaks if nobody is ever releasing
> the cache's last reference. For DRM/KMS these last references are
> dropped when the framebuffers are removed and therefore no longer
> needed.
>
> While at it, also add a note about the need to explicitly remove the
> final reference to the mapping in the cache.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
I have tested this and verified that it is working well.
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Thanks
Jon
--
nvpublic
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpu: host1x: Do not use mapping cache for job submissions
@ 2022-04-04 12:33 ` Jon Hunter
0 siblings, 0 replies; 5+ messages in thread
From: Jon Hunter @ 2022-04-04 12:33 UTC (permalink / raw)
To: Thierry Reding; +Cc: linux-tegra, dri-devel, Mikko Perttunen
On 24/03/2022 10:30, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Buffer mappings used in job submissions are usually small and not
> rapidly reused as opposed to framebuffers (which are usually large and
> rapidly reused, for example when page-flipping between double-buffered
> framebuffers). Avoid going through the mapping cache for these buffers
> since the cache would also lead to leaks if nobody is ever releasing
> the cache's last reference. For DRM/KMS these last references are
> dropped when the framebuffers are removed and therefore no longer
> needed.
>
> While at it, also add a note about the need to explicitly remove the
> final reference to the mapping in the cache.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
I have tested this and verified that it is working well.
Reviewed-by: Jon Hunter <jonathanh@nvidia.com>
Tested-by: Jon Hunter <jonathanh@nvidia.com>
Thanks
Jon
--
nvpublic
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] gpu: host1x: Do not use mapping cache for job submissions
2022-03-24 10:30 ` Thierry Reding
(?)
(?)
@ 2022-04-06 13:13 ` Thierry Reding
-1 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2022-04-06 13:13 UTC (permalink / raw)
To: Mikko Perttunen, Jon Hunter, dri-devel, linux-tegra
[-- Attachment #1: Type: text/plain, Size: 968 bytes --]
On Thu, Mar 24, 2022 at 11:30:25AM +0100, Thierry Reding wrote:
> From: Thierry Reding <treding@nvidia.com>
>
> Buffer mappings used in job submissions are usually small and not
> rapidly reused as opposed to framebuffers (which are usually large and
> rapidly reused, for example when page-flipping between double-buffered
> framebuffers). Avoid going through the mapping cache for these buffers
> since the cache would also lead to leaks if nobody is ever releasing
> the cache's last reference. For DRM/KMS these last references are
> dropped when the framebuffers are removed and therefore no longer
> needed.
>
> While at it, also add a note about the need to explicitly remove the
> final reference to the mapping in the cache.
>
> Signed-off-by: Thierry Reding <treding@nvidia.com>
> ---
> drivers/gpu/host1x/job.c | 4 ++--
> include/linux/host1x.h | 5 +++++
> 2 files changed, 7 insertions(+), 2 deletions(-)
Applied.
Thierry
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2022-04-06 15:41 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-24 10:30 [PATCH] gpu: host1x: Do not use mapping cache for job submissions Thierry Reding
2022-03-24 10:30 ` Thierry Reding
2022-04-04 12:33 ` Jon Hunter
2022-04-04 12:33 ` Jon Hunter
2022-04-06 13:13 ` Thierry Reding
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.