Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp256335ybk; Tue, 19 May 2020 21:53:02 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxsPw0Vqjtnj0ds1ag6TaHqP1w+5kRQgLe8qazez/H0yWIxDONmyGO+d2ZIj5WkM8HTxg3x X-Received: by 2002:a17:906:2ec6:: with SMTP id s6mr2463561eji.532.1589950381831; Tue, 19 May 2020 21:53:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589950381; cv=none; d=google.com; s=arc-20160816; b=huFZ1MWOdiNrSGBMIBlrO2MQE/DMMRBTOoVhAoUtDvCs5aPStiLDPUXhEICV0EiiZl 0YMOdZHJE1G4GiX0ItV8lXemnd+//UC7Mp/DSGY8AbcLnRqKBRjDYP71Mnm2K+ZYoUR5 Z7gfDlvmX32x+hOBxua5GBL4tpiGeWf3zpfwS7dL63bAsS32g4g1ipAVHtWOFhaeBALR /JUd7pQNu5m8b4zW31m+zGNFYLzs976q1NPC89w2EqiKbZDBLbB2Ia3agFRwUB3MR+wm dxHT1Co95xfpe4Xrw3Bt2dLPB2BECUlQxFngIg+052T1kE/tBF3MgQZJBWAc6IRzaf7Q WkXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=0tbXb80+Yh7B9nFEtfOBNTUNTV7zrMR7BziU+1EVuks=; b=adEWgC7LZA0i3/P4si6q3RSwQ55NdsTxshQ1SJEMjRjUIf58ROroqXF9l4q64v5wvh MOnz1n0ZuDCopcqpHRItmr8O6zlGXhC2Qb4Ib4bCrpihd1Snrk213+cVov608H+kFuhV K5qNo5nrpb92Y7DuO6Y9F7AefvdPUwerRyUvsIyBnNru57x8nEOA1v1w8c2dUICGa9XJ MgeyrlpyqOkygM4n5pol9b1W0Cdcd4S6qR59Fm42oUKxJOM+QFxMlc8LTiwwy/U7EXho ji/AvXGMgaGki/B7P/kIc4CRS7r0KnKbZ/LfxZf9z7eWdMcofADcdlBhduPshCwjCs0x wIfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=ieZw2mYV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id b25si1213399edn.602.2020.05.19.21.52.37; Tue, 19 May 2020 21:53:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@verdurent-com.20150623.gappssmtp.com header.s=20150623 header.b=ieZw2mYV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726673AbgETEug (ORCPT + 99 others); Wed, 20 May 2020 00:50:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726562AbgETEug (ORCPT ); Wed, 20 May 2020 00:50:36 -0400 Received: from mail-vs1-xe42.google.com (mail-vs1-xe42.google.com [IPv6:2607:f8b0:4864:20::e42]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87BDCC061A0F for ; Tue, 19 May 2020 21:50:35 -0700 (PDT) Received: by mail-vs1-xe42.google.com with SMTP id e10so1055642vsp.12 for ; Tue, 19 May 2020 21:50:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=verdurent-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=0tbXb80+Yh7B9nFEtfOBNTUNTV7zrMR7BziU+1EVuks=; b=ieZw2mYVxPGUlbMGmsKSDyXIuetO2Ee3KwdBkVCfJdW0WhP8FZb1ISRNsDfGSJPf4H cLI/9TyJktZdy21zfRpAJDZIAHqTkpg2Pl+yRFtsG6i7k+1ylzyb8cpXoyxzAFMOdr67 bk9C5ntEWwCmqf5Q8Yjm30aenkNW5+iBSrOQ/ncL7T0dppuNhI8Igk+qtts3nR815zwb bpjJ/T0IiQ77tOaHpSYsgFZskxYM5iKzqi5M6aJn9Szm+lEycFQT/YmYytUSSSr1i0o1 rk8X8puwnJxGbDHL6t0T+BiJJm3j3cKX10Y1NddXgGpJjjrQ/nCj0pU8CAzSmqaNiWhd qgCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=0tbXb80+Yh7B9nFEtfOBNTUNTV7zrMR7BziU+1EVuks=; b=ajKuqQ52pcqTUSLGGnbuPtklW0pPho5h9ZLmFGIAheefecwhItbOod3srRuAj0R0/v 4caG9NHctGKF1L98DkTp9JQqBapCbjkNflWHT7pzqlEFrvflQ+1NoeXLOufaXhybNbhK KUYC0dPngzVR2DMuLUt5cb9BKzaBEQ+yCmzWoBhF3NFE48yUk2g4J3M08490ECSLBGtM kn+tITnQBmGpZNP9t++8kcyGg1wabMsOVtBDMkYAMcQe9FqoKyMqHeC1c8iM/TkXMBDK FD+V6YS6vr1BvKv9IROCakYsgyGGhSaWeohezGyLf9WyETs5Ocf8ob02cN8pJ45/Y1Qf SiuQ== X-Gm-Message-State: AOAM532rMJGmD6VohIUcXjtOV3HV0UH42HOFylxmHJMluVZ/sD7HCfC+ fq5EcdN6KyTecSxCDl0odqi81CAdymQnA5yAsBBFdA== X-Received: by 2002:a67:b42:: with SMTP id 63mr1965745vsl.182.1589950234641; Tue, 19 May 2020 21:50:34 -0700 (PDT) MIME-Version: 1.0 References: <20200504181616.175477-1-srinivas.pandruvada@linux.intel.com> <20200504181616.175477-6-srinivas.pandruvada@linux.intel.com> In-Reply-To: <20200504181616.175477-6-srinivas.pandruvada@linux.intel.com> From: Amit Kucheria Date: Wed, 20 May 2020 10:19:52 +0530 Message-ID: Subject: Re: [RFC][PATCH 5/5] thermal: int340x: Use new device interface To: Srinivas Pandruvada Cc: Zhang Rui , Daniel Lezcano , LKML , Linux PM list Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, May 4, 2020 at 11:47 PM Srinivas Pandruvada wrote: > > Use the new framework to send notifications for: > - Setting temperature threshold for notification to avoid polling > - Send THERMAL_TRIP_REACHED event on reaching threshold > - Send THERMAL_TRIP_UPDATE when firmware change the the existing trip > temperature I am a little confused here. I would've expected the thermal core to send the THERMAL_TRIP_* notifications, not platform drivers. Why shouldn't this be done in thermal core? > > Signed-off-by: Srinivas Pandruvada > --- > .../intel/int340x_thermal/int3403_thermal.c | 3 ++ > .../int340x_thermal/int340x_thermal_zone.c | 29 +++++++++++++++++++ > .../int340x_thermal/int340x_thermal_zone.h | 7 +++++ > .../processor_thermal_device.c | 1 + > 4 files changed, 40 insertions(+) > > diff --git a/drivers/thermal/intel/int340x_thermal/int3403_thermal.c b/drivers/thermal/intel/int340x_thermal/int3403_thermal.c > index f86cbb125e2f..77c014a113a4 100644 > --- a/drivers/thermal/intel/int340x_thermal/int3403_thermal.c > +++ b/drivers/thermal/intel/int340x_thermal/int3403_thermal.c > @@ -63,15 +63,18 @@ static void int3403_notify(acpi_handle handle, > > switch (event) { > case INT3403_PERF_CHANGED_EVENT: > + int340x_thermal_send_user_event(obj->int340x_zone, THERMAL_PERF_CHANGED, 0); > break; > case INT3403_THERMAL_EVENT: > int340x_thermal_zone_device_update(obj->int340x_zone, > THERMAL_TRIP_VIOLATED); > + int340x_thermal_send_user_event(obj->int340x_zone, THERMAL_TRIP_REACHED, 0); > break; > case INT3403_PERF_TRIP_POINT_CHANGED: > int340x_thermal_read_trips(obj->int340x_zone); > int340x_thermal_zone_device_update(obj->int340x_zone, > THERMAL_TRIP_CHANGED); > + int340x_thermal_send_user_event(obj->int340x_zone, THERMAL_TRIP_UPDATE, 0); > break; > default: > dev_err(&priv->pdev->dev, "Unsupported event [0x%x]\n", event); > diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c > index 432213272f1e..9568a2db7afd 100644 > --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c > +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.c > @@ -146,12 +146,41 @@ static int int340x_thermal_get_trip_hyst(struct thermal_zone_device *zone, > return 0; > } > > +static int int340x_thermal_get_thres_low(struct thermal_zone_device *zone, int *temp) > +{ > + struct int34x_thermal_zone *d = zone->devdata; > + > + *temp = d->aux_trips[0]; > + > + return 0; > +} > + > +static int int340x_thermal_set_thres_low(struct thermal_zone_device *zone, int temp) > +{ > + struct int34x_thermal_zone *d = zone->devdata; > + acpi_status status; > + > + if (d->override_ops && d->override_ops->set_trip_temp) > + return d->override_ops->set_trip_temp(zone, 0, temp); > + > + status = acpi_execute_simple_method(d->adev->handle, "PAT0", > + millicelsius_to_deci_kelvin(temp)); > + if (ACPI_FAILURE(status)) > + return -EIO; > + > + d->aux_trips[0] = temp; > + > + return 0; > +} > + > static struct thermal_zone_device_ops int340x_thermal_zone_ops = { > .get_temp = int340x_thermal_get_zone_temp, > .get_trip_temp = int340x_thermal_get_trip_temp, > .get_trip_type = int340x_thermal_get_trip_type, > .set_trip_temp = int340x_thermal_set_trip_temp, > .get_trip_hyst = int340x_thermal_get_trip_hyst, > + .set_temp_thres_low = int340x_thermal_set_thres_low, > + .get_temp_thres_low = int340x_thermal_get_thres_low, > }; > > static int int340x_thermal_get_trip_config(acpi_handle handle, char *name, > diff --git a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h > index 3b4971df1b33..142027e4955f 100644 > --- a/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h > +++ b/drivers/thermal/intel/int340x_thermal/int340x_thermal_zone.h > @@ -58,4 +58,11 @@ static inline void int340x_thermal_zone_device_update( > thermal_zone_device_update(tzone->zone, event); > } > > +static inline void int340x_thermal_send_user_event( > + struct int34x_thermal_zone *tzone, > + enum thermal_device_events event, > + u64 data) > +{ > + thermal_dev_send_event(tzone->zone->id, event, data); > +} > #endif > diff --git a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c > index 297db1d2d960..e25f01948d33 100644 > --- a/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c > +++ b/drivers/thermal/intel/int340x_thermal/processor_thermal_device.c > @@ -340,6 +340,7 @@ static void proc_thermal_notify(acpi_handle handle, u32 event, void *data) > proc_thermal_read_ppcc(proc_priv); > int340x_thermal_zone_device_update(proc_priv->int340x_zone, > THERMAL_DEVICE_POWER_CAPABILITY_CHANGED); > + int340x_thermal_send_user_event(proc_priv->int340x_zone, THERMAL_PERF_CHANGED, 0); > break; > default: > dev_dbg(proc_priv->dev, "Unsupported event [0x%x]\n", event); > -- > 2.25.4 >