Skip to content

Commit 2f4b3b8

Browse files
oberparhcahca
authored andcommitted
s390/cio: Externalize full CMG characteristics
The current "measurement_chars" CHPID sysfs attribute exposes only a limited, validity-filtered portion of data from the associated Channel- Measurements Characteristics Block (CMCB). New machine models add data that is relevant for userspace tooling to the "header"-portion of the CMCB. This data that is not currently accessible to userspace. To prevent having to add new sysfs attributes whenever a new bit of data is added to the CMCB "header", add a new sysfs attribute named "measurement_chars_full" that exposes the full, unfiltered CMCB. Signed-off-by: Peter Oberparleiter <[email protected]> Reviewed-by: Vineeth Vijayan <[email protected]> Signed-off-by: Heiko Carstens <[email protected]>
1 parent 182c02a commit 2f4b3b8

File tree

4 files changed

+39
-20
lines changed

4 files changed

+39
-20
lines changed

drivers/s390/cio/chp.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,18 @@ static ssize_t measurement_chars_read(struct file *filp, struct kobject *kobj,
144144
}
145145
static BIN_ATTR_ADMIN_RO(measurement_chars, sizeof(struct cmg_chars));
146146

147+
static ssize_t measurement_chars_full_read(struct file *filp,
148+
struct kobject *kobj,
149+
struct bin_attribute *bin_attr,
150+
char *buf, loff_t off, size_t count)
151+
{
152+
struct channel_path *chp = to_channelpath(kobj_to_dev(kobj));
153+
154+
return memory_read_from_buffer(buf, count, &off, &chp->cmcb,
155+
sizeof(chp->cmcb));
156+
}
157+
static BIN_ATTR_ADMIN_RO(measurement_chars_full, sizeof(struct cmg_cmcb));
158+
147159
static ssize_t chp_measurement_copy_block(void *buf, loff_t off, size_t count,
148160
struct kobject *kobj, bool extended)
149161
{
@@ -201,6 +213,7 @@ static BIN_ATTR_ADMIN_RO(ext_measurement, sizeof(struct cmg_ext_entry));
201213

202214
static struct bin_attribute *measurement_attrs[] = {
203215
&bin_attr_measurement_chars,
216+
&bin_attr_measurement_chars_full,
204217
&bin_attr_measurement,
205218
&bin_attr_ext_measurement,
206219
NULL,

drivers/s390/cio/chp.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct channel_path {
5454
int extended;
5555
unsigned long speed;
5656
struct cmg_chars cmg_chars;
57+
struct cmg_cmcb cmcb;
5758
};
5859

5960
/* Return channel_path struct for given chpid. */

drivers/s390/cio/chsc.c

Lines changed: 9 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1092,19 +1092,7 @@ int chsc_get_channel_measurement_chars(struct channel_path *chp)
10921092
u32 zeroes1;
10931093
struct chsc_header response;
10941094
u32 zeroes2;
1095-
u32 not_valid : 1;
1096-
u32 shared : 1;
1097-
u32 extended : 1;
1098-
u32 : 21;
1099-
u32 chpid : 8;
1100-
u32 cmcv : 5;
1101-
u32 : 7;
1102-
u32 cmgp : 4;
1103-
u32 cmgq : 8;
1104-
u32 cmg : 8;
1105-
u32 : 16;
1106-
u32 cmgs : 16;
1107-
u32 data[NR_MEASUREMENT_CHARS];
1095+
struct cmg_cmcb cmcb;
11081096
} *scmc_area;
11091097

11101098
chp->shared = -1;
@@ -1135,15 +1123,16 @@ int chsc_get_channel_measurement_chars(struct channel_path *chp)
11351123
scmc_area->response.code);
11361124
goto out;
11371125
}
1138-
if (scmc_area->not_valid)
1126+
chp->cmcb = scmc_area->cmcb;
1127+
if (scmc_area->cmcb.not_valid)
11391128
goto out;
11401129

1141-
chp->cmg = scmc_area->cmg;
1142-
chp->shared = scmc_area->shared;
1143-
chp->extended = scmc_area->extended;
1144-
chp->speed = scmc_get_speed(scmc_area->cmgs, scmc_area->cmgp);
1145-
chsc_initialize_cmg_chars(chp, scmc_area->cmcv,
1146-
(struct cmg_chars *) &scmc_area->data);
1130+
chp->cmg = scmc_area->cmcb.cmg;
1131+
chp->shared = scmc_area->cmcb.shared;
1132+
chp->extended = scmc_area->cmcb.extended;
1133+
chp->speed = scmc_get_speed(scmc_area->cmcb.cmgs, scmc_area->cmcb.cmgp);
1134+
chsc_initialize_cmg_chars(chp, scmc_area->cmcb.cmcv,
1135+
(struct cmg_chars *)&scmc_area->cmcb.data);
11471136
out:
11481137
spin_unlock_irqrestore(&chsc_page_lock, flags);
11491138
return ret;

drivers/s390/cio/chsc.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,22 @@ struct cmg_chars {
1717
u32 values[NR_MEASUREMENT_CHARS];
1818
};
1919

20+
struct cmg_cmcb {
21+
u32 not_valid : 1;
22+
u32 shared : 1;
23+
u32 extended : 1;
24+
u32 : 21;
25+
u32 chpid : 8;
26+
u32 cmcv : 5;
27+
u32 : 7;
28+
u32 cmgp : 4;
29+
u32 cmgq : 8;
30+
u32 cmg : 8;
31+
u32 : 16;
32+
u32 cmgs : 16;
33+
u32 data[NR_MEASUREMENT_CHARS];
34+
};
35+
2036
#define NR_MEASUREMENT_ENTRIES 8
2137
struct cmg_entry {
2238
u32 values[NR_MEASUREMENT_ENTRIES];

0 commit comments

Comments
 (0)