nfit: Fix nfit_intel_shutdown_status() command submission
authorDan Williams <dan.j.williams@intel.com>
Wed, 30 Jan 2019 06:06:41 +0000 (22:06 -0800)
committerDan Williams <dan.j.williams@intel.com>
Wed, 30 Jan 2019 06:08:34 +0000 (22:08 -0800)
commitf596c8844fe1d0022007ae6c7a377361fb653eff
tree6e702de90e66c6f2f4d0727676dbe3d046d22966
parent966d23a006ca7b44ac8cf4d0c96b19785e0c3da0
nfit: Fix nfit_intel_shutdown_status() command submission

The implementation is broken in all the ways the unit test did not touch:

1/ The local definition of in_buf and in_obj violated C99 initializer
   expectations for zeroing. By only initializing 2 out of the three
   struct members the compiler was free to zero-initialize the remaining
   entry even though the aliased location in the union was initialized.

2/ The implementation made assumptions about the state of the 'smart'
   payload after command execution that are satisfied by
   acpi_nfit_ctl(), but not acpi_evaluate_dsm().

3/ populate_shutdown_status() is skipped on Intel NVDIMMs due to the early
   return for skipping the common _LS{I,R,W} enabling.

4/ The input length should be zero.

This breakage was missed due to the unit test implementation only
testing the case where nfit_intel_shutdown_status() returns a valid
payload.

Much of this complexity would be saved if acpi_nfit_ctl() could be used, but
that currently requires a 'struct nvdimm *' argument and one is not created
until later in the init process. The health result is needed before the device
is created because the payload gates whether the nmemX/nfit/dirty_shutdown
property is visible in sysfs.

Cc: <stable@vger.kernel.org>
Fixes: 0ead11181fe0 ("acpi, nfit: Collect shutdown status")
Reported-by: Dexuan Cui <decui@microsoft.com>
Reviewed-by: Dexuan Cui <decui@microsoft.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
drivers/acpi/nfit/core.c