Skip to content

Commit 3446d7e

Browse files
committed
drm/lima: add resume/suspend callback for each ip
For called when PM do resume/suspend. Tested-by: Bhushan Shah <bshah@kde.org> Reviewed-by: Vasily Khoruzhick <anarsoul@gmail.com> Signed-off-by: Qiang Yu <yuq825@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200421133551.31481-8-yuq825@gmail.com
1 parent 9f5072a commit 3446d7e

File tree

16 files changed

+187
-37
lines changed

16 files changed

+187
-37
lines changed

drivers/gpu/drm/lima/lima_bcast.c

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,18 +26,33 @@ void lima_bcast_enable(struct lima_device *dev, int num_pp)
2626
bcast_write(LIMA_BCAST_BROADCAST_MASK, mask);
2727
}
2828

29+
static int lima_bcast_hw_init(struct lima_ip *ip)
30+
{
31+
bcast_write(LIMA_BCAST_BROADCAST_MASK, ip->data.mask << 16);
32+
bcast_write(LIMA_BCAST_INTERRUPT_MASK, ip->data.mask);
33+
return 0;
34+
}
35+
36+
int lima_bcast_resume(struct lima_ip *ip)
37+
{
38+
return lima_bcast_hw_init(ip);
39+
}
40+
41+
void lima_bcast_suspend(struct lima_ip *ip)
42+
{
43+
44+
}
45+
2946
int lima_bcast_init(struct lima_ip *ip)
3047
{
31-
int i, mask = 0;
48+
int i;
3249

3350
for (i = lima_ip_pp0; i <= lima_ip_pp7; i++) {
3451
if (ip->dev->ip[i].present)
35-
mask |= 1 << (i - lima_ip_pp0);
52+
ip->data.mask |= 1 << (i - lima_ip_pp0);
3653
}
3754

38-
bcast_write(LIMA_BCAST_BROADCAST_MASK, mask << 16);
39-
bcast_write(LIMA_BCAST_INTERRUPT_MASK, mask);
40-
return 0;
55+
return lima_bcast_hw_init(ip);
4156
}
4257

4358
void lima_bcast_fini(struct lima_ip *ip)

drivers/gpu/drm/lima/lima_bcast.h

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

77
struct lima_ip;
88

9+
int lima_bcast_resume(struct lima_ip *ip);
10+
void lima_bcast_suspend(struct lima_ip *ip);
911
int lima_bcast_init(struct lima_ip *ip);
1012
void lima_bcast_fini(struct lima_ip *ip);
1113

drivers/gpu/drm/lima/lima_device.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ struct lima_ip_desc {
2525

2626
int (*init)(struct lima_ip *ip);
2727
void (*fini)(struct lima_ip *ip);
28+
int (*resume)(struct lima_ip *ip);
29+
void (*suspend)(struct lima_ip *ip);
2830
};
2931

3032
#define LIMA_IP_DESC(ipname, mst0, mst1, off0, off1, func, irq) \
@@ -41,6 +43,8 @@ struct lima_ip_desc {
4143
}, \
4244
.init = lima_##func##_init, \
4345
.fini = lima_##func##_fini, \
46+
.resume = lima_##func##_resume, \
47+
.suspend = lima_##func##_suspend, \
4448
}
4549

4650
static struct lima_ip_desc lima_ip_desc[lima_ip_num] = {

drivers/gpu/drm/lima/lima_device.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ struct lima_ip {
6464
bool async_reset;
6565
/* l2 cache */
6666
spinlock_t lock;
67-
/* pmu */
67+
/* pmu/bcast */
6868
u32 mask;
6969
} data;
7070
};

drivers/gpu/drm/lima/lima_dlbu.c

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ void lima_dlbu_set_reg(struct lima_ip *ip, u32 *reg)
4242
dlbu_write(LIMA_DLBU_START_TILE_POS, reg[3]);
4343
}
4444

45-
int lima_dlbu_init(struct lima_ip *ip)
45+
static int lima_dlbu_hw_init(struct lima_ip *ip)
4646
{
4747
struct lima_device *dev = ip->dev;
4848

@@ -52,6 +52,21 @@ int lima_dlbu_init(struct lima_ip *ip)
5252
return 0;
5353
}
5454

