Commit graph

114 commits

Author SHA1 Message Date
Jason Macnak
8956e04c7f Revert^2 "Merge remote-tracking branch 'aosp/upstream-main'"
8a3215bf53

Change-Id: I299a95b80910f102a652cbd577838ddfc65fdbc6
2024-10-16 19:19:47 +00:00
Jason Macnak
8a3215bf53 Revert "Merge remote-tracking branch 'aosp/upstream-main'"
Revert submission 3308804

Reason for revert: b/373667975

Reverted changes: /q/submissionid:3308804

Change-Id: Ieb4e87d2bdcd975f5aa231c8e05f1053963c6c6e
2024-10-15 20:15:13 +00:00
Chia-I Wu
e2fdd90122 dri: pass use_flags to dri_bo_create_with_modifiers
We need use_flags when we implement the dri interface on top of hbm.

Also, dri_bo_create_with_modifiers does not take use flags only because
gbm_bo_create_with_modifiers does not.  That has changed with
gbm_bo_create_with_modifiers2 although minigbm does not reflect that.

BUG=b:292148713
TEST=CQ

Change-Id: I120358c843140a937fee1dd6183d1836ea622eec
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5801181
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
Tested-by: Chia-I Wu <olv@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
2024-09-04 02:19:39 +00:00
Chia-I Wu
2743358812 dri: make dri_driver a proper object
Make dri_driver a proper object that the backend can create, rather than
something that the backend must inherit from.

This makes dri_init return a dri_driver and make the rest dri_*
functions take a dri_driver.  There is no functional change.

BUG=b:292148713
TEST=CQ

Change-Id: I3ef045d73b0015b5c6d926dec7bae69d35d94275
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/5801179
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
Tested-by: Chia-I Wu <olv@google.com>
2024-09-04 02:19:34 +00:00
Dawn Han
84b3a09ef0 minigbm: clean up bo.handles
The multi-planar formats are being allocated into a single plane,
and the minigbm exynos backend is dropped. So we can use `handle` instead of handles as of now.

Remove some of the helper functions that calculate the number of planes.
There is no need to check if there is more than one kernel buffer per buffer object.

Added a new function `drv_gem_close` in `drv_helpers` that can be used by `drv_gem_bo_destroy` and `drv_prime_bo_import`. It can be used to clean the unused gem_handle.

Bug=b:266776512
TEST=camera and screenshot work fine after deploying the change #strongbad
TEST=camera and screenshot work fine after deploying the change #kukui-arc-r
TEST=camera and screenshot work fine after deploying the change, tested a couple of apps in the Google Play Store, and checked file `dma_buf/bufinfo` to see there's no object leaking. #guybrush

Change-Id: Ib63559504e4cb8f1a32ae90170925146613d694f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4297873
Commit-Queue: Dawn Han <dawnhan@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Dawn Han <dawnhan@google.com>
2023-04-09 18:57:40 +00:00
Chia-I Wu
a93e79aa9b amdgpu: work around a CTS issue before R
The test requires the strides to be aligned consistently despite the use
flags.  This is a test bug (b/167947334) before R.

BUG=b:265746435
TEST=android.hardware.camera2.cts.ImageWriterTest#testYuvImageWriterReaderOperation

Change-Id: I0f56b12f46c1a2d65ec7096d337c562459c35ee8
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4351634
Tested-by: Chia-I Wu <olv@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2023-03-20 22:16:22 +00:00
Chia-I Wu
66c664213f amdgpu: treat BO_USE_LINEAR as an HW flag
sommelier makes VIRTWL_IOCTL_NEW_DMABUF requests for 2D apps.  crosvm's
virtio-wl allocates linear BOs in response and expects them to be
presentable.

BUG=b:273797429
TEST=xeyes and gedit in crostini

Change-Id: Id5a955e5c22342ee11e9e333720eb95ac08fd175
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4343374
Tested-by: Chia-I Wu <olv@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Chia-I Wu <olv@google.com>
2023-03-16 07:19:35 +00:00
Chia-I Wu
20c9f05773 amdgpu: improve android YV12 support on GFX10+
GFX10+ cannot support DRM_FORMAT_YVU420_ANDROID when the strides do not
meet hw requirement.  When that happens, force the format to
DRM_FORMAT_YVU420 and log an error.

When the bo is used as a classic resource by virglrenderer, this is
hopefully fine because the guest only sees the guest storage (unless
there are bugs elsewhere).  Otherwise, the logs can lead us to proper
fixes.

BUG=b:265746435
TEST=subset of CTS and CTS Verifier on grunt, guybrush and skyrim

