Skip to content

Commit 43861f7

Browse files
marekolsakairlied
authored andcommitted
drm/radeon: add a way to revoke hyper-z access
Signed-off-by: Marek Olšák <[email protected]> Signed-off-by: Dave Airlie <[email protected]>
1 parent c17c2f8 commit 43861f7

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

drivers/gpu/drm/radeon/radeon_kms.c

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,27 @@ int radeon_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
162162
return -EINVAL;
163163
}
164164
case RADEON_INFO_WANT_HYPERZ:
165+
/* The "value" here is both an input and output parameter.
166+
* If the input value is 1, filp requests hyper-z access.
167+
* If the input value is 0, filp revokes its hyper-z access.
168+
*
169+
* When returning, the value is 1 if filp owns hyper-z access,
170+
* 0 otherwise. */
171+
if (value >= 2) {
172+
DRM_DEBUG_KMS("WANT_HYPERZ: invalid value %d\n", value);
173+
return -EINVAL;
174+
}
165175
mutex_lock(&dev->struct_mutex);
166-
if (rdev->hyperz_filp)
167-
value = 0;
168-
else {
169-
rdev->hyperz_filp = filp;
170-
value = 1;
176+
if (value == 1) {
177+
/* wants hyper-z */
178+
if (!rdev->hyperz_filp)
179+
rdev->hyperz_filp = filp;
180+
} else if (value == 0) {
181+
/* revokes hyper-z */
182+
if (rdev->hyperz_filp == filp)
183+
rdev->hyperz_filp = NULL;
171184
}
185+
value = rdev->hyperz_filp == filp ? 1 : 0;
172186
mutex_unlock(&dev->struct_mutex);
173187
break;
174188
default:

0 commit comments

Comments
 (0)