Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2d9445db authored by Kieran Bingham's avatar Kieran Bingham Committed by Mauro Carvalho Chehab
Browse files

media: vsp1: Use reference counting for bodies



Extend the display list body with a reference count, allowing bodies to
be kept as long as a reference is maintained. This provides the ability
to keep a cached copy of bodies which will not change, so that they can
be re-applied to multiple display lists.

Signed-off-by: default avatarKieran Bingham <kieran.bingham+renesas@ideasonboard.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+samsung@kernel.org>
parent 5d7936b8
Loading
Loading
Loading
Loading
+6 −1
Original line number Original line Diff line number Diff line
@@ -212,8 +212,13 @@ static void clu_configure(struct vsp1_entity *entity,
		clu->clu = NULL;
		clu->clu = NULL;
		spin_unlock_irqrestore(&clu->lock, flags);
		spin_unlock_irqrestore(&clu->lock, flags);


		if (dlb)
		if (dlb) {
			vsp1_dl_list_add_body(dl, dlb);
			vsp1_dl_list_add_body(dl, dlb);

			/* Release our local reference. */
			vsp1_dl_body_put(dlb);
		}

		break;
		break;
	}
	}
}
}
+14 −2
Original line number Original line Diff line number Diff line
@@ -10,6 +10,7 @@
#include <linux/device.h>
#include <linux/device.h>
#include <linux/dma-mapping.h>
#include <linux/dma-mapping.h>
#include <linux/gfp.h>
#include <linux/gfp.h>
#include <linux/refcount.h>
#include <linux/slab.h>
#include <linux/slab.h>
#include <linux/workqueue.h>
#include <linux/workqueue.h>


@@ -54,6 +55,8 @@ struct vsp1_dl_body {
	struct list_head list;
	struct list_head list;
	struct list_head free;
	struct list_head free;


	refcount_t refcnt;

	struct vsp1_dl_body_pool *pool;
	struct vsp1_dl_body_pool *pool;
	struct vsp1_device *vsp1;
	struct vsp1_device *vsp1;


@@ -258,6 +261,7 @@ struct vsp1_dl_body *vsp1_dl_body_get(struct vsp1_dl_body_pool *pool)
	if (!list_empty(&pool->free)) {
	if (!list_empty(&pool->free)) {
		dlb = list_first_entry(&pool->free, struct vsp1_dl_body, free);
		dlb = list_first_entry(&pool->free, struct vsp1_dl_body, free);
		list_del(&dlb->free);
		list_del(&dlb->free);
		refcount_set(&dlb->refcnt, 1);
	}
	}


	spin_unlock_irqrestore(&pool->lock, flags);
	spin_unlock_irqrestore(&pool->lock, flags);
@@ -278,6 +282,9 @@ void vsp1_dl_body_put(struct vsp1_dl_body *dlb)
	if (!dlb)
	if (!dlb)
		return;
		return;


	if (!refcount_dec_and_test(&dlb->refcnt))
		return;

	dlb->num_entries = 0;
	dlb->num_entries = 0;


	spin_lock_irqsave(&dlb->pool->lock, flags);
	spin_lock_irqsave(&dlb->pool->lock, flags);
@@ -463,8 +470,11 @@ void vsp1_dl_list_write(struct vsp1_dl_list *dl, u32 reg, u32 data)
 * which bodies are added.
 * which bodies are added.
 *
 *
 * Adding a body to a display list passes ownership of the body to the list. The
 * Adding a body to a display list passes ownership of the body to the list. The
 * caller must not touch the body after this call, and must not release it
 * caller retains its reference to the fragment when adding it to the display
 * explicitly with vsp1_dl_body_put().
 * list, but is not allowed to add new entries to the body.
 *
 * The reference must be explicitly released by a call to vsp1_dl_body_put()
 * when the body isn't needed anymore.
 *
 *
 * Additional bodies are only usable for display lists in header mode.
 * Additional bodies are only usable for display lists in header mode.
 * Attempting to add a body to a header-less display list will return an error.
 * Attempting to add a body to a header-less display list will return an error.
@@ -475,6 +485,8 @@ int vsp1_dl_list_add_body(struct vsp1_dl_list *dl, struct vsp1_dl_body *dlb)
	if (dl->dlm->mode != VSP1_DL_MODE_HEADER)
	if (dl->dlm->mode != VSP1_DL_MODE_HEADER)
		return -EINVAL;
		return -EINVAL;


	refcount_inc(&dlb->refcnt);

	list_add_tail(&dlb->list, &dl->bodies);
	list_add_tail(&dlb->list, &dl->bodies);


	return 0;
	return 0;
+6 −1
Original line number Original line Diff line number Diff line
@@ -168,8 +168,13 @@ static void lut_configure(struct vsp1_entity *entity,
		lut->lut = NULL;
		lut->lut = NULL;
		spin_unlock_irqrestore(&lut->lock, flags);
		spin_unlock_irqrestore(&lut->lock, flags);


		if (dlb)
		if (dlb) {
			vsp1_dl_list_add_body(dl, dlb);
			vsp1_dl_list_add_body(dl, dlb);

			/* Release our local reference. */
			vsp1_dl_body_put(dlb);
		}

		break;
		break;
	}
	}
}
}