Re: [RESEND v13 17/25] cxl: Introduce cxl_pci_drv_bound() to check for bound driver

dan.j.williams
2025-11-20T01:24:26Z

Terry Bowman wrote:
> CXL devices handle protocol errors via driver-specific callbacks rather
> than the generic pci_driver::err_handlers by default. The callbacks are
> implemented in the cxl_pci driver and are not part of struct pci_driver, so
> cxl_core must verify that a device is actually bound to the cxl_pci
> module's driver before invoking the callbacks (the device could be bound
> to another driver, e.g. VFIO).
>
> However, cxl_core can not reference symbols in the cxl_pci module because
> it creates a circular dependency. This prevents cxl_core from checking the
> EP's bound driver and calling the callbacks.
>
> To fix this, move drivers/cxl/pci.c into drivers/cxl/core/pci_drv.c and
> build it as part of the cxl_core module. Compile into cxl_core using
> CXL_PCI and CXL_CORE Kconfig dependencies. This removes the standalone
> cxl_pci module, consolidates the cxl_pci driver code into cxl_core, and
> eliminates the circular dependency so cxl_core can safely perform
> bound-driver checks and invoke the CXL PCI callbacks.
>
> Introduce cxl_pci_drv_bound() to return boolean depending on if the PCI EP
> parameter is bound to a CXL driver instance. This will be used in future
> patch when dequeuing work from the kfifo.

I am thoroughly confused about what this patch is trying to do. The
whole point of a cxl_core is to separate the potential shared mechanics
across CXL device types from the specific special case of the CXL memory
class device.

This would be like saying that all PCI drivers need to be built-into the
PCI core to satisfy PCI error handling.

If the core needs to verify the driver before calling the handler then
the design is broken.

The design should accommodate a case of *only* a CXL accelerator driver
loading and not a CXL memory expander driver. Let me go take a look at
how cxl_pci_drv_bound() is used. There must be a simple misunderstanding
that we can resolve quickly.