Received: by 2002:a05:6a10:6d25:0:0:0:0 with SMTP id gq37csp1134258pxb; Sun, 12 Sep 2021 08:57:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyivuN2+QYcTkFZhF3eImGEWM5d4hjmmZjBlnhH6n+Pagq/gUiIbpcfE1D/yohVuavQ8ANG X-Received: by 2002:a17:906:c249:: with SMTP id bl9mr8116877ejb.225.1631462272369; Sun, 12 Sep 2021 08:57:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1631462272; cv=none; d=google.com; s=arc-20160816; b=tWx2kZzuSTnNNjoSUd6d60iMxiOjg9hihZfdDIO5/N0+Pht8rSiQWJYP+iHEj2COW7 0oPTyuobgoWN1HqiS++OSdbJgkrWom89BFdDbltAyCfrNnY0bmwFuGtVIXdxNt3moqQB jifO2fizOgZRwfY3JcKQHupCvbj48Z4p49SeiHR1byFCk66J/lTOIxsY39fqajGVMjop payjvstyiUx6YbJxHTbKFS2M5Xhoo/VBhKg72RtCcmUEv0pIP8FyqqgKrAib7GbvNdhE kfJalqOk5+mSCqVtu9gkc6Zghx5C3JSzj7iwiyUUjx/6wsNnUhzcZnjqdu0xWtl1dLPo dhgA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:sender:dkim-signature; bh=gkFfv9CT7s4mw1MdJMwa+I2vDXO1SHGa8wxdgOd7jr4=; b=xRvfe2C6VKwxQXbpv7/6pwqKDJVVmap2y3vizxP+Mm1WX1DHJcB45yFET/XTJ+x6K3 +HDVbE2Y3YchbAR8Lem4a4QTWptFhicUL6hAJc5RcaVH2B85CN+hgWt6ty3JUvQpyVWM 1o4YWyzIp9+3Ofhdt268VJpfqMxj2kqBD5vAKpNPfVOmPmJ4itg9GtjdCO8gsU8eKAI5 hV/E6enJxihUCdqugmBcITf8P/w7E6D1WTDBoHVi+Fs8c/tCC/qqb6IzZLboUMSbtT8K R1lDBXjHxysW2JU8tHpF2Hc/lSRSVdUdMS8X8FnmBey1Qz1rx7yIr6zfWMCXnOUtEJuh 5QyA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=lQo8XSTR; 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 a16si6631459ejk.287.2021.09.12.08.57.28; Sun, 12 Sep 2021 08:57:52 -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=@gmail.com header.s=20210112 header.b=lQo8XSTR; 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 S231837AbhILP5J (ORCPT + 99 others); Sun, 12 Sep 2021 11:57:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229560AbhILP5I (ORCPT ); Sun, 12 Sep 2021 11:57:08 -0400 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E150C061574; Sun, 12 Sep 2021 08:55:54 -0700 (PDT) Received: by mail-ot1-x32a.google.com with SMTP id i3-20020a056830210300b0051af5666070so9863510otc.4; Sun, 12 Sep 2021 08:55:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=sender:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=gkFfv9CT7s4mw1MdJMwa+I2vDXO1SHGa8wxdgOd7jr4=; b=lQo8XSTR1G4SyEkWhYczm/pSxyknMAgPLMA7paj4a+TPnjGGtIb8WwZmj6VuZczKND rk/0sTiLfARQ0I6raeGfR/HRVTANACWNL7oVeBvyVKrg0934/tNHvQ1WHC7/O0k+VrUR OCM7ahRyvSUeWTmLHdMUcqjpfKa+6hWfSpjptom2S9EbAlzjYYmnOLKoTyAlBZbQMPjo wVUCydRNiEHtVqJXajo0oHmuWOvuUKBpBadzT7bdspsj/R5F6wd1QOZ0zW4nbpSRly5v KX6n9KDENqQIAjpRAMBxr8NiW8GX+8ODEmVK+RjgoBNY8YO4PflXjqEPFXXy2Aw0xRfV VqJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:sender:subject:to:cc:references:from:message-id :date:user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=gkFfv9CT7s4mw1MdJMwa+I2vDXO1SHGa8wxdgOd7jr4=; b=iu1Y8K9Dr6eZgnVGGjsQSWmomllLvQCr+8wVDQc5NGGMhpuewgkWaTFZcaA4eANAuj SSlmKAbq/wEHjR6H0WdNN8hGizKX5qX8URi+vrpEptt9harMCbKhjS3f39aeZJ11BT5N Hr18wuOzMFbhb8PhpUP8kRK3RnPIm006OzzR8zV14EpS/ZkRbjO6GsB4Z2TZwBRj5BZT bq89meuKP6mdlwszW5PegYt86+9+a3nH4gzuy5E9DwDUY7tvgnMfvQ4256d+x0HR70kL m4FN+TVY4rJ1VDMdCWanS1Eb7oW3tH4vFmWj/cAmdgYzT+aPtD5udBErLWJXmuxK7jl4 ZV+A== X-Gm-Message-State: AOAM530QqbtKlZ0onuW35jM2HfkKvC7ztKQrlolHaMpuMNH5A8Dzf2LS Aq+Z7gKrURnRfSPE7yihM4k= X-Received: by 2002:a05:6830:1184:: with SMTP id u4mr6536947otq.55.1631462153806; Sun, 12 Sep 2021 08:55:53 -0700 (PDT) Received: from server.roeck-us.net ([2600:1700:e321:62f0:329c:23ff:fee3:9d7c]) by smtp.gmail.com with ESMTPSA id k1sm1238724otr.43.2021.09.12.08.55.52 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 12 Sep 2021 08:55:53 -0700 (PDT) Sender: Guenter Roeck Subject: Re: [PATCH v3 2/2] scsi: ufs: Add temperature notification exception handling To: Avri Altman , "James E . J . Bottomley" , "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, Bart Van Assche , Adrian Hunter , Bean Huo References: <20210912131919.12962-1-avri.altman@wdc.com> <20210912131919.12962-3-avri.altman@wdc.com> From: Guenter Roeck Message-ID: <3dddb2a8-a599-2061-08e6-b4c5ca865cb9@roeck-us.net> Date: Sun, 12 Sep 2021 08:55:51 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210912131919.12962-3-avri.altman@wdc.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 9/12/21 6:19 AM, Avri Altman wrote: > The device may notify the host of an extreme temperature by using the > exception event mechanism. The exception can be raised when the device’s > Tcase temperature is either too high or too low. > > It is essentially up to the platform to decide what further actions need > to be taken. leave a placeholder for a designated vop for that. > > Signed-off-by: Avri Altman > --- > drivers/scsi/ufs/ufs-hwmon.c | 14 ++++++++++++++ > drivers/scsi/ufs/ufs.h | 2 ++ > drivers/scsi/ufs/ufshcd.c | 21 +++++++++++++++++++++ > drivers/scsi/ufs/ufshcd.h | 2 ++ > 4 files changed, 39 insertions(+) > > diff --git a/drivers/scsi/ufs/ufs-hwmon.c b/drivers/scsi/ufs/ufs-hwmon.c > index a50e83f645f4..b466b4649c21 100644 > --- a/drivers/scsi/ufs/ufs-hwmon.c > +++ b/drivers/scsi/ufs/ufs-hwmon.c > @@ -177,3 +177,17 @@ void ufs_hwmon_remove(struct ufs_hba *hba) > hba->hwmon_device = NULL; > kfree(data); > } > + > +void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask) > +{ > + if (!hba->hwmon_device) > + return; > + > + if (ee_mask & MASK_EE_TOO_HIGH_TEMP) > + hwmon_notify_event(hba->hwmon_device, hwmon_temp, > + hwmon_temp_max_alarm, 0); > + > + if (ee_mask & MASK_EE_TOO_LOW_TEMP) > + hwmon_notify_event(hba->hwmon_device, hwmon_temp, > + hwmon_temp_min_alarm, 0); > +} > diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h > index 171b27be7b1d..d9bc048c2a71 100644 > --- a/drivers/scsi/ufs/ufs.h > +++ b/drivers/scsi/ufs/ufs.h > @@ -377,6 +377,8 @@ enum { > MASK_EE_PERFORMANCE_THROTTLING = BIT(6), > }; > > +#define MASK_EE_URGENT_TEMP (MASK_EE_TOO_HIGH_TEMP | MASK_EE_TOO_LOW_TEMP) > + > /* Background operation status */ > enum bkops_status { > BKOPS_STATUS_NO_OP = 0x0, > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 90c2e9677435..3f4c7124b74b 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -5642,6 +5642,24 @@ static void ufshcd_bkops_exception_event_handler(struct ufs_hba *hba) > __func__, err); > } > > +static void ufshcd_temp_exception_event_handler(struct ufs_hba *hba, u16 status) > +{ > + u32 value; > + > + if (ufshcd_query_attr_retry(hba, UPIU_QUERY_OPCODE_READ_ATTR, > + QUERY_ATTR_IDN_CASE_ROUGH_TEMP, 0, 0, &value)) > + return; > + > + dev_info(hba->dev, "exception Tcase %d\n", value - 80); > + > + ufs_hwmon_notify_event(hba, status & MASK_EE_URGENT_TEMP); > + > + /* > + * A placeholder for the platform vendors to add whatever additional > + * steps required > + */ > +} > + > static int __ufshcd_wb_toggle(struct ufs_hba *hba, bool set, enum flag_idn idn) > { > u8 index; > @@ -5821,6 +5839,9 @@ static void ufshcd_exception_event_handler(struct work_struct *work) > if (status & hba->ee_drv_mask & MASK_EE_URGENT_BKOPS) > ufshcd_bkops_exception_event_handler(hba); > > + if (status & hba->ee_drv_mask & MASK_EE_URGENT_TEMP) > + ufshcd_temp_exception_event_handler(hba, status); > + > ufs_debugfs_exception_event(hba, status); > out: > ufshcd_scsi_unblock_requests(hba); > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index 798a408d71e5..e6abce9a8b00 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -1063,9 +1063,11 @@ static inline u8 ufshcd_wb_get_query_index(struct ufs_hba *hba) > #ifdef CONFIG_SCSI_UFS_HWMON > void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask); > void ufs_hwmon_remove(struct ufs_hba *hba); > +void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask); > #else > static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {} > static inline void ufs_hwmon_remove(struct ufs_hba *hba) {} > +void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask) {} static > #endif > > #ifdef CONFIG_PM >