Remove cxl driver
Subsystems (4)
v3 cover Remove cxl driver
This series removes the cxl for IBM CAPI devices.
CAPI devices have been out of production for some time, and we're not aware of any remaining users who are likely to want a modern kernel. There's almost certainly some remaining driver bugs and we don't have much hardware available to properly test the drivers any more. Removing these drivers will also mean we can get rid of a non-trivial amount of support code in arch/powerpc.
Thanks to everyone who's worked on these drivers over the last decade.
This series does not affect the OpenCAPI/ocxl driver, nor does it affect Compute Express Link (the other cxl, an amusing but unfortunate naming collision).
The previous version of this series also removed the cxlflash driver, which has now been merged into the scsi tree as 772ba9b5bd27 ("scsi:
cxlflash: Remove driver").
This series applies on top of 772ba9b5bd27 and the patch at [0].
[0] https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/
v1: https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=436014&state=*
v2: https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=442572&state=*
v1->v2: rebase and update docsv2->v3: rebase on docs changes
Andrew Donnellan (1):
cxl: Remove driver
.../ABI/{obsolete => removed}/sysfs-class-cxl | 55 +-
Documentation/arch/powerpc/cxl.rst | 470 ----
Documentation/arch/powerpc/index.rst | 1 -
.../userspace-api/ioctl/ioctl-number.rst | 2 +-
MAINTAINERS | 12 -
arch/powerpc/configs/skiroot_defconfig | 1 -
arch/powerpc/include/asm/copro.h | 6 -
arch/powerpc/include/asm/device.h | 3 -
arch/powerpc/include/asm/pnv-pci.h | 17 -
arch/powerpc/mm/book3s64/hash_native.c | 13 +-
arch/powerpc/mm/book3s64/hash_utils.c | 10 +-
arch/powerpc/mm/book3s64/pgtable.c | 1 -
arch/powerpc/mm/book3s64/slice.c | 6 +-
arch/powerpc/mm/copro_fault.c | 12 -
arch/powerpc/platforms/powernv/Makefile | 1 -
arch/powerpc/platforms/powernv/pci-cxl.c | 153 --
arch/powerpc/platforms/powernv/pci-ioda.c | 43 -
arch/powerpc/platforms/powernv/pci.c | 61 -
arch/powerpc/platforms/powernv/pci.h | 2 -
drivers/misc/Kconfig | 1 -
drivers/misc/Makefile | 1 -
drivers/misc/cxl/Kconfig | 28 -
drivers/misc/cxl/Makefile | 14 -
drivers/misc/cxl/api.c | 532 -----
drivers/misc/cxl/base.c | 126 -
drivers/misc/cxl/context.c | 362 ---
drivers/misc/cxl/cxl.h | 1135 ---------
drivers/misc/cxl/cxllib.c | 271 ---
drivers/misc/cxl/debugfs.c | 134 --
drivers/misc/cxl/fault.c | 341 ---
drivers/misc/cxl/file.c | 699 ------
drivers/misc/cxl/flash.c | 538 -----
drivers/misc/cxl/guest.c | 1208 ----------
drivers/misc/cxl/hcalls.c | 643 -----
drivers/misc/cxl/hcalls.h | 200 --
drivers/misc/cxl/irq.c | 450 ----
drivers/misc/cxl/main.c | 383 ---
drivers/misc/cxl/native.c | 1592 -------------
drivers/misc/cxl/of.c | 346 ---
drivers/misc/cxl/pci.c | 2103 -----------------
drivers/misc/cxl/sysfs.c | 771 ------
drivers/misc/cxl/trace.c | 9 -
drivers/misc/cxl/trace.h | 691 ------
drivers/misc/cxl/vphb.c | 309 ---
include/misc/cxl-base.h | 48 -
include/misc/cxl.h | 265 ---
include/misc/cxllib.h | 129 -
include/uapi/misc/cxl.h | 156 --
48 files changed, 42 insertions(+), 14312 deletions(-)
rename Documentation/ABI/{obsolete => removed}/sysfs-class-cxl (87%)
delete mode 100644 Documentation/arch/powerpc/cxl.rst
delete mode 100644 arch/powerpc/platforms/powernv/pci-cxl.c
delete mode 100644 drivers/misc/cxl/Kconfig
delete mode 100644 drivers/misc/cxl/Makefile
delete mode 100644 drivers/misc/cxl/api.c
delete mode 100644 drivers/misc/cxl/base.c
delete mode 100644 drivers/misc/cxl/context.c
delete mode 100644 drivers/misc/cxl/cxl.h
delete mode 100644 drivers/misc/cxl/cxllib.c
delete mode 100644 drivers/misc/cxl/debugfs.c
delete mode 100644 drivers/misc/cxl/fault.c
delete mode 100644 drivers/misc/cxl/file.c
delete mode 100644 drivers/misc/cxl/flash.c
delete mode 100644 drivers/misc/cxl/guest.c
delete mode 100644 drivers/misc/cxl/hcalls.c
delete mode 100644 drivers/misc/cxl/hcalls.h
delete mode 100644 drivers/misc/cxl/irq.c
delete mode 100644 drivers/misc/cxl/main.c
delete mode 100644 drivers/misc/cxl/native.c
delete mode 100644 drivers/misc/cxl/of.c
delete mode 100644 drivers/misc/cxl/pci.c
delete mode 100644 drivers/misc/cxl/sysfs.c
delete mode 100644 drivers/misc/cxl/trace.c
delete mode 100644 drivers/misc/cxl/trace.h
delete mode 100644 drivers/misc/cxl/vphb.c
delete mode 100644 include/misc/cxl-base.h
delete mode 100644 include/misc/cxl.h
delete mode 100644 include/misc/cxllib.h
delete mode 100644 include/uapi/misc/cxl.hSignature · 1 line
2.48.1
PATCH v3 1/1 cxl: Remove driver
Remove the cxl driver that provides support for the IBM Coherent Accelerator Processor Interface. Revert or clean up associated code in arch/powerpc that is no longer necessary.
cxl has received minimal maintenance for several years, and is not supported on the Power10 processor. We aren't aware of any users who are likely to be using recent kernels.
Thanks to Mikey Neuling, Ian Munsie, Daniel Axtens, Frederic Barrat, Christophe Lombard, Philippe Bergheaud, Vaibhav Jain and Alastair D'Silva for their work on this driver over the years.
---
Applies on top of commit 772ba9b5bd27 ("scsi: cxlflash: Remove driver") (currently in the scsi tree), and [0].
Maddy: how do you want to take this? I've cc'd Martin and the scsi list.
[0] https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/
v3: rebase on top of docs change
v2: rebase, update docs
---
.../ABI/{obsolete => removed}/sysfs-class-cxl | 55 +-
Documentation/arch/powerpc/cxl.rst | 470 ----
Documentation/arch/powerpc/index.rst | 1 -
.../userspace-api/ioctl/ioctl-number.rst | 2 +-
MAINTAINERS | 12 -
arch/powerpc/configs/skiroot_defconfig | 1 -
arch/powerpc/include/asm/copro.h | 6 -
arch/powerpc/include/asm/device.h | 3 -
arch/powerpc/include/asm/pnv-pci.h | 17 -
arch/powerpc/mm/book3s64/hash_native.c | 13 +-
arch/powerpc/mm/book3s64/hash_utils.c | 10 +-
arch/powerpc/mm/book3s64/pgtable.c | 1 -
arch/powerpc/mm/book3s64/slice.c | 6 +-
arch/powerpc/mm/copro_fault.c | 12 -
arch/powerpc/platforms/powernv/Makefile | 1 -
arch/powerpc/platforms/powernv/pci-cxl.c | 153 --
arch/powerpc/platforms/powernv/pci-ioda.c | 43 -
arch/powerpc/platforms/powernv/pci.c | 61 -
arch/powerpc/platforms/powernv/pci.h | 2 -
drivers/misc/Kconfig | 1 -
drivers/misc/Makefile | 1 -
drivers/misc/cxl/Kconfig | 28 -
drivers/misc/cxl/Makefile | 14 -
drivers/misc/cxl/api.c | 532 -----
drivers/misc/cxl/base.c | 126 -
drivers/misc/cxl/context.c | 362 ---
drivers/misc/cxl/cxl.h | 1135 ---------
drivers/misc/cxl/cxllib.c | 271 ---
drivers/misc/cxl/debugfs.c | 134 --
drivers/misc/cxl/fault.c | 341 ---
drivers/misc/cxl/file.c | 699 ------
drivers/misc/cxl/flash.c | 538 -----
drivers/misc/cxl/guest.c | 1208 ----------
drivers/misc/cxl/hcalls.c | 643 -----
drivers/misc/cxl/hcalls.h | 200 --
drivers/misc/cxl/irq.c | 450 ----
drivers/misc/cxl/main.c | 383 ---
drivers/misc/cxl/native.c | 1592 -------------
drivers/misc/cxl/of.c | 346 ---
drivers/misc/cxl/pci.c | 2103 -----------------
drivers/misc/cxl/sysfs.c | 771 ------
drivers/misc/cxl/trace.c | 9 -
drivers/misc/cxl/trace.h | 691 ------
drivers/misc/cxl/vphb.c | 309 ---
include/misc/cxl-base.h | 48 -
include/misc/cxl.h | 265 ---
include/misc/cxllib.h | 129 -
include/uapi/misc/cxl.h | 156 --
48 files changed, 42 insertions(+), 14312 deletions(-)
rename Documentation/ABI/{obsolete => removed}/sysfs-class-cxl (87%)
delete mode 100644 Documentation/arch/powerpc/cxl.rst
delete mode 100644 arch/powerpc/platforms/powernv/pci-cxl.c
delete mode 100644 drivers/misc/cxl/Kconfig
delete mode 100644 drivers/misc/cxl/Makefile
delete mode 100644 drivers/misc/cxl/api.c
delete mode 100644 drivers/misc/cxl/base.c
delete mode 100644 drivers/misc/cxl/context.c
delete mode 100644 drivers/misc/cxl/cxl.h
delete mode 100644 drivers/misc/cxl/cxllib.c
delete mode 100644 drivers/misc/cxl/debugfs.c
delete mode 100644 drivers/misc/cxl/fault.c
delete mode 100644 drivers/misc/cxl/file.c
delete mode 100644 drivers/misc/cxl/flash.c
delete mode 100644 drivers/misc/cxl/guest.c
delete mode 100644 drivers/misc/cxl/hcalls.c
delete mode 100644 drivers/misc/cxl/hcalls.h
delete mode 100644 drivers/misc/cxl/irq.c
delete mode 100644 drivers/misc/cxl/main.c
delete mode 100644 drivers/misc/cxl/native.c
delete mode 100644 drivers/misc/cxl/of.c
delete mode 100644 drivers/misc/cxl/pci.c
delete mode 100644 drivers/misc/cxl/sysfs.c
delete mode 100644 drivers/misc/cxl/trace.c
delete mode 100644 drivers/misc/cxl/trace.h
delete mode 100644 drivers/misc/cxl/vphb.c
delete mode 100644 include/misc/cxl-base.h
delete mode 100644 include/misc/cxl.h
delete mode 100644 include/misc/cxllib.h
delete mode 100644 include/uapi/misc/cxl.hDocumentation/ABI/removed/sysfs-class-cxl renamed from Documentation/ABI/obsolete/sysfs-class-cxl +27 -28
@@ -1,5 +1,4 @@ -The cxl driver is no longer maintained, and will be removed from the kernel in -the near future. +The cxl driver was removed in 6.14. Please note that attributes that are shared between devices are stored in the directory pointed to by the symlink device/.
@@ -10,7 +9,7 @@ For example, the real path of the attribute /sys/class/cxl/afu0.0s/irqs_max is Slave contexts (eg. /sys/class/cxl/afu0.0s): What: /sys/class/cxl/<afu>/afu_err_buf -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only AFU Error Buffer contents. The contents of this file are
@@ -21,7 +20,7 @@ Description: read only What: /sys/class/cxl/<afu>/irqs_max -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read/write Decimal value of maximum number of interrupts that can be
@@ -32,7 +31,7 @@ Description: read/write Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/irqs_min -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Decimal value of the minimum number of interrupts that
@@ -42,7 +41,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/mmio_size -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Decimal value of the size of the MMIO space that may be mmapped
@@ -50,7 +49,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/modes_supported -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only List of the modes this AFU supports. One per line.
@@ -58,7 +57,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/mode -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read/write The current mode the AFU is using. Will be one of the modes
@@ -68,7 +67,7 @@ Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/prefault_mode -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read/write Set the mode for prefaulting in segments into the segment table
@@ -88,7 +87,7 @@ Description: read/write Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/reset -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: write only Writing 1 here will reset the AFU provided there are not
@@ -96,14 +95,14 @@ Description: write only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/api_version -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Decimal value of the current version of the kernel/user API. Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/api_version_compatible -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Decimal value of the lowest version of the userspace API
@@ -117,7 +116,7 @@ An AFU may optionally export one or more PCIe like configuration records, known as AFU configuration records, which will show up here (if present). What: /sys/class/cxl/<afu>/cr<config num>/vendor -Date: February 2015 +Date: February 2015, removed February 2025 Contact: [email protected] Description: read only Hexadecimal value of the vendor ID found in this AFU
@@ -125,7 +124,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/cr<config num>/device -Date: February 2015 +Date: February 2015, removed February 2025 Contact: [email protected] Description: read only Hexadecimal value of the device ID found in this AFU
@@ -133,7 +132,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/cr<config num>/class -Date: February 2015 +Date: February 2015, removed February 2025 Contact: [email protected] Description: read only Hexadecimal value of the class code found in this AFU
@@ -141,7 +140,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/cr<config num>/config -Date: February 2015 +Date: February 2015, removed February 2025 Contact: [email protected] Description: read only This binary file provides raw access to the AFU configuration
@@ -155,7 +154,7 @@ Users: https://github.com/ibm-capi/libcxl Master contexts (eg. /sys/class/cxl/afu0.0m) What: /sys/class/cxl/<afu>m/mmio_size -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Decimal value of the size of the MMIO space that may be mmapped
@@ -163,14 +162,14 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>m/pp_mmio_len -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Decimal value of the Per Process MMIO space length. Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>m/pp_mmio_off -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only (not in a guest)
@@ -181,21 +180,21 @@ Users: https://github.com/ibm-capi/libcxl Card info (eg. /sys/class/cxl/card0) What: /sys/class/cxl/<card>/caia_version -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Identifies the CAIA Version the card implements. Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/psl_revision -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Identifies the revision level of the PSL. Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/base_image -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only (not in a guest)
@@ -206,7 +205,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/image_loaded -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only (not in a guest)
@@ -215,7 +214,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/load_image_on_perst -Date: December 2014 +Date: December 2014, removed February 2025 Contact: [email protected] Description: read/write (not in a guest)
@@ -232,7 +231,7 @@ Description: read/write Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/reset -Date: October 2014 +Date: October 2014, removed February 2025 Contact: [email protected] Description: write only Writing 1 will issue a PERST to card provided there are no
@@ -243,7 +242,7 @@ Description: write only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/perst_reloads_same_image -Date: July 2015 +Date: July 2015, removed February 2025 Contact: [email protected] Description: read/write (not in a guest)
@@ -257,7 +256,7 @@ Description: read/write Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/psl_timebase_synced -Date: March 2016 +Date: March 2016, removed February 2025 Contact: [email protected] Description: read only Returns 1 if the psl timebase register is synchronized
@@ -265,7 +264,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/tunneled_ops_supported -Date: May 2018 +Date: May 2018, removed February 2025 Contact: [email protected] Description: read only Returns 1 if tunneled operations are supported in capi mode,
Documentation/arch/powerpc/cxl.rst deleted +0 -470
470 lines not on this page · raw message
Documentation/arch/powerpc/index.rst +0 -1
@@ -12,7 +12,6 @@ powerpc bootwrapper cpu_families cpu_features - cxl dawr-power9 dexcr dscr
Documentation/userspace-api/ioctl/ioctl-number.rst +1 -1
@@ -373,7 +373,7 @@ Code Seq# Include File Comments 0xB7 all uapi/linux/nsfs.h <mailto:Andrei Vagin <[email protected]>> 0xB8 01-02 uapi/misc/mrvl_cn10k_dpi.h Marvell CN10K DPI driver 0xC0 00-0F linux/usb/iowarrior.h -0xCA 00-0F uapi/misc/cxl.h +0xCA 00-0F uapi/misc/cxl.h Dead since 6.14 0xCA 10-2F uapi/misc/ocxl.h 0xCA 80-BF uapi/scsi/cxlflash_ioctl.h Dead since 6.14 0xCB 00-1F CBM serial IEC bus in development:
MAINTAINERS +0 -12
@@ -6316,18 +6316,6 @@ S: Maintained W: http://www.chelsio.com F: drivers/net/ethernet/chelsio/cxgb4vf/ -CXL (IBM Coherent Accelerator Processor Interface CAPI) DRIVER -M: Frederic Barrat <[email protected]> -M: Andrew Donnellan <[email protected]> -L: [email protected] -S: Obsolete -F: Documentation/ABI/obsolete/sysfs-class-cxl -F: Documentation/arch/powerpc/cxl.rst -F: arch/powerpc/platforms/powernv/pci-cxl.c -F: drivers/misc/cxl/ -F: include/misc/cxl* -F: include/uapi/misc/cxl.h - CYBERPRO FB DRIVER M: Russell King <[email protected]> L: [email protected] (moderated for non-subscribers)
arch/powerpc/configs/skiroot_defconfig +0 -1
@@ -78,7 +78,6 @@ CONFIG_VIRTIO_BLK=m CONFIG_BLK_DEV_NVME=m CONFIG_NVME_MULTIPATH=y CONFIG_EEPROM_AT24=m -# CONFIG_CXL is not set # CONFIG_OCXL is not set CONFIG_BLK_DEV_SD=m CONFIG_BLK_DEV_SR=m
arch/powerpc/include/asm/copro.h +0 -6
@@ -18,10 +18,4 @@ int copro_handle_mm_fault(struct mm_struct *mm, unsigned long ea,int copro_calculate_slb (struct mm_struct *mm,u64 ea,struct copro_slb *slb); - -#ifdef CONFIG_PPC_COPRO_BASE -void copro_flush_all_slbs (struct mm_struct *mm); -#else -static inline void copro_flush_all_slbs (struct mm_struct *mm) {} -#endif #endif /* _ASM_POWERPC_COPRO_H */
arch/powerpc/include/asm/device.h +0 -3
@@ -38,9 +38,6 @@ struct dev_archdata {#ifdef CONFIG_FAIL_IOMMU int fail_iommu;#endif -#ifdef CONFIG_CXL_BASE -struct cxl_context *cxl_ctx; -#endif #ifdef CONFIG_PCI_IOV void *iov_data;#endif
arch/powerpc/include/asm/pnv-pci.h +0 -17
@@ -10,7 +10,6 @@#include <linux/pci_hotplug.h> #include <linux/irq.h> #include <linux/of.h> -#include <misc/cxl-base.h> #include <asm/opal-api.h> #define PCI_SLOT_ID_PREFIX (1UL << 63)
@@ -25,25 +24,9 @@ extern int pnv_pci_get_power_state(uint64_t id, uint8_t *state);extern int pnv_pci_set_power_state (uint64_t id,uint8_t state,struct opal_msg *msg); -extern int pnv_pci_set_tunnel_bar (struct pci_dev *dev,uint64_t addr, -int enable); -int pnv_phb_to_cxl_mode (struct pci_dev *dev,uint64_t mode); -int pnv_cxl_ioda_msi_setup (struct pci_dev *dev,unsigned int hwirq, -unsigned int virq); -int pnv_cxl_alloc_hwirqs (struct pci_dev *dev,int num); -void pnv_cxl_release_hwirqs (struct pci_dev *dev,int hwirq,int num); -int pnv_cxl_get_irq_count (struct pci_dev *dev); -struct device_node *pnv_pci_get_phb_node (struct pci_dev *dev);int64_t pnv_opal_pci_msi_eoi (struct irq_data *d);bool is_pnv_opal_msi (struct irq_chip *chip); -#ifdef CONFIG_CXL_BASE -int pnv_cxl_alloc_hwirq_ranges (struct cxl_irq_ranges *irqs, -struct pci_dev *dev,int num); -void pnv_cxl_release_hwirq_ranges (struct cxl_irq_ranges *irqs, -struct pci_dev *dev); -#endif -struct pnv_php_slot {struct hotplug_slot slot;uint64_t id;
arch/powerpc/mm/book3s64/hash_native.c +3 -10
@@ -27,8 +27,6 @@#include <asm/ppc-opcode.h> #include <asm/feature-fixups.h> -#include <misc/cxl-base.h> -#ifdef DEBUG_LOW #define DBG_LOW(fmt...) udbg_printf(fmt)#else
@@ -217,11 +215,9 @@ static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)static inline void tlbie (unsigned long vpn,int psize,int apsize,int ssize,int local) { -unsigned int use_local; +unsigned int use_local = local &&mmu_has_feature (MMU_FTR_TLBIEL );int lock_tlbie = !mmu_has_feature (MMU_FTR_LOCKLESS_TLBIE ); - use_local = local &&mmu_has_feature (MMU_FTR_TLBIEL ) && !cxl_ctx_in_use (); -if (use_local) use_local = mmu_psize_defs[psize].tlbiel;if (lock_tlbie && !use_local)
@@ -789,10 +785,6 @@ static void native_flush_hash_range(unsigned long number, int local)unsigned long psize = batch->psize;int ssize = batch->ssize;int i; -unsigned int use_local; - - use_local = local &&mmu_has_feature (MMU_FTR_TLBIEL ) && - mmu_psize_defs[psize].tlbiel && !cxl_ctx_in_use ();local_irq_save (flags);
@@ -827,7 +819,8 @@ static void native_flush_hash_range(unsigned long number, int local) }pte_iterate_hashed_end (); } -if (use_local) { +if (mmu_has_feature (MMU_FTR_TLBIEL ) && + mmu_psize_defs[psize].tlbiel && local) { asmvolatile ("ptesync" :::"memory" );for (i =0 ; i < number; i++) { vpn = batch->vpn[i];
arch/powerpc/mm/book3s64/hash_utils.c +7 -3
@@ -56,7 +56,7 @@#include <asm/cacheflush.h> #include <asm/cputable.h> #include <asm/sections.h> -#include <asm/copro.h> +#include <asm/spu.h> #include <asm/udbg.h> #include <asm/text-patching.h> #include <asm/fadump.h>
@@ -1612,7 +1612,9 @@ void demote_segment_4k(struct mm_struct *mm, unsigned long addr)if (get_slice_psize (mm, addr) ==MMU_PAGE_4K )return ;slice_set_range_psize (mm, addr,1 ,MMU_PAGE_4K ); -copro_flush_all_slbs (mm); +#ifdef CONFIG_SPU_BASE +spu_flush_all_slbs (mm); +#endif if ((get_paca_psize (addr) !=MMU_PAGE_4K ) && (current->mm == mm)) {copy_mm_to_paca (mm);
@@ -1881,7 +1883,9 @@ int hash_page_mm(struct mm_struct *mm, unsigned long ea,"to 4kB pages because of " "non-cacheable mapping\n"); psize = mmu_vmalloc_psize =MMU_PAGE_4K ; -copro_flush_all_slbs (mm); +#ifdef CONFIG_SPU_BASE +spu_flush_all_slbs (mm); +#endif } }
arch/powerpc/mm/book3s64/pgtable.c +0 -1
@@ -10,7 +10,6 @@#include <linux/pkeys.h> #include <linux/debugfs.h> #include <linux/proc_fs.h> -#include <misc/cxl-base.h> #include <asm/pgalloc.h> #include <asm/tlb.h>
arch/powerpc/mm/book3s64/slice.c +4 -2
@@ -22,7 +22,7 @@#include <linux/security.h> #include <asm/mman.h> #include <asm/mmu.h> -#include <asm/copro.h> +#include <asm/spu.h> #include <asm/hugetlb.h> #include <asm/mmu_context.h>
@@ -248,7 +248,9 @@ static void slice_convert(struct mm_struct *mm,spin_unlock_irqrestore (&slice_convert_lock, flags); -copro_flush_all_slbs (mm); +#ifdef CONFIG_SPU_BASE +spu_flush_all_slbs (mm); +#endif }/*
arch/powerpc/mm/copro_fault.c +0 -12
@@ -12,8 +12,6 @@#include <linux/export.h> #include <asm/reg.h> #include <asm/copro.h> -#include <asm/spu.h> -#include <misc/cxl-base.h> /* * This ought to be kept in sync with the powerpc specific do_page_fault
@@ -135,13 +133,3 @@ int copro_calculate_slb(struct mm_struct *mm, u64 ea, struct copro_slb *slb)return 0 ; }EXPORT_SYMBOL_GPL (copro_calculate_slb); - -void copro_flush_all_slbs (struct mm_struct *mm) -{ -#ifdef CONFIG_SPU_BASE -spu_flush_all_slbs (mm); -#endif -cxl_slbia (mm); -} -EXPORT_SYMBOL_GPL (copro_flush_all_slbs); -#endif
arch/powerpc/platforms/powernv/Makefile +0 -1
@@ -21,7 +21,6 @@ obj-$(CONFIG_PRESERVE_FA_DUMP) += opal-fadump.o obj-$(CONFIG_OPAL_CORE) += opal-core.o obj-$(CONFIG_PCI) += pci.o pci-ioda.o pci-ioda-tce.o obj-$(CONFIG_PCI_IOV) += pci-sriov.o -obj-$(CONFIG_CXL_BASE) += pci-cxl.o obj-$(CONFIG_EEH) += eeh-powernv.o obj-$(CONFIG_MEMORY_FAILURE) += opal-memory-errors.o obj-$(CONFIG_OPAL_PRD) += opal-prd.o
arch/powerpc/platforms/powernv/pci-cxl.c deleted +0 -153
153 lines not on this page · raw message
arch/powerpc/platforms/powernv/pci-ioda.c +0 -43
55 lines not on this page · raw message
arch/powerpc/platforms/powernv/pci.c +0 -61
79 lines not on this page · raw message
arch/powerpc/platforms/powernv/pci.h +0 -2
@@ -163,7 +163,6 @@ struct pnv_phb {unsigned int *io_segmap;/* IRQ chip */ -int irq_chip_init;struct irq_chip irq_chip;/* Sorted list of used PE's based
@@ -281,7 +280,6 @@ extern int pnv_eeh_phb_reset(struct pci_controller *hose, int option);extern struct pnv_ioda_pe *pnv_pci_bdfn_to_pe (struct pnv_phb *phb,u16 bdfn);extern struct pnv_ioda_pe *pnv_ioda_get_pe (struct pci_dev *dev); -extern void pnv_set_msi_irq_chip (struct pnv_phb *phb,unsigned int virq);extern unsigned long pnv_pci_ioda2_get_table_size (__u32 page_shift,__u64 window_size,__u32 levels);extern int pnv_eeh_post_init (void );
drivers/misc/Kconfig +0 -1
@@ -641,7 +641,6 @@ source "drivers/misc/mei/Kconfig" source "drivers/misc/vmw_vmci/Kconfig" source "drivers/misc/genwqe/Kconfig" source "drivers/misc/echo/Kconfig" -source "drivers/misc/cxl/Kconfig" source "drivers/misc/ocxl/Kconfig" source "drivers/misc/bcm-vk/Kconfig" source "drivers/misc/cardreader/Kconfig"
drivers/misc/Makefile +0 -1
@@ -50,7 +50,6 @@ obj-$(CONFIG_SRAM) += sram.o obj-$(CONFIG_SRAM_EXEC) += sram-exec.o obj-$(CONFIG_GENWQE) += genwqe/ obj-$(CONFIG_ECHO) += echo/ -obj-$(CONFIG_CXL_BASE) += cxl/ obj-$(CONFIG_DW_XDATA_PCIE) += dw-xdata-pcie.o obj-$(CONFIG_PCI_ENDPOINT_TEST) += pci_endpoint_test.o obj-$(CONFIG_OCXL) += ocxl/
drivers/misc/cxl/Kconfig deleted +0 -28
@@ -1,28 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# -# IBM Coherent Accelerator (CXL) compatible devices -# - -config CXL_BASE - bool - select PPC_COPRO_BASE - select PPC_64S_HASH_MMU - -config CXL - tristate "Support for IBM Coherent Accelerators (CXL) (DEPRECATED)" - depends on PPC_POWERNV && PCI_MSI && EEH - select CXL_BASE - help - The cxl driver is deprecated and will be removed in a future - kernel release. - - Select this option to enable driver support for IBM Coherent - Accelerators (CXL). CXL is otherwise known as Coherent Accelerator - Processor Interface (CAPI). CAPI allows accelerators in FPGAs to be - coherently attached to a CPU via an MMU. This driver enables - userspace programs to access these accelerators via /dev/cxl/afuM.N - devices. - - CAPI adapters are found in POWER8 based systems. - - If unsure, say N.
drivers/misc/cxl/Makefile deleted +0 -14
@@ -1,14 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -ccflags-y := $(call cc-disable-warning, unused-const-variable) -ccflags-$(CONFIG_PPC_WERROR) += -Werror - -cxl-y += main.o file.o irq.o fault.o native.o -cxl-y += context.o sysfs.o pci.o trace.o -cxl-y += vphb.o api.o cxllib.o -cxl-$(CONFIG_PPC_PSERIES) += flash.o guest.o of.o hcalls.o -cxl-$(CONFIG_DEBUG_FS) += debugfs.o -obj-$(CONFIG_CXL) += cxl.o -obj-$(CONFIG_CXL_BASE) += base.o - -# For tracepoints to include our trace.h from tracepoint infrastructure: -CFLAGS_trace.o := -I$(src)
drivers/misc/cxl/api.c deleted +0 -532
532 lines not on this page · raw message
drivers/misc/cxl/base.c deleted +0 -126
126 lines not on this page · raw message
drivers/misc/cxl/context.c deleted +0 -362
362 lines not on this page · raw message
drivers/misc/cxl/cxl.h deleted +0 -1135
728 lines not on this page · raw message
drivers/misc/cxl/cxllib.c deleted +0 -271
271 lines not on this page · raw message
drivers/misc/cxl/debugfs.c deleted +0 -134
134 lines not on this page · raw message
drivers/misc/cxl/fault.c deleted +0 -341
341 lines not on this page · raw message
drivers/misc/cxl/file.c deleted +0 -699
699 lines not on this page · raw message
drivers/misc/cxl/flash.c deleted +0 -538
538 lines not on this page · raw message
drivers/misc/cxl/guest.c deleted +0 -1208
1,208 lines not on this page · raw message
drivers/misc/cxl/hcalls.c deleted +0 -643
643 lines not on this page · raw message
drivers/misc/cxl/hcalls.h deleted +0 -200
200 lines not on this page · raw message
drivers/misc/cxl/irq.c deleted +0 -450
450 lines not on this page · raw message
drivers/misc/cxl/main.c deleted +0 -383
383 lines not on this page · raw message
drivers/misc/cxl/native.c deleted +0 -1592
1,592 lines not on this page · raw message
drivers/misc/cxl/of.c deleted +0 -346
346 lines not on this page · raw message
drivers/misc/cxl/pci.c deleted +0 -2103
2,103 lines not on this page · raw message
drivers/misc/cxl/sysfs.c deleted +0 -771
771 lines not on this page · raw message
drivers/misc/cxl/trace.h deleted +0 -691
691 lines not on this page · raw message
drivers/misc/cxl/vphb.c deleted +0 -309
309 lines not on this page · raw message
include/misc/cxl-base.h deleted +0 -48
48 lines not on this page · raw message
include/misc/cxl.h deleted +0 -265
265 lines not on this page · raw message
include/misc/cxllib.h deleted +0 -129
129 lines not on this page · raw message
include/uapi/misc/cxl.h deleted +0 -156
156 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.48.1
Part of the diff is not shown here. View the raw message.
Re: [PATCH v3 1/1] cxl: Remove driver
Quoted 8 lines · Andrew Donnellan
Remove the cxl driver that provides support for the IBM Coherent Accelerator Processor Interface. Revert or clean up associated code in
arch/powerpcthat is no longer necessary.cxl has received minimal maintenance for several years, and is not supported on the Power10 processor. We aren't aware of any users who are likely to be using recent kernels.
Quoted 6 lines
Thanks to Mikey Neuling, Ian Munsie, Daniel Axtens, Frederic Barrat, Christophe Lombard, Philippe Bergheaud, Vaibhav Jain and Alastair D'Silva for their work on this driver over the years.
Signed-off-by Andrew Donnellan <[email protected]>Acked-by Frederic Barrat <[email protected]>
Martin,
This patch has depenednecy with the first patch
https://lists.ozlabs.org/pipermail/linuxppc-dev/2025-February/280990.html
Which is already part of your staging tree. Can you please take this patch along with the previous patch.
Maddy
Quoted 15,092 lines
---
Applies on top of commit
772ba9b5bd27("scsi: cxlflash: Remove driver") (currently in the scsi tree), and [0].Maddy: how do you want to take this? I've cc'd Martin and the scsi list.
[0] https://patchwork.ozlabs.org/project/linuxppc-dev/patch/[email protected]/
v3: rebase on top of docs change
v2: rebase, update docs--- .../ABI/{obsolete => removed}/sysfs-class-cxl | 55 +- Documentation/arch/powerpc/cxl.rst | 470 ---- Documentation/arch/powerpc/index.rst | 1 - .../userspace-api/ioctl/ioctl-number.rst | 2 +- MAINTAINERS | 12 - arch/powerpc/configs/skiroot_defconfig | 1 - arch/powerpc/include/asm/copro.h | 6 - arch/powerpc/include/asm/device.h | 3 - arch/powerpc/include/asm/pnv-pci.h | 17 - arch/powerpc/mm/book3s64/hash_native.c | 13 +- arch/powerpc/mm/book3s64/hash_utils.c | 10 +- arch/powerpc/mm/book3s64/pgtable.c | 1 - arch/powerpc/mm/book3s64/slice.c | 6 +- arch/powerpc/mm/copro_fault.c | 12 - arch/powerpc/platforms/powernv/Makefile | 1 - arch/powerpc/platforms/powernv/pci-cxl.c | 153 -- arch/powerpc/platforms/powernv/pci-ioda.c | 43 - arch/powerpc/platforms/powernv/pci.c | 61 - arch/powerpc/platforms/powernv/pci.h | 2 - drivers/misc/Kconfig | 1 - drivers/misc/Makefile | 1 - drivers/misc/cxl/Kconfig | 28 - drivers/misc/cxl/Makefile | 14 - drivers/misc/cxl/api.c | 532 ----- drivers/misc/cxl/base.c | 126 - drivers/misc/cxl/context.c | 362 --- drivers/misc/cxl/cxl.h | 1135 --------- drivers/misc/cxl/cxllib.c | 271 --- drivers/misc/cxl/debugfs.c | 134 -- drivers/misc/cxl/fault.c | 341 --- drivers/misc/cxl/file.c | 699 ------ drivers/misc/cxl/flash.c | 538 ----- drivers/misc/cxl/guest.c | 1208 ---------- drivers/misc/cxl/hcalls.c | 643 ----- drivers/misc/cxl/hcalls.h | 200 -- drivers/misc/cxl/irq.c | 450 ---- drivers/misc/cxl/main.c | 383 --- drivers/misc/cxl/native.c | 1592 ------------- drivers/misc/cxl/of.c | 346 --- drivers/misc/cxl/pci.c | 2103 ----------------- drivers/misc/cxl/sysfs.c | 771 ------ drivers/misc/cxl/trace.c | 9 - drivers/misc/cxl/trace.h | 691 ------ drivers/misc/cxl/vphb.c | 309 --- include/misc/cxl-base.h | 48 - include/misc/cxl.h | 265 --- include/misc/cxllib.h | 129 - include/uapi/misc/cxl.h | 156 -- 48 files changed, 42 insertions(+), 14312 deletions(-) rename Documentation/ABI/{obsolete => removed}/sysfs-class-cxl (87%) delete mode 100644 Documentation/arch/powerpc/cxl.rst delete mode 100644 arch/powerpc/platforms/powernv/pci-cxl.c delete mode 100644 drivers/misc/cxl/Kconfig delete mode 100644 drivers/misc/cxl/Makefile delete mode 100644 drivers/misc/cxl/api.c delete mode 100644 drivers/misc/cxl/base.c delete mode 100644 drivers/misc/cxl/context.c delete mode 100644 drivers/misc/cxl/cxl.h delete mode 100644 drivers/misc/cxl/cxllib.c delete mode 100644 drivers/misc/cxl/debugfs.c delete mode 100644 drivers/misc/cxl/fault.c delete mode 100644 drivers/misc/cxl/file.c delete mode 100644 drivers/misc/cxl/flash.c delete mode 100644 drivers/misc/cxl/guest.c delete mode 100644 drivers/misc/cxl/hcalls.c delete mode 100644 drivers/misc/cxl/hcalls.h delete mode 100644 drivers/misc/cxl/irq.c delete mode 100644 drivers/misc/cxl/main.c delete mode 100644 drivers/misc/cxl/native.c delete mode 100644 drivers/misc/cxl/of.c delete mode 100644 drivers/misc/cxl/pci.c delete mode 100644 drivers/misc/cxl/sysfs.c delete mode 100644 drivers/misc/cxl/trace.c delete mode 100644 drivers/misc/cxl/trace.h delete mode 100644 drivers/misc/cxl/vphb.c delete mode 100644 include/misc/cxl-base.h delete mode 100644 include/misc/cxl.h delete mode 100644 include/misc/cxllib.h delete mode 100644 include/uapi/misc/cxl.hDocumentation/ABI/removed/sysfs-class-cxl renamed from Documentation/ABI/obsolete/sysfs-class-cxl +27
-28@@ -1,5 +1,4 @@ -The cxl driver is no longer maintained, and will be removed from the kernel in -the near future. +The cxl driver was removed in 6.14. Please note that attributes that are shared between devices are stored in the directory pointed to by the symlink device/.@@ -10,7 +9,7 @@ For example, the real path of the attribute /sys/class/cxl/afu0.0s/irqs_max is Slave contexts (eg. /sys/class/cxl/afu0.0s): What: /sys/class/cxl/<afu>/afu_err_buf -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only AFU Error Buffer contents. The contents of this file are@@ -21,7 +20,7 @@ Description: read only What: /sys/class/cxl/<afu>/irqs_max -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read/write Decimal value of maximum number of interrupts that can be@@ -32,7 +31,7 @@ Description: read/write Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/irqs_min -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Decimal value of the minimum number of interrupts that@@ -42,7 +41,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/mmio_size -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Decimal value of the size of the MMIO space that may be mmapped@@ -50,7 +49,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/modes_supported -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only List of the modes this AFU supports. One per line.@@ -58,7 +57,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/mode -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read/write The current mode the AFU is using. Will be one of the modes@@ -68,7 +67,7 @@ Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/prefault_mode -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read/write Set the mode for prefaulting in segments into the segment table@@ -88,7 +87,7 @@ Description: read/write Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/reset -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: write only Writing 1 here will reset the AFU provided there are not@@ -96,14 +95,14 @@ Description: write only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/api_version -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Decimal value of the current version of the kernel/user API. Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/api_version_compatible -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Decimal value of the lowest version of the userspace API@@ -117,7 +116,7 @@ An AFU may optionally export one or more PCIe like configuration records, known as AFU configuration records, which will show up here (if present). What: /sys/class/cxl/<afu>/cr<config num>/vendor -Date: February 2015 +Date: February 2015, removed February 2025 Contact: [email protected] Description: read only Hexadecimal value of the vendor ID found in this AFU@@ -125,7 +124,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/cr<config num>/device -Date: February 2015 +Date: February 2015, removed February 2025 Contact: [email protected] Description: read only Hexadecimal value of the device ID found in this AFU@@ -133,7 +132,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/cr<config num>/class -Date: February 2015 +Date: February 2015, removed February 2025 Contact: [email protected] Description: read only Hexadecimal value of the class code found in this AFU@@ -141,7 +140,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>/cr<config num>/config -Date: February 2015 +Date: February 2015, removed February 2025 Contact: [email protected] Description: read only This binary file provides raw access to the AFU configuration@@ -155,7 +154,7 @@ Users: https://github.com/ibm-capi/libcxl Master contexts (eg. /sys/class/cxl/afu0.0m) What: /sys/class/cxl/<afu>m/mmio_size -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Decimal value of the size of the MMIO space that may be mmapped@@ -163,14 +162,14 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>m/pp_mmio_len -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Decimal value of the Per Process MMIO space length. Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<afu>m/pp_mmio_off -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only (not in a guest)@@ -181,21 +180,21 @@ Users: https://github.com/ibm-capi/libcxl Card info (eg. /sys/class/cxl/card0) What: /sys/class/cxl/<card>/caia_version -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Identifies the CAIA Version the card implements. Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/psl_revision -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only Identifies the revision level of the PSL. Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/base_image -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only (not in a guest)@@ -206,7 +205,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/image_loaded -Date: September 2014 +Date: September 2014, removed February 2025 Contact: [email protected] Description: read only (not in a guest)@@ -215,7 +214,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/load_image_on_perst -Date: December 2014 +Date: December 2014, removed February 2025 Contact: [email protected] Description: read/write (not in a guest)@@ -232,7 +231,7 @@ Description: read/write Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/reset -Date: October 2014 +Date: October 2014, removed February 2025 Contact: [email protected] Description: write only Writing 1 will issue a PERST to card provided there are no@@ -243,7 +242,7 @@ Description: write only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/perst_reloads_same_image -Date: July 2015 +Date: July 2015, removed February 2025 Contact: [email protected] Description: read/write (not in a guest)@@ -257,7 +256,7 @@ Description: read/write Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/psl_timebase_synced -Date: March 2016 +Date: March 2016, removed February 2025 Contact: [email protected] Description: read only Returns 1 if the psl timebase register is synchronized@@ -265,7 +264,7 @@ Description: read only Users: https://github.com/ibm-capi/libcxl What: /sys/class/cxl/<card>/tunneled_ops_supported -Date: May 2018 +Date: May 2018, removed February 2025 Contact: [email protected] Description: read only Returns 1 if tunneled operations are supported in capi mode,Documentation/arch/powerpc/cxl.rst deleted +0
-470@@ -1,470 +0,0 @@ -==================================== -Coherent Accelerator Interface (CXL) -==================================== - -Introduction -============ - - The coherent accelerator interface is designed to allow the - coherent connection of accelerators (FPGAs and other devices) to a - POWER system. These devices need to adhere to the Coherent - Accelerator Interface Architecture (CAIA). - - IBM refers to this as the Coherent Accelerator Processor Interface - or CAPI. In the kernel it's referred to by the name CXL to avoid - confusion with the ISDN CAPI subsystem. - - Coherent in this context means that the accelerator and CPUs can - both access system memory directly and with the same effective - addresses. - - **This driver is deprecated and will be removed in a future release.** - -Hardware overview -================= - - :: - - POWER8/9 FPGA - +----------+ +---------+ - | | | | - | CPU | | AFU | - | | | | - | | | | - | | | | - +----------+ +---------+ - | PHB | | | - | +------+ | PSL | - | | CAPP |<------>| | - +---+------+ PCIE +---------+ - - The POWER8/9 chip has a Coherently Attached Processor Proxy (CAPP) - unit which is part of the PCIe Host Bridge (PHB). This is managed - by Linux by calls into OPAL. Linux doesn't directly program the - CAPP. - - The FPGA (or coherently attached device) consists of two parts. - The POWER Service Layer (PSL) and the Accelerator Function Unit - (AFU). The AFU is used to implement specific functionality behind - the PSL. The PSL, among other things, provides memory address - translation services to allow each AFU direct access to userspace - memory. - - The AFU is the core part of the accelerator (eg. the compression, - crypto etc function). The kernel has no knowledge of the function - of the AFU. Only userspace interacts directly with the AFU. - - The PSL provides the translation and interrupt services that the - AFU needs. This is what the kernel interacts with. For example, if - the AFU needs to read a particular effective address, it sends - that address to the PSL, the PSL then translates it, fetches the - data from memory and returns it to the AFU. If the PSL has a - translation miss, it interrupts the kernel and the kernel services - the fault. The context to which this fault is serviced is based on - who owns that acceleration function. - - - POWER8 and PSL Version 8 are compliant to the CAIA Version 1.0. - - POWER9 and PSL Version 9 are compliant to the CAIA Version 2.0. - - This PSL Version 9 provides new features such as: - - * Interaction with the nest MMU on the P9 chip. - * Native DMA support. - * Supports sending ASB_Notify messages for host thread wakeup. - * Supports Atomic operations. - * etc. - - Cards with a PSL9 won't work on a POWER8 system and cards with a - PSL8 won't work on a POWER9 system. - -AFU Modes -========= - - There are two programming modes supported by the AFU. Dedicated - and AFU directed. AFU may support one or both modes. - - When using dedicated mode only one MMU context is supported. In - this mode, only one userspace process can use the accelerator at - time. - - When using AFU directed mode, up to 16K simultaneous contexts can - be supported. This means up to 16K simultaneous userspace - applications may use the accelerator (although specific AFUs may - support fewer). In this mode, the AFU sends a 16 bit context ID - with each of its requests. This tells the PSL which context is - associated with each operation. If the PSL can't translate an - operation, the ID can also be accessed by the kernel so it can - determine the userspace context associated with an operation. - - -MMIO space -========== - - A portion of the accelerator MMIO space can be directly mapped - from the AFU to userspace. Either the whole space can be mapped or - just a per context portion. The hardware is self describing, hence - the kernel can determine the offset and size of the per context - portion. - - -Interrupts -========== - - AFUs may generate interrupts that are destined for userspace. These - are received by the kernel as hardware interrupts and passed onto - userspace by a read syscall documented below. - - Data storage faults and error interrupts are handled by the kernel - driver. - - -Work Element Descriptor (WED) -============================= - - The WED is a 64-bit parameter passed to the AFU when a context is - started. Its format is up to the AFU hence the kernel has no - knowledge of what it represents. Typically it will be the - effective address of a work queue or status block where the AFU - and userspace can share control and status information. - - - - -User API -======== - -1. AFU character devices -^^^^^^^^^^^^^^^^^^^^^^^^ - - For AFUs operating in AFU directed mode, two character device - files will be created. /dev/cxl/afu0.0m will correspond to a - master context and /dev/cxl/afu0.0s will correspond to a slave - context. Master contexts have access to the full MMIO space an - AFU provides. Slave contexts have access to only the per process - MMIO space an AFU provides. - - For AFUs operating in dedicated process mode, the driver will - only create a single character device per AFU called - /dev/cxl/afu0.0d. This will have access to the entire MMIO space - that the AFU provides (like master contexts in AFU directed). - - The types described below are defined in include/uapi/misc/cxl.h - - The following file operations are supported on both slave and - master devices. - - A userspace library libcxl is available here: - - https://github.com/ibm-capi/libcxl - - This provides a C interface to this kernel API. - -open ----- - - Opens the device and allocates a file descriptor to be used with - the rest of the API. - - A dedicated mode AFU only has one context and only allows the - device to be opened once. - - An AFU directed mode AFU can have many contexts, the device can be - opened once for each context that is available. - - When all available contexts are allocated the open call will fail - and return -ENOSPC. - - Note: - IRQs need to be allocated for each context, which may limit - the number of contexts that can be created, and therefore - how many times the device can be opened. The POWER8 CAPP - supports 2040 IRQs and 3 are used by the kernel, so 2037 are - left. If 1 IRQ is needed per context, then only 2037 - contexts can be allocated. If 4 IRQs are needed per context, - then only 2037/4 = 509 contexts can be allocated. - - -ioctl ------ - - CXL_IOCTL_START_WORK: - Starts the AFU context and associates it with the current - process. Once this ioctl is successfully executed, all memory - mapped into this process is accessible to this AFU context - using the same effective addresses. No additional calls are - required to map/unmap memory. The AFU memory context will be - updated as userspace allocates and frees memory. This ioctl - returns once the AFU context is started. - - Takes a pointer to a struct cxl_ioctl_start_work - - :: - - struct cxl_ioctl_start_work { - __u64 flags; - __u64 work_element_descriptor; - __u64 amr; - __s16 num_interrupts; - __s16 reserved1; - __s32 reserved2; - __u64 reserved3; - __u64 reserved4; - __u64 reserved5; - __u64 reserved6; - }; - - flags: - Indicates which optional fields in the structure are - valid. - - work_element_descriptor: - The Work Element Descriptor (WED) is a 64-bit argument - defined by the AFU. Typically this is an effective - address pointing to an AFU specific structure - describing what work to perform. - - amr: - Authority Mask Register (AMR), same as the powerpc - AMR. This field is only used by the kernel when the - corresponding CXL_START_WORK_AMR value is specified in - flags. If not specified the kernel will use a default - value of 0. - - num_interrupts: - Number of userspace interrupts to request. This field - is only used by the kernel when the corresponding - CXL_START_WORK_NUM_IRQS value is specified in flags. - If not specified the minimum number required by the - AFU will be allocated. The min and max number can be - obtained from sysfs. - - reserved fields: - For ABI padding and future extensions - - CXL_IOCTL_GET_PROCESS_ELEMENT: - Get the current context id, also known as the process element. - The value is returned from the kernel as a __u32. - - -mmap ----- - - An AFU may have an MMIO space to facilitate communication with the - AFU. If it does, the MMIO space can be accessed via mmap. The size - and contents of this area are specific to the particular AFU. The - size can be discovered via sysfs. - - In AFU directed mode, master contexts are allowed to map all of - the MMIO space and slave contexts are allowed to only map the per - process MMIO space associated with the context. In dedicated - process mode the entire MMIO space can always be mapped. - - This mmap call must be done after the START_WORK ioctl. - - Care should be taken when accessing MMIO space. Only 32 and 64-bit - accesses are supported by POWER8. Also, the AFU will be designed - with a specific endianness, so all MMIO accesses should consider - endianness (recommend endian(3) variants like: le64toh(), - be64toh() etc). These endian issues equally apply to shared memory - queues the WED may describe. - - -read ----- - - Reads events from the AFU. Blocks if no events are pending - (unless O_NONBLOCK is supplied). Returns -EIO in the case of an - unrecoverable error or if the card is removed. - - read() will always return an integral number of events. - - The buffer passed to read() must be at least 4K bytes. - - The result of the read will be a buffer of one or more events, - each event is of type struct cxl_event, of varying size:: - - struct cxl_event { - struct cxl_event_header header; - union { - struct cxl_event_afu_interrupt irq; - struct cxl_event_data_storage fault; - struct cxl_event_afu_error afu_error; - }; - }; - - The struct cxl_event_header is defined as - - :: - - struct cxl_event_header { - __u16 type; - __u16 size; - __u16 process_element; - __u16 reserved1; - }; - - type: - This defines the type of event. The type determines how - the rest of the event is structured. These types are - described below and defined by enum cxl_event_type. - - size: - This is the size of the event in bytes including the - struct cxl_event_header. The start of the next event can - be found at this offset from the start of the current - event. - - process_element: - Context ID of the event. - - reserved field: - For future extensions and padding. - - If the event type is CXL_EVENT_AFU_INTERRUPT then the event - structure is defined as - - :: - - struct cxl_event_afu_interrupt { - __u16 flags; - __u16 irq; /* Raised AFU interrupt number */ - __u32 reserved1; - }; - - flags: - These flags indicate which optional fields are present - in this struct. Currently all fields are mandatory. - - irq: - The IRQ number sent by the AFU. - - reserved field: - For future extensions and padding. - - If the event type is CXL_EVENT_DATA_STORAGE then the event - structure is defined as - - :: - - struct cxl_event_data_storage { - __u16 flags; - __u16 reserved1; - __u32 reserved2; - __u64 addr; - __u64 dsisr; - __u64 reserved3; - }; - - flags: - These flags indicate which optional fields are present in - this struct. Currently all fields are mandatory. - - address: - The address that the AFU unsuccessfully attempted to - access. Valid accesses will be handled transparently by the - kernel but invalid accesses will generate this event. - - dsisr: - This field gives information on the type of fault. It is a - copy of the DSISR from the PSL hardware when the address - fault occurred. The form of the DSISR is as defined in the - CAIA. - - reserved fields: - For future extensions - - If the event type is CXL_EVENT_AFU_ERROR then the event structure - is defined as - - :: - - struct cxl_event_afu_error { - __u16 flags; - __u16 reserved1; - __u32 reserved2; - __u64 error; - }; - - flags: - These flags indicate which optional fields are present in - this struct. Currently all fields are Mandatory. - - error: - Error status from the AFU. Defined by the AFU. - - reserved fields: - For future extensions and padding - - -2. Card character device (powerVM guest only) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - - In a powerVM guest, an extra character device is created for the - card. The device is only used to write (flash) a new image on the - FPGA accelerator. Once the image is written and verified, the - device tree is updated and the card is reset to reload the updated - image. - -open ----- - - Opens the device and allocates a file descriptor to be used with - the rest of the API. The device can only be opened once. - -ioctl ------ - -CXL_IOCTL_DOWNLOAD_IMAGE / CXL_IOCTL_VALIDATE_IMAGE: - Starts and controls flashing a new FPGA image. Partial - reconfiguration is not supported (yet), so the image must contain - a copy of the PSL and AFU(s). Since an image can be quite large, - the caller may have to iterate, splitting the image in smaller - chunks. - - Takes a pointer to a struct cxl_adapter_image:: - - struct cxl_adapter_image { - __u64 flags; - __u64 data; - __u64 len_data; - __u64 len_image; - __u64 reserved1; - __u64 reserved2; - __u64 reserved3; - __u64 reserved4; - }; - - flags: - These flags indicate which optional fields are present in - this struct. Currently all fields are mandatory. - - data: - Pointer to a buffer with part of the image to write to the - card. - - len_data: - Size of the buffer pointed to by data. - - len_image: - Full size of the image. - - -Sysfs Class -=========== - - A cxl sysfs class is added under /sys/class/cxl to facilitate - enumeration and tuning of the accelerators. Its layout is - described in Documentation/ABI/obsolete/sysfs-class-cxl - - -Udev rules -========== - - The following udev rules could be used to create a symlink to the - most logical chardev to use in any programming mode (afuX.Yd for - dedicated, afuX.Ys for afu directed), since the API is virtually - identical for each:: - - SUBSYSTEM=="cxl", ATTRS{mode}=="dedicated_process", SYMLINK="cxl/%b" - SUBSYSTEM=="cxl", ATTRS{mode}=="afu_directed", \ - KERNEL=="afu[0-9]*.[0-9]*s", SYMLINK="cxl/%b"Documentation/arch/powerpc/index.rst +0
-1@@ -12,7 +12,6 @@ powerpc bootwrapper cpu_families cpu_features - cxl dawr-power9 dexcr dscrDocumentation/userspace-api/ioctl/ioctl-number.rst +1
-1@@ -373,7 +373,7 @@ Code Seq# Include File Comments 0xB7 all uapi/linux/nsfs.h <mailto:Andrei Vagin <[email protected]>> 0xB8 01-02 uapi/misc/mrvl_cn10k_dpi.h Marvell CN10K DPI driver 0xC0 00-0F linux/usb/iowarrior.h -0xCA 00-0F uapi/misc/cxl.h +0xCA 00-0F uapi/misc/cxl.h Dead since 6.14 0xCA 10-2F uapi/misc/ocxl.h 0xCA 80-BF uapi/scsi/cxlflash_ioctl.h Dead since 6.14 0xCB 00-1F CBM serial IEC bus in development:MAINTAINERS +0
-12@@ -6316,18 +6316,6 @@ S: Maintained W: http://www.chelsio.com F: drivers/net/ethernet/chelsio/cxgb4vf/ -CXL (IBM Coherent Accelerator Processor Interface CAPI) DRIVER -M: Frederic Barrat <[email protected]> -M: Andrew Donnellan <[email protected]> -L: [email protected] -S: Obsolete -F: Documentation/ABI/obsolete/sysfs-class-cxl -F: Documentation/arch/powerpc/cxl.rst -F: arch/powerpc/platforms/powernv/pci-cxl.c -F: drivers/misc/cxl/ -F: include/misc/cxl* -F: include/uapi/misc/cxl.h - CYBERPRO FB DRIVER M: Russell King <[email protected]> L: [email protected] (moderated for non-subscribers)arch/powerpc/configs/skiroot_defconfig +0
-1@@ -78,7 +78,6 @@ CONFIG_VIRTIO_BLK=m CONFIG_BLK_DEV_NVME=m CONFIG_NVME_MULTIPATH=y CONFIG_EEPROM_AT24=m -# CONFIG_CXL is not set # CONFIG_OCXL is not set CONFIG_BLK_DEV_SD=m CONFIG_BLK_DEV_SR=march/powerpc/include/asm/copro.h +0
-6@@ -18,10 +18,4 @@ int copro_handle_mm_fault(struct mm_struct *mm, unsigned long ea,int copro_calculate_slb (struct mm_struct *mm,u64 ea,struct copro_slb *slb); - -#ifdef CONFIG_PPC_COPRO_BASE -void copro_flush_all_slbs (struct mm_struct *mm); -#else -static inline void copro_flush_all_slbs (struct mm_struct *mm) {} -#endif #endif /* _ASM_POWERPC_COPRO_H */ arch/powerpc/include/asm/device.h +0
-3@@ -38,9 +38,6 @@ struct dev_archdata {#ifdef CONFIG_FAIL_IOMMU int fail_iommu;#endif -#ifdef CONFIG_CXL_BASE -struct cxl_context *cxl_ctx; -#endif #ifdef CONFIG_PCI_IOV void *iov_data;#endif arch/powerpc/include/asm/pnv-pci.h +0
-17@@ -10,7 +10,6 @@#include <linux/pci_hotplug.h> #include <linux/irq.h> #include <linux/of.h> -#include <misc/cxl-base.h> #include <asm/opal-api.h> #define PCI_SLOT_ID_PREFIX (1UL << 63)@@ -25,25 +24,9 @@ extern int pnv_pci_get_power_state(uint64_t id, uint8_t *state);extern int pnv_pci_set_power_state (uint64_t id,uint8_t state,struct opal_msg *msg); -extern int pnv_pci_set_tunnel_bar (struct pci_dev *dev,uint64_t addr, -int enable); -int pnv_phb_to_cxl_mode (struct pci_dev *dev,uint64_t mode); -int pnv_cxl_ioda_msi_setup (struct pci_dev *dev,unsigned int hwirq, -unsigned int virq); -int pnv_cxl_alloc_hwirqs (struct pci_dev *dev,int num); -void pnv_cxl_release_hwirqs (struct pci_dev *dev,int hwirq,int num); -int pnv_cxl_get_irq_count (struct pci_dev *dev); -struct device_node *pnv_pci_get_phb_node (struct pci_dev *dev);int64_t pnv_opal_pci_msi_eoi (struct irq_data *d);bool is_pnv_opal_msi (struct irq_chip *chip); -#ifdef CONFIG_CXL_BASE -int pnv_cxl_alloc_hwirq_ranges (struct cxl_irq_ranges *irqs, -struct pci_dev *dev,int num); -void pnv_cxl_release_hwirq_ranges (struct cxl_irq_ranges *irqs, -struct pci_dev *dev); -#endif -struct pnv_php_slot {struct hotplug_slot slot;uint64_t id;arch/powerpc/mm/book3s64/hash_native.c +3
-10@@ -27,8 +27,6 @@#include <asm/ppc-opcode.h> #include <asm/feature-fixups.h> -#include <misc/cxl-base.h> -#ifdef DEBUG_LOW #define DBG_LOW(fmt...) udbg_printf(fmt)#else @@ -217,11 +215,9 @@ static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int ssize)static inline void tlbie (unsigned long vpn,int psize,int apsize,int ssize,int local) { -unsigned int use_local; +unsigned int use_local = local &&mmu_has_feature (MMU_FTR_TLBIEL );int lock_tlbie = !mmu_has_feature (MMU_FTR_LOCKLESS_TLBIE ); - use_local = local &&mmu_has_feature (MMU_FTR_TLBIEL ) && !cxl_ctx_in_use (); -if (use_local) use_local = mmu_psize_defs[psize].tlbiel;if (lock_tlbie && !use_local)@@ -789,10 +785,6 @@ static void native_flush_hash_range(unsigned long number, int local)unsigned long psize = batch->psize;int ssize = batch->ssize;int i; -unsigned int use_local; - - use_local = local &&mmu_has_feature (MMU_FTR_TLBIEL ) && - mmu_psize_defs[psize].tlbiel && !cxl_ctx_in_use ();local_irq_save (flags);@@ -827,7 +819,8 @@ static void native_flush_hash_range(unsigned long number, int local) }pte_iterate_hashed_end (); } -if (use_local) { +if (mmu_has_feature (MMU_FTR_TLBIEL ) && + mmu_psize_defs[psize].tlbiel && local) { asmvolatile ("ptesync" :::"memory" );for (i =0 ; i < number; i++) { vpn = batch->vpn[i];arch/powerpc/mm/book3s64/hash_utils.c +7
-3@@ -56,7 +56,7 @@#include <asm/cacheflush.h> #include <asm/cputable.h> #include <asm/sections.h> -#include <asm/copro.h> +#include <asm/spu.h> #include <asm/udbg.h> #include <asm/text-patching.h> #include <asm/fadump.h> @@ -1612,7 +1612,9 @@ void demote_segment_4k(struct mm_struct *mm, unsigned long addr)if (get_slice_psize (mm, addr) ==MMU_PAGE_4K )return ;slice_set_range_psize (mm, addr,1 ,MMU_PAGE_4K ); -copro_flush_all_slbs (mm); +#ifdef CONFIG_SPU_BASE +spu_flush_all_slbs (mm); +#endif if ((get_paca_psize (addr) !=MMU_PAGE_4K ) && (current->mm == mm)) {copy_mm_to_paca (mm);@@ -1881,7 +1883,9 @@ int hash_page_mm(struct mm_struct *mm, unsigned long ea,"to 4kB pages because of " "non-cacheable mapping\n"); psize = mmu_vmalloc_psize =MMU_PAGE_4K ; -copro_flush_all_slbs (mm); +#ifdef CONFIG_SPU_BASE +spu_flush_all_slbs (mm); +#endif } }arch/powerpc/mm/book3s64/pgtable.c +0
-1@@ -10,7 +10,6 @@#include <linux/pkeys.h> #include <linux/debugfs.h> #include <linux/proc_fs.h> -#include <misc/cxl-base.h> #include <asm/pgalloc.h> #include <asm/tlb.h> arch/powerpc/mm/book3s64/slice.c +4
-2@@ -22,7 +22,7 @@#include <linux/security.h> #include <asm/mman.h> #include <asm/mmu.h> -#include <asm/copro.h> +#include <asm/spu.h> #include <asm/hugetlb.h> #include <asm/mmu_context.h> @@ -248,7 +248,9 @@ static void slice_convert(struct mm_struct *mm,spin_unlock_irqrestore (&slice_convert_lock, flags); -copro_flush_all_slbs (mm); +#ifdef CONFIG_SPU_BASE +spu_flush_all_slbs (mm); +#endif }/* arch/powerpc/mm/copro_fault.c +0
-12@@ -12,8 +12,6 @@#include <linux/export.h> #include <asm/reg.h> #include <asm/copro.h> -#include <asm/spu.h> -#include <misc/cxl-base.h> /* * This ought to be kept in sync with the powerpc specific do_page_fault @@ -135,13 +133,3 @@ int copro_calculate_slb(struct mm_struct *mm, u64 ea, struct copro_slb *slb)return 0 ; }EXPORT_SYMBOL_GPL (copro_calculate_slb); - -void copro_flush_all_slbs (struct mm_struct *mm) -{ -#ifdef CONFIG_SPU_BASE -spu_flush_all_slbs (mm); -#endif -cxl_slbia (mm); -} -EXPORT_SYMBOL_GPL (copro_flush_all_slbs); -#endif arch/powerpc/platforms/powernv/Makefile +0
-1@@ -21,7 +21,6 @@ obj-$(CONFIG_PRESERVE_FA_DUMP) += opal-fadump.o obj-$(CONFIG_OPAL_CORE) += opal-core.o obj-$(CONFIG_PCI) += pci.o pci-ioda.o pci-ioda-tce.o obj-$(CONFIG_PCI_IOV) += pci-sriov.o -obj-$(CONFIG_CXL_BASE) += pci-cxl.o obj-$(CONFIG_EEH) += eeh-powernv.o obj-$(CONFIG_MEMORY_FAILURE) += opal-memory-errors.o obj-$(CONFIG_OPAL_PRD) += opal-prd.oarch/powerpc/platforms/powernv/pci-cxl.c deleted +0
-153@@ -1,153 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* -* Copyright 2014-2016 IBM Corp. -*/ - -#include <linux/module.h> -#include <misc/cxl-base.h> -#include <asm/pnv-pci.h> -#include <asm/opal.h> - -#include "pci.h" - -int pnv_phb_to_cxl_mode (struct pci_dev *dev,uint64_t mode) -{ -struct pci_controller *hose =pci_bus_to_host (dev->bus); -struct pnv_phb *phb = hose->private_data; -struct pnv_ioda_pe *pe; -int rc; - - pe =pnv_ioda_get_pe (dev); -if (!pe) -return -ENODEV ; - -pe_info (pe,"Switching PHB to CXL\n" ); - - rc =opal_pci_set_phb_cxl_mode (phb->opal_id, mode, pe->pe_number); -if (rc ==OPAL_UNSUPPORTED ) -dev_err (&dev->dev,"Required cxl mode not supported by firmware - update skiboot\n" ); -else if (rc) -dev_err (&dev->dev,"opal_pci_set_phb_cxl_mode failed: %i\n" , rc); - -return rc; -} -EXPORT_SYMBOL (pnv_phb_to_cxl_mode); - -/* Find PHB for cxl dev and allocate MSI hwirqs? -* Returns the absolute hardware IRQ number -*/ -int pnv_cxl_alloc_hwirqs (struct pci_dev *dev,int num) -{ -struct pci_controller *hose =pci_bus_to_host (dev->bus); -struct pnv_phb *phb = hose->private_data; -int hwirq =msi_bitmap_alloc_hwirqs (&phb->msi_bmp, num); - -if (hwirq <0 ) { -dev_warn (&dev->dev,"Failed to find a free MSI\n" ); -return -ENOSPC ; - } - -return phb->msi_base + hwirq; -} -EXPORT_SYMBOL (pnv_cxl_alloc_hwirqs); - -void pnv_cxl_release_hwirqs (struct pci_dev *dev,int hwirq,int num) -{ -struct pci_controller *hose =pci_bus_to_host (dev->bus); -struct pnv_phb *phb = hose->private_data; - -msi_bitmap_free_hwirqs (&phb->msi_bmp, hwirq - phb->msi_base, num); -} -EXPORT_SYMBOL (pnv_cxl_release_hwirqs); - -void pnv_cxl_release_hwirq_ranges (struct cxl_irq_ranges *irqs, -struct pci_dev *dev) -{ -struct pci_controller *hose =pci_bus_to_host (dev->bus); -struct pnv_phb *phb = hose->private_data; -int i, hwirq; - -for (i =1 ; i <CXL_IRQ_RANGES ; i++) { -if (!irqs->range[i]) -continue ; -pr_devel ("cxl release irq range 0x%x: offset: 0x%lx limit: %ld\n" , - i, irqs->offset[i], - irqs->range[i]); - hwirq = irqs->offset[i] - phb->msi_base; -msi_bitmap_free_hwirqs (&phb->msi_bmp, hwirq, - irqs->range[i]); - } -} -EXPORT_SYMBOL (pnv_cxl_release_hwirq_ranges); - -int pnv_cxl_alloc_hwirq_ranges (struct cxl_irq_ranges *irqs, -struct pci_dev *dev,int num) -{ -struct pci_controller *hose =pci_bus_to_host (dev->bus); -struct pnv_phb *phb = hose->private_data; -int i, hwirq, try; - -memset (irqs,0 ,sizeof (struct cxl_irq_ranges )); - -/* 0 is reserved for the multiplexed PSL DSI interrupt */ -for (i =1 ; i <CXL_IRQ_RANGES && num; i++) { - try = num; -while (try) { - hwirq =msi_bitmap_alloc_hwirqs (&phb->msi_bmp, try); -if (hwirq >=0 ) -break ; - try /=2 ; - } -if (!try) - goto fail; - - irqs->offset[i] = phb->msi_base + hwirq; - irqs->range[i] = try; -pr_devel ("cxl alloc irq range 0x%x: offset: 0x%lx limit: %li\n" , - i, irqs->offset[i], irqs->range[i]); - num -= try; - } -if (num) - goto fail; - -return 0 ; -fail: -pnv_cxl_release_hwirq_ranges (irqs, dev); -return -ENOSPC ; -} -EXPORT_SYMBOL (pnv_cxl_alloc_hwirq_ranges); - -int pnv_cxl_get_irq_count (struct pci_dev *dev) -{ -struct pci_controller *hose =pci_bus_to_host (dev->bus); -struct pnv_phb *phb = hose->private_data; - -return phb->msi_bmp.irq_count; -} -EXPORT_SYMBOL (pnv_cxl_get_irq_count); - -int pnv_cxl_ioda_msi_setup (struct pci_dev *dev,unsigned int hwirq, -unsigned int virq) -{ -struct pci_controller *hose =pci_bus_to_host (dev->bus); -struct pnv_phb *phb = hose->private_data; -unsigned int xive_num = hwirq - phb->msi_base; -struct pnv_ioda_pe *pe; -int rc; - -if (!(pe =pnv_ioda_get_pe (dev))) -return -ENODEV ; - -/* Assign XIVE to PE */ - rc =opal_pci_set_xive_pe (phb->opal_id, pe->pe_number, xive_num); -if (rc) { -pe_warn (pe,"%s: OPAL error %d setting msi_base 0x%x " -"hwirq 0x%x XIVE 0x%x PE\n" , -pci_name (dev), rc, phb->msi_base, hwirq, xive_num); -return -EIO ; - } -pnv_set_msi_irq_chip (phb, virq); - -return 0 ; -} -EXPORT_SYMBOL (pnv_cxl_ioda_msi_setup);arch/powerpc/platforms/powernv/pci-ioda.c +0
-43@@ -39,8 +39,6 @@#include <asm/mmzone.h> #include <asm/xive.h> -#include <misc/cxl-base.h> -#include "powernv.h" #include "pci.h" #include "../../../../drivers/pci/pci.h" @@ -1636,47 +1634,6 @@ int64_t pnv_opal_pci_msi_eoi(struct irq_data *d)return opal_pci_msi_eoi (phb->opal_id, d->parent_data->hwirq); } -/* -* The IRQ data is mapped in the XICS domain, with OPAL HW IRQ numbers -*/ -static void pnv_ioda2_msi_eoi (struct irq_data *d) -{ -int64_t rc; -unsigned int hw_irq = (unsigned int )irqd_to_hwirq (d); -struct pci_controller *hose =irq_data_get_irq_chip_data (d); -struct pnv_phb *phb = hose->private_data; - - rc =opal_pci_msi_eoi (phb->opal_id, hw_irq); -WARN_ON_ONCE (rc); - -icp_native_eoi (d); -} - -/* P8/CXL only */ -void pnv_set_msi_irq_chip (struct pnv_phb *phb,unsigned int virq) -{ -struct irq_data *idata; -struct irq_chip *ichip; - -/* The MSI EOI OPAL call is only needed on PHB3 */ -if (phb->model !=PNV_PHB_MODEL_PHB3 ) -return ; - -if (!phb->ioda.irq_chip_init) { -/* -* First time we setup an MSI IRQ, we need to setup the -* corresponding IRQ chip to route correctly. -*/ - idata =irq_get_irq_data (virq); - ichip =irq_data_get_irq_chip (idata); - phb->ioda.irq_chip_init =1 ; - phb->ioda.irq_chip = *ichip; - phb->ioda.irq_chip.irq_eoi = pnv_ioda2_msi_eoi; - } -irq_set_chip (virq, &phb->ioda.irq_chip); -irq_set_chip_data (virq, phb->hose); -} -static struct irq_chip pnv_pci_msi_irq_chip;/* arch/powerpc/platforms/powernv/pci.c +0
-61@@ -14,7 +14,6 @@#include <linux/io.h> #include <linux/msi.h> #include <linux/iommu.h> -#include <linux/sched/mm.h> #include <asm/sections.h> #include <asm/io.h> @@ -33,8 +32,6 @@#include "powernv.h" #include "pci.h" -static DEFINE_MUTEX (tunnel_mutex); -int pnv_pci_get_slot_id (struct device_node *np,uint64_t *id) {struct device_node *node = np;@@ -744,64 +741,6 @@ struct iommu_table *pnv_pci_table_alloc(int nid)return tbl; } -struct device_node *pnv_pci_get_phb_node (struct pci_dev *dev) -{ -struct pci_controller *hose =pci_bus_to_host (dev->bus); - -return of_node_get (hose->dn); -} -EXPORT_SYMBOL (pnv_pci_get_phb_node); - -int pnv_pci_set_tunnel_bar (struct pci_dev *dev,u64 addr,int enable) -{ -struct pnv_phb *phb =pci_bus_to_pnvhb (dev->bus); -u64 tunnel_bar; -__be64 val; -int rc; - -if (!opal_check_token (OPAL_PCI_GET_PBCQ_TUNNEL_BAR )) -return -ENXIO ; -if (!opal_check_token (OPAL_PCI_SET_PBCQ_TUNNEL_BAR )) -return -ENXIO ; - -mutex_lock (&tunnel_mutex); - rc =opal_pci_get_pbcq_tunnel_bar (phb->opal_id, &val); -if (rc !=OPAL_SUCCESS ) { - rc = -EIO ; - goto out; - } - tunnel_bar =be64_to_cpu (val); -if (enable) { -/* -* Only one device per PHB can use atomics. -* Our policy is first-come, first-served. -*/ -if (tunnel_bar) { -if (tunnel_bar != addr) - rc = -EBUSY ; -else - rc =0 ;/* Setting same address twice is ok */ - goto out; - } - }else { -/* -* The device that owns atomics and wants to release -* them must pass the same address with enable == 0. -*/ -if (tunnel_bar != addr) { - rc = -EPERM ; - goto out; - } - addr =0x0ULL ; - } - rc =opal_pci_set_pbcq_tunnel_bar (phb->opal_id, addr); - rc =opal_error_code (rc); -out: -mutex_unlock (&tunnel_mutex); -return rc; -} -EXPORT_SYMBOL_GPL (pnv_pci_set_tunnel_bar); -void pnv_pci_shutdown (void ) {struct pci_controller *hose;arch/powerpc/platforms/powernv/pci.h +0
-2@@ -163,7 +163,6 @@ struct pnv_phb {unsigned int *io_segmap;/* IRQ chip */ -int irq_chip_init;struct irq_chip irq_chip;/* Sorted list of used PE's based @@ -281,7 +280,6 @@ extern int pnv_eeh_phb_reset(struct pci_controller *hose, int option);extern struct pnv_ioda_pe *pnv_pci_bdfn_to_pe (struct pnv_phb *phb,u16 bdfn);extern struct pnv_ioda_pe *pnv_ioda_get_pe (struct pci_dev *dev); -extern void pnv_set_msi_irq_chip (struct pnv_phb *phb,unsigned int virq);extern unsigned long pnv_pci_ioda2_get_table_size (__u32 page_shift,__u64 window_size,__u32 levels);extern int pnv_eeh_post_init (void );drivers/misc/Kconfig +0
-1@@ -641,7 +641,6 @@ source "drivers/misc/mei/Kconfig" source "drivers/misc/vmw_vmci/Kconfig" source "drivers/misc/genwqe/Kconfig" source "drivers/misc/echo/Kconfig" -source "drivers/misc/cxl/Kconfig" source "drivers/misc/ocxl/Kconfig" source "drivers/misc/bcm-vk/Kconfig" source "drivers/misc/cardreader/Kconfig"drivers/misc/Makefile +0
-1@@ -50,7 +50,6 @@ obj-$(CONFIG_SRAM) += sram.o obj-$(CONFIG_SRAM_EXEC) += sram-exec.o obj-$(CONFIG_GENWQE) += genwqe/ obj-$(CONFIG_ECHO) += echo/ -obj-$(CONFIG_CXL_BASE) += cxl/ obj-$(CONFIG_DW_XDATA_PCIE) += dw-xdata-pcie.o obj-$(CONFIG_PCI_ENDPOINT_TEST) += pci_endpoint_test.o obj-$(CONFIG_OCXL) += ocxl/drivers/misc/cxl/Kconfig deleted +0
-28@@ -1,28 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# -# IBM Coherent Accelerator (CXL) compatible devices -# - -config CXL_BASE - bool - select PPC_COPRO_BASE - select PPC_64S_HASH_MMU - -config CXL - tristate "Support for IBM Coherent Accelerators (CXL) (DEPRECATED)" - depends on PPC_POWERNV && PCI_MSI && EEH - select CXL_BASE - help - The cxl driver is deprecated and will be removed in a future - kernel release. - - Select this option to enable driver support for IBM Coherent - Accelerators (CXL). CXL is otherwise known as Coherent Accelerator - Processor Interface (CAPI). CAPI allows accelerators in FPGAs to be - coherently attached to a CPU via an MMU. This driver enables - userspace programs to access these accelerators via /dev/cxl/afuM.N - devices. - - CAPI adapters are found in POWER8 based systems. - - If unsure, say N.drivers/misc/cxl/Makefile deleted +0
-14@@ -1,14 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0 -ccflags-y := $(call cc-disable-warning, unused-const-variable) -ccflags-$(CONFIG_PPC_WERROR) += -Werror - -cxl-y += main.o file.o irq.o fault.o native.o -cxl-y += context.o sysfs.o pci.o trace.o -cxl-y += vphb.o api.o cxllib.o -cxl-$(CONFIG_PPC_PSERIES) += flash.o guest.o of.o hcalls.o -cxl-$(CONFIG_DEBUG_FS) += debugfs.o -obj-$(CONFIG_CXL) += cxl.o -obj-$(CONFIG_CXL_BASE) += base.o - -# For tracepoints to include our trace.h from tracepoint infrastructure: -CFLAGS_trace.o := -I$(src)drivers/misc/cxl/api.c deleted +0
-532@@ -1,532 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* -* Copyright 2014 IBM Corp. -*/ - -#include <linux/pci.h> -#include <linux/slab.h> -#include <linux/file.h> -#include <misc/cxl.h> -#include <linux/module.h> -#include <linux/mount.h> -#include <linux/pseudo_fs.h> -#include <linux/sched/mm.h> -#include <linux/mmu_context.h> -#include <linux/irqdomain.h> - -#include "cxl.h" - -/* -* Since we want to track memory mappings to be able to force-unmap -* when the AFU is no longer reachable, we need an inode. For devices -* opened through the cxl user API, this is not a problem, but a -* userland process can also get a cxl fd through the cxl_get_fd() -* API, which is used by the cxlflash driver. -* -* Therefore we implement our own simple pseudo-filesystem and inode -* allocator. We don't use the anonymous inode, as we need the -* meta-data associated with it (address_space) and it is shared by -* other drivers/processes, so it could lead to cxl unmapping VMAs -* from random processes. -*/ - -#define CXL_PSEUDO_FS_MAGIC 0x1697697f - -static int cxl_fs_cnt; -static struct vfsmount *cxl_vfs_mount; - -static int cxl_fs_init_fs_context (struct fs_context *fc) -{ -return init_pseudo (fc,CXL_PSEUDO_FS_MAGIC ) ?0 : -ENOMEM ; -} - -static struct file_system_type cxl_fs_type = { - .name ="cxl" , - .owner =THIS_MODULE , - .init_fs_context = cxl_fs_init_fs_context, - .kill_sb = kill_anon_super, -}; - - -void cxl_release_mapping (struct cxl_context *ctx) -{ -if (ctx->kernelapi && ctx->mapping) -simple_release_fs (&cxl_vfs_mount, &cxl_fs_cnt); -} - -static struct file *cxl_getfile (const char *name, -const struct file_operations *fops, -void *priv,int flags) -{ -struct file *file; -struct inode *inode; -int rc; - -/* strongly inspired by anon_inode_getfile() */ - -if (fops->owner && !try_module_get (fops->owner)) -return ERR_PTR (-ENOENT ); - - rc =simple_pin_fs (&cxl_fs_type, &cxl_vfs_mount, &cxl_fs_cnt); -if (rc <0 ) { -pr_err ("Cannot mount cxl pseudo filesystem: %d\n" , rc); - file =ERR_PTR (rc); - goto err_module; - } - - inode =alloc_anon_inode (cxl_vfs_mount->mnt_sb); -if (IS_ERR (inode)) { - file =ERR_CAST (inode); - goto err_fs; - } - - file =alloc_file_pseudo (inode, cxl_vfs_mount, name, - flags & (O_ACCMODE |O_NONBLOCK ), fops); -if (IS_ERR (file)) - goto err_inode; - - file->private_data = priv; - -return file; - -err_inode: -iput (inode); -err_fs: -simple_release_fs (&cxl_vfs_mount, &cxl_fs_cnt); -err_module: -module_put (fops->owner); -return file; -} - -struct cxl_context *cxl_dev_context_init (struct pci_dev *dev) -{ -struct cxl_afu *afu; -struct cxl_context *ctx; -int rc; - - afu =cxl_pci_to_afu (dev); -if (IS_ERR (afu)) -return ERR_CAST (afu); - - ctx =cxl_context_alloc (); -if (!ctx) -return ERR_PTR (-ENOMEM ); - - ctx->kernelapi = true; - -/* Make it a slave context. We can promote it later? */ - rc =cxl_context_init (ctx, afu, false); -if (rc) - goto err_ctx; - -return ctx; - -err_ctx: -kfree (ctx); -return ERR_PTR (rc); -} -EXPORT_SYMBOL_GPL (cxl_dev_context_init); - -struct cxl_context *cxl_get_context (struct pci_dev *dev) -{ -return dev->dev.archdata.cxl_ctx; -} -EXPORT_SYMBOL_GPL (cxl_get_context); - -int cxl_release_context (struct cxl_context *ctx) -{ -if (ctx->status >=STARTED ) -return -EBUSY ; - -cxl_context_free (ctx); - -return 0 ; -} -EXPORT_SYMBOL_GPL (cxl_release_context); - -static irq_hw_number_t cxl_find_afu_irq (struct cxl_context *ctx,int num) -{ -__u16 range; -int r; - -for (r =0 ; r <CXL_IRQ_RANGES ; r++) { - range = ctx->irqs.range[r]; -if (num < range) { -return ctx->irqs.offset[r] + num; - } - num -= range; - } -return 0 ; -} - - -int cxl_set_priv (struct cxl_context *ctx,void *priv) -{ -if (!ctx) -return -EINVAL ; - - ctx->priv = priv; - -return 0 ; -} -EXPORT_SYMBOL_GPL (cxl_set_priv); - -void *cxl_get_priv (struct cxl_context *ctx) -{ -if (!ctx) -return ERR_PTR (-EINVAL ); - -return ctx->priv; -} -EXPORT_SYMBOL_GPL (cxl_get_priv); - -int cxl_allocate_afu_irqs (struct cxl_context *ctx,int num) -{ -int res; -irq_hw_number_t hwirq; - -if (num ==0 ) - num = ctx->afu->pp_irqs; - res =afu_allocate_irqs (ctx, num); -if (res) -return res; - -if (!cpu_has_feature (CPU_FTR_HVMODE )) { -/* In a guest, the PSL interrupt is not multiplexed. It was -* allocated above, and we need to set its handler -*/ - hwirq =cxl_find_afu_irq (ctx,0 ); -if (hwirq) -cxl_map_irq (ctx->afu->adapter, hwirq, cxl_ops->psl_interrupt, ctx,"psl" ); - } - -if (ctx->status ==STARTED ) { -if (cxl_ops->update_ivtes) - cxl_ops->update_ivtes (ctx); -else WARN (1 ,"BUG: cxl_allocate_afu_irqs must be called prior to starting the context on this platform\n" ); - } - -return res; -} -EXPORT_SYMBOL_GPL (cxl_allocate_afu_irqs); - -void cxl_free_afu_irqs (struct cxl_context *ctx) -{ -irq_hw_number_t hwirq; -unsigned int virq; - -if (!cpu_has_feature (CPU_FTR_HVMODE )) { - hwirq =cxl_find_afu_irq (ctx,0 ); -if (hwirq) { - virq =irq_find_mapping (NULL , hwirq); -if (virq) -cxl_unmap_irq (virq, ctx); - } - } -afu_irq_name_free (ctx); - cxl_ops->release_irq_ranges (&ctx->irqs, ctx->afu->adapter); -} -EXPORT_SYMBOL_GPL (cxl_free_afu_irqs); - -int cxl_map_afu_irq (struct cxl_context *ctx,int num, -irq_handler_t handler,void *cookie,char *name) -{ -irq_hw_number_t hwirq; - -/* -* Find interrupt we are to register. -*/ - hwirq =cxl_find_afu_irq (ctx, num); -if (!hwirq) -return -ENOENT ; - -return cxl_map_irq (ctx->afu->adapter, hwirq, handler, cookie, name); -} -EXPORT_SYMBOL_GPL (cxl_map_afu_irq); - -void cxl_unmap_afu_irq (struct cxl_context *ctx,int num,void *cookie) -{ -irq_hw_number_t hwirq; -unsigned int virq; - - hwirq =cxl_find_afu_irq (ctx, num); -if (!hwirq) -return ; - - virq =irq_find_mapping (NULL , hwirq); -if (virq) -cxl_unmap_irq (virq, cookie); -} -EXPORT_SYMBOL_GPL (cxl_unmap_afu_irq); - -/* -* Start a context -* Code here similar to afu_ioctl_start_work(). -*/ -int cxl_start_context (struct cxl_context *ctx,u64 wed, -struct task_struct *task) -{ -int rc =0 ; -bool kernel = true; - -pr_devel ("%s: pe: %i\n" , __func__, ctx->pe); - -mutex_lock (&ctx->status_mutex); -if (ctx->status ==STARTED ) - goto out;/* already started */ - -/* -* Increment the mapped context count for adapter. This also checks -* if adapter_context_lock is taken. -*/ - rc =cxl_adapter_context_get (ctx->afu->adapter); -if (rc) - goto out; - -if (task) { - ctx->pid =get_task_pid (task,PIDTYPE_PID ); - kernel = false; - -/* acquire a reference to the task's mm */ - ctx->mm =get_task_mm (current); - -/* ensure this mm_struct can't be freed */ -cxl_context_mm_count_get (ctx); - -if (ctx->mm) { -/* decrement the use count from above */ -mmput (ctx->mm); -/* make TLBIs for this context global */ -mm_context_add_copro (ctx->mm); - } - } - -/* -* Increment driver use count. Enables global TLBIs for hash -* and callbacks to handle the segment table -*/ -cxl_ctx_get (); - -/* See the comment in afu_ioctl_start_work() */ -smp_mb (); - -if ((rc = cxl_ops->attach_process (ctx, kernel, wed,0 ))) { -put_pid (ctx->pid); - ctx->pid =NULL ; -cxl_adapter_context_put (ctx->afu->adapter); -cxl_ctx_put (); -if (task) { -cxl_context_mm_count_put (ctx); -if (ctx->mm) -mm_context_remove_copro (ctx->mm); - } - goto out; - } - - ctx->status =STARTED ; -out: -mutex_unlock (&ctx->status_mutex); -return rc; -} -EXPORT_SYMBOL_GPL (cxl_start_context); - -int cxl_process_element (struct cxl_context *ctx) -{ -return ctx->external_pe; -} -EXPORT_SYMBOL_GPL (cxl_process_element); - -/* Stop a context. Returns 0 on success, otherwise -Errno */ -int cxl_stop_context (struct cxl_context *ctx) -{ -return __detach_context (ctx); -} -EXPORT_SYMBOL_GPL (cxl_stop_context); - -void cxl_set_master (struct cxl_context *ctx) -{ - ctx->master = true; -} -EXPORT_SYMBOL_GPL (cxl_set_master); - -/* wrappers around afu_* file ops which are EXPORTED */ -int cxl_fd_open (struct inode *inode,struct file *file) -{ -return afu_open (inode, file); -} -EXPORT_SYMBOL_GPL (cxl_fd_open); -int cxl_fd_release (struct inode *inode,struct file *file) -{ -return afu_release (inode, file); -} -EXPORT_SYMBOL_GPL (cxl_fd_release); -long cxl_fd_ioctl (struct file *file,unsigned int cmd,unsigned long arg) -{ -return afu_ioctl (file, cmd, arg); -} -EXPORT_SYMBOL_GPL (cxl_fd_ioctl); -int cxl_fd_mmap (struct file *file,struct vm_area_struct *vm) -{ -return afu_mmap (file, vm); -} -EXPORT_SYMBOL_GPL (cxl_fd_mmap); -__poll_t cxl_fd_poll (struct file *file,struct poll_table_struct *poll) -{ -return afu_poll (file, poll); -} -EXPORT_SYMBOL_GPL (cxl_fd_poll); -ssize_t cxl_fd_read (struct file *file,char __user *buf,size_t count, -loff_t *off) -{ -return afu_read (file, buf, count, off); -} -EXPORT_SYMBOL_GPL (cxl_fd_read); - -#define PATCH_FOPS (NAME ) if (!fops->NAME) fops->NAME = afu_fops.NAME - -/* Get a struct file and fd for a context and attach the ops */ -struct file *cxl_get_fd (struct cxl_context *ctx,struct file_operations *fops, -int *fd) -{ -struct file *file; -int rc, flags, fdtmp; -char *name =NULL ; - -/* only allow one per context */ -if (ctx->mapping) -return ERR_PTR (-EEXIST ); - - flags =O_RDWR |O_CLOEXEC ; - -/* This code is similar to anon_inode_getfd() */ - rc =get_unused_fd_flags (flags); -if (rc <0 ) -return ERR_PTR (rc); - fdtmp = rc; - -/* -* Patch the file ops. Needs to be careful that this is rentrant safe. -*/ -if (fops) { -PATCH_FOPS (open); -PATCH_FOPS (poll); -PATCH_FOPS (read); -PATCH_FOPS (release); -PATCH_FOPS (unlocked_ioctl); -PATCH_FOPS (compat_ioctl); -PATCH_FOPS (mmap); - }else /* use default ops */ - fops = (struct file_operations *)&afu_fops; - - name =kasprintf (GFP_KERNEL ,"cxl:%d" , ctx->pe); - file =cxl_getfile (name, fops, ctx, flags); -kfree (name); -if (IS_ERR (file)) - goto err_fd; - -cxl_context_set_mapping (ctx, file->f_mapping); - *fd = fdtmp; -return file; - -err_fd: -put_unused_fd (fdtmp); -return NULL ; -} -EXPORT_SYMBOL_GPL (cxl_get_fd); - -struct cxl_context *cxl_fops_get_context (struct file *file) -{ -return file->private_data; -} -EXPORT_SYMBOL_GPL (cxl_fops_get_context); - -void cxl_set_driver_ops (struct cxl_context *ctx, -struct cxl_afu_driver_ops *ops) -{ -WARN_ON (!ops->fetch_event || !ops->event_delivered); -atomic_set (&ctx->afu_driver_events,0 ); - ctx->afu_driver_ops = ops; -} -EXPORT_SYMBOL_GPL (cxl_set_driver_ops); - -void cxl_context_events_pending (struct cxl_context *ctx, -unsigned int new_events) -{ -atomic_add (new_events, &ctx->afu_driver_events); -wake_up_all (&ctx->wq); -} -EXPORT_SYMBOL_GPL (cxl_context_events_pending); - -int cxl_start_work (struct cxl_context *ctx, -struct cxl_ioctl_start_work *work) -{ -int rc; - -/* code taken from afu_ioctl_start_work */ -if (!(work->flags &CXL_START_WORK_NUM_IRQS )) - work->num_interrupts = ctx->afu->pp_irqs; -else if ((work->num_interrupts < ctx->afu->pp_irqs) || - (work->num_interrupts > ctx->afu->irqs_max)) { -return -EINVAL ; - } - - rc =afu_register_irqs (ctx, work->num_interrupts); -if (rc) -return rc; - - rc =cxl_start_context (ctx, work->work_element_descriptor, current); -if (rc <0 ) { -afu_release_irqs (ctx, ctx); -return rc; - } - -return 0 ; -} -EXPORT_SYMBOL_GPL (cxl_start_work); - -void __iomem *cxl_psa_map (struct cxl_context *ctx) -{ -if (ctx->status !=STARTED ) -return NULL ; - -pr_devel ("%s: psn_phys%llx size:%llx\n" , - __func__, ctx->psn_phys, ctx->psn_size); -return ioremap (ctx->psn_phys, ctx->psn_size); -} -EXPORT_SYMBOL_GPL (cxl_psa_map); - -void cxl_psa_unmap (void __iomem *addr) -{ -iounmap (addr); -} -EXPORT_SYMBOL_GPL (cxl_psa_unmap); - -int cxl_afu_reset (struct cxl_context *ctx) -{ -struct cxl_afu *afu = ctx->afu; -int rc; - - rc = cxl_ops->afu_reset (afu); -if (rc) -return rc; - -return cxl_ops->afu_check_and_enable (afu); -} -EXPORT_SYMBOL_GPL (cxl_afu_reset); - -void cxl_perst_reloads_same_image (struct cxl_afu *afu, -bool perst_reloads_same_image) -{ - afu->adapter->perst_same_image = perst_reloads_same_image; -} -EXPORT_SYMBOL_GPL (cxl_perst_reloads_same_image); - -ssize_t cxl_read_adapter_vpd (struct pci_dev *dev,void *buf,size_t count) -{ -struct cxl_afu *afu =cxl_pci_to_afu (dev); -if (IS_ERR (afu)) -return -ENODEV ; - -return cxl_ops->read_adapter_vpd (afu->adapter, buf, count); -} -EXPORT_SYMBOL_GPL (cxl_read_adapter_vpd);drivers/misc/cxl/base.c deleted +0
-126@@ -1,126 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* -* Copyright 2014 IBM Corp. -*/ - -#include <linux/module.h> -#include <linux/rcupdate.h> -#include <asm/errno.h> -#include <misc/cxl-base.h> -#include <linux/of.h> -#include <linux/of_platform.h> -#include "cxl.h" - -/* protected by rcu */ -static struct cxl_calls *cxl_calls; - -atomic_t cxl_use_count =ATOMIC_INIT (0 ); -EXPORT_SYMBOL (cxl_use_count); - -#ifdef CONFIG_CXL_MODULE - -static inline struct cxl_calls *cxl_calls_get (void ) -{ -struct cxl_calls *calls =NULL ; - -rcu_read_lock (); - calls =rcu_dereference (cxl_calls); -if (calls && !try_module_get (calls->owner)) - calls =NULL ; -rcu_read_unlock (); - -return calls; -} - -static inline void cxl_calls_put (struct cxl_calls *calls) -{ -BUG_ON (calls != cxl_calls); - -/* we don't need to rcu this, as we hold a reference to the module */ -module_put (cxl_calls->owner); -} - -#else /* !defined CONFIG_CXL_MODULE */ - -static inline struct cxl_calls *cxl_calls_get (void ) -{ -return cxl_calls; -} - -static inline void cxl_calls_put (struct cxl_calls *calls) { } - -#endif /* CONFIG_CXL_MODULE */ - -/* AFU refcount management */ -struct cxl_afu *cxl_afu_get (struct cxl_afu *afu) -{ -return (get_device (&afu->dev) ==NULL ) ?NULL : afu; -} -EXPORT_SYMBOL_GPL (cxl_afu_get); - -void cxl_afu_put (struct cxl_afu *afu) -{ -put_device (&afu->dev); -} -EXPORT_SYMBOL_GPL (cxl_afu_put); - -void cxl_slbia (struct mm_struct *mm) -{ -struct cxl_calls *calls; - - calls =cxl_calls_get (); -if (!calls) -return ; - -if (cxl_ctx_in_use ()) - calls->cxl_slbia (mm); - -cxl_calls_put (calls); -} - -int register_cxl_calls (struct cxl_calls *calls) -{ -if (cxl_calls) -return -EBUSY ; - -rcu_assign_pointer (cxl_calls, calls); -return 0 ; -} -EXPORT_SYMBOL_GPL (register_cxl_calls); - -void unregister_cxl_calls (struct cxl_calls *calls) -{ -BUG_ON (cxl_calls->owner != calls->owner); -RCU_INIT_POINTER (cxl_calls,NULL ); -synchronize_rcu (); -} -EXPORT_SYMBOL_GPL (unregister_cxl_calls); - -int cxl_update_properties (struct device_node *dn, -struct property *new_prop) -{ -return of_update_property (dn, new_prop); -} -EXPORT_SYMBOL_GPL (cxl_update_properties); - -static int __init cxl_base_init (void ) -{ -struct device_node *np; -struct platform_device *dev; -int count =0 ; - -/* -* Scan for compatible devices in guest only -*/ -if (cpu_has_feature (CPU_FTR_HVMODE )) -return 0 ; - -for_each_compatible_node (np,NULL ,"ibm,coherent-platform-facility" ) { - dev =of_platform_device_create (np,NULL ,NULL ); -if (dev) - count++; - } -pr_devel ("Found %d cxl device(s)\n" , count); -return 0 ; -} -device_initcall (cxl_base_init);drivers/misc/cxl/context.c deleted +0
-362@@ -1,362 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* -* Copyright 2014 IBM Corp. -*/ - -#include <linux/module.h> -#include <linux/kernel.h> -#include <linux/bitmap.h> -#include <linux/sched.h> -#include <linux/pid.h> -#include <linux/fs.h> -#include <linux/mm.h> -#include <linux/debugfs.h> -#include <linux/slab.h> -#include <linux/idr.h> -#include <linux/sched/mm.h> -#include <linux/mmu_context.h> -#include <asm/cputable.h> -#include <asm/current.h> -#include <asm/copro.h> - -#include "cxl.h" - -/* -* Allocates space for a CXL context. -*/ -struct cxl_context *cxl_context_alloc (void ) -{ -return kzalloc (sizeof (struct cxl_context ),GFP_KERNEL ); -} - -/* -* Initialises a CXL context. -*/ -int cxl_context_init (struct cxl_context *ctx,struct cxl_afu *afu,bool master) -{ -int i; - - ctx->afu = afu; - ctx->master = master; - ctx->pid =NULL ;/* Set in start work ioctl */ -mutex_init (&ctx->mapping_lock); - ctx->mapping =NULL ; - ctx->tidr =0 ; - ctx->assign_tidr = false; - -if (cxl_is_power8 ()) { -spin_lock_init (&ctx->sste_lock); - -/* -* Allocate the segment table before we put it in the IDR so that we -* can always access it when dereferenced from IDR. For the same -* reason, the segment table is only destroyed after the context is -* removed from the IDR. Access to this in the IOCTL is protected by -* Linux filesystem semantics (can't IOCTL until open is complete). -*/ - i =cxl_alloc_sst (ctx); -if (i) -return i; - } - -INIT_WORK (&ctx->fault_work, cxl_handle_fault); - -init_waitqueue_head (&ctx->wq); -spin_lock_init (&ctx->lock); - - ctx->irq_bitmap =NULL ; - ctx->pending_irq = false; - ctx->pending_fault = false; - ctx->pending_afu_err = false; - -INIT_LIST_HEAD (&ctx->irq_names); - -/* -* When we have to destroy all contexts in cxl_context_detach_all() we -* end up with afu_release_irqs() called from inside a -* idr_for_each_entry(). Hence we need to make sure that anything -* dereferenced from this IDR is ok before we allocate the IDR here. -* This clears out the IRQ ranges to ensure this. -*/ -for (i =0 ; i <CXL_IRQ_RANGES ; i++) - ctx->irqs.range[i] =0 ; - -mutex_init (&ctx->status_mutex); - - ctx->status =OPENED ; - -/* -* Allocating IDR! We better make sure everything's setup that -* dereferences from it. -*/ -mutex_lock (&afu->contexts_lock); -idr_preload (GFP_KERNEL ); - i =idr_alloc (&ctx->afu->contexts_idr, ctx,0 , - ctx->afu->num_procs,GFP_NOWAIT ); -idr_preload_end (); -mutex_unlock (&afu->contexts_lock); -if (i <0 ) -return i; - - ctx->pe = i; -if (cpu_has_feature (CPU_FTR_HVMODE )) { - ctx->elem = &ctx->afu->native->spa[i]; - ctx->external_pe = ctx->pe; - }else { - ctx->external_pe =-1 ;/* assigned when attaching */ - } - ctx->pe_inserted = false; - -/* -* take a ref on the afu so that it stays alive at-least till -* this context is reclaimed inside reclaim_ctx. -*/ -cxl_afu_get (afu); -return 0 ; -} - -void cxl_context_set_mapping (struct cxl_context *ctx, -struct address_space *mapping) -{ -mutex_lock (&ctx->mapping_lock); - ctx->mapping = mapping; -mutex_unlock (&ctx->mapping_lock); -} - -static vm_fault_t cxl_mmap_fault (struct vm_fault *vmf) -{ -struct vm_area_struct *vma = vmf->vma; -struct cxl_context *ctx = vma->vm_file->private_data; -u64 area, offset; -vm_fault_t ret; - - offset = vmf->pgoff <<PAGE_SHIFT ; - -pr_devel ("%s: pe: %i address: 0x%lx offset: 0x%llx\n" , - __func__, ctx->pe, vmf->address, offset); - -if (ctx->afu->current_mode ==CXL_MODE_DEDICATED ) { - area = ctx->afu->psn_phys; -if (offset >= ctx->afu->adapter->ps_size) -return VM_FAULT_SIGBUS ; - }else { - area = ctx->psn_phys; -if (offset >= ctx->psn_size) -return VM_FAULT_SIGBUS ; - } - -mutex_lock (&ctx->status_mutex); - -if (ctx->status !=STARTED ) { -mutex_unlock (&ctx->status_mutex); -pr_devel ("%s: Context not started, failing problem state access\n" , __func__); -if (ctx->mmio_err_ff) { -if (!ctx->ff_page) { - ctx->ff_page =alloc_page (GFP_USER ); -if (!ctx->ff_page) -return VM_FAULT_OOM ; -memset (page_address (ctx->ff_page),0xff ,PAGE_SIZE ); - } -get_page (ctx->ff_page); - vmf->page = ctx->ff_page; - vma->vm_page_prot =pgprot_cached (vma->vm_page_prot); -return 0 ; - } -return VM_FAULT_SIGBUS ; - } - - ret =vmf_insert_pfn (vma, vmf->address, (area + offset) >>PAGE_SHIFT ); - -mutex_unlock (&ctx->status_mutex); - -return ret; -} - -static const struct vm_operations_struct cxl_mmap_vmops = { - .fault = cxl_mmap_fault, -}; - -/* -* Map a per-context mmio space into the given vma. -*/ -int cxl_context_iomap (struct cxl_context *ctx,struct vm_area_struct *vma) -{ -u64 start = vma->vm_pgoff <<PAGE_SHIFT ; -u64 len = vma->vm_end - vma->vm_start; - -if (ctx->afu->current_mode ==CXL_MODE_DEDICATED ) { -if (start + len > ctx->afu->adapter->ps_size) -return -EINVAL ; - -if (cxl_is_power9 ()) { -/* -* Make sure there is a valid problem state -* area space for this AFU. -*/ -if (ctx->master && !ctx->afu->psa) { -pr_devel ("AFU doesn't support mmio space\n" ); -return -EINVAL ; - } - -/* Can't mmap until the AFU is enabled */ -if (!ctx->afu->enabled) -return -EBUSY ; - } - }else { -if (start + len > ctx->psn_size) -return -EINVAL ; - -/* Make sure there is a valid per process space for this AFU */ -if ((ctx->master && !ctx->afu->psa) || (!ctx->afu->pp_psa)) { -pr_devel ("AFU doesn't support mmio space\n" ); -return -EINVAL ; - } - -/* Can't mmap until the AFU is enabled */ -if (!ctx->afu->enabled) -return -EBUSY ; - } - -pr_devel ("%s: mmio physical: %llx pe: %i master:%i\n" , __func__, - ctx->psn_phys, ctx->pe , ctx->master); - -vm_flags_set (vma,VM_IO |VM_PFNMAP ); - vma->vm_page_prot =pgprot_noncached (vma->vm_page_prot); - vma->vm_ops = &cxl_mmap_vmops; -return 0 ; -} - -/* -* Detach a context from the hardware. This disables interrupts and doesn't -* return until all outstanding interrupts for this context have completed. The -* hardware should no longer access *ctx after this has returned. -*/ -int __detach_context (struct cxl_context *ctx) -{ -enum cxl_context_status status; - -mutex_lock (&ctx->status_mutex); - status = ctx->status; - ctx->status =CLOSED ; -mutex_unlock (&ctx->status_mutex); -if (status !=STARTED ) -return -EBUSY ; - -/* Only warn if we detached while the link was OK. -* If detach fails when hw is down, we don't care. -*/ -WARN_ON (cxl_ops->detach_process (ctx) && - cxl_ops->link_ok (ctx->afu->adapter, ctx->afu)); -flush_work (&ctx->fault_work);/* Only needed for dedicated process */ - -/* -* Wait until no further interrupts are presented by the PSL -* for this context. -*/ -if (cxl_ops->irq_wait) - cxl_ops->irq_wait (ctx); - -/* release the reference to the group leader and mm handling pid */ -put_pid (ctx->pid); - -cxl_ctx_put (); - -/* Decrease the attached context count on the adapter */ -cxl_adapter_context_put (ctx->afu->adapter); - -/* Decrease the mm count on the context */ -cxl_context_mm_count_put (ctx); -if (ctx->mm) -mm_context_remove_copro (ctx->mm); - ctx->mm =NULL ; - -return 0 ; -} - -/* -* Detach the given context from the AFU. This doesn't actually -* free the context but it should stop the context running in hardware -* (ie. prevent this context from generating any further interrupts -* so that it can be freed). -*/ -void cxl_context_detach (struct cxl_context *ctx) -{ -int rc; - - rc =__detach_context (ctx); -if (rc) -return ; - -afu_release_irqs (ctx, ctx); -wake_up_all (&ctx->wq); -} - -/* -* Detach all contexts on the given AFU. -*/ -void cxl_context_detach_all (struct cxl_afu *afu) -{ -struct cxl_context *ctx; -int tmp; - -mutex_lock (&afu->contexts_lock); -idr_for_each_entry (&afu->contexts_idr, ctx, tmp) { -/* -* Anything done in here needs to be setup before the IDR is -* created and torn down after the IDR removed -*/ -cxl_context_detach (ctx); - -/* -* We are force detaching - remove any active PSA mappings so -* userspace cannot interfere with the card if it comes back. -* Easiest way to exercise this is to unbind and rebind the -* driver via sysfs while it is in use. -*/ -mutex_lock (&ctx->mapping_lock); -if (ctx->mapping) -unmap_mapping_range (ctx->mapping,0 ,0 ,1 ); -mutex_unlock (&ctx->mapping_lock); - } -mutex_unlock (&afu->contexts_lock); -} - -static void reclaim_ctx (struct rcu_head *rcu) -{ - struct cxl_context *ctx = container_of(rcu, struct cxl_context, rcu); - -if (cxl_is_power8 ()) -free_page ((u64 )ctx->sstp); -if (ctx->ff_page) -__free_page (ctx->ff_page); - ctx->sstp =NULL ; - -bitmap_free (ctx->irq_bitmap); - -/* Drop ref to the afu device taken during cxl_context_init */ -cxl_afu_put (ctx->afu); - -kfree (ctx); -} - -void cxl_context_free (struct cxl_context *ctx) -{ -if (ctx->kernelapi && ctx->mapping) -cxl_release_mapping (ctx); -mutex_lock (&ctx->afu->contexts_lock); -idr_remove (&ctx->afu->contexts_idr, ctx->pe); -mutex_unlock (&ctx->afu->contexts_lock); -call_rcu (&ctx->rcu, reclaim_ctx); -} - -void cxl_context_mm_count_get (struct cxl_context *ctx) -{ -if (ctx->mm) -mmgrab (ctx->mm); -} - -void cxl_context_mm_count_put (struct cxl_context *ctx) -{ -if (ctx->mm) -mmdrop (ctx->mm); -}drivers/misc/cxl/cxl.h deleted +0
-1135@@ -1,1135 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* -* Copyright 2014 IBM Corp. -*/ - -#ifndef _CXL_H_ -#define _CXL_H_ - -#include <linux/interrupt.h> -#include <linux/semaphore.h> -#include <linux/device.h> -#include <linux/types.h> -#include <linux/cdev.h> -#include <linux/pid.h> -#include <linux/io.h> -#include <linux/pci.h> -#include <linux/fs.h> -#include <asm/cputable.h> -#include <asm/mmu.h> -#include <asm/reg.h> -#include <misc/cxl-base.h> - -#include <misc/cxl.h> -#include <uapi/misc/cxl.h> - -extern uint cxl_verbose; - -struct property; - -#define CXL_TIMEOUT 5 - -/* - * Bump version each time a user API change is made, whether it is - * backwards compatible ot not. - */ -#define CXL_API_VERSION 3 -#define CXL_API_VERSION_COMPATIBLE 1 - -/* - * Opaque types to avoid accidentally passing registers for the wrong MMIO - * - * At the end of the day, I'm not married to using typedef here, but it might - * (and has!) help avoid bugs like mixing up CXL_PSL_CtxTime and - * CXL_PSL_CtxTime_An, or calling cxl_p1n_write instead of cxl_p1_write. - * - * I'm quite happy if these are changed back to #defines before upstreaming, it - * should be little more than a regexp search+replace operation in this file. - */ -typedef struct { - const int x; -} cxl_p1_reg_t; -typedef struct { - const int x; -} cxl_p1n_reg_t; -typedef struct { - const int x; -} cxl_p2n_reg_t; -#define cxl_reg_off(reg) \ - (reg.x) - -/* Memory maps. Ref CXL Appendix A */ - -/* PSL Privilege 1 Memory Map */ -/* Configuration and Control area - CAIA 1&2 */ -static const cxl_p1_reg_t CXL_PSL_CtxTime = {0x0000}; -static const cxl_p1_reg_t CXL_PSL_ErrIVTE = {0x0008}; -static const cxl_p1_reg_t CXL_PSL_KEY1 = {0x0010}; -static const cxl_p1_reg_t CXL_PSL_KEY2 = {0x0018}; -static const cxl_p1_reg_t CXL_PSL_Control = {0x0020}; -/* Downloading */ -static const cxl_p1_reg_t CXL_PSL_DLCNTL = {0x0060}; -static const cxl_p1_reg_t CXL_PSL_DLADDR = {0x0068}; - -/* PSL Lookaside Buffer Management Area - CAIA 1 */ -static const cxl_p1_reg_t CXL_PSL_LBISEL = {0x0080}; -static const cxl_p1_reg_t CXL_PSL_SLBIE = {0x0088}; -static const cxl_p1_reg_t CXL_PSL_SLBIA = {0x0090}; -static const cxl_p1_reg_t CXL_PSL_TLBIE = {0x00A0}; -static const cxl_p1_reg_t CXL_PSL_TLBIA = {0x00A8}; -static const cxl_p1_reg_t CXL_PSL_AFUSEL = {0x00B0}; - -/* 0x00C0:7EFF Implementation dependent area */ -/* PSL registers - CAIA 1 */ -static const cxl_p1_reg_t CXL_PSL_FIR1 = {0x0100}; -static const cxl_p1_reg_t CXL_PSL_FIR2 = {0x0108}; -static const cxl_p1_reg_t CXL_PSL_Timebase = {0x0110}; -static const cxl_p1_reg_t CXL_PSL_VERSION = {0x0118}; -static const cxl_p1_reg_t CXL_PSL_RESLCKTO = {0x0128}; -static const cxl_p1_reg_t CXL_PSL_TB_CTLSTAT = {0x0140}; -static const cxl_p1_reg_t CXL_PSL_FIR_CNTL = {0x0148}; -static const cxl_p1_reg_t CXL_PSL_DSNDCTL = {0x0150}; -static const cxl_p1_reg_t CXL_PSL_SNWRALLOC = {0x0158}; -static const cxl_p1_reg_t CXL_PSL_TRACE = {0x0170}; -/* PSL registers - CAIA 2 */ -static const cxl_p1_reg_t CXL_PSL9_CONTROL = {0x0020}; -static const cxl_p1_reg_t CXL_XSL9_INV = {0x0110}; -static const cxl_p1_reg_t CXL_XSL9_DBG = {0x0130}; -static const cxl_p1_reg_t CXL_XSL9_DEF = {0x0140}; -static const cxl_p1_reg_t CXL_XSL9_DSNCTL = {0x0168}; -static const cxl_p1_reg_t CXL_PSL9_FIR1 = {0x0300}; -static const cxl_p1_reg_t CXL_PSL9_FIR_MASK = {0x0308}; -static const cxl_p1_reg_t CXL_PSL9_Timebase = {0x0310}; -static const cxl_p1_reg_t CXL_PSL9_DEBUG = {0x0320}; -static const cxl_p1_reg_t CXL_PSL9_FIR_CNTL = {0x0348}; -static const cxl_p1_reg_t CXL_PSL9_DSNDCTL = {0x0350}; -static const cxl_p1_reg_t CXL_PSL9_TB_CTLSTAT = {0x0340}; -static const cxl_p1_reg_t CXL_PSL9_TRACECFG = {0x0368}; -static const cxl_p1_reg_t CXL_PSL9_APCDEDALLOC = {0x0378}; -static const cxl_p1_reg_t CXL_PSL9_APCDEDTYPE = {0x0380}; -static const cxl_p1_reg_t CXL_PSL9_TNR_ADDR = {0x0388}; -static const cxl_p1_reg_t CXL_PSL9_CTCCFG = {0x0390}; -static const cxl_p1_reg_t CXL_PSL9_GP_CT = {0x0398}; -static const cxl_p1_reg_t CXL_XSL9_IERAT = {0x0588}; -static const cxl_p1_reg_t CXL_XSL9_ILPP = {0x0590}; - -/* 0x7F00:7FFF Reserved PCIe MSI-X Pending Bit Array area */ -/* 0x8000:FFFF Reserved PCIe MSI-X Table Area */ - -/* PSL Slice Privilege 1 Memory Map */ -/* Configuration Area - CAIA 1&2 */ -static const cxl_p1n_reg_t CXL_PSL_SR_An = {0x00}; -static const cxl_p1n_reg_t CXL_PSL_LPID_An = {0x08}; -static const cxl_p1n_reg_t CXL_PSL_AMBAR_An = {0x10}; -static const cxl_p1n_reg_t CXL_PSL_SPOffset_An = {0x18}; -static const cxl_p1n_reg_t CXL_PSL_ID_An = {0x20}; -static const cxl_p1n_reg_t CXL_PSL_SERR_An = {0x28}; -/* Memory Management and Lookaside Buffer Management - CAIA 1*/ -static const cxl_p1n_reg_t CXL_PSL_SDR_An = {0x30}; -/* Memory Management and Lookaside Buffer Management - CAIA 1&2 */ -static const cxl_p1n_reg_t CXL_PSL_AMOR_An = {0x38}; -/* Pointer Area - CAIA 1&2 */ -static const cxl_p1n_reg_t CXL_HAURP_An = {0x80}; -static const cxl_p1n_reg_t CXL_PSL_SPAP_An = {0x88}; -static const cxl_p1n_reg_t CXL_PSL_LLCMD_An = {0x90}; -/* Control Area - CAIA 1&2 */ -static const cxl_p1n_reg_t CXL_PSL_SCNTL_An = {0xA0}; -static const cxl_p1n_reg_t CXL_PSL_CtxTime_An = {0xA8}; -static const cxl_p1n_reg_t CXL_PSL_IVTE_Offset_An = {0xB0}; -static const cxl_p1n_reg_t CXL_PSL_IVTE_Limit_An = {0xB8}; -/* 0xC0:FF Implementation Dependent Area - CAIA 1&2 */ -static const cxl_p1n_reg_t CXL_PSL_FIR_SLICE_An = {0xC0}; -static const cxl_p1n_reg_t CXL_AFU_DEBUG_An = {0xC8}; -/* 0xC0:FF Implementation Dependent Area - CAIA 1 */ -static const cxl_p1n_reg_t CXL_PSL_APCALLOC_A = {0xD0}; -static const cxl_p1n_reg_t CXL_PSL_COALLOC_A = {0xD8}; -static const cxl_p1n_reg_t CXL_PSL_RXCTL_A = {0xE0}; -static const cxl_p1n_reg_t CXL_PSL_SLICE_TRACE = {0xE8}; - -/* PSL Slice Privilege 2 Memory Map */ -/* Configuration and Control Area - CAIA 1&2 */ -static const cxl_p2n_reg_t CXL_PSL_PID_TID_An = {0x000}; -static const cxl_p2n_reg_t CXL_CSRP_An = {0x008}; -/* Configuration and Control Area - CAIA 1 */ -static const cxl_p2n_reg_t CXL_AURP0_An = {0x010}; -static const cxl_p2n_reg_t CXL_AURP1_An = {0x018}; -static const cxl_p2n_reg_t CXL_SSTP0_An = {0x020}; -static const cxl_p2n_reg_t CXL_SSTP1_An = {0x028}; -/* Configuration and Control Area - CAIA 1 */ -static const cxl_p2n_reg_t CXL_PSL_AMR_An = {0x030}; -/* Segment Lookaside Buffer Management - CAIA 1 */ -static const cxl_p2n_reg_t CXL_SLBIE_An = {0x040}; -static const cxl_p2n_reg_t CXL_SLBIA_An = {0x048}; -static const cxl_p2n_reg_t CXL_SLBI_Select_An = {0x050}; -/* Interrupt Registers - CAIA 1&2 */ -static const cxl_p2n_reg_t CXL_PSL_DSISR_An = {0x060}; -static const cxl_p2n_reg_t CXL_PSL_DAR_An = {0x068}; -static const cxl_p2n_reg_t CXL_PSL_DSR_An = {0x070}; -static const cxl_p2n_reg_t CXL_PSL_TFC_An = {0x078}; -static const cxl_p2n_reg_t CXL_PSL_PEHandle_An = {0x080}; -static const cxl_p2n_reg_t CXL_PSL_ErrStat_An = {0x088}; -/* AFU Registers - CAIA 1&2 */ -static const cxl_p2n_reg_t CXL_AFU_Cntl_An = {0x090}; -static const cxl_p2n_reg_t CXL_AFU_ERR_An = {0x098}; -/* Work Element Descriptor - CAIA 1&2 */ -static const cxl_p2n_reg_t CXL_PSL_WED_An = {0x0A0}; -/* 0x0C0:FFF Implementation Dependent Area */ - -#define CXL_PSL_SPAP_Addr 0x0ffffffffffff000ULL -#define CXL_PSL_SPAP_Size 0x0000000000000ff0ULL -#define CXL_PSL_SPAP_Size_Shift 4 -#define CXL_PSL_SPAP_V 0x0000000000000001ULL - -/****** CXL_PSL_Control ****************************************************/ -#define CXL_PSL_Control_tb (0x1ull << (63-63)) -#define CXL_PSL_Control_Fr (0x1ull << (63-31)) -#define CXL_PSL_Control_Fs_MASK (0x3ull << (63-29)) -#define CXL_PSL_Control_Fs_Complete (0x3ull << (63-29)) - -/****** CXL_PSL_DLCNTL *****************************************************/ -#define CXL_PSL_DLCNTL_D (0x1ull << (63-28)) -#define CXL_PSL_DLCNTL_C (0x1ull << (63-29)) -#define CXL_PSL_DLCNTL_E (0x1ull << (63-30)) -#define CXL_PSL_DLCNTL_S (0x1ull << (63-31)) -#define CXL_PSL_DLCNTL_CE (CXL_PSL_DLCNTL_C | CXL_PSL_DLCNTL_E) -#define CXL_PSL_DLCNTL_DCES (CXL_PSL_DLCNTL_D | CXL_PSL_DLCNTL_CE | CXL_PSL_DLCNTL_S) - -/****** CXL_PSL_SR_An ******************************************************/ -#define CXL_PSL_SR_An_SF MSR_SF /* 64bit */ -#define CXL_PSL_SR_An_TA (1ull << (63-1)) /* Tags active, GA1: 0 */ -#define CXL_PSL_SR_An_HV MSR_HV /* Hypervisor, GA1: 0 */ -#define CXL_PSL_SR_An_XLAT_hpt (0ull << (63-6))/* Hashed page table (HPT) mode */ -#define CXL_PSL_SR_An_XLAT_roh (2ull << (63-6))/* Radix on HPT mode */ -#define CXL_PSL_SR_An_XLAT_ror (3ull << (63-6))/* Radix on Radix mode */ -#define CXL_PSL_SR_An_BOT (1ull << (63-10)) /* Use the in-memory segment table */ -#define CXL_PSL_SR_An_PR MSR_PR /* Problem state, GA1: 1 */ -#define CXL_PSL_SR_An_ISL (1ull << (63-53)) /* Ignore Segment Large Page */ -#define CXL_PSL_SR_An_TC (1ull << (63-54)) /* Page Table secondary hash */ -#define CXL_PSL_SR_An_US (1ull << (63-56)) /* User state, GA1: X */ -#define CXL_PSL_SR_An_SC (1ull << (63-58)) /* Segment Table secondary hash */ -#define CXL_PSL_SR_An_R MSR_DR /* Relocate, GA1: 1 */ -#define CXL_PSL_SR_An_MP (1ull << (63-62)) /* Master Process */ -#define CXL_PSL_SR_An_LE (1ull << (63-63)) /* Little Endian */ - -/****** CXL_PSL_ID_An ****************************************************/ -#define CXL_PSL_ID_An_F (1ull << (63-31)) -#define CXL_PSL_ID_An_L (1ull << (63-30)) - -/****** CXL_PSL_SERR_An ****************************************************/ -#define CXL_PSL_SERR_An_afuto (1ull << (63-0)) -#define CXL_PSL_SERR_An_afudis (1ull << (63-1)) -#define CXL_PSL_SERR_An_afuov (1ull << (63-2)) -#define CXL_PSL_SERR_An_badsrc (1ull << (63-3)) -#define CXL_PSL_SERR_An_badctx (1ull << (63-4)) -#define CXL_PSL_SERR_An_llcmdis (1ull << (63-5)) -#define CXL_PSL_SERR_An_llcmdto (1ull << (63-6)) -#define CXL_PSL_SERR_An_afupar (1ull << (63-7)) -#define CXL_PSL_SERR_An_afudup (1ull << (63-8)) -#define CXL_PSL_SERR_An_IRQS ( \ - CXL_PSL_SERR_An_afuto | CXL_PSL_SERR_An_afudis | CXL_PSL_SERR_An_afuov | \ - CXL_PSL_SERR_An_badsrc | CXL_PSL_SERR_An_badctx | CXL_PSL_SERR_An_llcmdis | \ - CXL_PSL_SERR_An_llcmdto | CXL_PSL_SERR_An_afupar | CXL_PSL_SERR_An_afudup) -#define CXL_PSL_SERR_An_afuto_mask (1ull << (63-32)) -#define CXL_PSL_SERR_An_afudis_mask (1ull << (63-33)) -#define CXL_PSL_SERR_An_afuov_mask (1ull << (63-34)) -#define CXL_PSL_SERR_An_badsrc_mask (1ull << (63-35)) -#define CXL_PSL_SERR_An_badctx_mask (1ull << (63-36)) -#define CXL_PSL_SERR_An_llcmdis_mask (1ull << (63-37)) -#define CXL_PSL_SERR_An_llcmdto_mask (1ull << (63-38)) -#define CXL_PSL_SERR_An_afupar_mask (1ull << (63-39)) -#define CXL_PSL_SERR_An_afudup_mask (1ull << (63-40)) -#define CXL_PSL_SERR_An_IRQ_MASKS ( \ - CXL_PSL_SERR_An_afuto_mask | CXL_PSL_SERR_An_afudis_mask | CXL_PSL_SERR_An_afuov_mask | \ - CXL_PSL_SERR_An_badsrc_mask | CXL_PSL_SERR_An_badctx_mask | CXL_PSL_SERR_An_llcmdis_mask | \ - CXL_PSL_SERR_An_llcmdto_mask | CXL_PSL_SERR_An_afupar_mask | CXL_PSL_SERR_An_afudup_mask) - -#define CXL_PSL_SERR_An_AE (1ull << (63-30)) - -/****** CXL_PSL_SCNTL_An ****************************************************/ -#define CXL_PSL_SCNTL_An_CR (0x1ull << (63-15)) -/* Programming Modes: */ -#define CXL_PSL_SCNTL_An_PM_MASK (0xffffull << (63-31)) -#define CXL_PSL_SCNTL_An_PM_Shared (0x0000ull << (63-31)) -#define CXL_PSL_SCNTL_An_PM_OS (0x0001ull << (63-31)) -#define CXL_PSL_SCNTL_An_PM_Process (0x0002ull << (63-31)) -#define CXL_PSL_SCNTL_An_PM_AFU (0x0004ull << (63-31)) -#define CXL_PSL_SCNTL_An_PM_AFU_PBT (0x0104ull << (63-31)) -/* Purge Status (ro) */ -#define CXL_PSL_SCNTL_An_Ps_MASK (0x3ull << (63-39)) -#define CXL_PSL_SCNTL_An_Ps_Pending (0x1ull << (63-39)) -#define CXL_PSL_SCNTL_An_Ps_Complete (0x3ull << (63-39)) -/* Purge */ -#define CXL_PSL_SCNTL_An_Pc (0x1ull << (63-48)) -/* Suspend Status (ro) */ -#define CXL_PSL_SCNTL_An_Ss_MASK (0x3ull << (63-55)) -#define CXL_PSL_SCNTL_An_Ss_Pending (0x1ull << (63-55)) -#define CXL_PSL_SCNTL_An_Ss_Complete (0x3ull << (63-55)) -/* Suspend Control */ -#define CXL_PSL_SCNTL_An_Sc (0x1ull << (63-63)) - -/* AFU Slice Enable Status (ro) */ -#define CXL_AFU_Cntl_An_ES_MASK (0x7ull << (63-2)) -#define CXL_AFU_Cntl_An_ES_Disabled (0x0ull << (63-2)) -#define CXL_AFU_Cntl_An_ES_Enabled (0x4ull << (63-2)) -/* AFU Slice Enable */ -#define CXL_AFU_Cntl_An_E (0x1ull << (63-3)) -/* AFU Slice Reset status (ro) */ -#define CXL_AFU_Cntl_An_RS_MASK (0x3ull << (63-5)) -#define CXL_AFU_Cntl_An_RS_Pending (0x1ull << (63-5)) -#define CXL_AFU_Cntl_An_RS_Complete (0x2ull << (63-5)) -/* AFU Slice Reset */ -#define CXL_AFU_Cntl_An_RA (0x1ull << (63-7)) - -/****** CXL_SSTP0/1_An ******************************************************/ -/* These top bits are for the segment that CONTAINS the segment table */ -#define CXL_SSTP0_An_B_SHIFT SLB_VSID_SSIZE_SHIFT -#define CXL_SSTP0_An_KS (1ull << (63-2)) -#define CXL_SSTP0_An_KP (1ull << (63-3)) -#define CXL_SSTP0_An_N (1ull << (63-4)) -#define CXL_SSTP0_An_L (1ull << (63-5)) -#define CXL_SSTP0_An_C (1ull << (63-6)) -#define CXL_SSTP0_An_TA (1ull << (63-7)) -#define CXL_SSTP0_An_LP_SHIFT (63-9) /* 2 Bits */ -/* And finally, the virtual address & size of the segment table: */ -#define CXL_SSTP0_An_SegTableSize_SHIFT (63-31) /* 12 Bits */ -#define CXL_SSTP0_An_SegTableSize_MASK \ - (((1ull << 12) - 1) << CXL_SSTP0_An_SegTableSize_SHIFT) -#define CXL_SSTP0_An_STVA_U_MASK ((1ull << (63-49))-1) -#define CXL_SSTP1_An_STVA_L_MASK (~((1ull << (63-55))-1)) -#define CXL_SSTP1_An_V (1ull << (63-63)) - -/****** CXL_PSL_SLBIE_[An] - CAIA 1 **************************************************/ -/* write: */ -#define CXL_SLBIE_C PPC_BIT(36) /* Class */ -#define CXL_SLBIE_SS PPC_BITMASK(37, 38) /* Segment Size */ -#define CXL_SLBIE_SS_SHIFT PPC_BITLSHIFT(38) -#define CXL_SLBIE_TA PPC_BIT(38) /* Tags Active */ -/* read: */ -#define CXL_SLBIE_MAX PPC_BITMASK(24, 31) -#define CXL_SLBIE_PENDING PPC_BITMASK(56, 63) - -/****** Common to all CXL_TLBIA/SLBIA_[An] - CAIA 1 **********************************/ -#define CXL_TLB_SLB_P (1ull) /* Pending (read) */ - -/****** Common to all CXL_TLB/SLB_IA/IE_[An] registers - CAIA 1 **********************/ -#define CXL_TLB_SLB_IQ_ALL (0ull) /* Inv qualifier */ -#define CXL_TLB_SLB_IQ_LPID (1ull) /* Inv qualifier */ -#define CXL_TLB_SLB_IQ_LPIDPID (3ull) /* Inv qualifier */ - -/****** CXL_PSL_AFUSEL ******************************************************/ -#define CXL_PSL_AFUSEL_A (1ull << (63-55)) /* Adapter wide invalidates affect all AFUs */ - -/****** CXL_PSL_DSISR_An - CAIA 1 ****************************************************/ -#define CXL_PSL_DSISR_An_DS (1ull << (63-0)) /* Segment not found */ -#define CXL_PSL_DSISR_An_DM (1ull << (63-1)) /* PTE not found (See also: M) or protection fault */ -#define CXL_PSL_DSISR_An_ST (1ull << (63-2)) /* Segment Table PTE not found */ -#define CXL_PSL_DSISR_An_UR (1ull << (63-3)) /* AURP PTE not found */ -#define CXL_PSL_DSISR_TRANS (CXL_PSL_DSISR_An_DS | CXL_PSL_DSISR_An_DM | CXL_PSL_DSISR_An_ST | CXL_PSL_DSISR_An_UR) -#define CXL_PSL_DSISR_An_PE (1ull << (63-4)) /* PSL Error (implementation specific) */ -#define CXL_PSL_DSISR_An_AE (1ull << (63-5)) /* AFU Error */ -#define CXL_PSL_DSISR_An_OC (1ull << (63-6)) /* OS Context Warning */ -#define CXL_PSL_DSISR_PENDING (CXL_PSL_DSISR_TRANS | CXL_PSL_DSISR_An_PE | CXL_PSL_DSISR_An_AE | CXL_PSL_DSISR_An_OC) -/* NOTE: Bits 32:63 are undefined if DSISR[DS] = 1 */ -#define CXL_PSL_DSISR_An_M DSISR_NOHPTE /* PTE not found */ -#define CXL_PSL_DSISR_An_P DSISR_PROTFAULT /* Storage protection violation */ -#define CXL_PSL_DSISR_An_A (1ull << (63-37)) /* AFU lock access to write through or cache inhibited storage */ -#define CXL_PSL_DSISR_An_S DSISR_ISSTORE /* Access was afu_wr or afu_zero */ -#define CXL_PSL_DSISR_An_K DSISR_KEYFAULT /* Access not permitted by virtual page class key protection */ - -/****** CXL_PSL_DSISR_An - CAIA 2 ****************************************************/ -#define CXL_PSL9_DSISR_An_TF (1ull << (63-3)) /* Translation fault */ -#define CXL_PSL9_DSISR_An_PE (1ull << (63-4)) /* PSL Error (implementation specific) */ -#define CXL_PSL9_DSISR_An_AE (1ull << (63-5)) /* AFU Error */ -#define CXL_PSL9_DSISR_An_OC (1ull << (63-6)) /* OS Context Warning */ -#define CXL_PSL9_DSISR_An_S (1ull << (63-38)) /* TF for a write operation */ -#define CXL_PSL9_DSISR_PENDING (CXL_PSL9_DSISR_An_TF | CXL_PSL9_DSISR_An_PE | CXL_PSL9_DSISR_An_AE | CXL_PSL9_DSISR_An_OC) -/* - * NOTE: Bits 56:63 (Checkout Response Status) are valid when DSISR_An[TF] = 1 - * Status (0:7) Encoding - */ -#define CXL_PSL9_DSISR_An_CO_MASK 0x00000000000000ffULL -#define CXL_PSL9_DSISR_An_SF 0x0000000000000080ULL /* Segment Fault 0b10000000 */ -#define CXL_PSL9_DSISR_An_PF_SLR 0x0000000000000088ULL /* PTE not found (Single Level Radix) 0b10001000 */ -#define CXL_PSL9_DSISR_An_PF_RGC 0x000000000000008CULL /* PTE not found (Radix Guest (child)) 0b10001100 */ -#define CXL_PSL9_DSISR_An_PF_RGP 0x0000000000000090ULL /* PTE not found (Radix Guest (parent)) 0b10010000 */ -#define CXL_PSL9_DSISR_An_PF_HRH 0x0000000000000094ULL /* PTE not found (HPT/Radix Host) 0b10010100 */ -#define CXL_PSL9_DSISR_An_PF_STEG 0x000000000000009CULL /* PTE not found (STEG VA) 0b10011100 */ -#define CXL_PSL9_DSISR_An_URTCH 0x00000000000000B4ULL /* Unsupported Radix Tree Configuration 0b10110100 */ - -/****** CXL_PSL_TFC_An ******************************************************/ -#define CXL_PSL_TFC_An_A (1ull << (63-28)) /* Acknowledge non-translation fault */ -#define CXL_PSL_TFC_An_C (1ull << (63-29)) /* Continue (abort transaction) */ -#define CXL_PSL_TFC_An_AE (1ull << (63-30)) /* Restart PSL with address error */ -#define CXL_PSL_TFC_An_R (1ull << (63-31)) /* Restart PSL transaction */ - -/****** CXL_PSL_DEBUG *****************************************************/ -#define CXL_PSL_DEBUG_CDC (1ull << (63-27)) /* Coherent Data cache support */ - -/****** CXL_XSL9_IERAT_ERAT - CAIA 2 **********************************/ -#define CXL_XSL9_IERAT_MLPID (1ull << (63-0)) /* Match LPID */ -#define CXL_XSL9_IERAT_MPID (1ull << (63-1)) /* Match PID */ -#define CXL_XSL9_IERAT_PRS (1ull << (63-4)) /* PRS bit for Radix invalidations */ -#define CXL_XSL9_IERAT_INVR (1ull << (63-3)) /* Invalidate Radix */ -#define CXL_XSL9_IERAT_IALL (1ull << (63-8)) /* Invalidate All */ -#define CXL_XSL9_IERAT_IINPROG (1ull << (63-63)) /* Invalidate in progress */ - -/* cxl_process_element->software_status */ -#define CXL_PE_SOFTWARE_STATE_V (1ul << (31 - 0)) /* Valid */ -#define CXL_PE_SOFTWARE_STATE_C (1ul << (31 - 29)) /* Complete */ -#define CXL_PE_SOFTWARE_STATE_S (1ul << (31 - 30)) /* Suspend */ -#define CXL_PE_SOFTWARE_STATE_T (1ul << (31 - 31)) /* Terminate */ - -/****** CXL_PSL_RXCTL_An (Implementation Specific) ************************** - * Controls AFU Hang Pulse, which sets the timeout for the AFU to respond to - * the PSL for any response (except MMIO). Timeouts will occur between 1x to 2x - * of the hang pulse frequency. - */ -#define CXL_PSL_RXCTL_AFUHP_4S 0x7000000000000000ULL - -/* SPA->sw_command_status */ -#define CXL_SPA_SW_CMD_MASK 0xffff000000000000ULL -#define CXL_SPA_SW_CMD_TERMINATE 0x0001000000000000ULL -#define CXL_SPA_SW_CMD_REMOVE 0x0002000000000000ULL -#define CXL_SPA_SW_CMD_SUSPEND 0x0003000000000000ULL -#define CXL_SPA_SW_CMD_RESUME 0x0004000000000000ULL -#define CXL_SPA_SW_CMD_ADD 0x0005000000000000ULL -#define CXL_SPA_SW_CMD_UPDATE 0x0006000000000000ULL -#define CXL_SPA_SW_STATE_MASK 0x0000ffff00000000ULL -#define CXL_SPA_SW_STATE_TERMINATED 0x0000000100000000ULL -#define CXL_SPA_SW_STATE_REMOVED 0x0000000200000000ULL -#define CXL_SPA_SW_STATE_SUSPENDED 0x0000000300000000ULL -#define CXL_SPA_SW_STATE_RESUMED 0x0000000400000000ULL -#define CXL_SPA_SW_STATE_ADDED 0x0000000500000000ULL -#define CXL_SPA_SW_STATE_UPDATED 0x0000000600000000ULL -#define CXL_SPA_SW_PSL_ID_MASK 0x00000000ffff0000ULL -#define CXL_SPA_SW_LINK_MASK 0x000000000000ffffULL - -#define CXL_MAX_SLICES 4 -#define MAX_AFU_MMIO_REGS 3 - -#define CXL_MODE_TIME_SLICED 0x4 -#define CXL_SUPPORTED_MODES (CXL_MODE_DEDICATED | CXL_MODE_DIRECTED) - -#define CXL_DEV_MINORS 13 /* 1 control + 4 AFUs * 3 (dedicated/master/shared) */ -#define CXL_CARD_MINOR(adapter) (adapter->adapter_num * CXL_DEV_MINORS) -#define CXL_DEVT_ADAPTER(dev) (MINOR(dev) / CXL_DEV_MINORS) - -#define CXL_PSL9_TRACEID_MAX 0xAU -#define CXL_PSL9_TRACESTATE_FIN 0x3U - -enum cxl_context_status { - CLOSED, - OPENED, - STARTED -}; - -enum prefault_modes { - CXL_PREFAULT_NONE, - CXL_PREFAULT_WED, - CXL_PREFAULT_ALL, -}; - -enum cxl_attrs { - CXL_ADAPTER_ATTRS, - CXL_AFU_MASTER_ATTRS, - CXL_AFU_ATTRS, -}; - -struct cxl_sste { - __be64 esid_data; - __be64 vsid_data; -}; - -#define to_cxl_adapter(d) container_of(d, struct cxl, dev) -#define to_cxl_afu(d) container_of(d, struct cxl_afu, dev) - -struct cxl_afu_native { - void __iomem *p1n_mmio; - void __iomem *afu_desc_mmio; - irq_hw_number_t psl_hwirq; - unsigned int psl_virq; - struct mutex spa_mutex; - /* - * Only the first part of the SPA is used for the process element - * linked list. The only other part that software needs to worry about - * is sw_command_status, which we store a separate pointer to. - * Everything else in the SPA is only used by hardware - */ - struct cxl_process_element *spa; - __be64 *sw_command_status; - unsigned int spa_size; - int spa_order; - int spa_max_procs; - u64 pp_offset; -}; - -struct cxl_afu_guest { - struct cxl_afu *parent; - u64 handle; - phys_addr_t p2n_phys; - u64 p2n_size; - int max_ints; - bool handle_err; - struct delayed_work work_err; - int previous_state; -}; - -struct cxl_afu { - struct cxl_afu_native *native; - struct cxl_afu_guest *guest; - irq_hw_number_t serr_hwirq; - unsigned int serr_virq; - char *psl_irq_name; - char *err_irq_name; - void __iomem *p2n_mmio; - phys_addr_t psn_phys; - u64 pp_size; - - struct cxl *adapter; - struct device dev; - struct cdev afu_cdev_s, afu_cdev_m, afu_cdev_d; - struct device *chardev_s, *chardev_m, *chardev_d; - struct idr contexts_idr; - struct dentry *debugfs; - struct mutex contexts_lock; - spinlock_t afu_cntl_lock; - - /* -1: AFU deconfigured/locked, >= 0: number of readers */ - atomic_t configured_state; - - /* AFU error buffer fields and bin attribute for sysfs */ - u64 eb_len, eb_offset; - struct bin_attribute attr_eb; - - /* pointer to the vphb */ - struct pci_controller *phb; - - int pp_irqs; - int irqs_max; - int num_procs; - int max_procs_virtualised; - int slice; - int modes_supported; - int current_mode; - int crs_num; - u64 crs_len; - u64 crs_offset; - struct list_head crs; - enum prefault_modes prefault_mode; - bool psa; - bool pp_psa; - bool enabled; -}; - - -struct cxl_irq_name { - struct list_head list; - char *name; -}; - -struct irq_avail { - irq_hw_number_t offset; - irq_hw_number_t range; - unsigned long *bitmap; -}; - -/* - * This is a cxl context. If the PSL is in dedicated mode, there will be one - * of these per AFU. If in AFU directed there can be lots of these. - */ -struct cxl_context { - struct cxl_afu *afu; - - /* Problem state MMIO */ - phys_addr_t psn_phys; - u64 psn_size; - - /* Used to unmap any mmaps when force detaching */ - struct address_space *mapping; - struct mutex mapping_lock; - struct page *ff_page; - bool mmio_err_ff; - bool kernelapi; - - spinlock_t sste_lock; /* Protects segment table entries */ - struct cxl_sste *sstp; - u64 sstp0, sstp1; - unsigned int sst_size, sst_lru; - - wait_queue_head_t wq; - /* use mm context associated with this pid for ds faults */ - struct pid *pid; - spinlock_t lock; /* Protects pending_irq_mask, pending_fault and fault_addr */ - /* Only used in PR mode */ - u64 process_token; - - /* driver private data */ - void *priv; - - unsigned long *irq_bitmap; /* Accessed from IRQ context */ - struct cxl_irq_ranges irqs; - struct list_head irq_names; - u64 fault_addr; - u64 fault_dsisr; - u64 afu_err; - - /* - * This status and it's lock pretects start and detach context - * from racing. It also prevents detach from racing with - * itself - */ - enum cxl_context_status status; - struct mutex status_mutex; - - - /* XXX: Is it possible to need multiple work items at once? */ - struct work_struct fault_work; - u64 dsisr; - u64 dar; - - struct cxl_process_element *elem; - - /* - * pe is the process element handle, assigned by this driver when the - * context is initialized. - * - * external_pe is the PE shown outside of cxl. - * On bare-metal, pe=external_pe, because we decide what the handle is. - * In a guest, we only find out about the pe used by pHyp when the - * context is attached, and that's the value we want to report outside - * of cxl. - */ - int pe; - int external_pe; - - u32 irq_count; - bool pe_inserted; - bool master; - bool kernel; - bool pending_irq; - bool pending_fault; - bool pending_afu_err; - - /* Used by AFU drivers for driver specific event delivery */ - struct cxl_afu_driver_ops *afu_driver_ops; - atomic_t afu_driver_events; - - struct rcu_head rcu; - - struct mm_struct *mm; - - u16 tidr; - bool assign_tidr; -}; - -struct cxl_irq_info; - -struct cxl_service_layer_ops { - int (*adapter_regs_init)(struct cxl *adapter, struct pci_dev *dev); - int (*invalidate_all)(struct cxl *adapter); - int (*afu_regs_init)(struct cxl_afu *afu); - int (*sanitise_afu_regs)(struct cxl_afu *afu); - int (*register_serr_irq)(struct cxl_afu *afu); - void (*release_serr_irq)(struct cxl_afu *afu); - irqreturn_t (*handle_interrupt)(int irq, struct cxl_context *ctx, struct cxl_irq_info *irq_info); - irqreturn_t (*fail_irq)(struct cxl_afu *afu, struct cxl_irq_info *irq_info); - int (*activate_dedicated_process)(struct cxl_afu *afu); - int (*attach_afu_directed)(struct cxl_context *ctx, u64 wed, u64 amr); - int (*attach_dedicated_process)(struct cxl_context *ctx, u64 wed, u64 amr); - void (*update_dedicated_ivtes)(struct cxl_context *ctx); - void (*debugfs_add_adapter_regs)(struct cxl *adapter, struct dentry *dir); - void (*debugfs_add_afu_regs)(struct cxl_afu *afu, struct dentry *dir); - void (*psl_irq_dump_registers)(struct cxl_context *ctx); - void (*err_irq_dump_registers)(struct cxl *adapter); - void (*debugfs_stop_trace)(struct cxl *adapter); - void (*write_timebase_ctrl)(struct cxl *adapter); - u64 (*timebase_read)(struct cxl *adapter); - int capi_mode; - bool needs_reset_before_disable; -}; - -struct cxl_native { - u64 afu_desc_off; - u64 afu_desc_size; - void __iomem *p1_mmio; - void __iomem *p2_mmio; - irq_hw_number_t err_hwirq; - unsigned int err_virq; - u64 ps_off; - bool no_data_cache; /* set if no data cache on the card */ - const struct cxl_service_layer_ops *sl_ops; -}; - -struct cxl_guest { - struct platform_device *pdev; - int irq_nranges; - struct cdev cdev; - irq_hw_number_t irq_base_offset; - struct irq_avail *irq_avail; - spinlock_t irq_alloc_lock; - u64 handle; - char *status; - u16 vendor; - u16 device; - u16 subsystem_vendor; - u16 subsystem; -}; - -struct cxl { - struct cxl_native *native; - struct cxl_guest *guest; - spinlock_t afu_list_lock; - struct cxl_afu *afu[CXL_MAX_SLICES]; - struct device dev; - struct dentry *trace; - struct dentry *psl_err_chk; - struct dentry *debugfs; - char *irq_name; - struct bin_attribute cxl_attr; - int adapter_num; - int user_irqs; - u64 ps_size; - u16 psl_rev; - u16 base_image; - u8 vsec_status; - u8 caia_major; - u8 caia_minor; - u8 slices; - bool user_image_loaded; - bool perst_loads_image; - bool perst_select_user; - bool perst_same_image; - bool psl_timebase_synced; - bool tunneled_ops_supported; - - /* - * number of contexts mapped on to this card. Possible values are: - * >0: Number of contexts mapped and new one can be mapped. - * 0: No active contexts and new ones can be mapped. - * -1: No contexts mapped and new ones cannot be mapped. - */ - atomic_t contexts_num; -}; - -int cxl_pci_alloc_one_irq(struct cxl *adapter); -void cxl_pci_release_one_irq(struct cxl *adapter, int hwirq); -int cxl_pci_alloc_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter, unsigned int num); -void cxl_pci_release_irq_ranges(struct cxl_irq_ranges *irqs, struct cxl *adapter); -int cxl_pci_setup_irq(struct cxl *adapter, unsigned int hwirq, unsigned int virq); -int cxl_update_image_control(struct cxl *adapter); -int cxl_pci_reset(struct cxl *adapter); -void cxl_pci_release_afu(struct device *dev); -ssize_t cxl_pci_read_adapter_vpd(struct cxl *adapter, void *buf, size_t len); - -/* common == phyp + powernv - CAIA 1&2 */ -struct cxl_process_element_common { - __be32 tid; - __be32 pid; - __be64 csrp;Lines of this file are not shown. View the raw message.
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Re: [PATCH v3 1/1] cxl: Remove driver
Hi Madhavan!
Quoted 6 lines
This patch has depenednecy with the first patch
https://lists.ozlabs.org/pipermail/linuxppc-dev/2025-February/280990.html
Which is already part of your staging tree. Can you please take this patch along with the previous patch.
If I merge the main cxl patch we'll have another conflict due to the docs patch below:
Quoted 1 line
I don't mind taking both patches but it seems more appropriate for a major feature removal like this to go through the relevant architecture tree.
Maybe the path of least resistance is for you to put the cxl removal in a separate branch and defer sending the pull request until after Linus has merged the initial SCSI bits for 6.15?
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Madhavan Srinivasan
maintainerRe: [PATCH v3 1/1] cxl: Remove driver
Quoted 15 lines · Martin K. Petersen
Hi Madhavan!
Quoted 6 lines
This patch has depenednecy with the first patch
https://lists.ozlabs.org/pipermail/linuxppc-dev/2025-February/280990.html
Which is already part of your staging tree. Can you please take this patch along with the previous patch.
If I merge the main cxl patch we'll have another conflict due to the docs patch below:
Quoted 1 line
Quoted 7 lines
I don't mind taking both patches but it seems more appropriate for a major feature removal like this to go through the relevant architecture tree.
Maybe the path of least resistance is for you to put the cxl removal in a separate branch and defer sending the pull request until after Linus has merged the initial SCSI bits for 6.15?
Yes, I agree and I was thinking of doing it, but wanted to check. I will send a separate PR after SCSI merge PR.
Thanks for response.
Maddy