Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c5a49cc8 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: thermal: Decouple Gfx phase control monitoring"

parents e1985f91 7b20391a
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -154,35 +154,31 @@ Optional child nodes
			temperature band to RPM, in degC. This will aid RPM in
			deciding the number of phases required for GFX rail.
			If this property exists, then the properties,
			qcom,gfx-phase-hot-crit-temp-hyst, qcom,gfx-sensor-id,
			qcom,gfx-phase-warm-temp and qcom,gfx-phase-warm-temp-hyst
			qcom,gfx-phase-hot-crit-temp-hyst and qcom,gfx-sensor-id
			should also be defined to enable this feature.
- qcom,gfx-phase-hot-crit-temp-hyst: Degree below the threshold to clear the 'HOT_CRITICAL'
			band and send the 'WARM' temperature band to RPM, in degC.
			This will aid RPM in deciding the number of phases required
			for GFX rail. If this property exists, then the properties,
			qcom,gfx-phase-hot-crit-temp, qcom,gfx-sensor-id,
			qcom,gfx-phase-warm-temp and qcom,gfx-phase-warm-temp-hyst
			qcom,gfx-phase-hot-crit-temp and qcom,gfx-sensor-id
			should also be defined to enable this feature.
- qcom,gfx-phase-warm-temp: Threshold temperature for sending the 'WARM' temperature
			band to RPM, in degC. This will aid RPM in deciding the
			number of phases required for GFX rail. If this property
			exists, then the properties, qcom,gfx-phase-hot-crit-temp,
			qcom,gfx-phase-hot-crit-temp-hyst, qcom,gfx-sensor-id and
			exists, then the properties, qcom,gfx-sensor-id and
			qcom,gfx-phase-warm-temp-hyst should also be defined to
			enable this feature.
- qcom,gfx-phase-warm-temp-hyst: Degree below the threshold to clear the 'WARM'
			band and send the 'NORMAL' temperature band to RPM, in degC.
			This will aid RPM in deciding the number of phases required
			for GFX rail. If this property exists, then the property,
			qcom,gfx-phase-hot-crit-temp, qcom,gfx-phase-hot-temp-hyst,
			qcom,gfx-sensor-id and qcom,gfx-phase-warm-temp should also
			be defined to enable this feature.
-qcom,gfx-sensor-id:     The ID of the TSENS sensor, which is closest to graphics
			processor, monitoring the GPU temperature. If this property
			exists, then the property, qcom,gfx-phase-hot-crit-temp,
			qcom,gfx-phase-hot-crit-temp-hyst, qcom,gfx-phase-warm-temp and
			qcom,gfx-phase-warm-temp-hyst should also be defined to
			exists, then the property, qcom,gfx-phase-hot-crit-temp and
			qcom,gfx-phase-hot-crit-temp-hyst or/and qcom,gfx-phase-warm-temp
			and qcom,gfx-phase-warm-temp-hyst should also be defined to
			enable this feature.
- qcom,gfx-phase-resource-key: The key name to be used for sending the GFX temperature
			band message to RPM. This property should be defined along
