Skip to content

cxl: add type2 device basic support

[email protected] linux-cxl netdev oe-kbuild-all 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v10 Latest26 patches 47 repliesIn review

Changes in v10 from the cover letter

- Using cxl_memdev_state instead of cxl_dev_state for type2 which has a memory after all and facilitates the setup.
- Adapt core for using cxl_memdev_state allowing accel drivers to work with them without further awareness of internal cxl structs.
- Using last DPA changes for creating DPA partitions with accel driver hardcoding mds values when no mailbox.
- capabilities not a new field but built up when current register maps is performed and returned to the caller for checking.
- HPA free space supporting interleaving.
- DPA free space droping max-min for a simple alloc size.

Patches in v10 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/26cxl: make memdev creation type agnosticdrivers/cxl/core/mbox.c drivers/cxl/core/memdev.c drivers/cxl/cxlmem.h +4 more+85 -5810 replies
2/26sfc: add basic cxl initializationdrivers/net/ethernet/sfc/Kconfig drivers/net/ethernet/sfc/Makefile drivers/net/ethernet/sfc/efx.c +3 more+131 -16 replies
3/26cxl: move pci generic codedrivers/cxl/core/core.h drivers/cxl/core/pci.c drivers/cxl/core/regs.c +6 more+81 -934 replies
4/26cxl: move register/capability check to driverdrivers/cxl/core/pci.c drivers/cxl/core/port.c drivers/cxl/core/regs.c +4 more+78 -304 replies
5/26cxl: add function for type2 cxl regs setupdrivers/cxl/core/pci.c include/cxl/cxl.h+57 -02 replies
6/26sfc: use cxl api for regs setup and checkingdrivers/net/ethernet/sfc/efx_cxl.c+32 -02 replies
7/26cxl: add support for setting media ready by an accel driverdrivers/cxl/core/pci.c drivers/cxl/cxlmem.h drivers/cxl/pci.c +1 more+14 -32 replies
8/26sfc: set cxl media readydrivers/net/ethernet/sfc/efx_cxl.c+5 -00 replies
9/26cxl: support device identification without mailboxdrivers/cxl/core/memdev.c include/cxl/cxl.h+23 -04 replies
10/26cxl: modify dpa setup process for supporting type2drivers/cxl/core/hdm.c drivers/cxl/cxl.h drivers/cxl/cxlmem.h +2 more+24 -210 replies
11/26sfc: initialize dpa resourcesdrivers/net/ethernet/sfc/efx_cxl.c+16 -00 replies
12/26cxl: prepare memdev creation for type2drivers/cxl/core/memdev.c drivers/cxl/cxlmem.h drivers/cxl/pci.c +1 more+19 -70 replies
13/26sfc: create type2 cxl memdevdrivers/net/ethernet/sfc/efx_cxl.c+8 -00 replies
14/26cxl: define a driver interface for HPA free space enumerationdrivers/cxl/core/region.c drivers/cxl/cxl.h include/cxl/cxl.h+173 -04 replies
15/26sfc: obtain root decoder with enough HPA free spacedrivers/net/ethernet/sfc/Kconfig drivers/net/ethernet/sfc/efx_cxl.c+23 -13 replies
16/26cxl: define a driver interface for DPA allocationdrivers/cxl/core/hdm.c include/cxl/cxl.h+87 -04 replies
17/26sfc: get endpoint decoderdrivers/net/ethernet/sfc/efx_cxl.c+9 -00 replies
18/26cxl: make region type based on endpoint typedrivers/cxl/core/region.c+6 -40 replies
19/26cxl/region: factor out interleave ways setupdrivers/cxl/core/region.c+27 -190 replies
20/26cxl/region: factor out interleave granularity setupdrivers/cxl/core/region.c+23 -160 replies
21/26cxl: allow region creation by type2 driversdrivers/cxl/core/region.c drivers/cxl/cxlmem.h drivers/cxl/port.c +1 more+141 -151 reply
22/26cxl: add region flag for precluding a device memory to be used for daxdrivers/cxl/core/region.c drivers/cxl/cxl.h drivers/cxl/cxlmem.h +1 more+15 -40 replies
23/26sfc: create cxl regiondrivers/net/ethernet/sfc/efx_cxl.c+10 -00 replies
24/26cxl: add function for obtaining region rangedrivers/cxl/core/region.c drivers/cxl/cxl.h include/cxl/cxl.h+18 -00 replies
25/26sfc: update MCDI protocol headersdrivers/net/ethernet/sfc/mcdi_pcol.h+4861 -87840 replies
26/26sfc: support pio mapping based on cxldrivers/net/ethernet/sfc/ef10.c drivers/net/ethernet/sfc/efx_cxl.c drivers/net/ethernet/sfc/net_driver.h +1 more+67 -80 replies

Reviews trailers per patch

19 of 26 patches have a Reviewed-by or Acked-by.

