diff options
| -rw-r--r-- | drivers/acpi/nfit/core.c | 30 | ||||
| -rw-r--r-- | drivers/acpi/nfit/nfit.h | 8 |
2 files changed, 23 insertions, 15 deletions
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 9a23ae74e82b..90312892093e 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c | |||
| @@ -1317,19 +1317,23 @@ static ssize_t scrub_show(struct device *dev, | |||
| 1317 | struct device_attribute *attr, char *buf) | 1317 | struct device_attribute *attr, char *buf) |
| 1318 | { | 1318 | { |
| 1319 | struct nvdimm_bus_descriptor *nd_desc; | 1319 | struct nvdimm_bus_descriptor *nd_desc; |
| 1320 | struct acpi_nfit_desc *acpi_desc; | ||
| 1320 | ssize_t rc = -ENXIO; | 1321 | ssize_t rc = -ENXIO; |
| 1322 | bool busy; | ||
| 1321 | 1323 | ||
| 1322 | device_lock(dev); | 1324 | device_lock(dev); |
| 1323 | nd_desc = dev_get_drvdata(dev); | 1325 | nd_desc = dev_get_drvdata(dev); |
| 1324 | if (nd_desc) { | 1326 | if (!nd_desc) { |
| 1325 | struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc); | 1327 | device_unlock(dev); |
| 1326 | 1328 | return rc; | |
| 1327 | mutex_lock(&acpi_desc->init_mutex); | ||
| 1328 | rc = sprintf(buf, "%d%s", acpi_desc->scrub_count, | ||
| 1329 | acpi_desc->scrub_busy | ||
| 1330 | && !acpi_desc->cancel ? "+\n" : "\n"); | ||
| 1331 | mutex_unlock(&acpi_desc->init_mutex); | ||
| 1332 | } | 1329 | } |
| 1330 | acpi_desc = to_acpi_desc(nd_desc); | ||
| 1331 | |||
| 1332 | mutex_lock(&acpi_desc->init_mutex); | ||
| 1333 | busy = test_bit(ARS_BUSY, &acpi_desc->scrub_flags) | ||
| 1334 | && !test_bit(ARS_CANCEL, &acpi_desc->scrub_flags); | ||
| 1335 | rc = sprintf(buf, "%d%s", acpi_desc->scrub_count, busy ? "+\n" : "\n"); | ||
| 1336 | mutex_unlock(&acpi_desc->init_mutex); | ||
| 1333 | device_unlock(dev); | 1337 | device_unlock(dev); |
| 1334 | return rc; | 1338 | return rc; |
| 1335 | } | 1339 | } |
| @@ -3072,7 +3076,7 @@ static unsigned int __acpi_nfit_scrub(struct acpi_nfit_desc *acpi_desc, | |||
| 3072 | 3076 | ||
| 3073 | lockdep_assert_held(&acpi_desc->init_mutex); | 3077 | lockdep_assert_held(&acpi_desc->init_mutex); |
| 3074 | 3078 | ||
| 3075 | if (acpi_desc->cancel) | 3079 | if (test_bit(ARS_CANCEL, &acpi_desc->scrub_flags)) |
| 3076 | return 0; | 3080 | return 0; |
| 3077 | 3081 | ||
| 3078 | if (query_rc == -EBUSY) { | 3082 | if (query_rc == -EBUSY) { |
| @@ -3146,7 +3150,7 @@ static void __sched_ars(struct acpi_nfit_desc *acpi_desc, unsigned int tmo) | |||
| 3146 | { | 3150 | { |
| 3147 | lockdep_assert_held(&acpi_desc->init_mutex); | 3151 | lockdep_assert_held(&acpi_desc->init_mutex); |
| 3148 | 3152 | ||
| 3149 | acpi_desc->scrub_busy = 1; | 3153 | set_bit(ARS_BUSY, &acpi_desc->scrub_flags); |
| 3150 | /* note this should only be set from within the workqueue */ | 3154 | /* note this should only be set from within the workqueue */ |
| 3151 | if (tmo) | 3155 | if (tmo) |
| 3152 | acpi_desc->scrub_tmo = tmo; | 3156 | acpi_desc->scrub_tmo = tmo; |
| @@ -3162,7 +3166,7 @@ static void notify_ars_done(struct acpi_nfit_desc *acpi_desc) | |||
| 3162 | { | 3166 | { |
| 3163 | lockdep_assert_held(&acpi_desc->init_mutex); | 3167 | lockdep_assert_held(&acpi_desc->init_mutex); |
| 3164 | 3168 | ||
| 3165 | acpi_desc->scrub_busy = 0; | 3169 | clear_bit(ARS_BUSY, &acpi_desc->scrub_flags); |
| 3166 | acpi_desc->scrub_count++; | 3170 | acpi_desc->scrub_count++; |
| 3167 | if (acpi_desc->scrub_count_state) | 3171 | if (acpi_desc->scrub_count_state) |
| 3168 | sysfs_notify_dirent(acpi_desc->scrub_count_state); | 3172 | sysfs_notify_dirent(acpi_desc->scrub_count_state); |
| @@ -3451,7 +3455,7 @@ int acpi_nfit_ars_rescan(struct acpi_nfit_desc *acpi_desc, | |||
| 3451 | struct nfit_spa *nfit_spa; | 3455 | struct nfit_spa *nfit_spa; |
| 3452 | 3456 | ||
| 3453 | mutex_lock(&acpi_desc->init_mutex); | 3457 | mutex_lock(&acpi_desc->init_mutex); |
| 3454 | if (acpi_desc->cancel) { | 3458 | if (test_bit(ARS_CANCEL, &acpi_desc->scrub_flags)) { |
| 3455 | mutex_unlock(&acpi_desc->init_mutex); | 3459 | mutex_unlock(&acpi_desc->init_mutex); |
| 3456 | return 0; | 3460 | return 0; |
| 3457 | } | 3461 | } |
| @@ -3530,7 +3534,7 @@ void acpi_nfit_shutdown(void *data) | |||
| 3530 | mutex_unlock(&acpi_desc_lock); | 3534 | mutex_unlock(&acpi_desc_lock); |
| 3531 | 3535 | ||
| 3532 | mutex_lock(&acpi_desc->init_mutex); | 3536 | mutex_lock(&acpi_desc->init_mutex); |
| 3533 | acpi_desc->cancel = 1; | 3537 | set_bit(ARS_CANCEL, &acpi_desc->scrub_flags); |
| 3534 | cancel_delayed_work_sync(&acpi_desc->dwork); | 3538 | cancel_delayed_work_sync(&acpi_desc->dwork); |
| 3535 | mutex_unlock(&acpi_desc->init_mutex); | 3539 | mutex_unlock(&acpi_desc->init_mutex); |
| 3536 | 3540 | ||
diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h index 871fb3de3b30..897ce10192a0 100644 --- a/drivers/acpi/nfit/nfit.h +++ b/drivers/acpi/nfit/nfit.h | |||
| @@ -210,6 +210,11 @@ struct nfit_mem { | |||
| 210 | int family; | 210 | int family; |
| 211 | }; | 211 | }; |
| 212 | 212 | ||
| 213 | enum scrub_flags { | ||
| 214 | ARS_BUSY, | ||
| 215 | ARS_CANCEL, | ||
| 216 | }; | ||
| 217 | |||
| 213 | struct acpi_nfit_desc { | 218 | struct acpi_nfit_desc { |
| 214 | struct nvdimm_bus_descriptor nd_desc; | 219 | struct nvdimm_bus_descriptor nd_desc; |
| 215 | struct acpi_table_header acpi_header; | 220 | struct acpi_table_header acpi_header; |
| @@ -231,8 +236,7 @@ struct acpi_nfit_desc { | |||
| 231 | unsigned int max_ars; | 236 | unsigned int max_ars; |
| 232 | unsigned int scrub_count; | 237 | unsigned int scrub_count; |
| 233 | unsigned int scrub_mode; | 238 | unsigned int scrub_mode; |
| 234 | unsigned int scrub_busy:1; | 239 | unsigned long scrub_flags; |
| 235 | unsigned int cancel:1; | ||
| 236 | unsigned long dimm_cmd_force_en; | 240 | unsigned long dimm_cmd_force_en; |
| 237 | unsigned long bus_cmd_force_en; | 241 | unsigned long bus_cmd_force_en; |
| 238 | unsigned long bus_nfit_cmd_force_en; | 242 | unsigned long bus_nfit_cmd_force_en; |