+115 −75
Original line number Diff line number Diff line
@@ -96,7 +96,8 @@ static bool ocr_reg_init_defer;
static bool hotplug_enabled;
static bool interrupt_mode_enable;
static bool msm_thermal_probed;
static bool gfx_phase_ctrl_enabled;
static bool gfx_crit_phase_ctrl_enabled;
static bool gfx_warm_phase_ctrl_enabled;
static bool cx_phase_ctrl_enabled;
static bool vdd_mx_enabled;
static bool therm_reset_enabled;
@@ -1999,10 +2000,11 @@ static int do_gfx_phase_cond(void)
	int ret = 0;
	uint32_t new_req_band = curr_gfx_band;

	if (!gfx_phase_ctrl_enabled)
	if (!gfx_warm_phase_ctrl_enabled && !gfx_crit_phase_ctrl_enabled)
		return ret;

	mutex_lock(&gfx_mutex);
	if (gfx_warm_phase_ctrl_enabled) {
		ret = therm_get_temp(
			thresh[MSM_GFX_PHASE_CTRL_WARM].thresh_list->sensor_id,
			thresh[MSM_GFX_PHASE_CTRL_WARM].thresh_list->id_type,
@@ -2013,6 +2015,18 @@ static int do_gfx_phase_cond(void)
			ret);
			goto gfx_phase_cond_exit;
		}
	} else {
		ret = therm_get_temp(
			thresh[MSM_GFX_PHASE_CTRL_HOT].thresh_list->sensor_id,
			thresh[MSM_GFX_PHASE_CTRL_HOT].thresh_list->id_type,
			&temp);
		if (ret) {
			pr_err("Unable to read TSENS sensor:%d. err:%d\n",
			thresh[MSM_GFX_PHASE_CTRL_HOT].thresh_list->sensor_id,
			ret);
			goto gfx_phase_cond_exit;
		}
	}

	switch (curr_gfx_band) {
	case MSM_HOT_CRITICAL:
@@ -2866,17 +2880,20 @@ static void gfx_phase_ctrl_notify(struct therm_threshold *trig_thresh)
	uint32_t new_req_band = curr_gfx_band;
	int ret = 0;

	if (!gfx_phase_ctrl_enabled)
	if (!gfx_warm_phase_ctrl_enabled && !gfx_crit_phase_ctrl_enabled)
		return;

	if (trig_thresh->trip_triggered < 0)
		goto gfx_phase_ctrl_exit;

	mutex_lock(&gfx_mutex);
	switch (thresh[MSM_GFX_PHASE_CTRL_HOT].thresh_list->trip_triggered) {
	if (gfx_crit_phase_ctrl_enabled) {
		switch (
		thresh[MSM_GFX_PHASE_CTRL_HOT].thresh_list->trip_triggered) {
		case THERMAL_TRIP_CONFIGURABLE_HI:
			new_req_band = MSM_HOT_CRITICAL;
		pr_debug("sensor:%d reached hot critical thresh for GFX\n",
			pr_debug(
			"sensor:%d reached hot critical thresh for GFX\n",
				tsens_id_map[trig_thresh->sensor_id]);
			goto notify_new_band;
			break;
@@ -2889,7 +2906,10 @@ static void gfx_phase_ctrl_notify(struct therm_threshold *trig_thresh)
		default:
			break;
		}
	switch (thresh[MSM_GFX_PHASE_CTRL_WARM].thresh_list->trip_triggered) {
	}
	if (gfx_warm_phase_ctrl_enabled) {
		switch (
		thresh[MSM_GFX_PHASE_CTRL_WARM].thresh_list->trip_triggered) {
		case THERMAL_TRIP_CONFIGURABLE_HI:
			new_req_band = MSM_WARM;
			pr_debug("sensor:%d reached warm thresh for GFX\n",
@@ -2905,6 +2925,7 @@ static void gfx_phase_ctrl_notify(struct therm_threshold *trig_thresh)
		default:
			break;
		}
	}

notify_new_band:
	if (new_req_band != curr_gfx_band) {
@@ -2916,14 +2937,18 @@ notify_new_band:
gfx_phase_ctrl_exit:
	switch (curr_gfx_band) {
	case MSM_HOT_CRITICAL:
		if (gfx_crit_phase_ctrl_enabled)
			therm_set_threshold(&thresh[MSM_GFX_PHASE_CTRL_HOT]);
		break;
	case MSM_NORMAL:
		if (gfx_warm_phase_ctrl_enabled)
			therm_set_threshold(&thresh[MSM_GFX_PHASE_CTRL_WARM]);
		break;
	case MSM_WARM:
	default:
		if (gfx_crit_phase_ctrl_enabled)
			therm_set_threshold(&thresh[MSM_GFX_PHASE_CTRL_HOT]);
		if (gfx_warm_phase_ctrl_enabled)
			therm_set_threshold(&thresh[MSM_GFX_PHASE_CTRL_WARM]);
		break;
	}
@@ -3113,10 +3138,13 @@ static void thermal_monitor_init(void)
		!(convert_to_zone_id(&thresh[MSM_VDD_RESTRICTION])))
		therm_set_threshold(&thresh[MSM_VDD_RESTRICTION]);

	if ((gfx_phase_ctrl_enabled) &&
		!(convert_to_zone_id(&thresh[MSM_GFX_PHASE_CTRL_WARM])) &&
		!(convert_to_zone_id(&thresh[MSM_GFX_PHASE_CTRL_HOT]))) {
	if ((gfx_warm_phase_ctrl_enabled) &&
		!(convert_to_zone_id(&thresh[MSM_GFX_PHASE_CTRL_WARM]))) {
		therm_set_threshold(&thresh[MSM_GFX_PHASE_CTRL_WARM]);
	}

	if ((gfx_crit_phase_ctrl_enabled) &&
		!(convert_to_zone_id(&thresh[MSM_GFX_PHASE_CTRL_HOT]))) {
		therm_set_threshold(&thresh[MSM_GFX_PHASE_CTRL_HOT]);
	}

@@ -3224,7 +3252,7 @@ static int msm_thermal_add_gfx_nodes(void)
	struct kobject *gfx_kobj = NULL;
	int ret = 0;

	if (!gfx_phase_ctrl_enabled)
	if (!gfx_warm_phase_ctrl_enabled && !gfx_crit_phase_ctrl_enabled)
		return -EINVAL;

	module_kobj = kset_find_obj(module_kset, KBUILD_MODNAME);
@@ -4535,30 +4563,6 @@ static int probe_gfx_phase_ctrl(struct device_node *node,
	const char *tmp_str = NULL;
	int ret = 0;

	key = "qcom,gfx-phase-warm-temp";
	ret = of_property_read_u32(node, key,
		&data->gfx_phase_warm_temp_degC);
	if (ret)
		goto probe_gfx_exit;

	key = "qcom,gfx-phase-warm-temp-hyst";
	ret = of_property_read_u32(node, key,
		&data->gfx_phase_warm_temp_hyst_degC);
	if (ret)
		goto probe_gfx_exit;

	key = "qcom,gfx-phase-hot-crit-temp";
	ret = of_property_read_u32(node, key,
		&data->gfx_phase_hot_temp_degC);
	if (ret)
		goto probe_gfx_exit;

	key = "qcom,gfx-phase-hot-crit-temp-hyst";
	ret = of_property_read_u32(node, key,
		&data->gfx_phase_hot_temp_hyst_degC);
	if (ret)
		goto probe_gfx_exit;

	key = "qcom,gfx-sensor-id";
	ret = of_property_read_u32(node, key,
		&data->gfx_sensor);
@@ -4572,15 +4576,52 @@ static int probe_gfx_phase_ctrl(struct device_node *node,
		goto probe_gfx_exit;
	data->gfx_phase_request_key = msm_thermal_str_to_int(tmp_str);

	key = "qcom,gfx-phase-warm-temp";
	ret = of_property_read_u32(node, key,
		&data->gfx_phase_warm_temp_degC);
	if (ret) {
		dev_info(&pdev->dev,
		"%s:Failed reading node=%s, key=%s. err=%d. KTM continues\n",
			KBUILD_MODNAME, node->full_name, key, ret);
		data->gfx_phase_warm_temp_degC = INT_MIN;
		goto probe_gfx_crit;
	}

	key = "qcom,gfx-phase-warm-temp-hyst";
	ret = of_property_read_u32(node, key,
		&data->gfx_phase_warm_temp_hyst_degC);
	if (ret) {
		dev_info(&pdev->dev,
		"%s:Failed reading node=%s, key=%s. err=%d. KTM continues\n",
			KBUILD_MODNAME, node->full_name, key, ret);
		goto probe_gfx_crit;
	}

	ret = init_threshold(MSM_GFX_PHASE_CTRL_WARM, data->gfx_sensor,
		data->gfx_phase_warm_temp_degC, data->gfx_phase_warm_temp_degC -
		data->gfx_phase_warm_temp_hyst_degC,
		gfx_phase_ctrl_notify);
	if (ret) {
		pr_err("init WARM threshold failed. err:%d\n", ret);
		goto probe_gfx_crit;
	}
	gfx_warm_phase_ctrl_enabled = true;

probe_gfx_crit:
	key = "qcom,gfx-phase-hot-crit-temp";
	ret = of_property_read_u32(node, key,
		&data->gfx_phase_hot_temp_degC);
	if (ret) {
		data->gfx_phase_hot_temp_degC = INT_MAX;
		goto probe_gfx_exit;
	}

	key = "qcom,gfx-phase-hot-crit-temp-hyst";
	ret = of_property_read_u32(node, key,
		&data->gfx_phase_hot_temp_hyst_degC);
	if (ret)
		goto probe_gfx_exit;

	ret = init_threshold(MSM_GFX_PHASE_CTRL_HOT, data->gfx_sensor,
		data->gfx_phase_hot_temp_degC, data->gfx_phase_hot_temp_degC -
		data->gfx_phase_hot_temp_hyst_degC,
@@ -4590,14 +4631,13 @@ static int probe_gfx_phase_ctrl(struct device_node *node,
		goto probe_gfx_exit;
	}

	gfx_phase_ctrl_enabled = true;
	gfx_crit_phase_ctrl_enabled = true;

probe_gfx_exit:
	if (ret) {
		dev_info(&pdev->dev,
		"%s:Failed reading node=%s, key=%s. err=%d. KTM continues\n",
			KBUILD_MODNAME, node->full_name, key, ret);
		gfx_phase_ctrl_enabled = false;
	}
	return ret;
}
@@ -4866,10 +4906,10 @@ static int msm_thermal_dev_exit(struct platform_device *inp_dev)
			kfree(thresh[MSM_VDD_RESTRICTION].thresh_list);
		if (cx_phase_ctrl_enabled)
			kfree(thresh[MSM_CX_PHASE_CTRL_HOT].thresh_list);
		if (gfx_phase_ctrl_enabled) {
		if (gfx_warm_phase_ctrl_enabled)
			kfree(thresh[MSM_GFX_PHASE_CTRL_WARM].thresh_list);
		if (gfx_crit_phase_ctrl_enabled)
			kfree(thresh[MSM_GFX_PHASE_CTRL_HOT].thresh_list);
		}
		if (ocr_enabled) {
			for (i = 0; i < ocr_rail_cnt; i++)
				kfree(ocr_rails[i].attr_gp.attrs);