Change-Id: I0fda9e2f09bec8c26e87748b9d58c4f8e186e34d
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4336266
Tested-by: Chia-I Wu <olv@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
2023-03-15 05:13:38 +00:00
Chia-I Wu
5ff4a55d37 drv: pass stride_align to drv_bo_from_format
drv_bo_from_format will apply stride_align to all planes.  Since we
always pass 1 for stride_align, there is no change except when the
format is DRM_FORMAT_YVU420_ANDROID.

When the format is DRM_FORMAT_YVU420_ANDROID, and when stride_align is 0
or 1, drv_bo_from_format assumes there is no hw requirement and forces
stride_align to 16.  But because we used to require stride to be aligned
to 32, there is no actual change either.

BUG=b:265746435
TEST=subset of CTS and CTS Verifier on grunt, guybrush and skyrim

Change-Id: Ia6ef89bb744c39d2baead07bc47f11b0eea96b97
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4336265
Tested-by: Chia-I Wu <olv@google.com>
Commit-Queue: Chia-I Wu <olv@google.com>
Reviewed-by: Ryan Neph <ryanneph@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Dawn Han <dawnhan@google.com>
2023-03-15 05:13:37 +00:00
Dawn Han
ecbc89179e minigbm: Remove plane in bo_map
Remove the parameter to align with upstream gbm.
For some places that use the number of planes. The number is 1. The
multi-planar formats are being allocated into a single plane, and
minigbm exynos backend is dropped. So we can just set the plane
index to 0 if needed.

Fixed the format in i915.c.

Bug=b:266776512
TEST=camera works after deploying the change #strongbad
TEST=camera works after deploying the change #corsola

Change-Id: I0880917754c01b9d0f27d21f3c42d87f00a09f50
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4249501
Commit-Queue: Dawn Han <dawnhan@google.com>
Tested-by: Dawn Han <dawnhan@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
2023-02-27 19:34:38 +00:00
Chia-I Wu
bf1f37f516 drv: add drv_preload
It can be used to preload a backend, currently only used to preload
amdgpu.

BUG=b:269664560
TEST="grep radeonsi /proc/$(pidof zygote)/maps" on grunt

Change-Id: I30d9f701f1da3bc243a9c81326a1ba0c5e0562de
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/4262034
Commit-Queue: Chia-I Wu <olv@google.com>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Chia-I Wu <olv@google.com>
2023-02-21 19:57:34 +00:00
Jason Macnak
80f664c422 minigbm: passthrough SENSOR_DIRECT_DATA via gbm frontend
BUG=b:238609372
TEST=vts -m VtsHalSensorsV2_1TargetTest

Change-Id: I37834f80d71e453e6e29b88198efc1584c109456
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3773926
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Jason Macnak <natsu@google.com>
Tested-by: Jason Macnak <natsu@google.com>
2022-07-26 23:41:35 +00:00
Yiwei Zhang
bbe1fd3a8c minigbm: passthrough GPU_DATA_BUFFER via gbm frontend
This is required for modern Android atop a gralloc with the cross_domain
backend or other native backend.

BUG=b:238609372
TEST=build and AHB cts

Change-Id: Id963eeec62c4400cc009384e127c93588c99346e
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3777566
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-21 05:37:37 +00:00
Yiwei Zhang
0495473b90 minigbm: deprecate drv_log to favor log level
TEST=build

Change-Id: I3f0021bfd05eb1ab7c3b35ae2f31d806bc0a58dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3761446
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-19 04:16:15 +00:00
Yiwei Zhang
7648f0649b minigbm: fix some formating
TEST=./presubmit.sh

Change-Id: Ia53da4264de6ab637a21ad55029024c52a253c0f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3761444
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2022-07-15 06:50:50 +00:00
Miguel Casas
26960909ad amdgpu: Only align video BOs to 512 for Android
crrev/c/3633249 compares libva and minigbm allocated Surfaces/BOs
for accelerated video decoding. Currently it fails on e.g. zork
because libva (mesa-amd backend) aligns those buffers to 256,
whereas minigbm aligns them to 512. This CL reduces the 512-align
provision in amdgpu to Android-originated buffers, where IIUC
from the bug there is such restriction.

BUG=b:200680176
BUG=b:171013552
TEST=vaapi_unittest on zork w/ crrev/c/3633249

Change-Id: I703037c70dded8596408c475518a29de3b59f039
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3647157
Tested-by: Miguel Casas-Sanchez <mcasas@chromium.org>
Reviewed-by: Drew Davenport <ddavenport@chromium.org>
Commit-Queue: Miguel Casas-Sanchez <mcasas@chromium.org>
2022-05-19 01:28:29 +00:00
Robert Mader
d73fa7ff37 minigbm: amdgpu: Update plane count in bo_import
This is required for importing multi-plane modifiers where the
format plane count is lower (usually `1`). It will be used
by Exo for v3/4 of the `zwp_linux_dmabuf_v1` Wayland potocol,
allowing Wayland clients (and thus all clients that build on
the Wayland support) to use explicit modifiers which again
can increase performance on many GPUs.

