public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Thierry Reding <thierry.reding@gmail.com>
To: Alexandre Courbot <acourbot@nvidia.com>
Cc: Ben Skeggs <bskeggs@redhat.com>,
	nouveau@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
	linux-tegra@vger.kernel.org, linux-kernel@vger.kernel.org,
	gnurou@gmail.com
Subject: Re: [PATCH 06/12] drm/nouveau/ibus: add GK20A support
Date: Mon, 24 Mar 2014 23:34:45 +0100	[thread overview]
Message-ID: <20140324223444.GF17218@mithrandir> (raw)
In-Reply-To: <1395650554-31925-7-git-send-email-acourbot@nvidia.com>

[-- Attachment #1: Type: text/plain, Size: 2045 bytes --]

On Mon, Mar 24, 2014 at 05:42:28PM +0900, Alexandre Courbot wrote:
[...]
> diff --git a/drivers/gpu/drm/nouveau/core/subdev/ibus/nvea.c b/drivers/gpu/drm/nouveau/core/subdev/ibus/nvea.c
[...]
> +#include <subdev/ibus.h>
> +
> +struct nvea_ibus_priv {
> +	struct nouveau_ibus base;
> +};
> +
> +static void
> +nvea_ibus_init_priv_ring(struct nvea_ibus_priv *priv)
> +{
> +	nv_mask(priv, 0x137250, 0x3f, 0);
> +
> +	nv_mask(priv, 0x000200, 0x20, 0);
> +	udelay(20);

usleep_range()?

> +static void
> +nvea_ibus_intr(struct nouveau_subdev *subdev)
> +{
[...]
> +	/* Acknowledge interrupt */
> +	nv_mask(priv, 0x12004c, 0x2, 0x2);
> +
> +	while (--retry >= 0) {
> +		command = nv_rd32(priv, 0x12004c) & 0x3f;
> +		if (command == 0)
> +			break;
> +	}
> +
> +	if (retry < 0)
> +		nv_warn(priv, "timeout waiting for ringmaster ack\n");
> +}

Perhaps I'm being paranoid, but this loop now depends on the frequency
of the various clocks involved and therefore might break at some point
if the frequencies get sufficiently high.

So a slightly safer implementation would use a proper timeout using a
combination of msecs_to_jiffies(), time_before() and usleep_range(),
like so:

	timeout = jiffies + msecs_to_jiffies(...);

	while (time_before(jiffies, timeout)) {
		command = nv_rd32(...) & 0x3f;
		if (command == 0)
			break;

		usleep_range(...);
	}

	if (time_after(jiffies, timeout))
		nv_warn(...);

This assumes that there's some known timeout after which the ringmaster
is expected to have acked the interrupt. On that note, I wonder if the
warning is accurate here: it's my understanding that writing 0x2 to the
register does acknowledge the interrupt, so the ringmaster does in fact
"clear" it rather than "acknowledge" it, doesn't it?

Although now that I mention it I seem to remember that this write is
actually sending a command to the ring master and perhaps waiting for
the register to return to 0 is indeed waiting for an ACK of sorts. Maybe
adding a comment or so describing what this sequence does would be
appropriate here?

Thierry

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2014-03-24 22:34 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-03-24  8:42 [PATCH 00/12] drm/nouveau: support for GK20A, cont'd Alexandre Courbot
2014-03-24  8:42 ` [PATCH 01/12] drm/nouveau: fix missing newline Alexandre Courbot
2014-03-24 21:49   ` Thierry Reding
2014-03-24  8:42 ` [PATCH 02/12] drm/nouveau/timer: skip calibration on GK20A Alexandre Courbot
2014-03-24 21:54   ` Thierry Reding
2014-03-26  4:19     ` Ben Skeggs
2014-04-11  2:46       ` Alexandre Courbot
2014-04-11  7:31         ` Ben Skeggs
2014-04-11  7:34           ` Alexandre Courbot
2014-04-14  8:35             ` Ben Skeggs
2014-04-15  6:10               ` Alexandre Courbot
2014-03-24  8:42 ` [PATCH 03/12] drm/nouveau/bar: only ioremap BAR3 if it exists Alexandre Courbot
2014-03-24 22:13   ` Thierry Reding
2014-03-26  4:20     ` [Nouveau] " Ben Skeggs
2014-03-24  8:42 ` [PATCH 04/12] drm/nouveau/bar/nvc0: support chips without BAR3 Alexandre Courbot
2014-03-24 22:10   ` Thierry Reding
2014-04-02 13:47     ` Alexandre Courbot
2014-03-24  8:42 ` [PATCH 05/12] drm/nouveau/fifo: add GK20A support Alexandre Courbot
2014-03-24 22:14   ` Thierry Reding
2014-03-24  8:42 ` [PATCH 06/12] drm/nouveau/ibus: " Alexandre Courbot
2014-03-24 22:34   ` Thierry Reding [this message]
2014-04-02 13:52     ` Alexandre Courbot
2014-04-02 14:18       ` [Nouveau] " Ilia Mirkin
2014-04-02 14:22         ` Alexandre Courbot
2014-03-24  8:42 ` [PATCH 07/12] drm/nouveau/fb: " Alexandre Courbot
2014-03-24  8:42 ` [PATCH 08/12] drm/nouveau/graph: enable when using external firmware Alexandre Courbot
2014-03-24 22:58   ` Thierry Reding
2014-03-26  4:21     ` Ben Skeggs
2014-04-02 13:53       ` Alexandre Courbot
2014-03-24  8:42 ` [PATCH 09/12] drm/nouveau/graph: pad firmware code at load time Alexandre Courbot
2014-03-24 23:02   ` Thierry Reding
2014-03-26  4:22   ` [Nouveau] " Ben Skeggs
2014-04-02 13:54     ` Alexandre Courbot
2014-03-24  8:42 ` [PATCH 10/12] drm/nouveau/graph: add GK20A support Alexandre Courbot
2014-03-26  4:24   ` Ben Skeggs
2014-04-02 14:03     ` Alexandre Courbot
2014-04-02 23:11       ` Ben Skeggs
2014-03-24  8:42 ` [PATCH 11/12] drm/nouveau: support GK20A in nouveau_accel_init() Alexandre Courbot
2014-03-24 23:10   ` Thierry Reding
2014-03-26  4:27     ` Ben Skeggs
2014-04-02 14:14       ` Alexandre Courbot
2014-04-02 14:23         ` [Nouveau] " Ilia Mirkin
2014-04-02 23:14           ` Ben Skeggs
2014-04-16  5:57       ` Alexandre Courbot
2014-03-24  8:42 ` [PATCH 12/12] drm/nouveau: support for probing GK20A Alexandre Courbot
2014-03-24 23:11   ` Thierry Reding
2014-03-26  4:28   ` [Nouveau] " Ben Skeggs
2014-04-02 14:19     ` Alexandre Courbot
2014-03-24 13:19 ` [PATCH 00/12] drm/nouveau: support for GK20A, cont'd Lucas Stach
2014-03-26  6:33   ` Alexandre Courbot
2014-03-26 10:33     ` Lucas Stach
2014-03-27  3:50       ` Alexandre Courbot

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=20140324223444.GF17218@mithrandir \
    --to=thierry.reding@gmail.com \
    --cc=acourbot@nvidia.com \
    --cc=bskeggs@redhat.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gnurou@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=nouveau@lists.freedesktop.org \
    /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