Skip to content

Commit 45f06ea

Browse files
hmynenimpe
authored andcommitted
powerpc/pseries/vas: Add 'update_total_credits' entry for QoS capabilities
pseries supports two types of credits - Default (uses normal priority FIFO) and Qality of service (QoS uses high priority FIFO). The user decides the number of QoS credits and sets this value with HMC interface. The total credits for QoS capabilities can be changed dynamically with HMC interface which invokes drmgr to communicate to the kernel. This patch creats 'update_total_credits' entry for QoS capabilities so that drmgr command can write the new target QoS credits in sysfs. Instead of using this value, the kernel gets the new QoS capabilities from the hypervisor whenever update_total_credits is updated to make sure sync with the QoS target credits in the hypervisor. Signed-off-by: Haren Myneni <[email protected]> Signed-off-by: Michael Ellerman <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent b903737 commit 45f06ea

File tree

3 files changed

+50
-7
lines changed

3 files changed

+50
-7
lines changed

arch/powerpc/platforms/pseries/vas-sysfs.c

Lines changed: 48 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,27 @@ struct vas_caps_entry {
2525

2626
#define to_caps_entry(entry) container_of(entry, struct vas_caps_entry, kobj)
2727

28+
/*
29+
* This function is used to get the notification from the drmgr when
30+
* QoS credits are changed. Though receiving the target total QoS
31+
* credits here, get the official QoS capabilities from the hypervisor.
32+
*/
33+
static ssize_t update_total_credits_trigger(struct vas_cop_feat_caps *caps,
34+
const char *buf, size_t count)
35+
{
36+
int err;
37+
u16 creds;
38+
39+
err = kstrtou16(buf, 0, &creds);
40+
if (!err)
41+
err = vas_reconfig_capabilties(caps->win_type);
42+
43+
if (err)
44+
return -EINVAL;
45+
46+
return count;
47+
}
48+
2849
#define sysfs_caps_entry_read(_name) \
2950
static ssize_t _name##_show(struct vas_cop_feat_caps *caps, char *buf) \
3051
{ \
@@ -63,17 +84,29 @@ struct vas_sysfs_entry {
6384
* changed dynamically by the user.
6485
* /sys/devices/vas/vas0/gzip/qos_capabilities/nr_used_credits
6586
* Number of credits used by the user space.
87+
* /sys/devices/vas/vas0/gzip/qos_capabilities/update_total_credits
88+
* Update total QoS credits dynamically
6689
*/
6790

6891
VAS_ATTR_RO(nr_total_credits);
6992
VAS_ATTR_RO(nr_used_credits);
7093

71-
static struct attribute *vas_capab_attrs[] = {
94+
static struct vas_sysfs_entry update_total_credits_attribute =
95+
__ATTR(update_total_credits, 0200, NULL, update_total_credits_trigger);
96+
97+
static struct attribute *vas_def_capab_attrs[] = {
7298
&nr_total_credits_attribute.attr,
7399
&nr_used_credits_attribute.attr,
74100
NULL,
75101
};
76102

103+
static struct attribute *vas_qos_capab_attrs[] = {
104+
&nr_total_credits_attribute.attr,
105+
&nr_used_credits_attribute.attr,
106+
&update_total_credits_attribute.attr,
107+
NULL,
108+
};
109+
77110
static ssize_t vas_type_show(struct kobject *kobj, struct attribute *attr,
78111
char *buf)
79112
{
@@ -118,19 +151,29 @@ static const struct sysfs_ops vas_sysfs_ops = {
118151
.store = vas_type_store,
119152
};
120153

121-
static struct kobj_type vas_attr_type = {
154+
static struct kobj_type vas_def_attr_type = {
122155
.release = vas_type_release,
123156
.sysfs_ops = &vas_sysfs_ops,
124-
.default_attrs = vas_capab_attrs,
157+
.default_attrs = vas_def_capab_attrs,
125158
};
126159

127-
static char *vas_caps_kobj_name(struct vas_cop_feat_caps *caps,
160+
static struct kobj_type vas_qos_attr_type = {
161+
.release = vas_type_release,
162+
.sysfs_ops = &vas_sysfs_ops,
163+
.default_attrs = vas_qos_capab_attrs,
164+
};
165+
166+
static char *vas_caps_kobj_name(struct vas_caps_entry *centry,
128167
struct kobject **kobj)
129168
{
169+
struct vas_cop_feat_caps *caps = centry->caps;
170+
130171
if (caps->descriptor == VAS_GZIP_QOS_CAPABILITIES) {
172+
kobject_init(&centry->kobj, &vas_qos_attr_type);
131173
*kobj = gzip_caps_kobj;
132174
return "qos_capabilities";
133175
} else if (caps->descriptor == VAS_GZIP_DEFAULT_CAPABILITIES) {
176+
kobject_init(&centry->kobj, &vas_def_attr_type);
134177
*kobj = gzip_caps_kobj;
135178
return "default_capabilities";
136179
} else
@@ -152,9 +195,8 @@ int sysfs_add_vas_caps(struct vas_cop_feat_caps *caps)
152195
if (!centry)
153196
return -ENOMEM;
154197

155-
kobject_init(&centry->kobj, &vas_attr_type);
156198
centry->caps = caps;
157-
name = vas_caps_kobj_name(caps, &kobj);
199+
name = vas_caps_kobj_name(centry, &kobj);
158200

159201
if (kobj) {
160202
ret = kobject_add(&centry->kobj, kobj, "%s", name);

arch/powerpc/platforms/pseries/vas.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ static int reconfig_close_windows(struct vas_caps *vcap, int excess_creds)
722722
* changes. Reconfig window configurations based on the credits
723723
* availability from this new capabilities.
724724
*/
725-
static int vas_reconfig_capabilties(u8 type)
725+
int vas_reconfig_capabilties(u8 type)
726726
{
727727
struct hv_vas_cop_feat_caps *hv_caps;
728728
struct vas_cop_feat_caps *caps;

arch/powerpc/platforms/pseries/vas.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,5 +130,6 @@ struct pseries_vas_window {
130130
};
131131

132132
int sysfs_add_vas_caps(struct vas_cop_feat_caps *caps);
133+
int vas_reconfig_capabilties(u8 type);
133134
int __init sysfs_pseries_vas_init(struct vas_all_caps *vas_caps);
134135
#endif /* _VAS_H */

0 commit comments

Comments
 (0)