Skip to content

Commit

Permalink
vgaarb: provide a vga_client_unregister wrapper
Browse files Browse the repository at this point in the history
Add a trivial wrapper for the unregister case that sets all fields to
NULL.

Signed-off-by: Christoph Hellwig <hch@lst.de>
Link: https://patchwork.freedesktop.org/patch/msgid/20210716061634.2446357-6-hch@lst.de
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
  • Loading branch information
Christoph Hellwig authored and Christian König committed Jul 21, 2021
1 parent 6609176 commit b877947
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 9 deletions.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -3802,7 +3802,7 @@ void amdgpu_device_fini_sw(struct amdgpu_device *adev)
vga_switcheroo_fini_domain_pm_ops(adev->dev);
}
if ((adev->pdev->class >> 8) == PCI_CLASS_DISPLAY_VGA)
vga_client_register(adev->pdev, NULL, NULL, NULL);
vga_client_unregister(adev->pdev);

if (IS_ENABLED(CONFIG_PERF_EVENTS))
amdgpu_pmu_fini(adev);
Expand Down
4 changes: 2 additions & 2 deletions drivers/gpu/drm/drm_irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ int drm_irq_install(struct drm_device *dev, int irq)
if (ret < 0) {
dev->irq_enabled = false;
if (drm_core_check_feature(dev, DRIVER_LEGACY))
vga_client_register(to_pci_dev(dev->dev), NULL, NULL, NULL);
vga_client_unregister(to_pci_dev(dev->dev));
free_irq(irq, dev);
} else {
dev->irq = irq;
Expand Down Expand Up @@ -198,7 +198,7 @@ int drm_irq_uninstall(struct drm_device *dev)
DRM_DEBUG("irq=%d\n", dev->irq);

if (drm_core_check_feature(dev, DRIVER_LEGACY))
vga_client_register(to_pci_dev(dev->dev), NULL, NULL, NULL);
vga_client_unregister(to_pci_dev(dev->dev));

if (dev->driver->irq_uninstall)
dev->driver->irq_uninstall(dev);
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/i915/display/intel_vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,5 +158,5 @@ void intel_vga_unregister(struct drm_i915_private *i915)
{
struct pci_dev *pdev = to_pci_dev(i915->drm.dev);

vga_client_register(pdev, NULL, NULL, NULL);
vga_client_unregister(pdev);
}
2 changes: 1 addition & 1 deletion drivers/gpu/drm/nouveau/nouveau_vga.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ nouveau_vga_fini(struct nouveau_drm *drm)
return;
pdev = to_pci_dev(dev->dev);

vga_client_register(pdev, NULL, NULL, NULL);
vga_client_unregister(pdev);

if (pci_is_thunderbolt_attached(pdev))
return;
Expand Down
2 changes: 1 addition & 1 deletion drivers/gpu/drm/radeon/radeon_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -1530,7 +1530,7 @@ void radeon_device_fini(struct radeon_device *rdev)
vga_switcheroo_unregister_client(rdev->pdev);
if (rdev->flags & RADEON_IS_PX)
vga_switcheroo_fini_domain_pm_ops(rdev->dev);
vga_client_register(rdev->pdev, NULL, NULL, NULL);
vga_client_unregister(rdev->pdev);
if (rdev->rio_mem)
pci_iounmap(rdev->pdev, rdev->rio_mem);
rdev->rio_mem = NULL;
Expand Down
3 changes: 1 addition & 2 deletions drivers/gpu/vga/vgaarb.c
Original file line number Diff line number Diff line change
Expand Up @@ -877,8 +877,7 @@ EXPORT_SYMBOL(vga_set_legacy_decoding);
* This function does not check whether a client for @pdev has been registered
* already.
*
* To unregister just call this function with @irq_set_state and @set_vga_decode
* both set to NULL for the same @pdev as originally used to register them.
* To unregister just call vga_client_unregister().
*
* Returns: 0 on success, -1 on failure
*/
Expand Down
2 changes: 1 addition & 1 deletion drivers/vfio/pci/vfio_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -1964,7 +1964,7 @@ static void vfio_pci_vga_uninit(struct vfio_pci_device *vdev)

if (!vfio_pci_is_vga(pdev))
return;
vga_client_register(pdev, NULL, NULL, NULL);
vga_client_unregister(pdev);
vga_set_legacy_decoding(pdev, VGA_RSRC_NORMAL_IO | VGA_RSRC_NORMAL_MEM |
VGA_RSRC_LEGACY_IO |
VGA_RSRC_LEGACY_MEM);
Expand Down
5 changes: 5 additions & 0 deletions include/linux/vgaarb.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,9 @@ static inline int vga_get_uninterruptible(struct pci_dev *pdev,
return vga_get(pdev, rsrc, 0);
}

static inline void vga_client_unregister(struct pci_dev *pdev)
{
vga_client_register(pdev, NULL, NULL, NULL);
}

#endif /* LINUX_VGA_H */

0 comments on commit b877947

Please sign in to comment.