Skip to content

Commit 66aa696

Browse files
tormodvoldenairlied
authored andcommitted
drm: Compare only lower 32 bits of framebuffer map offsets
Drivers using multiple framebuffers got broken by commit 41c2e75 which ignored the framebuffer (or register) map offset when looking for existing maps. The rationale was that the kernel-userspace ABI is fixed at a 32-bit offset, so the real offsets could not always be handed over for comparison. Instead of ignoring the offset we will compare the lower 32 bit. Drivers using multiple framebuffers should just make sure that the lower 32 bit are different. The existing drivers in question are practically limited to 32-bit systems so that should be fine for them. It is assumed that current drivers always specify a correct framebuffer map offset, even if this offset was ignored since above commit. So this patch should not change anything for drivers using only one framebuffer. Drivers needing multiple framebuffers with 64-bit map offsets will need to cook up something, for instance keeping an ID in the lower bit which is to be aligned away when it comes to using the offset. All of above applies to _DRM_REGISTERS as well. Signed-off-by: Tormod Volden <debian.tormod@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent b65552f commit 66aa696

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

‎drivers/gpu/drm/drm_bufs.c‎

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ static struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
4646
list_for_each_entry(entry, &dev->maplist, head) {
4747
/*
4848
* Because the kernel-userspace ABI is fixed at a 32-bit offset
49-
* while PCI resources may live above that, we ignore the map
50-
* offset for maps of type _DRM_FRAMEBUFFER or _DRM_REGISTERS.
51-
* It is assumed that each driver will have only one resource of
52-
* each type.
49+
* while PCI resources may live above that, we only compare the
50+
* lower 32 bits of the map offset for maps of type
51+
* _DRM_FRAMEBUFFER or _DRM_REGISTERS.
52+
* It is assumed that if a driver have more than one resource
53+
* of each type, the lower 32 bits are different.
5354
*/
5455
if (!entry->map ||
5556
map->type != entry->map->type ||
@@ -59,9 +60,12 @@ static struct drm_map_list *drm_find_matching_map(struct drm_device *dev,
5960
case _DRM_SHM:
6061
if (map->flags != _DRM_CONTAINS_LOCK)
6162
break;
63+
return entry;
6264
case _DRM_REGISTERS:
6365
case _DRM_FRAME_BUFFER:
64-
return entry;
66+
if ((entry->map->offset & 0xffffffff) ==
67+
(map->offset & 0xffffffff))
68+
return entry;
6569
default: /* Make gcc happy */
6670
;
6771
}

0 commit comments

Comments
 (0)