@@ -43,7 +43,7 @@ config SCSI_UFS_FAULT_INJECTION
to test the UFS error handler and abort handler.
config SCSI_UFS_HWMON
- bool "UFS Temperature Notification"
+ bool "UFS Hardware Monitoring"
depends on SCSI_UFSHCD=HWMON || HWMON=y
help
This provides support for UFS hardware monitoring. If enabled,
@@ -12,10 +12,10 @@
struct ufs_hwmon_data {
struct ufs_hba *hba;
- u8 mask;
+ u16 mask;
};
-static int ufs_read_temp_enable(struct ufs_hba *hba, u8 mask, long *val)
+static int ufs_read_temp_enable(struct ufs_hba *hba, u16 mask, long *val)
{
u32 ee_mask;
int err;
@@ -163,7 +163,7 @@ static const struct hwmon_chip_info ufs_hwmon_hba_info = {
.info = ufs_hwmon_info,
};
-void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask)
+void ufs_hwmon_probe(struct ufs_hba *hba, u16 mask)
{
struct device *dev = hba->dev;
struct ufs_hwmon_data *data;
@@ -199,7 +199,7 @@ void ufs_hwmon_remove(struct ufs_hba *hba)
kfree(data);
}
-void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask)
+void ufs_hwmon_notify_event(struct ufs_hba *hba, u16 ee_mask)
{
if (!hba->hwmon_device)
return;
@@ -33,13 +33,13 @@ static inline bool ufshcd_is_wb_buf_flush_allowed(struct ufs_hba *hba)
}
#ifdef CONFIG_SCSI_UFS_HWMON
-void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask);
+void ufs_hwmon_probe(struct ufs_hba *hba, u16 mask);
void ufs_hwmon_remove(struct ufs_hba *hba);
-void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask);
+void ufs_hwmon_notify_event(struct ufs_hba *hba, u16 ee_mask);
#else
-static inline void ufs_hwmon_probe(struct ufs_hba *hba, u8 mask) {}
+static inline void ufs_hwmon_probe(struct ufs_hba *hba, u16 mask) {}
static inline void ufs_hwmon_remove(struct ufs_hba *hba) {}
-static inline void ufs_hwmon_notify_event(struct ufs_hba *hba, u8 ee_mask) {}
+static inline void ufs_hwmon_notify_event(struct ufs_hba *hba, u16 ee_mask) {}
#endif
int ufshcd_query_descriptor_retry(struct ufs_hba *hba,
@@ -8074,11 +8074,10 @@ static void ufshcd_wb_probe(struct ufs_hba *hba, const u8 *desc_buf)
hba->caps &= ~UFSHCD_CAP_WB_EN;
}
-static void ufshcd_temp_notif_probe(struct ufs_hba *hba, const u8 *desc_buf)
+static void ufshcd_temp_notif_probe(struct ufs_hba *hba, const u8 *desc_buf, u16 *mask)
{
struct ufs_dev_info *dev_info = &hba->dev_info;
u32 ext_ufs_feature;
- u8 mask = 0;
if (!(hba->caps & UFSHCD_CAP_TEMP_NOTIF) || dev_info->wspecversion < 0x300)
return;
@@ -8086,10 +8085,17 @@ static void ufshcd_temp_notif_probe(struct ufs_hba *hba, const u8 *desc_buf)
ext_ufs_feature = get_unaligned_be32(desc_buf + DEVICE_DESC_PARAM_EXT_UFS_FEATURE_SUP);
if (ext_ufs_feature & UFS_DEV_LOW_TEMP_NOTIF)
- mask |= MASK_EE_TOO_LOW_TEMP;
+ *mask |= MASK_EE_TOO_LOW_TEMP;
if (ext_ufs_feature & UFS_DEV_HIGH_TEMP_NOTIF)
- mask |= MASK_EE_TOO_HIGH_TEMP;
+ *mask |= MASK_EE_TOO_HIGH_TEMP;
+}
+
+static void ufshcd_hwmon_probe(struct ufs_hba *hba, const u8 *desc_buf)
+{
+ u16 mask = 0;
+
+ ufshcd_temp_notif_probe(hba, desc_buf, &mask);
if (mask) {
ufshcd_enable_ee(hba, mask);
@@ -8288,7 +8294,7 @@ static int ufs_get_device_desc(struct ufs_hba *hba)
ufshcd_wb_probe(hba, desc_buf);
- ufshcd_temp_notif_probe(hba, desc_buf);
+ ufshcd_hwmon_probe(hba, desc_buf);
ufs_init_rtc(hba, desc_buf);
This commit updates the UFS hwmon driver to prepare for handling more hardware monitoring notifications. Specifically, it changes the type of the `mask` parameter from `u8` to `u16` to accommodate additional notification types. While at it, the Kconfig entry for `CONFIG_SCSI_UFS_HWMON` has been updated to better reflect its purpose. The description has been changed from "UFS Temperature Notification" to "UFS Hardware Monitoring" to indicate that the driver now supports a broader range of hardware monitoring notifications beyond just temperature. Signed-off-by: Avri Altman <avri.altman@wdc.com> --- drivers/ufs/core/Kconfig | 2 +- drivers/ufs/core/ufs-hwmon.c | 8 ++++---- drivers/ufs/core/ufshcd-priv.h | 8 ++++---- drivers/ufs/core/ufshcd.c | 16 +++++++++++----- 4 files changed, 20 insertions(+), 14 deletions(-)