diff options
-rw-r--r-- | Documentation/ABI/testing/sysfs-class-cxl | 14 | ||||
-rw-r--r-- | drivers/misc/cxl/sysfs.c | 39 |
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 | |||
132 | Description: read only | 132 | Description: 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 | |||
136 | What: /sys/class/cxl/<card>/load_image_on_perst | ||
137 | Date: December 2014 | ||
138 | Contact: linuxppc-dev@lists.ozlabs.org | ||
139 | Description: 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 | ||
59 | static 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 | |||
73 | static 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 | |||
59 | static struct device_attribute adapter_attrs[] = { | 97 | static 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 | ||