aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan Grimm <grimm@linux.vnet.ibm.com>2015-01-19 12:52:49 -0500
committerMichael Ellerman <mpe@ellerman.id.au>2015-01-22 01:31:51 -0500
commit95bc11bcd1428afdb48400ec84dc6d5a83926138 (patch)
tree3831e60e399dd4e2f4e90b3bc358e2fdbd90ef59
parent4beb5421babee1204757b877622830c6aa31be6d (diff)
cxl: Add image control to sysfs
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>
-rw-r--r--Documentation/ABI/testing/sysfs-class-cxl14
-rw-r--r--drivers/misc/cxl/sysfs.c39
2 files changed, 53 insertions, 0 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-cxl b/Documentation/ABI/testing/sysfs-class-cxl
index 2ab97527e186..5941ff38d4a3 100644
--- a/Documentation/ABI/testing/sysfs-class-cxl
+++ b/Documentation/ABI/testing/sysfs-class-cxl
@@ -132,3 +132,17 @@ Contact: linuxppc-dev@lists.ozlabs.org
132Description: read only 132Description: read only
133 Will return "user" or "factory" depending on the image loaded 133 Will return "user" or "factory" depending on the image loaded
134 onto the card. 134 onto the card.
135
136What: /sys/class/cxl/<card>/load_image_on_perst
137Date: December 2014
138Contact: linuxppc-dev@lists.ozlabs.org
139Description: read/write
140 Valid entries are "none", "user", and "factory".
141 "none" means PERST will not cause image to be loaded to the
142 card. A power cycle is required to load the image.
143 "none" could be useful for debugging because the trace arrays
144 are preserved.
145 "user" and "factory" means PERST will cause either the user or
146 user or factory image to be loaded.
147 Default is to reload on PERST whichever image the card has
148 loaded.
diff --git a/drivers/misc/cxl/sysfs.c b/drivers/misc/cxl/sysfs.c
index 461bdbd5d483..ed4ad461143c 100644
--- a/drivers/misc/cxl/sysfs.c
+++ b/drivers/misc/cxl/sysfs.c
@@ -56,11 +56,50 @@ static ssize_t image_loaded_show(struct device *device,
56 return scnprintf(buf, PAGE_SIZE, "factory\n"); 56 return scnprintf(buf, PAGE_SIZE, "factory\n");
57} 57}
58 58
59static ssize_t load_image_on_perst_show(struct device *device,
60 struct device_attribute *attr,
61 char *buf)
62{
63 struct cxl *adapter = to_cxl_adapter(device);
64
65 if (!adapter->perst_loads_image)
66 return scnprintf(buf, PAGE_SIZE, "none\n");
67
68 if (adapter->perst_select_user)
69 return scnprintf(buf, PAGE_SIZE, "user\n");
70 return scnprintf(buf, PAGE_SIZE, "factory\n");
71}
72
73static ssize_t load_image_on_perst_store(struct device *device,
74 struct device_attribute *attr,
75 const char *buf, size_t count)
76{
77 struct cxl *adapter = to_cxl_adapter(device);
78 int rc;
79
80 if (!strncmp(buf, "none", 4))
81 adapter->perst_loads_image = false;
82 else if (!strncmp(buf, "user", 4)) {
83 adapter->perst_select_user = true;
84 adapter->perst_loads_image = true;
85 } else if (!strncmp(buf, "factory", 7)) {
86 adapter->perst_select_user = false;
87 adapter->perst_loads_image = true;
88 } else
89 return -EINVAL;
90
91 if ((rc = cxl_update_image_control(adapter)))
92 return rc;
93
94 return count;
95}
96
59static struct device_attribute adapter_attrs[] = { 97static struct device_attribute adapter_attrs[] = {
60 __ATTR_RO(caia_version), 98 __ATTR_RO(caia_version),
61 __ATTR_RO(psl_revision), 99 __ATTR_RO(psl_revision),
62 __ATTR_RO(base_image), 100 __ATTR_RO(base_image),
63 __ATTR_RO(image_loaded), 101 __ATTR_RO(image_loaded),
102 __ATTR_RW(load_image_on_perst),
64}; 103};
65 104
66 105