From: Leo Liu <leo.liu-5C7GfCeVMHo@public.gmane.org> To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org Cc: Leo Liu <leo.liu-5C7GfCeVMHo@public.gmane.org> Subject: [PATCH 02/21] drm/amdgpu: add amdgpu_jpeg and JPEG tests Date: Tue, 12 Nov 2019 13:03:10 -0500 [thread overview] Message-ID: <20191112180329.3927-3-leo.liu@amd.com> (raw) In-Reply-To: <20191112180329.3927-1-leo.liu-5C7GfCeVMHo@public.gmane.org> It will be used for all versions of JPEG eventually. Previous JPEG tests will be removed later since they are still used by JPEG2.x. Signed-off-by: Leo Liu <leo.liu@amd.com> --- drivers/gpu/drm/amd/amdgpu/Makefile | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c | 135 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h | 3 + 3 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index 7eb172ebf3f8..11ca70105eeb 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile @@ -147,12 +147,13 @@ amdgpu-y += \ vce_v3_0.o \ vce_v4_0.o -# add VCN block +# add VCN and JPEG block amdgpu-y += \ amdgpu_vcn.o \ vcn_v1_0.o \ vcn_v2_0.o \ - vcn_v2_5.o + vcn_v2_5.o \ + amdgpu_jpeg.o # add ATHUB block amdgpu-y += \ diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c new file mode 100644 index 000000000000..d9a547d4d3b2 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c @@ -0,0 +1,135 @@ +/* + * Copyright 2019 Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + */ + +#include "amdgpu.h" +#include "amdgpu_jpeg.h" +#include "soc15d.h" +#include "soc15_common.h" + +int amdgpu_jpeg_dec_ring_test_ring(struct amdgpu_ring *ring) +{ + struct amdgpu_device *adev = ring->adev; + uint32_t tmp = 0; + unsigned i; + int r; + + WREG32(adev->jpeg.inst[ring->me].external.jpeg_pitch, 0xCAFEDEAD); + r = amdgpu_ring_alloc(ring, 3); + if (r) + return r; + + amdgpu_ring_write(ring, PACKET0(adev->jpeg.internal.jpeg_pitch, 0)); + amdgpu_ring_write(ring, 0xDEADBEEF); + amdgpu_ring_commit(ring); + + for (i = 0; i < adev->usec_timeout; i++) { + tmp = RREG32(adev->jpeg.inst[ring->me].external.jpeg_pitch); + if (tmp == 0xDEADBEEF) + break; + udelay(1); + } + + if (i >= adev->usec_timeout) + r = -ETIMEDOUT; + + return r; +} + +static int amdgpu_jpeg_dec_set_reg(struct amdgpu_ring *ring, uint32_t handle, + struct dma_fence **fence) +{ + struct amdgpu_device *adev = ring->adev; + struct amdgpu_job *job; + struct amdgpu_ib *ib; + struct dma_fence *f = NULL; + const unsigned ib_size_dw = 16; + int i, r; + + r = amdgpu_job_alloc_with_ib(ring->adev, ib_size_dw * 4, &job); + if (r) + return r; + + ib = &job->ibs[0]; + + ib->ptr[0] = PACKETJ(adev->jpeg.internal.jpeg_pitch, 0, 0, PACKETJ_TYPE0); + ib->ptr[1] = 0xDEADBEEF; + for (i = 2; i < 16; i += 2) { + ib->ptr[i] = PACKETJ(0, 0, 0, PACKETJ_TYPE6); + ib->ptr[i+1] = 0; + } + ib->length_dw = 16; + + r = amdgpu_job_submit_direct(job, ring, &f); + if (r) + goto err; + + if (fence) + *fence = dma_fence_get(f); + dma_fence_put(f); + + return 0; + +err: + amdgpu_job_free(job); + return r; +} + +int amdgpu_jpeg_dec_ring_test_ib(struct amdgpu_ring *ring, long timeout) +{ + struct amdgpu_device *adev = ring->adev; + uint32_t tmp = 0; + unsigned i; + struct dma_fence *fence = NULL; + long r = 0; + + r = amdgpu_jpeg_dec_set_reg(ring, 1, &fence); + if (r) + goto error; + + r = dma_fence_wait_timeout(fence, false, timeout); + if (r == 0) { + r = -ETIMEDOUT; + goto error; + } else if (r < 0) { + goto error; + } else { + r = 0; + } + + for (i = 0; i < adev->usec_timeout; i++) { + tmp = RREG32(adev->jpeg.inst[ring->me].external.jpeg_pitch); + if (tmp == 0xDEADBEEF) + break; + udelay(1); + } + + if (i >= adev->usec_timeout) + r = -ETIMEDOUT; + + dma_fence_put(fence); +error: + return r; +} diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h index 36e2b7340c97..a8d988c25f45 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h @@ -43,4 +43,7 @@ struct amdgpu_jpeg { unsigned harvest_config; }; +int amdgpu_jpeg_dec_ring_test_ring(struct amdgpu_ring *ring); +int amdgpu_jpeg_dec_ring_test_ib(struct amdgpu_ring *ring, long timeout); + #endif /*__AMDGPU_JPEG_H__*/ -- 2.17.1 _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
WARNING: multiple messages have this Message-ID (diff)
From: Leo Liu <leo.liu@amd.com> To: amd-gfx@lists.freedesktop.org Cc: Leo Liu <leo.liu@amd.com> Subject: [PATCH 02/21] drm/amdgpu: add amdgpu_jpeg and JPEG tests Date: Tue, 12 Nov 2019 13:03:10 -0500 [thread overview] Message-ID: <20191112180329.3927-3-leo.liu@amd.com> (raw) Message-ID: <20191112180310.2hc4VSs77Hsun8NZ6Pzi-XRQfxPGi37HD6ATXGZJHwQ@z> (raw) In-Reply-To: <20191112180329.3927-1-leo.liu@amd.com> It will be used for all versions of JPEG eventually. Previous JPEG tests will be removed later since they are still used by JPEG2.x. Signed-off-by: Leo Liu <leo.liu@amd.com> --- drivers/gpu/drm/amd/amdgpu/Makefile | 5 +- drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c | 135 +++++++++++++++++++++++ drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h | 3 + 3 files changed, 141 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c diff --git a/drivers/gpu/drm/amd/amdgpu/Makefile b/drivers/gpu/drm/amd/amdgpu/Makefile index 7eb172ebf3f8..11ca70105eeb 100644 --- a/drivers/gpu/drm/amd/amdgpu/Makefile +++ b/drivers/gpu/drm/amd/amdgpu/Makefile @@ -147,12 +147,13 @@ amdgpu-y += \ vce_v3_0.o \ vce_v4_0.o -# add VCN block +# add VCN and JPEG block amdgpu-y += \ amdgpu_vcn.o \ vcn_v1_0.o \ vcn_v2_0.o \ - vcn_v2_5.o + vcn_v2_5.o \ + amdgpu_jpeg.o # add ATHUB block amdgpu-y += \ diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c new file mode 100644 index 000000000000..d9a547d4d3b2 --- /dev/null +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.c @@ -0,0 +1,135 @@ +/* + * Copyright 2019 Advanced Micro Devices, Inc. + * All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL + * THE COPYRIGHT HOLDERS, AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, + * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR + * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE + * USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + */ + +#include "amdgpu.h" +#include "amdgpu_jpeg.h" +#include "soc15d.h" +#include "soc15_common.h" + +int amdgpu_jpeg_dec_ring_test_ring(struct amdgpu_ring *ring) +{ + struct amdgpu_device *adev = ring->adev; + uint32_t tmp = 0; + unsigned i; + int r; + + WREG32(adev->jpeg.inst[ring->me].external.jpeg_pitch, 0xCAFEDEAD); + r = amdgpu_ring_alloc(ring, 3); + if (r) + return r; + + amdgpu_ring_write(ring, PACKET0(adev->jpeg.internal.jpeg_pitch, 0)); + amdgpu_ring_write(ring, 0xDEADBEEF); + amdgpu_ring_commit(ring); + + for (i = 0; i < adev->usec_timeout; i++) { + tmp = RREG32(adev->jpeg.inst[ring->me].external.jpeg_pitch); + if (tmp == 0xDEADBEEF) + break; + udelay(1); + } + + if (i >= adev->usec_timeout) + r = -ETIMEDOUT; + + return r; +} + +static int amdgpu_jpeg_dec_set_reg(struct amdgpu_ring *ring, uint32_t handle, + struct dma_fence **fence) +{ + struct amdgpu_device *adev = ring->adev; + struct amdgpu_job *job; + struct amdgpu_ib *ib; + struct dma_fence *f = NULL; + const unsigned ib_size_dw = 16; + int i, r; + + r = amdgpu_job_alloc_with_ib(ring->adev, ib_size_dw * 4, &job); + if (r) + return r; + + ib = &job->ibs[0]; + + ib->ptr[0] = PACKETJ(adev->jpeg.internal.jpeg_pitch, 0, 0, PACKETJ_TYPE0); + ib->ptr[1] = 0xDEADBEEF; + for (i = 2; i < 16; i += 2) { + ib->ptr[i] = PACKETJ(0, 0, 0, PACKETJ_TYPE6); + ib->ptr[i+1] = 0; + } + ib->length_dw = 16; + + r = amdgpu_job_submit_direct(job, ring, &f); + if (r) + goto err; + + if (fence) + *fence = dma_fence_get(f); + dma_fence_put(f); + + return 0; + +err: + amdgpu_job_free(job); + return r; +} + +int amdgpu_jpeg_dec_ring_test_ib(struct amdgpu_ring *ring, long timeout) +{ + struct amdgpu_device *adev = ring->adev; + uint32_t tmp = 0; + unsigned i; + struct dma_fence *fence = NULL; + long r = 0; + + r = amdgpu_jpeg_dec_set_reg(ring, 1, &fence); + if (r) + goto error; + + r = dma_fence_wait_timeout(fence, false, timeout); + if (r == 0) { + r = -ETIMEDOUT; + goto error; + } else if (r < 0) { + goto error; + } else { + r = 0; + } + + for (i = 0; i < adev->usec_timeout; i++) { + tmp = RREG32(adev->jpeg.inst[ring->me].external.jpeg_pitch); + if (tmp == 0xDEADBEEF) + break; + udelay(1); + } + + if (i >= adev->usec_timeout) + r = -ETIMEDOUT; + + dma_fence_put(fence); +error: + return r; +} diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h index 36e2b7340c97..a8d988c25f45 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_jpeg.h @@ -43,4 +43,7 @@ struct amdgpu_jpeg { unsigned harvest_config; }; +int amdgpu_jpeg_dec_ring_test_ring(struct amdgpu_ring *ring); +int amdgpu_jpeg_dec_ring_test_ib(struct amdgpu_ring *ring, long timeout); + #endif /*__AMDGPU_JPEG_H__*/ -- 2.17.1 _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx
next prev parent reply other threads:[~2019-11-12 18:03 UTC|newest] Thread overview: 76+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-11-12 18:03 [PATCH 00/21] Separate JPEG from VCN Leo Liu 2019-11-12 18:03 ` Leo Liu [not found] ` <20191112180329.3927-1-leo.liu-5C7GfCeVMHo@public.gmane.org> 2019-11-12 18:03 ` [PATCH 01/21] drm/amdgpu: add JPEG HW IP and SW structures Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` Leo Liu [this message] 2019-11-12 18:03 ` [PATCH 02/21] drm/amdgpu: add amdgpu_jpeg and JPEG tests Leo Liu 2019-11-12 18:03 ` [PATCH 03/21] drm/amdgpu: separate JPEG1.0 code out from VCN1.0 Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 04/21] drm/amdgpu: use the JPEG structure for general driver support Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 05/21] drm/amdgpu: add JPEG IP block type Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 06/21] drm/amdgpu: add JPEG common functions to amdgpu_jpeg Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 07/21] drm/amdgpu: add JPEG v2.0 function supports Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 08/21] drm/amdgpu: remove unnecessary JPEG2.0 code from VCN2.0 Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 09/21] drm/amdgpu: add JPEG PG and CG interface Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 10/21] drm/amdgpu: add PG and CG for JPEG2.0 Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 11/21] drm/amd/powerplay: add JPEG Powerplay interface Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 12/21] drm/amd/powerplay: add JPEG power control for Navi1x Leo Liu 2019-11-12 18:03 ` Leo Liu [not found] ` <20191112180329.3927-13-leo.liu-5C7GfCeVMHo@public.gmane.org> 2019-11-13 3:50 ` Quan, Evan 2019-11-13 3:50 ` Quan, Evan [not found] ` <MN2PR12MB334438FF2957ED7C7C8E226FE4760-rweVpJHSKToDMgCC8P//OwdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org> 2019-11-13 13:50 ` Leo Liu 2019-11-13 13:50 ` Leo Liu 2019-11-13 14:11 ` Leo Liu 2019-11-13 14:11 ` Leo Liu 2019-11-12 18:03 ` [PATCH 13/21] drm/amd/powerplay: add Powergate JPEG for Renoir Leo Liu 2019-11-12 18:03 ` Leo Liu [not found] ` <20191112180329.3927-14-leo.liu-5C7GfCeVMHo@public.gmane.org> 2019-11-13 3:52 ` Quan, Evan 2019-11-13 3:52 ` Quan, Evan 2019-11-13 14:12 ` Leo Liu 2019-11-13 14:12 ` Leo Liu 2019-11-12 18:03 ` [PATCH 14/21] drm/amd/powerplay: add JPEG power control " Leo Liu 2019-11-12 18:03 ` Leo Liu [not found] ` <20191112180329.3927-15-leo.liu-5C7GfCeVMHo@public.gmane.org> 2019-11-13 3:52 ` Quan, Evan 2019-11-13 3:52 ` Quan, Evan 2019-11-13 14:13 ` Leo Liu 2019-11-13 14:13 ` Leo Liu 2019-11-12 18:03 ` [PATCH 15/21] drm/amd/powerplay: set JPEG to SMU dpm Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 16/21] drm/amdgpu: enable JPEG2.0 dpm Leo Liu 2019-11-12 18:03 ` Leo Liu [not found] ` <20191112180329.3927-17-leo.liu-5C7GfCeVMHo@public.gmane.org> 2019-11-14 16:03 ` Alex Deucher 2019-11-14 16:03 ` Alex Deucher [not found] ` <CADnq5_PTs-1fU3o3rpQ1hhAdbiicwixWMHuOxSbZ7bshMSBVxA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2019-11-14 16:14 ` Leo Liu 2019-11-14 16:14 ` Leo Liu 2019-11-12 18:03 ` [PATCH 17/21] drm/amdgpu: add driver support for JPEG2.0 and above Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 18/21] drm/amdgpu: enable JPEG2.0 for Navi1x and Renoir Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 19/21] drm/amdgpu: move JPEG2.5 out from VCN2.5 Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 20/21] drm/amdgpu: enable Arcturus CG for VCN and JPEG blocks Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:03 ` [PATCH 21/21] drm/amdgpu: enable Arcturus JPEG2.5 block Leo Liu 2019-11-12 18:03 ` Leo Liu 2019-11-12 18:59 ` [PATCH 00/21] Separate JPEG from VCN Leo Liu 2019-11-12 18:59 ` Leo Liu 2019-11-12 19:49 ` Alex Deucher 2019-11-12 19:49 ` Alex Deucher [not found] ` <CADnq5_NVBemrfE5OB=NBeb5XM5HPWdnhjaWM0KjdDyb6+pm9zA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2019-11-12 19:57 ` Leo Liu 2019-11-12 19:57 ` Leo Liu [not found] ` <171a5818-a2b5-6e91-ac35-050b43963988-5C7GfCeVMHo@public.gmane.org> 2019-11-12 20:12 ` Alex Deucher 2019-11-12 20:12 ` Alex Deucher [not found] ` <CADnq5_MRfvfE1D5SPOWTyWZFnLZezZ3N61QXvrwnLFssM++LrA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2019-11-12 20:16 ` Leo Liu 2019-11-12 20:16 ` Leo Liu [not found] ` <bf523547-408a-536d-5f61-226691058a7b-5C7GfCeVMHo@public.gmane.org> 2019-11-12 20:34 ` Alex Deucher 2019-11-12 20:34 ` Alex Deucher [not found] ` <CADnq5_NjNPZC=2xt5Qft6_jiZnbdtR+LqogTWdfty_N_zWR_uA-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org> 2019-11-12 20:37 ` Leo Liu 2019-11-12 20:37 ` Leo Liu
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20191112180329.3927-3-leo.liu@amd.com \ --to=leo.liu-5c7gfcevmho@public.gmane.org \ --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).