Skip to contentSkip to conversation

nvme: fix nvme_pr_* status code parsing

PATCH Applied Weiwen Hu 3 participants 5 messages May 30, 2024 – May 31, 2024 NVMe

lore
Share & tools
lore

Weiwen Hu

author
#0 lore raw

PATCH v2 1/1 nvme: fix nvme_pr_* status code parsing

Fix the parsing if extra status bits (e.g. MORE) is present.

Fixes 7fb42780d06c ("nvme: Convert NVMe errors to PR errors")

---
previous version of this is sent as
https://lore.kernel.org/linux-nvme/[email protected]/

 drivers/nvme/host/pr.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/nvme/host/pr.c +1 -1
index e05571b2a1b0..8fa1ffcdaed4 100644
@@ -77,7 +77,7 @@ static int nvme_sc_to_pr_err(int nvme_sc)
 	if (nvme_is_path_error(nvme_sc))
 		return PR_STS_PATH_FAILED;
 
-	switch (nvme_sc) {
+	switch (nvme_sc & 0x7ff) {
 	case NVME_SC_SUCCESS:
 		return PR_STS_SUCCESS;
 	case NVME_SC_RESERVATION_CONFLICT:
Signature · 1 line
2.45.1
#1 lore raw

drivers/nvme/host/pr.c static int nvme_sc_to_pr_err(int nvme_sc) · line 80

Quoted 1 line · Weiwen Hu
drivers/nvme/host/pr.c +1 -0
+	switch (nvme_sc & 0x7ff) {

Can you use the opportunity to add a NVME_SC_MASK symbolic name for the magic 0x7ff? We should have done this earlier with already 5 occurrences, but better now than never.

Otherwise this looks good to me.

author
#2 lore raw
Quoted 6 lines · Christoph Hellwig

drivers/nvme/host/pr.c static int nvme_sc_to_pr_err(int nvme_sc) · line 80

Quoted 1 line · Weiwen Hu
drivers/nvme/host/pr.c +1 -0
+	switch (nvme_sc & 0x7ff) {

Can you use the opportunity to add a NVME_SC_MASK symbolic name for the magic 0x7ff? We should have done this earlier with already 5 occurrences, but better now than never.

I've already sent this in the previous patch:
[PATCH 2/3] nvme: fix status magic numbers

I chose the name NVME_SCT_SC_MASK to match the NVMe spec better

maintainer
#3 lore raw
In reply to Christoph Hellwig
Quoted 8 lines · Christoph Hellwig

drivers/nvme/host/pr.c static int nvme_sc_to_pr_err(int nvme_sc) · line 80

Quoted 1 line · Weiwen Hu
drivers/nvme/host/pr.c +1 -0
+	switch (nvme_sc & 0x7ff) {

Can you use the opportunity to add a NVME_SC_MASK symbolic name for the magic 0x7ff? We should have done this earlier with already 5 occurrences, but better now than never.

Otherwise this looks good to me.

Yeah, I suggested sending the minimal patch first just for the backport-ability.