Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp6960961rwb; Wed, 18 Jan 2023 11:32:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXuxx7XU7acCcKMgvaKKsi+Lr9Octb19YYwvHjY5qT41jG8toa8vOT5ikYaVikjw8BM7G4kq X-Received: by 2002:a17:902:f2ca:b0:193:2303:c9e5 with SMTP id h10-20020a170902f2ca00b001932303c9e5mr7745762plc.20.1674070337466; Wed, 18 Jan 2023 11:32:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674070337; cv=none; d=google.com; s=arc-20160816; b=dFru2MqUQvxdp/irQ8ynGMX5jJWDmw/14PxvIIxbrmM7N61V7wNrgGR+654fwKDhjU Sazw/M4oBxbh0a93ES4FturSgjGVP8a7y7R3nD8W3/nnYxn0lTuCK1LmdjzkwdwH01G6 rTO8Up6ZEncPTUqXp+V/7IwZ2F7O3syCJ/0VrcaGy0KRjmHc+V1M9IpE0QsGIlZ4CgaS IiKMCsZ2yilfSPdR1NaAwyHfdVdVg2t2eLBFrCuv1BX3LQKbH4JAQZhG0Ym4KIFJuRGN PuDtytS1JxnfWiI4XV9vbXfJmdadL7wyX3rQxJGs0+3W9KTWb2fTWkt7EqNNAm9FDHTe LGLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature; bh=fkqVYbukIeNYI6LTTBy5YFHkWr98XZB/etshPNSxpKs=; b=KFFZgldOfbfRfJfFC9ghCQxc0bzAVNnO4SQhVsozMcP7UQpf7kBOZuOFk8Ajwrz3dk nUxuCaDSKALjQaeznRY5cphD+dA20+0Wyjht9gjrdxPe0XZ7W/VTWm/akm/vxG2O7GBY Kr6gntguLeC5RgUJkqtpGRyCsTv/tDI2mZUWBEwYPj1nh6ku0Hpw4CF7DfBvHDteyuNz 3mwlgoRcDbDT/Xdf/vPbYw3ZwOFnPvUIuH7YmhADlgQkCN4Hwgqk2ous6cYPJMCF5lTL Qf7eFA6DNt6hcLp1bxX8uRqOcwYfX/O0OdPHbsZ8bgfn6o8o0rh2gJ6hi31w0Bq3OoQP faGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nhpjAblN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g2-20020a170902c38200b0019489437a80si11430015plg.144.2023.01.18.11.32.11; Wed, 18 Jan 2023 11:32:17 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=nhpjAblN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229572AbjARTJ6 (ORCPT + 45 others); Wed, 18 Jan 2023 14:09:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229840AbjARTJx (ORCPT ); Wed, 18 Jan 2023 14:09:53 -0500 Received: from mga05.intel.com (mga05.intel.com [192.55.52.43]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62EFF5143A; Wed, 18 Jan 2023 11:09:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1674068992; x=1705604992; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=4ZvVKyuc/15y4uwM2vM5DwHTEG1jR38Bd4ONK3Npz5Y=; b=nhpjAblNZMqAvOr3mjXyn4NKB5QETpjn446T9LpTJ41weg33KedolgKJ PXx4i054BXuoxx1Pti3uYvunSz8F9mV2BZ8BHvWes5FiM8qBheKinP6I9 mu7GL3guQKx5hovPrPar9+qFc+sOpulm3WTvwXTSG2wQR0XDjDHKQ3f2X S05MyE21lDAs0myMxjL5ZbnXn7aa04PEy0sm7V9YYT8GL3BjasdtiZmTG 2x+7KZQF0dQWuAHC1boPHZ8Kq6nUIMUT6rWvNhQapIYTdJeCTv3ZkqiI4 WXSATCy9YvfHmKgO81JlpERLRjbo2wyIhOOrgI6bqrQRxsmjpEpLgGtq3 Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="411313056" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="411313056" Received: from orsmga007.jf.intel.com ([10.7.209.58]) by fmsmga105.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 11:09:52 -0800 X-IronPort-AV: E=McAfee;i="6500,9779,10594"; a="653065942" X-IronPort-AV: E=Sophos;i="5.97,226,1669104000"; d="scan'208";a="653065942" Received: from yzeleke-mobl1.amr.corp.intel.com (HELO spandruv-desk1.amr.corp.intel.com) ([10.209.16.158]) by orsmga007-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Jan 2023 11:09:51 -0800 Message-ID: Subject: Re: [PATCH 2/3] thermal/drivers/intel: Use generic trip points for processor_thermal_device_pci From: srinivas pandruvada To: Daniel Lezcano , rafael@kernel.org Cc: linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, rui.zhang@intel.com, Amit Kucheria , Sumeet Pawnikar , Shang XiaoJing Date: Wed, 18 Jan 2023 11:09:51 -0800 In-Reply-To: <20230118181622.33335-2-daniel.lezcano@linaro.org> References: <20230118181622.33335-1-daniel.lezcano@linaro.org> <20230118181622.33335-2-daniel.lezcano@linaro.org> Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.42.4 (3.42.4-2.fc35) MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-4.3 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_MED,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 2023-01-18 at 19:16 +0100, Daniel Lezcano wrote: > The thermal framework gives the possibility to register the trip > points with the thermal zone. When that is done, no get_trip_* ops > are > needed and they can be removed. > > Convert ops content logic into generic trip points and register them > with the > thermal zone. > In this scheme is the assumption is that trip point temperature never changes? If firmware updated the trip temperature, what needs to be done? Thanks, Srinivas > Signed-off-by: Daniel Lezcano > --- >  .../processor_thermal_device_pci.c            | 53 ++++++++--------- > -- >  1 file changed, 22 insertions(+), 31 deletions(-) > > diff --git > a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci. > c > b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci. > c > index bf1b1cdfade4..c7d50862bf56 100644 > --- > a/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci. > c > +++ > b/drivers/thermal/intel/int340x_thermal/processor_thermal_device_pci. > c > @@ -144,34 +144,6 @@ static int sys_get_curr_temp(struct > thermal_zone_device *tzd, int *temp) >         return 0; >  } >   > -static int sys_get_trip_temp(struct thermal_zone_device *tzd, > -                            int trip, int *temp) > -{ > -       struct proc_thermal_pci *pci_info = tzd->devdata; > -       u32 _temp; > - > -       proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_THRES_0, > &_temp); > -       if (!_temp) { > -               *temp = THERMAL_TEMP_INVALID; > -       } else { > -               int tjmax; > - > -               proc_thermal_mmio_read(pci_info, > PROC_THERMAL_MMIO_TJMAX, &tjmax); > -               _temp = tjmax - _temp; > -               *temp = (unsigned long)_temp * 1000; > -       } > - > -       return 0; > -} > - > -static int sys_get_trip_type(struct thermal_zone_device *tzd, int > trip, > -                             enum thermal_trip_type *type) > -{ > -       *type = THERMAL_TRIP_PASSIVE; > - > -       return 0; > -} > - >  static int sys_set_trip_temp(struct thermal_zone_device *tzd, int > trip, int temp) >  { >         struct proc_thermal_pci *pci_info = tzd->devdata; > @@ -200,10 +172,26 @@ static int sys_set_trip_temp(struct > thermal_zone_device *tzd, int trip, int temp >         return 0; >  } >   > +static int get_trip_temp(struct proc_thermal_pci *pci_info) > +{ > +       int temp, tjmax; > + > +       proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_THRES_0, > &temp); > +       if (!temp) > +               return THERMAL_TEMP_INVALID; > + > +       proc_thermal_mmio_read(pci_info, PROC_THERMAL_MMIO_TJMAX, > &tjmax); > +       temp = (tjmax - temp) * 1000; > + > +       return temp; > +} > + > +static struct thermal_trip psv_trip = { > +       .type = THERMAL_TRIP_PASSIVE, > +}; > + >  static struct thermal_zone_device_ops tzone_ops = { >         .get_temp = sys_get_curr_temp, > -       .get_trip_temp = sys_get_trip_temp, > -       .get_trip_type = sys_get_trip_type, >         .set_trip_temp  = sys_set_trip_temp, >  }; >   > @@ -251,7 +239,10 @@ static int proc_thermal_pci_probe(struct pci_dev > *pdev, const struct pci_device_ >         if (ret) >                 goto err_ret_thermal; >   > -       pci_info->tzone = thermal_zone_device_register("TCPU_PCI", 1, > 1, pci_info, > +       psv_trip.temperature = get_trip_temp(pci_info); > +        > +       pci_info->tzone = > thermal_zone_device_register_with_trips("TCPU_PCI", &psv_trip, > +                                                       1, 1, > pci_info, >                                                         &tzone_ops, >                                                         &tzone_params > , 0, 0); >         if (IS_ERR(pci_info->tzone)) {