All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Asutosh Das (asd)" <asutoshd@codeaurora.org>
To: Avri Altman <avri.altman@wdc.com>,
	"James E . J . Bottomley" <jejb@linux.vnet.ibm.com>,
	"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	Bart Van Assche <bvanassche@acm.org>,
	Adrian Hunter <adrian.hunter@intel.com>,
	Bean Huo <beanhuo@micron.com>
Subject: Re: [PATCH 2/3] scsi: ufs: Add temperature notification exception handling
Date: Wed, 1 Sep 2021 08:51:44 -0700	[thread overview]
Message-ID: <c00af2a5-63f0-e38d-a209-952b11db2b51@codeaurora.org> (raw)
In-Reply-To: <20210901123707.5014-3-avri.altman@wdc.com>

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 <avri.altman@wdc.com>
> ---
>   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

  reply	other threads:[~2021-09-01 15:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-01 12:37 [PATCH 0/3] Add temperature notification support Avri Altman
2021-09-01 12:37 ` [PATCH 1/3] scsi: ufs: Probe for " Avri Altman
2021-09-01 16:35   ` Bart Van Assche
2021-09-02  6:24     ` Avri Altman
2021-09-01 12:37 ` [PATCH 2/3] scsi: ufs: Add temperature notification exception handling Avri Altman
2021-09-01 15:51   ` Asutosh Das (asd) [this message]
2021-09-01 16:39   ` Bart Van Assche
2021-09-01 19:40     ` Asutosh Das (asd)
2021-09-02  6:46       ` Avri Altman
2021-09-01 12:37 ` [PATCH 3/3] scsi: ufs-sysfs: Add sysfs entries for temperature notification Avri Altman
2021-09-01 16:52   ` Bart Van Assche
2021-09-02  6:52     ` Avri Altman
2021-09-02 19:58       ` Avri Altman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c00af2a5-63f0-e38d-a209-952b11db2b51@codeaurora.org \
    --to=asutoshd@codeaurora.org \
    --cc=adrian.hunter@intel.com \
    --cc=avri.altman@wdc.com \
    --cc=beanhuo@micron.com \
    --cc=bvanassche@acm.org \
    --cc=jejb@linux.vnet.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.