Skip to content

Commit 9f5072a

Browse files
committed
drm/lima: power down ip blocks when pmu exit
Prepare resume/suspend PM. v2: Fix lima_pmu_wait_cmd timeout when mali400 case. 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-7-yuq825@gmail.com
1 parent 4836cf0 commit 9f5072a

2 files changed

Lines changed: 54 additions & 1 deletion

File tree

‎drivers/gpu/drm/lima/lima_device.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ struct lima_ip {
6464
bool async_reset;
6565
/* l2 cache */
6666
spinlock_t lock;
67+
/* pmu */
68+
u32 mask;
6769
} data;
6870
};
6971

‎drivers/gpu/drm/lima/lima_pmu.c‎

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,48 @@ static int lima_pmu_wait_cmd(struct lima_ip *ip)
2121
v, v & LIMA_PMU_INT_CMD_MASK,
2222
100, 100000);
2323
if (err) {
24-
dev_err(dev->dev, "timeout wait pmd cmd\n");
24+
dev_err(dev->dev, "timeout wait pmu cmd\n");
2525
return err;
2626
}
2727

2828
pmu_write(LIMA_PMU_INT_CLEAR, LIMA_PMU_INT_CMD_MASK);
2929
return 0;
3030
}
3131

32+
static u32 lima_pmu_get_ip_mask(struct lima_ip *ip)
33+
{
34+
struct lima_device *dev = ip->dev;
35+
u32 ret = 0;
36+
int i;
37+
38+
ret |= LIMA_PMU_POWER_GP0_MASK;
39+
40+
if (dev->id == lima_gpu_mali400) {
41+
ret |= LIMA_PMU_POWER_L2_MASK;
42+
for (i = 0; i < 4; i++) {
43+
if (dev->ip[lima_ip_pp0 + i].present)
44+
ret |= LIMA_PMU_POWER_PP_MASK(i);
45+
}
46+
} else {
47+
if (dev->ip[lima_ip_pp0].present)
48+
ret |= LIMA450_PMU_POWER_PP0_MASK;
49+
for (i = lima_ip_pp1; i <= lima_ip_pp3; i++) {
50+
if (dev->ip[i].present) {
51+
ret |= LIMA450_PMU_POWER_PP13_MASK;
52+
break;
53+
}
54+
}
55+
for (i = lima_ip_pp4; i <= lima_ip_pp7; i++) {
56+
if (dev->ip[i].present) {
57+
ret |= LIMA450_PMU_POWER_PP47_MASK;
58+
break;
59+
}
60+
}
61+
}
62+
63+
return ret;
64+
}
65+
3266
int lima_pmu_init(struct lima_ip *ip)
3367
{
3468
int err;
@@ -56,5 +90,22 @@ int lima_pmu_init(struct lima_ip *ip)
5690

5791
void lima_pmu_fini(struct lima_ip *ip)
5892
{
93+
u32 stat;
94+
95+
if (!ip->data.mask)
96+
ip->data.mask = lima_pmu_get_ip_mask(ip);
5997

98+
stat = ~pmu_read(LIMA_PMU_STATUS) & ip->data.mask;
99+
if (stat) {
100+
pmu_write(LIMA_PMU_POWER_DOWN, stat);
101+
102+
/* Don't wait for interrupt on Mali400 if all domains are
103+
* powered off because the HW won't generate an interrupt
104+
* in this case.
105+
*/
106+
if (ip->dev->id == lima_gpu_mali400)
107+
pmu_write(LIMA_PMU_INT_CLEAR, LIMA_PMU_INT_CMD_MASK);
108+
else
109+
lima_pmu_wait_cmd(ip);
110+
}
60111
}

0 commit comments

Comments
 (0)