Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Philipp Stanner and committed by
Michael S. Tsirkin
eec81277 ac9dcca2

+12 -5
+12 -5
drivers/vdpa/octeon_ep/octep_vdpa_main.c
··· 454 454 octep_iounmap_region(pdev, octpf->base, OCTEP_HW_MBOX_BAR); 455 455 456 456 octep_vdpa_pf_bar_expand(octpf); 457 + 458 + /* The pf version does not use managed PCI. */ 459 + pci_disable_device(pdev); 457 460 } 458 461 459 462 static void octep_vdpa_vf_bar_shrink(struct pci_dev *pdev) ··· 828 825 struct octep_pf *octpf; 829 826 int ret; 830 827 831 - ret = pcim_enable_device(pdev); 828 + ret = pci_enable_device(pdev); 832 829 if (ret) { 833 830 dev_err(dev, "Failed to enable device\n"); 834 831 return ret; ··· 837 834 ret = dma_set_mask_and_coherent(dev, DMA_BIT_MASK(64)); 838 835 if (ret) { 839 836 dev_err(dev, "No usable DMA configuration\n"); 840 - return ret; 837 + goto disable_pci; 841 838 } 842 839 octpf = devm_kzalloc(dev, sizeof(*octpf), GFP_KERNEL); 843 - if (!octpf) 844 - return -ENOMEM; 840 + if (!octpf) { 841 + ret = -ENOMEM; 842 + goto disable_pci; 843 + } 845 844 846 845 ret = octep_iomap_region(pdev, octpf->base, OCTEP_HW_MBOX_BAR); 847 846 if (ret) 848 - return ret; 847 + goto disable_pci; 849 848 850 849 pci_set_master(pdev); 851 850 pci_set_drvdata(pdev, octpf); ··· 861 856 862 857 unmap_region: 863 858 octep_iounmap_region(pdev, octpf->base, OCTEP_HW_MBOX_BAR); 859 + disable_pci: 860 + pci_disable_device(pdev); 864 861 return ret; 865 862 } 866 863