Commit 2f07229f authored by Greg Kurz's avatar Greg Kurz Committed by Michael Ellerman

ocxl: Fix endiannes bug in read_afu_name()

The AFU Descriptor Template in the PCI config space has a Name Space
field which is a 24 Byte ASCII character string of descriptive name
space for the AFU. The OCXL driver read the string four characters at
a time with pci_read_config_dword().

This optimization is valid on a little-endian system since this is PCI,
but a big-endian system ends up with each subset of four characters in
reverse order.

This could be fixed by switching to read characters one by one. Another
option is to swap the bytes if we're big-endian.

Go for the latter with le32_to_cpu().

Cc: stable@vger.kernel.org      # v4.16
Signed-off-by: default avatarGreg Kurz <groug@kaod.org>
Acked-by: default avatarFrederic Barrat <fbarrat@linux.ibm.com>
Acked-by: default avatarAndrew Donnellan <andrew.donnellan@au1.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 34642d70
...@@ -318,7 +318,7 @@ static int read_afu_name(struct pci_dev *dev, struct ocxl_fn_config *fn, ...@@ -318,7 +318,7 @@ static int read_afu_name(struct pci_dev *dev, struct ocxl_fn_config *fn,
if (rc) if (rc)
return rc; return rc;
ptr = (u32 *) &afu->name[i]; ptr = (u32 *) &afu->name[i];
*ptr = val; *ptr = le32_to_cpu((__force __le32) val);
} }
afu->name[OCXL_AFU_NAME_SZ - 1] = '\0'; /* play safe */ afu->name[OCXL_AFU_NAME_SZ - 1] = '\0'; /* play safe */
return 0; return 0;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment