spapr: nvdimm: Introduce spapr-nvdimm device
commit8601b4f11d47d36927a617e67687a4a85445ccdd
authorShivaprasad G Bhat <sbhat@linux.ibm.com>
Fri, 18 Feb 2022 07:34:14 +0000 (18 08:34 +0100)
committerCédric Le Goater <clg@kaod.org>
Fri, 18 Feb 2022 07:34:14 +0000 (18 08:34 +0100)
tree56354ba660a8ef1cba060b4d9327505aebf501dd
parentb5513584a08db477160ea7f0b700a2367028720c
spapr: nvdimm: Introduce spapr-nvdimm device

If the device backend is not persistent memory for the nvdimm, there is
need for explicit IO flushes on the backend to ensure persistence.

On SPAPR, the issue is addressed by adding a new hcall to request for
an explicit flush from the guest when the backend is not pmem. So, the
approach here is to convey when the hcall flush is required in a device
tree property. The guest once it knows the device backend is not pmem,
makes the hcall whenever flush is required.

To set the device tree property, a new PAPR specific device type inheriting
the nvdimm device is implemented. When the backend doesn't have pmem=on
the device tree property "ibm,hcall-flush-required" is set, and the guest
makes hcall H_SCM_FLUSH requesting for an explicit flush. The new device
has boolean property pmem-override which when "on" advertises the device
tree property even when pmem=on for the backend. The flush function
invokes the fdatasync or pmem_persist() based on the type of backend.

The vmstate structures are made part of the spapr-nvdimm device object.
The patch attempts to keep the migration compatibility between source and
destination while rejecting the incompatibles ones with failures.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.ibm.com>
Reviewed-by: Daniel Henrique Barboza <danielhb413@gmail.com>
Message-Id: <164396256092.109112.17933240273840803354.stgit@ltczzess4.aus.stglabs.ibm.com>
Signed-off-by: Cédric Le Goater <clg@kaod.org>
hw/ppc/spapr_nvdimm.c