From 1a4cc0ae7a7811c58eb28c9c3f3ee432646aec2a Mon Sep 17 00:00:00 2001 From: Danny Lin Date: Fri, 16 May 2025 01:34:46 +0530 Subject: [PATCH 1/5] arm64: dts: yupik: Power off DSI PHY during idle PC On command mode panels, we can power off the DSI PHY entirely during idle PC to save more power than ULPS. --- arch/arm64/boot/dts/vendor/qcom/display/yupik-sde.dtsi | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/boot/dts/vendor/qcom/display/yupik-sde.dtsi b/arch/arm64/boot/dts/vendor/qcom/display/yupik-sde.dtsi index c5e834a18938..f3b7349917d1 100644 --- a/arch/arm64/boot/dts/vendor/qcom/display/yupik-sde.dtsi +++ b/arch/arm64/boot/dts/vendor/qcom/display/yupik-sde.dtsi @@ -351,5 +351,6 @@ qcom,dsi-pll-ssc-en; qcom,dsi-pll-ssc-mode = "down-spread"; memory-region = <&dfps_data_memory>; + qcom,panel-allow-phy-poweroff; }; -- GitLab From bde492a560ac5498e3863e0852d6ccf6758e1e8d Mon Sep 17 00:00:00 2001 From: John Dias Date: Fri, 16 May 2025 23:18:40 +0530 Subject: [PATCH 2/5] fs: Improve eventpoll logging to stop indicting timerfd timerfd doesn't create any wakelocks; eventpoll can, and is creating the wakelocks we see called "[timerfd]". eventpoll creates two kinds of wakelocks: a single top-level lock associated with the eventpoll fd itself, and one additional lock for each fd it is polling that needs such a lock (e.g. those using EPOLLWAKEUP). Current code names the per-fd locks using the undecorated names of the fds' associated files (hence "[timerfd]"), and is naming the top-level lock after the PID of the caller and the name of the file behind the first fd for which a per-fd lock is created. To make things clearer, the top-level lock is now named using the caller PID and an "epollfd" designation, while the per-fd locks are also named with the caller's PID (to associate them with the top-level lock) and their respective fds' file names. Port of fix already applied to previous 2 generations. Note that this set of changes does not fully solve the problem of eventpoll/timerfd wakelock attribution to the original process, since most activity is relayed through system_server, but it does at least ensure that different eventpoll wakelocks - and their stats - are properly disambiguated. Test: Ran on device and observed new wakelock naming in /d/wakeup_sources and (file naming in) lsof output. Bug: 146917063 Bug: 116363986 Change-Id: I34bada5ddab04cf3830762c745f46bfcd1549cb8 Signed-off-by: John Dias Signed-off-by: Kelly Rossmoyer Signed-off-by: Miguel de Dios (cherry picked from commit 3c482c62a7b71c0f971067ff09e9ef9abf5b7a0b) (Manu: update for 5.4) --- fs/eventpoll.c | 12 ++++++++++-- fs/timerfd.c | 12 +++++++++++- 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/fs/eventpoll.c b/fs/eventpoll.c index 752497e773b0..58a7ad61e79f 100644 --- a/fs/eventpoll.c +++ b/fs/eventpoll.c @@ -1459,15 +1459,23 @@ static int ep_create_wakeup_source(struct epitem *epi) { struct name_snapshot n; struct wakeup_source *ws; + char task_comm_buf[TASK_COMM_LEN]; + char buf[64]; + + get_task_comm(task_comm_buf, current); if (!epi->ep->ws) { - epi->ep->ws = wakeup_source_register(NULL, "eventpoll"); + snprintf(buf, sizeof(buf), "epoll_%.*s_epollfd", + (int)sizeof(task_comm_buf), task_comm_buf); + epi->ep->ws = wakeup_source_register(NULL, buf); if (!epi->ep->ws) return -ENOMEM; } take_dentry_name_snapshot(&n, epi->ffd.file->f_path.dentry); - ws = wakeup_source_register(NULL, n.name.name); + snprintf(buf, sizeof(buf), "epoll_%.*s_file:%s", + (int)sizeof(task_comm_buf), task_comm_buf, n.name.name); + ws = wakeup_source_register(NULL, buf); release_dentry_name_snapshot(&n); if (!ws) diff --git a/fs/timerfd.c b/fs/timerfd.c index 48305ba41e3c..ce064bd591c7 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c @@ -45,6 +45,8 @@ struct timerfd_ctx { bool might_cancel; }; +static atomic_t instance_count = ATOMIC_INIT(0); + static LIST_HEAD(cancel_list); static DEFINE_SPINLOCK(cancel_lock); @@ -388,6 +390,9 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags) { int ufd; struct timerfd_ctx *ctx; + char task_comm_buf[TASK_COMM_LEN]; + char file_name_buf[32]; + int instance; /* Check the TFD_* constants for consistency. */ BUILD_BUG_ON(TFD_CLOEXEC != O_CLOEXEC); @@ -424,7 +429,12 @@ SYSCALL_DEFINE2(timerfd_create, int, clockid, int, flags) ctx->moffs = ktime_mono_to_real(0); - ufd = anon_inode_getfd("[timerfd]", &timerfd_fops, ctx, + instance = atomic_inc_return(&instance_count); + get_task_comm(task_comm_buf, current); + snprintf(file_name_buf, sizeof(file_name_buf), "[timerfd%d_%.*s]", + instance, (int)sizeof(task_comm_buf), task_comm_buf); + + ufd = anon_inode_getfd(file_name_buf, &timerfd_fops, ctx, O_RDWR | (flags & TFD_SHARED_FCNTL_FLAGS)); if (ufd < 0) kfree(ctx); -- GitLab From b43a95bd47d85bca6950b7e512a0207366da1d3e Mon Sep 17 00:00:00 2001 From: Ryan Lattrel Date: Sat, 17 May 2025 00:11:59 +0530 Subject: [PATCH 3/5] (CR): alarmtimer: add debug to identify alarmtimers Based on KBA-200505201040 Print out timer wake-up info to debug the sources of pm8xxx_rtc_alarm wake-ups. Change-Id: I39f24dad0613a08844eefcd25076831589256e52 Signed-off-by: Ryan Lattrel Reviewed-on: https://gerrit.mot.com/1668046 SLTApproved: Slta Waiver SME-Granted: SME Approvals Granted Tested-by: Jira Key Reviewed-by: Ling Jin Submit-Approved: Jira Key Reviewed-on: https://gerrit.mot.com/1778266 Reviewed-by: Huosheng Liao --- fs/timerfd.c | 6 ++++++ kernel/time/alarmtimer.c | 17 +++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/fs/timerfd.c b/fs/timerfd.c index ce064bd591c7..57d0f2354866 100644 --- a/fs/timerfd.c +++ b/fs/timerfd.c @@ -240,6 +240,12 @@ static __poll_t timerfd_poll(struct file *file, poll_table *wait) spin_lock_irqsave(&ctx->wqh.lock, flags); if (ctx->ticks) events |= EPOLLIN; + + if (ctx->expired && isalarm(ctx)) + pr_info("%s: comm:%s pid:%d exp:%llu\n", __func__, + current->comm, current->pid, + ktime_to_ms(ctx->t.alarm.node.expires)); + spin_unlock_irqrestore(&ctx->wqh.lock, flags); return events; diff --git a/kernel/time/alarmtimer.c b/kernel/time/alarmtimer.c index 9bd4e492823b..1e716c953fcd 100644 --- a/kernel/time/alarmtimer.c +++ b/kernel/time/alarmtimer.c @@ -60,6 +60,7 @@ static struct wakeup_source *ws; /* rtc timer and device for setting alarm wakeups at suspend */ static struct rtc_timer rtctimer; static struct rtc_device *rtcdev; +static int alarm_debug = 0; static DEFINE_SPINLOCK(rtcdev_lock); /** @@ -215,6 +216,12 @@ static enum hrtimer_restart alarmtimer_fired(struct hrtimer *timer) alarmtimer_dequeue(base, alarm); spin_unlock_irqrestore(&base->lock, flags); + if(alarm_debug & 0x1){ + pr_info("%s: type=%d, func=%pf, exp:%llu\n", __func__, + alarm->type, alarm->function, ktime_to_ms(alarm->node.expires)); + alarm_debug &= 0xFE; + } + if (alarm->function) restart = alarm->function(alarm, base->gettime()); @@ -255,6 +262,7 @@ static int alarmtimer_suspend(struct device *dev) struct rtc_device *rtc; unsigned long flags; struct rtc_time tm; + struct alarm* min_timer = NULL; spin_lock_irqsave(&freezer_delta_lock, flags); min = freezer_delta; @@ -281,6 +289,7 @@ static int alarmtimer_suspend(struct device *dev) continue; delta = ktime_sub(next->expires, base->gettime()); if (!min || (delta < min)) { + min_timer = container_of(next, struct alarm, node); expires = next->expires; min = delta; type = i; @@ -289,6 +298,14 @@ static int alarmtimer_suspend(struct device *dev) if (min == 0) return 0; + if (min_timer){ + pr_info("%s: [%p]type=%d, func=%pf, exp:%llu\n", __func__, + min_timer, min_timer->type, min_timer->function, + ktime_to_ms(min_timer->node.expires)); + min_timer = NULL; + } + alarm_debug = 0x1; + if (ktime_to_ns(min) < 2 * NSEC_PER_SEC) { __pm_wakeup_event(ws, 2 * MSEC_PER_SEC); return -EBUSY; -- GitLab From 342c3671e276526af482956a8f3b0e4405d3d6ca Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Sat, 17 May 2025 18:59:57 +0530 Subject: [PATCH 4/5] FROMGIT: 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/20220228113652.970857-2-adrian.hunter@intel.com Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter Signed-off-by: Martin K. Petersen (cherry picked from commit af4edb1d50c6d1044cb34bc43621411b7ba2cffe git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next) Change-Id: I8834c9d71618fd04635804779a41117629a75166 Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_error.c | 9 +++++++-- drivers/scsi/sd.c | 6 ++++-- include/scsi/scsi_device.h | 1 + 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index 5d56836dfae5..07c5e2d01bff 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -440,8 +440,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) { diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index e90a22e7fc4e..55d040fec17e 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3572,7 +3572,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) { @@ -3594,7 +3595,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) diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 576840c6e323..ad6a72094f09 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -203,6 +203,7 @@ struct scsi_device { unsigned unmap_limit_for_ws:1; /* Use the UNMAP limit for WRITE SAME */ unsigned rpm_autosuspend:1; /* Enable runtime autosuspend at device * creation time */ + unsigned silence_suspend:1; /* Do not print runtime PM related messages */ atomic_t disk_events_disable_depth; /* disable depth for disk events */ DECLARE_BITMAP(supported_events, SDEV_EVT_MAXBITS); /* supported events */ -- GitLab From c404b509fb4b080718005b6acc2b427f4089ad7f Mon Sep 17 00:00:00 2001 From: Adrian Hunter Date: Sat, 17 May 2025 18:44:25 +0530 Subject: [PATCH 5/5] FROMGIT: scsi: ufs: Fix runtime PM messages never-ending cycle 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 suppress them. UFS driver messages are changes to from dev_err() to dev_dbg() which means they will not display unless activated by dynamic debug of building with -DDEBUG. sdev->silence_suspend is set to skip messages from sd_suspend_common() "Synchronizing SCSI cache", "Stopping disk" and scsi_report_sense() "Power-on or device reset occurred" message (Note, that message appears when the LUN is accessed after runtime PM, not during runtime PM) Example messages from Ubuntu 21.10: $ dmesg | tail [ 1620.380071] ufshcd 0000:00:12.5: ufshcd_print_pwr_info:[RX, TX]: gear=[1, 1], lane[1, 1], pwr[SLOWAUTO_MODE, SLOWAUTO_MODE], rate = 0 [ 1620.408825] ufshcd 0000:00:12.5: ufshcd_print_pwr_info:[RX, TX]: gear=[4, 4], lane[2, 2], pwr[FAST MODE, FAST MODE], rate = 2 [ 1620.409020] ufshcd 0000:00:12.5: ufshcd_find_max_sup_active_icc_level: Regulator capability was not set, actvIccLevel=0 [ 1620.409524] sd 0:0:0:0: Power-on or device reset occurred [ 1622.938794] sd 0:0:0:0: [sda] Synchronizing SCSI cache [ 1622.939184] ufs_device_wlun 0:0:0:49488: Power-on or device reset occurred [ 1625.183175] ufshcd 0000:00:12.5: ufshcd_print_pwr_info:[RX, TX]: gear=[1, 1], lane[1, 1], pwr[SLOWAUTO_MODE, SLOWAUTO_MODE], rate = 0 [ 1625.208041] ufshcd 0000:00:12.5: ufshcd_print_pwr_info:[RX, TX]: gear=[4, 4], lane[2, 2], pwr[FAST MODE, FAST MODE], rate = 2 [ 1625.208311] ufshcd 0000:00:12.5: ufshcd_find_max_sup_active_icc_level: Regulator capability was not set, actvIccLevel=0 [ 1625.209035] sd 0:0:0:0: Power-on or device reset occurred Note for stable: depends on patch "scsi: core: sd: Add silence_suspend flag to suppress some PM messages". Link: https://lore.kernel.org/r/20220228113652.970857-3-adrian.hunter@intel.com Cc: stable@vger.kernel.org Signed-off-by: Adrian Hunter Signed-off-by: Martin K. Petersen Bug: 204438323 (cherry picked from commit 71bb9ab6e3511b7bb98678a19eb8cf1ccbf3ca2f git://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next) Signed-off-by: Bart Van Assche Change-Id: I2a50283162aa1dc100e1269533ac61056172bd1d (Manu: update for 5.4) --- drivers/scsi/ufs/ufshcd.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index e2df10b0c341..83338ab62217 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -614,7 +614,12 @@ static void ufshcd_print_pwr_info(struct ufs_hba *hba) "INVALID MODE", }; - dev_err(hba->dev, "%s:[RX, TX]: gear=[%d, %d], lane[%d, %d], pwr[%s, %s], rate = %d\n", + /* + * Using dev_dbg to avoid messages during runtime PM to avoid + * never-ending cycles of messages written back to storage by user space + * causing runtime resume, causing more messages and so on. + */ + dev_dbg(hba->dev, "%s:[RX, TX]: gear=[%d, %d], lane[%d, %d], pwr[%s, %s], rate = %d\n", __func__, hba->pwr_info.gear_rx, hba->pwr_info.gear_tx, hba->pwr_info.lane_rx, hba->pwr_info.lane_tx, @@ -4968,6 +4973,12 @@ static int ufshcd_slave_configure(struct scsi_device *sdev) if (ufshcd_is_rpm_autosuspend_allowed(hba)) sdev->rpm_autosuspend = 1; + /* + * Do not print messages during runtime PM to avoid never-ending cycles + * of messages written back to storage by user space causing runtime + * resume, causing more messages and so on. + */ + sdev->silence_suspend = 1; return 0; } @@ -7122,7 +7133,13 @@ static u32 ufshcd_find_max_sup_active_icc_level(struct ufs_hba *hba, if (!hba->vreg_info.vcc || (!hba->vreg_info.vccq && hba->dev_info.wspecversion >= 0x300) || (!hba->vreg_info.vccq2 && hba->dev_info.wspecversion < 0x300)) { - dev_err(hba->dev, + /* + * Using dev_dbg to avoid messages during runtime PM to avoid + * never-ending cycles of messages written back to storage by + * user space causing runtime resume, causing more messages and + * so on. + */ + dev_dbg(hba->dev, "%s: Regulator capability was not set, actvIccLevel=%d", __func__, icc_level); goto out; -- GitLab