mirror of
https://github.com/linux-msm/laptops-kernel.git
synced 2026-08-13 14:19:53 -07:00
PCI: Add managed partial-BAR request and map infrastructure
The pcim_iomap_devres table tracks entire-BAR mappings, so we can't use it to build a managed version of pci_iomap_range(), which maps partial BARs. Add struct pcim_addr_devres, which can track request and mapping of both entire BARs and partial BARs. Add the following internal devres functions based on struct pcim_addr_devres: pcim_iomap_region() # request & map entire BAR pcim_iounmap_region() # unmap & release entire BAR pcim_request_region() # request entire BAR pcim_release_region() # release entire BAR pcim_request_all_regions() # request all entire BARs pcim_release_all_regions() # release all entire BARs Rework the following public interfaces using the new infrastructure listed above: pcim_iomap() # map partial BAR pcim_iounmap() # unmap partial BAR pcim_iomap_regions() # request & map specified BARs pcim_iomap_regions_request_all() # request all BARs, map specified BARs pcim_iounmap_regions() # unmap & release specified BARs Link: https://lore.kernel.org/r/20240613115032.29098-4-pstanner@redhat.com Signed-off-by: Philipp Stanner <pstanner@redhat.com> Signed-off-by: Krzysztof Wilczyński <kwilczynski@kernel.org> [bhelgaas: commit log] Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
+544
-67
File diff suppressed because it is too large
Load Diff
@@ -3883,6 +3883,17 @@ void pci_release_region(struct pci_dev *pdev, int bar)
|
||||
release_mem_region(pci_resource_start(pdev, bar),
|
||||
pci_resource_len(pdev, bar));
|
||||
|
||||
/*
|
||||
* This devres utility makes this function sometimes managed
|
||||
* (when pcim_enable_device() has been called before).
|
||||
*
|
||||
* This is bad because it conflicts with the pcim_ functions being
|
||||
* exclusively responsible for managed PCI. Its "sometimes yes,
|
||||
* sometimes no" nature can cause bugs.
|
||||
*
|
||||
* TODO: Remove this once all users that use pcim_enable_device() PLUS
|
||||
* a region request function have been ported to using pcim_ functions.
|
||||
*/
|
||||
dr = find_pci_dr(pdev);
|
||||
if (dr)
|
||||
dr->region_mask &= ~(1 << bar);
|
||||
@@ -3927,6 +3938,17 @@ static int __pci_request_region(struct pci_dev *pdev, int bar,
|
||||
goto err_out;
|
||||
}
|
||||
|
||||
/*
|
||||
* This devres utility makes this function sometimes managed
|
||||
* (when pcim_enable_device() has been called before).
|
||||
*
|
||||
* This is bad because it conflicts with the pcim_ functions being
|
||||
* exclusively responsible for managed pci. Its "sometimes yes,
|
||||
* sometimes no" nature can cause bugs.
|
||||
*
|
||||
* TODO: Remove this once all users that use pcim_enable_device() PLUS
|
||||
* a region request function have been ported to using pcim_ functions.
|
||||
*/
|
||||
dr = find_pci_dr(pdev);
|
||||
if (dr)
|
||||
dr->region_mask |= 1 << bar;
|
||||
|
||||
@@ -826,6 +826,11 @@ struct pci_devres {
|
||||
unsigned int orig_intx:1;
|
||||
unsigned int restore_intx:1;
|
||||
unsigned int mwi:1;
|
||||
|
||||
/*
|
||||
* TODO: remove the region_mask once everyone calling
|
||||
* pcim_enable_device() + pci_*region*() is ported to pcim_ functions.
|
||||
*/
|
||||
u32 region_mask;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user