Also add another fallback path to `dri_num_planes_from_modifier()`
for cases when `queryDmaBufFormatModifierAttribs()` fails and do
some refactoring there. Without this, some test apparently fail.

This includes the amdgpu part of
commit 1a733377e9, partially reverting
commit 853b8542fb.

Bug🅱️224580219
Change-Id: I93b64123420b39f3b83ff1bbbb9c59ddf4bc6105
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3568489
Reviewed-by: Bas Nieuwenhuizen <basni@chromium.org>
Tested-by: Robert Mader <robert.mader@collabora.com>
Commit-Queue: Robert Mader <robert.mader@collabora.com>
2022-05-04 08:47:25 +00:00
Kazuhiro Inaba
853b8542fb Revert "minigbm: i915/amdgpu: Update plane count in bo_import"
This reverts commit 1a733377e9.

Reason for revert: Broke many ARC tests b/227807607 b/227830888

Original change's description:
> minigbm: i915/amdgpu: Update plane count in bo_import
>
> For format/modifier combination where the plane count does not
> match the `DRM_FORMAT_MOD_INVALID` case, importing BOs
> (via e.g. `gbm_bo_import`) currently fails as `bo->meta.num_planes`
> is not set correctly.
>
> Fix that by making the driver backends that support such
> format/modifier combinations update the plane count accordingly.
>
>
> minigbm: i915: Implement num_planes_from_modifier interface
>
> Some format/modifier combinations have different plane counts
> compared to the formats default (i.e. when the modifier is
> `DRM_FORMAT_MOD_INVALID`).
>
> Right now the supported cases are hardcoded in
> `i915_bo_compute_metadata()`, however this does not cover all
> use-cases. So implement the already existing backend interface,
> aligning i915 with e.g. amdgpu.
>
> Bug🅱️224580219
> Change-Id: If017997c70ab7da04ebf9d6cb9db775d9271ed05
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3516490
> Reviewed-by: Bas Nieuwenhuizen <basni@chromium.org>
> Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
> Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>

Bug: b:224580219
Change-Id: I334f8cedb1d0414ecd0a38217afa4afc0df6ab47
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3568890
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Tested-by: Kazuhiro Inaba <kinaba@chromium.org>
Auto-Submit: Kazuhiro Inaba <kinaba@chromium.org>
Reviewed-by: Tadashi G. Takaoka <takaoka@google.com>
Commit-Queue: Tadashi G. Takaoka <takaoka@google.com>
Owners-Override: Tadashi G. Takaoka <takaoka@google.com>
2022-04-05 04:32:14 +00:00
Robert Mader
1a733377e9 minigbm: i915/amdgpu: Update plane count in bo_import
For format/modifier combination where the plane count does not
match the `DRM_FORMAT_MOD_INVALID` case, importing BOs
(via e.g. `gbm_bo_import`) currently fails as `bo->meta.num_planes`
is not set correctly.

Fix that by making the driver backends that support such
format/modifier combinations update the plane count accordingly.


minigbm: i915: Implement num_planes_from_modifier interface

Some format/modifier combinations have different plane counts
compared to the formats default (i.e. when the modifier is
`DRM_FORMAT_MOD_INVALID`).

Right now the supported cases are hardcoded in
`i915_bo_compute_metadata()`, however this does not cover all
use-cases. So implement the already existing backend interface,
aligning i915 with e.g. amdgpu.

Bug🅱️224580219
Change-Id: If017997c70ab7da04ebf9d6cb9db775d9271ed05
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3516490
Reviewed-by: Bas Nieuwenhuizen <basni@chromium.org>
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
2022-03-31 22:56:47 +00:00
Bas Nieuwenhuizen
136d9228c0 amdgpu: Use bo_release to free DRI images.
Previously these would get leaked if we had multiple bo structs
pointing to the same image/GEM BO as each has their own DRI image,
but bo_destroy only gets called on the last struct.

To mitigate this we have a new callback for every struct where we
can free the DRI image.

BUG=b:185869479
TEST=Repeatedly open/close camera app on Grunt.

Change-Id: I6188346b5bf9e5cbbbbf32a3db621a3fe0276d4f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3270684
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
2021-11-12 14:06:35 +00:00
Yiwei Zhang
b8ad7b88ca minigbm: refactor to add unified resolve_format_and_use_flags helper
It makes more sense to resovle the format and use_flags together to
avoid duplicates.

Add the helper to vc4 and dumb_driver backends since that's missed
from prior frontend refactoring.

Split the resolve helper in virtgpu_virgl for the 3d and 2d paths to
make code logic cleaner.

BUG=b:199524294
TEST=CQ

