RE: [PATCH v4 02/27] cxl/regs: Skip sub-block region request for BAR-owning drivers
From: Manish Honap
Date: Thu Sep 03 2026 - 08:20:09 EST
> -----Original Message-----
> From: Alex Williamson <alex@xxxxxxxxxxx>
> Sent: Wednesday, August 26, 2026 2:56 AM
> To: Manish Honap <mhonap@xxxxxxxxxx>
> Cc: jgg@xxxxxxxx; Ankit Agrawal <ankita@xxxxxxxxxx>; jic23@xxxxxxxxxx;
> dave.jiang@xxxxxxxxx; alejandro.lucero-palau@xxxxxxx; Srirangan Madhavan
> <smadhavan@xxxxxxxxxx>; corbet@xxxxxxx; skhan@xxxxxxxxxxxxxxxxxxx;
> dave@xxxxxxxxxxxx; alison.schofield@xxxxxxxxx; vishal.l.verma@xxxxxxxxx;
> iweiny@xxxxxxxxxx; ming.li@xxxxxxxxxxxx; Yishai Hadas
> <yishaih@xxxxxxxxxx>; Shameer Kolothum Thodi
> <skolothumtho@xxxxxxxxxx>; kevin.tian@xxxxxxxxx; bhelgaas@xxxxxxxxxx;
> dmatlack@xxxxxxxxxx; kees@xxxxxxxxxx; gustavoars@xxxxxxxxxx; Neo Jia
> <cjia@xxxxxxxxxx>; Krishnakant Jaju <kjaju@xxxxxxxxxx>; Vikram Sethi
> <vsethi@xxxxxxxxxx>; Zhi Wang <zhiw@xxxxxxxxxx>; linux-
> doc@xxxxxxxxxxxxxxx; linux-kernel@xxxxxxxxxxxxxxx; kvm@xxxxxxxxxxxxxxx;
> linux-cxl@xxxxxxxxxxxxxxx; linux-pci@xxxxxxxxxxxxxxx; linux-
> kselftest@xxxxxxxxxxxxxxx; linux-hardening@xxxxxxxxxxxxxxx; alex@xxxxxxxxxxx
> Subject: Re: [PATCH v4 02/27] cxl/regs: Skip sub-block region request for BAR-
> owning drivers
>
> External email: Use caution opening links or attachments
>
>
> On Thu, 13 Aug 2026 15:06:06 +0530
> <mhonap@xxxxxxxxxx> wrote:
>
> > From: Manish Honap <mhonap@xxxxxxxxxx>
> >
> > cxl_map_component_regs() claims each mapped sub-block with
> > devm_request_mem_region(). A driver that owns the whole component
> > register BAR, such as vfio-cxl, has already claimed the full BAR, so
> > the per-sub-block claim collides and the mapping fails.
> >
> > Add a bar_owned parameter to cxl_pci_setup_regs() and record it in
> > skip_sub_bar_request on the register map. When set, cxl-core maps the
> > sub-block without requesting the region and leaves ownership with the
> > upper driver. cxl_pci passes false and keeps its existing claim,
> > preserving /dev/mem tooling access to the rest of the component space.
>
> The bool arg itself is an undesirable shape, but then threading it through
> @bar_owned to @skip_sub_bar_request to @request is difficult to follow with
> limited utility.
>
> What if instead cxl allowed drivers to register the resources they've already
> requested into the reg_map, ex:
>
> int cxl_reg_map_add_owned_resource(struct cxl_register_map *reg_map,
> struct resource *res)
>
> Then before cxl does any devm_request_mem_region() calls it creates a
> temporary struct resource for the range it wants to request and compares it to
> the resources the driver already reported as owned via resource_contains()?
>
> I'm picking reg_map vs cxlds because it seems easier to thread through to
> where we need it. In this flow, devm_cxl_iomap_block() could be split into
> devm_cxl_request_block() and devm_cxl_ioremap_block(), where
> cxl_map_component_regs() would conditionally call the former when
> resource_contains() finds no matches for driver owned resources, and the
> latter is called unconditionally. devm_cxl_iomap_block() could remain as the
> unconditional user of both. Thanks,
>
> Alex
Thanks, agreed on both counts; I will switch to the registered-resource
cxl_reg_map_add_owned_resource approach you described.
Manish