Skip to content

Commit

Permalink
pds_core: pass opcode to devcmd_wait
Browse files Browse the repository at this point in the history
[ Upstream commit 0ea064e ]

Don't rely on the PCI memory for the devcmd opcode because we
read a 0xff value if the PCI bus is broken, which can cause us
to report a bogus dev_cmd opcode later.

Fixes: 523847d ("pds_core: add devcmd device interfaces")
Signed-off-by: Shannon Nelson <[email protected]>
Reviewed-by: Brett Creeley <[email protected]>
Reviewed-by: Simon Horman <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Jakub Kicinski <[email protected]>
Signed-off-by: Sasha Levin <[email protected]>
  • Loading branch information
emusln authored and gregkh committed Sep 13, 2023
1 parent 410b246 commit b115509
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions drivers/net/ethernet/amd/pds_core/dev.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static const char *pdsc_devcmd_str(int opcode)
}
}

static int pdsc_devcmd_wait(struct pdsc *pdsc, int max_seconds)
static int pdsc_devcmd_wait(struct pdsc *pdsc, u8 opcode, int max_seconds)
{
struct device *dev = pdsc->dev;
unsigned long start_time;
Expand All @@ -131,9 +131,6 @@ static int pdsc_devcmd_wait(struct pdsc *pdsc, int max_seconds)
int done = 0;
int err = 0;
int status;
int opcode;

opcode = ioread8(&pdsc->cmd_regs->cmd.opcode);

start_time = jiffies;
max_wait = start_time + (max_seconds * HZ);
Expand Down Expand Up @@ -180,7 +177,7 @@ int pdsc_devcmd_locked(struct pdsc *pdsc, union pds_core_dev_cmd *cmd,

memcpy_toio(&pdsc->cmd_regs->cmd, cmd, sizeof(*cmd));
pdsc_devcmd_dbell(pdsc);
err = pdsc_devcmd_wait(pdsc, max_seconds);
err = pdsc_devcmd_wait(pdsc, cmd->opcode, max_seconds);
memcpy_fromio(comp, &pdsc->cmd_regs->comp, sizeof(*comp));

if ((err == -ENXIO || err == -ETIMEDOUT) && pdsc->wq)
Expand Down

0 comments on commit b115509

Please sign in to comment.