Commit adc21579 authored by Philipp Stanner's avatar Philipp Stanner Committed by Danilo Krummrich
Browse files

drm/nouveau: nouveau_fence: Standardize list iterations



nouveau_fence.c iterates over lists in a non-canonical way. Since the
operations done are just basic for-each-loops and list-empty checks,
they should be written in the standard form.

Use standard list operations.

Signed-off-by: default avatarPhilipp Stanner <phasta@kernel.org>
Link: https://lore.kernel.org/r/20250424130254.42046-3-phasta@kernel.org


Signed-off-by: default avatarDanilo Krummrich <dakr@kernel.org>
parent a26fd92b
Loading
Loading
Loading
Loading
+8 −13
Original line number Diff line number Diff line
@@ -83,13 +83,11 @@ nouveau_local_fence(struct dma_fence *fence, struct nouveau_drm *drm)
void
nouveau_fence_context_kill(struct nouveau_fence_chan *fctx, int error)
{
	struct nouveau_fence *fence;
	struct nouveau_fence *fence, *tmp;
	unsigned long flags;

	spin_lock_irqsave(&fctx->lock, flags);
	while (!list_empty(&fctx->pending)) {
		fence = list_entry(fctx->pending.next, typeof(*fence), head);

	list_for_each_entry_safe(fence, tmp, &fctx->pending, head) {
		if (error && !dma_fence_is_signaled_locked(&fence->base))
			dma_fence_set_error(&fence->base, error);

@@ -130,13 +128,11 @@ nouveau_fence_context_free(struct nouveau_fence_chan *fctx)
static int
nouveau_fence_update(struct nouveau_channel *chan, struct nouveau_fence_chan *fctx)
{
	struct nouveau_fence *fence;
	struct nouveau_fence *fence, *tmp;
	int drop = 0;
	u32 seq = fctx->read(chan);

	while (!list_empty(&fctx->pending)) {
		fence = list_entry(fctx->pending.next, typeof(*fence), head);

	list_for_each_entry_safe(fence, tmp, &fctx->pending, head) {
		if ((int)(seq - fence->base.seqno) < 0)
			break;

@@ -151,15 +147,14 @@ nouveau_fence_uevent_work(struct work_struct *work)
{
	struct nouveau_fence_chan *fctx = container_of(work, struct nouveau_fence_chan,
						       uevent_work);
	struct nouveau_channel *chan;
	struct nouveau_fence *fence;
	unsigned long flags;
	int drop = 0;

	spin_lock_irqsave(&fctx->lock, flags);
	if (!list_empty(&fctx->pending)) {
		struct nouveau_fence *fence;
		struct nouveau_channel *chan;

		fence = list_entry(fctx->pending.next, typeof(*fence), head);
	fence = list_first_entry_or_null(&fctx->pending, typeof(*fence), head);
	if (fence) {
		chan = rcu_dereference_protected(fence->channel, lockdep_is_held(&fctx->lock));
		if (nouveau_fence_update(chan, fctx))
			drop = 1;