Skip to content

Commit af4edb1

Browse files
ahunter6martinkpetersen
authored andcommitted
scsi: core: sd: Add silence_suspend flag to suppress some PM messages
Kernel messages produced during runtime PM can cause a never-ending cycle because user space utilities (e.g. journald or rsyslog) write the messages back to storage, causing runtime resume, more messages, and so on. Messages that tell of things that are expected to happen are arguably unnecessary, so add a flag to suppress them. This flag is used by the UFS driver. Link: https://lore.kernel.org/r/[email protected] Cc: [email protected] Signed-off-by: Adrian Hunter <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent e81ce97 commit af4edb1

File tree

3 files changed

+12
-4
lines changed

3 files changed

+12
-4
lines changed

drivers/scsi/scsi_error.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -484,8 +484,13 @@ static void scsi_report_sense(struct scsi_device *sdev,
484484

485485
if (sshdr->asc == 0x29) {
486486
evt_type = SDEV_EVT_POWER_ON_RESET_OCCURRED;
487-
sdev_printk(KERN_WARNING, sdev,
488-
"Power-on or device reset occurred\n");
487+
/*
488+
* Do not print message if it is an expected side-effect
489+
* of runtime PM.
490+
*/
491+
if (!sdev->silence_suspend)
492+
sdev_printk(KERN_WARNING, sdev,
493+
"Power-on or device reset occurred\n");
489494
}
490495

491496
if (sshdr->asc == 0x2a && sshdr->ascq == 0x01) {

drivers/scsi/sd.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3676,7 +3676,8 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)
36763676
return 0;
36773677

36783678
if (sdkp->WCE && sdkp->media_present) {
3679-
sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
3679+
if (!sdkp->device->silence_suspend)
3680+
sd_printk(KERN_NOTICE, sdkp, "Synchronizing SCSI cache\n");
36803681
ret = sd_sync_cache(sdkp, &sshdr);
36813682

36823683
if (ret) {
@@ -3698,7 +3699,8 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)
36983699
}
36993700

37003701
if (sdkp->device->manage_start_stop) {
3701-
sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
3702+
if (!sdkp->device->silence_suspend)
3703+
sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
37023704
/* an error is not worth aborting a system sleep */
37033705
ret = sd_start_stop_device(sdkp, 0);
37043706
if (ignore_stop_errors)

include/scsi/scsi_device.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ struct scsi_device {
206206
unsigned rpm_autosuspend:1; /* Enable runtime autosuspend at device
207207
* creation time */
208208
unsigned ignore_media_change:1; /* Ignore MEDIA CHANGE on resume */
209+
unsigned silence_suspend:1; /* Do not print runtime PM related messages */
209210

210211
unsigned int queue_stopped; /* request queue is quiesced */
211212
bool offline_already; /* Device offline message logged */

0 commit comments

Comments
 (0)