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

drm/radeon: Move AGP data structures into radeon

With the AGP code already duplicated, move over the AGP structures
from the legacy code base in to radeon. The AGP data structures that
are required by radeon are now declared within the driver. The AGP
instance is stored in struct radeon_device.agp.

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-3-tzimmermann@suse.de

+86 -59
+36 -2
drivers/gpu/drm/radeon/radeon.h
··· 60 60 * are considered as fatal) 61 61 */ 62 62 63 + #include <linux/agp_backend.h> 63 64 #include <linux/atomic.h> 64 65 #include <linux/wait.h> 65 66 #include <linux/list.h> ··· 1111 1110 /* 1112 1111 * AGP 1113 1112 */ 1113 + 1114 + struct radeon_agp_mode { 1115 + unsigned long mode; /**< AGP mode */ 1116 + }; 1117 + 1118 + struct radeon_agp_info { 1119 + int agp_version_major; 1120 + int agp_version_minor; 1121 + unsigned long mode; 1122 + unsigned long aperture_base; /* physical address */ 1123 + unsigned long aperture_size; /* bytes */ 1124 + unsigned long memory_allowed; /* bytes */ 1125 + unsigned long memory_used; 1126 + 1127 + /* PCI information */ 1128 + unsigned short id_vendor; 1129 + unsigned short id_device; 1130 + }; 1131 + 1132 + struct radeon_agp_head { 1133 + struct agp_kern_info agp_info; 1134 + struct list_head memory; 1135 + unsigned long mode; 1136 + struct agp_bridge_data *bridge; 1137 + int enabled; 1138 + int acquired; 1139 + unsigned long base; 1140 + int agp_mtrr; 1141 + int cant_use_aperture; 1142 + unsigned long page_mask; 1143 + }; 1144 + 1114 1145 #if IS_ENABLED(CONFIG_AGP) 1115 - struct drm_agp_head *radeon_agp_head_init(struct drm_device *dev); 1146 + struct radeon_agp_head *radeon_agp_head_init(struct drm_device *dev); 1116 1147 #else 1117 - static inline struct drm_agp_head *radeon_agp_head_init(struct drm_device *dev) 1148 + static inline struct radeon_agp_head *radeon_agp_head_init(struct drm_device *dev) 1118 1149 { 1119 1150 return NULL; 1120 1151 } ··· 2343 2310 #ifdef __alpha__ 2344 2311 struct pci_controller *hose; 2345 2312 #endif 2313 + struct radeon_agp_head *agp; 2346 2314 struct rw_semaphore exclusive_lock; 2347 2315 /* ASIC */ 2348 2316 union radeon_asic_config config;
+35 -35
drivers/gpu/drm/radeon/radeon_agp.c
··· 27 27 28 28 #include <linux/pci.h> 29 29 30 - #include <drm/drm_agpsupport.h> 31 30 #include <drm/drm_device.h> 32 31 #include <drm/radeon_drm.h> 33 32 ··· 127 128 { 0, 0, 0, 0, 0, 0, 0 }, 128 129 }; 129 130 130 - struct drm_agp_head *radeon_agp_head_init(struct drm_device *dev) 131 + struct radeon_agp_head *radeon_agp_head_init(struct drm_device *dev) 131 132 { 132 133 struct pci_dev *pdev = to_pci_dev(dev->dev); 133 - struct drm_agp_head *head = NULL; 134 + struct radeon_agp_head *head = NULL; 134 135 135 136 head = kzalloc(sizeof(*head), GFP_KERNEL); 136 137 if (!head) ··· 159 160 return head; 160 161 } 161 162 162 - static int radeon_agp_head_acquire(struct drm_device *dev) 163 + static int radeon_agp_head_acquire(struct radeon_device *rdev) 163 164 { 165 + struct drm_device *dev = rdev->ddev; 164 166 struct pci_dev *pdev = to_pci_dev(dev->dev); 165 167 166 - if (!dev->agp) 168 + if (!rdev->agp) 167 169 return -ENODEV; 168 - if (dev->agp->acquired) 170 + if (rdev->agp->acquired) 169 171 return -EBUSY; 170 - dev->agp->bridge = agp_backend_acquire(pdev); 171 - if (!dev->agp->bridge) 172 + rdev->agp->bridge = agp_backend_acquire(pdev); 173 + if (!rdev->agp->bridge) 172 174 return -ENODEV; 173 - dev->agp->acquired = 1; 175 + rdev->agp->acquired = 1; 174 176 return 0; 175 177 } 176 178 177 - static int radeon_agp_head_release(struct drm_device *dev) 179 + static int radeon_agp_head_release(struct radeon_device *rdev) 178 180 { 179 - if (!dev->agp || !dev->agp->acquired) 181 + if (!rdev->agp || !rdev->agp->acquired) 180 182 return -EINVAL; 181 - agp_backend_release(dev->agp->bridge); 182 - dev->agp->acquired = 0; 183 + agp_backend_release(rdev->agp->bridge); 184 + rdev->agp->acquired = 0; 183 185 return 0; 184 186 } 185 187 186 - static int radeon_agp_head_enable(struct drm_device *dev, struct drm_agp_mode mode) 188 + static int radeon_agp_head_enable(struct radeon_device *rdev, struct radeon_agp_mode mode) 187 189 { 188 - if (!dev->agp || !dev->agp->acquired) 190 + if (!rdev->agp || !rdev->agp->acquired) 189 191 return -EINVAL; 190 192 191 - dev->agp->mode = mode.mode; 192 - agp_enable(dev->agp->bridge, mode.mode); 193 - dev->agp->enabled = 1; 193 + rdev->agp->mode = mode.mode; 194 + agp_enable(rdev->agp->bridge, mode.mode); 195 + rdev->agp->enabled = 1; 194 196 return 0; 195 197 } 196 198 197 - static int radeon_agp_head_info(struct drm_device *dev, struct drm_agp_info *info) 199 + static int radeon_agp_head_info(struct radeon_device *rdev, struct radeon_agp_info *info) 198 200 { 199 201 struct agp_kern_info *kern; 200 202 201 - if (!dev->agp || !dev->agp->acquired) 203 + if (!rdev->agp || !rdev->agp->acquired) 202 204 return -EINVAL; 203 205 204 - kern = &dev->agp->agp_info; 206 + kern = &rdev->agp->agp_info; 205 207 info->agp_version_major = kern->version.major; 206 208 info->agp_version_minor = kern->version.minor; 207 209 info->mode = kern->mode; ··· 221 221 { 222 222 #if IS_ENABLED(CONFIG_AGP) 223 223 struct radeon_agpmode_quirk *p = radeon_agpmode_quirk_list; 224 - struct drm_agp_mode mode; 225 - struct drm_agp_info info; 224 + struct radeon_agp_mode mode; 225 + struct radeon_agp_info info; 226 226 uint32_t agp_status; 227 227 int default_mode; 228 228 bool is_v3; 229 229 int ret; 230 230 231 231 /* Acquire AGP. */ 232 - ret = radeon_agp_head_acquire(rdev->ddev); 232 + ret = radeon_agp_head_acquire(rdev); 233 233 if (ret) { 234 234 DRM_ERROR("Unable to acquire AGP: %d\n", ret); 235 235 return ret; 236 236 } 237 237 238 - ret = radeon_agp_head_info(rdev->ddev, &info); 238 + ret = radeon_agp_head_info(rdev, &info); 239 239 if (ret) { 240 - radeon_agp_head_release(rdev->ddev); 240 + radeon_agp_head_release(rdev); 241 241 DRM_ERROR("Unable to get AGP info: %d\n", ret); 242 242 return ret; 243 243 } 244 244 245 - if (rdev->ddev->agp->agp_info.aper_size < 32) { 246 - radeon_agp_head_release(rdev->ddev); 245 + if (rdev->agp->agp_info.aper_size < 32) { 246 + radeon_agp_head_release(rdev); 247 247 dev_warn(rdev->dev, "AGP aperture too small (%zuM) " 248 248 "need at least 32M, disabling AGP\n", 249 - rdev->ddev->agp->agp_info.aper_size); 249 + rdev->agp->agp_info.aper_size); 250 250 return -EINVAL; 251 251 } 252 252 ··· 327 327 } 328 328 329 329 mode.mode &= ~RADEON_AGP_FW_MODE; /* disable fw */ 330 - ret = radeon_agp_head_enable(rdev->ddev, mode); 330 + ret = radeon_agp_head_enable(rdev, mode); 331 331 if (ret) { 332 332 DRM_ERROR("Unable to enable AGP (mode = 0x%lx)\n", mode.mode); 333 - radeon_agp_head_release(rdev->ddev); 333 + radeon_agp_head_release(rdev); 334 334 return ret; 335 335 } 336 336 337 - rdev->mc.agp_base = rdev->ddev->agp->agp_info.aper_base; 338 - rdev->mc.gtt_size = rdev->ddev->agp->agp_info.aper_size << 20; 337 + rdev->mc.agp_base = rdev->agp->agp_info.aper_base; 338 + rdev->mc.gtt_size = rdev->agp->agp_info.aper_size << 20; 339 339 rdev->mc.gtt_start = rdev->mc.agp_base; 340 340 rdev->mc.gtt_end = rdev->mc.gtt_start + rdev->mc.gtt_size - 1; 341 341 dev_info(rdev->dev, "GTT: %lluM 0x%08llX - 0x%08llX\n", ··· 366 366 void radeon_agp_fini(struct radeon_device *rdev) 367 367 { 368 368 #if IS_ENABLED(CONFIG_AGP) 369 - if (rdev->ddev->agp && rdev->ddev->agp->acquired) { 370 - radeon_agp_head_release(rdev->ddev); 369 + if (rdev->agp && rdev->agp->acquired) { 370 + radeon_agp_head_release(rdev); 371 371 } 372 372 #endif 373 373 }
-13
drivers/gpu/drm/radeon/radeon_drv.c
··· 39 39 #include <linux/pci.h> 40 40 41 41 #include <drm/drm_aperture.h> 42 - #include <drm/drm_agpsupport.h> 43 42 #include <drm/drm_crtc_helper.h> 44 43 #include <drm/drm_drv.h> 45 44 #include <drm/drm_fb_helper.h> ··· 344 345 345 346 pci_set_drvdata(pdev, dev); 346 347 347 - if (pci_find_capability(pdev, PCI_CAP_ID_AGP)) 348 - dev->agp = radeon_agp_head_init(dev); 349 - if (dev->agp) { 350 - dev->agp->agp_mtrr = arch_phys_wc_add( 351 - dev->agp->agp_info.aper_base, 352 - dev->agp->agp_info.aper_size * 353 - 1024 * 1024); 354 - } 355 - 356 348 ret = drm_dev_register(dev, ent->driver_data); 357 349 if (ret) 358 350 goto err_agp; ··· 351 361 return 0; 352 362 353 363 err_agp: 354 - if (dev->agp) 355 - arch_phys_wc_del(dev->agp->agp_mtrr); 356 - kfree(dev->agp); 357 364 pci_disable_device(pdev); 358 365 err_free: 359 366 drm_dev_put(dev);
+13 -5
drivers/gpu/drm/radeon/radeon_kms.c
··· 32 32 #include <linux/uaccess.h> 33 33 #include <linux/vga_switcheroo.h> 34 34 35 - #include <drm/drm_agpsupport.h> 36 35 #include <drm/drm_fb_helper.h> 37 36 #include <drm/drm_file.h> 38 37 #include <drm/drm_ioctl.h> ··· 79 80 radeon_modeset_fini(rdev); 80 81 radeon_device_fini(rdev); 81 82 82 - if (dev->agp) 83 - arch_phys_wc_del(dev->agp->agp_mtrr); 84 - kfree(dev->agp); 85 - dev->agp = NULL; 83 + if (rdev->agp) 84 + arch_phys_wc_del(rdev->agp->agp_mtrr); 85 + kfree(rdev->agp); 86 + rdev->agp = NULL; 86 87 87 88 done_free: 88 89 kfree(rdev); ··· 117 118 #ifdef __alpha__ 118 119 rdev->hose = pdev->sysdata; 119 120 #endif 121 + 122 + if (pci_find_capability(pdev, PCI_CAP_ID_AGP)) 123 + rdev->agp = radeon_agp_head_init(rdev->ddev); 124 + if (rdev->agp) { 125 + rdev->agp->agp_mtrr = arch_phys_wc_add( 126 + rdev->agp->agp_info.aper_base, 127 + rdev->agp->agp_info.aper_size * 128 + 1024 * 1024); 129 + } 120 130 121 131 /* update BUS flag */ 122 132 if (pci_find_capability(pdev, PCI_CAP_ID_AGP)) {
+2 -4
drivers/gpu/drm/radeon/radeon_ttm.c
··· 38 38 #include <linux/swap.h> 39 39 #include <linux/swiotlb.h> 40 40 41 - #include <drm/drm_agpsupport.h> 42 41 #include <drm/drm_device.h> 43 42 #include <drm/drm_file.h> 44 43 #include <drm/drm_prime.h> ··· 290 291 /* RADEON_IS_AGP is set only if AGP is active */ 291 292 mem->bus.offset = (mem->start << PAGE_SHIFT) + 292 293 rdev->mc.agp_base; 293 - mem->bus.is_iomem = !rdev->ddev->agp->cant_use_aperture; 294 + mem->bus.is_iomem = !rdev->agp->cant_use_aperture; 294 295 mem->bus.caching = ttm_write_combined; 295 296 } 296 297 #endif ··· 512 513 struct radeon_device *rdev = radeon_get_rdev(bo->bdev); 513 514 514 515 if (rdev->flags & RADEON_IS_AGP) { 515 - return ttm_agp_tt_create(bo, rdev->ddev->agp->bridge, 516 - page_flags); 516 + return ttm_agp_tt_create(bo, rdev->agp->bridge, page_flags); 517 517 } 518 518 #endif 519 519 rbo = container_of(bo, struct radeon_bo, tbo);