Centos-kernel-stream-9/drivers/pci
John W. Linville 5adac8b36e cxl/pci: Fix CDAT retrieval on big endian
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2171891

The CDAT exposed in sysfs differs between little endian and big endian
arches:  On big endian, every 4 bytes are byte-swapped.

PCI Configuration Space is little endian (PCI r3.0 sec 6.1).  Accessors
such as pci_read_config_dword() implicitly swap bytes on big endian.
That way, the macros in include/uapi/linux/pci_regs.h work regardless of
the arch's endianness.  For an example of implicit byte-swapping, see
ppc4xx_pciex_read_config(), which calls in_le32(), which uses lwbrx
(Load Word Byte-Reverse Indexed).

DOE Read/Write Data Mailbox Registers are unlike other registers in
Configuration Space in that they contain or receive a 4 byte portion of
an opaque byte stream (a "Data Object" per PCIe r6.0 sec 7.9.24.5f).
They need to be copied to or from the request/response buffer verbatim.
So amend pci_doe_send_req() and pci_doe_recv_resp() to undo the implicit
byte-swapping.

The CXL_DOE_TABLE_ACCESS_* and PCI_DOE_DATA_OBJECT_DISC_* macros assume
implicit byte-swapping.  Byte-swap requests after constructing them with
those macros and byte-swap responses before parsing them.

Change the request and response type to __le32 to avoid sparse warnings.
Per a request from Jonathan, replace sizeof(u32) with sizeof(__le32) for
consistency.

Fixes: c97006046c79 ("cxl/port: Read CDAT table")
Tested-by: Ira Weiny <ira.weiny@intel.com>
Signed-off-by: Lukas Wunner <lukas@wunner.de>
Reviewed-by: Dan Williams <dan.j.williams@intel.com>
Cc: stable@vger.kernel.org # v6.0+
Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
Link: https://lore.kernel.org/r/3051114102f41d19df3debbee123129118fc5e6d.1678543498.git.lukas@wunner.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
(cherry picked from commit fbaa38214cd9e150764ccaa82e04ecf42cc1140c)
Signed-off-by: John W. Linville <linville@redhat.com>
2023-05-01 09:24:07 -04:00
..
controller PCI: dwc: Fix PORT_LINK_CONTROL update when CDM check enabled 2023-04-22 09:28:42 -06:00
endpoint PCI: endpoint: pci-epf-vntb: Add epf_ntb_mw_bar_clear() num_mws kernel-doc 2023-03-29 09:01:28 -06:00
hotplug PCI: Remove MODULE_LICENSE so boolean drivers don't look like modules 2023-03-29 08:56:44 -06:00
msi PCI/MSI: Provide pci_ims_alloc/free_irq() 2023-04-07 07:31:47 -04:00
pcie PCI/ASPM: Add pci_enable_link_state() 2023-03-29 09:01:27 -06:00
switch PCI: switchtec: Return -EFAULT for copy_to_user() errors 2023-03-29 09:00:01 -06:00
Kconfig Merge: Update kernel's PCI subsystem to v6.2 2023-03-27 07:05:15 +02:00
Makefile PCI/DOE: Add DOE mailbox support functions 2023-03-07 07:21:24 -07:00
access.c PCI: Access Link 2 registers only for devices with Links 2023-03-07 07:21:26 -07:00
ats.c PCI: Enable PASID only when ACS RR & UF enabled on upstream path 2023-03-09 16:34:03 -07:00
bus.c PCI: Skip allocate_resource() if too little space available 2023-03-07 07:21:29 -07:00
doe.c cxl/pci: Fix CDAT retrieval on big endian 2023-05-01 09:24:07 -04:00
ecam.c
host-bridge.c
iov.c PCI/IOV: Enlarge virtfn sysfs name buffer 2023-03-29 08:56:44 -06:00
irq.c PCI: Check for alloc failure in pci_request_irq() 2023-03-07 07:21:26 -07:00
mmap.c
of.c PCI: Restrict device disabled status check to DT 2023-04-21 09:41:55 -06:00
p2pdma.c PCI/P2PDMA: Annotate RCU dereference 2023-03-29 08:56:45 -06:00
pci-acpi.c PCI/ACPI: Account for _S0W of the target bridge in acpi_pci_bridge_d3() 2023-03-29 08:56:45 -06:00
pci-bridge-emul.c PCI: pci-bridge-emul: Set position of PCI capabilities to real HW value 2022-11-06 09:09:46 -07:00
pci-bridge-emul.h PCI: pci-bridge-emul: Set position of PCI capabilities to real HW value 2022-11-06 09:09:46 -07:00
pci-driver.c PCI: Unify delay handling for reset and resume 2023-03-29 08:56:45 -06:00
pci-label.c
pci-mid.c
pci-pf-stub.c
pci-stub.c
pci-sysfs.c PCI: Allow drivers to request exclusive config regions 2023-03-13 09:52:37 -04:00
pci.c PCI/DPC: Await readiness of secondary bus after reset 2023-03-29 08:56:45 -06:00
pci.h PCI: Restrict device disabled status check to DT 2023-04-21 09:41:55 -06:00
probe.c PCI: Restrict device disabled status check to DT 2023-04-21 09:41:55 -06:00
proc.c
quirks.c PCI: Add ACS quirk for Wangxun NICs 2023-03-29 08:56:47 -06:00
remove.c PCI: Fix use-after-free in pci_bus_release_domain_nr() 2023-04-13 14:49:43 -06:00
rom.c
search.c
setup-bus.c PCI: Distribute available resources for root buses, too 2023-03-29 08:56:46 -06:00
setup-irq.c
setup-res.c PCI: Sanitise firmware BAR assignments behind a PCI-PCI bridge 2022-11-06 09:09:46 -07:00
slot.c PCI/sysfs: Constify struct kobj_type pci_slot_ktype 2023-03-29 09:01:28 -06:00
syscall.c
vc.c
vgaarb.c
vpd.c
xen-pcifront.c xen/pcifront: Rework MSI handling 2023-03-13 09:52:34 -04:00