linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] fixup null q->dev checking in both block and scsi layer
@ 2019-09-12  8:35 Stanley Chu
  2019-09-12  8:35 ` [PATCH v2 1/2] block: bypass blk_set_runtime_active for uninitialized q->dev Stanley Chu
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stanley Chu @ 2019-09-12  8:35 UTC (permalink / raw)
  To: linux-scsi, linux-block, martin.petersen, axboe, jejb, matthias.bgg
  Cc: linux-mediatek, linux-arm-kernel, kuohong.wang, peter.wang,
	chun-hung.wu, andy.teng, Stanley Chu

Some devices may skip blk_pm_runtime_init() and have null pointer in its request_queue->dev. For example, SCSI devices of UFS Well-Known LUNs.

Currently the null pointer is checked by the user of blk_set_runtime_active(), i.e., scsi_dev_type_resume(). It is better to check it by blk_set_runtime_active() itself instead of by its users.

v1 => v2:
- Change if style in blk_set_runtime_active() (Jens)

Stanley Chu (2):
  block: bypass blk_set_runtime_active for uninitialized q->dev
  scsi: core: remove dummy q->dev check

 block/blk-pm.c         | 12 +++++++-----
 drivers/scsi/scsi_pm.c |  3 +--
 2 files changed, 8 insertions(+), 7 deletions(-)

-- 
2.18.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] block: bypass blk_set_runtime_active for uninitialized q->dev
  2019-09-12  8:35 [PATCH v2] fixup null q->dev checking in both block and scsi layer Stanley Chu
@ 2019-09-12  8:35 ` Stanley Chu
  2019-09-12  8:35 ` [PATCH v2 2/2] scsi: core: remove dummy q->dev check Stanley Chu
  2019-09-12 13:12 ` [PATCH v2] fixup null q->dev checking in both block and scsi layer Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Stanley Chu @ 2019-09-12  8:35 UTC (permalink / raw)
  To: linux-scsi, linux-block, martin.petersen, axboe, jejb, matthias.bgg
  Cc: linux-mediatek, linux-arm-kernel, kuohong.wang, peter.wang,
	chun-hung.wu, andy.teng, Stanley Chu

Some devices may skip blk_pm_runtime_init() and have null pointer
in its request_queue->dev. For example, SCSI devices of UFS Well-Known
LUNs.

Currently the null pointer is checked by the user of
blk_set_runtime_active(), i.e., scsi_dev_type_resume(). It is better to
check it by blk_set_runtime_active() itself instead of by its users.

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
 block/blk-pm.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/block/blk-pm.c b/block/blk-pm.c
index 0a028c189897..1adc1cd748b4 100644
--- a/block/blk-pm.c
+++ b/block/blk-pm.c
@@ -207,10 +207,12 @@ EXPORT_SYMBOL(blk_post_runtime_resume);
  */
 void blk_set_runtime_active(struct request_queue *q)
 {
-	spin_lock_irq(&q->queue_lock);
-	q->rpm_status = RPM_ACTIVE;
-	pm_runtime_mark_last_busy(q->dev);
-	pm_request_autosuspend(q->dev);
-	spin_unlock_irq(&q->queue_lock);
+	if (q->dev) {
+		spin_lock_irq(&q->queue_lock);
+		q->rpm_status = RPM_ACTIVE;
+		pm_runtime_mark_last_busy(q->dev);
+		pm_request_autosuspend(q->dev);
+		spin_unlock_irq(&q->queue_lock);
+	}
 }
 EXPORT_SYMBOL(blk_set_runtime_active);
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v2 2/2] scsi: core: remove dummy q->dev check
  2019-09-12  8:35 [PATCH v2] fixup null q->dev checking in both block and scsi layer Stanley Chu
  2019-09-12  8:35 ` [PATCH v2 1/2] block: bypass blk_set_runtime_active for uninitialized q->dev Stanley Chu
@ 2019-09-12  8:35 ` Stanley Chu
  2019-09-12 13:12 ` [PATCH v2] fixup null q->dev checking in both block and scsi layer Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Stanley Chu @ 2019-09-12  8:35 UTC (permalink / raw)
  To: linux-scsi, linux-block, martin.petersen, axboe, jejb, matthias.bgg
  Cc: linux-mediatek, linux-arm-kernel, kuohong.wang, peter.wang,
	chun-hung.wu, andy.teng, Stanley Chu

Currently blk_set_runtime_active() is checking if q->dev is null by
itself, thus remove the same checking in its user: scsi_dev_type_resume().

Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
---
 drivers/scsi/scsi_pm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c
index 74ded5f3c236..3717eea37ecb 100644
--- a/drivers/scsi/scsi_pm.c
+++ b/drivers/scsi/scsi_pm.c
@@ -94,8 +94,7 @@ static int scsi_dev_type_resume(struct device *dev,
 		if (!err && scsi_is_sdev_device(dev)) {
 			struct scsi_device *sdev = to_scsi_device(dev);
 
-			if (sdev->request_queue->dev)
-				blk_set_runtime_active(sdev->request_queue);
+			blk_set_runtime_active(sdev->request_queue);
 		}
 	}
 
-- 
2.18.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2] fixup null q->dev checking in both block and scsi layer
  2019-09-12  8:35 [PATCH v2] fixup null q->dev checking in both block and scsi layer Stanley Chu
  2019-09-12  8:35 ` [PATCH v2 1/2] block: bypass blk_set_runtime_active for uninitialized q->dev Stanley Chu
  2019-09-12  8:35 ` [PATCH v2 2/2] scsi: core: remove dummy q->dev check Stanley Chu
@ 2019-09-12 13:12 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2019-09-12 13:12 UTC (permalink / raw)
  To: Stanley Chu, linux-scsi, linux-block, martin.petersen, jejb,
	matthias.bgg
  Cc: linux-mediatek, linux-arm-kernel, kuohong.wang, peter.wang,
	chun-hung.wu, andy.teng

On 9/12/19 2:35 AM, Stanley Chu wrote:
> Some devices may skip blk_pm_runtime_init() and have null pointer in
> its request_queue->dev. For example, SCSI devices of UFS Well-Known
> LUNs.
> 
> Currently the null pointer is checked by the user of
> blk_set_runtime_active(), i.e., scsi_dev_type_resume(). It is better
> to check it by blk_set_runtime_active() itself instead of by its
> users.

Applied, thanks.

-- 
Jens Axboe


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-09-12 13:12 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-12  8:35 [PATCH v2] fixup null q->dev checking in both block and scsi layer Stanley Chu
2019-09-12  8:35 ` [PATCH v2 1/2] block: bypass blk_set_runtime_active for uninitialized q->dev Stanley Chu
2019-09-12  8:35 ` [PATCH v2 2/2] scsi: core: remove dummy q->dev check Stanley Chu
2019-09-12 13:12 ` [PATCH v2] fixup null q->dev checking in both block and scsi layer Jens Axboe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).