Change-Id: I89b633ea484f0fc5bb9b4e0548cad017b9970cc6
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3200143
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Tested-by: Jason Macnak <natsu@google.com>
Reviewed-by: Chia-I Wu <olv@google.com>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Dominik Behr <dbehr@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-10-05 03:43:18 +00:00
Yiwei Zhang
b7a64441ef minigbm: refactor driver helpers
1. frontends access the driver via drv.h only
2. the renamed drv_helpers and drv_array_helpers are for driver only
3. remove extern "C" from drv_helpers.h given not exposed to gralloc
4. remove all redundant includes for those helpers

BUG=b:199524294
TEST=CQ and gralloc builds on aosp

Change-Id: I3f4d33076a6a8161804f1b7c26950ff5496507e9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3195651
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Chia-I Wu <olv@google.com>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-10-01 18:35:11 +00:00
Yiwei Zhang
c1413ea43a minigbm: conditionally fallback to strip scanout use_flag
Only 2d virtgpu backend needs to fallback here because virtio primary
plane only allows DRM_FORMAT_XRGB8888.

Most our platforms cannot display YV12 (except msm), thus the fallback
is required for the converted DRM_FORMAT_YVU420_ANDROID. For virgl
backend, additionally append a BO_USE_LINEAR as a replacement for the
hack inside compute_virgl_bind_flags.

BUG=b:199524294
TEST=CQ
TEST=gralloctest alloc_combinations
TEST=android.media.cts.VideoDecoderRotationTest

Change-Id: Ic87838ea2aae2b0abf87ed898ad75a3d7e556471
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3166775
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Auto-Submit: Yiwei Zhang <zzyiwei@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-22 19:47:06 +00:00
Yiwei Zhang
1c2a0efbee amdgpu: add scanout capable linear DRM_FORMAT_RGB565 support
rgb565 is a common default pixel format for a native window on Android
when app or the platform doesn't override the pixel format. So it's a
must support format for scanout.

BUG=b:198669698
BUG=b:198098339
BUG=b:198098005
TEST=ASurfaceControlTest
TEST=SurfaceViewTests

Change-Id: Ie7199a3e7b181660497566c4a51d413e73ac4540
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3140733
Reviewed-by: Lepton Wu <lepton@chromium.org>
Tested-by: Yiwei Zhang <zzyiwei@chromium.org>
Commit-Queue: Yiwei Zhang <zzyiwei@chromium.org>
2021-09-03 07:24:01 +00:00
Bas Nieuwenhuizen
4c0371bacf amdgpu: Always allocate bo with modifier on GFX9+.
For virtualization purposes we always want to have a modifier. With
radeonsi that means allocating with modifiers. This has the
complication that the structure of modifiers isn't trivial.

Three implementation options:

1) Add dri-flag to create bo with valid modifier
2) Figure out scanout capable modifiers in minigbm
3) Take scanout capable modifiers from kernel.

3 is an issue because the card node is often behind a video group
on desktop linux and we don't want to create something that won't
work on desktop linux.

For 2 I figured out that the structure is actually fairly simple if
we assume that the DRI driver doesn't provide useless modifiers.

For 1 we'd end up having to do the same work as 2 + define the
DRI interface + maybe have to deal with older somewhat buggy kernels.

So I ended up selecting 2.

Note that this also removes CURSOR usage in the old path with DRI
On AMD we only allow linear for the cursor so this gets handled
in the linear path.

BUG=b:192390822
TEST=Run vkcube on zork-arc-r.

Change-Id: Ibde0e2ec761e293486c8ee71cfd88d9846ba09da
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3086527
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Yiwei Zhang <zzyiwei@chromium.org>
2021-08-26 22:53:18 +00:00
Drew Davenport
e1178658ea amdgpu: Don't align stride to 512 for VCE
Aligning the stride to 512 for multiplane images seems to be problematic
for VCE, resulting in protection faults and kernel hangs.

To avoid this situation, don't apply the 512 stride alignment workaround
for bos that will be used for encoding on Stoney.

BUG=b:195623914, b:195676997, b:195025184
TEST=camera.CCAUISmoke.video_fake and camera.CCAUISmoke.video_fake pass on grunt
     CtsMediaTestCases android.media.cts.EncodeDecodeTest passes on grunt

Change-Id: I233391105c4fe1bc56d684676eb0e5813ccda9dc
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3097148
Tested-by: Drew Davenport <ddavenport@chromium.org>
Reviewed-by: Bas Nieuwenhuizen <basni@chromium.org>
Commit-Queue: Drew Davenport <ddavenport@chromium.org>
2021-08-19 19:19:53 +00:00
Drew Davenport
49b804b11a minigbm: Align stride to 512 for multiplane formats
This was restricted to Raven. Modify that restriction so that this
happens for Stoney as well. It seems that Stoney is also affected by
this same issue, but it just didn't cause any CTS or other errors until
the mesa-amd uprev added some additional correctness checks.

