Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 693704 | Differences between
and this patch

Collapse All | Expand All

(-)a/kernel/nv-drm.c (+131 lines)
Lines 51-56 Link Here
51
#define nv_drm_pci_init drm_legacy_pci_init
51
#define nv_drm_pci_init drm_legacy_pci_init
52
#define nv_drm_pci_exit drm_legacy_pci_exit
52
#define nv_drm_pci_exit drm_legacy_pci_exit
53
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
53
#elif LINUX_VERSION_CODE >= KERNEL_VERSION(5, 6, 0)
54
55
#if LINUX_VERSION_CODE >= KERNEL_VERSION(5, 7, 0)
56
#include <drm/drm_agpsupport.h>
57
58
struct drm_agp_mem {
59
	unsigned long handle;
60
	struct agp_memory *memory;
61
	unsigned long bound;
62
	int pages;
63
	struct list_head head;
64
};
65
66
/**
67
 * drm_legacy_agp_clear - Clear AGP resource list
68
 * @dev: DRM device
69
 *
70
 * Iterate over all AGP resources and remove them. But keep the AGP head
71
 * intact so it can still be used. It is safe to call this if AGP is disabled or
72
 * was already removed.
73
 *
74
 * Cleanup is only done for drivers who have DRIVER_LEGACY set.
75
 */
76
void drm_legacy_agp_clear(struct drm_device *dev)
77
{
78
	struct drm_agp_mem *entry, *tempe;
79
80
	if (!dev->agp)
81
		return;
82
	if (!drm_core_check_feature(dev, DRIVER_LEGACY))
83
		return;
84
85
	list_for_each_entry_safe(entry, tempe, &dev->agp->memory, head) {
86
		if (entry->bound)
87
			agp_unbind_memory(entry->memory);
88
		agp_free_memory(entry->memory);
89
		kfree(entry);
90
	}
91
	INIT_LIST_HEAD(&dev->agp->memory);
92
93
	if (dev->agp->acquired)
94
		drm_agp_release(dev);
95
96
	dev->agp->acquired = 0;
97
	dev->agp->enabled = 0;
98
}
99
100
static void drm_pci_agp_init(struct drm_device *dev)
101
{
102
	if (drm_core_check_feature(dev, DRIVER_USE_AGP)) {
103
		if (pci_find_capability(dev->pdev, PCI_CAP_ID_AGP))
104
			dev->agp = drm_agp_init(dev);
105
		if (dev->agp) {
106
			dev->agp->agp_mtrr = arch_phys_wc_add(
107
				dev->agp->agp_info.aper_base,
108
				dev->agp->agp_info.aper_size *
109
				1024 * 1024);
110
		}
111
	}
112
}
113
114
void drm_pci_agp_destroy(struct drm_device *dev)
115
{
116
	if (dev->agp) {
117
		arch_phys_wc_del(dev->agp->agp_mtrr);
118
		drm_legacy_agp_clear(dev);
119
		kfree(dev->agp);
120
		dev->agp = NULL;
121
	}
122
}
123
124
/**
125
 * drm_get_pci_dev - Register a PCI device with the DRM subsystem
126
 * @pdev: PCI device
127
 * @ent: entry from the PCI ID table that matches @pdev
128
 * @driver: DRM device driver
129
 *
130
 * Attempt to gets inter module "drm" information. If we are first
131
 * then register the character device and inter module information.
132
 * Try and register, if we fail to register, backout previous work.
133
 *
134
 * NOTE: This function is deprecated, please use drm_dev_alloc() and
135
 * drm_dev_register() instead and remove your &drm_driver.load callback.
136
 *
137
 * Return: 0 on success or a negative error code on failure.
138
 */
139
int drm_get_pci_dev(struct pci_dev *pdev, const struct pci_device_id *ent,
140
		    struct drm_driver *driver)
141
{
142
	struct drm_device *dev;
143
	int ret;
144
145
	DRM_DEBUG("\n");
146
147
	dev = drm_dev_alloc(driver, &pdev->dev);
148
	if (IS_ERR(dev))
149
		return PTR_ERR(dev);
150
151
	ret = pci_enable_device(pdev);
152
	if (ret)
153
		goto err_free;
154
155
	dev->pdev = pdev;
156
#ifdef __alpha__
157
	dev->hose = pdev->sysdata;
158
#endif
159
160
	if (drm_core_check_feature(dev, DRIVER_MODESET))
161
		pci_set_drvdata(pdev, dev);
162
163
	drm_pci_agp_init(dev);
164
165
	ret = drm_dev_register(dev, ent->driver_data);
166
	if (ret)
167
		goto err_agp;
168
169
	/* No locking needed since shadow-attach is single-threaded since it may
170
	 * only be called from the per-driver module init hook. */
171
	if (drm_core_check_feature(dev, DRIVER_LEGACY))
172
		list_add_tail(&dev->legacy_dev_list, &driver->legacy_dev_list);
173
174
	return 0;
175
176
err_agp:
177
	drm_pci_agp_destroy(dev);
178
	pci_disable_device(pdev);
179
err_free:
180
	drm_dev_put(dev);
181
	return ret;
182
}
183
#endif
184
54
int nv_drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
185
int nv_drm_pci_init(struct drm_driver *driver, struct pci_driver *pdriver)
55
{
186
{
56
	struct pci_dev *pdev = NULL;
187
	struct pci_dev *pdev = NULL;

Return to bug 693704