... | ... | ||
---|---|---|---|
12 | nvme: Add warning for PST table memory allocation failure in | 12 | nvme: Add warning for PST table memory allocation failure in |
13 | nvme_configure_apst | 13 | nvme_configure_apst |
14 | nvme: add sysfs interface for APST table updates | 14 | nvme: add sysfs interface for APST table updates |
15 | nvme: add per-controller sysfs interface for APST configuration | 15 | nvme: add per-controller sysfs interface for APST configuration |
16 | 16 | ||
17 | Changes in v2 | ||
18 | |||
19 | Add mutex_lock in nvme_set_latency_tolerance() for Potential competition | ||
20 | between nvme_set_latency_tolerance() and apst_update_store(). | ||
21 | |||
22 | Changes in v3 | ||
23 | In PACH nvme: add sysfs interface for APST table updates,Add why dynamic APST | ||
24 | updates are needed in the commit message, fix code formatting issues. | ||
25 | |||
17 | drivers/nvme/host/core.c | 24 ++++++++++------ | 26 | drivers/nvme/host/core.c | 24 ++++++++++------ |
18 | drivers/nvme/host/nvme.h | 6 ++++ | 27 | drivers/nvme/host/nvme.h | 6 ++++ |
19 | drivers/nvme/host/sysfs.c | 59 +++++++++++++++++++++++++++++++++++++++ | 28 | drivers/nvme/host/sysfs.c | 59 +++++++++++++++++++++++++++++++++++++++ |
20 | 3 files changed, 81 insertions(+), 8 deletions(-) | 29 | 3 files changed, 81 insertions(+), 8 deletions(-) |
21 | 30 | ||
22 | -- | 31 | -- |
23 | 2.25.1 | 32 | 2.25.1 | diff view generated by jsdifflib |
1 | From: Yaxiong Tian <tianyaxiong@kylinos.cn> | 1 | From: Yaxiong Tian <tianyaxiong@kylinos.cn> |
---|---|---|---|
2 | 2 | ||
3 | Currently the function fails silently on PST table memory allocation failure. | 3 | Currently the function fails silently on PST table memory allocation failure. |
4 | Add warning messages to improve error visibility. | 4 | Add warning messages to improve error visibility. |
5 | 5 | ||
6 | Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com> | ||
6 | Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn> | 7 | Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn> |
7 | --- | 8 | --- |
8 | drivers/nvme/host/core.c | 4 +++- | 9 | drivers/nvme/host/core.c | 4 +++- |
9 | 1 file changed, 3 insertions(+), 1 deletion(-) | 10 | 1 file changed, 3 insertions(+), 1 deletion(-) |
10 | 11 | ||
... | ... | diff view generated by jsdifflib |
1 | From: Yaxiong Tian <tianyaxiong@kylinos.cn> | 1 | From: Yaxiong Tian <tianyaxiong@kylinos.cn> |
---|---|---|---|
2 | |||
3 | In desktop systems, users can choose between power-saving mode and | ||
4 | performance mode. These two modes involve different trade-offs between | ||
5 | NVMe performance and power efficiency, thus requiring dynamic updates to APST. | ||
2 | 6 | ||
3 | Currently, the APST (Autonomous Power State Transition) table can only be | 7 | Currently, the APST (Autonomous Power State Transition) table can only be |
4 | updated during module initialization via module parameters or indirectly | 8 | updated during module initialization via module parameters or indirectly |
5 | by setting QoS latency requirements. This patch adds a direct sysfs | 9 | by setting QoS latency requirements. This patch adds a direct sysfs |
6 | interface to allow dynamic updates to the APST table at runtime. | 10 | interface to allow dynamic updates to the APST table at runtime. |
... | ... | ||
15 | update nvme module parameters. | 19 | update nvme module parameters. |
16 | echo 1 > /sys/class/nvme/nvme0/apst_update | 20 | echo 1 > /sys/class/nvme/nvme0/apst_update |
17 | 21 | ||
18 | Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn> | 22 | Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn> |
19 | --- | 23 | --- |
20 | drivers/nvme/host/core.c | 4 +++- | 24 | drivers/nvme/host/core.c | 9 +++++++-- |
21 | drivers/nvme/host/nvme.h | 2 ++ | 25 | drivers/nvme/host/nvme.h | 2 ++ |
22 | drivers/nvme/host/sysfs.c | 23 +++++++++++++++++++++++ | 26 | drivers/nvme/host/sysfs.c | 24 ++++++++++++++++++++++++ |
23 | 3 files changed, 28 insertions(+), 1 deletion(-) | 27 | 3 files changed, 33 insertions(+), 2 deletions(-) |
24 | 28 | ||
25 | diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c | 29 | diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c |
26 | index XXXXXXX..XXXXXXX 100644 | 30 | index XXXXXXX..XXXXXXX 100644 |
27 | --- a/drivers/nvme/host/core.c | 31 | --- a/drivers/nvme/host/core.c |
28 | +++ b/drivers/nvme/host/core.c | 32 | +++ b/drivers/nvme/host/core.c |
... | ... | ||
33 | -static int nvme_configure_apst(struct nvme_ctrl *ctrl) | 37 | -static int nvme_configure_apst(struct nvme_ctrl *ctrl) |
34 | +int nvme_configure_apst(struct nvme_ctrl *ctrl) | 38 | +int nvme_configure_apst(struct nvme_ctrl *ctrl) |
35 | { | 39 | { |
36 | struct nvme_feat_auto_pst *table; | 40 | struct nvme_feat_auto_pst *table; |
37 | unsigned apste = 0; | 41 | unsigned apste = 0; |
42 | @@ -XXX,XX +XXX,XX @@ static void nvme_set_latency_tolerance(struct device *dev, s32 val) | ||
43 | |||
44 | if (ctrl->ps_max_latency_us != latency) { | ||
45 | ctrl->ps_max_latency_us = latency; | ||
46 | - if (nvme_ctrl_state(ctrl) == NVME_CTRL_LIVE) | ||
47 | + if (nvme_ctrl_state(ctrl) == NVME_CTRL_LIVE) { | ||
48 | + mutex_lock(&ctrl->apst_lock); | ||
49 | nvme_configure_apst(ctrl); | ||
50 | + mutex_unlock(&ctrl->apst_lock); | ||
51 | + } | ||
52 | } | ||
53 | } | ||
54 | |||
38 | @@ -XXX,XX +XXX,XX @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, | 55 | @@ -XXX,XX +XXX,XX @@ int nvme_init_ctrl(struct nvme_ctrl *ctrl, struct device *dev, |
39 | ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive; | 56 | ctrl->ka_cmd.common.opcode = nvme_admin_keep_alive; |
40 | ctrl->ka_last_check_time = jiffies; | 57 | ctrl->ka_last_check_time = jiffies; |
41 | 58 | ||
42 | + mutex_init(&ctrl->apst_lock); | 59 | + mutex_init(&ctrl->apst_lock); |
... | ... | ||
74 | 91 | ||
75 | +static ssize_t apst_update_store(struct device *dev, | 92 | +static ssize_t apst_update_store(struct device *dev, |
76 | + struct device_attribute *attr, | 93 | + struct device_attribute *attr, |
77 | + const char *buf, size_t size) | 94 | + const char *buf, size_t size) |
78 | +{ | 95 | +{ |
96 | + struct nvme_ctrl *ctrl = dev_get_drvdata(dev); | ||
97 | + bool bool_data = false; | ||
79 | + int err; | 98 | + int err; |
80 | + bool bool_data = false; | 99 | + |
81 | + struct nvme_ctrl *ctrl = dev_get_drvdata(dev); | ||
82 | + err = kstrtobool(buf, &bool_data); | 100 | + err = kstrtobool(buf, &bool_data); |
83 | + | 101 | + |
84 | + if (err) | 102 | + if (err) |
85 | + return err; | 103 | + return err; |
86 | + | 104 | + |
... | ... | diff view generated by jsdifflib |
... | ... | ||
---|---|---|---|
9 | - apst_primary_timeout_ms | 9 | - apst_primary_timeout_ms |
10 | - apst_secondary_timeout_ms | 10 | - apst_secondary_timeout_ms |
11 | - apst_primary_latency_tol_us | 11 | - apst_primary_latency_tol_us |
12 | - apst_secondary_latency_tol_us | 12 | - apst_secondary_latency_tol_us |
13 | 13 | ||
14 | The attributes allow runtime configuration of: | 14 | The attributes allow runtime configuration of: Timeout values for |
15 | 1. Timeout values for primary/secondary states | 15 | primary/secondary states. |
16 | 2. Latency tolerance requirements | ||
17 | 16 | ||
18 | The existing module parameters are retained for backward compatibility | 17 | The existing module parameters are retained for backward compatibility |
19 | but now only serve as default values for new controllers. | 18 | but now only serve as default values for new controllers. |
20 | 19 | ||
21 | Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn> | 20 | Signed-off-by: Yaxiong Tian <tianyaxiong@kylinos.cn> |
22 | --- | 21 | --- |
23 | drivers/nvme/host/core.c | 16 ++++++++++------ | 22 | drivers/nvme/host/core.c | 16 ++++++++++------ |
24 | drivers/nvme/host/nvme.h | 4 ++++ | 23 | drivers/nvme/host/nvme.h | 4 ++++ |
25 | drivers/nvme/host/sysfs.c | 36 ++++++++++++++++++++++++++++++++++++ | 24 | drivers/nvme/host/sysfs.c | 38 ++++++++++++++++++++++++++++++++++++++ |
26 | 3 files changed, 50 insertions(+), 6 deletions(-) | 25 | 3 files changed, 52 insertions(+), 6 deletions(-) |
27 | 26 | ||
28 | diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c | 27 | diff --git a/drivers/nvme/host/core.c b/drivers/nvme/host/core.c |
29 | index XXXXXXX..XXXXXXX 100644 | 28 | index XXXXXXX..XXXXXXX 100644 |
30 | --- a/drivers/nvme/host/core.c | 29 | --- a/drivers/nvme/host/core.c |
31 | +++ b/drivers/nvme/host/core.c | 30 | +++ b/drivers/nvme/host/core.c |
... | ... | ||
103 | +#define nvme_apst_show_and_store_function(field) \ | 102 | +#define nvme_apst_show_and_store_function(field) \ |
104 | +static ssize_t field##_show(struct device *dev, \ | 103 | +static ssize_t field##_show(struct device *dev, \ |
105 | + struct device_attribute *attr, char *buf) \ | 104 | + struct device_attribute *attr, char *buf) \ |
106 | +{ \ | 105 | +{ \ |
107 | + struct nvme_ctrl *ctrl = dev_get_drvdata(dev); \ | 106 | + struct nvme_ctrl *ctrl = dev_get_drvdata(dev); \ |
107 | +\ | ||
108 | + return sysfs_emit(buf, "%llu\n", ctrl->field); \ | 108 | + return sysfs_emit(buf, "%llu\n", ctrl->field); \ |
109 | +} \ | 109 | +} \ |
110 | + \ | 110 | + \ |
111 | +static ssize_t field##_store(struct device *dev, \ | 111 | +static ssize_t field##_store(struct device *dev, \ |
112 | + struct device_attribute *attr, \ | 112 | + struct device_attribute *attr, \ |
113 | + const char *buf, size_t size) \ | 113 | + const char *buf, size_t size) \ |
114 | +{ \ | 114 | +{ \ |
115 | + struct nvme_ctrl *ctrl = dev_get_drvdata(dev); \ | ||
116 | + u64 data = 0; \ | ||
115 | + int err; \ | 117 | + int err; \ |
116 | + u64 data = 0; \ | 118 | +\ |
117 | + struct nvme_ctrl *ctrl = dev_get_drvdata(dev); \ | ||
118 | + err = kstrtou64(buf, 0, &data); \ | 119 | + err = kstrtou64(buf, 0, &data); \ |
119 | + if (err < 0) \ | 120 | + if (err < 0) \ |
120 | + return err; \ | 121 | + return err; \ |
121 | + \ | 122 | + \ |
122 | + mutex_lock(&ctrl->apst_lock); \ | 123 | + mutex_lock(&ctrl->apst_lock); \ |
... | ... | diff view generated by jsdifflib |