]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
cxl: Add image control to sysfs
authorRyan Grimm <grimm@linux.vnet.ibm.com>
Mon, 19 Jan 2015 17:52:49 +0000 (11:52 -0600)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 22 Jan 2015 06:31:51 +0000 (17:31 +1100)
load_image_on_perst identifies whether a PERST will cause the image to be
flashed to the card. And if so, which image.

Valid entries are: "none", "user" and "factory".

A value of "none" means PERST will not cause the image to be flashed. A
power cycle to the pcie slot is required to load the image.

"user" loads the user provided image and "factory" loads the factory image upon
PERST.

sysfs updates the cxl struct in the driver then calls cxl_update_image_control
to write the vals in the VSEC.

Signed-off-by: Ryan Grimm <grimm@linux.vnet.ibm.com>
Acked-by: Ian Munsie <imunsie@au1.ibm.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Documentation/ABI/testing/sysfs-class-cxl
drivers/misc/cxl/sysfs.c

index 2ab97527e18696e946e69bd498b27a43487d309f..5941ff38d4a316f34a5f40f47d32463e07c4dc45 100644 (file)
@@ -132,3 +132,17 @@ Contact:        linuxppc-dev@lists.ozlabs.org
 Description:    read only
                 Will return "user" or "factory" depending on the image loaded
                 onto the card.
+
+What:           /sys/class/cxl/<card>/load_image_on_perst
+Date:           December 2014
+Contact:        linuxppc-dev@lists.ozlabs.org
+Description:    read/write
+                Valid entries are "none", "user", and "factory".
+                "none" means PERST will not cause image to be loaded to the
+                card.  A power cycle is required to load the image.
+                "none" could be useful for debugging because the trace arrays
+                are preserved.
+                "user" and "factory" means PERST will cause either the user or
+                user or factory image to be loaded.
+                Default is to reload on PERST whichever image the card has
+                loaded.
index 461bdbd5d48317fa941ac002aa1f014761336f9a..ed4ad461143c1a160d05e95da9f6e2fc4aff4cab 100644 (file)
@@ -56,11 +56,50 @@ static ssize_t image_loaded_show(struct device *device,
        return scnprintf(buf, PAGE_SIZE, "factory\n");
 }
 
+static ssize_t load_image_on_perst_show(struct device *device,
+                                struct device_attribute *attr,
+                                char *buf)
+{
+       struct cxl *adapter = to_cxl_adapter(device);
+
+       if (!adapter->perst_loads_image)
+               return scnprintf(buf, PAGE_SIZE, "none\n");
+
+       if (adapter->perst_select_user)
+               return scnprintf(buf, PAGE_SIZE, "user\n");
+       return scnprintf(buf, PAGE_SIZE, "factory\n");
+}
+
+static ssize_t load_image_on_perst_store(struct device *device,
+                                struct device_attribute *attr,
+                                const char *buf, size_t count)
+{
+       struct cxl *adapter = to_cxl_adapter(device);
+       int rc;
+
+       if (!strncmp(buf, "none", 4))
+               adapter->perst_loads_image = false;
+       else if (!strncmp(buf, "user", 4)) {
+               adapter->perst_select_user = true;
+               adapter->perst_loads_image = true;
+       } else if (!strncmp(buf, "factory", 7)) {
+               adapter->perst_select_user = false;
+               adapter->perst_loads_image = true;
+       } else
+               return -EINVAL;
+
+       if ((rc = cxl_update_image_control(adapter)))
+               return rc;
+
+       return count;
+}
+
 static struct device_attribute adapter_attrs[] = {
        __ATTR_RO(caia_version),
        __ATTR_RO(psl_revision),
        __ATTR_RO(base_image),
        __ATTR_RO(image_loaded),
+       __ATTR_RW(load_image_on_perst),
 };