55+
int lima_dlbu_resume(struct lima_ip *ip)
56+
{
57+
return lima_dlbu_hw_init(ip);
58+
}
59+
60+
void lima_dlbu_suspend(struct lima_ip *ip)
61+
{
62+
63+
}
64+
65+
int lima_dlbu_init(struct lima_ip *ip)
66+
{
67+
return lima_dlbu_hw_init(ip);
68+
}
69+
5570
void lima_dlbu_fini(struct lima_ip *ip)
5671
{
5772

drivers/gpu/drm/lima/lima_dlbu.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ void lima_dlbu_disable(struct lima_device *dev);
1212

1313
void lima_dlbu_set_reg(struct lima_ip *ip, u32 *reg);
1414

15+
int lima_dlbu_resume(struct lima_ip *ip);
16+
void lima_dlbu_suspend(struct lima_ip *ip);
1517
int lima_dlbu_init(struct lima_ip *ip);
1618
void lima_dlbu_fini(struct lima_ip *ip);
1719

drivers/gpu/drm/lima/lima_gp.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -274,16 +274,31 @@ static void lima_gp_print_version(struct lima_ip *ip)
274274
static struct kmem_cache *lima_gp_task_slab;
275275
static int lima_gp_task_slab_refcnt;
276276

277+
static int lima_gp_hw_init(struct lima_ip *ip)
278+
{
279+
ip->data.async_reset = false;
280+
lima_gp_soft_reset_async(ip);
281+
return lima_gp_soft_reset_async_wait(ip);
282+
}
283+
284+
int lima_gp_resume(struct lima_ip *ip)
285+
{
286+
return lima_gp_hw_init(ip);
287+
}
288+
289+
void lima_gp_suspend(struct lima_ip *ip)
290+
{
291+
292+
}
293+
277294
int lima_gp_init(struct lima_ip *ip)
278295
{
279296
struct lima_device *dev = ip->dev;
280297
int err;
281298

282299
lima_gp_print_version(ip);
283300

284-
ip->data.async_reset = false;
285-
lima_gp_soft_reset_async(ip);
286-
err = lima_gp_soft_reset_async_wait(ip);
301+
err = lima_gp_hw_init(ip);
287302
if (err)
288303
return err;
289304

drivers/gpu/drm/lima/lima_gp.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
struct lima_ip;
88
struct lima_device;
99

10+
int lima_gp_resume(struct lima_ip *ip);
11+
void lima_gp_suspend(struct lima_ip *ip);
1012
int lima_gp_init(struct lima_ip *ip);
1113
void lima_gp_fini(struct lima_ip *ip);
1214

drivers/gpu/drm/lima/lima_l2_cache.c

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,35 @@ int lima_l2_cache_flush(struct lima_ip *ip)
3838
return ret;
3939
}
4040

41+
static int lima_l2_cache_hw_init(struct lima_ip *ip)
42+
{
43+
int err;
44+
45+
err = lima_l2_cache_flush(ip);
46+
if (err)
47+
return err;
48+
49+
l2_cache_write(LIMA_L2_CACHE_ENABLE,
50+
LIMA_L2_CACHE_ENABLE_ACCESS |
51+
LIMA_L2_CACHE_ENABLE_READ_ALLOCATE);
52+
l2_cache_write(LIMA_L2_CACHE_MAX_READS, 0x1c);
53+
54+
return 0;
55+
}
56+
57+
int lima_l2_cache_resume(struct lima_ip *ip)
58+
{
59+
return lima_l2_cache_hw_init(ip);
60+
}
61+
62+
void lima_l2_cache_suspend(struct lima_ip *ip)
63+
{
64+
65+
}
66+
4167
int lima_l2_cache_init(struct lima_ip *ip)
4268
{
43-
int i, err;
69+
int i;
4470
u32 size;
4571
struct lima_device *dev = ip->dev;
4672

@@ -63,15 +89,7 @@ int lima_l2_cache_init(struct lima_ip *ip)
6389
1 << (size & 0xff),
6490
1 << ((size >> 24) & 0xff));
6591

66-
err = lima_l2_cache_flush(ip);
67-
if (err)
68-
return err;
69-
70-
l2_cache_write(LIMA_L2_CACHE_ENABLE,
71-
LIMA_L2_CACHE_ENABLE_ACCESS|LIMA_L2_CACHE_ENABLE_READ_ALLOCATE);
72-
l2_cache_write(LIMA_L2_CACHE_MAX_READS, 0x1c);
73-
74-
return 0;
92+
return lima_l2_cache_hw_init(ip);
7593
}
7694

7795
void lima_l2_cache_fini(struct lima_ip *ip)

drivers/gpu/drm/lima/lima_l2_cache.h

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

77
struct lima_ip;
88

9+
int lima_l2_cache_resume(struct lima_ip *ip);
10+
void lima_l2_cache_suspend(struct lima_ip *ip);
911
int lima_l2_cache_init(struct lima_ip *ip);
1012
void lima_l2_cache_fini(struct lima_ip *ip);
1113

0 commit comments

Comments
 (0)