Skip to content

Commit e34b825

Browse files
committed
nfit/ars: Introduce scrub_flags
In preparation for introducing new flags to gate whether ARS results are stale, or poll the completion state, convert the existing flags to an unsigned long with enumerated values. This conversion allows the flags to be atomically updated outside of ->init_mutex. Reviewed-by: Toshi Kani <toshi.kani@hpe.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 317a992 commit e34b825

File tree

2 files changed

+23
-15
lines changed

2 files changed

+23
-15
lines changed

drivers/acpi/nfit/core.c

Lines changed: 17 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,19 +1317,23 @@ static ssize_t scrub_show(struct device *dev,
13171317
struct device_attribute *attr, char *buf)
13181318
{
13191319
struct nvdimm_bus_descriptor *nd_desc;
1320+
struct acpi_nfit_desc *acpi_desc;
13201321
ssize_t rc = -ENXIO;
1322+
bool busy;
13211323

13221324
device_lock(dev);
13231325
nd_desc = dev_get_drvdata(dev);
1324-
if (nd_desc) {
1325-
struct acpi_nfit_desc *acpi_desc = to_acpi_desc(nd_desc);
1326-
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);
1326+
if (!nd_desc) {
1327+
device_unlock(dev);
1328+
return rc;
13321329
}
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);
13331337
device_unlock(dev);
13341338
return rc;
13351339
}
@@ -3072,7 +3076,7 @@ static unsigned int __acpi_nfit_scrub(struct acpi_nfit_desc *acpi_desc,
30723076

30733077
lockdep_assert_held(&acpi_desc->init_mutex);
30743078

3075-
if (acpi_desc->cancel)
3079+
if (test_bit(ARS_CANCEL, &acpi_desc->scrub_flags))
30763080
return 0;
30773081

30783082
if (query_rc == -EBUSY) {
@@ -3146,7 +3150,7 @@ static void __sched_ars(struct acpi_nfit_desc *acpi_desc, unsigned int tmo)
31463150
{
31473151
lockdep_assert_held(&acpi_desc->init_mutex);
31483152

3149-
acpi_desc->scrub_busy = 1;
3153+
set_bit(ARS_BUSY, &acpi_desc->scrub_flags);
31503154
/* note this should only be set from within the workqueue */
31513155
if (tmo)
31523156
acpi_desc->scrub_tmo = tmo;
@@ -3162,7 +3166,7 @@ static void notify_ars_done(struct acpi_nfit_desc *acpi_desc)
31623166
{
31633167
lockdep_assert_held(&acpi_desc->init_mutex);
31643168

3165-
acpi_desc->scrub_busy = 0;
3169+
clear_bit(ARS_BUSY, &acpi_desc->scrub_flags);
31663170
acpi_desc->scrub_count++;
31673171
if (acpi_desc->scrub_count_state)
31683172
sysfs_notify_dirent(acpi_desc->scrub_count_state);
@@ -3451,7 +3455,7 @@ int acpi_nfit_ars_rescan(struct acpi_nfit_desc *acpi_desc,
34513455
struct nfit_spa *nfit_spa;
34523456

34533457
mutex_lock(&acpi_desc->init_mutex);
3454-
if (acpi_desc->cancel) {
3458+
if (test_bit(ARS_CANCEL, &acpi_desc->scrub_flags)) {
34553459
mutex_unlock(&acpi_desc->init_mutex);
34563460
return 0;
34573461
}
@@ -3530,7 +3534,7 @@ void acpi_nfit_shutdown(void *data)
35303534
mutex_unlock(&acpi_desc_lock);
35313535

35323536
mutex_lock(&acpi_desc->init_mutex);
3533-
acpi_desc->cancel = 1;
3537+
set_bit(ARS_CANCEL, &acpi_desc->scrub_flags);
35343538
cancel_delayed_work_sync(&acpi_desc->dwork);
35353539
mutex_unlock(&acpi_desc->init_mutex);
35363540

drivers/acpi/nfit/nfit.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ struct nfit_mem {
210210
int family;
211211
};
212212

213+
enum scrub_flags {
214+
ARS_BUSY,
215+
ARS_CANCEL,
216+
};
217+
213218
struct acpi_nfit_desc {
214219
struct nvdimm_bus_descriptor nd_desc;
215220
struct acpi_table_header acpi_header;
@@ -231,8 +236,7 @@ struct acpi_nfit_desc {
231236
unsigned int max_ars;
232237
unsigned int scrub_count;
233238
unsigned int scrub_mode;
234-
unsigned int scrub_busy:1;
235-
unsigned int cancel:1;
239+
unsigned long scrub_flags;
236240
unsigned long dimm_cmd_force_en;
237241
unsigned long bus_cmd_force_en;
238242
unsigned long bus_nfit_cmd_force_en;

0 commit comments

Comments
 (0)