TEST=android.media.cts.EncodeDecodeTest passes on grunt
BUG=b:190484589

Change-Id: Ieebbffb0d711d08c24c071e79c0b3224663c8369
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/3060894
Reviewed-by: Bas Nieuwenhuizen <basni@chromium.org>
Tested-by: Drew Davenport <ddavenport@chromium.org>
Commit-Queue: Drew Davenport <ddavenport@chromium.org>
2021-07-31 11:30:21 +00:00
Drew Davenport
5ebd19f7e1 amdgpu: Remove 256 alignment workaround
Tiled buffers do not need 256 alignment, and doing so leads to failing
new sanity checks added in a more recent mesa version [1].

The underlying problem for android (different map-time and allocation-time
strides for tiled buffers) is worked around in another way.

[1] https://chromium.googlesource.com/chromiumos/third_party/mesa/+/f7a4051b836/src/amd/common/ac_surface.c#2791

BUG=b:190028349
TEST=Pass CtsNativeHardwareTestCases on zork and grunt

Change-Id: I72f67f1bc089a27b187024df64280efbd8465217
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2952005
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Drew Davenport <ddavenport@chromium.org>
Commit-Queue: Drew Davenport <ddavenport@chromium.org>
2021-06-18 08:16:52 +00:00
Drew Davenport
f1a7dfc6c6 amdgpu: Do not support mapping tiled buffers on android
Some CTS tests allocate buffers with
AHARDWAREBUFFER_USAGE_GPU_SAMPLED_IMAGE or
AHARDWAREBUFFER_USAGE_GPU_COLOR_OUTPUT along with
AHARDWAREBUFFER_USAGE_CPU_READ_RARELY, which is not a common usage in
the real world.

On AMD platforms, this results in a tiled buffer being allocated which
ends up having a different stride when mapped for read, and the
different stride does not get propagated to the caller through the
gralloc API. This results in CTS test failures when checking buffer
contents.

Removing support for READ_RARELY and WRITE_RARELY usage for tiled buffers
in Android works around this by ensuring that any buffers that need to be
mapped for read/write are linear buffers.

BUG=b:190028349
TEST=CtsNativeHardwareTestCases passes on grunt and zork

Change-Id: I9d595ea980b352610b2379330935505d92e8a555
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2952004
Tested-by: Drew Davenport <ddavenport@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Drew Davenport <ddavenport@chromium.org>
2021-06-18 08:16:51 +00:00
Drew Davenport
8ed9b31127 minigbm: Restrict 256 alignment to grunt
This workaround addresses instability on grunt devices, but is a much
larger alignment than should be required. On zork, the larger alignment
ends up triggering a check that was added in mesa 21.1, causing an
allocation failure for some use cases.

Restrict the workaround to grunt devices, which are not affected by the
new check in mesa 21.1

BUG=b:180755705
TEST=start crostini on zork

Change-Id: I15855e06edb784fbca6b1128ed260450c2c82e27
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2879313
Tested-by: Drew Davenport <ddavenport@chromium.org>
Reviewed-by: Bas Nieuwenhuizen <basni@chromium.org>
Commit-Queue: Drew Davenport <ddavenport@chromium.org>
2021-05-07 17:32:52 +00:00
Gurchetan Singh
45ca4495d0 minigbm: run presubmit.sh
Am I the only one who does this????

BUG=none
TEST=none

Change-Id: Ie121703c631debd5e7eed1760334bb8ce5ebe115
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2857885
Reviewed-by: Lingfeng Yang <lfy@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Auto-Submit: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-04-30 20:41:41 +00:00
Lepton Wu
c83116f67d minigbm:amdgpu: Add ABGR16161616F format
Virgl are expecting host gpm can handle this format, so just
enable this for amdgpu.

BUG=b:177032502
TEST=manual - run CtsNativeHardwareTestCases on zork-arc-r

Change-Id: I574d3bfda5a86a6a42790cd02edc137f0e367471
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2850989
Tested-by: Lepton Wu <lepton@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Lepton Wu <lepton@chromium.org>
2021-04-27 19:13:41 +00:00
Ikshwaku Chauhan
4b69e28065 minigbm:amdgpu: allocate buffer from TMZ
For protected content playback need to allocate the buffer from
Trusted Memory Zone.

BUG=b:177681002
TEST=none

Signed-off-by: Ikshwaku Chauhan <ikshwaku.chauhan@amd.corp-partner.google.com>
Change-Id: Iae154dc8f6668369bfb72abd9baa285a7f120217
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2658261
Reviewed-by: Shirish S <shirish.s@amd.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Drew Davenport <ddavenport@chromium.org>
2021-04-06 23:31:46 +00:00
Gurchetan Singh
695125c0b3 minigbm: add drv_resolve_format_helper
Removes duplicated code.

