Skip to content

Commit ed3d148

Browse files
author
Ben Skeggs
committed
drm/nouveau/nvif: protect waits against GPU falling off the bus
Signed-off-by: Ben Skeggs <[email protected]>
1 parent 58e92b5 commit ed3d148

File tree

11 files changed

+102
-22
lines changed

11 files changed

+102
-22
lines changed

drivers/gpu/drm/nouveau/dispnv04/dac.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@
3535

3636
#include <subdev/bios/gpio.h>
3737
#include <subdev/gpio.h>
38-
#include <subdev/timer.h>
38+
39+
#include <nvif/timer.h>
3940

4041
int nv04_dac_output_offset(struct drm_encoder *encoder)
4142
{

drivers/gpu/drm/nouveau/dispnv04/hw.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "hw.h"
2727

2828
#include <subdev/bios/pll.h>
29+
#include <nvif/timer.h>
2930

3031
#define CHIPSET_NFORCE 0x01a0
3132
#define CHIPSET_NFORCE2 0x01f0

drivers/gpu/drm/nouveau/dispnv50/base507c.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
#include <nvif/cl507c.h>
2525
#include <nvif/event.h>
26+
#include <nvif/timer.h>
2627

2728
#include <drm/drm_atomic_helper.h>
2829
#include <drm/drm_fourcc.h>

drivers/gpu/drm/nouveau/dispnv50/core507d.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "head.h"
2424

2525
#include <nvif/cl507d.h>
26+
#include <nvif/timer.h>
2627

2728
#include "nouveau_bo.h"
2829

drivers/gpu/drm/nouveau/dispnv50/corec37d.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include <nouveau_bo.h>
2626

27+
#include <nvif/timer.h>
28+
2729
void
2830
corec37d_wndw_owner(struct nv50_core *core)
2931
{

drivers/gpu/drm/nouveau/dispnv50/disp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
#include <nvif/cl5070.h>
4646
#include <nvif/cl507d.h>
4747
#include <nvif/event.h>
48+
#include <nvif/timer.h>
4849

4950
#include "nouveau_drv.h"
5051
#include "nouveau_dma.h"

drivers/gpu/drm/nouveau/dispnv50/ovly827e.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include <nouveau_bo.h>
2626

27+
#include <nvif/timer.h>
28+
2729
static void
2830
ovly827e_image_set(struct nv50_wndw *wndw, struct nv50_wndw_atom *asyw)
2931
{

drivers/gpu/drm/nouveau/include/nvif/device.h

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -23,27 +23,6 @@ int nvif_device_init(struct nvif_object *, u32 handle, s32 oclass, void *, u32,
2323
void nvif_device_fini(struct nvif_device *);
2424
u64 nvif_device_time(struct nvif_device *);
2525

26-
/* Delay based on GPU time (ie. PTIMER).
27-
*
28-
* Will return -ETIMEDOUT unless the loop was terminated with 'break',
29-
* where it will return the number of nanoseconds taken instead.
30-
*/
31-
#define nvif_nsec(d,n,cond...) ({ \
32-
struct nvif_device *_device = (d); \
33-
u64 _nsecs = (n), _time0 = nvif_device_time(_device); \
34-
s64 _taken = 0; \
35-
\
36-
do { \
37-
cond \
38-
} while (_taken = nvif_device_time(_device) - _time0, _taken < _nsecs);\
39-
\
40-
if (_taken >= _nsecs) \
41-
_taken = -ETIMEDOUT; \
42-
_taken; \
43-
})
44-
#define nvif_usec(d,u,cond...) nvif_nsec((d), (u) * 1000, ##cond)
45-
#define nvif_msec(d,m,cond...) nvif_usec((d), (m) * 1000, ##cond)
46-
4726
/*XXX*/
4827
#include <subdev/bios.h>
4928
#include <subdev/fb.h>
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#ifndef __NVIF_TIMER_H__
2+
#define __NVIF_TIMER_H__
3+
#include <nvif/os.h>
4+
5+
struct nvif_timer_wait {
6+
struct nvif_device *device;
7+
u64 limit;
8+
u64 time0;
9+
u64 time1;
10+
int reads;
11+
};
12+
13+
void nvif_timer_wait_init(struct nvif_device *, u64 nsec,
14+
struct nvif_timer_wait *);
15+
s64 nvif_timer_wait_test(struct nvif_timer_wait *);
16+
17+
/* Delay based on GPU time (ie. PTIMER).
18+
*
19+
* Will return -ETIMEDOUT unless the loop was terminated with 'break',
20+
* where it will return the number of nanoseconds taken instead.
21+
*/
22+
#define nvif_nsec(d,n,cond...) ({ \
23+
struct nvif_timer_wait _wait; \
24+
s64 _taken = 0; \
25+
\
26+
nvif_timer_wait_init((d), (n), &_wait); \
27+
do { \
28+
cond \
29+
} while ((_taken = nvif_timer_wait_test(&_wait)) >= 0); \
30+
\
31+
_taken; \
32+
})
33+
#define nvif_usec(d,u,cond...) nvif_nsec((d), (u) * 1000, ##cond)
34+
#define nvif_msec(d,m,cond...) nvif_usec((d), (m) * 1000, ##cond)
35+
#endif

drivers/gpu/drm/nouveau/nvif/Kbuild

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ nvif-y += nvif/fifo.o
88
nvif-y += nvif/mem.o
99
nvif-y += nvif/mmu.o
1010
nvif-y += nvif/notify.o
11+
nvif-y += nvif/timer.o
1112
nvif-y += nvif/vmm.o
1213

1314
# Usermode classes

0 commit comments

Comments
 (0)