From: Boris Brezillon <boris.brezillon@collabora.com>
To: Steven Price <steven.price@arm.com>
Cc: Rob Herring <robh+dt@kernel.org>,
Tomeu Vizoso <tomeu@tomeuvizoso.net>,
Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>,
Robin Murphy <robin.murphy@arm.com>,
Daniel Vetter <daniel@ffwll.ch>,
dri-devel@lists.freedesktop.org, stable@vger.kernel.org
Subject: Re: [PATCH v4] drm/panfrost: Move the GPU reset bits outside the timeout handler
Date: Thu, 5 Nov 2020 14:39:53 +0100 [thread overview]
Message-ID: <20201105143953.516e75b2@collabora.com> (raw)
In-Reply-To: <d59e4750-ad1a-5573-16db-ad9b57b6eec5@arm.com>
On Thu, 5 Nov 2020 13:27:04 +0000
Steven Price <steven.price@arm.com> wrote:
> > + old_status = atomic_xchg(&queue->status,
> > + PANFROST_QUEUE_STATUS_STOPPED);
> > + WARN_ON(old_status != PANFROST_QUEUE_STATUS_ACTIVE &&
> > + old_status != PANFROST_QUEUE_STATUS_STOPPED);
> > + if (old_status == PANFROST_QUEUE_STATUS_STOPPED)
> > + goto out;
>
> NIT: It's slightly cleaner if you swap the above lines, i.e.:
>
> if (old_status == PANFROST_QUEUE_STATUS_STOPPED)
> goto out;
> WARN_ON(old_status != PANFROST_QUEUE_STATUS_ACTIVE);
I agree.
>
> > +
> > + drm_sched_stop(&queue->sched, bad);
> > + if (bad)
> > + drm_sched_increase_karma(bad);
> > +
> > + stopped = true;
> > +
> > + /*
> > + * Set the timeout to max so the timer doesn't get started
> > + * when we return from the timeout handler (restored in
> > + * panfrost_scheduler_start()).
> > + */
> > + queue->sched.timeout = MAX_SCHEDULE_TIMEOUT;
> > +
> > +out:
> > mutex_unlock(&queue->lock);
> >
> > return stopped;
> > }
> >
> > +static void panfrost_scheduler_start(struct panfrost_queue_state *queue)
> > +{
> > + enum panfrost_queue_status old_status;
> > +
> > + mutex_lock(&queue->lock);
> > + old_status = atomic_xchg(&queue->status,
> > + PANFROST_QUEUE_STATUS_STARTING);
> > + if (WARN_ON(old_status != PANFROST_QUEUE_STATUS_STOPPED))
> > + goto out;
>
> The error handling isn't great here - in this case the queue status is
> left in _STATUS_STARTING, which at best would lead to another WARN_ON
> being hit, but also has the effect of ignoring job faults. Probably the
> timeout would eventually get things back to normal.
>
> Obviously this situation will never occur™, but we can do better either
> by continuing with the normal logic below, or even better replacing
> atomic_xchg() with an atomic_cmpxchg() (so leave the status alone if not
> _STOPPED). Both seem like better error recovery options to me. But keep
> the WARN_ON because something has clearly gone wrong if this happens.
The second approach doesn't unblock things if we end up with
old_status != STOPPED and the queue is really stopped (which shouldn't
happen, unless we have a problem in our state machine). I think I'll
go for the first option and restart the queue unconditionally (I'm
keeping the WARN_ON(), of course).
prev parent reply other threads:[~2020-11-05 13:40 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-04 17:07 [PATCH v4] drm/panfrost: Move the GPU reset bits outside the timeout handler Boris Brezillon
2020-11-04 17:20 ` Boris Brezillon
2020-11-05 13:27 ` Steven Price
2020-11-05 13:39 ` Boris Brezillon [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201105143953.516e75b2@collabora.com \
--to=boris.brezillon@collabora.com \
--cc=alyssa.rosenzweig@collabora.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=robh+dt@kernel.org \
--cc=robin.murphy@arm.com \
--cc=stable@vger.kernel.org \
--cc=steven.price@arm.com \
--cc=tomeu@tomeuvizoso.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).