diff options
author | Dan Williams <dan.j.williams@intel.com> | 2018-09-26 13:48:38 -0400 |
---|---|---|
committer | Dan Williams <dan.j.williams@intel.com> | 2018-10-16 20:57:58 -0400 |
commit | 6f07f86c494074a0755930473f67cc8916654221 (patch) | |
tree | 6f53f491740d941ece294f4158fa147d415eecc0 | |
parent | 97052c1c31d5bcf08823ce1ea272447edd2d52de (diff) |
acpi, nfit: Introduce nfit_mem flags
In preparation for adding a flag to indicate whether a DIMM publishes a
dirty-shutdown count, convert the existing flags to a bit field.
Reviewed-by: Keith Busch <keith.busch@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r-- | drivers/acpi/nfit/core.c | 27 | ||||
-rw-r--r-- | drivers/acpi/nfit/nfit.h | 8 |
2 files changed, 22 insertions, 13 deletions
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index b072cfc5f20e..308a77b6c837 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c | |||
@@ -191,18 +191,20 @@ static int xlat_nvdimm_status(struct nvdimm *nvdimm, void *buf, unsigned int cmd | |||
191 | * In the _LSI, _LSR, _LSW case the locked status is | 191 | * In the _LSI, _LSR, _LSW case the locked status is |
192 | * communicated via the read/write commands | 192 | * communicated via the read/write commands |
193 | */ | 193 | */ |
194 | if (nfit_mem->has_lsr) | 194 | if (test_bit(NFIT_MEM_LSR, &nfit_mem->flags)) |
195 | break; | 195 | break; |
196 | 196 | ||
197 | if (status >> 16 & ND_CONFIG_LOCKED) | 197 | if (status >> 16 & ND_CONFIG_LOCKED) |
198 | return -EACCES; | 198 | return -EACCES; |
199 | break; | 199 | break; |
200 | case ND_CMD_GET_CONFIG_DATA: | 200 | case ND_CMD_GET_CONFIG_DATA: |
201 | if (nfit_mem->has_lsr && status == ACPI_LABELS_LOCKED) | 201 | if (test_bit(NFIT_MEM_LSR, &nfit_mem->flags) |
202 | && status == ACPI_LABELS_LOCKED) | ||
202 | return -EACCES; | 203 | return -EACCES; |
203 | break; | 204 | break; |
204 | case ND_CMD_SET_CONFIG_DATA: | 205 | case ND_CMD_SET_CONFIG_DATA: |
205 | if (nfit_mem->has_lsw && status == ACPI_LABELS_LOCKED) | 206 | if (test_bit(NFIT_MEM_LSW, &nfit_mem->flags) |
207 | && status == ACPI_LABELS_LOCKED) | ||
206 | return -EACCES; | 208 | return -EACCES; |
207 | break; | 209 | break; |
208 | default: | 210 | default: |
@@ -480,14 +482,16 @@ int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc, struct nvdimm *nvdimm, | |||
480 | min_t(u32, 256, in_buf.buffer.length), true); | 482 | min_t(u32, 256, in_buf.buffer.length), true); |
481 | 483 | ||
482 | /* call the BIOS, prefer the named methods over _DSM if available */ | 484 | /* call the BIOS, prefer the named methods over _DSM if available */ |
483 | if (nvdimm && cmd == ND_CMD_GET_CONFIG_SIZE && nfit_mem->has_lsr) | 485 | if (nvdimm && cmd == ND_CMD_GET_CONFIG_SIZE |
486 | && test_bit(NFIT_MEM_LSR, &nfit_mem->flags)) | ||
484 | out_obj = acpi_label_info(handle); | 487 | out_obj = acpi_label_info(handle); |
485 | else if (nvdimm && cmd == ND_CMD_GET_CONFIG_DATA && nfit_mem->has_lsr) { | 488 | else if (nvdimm && cmd == ND_CMD_GET_CONFIG_DATA |
489 | && test_bit(NFIT_MEM_LSR, &nfit_mem->flags)) { | ||
486 | struct nd_cmd_get_config_data_hdr *p = buf; | 490 | struct nd_cmd_get_config_data_hdr *p = buf; |
487 | 491 | ||
488 | out_obj = acpi_label_read(handle, p->in_offset, p->in_length); | 492 | out_obj = acpi_label_read(handle, p->in_offset, p->in_length); |
489 | } else if (nvdimm && cmd == ND_CMD_SET_CONFIG_DATA | 493 | } else if (nvdimm && cmd == ND_CMD_SET_CONFIG_DATA |
490 | && nfit_mem->has_lsw) { | 494 | && test_bit(NFIT_MEM_LSW, &nfit_mem->flags)) { |
491 | struct nd_cmd_set_config_hdr *p = buf; | 495 | struct nd_cmd_set_config_hdr *p = buf; |
492 | 496 | ||
493 | out_obj = acpi_label_write(handle, p->in_offset, p->in_length, | 497 | out_obj = acpi_label_write(handle, p->in_offset, p->in_length, |
@@ -1784,12 +1788,13 @@ static int acpi_nfit_add_dimm(struct acpi_nfit_desc *acpi_desc, | |||
1784 | if (acpi_nvdimm_has_method(adev_dimm, "_LSI") | 1788 | if (acpi_nvdimm_has_method(adev_dimm, "_LSI") |
1785 | && acpi_nvdimm_has_method(adev_dimm, "_LSR")) { | 1789 | && acpi_nvdimm_has_method(adev_dimm, "_LSR")) { |
1786 | dev_dbg(dev, "%s: has _LSR\n", dev_name(&adev_dimm->dev)); | 1790 | dev_dbg(dev, "%s: has _LSR\n", dev_name(&adev_dimm->dev)); |
1787 | nfit_mem->has_lsr = true; | 1791 | set_bit(NFIT_MEM_LSR, &nfit_mem->flags); |
1788 | } | 1792 | } |
1789 | 1793 | ||
1790 | if (nfit_mem->has_lsr && acpi_nvdimm_has_method(adev_dimm, "_LSW")) { | 1794 | if (test_bit(NFIT_MEM_LSR, &nfit_mem->flags) |
1795 | && acpi_nvdimm_has_method(adev_dimm, "_LSW")) { | ||
1791 | dev_dbg(dev, "%s: has _LSW\n", dev_name(&adev_dimm->dev)); | 1796 | dev_dbg(dev, "%s: has _LSW\n", dev_name(&adev_dimm->dev)); |
1792 | nfit_mem->has_lsw = true; | 1797 | set_bit(NFIT_MEM_LSW, &nfit_mem->flags); |
1793 | } | 1798 | } |
1794 | 1799 | ||
1795 | return 0; | 1800 | return 0; |
@@ -1878,11 +1883,11 @@ static int acpi_nfit_register_dimms(struct acpi_nfit_desc *acpi_desc) | |||
1878 | cmd_mask |= nfit_mem->dsm_mask & NVDIMM_STANDARD_CMDMASK; | 1883 | cmd_mask |= nfit_mem->dsm_mask & NVDIMM_STANDARD_CMDMASK; |
1879 | } | 1884 | } |
1880 | 1885 | ||
1881 | if (nfit_mem->has_lsr) { | 1886 | if (test_bit(NFIT_MEM_LSR, &nfit_mem->flags)) { |
1882 | set_bit(ND_CMD_GET_CONFIG_SIZE, &cmd_mask); | 1887 | set_bit(ND_CMD_GET_CONFIG_SIZE, &cmd_mask); |
1883 | set_bit(ND_CMD_GET_CONFIG_DATA, &cmd_mask); | 1888 | set_bit(ND_CMD_GET_CONFIG_DATA, &cmd_mask); |
1884 | } | 1889 | } |
1885 | if (nfit_mem->has_lsw) | 1890 | if (test_bit(NFIT_MEM_LSW, &nfit_mem->flags)) |
1886 | set_bit(ND_CMD_SET_CONFIG_DATA, &cmd_mask); | 1891 | set_bit(ND_CMD_SET_CONFIG_DATA, &cmd_mask); |
1887 | 1892 | ||
1888 | flush = nfit_mem->nfit_flush ? nfit_mem->nfit_flush->flush | 1893 | flush = nfit_mem->nfit_flush ? nfit_mem->nfit_flush->flush |
diff --git a/drivers/acpi/nfit/nfit.h b/drivers/acpi/nfit/nfit.h index d1274ea2d251..111c3c437c80 100644 --- a/drivers/acpi/nfit/nfit.h +++ b/drivers/acpi/nfit/nfit.h | |||
@@ -159,6 +159,11 @@ struct nfit_memdev { | |||
159 | struct acpi_nfit_memory_map memdev[0]; | 159 | struct acpi_nfit_memory_map memdev[0]; |
160 | }; | 160 | }; |
161 | 161 | ||
162 | enum nfit_mem_flags { | ||
163 | NFIT_MEM_LSR, | ||
164 | NFIT_MEM_LSW, | ||
165 | }; | ||
166 | |||
162 | /* assembled tables for a given dimm/memory-device */ | 167 | /* assembled tables for a given dimm/memory-device */ |
163 | struct nfit_mem { | 168 | struct nfit_mem { |
164 | struct nvdimm *nvdimm; | 169 | struct nvdimm *nvdimm; |
@@ -178,9 +183,8 @@ struct nfit_mem { | |||
178 | struct acpi_nfit_desc *acpi_desc; | 183 | struct acpi_nfit_desc *acpi_desc; |
179 | struct resource *flush_wpq; | 184 | struct resource *flush_wpq; |
180 | unsigned long dsm_mask; | 185 | unsigned long dsm_mask; |
186 | unsigned long flags; | ||
181 | int family; | 187 | int family; |
182 | bool has_lsr; | ||
183 | bool has_lsw; | ||
184 | }; | 188 | }; |
185 | 189 | ||
186 | struct acpi_nfit_desc { | 190 | struct acpi_nfit_desc { |