]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
scsi: core: sd: Add silence_suspend flag to suppress some PM messages
authorAdrian Hunter <adrian.hunter@intel.com>
Mon, 28 Feb 2022 11:36:51 +0000 (13:36 +0200)
committerStefan Bader <stefan.bader@canonical.com>
Wed, 27 Apr 2022 09:56:33 +0000 (11:56 +0200)
BugLink: https://bugs.launchpad.net/bugs/1969110
commit af4edb1d50c6d1044cb34bc43621411b7ba2cffe upstream.

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/20220228113652.970857-2-adrian.hunter@intel.com
Cc: stable@vger.kernel.org
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
(cherry picked from commit 6ade94e6afc6b7f6b0829c521cc3caaa7fbb82ab)
Signed-off-by: Paolo Pisati <paolo.pisati@canonical.com>
drivers/scsi/scsi_error.c
drivers/scsi/sd.c
include/scsi/scsi_device.h

index 408d49c304b8dc1a8012bcbdd6268d7b451d39b3..bb5a6e0fa49ab3724b9ca1afa33a20ea536943cd 100644 (file)
@@ -485,8 +485,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) {
index 564a21b5da9db7e12a1adf6af816b2ce7a3caea3..a713babaee0f52731c661d7587feabbccd8ed6c9 100644 (file)
@@ -3628,7 +3628,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) {
@@ -3650,7 +3651,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)
index b97e142a7ca92d5f45fa21374c2e627ff29afef5..3b3dbc37653da6b8a11742a60ae4f280e6120f13 100644 (file)
@@ -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 */
 
        bool offline_already;           /* Device offline message logged */