Skip to content

Commit 33beadb

Browse files
wangxiaoningnxpalexandrebelloni
authored andcommitted
i3c: master: svc: fix cpu schedule in spin lock
pm_runtime_resume_and_get() may call sleep(). It cannot be used in svc_i3c_master_start_xfer_locked(), because it is in a spin lock. Move the pm runtime operations to svc_i3c_master_enqueue_xfer(). Signed-off-by: Clark Wang <xiaoning.wang@nxp.com> Fixes: 05be23e ("i3c: master: svc: add runtime pm support") Reviewed-by: Miquel Raynal <miquel.raynal@bootlin.com> Link: https://lore.kernel.org/r/20230517033030.3068085-2-xiaoning.wang@nxp.com Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
1 parent 1c5ee2a commit 33beadb

1 file changed

Lines changed: 10 additions & 9 deletions

File tree

drivers/i3c/master/svc-i3c-master.c

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1096,12 +1096,6 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)
10961096
if (!xfer)
10971097
return;
10981098

1099-
ret = pm_runtime_resume_and_get(master->dev);
1100-
if (ret < 0) {
1101-
dev_err(master->dev, "<%s> Cannot get runtime PM.\n", __func__);
1102-
return;
1103-
}
1104-
11051099
svc_i3c_master_clear_merrwarn(master);
11061100
svc_i3c_master_flush_fifo(master);
11071101

@@ -1116,9 +1110,6 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master)
11161110
break;
11171111
}
11181112

1119-
pm_runtime_mark_last_busy(master->dev);
1120-
pm_runtime_put_autosuspend(master->dev);
1121-
11221113
xfer->ret = ret;
11231114
complete(&xfer->comp);
11241115

@@ -1139,6 +1130,13 @@ static void svc_i3c_master_enqueue_xfer(struct svc_i3c_master *master,
11391130
struct svc_i3c_xfer *xfer)
11401131
{
11411132
unsigned long flags;
1133+
int ret;
1134+
1135+
ret = pm_runtime_resume_and_get(master->dev);
1136+
if (ret < 0) {
1137+
dev_err(master->dev, "<%s> Cannot get runtime PM.\n", __func__);
1138+
return;
1139+
}
11421140

11431141
init_completion(&xfer->comp);
11441142
spin_lock_irqsave(&master->xferqueue.lock, flags);
@@ -1149,6 +1147,9 @@ static void svc_i3c_master_enqueue_xfer(struct svc_i3c_master *master,
11491147
svc_i3c_master_start_xfer_locked(master);
11501148
}
11511149
spin_unlock_irqrestore(&master->xferqueue.lock, flags);
1150+
1151+
pm_runtime_mark_last_busy(master->dev);
1152+
pm_runtime_put_autosuspend(master->dev);
11521153
}
11531154

11541155
static bool

0 commit comments

Comments
 (0)