Skip to content

Commit d990675

Browse files
danvetairlied
authored andcommitted
drm: rip out drm_core_has_AGP
Most place actually want to just check for dev->agp (most do, but a few don't so this fixes a few potential NULL derefs). The only exception is the agp init code which should check for the AGP driver feature flag. Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 8da79cc commit d990675

7 files changed

Lines changed: 11 additions & 26 deletions

File tree

‎drivers/gpu/drm/drm_agpsupport.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -439,7 +439,7 @@ void drm_agp_clear(struct drm_device *dev)
439439
{
440440
struct drm_agp_mem *entry, *tempe;
441441

442-
if (!drm_core_has_AGP(dev) || !dev->agp)
442+
if (!dev->agp)
443443
return;
444444
if (drm_core_check_feature(dev, DRIVER_MODESET))
445445
return;

‎drivers/gpu/drm/drm_bufs.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
261261
struct drm_agp_mem *entry;
262262
int valid = 0;
263263

264-
if (!drm_core_has_AGP(dev)) {
264+
if (!dev->agp) {
265265
kfree(map);
266266
return -EINVAL;
267267
}
@@ -1390,7 +1390,7 @@ int drm_mapbufs(struct drm_device *dev, void *data,
13901390
spin_unlock(&dev->count_lock);
13911391

13921392
if (request->count >= dma->buf_count) {
1393-
if ((drm_core_has_AGP(dev) && (dma->flags & _DRM_DMA_USE_AGP))
1393+
if ((dev->agp && (dma->flags & _DRM_DMA_USE_AGP))
13941394
|| (drm_core_check_feature(dev, DRIVER_SG)
13951395
&& (dma->flags & _DRM_DMA_USE_SG))) {
13961396
struct drm_local_map *map = dev->agp_buffer_map;

‎drivers/gpu/drm/drm_memory.c‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ static inline void *agp_remap(unsigned long offset, unsigned long size,
110110

111111
void drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
112112
{
113-
if (drm_core_has_AGP(dev) &&
114-
dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
113+
if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
115114
map->handle = agp_remap(map->offset, map->size, dev);
116115
else
117116
map->handle = ioremap(map->offset, map->size);
@@ -120,8 +119,7 @@ EXPORT_SYMBOL(drm_core_ioremap);
120119

121120
void drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev)
122121
{
123-
if (drm_core_has_AGP(dev) &&
124-
dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
122+
if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
125123
map->handle = agp_remap(map->offset, map->size, dev);
126124
else
127125
map->handle = ioremap_wc(map->offset, map->size);
@@ -133,8 +131,7 @@ void drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
133131
if (!map->handle || !map->size)
134132
return;
135133

136-
if (drm_core_has_AGP(dev) &&
137-
dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
134+
if (dev->agp && dev->agp->cant_use_aperture && map->type == _DRM_AGP)
138135
vunmap(map->handle);
139136
else
140137
iounmap(map->handle);

‎drivers/gpu/drm/drm_pci.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,7 @@ static int drm_pci_irq_by_busid(struct drm_device *dev, struct drm_irq_busid *p)
264264

265265
static void drm_pci_agp_init(struct drm_device *dev)
266266
{
267-
if (drm_core_has_AGP(dev)) {
267+
if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
268268
if (drm_pci_device_is_agp(dev))
269269
dev->agp = drm_agp_init(dev);
270270
if (dev->agp) {
@@ -278,7 +278,7 @@ static void drm_pci_agp_init(struct drm_device *dev)
278278

279279
static void drm_pci_agp_destroy(struct drm_device *dev)
280280
{
281-
if (drm_core_has_AGP(dev) && dev->agp) {
281+
if (dev->agp) {
282282
arch_phys_wc_del(dev->agp->agp_mtrr);
283283
drm_agp_clear(dev);
284284
drm_agp_destroy(dev->agp);

‎drivers/gpu/drm/drm_vm.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static int drm_do_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)
101101
/*
102102
* Find the right map
103103
*/
104-
if (!drm_core_has_AGP(dev))
104+
if (!dev->agp)
105105
goto vm_fault_error;
106106

107107
if (!dev->agp || !dev->agp->cant_use_aperture)
@@ -592,7 +592,7 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma)
592592
switch (map->type) {
593593
#if !defined(__arm__)
594594
case _DRM_AGP:
595-
if (drm_core_has_AGP(dev) && dev->agp->cant_use_aperture) {
595+
if (dev->agp && dev->agp->cant_use_aperture) {
596596
/*
597597
* On some platforms we can't talk to bus dma address from the CPU, so for
598598
* memory of type DRM_AGP, we'll deal with sorting out the real physical

‎drivers/gpu/drm/radeon/radeon_ttm.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ static int radeon_init_mem_type(struct ttm_bo_device *bdev, uint32_t type,
142142
man->flags = TTM_MEMTYPE_FLAG_MAPPABLE | TTM_MEMTYPE_FLAG_CMA;
143143
#if __OS_HAS_AGP
144144
if (rdev->flags & RADEON_IS_AGP) {
145-
if (!(drm_core_has_AGP(rdev->ddev) && rdev->ddev->agp)) {
145+
if (!rdev->ddev->agp) {
146146
DRM_ERROR("AGP is not enabled for memory type %u\n",
147147
(unsigned)type);
148148
return -EINVAL;

‎include/drm/drm_agpsupport.h‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,6 @@ int drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
4646
int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
4747
int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
4848
struct drm_file *file_priv);
49-
50-
static inline int drm_core_has_AGP(struct drm_device *dev)
51-
{
52-
return drm_core_check_feature(dev, DRIVER_USE_AGP);
53-
}
54-
5549
#else /* __OS_HAS_AGP */
5650

5751
static inline void drm_free_agp(DRM_AGP_MEM * handle, int pages)
@@ -183,12 +177,6 @@ static inline int drm_agp_bind_ioctl(struct drm_device *dev, void *data,
183177
{
184178
return -ENODEV;
185179
}
186-
187-
static inline int drm_core_has_AGP(struct drm_device *dev)
188-
{
189-
return 0;
190-
}
191-
192180
#endif /* __OS_HAS_AGP */
193181

194182
#endif /* _DRM_AGPSUPPORT_H_ */

0 commit comments

Comments
 (0)