PatchDave JiangBen CheathamFan NiJonathan CameronMartin HabetsZhi WangEdward Cree
1/26
2/26A-b
3/26R-b R-b R-b R-b
4/26R-b
5/26
6/26R-b R-b R-b A-b
7/26R-b R-b R-b
8/26R-b R-b A-b
9/26
10/26
11/26
12/26
13/26R-b R-b R-b A-b
14/26R-b
15/26R-b R-b A-b
16/26
17/26R-b R-b A-b
18/26R-b R-b R-b
19/26R-b R-b R-b
20/26R-b R-b R-b
21/26R-b R-b
22/26R-b R-b
23/26R-b R-b A-b
24/26R-b R-b
25/26R-b R-b
26/26A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 7 reviewers.

Read the v10 thread

Cover letter [PATCH v10 00/26] cxl: add type2 device basic support

From: Alejandro Lucero <[email protected]>

v10 changes:
- Using cxl_memdev_state instead of cxl_dev_state for type2 which has a memory after all and facilitates the setup.
- Adapt core for using cxl_memdev_state allowing accel drivers to work with them without further awareness of internal cxl structs.
- Using last DPA changes for creating DPA partitions with accel driver hardcoding mds values when no mailbox.
- capabilities not a new field but built up when current register maps is performed and returned to the caller for checking.
- HPA free space supporting interleaving.
- DPA free space droping max-min for a simple alloc size.

v9 changes:
- adding forward definitions (Jonathan Cameron)
- using set_bit instead of bitmap_set (Jonathan Cameron)
- fix rebase problem (Jonathan Cameron)
- Improve error path (Jonathan Cameron)
- fix build problems with cxl region dependency (robot)
- fix error path (Simon Horman)

v8 changes:
- Change error path labeling inside sfc cxl code (Edward Cree)
- Properly handling checks and error in sfc cxl code (Simon Horman)
- Fix bug when checking resource_size (Simon Horman)
- Avoid bisect problems reordering patches (Edward Cree)
- Fix buffer allocation size in sfc (Simon Horman)

v7 changes:

- fixing kernel test robot complains
- fix type with Type3 mandatory capabilities (Zhi Wang)
- optimize code in cxl_request_resource (Kalesh Anakkur Purayil)
- add sanity check when dealing with resources arithmetics (Fan Ni)
- fix typos and blank lines (Fan Ni)
- keep previous log errors/warnings in sfc driver (Martin Habets)
- add WARN_ON_ONCE if region given is NULL

v6 changes:

- update sfc mcdi_pcol.h with full hardware changes most not related to this patchset. This is an automatic file created from hardware design changes and not touched by software. It is updated from time to time and it required update for the sfc driver CXL support.
- remove CXL capabilities definitions not used by the patchset or previous kernel code. (Dave Jiang, Jonathan Cameron)
- Use bitmap_subset instead of reinventing the wheel ... (Ben Cheatham)
- Use cxl_accel_memdev for new device_type created (Ben Cheatham)
- Fix construct_region use of rwsem (Zhi Wang)
- Obtain region range instead of region params (Allison Schofield, Dave Jiang)

v5 changes:

- Fix SFC configuration based on kernel CXL configuration
- Add subset check for capabilities.
- fix region creation when HDM decoders programmed by firmware/BIOS (Ben Cheatham)
- Add option for creating dax region based on driver decission (Ben Cheatham)
- Using sfc probe_data struct for keeping sfc cxl data

v4 changes:

- Use bitmap for capabilities new field (Jonathan Cameron)

- Use cxl_mem attributes for sysfs based on device type (Dave Jian)

- Add conditional cxl sfc compilation relying on kernel CXL config (kernel test robot)

- Add sfc changes in different patches for facilitating backport (Jonathan Cameron)

- Remove patch for dealing with cxl modules dependencies and using sfc kconfig plus MODULE_SOFTDEP instead.

v3 changes:

- cxl_dev_state not defined as opaque but only manipulated by accel drivers through accessors.

- accessors names not identified as only for accel drivers.

- move pci code from pci driver (drivers/cxl/pci.c) to generic pci code (drivers/cxl/core/pci.c).

- capabilities field from u8 to u32 and initialised by CXL regs discovering code.

- add capabilities check and removing current check by CXL regs discovering code.

- Not fail if CXL Device Registers not found. Not mandatory for Type2.

- add timeout in acquire_endpoint for solving a race with the endpoint port creation.

- handle EPROBE_DEFER by sfc driver.

- Limiting interleave ways to 1 for accel driver HPA/DPA requests.

- factoring out interleave ways and granularity helpers from type2 region creation patch.

- restricting region_creation for type2 to one endpoint decoder.

- add accessor for release_resource.

- handle errors and errors messages properly.

v2 changes:

I have removed the introduction about the concerns with BIOS/UEFI after the discussion leading to confirm the need of the functionality implemented, at least is some scenarios.

There are two main changes from the RFC:

1) Following concerns about drivers using CXL core without restrictions, the CXL struct to work with is opaque to those drivers, therefore functions are implemented for modifying or reading those structs indirectly.

2) The driver for using the added functionality is not a test driver but a real
one: the SFC ethernet network driver. It uses the CXL region mapped for PIO buffers instead of regions inside PCIe BARs.

RFC:

Current CXL kernel code is focused on supporting Type3 CXL devices, aka memory expanders. Type2 CXL devices, aka device accelerators, share some functionalities but require some special handling.

First of all, Type2 are by definition specific to drivers doing something and not just a memory expander, so it is expected to work with the CXL specifics. This implies the CXL setup needs to be done by such a driver instead of by a generic CXL PCI driver as for memory expanders. Most of such setup needs to use current CXL core code and therefore needs to be accessible to those vendor drivers. This is accomplished exporting opaque CXL structs and adding and exporting functions for working with those structs indirectly.

Some of the patches are based on a patchset sent by Dan Williams [1] which was just partially integrated, most related to making things ready for Type2 but none related to specific Type2 support. Those patches based on Dan´s work have Dan´s signing as co-developer, and a link to the original patch.

A final note about CXL.cache is needed. This patchset does not cover it at all, although the emulated Type2 device advertises it. From the kernel point of view supporting CXL.cache will imply to be sure the CXL path supports what the Type2 device needs. A device accelerator will likely be connected to a Root Switch, but other configurations can not be discarded. Therefore the kernel will need to check not just HPA, DPA, interleave and granularity, but also the available CXL.cache support and resources in each switch in the CXL path to the Type2 device. I expect to contribute to this support in the following months, and it would be good to discuss about it when possible.

[1] https://lore.kernel.org/linux-cxl/[email protected]/T/

Alejandro Lucero (26):
cxl: make memdev creation type agnostic
sfc: add basic cxl initialization
cxl: move pci generic code
cxl: move register/capability check to driver
cxl: add function for type2 cxl regs setup
sfc: use cxl api for regs setup and checking
cxl: add support for setting media ready by an accel driver
sfc: set cxl media ready
cxl: support device identification without mailbox
cxl: modify dpa setup process for supporting type2
sfc: initialize dpa resources
cxl: prepare memdev creation for type2
sfc: create type2 cxl memdev
cxl: define a driver interface for HPA free space enumeration
sfc: obtain root decoder with enough HPA free space
cxl: define a driver interface for DPA allocation
sfc: get endpoint decoder
cxl: make region type based on endpoint type
cxl/region: factor out interleave ways setup
cxl/region: factor out interleave granularity setup
cxl: allow region creation by type2 drivers
cxl: add region flag for precluding a device memory to be used for dax
sfc: create cxl region
cxl: add function for obtaining region range
sfc: update MCDI protocol headers
sfc: support pio mapping based on cxl

 drivers/cxl/core/core.h               |     2 +
 drivers/cxl/core/hdm.c                |    87 +-
 drivers/cxl/core/mbox.c               |    20 -
 drivers/cxl/core/memdev.c             |    52 +-
 drivers/cxl/core/pci.c                |   127 +-
 drivers/cxl/core/port.c               |     8 +-
 drivers/cxl/core/region.c             |   424 +-
 drivers/cxl/core/regs.c               |    37 +-
 drivers/cxl/cxl.h                     |    21 +-
 drivers/cxl/cxlmem.h                  |    38 +-
 drivers/cxl/cxlpci.h                  |    19 +-
 drivers/cxl/pci.c                     |   123 +-
 drivers/cxl/port.c                    |     5 +-
 drivers/net/ethernet/sfc/Kconfig      |     6 +
 drivers/net/ethernet/sfc/Makefile     |     1 +
 drivers/net/ethernet/sfc/ef10.c       |    50 +-
 drivers/net/ethernet/sfc/efx.c        |    16 +-
 drivers/net/ethernet/sfc/efx_cxl.c    |   179 +
 drivers/net/ethernet/sfc/efx_cxl.h    |    40 +
 drivers/net/ethernet/sfc/mcdi_pcol.h  | 13645 +++++++++---------------
 drivers/net/ethernet/sfc/net_driver.h |    12 +
 drivers/net/ethernet/sfc/nic.h        |     3 +
 include/cxl/cxl.h                     |   104 +
 include/cxl/pci.h                     |    36 +
 tools/testing/cxl/Kbuild              |     1 -
 tools/testing/cxl/test/mock.c         |    17 -
 26 files changed, 6021 insertions(+), 9052 deletions(-)
 create mode 100644 drivers/net/ethernet/sfc/efx_cxl.c
 create mode 100644 drivers/net/ethernet/sfc/efx_cxl.h
 create mode 100644 include/cxl/cxl.h
 create mode 100644 include/cxl/pci.h

base-commit: 6cd498f39cf5e1475b567eb67a6fcf1ca3d67d46

Signature · 1 line
2.17.1