/** * omap_panic_zone() - Force CPU frequency to a "safe frequency" * . Force the CPU frequency to a “safe” frequency * . Limit max CPU frequency to the “safe” frequency * * @cooling_list: The list of cooling devices available to cool the zone * @cpu_temp: The current adjusted CPU temperature * * Returns 0 on success and -ENODEV for no cooling devices available to cool */ static int omap_panic_zone(struct list_head *cooling_list, int cpu_temp) { struct thermal_dev *cooling_dev, *tmp; int die_temp_upper = 0; int die_temp_lower = 0; pr_info("%s:hot spot temp %d\n", __func__, cpu_temp); /* TO DO: need to build an algo to find the right cooling agent */ list_for_each_entry_safe(cooling_dev, tmp, cooling_list, node) { if (cooling_dev->dev_ops && cooling_dev->dev_ops->cool_device) { /* TO DO: Add cooling agents to a list here */ list_add(&cooling_dev->node, &cooling_agents); goto out; } else { pr_info("%s:Cannot find cool_device for %s\n", __func__, cooling_dev->name); } } out: if (list_empty(&cooling_agents)) { pr_err("%s: No Cooling devices registered\n", __func__); return -ENODEV; } else { omap_gov->cooling_level++; omap_gov->panic_zone_reached++; pr_info("%s: Panic zone reached %i times\n", __func__, omap_gov->panic_zone_reached); thermal_cooling_set_level(&cooling_agents, omap_gov->cooling_level); list_del_init(&cooling_agents); die_temp_lower = hotspot_temp_to_sensor_temp( OMAP_PANIC_TEMP - HYSTERESIS_VALUE); /* Set the threshold window to below fatal. This way the * governor can manage the thermal if the temp should rise * while throttling. We need to be agressive with throttling * should we reach this zone. */ die_temp_upper = (((OMAP_FATAL_TEMP - OMAP_PANIC_TEMP) / 4) * omap_gov->panic_zone_reached ) + OMAP_PANIC_TEMP; if (die_temp_upper >= OMAP_FATAL_TEMP) die_temp_upper = OMAP_FATAL_TEMP; die_temp_upper = hotspot_temp_to_sensor_temp(die_temp_upper); thermal_update_temp_thresholds(omap_gov->temp_sensor, die_temp_lower, die_temp_upper); omap_update_report_rate(omap_gov->temp_sensor, FAST_TEMP_MONITORING_RATE); } return 0; }
/** * omap_alert_zone() - "Alert Zone" definition: * - If the Panic Zone has never been reached, then * - Define constraint about Max CPU frequency * if Current frequency < Max frequency, * then Max frequency = Current frequency * - Else keep the constraints set previously until * temperature falls to safe zone * * @cooling_list: The list of cooling devices available to cool the zone * @cpu_temp: The current adjusted CPU temperature * * Returns 0 on success and -ENODEV for no cooling devices available to cool */ static int omap_alert_zone(struct list_head *cooling_list, int cpu_temp) { struct thermal_dev *cooling_dev, *tmp; int die_temp_upper = 0; int die_temp_lower = 0; pr_info("%s:hot spot temp %d\n", __func__, cpu_temp); /* TO DO: need to build an algo to find the right cooling agent */ list_for_each_entry_safe(cooling_dev, tmp, cooling_list, node) { if (cooling_dev->dev_ops && cooling_dev->dev_ops->cool_device) { /* TO DO: Add cooling agents to a list here */ list_add(&cooling_dev->node, &cooling_agents); goto out; } else { pr_info("%s:Cannot find cool_device for %s\n", __func__, cooling_dev->name); } } out: if (list_empty(&cooling_agents)) { pr_err("%s: No Cooling devices registered\n", __func__); return -ENODEV; } else { if (omap_gov->panic_zone_reached == 0) { /* Temperature rises and enters into alert zone */ omap_gov->cooling_level = 0; thermal_cooling_set_level(&cooling_agents, omap_gov->cooling_level); } list_del_init(&cooling_agents); omap_gov->hotspot_temp_lower = (OMAP_ALERT_TEMP - HYSTERESIS_VALUE); omap_gov->hotspot_temp_upper = OMAP_PANIC_TEMP; die_temp_lower = hotspot_temp_to_sensor_temp( omap_gov->hotspot_temp_lower); die_temp_upper = hotspot_temp_to_sensor_temp( omap_gov->hotspot_temp_upper); thermal_update_temp_thresholds(omap_gov->temp_sensor, die_temp_lower, die_temp_upper); omap_update_report_rate(omap_gov->temp_sensor, FAST_TEMP_MONITORING_RATE); if (pcb_sensor) omap_gov->average_period = FAST_TEMP_MONITORING_RATE; } return 0; }