Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp879200pxb; Wed, 1 Sep 2021 11:57:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyKTiaJ8vzftkOLaHdqVgHdqBLZtA8jd2ptJTCNFw88x+GvAD7lv25GdzciT3OGVs1wT8lW X-Received: by 2002:a05:6e02:d06:: with SMTP id g6mr672566ilj.153.1630522645321; Wed, 01 Sep 2021 11:57:25 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1630522645; cv=none; d=google.com; s=arc-20160816; b=nuDYptwCvmu+pftJkJWKjtgGDg1K19hqAK93VITmNmxYMUGugG98fOMWSEjwzufqAE JLT2MCwcKon3CoqK59jDRSujMzi9VAE7Gydz/MpfEWWulnkIzHxYSkcc1R0KSrDHbo8+ b1Q9PEFo1scAkS5YWxZsFv8BfVJq0F3UxNrxZlnNCllcnoX78slm51k0zI+uMRsUjiHt Di6jXSKM2ep9XVUgRQxJn4JBp9Lkup6JxuXbCPBIQJL8G83QdgAP5HGR4p+lkI8/ot1N OWeqt28gdiXwkNG5e9W3coOrg2ecSGl5xxSFOCC4Qpq8SecIsl0c5mCgzO+/RKOk0/bb CGLQ== 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:dmarc-filter:sender:dkim-signature; bh=DJPKLCjknE7MNkfUkV2JvIF1pJAJ2fVxt2U+Ra9y/r0=; b=ja2isq+fhiFvG7OuMW+bA759F9nTnI8DyXk9RUgUBFUq7V7iChktTiv5Tpok10EUnP WxfLNDjFIPi02yyR/KOeDb/zU7H8tNjBHN/Jhw8HoHdQwK7HVTMJ11zwro/N0T3ZWvBc CT8eSviq1HsJDQ3zUVcEi+iYdFL22mppdRRFgJl8nFcDRSI7Szrj7zwcMBFOspCcU0LM YbNrbB3Ci5DLBXYhcKWV+h13w20f3gOGc5mD5J++D8jlhXt2hCwNDwHNedEIgIkhtVMf SdOsYTIrX4PwAWha35Gj/Qizl4yfS/byjOobwi3F6gsSRbD347MBrr3v5TySwFpQf7Zf 2SzA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=AyHP5irc; 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 p15si372961ilc.68.2021.09.01.11.57.13; Wed, 01 Sep 2021 11:57:25 -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=@mg.codeaurora.org header.s=smtp header.b=AyHP5irc; 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 S1343866AbhIAPwt (ORCPT + 99 others); Wed, 1 Sep 2021 11:52:49 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:59312 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1343807AbhIAPws (ORCPT ); Wed, 1 Sep 2021 11:52:48 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1630511512; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=DJPKLCjknE7MNkfUkV2JvIF1pJAJ2fVxt2U+Ra9y/r0=; b=AyHP5ircplAOngBuamy8vsPAVBcoijktU2Uh6JHc+bMywAyOjd1QIdES+ZT9HUXvsZE9ZJ0J KoLRwp3OhB/DCS75rXA6fJaRwmm27JX9+KAVq3tgjVKva7B5VgoHxjZkq4Uv8bmv/9KlYLb5 lWBdTEXfh7TP3s3Z1yKCswxH2lk= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n02.prod.us-east-1.postgun.com with SMTP id 612fa193825e13c54a159082 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 01 Sep 2021 15:51:47 GMT Sender: asutoshd=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id E2B5CC43619; Wed, 1 Sep 2021 15:51:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, NICE_REPLY_A,SPF_FAIL,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from [192.168.1.8] (cpe-66-27-70-157.san.res.rr.com [66.27.70.157]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: asutoshd) by smtp.codeaurora.org (Postfix) with ESMTPSA id 2B976C4338F; Wed, 1 Sep 2021 15:51:45 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 smtp.codeaurora.org 2B976C4338F Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=codeaurora.org Subject: Re: [PATCH 2/3] 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: <20210901123707.5014-1-avri.altman@wdc.com> <20210901123707.5014-3-avri.altman@wdc.com> From: "Asutosh Das (asd)" Message-ID: Date: Wed, 1 Sep 2021 08:51:44 -0700 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <20210901123707.5014-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/1/2021 5:37 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. So add a designated vop for that. Each chipset vendor can > decide if it wants to use the thermal subsystem, hw monitor, or some > Privet implementation. The sensors of thermal subsystem would essentially get the skin temperature and invoke the registered handlers to throttle, if possible. I'm not sure how the vendor drivers can use thermal subsystem now if the ufs device doesn't inform the thermal subsystem about its increase in temperature. Meaning, (FWIU): -> ufs device senses an increase in temperature -> informs thermal subsystem -> registered vendor driver cb() is invoked by thermal subsystem. Please let me know if I'm missing something. > > Signed-off-by: Avri Altman > --- > drivers/scsi/ufs/ufs.h | 2 ++ > drivers/scsi/ufs/ufshcd.c | 18 ++++++++++++++++++ > drivers/scsi/ufs/ufshcd.h | 7 +++++++ > 3 files changed, 27 insertions(+) > > diff --git a/drivers/scsi/ufs/ufs.h b/drivers/scsi/ufs/ufs.h > index dee897ef9631..4f2a2fe0c84a 100644 > --- a/drivers/scsi/ufs/ufs.h > +++ b/drivers/scsi/ufs/ufs.h > @@ -374,6 +374,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 6ad51ae764c5..5f1fce21b655 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -5642,6 +5642,11 @@ 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) > +{ > + ufshcd_vops_temp_notify(hba, status); > +} > + > static int __ufshcd_wb_toggle(struct ufs_hba *hba, bool set, enum flag_idn idn) > { > u8 index; > @@ -5821,6 +5826,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); > @@ -7473,6 +7481,7 @@ static void ufshcd_temp_notif_probe(struct ufs_hba *hba, u8 *desc_buf) > { > struct ufs_dev_info *dev_info = &hba->dev_info; > u32 ext_ufs_feature; > + u16 mask = 0; > > if (!(hba->caps & UFSHCD_CAP_TEMP_NOTIF) || > dev_info->wspecversion < 0x300) > @@ -7483,6 +7492,15 @@ static void ufshcd_temp_notif_probe(struct ufs_hba *hba, u8 *desc_buf) > > dev_info->low_temp_notif = ext_ufs_feature & UFS_DEV_LOW_TEMP_NOTIF; > dev_info->high_temp_notif = ext_ufs_feature & UFS_DEV_HIGH_TEMP_NOTIF; > + > + if (dev_info->low_temp_notif) > + mask |= MASK_EE_TOO_LOW_TEMP; > + > + if (dev_info->high_temp_notif) > + mask |= MASK_EE_TOO_HIGH_TEMP; > + > + if (mask) > + ufshcd_enable_ee(hba, mask); > } > > void ufshcd_fixup_dev_quirks(struct ufs_hba *hba, struct ufs_dev_fix *fixups) > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index 467affbaec80..98ac7e7c8ec3 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -356,6 +356,7 @@ struct ufs_hba_variant_ops { > const union ufs_crypto_cfg_entry *cfg, int slot); > void (*event_notify)(struct ufs_hba *hba, > enum ufs_event_type evt, void *data); > + void (*temp_notify)(struct ufs_hba *hba, u16 status); > }; > > /* clock gating state */ > @@ -1355,6 +1356,12 @@ static inline void ufshcd_vops_config_scaling_param(struct ufs_hba *hba, > hba->vops->config_scaling_param(hba, profile, data); > } > > +static inline void ufshcd_vops_temp_notify(struct ufs_hba *hba, u16 status) > +{ > + if (hba->vops && hba->vops->temp_notify) > + hba->vops->temp_notify(hba, status); > +} > + > extern struct ufs_pm_lvl_states ufs_pm_lvl_states[]; > > /* > -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, Linux Foundation Collaborative Project