From e48a262853b5ae8037609f740ac03ff6b76a71d2 Mon Sep 17 00:00:00 2001 From: Asutosh Das Date: Tue, 26 Jan 2021 19:30:44 -0800 Subject: [PATCH] FROMLIST: block: bsg: resume platform device before accessing It may happen that the underlying device's runtime-pm is not controlled by block-pm. So it's possible that when commands are sent to the device, it's suspended and may not be resumed by blk-pm. Hence explicitly resume the parent which is the platform device. Bug: 178653131 Link: https://lore.kernel.org/linux-arm-msm/b1db5394aa3f6cf44cd9adb9c8d569caa0c9e4f5.1611803264.git.asutoshd@codeaurora.org/T/#u Change-Id: Iead4102ea609d339549694164771e47debb58a00 Signed-off-by: Asutosh Das Signed-off-by: Can Guo Signed-off-by: Bao D. Nguyen --- block/bsg.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block/bsg.c b/block/bsg.c index d7bae94b64d9..e9fc89634831 100644 --- a/block/bsg.c +++ b/block/bsg.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include @@ -306,12 +307,15 @@ static struct bsg_device *bsg_get_device(struct inode *inode, struct file *file) static int bsg_open(struct inode *inode, struct file *file) { struct bsg_device *bd; + struct bsg_class_device *bcd; bd = bsg_get_device(inode, file); if (IS_ERR(bd)) return PTR_ERR(bd); + bcd = &bd->queue->bsg_dev; + pm_runtime_get_sync(bcd->class_dev->parent); file->private_data = bd; return 0; } @@ -319,8 +323,12 @@ static int bsg_open(struct inode *inode, struct file *file) static int bsg_release(struct inode *inode, struct file *file) { struct bsg_device *bd = file->private_data; + struct bsg_class_device *bcd; file->private_data = NULL; + + bcd = &bd->queue->bsg_dev; + pm_runtime_put_sync(bcd->class_dev->parent); return bsg_put_device(bd); }