BUG=none
TEST=CQ

Change-Id: Iea59cc6ca20e13756b6121db7f5294855cc6cfcd
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2672509
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Chad Versace <chadversary@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-02-04 19:14:50 +00:00
Gurchetan Singh
cadc54fe5d minigbm: consistent style
- Sometimes were return -1 and sometimes -errno.  Prefer -errno
  wherever possible.
- No braces for single line if/else statements.  This does not
  apply gralloc3/gralloc4, since that directory follows AOSP
  style.

BUG=b:178495907
TEST=Cuttlefish CFI

Change-Id: I4c35768e015109730772a972b4b18e8d2c3cbb9b
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2665001
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Jason Macnak <natsu@google.com>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
2021-02-03 04:22:38 +00:00
Gurchetan Singh
52155b4b57 minigbm: format_modifiers[0] -> format_modifier
The early version of the modifier assumed per plane modifiers.
The current version is only one modifier per buffer object.

BUG=none
TEST=compile

Change-Id: Ic3899118d44cb172ee2e4eae346e98cdf8328cf9
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2654590
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2021-01-29 22:47:35 +00:00
Bas Nieuwenhuizen
b5e0f2d61b amdgpu: Add P010 format.
BUG=b:169591197
TEST=Load http://crosvideo.appspot.com/?codec=vp9.2_30&loop=true&mute=true

Change-Id: I7f8b02b4809b6bae877c30aefdee03977abce9ab
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2436746
Reviewed-by: Miguel Casas <mcasas@chromium.org>
Reviewed-by: Drew Davenport <ddavenport@chromium.org>
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Commit-Queue: Miguel Casas <mcasas@chromium.org>
2021-01-20 08:47:31 +00:00
Drew Davenport
8db36fe931 amdgpu: Align stride to 512 for multiplane formats
Quick fix to ensure subsample stride is aligned to 256 for multiplane formats.

BUG=b:171013552
TEST=CtsMediaTestCases passes on zork

Change-Id: I0f47ae3585e5875f3e35cbb667cb7a0ab6421898
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2477987
Reviewed-by: Bas Nieuwenhuizen <basni@chromium.org>
Commit-Queue: Drew Davenport <ddavenport@chromium.org>
Tested-by: Drew Davenport <ddavenport@chromium.org>
2020-10-16 22:57:53 +00:00
Gurchetan Singh
9964438dbb minigbm: reduce use of memset
Also run presubmit.sh.

BUG=none
TEST=compile

Change-Id: I6f5d2afca41c4228a4f8eb40f3670b39bce7b641
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2459529
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-10-12 21:56:58 +00:00
Gurchetan Singh
9b4c8b73f1 minigbm: run presubmit.sh
It's good to do this every once and a while.

Change-Id: Ief71a50e07a51e2ac1b66daf1ed0c8b9129d9c1f
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2368212
Reviewed-by: Jason Macnak <natsu@google.com>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Gurchetan Singh <gurchetansingh@chromium.org>
2020-08-25 05:23:28 +00:00
Bas Nieuwenhuizen
b16076b583 amdgpu: Add 10-bit color formats.
Should be fine for rendering and texturing.

AMDGPU only exposes this on the primary plane though, not on the
overlay or cursor. I strongly suspect the HW could also do this
on the overlay but I lack a proper testcase for now.

BUG=b:159011420
TEST=Run tast.video.Play.vp9_2_sw on Zork

Change-Id: Ie3a5356576a960985aac0ba16665425f45bd1541
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2272566
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Miguel Casas <mcasas@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
2020-07-09 19:06:49 +00:00
Ikshwaku Chauhan
047df2b4e9 minigbm:amdgpu: align height to 16 bit for video buffers
Currently, allocator used by chrome aligns the height of Encoder/Decoder
buffer while allocator used by android(gralloc/minigbm) doesn't provide
any aligment.Aligned the height for video buffers in minigbm.

BUG=b:153130069
TEST=cheets_CTS_P.x86.CtsVideoTestCases

Signed-off-by: Ikshwaku Chauhan <ikshwaku.chauhan@amd.corp-partner.google.com>
Change-Id: I62a883ca55c07674fab7981af0974277fbd2c5b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2273037
Reviewed-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Drew Davenport <ddavenport@chromium.org>
Tested-by: Drew Davenport <ddavenport@chromium.org>
Commit-Queue: Drew Davenport <ddavenport@chromium.org>
2020-07-02 05:29:56 +00:00
Bas Nieuwenhuizen
4daf12cff0 Revert "Revert "amdgpu: Set USWC for SCANOUT images.""
This reverts commit 91d36976aa84abde87f0f56d235d57042ca3ea81.i

The previous changes should fix the mapping performance with USWC
memory.

