Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp4866758ybv; Mon, 17 Feb 2020 07:25:44 -0800 (PST) X-Google-Smtp-Source: APXvYqxwJZ4d0ehsBiFRLy8MGVCgbrw7FgMkulFhAUG55h6VLKRnXoe8J0B19RXIF6MRne7pEWuD X-Received: by 2002:a05:6830:1498:: with SMTP id s24mr13390466otq.79.1581953143915; Mon, 17 Feb 2020 07:25:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581953143; cv=none; d=google.com; s=arc-20160816; b=uolCMIN6Nx9JCRsswQqhuKk6A3XNqQoOcUMbilcGoMw9MgH5j4RfX9xznhkn6MesoB Elw+TJQV/a//83ijp6NaEIWb0gHmJDe6AjMqjdV+uX7IRdDf9H8UYjaHKzoyI2ka9mDE CzdJf++PpcDgSC9yIOpQZiAaMXXlJFnP/hOtjv6VgEQCiLzCdu3qD+rYXYrjga9s2ahO +oOdetKPX/kSlHQc4mI7PTmIMbTnSN1HO60GH71JRyOlJQdw3yf3pNgQBNmzdRw3GyR+ 4soDGMoA+db4MN9sNlTT2JktPXYo5j++WGug8ykqAIkDqySbIFmPOgCEhnV1w7eziC+d NJFg== 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=uWzJUoyM/E+cChM1AtHHgZTTLGuCAVXjAFYI38VEtZ0=; b=fw5Pcmha7A0Ji4LYIG8ZE7fCmh02/yxf9+IS3gBKm8bjzFGnyKqVxZih8Y3fv/SbCm VhRITtjpoo3QM45s+e0EpEUDoF2RLVKsGtUI7bIS2JNTwuak+WnwgQNc+dcUkVHLZl6Y 2aRPPq0KpzFsUnVv4jxlKQ50aU5dSqXj9T0RskgE1zy761fRPa7cghCIFCRu5NjcDmhH 5/pLiqRYg7AbL7FlnkCJswvD/XMfEbkrhVatcp/qRS0gVhv2jvCyMg9pK0CFFSmxR6/n eqkc32JpvK+DEQ3ruip22kCcicuK36PJytZwqTKAX2o1XMBj7HL9kqjIGgRYeWPZ6btO FUww== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=JSYel0nS; 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 4si6506039oip.107.2020.02.17.07.25.31; Mon, 17 Feb 2020 07:25:43 -0800 (PST) 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=JSYel0nS; 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 S1728595AbgBQPTF (ORCPT + 99 others); Mon, 17 Feb 2020 10:19:05 -0500 Received: from mail-wr1-f65.google.com ([209.85.221.65]:33634 "EHLO mail-wr1-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727533AbgBQPTF (ORCPT ); Mon, 17 Feb 2020 10:19:05 -0500 Received: by mail-wr1-f65.google.com with SMTP id u6so20251974wrt.0 for ; Mon, 17 Feb 2020 07:19:02 -0800 (PST) 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=uWzJUoyM/E+cChM1AtHHgZTTLGuCAVXjAFYI38VEtZ0=; b=JSYel0nSekRza1rap31VPpG3XQOWmubSzagYhvCjd8h5giFdy2G9q4UHhjCGH/SyRg mdBfhRgQQfyCDjH74EMsjTh1KEyH5nWN87+z9O8WQoJKpdSltsUdmzA4HepWUlHX2/SW mJo6VxODQ7dV6hXyNgPpWELSSY4yBW/PLMikRLIVFS/MTO18wn2cRekNdygj9jXZQqAO NoyBo5/mSnLf7atXx4c9KQSOmbcpQYbZE4LO8UUyx2xFO/jy73v7FqpBo/uZW5Nr6ZwY 9Ao1BAUuyhCHzBUoy3lRnO9eRtViXkiZIDVfdJBsWa3CDAJ6uPRo8YNyisqTUPCm7ws4 T/yg== 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=uWzJUoyM/E+cChM1AtHHgZTTLGuCAVXjAFYI38VEtZ0=; b=RwK1LesPa3TXFrGnotnEv07xFnGyYHxAI3IIT21dw95E8JvBBa/DqHvvz/S3zFVAgw eiSWL3bGUmhWMOUYpOLfNxEIcHuH5Ol5PdTRkW8uvqGMggWql2m/KOLGKyrIpju7JZHv n7bslngGD/ioEO/olOnINpUc3KXcNjeO3SwieD8HrDl3ke763ul5nYg1bKYvtLJyEeQO 3H+4gBMGfAB25PEGv6jBhOFwKdEXfqa4n16LZGGbPC3NV0zXUhmSgE6JV8kMX4C+/663 F24dRVbzNbnGxsiYoImuJAIws+Awrmo1q+8xnB++hw3bk/4krp0hscHJj+3tEeKvy/ml Zd5Q== X-Gm-Message-State: APjAAAV6nrA30ShBKz97li4yrul7hDUZKyYjIAfEEkAuYl+wSZpfEMmk f/ESLMkVV/Jfp6rXY21z7P2FsQ== X-Received: by 2002:adf:a453:: with SMTP id e19mr21803434wra.48.1581952741723; Mon, 17 Feb 2020 07:19:01 -0800 (PST) Received: from ?IPv6:2a01:e34:ed2f:f020:9dbe:964b:c22d:ab7e? ([2a01:e34:ed2f:f020:9dbe:964b:c22d:ab7e]) by smtp.googlemail.com with ESMTPSA id r1sm1458288wrx.11.2020.02.17.07.19.00 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Feb 2020 07:19:01 -0800 (PST) Subject: Re: [PATCH 1/5] scsi: ufs: Add ufs thermal support To: Avi Shchislowski , alim.akhtar@samsung.com, avri.altman@wdc.com, jejb@linux.ibm.com, martin.petersen@oracle.com, stanley.chu@mediatek.com, linux-kernel@vger.kernel.org Cc: Uri Yanai References: <1580658445-15232-1-git-send-email-avi.shchislowski@wdc.com> <1580658445-15232-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+nDlD3mmVMd20VyE9W7AgTIsvDxWUnMPvww5iEx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+0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <1580658445-15232-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 02/02/2020 16:47, Avi Shchislowski wrote: > Support the new temperature notification attributes introduced in > UFSv3.0. Add exception event mask, and ufs features attributes. > > Signed-off-by: Uri Yanai > Signed-off-by: Avi Shchislowski Please resend the series with thermal maintainer in Cc. > --- > drivers/scsi/ufs/Kconfig | 11 ++++ > drivers/scsi/ufs/Makefile | 1 + > drivers/scsi/ufs/ufs-thermal.c | 123 +++++++++++++++++++++++++++++++++++++++++ > 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, > +}; > + > +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; > + } > + > + /* thermal support is enabled only after successful > + * 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; > + } > + > +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; > +} > 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