Skip to content

Commit

Permalink
drm: Mark PCI AGP helpers as legacy
Browse files Browse the repository at this point in the history
DRM's AGP helpers for PCI are only required by legacy drivers. Put them
behind CONFIG_DRM_LEGACY and add the _legacy_ infix.

Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210507185709.22797-4-tzimmermann@suse.de
  • Loading branch information
Thomas Zimmermann committed May 10, 2021
1 parent 4335978 commit 6bff227
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
4 changes: 1 addition & 3 deletions drivers/gpu/drm/drm_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -941,9 +941,7 @@ void drm_dev_unregister(struct drm_device *dev)
if (dev->driver->unload)
dev->driver->unload(dev);

if (dev->agp)
drm_pci_agp_destroy(dev);

drm_legacy_pci_agp_destroy(dev);
drm_legacy_rmmaps(dev);

remove_compat_control_link(dev);
Expand Down
5 changes: 0 additions & 5 deletions drivers/gpu/drm/drm_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ void drm_lastclose(struct drm_device *dev);
/* drm_pci.c */
int drm_legacy_irq_by_busid(struct drm_device *dev, void *data,
struct drm_file *file_priv);
void drm_pci_agp_destroy(struct drm_device *dev);
int drm_pci_set_busid(struct drm_device *dev, struct drm_master *master);

#else
Expand All @@ -67,10 +66,6 @@ static inline int drm_legacy_irq_by_busid(struct drm_device *dev, void *data,
return -EINVAL;
}

static inline void drm_pci_agp_destroy(struct drm_device *dev)
{
}

static inline int drm_pci_set_busid(struct drm_device *dev,
struct drm_master *master)
{
Expand Down
6 changes: 6 additions & 0 deletions drivers/gpu/drm/drm_legacy.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,4 +211,10 @@ void drm_master_legacy_init(struct drm_master *master);
static inline void drm_master_legacy_init(struct drm_master *master) {}
#endif

#if IS_ENABLED(CONFIG_DRM_LEGACY) && IS_ENABLED(CONFIG_PCI)
void drm_legacy_pci_agp_destroy(struct drm_device *dev);
#else
static inline void drm_legacy_pci_agp_destroy(struct drm_device *dev) {}
#endif

#endif /* __DRM_LEGACY_H__ */
20 changes: 10 additions & 10 deletions drivers/gpu/drm/drm_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,9 @@ int drm_legacy_irq_by_busid(struct drm_device *dev, void *data,
return drm_pci_irq_by_busid(dev, p);
}

void drm_pci_agp_destroy(struct drm_device *dev)
#ifdef CONFIG_DRM_LEGACY

void drm_legacy_pci_agp_destroy(struct drm_device *dev)
{
if (dev->agp) {
arch_phys_wc_del(dev->agp->agp_mtrr);
Expand All @@ -129,9 +131,7 @@ void drm_pci_agp_destroy(struct drm_device *dev)
}
}

#ifdef CONFIG_DRM_LEGACY

static void drm_pci_agp_init(struct drm_device *dev)
static void drm_legacy_pci_agp_init(struct drm_device *dev)
{
if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
if (pci_find_capability(to_pci_dev(dev->dev), PCI_CAP_ID_AGP))
Expand All @@ -145,9 +145,9 @@ static void drm_pci_agp_init(struct drm_device *dev)
}
}

static int drm_get_pci_dev(struct pci_dev *pdev,
const struct pci_device_id *ent,
const struct drm_driver *driver)
static int drm_legacy_get_pci_dev(struct pci_dev *pdev,
const struct pci_device_id *ent,
const struct drm_driver *driver)
{
struct drm_device *dev;
int ret;
Expand All @@ -169,7 +169,7 @@ static int drm_get_pci_dev(struct pci_dev *pdev,
if (drm_core_check_feature(dev, DRIVER_MODESET))
pci_set_drvdata(pdev, dev);

drm_pci_agp_init(dev);
drm_legacy_pci_agp_init(dev);

ret = drm_dev_register(dev, ent->driver_data);
if (ret)
Expand All @@ -184,7 +184,7 @@ static int drm_get_pci_dev(struct pci_dev *pdev,
return 0;

err_agp:
drm_pci_agp_destroy(dev);
drm_legacy_pci_agp_destroy(dev);
pci_disable_device(pdev);
err_free:
drm_dev_put(dev);
Expand Down Expand Up @@ -231,7 +231,7 @@ int drm_legacy_pci_init(const struct drm_driver *driver,

/* stealth mode requires a manual probe */
pci_dev_get(pdev);
drm_get_pci_dev(pdev, pid, driver);
drm_legacy_get_pci_dev(pdev, pid, driver);
}
}
return 0;
Expand Down

0 comments on commit 6bff227

Please sign in to comment.