Re: [PATCH v4 02/27] cxl/regs: Skip sub-block region request for BAR-owning drivers
Alex Williamson <[email protected]>
| Newsgroups | org.kernel.vger.kvm,org.kernel.vger.linux-cxl,org.kernel.vger.linux-doc,org.kernel.vger.linux-hardening,org.kernel.vger.linux-kernel,org.kernel.vger.linux-kselftest,org.kernel.vger.linux-pci |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 13 Aug 2026 15:06:06 +0530 <[email protected]> wrote: > From: Manish Honap <[email protected]> > > 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