[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20251222135400.000041d6@huawei.com>
Date: Mon, 22 Dec 2025 13:54:00 +0000
From: Jonathan Cameron <jonathan.cameron@...wei.com>
To: <mhonap@...dia.com>
CC: <aniketa@...dia.com>, <ankita@...dia.com>, <alwilliamson@...dia.com>,
<vsethi@...dia.com>, <jgg@...dia.com>, <mochs@...dia.com>,
<skolothumtho@...dia.com>, <alejandro.lucero-palau@....com>,
<dave@...olabs.net>, <dave.jiang@...el.com>, <alison.schofield@...el.com>,
<vishal.l.verma@...el.com>, <ira.weiny@...el.com>,
<dan.j.williams@...el.com>, <jgg@...pe.ca>, <yishaih@...dia.com>,
<kevin.tian@...el.com>, <cjia@...dia.com>, <kwankhede@...dia.com>,
<targupta@...dia.com>, <zhiw@...dia.com>, <kjaju@...dia.com>,
<linux-kernel@...r.kernel.org>, <linux-cxl@...r.kernel.org>,
<kvm@...r.kernel.org>
Subject: Re: [RFC v2 06/15] vfio/cxl: introduce vfio-cxl core preludes
On Tue, 9 Dec 2025 22:20:10 +0530
mhonap@...dia.com wrote:
> From: Manish Honap <mhonap@...dia.com>
>
> In VFIO, common functions that used by VFIO variant drivers are managed
> in a set of "core" functions. E.g. the vfio-pci-core provides the common
> functions used by VFIO variant drviers to support PCI device
> passhthrough.
>
> Although the CXL type-2 device has a PCI-compatible interface for device
> configuration and programming, they still needs special handlings when
> initialize the device:
>
> - Probing the CXL DVSECs in the configuration.
> - Probing the CXL register groups implemented by the device.
> - Configuring the CXL device state required by the kernel CXL core.
> - Create the CXL region.
> - Special handlings of the CXL MMIO BAR.
>
> Introduce vfio-cxl core preludes to hold all the common functions used
> by VFIO variant drivers to support CXL device passthrough.
>
> Co-developed-by: Zhi Wang <zhiw@...dia.com>
> Signed-off-by: Zhi Wang <zhiw@...dia.com>
> Signed-off-by: Manish Honap <mhonap@...dia.com>
One trivial thing from a first look.
> diff --git a/drivers/vfio/pci/vfio_cxl_core.c b/drivers/vfio/pci/vfio_cxl_core.c
> new file mode 100644
> index 000000000000..cf53720c0cb7
> --- /dev/null
> +++ b/drivers/vfio/pci/vfio_cxl_core.c
> @@ -0,0 +1,238 @@
> +
> +int vfio_cxl_core_create_cxl_region(struct vfio_cxl_core_device *cxl, u64 size)
> +{
> + struct cxl_region *region;
> + struct range range;
> + int ret;
> + struct vfio_cxl *cxl_core = cxl->cxl_core;
> +
> + if (WARN_ON(cxl_core->region.region))
> + return -EEXIST;
> +
> + ret = get_hpa_and_request_dpa(cxl, size);
> + if (ret)
> + return ret;
> +
> + region = cxl_create_region(cxl_core->cxlrd, &cxl_core->cxled, true);
> + if (IS_ERR(region)) {
> + ret = PTR_ERR(region);
> + cxl_dpa_free(cxl_core->cxled);
> + return ret;
Trivial but might as well do:
return PTR_ERR(region);
and save a line.
> + }
> +
> + cxl_get_region_range(region, &range);
> +
> + cxl_core->region.addr = range.start;
> + cxl_core->region.size = size;
> + cxl_core->region.region = region;
> + return 0;
> +}
> +EXPORT_SYMBOL_GPL(vfio_cxl_core_create_cxl_region);
Powered by blists - more mailing lists