Skip to content

Commit eec8127

Browse files
Philipp Stannermstsirkin
authored andcommitted
vdpa/octeon_ep: Control PCI dev enabling manually
PCI region request functions such as pci_request_region() currently have the problem of becoming sometimes managed functions, if pcim_enable_device() instead of pci_enable_device() was called. The PCI subsystem wants to remove this deprecated behavior from its interfaces. octeopn_ep enables its device with pcim_enable_device() (for VF. PF uses manual management), but does so only to get automatic disablement. The driver wants to manage its PCI resources for VF manually, without devres. The easiest way not to use automatic resource management at all is by also handling device enable- and disablement manually. Replace pcim_enable_device() with pci_enable_device(). Add the necessary calls to pci_disable_device(). Signed-off-by: Philipp Stanner <phasta@kernel.org> Acked-by: Vamsi Attunuru <vattunuru@marvell.com> Message-Id: <20250508085134.24084-2-phasta@kernel.org> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Tested-by: Lei Yang <leiyang@redhat.com> Signed-off-by: Philipp Stanner &lt;<a href="mailto:phasta@kernel.org" target="_blank">phasta@kernel.org</a>&gt;<br> Acked-by: Vamsi Attunuru &lt;<a href="mailto:vattunuru@marvell.com" target="_blank">vattunuru@marvell.com</a>&gt;<br>
1 parent ac9dcca commit eec8127

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

drivers/vdpa/octeon_ep/octep_vdpa_main.c

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -454,6 +454,9 @@ static void octep_vdpa_remove_pf(struct pci_dev *pdev)
454454
octep_iounmap_region(pdev, octpf->base, OCTEP_HW_MBOX_BAR);
455455

456456
octep_vdpa_pf_bar_expand(octpf);
457+
458+
/* The pf version does not use managed PCI. */
459+
pci_disable_device(pdev);
457460
}
458461

459462
static void octep_vdpa_vf_bar_shrink(struct pci_dev *pdev)
@@ -825,7 +828,7 @@ static int octep_vdpa_probe_pf(struct pci_dev *pdev)
825828
struct octep_pf *octpf;
826829
int ret;
827830

828-
ret = pcim_enable_device(pdev);
831+
ret = pci_enable_device(pdev);
829832
if (ret) {
830833
dev_err(dev, "Failed to enable device\n");
831834
return ret;
@@ -834,15 +837,17 @@ static int octep_vdpa_probe_pf(struct pci_dev *pdev)
834837
ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64));
835838
if (ret) {
836839
dev_err(dev, "No usable DMA configuration\n");
837-
return ret;
840+
goto disable_pci;
838841
}
839842
octpf = devm_kzalloc(dev, sizeof(*octpf), GFP_KERNEL);
840-
if (!octpf)
841-
return -ENOMEM;
843+
if (!octpf) {
844+
ret = -ENOMEM;
845+
goto disable_pci;
846+
}
842847

843848
ret = octep_iomap_region(pdev, octpf->base, OCTEP_HW_MBOX_BAR);
844849
if (ret)
845-
return ret;
850+
goto disable_pci;
846851

847852
pci_set_master(pdev);
848853
pci_set_drvdata(pdev, octpf);
@@ -856,6 +861,8 @@ static int octep_vdpa_probe_pf(struct pci_dev *pdev)
856861

857862
unmap_region:
858863
octep_iounmap_region(pdev, octpf->base, OCTEP_HW_MBOX_BAR);
864+
disable_pci:
865+
pci_disable_device(pdev);
859866
return ret;
860867
}
861868

0 commit comments

Comments
 (0)