Remove cxl and cxlflash drivers
Subsystems (5)
v2 cover Remove cxl and cxlflash drivers
This series removes the cxl and cxlflash drivers 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).
v1: https://patchwork.ozlabs.org/project/linuxppc-dev/list/?series=436014&state=*
v1->v2: rebase and update docs
Andrew Donnellan (2):
cxlflash: Remove driver
cxl: Remove driver
.../ABI/{obsolete => removed}/sysfs-class-cxl | 55 +-
Documentation/arch/powerpc/cxl.rst | 469 --
Documentation/arch/powerpc/cxlflash.rst | 433 --
Documentation/arch/powerpc/index.rst | 2 -
.../userspace-api/ioctl/ioctl-number.rst | 4 +-
MAINTAINERS | 21 -
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 --
drivers/scsi/Kconfig | 1 -
drivers/scsi/Makefile | 1 -
drivers/scsi/cxlflash/Kconfig | 15 -
drivers/scsi/cxlflash/Makefile | 5 -
drivers/scsi/cxlflash/backend.h | 48 -
drivers/scsi/cxlflash/common.h | 340 --
drivers/scsi/cxlflash/cxl_hw.c | 177 -
drivers/scsi/cxlflash/lunmgt.c | 278 --
drivers/scsi/cxlflash/main.c | 3970 -----------------
drivers/scsi/cxlflash/main.h | 129 -
drivers/scsi/cxlflash/ocxl_hw.c | 1399 ------
drivers/scsi/cxlflash/ocxl_hw.h | 72 -
drivers/scsi/cxlflash/sislite.h | 560 ---
drivers/scsi/cxlflash/superpipe.c | 2218 ---------
drivers/scsi/cxlflash/superpipe.h | 150 -
drivers/scsi/cxlflash/vlun.c | 1336 ------
drivers/scsi/cxlflash/vlun.h | 82 -
include/misc/cxl-base.h | 48 -
include/misc/cxl.h | 265 --
include/misc/cxllib.h | 129 -
include/uapi/misc/cxl.h | 156 -
include/uapi/scsi/cxlflash_ioctl.h | 276 --
.../filesystems/statmount/statmount_test.c | 13 +-
68 files changed, 49 insertions(+), 25819 deletions(-)
rename Documentation/ABI/{obsolete => removed}/sysfs-class-cxl (87%)
delete mode 100644 Documentation/arch/powerpc/cxl.rst
delete mode 100644 Documentation/arch/powerpc/cxlflash.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 drivers/scsi/cxlflash/Kconfig
delete mode 100644 drivers/scsi/cxlflash/Makefile
delete mode 100644 drivers/scsi/cxlflash/backend.h
delete mode 100644 drivers/scsi/cxlflash/common.h
delete mode 100644 drivers/scsi/cxlflash/cxl_hw.c
delete mode 100644 drivers/scsi/cxlflash/lunmgt.c
delete mode 100644 drivers/scsi/cxlflash/main.c
delete mode 100644 drivers/scsi/cxlflash/main.h
delete mode 100644 drivers/scsi/cxlflash/ocxl_hw.c
delete mode 100644 drivers/scsi/cxlflash/ocxl_hw.h
delete mode 100644 drivers/scsi/cxlflash/sislite.h
delete mode 100644 drivers/scsi/cxlflash/superpipe.c
delete mode 100644 drivers/scsi/cxlflash/superpipe.h
delete mode 100644 drivers/scsi/cxlflash/vlun.c
delete mode 100644 drivers/scsi/cxlflash/vlun.h
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.h
delete mode 100644 include/uapi/scsi/cxlflash_ioctl.hSignature · 1 line
2.48.1
PATCH v2 1/2 cxlflash: Remove driver
Remove the cxlflash driver for IBM CAPI Flash devices.
The cxlflash driver has received minimal maintenance for some time, and the CAPI Flash hardware that uses it is no longer commercially available.
Thanks to Uma Krishnan, Matthew Ochs and Manoj Kumar for their work on this driver over the years.
---
v2: rebase
--- Documentation/arch/powerpc/cxlflash.rst | 433 -- Documentation/arch/powerpc/index.rst | 1 - .../userspace-api/ioctl/ioctl-number.rst | 2 +- MAINTAINERS | 9 - drivers/scsi/Kconfig | 1 - drivers/scsi/Makefile | 1 - drivers/scsi/cxlflash/Kconfig | 15 - drivers/scsi/cxlflash/Makefile | 5 - drivers/scsi/cxlflash/backend.h | 48 - drivers/scsi/cxlflash/common.h | 340 -- drivers/scsi/cxlflash/cxl_hw.c | 177 - drivers/scsi/cxlflash/lunmgt.c | 278 -- drivers/scsi/cxlflash/main.c | 3970 ----------------- drivers/scsi/cxlflash/main.h | 129 - drivers/scsi/cxlflash/ocxl_hw.c | 1399 ------ drivers/scsi/cxlflash/ocxl_hw.h | 72 - drivers/scsi/cxlflash/sislite.h | 560 --- drivers/scsi/cxlflash/superpipe.c | 2218 --------- drivers/scsi/cxlflash/superpipe.h | 150 - drivers/scsi/cxlflash/vlun.c | 1336 ------ drivers/scsi/cxlflash/vlun.h | 82 - include/uapi/scsi/cxlflash_ioctl.h | 276 -- .../filesystems/statmount/statmount_test.c | 13 +- 23 files changed, 7 insertions(+), 11508 deletions(-) delete mode 100644 Documentation/arch/powerpc/cxlflash.rst delete mode 100644 drivers/scsi/cxlflash/Kconfig delete mode 100644 drivers/scsi/cxlflash/Makefile delete mode 100644 drivers/scsi/cxlflash/backend.h delete mode 100644 drivers/scsi/cxlflash/common.h delete mode 100644 drivers/scsi/cxlflash/cxl_hw.c delete mode 100644 drivers/scsi/cxlflash/lunmgt.c delete mode 100644 drivers/scsi/cxlflash/main.c delete mode 100644 drivers/scsi/cxlflash/main.h delete mode 100644 drivers/scsi/cxlflash/ocxl_hw.c delete mode 100644 drivers/scsi/cxlflash/ocxl_hw.h delete mode 100644 drivers/scsi/cxlflash/sislite.h delete mode 100644 drivers/scsi/cxlflash/superpipe.c delete mode 100644 drivers/scsi/cxlflash/superpipe.h delete mode 100644 drivers/scsi/cxlflash/vlun.c delete mode 100644 drivers/scsi/cxlflash/vlun.h delete mode 100644 include/uapi/scsi/cxlflash_ioctl.h
Documentation/arch/powerpc/cxlflash.rst deleted +0 -433
@@ -1,433 +0,0 @@ -================================ -Coherent Accelerator (CXL) Flash -================================ - -Introduction -============ - - The IBM Power architecture provides support for CAPI (Coherent - Accelerator Power Interface), which is available to certain PCIe slots - on Power 8 systems. CAPI can be thought of as a special tunneling - protocol through PCIe that allow PCIe adapters to look like special - purpose co-processors which can read or write an application's - memory and generate page faults. As a result, the host interface to - an adapter running in CAPI mode does not require the data buffers to - be mapped to the device's memory (IOMMU bypass) nor does it require - memory to be pinned. - - On Linux, Coherent Accelerator (CXL) kernel services present CAPI - devices as a PCI device by implementing a virtual PCI host bridge. - This abstraction simplifies the infrastructure and programming - model, allowing for drivers to look similar to other native PCI - device drivers. - - CXL provides a mechanism by which user space applications can - directly talk to a device (network or storage) bypassing the typical - kernel/device driver stack. The CXL Flash Adapter Driver enables a - user space application direct access to Flash storage. - - The CXL Flash Adapter Driver is a kernel module that sits in the - SCSI stack as a low level device driver (below the SCSI disk and - protocol drivers) for the IBM CXL Flash Adapter. This driver is - responsible for the initialization of the adapter, setting up the - special path for user space access, and performing error recovery. It - communicates directly the Flash Accelerator Functional Unit (AFU) - as described in Documentation/arch/powerpc/cxl.rst. - - The cxlflash driver supports two, mutually exclusive, modes of - operation at the device (LUN) level: - - - Any flash device (LUN) can be configured to be accessed as a - regular disk device (i.e.: /dev/sdc). This is the default mode. - - - Any flash device (LUN) can be configured to be accessed from - user space with a special block library. This mode further - specifies the means of accessing the device and provides for - either raw access to the entire LUN (referred to as direct - or physical LUN access) or access to a kernel/AFU-mediated - partition of the LUN (referred to as virtual LUN access). The - segmentation of a disk device into virtual LUNs is assisted - by special translation services provided by the Flash AFU. - -Overview -======== - - The Coherent Accelerator Interface Architecture (CAIA) introduces a - concept of a master context. A master typically has special privileges - granted to it by the kernel or hypervisor allowing it to perform AFU - wide management and control. The master may or may not be involved - directly in each user I/O, but at the minimum is involved in the - initial setup before the user application is allowed to send requests - directly to the AFU. - - The CXL Flash Adapter Driver establishes a master context with the - AFU. It uses memory mapped I/O (MMIO) for this control and setup. The - Adapter Problem Space Memory Map looks like this:: - - +-------------------------------+ - | 512 * 64 KB User MMIO | - | (per context) | - | User Accessible | - +-------------------------------+ - | 512 * 128 B per context | - | Provisioning and Control | - | Trusted Process accessible | - +-------------------------------+ - | 64 KB Global | - | Trusted Process accessible | - +-------------------------------+ - - This driver configures itself into the SCSI software stack as an - adapter driver. The driver is the only entity that is considered a - Trusted Process to program the Provisioning and Control and Global - areas in the MMIO Space shown above. The master context driver - discovers all LUNs attached to the CXL Flash adapter and instantiates - scsi block devices (/dev/sdb, /dev/sdc etc.) for each unique LUN - seen from each path. - - Once these scsi block devices are instantiated, an application - written to a specification provided by the block library may get - access to the Flash from user space (without requiring a system call). - - This master context driver also provides a series of ioctls for this - block library to enable this user space access. The driver supports - two modes for accessing the block device. - - The first mode is called a virtual mode. In this mode a single scsi - block device (/dev/sdb) may be carved up into any number of distinct - virtual LUNs. The virtual LUNs may be resized as long as the sum of - the sizes of all the virtual LUNs, along with the meta-data associated - with it does not exceed the physical capacity. - - The second mode is called the physical mode. In this mode a single - block device (/dev/sdb) may be opened directly by the block library - and the entire space for the LUN is available to the application. - - Only the physical mode provides persistence of the data. i.e. The - data written to the block device will survive application exit and - restart and also reboot. The virtual LUNs do not persist (i.e. do - not survive after the application terminates or the system reboots). - - -Block library API -================= - - Applications intending to get access to the CXL Flash from user - space should use the block library, as it abstracts the details of - interfacing directly with the cxlflash driver that are necessary for - performing administrative actions (i.e.: setup, tear down, resize). - The block library can be thought of as a 'user' of services, - implemented as IOCTLs, that are provided by the cxlflash driver - specifically for devices (LUNs) operating in user space access - mode. While it is not a requirement that applications understand - the interface between the block library and the cxlflash driver, - a high-level overview of each supported service (IOCTL) is provided - below. - - The block library can be found on GitHub: - http://github.com/open-power/capiflash - - -CXL Flash Driver LUN IOCTLs -=========================== - - Users, such as the block library, that wish to interface with a flash - device (LUN) via user space access need to use the services provided - by the cxlflash driver. As these services are implemented as ioctls, - a file descriptor handle must first be obtained in order to establish - the communication channel between a user and the kernel. This file - descriptor is obtained by opening the device special file associated - with the scsi disk device (/dev/sdb) that was created during LUN - discovery. As per the location of the cxlflash driver within the - SCSI protocol stack, this open is actually not seen by the cxlflash - driver. Upon successful open, the user receives a file descriptor - (herein referred to as fd1) that should be used for issuing the - subsequent ioctls listed below. - - The structure definitions for these IOCTLs are available in: - uapi/scsi/cxlflash_ioctl.h - -DK_CXLFLASH_ATTACH ------------------- - - This ioctl obtains, initializes, and starts a context using the CXL - kernel services. These services specify a context id (u16) by which - to uniquely identify the context and its allocated resources. The - services additionally provide a second file descriptor (herein - referred to as fd2) that is used by the block library to initiate - memory mapped I/O (via mmap()) to the CXL flash device and poll for - completion events. This file descriptor is intentionally installed by - this driver and not the CXL kernel services to allow for intermediary - notification and access in the event of a non-user-initiated close(), - such as a killed process. This design point is described in further - detail in the description for the DK_CXLFLASH_DETACH ioctl. - - There are a few important aspects regarding the "tokens" (context id - and fd2) that are provided back to the user: - - - These tokens are only valid for the process under which they - were created. The child of a forked process cannot continue - to use the context id or file descriptor created by its parent - (see DK_CXLFLASH_VLUN_CLONE for further details). - - - These tokens are only valid for the lifetime of the context and - the process under which they were created. Once either is - destroyed, the tokens are to be considered stale and subsequent - usage will result in errors. - - - A valid adapter file descriptor (fd2 >= 0) is only returned on - the initial attach for a context. Subsequent attaches to an - existing context (DK_CXLFLASH_ATTACH_REUSE_CONTEXT flag present) - do not provide the adapter file descriptor as it was previously - made known to the application. - - - When a context is no longer needed, the user shall detach from - the context via the DK_CXLFLASH_DETACH ioctl. When this ioctl - returns with a valid adapter file descriptor and the return flag - DK_CXLFLASH_APP_CLOSE_ADAP_FD is present, the application _must_ - close the adapter file descriptor following a successful detach. - - - When this ioctl returns with a valid fd2 and the return flag - DK_CXLFLASH_APP_CLOSE_ADAP_FD is present, the application _must_ - close fd2 in the following circumstances: - - + Following a successful detach of the last user of the context - + Following a successful recovery on the context's original fd2 - + In the child process of a fork(), following a clone ioctl, - on the fd2 associated with the source context - - - At any time, a close on fd2 will invalidate the tokens. Applications - should exercise caution to only close fd2 when appropriate (outlined - in the previous bullet) to avoid premature loss of I/O. - -DK_CXLFLASH_USER_DIRECT ------------------------ - This ioctl is responsible for transitioning the LUN to direct - (physical) mode access and configuring the AFU for direct access from - user space on a per-context basis. Additionally, the block size and - last logical block address (LBA) are returned to the user. - - As mentioned previously, when operating in user space access mode, - LUNs may be accessed in whole or in part. Only one mode is allowed - at a time and if one mode is active (outstanding references exist), - requests to use the LUN in a different mode are denied. - - The AFU is configured for direct access from user space by adding an - entry to the AFU's resource handle table. The index of the entry is - treated as a resource handle that is returned to the user. The user - is then able to use the handle to reference the LUN during I/O. - -DK_CXLFLASH_USER_VIRTUAL ------------------------- - This ioctl is responsible for transitioning the LUN to virtual mode - of access and configuring the AFU for virtual access from user space - on a per-context basis. Additionally, the block size and last logical - block address (LBA) are returned to the user. - - As mentioned previously, when operating in user space access mode, - LUNs may be accessed in whole or in part. Only one mode is allowed - at a time and if one mode is active (outstanding references exist), - requests to use the LUN in a different mode are denied. - - The AFU is configured for virtual access from user space by adding - an entry to the AFU's resource handle table. The index of the entry - is treated as a resource handle that is returned to the user. The - user is then able to use the handle to reference the LUN during I/O. - - By default, the virtual LUN is created with a size of 0. The user - would need to use the DK_CXLFLASH_VLUN_RESIZE ioctl to adjust the grow - the virtual LUN to a desired size. To avoid having to perform this - resize for the initial creation of the virtual LUN, the user has the - option of specifying a size as part of the DK_CXLFLASH_USER_VIRTUAL - ioctl, such that when success is returned to the user, the - resource handle that is provided is already referencing provisioned - storage. This is reflected by the last LBA being a non-zero value. - - When a LUN is accessible from more than one port, this ioctl will - return with the DK_CXLFLASH_ALL_PORTS_ACTIVE return flag set. This - provides the user with a hint that I/O can be retried in the event - of an I/O error as the LUN can be reached over multiple paths. - -DK_CXLFLASH_VLUN_RESIZE ------------------------ - This ioctl is responsible for resizing a previously created virtual - LUN and will fail if invoked upon a LUN that is not in virtual - mode. Upon success, an updated last LBA is returned to the user - indicating the new size of the virtual LUN associated with the - resource handle. - - The partitioning of virtual LUNs is jointly mediated by the cxlflash - driver and the AFU. An allocation table is kept for each LUN that is - operating in the virtual mode and used to program a LUN translation - table that the AFU references when provided with a resource handle. - - This ioctl can return -EAGAIN if an AFU sync operation takes too long. - In addition to returning a failure to user, cxlflash will also schedule - an asynchronous AFU reset. Should the user choose to retry the operation, - it is expected to succeed. If this ioctl fails with -EAGAIN, the user - can either retry the operation or treat it as a failure. - -DK_CXLFLASH_RELEASE -------------------- - This ioctl is responsible for releasing a previously obtained - reference to either a physical or virtual LUN. This can be - thought of as the inverse of the DK_CXLFLASH_USER_DIRECT or - DK_CXLFLASH_USER_VIRTUAL ioctls. Upon success, the resource handle - is no longer valid and the entry in the resource handle table is - made available to be used again. - - As part of the release process for virtual LUNs, the virtual LUN - is first resized to 0 to clear out and free the translation tables - associated with the virtual LUN reference. - -DK_CXLFLASH_DETACH ------------------- - This ioctl is responsible for unregistering a context with the - cxlflash driver and release outstanding resources that were - not explicitly released via the DK_CXLFLASH_RELEASE ioctl. Upon - success, all "tokens" which had been provided to the user from the - DK_CXLFLASH_ATTACH onward are no longer valid. - - When the DK_CXLFLASH_APP_CLOSE_ADAP_FD flag was returned on a successful - attach, the application _must_ close the fd2 associated with the context - following the detach of the final user of the context. - -DK_CXLFLASH_VLUN_CLONE ----------------------- - This ioctl is responsible for cloning a previously created - context to a more recently created context. It exists solely to - support maintaining user space access to storage after a process - forks. Upon success, the child process (which invoked the ioctl) - will have access to the same LUNs via the same resource handle(s) - as the parent, but under a different context. - - Context sharing across processes is not supported with CXL and - therefore each fork must be met with establishing a new context - for the child process. This ioctl simplifies the state management - and playback required by a user in such a scenario. When a process - forks, child process can clone the parents context by first creating - a context (via DK_CXLFLASH_ATTACH) and then using this ioctl to - perform the clone from the parent to the child. - - The clone itself is fairly simple. The resource handle and lun - translation tables are copied from the parent context to the child's - and then synced with the AFU. - - When the DK_CXLFLASH_APP_CLOSE_ADAP_FD flag was returned on a successful - attach, the application _must_ close the fd2 associated with the source - context (still resident/accessible in the parent process) following the - clone. This is to avoid a stale entry in the file descriptor table of the - child process. - - This ioctl can return -EAGAIN if an AFU sync operation takes too long. - In addition to returning a failure to user, cxlflash will also schedule - an asynchronous AFU reset. Should the user choose to retry the operation, - it is expected to succeed. If this ioctl fails with -EAGAIN, the user - can either retry the operation or treat it as a failure. - -DK_CXLFLASH_VERIFY ------------------- - This ioctl is used to detect various changes such as the capacity of - the disk changing, the number of LUNs visible changing, etc. In cases - where the changes affect the application (such as a LUN resize), the - cxlflash driver will report the changed state to the application. - - The user calls in when they want to validate that a LUN hasn't been - changed in response to a check condition. As the user is operating out - of band from the kernel, they will see these types of events without - the kernel's knowledge. When encountered, the user's architected - behavior is to call in to this ioctl, indicating what they want to - verify and passing along any appropriate information. For now, only - verifying a LUN change (ie: size different) with sense data is - supported. - -DK_CXLFLASH_RECOVER_AFU ------------------------ - This ioctl is used to drive recovery (if such an action is warranted) - of a specified user context. Any state associated with the user context - is re-established upon successful recovery. - - User contexts are put into an error condition when the device needs to - be reset or is terminating. Users are notified of this error condition - by seeing all 0xF's on an MMIO read. Upon encountering this, the - architected behavior for a user is to call into this ioctl to recover - their context. A user may also call into this ioctl at any time to - check if the device is operating normally. If a failure is returned - from this ioctl, the user is expected to gracefully clean up their - context via release/detach ioctls. Until they do, the context they - hold is not relinquished. The user may also optionally exit the process - at which time the context/resources they held will be freed as part of - the release fop. - - When the DK_CXLFLASH_APP_CLOSE_ADAP_FD flag was returned on a successful - attach, the application _must_ unmap and close the fd2 associated with the - original context following this ioctl returning success and indicating that - the context was recovered (DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET). - -DK_CXLFLASH_MANAGE_LUN ----------------------- - This ioctl is used to switch a LUN from a mode where it is available - for file-system access (legacy), to a mode where it is set aside for - exclusive user space access (superpipe). In case a LUN is visible - across multiple ports and adapters, this ioctl is used to uniquely - identify each LUN by its World Wide Node Name (WWNN). - - -CXL Flash Driver Host IOCTLs -============================ - - Each host adapter instance that is supported by the cxlflash driver - has a special character device associated with it to enable a set of - host management function. These character devices are hosted in a - class dedicated for cxlflash and can be accessed via `/dev/cxlflash/*`. - - Applications can be written to perform various functions using the - host ioctl APIs below. - - The structure definitions for these IOCTLs are available in: - uapi/scsi/cxlflash_ioctl.h - -HT_CXLFLASH_LUN_PROVISION -------------------------- - This ioctl is used to create and delete persistent LUNs on cxlflash - devices that lack an external LUN management interface. It is only - valid when used with AFUs that support the LUN provision capability. - - When sufficient space is available, LUNs can be created by specifying - the target port to host the LUN and a desired size in 4K blocks. Upon - success, the LUN ID and WWID of the created LUN will be returned and - the SCSI bus can be scanned to detect the change in LUN topology. Note - that partial allocations are not supported. Should a creation fail due - to a space issue, the target port can be queried for its current LUN - geometry. - - To remove a LUN, the device must first be disassociated from the Linux - SCSI subsystem. The LUN deletion can then be initiated by specifying a - target port and LUN ID. Upon success, the LUN geometry associated with - the port will be updated to reflect new number of provisioned LUNs and - available capacity. - - To query the LUN geometry of a port, the target port is specified and - upon success, the following information is presented: - - - Maximum number of provisioned LUNs allowed for the port - - Current number of provisioned LUNs for the port - - Maximum total capacity of provisioned LUNs for the port (4K blocks) - - Current total capacity of provisioned LUNs for the port (4K blocks) - - With this information, the number of available LUNs and capacity can be - can be calculated. - -HT_CXLFLASH_AFU_DEBUG ---------------------- - This ioctl is used to debug AFUs by supporting a command pass-through - interface. It is only valid when used with AFUs that support the AFU - debug capability. - - With exception of buffer management, AFU debug commands are opaque to - cxlflash and treated as pass-through. For debug commands that do require - data transfer, the user supplies an adequately sized data buffer and must - specify the data transfer direction with respect to the host. There is a - maximum transfer size of 256K imposed. Note that partial read completions - are not supported - when errors are experienced with a host read data - transfer, the data buffer is not copied back to the user.
Documentation/arch/powerpc/index.rst +0 -1
@@ -13,7 +13,6 @@ powerpc cpu_families cpu_features cxl - cxlflash dawr-power9 dexcr dscr
Documentation/userspace-api/ioctl/ioctl-number.rst +1 -1
@@ -373,7 +373,7 @@ Code Seq# Include File Comments 0xC0 00-0F linux/usb/iowarrior.h 0xCA 00-0F uapi/misc/cxl.h 0xCA 10-2F uapi/misc/ocxl.h -0xCA 80-BF uapi/scsi/cxlflash_ioctl.h +0xCA 80-BF uapi/scsi/cxlflash_ioctl.h Dead since 6.14 0xCB 00-1F CBM serial IEC bus in development: <mailto:[email protected]> 0xCC 00-0F drivers/misc/ibmvmc.h pseries VMC driver
MAINTAINERS +0 -9
@@ -6318,15 +6318,6 @@ F: drivers/misc/cxl/ F: include/misc/cxl* F: include/uapi/misc/cxl.h -CXLFLASH (IBM Coherent Accelerator Processor Interface CAPI Flash) SCSI DRIVER -M: Manoj N. Kumar <[email protected]> -M: Uma Krishnan <[email protected]> -L: [email protected] -S: Obsolete -F: Documentation/arch/powerpc/cxlflash.rst -F: drivers/scsi/cxlflash/ -F: include/uapi/scsi/cxlflash_ioctl.h - CYBERPRO FB DRIVER M: Russell King <[email protected]> L: [email protected] (moderated for non-subscribers)
drivers/scsi/Kconfig +0 -1
@@ -336,7 +336,6 @@ source "drivers/scsi/cxgbi/Kconfig" source "drivers/scsi/bnx2i/Kconfig" source "drivers/scsi/bnx2fc/Kconfig" source "drivers/scsi/be2iscsi/Kconfig" -source "drivers/scsi/cxlflash/Kconfig" config SGIWD93_SCSI tristate "SGI WD93C93 SCSI Driver"
drivers/scsi/Makefile +0 -1
@@ -96,7 +96,6 @@ obj-$(CONFIG_SCSI_SYM53C8XX_2) += sym53c8xx_2/ obj-$(CONFIG_SCSI_ZALON) += zalon7xx.o obj-$(CONFIG_SCSI_DC395x) += dc395x.o obj-$(CONFIG_SCSI_AM53C974) += esp_scsi.o am53c974.o -obj-$(CONFIG_CXLFLASH) += cxlflash/ obj-$(CONFIG_MEGARAID_LEGACY) += megaraid.o obj-$(CONFIG_MEGARAID_NEWGEN) += megaraid/ obj-$(CONFIG_MEGARAID_SAS) += megaraid/
drivers/scsi/cxlflash/Kconfig deleted +0 -15
@@ -1,15 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# -# IBM CXL-attached Flash Accelerator SCSI Driver -# - -config CXLFLASH - tristate "Support for IBM CAPI Flash (DEPRECATED)" - depends on PCI && SCSI && (CXL || OCXL) && EEH - select IRQ_POLL - help - The cxlflash driver is deprecated and will be removed in a future - kernel release. - - Allows CAPI Accelerated IO to Flash - If unsure, say N.
drivers/scsi/cxlflash/Makefile deleted +0 -5
@@ -1,5 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_CXLFLASH) += cxlflash.o -cxlflash-y += main.o superpipe.o lunmgt.o vlun.o -cxlflash-$(CONFIG_CXL) += cxl_hw.o -cxlflash-$(CONFIG_OCXL) += ocxl_hw.o
drivers/scsi/cxlflash/backend.h deleted +0 -48
48 lines not on this page · raw message
drivers/scsi/cxlflash/common.h deleted +0 -340
340 lines not on this page · raw message
drivers/scsi/cxlflash/cxl_hw.c deleted +0 -177
177 lines not on this page · raw message
drivers/scsi/cxlflash/lunmgt.c deleted +0 -278
278 lines not on this page · raw message
drivers/scsi/cxlflash/main.c deleted +0 -3970
1,660 lines not on this page · raw message
drivers/scsi/cxlflash/main.h deleted +0 -129
129 lines not on this page · raw message
drivers/scsi/cxlflash/ocxl_hw.c deleted +0 -1399
1,399 lines not on this page · raw message
drivers/scsi/cxlflash/ocxl_hw.h deleted +0 -72
72 lines not on this page · raw message
drivers/scsi/cxlflash/sislite.h deleted +0 -560
560 lines not on this page · raw message
drivers/scsi/cxlflash/superpipe.c deleted +0 -2218
2,218 lines not on this page · raw message
drivers/scsi/cxlflash/superpipe.h deleted +0 -150
150 lines not on this page · raw message
drivers/scsi/cxlflash/vlun.c deleted +0 -1336
1,336 lines not on this page · raw message
drivers/scsi/cxlflash/vlun.h deleted +0 -82
82 lines not on this page · raw message
include/uapi/scsi/cxlflash_ioctl.h deleted +0 -276
276 lines not on this page · raw message
tools/testing/selftests/filesystems/statmount/statmount_test.c +6 -7
Lines of this file are not shown. View the 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.
PATCH v2 2/2 cxl: Remove driver
In reply to Andrew DonnellanRemove 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.
---
v2: rebase, update docs
---
.../ABI/{obsolete => removed}/sysfs-class-cxl | 55 +-
Documentation/arch/powerpc/cxl.rst | 469 ----
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(+), 14311 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 -469
469 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
@@ -371,7 +371,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
@@ -6306,18 +6306,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
729 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 v2 1/2] cxlflash: Remove driver
In reply to Andrew DonnellanQuoted 9 lines · Andrew Donnellan
Remove the cxlflash driver for IBM CAPI Flash devices.
The cxlflash driver has received minimal maintenance for some time, and the CAPI Flash hardware that uses it is no longer commercially available.
Thanks to Uma Krishnan, Matthew Ochs and Manoj Kumar for their work on this driver over the years.
Signed-off-by Andrew Donnellan <[email protected]>
Thanks!
Fred
Quoted 11,728 lines
---
v2: rebase--- Documentation/arch/powerpc/cxlflash.rst | 433 -- Documentation/arch/powerpc/index.rst | 1 - .../userspace-api/ioctl/ioctl-number.rst | 2 +- MAINTAINERS | 9 - drivers/scsi/Kconfig | 1 - drivers/scsi/Makefile | 1 - drivers/scsi/cxlflash/Kconfig | 15 - drivers/scsi/cxlflash/Makefile | 5 - drivers/scsi/cxlflash/backend.h | 48 - drivers/scsi/cxlflash/common.h | 340 -- drivers/scsi/cxlflash/cxl_hw.c | 177 - drivers/scsi/cxlflash/lunmgt.c | 278 -- drivers/scsi/cxlflash/main.c | 3970 ----------------- drivers/scsi/cxlflash/main.h | 129 - drivers/scsi/cxlflash/ocxl_hw.c | 1399 ------ drivers/scsi/cxlflash/ocxl_hw.h | 72 - drivers/scsi/cxlflash/sislite.h | 560 --- drivers/scsi/cxlflash/superpipe.c | 2218 --------- drivers/scsi/cxlflash/superpipe.h | 150 - drivers/scsi/cxlflash/vlun.c | 1336 ------ drivers/scsi/cxlflash/vlun.h | 82 - include/uapi/scsi/cxlflash_ioctl.h | 276 -- .../filesystems/statmount/statmount_test.c | 13 +- 23 files changed, 7 insertions(+), 11508 deletions(-)delete mode 100644
Documentation/arch/powerpc/cxlflash.rstdelete mode 100644drivers/scsi/cxlflash/Kconfigdelete mode 100644drivers/scsi/cxlflash/Makefiledelete mode 100644drivers/scsi/cxlflash/backend.hdelete mode 100644drivers/scsi/cxlflash/common.hdelete mode 100644drivers/scsi/cxlflash/cxl_hw.cdelete mode 100644drivers/scsi/cxlflash/lunmgt.cdelete mode 100644drivers/scsi/cxlflash/main.cdelete mode 100644drivers/scsi/cxlflash/main.hdelete mode 100644drivers/scsi/cxlflash/ocxl_hw.cdelete mode 100644drivers/scsi/cxlflash/ocxl_hw.hdelete mode 100644drivers/scsi/cxlflash/sislite.hdelete mode 100644drivers/scsi/cxlflash/superpipe.cdelete mode 100644drivers/scsi/cxlflash/superpipe.hdelete mode 100644drivers/scsi/cxlflash/vlun.cdelete mode 100644drivers/scsi/cxlflash/vlun.hdelete mode 100644include/uapi/scsi/cxlflash_ioctl.hDocumentation/arch/powerpc/cxlflash.rst deleted +0
-433@@ -1,433 +0,0 @@ -================================ -Coherent Accelerator (CXL) Flash -================================ - -Introduction -============ - - The IBM Power architecture provides support for CAPI (Coherent - Accelerator Power Interface), which is available to certain PCIe slots - on Power 8 systems. CAPI can be thought of as a special tunneling - protocol through PCIe that allow PCIe adapters to look like special - purpose co-processors which can read or write an application's - memory and generate page faults. As a result, the host interface to - an adapter running in CAPI mode does not require the data buffers to - be mapped to the device's memory (IOMMU bypass) nor does it require - memory to be pinned. - - On Linux, Coherent Accelerator (CXL) kernel services present CAPI - devices as a PCI device by implementing a virtual PCI host bridge. - This abstraction simplifies the infrastructure and programming - model, allowing for drivers to look similar to other native PCI - device drivers. - - CXL provides a mechanism by which user space applications can - directly talk to a device (network or storage) bypassing the typical - kernel/device driver stack. The CXL Flash Adapter Driver enables a - user space application direct access to Flash storage. - - The CXL Flash Adapter Driver is a kernel module that sits in the - SCSI stack as a low level device driver (below the SCSI disk and - protocol drivers) for the IBM CXL Flash Adapter. This driver is - responsible for the initialization of the adapter, setting up the - special path for user space access, and performing error recovery. It - communicates directly the Flash Accelerator Functional Unit (AFU) - as described in Documentation/arch/powerpc/cxl.rst. - - The cxlflash driver supports two, mutually exclusive, modes of - operation at the device (LUN) level: - - - Any flash device (LUN) can be configured to be accessed as a - regular disk device (i.e.: /dev/sdc). This is the default mode. - - - Any flash device (LUN) can be configured to be accessed from - user space with a special block library. This mode further - specifies the means of accessing the device and provides for - either raw access to the entire LUN (referred to as direct - or physical LUN access) or access to a kernel/AFU-mediated - partition of the LUN (referred to as virtual LUN access). The - segmentation of a disk device into virtual LUNs is assisted - by special translation services provided by the Flash AFU. - -Overview -======== - - The Coherent Accelerator Interface Architecture (CAIA) introduces a - concept of a master context. A master typically has special privileges - granted to it by the kernel or hypervisor allowing it to perform AFU - wide management and control. The master may or may not be involved - directly in each user I/O, but at the minimum is involved in the - initial setup before the user application is allowed to send requests - directly to the AFU. - - The CXL Flash Adapter Driver establishes a master context with the - AFU. It uses memory mapped I/O (MMIO) for this control and setup. The - Adapter Problem Space Memory Map looks like this:: - - +-------------------------------+ - | 512 * 64 KB User MMIO | - | (per context) | - | User Accessible | - +-------------------------------+ - | 512 * 128 B per context | - | Provisioning and Control | - | Trusted Process accessible | - +-------------------------------+ - | 64 KB Global | - | Trusted Process accessible | - +-------------------------------+ - - This driver configures itself into the SCSI software stack as an - adapter driver. The driver is the only entity that is considered a - Trusted Process to program the Provisioning and Control and Global - areas in the MMIO Space shown above. The master context driver - discovers all LUNs attached to the CXL Flash adapter and instantiates - scsi block devices (/dev/sdb, /dev/sdc etc.) for each unique LUN - seen from each path. - - Once these scsi block devices are instantiated, an application - written to a specification provided by the block library may get - access to the Flash from user space (without requiring a system call). - - This master context driver also provides a series of ioctls for this - block library to enable this user space access. The driver supports - two modes for accessing the block device. - - The first mode is called a virtual mode. In this mode a single scsi - block device (/dev/sdb) may be carved up into any number of distinct - virtual LUNs. The virtual LUNs may be resized as long as the sum of - the sizes of all the virtual LUNs, along with the meta-data associated - with it does not exceed the physical capacity. - - The second mode is called the physical mode. In this mode a single - block device (/dev/sdb) may be opened directly by the block library - and the entire space for the LUN is available to the application. - - Only the physical mode provides persistence of the data. i.e. The - data written to the block device will survive application exit and - restart and also reboot. The virtual LUNs do not persist (i.e. do - not survive after the application terminates or the system reboots). - - -Block library API -================= - - Applications intending to get access to the CXL Flash from user - space should use the block library, as it abstracts the details of - interfacing directly with the cxlflash driver that are necessary for - performing administrative actions (i.e.: setup, tear down, resize). - The block library can be thought of as a 'user' of services, - implemented as IOCTLs, that are provided by the cxlflash driver - specifically for devices (LUNs) operating in user space access - mode. While it is not a requirement that applications understand - the interface between the block library and the cxlflash driver, - a high-level overview of each supported service (IOCTL) is provided - below. - - The block library can be found on GitHub: - http://github.com/open-power/capiflash - - -CXL Flash Driver LUN IOCTLs -=========================== - - Users, such as the block library, that wish to interface with a flash - device (LUN) via user space access need to use the services provided - by the cxlflash driver. As these services are implemented as ioctls, - a file descriptor handle must first be obtained in order to establish - the communication channel between a user and the kernel. This file - descriptor is obtained by opening the device special file associated - with the scsi disk device (/dev/sdb) that was created during LUN - discovery. As per the location of the cxlflash driver within the - SCSI protocol stack, this open is actually not seen by the cxlflash - driver. Upon successful open, the user receives a file descriptor - (herein referred to as fd1) that should be used for issuing the - subsequent ioctls listed below. - - The structure definitions for these IOCTLs are available in: - uapi/scsi/cxlflash_ioctl.h - -DK_CXLFLASH_ATTACH ------------------- - - This ioctl obtains, initializes, and starts a context using the CXL - kernel services. These services specify a context id (u16) by which - to uniquely identify the context and its allocated resources. The - services additionally provide a second file descriptor (herein - referred to as fd2) that is used by the block library to initiate - memory mapped I/O (via mmap()) to the CXL flash device and poll for - completion events. This file descriptor is intentionally installed by - this driver and not the CXL kernel services to allow for intermediary - notification and access in the event of a non-user-initiated close(), - such as a killed process. This design point is described in further - detail in the description for the DK_CXLFLASH_DETACH ioctl. - - There are a few important aspects regarding the "tokens" (context id - and fd2) that are provided back to the user: - - - These tokens are only valid for the process under which they - were created. The child of a forked process cannot continue - to use the context id or file descriptor created by its parent - (see DK_CXLFLASH_VLUN_CLONE for further details). - - - These tokens are only valid for the lifetime of the context and - the process under which they were created. Once either is - destroyed, the tokens are to be considered stale and subsequent - usage will result in errors. - - - A valid adapter file descriptor (fd2 >= 0) is only returned on - the initial attach for a context. Subsequent attaches to an - existing context (DK_CXLFLASH_ATTACH_REUSE_CONTEXT flag present) - do not provide the adapter file descriptor as it was previously - made known to the application. - - - When a context is no longer needed, the user shall detach from - the context via the DK_CXLFLASH_DETACH ioctl. When this ioctl - returns with a valid adapter file descriptor and the return flag - DK_CXLFLASH_APP_CLOSE_ADAP_FD is present, the application _must_ - close the adapter file descriptor following a successful detach. - - - When this ioctl returns with a valid fd2 and the return flag - DK_CXLFLASH_APP_CLOSE_ADAP_FD is present, the application _must_ - close fd2 in the following circumstances: - - + Following a successful detach of the last user of the context - + Following a successful recovery on the context's original fd2 - + In the child process of a fork(), following a clone ioctl, - on the fd2 associated with the source context - - - At any time, a close on fd2 will invalidate the tokens. Applications - should exercise caution to only close fd2 when appropriate (outlined - in the previous bullet) to avoid premature loss of I/O. - -DK_CXLFLASH_USER_DIRECT ------------------------ - This ioctl is responsible for transitioning the LUN to direct - (physical) mode access and configuring the AFU for direct access from - user space on a per-context basis. Additionally, the block size and - last logical block address (LBA) are returned to the user. - - As mentioned previously, when operating in user space access mode, - LUNs may be accessed in whole or in part. Only one mode is allowed - at a time and if one mode is active (outstanding references exist), - requests to use the LUN in a different mode are denied. - - The AFU is configured for direct access from user space by adding an - entry to the AFU's resource handle table. The index of the entry is - treated as a resource handle that is returned to the user. The user - is then able to use the handle to reference the LUN during I/O. - -DK_CXLFLASH_USER_VIRTUAL ------------------------- - This ioctl is responsible for transitioning the LUN to virtual mode - of access and configuring the AFU for virtual access from user space - on a per-context basis. Additionally, the block size and last logical - block address (LBA) are returned to the user. - - As mentioned previously, when operating in user space access mode, - LUNs may be accessed in whole or in part. Only one mode is allowed - at a time and if one mode is active (outstanding references exist), - requests to use the LUN in a different mode are denied. - - The AFU is configured for virtual access from user space by adding - an entry to the AFU's resource handle table. The index of the entry - is treated as a resource handle that is returned to the user. The - user is then able to use the handle to reference the LUN during I/O. - - By default, the virtual LUN is created with a size of 0. The user - would need to use the DK_CXLFLASH_VLUN_RESIZE ioctl to adjust the grow - the virtual LUN to a desired size. To avoid having to perform this - resize for the initial creation of the virtual LUN, the user has the - option of specifying a size as part of the DK_CXLFLASH_USER_VIRTUAL - ioctl, such that when success is returned to the user, the - resource handle that is provided is already referencing provisioned - storage. This is reflected by the last LBA being a non-zero value. - - When a LUN is accessible from more than one port, this ioctl will - return with the DK_CXLFLASH_ALL_PORTS_ACTIVE return flag set. This - provides the user with a hint that I/O can be retried in the event - of an I/O error as the LUN can be reached over multiple paths. - -DK_CXLFLASH_VLUN_RESIZE ------------------------ - This ioctl is responsible for resizing a previously created virtual - LUN and will fail if invoked upon a LUN that is not in virtual - mode. Upon success, an updated last LBA is returned to the user - indicating the new size of the virtual LUN associated with the - resource handle. - - The partitioning of virtual LUNs is jointly mediated by the cxlflash - driver and the AFU. An allocation table is kept for each LUN that is - operating in the virtual mode and used to program a LUN translation - table that the AFU references when provided with a resource handle. - - This ioctl can return -EAGAIN if an AFU sync operation takes too long. - In addition to returning a failure to user, cxlflash will also schedule - an asynchronous AFU reset. Should the user choose to retry the operation, - it is expected to succeed. If this ioctl fails with -EAGAIN, the user - can either retry the operation or treat it as a failure. - -DK_CXLFLASH_RELEASE -------------------- - This ioctl is responsible for releasing a previously obtained - reference to either a physical or virtual LUN. This can be - thought of as the inverse of the DK_CXLFLASH_USER_DIRECT or - DK_CXLFLASH_USER_VIRTUAL ioctls. Upon success, the resource handle - is no longer valid and the entry in the resource handle table is - made available to be used again. - - As part of the release process for virtual LUNs, the virtual LUN - is first resized to 0 to clear out and free the translation tables - associated with the virtual LUN reference. - -DK_CXLFLASH_DETACH ------------------- - This ioctl is responsible for unregistering a context with the - cxlflash driver and release outstanding resources that were - not explicitly released via the DK_CXLFLASH_RELEASE ioctl. Upon - success, all "tokens" which had been provided to the user from the - DK_CXLFLASH_ATTACH onward are no longer valid. - - When the DK_CXLFLASH_APP_CLOSE_ADAP_FD flag was returned on a successful - attach, the application _must_ close the fd2 associated with the context - following the detach of the final user of the context. - -DK_CXLFLASH_VLUN_CLONE ----------------------- - This ioctl is responsible for cloning a previously created - context to a more recently created context. It exists solely to - support maintaining user space access to storage after a process - forks. Upon success, the child process (which invoked the ioctl) - will have access to the same LUNs via the same resource handle(s) - as the parent, but under a different context. - - Context sharing across processes is not supported with CXL and - therefore each fork must be met with establishing a new context - for the child process. This ioctl simplifies the state management - and playback required by a user in such a scenario. When a process - forks, child process can clone the parents context by first creating - a context (via DK_CXLFLASH_ATTACH) and then using this ioctl to - perform the clone from the parent to the child. - - The clone itself is fairly simple. The resource handle and lun - translation tables are copied from the parent context to the child's - and then synced with the AFU. - - When the DK_CXLFLASH_APP_CLOSE_ADAP_FD flag was returned on a successful - attach, the application _must_ close the fd2 associated with the source - context (still resident/accessible in the parent process) following the - clone. This is to avoid a stale entry in the file descriptor table of the - child process. - - This ioctl can return -EAGAIN if an AFU sync operation takes too long. - In addition to returning a failure to user, cxlflash will also schedule - an asynchronous AFU reset. Should the user choose to retry the operation, - it is expected to succeed. If this ioctl fails with -EAGAIN, the user - can either retry the operation or treat it as a failure. - -DK_CXLFLASH_VERIFY ------------------- - This ioctl is used to detect various changes such as the capacity of - the disk changing, the number of LUNs visible changing, etc. In cases - where the changes affect the application (such as a LUN resize), the - cxlflash driver will report the changed state to the application. - - The user calls in when they want to validate that a LUN hasn't been - changed in response to a check condition. As the user is operating out - of band from the kernel, they will see these types of events without - the kernel's knowledge. When encountered, the user's architected - behavior is to call in to this ioctl, indicating what they want to - verify and passing along any appropriate information. For now, only - verifying a LUN change (ie: size different) with sense data is - supported. - -DK_CXLFLASH_RECOVER_AFU ------------------------ - This ioctl is used to drive recovery (if such an action is warranted) - of a specified user context. Any state associated with the user context - is re-established upon successful recovery. - - User contexts are put into an error condition when the device needs to - be reset or is terminating. Users are notified of this error condition - by seeing all 0xF's on an MMIO read. Upon encountering this, the - architected behavior for a user is to call into this ioctl to recover - their context. A user may also call into this ioctl at any time to - check if the device is operating normally. If a failure is returned - from this ioctl, the user is expected to gracefully clean up their - context via release/detach ioctls. Until they do, the context they - hold is not relinquished. The user may also optionally exit the process - at which time the context/resources they held will be freed as part of - the release fop. - - When the DK_CXLFLASH_APP_CLOSE_ADAP_FD flag was returned on a successful - attach, the application _must_ unmap and close the fd2 associated with the - original context following this ioctl returning success and indicating that - the context was recovered (DK_CXLFLASH_RECOVER_AFU_CONTEXT_RESET). - -DK_CXLFLASH_MANAGE_LUN ----------------------- - This ioctl is used to switch a LUN from a mode where it is available - for file-system access (legacy), to a mode where it is set aside for - exclusive user space access (superpipe). In case a LUN is visible - across multiple ports and adapters, this ioctl is used to uniquely - identify each LUN by its World Wide Node Name (WWNN). - - -CXL Flash Driver Host IOCTLs -============================ - - Each host adapter instance that is supported by the cxlflash driver - has a special character device associated with it to enable a set of - host management function. These character devices are hosted in a - class dedicated for cxlflash and can be accessed via `/dev/cxlflash/*`. - - Applications can be written to perform various functions using the - host ioctl APIs below. - - The structure definitions for these IOCTLs are available in: - uapi/scsi/cxlflash_ioctl.h - -HT_CXLFLASH_LUN_PROVISION -------------------------- - This ioctl is used to create and delete persistent LUNs on cxlflash - devices that lack an external LUN management interface. It is only - valid when used with AFUs that support the LUN provision capability. - - When sufficient space is available, LUNs can be created by specifying - the target port to host the LUN and a desired size in 4K blocks. Upon - success, the LUN ID and WWID of the created LUN will be returned and - the SCSI bus can be scanned to detect the change in LUN topology. Note - that partial allocations are not supported. Should a creation fail due - to a space issue, the target port can be queried for its current LUN - geometry. - - To remove a LUN, the device must first be disassociated from the Linux - SCSI subsystem. The LUN deletion can then be initiated by specifying a - target port and LUN ID. Upon success, the LUN geometry associated with - the port will be updated to reflect new number of provisioned LUNs and - available capacity. - - To query the LUN geometry of a port, the target port is specified and - upon success, the following information is presented: - - - Maximum number of provisioned LUNs allowed for the port - - Current number of provisioned LUNs for the port - - Maximum total capacity of provisioned LUNs for the port (4K blocks) - - Current total capacity of provisioned LUNs for the port (4K blocks) - - With this information, the number of available LUNs and capacity can be - can be calculated. - -HT_CXLFLASH_AFU_DEBUG ---------------------- - This ioctl is used to debug AFUs by supporting a command pass-through - interface. It is only valid when used with AFUs that support the AFU - debug capability. - - With exception of buffer management, AFU debug commands are opaque to - cxlflash and treated as pass-through. For debug commands that do require - data transfer, the user supplies an adequately sized data buffer and must - specify the data transfer direction with respect to the host. There is a - maximum transfer size of 256K imposed. Note that partial read completions - are not supported - when errors are experienced with a host read data - transfer, the data buffer is not copied back to the user.Documentation/arch/powerpc/index.rst +0
-1@@ -13,7 +13,6 @@ powerpc cpu_families cpu_features cxl - cxlflash dawr-power9 dexcr dscrDocumentation/userspace-api/ioctl/ioctl-number.rst +1
-1@@ -373,7 +373,7 @@ Code Seq# Include File Comments 0xC0 00-0F linux/usb/iowarrior.h 0xCA 00-0F uapi/misc/cxl.h 0xCA 10-2F uapi/misc/ocxl.h -0xCA 80-BF uapi/scsi/cxlflash_ioctl.h +0xCA 80-BF uapi/scsi/cxlflash_ioctl.h Dead since 6.14 0xCB 00-1F CBM serial IEC bus in development: <mailto:[email protected]> 0xCC 00-0F drivers/misc/ibmvmc.h pseries VMC driverMAINTAINERS +0
-9@@ -6318,15 +6318,6 @@ F: drivers/misc/cxl/ F: include/misc/cxl* F: include/uapi/misc/cxl.h -CXLFLASH (IBM Coherent Accelerator Processor Interface CAPI Flash) SCSI DRIVER -M: Manoj N. Kumar <[email protected]> -M: Uma Krishnan <[email protected]> -L: [email protected] -S: Obsolete -F: Documentation/arch/powerpc/cxlflash.rst -F: drivers/scsi/cxlflash/ -F: include/uapi/scsi/cxlflash_ioctl.h - CYBERPRO FB DRIVER M: Russell King <[email protected]> L: [email protected] (moderated for non-subscribers)drivers/scsi/Kconfig +0
-1@@ -336,7 +336,6 @@ source "drivers/scsi/cxgbi/Kconfig" source "drivers/scsi/bnx2i/Kconfig" source "drivers/scsi/bnx2fc/Kconfig" source "drivers/scsi/be2iscsi/Kconfig" -source "drivers/scsi/cxlflash/Kconfig" config SGIWD93_SCSI tristate "SGI WD93C93 SCSI Driver"drivers/scsi/Makefile +0
-1@@ -96,7 +96,6 @@ obj-$(CONFIG_SCSI_SYM53C8XX_2) += sym53c8xx_2/ obj-$(CONFIG_SCSI_ZALON) += zalon7xx.o obj-$(CONFIG_SCSI_DC395x) += dc395x.o obj-$(CONFIG_SCSI_AM53C974) += esp_scsi.o am53c974.o -obj-$(CONFIG_CXLFLASH) += cxlflash/ obj-$(CONFIG_MEGARAID_LEGACY) += megaraid.o obj-$(CONFIG_MEGARAID_NEWGEN) += megaraid/ obj-$(CONFIG_MEGARAID_SAS) += megaraid/drivers/scsi/cxlflash/Kconfig deleted +0
-15@@ -1,15 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -# -# IBM CXL-attached Flash Accelerator SCSI Driver -# - -config CXLFLASH - tristate "Support for IBM CAPI Flash (DEPRECATED)" - depends on PCI && SCSI && (CXL || OCXL) && EEH - select IRQ_POLL - help - The cxlflash driver is deprecated and will be removed in a future - kernel release. - - Allows CAPI Accelerated IO to Flash - If unsure, say N.drivers/scsi/cxlflash/Makefile deleted +0
-5@@ -1,5 +0,0 @@ -# SPDX-License-Identifier: GPL-2.0-only -obj-$(CONFIG_CXLFLASH) += cxlflash.o -cxlflash-y += main.o superpipe.o lunmgt.o vlun.o -cxlflash-$(CONFIG_CXL) += cxl_hw.o -cxlflash-$(CONFIG_OCXL) += ocxl_hw.odrivers/scsi/cxlflash/backend.h deleted +0
-48@@ -1,48 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* -* CXL Flash Device Driver -* -* Written by: Matthew R. Ochs <[email protected]>, IBM Corporation -* Uma Krishnan <[email protected]>, IBM Corporation -* -* Copyright (C) 2018 IBM Corporation -*/ - -#ifndef _CXLFLASH_BACKEND_H -#define _CXLFLASH_BACKEND_H - -extern const struct cxlflash_backend_ops cxlflash_cxl_ops; -extern const struct cxlflash_backend_ops cxlflash_ocxl_ops; - -struct cxlflash_backend_ops { -struct module *module; -void __iomem * (*psa_map)(void *ctx_cookie); -void (*psa_unmap)(void __iomem *addr); -int (*process_element)(void *ctx_cookie); -int (*map_afu_irq)(void *ctx_cookie,int num,irq_handler_t handler, -void *cookie,char *name); -void (*unmap_afu_irq)(void *ctx_cookie,int num,void *cookie); -u64 (*get_irq_objhndl)(void *ctx_cookie,int irq); -int (*start_context)(void *ctx_cookie); -int (*stop_context)(void *ctx_cookie); -int (*afu_reset)(void *ctx_cookie); -void (*set_master)(void *ctx_cookie); -void * (*get_context)(struct pci_dev *dev,void *afu_cookie); -void * (*dev_context_init)(struct pci_dev *dev,void *afu_cookie); -int (*release_context)(void *ctx_cookie); -void (*perst_reloads_same_image)(void *afu_cookie,bool image); -ssize_t (*read_adapter_vpd)(struct pci_dev *dev,void *buf, -size_t count); -int (*allocate_afu_irqs)(void *ctx_cookie,int num); -void (*free_afu_irqs)(void *ctx_cookie); -void * (*create_afu)(struct pci_dev *dev); -void (*destroy_afu)(void *afu_cookie); -struct file * (*get_fd)(void *ctx_cookie,struct file_operations *fops, -int *fd); -void * (*fops_get_context)(struct file *file); -int (*start_work)(void *ctx_cookie,u64 irqs); -int (*fd_mmap)(struct file *file,struct vm_area_struct *vm); -int (*fd_release)(struct inode *inode,struct file *file); -}; - -#endif /* _CXLFLASH_BACKEND_H */ drivers/scsi/cxlflash/common.h deleted +0
-340@@ -1,340 +0,0 @@ -/* SPDX-License-Identifier: GPL-2.0-or-later */ -/* -* CXL Flash Device Driver -* -* Written by: Manoj N. Kumar <[email protected]>, IBM Corporation -* Matthew R. Ochs <[email protected]>, IBM Corporation -* -* Copyright (C) 2015 IBM Corporation -*/ - -#ifndef _CXLFLASH_COMMON_H -#define _CXLFLASH_COMMON_H - -#include <linux/async.h> -#include <linux/cdev.h> -#include <linux/irq_poll.h> -#include <linux/list.h> -#include <linux/rwsem.h> -#include <linux/types.h> -#include <scsi/scsi.h> -#include <scsi/scsi_cmnd.h> -#include <scsi/scsi_device.h> - -#include "backend.h" - -extern const struct file_operations cxlflash_cxl_fops; - -#define MAX_CONTEXT CXLFLASH_MAX_CONTEXT/* num contexts per afu */ -#define MAX_FC_PORTS CXLFLASH_MAX_FC_PORTS/* max ports per AFU */ -#define LEGACY_FC_PORTS 2/* legacy ports per AFU */ - -#define CHAN2PORTBANK (_x) ((_x) >> ilog2(CXLFLASH_NUM_FC_PORTS_PER_BANK)) -#define CHAN2BANKPORT (_x) ((_x) & (CXLFLASH_NUM_FC_PORTS_PER_BANK - 1)) - -#define CHAN2PORTMASK (_x) (1 << (_x))/* channel to port mask */ -#define PORTMASK2CHAN (_x) (ilog2((_x)))/* port mask to channel */ -#define PORTNUM2CHAN (_x) ((_x) - 1)/* port number to channel */ - -#define CXLFLASH_BLOCK_SIZE 4096/* 4K blocks */ -#define CXLFLASH_MAX_XFER_SIZE 16777216/* 16MB transfer */ -#define CXLFLASH_MAX_SECTORS (CXLFLASH_MAX_XFER_SIZE/512)/* SCSI wants -* max_sectors -* in units of -* 512 byte -* sectors -*/ - -#define MAX_RHT_PER_CONTEXT (PAGE_SIZE / sizeof(struct sisl_rht_entry)) - -/* AFU command retry limit */ -#define MC_RETRY_CNT 5/* Sufficient for SCSI and certain AFU errors */ - -/* Command management definitions */ -#define CXLFLASH_MAX_CMDS 256 -#define CXLFLASH_MAX_CMDS_PER_LUN CXLFLASH_MAX_CMDS - -/* RRQ for master issued cmds */ -#define NUM_RRQ_ENTRY CXLFLASH_MAX_CMDS - -/* SQ for master issued cmds */ -#define NUM_SQ_ENTRY CXLFLASH_MAX_CMDS - -/* Hardware queue definitions */ -#define CXLFLASH_DEF_HWQS 1 -#define CXLFLASH_MAX_HWQS 8 -#define PRIMARY_HWQ 0 - - -static inline void check_sizes (void ) -{ -BUILD_BUG_ON_NOT_POWER_OF_2 (CXLFLASH_NUM_FC_PORTS_PER_BANK ); -BUILD_BUG_ON_NOT_POWER_OF_2 (CXLFLASH_MAX_CMDS ); -} - -/* AFU defines a fixed size of 4K for command buffers (borrow 4K page define) */ -#define CMD_BUFSIZE SIZE_4K - -enum cxlflash_lr_state { -LINK_RESET_INVALID , -LINK_RESET_REQUIRED , -LINK_RESET_COMPLETE -}; - -enum cxlflash_init_state { -INIT_STATE_NONE , -INIT_STATE_PCI , -INIT_STATE_AFU , -INIT_STATE_SCSI , -INIT_STATE_CDEV -}; - -enum cxlflash_state { -STATE_PROBING ,/* Initial state during probe */ -STATE_PROBED ,/* Temporary state, probe completed but EEH occurred */ -STATE_NORMAL ,/* Normal running state, everything good */ -STATE_RESET ,/* Reset state, trying to reset/recover */ -STATE_FAILTERM /* Failed/terminating state, error out users/threads */ -}; - -enum cxlflash_hwq_mode { -HWQ_MODE_RR ,/* Roundrobin (default) */ -HWQ_MODE_TAG ,/* Distribute based on block MQ tag */ -HWQ_MODE_CPU ,/* CPU affinity */ -MAX_HWQ_MODE -}; - -/* -* Each context has its own set of resource handles that is visible -* only from that context. -*/ - -struct cxlflash_cfg { -struct afu *afu; - -const struct cxlflash_backend_ops *ops; -struct pci_dev *dev; -struct pci_device_id *dev_id; -struct Scsi_Host *host; -int num_fc_ports; -struct cdev cdev; -struct device *chardev; - -ulong cxlflash_regs_pci; - -struct work_struct work_q; -enum cxlflash_init_state init_state; -enum cxlflash_lr_state lr_state; -int lr_port; -atomic_t scan_host_needed; - -void *afu_cookie; - -atomic_t recovery_threads; -struct mutex ctx_recovery_mutex; -struct mutex ctx_tbl_list_mutex; -struct rw_semaphore ioctl_rwsem; -struct ctx_info *ctx_tbl[MAX_CONTEXT ]; -struct list_head ctx_err_recovery;/* contexts w/ recovery pending */ -struct file_operations cxl_fops; - -/* Parameters that are LUN table related */ -int last_lun_index[MAX_FC_PORTS ]; -int promote_lun_index; -struct list_head lluns;/* list of llun_info structs */ - -wait_queue_head_t tmf_waitq; -spinlock_t tmf_slock; -bool tmf_active; -bool ws_unmap;/* Write-same unmap supported */ -wait_queue_head_t reset_waitq; -enum cxlflash_state state; -async_cookie_t async_reset_cookie; -}; - -struct afu_cmd { -struct sisl_ioarcb rcb;/* IOARCB (cache line aligned) */ -struct sisl_ioasa sa;/* IOASA must follow IOARCB */ -struct afu *parent; -struct scsi_cmnd *scp; -struct completion cevent; -struct list_head queue; -u32 hwq_index; - -u8 cmd_tmf:1 , - cmd_aborted:1 ; - -struct list_head list;/* Pending commands link */ - -/* As per the SISLITE spec the IOARCB EA has to be 16-byte aligned. -* However for performance reasons the IOARCB/IOASA should be -* cache line aligned. -*/ -}__aligned(cache_line_size()) ; - -static inline struct afu_cmd *sc_to_afuc (struct scsi_cmnd *sc) -{ -return PTR_ALIGN (scsi_cmd_priv (sc), __alignof__(struct afu_cmd )); -} - -static inline struct afu_cmd *sc_to_afuci (struct scsi_cmnd *sc) -{ -struct afu_cmd *afuc =sc_to_afuc (sc); - -INIT_LIST_HEAD (&afuc->queue); -return afuc; -} - -static inline struct afu_cmd *sc_to_afucz (struct scsi_cmnd *sc) -{ -struct afu_cmd *afuc =sc_to_afuc (sc); - -memset (afuc,0 ,sizeof (*afuc)); -return sc_to_afuci (sc); -} - -struct hwq { -/* Stuff requiring alignment go first. */ -struct sisl_ioarcb sq[NUM_SQ_ENTRY ];/* 16K SQ */ -u64 rrq_entry[NUM_RRQ_ENTRY ];/* 2K RRQ */ - -/* Beware of alignment till here. Preferably introduce new -* fields after this point -*/ -struct afu *afu; -void *ctx_cookie; -struct sisl_host_map __iomem *host_map;/* MC host map */ -struct sisl_ctrl_map __iomem *ctrl_map;/* MC control map */ -ctx_hndl_t ctx_hndl;/* master's context handle */ -u32 index;/* Index of this hwq */ -int num_irqs;/* Number of interrupts requested for context */ -struct list_head pending_cmds;/* Commands pending completion */ - -atomic_t hsq_credits; -spinlock_t hsq_slock;/* Hardware send queue lock */ -struct sisl_ioarcb *hsq_start; -struct sisl_ioarcb *hsq_end; -struct sisl_ioarcb *hsq_curr; -spinlock_t hrrq_slock; -u64 *hrrq_start; -u64 *hrrq_end; -u64 *hrrq_curr; -bool toggle; -bool hrrq_online; - -s64 room; - -struct irq_poll irqpoll; -}__aligned(cache_line_size()) ; - -struct afu { -struct hwq hwqs[CXLFLASH_MAX_HWQS ]; -int (*send_cmd)(struct afu *afu,struct afu_cmd *cmd); -int (*context_reset)(struct hwq *hwq); - -/* AFU HW */ -struct cxlflash_afu_map __iomem *afu_map;/* entire MMIO map */ - -atomic_t cmds_active;/* Number of currently active AFU commands */ -struct mutex sync_active;/* Mutex to serialize AFU commands */ -u64 hb; -u32 internal_lun;/* User-desired LUN mode for this AFU */ - -u32 num_hwqs;/* Number of hardware queues */ -u32 desired_hwqs;/* Desired h/w queues, effective on AFU reset */ -enum cxlflash_hwq_mode hwq_mode;/* Steering mode for h/w queues */ -u32 hwq_rr_count;/* Count to distribute traffic for roundrobin */ - -char version[16 ]; -u64 interface_version; - -u32 irqpoll_weight; -struct cxlflash_cfg *parent;/* Pointer back to parent cxlflash_cfg */ -}; - -static inline struct hwq *get_hwq (struct afu *afu,u32 index) -{ -WARN_ON (index >=CXLFLASH_MAX_HWQS ); - -return &afu->hwqs[index]; -} - -static inline bool afu_is_irqpoll_enabled (struct afu *afu) -{ -return !!afu->irqpoll_weight; -} - -static inline bool afu_has_cap (struct afu *afu,u64 cap) -{ -u64 afu_cap = afu->interface_version >>SISL_INTVER_CAP_SHIFT ; - -return afu_cap & cap; -} - -static inline bool afu_is_ocxl_lisn (struct afu *afu) -{ -return afu_has_cap (afu,SISL_INTVER_CAP_OCXL_LISN ); -} - -static inline bool afu_is_afu_debug (struct afu *afu) -{ -return afu_has_cap (afu,SISL_INTVER_CAP_AFU_DEBUG ); -} - -static inline bool afu_is_lun_provision (struct afu *afu) -{ -return afu_has_cap (afu,SISL_INTVER_CAP_LUN_PROVISION ); -} - -static inline bool afu_is_sq_cmd_mode (struct afu *afu) -{ -return afu_has_cap (afu,SISL_INTVER_CAP_SQ_CMD_MODE ); -} - -static inline bool afu_is_ioarrin_cmd_mode (struct afu *afu) -{ -return afu_has_cap (afu,SISL_INTVER_CAP_IOARRIN_CMD_MODE ); -} - -static inline u64 lun_to_lunid (u64 lun) -{ -__be64 lun_id; - -int_to_scsilun (lun, (struct scsi_lun *)&lun_id); -return be64_to_cpu (lun_id); -} - -static inline struct fc_port_bank __iomem *get_fc_port_bank ( -struct cxlflash_cfg *cfg,int i) -{ -struct afu *afu = cfg->afu; - -return &afu->afu_map->global.bank[CHAN2PORTBANK (i)]; -} - -static inline __be64 __iomem *get_fc_port_regs (struct cxlflash_cfg *cfg,int i) -{ -struct fc_port_bank __iomem *fcpb =get_fc_port_bank (cfg, i); - -return &fcpb->fc_port_regs[CHAN2BANKPORT (i)][0 ]; -} - -static inline __be64 __iomem *get_fc_port_luns (struct cxlflash_cfg *cfg,int i) -{ -struct fc_port_bank __iomem *fcpb =get_fc_port_bank (cfg, i); - -return &fcpb->fc_port_luns[CHAN2BANKPORT (i)][0 ]; -} - -int cxlflash_afu_sync (struct afu *afu,ctx_hndl_t c,res_hndl_t r,u8 mode); -void cxlflash_list_init (void ); -void cxlflash_term_global_luns (void ); -void cxlflash_free_errpage (void ); -int cxlflash_ioctl (struct scsi_device *sdev,unsigned int cmd, -void __user *arg); -void cxlflash_stop_term_user_contexts (struct cxlflash_cfg *cfg); -int cxlflash_mark_contexts_error (struct cxlflash_cfg *cfg); -void cxlflash_term_local_luns (struct cxlflash_cfg *cfg); -void cxlflash_restore_luntable (struct cxlflash_cfg *cfg); - -#endif /* ifndef _CXLFLASH_COMMON_H */ drivers/scsi/cxlflash/cxl_hw.c deleted +0
-177@@ -1,177 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* -* CXL Flash Device Driver -* -* Written by: Matthew R. Ochs <[email protected]>, IBM Corporation -* Uma Krishnan <[email protected]>, IBM Corporation -* -* Copyright (C) 2018 IBM Corporation -*/ - -#include <misc/cxl.h> - -#include "backend.h" - -/* -* The following routines map the cxlflash backend operations to existing CXL -* kernel API function and are largely simple shims that provide an abstraction -* for converting generic context and AFU cookies into cxl_context or cxl_afu -* pointers. -*/ - -static void __iomem *cxlflash_psa_map (void *ctx_cookie) -{ -return cxl_psa_map (ctx_cookie); -} - -static void cxlflash_psa_unmap (void __iomem *addr) -{ -cxl_psa_unmap (addr); -} - -static int cxlflash_process_element (void *ctx_cookie) -{ -return cxl_process_element (ctx_cookie); -} - -static int cxlflash_map_afu_irq (void *ctx_cookie,int num, -irq_handler_t handler,void *cookie,char *name) -{ -return cxl_map_afu_irq (ctx_cookie, num, handler, cookie, name); -} - -static void cxlflash_unmap_afu_irq (void *ctx_cookie,int num,void *cookie) -{ -cxl_unmap_afu_irq (ctx_cookie, num, cookie); -} - -static u64 cxlflash_get_irq_objhndl (void *ctx_cookie,int irq) -{ -/* Dummy fop for cxl */ -return 0 ; -} - -static int cxlflash_start_context (void *ctx_cookie) -{ -return cxl_start_context (ctx_cookie,0 ,NULL ); -} - -static int cxlflash_stop_context (void *ctx_cookie) -{ -return cxl_stop_context (ctx_cookie); -} - -static int cxlflash_afu_reset (void *ctx_cookie) -{ -return cxl_afu_reset (ctx_cookie); -} - -static void cxlflash_set_master (void *ctx_cookie) -{ -cxl_set_master (ctx_cookie); -} - -static void *cxlflash_get_context (struct pci_dev *dev,void *afu_cookie) -{ -return cxl_get_context (dev); -} - -static void *cxlflash_dev_context_init (struct pci_dev *dev,void *afu_cookie) -{ -return cxl_dev_context_init (dev); -} - -static int cxlflash_release_context (void *ctx_cookie) -{ -return cxl_release_context (ctx_cookie); -} - -static void cxlflash_perst_reloads_same_image (void *afu_cookie,bool image) -{ -cxl_perst_reloads_same_image (afu_cookie, image); -} - -static ssize_t cxlflash_read_adapter_vpd (struct pci_dev *dev, -void *buf,size_t count) -{ -return cxl_read_adapter_vpd (dev, buf, count); -} - -static int cxlflash_allocate_afu_irqs (void *ctx_cookie,int num) -{ -return cxl_allocate_afu_irqs (ctx_cookie, num); -} - -static void cxlflash_free_afu_irqs (void *ctx_cookie) -{ -cxl_free_afu_irqs (ctx_cookie); -} - -static void *cxlflash_create_afu (struct pci_dev *dev) -{ -return cxl_pci_to_afu (dev); -} - -static void cxlflash_destroy_afu (void *afu) -{ -/* Dummy fop for cxl */ -} - -static struct file *cxlflash_get_fd (void *ctx_cookie, -struct file_operations *fops,int *fd) -{ -return cxl_get_fd (ctx_cookie, fops, fd); -} - -static void *cxlflash_fops_get_context (struct file *file) -{ -return cxl_fops_get_context (file); -} - -static int cxlflash_start_work (void *ctx_cookie,u64 irqs) -{ -struct cxl_ioctl_start_work work = {0 }; - - work.num_interrupts = irqs; - work.flags =CXL_START_WORK_NUM_IRQS ; - -return cxl_start_work (ctx_cookie, &work); -} - -static int cxlflash_fd_mmap (struct file *file,struct vm_area_struct *vm) -{ -return cxl_fd_mmap (file, vm); -} - -static int cxlflash_fd_release (struct inode *inode,struct file *file) -{ -return cxl_fd_release (inode, file); -} - -const struct cxlflash_backend_ops cxlflash_cxl_ops = { - .module =THIS_MODULE , - .psa_map = cxlflash_psa_map, - .psa_unmap = cxlflash_psa_unmap, - .process_element = cxlflash_process_element, - .map_afu_irq = cxlflash_map_afu_irq, - .unmap_afu_irq = cxlflash_unmap_afu_irq, - .get_irq_objhndl = cxlflash_get_irq_objhndl, - .start_context = cxlflash_start_context, - .stop_context = cxlflash_stop_context, - .afu_reset = cxlflash_afu_reset, - .set_master = cxlflash_set_master, - .get_context = cxlflash_get_context, - .dev_context_init = cxlflash_dev_context_init, - .release_context = cxlflash_release_context, - .perst_reloads_same_image = cxlflash_perst_reloads_same_image, - .read_adapter_vpd = cxlflash_read_adapter_vpd, - .allocate_afu_irqs = cxlflash_allocate_afu_irqs, - .free_afu_irqs = cxlflash_free_afu_irqs, - .create_afu = cxlflash_create_afu, - .destroy_afu = cxlflash_destroy_afu, - .get_fd = cxlflash_get_fd, - .fops_get_context = cxlflash_fops_get_context, - .start_work = cxlflash_start_work, - .fd_mmap = cxlflash_fd_mmap, - .fd_release = cxlflash_fd_release, -};drivers/scsi/cxlflash/lunmgt.c deleted +0
-278@@ -1,278 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* -* CXL Flash Device Driver -* -* Written by: Manoj N. Kumar <[email protected]>, IBM Corporation -* Matthew R. Ochs <[email protected]>, IBM Corporation -* -* Copyright (C) 2015 IBM Corporation -*/ - -#include <linux/unaligned.h> - -#include <linux/interrupt.h> -#include <linux/pci.h> - -#include <scsi/scsi_host.h> -#include <uapi/scsi/cxlflash_ioctl.h> - -#include "sislite.h" -#include "common.h" -#include "vlun.h" -#include "superpipe.h" - -/** -* create_local() - allocate and initialize a local LUN information structure -* @sdev: SCSI device associated with LUN. -* @wwid: World Wide Node Name for LUN. -* -* Return: Allocated local llun_info structure on success, NULL on failure -*/ -static struct llun_info *create_local (struct scsi_device *sdev,u8 *wwid) -{ -struct cxlflash_cfg *cfg =shost_priv (sdev->host); -struct device *dev = &cfg->dev->dev; -struct llun_info *lli =NULL ; - - lli =kzalloc (sizeof (*lli),GFP_KERNEL ); -if (unlikely (!lli)) { -dev_err (dev,"%s: could not allocate lli\n" , __func__); - goto out; - } - - lli->sdev = sdev; - lli->host_no = sdev->host->host_no; - lli->in_table = false; - -memcpy (lli->wwid, wwid,DK_CXLFLASH_MANAGE_LUN_WWID_LEN ); -out: -return lli; -} - -/** -* create_global() - allocate and initialize a global LUN information structure -* @sdev: SCSI device associated with LUN. -* @wwid: World Wide Node Name for LUN. -* -* Return: Allocated global glun_info structure on success, NULL on failure -*/ -static struct glun_info *create_global (struct scsi_device *sdev,u8 *wwid) -{ -struct cxlflash_cfg *cfg =shost_priv (sdev->host); -struct device *dev = &cfg->dev->dev; -struct glun_info *gli =NULL ; - - gli =kzalloc (sizeof (*gli),GFP_KERNEL ); -if (unlikely (!gli)) { -dev_err (dev,"%s: could not allocate gli\n" , __func__); - goto out; - } - -mutex_init (&gli->mutex); -memcpy (gli->wwid, wwid,DK_CXLFLASH_MANAGE_LUN_WWID_LEN ); -out: -return gli; -} - -/** -* lookup_local() - find a local LUN information structure by WWID -* @cfg: Internal structure associated with the host. -* @wwid: WWID associated with LUN. -* -* Return: Found local lun_info structure on success, NULL on failure -*/ -static struct llun_info *lookup_local (struct cxlflash_cfg *cfg,u8 *wwid) -{ -struct llun_info *lli, *temp; - -list_for_each_entry_safe (lli, temp, &cfg->lluns, list) -if (!memcmp (lli->wwid, wwid,DK_CXLFLASH_MANAGE_LUN_WWID_LEN )) -return lli; - -return NULL ; -} - -/** -* lookup_global() - find a global LUN information structure by WWID -* @wwid: WWID associated with LUN. -* -* Return: Found global lun_info structure on success, NULL on failure -*/ -static struct glun_info *lookup_global (u8 *wwid) -{ -struct glun_info *gli, *temp; - -list_for_each_entry_safe (gli, temp, &global.gluns, list) -if (!memcmp (gli->wwid, wwid,DK_CXLFLASH_MANAGE_LUN_WWID_LEN )) -return gli; - -return NULL ; -} - -/** -* find_and_create_lun() - find or create a local LUN information structure -* @sdev: SCSI device associated with LUN. -* @wwid: WWID associated with LUN. -* -* The LUN is kept both in a local list (per adapter) and in a global list -* (across all adapters). Certain attributes of the LUN are local to the -* adapter (such as index, port selection mask, etc.). -* -* The block allocation map is shared across all adapters (i.e. associated -* wih the global list). Since different attributes are associated with -* the per adapter and global entries, allocate two separate structures for each -* LUN (one local, one global). -* -* Keep a pointer back from the local to the global entry. -* -* This routine assumes the caller holds the global mutex. -* -* Return: Found/Allocated local lun_info structure on success, NULL on failure -*/ -static struct llun_info *find_and_create_lun (struct scsi_device *sdev,u8 *wwid) -{ -struct cxlflash_cfg *cfg =shost_priv (sdev->host); -struct device *dev = &cfg->dev->dev; -struct llun_info *lli =NULL ; -struct glun_info *gli =NULL ; - -if (unlikely (!wwid)) - goto out; - - lli =lookup_local (cfg, wwid); -if (lli) - goto out; - - lli =create_local (sdev, wwid); -if (unlikely (!lli)) - goto out; - - gli =lookup_global (wwid); -if (gli) { - lli->parent = gli; -list_add (&lli->list, &cfg->lluns); - goto out; - } - - gli =create_global (sdev, wwid); -if (unlikely (!gli)) { -kfree (lli); - lli =NULL ; - goto out; - } - - lli->parent = gli; -list_add (&lli->list, &cfg->lluns); - -list_add (&gli->list, &global.gluns); - -out: -dev_dbg (dev,"%s: returning lli=%p, gli=%p\n" , __func__, lli, gli); -return lli; -} - -/** -* cxlflash_term_local_luns() - Delete all entries from local LUN list, free. -* @cfg: Internal structure associated with the host. -*/ -void cxlflash_term_local_luns (struct cxlflash_cfg *cfg) -{ -struct llun_info *lli, *temp; - -mutex_lock (&global.mutex); -list_for_each_entry_safe (lli, temp, &cfg->lluns, list) { -list_del (&lli->list); -kfree (lli); - } -mutex_unlock (&global.mutex); -} - -/** -* cxlflash_list_init() - initializes the global LUN list -*/ -void cxlflash_list_init (void ) -{ -INIT_LIST_HEAD (&global.gluns); -mutex_init (&global.mutex); - global.err_page =NULL ; -} - -/** -* cxlflash_term_global_luns() - frees resources associated with global LUN list -*/ -void cxlflash_term_global_luns (void ) -{ -struct glun_info *gli, *temp; - -mutex_lock (&global.mutex); -list_for_each_entry_safe (gli, temp, &global.gluns, list) { -list_del (&gli->list); -cxlflash_ba_terminate (&gli->blka.ba_lun); -kfree (gli); - } -mutex_unlock (&global.mutex); -} - -/** -* cxlflash_manage_lun() - handles LUN management activities -* @sdev: SCSI device associated with LUN. -* @arg: Manage ioctl data structure. -* -* This routine is used to notify the driver about a LUN's WWID and associate -* SCSI devices (sdev) with a global LUN instance. Additionally it serves to -* change a LUN's operating mode: legacy or superpipe. -* -* Return: 0 on success, -errno on failure -*/ -int cxlflash_manage_lun (struct scsi_device *sdev,void *arg) -{ -struct dk_cxlflash_manage_lun *manage = arg; -struct cxlflash_cfg *cfg =shost_priv (sdev->host); -struct device *dev = &cfg->dev->dev; -struct llun_info *lli =NULL ; -int rc =0 ; -u64 flags = manage->hdr.flags; -u32 chan = sdev->channel; - -mutex_lock (&global.mutex); - lli =find_and_create_lun (sdev, manage->wwid); -dev_dbg (dev,"%s: WWID=%016llx%016llx, flags=%016llx lli=%p\n" , - __func__,get_unaligned_be64 (&manage->wwid[0 ]), -get_unaligned_be64 (&manage->wwid[8 ]), manage->hdr.flags, lli); -if (unlikely (!lli)) { - rc = -ENOMEM ; - goto out; - } - -if (flags &DK_CXLFLASH_MANAGE_LUN_ENABLE_SUPERPIPE ) { -/* -* Update port selection mask based upon channel, store off LUN -* in unpacked, AFU-friendly format, and hang LUN reference in -* the sdev. -*/ - lli->port_sel |=CHAN2PORTMASK (chan); - lli->lun_id[chan] =lun_to_lunid (sdev->lun); - sdev->hostdata = lli; - }else if (flags &DK_CXLFLASH_MANAGE_LUN_DISABLE_SUPERPIPE ) { -if (lli->parent->mode !=MODE_NONE ) - rc = -EBUSY ; -else { -/* -* Clean up local LUN for this port and reset table -* tracking when no more references exist. -*/ - sdev->hostdata =NULL ; - lli->port_sel &= ~CHAN2PORTMASK (chan); -if (lli->port_sel ==0U ) - lli->in_table = false; - } - } - -dev_dbg (dev,"%s: port_sel=%08x chan=%u lun_id=%016llx\n" , - __func__, lli->port_sel, chan, lli->lun_id[chan]); - -out: -mutex_unlock (&global.mutex); -dev_dbg (dev,"%s: returning rc=%d\n" , __func__, rc); -return rc; -}drivers/scsi/cxlflash/main.c deleted +0
-3970@@ -1,3970 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0-or-later -/* -* CXL Flash Device Driver -* -* Written by: Manoj N. Kumar <[email protected]>, IBM Corporation -* Matthew R. Ochs <[email protected]>, IBM Corporation -* -* Copyright (C) 2015 IBM Corporation -*/ - -#include <linux/delay.h> -#include <linux/list.h> -#include <linux/module.h> -#include <linux/pci.h> - -#include <linux/unaligned.h> - -#include <scsi/scsi_cmnd.h> -#include <scsi/scsi_host.h> -#include <uapi/scsi/cxlflash_ioctl.h> - -#include "main.h" -#include "sislite.h" -#include "common.h" - -MODULE_DESCRIPTION (CXLFLASH_ADAPTER_NAME ); -MODULE_AUTHOR ("Manoj N. Kumar <[email protected]>" ); -MODULE_AUTHOR ("Matthew R. Ochs <[email protected]>" ); -MODULE_LICENSE ("GPL" ); - -static char *cxlflash_devnode (const struct device *dev,umode_t *mode); -static const struct class cxlflash_class = { - .name ="cxlflash" , - .devnode = cxlflash_devnode, -}; - -static u32 cxlflash_major; -static DECLARE_BITMAP(cxlflash_minor, CXLFLASH_MAX_ADAPTERS); - -/** -* process_cmd_err() - command error handler -* @cmd: AFU command that experienced the error. -* @scp: SCSI command associated with the AFU command in error. -* -* Translates error bits from AFU command to SCSI command results. -*/ -static void process_cmd_err (struct afu_cmd *cmd,struct scsi_cmnd *scp) -{ -struct afu *afu = cmd->parent; -struct cxlflash_cfg *cfg = afu->parent; -struct device *dev = &cfg->dev->dev; -struct sisl_ioasa *ioasa; -u32 resid; - - ioasa = &(cmd->sa); - -if (ioasa->rc.flags &SISL_RC_FLAGS_UNDERRUN ) { - resid = ioasa->resid; -scsi_set_resid (scp, resid); -dev_dbg (dev,"%s: cmd underrun cmd = %p scp = %p, resid = %d\n" , - __func__, cmd, scp, resid); - } - -if (ioasa->rc.flags &SISL_RC_FLAGS_OVERRUN ) { -dev_dbg (dev,"%s: cmd underrun cmd = %p scp = %p\n" , - __func__, cmd, scp); - scp->result = (DID_ERROR <<16 ); - } - -dev_dbg (dev,"%s: cmd failed afu_rc=%02x scsi_rc=%02x fc_rc=%02x " -"afu_extra=%02x scsi_extra=%02x fc_extra=%02x\n" , __func__, - ioasa->rc.afu_rc, ioasa->rc.scsi_rc, ioasa->rc.fc_rc, - ioasa->afu_extra, ioasa->scsi_extra, ioasa->fc_extra); - -if (ioasa->rc.scsi_rc) { -/* We have a SCSI status */ -if (ioasa->rc.flags &SISL_RC_FLAGS_SENSE_VALID ) { -memcpy (scp->sense_buffer, ioasa->sense_data, -SISL_SENSE_DATA_LEN ); - scp->result = ioasa->rc.scsi_rc; - }else - scp->result = ioasa->rc.scsi_rc | (DID_ERROR <<16 ); - } - -/* -* We encountered an error. Set scp->result based on nature -* of error. -*/ -if (ioasa->rc.fc_rc) { -/* We have an FC status */ -switch (ioasa->rc.fc_rc) { -case SISL_FC_RC_LINKDOWN : - scp->result = (DID_REQUEUE <<16 ); -break ; -case SISL_FC_RC_RESID : -/* This indicates an FCP resid underrun */ -if (!(ioasa->rc.flags &SISL_RC_FLAGS_OVERRUN )) { -/* If the SISL_RC_FLAGS_OVERRUN flag was set, -* then we will handle this error else where. -* If not then we must handle it here. -* This is probably an AFU bug. -*/ - scp->result = (DID_ERROR <<16 ); - } -break ; -case SISL_FC_RC_RESIDERR : -/* Resid mismatch between adapter and device */ -case SISL_FC_RC_TGTABORT : -case SISL_FC_RC_ABORTOK : -case SISL_FC_RC_ABORTFAIL : -case SISL_FC_RC_NOLOGI : -case SISL_FC_RC_ABORTPEND : -case SISL_FC_RC_WRABORTPEND : -case SISL_FC_RC_NOEXP : -case SISL_FC_RC_INUSE : - scp->result = (DID_ERROR <<16 ); -break ; - } - } - -if (ioasa->rc.afu_rc) { -/* We have an AFU error */ -switch (ioasa->rc.afu_rc) { -case SISL_AFU_RC_NO_CHANNELS : - scp->result = (DID_NO_CONNECT <<16 ); -break ; -case SISL_AFU_RC_DATA_DMA_ERR : -switch (ioasa->afu_extra) { -case SISL_AFU_DMA_ERR_PAGE_IN : -/* Retry */ - scp->result = (DID_IMM_RETRY <<16 ); -break ; -case SISL_AFU_DMA_ERR_INVALID_EA : -default : - scp->result = (DID_ERROR <<16 ); - } -break ; -case SISL_AFU_RC_OUT_OF_DATA_BUFS : -/* Retry */ - scp->result = (DID_ERROR <<16 ); -break ; -default : - scp->result = (DID_ERROR <<16 ); - } - } -} - -/** -* cmd_complete() - command completion handler -* @cmd: AFU command that has completed. -* -* For SCSI commands this routine prepares and submits commands that have -* either completed or timed out to the SCSI stack. For internal commands -* (TMF or AFU), this routine simply notifies the originator that the -* command has completed. -*/ -static void cmd_complete (struct afu_cmd *cmd) -{ -struct scsi_cmnd *scp; -ulong lock_flags; -struct afu *afu = cmd->parent; -struct cxlflash_cfg *cfg = afu->parent; -struct device *dev = &cfg->dev->dev; -struct hwq *hwq =get_hwq (afu, cmd->hwq_index); - -spin_lock_irqsave (&hwq->hsq_slock, lock_flags); -list_del (&cmd->list); -spin_unlock_irqrestore (&hwq->hsq_slock, lock_flags); - -if (cmd->scp) { - scp = cmd->scp; -if (unlikely (cmd->sa.ioasc)) -process_cmd_err (cmd, scp); -else - scp->result = (DID_OK <<16 ); - -dev_dbg_ratelimited (dev,"%s:scp=%p result=%08x ioasc=%08x\n" , - __func__, scp, scp->result, cmd->sa.ioasc); -scsi_done (scp); - }else if (cmd->cmd_tmf) { -spin_lock_irqsave (&cfg->tmf_slock, lock_flags); - cfg->tmf_active = false; -wake_up_all_locked (&cfg->tmf_waitq); -spin_unlock_irqrestore (&cfg->tmf_slock, lock_flags); - }else -complete (&cmd->cevent); -} - -/** -* flush_pending_cmds() - flush all pending commands on this hardware queue -* @hwq: Hardware queue to flush. -* -* The hardware send queue lock associated with this hardware queue must be -* held when calling this routine. -*/ -static void flush_pending_cmds (struct hwq *hwq) -{ -struct cxlflash_cfg *cfg = hwq->afu->parent; -struct afu_cmd *cmd, *tmp; -struct scsi_cmnd *scp; -ulong lock_flags; - -list_for_each_entry_safe (cmd, tmp, &hwq->pending_cmds, list) { -/* Bypass command when on a doneq, cmd_complete() will handle */ -if (!list_empty (&cmd->queue)) -continue ; - -list_del (&cmd->list); - -if (cmd->scp) { - scp = cmd->scp; - scp->result = (DID_IMM_RETRY <<16 ); -scsi_done (scp); - }else { - cmd->cmd_aborted = true; - -if (cmd->cmd_tmf) { -spin_lock_irqsave (&cfg->tmf_slock, lock_flags); - cfg->tmf_active = false; -wake_up_all_locked (&cfg->tmf_waitq); -spin_unlock_irqrestore (&cfg->tmf_slock, - lock_flags); - }else -complete (&cmd->cevent); - } - } -} - -/** -* context_reset() - reset context via specified register -* @hwq: Hardware queue owning the context to be reset. -* @reset_reg: MMIO register to perform reset. -* -* When the reset is successful, the SISLite specification guarantees that -* the AFU has aborted all currently pending I/O. Accordingly, these commands -* must be flushed. -* -* Return: 0 on success, -errno on failure -*/ -static int context_reset (struct hwq *hwq,__be64 __iomem *reset_reg) -{ -struct cxlflash_cfg *cfg = hwq->afu->parent; -struct device *dev = &cfg->dev->dev; -int rc = -ETIMEDOUT ; -int nretry =0 ; -u64 val =0x1 ; -ulong lock_flags; - -dev_dbg (dev,"%s: hwq=%p\n" , __func__, hwq); - -spin_lock_irqsave (&hwq->hsq_slock, lock_flags); - -writeq_be (val, reset_reg); -do { - val =readq_be (reset_reg); -if ((val &0x1 ) ==0x0 ) { - rc =0 ; -break ; - } - -/* Double delay each time */ -udelay (1 << nretry); - }while (nretry++ <MC_ROOM_RETRY_CNT ); - -if (!rc) -flush_pending_cmds (hwq); - -spin_unlock_irqrestore (&hwq->hsq_slock, lock_flags); - -dev_dbg (dev,"%s: returning rc=%d, val=%016llx nretry=%d\n" , - __func__, rc, val, nretry); -return rc; -} - -/** -* context_reset_ioarrin() - reset context via IOARRIN register -* @hwq: Hardware queue owning the context to be reset. -* -* Return: 0 on success, -errno on failure -*/ -static int context_reset_ioarrin (struct hwq *hwq) -{ -return context_reset (hwq, &hwq->host_map->ioarrin); -} - -/** -* context_reset_sq() - reset context via SQ_CONTEXT_RESET register -* @hwq: Hardware queue owning the context to be reset. -* -* Return: 0 on success, -errno on failure -*/ -static int context_reset_sq (struct hwq *hwq) -{ -return context_reset (hwq, &hwq->host_map->sq_ctx_reset); -} - -/** -* send_cmd_ioarrin() - sends an AFU command via IOARRIN register -* @afu: AFU associated with the host. -* @cmd: AFU command to send. -* -* Return: -* 0 on success, SCSI_MLQUEUE_HOST_BUSY on failure -*/ -static int send_cmd_ioarrin (struct afu *afu,struct afu_cmd *cmd) -{ -struct cxlflash_cfg *cfg = afu->parent; -struct device *dev = &cfg->dev->dev; -struct hwq *hwq =get_hwq (afu, cmd->hwq_index); -int rc =0 ; -s64 room; -ulong lock_flags; - -/* -* To avoid the performance penalty of MMIO, spread the update of -* 'room' over multiple commands. -*/ -spin_lock_irqsave (&hwq->hsq_slock, lock_flags); -if (--hwq->room <0 ) { - room =readq_be (&hwq->host_map->cmd_room); -if (room <=0 ) { -dev_dbg_ratelimited (dev,"%s: no cmd_room to send " -"0x%02X, room=0x%016llX\n" , - __func__, cmd->rcb.cdb[0 ], room); - hwq->room =0 ; - rc =SCSI_MLQUEUE_HOST_BUSY ; - goto out; - } - hwq->room = room -1 ; - } - -list_add (&cmd->list, &hwq->pending_cmds); -writeq_be ((u64)&cmd->rcb, &hwq->host_map->ioarrin); -out: -spin_unlock_irqrestore (&hwq->hsq_slock, lock_flags); -dev_dbg_ratelimited (dev,"%s: cmd=%p len=%u ea=%016llx rc=%d\n" , - __func__, cmd, cmd->rcb.data_len, cmd->rcb.data_ea, rc); -return rc; -} - -/** -* send_cmd_sq() - sends an AFU command via SQ ring -* @afu: AFU associated with the host. -* @cmd: AFU command to send. -* -* Return: -* 0 on success, SCSI_MLQUEUE_HOST_BUSY on failure -*/ -static int send_cmd_sq (struct afu *afu,struct afu_cmd *cmd) -{ -struct cxlflash_cfg *cfg = afu->parent; -struct device *dev = &cfg->dev->dev; -struct hwq *hwq =get_hwq (afu, cmd->hwq_index); -int rc =0 ; -int newval; -ulong lock_flags; - - newval =atomic_dec_if_positive (&hwq->hsq_credits); -if (newval <=0 ) { - rc =SCSI_MLQUEUE_HOST_BUSY ; - goto out; - } - - cmd->rcb.ioasa = &cmd->sa; - -spin_lock_irqsave (&hwq->hsq_slock, lock_flags); - - *hwq->hsq_curr = cmd->rcb; -if (hwq->hsq_curr < hwq->hsq_end) - hwq->hsq_curr++; -else - hwq->hsq_curr = hwq->hsq_start; - -list_add (&cmd->list, &hwq->pending_cmds); -writeq_be ((u64 )hwq->hsq_curr, &hwq->host_map->sq_tail); - -spin_unlock_irqrestore (&hwq->hsq_slock, lock_flags); -out: -dev_dbg (dev,"%s: cmd=%p len=%u ea=%016llx ioasa=%p rc=%d curr=%p " -"head=%016llx tail=%016llx\n" , __func__, cmd, cmd->rcb.data_len, - cmd->rcb.data_ea, cmd->rcb.ioasa, rc, hwq->hsq_curr, -readq_be (&hwq->host_map->sq_head), -readq_be (&hwq->host_map->sq_tail)); -return rc; -} - -/** -* wait_resp() - polls for a response or timeout to a sent AFU command -* @afu: AFU associated with the host. -* @cmd: AFU command that was sent. -* -* Return: 0 on success, -errno on failure -*/ -static int wait_resp (struct afu *afu,struct afu_cmd *cmd) -{ -struct cxlflash_cfg *cfg = afu->parent; -struct device *dev = &cfg->dev->dev; -int rc =0 ; -ulong timeout =msecs_to_jiffies (cmd->rcb.timeout *2 *1000 ); - - timeout =wait_for_completion_timeout (&cmd->cevent, timeout); -if (!timeout) - rc = -ETIMEDOUT ; - -if (cmd->cmd_aborted) - rc = -EAGAIN ; - -if (unlikely (cmd->sa.ioasc !=0 )) { -dev_err (dev,"%s: cmd %02x failed, ioasc=%08x\n" , - __func__, cmd->rcb.cdb[0 ], cmd->sa.ioasc); - rc = -EIO ; - } - -return rc; -} - -/** -* cmd_to_target_hwq() - selects a target hardware queue for a SCSI command -* @host: SCSI host associated with device. -* @scp: SCSI command to send. -* @afu: SCSI command to send. -* -* Hashes a command based upon the hardware queue mode. -* -* Return: Trusted index of target hardware queue -*/ -static u32 cmd_to_target_hwq (struct Scsi_Host *host,struct scsi_cmnd *scp, -struct afu *afu) -{ -u32 tag; -u32 hwq =0 ; - -if (afu->num_hwqs ==1 ) -return 0 ; - -switch (afu->hwq_mode) { -case HWQ_MODE_RR : - hwq = afu->hwq_rr_count++ % afu->num_hwqs; -break ; -case HWQ_MODE_TAG : - tag =blk_mq_unique_tag (scsi_cmd_to_rq (scp)); - hwq =blk_mq_unique_tag_to_hwq (tag); -break ; -case HWQ_MODE_CPU : - hwq =smp_processor_id () % afu->num_hwqs; -break ; -default : -WARN_ON_ONCE (1 ); - } - -return hwq; -} - -/** -* send_tmf() - sends a Task Management Function (TMF) -* @cfg: Internal structure associated with the host. -* @sdev: SCSI device destined for TMF. -* @tmfcmd: TMF command to send. -* -* Return: -* 0 on success, SCSI_MLQUEUE_HOST_BUSY or -errno on failure -*/ -static int send_tmf (struct cxlflash_cfg *cfg,struct scsi_device *sdev, -u64 tmfcmd) -{ -struct afu *afu = cfg->afu; -struct afu_cmd *cmd =NULL ; -struct device *dev = &cfg->dev->dev; -struct hwq *hwq =get_hwq (afu,PRIMARY_HWQ ); -bool needs_deletion = false; -char *buf =NULL ; -ulong lock_flags; -int rc =0 ; -ulong to; - - buf = kzalloc(sizeof(*cmd) + __alignof__(*cmd) - 1, GFP_KERNEL); -if (unlikely (!buf)) { -dev_err (dev,"%s: no memory for command\n" , __func__); - rc = -ENOMEM ; - goto out; - } - - cmd = (struct afu_cmd *)PTR_ALIGN(buf, __alignof__(*cmd)); -INIT_LIST_HEAD (&cmd->queue); - -/* When Task Management Function is active do not send another */ -spin_lock_irqsave (&cfg->tmf_slock, lock_flags); -if (cfg->tmf_active) -wait_event_interruptible_lock_irq (cfg->tmf_waitq, - !cfg->tmf_active, - cfg->tmf_slock); - cfg->tmf_active = true; -spin_unlock_irqrestore (&cfg->tmf_slock, lock_flags); - - cmd->parent = afu; - cmd->cmd_tmf = true; - cmd->hwq_index = hwq->index; - - cmd->rcb.ctx_id = hwq->ctx_hndl; - cmd->rcb.msi =SISL_MSI_RRQ_UPDATED ; - cmd->rcb.port_sel =CHAN2PORTMASK (sdev->channel); - cmd->rcb.lun_id =lun_to_lunid (sdev->lun); - cmd->rcb.req_flags = (SISL_REQ_FLAGS_PORT_LUN_ID | -SISL_REQ_FLAGS_SUP_UNDERRUN | -SISL_REQ_FLAGS_TMF_CMD ); -memcpy (cmd->rcb.cdb, &tmfcmd,sizeof (tmfcmd)); - - rc = afu->send_cmd (afu, cmd); -if (unlikely (rc)) { -spin_lock_irqsave (&cfg->tmf_slock, lock_flags); - cfg->tmf_active = false; -spin_unlock_irqrestore (&cfg->tmf_slock, lock_flags); - goto out; - } - -spin_lock_irqsave (&cfg->tmf_slock, lock_flags); - to =msecs_to_jiffies (5000 ); - to =wait_event_interruptible_lock_irq_timeout (cfg->tmf_waitq, - !cfg->tmf_active, - cfg->tmf_slock, - to); -if (!to) { -dev_err (dev,"%s: TMF timed out\n" , __func__); - rc = -ETIMEDOUT ; - needs_deletion = true; - }else if (cmd->cmd_aborted) { -dev_err (dev,"%s: TMF aborted\n" , __func__); - rc = -EAGAIN ; - }else if (cmd->sa.ioasc) { -dev_err (dev,"%s: TMF failed ioasc=%08x\n" , - __func__, cmd->sa.ioasc); - rc = -EIO ; - } - cfg->tmf_active = false; -spin_unlock_irqrestore (&cfg->tmf_slock, lock_flags); - -if (needs_deletion) { -spin_lock_irqsave (&hwq->hsq_slock, lock_flags); -list_del (&cmd->list); -spin_unlock_irqrestore (&hwq->hsq_slock, lock_flags); - } -out: -kfree (buf); -return rc; -} - -/** -* cxlflash_driver_info() - information handler for this host driver -* @host: SCSI host associated with device. -* -* Return: A string describing the device. -*/ -static const char *cxlflash_driver_info (struct Scsi_Host *host) -{ -return CXLFLASH_ADAPTER_NAME ; -} - -/** -* cxlflash_queuecommand() - sends a mid-layer request -* @host: SCSI host associated with device. -* @scp: SCSI command to send. -* -* Return: 0 on success, SCSI_MLQUEUE_HOST_BUSY on failure -*/ -static int cxlflash_queuecommand (struct Scsi_Host *host,struct scsi_cmnd *scp) -{ -struct cxlflash_cfg *cfg =shost_priv (host); -struct afu *afu = cfg->afu; -struct device *dev = &cfg->dev->dev; -struct afu_cmd *cmd =sc_to_afuci (scp); -struct scatterlist *sg =scsi_sglist (scp); -int hwq_index =cmd_to_target_hwq (host, scp, afu); -struct hwq *hwq =get_hwq (afu, hwq_index); -u16 req_flags =SISL_REQ_FLAGS_SUP_UNDERRUN ; -ulong lock_flags; -int rc =0 ; - -dev_dbg_ratelimited (dev,"%s: (scp=%p) %d/%d/%d/%llu " -"cdb=(%08x-%08x-%08x-%08x)\n" , - __func__, scp, host->host_no, scp->device->channel, - scp->device->id, scp->device->lun, -get_unaligned_be32 (&((u32 *)scp->cmnd)[0 ]), -get_unaligned_be32 (&((u32 *)scp->cmnd)[1 ]), -get_unaligned_be32 (&((u32 *)scp->cmnd)[2 ]), -get_unaligned_be32 (&((u32 *)scp->cmnd)[3 ])); - -/* -* If a Task Management Function is active, wait for it to complete -* before continuing with regular commands. -*/ -spin_lock_irqsave (&cfg->tmf_slock, lock_flags); -if (cfg->tmf_active) { -spin_unlock_irqrestore (&cfg->tmf_slock, lock_flags); - rc =SCSI_MLQUEUE_HOST_BUSY ; - goto out; - } -spin_unlock_irqrestore (&cfg->tmf_slock, lock_flags); - -switch (cfg->state) { -case STATE_PROBING : -case STATE_PROBED : -case STATE_RESET : -dev_dbg_ratelimited (dev,"%s: device is in reset\n" , __func__); - rc =SCSI_MLQUEUE_HOST_BUSY ; - goto out; -case STATE_FAILTERM : -dev_dbg_ratelimited (dev,"%s: device has failed\n" , __func__); - scp->result = (DID_NO_CONNECT <<16 ); -scsi_done (scp); - rc =0 ; - goto out; -default : -atomic_inc (&afu->cmds_active); -break ; - } - -if (likely (sg)) { - cmd->rcb.data_len = sg->length; - cmd->rcb.data_ea = (uintptr_t )sg_virt (sg); - } - - cmd->scp = scp; - cmd->parent = afu; - cmd->hwq_index = hwq_index; - - cmd->sa.ioasc =0 ; - cmd->rcb.ctx_id = hwq->ctx_hndl; - cmd->rcb.msi =SISL_MSI_RRQ_UPDATED ; - cmd->rcb.port_sel =CHAN2PORTMASK (scp->device->channel); - cmd->rcb.lun_id =lun_to_lunid (scp->device->lun); - -if (scp->sc_data_direction ==DMA_TO_DEVICE ) - req_flags |=SISL_REQ_FLAGS_HOST_WRITE ; - - cmd->rcb.req_flags = req_flags; -memcpy (cmd->rcb.cdb, scp->cmnd,sizeof (cmd->rcb.cdb)); - - rc = afu->send_cmd (afu, cmd); -atomic_dec (&afu->cmds_active); -out: -return rc; -} - -/** -* cxlflash_wait_for_pci_err_recovery() - wait for error recovery during probe -* @cfg: Internal structure associated with the host. -*/ -static void cxlflash_wait_for_pci_err_recovery (struct cxlflash_cfg *cfg) -{ -struct pci_dev *pdev = cfg->dev; - -if (pci_channel_offline (pdev)) -wait_event_timeout (cfg->reset_waitq, - !pci_channel_offline (pdev), -CXLFLASH_PCI_ERROR_RECOVERY_TIMEOUT ); -} - -/** -* free_mem() - free memory associated with the AFU -* @cfg: Internal structure associated with the host. -*/ -static void free_mem (struct cxlflash_cfg *cfg) -{ -struct afu *afu = cfg->afu; - -if (cfg->afu) { -free_pages ((ulong )afu,get_order (sizeof (struct afu ))); - cfg->afu =NULL ; - } -} - -/** -* cxlflash_reset_sync() - synchronizing point for asynchronous resets -* @cfg: Internal structure associated with the host. -*/ -static void cxlflash_reset_sync (struct cxlflash_cfg *cfg) -{ -if (cfg->async_reset_cookie ==0 ) -return ; - -/* Wait until all async calls prior to this cookie have completed */ -async_synchronize_cookie (cfg->async_reset_cookie +1 ); - cfg->async_reset_cookie =0 ; -} - -/** -* stop_afu() - stops the AFU command timers and unmaps the MMIO space -* @cfg: Internal structure associated with the host. -* -* Safe to call with AFU in a partially allocated/initialized state. -* -* Cancels scheduled worker threads, waits for any active internal AFU -* commands to timeout, disables IRQ polling and then unmaps the MMIO space. -*/ -static void stop_afu (struct cxlflash_cfg *cfg) -{ -struct afu *afu = cfg->afu; -struct hwq *hwq; -int i; - -cancel_work_sync (&cfg->work_q); -if (!current_is_async ()) -cxlflash_reset_sync (cfg); - -if (likely (afu)) { -while (atomic_read (&afu->cmds_active)) -ssleep (1 ); - -if (afu_is_irqpoll_enabled (afu)) { -for (i =0 ; i < afu->num_hwqs; i++) { - hwq =get_hwq (afu, i); - -irq_poll_disable (&hwq->irqpoll); - } - } - -if (likely (afu->afu_map)) { - cfg->ops->psa_unmap (afu->afu_map); - afu->afu_map =NULL ; - } - } -} - -/** -* term_intr() - disables all AFU interrupts -* @cfg: Internal structure associated with the host. -* @level: Depth of allocation, where to begin waterfall tear down. -* @index: Index of the hardware queue. -* -* Safe to call with AFU/MC in partially allocated/initialized state. -*/ -static void term_intr (struct cxlflash_cfg *cfg,enum undo_level level, -u32 index) -{ -struct afu *afu = cfg->afu; -struct device *dev = &cfg->dev->dev; -struct hwq *hwq; - -if (!afu) { -dev_err (dev,"%s: returning with NULL afu\n" , __func__); -return ; - } - - hwq =get_hwq (afu, index); - -if (!hwq->ctx_cookie) { -dev_err (dev,"%s: returning with NULL MC\n" , __func__); -return ; - } - -switch (level) { -case UNMAP_THREE : -/* SISL_MSI_ASYNC_ERROR is setup only for the primary HWQ */ -if (index ==PRIMARY_HWQ ) - cfg->ops->unmap_afu_irq (hwq->ctx_cookie,3 , hwq); - fallthrough; -case UNMAP_TWO : - cfg->ops->unmap_afu_irq (hwq->ctx_cookie,2 , hwq); - fallthrough; -case UNMAP_ONE : - cfg->ops->unmap_afu_irq (hwq->ctx_cookie,1 , hwq); - fallthrough; -case FREE_IRQ : - cfg->ops->free_afu_irqs (hwq->ctx_cookie); - fallthrough; -case UNDO_NOOP : -/* No action required */ -break ; - } -} - -/** -* term_mc() - terminates the master context -* @cfg: Internal structure associated with the host. -* @index: Index of the hardware queue. -* -* Safe to call with AFU/MC in partially allocated/initialized state. -*/ -static void term_mc (struct cxlflash_cfg *cfg,u32 index) -{ -struct afu *afu = cfg->afu; -struct device *dev = &cfg->dev->dev; -struct hwq *hwq; -ulong lock_flags; - -if (!afu) { -dev_err (dev,"%s: returning with NULL afu\n" , __func__); -return ; - } - - hwq =get_hwq (afu, index); - -if (!hwq->ctx_cookie) { -dev_err (dev,"%s: returning with NULL MC\n" , __func__); -return ; - } - -WARN_ON (cfg->ops->stop_context (hwq->ctx_cookie)); -if (index !=PRIMARY_HWQ ) -WARN_ON (cfg->ops->release_context (hwq->ctx_cookie)); - hwq->ctx_cookie =NULL ; - -spin_lock_irqsave (&hwq->hrrq_slock, lock_flags); - hwq->hrrq_online = false; -spin_unlock_irqrestore (&hwq->hrrq_slock, lock_flags); - -spin_lock_irqsave (&hwq->hsq_slock, lock_flags); -flush_pending_cmds (hwq); -spin_unlock_irqrestore (&hwq->hsq_slock, lock_flags); -} - -/** -* term_afu() - terminates the AFU -* @cfg: Internal structure associated with the host. -* -* Safe to call with AFU/MC in partially allocated/initialized state. -*/ -static void term_afu (struct cxlflash_cfg *cfg) -{ -struct device *dev = &cfg->dev->dev; -int k; - -/* -* Tear down is carefully orchestrated to ensure -* no interrupts can come in when the problem state -* area is unmapped. -* -* 1) Disable all AFU interrupts for each master -* 2) Unmap the problem state area -* 3) Stop each master context -*/ -for (k = cfg->afu->num_hwqs -1 ; k >=0 ; k--) -term_intr (cfg,UNMAP_THREE , k); - -stop_afu (cfg); - -for (k = cfg->afu->num_hwqs -1 ; k >=0 ; k--) -term_mc (cfg, k); - -dev_dbg (dev,"%s: returning\n" , __func__); -} - -/** -* notify_shutdown() - notifies device of pending shutdown -* @cfg: Internal structure associated with the host. -* @wait: Whether to wait for shutdown processing to complete. -* -* This function will notify the AFU that the adapter is being shutdown -* and will wait for shutdown processing to complete if wait is true. -* This notification should flush pending I/Os to the device and halt -* further I/Os until the next AFU reset is issued and device restarted. -*/ -static void notify_shutdown (struct cxlflash_cfg *cfg,bool wait) -{ -struct afu *afu = cfg->afu; -struct device *dev = &cfg->dev->dev; -struct dev_dependent_vals *ddv; -__be64 __iomem *fc_port_regs; -u64 reg, status; -int i, retry_cnt =0 ; - - ddv = (struct dev_dependent_vals *)cfg->dev_id->driver_data; -if (!(ddv->flags &CXLFLASH_NOTIFY_SHUTDOWN )) -return ; - -if (!afu || !afu->afu_map) { -dev_dbg (dev,"%s: Problem state area not mapped\n" , __func__); -return ; - } - -/* Notify AFU */ -for (i =0 ; i < cfg->num_fc_ports; i++) { - fc_port_regs =get_fc_port_regs (cfg, i); - - reg =readq_be (&fc_port_regs[FC_CONFIG2 /8 ]); - reg |=SISL_FC_SHUTDOWN_NORMAL ; -writeq_be (reg, &fc_port_regs[FC_CONFIG2 /8 ]); - } - -if (!wait) -return ; - -/* Wait up to 1.5 seconds for shutdown processing to complete */ -for (i =0 ; i < cfg->num_fc_ports; i++) { - fc_port_regs =get_fc_port_regs (cfg, i); - retry_cnt =0 ; - -while (true) { - status =readq_be (&fc_port_regs[FC_STATUS /8 ]); -if (status &SISL_STATUS_SHUTDOWN_COMPLETE ) -break ; -if (++retry_cnt >=MC_RETRY_CNT ) { -dev_dbg (dev,"%s: port %d shutdown processing " -"not yet completed\n" , __func__, i); -break ; - } -msleep (100 * retry_cnt); - } - } -} - -/** -* cxlflash_get_minor() - gets the first available minor number -* -* Return: Unique minor number that can be used to create the character device. -*/ -static int cxlflash_get_minor (void ) -{ -int minor; -long bit; - - bit =find_first_zero_bit (cxlflash_minor,CXLFLASH_MAX_ADAPTERS ); -if (bit >=CXLFLASH_MAX_ADAPTERS ) -return -1 ; - - minor = bit &MINORMASK ; -set_bit (minor, cxlflash_minor); -return minor; -} - -/** -* cxlflash_put_minor() - releases the minor number -* @minor: Minor number that is no longer needed. -*/ -static void cxlflash_put_minor (int minor) -{ -clear_bit (minor, cxlflash_minor); -} - -/** -* cxlflash_release_chrdev() - release the character device for the host -* @cfg: Internal structure associated with the host. -*/ -static void cxlflash_release_chrdev (struct cxlflash_cfg *cfg) -{ -device_unregister (cfg->chardev); - cfg->chardev =NULL ; -cdev_del (&cfg->cdev); -cxlflash_put_minor (MINOR (cfg->cdev.dev)); -} - -/** -* cxlflash_remove() - PCI entry point to tear down host -* @pdev: PCI device associated with the host. -* -* Safe to use as a cleanup in partially allocated/initialized state. Note that -* the reset_waitq is flushed as part of the stop/termination of user contexts. -*/ -static void cxlflash_remove (struct pci_dev *pdev) -{ -struct cxlflash_cfg *cfg =pci_get_drvdata (pdev); -struct device *dev = &pdev->dev; -ulong lock_flags; - -if (!pci_is_enabled (pdev)) { -dev_dbg (dev,"%s: Device is disabled\n" , __func__); -return ; - } - -/* Yield to running recovery threads before continuing with remove */ -wait_event (cfg->reset_waitq, cfg->state !=STATE_RESET && - cfg->state !=STATE_PROBING ); -spin_lock_irqsave (&cfg->tmf_slock, lock_flags); -if (cfg->tmf_active) -wait_event_interruptible_lock_irq (cfg->tmf_waitq, - !cfg->tmf_active, - cfg->tmf_slock); -spin_unlock_irqrestore (&cfg->tmf_slock, lock_flags); - -/* Notify AFU and wait for shutdown processing to complete */ -notify_shutdown (cfg, true); - - cfg->state =STATE_FAILTERM ; -cxlflash_stop_term_user_contexts (cfg); - -switch (cfg->init_state) { -case INIT_STATE_CDEV : -cxlflash_release_chrdev (cfg); - fallthrough; -case INIT_STATE_SCSI : -cxlflash_term_local_luns (cfg); -scsi_remove_host (cfg->host); - fallthrough; -case INIT_STATE_AFU : -term_afu (cfg); - fallthrough; -case INIT_STATE_PCI : - cfg->ops->destroy_afu (cfg->afu_cookie); -pci_disable_device (pdev); - fallthrough; -case INIT_STATE_NONE : -free_mem (cfg); -scsi_host_put (cfg->host); -break ; - } - -dev_dbg (dev,"%s: returning\n" , __func__); -} - -/** -* alloc_mem() - allocates the AFU and its command pool -* @cfg: Internal structure associated with the host. -* -* A partially allocated state remains on failure. -* -* Return: -* 0 on success -* -ENOMEM on failure to allocate memory -*/ -static int alloc_mem (struct cxlflash_cfg *cfg) -{ -int rc =0 ; -struct device *dev = &cfg->dev->dev; - -/* AFU is ~28k, i.e. only one 64k page or up to seven 4k pages */ - cfg->afu = (void *)__get_free_pages (GFP_KERNEL | __GFP_ZERO, -get_order (sizeof (struct afu ))); -if (unlikely (!cfg->afu)) { -dev_err (dev,"%s: cannot get %d free pages\n" , - __func__,get_order (sizeof (struct afu ))); - rc = -ENOMEM ; - goto out; - } - cfg->afu->parent = cfg; - cfg->afu->desired_hwqs =CXLFLASH_DEF_HWQS ; - cfg->afu->afu_map =NULL ; -out: -return rc; -} - -/** -* init_pci() - initializes the host as a PCI device -* @cfg: Internal structure associated with the host. -* -* Return: 0 on success, -errno on failure -*/ -static int init_pci (struct cxlflash_cfg *cfg) -{ -struct pci_dev *pdev = cfg->dev; -struct device *dev = &cfg->dev->dev; -int rc =0 ; - - rc =pci_enable_device (pdev); -if (rc ||pci_channel_offline (pdev)) { -if (pci_channel_offline (pdev)) { -cxlflash_wait_for_pci_err_recovery (cfg); - rc =pci_enable_device (pdev); - } - -if (rc) { -dev_err (dev,"%s: Cannot enable adapter\n" , __func__); -cxlflash_wait_for_pci_err_recovery (cfg); - goto out; - } - } - -out: -dev_dbg (dev,"%s: returning rc=%d\n" , __func__, rc); -return rc; -} - -/** -* init_scsi() - adds the host to the SCSI stack and kicks off host scan -* @cfg: Internal structure associated with the host. -* -* Return: 0 on success, -errno on failure -*/ -static int init_scsi (struct cxlflash_cfg *cfg) -{ -struct pci_dev *pdev = cfg->dev; -struct device *dev = &cfg->dev->dev; -int rc =0 ; - - rc =scsi_add_host (cfg->host, &pdev->dev); -if (rc) { -dev_err (dev,"%s: scsi_add_host failed rc=%d\n" , __func__, rc); - goto out; - } - -scsi_scan_host (cfg->host); - -out: -dev_dbg (dev,"%s: returning rc=%d\n" , __func__, rc); -return rc; -} - -/** -* set_port_online() - transitions the specified host FC port to online state -* @fc_regs: Top of MMIO region defined for specified port. -* -* The provided MMIO region must be mapped prior to call. Online state means -* that the FC link layer has synced, completed the handshaking process, and -* is ready for login to start. -*/ -static void set_port_online (__be64 __iomem *fc_regs) -{ -u64 cmdcfg; - - cmdcfg =readq_be (&fc_regs[FC_MTIP_CMDCONFIG /8 ]); - cmdcfg &= (~FC_MTIP_CMDCONFIG_OFFLINE );/* clear OFF_LINE */ - cmdcfg |= (FC_MTIP_CMDCONFIG_ONLINE );/* set ON_LINE */ -writeq_be (cmdcfg, &fc_regs[FC_MTIP_CMDCONFIG /8 ]); -} - -/** -* set_port_offline() - transitions the specified host FC port to offline state -* @fc_regs: Top of MMIO region defined for specified port. -* -* The provided MMIO region must be mapped prior to call. -*/ -static void set_port_offline (__be64 __iomem *fc_regs) -{ -u64 cmdcfg; - - cmdcfg =readq_be (&fc_regs[FC_MTIP_CMDCONFIG /8 ]); - cmdcfg &= (~FC_MTIP_CMDCONFIG_ONLINE );/* clear ON_LINE */ - cmdcfg |= (FC_MTIP_CMDCONFIG_OFFLINE );/* set OFF_LINE */ -writeq_be (cmdcfg, &fc_regs[FC_MTIP_CMDCONFIG /8 ]); -} - -/** -* wait_port_online() - waits for the specified host FC port come online -* @fc_regs: Top of MMIO region defined for specified port. -* @delay_us: Number of microseconds to delay between reading port status. -* @nretry: Number of cycles to retry reading port status. -* -* The provided MMIO region must be mapped prior to call. This will timeout -* when the cable is not plugged in. -* -* Return: -* TRUE (1) when the specified port is online -* FALSE (0) when the specified port fails to come online after timeout -*/ -static bool wait_port_online (__be64 __iomem *fc_regs,u32 delay_us,u32 nretry) -{ -u64 status; - -WARN_ON (delay_us <1000 ); - -do { -msleep (delay_us /1000 ); - status =readq_be (&fc_regs[FC_MTIP_STATUS /8 ]); -if (status ==U64_MAX ) - nretry /=2 ; - }while ((status &FC_MTIP_STATUS_MASK ) !=FC_MTIP_STATUS_ONLINE && - nretry--); - -return ((status &FC_MTIP_STATUS_MASK ) ==FC_MTIP_STATUS_ONLINE ); -} - -/** -* wait_port_offline() - waits for the specified host FC port go offline -* @fc_regs: Top of MMIO region defined for specified port. -* @delay_us: Number of microseconds to delay between reading port status. -* @nretry: Number of cycles to retry reading port status. -* -* The provided MMIO region must be mapped prior to call. -* -* Return: -* TRUE (1) when the specified port is offline -* FALSE (0) when the specified port fails to go offline after timeout -*/ -static bool wait_port_offline (__be64 __iomem *fc_regs,u32 delay_us,u32 nretry) -{ -u64 status; - -WARN_ON (delay_us <1000 ); - -do { -msleep (delay_us /1000 ); - status =readq_be (&fc_regs[FC_MTIP_STATUS /8 ]); -if (status ==U64_MAX ) - nretry /=2 ; - }while ((status &FC_MTIP_STATUS_MASK ) !=FC_MTIP_STATUS_OFFLINE && - nretry--); - -return ((status &FC_MTIP_STATUS_MASK ) ==FC_MTIP_STATUS_OFFLINE ); -} - -/** -* afu_set_wwpn() - configures the WWPN for the specified host FC port -* @afu: AFU associated with the host that owns the specified FC port. -* @port: Port number being configured. -* @fc_regs: Top of MMIO region defined for specified port. -* @wwpn: The world-wide-port-number previously discovered for port. -* -* The provided MMIO region must be mapped prior to call. As part of the -* sequence to configure the WWPN, the port is toggled offline and then back -* online. This toggling action can cause this routine to delay up to a few -* seconds. When configured to use the internal LUN feature of the AFU, a -* failure to come online is overridden. -*/ -static void afu_set_wwpn (struct afu *afu,int port,__be64 __iomem *fc_regs, -u64 wwpn) -{ -struct cxlflash_cfg *cfg = afu->parent; -struct device *dev = &cfg->dev->dev; - -set_port_offline (fc_regs); -if (!wait_port_offline (fc_regs,FC_PORT_STATUS_RETRY_INTERVAL_US , -FC_PORT_STATUS_RETRY_CNT )) { -dev_dbg (dev,"%s: wait on port %d to go offline timed out\n" , - __func__, port); - } - -writeq_be (wwpn, &fc_regs[FC_PNAME /8 ]); - -set_port_online (fc_regs); -if (!wait_port_online (fc_regs,FC_PORT_STATUS_RETRY_INTERVAL_US , -FC_PORT_STATUS_RETRY_CNT )) { -dev_dbg (dev,"%s: wait on port %d to go online timed out\n" , - __func__, port); - } -} - -/** -* afu_link_reset() - resets the specified host FC port -* @afu: AFU associated with the host that owns the specified FC port. -* @port: Port number being configured. -* @fc_regs: Top of MMIO region defined for specified port. -* -* The provided MMIO region must be mapped prior to call. The sequence to -* reset the port involves toggling it offline and then back online. This -* action can cause this routine to delay up to a few seconds. An effort -* is made to maintain link with the device by switching to host to use -* the alternate port exclusively while the reset takes place. -* failure to come online is overridden. -*/ -static void afu_link_reset (struct afu *afu,int port,__be64 __iomem *fc_regs) -{ -struct cxlflash_cfg *cfg = afu->parent; -struct device *dev = &cfg->dev->dev; -u64 port_sel; - -/* first switch the AFU to the other links, if any */ - port_sel =readq_be (&afu->afu_map->global.regs.afu_port_sel); - port_sel &= ~(1ULL << port); -writeq_be (port_sel, &afu->afu_map->global.regs.afu_port_sel); -cxlflash_afu_sync (afu,0 ,0 ,AFU_GSYNC ); - -set_port_offline (fc_regs); -if (!wait_port_offline (fc_regs,FC_PORT_STATUS_RETRY_INTERVAL_US , -FC_PORT_STATUS_RETRY_CNT )) -dev_err (dev,"%s: wait on port %d to go offline timed out\n" , - __func__, port); - -set_port_online (fc_regs); -if (!wait_port_online (fc_regs,FC_PORT_STATUS_RETRY_INTERVAL_US , -FC_PORT_STATUS_RETRY_CNT )) -dev_err (dev,"%s: wait on port %d to go online timed out\n" , - __func__, port); - -/* switch back to include this port */ - port_sel |= (1ULL << port); -writeq_be (port_sel, &afu->afu_map->global.regs.afu_port_sel); -cxlflash_afu_sync (afu,0 ,0 ,AFU_GSYNC ); - -dev_dbg (dev,"%s: returning port_sel=%016llx\n" , __func__, port_sel); -} - -/** -* afu_err_intr_init() - clears and initializes the AFU for error interrupts -* @afu: AFU associated with the host. -*/ -static void afu_err_intr_init (struct afu *afu) -{ -struct cxlflash_cfg *cfg = afu->parent; -__be64 __iomem *fc_port_regs; -int i; -struct hwq *hwq =get_hwq (afu,PRIMARY_HWQ ); -u64 reg; - -/* global async interrupts: AFU clears afu_ctrl on context exit -* if async interrupts were sent to that context. This prevents -* the AFU form sending further async interrupts when -* there is -* nobody to receive them. -*/ - -/* mask all */ -writeq_be (-1ULL , &afu->afu_map->global.regs.aintr_mask); -/* set LISN# to send and point to primary master context */ - reg = ((u64) (((hwq->ctx_hndl <<8 ) |SISL_MSI_ASYNC_ERROR )) <<40 ); - -if (afu->internal_lun) - reg |=1 ;/* Bit 63 indicates local lun */ -writeq_be (reg, &afu->afu_map->global.regs.afu_ctrl); -/* clear all */ -writeq_be (-1ULL , &afu->afu_map->global.regs.aintr_clear); -/* unmask bits that are of interest */ -/* note: afu can send an interrupt after this step */ -writeq_be (SISL_ASTATUS_MASK , &afu->afu_map->global.regs.aintr_mask); -/* clear again in case a bit came on after previous clear but before */ -/* unmask */ -writeq_be (-1ULL , &afu->afu_map->global.regs.aintr_clear); - -/* Clear/Set internal lun bits */ - fc_port_regs =get_fc_port_regs (cfg,0 ); - reg =readq_be (&fc_port_regs[FC_CONFIG2 /8 ]); - reg &=SISL_FC_INTERNAL_MASK ; -if (afu->internal_lun) - reg |= ((u64)(afu->internal_lun -1 ) <<SISL_FC_INTERNAL_SHIFT ); -writeq_be (reg, &fc_port_regs[FC_CONFIG2 /8 ]); - -/* now clear FC errors */ -for (i =0 ; i < cfg->num_fc_ports; i++) { - fc_port_regs =get_fc_port_regs (cfg, i); - -writeq_be (0xFFFFFFFFU , &fc_port_regs[FC_ERROR /8 ]); -writeq_be (0 , &fc_port_regs[FC_ERRCAP /8 ]); - } - -/* sync interrupts for master's IOARRIN write */ -/* note that unlike asyncs, there can be no pending sync interrupts */ -/* at this time (this is a fresh context and master has not written */ -/* IOARRIN yet), so there is nothing to clear. */ - -/* set LISN#, it is always sent to the context that wrote IOARRIN */ -for (i =0 ; i < afu->num_hwqs; i++) { - hwq =get_hwq (afu, i); - - reg =readq_be (&hwq->host_map->ctx_ctrl); -WARN_ON ((reg &SISL_CTX_CTRL_LISN_MASK ) !=0 ); - reg |=SISL_MSI_SYNC_ERROR ; -writeq_be (reg, &hwq->host_map->ctx_ctrl); -writeq_be (SISL_ISTATUS_MASK , &hwq->host_map->intr_mask); - } -} - -/** -* cxlflash_sync_err_irq() - interrupt handler for synchronous errors -* @irq: Interrupt number. -* @data: Private data provided at interrupt registration, the AFU. -* -* Return: Always return IRQ_HANDLED. -*/ -static irqreturn_t cxlflash_sync_err_irq (int irq,void *data) -{ -struct hwq *hwq = (struct hwq *)data; -struct cxlflash_cfg *cfg = hwq->afu->parent; -struct device *dev = &cfg->dev->dev; -u64 reg; -u64 reg_unmasked; - - reg =readq_be (&hwq->host_map->intr_status); - reg_unmasked = (reg &SISL_ISTATUS_UNMASK ); - -if (reg_unmasked ==0UL ) { -dev_err (dev,"%s: spurious interrupt, intr_status=%016llx\n" , - __func__, reg); - goto cxlflash_sync_err_irq_exit; - } - -dev_err (dev,"%s: unexpected interrupt, intr_status=%016llx\n" , - __func__, reg); - -writeq_be (reg_unmasked, &hwq->host_map->intr_clear); - -cxlflash_sync_err_irq_exit: -return IRQ_HANDLED ; -} - -/** -* process_hrrq() - process the read-response queue -* @hwq: HWQ associated with the host. -* @doneq: Queue of commands harvested from the RRQ. -* @budget: Threshold of RRQ entries to process. -* -* This routine must be called holding the disabled RRQ spin lock. -* -* Return: The number of entries processed. -*/ -static int process_hrrq (struct hwq *hwq,struct list_head *doneq,int budget) -{ -struct afu *afu = hwq->afu; -struct afu_cmd *cmd; -struct sisl_ioasa *ioasa; -struct sisl_ioarcb *ioarcb; -bool toggle = hwq->toggle; -int num_hrrq =0 ; -u64 entry, - *hrrq_start = hwq->hrrq_start, - *hrrq_end = hwq->hrrq_end, - *hrrq_curr = hwq->hrrq_curr; - -/* Process ready RRQ entries up to the specified budget (if any) */ -while (true) { - entry = *hrrq_curr; - -if ((entry &SISL_RESP_HANDLE_T_BIT ) != toggle) -break ; - - entry &= ~SISL_RESP_HANDLE_T_BIT ; - -if (afu_is_sq_cmd_mode (afu)) { - ioasa = (struct sisl_ioasa *)entry; - cmd = container_of(ioasa, struct afu_cmd, sa); - }else { - ioarcb = (struct sisl_ioarcb *)entry; - cmd = container_of(ioarcb, struct afu_cmd, rcb); - } - -list_add_tail (&cmd->queue, doneq); - -/* Advance to next entry or wrap and flip the toggle bit */ -if (hrrq_curr < hrrq_end) - hrrq_curr++; -else { - hrrq_curr = hrrq_start; - toggle ^=SISL_RESP_HANDLE_T_BIT ; - } - -atomic_inc (&hwq->hsq_credits); - num_hrrq++; - -if (budget >0 && num_hrrq >= budget) -break ; - } - - hwq->hrrq_curr = hrrq_curr; - hwq->toggle = toggle; - -return num_hrrq; -} - -/** -* process_cmd_doneq() - process a queue of harvested RRQ commands -* @doneq: Queue of completed commands. -* -* Note that upon return the queue can no longer be trusted. -*/ -static void process_cmd_doneq (struct list_head *doneq) -{ -struct afu_cmd *cmd, *tmp; - -WARN_ON (list_empty (doneq)); - -list_for_each_entry_safe (cmd, tmp, doneq, queue) -cmd_complete (cmd); -} - -/** -* cxlflash_irqpoll() - process a queue of harvested RRQ commands -* @irqpoll: IRQ poll structure associated with queue to poll. -* @budget: Threshold of RRQ entries to process per poll. -* -* Return: The number of entries processed. -*/ -static int cxlflash_irqpoll (struct irq_poll *irqpoll,int budget) -{ - struct hwq *hwq = container_of(irqpoll, struct hwq, irqpoll); -unsigned long hrrq_flags; -LIST_HEAD (doneq); -int num_entries =0 ; - -spin_lock_irqsave (&hwq->hrrq_slock, hrrq_flags); - - num_entries =process_hrrq (hwq, &doneq, budget); -if (num_entries < budget) -irq_poll_complete (irqpoll); - -spin_unlock_irqrestore (&hwq->hrrq_slock, hrrq_flags); - -process_cmd_doneq (&doneq); -return num_entries; -} - -/** -* cxlflash_rrq_irq() - interrupt handler for read-response queue (normal path) -* @irq: Interrupt number. -* @data: Private data provided at interrupt registration, the AFU. -* -* Return: IRQ_HANDLED or IRQ_NONE when no ready entries found. -*/ -static irqreturn_t cxlflash_rrq_irq (int irq,void *data) -{ -struct hwq *hwq = (struct hwq *)data; -struct afu *afu = hwq->afu; -unsigned long hrrq_flags; -LIST_HEAD (doneq); -int num_entries =0 ; - -spin_lock_irqsave (&hwq->hrrq_slock, hrrq_flags); - -/* Silently drop spurious interrupts when queue is not online */ -if (!hwq->hrrq_online) { -spin_unlock_irqrestore (&hwq->hrrq_slock, hrrq_flags); -return IRQ_HANDLED ; - } - -if (afu_is_irqpoll_enabled (afu)) { -irq_poll_sched (&hwq->irqpoll); -spin_unlock_irqrestore (&hwq->hrrq_slock, hrrq_flags); -return IRQ_HANDLED ; - } - - num_entries =process_hrrq (hwq, &doneq,-1 ); -spin_unlock_irqrestore (&hwq->hrrq_slock, hrrq_flags); - -if (num_entries ==0 ) -return IRQ_NONE ; - -process_cmd_doneq (&doneq); -return IRQ_HANDLED ; -} - -/* -* Asynchronous interrupt information table -* -* NOTE: -* - Order matters here as this array is indexed by bit position. -* -* - The checkpatch script considers the BUILD_SISL_ASTATUS_FC_PORT macro -* as complex and complains due to a lack of parentheses/braces. -*/ -#define ASTATUS_FC (_a, _b, _c, _d) \ - { SISL_ASTATUS_FC##_a##_##_b, _c, _a, (_d) } - -#define BUILD_SISL_ASTATUS_FC_PORT (_a) \ - ASTATUS_FC(_a, LINK_UP, "link up", 0), \ - ASTATUS_FC(_a, LINK_DN, "link down", 0), \ - ASTATUS_FC(_a, LOGI_S, "login succeeded", SCAN_HOST), \ - ASTATUS_FC(_a, LOGI_F, "login failed", CLR_FC_ERROR), \ - ASTATUS_FC(_a, LOGI_R, "login timed out, retrying", LINK_RESET), \ - ASTATUS_FC(_a, CRC_T, "CRC threshold exceeded", LINK_RESET), \ - ASTATUS_FC(_a, LOGO, "target initiated LOGO", 0), \ - ASTATUS_FC(_a, OTHER, "other error", CLR_FC_ERROR | LINK_RESET) - -static const struct asyc_intr_info ainfo[] = { -BUILD_SISL_ASTATUS_FC_PORT (1 ), -BUILD_SISL_ASTATUS_FC_PORT (0 ), -BUILD_SISL_ASTATUS_FC_PORT (3 ), -BUILD_SISL_ASTATUS_FC_PORT (2 ) -}; - -/** -* cxlflash_async_err_irq() - interrupt handler for asynchronous errors -* @irq: Interrupt number. -* @data: Private data provided at interrupt registration, the AFU. -* -* Return: Always return IRQ_HANDLED. -*/ -static irqreturn_t cxlflash_async_err_irq (int irq,void *data) -{ -struct hwq *hwq = (struct hwq *)data; -struct afu *afu = hwq->afu; -struct cxlflash_cfg *cfg = afu->parent; -struct device *dev = &cfg->dev->dev; -const struct asyc_intr_info *info; -struct sisl_global_map __iomem *global = &afu->afu_map->global; -__be64 __iomem *fc_port_regs; -u64 reg_unmasked; -u64 reg; -u64 bit; -u8 port; - - reg =readq_be (&global->regs.aintr_status); - reg_unmasked = (reg &SISL_ASTATUS_UNMASK ); - -if (unlikely (reg_unmasked ==0 )) { -dev_err (dev,"%s: spurious interrupt, aintr_status=%016llx\n" , - __func__, reg); - goto out; - } - -/* FYI, it is 'okay' to clear AFU status before FC_ERROR */ -writeq_be (reg_unmasked, &global->regs.aintr_clear); - -/* Check each bit that is on */ -for_each_set_bit (bit, (ulong *)®_unmasked,BITS_PER_LONG ) { -if (unlikely (bit >=ARRAY_SIZE (ainfo))) { -WARN_ON_ONCE (1 ); -continue ; - } - - info = &ainfo[bit]; -if (unlikely (info->status !=1ULL << bit)) { -WARN_ON_ONCE (1 ); -continue ; - } - - port = info->port; - fc_port_regs =get_fc_port_regs (cfg, port); - -dev_err (dev,"%s: FC Port %d -> %s, fc_status=%016llx\n" , - __func__, port, info->desc, -readq_be (&fc_port_regs[FC_STATUS /8 ])); - -/* -* Do link reset first, some OTHER errors will set FC_ERROR -* again if cleared before or w/o a reset -*/ -if (info->action &LINK_RESET ) { -dev_err (dev,"%s: FC Port %d: resetting link\n" , - __func__, port); - cfg->lr_state =LINK_RESET_REQUIRED ; - cfg->lr_port = port; -schedule_work (&cfg->work_q); - } - -if (info->action &CLR_FC_ERROR ) { - reg =readq_be (&fc_port_regs[FC_ERROR /8 ]); - -/* -* Since all errors are unmasked, FC_ERROR and FC_ERRCAP -* should be the same and tracing one is sufficient. -*/ - -dev_err (dev,"%s: fc %d: clearing fc_error=%016llx\n" , - __func__, port, reg); - -writeq_be (reg, &fc_port_regs[FC_ERROR /8 ]); -writeq_be (0 , &fc_port_regs[FC_ERRCAP /8 ]); - } - -if (info->action &SCAN_HOST ) { -atomic_inc (&cfg->scan_host_needed); -schedule_work (&cfg->work_q); - } - } - -out: -return IRQ_HANDLED ; -} - -/** -* read_vpd() - obtains the WWPNs from VPD -* @cfg: Internal structure associated with the host. -* @wwpn: Array of size MAX_FC_PORTS to pass back WWPNs -* -* Return: 0 on success, -errno on failure -*/ -static int read_vpd (struct cxlflash_cfg *cfg,u64 wwpn[]) -{ -struct device *dev = &cfg->dev->dev; -struct pci_dev *pdev = cfg->dev; -int i, k, rc =0 ; -unsigned int kw_size; -ssize_t vpd_size; -char vpd_data[CXLFLASH_VPD_LEN ]; -char tmp_buf[WWPN_BUF_LEN ] = {0 }; -const struct dev_dependent_vals *ddv = (struct dev_dependent_vals *) - cfg->dev_id->driver_data; -const bool wwpn_vpd_required = ddv->flags &CXLFLASH_WWPN_VPD_REQUIRED ; -const char *wwpn_vpd_tags[MAX_FC_PORTS ] = {"V5" ,"V6" ,"V7" ,"V8" }; - -/* Get the VPD data from the device */ - vpd_size = cfg->ops->read_adapter_vpd (pdev, vpd_data,sizeof (vpd_data)); -if (unlikely (vpd_size <=0 )) { -dev_err (dev,"%s: Unable to read VPD (size = %ld)\n" , - __func__, vpd_size); - rc = -ENODEV ; - goto out; - } - -/* -* Find the offset of the WWPN tag within the read only -* VPD data and validate the found field (partials are -* no good to us). Convert the ASCII data to an integer -* value. Note that we must copy to a temporary buffer Lines of this file are not shown. View the raw message.
drivers/scsi/cxlflash/ocxl_hw.c deleted +0
-1399Lines of this file are not shown. View the raw message.
drivers/scsi/cxlflash/ocxl_hw.h deleted +0
-72Lines of this file are not shown. View the raw message.
drivers/scsi/cxlflash/sislite.h deleted +0
-560Lines of this file are not shown. View the raw message.
drivers/scsi/cxlflash/superpipe.c deleted +0
-2218Lines of this file are not shown. View the raw message.
drivers/scsi/cxlflash/superpipe.h deleted +0
-150Lines of this file are not shown. View the raw message.
drivers/scsi/cxlflash/vlun.c deleted +0
-1336Lines of this file are not shown. View the raw message.
include/uapi/scsi/cxlflash_ioctl.h deleted +0
-276Lines of this file are not shown. View the raw message.
tools/testing/selftests/filesystems/statmount/statmount_test.c +6
-7Lines 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 v2 2/2] cxl: Remove driver
In reply to Andrew DonnellanQuoted 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 5 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]>
Thanks!
Fred
Quoted 15,081 lines
---
v2: rebase, update docs--- .../ABI/{obsolete => removed}/sysfs-class-cxl | 55 +- Documentation/arch/powerpc/cxl.rst | 469 ---- 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(+), 14311 deletions(-)rename
Documentation/ABI/{obsolete=> removed}/sysfs-class-cxl (87%) delete mode 100644Documentation/arch/powerpc/cxl.rstdelete mode 100644arch/powerpc/platforms/powernv/pci-cxl.cdelete mode 100644drivers/misc/cxl/Kconfig
delete mode 100644drivers/misc/cxl/Makefile
delete mode 100644drivers/misc/cxl/api.c
delete mode 100644drivers/misc/cxl/base.c
delete mode 100644drivers/misc/cxl/context.c
delete mode 100644drivers/misc/cxl/cxl.h
delete mode 100644drivers/misc/cxl/cxllib.c
delete mode 100644drivers/misc/cxl/debugfs.c
delete mode 100644drivers/misc/cxl/fault.c
delete mode 100644drivers/misc/cxl/file.c
delete mode 100644drivers/misc/cxl/flash.c
delete mode 100644drivers/misc/cxl/guest.c
delete mode 100644drivers/misc/cxl/hcalls.c
delete mode 100644drivers/misc/cxl/hcalls.h
delete mode 100644drivers/misc/cxl/irq.c
delete mode 100644drivers/misc/cxl/main.c
delete mode 100644drivers/misc/cxl/native.c
delete mode 100644drivers/misc/cxl/of.c
delete mode 100644drivers/misc/cxl/pci.c
delete mode 100644drivers/misc/cxl/sysfs.c
delete mode 100644drivers/misc/cxl/trace.c
delete mode 100644drivers/misc/cxl/trace.h
delete mode 100644drivers/misc/cxl/vphb.c
delete mode 100644include/misc/cxl-base.h
delete mode 100644include/misc/cxl.h
delete mode 100644include/misc/cxllib.h
delete mode 100644include/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
-469@@ -1,469 +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. - - -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/testing/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@@ -371,7 +371,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@@ -6306,18 +6306,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; - union {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.
Martin K. Petersen
AppliedRe: [PATCH v2 1/2] cxlflash: Remove driver
In reply to Andrew DonnellanAndrew,
Quoted 1 line
Remove the cxlflash driver for IBM CAPI Flash devices.
Applied to 6.15/scsi-staging, thanks!
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering
Martin K. Petersen
AppliedRe: (subset) [PATCH v2 0/2] Remove cxl and cxlflash drivers
In reply to Andrew DonnellanQuoted 10 lines · Andrew Donnellan
This series removes the cxl and cxlflash drivers 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.[...]
Applied to 6.15/scsi-queue, thanks!
[1/2] cxlflash: Remove driver
https://git.kernel.org/mkp/scsi/c/772ba9b5bd27
Signature · 1 line
Martin K. Petersen Oracle Linux Engineering