Linux-ARM-Kernel Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v1] fixup null q->dev checking in both block and scsi layer
@ 2019-09-11  6:32 Stanley Chu
  2019-09-11  6:32 ` [PATCH v1 1/2] block: bypass blk_set_runtime_active for uninitialized q->dev Stanley Chu
  2019-09-11  6:32 ` [PATCH v1 2/2] scsi: core: remove dummy q->dev check Stanley Chu
  0 siblings, 2 replies; 5+ messages in thread
From: Stanley Chu @ 2019-09-11  6:32 UTC (permalink / raw)
  To: linux-scsi, linux-block, martin.petersen, axboe, jejb, matthias.bgg
  Cc: andy.teng, chun-hung.wu, kuohong.wang, linux-mediatek,
	peter.wang, Stanley Chu, linux-arm-kernel

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.

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

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

-- 
2.18.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

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

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 | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/block/blk-pm.c b/block/blk-pm.c
index 0a028c189897..56ed94f7a2a3 100644
--- a/block/blk-pm.c
+++ b/block/blk-pm.c
@@ -207,6 +207,9 @@ EXPORT_SYMBOL(blk_post_runtime_resume);
  */
 void blk_set_runtime_active(struct request_queue *q)
 {
+	if (!q->dev)
+		return;
+
 	spin_lock_irq(&q->queue_lock);
 	q->rpm_status = RPM_ACTIVE;
 	pm_runtime_mark_last_busy(q->dev);
-- 
2.18.0


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

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

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


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v1 1/2] block: bypass blk_set_runtime_active for uninitialized q->dev
  2019-09-11  6:32 ` [PATCH v1 1/2] block: bypass blk_set_runtime_active for uninitialized q->dev Stanley Chu
@ 2019-09-11 22:13   ` Jens Axboe
  2019-09-12  8:33     ` Stanley Chu
  0 siblings, 1 reply; 5+ messages in thread
From: Jens Axboe @ 2019-09-11 22:13 UTC (permalink / raw)
  To: Stanley Chu, linux-scsi, linux-block, martin.petersen, jejb,
	matthias.bgg
  Cc: andy.teng, chun-hung.wu, kuohong.wang, linux-mediatek,
	peter.wang, linux-arm-kernel

On 9/11/19 12:32 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.
> 
> Signed-off-by: Stanley Chu <stanley.chu@mediatek.com>
> ---
>   block/blk-pm.c | 3 +++
>   1 file changed, 3 insertions(+)
> 
> diff --git a/block/blk-pm.c b/block/blk-pm.c
> index 0a028c189897..56ed94f7a2a3 100644
> --- a/block/blk-pm.c
> +++ b/block/blk-pm.c
> @@ -207,6 +207,9 @@ EXPORT_SYMBOL(blk_post_runtime_resume);
>    */
>   void blk_set_runtime_active(struct request_queue *q)
>   {
> +	if (!q->dev)
> +		return;
> +
>   	spin_lock_irq(&q->queue_lock);
>   	q->rpm_status = RPM_ACTIVE;
>   	pm_runtime_mark_last_busy(q->dev);

I'd prefer just doing:

	if (q->dev) {
		...
	}

instead. Other than that little complaint, looks good to me.

-- 
Jens Axboe


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH v1 1/2] block: bypass blk_set_runtime_active for uninitialized q->dev
  2019-09-11 22:13   ` Jens Axboe
@ 2019-09-12  8:33     ` Stanley Chu
  0 siblings, 0 replies; 5+ messages in thread
From: Stanley Chu @ 2019-09-12  8:33 UTC (permalink / raw)
  To: Jens Axboe
  Cc: linux-scsi, martin.petersen, Andy Teng (鄧如宏),
	jejb, Chun-Hung Wu (巫駿宏),
	Kuohong Wang (王國鴻),
	linux-block, linux-mediatek,
	Peter Wang (王信友),
	matthias.bgg, linux-arm-kernel

Hi Jens,

> >   void blk_set_runtime_active(struct request_queue *q)
> >   {
> > +	if (!q->dev)
> > +		return;
> > +
> >   	spin_lock_irq(&q->queue_lock);
> >   	q->rpm_status = RPM_ACTIVE;
> >   	pm_runtime_mark_last_busy(q->dev);
> 
> I'd prefer just doing:
> 
> 	if (q->dev) {
> 		...
> 	}
> 
> instead. Other than that little complaint, looks good to me.
> 

OK! I will change it in v2.

Thanks,
Stanley



_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, back to index

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

Linux-ARM-Kernel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/0 linux-arm-kernel/git/0.git
	git clone --mirror https://lore.kernel.org/linux-arm-kernel/1 linux-arm-kernel/git/1.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-arm-kernel linux-arm-kernel/ https://lore.kernel.org/linux-arm-kernel \
		linux-arm-kernel@lists.infradead.org infradead-linux-arm-kernel@archiver.kernel.org
	public-inbox-index linux-arm-kernel


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.infradead.lists.linux-arm-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox