Commit 575e6986 authored by Daniel Axtens's avatar Daniel Axtens Committed by Michael Ellerman

cxl: Clean up adapter MMIO unmap path.

- MMIO pointer unmapping is guarded by a null pointer check.
   However, iounmap doesn't null the pointer, just invalidate it.
   Therefore, explicitly null the pointer after unmapping.

 - afu_desc_mmio also needs to be unmapped.

 - PCI regions are allocated in cxl_map_adapter_regs.
   Therefore they should be released in unmap, not elsewhere.
Acked-by: default avatarCyril Bur <cyrilbur@gmail.com>
Signed-off-by: default avatarDaniel Axtens <dja@axtens.net>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent e640d2fc
......@@ -539,10 +539,18 @@ static int cxl_map_slice_regs(struct cxl_afu *afu, struct cxl *adapter, struct p
static void cxl_unmap_slice_regs(struct cxl_afu *afu)
{
if (afu->p2n_mmio)
if (afu->p2n_mmio) {
iounmap(afu->p2n_mmio);
if (afu->p1n_mmio)
afu->p2n_mmio = NULL;
}
if (afu->p1n_mmio) {
iounmap(afu->p1n_mmio);
afu->p1n_mmio = NULL;
}
if (afu->afu_desc_mmio) {
iounmap(afu->afu_desc_mmio);
afu->afu_desc_mmio = NULL;
}
}
static void cxl_release_afu(struct device *dev)
......@@ -920,10 +928,16 @@ static int cxl_map_adapter_regs(struct cxl *adapter, struct pci_dev *dev)
static void cxl_unmap_adapter_regs(struct cxl *adapter)
{
if (adapter->p1_mmio)
if (adapter->p1_mmio) {
iounmap(adapter->p1_mmio);
if (adapter->p2_mmio)
adapter->p1_mmio = NULL;
pci_release_region(to_pci_dev(adapter->dev.parent), 2);
}
if (adapter->p2_mmio) {
iounmap(adapter->p2_mmio);
adapter->p2_mmio = NULL;
pci_release_region(to_pci_dev(adapter->dev.parent), 0);
}
}
static int cxl_read_vsec(struct cxl *adapter, struct pci_dev *dev)
......@@ -1132,8 +1146,6 @@ static void cxl_remove_adapter(struct cxl *adapter)
device_unregister(&adapter->dev);
pci_release_region(pdev, 0);
pci_release_region(pdev, 2);
pci_disable_device(pdev);
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment