• Rafael J. Wysocki's avatar
    thermal: intel: intel_soc_dts_iosf: Rework critical trip setup · 02a49aac
    Rafael J. Wysocki authored
    Critical trip points appear in the DTS thermal zones only after those
    thermal zones have been registered via intel_soc_dts_iosf_init().
    Moreover, they are "created" by changing the type of an existing trip
    point from THERMAL_TRIP_PASSIVE to THERMAL_TRIP_CRITICAL via
    intel_soc_dts_iosf_add_read_only_critical_trip(), the caller of which
    has to be careful enough to pass at least 1 as the number of read-only
    trip points to intel_soc_dts_iosf_init() beforehand.
    
    This is questionable, because user space may have started to use the
    trips at the time when intel_soc_dts_iosf_add_read_only_critical_trip()
    runs and there is no synchronization between it and sys_set_trip_temp().
    
    To address it, use the observation that nonzero number of read-only
    trip points is only passed to intel_soc_dts_iosf_init() when critical
    trip points are going to be used, so in fact that function may get all
    of the information regarding the critical trip points upfront and it
    can configure them before registering the corresponding thermal zones.
    
    Accordingly, replace the read_only_trip_count argument of
    intel_soc_dts_iosf_init() with a pair of new arguments related to
    critical trip points: a bool one indicating whether or not critical
    trip points are to be used at all and an int one representing the
    critical trip point temperature offset relative to Tj_max.  Use these
    arguments to configure the critical trip points before the registration
    of the thermal zones and to compute the number of writeable trip points
    in add_dts_thermal_zone().
    
    Modify both callers of intel_soc_dts_iosf_init() to take these changes
    into account and drop the intel_soc_dts_iosf_add_read_only_critical_trip()
    call, that is not necessary any more, from intel_soc_thermal_init(),
    which also allows it to return success right after requesting the IRQ.
    
    Finally, drop intel_soc_dts_iosf_add_read_only_critical_trip()
    altogether, because it does not have any more users.
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    Reviewed-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
    02a49aac
intel_soc_dts_thermal.c 2.84 KB