Re: [PATCH 2/3] block: add support for device frequency PM QoS tuning
From: Bart Van Assche <bvanassche@acm.org>
Date: 2025-09-15 21:26:50
Also in:
linux-pm, linux-scsi, lkml
On 9/14/25 4:45 AM, Wang Jianzheng wrote:
+#ifdef CONFIG_PM
+static void blk_mq_dev_frequency_work(struct work_struct *work)
+{
+ struct request_queue *q =
+ container_of(work, struct request_queue, dev_freq_work.work);
+ unsigned long timeout;
+ struct dev_pm_qos_request *qos = q->dev_freq_qos;
+
+ timeout = msecs_to_jiffies(q->disk->dev_freq_timeout);
+ if (!q || IS_ERR_OR_NULL(q->dev) || IS_ERR_OR_NULL(qos))
+ return;
+
+ if (q->pm_qos_status == PM_QOS_ACTIVE) {
+ q->pm_qos_status = PM_QOS_FREQ_SET;
+ dev_pm_qos_add_request(q->dev, qos, DEV_PM_QOS_MIN_FREQUENCY,
+ FREQ_QOS_MAX_DEFAULT_VALUE);
+ } else {
+ if (time_after(jiffies, READ_ONCE(q->last_active) + timeout))
+ q->pm_qos_status = PM_QOS_FREQ_REMOV;
+ }
+
+ if (q->pm_qos_status == PM_QOS_FREQ_REMOV) {
+ dev_pm_qos_remove_request(qos);
+ q->pm_qos_status = PM_QOS_ACTIVE;
+ } else {
+ schedule_delayed_work(&q->dev_freq_work,
+ q->last_active + timeout - jiffies);
+ }
+}The above code is similar in nature to the activity detection by the run-time power management (RPM) code. Why a new timer mechanism instead of adding more code in the UFS driver RPM callbacks?
quoted hunk ↗ jump to hunk
@@ -3161,6 +3211,8 @@ void blk_mq_submit_bio(struct bio *bio) goto queue_exit; } + blk_pm_qos_dev_freq_update(q, bio);
Good luck with adding power-management code in the block layer hot path ... I'm not sure anyone will be enthusiast seeing code being added in blk_mq_submit_bio(). Thanks, Bart.