raiden00pl commented on code in PR #19741:
URL: https://github.com/apache/nuttx/pull/19741#discussion_r3756233129


##########
drivers/devfreq/devfreq_ondemand.c:
##########
@@ -0,0 +1,238 @@
+/****************************************************************************
+ * drivers/devfreq/devfreq_ondemand.c
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <nuttx/devfreq.h>
+#include <nuttx/kmalloc.h>
+#include <nuttx/wqueue.h>
+#include <sys/param.h>
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+#define DEVFREQ_MIN_SAMPLING_INTERVAL   (2 * USEC_PER_TICK)
+#define DEVFREQ_LOAD_THRESHOLD_MAX      (100)
+
+/****************************************************************************
+ * Private Types
+ ****************************************************************************/
+
+struct devfreq_ondemand_s
+{
+  struct work_s work;
+  uint32_t threshold;
+  uint32_t sample_rate;
+  uint32_t target_freq;
+  FAR struct qos_request_s *req;
+};
+
+/****************************************************************************
+ * Private Function Prototypes
+ ****************************************************************************/
+
+static int devfreq_gov_ondemand_init(FAR struct devfreq_s *dev);
+static int devfreq_gov_ondemand_exit(FAR struct devfreq_s *dev);
+static int devfreq_gov_ondemand_start(FAR struct devfreq_s *dev);
+static void devfreq_gov_ondemand_stop(FAR struct devfreq_s *dev);
+static uint32_t devfreq_gov_ondemand_limit(FAR struct devfreq_s *dev);
+
+/****************************************************************************
+ * Private Data
+ ****************************************************************************/
+
+static struct devfreq_governor_s g_devfreq_gov_ondemand =
+{
+  .name   = "ondemand",
+  .init   = devfreq_gov_ondemand_init,
+  .exit   = devfreq_gov_ondemand_exit,
+  .start  = devfreq_gov_ondemand_start,
+  .stop   = devfreq_gov_ondemand_stop,
+  .limit  = devfreq_gov_ondemand_limit,
+};
+
+/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+static uint32_t devfreq_gov_ondemand_cpuload(void)
+{
+  struct cpuload_s loadavg;
+  uint32_t idleload = 0;
+  int cpu;
+
+  for (cpu = 0; cpu < CONFIG_SMP_NCPUS; cpu++)
+    {
+      clock_cpuload(cpu, &loadavg);
+      idleload += loadavg.active * 100 / loadavg.total;
+    }
+
+  return 100 - idleload;
+}
+
+static void devfreq_ondemand_worker(FAR void *arg)
+{
+  FAR struct devfreq_s *dev = arg;
+  FAR struct devfreq_ondemand_s *data;
+  FAR struct qos_request_s *req;
+  uint32_t cpuload;
+
+  cpuload = devfreq_gov_ondemand_cpuload();
+  nxmutex_lock(&dev->lock);
+  data = dev->governor_data;

Review Comment:
   @zzby0 @xiaoxiang781216 hi, this file doesn't compile. Is there any commit 
missing in this PR?



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to