original change:
    amdgpu: Set USWC for SCANOUT images.

    This is necessary for scanout from GTT. Without it, the kernel will
    migrate it to the carveout. For large resolutions this would not be
    feasible due to small carveout sizes and hence it is important that
    we alloc scanout from GTT.

    The original patch was on top of
    4eebcea "amdgpu: make AMDGPU_GEM_CREATE_CPU_GTT_USWC flag default"
    which set USWC unconditionally, but has since been reverted. The
    main failure reason is being addressed in mesa-amd. This patch also
    still disables USWC if we can and the image will be read often on
    the CPU, to avoid staging textures during memory mapping.

TEST=Run android.hardware.camera2.cts.RecordingTest#testVideoPreviewSurfaceSharing on Grunt.
BUG=b:152378755

Change-Id: Ice0041de6676c057a2659986b962c2d54833e928
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2246025
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
2020-06-25 18:41:30 +00:00
Bas Nieuwenhuizen
4a3f98cc34 amdgpu: Add SDMA copy support.
For SCANOUT images we need to use USWC memory. However USWC
memory is very slow to read from (~25 MiB/second).

At the same time for video decoding there are some images
that are allocated with SCANOUT but at the same time frequently
accessed from the CPU. Just mapping these is going to result
in non-satisfactory performance, so this patch adds a DMA step
to copy it to memory that is faster to acces from the CPU.

Benchmarked on Grunt with
android.hardware.camera2.cts.RecordingTest#testVideoPreviewSurfaceSharing

The time that an image (~500 KiB) is kept mapped for processing,
including the time for mapping and unmapping:

plain GTT (cachaeable):  1.5-2 ms
USWC:                    45-50 ms
USWC w/ memcpy:          20-30 ms
USWC w/ SDMA copy:       3.5-5.5 ms

We can clearly see that the Android video processing code only gets
a throughput of ~10 MiB/s with USWC memory. memcpy is slightly more
efficient by getting 20-30 MiB/s, but neither of these are suitable
for 30+ fps video.

Furthermore, with SDMA copy, the timing is roughly as follows:

map:
  - Allocate plain GTT BO:        ~400-800 us
  - map src & dst BO into GPU VM: ~25 us
  - submit SDMA copy:             ~80 us
  - wait till SDMA copy finishes: ~400 us
  - unmap src & dst BO from GPU:  ~15 us
  - map dst BO into CPU:          ~30 us

unmap:
  - unmapping dst BO from CPU:    ~30 us
  - Copy not benchmarked (avoided for RO map)
  - delete BO:                    ~100 us

ideas for further improvement:
  - BO cache
  - rely on implicit sync and don't wait for the copy during
    unmapping.

Alternatives that have been rejected:
  - Use radeonsi + DRI interface: each plane gets mapped into
    its own BO, which is an issue for gralloc.
  - more persistently mapping each BO into GPU VM: this needs
    proper address space management which adds complexity.
    librm_amdgpu can do it for us but brings its own can of worms
    with dedup of the drm fd. (which makes e.g. implicit sync not
    work with any radeonsi instances in the same process)
  - Use SDMA instead of DRI/Radeonsi for more images. This is an
    issue because SDMA for images is a whole mess with lots of
    corner cases and lots of changes per generation. Furthermore,
    it wouldn't work for DCC compressed images.

TEST=Run android.hardware.camera2.cts.RecordingTest#testVideoPreviewSurfaceSharing on Grunt.
BUG=b:152378755

Change-Id: I8f5e00ff4b6d9e31f78fd4de7eb62d0d3aa66438
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2256228
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
2020-06-25 18:41:28 +00:00
Hirokazu Honda
3bd681c62c Modify NV12 allowed buffer usages for camera capture use case
We use SCANOUT_VEA_READ_CAMERA_AND_CPU_READ_WRITE for camera
capture use scenario in Chrome. Therefore, NV12 format must be
allowed for all those usage masks. This CL modifies the usages on
all platforms.

BUG=chromium:982201
TEST=video.EncodeAccel.vp8_720p_i420 on eve

Change-Id: I7880e64049f3bbf9dd1c177619e41362baf641f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2240995
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Hirokazu Honda <hiroh@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
2020-06-25 14:17:05 +00:00
Hirokazu Honda
fd8b8abd7f Remove HW_VIDEO_ENCODER usage of YVU420
minigbm has allowed HW_VIDEO_ENCODER usage to YVU420 so that
chrome can allocate YVU420 with HW_VIDEO_ENCODER. But this
format is no longer allocated by chrome with the usage. Let's
delete the code.

BUG=chromium:982201
TEST=None

