Skip to content

Commit eb12c95

Browse files
danvetalexdeucher
authored andcommitted
drm/radeon: Inline drm_get_pci_dev
It's the last user, and more importantly, it's the last non-legacy user of anything in drm_pci.c. The only tricky bit is the agp initialization. But a close look shows that radeon does not use the drm_agp midlayer (the main use of that is drm_bufs for legacy drivers), and instead could use the agp subsystem directly (like nouveau does already). Hence we can just pull this in too. A further step would be to entirely drop the use of drm_device->agp, but feels like too much churn just for this patch. Signed-off-by: Daniel Vetter <[email protected]> Cc: Alex Deucher <[email protected]> Cc: "Christian König" <[email protected]> Cc: "David (ChunMing) Zhou" <[email protected]> Cc: [email protected] Reviewed-by: Alex Deucher <[email protected]> Reviewed-by: Emil Velikov <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Cc: [email protected]
1 parent 8a3bddf commit eb12c95

File tree

2 files changed

+47
-2
lines changed

2 files changed

+47
-2
lines changed

drivers/gpu/drm/radeon/radeon_drv.c

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <linux/vga_switcheroo.h>
3838
#include <linux/mmu_notifier.h>
3939

40+
#include <drm/drm_agpsupport.h>
4041
#include <drm/drm_crtc_helper.h>
4142
#include <drm/drm_drv.h>
4243
#include <drm/drm_fb_helper.h>
@@ -325,6 +326,7 @@ static int radeon_pci_probe(struct pci_dev *pdev,
325326
const struct pci_device_id *ent)
326327
{
327328
unsigned long flags = 0;
329+
struct drm_device *dev;
328330
int ret;
329331

330332
if (!ent)
@@ -365,7 +367,44 @@ static int radeon_pci_probe(struct pci_dev *pdev,
365367
if (ret)
366368
return ret;
367369

368-
return drm_get_pci_dev(pdev, ent, &kms_driver);
370+
dev = drm_dev_alloc(&kms_driver, &pdev->dev);
371+
if (IS_ERR(dev))
372+
return PTR_ERR(dev);
373+
374+
ret = pci_enable_device(pdev);
375+
if (ret)
376+
goto err_free;
377+
378+
dev->pdev = pdev;
379+
#ifdef __alpha__
380+
dev->hose = pdev->sysdata;
381+
#endif
382+
383+
pci_set_drvdata(pdev, dev);
384+
385+
if (pci_find_capability(dev->pdev, PCI_CAP_ID_AGP))
386+
dev->agp = drm_agp_init(dev);
387+
if (dev->agp) {
388+
dev->agp->agp_mtrr = arch_phys_wc_add(
389+
dev->agp->agp_info.aper_base,
390+
dev->agp->agp_info.aper_size *
391+
1024 * 1024);
392+
}
393+
394+
ret = drm_dev_register(dev, ent->driver_data);
395+
if (ret)
396+
goto err_agp;
397+
398+
return 0;
399+
400+
err_agp:
401+
if (dev->agp)
402+
arch_phys_wc_del(dev->agp->agp_mtrr);
403+
kfree(dev->agp);
404+
pci_disable_device(pdev);
405+
err_free:
406+
drm_dev_put(dev);
407+
return ret;
369408
}
370409

371410
static void
@@ -575,7 +614,7 @@ radeon_get_crtc_scanout_position(struct drm_device *dev, unsigned int pipe,
575614

576615
static struct drm_driver kms_driver = {
577616
.driver_features =
578-
DRIVER_USE_AGP | DRIVER_GEM | DRIVER_RENDER,
617+
DRIVER_GEM | DRIVER_RENDER,
579618
.load = radeon_driver_load_kms,
580619
.open = radeon_driver_open_kms,
581620
.postclose = radeon_driver_postclose_kms,

drivers/gpu/drm/radeon/radeon_kms.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
#include <linux/uaccess.h>
3333
#include <linux/vga_switcheroo.h>
3434

35+
#include <drm/drm_agpsupport.h>
3536
#include <drm/drm_fb_helper.h>
3637
#include <drm/drm_file.h>
3738
#include <drm/drm_ioctl.h>
@@ -77,6 +78,11 @@ void radeon_driver_unload_kms(struct drm_device *dev)
7778
radeon_modeset_fini(rdev);
7879
radeon_device_fini(rdev);
7980

81+
if (dev->agp)
82+
arch_phys_wc_del(dev->agp->agp_mtrr);
83+
kfree(dev->agp);
84+
dev->agp = NULL;
85+
8086
done_free:
8187
kfree(rdev);
8288
dev->dev_private = NULL;

0 commit comments

Comments
 (0)