Skip to content

Commit 9033832

Browse files
committed
Merge branch 'for-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux
Pull thermal management fixes from Zhang Rui: "These includes several commits that are necessary to properly fix regression for TMU test MUX address setting after reset, for exynos thermal driver. Specifics: - fix a regression that the removal of setting a certain field at TMU configuration setting results in immediately shutdown after reset on Exynos4412 SoC. - revert a patch which tries to link the thermal_zone device and its hwmon node but breaks libsensors. - fix a deadlock/lockdep warning issue in x86_pkg_temp thermal driver, which can be reproduced on a buggy platform only. - fix ti-soc-thermal driver to fall back on bandgap reading when reading from PCB temperature sensor fails" * 'for-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/rzhang/linux: Revert "drivers: thermal: parent virtual hwmon with thermal zone" drivers: thermal: allow ti-soc-thermal run without pcb zone thermal: exynos: Provide initial setting for TMU's test MUX address at Exynos4412 thermal: exynos: Provide separate TMU data for Exynos4412 thermal: exynos: Remove check for thermal device pointer at exynos_report_trigger() Thermal: x86_pkg_temp: change spin lock
2 parents ea89e1d + 167c3ad commit 9033832

File tree

8 files changed

+60
-21
lines changed

8 files changed

+60
-21
lines changed

drivers/thermal/samsung/exynos_thermal_common.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,8 +310,6 @@ void exynos_report_trigger(struct thermal_sensor_conf *conf)
310310
}
311311

312312
th_zone = conf->pzone_data;
313-
if (th_zone->therm_dev)
314-
return;
315313

