Skip to content

Commit 95bc11b

Browse files
Ryan Grimmmpe
authored andcommitted
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 <[email protected]> Acked-by: Ian Munsie <[email protected]> Signed-off-by: Michael Ellerman <[email protected]>
1 parent 4beb542 commit 95bc11b

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

Documentation/ABI/testing/sysfs-class-cxl

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,17 @@ Contact: [email protected]
132132
Description: read only
133133
Will return "user" or "factory" depending on the image loaded
134134
onto the card.
135+
136+
What: /sys/class/cxl/<card>/load_image_on_perst
137+
Date: December 2014
138+
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.

drivers/misc/cxl/sysfs.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,50 @@ static ssize_t image_loaded_show(struct device *device,
5656
return scnprintf(buf, PAGE_SIZE, "factory\n");
5757
}
5858

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+
5997
static struct device_attribute adapter_attrs[] = {
6098
__ATTR_RO(caia_version),
6199
__ATTR_RO(psl_revision),
62100
__ATTR_RO(base_image),
63101
__ATTR_RO(image_loaded),
102+
__ATTR_RW(load_image_on_perst),
64103
};
65104

66105

0 commit comments

Comments
 (0)