Skip to content

Commit 4045de8

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: sg: Enable runtime power management
In 2010, runtime power management support was implemented in the SCSI core. The description of patch "[SCSI] implement runtime Power Management" mentions that the sg driver is skipped but not why. This patch enables runtime power management even if an instance of the sg driver is held open. Enabling runtime PM for the sg driver is safe because all interactions of the sg driver with the SCSI device pass through the block layer (blk_execute_rq_nowait()) and the block layer already supports runtime PM. Cc: Alan Stern <stern@rowland.harvard.edu> Cc: Douglas Gilbert <dgilbert@interlog.com> Fixes: bc4f240 ("[SCSI] implement runtime Power Management") Signed-off-by: Bart Van Assche <bvanassche@acm.org> Link: https://lore.kernel.org/r/20241030220310.1373569-1-bvanassche@acm.org Acked-by: Alan Stern <stern@rowland.harvard.edu> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 95bbdca commit 4045de8

File tree

1 file changed

+1
-8
lines changed

1 file changed

+1
-8
lines changed

drivers/scsi/sg.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -307,18 +307,14 @@ sg_open(struct inode *inode, struct file *filp)
307307
if (retval)
308308
goto sg_put;
309309

310-
retval = scsi_autopm_get_device(device);
311-
if (retval)
312-
goto sdp_put;
313-
314310
/* scsi_block_when_processing_errors() may block so bypass
315311
* check if O_NONBLOCK. Permits SCSI commands to be issued
316312
* during error recovery. Tread carefully. */
317313
if (!((flags & O_NONBLOCK) ||
318314
scsi_block_when_processing_errors(device))) {
319315
retval = -ENXIO;
320316
/* we are in error recovery for this device */
321-
goto error_out;
317+
goto sdp_put;
322318
}
323319

324320
mutex_lock(&sdp->open_rel_lock);
@@ -371,8 +367,6 @@ sg_open(struct inode *inode, struct file *filp)
371367
}
372368
error_mutex_locked:
373369
mutex_unlock(&sdp->open_rel_lock);
374-
error_out:
375-
scsi_autopm_put_device(device);
376370
sdp_put:
377371
kref_put(&sdp->d_ref, sg_device_destroy);
378372
scsi_device_put(device);
@@ -392,7 +386,6 @@ sg_release(struct inode *inode, struct file *filp)
392386
SCSI_LOG_TIMEOUT(3, sg_printk(KERN_INFO, sdp, "sg_release\n"));
393387

394388
mutex_lock(&sdp->open_rel_lock);
395-
scsi_autopm_put_device(sdp->device);
396389
kref_put(&sfp->f_ref, sg_remove_sfp);
397390
sdp->open_cnt--;
398391

0 commit comments

Comments
 (0)