316314
if (th_zone->bind == false) {
317315
for (i = 0; i < th_zone->cool_dev_size; i++) {

drivers/thermal/samsung/exynos_tmu.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,9 @@ static void exynos_tmu_control(struct platform_device *pdev, bool on)
317317

318318
con = readl(data->base + reg->tmu_ctrl);
319319

320+
if (pdata->test_mux)
321+
con |= (pdata->test_mux << reg->test_mux_addr_shift);
322+
320323
if (pdata->reference_voltage) {
321324
con &= ~(reg->buf_vref_sel_mask << reg->buf_vref_sel_shift);
322325
con |= pdata->reference_voltage << reg->buf_vref_sel_shift;
@@ -488,7 +491,7 @@ static const struct of_device_id exynos_tmu_match[] = {
488491
},
489492
{
490493
.compatible = "samsung,exynos4412-tmu",
491-
.data = (void *)EXYNOS5250_TMU_DRV_DATA,
494+
.data = (void *)EXYNOS4412_TMU_DRV_DATA,
492495
},
493496
{
494497
.compatible = "samsung,exynos5250-tmu",
@@ -629,9 +632,10 @@ static int exynos_tmu_probe(struct platform_device *pdev)
629632
if (ret)
630633
return ret;
631634

632-
if (pdata->type == SOC_ARCH_EXYNOS ||
633-
pdata->type == SOC_ARCH_EXYNOS4210 ||
634-
pdata->type == SOC_ARCH_EXYNOS5440)
635+
if (pdata->type == SOC_ARCH_EXYNOS4210 ||
636+
pdata->type == SOC_ARCH_EXYNOS4412 ||
637+
pdata->type == SOC_ARCH_EXYNOS5250 ||
638+
pdata->type == SOC_ARCH_EXYNOS5440)
635639
data->soc = pdata->type;
636640
else {
637641
ret = -EINVAL;

drivers/thermal/samsung/exynos_tmu.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ enum calibration_mode {
4141

4242
enum soc_type {
4343
SOC_ARCH_EXYNOS4210 = 1,
44-
SOC_ARCH_EXYNOS,
44+
SOC_ARCH_EXYNOS4412,
45+
SOC_ARCH_EXYNOS5250,
4546
SOC_ARCH_EXYNOS5440,
4647
};
4748

@@ -84,6 +85,7 @@ enum soc_type {
8485
* @triminfo_reload_shift: shift of triminfo reload enable bit in triminfo_ctrl
8586
reg.
8687
* @tmu_ctrl: TMU main controller register.
88+
* @test_mux_addr_shift: shift bits of test mux address.
8789
* @buf_vref_sel_shift: shift bits of reference voltage in tmu_ctrl register.
8890
* @buf_vref_sel_mask: mask bits of reference voltage in tmu_ctrl register.
8991
* @therm_trip_mode_shift: shift bits of tripping mode in tmu_ctrl register.
@@ -150,6 +152,7 @@ struct exynos_tmu_registers {
150152
u32 triminfo_reload_shift;
151153

152154
u32 tmu_ctrl;
155+
u32 test_mux_addr_shift;
153156
u32 buf_vref_sel_shift;
154157
u32 buf_vref_sel_mask;
155158
u32 therm_trip_mode_shift;
@@ -257,6 +260,7 @@ struct exynos_tmu_registers {
257260
* @first_point_trim: temp value of the first point trimming
258261
* @second_point_trim: temp value of the second point trimming
259262
* @default_temp_offset: default temperature offset in case of no trimming
263+
* @test_mux; information if SoC supports test MUX
260264
* @cal_type: calibration type for temperature
261265
* @cal_mode: calibration mode for temperature
262266
* @freq_clip_table: Table representing frequency reduction percentage.
@@ -286,6 +290,7 @@ struct exynos_tmu_platform_data {
286290
u8 first_point_trim;
287291
u8 second_point_trim;
288292
u8 default_temp_offset;
293+
u8 test_mux;
289294

290295
enum calibration_type cal_type;
291296
enum calibration_mode cal_mode;

drivers/thermal/samsung/exynos_tmu_data.c

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,14 +90,15 @@ struct exynos_tmu_init_data const exynos4210_default_tmu_data = {
9090
};
9191
#endif
9292

93-
#if defined(CONFIG_SOC_EXYNOS5250) || defined(CONFIG_SOC_EXYNOS4412)
94-
static const struct exynos_tmu_registers exynos5250_tmu_registers = {
93+
#if defined(CONFIG_SOC_EXYNOS4412) || defined(CONFIG_SOC_EXYNOS5250)
94+
static const struct exynos_tmu_registers exynos4412_tmu_registers = {
9595
.triminfo_data = EXYNOS_TMU_REG_TRIMINFO,
9696
.triminfo_25_shift = EXYNOS_TRIMINFO_25_SHIFT,
9797
.triminfo_85_shift = EXYNOS_TRIMINFO_85_SHIFT,
9898
.triminfo_ctrl = EXYNOS_TMU_TRIMINFO_CON,
9999
.triminfo_reload_shift = EXYNOS_TRIMINFO_RELOAD_SHIFT,
100100
.tmu_ctrl = EXYNOS_TMU_REG_CONTROL,
101+
.test_mux_addr_shift = EXYNOS4412_MUX_ADDR_SHIFT,
101102
.buf_vref_sel_shift = EXYNOS_TMU_REF_VOLTAGE_SHIFT,
102103
.buf_vref_sel_mask = EXYNOS_TMU_REF_VOLTAGE_MASK,
103104
.therm_trip_mode_shift = EXYNOS_TMU_TRIP_MODE_SHIFT,
@@ -128,7 +129,7 @@ static const struct exynos_tmu_registers exynos5250_tmu_registers = {
128129
.emul_time_mask = EXYNOS_EMUL_TIME_MASK,
129130
};
130131

131-
#define EXYNOS5250_TMU_DATA \
132+
#define EXYNOS4412_TMU_DATA \
132133
.threshold_falling = 10, \
133134
.trigger_levels[0] = 85, \
134135
.trigger_levels[1] = 103, \
@@ -162,15 +163,32 @@ static const struct exynos_tmu_registers exynos5250_tmu_registers = {
162163
.temp_level = 103, \
163164
}, \
164165
.freq_tab_count = 2, \
165-
.type = SOC_ARCH_EXYNOS, \
166-
.registers = &exynos5250_tmu_registers, \
166+
.registers = &exynos4412_tmu_registers, \
167167
.features = (TMU_SUPPORT_EMULATION | TMU_SUPPORT_TRIM_RELOAD | \
168168
TMU_SUPPORT_FALLING_TRIP | TMU_SUPPORT_READY_STATUS | \
169169
TMU_SUPPORT_EMUL_TIME)
170+
#endif
170171

172+
#if defined(CONFIG_SOC_EXYNOS4412)
173+
struct exynos_tmu_init_data const exynos4412_default_tmu_data = {
174+
.tmu_data = {
175+
{
176+
EXYNOS4412_TMU_DATA,
177+
.type = SOC_ARCH_EXYNOS4412,
178+
.test_mux = EXYNOS4412_MUX_ADDR_VALUE,
179+
},
180+
},
181+
.tmu_count = 1,
182+
};
183+
#endif
184+
185+
#if defined(CONFIG_SOC_EXYNOS5250)
171186
struct exynos_tmu_init_data const exynos5250_default_tmu_data = {
172187
.tmu_data = {
173-
{ EXYNOS5250_TMU_DATA },
188+
{
189+
EXYNOS4412_TMU_DATA,
190+
.type = SOC_ARCH_EXYNOS5250,
191+
},
174192
},
175193
.tmu_count = 1,
176194
};

drivers/thermal/samsung/exynos_tmu_data.h

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,10 @@
9595

9696
#define EXYNOS_MAX_TRIGGER_PER_REG 4
9797

98+
/* Exynos4412 specific */
99+
#define EXYNOS4412_MUX_ADDR_VALUE 6
100+
#define EXYNOS4412_MUX_ADDR_SHIFT 20
101+
98102
/*exynos5440 specific registers*/
99103
#define EXYNOS5440_TMU_S0_7_TRIM 0x000
100104
#define EXYNOS5440_TMU_S0_7_CTRL 0x020
@@ -138,7 +142,14 @@ extern struct exynos_tmu_init_data const exynos4210_default_tmu_data;
138142
#define EXYNOS4210_TMU_DRV_DATA (NULL)
139143
#endif
140144

141-
#if (defined(CONFIG_SOC_EXYNOS5250) || defined(CONFIG_SOC_EXYNOS4412))
145+
#if defined(CONFIG_SOC_EXYNOS4412)
146+
extern struct exynos_tmu_init_data const exynos4412_default_tmu_data;
147+
#define EXYNOS4412_TMU_DRV_DATA (&exynos4412_default_tmu_data)
148+
#else
149+
#define EXYNOS4412_TMU_DRV_DATA (NULL)
150+
#endif
151+
152+
#if defined(CONFIG_SOC_EXYNOS5250)
142153
extern struct exynos_tmu_init_data const exynos5250_default_tmu_data;
143154
#define EXYNOS5250_TMU_DRV_DATA (&exynos5250_default_tmu_data)
144155
#else

drivers/thermal/thermal_hwmon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ int thermal_add_hwmon_sysfs(struct thermal_zone_device *tz)
159159

160160
INIT_LIST_HEAD(&hwmon->tz_list);
161161
strlcpy(hwmon->type, tz->type, THERMAL_NAME_LENGTH);
162-
hwmon->device = hwmon_device_register(&tz->device);
162+
hwmon->device = hwmon_device_register(NULL);
163163
if (IS_ERR(hwmon->device)) {
164164
result = PTR_ERR(hwmon->device);
165165
goto free_mem;

drivers/thermal/ti-soc-thermal/ti-thermal-common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ static inline int ti_thermal_get_temp(struct thermal_zone_device *thermal,
110110
} else {
111111
dev_err(bgp->dev,
112112
"Failed to read PCB state. Using defaults\n");
113+
ret = 0;
113114
}
114115
}
115116
*temp = ti_thermal_hotspot_temperature(tmp, slope, constant);

drivers/thermal/x86_pkg_temp_thermal.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,18 +316,19 @@ static void pkg_temp_thermal_threshold_work_fn(struct work_struct *work)
316316
int phy_id = topology_physical_package_id(cpu);
317317
struct phy_dev_entry *phdev = pkg_temp_thermal_get_phy_entry(cpu);
318318
bool notify = false;
319+
unsigned long flags;
319320

320321
if (!phdev)
321322
return;
322323

323-
spin_lock(&pkg_work_lock);
324+
spin_lock_irqsave(&pkg_work_lock, flags);
324325
++pkg_work_cnt;
325326
if (unlikely(phy_id > max_phy_id)) {
326-
spin_unlock(&pkg_work_lock);
327+
spin_unlock_irqrestore(&pkg_work_lock, flags);
327328
return;
328329
}
329330
pkg_work_scheduled[phy_id] = 0;
330-
spin_unlock(&pkg_work_lock);
331+
spin_unlock_irqrestore(&pkg_work_lock, flags);
331332

332333
enable_pkg_thres_interrupt();
333334
rdmsrl(MSR_IA32_PACKAGE_THERM_STATUS, msr_val);
@@ -397,6 +398,7 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
397398
int thres_count;
398399
u32 eax, ebx, ecx, edx;
399400
u8 *temp;
401+
unsigned long flags;
400402

401403
cpuid(6, &eax, &ebx, &ecx, &edx);
402404
thres_count = ebx & 0x07;
@@ -420,19 +422,19 @@ static int pkg_temp_thermal_device_add(unsigned int cpu)
420422
goto err_ret_unlock;
421423
}
422424

423-
spin_lock(&pkg_work_lock);
425+
spin_lock_irqsave(&pkg_work_lock, flags);
424426
if (topology_physical_package_id(cpu) > max_phy_id)
425427
max_phy_id = topology_physical_package_id(cpu);
426428
temp = krealloc(pkg_work_scheduled,
427429
(max_phy_id+1) * sizeof(u8), GFP_ATOMIC);
428430
if (!temp) {
429-
spin_unlock(&pkg_work_lock);
431+
spin_unlock_irqrestore(&pkg_work_lock, flags);
430432
err = -ENOMEM;
431433
goto err_ret_free;
432434
}
433435
pkg_work_scheduled = temp;
434436
pkg_work_scheduled[topology_physical_package_id(cpu)] = 0;
435-
spin_unlock(&pkg_work_lock);
437+
spin_unlock_irqrestore(&pkg_work_lock, flags);
436438

437439
phy_dev_entry->phys_proc_id = topology_physical_package_id(cpu);
438440
phy_dev_entry->first_cpu = cpu;

0 commit comments

Comments
 (0)