From: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Subject: [PATCH 10/10] drm/nouveau: fix off-by-one bugs related to command submission in IB mode
Date: Sun, 19 Aug 2012 23:02:00 +0200 [thread overview]
Message-ID: <20120819210200.GA26902@joi.lan> (raw)
Commit "drm/nouveau: port all engines to new engine module format" changed
IB size calculation to be less wasteful, but didn't take into account already
existing off-by-one bugs :).
So:
- ib_max is the last entry, so we need to +1 when calculating number of
free entries
- nv50_dma_wait already does +1 (for FIRE_RING), so we don't need another +1
on nouveau_gem_ioctl_pushbuf side
- there are 512 allocated IB entries (and it needs to be round number), so we
can accept at most 511 entries from userspace (we need one for FIRE_RING) -
fortunately userspace already flushes at 511, so nr_push check change won't
have any impact
Signed-off-by: Marcin Slusarz <marcin.slusarz-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/gpu/drm/nouveau/nouveau_chan.c | 2 +-
drivers/gpu/drm/nouveau/nouveau_dma.c | 2 +-
drivers/gpu/drm/nouveau/nouveau_gem.c | 4 ++--
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_chan.c b/drivers/gpu/drm/nouveau/nouveau_chan.c
index fd15ebf..d0c0271 100644
--- a/drivers/gpu/drm/nouveau/nouveau_chan.c
+++ b/drivers/gpu/drm/nouveau/nouveau_chan.c
@@ -318,7 +318,7 @@ nouveau_channel_init(struct nouveau_channel *chan, u32 vram, u32 gart)
chan->dma.ib_base = 0x10000 / 4;
chan->dma.ib_max = (0x01000 / 8) - 1;
chan->dma.ib_put = 0;
- chan->dma.ib_free = chan->dma.ib_max - chan->dma.ib_put;
+ chan->dma.ib_free = chan->dma.ib_max - chan->dma.ib_put + 1;
chan->dma.max = chan->dma.ib_base;
break;
}
diff --git a/drivers/gpu/drm/nouveau/nouveau_dma.c b/drivers/gpu/drm/nouveau/nouveau_dma.c
index 40f91e1..e814fab 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dma.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dma.c
@@ -128,7 +128,7 @@ nv50_dma_push_wait(struct nouveau_channel *chan, int count)
chan->dma.ib_free = get - chan->dma.ib_put;
if (chan->dma.ib_free <= 0)
- chan->dma.ib_free += chan->dma.ib_max;
+ chan->dma.ib_free += chan->dma.ib_max + 1;
}
return 0;
diff --git a/drivers/gpu/drm/nouveau/nouveau_gem.c b/drivers/gpu/drm/nouveau/nouveau_gem.c
index 6454370..d19c7aa 100644
--- a/drivers/gpu/drm/nouveau/nouveau_gem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_gem.c
@@ -662,7 +662,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
if (unlikely(req->nr_push == 0))
goto out_next;
- if (unlikely(req->nr_push > NOUVEAU_GEM_MAX_PUSH)) {
+ if (unlikely(req->nr_push >= NOUVEAU_GEM_MAX_PUSH)) {
NV_ERROR(drm, "pushbuf push count exceeds limit: %d max %d\n",
req->nr_push, NOUVEAU_GEM_MAX_PUSH);
return nouveau_abi16_put(abi16, -EINVAL);
@@ -718,7 +718,7 @@ nouveau_gem_ioctl_pushbuf(struct drm_device *dev, void *data,
}
if (chan->dma.ib_max) {
- ret = nouveau_dma_wait(chan, req->nr_push + 1, 16);
+ ret = nouveau_dma_wait(chan, req->nr_push, 16);
if (ret) {
NV_ERROR(drm, "nv50cal_space: %d\n", ret);
goto out;
--
1.7.8.6
next reply other threads:[~2012-08-19 21:02 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-08-19 21:02 Marcin Slusarz [this message]
[not found] ` <20120819210200.GA26902-OI9uyE9O0yo@public.gmane.org>
2012-08-19 21:11 ` [PATCH 10/10] drm/nouveau: fix off-by-one bugs related to command submission in IB mode Maarten Maathuis
2012-08-20 6:33 ` Ben Skeggs
[not found] ` <20120820063323.GF2013-7ZJhIA9XobAf7BdofF/totBPR1lH4CV8@public.gmane.org>
2012-08-20 17:07 ` Marcin Slusarz
[not found] ` <20120820170719.GB3143-OI9uyE9O0yo@public.gmane.org>
2012-08-20 21:13 ` Ben Skeggs
[not found] ` <CACAvsv7FKZFoVi9akwfmnry8O+draX_ZfuBbFF_2zEOV9kkK6Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-08-20 21:41 ` Marcin Slusarz
[not found] ` <20120820214151.GA5687-OI9uyE9O0yo@public.gmane.org>
2012-08-20 21:55 ` Maarten Maathuis
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=20120819210200.GA26902@joi.lan \
--to=marcin.slusarz-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
--cc=nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.