Skip to content

Commit

Permalink
scsi: core: sd: Add silence_suspend flag to suppress some PM messages
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
ahunter6 authored and martinkpetersen committed Mar 2, 2022
1 parent e81ce97 commit af4edb1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 4 deletions.
9 changes: 7 additions & 2 deletions drivers/scsi/scsi_error.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,13 @@ static void scsi_report_sense(struct scsi_device *sdev,

if (sshdr->asc == 0x29) {
evt_type = SDEV_EVT_POWER_ON_RESET_OCCURRED;
sdev_printk(KERN_WARNING, sdev,
"Power-on or device reset occurred\n");
/*
* Do not print message if it is an expected side-effect
* of runtime PM.
*/
if (!sdev->silence_suspend)
sdev_printk(KERN_WARNING, sdev,
"Power-on or device reset occurred\n");
}

if (sshdr->asc == 0x2a && sshdr->ascq == 0x01) {
Expand Down
6 changes: 4 additions & 2 deletions drivers/scsi/sd.c
Original file line number Diff line number Diff line change
Expand Up @@ -3676,7 +3676,8 @@ static int sd_suspend_common(struct device *dev, bool ignore_stop_errors)
return 0;

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

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

if (sdkp->device->manage_start_stop) {
sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
if (!sdkp->device->silence_suspend)
sd_printk(KERN_NOTICE, sdkp, "Stopping disk\n");
/* an error is not worth aborting a system sleep */
ret = sd_start_stop_device(sdkp, 0);
if (ignore_stop_errors)
Expand Down
1 change: 1 addition & 0 deletions include/scsi/scsi_device.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ struct scsi_device {
unsigned rpm_autosuspend:1; /* Enable runtime autosuspend at device
* creation time */
unsigned ignore_media_change:1; /* Ignore MEDIA CHANGE on resume */
unsigned silence_suspend:1; /* Do not print runtime PM related messages */

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

0 comments on commit af4edb1

Please sign in to comment.