Received: by 2002:a25:e7d8:0:0:0:0:0 with SMTP id e207csp369598ybh; Thu, 12 Mar 2020 03:38:44 -0700 (PDT) X-Google-Smtp-Source: ADFU+vtfxT6vpeIgQ8+qOYWtRPeATuxaLiUc+NeZw+RLRbMT1tjdomG/gvvTmxt+Br4xBt6Nm/8b X-Received: by 2002:aca:6156:: with SMTP id v83mr1974998oib.171.1584009524350; Thu, 12 Mar 2020 03:38:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1584009524; cv=none; d=google.com; s=arc-20160816; b=rfU9wIh/95LUhCZMSWhrs+cH/GQ2eLFdWpVRja0Tl6emzo9T4sDsGfaVPRP1Zr+GP9 KingJihJX1zWrK0VYBJjJI8uHKAA+wMMO8U5rt/fsndc1qPRcVTVi7derx0k5Zq6tAZr ye7w3P5ZHOXD2z7bT5kc3zXgEAqjhI2v7tdSMjFa0lVHKVu9FkG2X/0LgB+n1awGfHIR tHRp1N01KsxPes3Opc2qnQtCuDxTIODlrKXrDzEt+J8FMwUoQ3RQvHafGCpC6BPF6K4/ YgBS1lwCvSGOaDeInaBKLbFhlg5MJi2GCoNlNxCDDtGjLczMYuZlgAi/grpq04nm660s p3GA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject:dkim-signature; bh=OxW55xe9AlmvDZECFaEkxBFqcg4088n15QcCYOxDfUM=; b=o2By16b2kkDq1BX/zRvmgsyvwTSls3sdNdygrDhOCI9a399k+RxZTLcalRhfVjnykg dS2ZcI9rNXlOgQ8EqbKUT39SkMYMtObjLCvZ6dKzNuqBNFirAOruy1y8PAtX9pzksVDM q7WWuBMsRb8D5HfJESm7FB9pM13qIwz67TUO7wT2v/aPAWP4igOSyb54OtX74u6kiR+G Hbfu01NSA2aWjvhUiWayydfCJFRtpAAKl9mRUH7AAwW1MGNaSvD9OcF8vxwYeciWHm1H nSQwmlZACC+9CagixESeQ4Iw1rlkmQvhlHTciQk3+dD5dsQLU1+4QU79vvl1jgZ5R7h7 6zvQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nHb/MqOl"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r1si2699533oti.200.2020.03.12.03.38.31; Thu, 12 Mar 2020 03:38:44 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="nHb/MqOl"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726669AbgCLKiO (ORCPT + 99 others); Thu, 12 Mar 2020 06:38:14 -0400 Received: from mail-wr1-f65.google.com ([209.85.221.65]:44246 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726023AbgCLKiN (ORCPT ); Thu, 12 Mar 2020 06:38:13 -0400 Received: by mail-wr1-f65.google.com with SMTP id l18so6709089wru.11 for ; Thu, 12 Mar 2020 03:38:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:autocrypt:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=OxW55xe9AlmvDZECFaEkxBFqcg4088n15QcCYOxDfUM=; b=nHb/MqOluW8eExuZO33x8EvaByVXliZgDkWz3mCkgvqS9qPQQ2vvCxxK2JeeHNl0DC ptEwgoLqzusqKRneYkbdruveUAD/rKf+22uGTuSpDVfbNkB0scioR8U6oba5FpN+41KY fXaQWS7ZTXchw5AoQ2DxuZSHnPkO2yEdbPypbafqBuXiNhqCJF7fJv6oY98M+vLhNBbC ugir6OomXI4NB0ENnJkH2jgAQL2n8PoIgtSad8GZZh+aH6PoHqzQii4ppAaD1aPGyLRH 5zzizwtLp9/PE6Tb7BIUswLiSQQm/nx3GAZARA4+Jg+tvk1cH8C7i1G2WiRd719zkvDP 4pPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=OxW55xe9AlmvDZECFaEkxBFqcg4088n15QcCYOxDfUM=; b=J2tG8z247B2Wq3JdCY/FweaplhjceuIu/QIxS2hGc6jt6GCf+gQn7S+CAkKE3sZxp+ jn1pWyyEvRKeLZE1bQy63Zm9tfe/SsHuSlVjllt33XNbiuDEeNzvnqwcTYuitg/6jOgz peJMIJoU7bNlJS+oTYukfvewilKpuSHrdfUmFxis37FZbs7XVluIXtqB23X/lS7BTbme Czqs/aCktmHDb6vPGmoR86Iwht7RgibHcb+xtRt/KFcSt08Mhx2RFvNCo21A0S8FctPH T6L6scLcsukhmS/1yg6vx6qfbpI3PNQT0Aw+Za0FYB18QYFF5Q66CVjTKoIR57JBMGtH WCig== X-Gm-Message-State: ANhLgQ2X1nhuW5fJy+VGcwnRWLoeGytmAWTSMud7i8XxYy6CYTQSxWjh GBS9VEOt9VWwzQ4RdmLOO0takQ== X-Received: by 2002:adf:a506:: with SMTP id i6mr9729599wrb.146.1584009490068; Thu, 12 Mar 2020 03:38:10 -0700 (PDT) Received: from ?IPv6:2a01:e34:ed2f:f020:3880:fdc2:ef6b:879f? ([2a01:e34:ed2f:f020:3880:fdc2:ef6b:879f]) by smtp.googlemail.com with ESMTPSA id 98sm13554139wrm.64.2020.03.12.03.38.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 12 Mar 2020 03:38:09 -0700 (PDT) Subject: Re: [RESEND PATCH 1/5] scsi: ufs: Add ufs thermal support To: Avi Shchislowski , Avri Altman , Guenter Roeck , Alim Akhtar , "James E.J. Bottomley" , "Martin K. Petersen" , Zhang Rui , linux-kernel@vger.kernel.org Cc: Avi Shchislowski References: <1582450522-13256-1-git-send-email-avi.shchislowski@wdc.com> <1582450522-13256-2-git-send-email-avi.shchislowski@wdc.com> From: Daniel Lezcano Autocrypt: addr=daniel.lezcano@linaro.org; prefer-encrypt=mutual; keydata= xsFNBFv/yykBEADDdW8RZu7iZILSf3zxq5y8YdaeyZjI/MaqgnvG/c3WjFaunoTMspeusiFE sXvtg3ehTOoyD0oFjKkHaia1Zpa1m/gnNdT/WvTveLfGA1gH+yGes2Sr53Ht8hWYZFYMZc8V 2pbSKh8wepq4g8r5YI1XUy9YbcTdj5mVrTklyGWA49NOeJz2QbfytMT3DJmk40LqwK6CCSU0 9Ed8n0a+vevmQoRZJEd3Y1qXn2XHys0F6OHCC+VLENqNNZXdZE9E+b3FFW0lk49oLTzLRNIq 0wHeR1H54RffhLQAor2+4kSSu8mW5qB0n5Eb/zXJZZ/bRiXmT8kNg85UdYhvf03ZAsp3qxcr xMfMsC7m3+ADOtW90rNNLZnRvjhsYNrGIKH8Ub0UKXFXibHbafSuq7RqyRQzt01Ud8CAtq+w P9EftUysLtovGpLSpGDO5zQ++4ZGVygdYFr318aGDqCljKAKZ9hYgRimPBToDedho1S1uE6F 6YiBFnI3ry9+/KUnEP6L8Sfezwy7fp2JUNkUr41QF76nz43tl7oersrLxHzj2dYfWUAZWXva wW4IKF5sOPFMMgxoOJovSWqwh1b7hqI+nDlD3mmVMd20VyE9W7AgTIsvDxWUnMPvww5iExlY eIC0Wj9K4UqS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/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <1582450522-13256-2-git-send-email-avi.shchislowski@wdc.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 23/02/2020 10:35, Avi Shchislowski wrote: > From: Avi Shchislowski > > Support the new temperature notification attributes introduced in > UFSv3.0. Add exception event mask, and ufs features attributes. > > Signed-off-by: Avi Shchislowski > --- > drivers/scsi/ufs/Kconfig | 11 ++++ > drivers/scsi/ufs/Makefile | 1 + > drivers/scsi/ufs/ufs-thermal.c | 123 +++++++++++++++++++++++++++++++++++++++++ Why not put the driver under drivers/thermal/ ? > drivers/scsi/ufs/ufs-thermal.h | 19 +++++++ > drivers/scsi/ufs/ufs.h | 11 ++++ > drivers/scsi/ufs/ufshcd.c | 3 + > drivers/scsi/ufs/ufshcd.h | 10 ++++ > 7 files changed, 178 insertions(+) > create mode 100644 drivers/scsi/ufs/ufs-thermal.c > create mode 100644 drivers/scsi/ufs/ufs-thermal.h > > diff --git a/drivers/scsi/ufs/Kconfig b/drivers/scsi/ufs/Kconfig > index d14c224..bed56ee 100644 > --- a/drivers/scsi/ufs/Kconfig > +++ b/drivers/scsi/ufs/Kconfig > @@ -160,3 +160,14 @@ config SCSI_UFS_BSG > > Select this if you need a bsg device node for your UFS controller. > If unsure, say N. > + > +config THERMAL_UFS > + bool "Thermal UFS" > + depends on THERMAL && SCSI_UFSHCD > + help > + A UFS3.0 feature that allows using the ufs device as a temperature > + sensor. it provide notification to the host when the UFS device > + case temperature approaches its pre-defined boundaries. > + > + Select Y to enable this feature, otherwise say N. > + If unsure, say N. > \ No newline at end of file ^^^^ > diff --git a/drivers/scsi/ufs/Makefile b/drivers/scsi/ufs/Makefile > index 94c6c5d..fd35941 100644 > --- a/drivers/scsi/ufs/Makefile > +++ b/drivers/scsi/ufs/Makefile > @@ -12,3 +12,4 @@ obj-$(CONFIG_SCSI_UFSHCD_PLATFORM) += ufshcd-pltfrm.o > obj-$(CONFIG_SCSI_UFS_HISI) += ufs-hisi.o > obj-$(CONFIG_SCSI_UFS_MEDIATEK) += ufs-mediatek.o > obj-$(CONFIG_SCSI_UFS_TI_J721E) += ti-j721e-ufs.o > +obj-$(CONFIG_THERMAL_UFS) += ufs-thermal.o > diff --git a/drivers/scsi/ufs/ufs-thermal.c b/drivers/scsi/ufs/ufs-thermal.c > new file mode 100644 > index 0000000..469c1ed > --- /dev/null > +++ b/drivers/scsi/ufs/ufs-thermal.c > @@ -0,0 +1,123 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * thermal ufs > + * > + * Copyright (C) 2020 Western Digital Corporation > + */ > +#include > +#include "ufs-thermal.h" > + > +enum { > + UFS_THERM_MAX_TEMP, > + UFS_THERM_HIGH_TEMP, > + UFS_THERM_LOW_TEMP, > + UFS_THERM_MIN_TEMP, > + > + /* keep last */ > + UFS_THERM_MAX_TRIPS > +}; > + > +/** > + *struct ufs_thermal - thermal zone related data > + * @tzone: thermal zone device data > + */ > +static struct ufs_thermal { > + struct thermal_zone_device *zone; > +} thermal; > + > +static struct thermal_zone_device_ops ufs_thermal_ops = { > + .get_temp = NULL, > + .get_trip_temp = NULL, > + .get_trip_type = NULL, > +}; Can you merge all the patches related to this driver into a single one? > +static int ufs_thermal_enable_ee(struct ufs_hba *hba) > +{ > + /* later */ > + return -EINVAL; > +} > + > +static void ufs_thermal_zone_unregister(struct ufs_hba *hba) > +{ > + if (thermal.zone) { > + dev_dbg(hba->dev, "Thermal zone device unregister\n"); > + thermal_zone_device_unregister(thermal.zone); > + thermal.zone = NULL; > + } > +} > + > +static int ufs_thermal_register(struct ufs_hba *hba) > +{ > + int err = 0; > + char name[THERMAL_NAME_LENGTH] = {}; > + > + snprintf(name, THERMAL_NAME_LENGTH, "ufs_storage_%d", > + hba->host->host_no); > + > + thermal.zone = thermal_zone_device_register(name, UFS_THERM_MAX_TRIPS, > + 0, hba, &ufs_thermal_ops, NULL, 0, 0); > + if (IS_ERR(thermal.zone)) { > + err = PTR_ERR(thermal.zone); > + dev_err(hba->dev, "Failed to register to thermal zone, err %d\n", > + err); > + thermal.zone = NULL; > + goto out; > + } It is pointless to reassign thermal.zone to NULL. As there is no rollback involved here, This can be simplified to: if (IS_ERR(thermal.zone)) { dev_err(hba->dev, "..."); return PTR_ERR(thermal.zone); } > + > + /* thermal support is enabled only after successful nit: comment format /* * thermal support ... * ... */ > + * enablement of thermal exception > + */ > + if (ufs_thermal_enable_ee(hba)) { > + dev_info(hba->dev, "Failed to enable thermal exception\n"); > + ufs_thermal_zone_unregister(hba); > + err = -EINVAL; > + } err = ufs_thermal_enable_ee(hba); if (err) { ... return err; } return 0; > + > +out: > + return err; > +} > + > +int ufs_thermal_probe(struct ufs_hba *hba) > +{ > + u8 ufs_features; > + u8 *desc_buf = NULL; > + int err = -EINVAL; > + > + if (!ufshcd_thermal_management_enabled(hba)) > + goto out; > + > + desc_buf = kzalloc(hba->desc_size.dev_desc, GFP_KERNEL); > + if (!desc_buf) { > + err = -ENOMEM; > + goto out; > + } > + > + if (ufshcd_read_desc_param(hba, QUERY_DESC_IDN_DEVICE, 0, 0, desc_buf, > + hba->desc_size.dev_desc)) > + goto out; > + > + > + ufs_features = desc_buf[DEVICE_DESC_PARAM_UFS_FEAT] & > + (UFS_FEATURE_HTEMP | UFS_FEATURE_LTEMP); > + if (!ufs_features) > + goto out; > + > + err = ufs_thermal_register(hba); > + if (err) > + goto out; > + > + hba->thermal_features = ufs_features; > + > +out: > + kfree(desc_buf); > + return err; > +} > + > +void ufs_thermal_remove(struct ufs_hba *hba) > +{ > + if (!ufshcd_thermal_management_enabled(hba)) > + return; > + > + ufs_thermal_zone_unregister(hba); > + hba->thermal_features = 0; Why is this needed ? > +} > diff --git a/drivers/scsi/ufs/ufs-thermal.h b/drivers/scsi/ufs/ufs-thermal.h > new file mode 100644 > index 0000000..7c0fcbe > --- /dev/null > +++ b/drivers/scsi/ufs/ufs-thermal.h > @@ -0,0 +1,19 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > +/* > + * Copyright (C) 2018 Western Digital Corporation > + */ > +#ifndef UFS_THERMAL_H > +#define UFS_THERMAL_H > + > +#include "ufshcd.h" > +#include "ufs.h" > + > +#ifdef CONFIG_THERMAL_UFS > +void ufs_thermal_remove(struct ufs_hba *hba); > +int ufs_thermal_probe(struct ufs_hba *hba); > +#else > +static inline void ufs_thermal_remove(struct ufs_hba *hba) {} > +static inline int ufs_thermal_probe(struct ufs_hba *hba) {return 0; } > +#endif /* CONFIG_THERMAL_UFS */ > + > +#endif /* UFS_THERMAL_H */ > diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h > index dde2eb0..eb729cc 100644 > --- a/drivers/scsi/ufs/ufs.h > +++ b/drivers/scsi/ufs/ufs.h > @@ -332,6 +332,17 @@ enum { > UFSHCD_AMP = 3, > }; > > +/* UFS Features - to decode bUFSFeaturesSupport */ > +enum { > + UFS_FEATURE_FFU = BIT(0), > + UFS_FEATURE_PSA = BIT(1), > + UFS_FEATURE_LIFE = BIT(2), > + UFS_FEATURE_REFRESH = BIT(3), > + UFS_FEATURE_HTEMP = BIT(4), > + UFS_FEATURE_LTEMP = BIT(5), > + UFS_FEATURE_ETEMP = BIT(6), > +}; > + > #define POWER_DESC_MAX_SIZE 0x62 > #define POWER_DESC_MAX_ACTV_ICC_LVLS 16 > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index abd0e6b..099d2de 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -47,6 +47,7 @@ > #include "unipro.h" > #include "ufs-sysfs.h" > #include "ufs_bsg.h" > +#include "ufs-thermal.h" > > #define CREATE_TRACE_POINTS > #include > @@ -7111,6 +7112,7 @@ static int ufshcd_probe_hba(struct ufs_hba *hba, bool async) > > /* Enable Auto-Hibernate if configured */ > ufshcd_auto_hibern8_enable(hba); > + ufs_thermal_probe(hba); > > out: > > @@ -8278,6 +8280,7 @@ int ufshcd_shutdown(struct ufs_hba *hba) > */ > void ufshcd_remove(struct ufs_hba *hba) > { > + ufs_thermal_remove(hba); > ufs_bsg_remove(hba); > ufs_sysfs_remove_nodes(hba->dev); > blk_cleanup_queue(hba->tmf_queue); > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index 2ae6c7c..28c0063 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -730,6 +730,11 @@ struct ufs_hba { > > struct device bsg_dev; > struct request_queue *bsg_queue; > + > +#define UFSHCD_CAP_THERMAL_MANAGEMENT (1 << 7) > + > + u8 thermal_features; > + > }; > > /* Returns true if clocks can be gated. Otherwise false */ > @@ -754,6 +759,11 @@ static inline bool ufshcd_is_rpm_autosuspend_allowed(struct ufs_hba *hba) > return hba->caps & UFSHCD_CAP_RPM_AUTOSUSPEND; > } > > +static inline bool ufshcd_thermal_management_enabled(struct ufs_hba *hba) > +{ > + return hba->caps & UFSHCD_CAP_THERMAL_MANAGEMENT; > +} > + > static inline bool ufshcd_is_intr_aggr_allowed(struct ufs_hba *hba) > { > /* DWC UFS Core has the Interrupt aggregation feature but is not detectable*/ > -- Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog