Skip to content

Commit 2818564

Browse files
danvetairlied
authored andcommitted
drm: rip out drm_core_has_MTRR checks
The new arch_phys_wc_add/del functions do the right thing both with and without MTRR support in the kernel. So we can drop these additional checks. David Herrmann suggest to also kill the DRIVER_USE_MTRR flag since it's now unused, which spurred me to do a bit a better audit of the affected drivers. David helped a lot in that. Quoting our mail discussion: On Wed, Jul 10, 2013 at 5:41 PM, David Herrmann <dh.herrmann@gmail.com> wrote: > On Wed, Jul 10, 2013 at 5:22 PM, Daniel Vetter <daniel.vetter@ffwll.ch> wrote: >> On Wed, Jul 10, 2013 at 3:51 PM, David Herrmann <dh.herrmann@gmail.com> wrote: >>>> -#if __OS_HAS_MTRR >>>> -static inline int drm_core_has_MTRR(struct drm_device *dev) >>>> -{ >>>> - return drm_core_check_feature(dev, DRIVER_USE_MTRR); >>>> -} >>>> -#else >>>> -#define drm_core_has_MTRR(dev) (0) >>>> -#endif >>>> - >>> >>> That was the last user of DRIVER_USE_MTRR (apart from drivers setting >>> it in .driver_features). Any reason to keep it around? >> >> Yeah, I guess we could rip things out. Which will also force me to >> properly audit drivers for the eventual behaviour change this could >> entail (in case there's an x86 driver which did not ask for an mtrr, >> but iirc there isn't). > > david@david-mb ~/dev/kernel/linux $ for i in drivers/gpu/drm/* ; do if > test -d "$i" ; then if ! grep -q USE_MTRR -r $i ; then echo $i ; fi ; > fi ; done > drivers/gpu/drm/exynos > drivers/gpu/drm/gma500 > drivers/gpu/drm/i2c > drivers/gpu/drm/nouveau > drivers/gpu/drm/omapdrm > drivers/gpu/drm/qxl > drivers/gpu/drm/rcar-du > drivers/gpu/drm/shmobile > drivers/gpu/drm/tilcdc > drivers/gpu/drm/ttm > drivers/gpu/drm/udl > drivers/gpu/drm/vmwgfx > david@david-mb ~/dev/kernel/linux $ > > So for x86 gma500,nouveau,qxl,udl,vmwgfx don't set DRIVER_USE_MTRR. > But I cannot tell whether they break if we call arch_phys_wc_add/del, > anyway. At least nouveau seemed to work here, but it doesn't use AGP > or drm_bufs, I guess. Cool, thanks a lot for stitching together the list of drivers to look at. So for real KMS drivers it's the drives responsibility to add an mtrr if it needs one. nouvea, radeon, mgag200, i915 and vmwgfx do that already. Somehow the savage driver also ends up doing that, I have no idea why. Note that gma500 as a pure KMS driver doesn't need MTRR setup since the platforms that it supports all support PAT. So no MTRRs needed to get wc iomappings. The mtrr support in the drm core is all for legacy mappings of garts, framebuffers and registers. All legacy drivers set the USE_MTRR flag, so we're good there. All in all I think we can really just ditch this /endquote v2: Also kill DRIVER_USE_MTRR as suggested by David Herrmann v3: Rebase on top of David Herrmann's agp setup/cleanup changes. Cc: David Herrmann <dh.herrmann@gmail.com> Cc: Andy Lutomirski <luto@amacapital.net> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Acked-by: Andy Lutomirski <luto@amacapital.net> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent 1216f73 commit 2818564

16 files changed

Lines changed: 24 additions & 42 deletions

File tree

‎drivers/gpu/drm/ast/ast_drv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ static const struct file_operations ast_fops = {
197197
};
198198

199199
static struct drm_driver driver = {
200-
.driver_features = DRIVER_USE_MTRR | DRIVER_MODESET | DRIVER_GEM,
200+
.driver_features = DRIVER_MODESET | DRIVER_GEM,
201201
.dev_priv_size = 0,
202202

203203
.load = ast_driver_load,

‎drivers/gpu/drm/cirrus/cirrus_drv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ static const struct file_operations cirrus_driver_fops = {
8787
#endif
8888
};
8989
static struct drm_driver driver = {
90-
.driver_features = DRIVER_MODESET | DRIVER_GEM | DRIVER_USE_MTRR,
90+
.driver_features = DRIVER_MODESET | DRIVER_GEM,
9191
.load = cirrus_driver_load,
9292
.unload = cirrus_driver_unload,
9393
.fops = &cirrus_driver_fops,

‎drivers/gpu/drm/drm_bufs.c‎

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -207,12 +207,10 @@ static int drm_addmap_core(struct drm_device * dev, resource_size_t offset,
207207
return 0;
208208
}
209209

210-
if (drm_core_has_MTRR(dev)) {
211-
if (map->type == _DRM_FRAME_BUFFER ||
212-
(map->flags & _DRM_WRITE_COMBINING)) {
213-
map->mtrr =
214-
arch_phys_wc_add(map->offset, map->size);
215-
}
210+
if (map->type == _DRM_FRAME_BUFFER ||
211+
(map->flags & _DRM_WRITE_COMBINING)) {
212+
map->mtrr =
213+
arch_phys_wc_add(map->offset, map->size);
216214
}
217215
if (map->type == _DRM_REGISTERS) {
218216
if (map->flags & _DRM_WRITE_COMBINING)
@@ -464,8 +462,7 @@ int drm_rmmap_locked(struct drm_device *dev, struct drm_local_map *map)
464462
iounmap(map->handle);
465463
/* FALLTHROUGH */
466464
case _DRM_FRAME_BUFFER:
467-
if (drm_core_has_MTRR(dev))
468-
arch_phys_wc_del(map->mtrr);
465+
arch_phys_wc_del(map->mtrr);
469466
break;
470467
case _DRM_SHM:
471468
vfree(map->handle);

‎drivers/gpu/drm/drm_pci.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,11 @@ static int drm_pci_agp_init(struct drm_device *dev)
272272
DRM_ERROR("Cannot initialize the agpgart module.\n");
273273
return -EINVAL;
274274
}
275-
if (drm_core_has_MTRR(dev)) {
276-
if (dev->agp)
277-
dev->agp->agp_mtrr = arch_phys_wc_add(
278-
dev->agp->agp_info.aper_base,
279-
dev->agp->agp_info.aper_size *
280-
1024 * 1024);
275+
if (dev->agp) {
276+
dev->agp->agp_mtrr = arch_phys_wc_add(
277+
dev->agp->agp_info.aper_base,
278+
dev->agp->agp_info.aper_size *
279+
1024 * 1024);
281280
}
282281
}
283282
return 0;
@@ -286,8 +285,7 @@ static int drm_pci_agp_init(struct drm_device *dev)
286285
static void drm_pci_agp_destroy(struct drm_device *dev)
287286
{
288287
if (drm_core_has_AGP(dev) && dev->agp) {
289-
if (drm_core_has_MTRR(dev))
290-
arch_phys_wc_del(dev->agp->agp_mtrr);
288+
arch_phys_wc_del(dev->agp->agp_mtrr);
291289
drm_agp_clear(dev);
292290
drm_agp_destroy(dev->agp);
293291
dev->agp = NULL;

‎drivers/gpu/drm/drm_vm.c‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma)
251251
switch (map->type) {
252252
case _DRM_REGISTERS:
253253
case _DRM_FRAME_BUFFER:
254-
if (drm_core_has_MTRR(dev))
255-
arch_phys_wc_del(map->mtrr);
254+
arch_phys_wc_del(map->mtrr);
256255
iounmap(map->handle);
257256
break;
258257
case _DRM_SHM:

‎drivers/gpu/drm/i810/i810_drv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ static const struct file_operations i810_driver_fops = {
5757

5858
static struct drm_driver driver = {
5959
.driver_features =
60-
DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | DRIVER_USE_MTRR |
60+
DRIVER_USE_AGP | DRIVER_REQUIRE_AGP |
6161
DRIVER_HAVE_DMA,
6262
.dev_priv_size = sizeof(drm_i810_buf_priv_t),
6363
.load = i810_driver_load,

‎drivers/gpu/drm/i915/i915_drv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1006,7 +1006,7 @@ static struct drm_driver driver = {
10061006
* deal with them for Intel hardware.
10071007
*/
10081008
.driver_features =
1009-
DRIVER_USE_AGP | DRIVER_REQUIRE_AGP | /* DRIVER_USE_MTRR |*/
1009+
DRIVER_USE_AGP | DRIVER_REQUIRE_AGP |
10101010
DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED | DRIVER_GEM | DRIVER_PRIME,
10111011
.load = i915_driver_load,
10121012
.unload = i915_driver_unload,

‎drivers/gpu/drm/mga/mga_drv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static const struct file_operations mga_driver_fops = {
5858

5959
static struct drm_driver driver = {
6060
.driver_features =
61-
DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA |
61+
DRIVER_USE_AGP | DRIVER_PCI_DMA |
6262
DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
6363
.dev_priv_size = sizeof(drm_mga_buf_priv_t),
6464
.load = mga_driver_load,

‎drivers/gpu/drm/mgag200/mgag200_drv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ static const struct file_operations mgag200_driver_fops = {
8888
};
8989

9090
static struct drm_driver driver = {
91-
.driver_features = DRIVER_GEM | DRIVER_MODESET | DRIVER_USE_MTRR,
91+
.driver_features = DRIVER_GEM | DRIVER_MODESET,
9292
.load = mgag200_driver_load,
9393
.unload = mgag200_driver_unload,
9494
.fops = &mgag200_driver_fops,

‎drivers/gpu/drm/r128/r128_drv.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static const struct file_operations r128_driver_fops = {
5656

5757
static struct drm_driver driver = {
5858
.driver_features =
59-
DRIVER_USE_AGP | DRIVER_USE_MTRR | DRIVER_PCI_DMA | DRIVER_SG |
59+
DRIVER_USE_AGP | DRIVER_PCI_DMA | DRIVER_SG |
6060
DRIVER_HAVE_DMA | DRIVER_HAVE_IRQ | DRIVER_IRQ_SHARED,
6161
.dev_priv_size = sizeof(drm_r128_buf_priv_t),
6262
.load = r128_driver_load,

0 commit comments

Comments
 (0)