diff options
author | Andy Lutomirski <luto@kernel.org> | 2016-09-16 14:16:09 -0400 |
---|---|---|
committer | Jens Axboe <axboe@fb.com> | 2016-09-24 12:56:25 -0400 |
commit | 26501db8dcbc3c63c0d8fb6c5bb098bc7d35d741 (patch) | |
tree | 3da2b32d0d4c81951078f0528f78c31e8fcf5ee7 | |
parent | 2e5d0baa04845dc3a3d7dfa33d7663de270bb146 (diff) |
nvme/scsi: Remove power management support
As far as I can tell, there is basically nothing correct about this
code. It misinterprets npss (off-by-one). It hardcodes a bunch of
power states, which is nonsense, because they're all just indices
into a table that software needs to parse. It completely ignores
the distinction between operational and non-operational states.
And, until 4.8, if all of the above magically succeeded, it would
dereference a NULL pointer and OOPS.
Since this code appears to be useless, just delete it.
Signed-off-by: Andy Lutomirski <luto@kernel.org>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Acked-by: Jay Freyensee <james_p_freyensee@linux.intel.com>
Tested-by: Jay Freyensee <james_p_freyensee@linux.intel.com>
Signed-off-by: Jens Axboe <axboe@fb.com>
-rw-r--r-- | drivers/nvme/host/scsi.c | 74 |
1 files changed, 3 insertions, 71 deletions
diff --git a/drivers/nvme/host/scsi.c b/drivers/nvme/host/scsi.c index e947e298a737..44009105f8c8 100644 --- a/drivers/nvme/host/scsi.c +++ b/drivers/nvme/host/scsi.c | |||
@@ -72,15 +72,6 @@ static int sg_version_num = 30534; /* 2 digits for each component */ | |||
72 | #define ALL_LUNS_RETURNED 0x02 | 72 | #define ALL_LUNS_RETURNED 0x02 |
73 | #define ALL_WELL_KNOWN_LUNS_RETURNED 0x01 | 73 | #define ALL_WELL_KNOWN_LUNS_RETURNED 0x01 |
74 | #define RESTRICTED_LUNS_RETURNED 0x00 | 74 | #define RESTRICTED_LUNS_RETURNED 0x00 |
75 | #define NVME_POWER_STATE_START_VALID 0x00 | ||
76 | #define NVME_POWER_STATE_ACTIVE 0x01 | ||
77 | #define NVME_POWER_STATE_IDLE 0x02 | ||
78 | #define NVME_POWER_STATE_STANDBY 0x03 | ||
79 | #define NVME_POWER_STATE_LU_CONTROL 0x07 | ||
80 | #define POWER_STATE_0 0 | ||
81 | #define POWER_STATE_1 1 | ||
82 | #define POWER_STATE_2 2 | ||
83 | #define POWER_STATE_3 3 | ||
84 | #define DOWNLOAD_SAVE_ACTIVATE 0x05 | 75 | #define DOWNLOAD_SAVE_ACTIVATE 0x05 |
85 | #define DOWNLOAD_SAVE_DEFER_ACTIVATE 0x0E | 76 | #define DOWNLOAD_SAVE_DEFER_ACTIVATE 0x0E |
86 | #define ACTIVATE_DEFERRED_MICROCODE 0x0F | 77 | #define ACTIVATE_DEFERRED_MICROCODE 0x0F |
@@ -1229,64 +1220,6 @@ static void nvme_trans_fill_read_cap(u8 *response, struct nvme_id_ns *id_ns, | |||
1229 | 1220 | ||
1230 | /* Start Stop Unit Helper Functions */ | 1221 | /* Start Stop Unit Helper Functions */ |
1231 | 1222 | ||
1232 | static int nvme_trans_power_state(struct nvme_ns *ns, struct sg_io_hdr *hdr, | ||
1233 | u8 pc, u8 pcmod, u8 start) | ||
1234 | { | ||
1235 | int res; | ||
1236 | int nvme_sc; | ||
1237 | struct nvme_id_ctrl *id_ctrl; | ||
1238 | int lowest_pow_st; /* max npss = lowest power consumption */ | ||
1239 | unsigned ps_desired = 0; | ||
1240 | |||
1241 | nvme_sc = nvme_identify_ctrl(ns->ctrl, &id_ctrl); | ||
1242 | res = nvme_trans_status_code(hdr, nvme_sc); | ||
1243 | if (res) | ||
1244 | return res; | ||
1245 | |||
1246 | lowest_pow_st = max(POWER_STATE_0, (int)(id_ctrl->npss - 1)); | ||
1247 | kfree(id_ctrl); | ||
1248 | |||
1249 | switch (pc) { | ||
1250 | case NVME_POWER_STATE_START_VALID: | ||
1251 | /* Action unspecified if POWER CONDITION MODIFIER != 0 */ | ||
1252 | if (pcmod == 0 && start == 0x1) | ||
1253 | ps_desired = POWER_STATE_0; | ||
1254 | if (pcmod == 0 && start == 0x0) | ||
1255 | ps_desired = lowest_pow_st; | ||
1256 | break; | ||
1257 | case NVME_POWER_STATE_ACTIVE: | ||
1258 | /* Action unspecified if POWER CONDITION MODIFIER != 0 */ | ||
1259 | if (pcmod == 0) | ||
1260 | ps_desired = POWER_STATE_0; | ||
1261 | break; | ||
1262 | case NVME_POWER_STATE_IDLE: | ||
1263 | /* Action unspecified if POWER CONDITION MODIFIER != [0,1,2] */ | ||
1264 | if (pcmod == 0x0) | ||
1265 | ps_desired = POWER_STATE_1; | ||
1266 | else if (pcmod == 0x1) | ||
1267 | ps_desired = POWER_STATE_2; | ||
1268 | else if (pcmod == 0x2) | ||
1269 | ps_desired = POWER_STATE_3; | ||
1270 | break; | ||
1271 | case NVME_POWER_STATE_STANDBY: | ||
1272 | /* Action unspecified if POWER CONDITION MODIFIER != [0,1] */ | ||
1273 | if (pcmod == 0x0) | ||
1274 | ps_desired = max(POWER_STATE_0, (lowest_pow_st - 2)); | ||
1275 | else if (pcmod == 0x1) | ||
1276 | ps_desired = max(POWER_STATE_0, (lowest_pow_st - 1)); | ||
1277 | break; | ||
1278 | case NVME_POWER_STATE_LU_CONTROL: | ||
1279 | default: | ||
1280 | res = nvme_trans_completion(hdr, SAM_STAT_CHECK_CONDITION, | ||
1281 | ILLEGAL_REQUEST, SCSI_ASC_INVALID_CDB, | ||
1282 | SCSI_ASCQ_CAUSE_NOT_REPORTABLE); | ||
1283 | break; | ||
1284 | } | ||
1285 | nvme_sc = nvme_set_features(ns->ctrl, NVME_FEAT_POWER_MGMT, ps_desired, 0, | ||
1286 | NULL); | ||
1287 | return nvme_trans_status_code(hdr, nvme_sc); | ||
1288 | } | ||
1289 | |||
1290 | static int nvme_trans_send_activate_fw_cmd(struct nvme_ns *ns, struct sg_io_hdr *hdr, | 1223 | static int nvme_trans_send_activate_fw_cmd(struct nvme_ns *ns, struct sg_io_hdr *hdr, |
1291 | u8 buffer_id) | 1224 | u8 buffer_id) |
1292 | { | 1225 | { |
@@ -2235,11 +2168,10 @@ static int nvme_trans_synchronize_cache(struct nvme_ns *ns, | |||
2235 | static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr, | 2168 | static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr, |
2236 | u8 *cmd) | 2169 | u8 *cmd) |
2237 | { | 2170 | { |
2238 | u8 immed, pcmod, pc, no_flush, start; | 2171 | u8 immed, pcmod, no_flush, start; |
2239 | 2172 | ||
2240 | immed = cmd[1] & 0x01; | 2173 | immed = cmd[1] & 0x01; |
2241 | pcmod = cmd[3] & 0x0f; | 2174 | pcmod = cmd[3] & 0x0f; |
2242 | pc = (cmd[4] & 0xf0) >> 4; | ||
2243 | no_flush = cmd[4] & 0x04; | 2175 | no_flush = cmd[4] & 0x04; |
2244 | start = cmd[4] & 0x01; | 2176 | start = cmd[4] & 0x01; |
2245 | 2177 | ||
@@ -2254,8 +2186,8 @@ static int nvme_trans_start_stop(struct nvme_ns *ns, struct sg_io_hdr *hdr, | |||
2254 | if (res) | 2186 | if (res) |
2255 | return res; | 2187 | return res; |
2256 | } | 2188 | } |
2257 | /* Setup the expected power state transition */ | 2189 | |
2258 | return nvme_trans_power_state(ns, hdr, pc, pcmod, start); | 2190 | return 0; |
2259 | } | 2191 | } |
2260 | } | 2192 | } |
2261 | 2193 | ||