summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/openchrome
diff options
context:
space:
mode:
authorKevin Brace <kevinbrace@gmx.com>2020-11-23 14:05:00 -0800
committerKevin Brace <kevinbrace@gmx.com>2020-11-23 14:05:00 -0800
commit472a3583fbb15b3261cfbea7b4419041aa1b0c61 (patch)
tree960987328836d54f4e1608a5cbc3b7d486b8a806 /drivers/gpu/drm/openchrome
parentceaa5b2f9c9e75007ae9e32ecd69f48fee239b8f (diff)
drm/openchrome: Keep count of BO pin count
Signed-off-by: Kevin Brace <kevinbrace@gmx.com>
Diffstat (limited to 'drivers/gpu/drm/openchrome')
-rw-r--r--drivers/gpu/drm/openchrome/openchrome_drv.h1
-rw-r--r--drivers/gpu/drm/openchrome/openchrome_object.c27
2 files changed, 25 insertions, 3 deletions
diff --git a/drivers/gpu/drm/openchrome/openchrome_drv.h b/drivers/gpu/drm/openchrome/openchrome_drv.h
index 54740077f04a..d8fa91e5dcfa 100644
--- a/drivers/gpu/drm/openchrome/openchrome_drv.h
+++ b/drivers/gpu/drm/openchrome/openchrome_drv.h
@@ -196,6 +196,7 @@ struct openchrome_bo {
struct ttm_placement placement;
struct ttm_place placements[OPENCHROME_TTM_PL_NUM];
struct drm_gem_object gem;
+ int pin_count;
};
struct openchrome_framebuffer {
diff --git a/drivers/gpu/drm/openchrome/openchrome_object.c b/drivers/gpu/drm/openchrome/openchrome_object.c
index 24b421672a58..ec78df8a3c44 100644
--- a/drivers/gpu/drm/openchrome/openchrome_object.c
+++ b/drivers/gpu/drm/openchrome/openchrome_object.c
@@ -101,16 +101,27 @@ int openchrome_bo_pin(struct openchrome_bo *bo,
{
struct ttm_operation_ctx ctx = {false, false};
uint32_t i;
- int ret;
+ int ret = 0;
DRM_DEBUG_KMS("Entered %s.\n", __func__);
+ if (bo->pin_count) {
+ bo->pin_count++;
+ goto exit;
+ }
+
openchrome_ttm_domain_to_placement(bo, ttm_domain);
for (i = 0; i < bo->placement.num_placement; i++) {
bo->placements[i].flags |= TTM_PL_FLAG_NO_EVICT;
}
ret = ttm_bo_validate(&bo->ttm_bo, &bo->placement, &ctx);
+ if (ret) {
+ goto exit;
+ }
+
+ bo->pin_count++;
+exit:
DRM_DEBUG_KMS("Exiting %s.\n", __func__);
return ret;
@@ -120,16 +131,26 @@ int openchrome_bo_unpin(struct openchrome_bo *bo)
{
struct ttm_operation_ctx ctx = {false, false};
uint32_t i;
- int ret;
+ int ret = 0;
DRM_DEBUG_KMS("Entered %s.\n", __func__);
+ if (!bo->pin_count) {
+ DRM_ERROR("Bad unpin.\n");
+ goto exit;
+ }
+
+ bo->pin_count--;
+ if (bo->pin_count) {
+ goto exit;
+ }
+
for (i = 0; i < bo->placement.num_placement; i++) {
bo->placements[i].flags &= ~TTM_PL_FLAG_NO_EVICT;
}
ret = ttm_bo_validate(&bo->ttm_bo, &bo->placement, &ctx);
-
+exit:
DRM_DEBUG_KMS("Exiting %s.\n", __func__);
return ret;
}