Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/panfrost: Add AFBC_FEATURES parameter

The value of the AFBC_FEATURES register is required by userspace to
determine AFBC support on Bifrost. A user on our IRC channel (#panfrost)
reported a workload that raised a fault on one system's Mali G31 but
worked flawlessly with another system's Mali G31. We determined the
cause to be missing AFBC support on one vendor's Mali implementation --
it turns out AFBC is optional on Bifrost!

Whether AFBC is supported or not is exposed in the AFBC_FEATURES
register on Bifrost, which reads back as 0 on Midgard. A zero value
indicates AFBC is fully supported, provided the architecture itself
supports AFBC, allowing backwards-compatibility with Midgard. Bits 0 and
15 indicate that AFBC support is absent for texturing and rendering
respectively.

The user experiencing the fault reports that AFBC_FEATURES reads back
0x10001 on their system, confirming the architectural lack of AFBC.
Userspace needs this parameter to know to disable AFBC on that
chip, and perhaps others.

v2: Fix typo from copy-paste fail.

v3: Bump the UABI version. This commit was cherry-picked from another
series so chalking this up to a rebase fail.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Cc: Rob Herring <robh@kernel.org>
Cc: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Signed-off-by: Steven Price <steven.price@arm.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20210604130011.3203-1-alyssa.rosenzweig@collabora.com

authored by

Alyssa Rosenzweig and committed by
Steven Price
3e2926f8 cb1c8146

+7 -1
+1
drivers/gpu/drm/panfrost/panfrost_device.h
··· 45 45 u32 thread_max_workgroup_sz; 46 46 u32 thread_max_barrier_sz; 47 47 u32 coherency_features; 48 + u32 afbc_features; 48 49 u32 texture_features[4]; 49 50 u32 js_features[16]; 50 51
+3 -1
drivers/gpu/drm/panfrost/panfrost_drv.c
··· 63 63 PANFROST_FEATURE(THREAD_MAX_BARRIER_SZ, 64 64 thread_max_barrier_sz); 65 65 PANFROST_FEATURE(COHERENCY_FEATURES, coherency_features); 66 + PANFROST_FEATURE(AFBC_FEATURES, afbc_features); 66 67 PANFROST_FEATURE_ARRAY(TEXTURE_FEATURES, texture_features, 3); 67 68 PANFROST_FEATURE_ARRAY(JS_FEATURES, js_features, 15); 68 69 PANFROST_FEATURE(NR_CORE_GROUPS, nr_core_groups); ··· 548 547 * Panfrost driver version: 549 548 * - 1.0 - initial interface 550 549 * - 1.1 - adds HEAP and NOEXEC flags for CREATE_BO 550 + * - 1.2 - adds AFBC_FEATURES query 551 551 */ 552 552 static const struct drm_driver panfrost_drm_driver = { 553 553 .driver_features = DRIVER_RENDER | DRIVER_GEM | DRIVER_SYNCOBJ, ··· 561 559 .desc = "panfrost DRM", 562 560 .date = "20180908", 563 561 .major = 1, 564 - .minor = 1, 562 + .minor = 2, 565 563 566 564 .gem_create_object = panfrost_gem_create_object, 567 565 .prime_handle_to_fd = drm_gem_prime_handle_to_fd,
+1
drivers/gpu/drm/panfrost/panfrost_gpu.c
··· 228 228 pfdev->features.thread_max_workgroup_sz = gpu_read(pfdev, GPU_THREAD_MAX_WORKGROUP_SIZE); 229 229 pfdev->features.thread_max_barrier_sz = gpu_read(pfdev, GPU_THREAD_MAX_BARRIER_SIZE); 230 230 pfdev->features.coherency_features = gpu_read(pfdev, GPU_COHERENCY_FEATURES); 231 + pfdev->features.afbc_features = gpu_read(pfdev, GPU_AFBC_FEATURES); 231 232 for (i = 0; i < 4; i++) 232 233 pfdev->features.texture_features[i] = gpu_read(pfdev, GPU_TEXTURE_FEATURES(i)); 233 234
+1
drivers/gpu/drm/panfrost/panfrost_regs.h
··· 82 82 83 83 #define GPU_TEXTURE_FEATURES(n) (0x0B0 + ((n) * 4)) 84 84 #define GPU_JS_FEATURES(n) (0x0C0 + ((n) * 4)) 85 + #define GPU_AFBC_FEATURES (0x4C) /* (RO) AFBC support on Bifrost */ 85 86 86 87 #define GPU_SHADER_PRESENT_LO 0x100 /* (RO) Shader core present bitmap, low word */ 87 88 #define GPU_SHADER_PRESENT_HI 0x104 /* (RO) Shader core present bitmap, high word */
+1
include/uapi/drm/panfrost_drm.h
··· 171 171 DRM_PANFROST_PARAM_JS_FEATURES15, 172 172 DRM_PANFROST_PARAM_NR_CORE_GROUPS, 173 173 DRM_PANFROST_PARAM_THREAD_TLS_ALLOC, 174 + DRM_PANFROST_PARAM_AFBC_FEATURES, 174 175 }; 175 176 176 177 struct drm_panfrost_get_param {