Change-Id: Ia6bbc24e7782e3e73c2eb00c00127af212ddf486
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2245967
Reviewed-by: Tomasz Figa <tfiga@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Hirokazu Honda <hiroh@chromium.org>
Tested-by: Hirokazu Honda <hiroh@chromium.org>
Auto-Submit: Hirokazu Honda <hiroh@chromium.org>
2020-06-18 06:10:36 +00:00
David Stevens
495181462f minigbm: add encoder/decoder blob combination
ARCVM sets encoder/decoder usage on the blob output/input buffers, so
that virtio_gpu knows to perform transfers from/to the host where
appropriate. Recently, virtio_gpu started passing all bind flags to the
host, instead of reducing them in the guest. These factors combined
means that the host backends now need to support encoder/decoder usage
with R8 format.

Test: manually verify ARCVM YouTube
Bug: b:158957350
Change-Id: I58bf657496647f8002c693d17a1186f4cf527b01
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2245540
Tested-by: David Stevens <stevensd@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: David Stevens <stevensd@chromium.org>
2020-06-16 07:27:24 +00:00
Bas Nieuwenhuizen
91d36976aa Revert "amdgpu: Set USWC for SCANOUT images."
This reverts commit d2c2843919.

Reason for revert: b/55018529: broke android.hardware.camera2.cts.RecordingTest#testVideoPreviewSurfaceSharing and fixing it is non-trivial

Original change's description:
> amdgpu: Set USWC for SCANOUT images.
> 
> This is necessary for scanout from GTT. Without it, the kernel will
> migrate it to the carveout. For large resolutions this would not be
> feasible due to small carveout sizes and hence it is important that
> we alloc scanout from GTT.
> 
> The original patch was on top of
> 4eebcea "amdgpu: make AMDGPU_GEM_CREATE_CPU_GTT_USWC flag default"
> which set USWC unconditionally, but has since been reverted. The
> main failure reason is being addressed in mesa-amd. This patch also
> still disables USWC if we can and the image will be read often on
> the CPU, to avoid staging textures during memory mapping.
> 
> BUG=b:153247881
> TEST=Run CtsCameraTestCases on Grunt.
>      4k YouTube video p/b
> 
> Change-Id: If6393e60cea5d2a98a052d7c46604e0012de0618
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2134451
> Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
> Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
> Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>

Bug: b:153247881
Change-Id: I395798c637ab10a2cf2a2a65a3a418a18feb2310
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2167399
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
2020-04-29 04:10:06 +00:00
Bas Nieuwenhuizen
d2c2843919 amdgpu: Set USWC for SCANOUT images.
This is necessary for scanout from GTT. Without it, the kernel will
migrate it to the carveout. For large resolutions this would not be
feasible due to small carveout sizes and hence it is important that
we alloc scanout from GTT.

The original patch was on top of
4eebcea "amdgpu: make AMDGPU_GEM_CREATE_CPU_GTT_USWC flag default"
which set USWC unconditionally, but has since been reverted. The
main failure reason is being addressed in mesa-amd. This patch also
still disables USWC if we can and the image will be read often on
the CPU, to avoid staging textures during memory mapping.

BUG=b:153247881
TEST=Run CtsCameraTestCases on Grunt.
     4k YouTube video p/b

Change-Id: If6393e60cea5d2a98a052d7c46604e0012de0618
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2134451
Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
Reviewed-by: Gurchetan Singh <gurchetansingh@chromium.org>
Commit-Queue: Bas Nieuwenhuizen <basni@chromium.org>
2020-04-25 15:14:34 +00:00
Jao-ke Chin-Lee
5481e3c91e Revert "amdgpu: make AMDGPU_GEM_CREATE_CPU_GTT_USWC flag default"
This reverts commit 4eebcea0cc.

Reason for revert: Broke tast.video.DecodeAccel.*.h264_resolution_switch on grunt

Original change's description:
> amdgpu: make AMDGPU_GEM_CREATE_CPU_GTT_USWC flag default
>
> amdgpu kernel driver requires USWC flag for allowing bo
> allocation in GTT domain, hence enable it by default.
>
> BUG=b:152378755
> TEST=On Dali play 4k YouTube video
>
> Signed-off-by: Shirish S <shirish.s@amd.com>
> Change-Id: Ic509701f683d184d3fb85b7616dc9a7ed467cfe3
> Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2128147
> Tested-by: Bas Nieuwenhuizen <basni@chromium.org>
> Reviewed-by: Bas Nieuwenhuizen <basni@chromium.org>
> Reviewed-by: Drew Davenport <ddavenport@chromium.org>

Bug: b:152378755
Change-Id: If382833a741faa5462df841cc801e60fd9fca77a
Exempt-From-Owner-Approval: revert.
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/platform/minigbm/+/2145078
Tested-by: Ilja H. Friedel <ihf@chromium.org>
Reviewed-by: Jao-ke Chin-Lee <jchinlee@google.com>
2020-04-10 10:01:09 +00:00