@@ -140,11 +140,6 @@ static const char *const ufshcd_state_name[] = {
[UFSHCD_STATE_EH_SCHEDULED_NON_FATAL] = "eh_non_fatal",
};
-/* UFSHCD error handling flags */
-enum {
- UFSHCD_EH_IN_PROGRESS = (1 << 0),
-};
-
/* UFSHCD UIC layer error flags */
enum {
UFSHCD_UIC_DL_PA_INIT_ERROR = (1 << 0), /* Data link layer error */
@@ -156,13 +151,6 @@ enum {
UFSHCD_UIC_PA_GENERIC_ERROR = (1 << 6), /* Generic PA error */
};
-#define ufshcd_set_eh_in_progress(h) \
- ((h)->eh_flags |= UFSHCD_EH_IN_PROGRESS)
-#define ufshcd_eh_in_progress(h) \
- ((h)->eh_flags & UFSHCD_EH_IN_PROGRESS)
-#define ufshcd_clear_eh_in_progress(h) \
- ((h)->eh_flags &= ~UFSHCD_EH_IN_PROGRESS)
-
struct ufs_pm_lvl_states ufs_pm_lvl_states[] = {
[UFS_PM_LVL_0] = {UFS_ACTIVE_PWR_MODE, UIC_LINK_ACTIVE_STATE},
[UFS_PM_LVL_1] = {UFS_ACTIVE_PWR_MODE, UIC_LINK_HIBERN8_STATE},
@@ -992,9 +992,33 @@ static inline bool ufshcd_is_wb_allowed(struct ufs_hba *hba)
return hba->caps & UFSHCD_CAP_WB_EN;
}
+/* UFSHCD error handling flags */
+enum {
+ UFSHCD_EH_IN_PROGRESS = (1 << 0),
+};
+
+static inline void ufshcd_set_eh_in_progress(struct ufs_hba *hba)
+{
+ lockdep_assert_held(hba->host->host_lock);
+
+ hba->eh_flags |= UFSHCD_EH_IN_PROGRESS;
+}
+
+static inline void ufshcd_clear_eh_in_progress(struct ufs_hba *hba)
+{
+ lockdep_assert_held(hba->host->host_lock);
+
+ hba->eh_flags &= ~UFSHCD_EH_IN_PROGRESS;
+}
+
+static inline bool ufshcd_eh_in_progress(struct ufs_hba *hba)
+{
+ return hba->eh_flags & UFSHCD_EH_IN_PROGRESS;
+}
+
static inline bool ufshcd_is_user_access_allowed(struct ufs_hba *hba)
{
- return !hba->shutting_down;
+ return !hba->shutting_down && !ufshcd_eh_in_progress(hba);
}
#define ufshcd_writel(hba, val, reg) \
Improve the static type checking. while at it, do not allow user-space access if eh-in-progress. Signed-off-by: Avri Altman <avri.altman@wdc.com> --- drivers/scsi/ufs/ufshcd.c | 12 ------------ drivers/scsi/ufs/ufshcd.h | 26 +++++++++++++++++++++++++- 2 files changed, 25 insertions(+), 13 deletions(-)