Skip to content

Commit d6eb270

Browse files
committed
acpi, nfit: fix bus vs dimm confusion in xlat_status
Given dimms and bus commands share the same command number space we need to be careful that we are translating status in the correct context. Otherwise we can, for example, fail an ND_CMD_GET_CONFIG_SIZE command because max_xfer is zero. It fails because that condition erroneously correlates with the 'cleared == 0' failure of ND_CMD_CLEAR_ERROR. Cc: <[email protected]> Fixes: aef2533 ("libnvdimm, nfit: centralize command status translation") Signed-off-by: Dan Williams <[email protected]>
1 parent 82aa37c commit d6eb270

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

drivers/acpi/nfit/core.c

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static struct acpi_device *to_acpi_dev(struct acpi_nfit_desc *acpi_desc)
9494
return to_acpi_device(acpi_desc->dev);
9595
}
9696

97-
static int xlat_status(void *buf, unsigned int cmd, u32 status)
97+
static int xlat_bus_status(void *buf, unsigned int cmd, u32 status)
9898
{
9999
struct nd_cmd_clear_error *clear_err;
100100
struct nd_cmd_ars_status *ars_status;
@@ -175,6 +175,16 @@ static int xlat_status(void *buf, unsigned int cmd, u32 status)
175175
return 0;
176176
}
177177

178+
static int xlat_status(struct nvdimm *nvdimm, void *buf, unsigned int cmd,
179+
u32 status)
180+
{
181+
if (!nvdimm)
182+
return xlat_bus_status(buf, cmd, status);
183+
if (status)
184+
return -EIO;
185+
return 0;
186+
}
187+
178188
static int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc,
179189
struct nvdimm *nvdimm, unsigned int cmd, void *buf,
180190
unsigned int buf_len, int *cmd_rc)
@@ -335,7 +345,8 @@ static int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc,
335345
*/
336346
rc = buf_len - offset - in_buf.buffer.length;
337347
if (cmd_rc)
338-
*cmd_rc = xlat_status(buf, cmd, fw_status);
348+
*cmd_rc = xlat_status(nvdimm, buf, cmd,
349+
fw_status);
339350
} else {
340351
dev_err(dev, "%s:%s underrun cmd: %s buf_len: %d out_len: %d\n",
341352
__func__, dimm_name, cmd_name, buf_len,
@@ -345,7 +356,7 @@ static int acpi_nfit_ctl(struct nvdimm_bus_descriptor *nd_desc,
345356
} else {
346357
rc = 0;
347358
if (cmd_rc)
348-
*cmd_rc = xlat_status(buf, cmd, fw_status);
359+
*cmd_rc = xlat_status(nvdimm, buf, cmd, fw_status);
349360
}
350361

351362
out:

0 commit comments

Comments
 (0)