Skip to contentSkip to conversation

Ground foundation for VCE 1 implementation

PATCH In review Alexandre Demers 3 participants 13 messages Sep 8, 2017 – Sep 11, 2017 5 messages not in the archive

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover Ground foundation for VCE 1 implementation

This is the foundation for VCE 1 implementation, mostly ported from radeon to amdgpu. This should have no impact for now on the usability of the driver. This is the pretty straight-forward part. The heavier part is coming as a RFC.

I'd like to have this first part available to all, since I don't have as much time as I'd like to work on VCE 1 for now, but this could help others to help me on the task.

If you are not satisfied with this first series, this can also be considered as a RFC. Please, comment as needed.

Alexandre Demers (6):
Add initial VCE_V1_0 files.
Reorganize, rename, move and split some VCE 1 defines. Small precision when failing to load legacy firmware. Moving read and write pointer functions from radeon to amdgpu Add support for SI's VCE firmwares (with and without header) Fix indentation.

 drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c            | 100 ++++--
 drivers/gpu/drm/amd/amdgpu/si.c                    |  17 +-
 drivers/gpu/drm/amd/amdgpu/si_dma.c                |   5 +-
 drivers/gpu/drm/amd/amdgpu/si_ih.c                 |  21 +-
 drivers/gpu/drm/amd/amdgpu/sid.h                   |  70 ----
 drivers/gpu/drm/amd/amdgpu/vce_v1_0.c              | 394 +++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/vce_v1_0.h              |  29 ++
 .../gpu/drm/amd/include/asic_reg/vce/vce_1_0_d.h   |  80 +++--
 .../drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h |  13 +-
 drivers/gpu/drm/radeon/radeon_uvd.c                |   2 +-
 10 files changed, 589 insertions(+), 142 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.h
Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20170908024835.13638-1-alexandre.f.demers-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

PATCH 1/6 Add initial VCE_V1_0 files.

---
 drivers/gpu/drm/amd/amdgpu/vce_v1_0.c | 384 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/vce_v1_0.h |  29 +++
 2 files changed, 413 insertions(+)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.h
drivers/gpu/drm/amd/amdgpu/vce_v1_0.c new file +384 -0
new file mode 100644
index 000000000000..f541a4b5ac51
@@ -0,0 +1,384 @@
+/*
+ * Copyright 2013 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.
+ *
+ * Authors: Christian König <[email protected]>
+ */
+
+#include <linux/firmware.h>
+#include <drm/drmP.h>
+#include "radeon.h"
+#include "radeon_asic.h"
+#include "sid.h"
+
+#define VCE_V1_0_FW_SIZE	(256 * 1024)
+#define VCE_V1_0_STACK_SIZE	(64 * 1024)
+#define VCE_V1_0_DATA_SIZE	(7808 * (RADEON_MAX_VCE_HANDLES + 1))
+
+struct vce_v1_0_fw_signature
+{
+	int32_t off;
+	uint32_t len;
+	int32_t num;
+	struct {
+		uint32_t chip_id;
+		uint32_t keyselect;
+		uint32_t nonce[4];
+		uint32_t sigval[4];
+	} val[8];
+};
+
+/**
+ * vce_v1_0_get_rptr - get read pointer
+ *
+ * @rdev: radeon_device pointer
+ * @ring: radeon_ring pointer
+ *
+ * Returns the current hardware read pointer
+ */
+uint32_t vce_v1_0_get_rptr(struct radeon_device *rdev,
+			   struct radeon_ring *ring)
+{
+	if (ring->idx == TN_RING_TYPE_VCE1_INDEX)
+		return RREG32(VCE_RB_RPTR);
+	else
+		return RREG32(VCE_RB_RPTR2);
+}
+
+/**
+ * vce_v1_0_get_wptr - get write pointer
+ *
+ * @rdev: radeon_device pointer
+ * @ring: radeon_ring pointer
+ *
+ * Returns the current hardware write pointer
+ */
+uint32_t vce_v1_0_get_wptr(struct radeon_device *rdev,
+			   struct radeon_ring *ring)
+{
+	if (ring->idx == TN_RING_TYPE_VCE1_INDEX)
+		return RREG32(VCE_RB_WPTR);
+	else
+		return RREG32(VCE_RB_WPTR2);
+}
+
+/**
+ * vce_v1_0_set_wptr - set write pointer
+ *
+ * @rdev: radeon_device pointer
+ * @ring: radeon_ring pointer
+ *
+ * Commits the write pointer to the hardware
+ */
+void vce_v1_0_set_wptr(struct radeon_device *rdev,
+		       struct radeon_ring *ring)
+{
+	if (ring->idx == TN_RING_TYPE_VCE1_INDEX)
+		WREG32(VCE_RB_WPTR, ring->wptr);
+	else
+		WREG32(VCE_RB_WPTR2, ring->wptr);
+}
+
+void vce_v1_0_enable_mgcg(struct radeon_device *rdev, bool enable)
+{
+	u32 tmp;
+
+	if (enable && (rdev->cg_flags & RADEON_CG_SUPPORT_VCE_MGCG)) {
+		tmp = RREG32(VCE_CLOCK_GATING_A);
+		tmp |= CGC_DYN_CLOCK_MODE;
+		WREG32(VCE_CLOCK_GATING_A, tmp);
+
+		tmp = RREG32(VCE_UENC_CLOCK_GATING);
+		tmp &= ~0x1ff000;
+		tmp |= 0xff800000;
+		WREG32(VCE_UENC_CLOCK_GATING, tmp);
+
+		tmp = RREG32(VCE_UENC_REG_CLOCK_GATING);
+		tmp &= ~0x3ff;
+		WREG32(VCE_UENC_REG_CLOCK_GATING, tmp);
+	} else {
+		tmp = RREG32(VCE_CLOCK_GATING_A);
+		tmp &= ~CGC_DYN_CLOCK_MODE;
+		WREG32(VCE_CLOCK_GATING_A, tmp);
+
+		tmp = RREG32(VCE_UENC_CLOCK_GATING);
+		tmp |= 0x1ff000;
+		tmp &= ~0xff800000;
+		WREG32(VCE_UENC_CLOCK_GATING, tmp);
+
+		tmp = RREG32(VCE_UENC_REG_CLOCK_GATING);
+		tmp |= 0x3ff;
+		WREG32(VCE_UENC_REG_CLOCK_GATING, tmp);
+	}
+}
+
+static void vce_v1_0_init_cg(struct radeon_device *rdev)
+{
+	u32 tmp;
+
+	tmp = RREG32(VCE_CLOCK_GATING_A);
+	tmp |= CGC_DYN_CLOCK_MODE;
+	WREG32(VCE_CLOCK_GATING_A, tmp);
+
+	tmp = RREG32(VCE_CLOCK_GATING_B);
+	tmp |= 0x1e;
+	tmp &= ~0xe100e1;
+	WREG32(VCE_CLOCK_GATING_B, tmp);
+
+	tmp = RREG32(VCE_UENC_CLOCK_GATING);
+	tmp &= ~0xff9ff000;
+	WREG32(VCE_UENC_CLOCK_GATING, tmp);
+
+	tmp = RREG32(VCE_UENC_REG_CLOCK_GATING);
+	tmp &= ~0x3ff;
+	WREG32(VCE_UENC_REG_CLOCK_GATING, tmp);
+}
+
+int vce_v1_0_load_fw(struct radeon_device *rdev, uint32_t *data)
+{
+	struct vce_v1_0_fw_signature *sign = (void*)rdev->vce_fw->data;
+	uint32_t chip_id;
+	int i;
+
+	switch (rdev->family) {
+	case CHIP_TAHITI:
+		chip_id = 0x01000014;
+		break;
+	case CHIP_VERDE:
+		chip_id = 0x01000015;
+		break;
+	case CHIP_PITCAIRN:
+	case CHIP_OLAND:
+		chip_id = 0x01000016;
+		break;
+	case CHIP_ARUBA:
+		chip_id = 0x01000017;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	for (i = 0; i < le32_to_cpu(sign->num); ++i) {
+		if (le32_to_cpu(sign->val[i].chip_id) == chip_id)
+			break;
+	}
+
+	if (i == le32_to_cpu(sign->num))
+		return -EINVAL;
+
+	data += (256 - 64) / 4;
+	data[0] = sign->val[i].nonce[0];
+	data[1] = sign->val[i].nonce[1];
+	data[2] = sign->val[i].nonce[2];
+	data[3] = sign->val[i].nonce[3];
+	data[4] = cpu_to_le32(le32_to_cpu(sign->len) + 64);
+
+	memset(&data[5], 0, 44);
+	memcpy(&data[16], &sign[1], rdev->vce_fw->size - sizeof(*sign));
+
+	data += (le32_to_cpu(sign->len) + 64) / 4;
+	data[0] = sign->val[i].sigval[0];
+	data[1] = sign->val[i].sigval[1];
+	data[2] = sign->val[i].sigval[2];
+	data[3] = sign->val[i].sigval[3];
+
+	rdev->vce.keyselect = le32_to_cpu(sign->val[i].keyselect);
+
+	return 0;
+}
+
+unsigned vce_v1_0_bo_size(struct radeon_device *rdev)
+{
+	WARN_ON(VCE_V1_0_FW_SIZE < rdev->vce_fw->size);
+	return VCE_V1_0_FW_SIZE + VCE_V1_0_STACK_SIZE + VCE_V1_0_DATA_SIZE;
+}
+
+int vce_v1_0_resume(struct radeon_device *rdev)
+{
+	uint64_t addr = rdev->vce.gpu_addr;
+	uint32_t size;
+	int i;
+
+	WREG32_P(VCE_CLOCK_GATING_A, 0, ~(1 << 16));
+	WREG32_P(VCE_UENC_CLOCK_GATING, 0x1FF000, ~0xFF9FF000);
+	WREG32_P(VCE_UENC_REG_CLOCK_GATING, 0x3F, ~0x3F);
+	WREG32(VCE_CLOCK_GATING_B, 0);
+
+	WREG32_P(VCE_LMI_FW_PERIODIC_CTRL, 0x4, ~0x4);
+
+	WREG32(VCE_LMI_CTRL, 0x00398000);
+	WREG32_P(VCE_LMI_CACHE_CTRL, 0x0, ~0x1);
+	WREG32(VCE_LMI_SWAP_CNTL, 0);
+	WREG32(VCE_LMI_SWAP_CNTL1, 0);
+	WREG32(VCE_LMI_VM_CTRL, 0);
+
+	WREG32(VCE_VCPU_SCRATCH7, RADEON_MAX_VCE_HANDLES);
+
+	addr += 256;
+	size = VCE_V1_0_FW_SIZE;
+	WREG32(VCE_VCPU_CACHE_OFFSET0, addr & 0x7fffffff);
+	WREG32(VCE_VCPU_CACHE_SIZE0, size);
+
+	addr += size;
+	size = VCE_V1_0_STACK_SIZE;
+	WREG32(VCE_VCPU_CACHE_OFFSET1, addr & 0x7fffffff);
+	WREG32(VCE_VCPU_CACHE_SIZE1, size);
+
+	addr += size;
+	size = VCE_V1_0_DATA_SIZE;
+	WREG32(VCE_VCPU_CACHE_OFFSET2, addr & 0x7fffffff);
+	WREG32(VCE_VCPU_CACHE_SIZE2, size);
+
+	WREG32_P(VCE_LMI_CTRL2, 0x0, ~0x100);
+
+	WREG32(VCE_LMI_FW_START_KEYSEL, rdev->vce.keyselect);
+
+	for (i = 0; i < 10; ++i) {
+		mdelay(10);
+		if (RREG32(VCE_FW_REG_STATUS) & VCE_FW_REG_STATUS_DONE)
+			break;
+	}
+
+	if (i == 10)
+		return -ETIMEDOUT;
+
+	if (!(RREG32(VCE_FW_REG_STATUS) & VCE_FW_REG_STATUS_PASS))
+		return -EINVAL;
+
+	for (i = 0; i < 10; ++i) {
+		mdelay(10);
+		if (!(RREG32(VCE_FW_REG_STATUS) & VCE_FW_REG_STATUS_BUSY))
+			break;
+	}
+
+	if (i == 10)
+		return -ETIMEDOUT;
+
+	vce_v1_0_init_cg(rdev);
+
+	return 0;
+}
+
+/**
+ * vce_v1_0_start - start VCE block
+ *
+ * @rdev: radeon_device pointer
+ *
+ * Setup and start the VCE block
+ */
+int vce_v1_0_start(struct radeon_device *rdev)
+{
+	struct radeon_ring *ring;
+	int i, j, r;
+
+	/* set BUSY flag */
+	WREG32_P(VCE_STATUS, 1, ~1);
+
+	ring = &rdev->ring[TN_RING_TYPE_VCE1_INDEX];
+	WREG32(VCE_RB_RPTR, ring->wptr);
+	WREG32(VCE_RB_WPTR, ring->wptr);
+	WREG32(VCE_RB_BASE_LO, ring->gpu_addr);
+	WREG32(VCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
+	WREG32(VCE_RB_SIZE, ring->ring_size / 4);
+
+	ring = &rdev->ring[TN_RING_TYPE_VCE2_INDEX];
+	WREG32(VCE_RB_RPTR2, ring->wptr);
+	WREG32(VCE_RB_WPTR2, ring->wptr);
+	WREG32(VCE_RB_BASE_LO2, ring->gpu_addr);
+	WREG32(VCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
+	WREG32(VCE_RB_SIZE2, ring->ring_size / 4);
+
+	WREG32_P(VCE_VCPU_CNTL, VCE_CLK_EN, ~VCE_CLK_EN);
+
+	WREG32_P(VCE_SOFT_RESET,
+		 VCE_ECPU_SOFT_RESET |
+		 VCE_FME_SOFT_RESET, ~(
+		 VCE_ECPU_SOFT_RESET |
+		 VCE_FME_SOFT_RESET));
+
+	mdelay(100);
+
+	WREG32_P(VCE_SOFT_RESET, 0, ~(
+		 VCE_ECPU_SOFT_RESET |
+		 VCE_FME_SOFT_RESET));
+
+	for (i = 0; i < 10; ++i) {
+		uint32_t status;
+		for (j = 0; j < 100; ++j) {
+			status = RREG32(VCE_STATUS);
+			if (status & 2)
+				break;
+			mdelay(10);
+		}
+		r = 0;
+		if (status & 2)
+			break;
+
+		DRM_ERROR("VCE not responding, trying to reset the ECPU!!!\n");
+		WREG32_P(VCE_SOFT_RESET, VCE_ECPU_SOFT_RESET, ~VCE_ECPU_SOFT_RESET);
+		mdelay(10);
+		WREG32_P(VCE_SOFT_RESET, 0, ~VCE_ECPU_SOFT_RESET);
+		mdelay(10);
+		r = -1;
+	}
+
+	/* clear BUSY flag */
+	WREG32_P(VCE_STATUS, 0, ~1);
+
+	if (r) {
+		DRM_ERROR("VCE not responding, giving up!!!\n");
+		return r;
+	}
+
+	return 0;
+}
+
+int vce_v1_0_init(struct radeon_device *rdev)
+{
+	struct radeon_ring *ring;
+	int r;
+
+	r = vce_v1_0_start(rdev);
+	if (r)
+		return r;
+
+	ring = &rdev->ring[TN_RING_TYPE_VCE1_INDEX];
+	ring->ready = true;
+	r = radeon_ring_test(rdev, TN_RING_TYPE_VCE1_INDEX, ring);
+	if (r) {
+		ring->ready = false;
+		return r;
+	}
+
+	ring = &rdev->ring[TN_RING_TYPE_VCE2_INDEX];
+	ring->ready = true;
+	r = radeon_ring_test(rdev, TN_RING_TYPE_VCE2_INDEX, ring);
+	if (r) {
+		ring->ready = false;
+		return r;
+	}
+
+	DRM_INFO("VCE initialized successfully.\n");
+
+	return 0;
+}
drivers/gpu/drm/amd/amdgpu/vce_v1_0.h new file +29 -0
new file mode 100644
index 000000000000..4ba591897515
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2014 Advanced Micro Devices, Inc.
+ *
+ * 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, sublicense,
+ * 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 above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * 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 NONINFRINGEMENT.  IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ */
+
+#ifndef __VCE_V1_0_H__
+#define __VCE_V1_0_H__
+
+extern const struct amdgpu_ip_block_version vce_v1_0_ip_block;
+
+#endif
Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20170908024835.13638-2-alexandre.f.demers-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#4 lore raw

RE: [PATCH 1/6] Add initial VCE_V1_0 files.

Quoted 8 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Alexandre Demers
Sent: Thursday, September 07, 2017 10:49 PM
To: [email protected]
Subject: [PATCH 1/6] Add initial VCE_V1_0 files.

I'd suggest squashing patches 1 and 4 together and moving them after the register header changes.

Alex

Quoted 459 lines
---
 drivers/gpu/drm/amd/amdgpu/vce_v1_0.c | 384
++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/vce_v1_0.h |  29 +++
 2 files changed, 413 insertions(+)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.h
drivers/gpu/drm/amd/amdgpu/vce_v1_0.c new file +13 -0
new file mode 100644
index 000000000000..f541a4b5ac51
@@ -0,0 +1,384 @@
+/*
+ * Copyright 2013 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.
+ *
+ * Authors: Christian König <[email protected]>
+ */

drivers/gpu/drm/amd/amdgpu/vce_v1_0.c new file +10 -0
+
+#include <linux/firmware.h>
+#include <drm/drmP.h>
+#include "radeon.h"
+#include "radeon_asic.h"
+#include "sid.h"
+
+#define VCE_V1_0_FW_SIZE	(256 * 1024)
+#define VCE_V1_0_STACK_SIZE	(64 * 1024)
+#define VCE_V1_0_DATA_SIZE	(7808 *

(RADEON_MAX_VCE_HANDLES + 1))

drivers/gpu/drm/amd/amdgpu/vce_v1_0.c new file +70 -0
+
+struct vce_v1_0_fw_signature
+{
+	int32_t off;
+	uint32_t len;
+	int32_t num;
+	struct {
+		uint32_t chip_id;
+		uint32_t keyselect;
+		uint32_t nonce[4];
+		uint32_t sigval[4];
+	} val[8];
+};
+
+/**
+ * vce_v1_0_get_rptr - get read pointer
+ *
+ * @rdev: radeon_device pointer
+ * @ring: radeon_ring pointer
+ *
+ * Returns the current hardware read pointer
+ */
+uint32_t vce_v1_0_get_rptr(struct radeon_device *rdev,
+			   struct radeon_ring *ring)
+{
+	if (ring->idx == TN_RING_TYPE_VCE1_INDEX)
+		return RREG32(VCE_RB_RPTR);
+	else
+		return RREG32(VCE_RB_RPTR2);
+}
+
+/**
+ * vce_v1_0_get_wptr - get write pointer
+ *
+ * @rdev: radeon_device pointer
+ * @ring: radeon_ring pointer
+ *
+ * Returns the current hardware write pointer
+ */
+uint32_t vce_v1_0_get_wptr(struct radeon_device *rdev,
+			   struct radeon_ring *ring)
+{
+	if (ring->idx == TN_RING_TYPE_VCE1_INDEX)
+		return RREG32(VCE_RB_WPTR);
+	else
+		return RREG32(VCE_RB_WPTR2);
+}
+
+/**
+ * vce_v1_0_set_wptr - set write pointer
+ *
+ * @rdev: radeon_device pointer
+ * @ring: radeon_ring pointer
+ *
+ * Commits the write pointer to the hardware
+ */
+void vce_v1_0_set_wptr(struct radeon_device *rdev,
+		       struct radeon_ring *ring)
+{
+	if (ring->idx == TN_RING_TYPE_VCE1_INDEX)
+		WREG32(VCE_RB_WPTR, ring->wptr);
+	else
+		WREG32(VCE_RB_WPTR2, ring->wptr);
+}
+
+void vce_v1_0_enable_mgcg(struct radeon_device *rdev, bool enable)
+{
+	u32 tmp;
+
+	if (enable && (rdev->cg_flags &

RADEON_CG_SUPPORT_VCE_MGCG)) {

drivers/gpu/drm/amd/amdgpu/vce_v1_0.c new file +107 -0
+		tmp = RREG32(VCE_CLOCK_GATING_A);
+		tmp |= CGC_DYN_CLOCK_MODE;
+		WREG32(VCE_CLOCK_GATING_A, tmp);
+
+		tmp = RREG32(VCE_UENC_CLOCK_GATING);
+		tmp &= ~0x1ff000;
+		tmp |= 0xff800000;
+		WREG32(VCE_UENC_CLOCK_GATING, tmp);
+
+		tmp = RREG32(VCE_UENC_REG_CLOCK_GATING);
+		tmp &= ~0x3ff;
+		WREG32(VCE_UENC_REG_CLOCK_GATING, tmp);
+	} else {
+		tmp = RREG32(VCE_CLOCK_GATING_A);
+		tmp &= ~CGC_DYN_CLOCK_MODE;
+		WREG32(VCE_CLOCK_GATING_A, tmp);
+
+		tmp = RREG32(VCE_UENC_CLOCK_GATING);
+		tmp |= 0x1ff000;
+		tmp &= ~0xff800000;
+		WREG32(VCE_UENC_CLOCK_GATING, tmp);
+
+		tmp = RREG32(VCE_UENC_REG_CLOCK_GATING);
+		tmp |= 0x3ff;
+		WREG32(VCE_UENC_REG_CLOCK_GATING, tmp);
+	}
+}
+
+static void vce_v1_0_init_cg(struct radeon_device *rdev)
+{
+	u32 tmp;
+
+	tmp = RREG32(VCE_CLOCK_GATING_A);
+	tmp |= CGC_DYN_CLOCK_MODE;
+	WREG32(VCE_CLOCK_GATING_A, tmp);
+
+	tmp = RREG32(VCE_CLOCK_GATING_B);
+	tmp |= 0x1e;
+	tmp &= ~0xe100e1;
+	WREG32(VCE_CLOCK_GATING_B, tmp);
+
+	tmp = RREG32(VCE_UENC_CLOCK_GATING);
+	tmp &= ~0xff9ff000;
+	WREG32(VCE_UENC_CLOCK_GATING, tmp);
+
+	tmp = RREG32(VCE_UENC_REG_CLOCK_GATING);
+	tmp &= ~0x3ff;
+	WREG32(VCE_UENC_REG_CLOCK_GATING, tmp);
+}
+
+int vce_v1_0_load_fw(struct radeon_device *rdev, uint32_t *data)
+{
+	struct vce_v1_0_fw_signature *sign = (void*)rdev->vce_fw->data;
+	uint32_t chip_id;
+	int i;
+
+	switch (rdev->family) {
+	case CHIP_TAHITI:
+		chip_id = 0x01000014;
+		break;
+	case CHIP_VERDE:
+		chip_id = 0x01000015;
+		break;
+	case CHIP_PITCAIRN:
+	case CHIP_OLAND:
+		chip_id = 0x01000016;
+		break;
+	case CHIP_ARUBA:
+		chip_id = 0x01000017;
+		break;
+	default:
+		return -EINVAL;
+	}
+
+	for (i = 0; i < le32_to_cpu(sign->num); ++i) {
+		if (le32_to_cpu(sign->val[i].chip_id) == chip_id)
+			break;
+	}
+
+	if (i == le32_to_cpu(sign->num))
+		return -EINVAL;
+
+	data += (256 - 64) / 4;
+	data[0] = sign->val[i].nonce[0];
+	data[1] = sign->val[i].nonce[1];
+	data[2] = sign->val[i].nonce[2];
+	data[3] = sign->val[i].nonce[3];
+	data[4] = cpu_to_le32(le32_to_cpu(sign->len) + 64);
+
+	memset(&data[5], 0, 44);
+	memcpy(&data[16], &sign[1], rdev->vce_fw->size - sizeof(*sign));
+
+	data += (le32_to_cpu(sign->len) + 64) / 4;
+	data[0] = sign->val[i].sigval[0];
+	data[1] = sign->val[i].sigval[1];
+	data[2] = sign->val[i].sigval[2];
+	data[3] = sign->val[i].sigval[3];
+
+	rdev->vce.keyselect = le32_to_cpu(sign->val[i].keyselect);
+
+	return 0;
+}
+
+unsigned vce_v1_0_bo_size(struct radeon_device *rdev)
+{
+	WARN_ON(VCE_V1_0_FW_SIZE < rdev->vce_fw->size);
+	return VCE_V1_0_FW_SIZE + VCE_V1_0_STACK_SIZE +

VCE_V1_0_DATA_SIZE;

drivers/gpu/drm/amd/amdgpu/vce_v1_0.c new file +45 -0
+}
+
+int vce_v1_0_resume(struct radeon_device *rdev)
+{
+	uint64_t addr = rdev->vce.gpu_addr;
+	uint32_t size;
+	int i;
+
+	WREG32_P(VCE_CLOCK_GATING_A, 0, ~(1 << 16));
+	WREG32_P(VCE_UENC_CLOCK_GATING, 0x1FF000, ~0xFF9FF000);
+	WREG32_P(VCE_UENC_REG_CLOCK_GATING, 0x3F, ~0x3F);
+	WREG32(VCE_CLOCK_GATING_B, 0);
+
+	WREG32_P(VCE_LMI_FW_PERIODIC_CTRL, 0x4, ~0x4);
+
+	WREG32(VCE_LMI_CTRL, 0x00398000);
+	WREG32_P(VCE_LMI_CACHE_CTRL, 0x0, ~0x1);
+	WREG32(VCE_LMI_SWAP_CNTL, 0);
+	WREG32(VCE_LMI_SWAP_CNTL1, 0);
+	WREG32(VCE_LMI_VM_CTRL, 0);
+
+	WREG32(VCE_VCPU_SCRATCH7, RADEON_MAX_VCE_HANDLES);
+
+	addr += 256;
+	size = VCE_V1_0_FW_SIZE;
+	WREG32(VCE_VCPU_CACHE_OFFSET0, addr & 0x7fffffff);
+	WREG32(VCE_VCPU_CACHE_SIZE0, size);
+
+	addr += size;
+	size = VCE_V1_0_STACK_SIZE;
+	WREG32(VCE_VCPU_CACHE_OFFSET1, addr & 0x7fffffff);
+	WREG32(VCE_VCPU_CACHE_SIZE1, size);
+
+	addr += size;
+	size = VCE_V1_0_DATA_SIZE;
+	WREG32(VCE_VCPU_CACHE_OFFSET2, addr & 0x7fffffff);
+	WREG32(VCE_VCPU_CACHE_SIZE2, size);
+
+	WREG32_P(VCE_LMI_CTRL2, 0x0, ~0x100);
+
+	WREG32(VCE_LMI_FW_START_KEYSEL, rdev->vce.keyselect);
+
+	for (i = 0; i < 10; ++i) {
+		mdelay(10);
+		if (RREG32(VCE_FW_REG_STATUS) &

VCE_FW_REG_STATUS_DONE)

drivers/gpu/drm/amd/amdgpu/vce_v1_0.c new file +7 -0
+			break;
+	}
+
+	if (i == 10)
+		return -ETIMEDOUT;
+
+	if (!(RREG32(VCE_FW_REG_STATUS) &

VCE_FW_REG_STATUS_PASS))

drivers/gpu/drm/amd/amdgpu/vce_v1_0.c new file +5 -0
+		return -EINVAL;
+
+	for (i = 0; i < 10; ++i) {
+		mdelay(10);
+		if (!(RREG32(VCE_FW_REG_STATUS) &

VCE_FW_REG_STATUS_BUSY))

drivers/gpu/drm/amd/amdgpu/vce_v1_0.c new file +67 -0
+			break;
+	}
+
+	if (i == 10)
+		return -ETIMEDOUT;
+
+	vce_v1_0_init_cg(rdev);
+
+	return 0;
+}
+
+/**
+ * vce_v1_0_start - start VCE block
+ *
+ * @rdev: radeon_device pointer
+ *
+ * Setup and start the VCE block
+ */
+int vce_v1_0_start(struct radeon_device *rdev)
+{
+	struct radeon_ring *ring;
+	int i, j, r;
+
+	/* set BUSY flag */
+	WREG32_P(VCE_STATUS, 1, ~1);
+
+	ring = &rdev->ring[TN_RING_TYPE_VCE1_INDEX];
+	WREG32(VCE_RB_RPTR, ring->wptr);
+	WREG32(VCE_RB_WPTR, ring->wptr);
+	WREG32(VCE_RB_BASE_LO, ring->gpu_addr);
+	WREG32(VCE_RB_BASE_HI, upper_32_bits(ring->gpu_addr));
+	WREG32(VCE_RB_SIZE, ring->ring_size / 4);
+
+	ring = &rdev->ring[TN_RING_TYPE_VCE2_INDEX];
+	WREG32(VCE_RB_RPTR2, ring->wptr);
+	WREG32(VCE_RB_WPTR2, ring->wptr);
+	WREG32(VCE_RB_BASE_LO2, ring->gpu_addr);
+	WREG32(VCE_RB_BASE_HI2, upper_32_bits(ring->gpu_addr));
+	WREG32(VCE_RB_SIZE2, ring->ring_size / 4);
+
+	WREG32_P(VCE_VCPU_CNTL, VCE_CLK_EN, ~VCE_CLK_EN);
+
+	WREG32_P(VCE_SOFT_RESET,
+		 VCE_ECPU_SOFT_RESET |
+		 VCE_FME_SOFT_RESET, ~(
+		 VCE_ECPU_SOFT_RESET |
+		 VCE_FME_SOFT_RESET));
+
+	mdelay(100);
+
+	WREG32_P(VCE_SOFT_RESET, 0, ~(
+		 VCE_ECPU_SOFT_RESET |
+		 VCE_FME_SOFT_RESET));
+
+	for (i = 0; i < 10; ++i) {
+		uint32_t status;
+		for (j = 0; j < 100; ++j) {
+			status = RREG32(VCE_STATUS);
+			if (status & 2)
+				break;
+			mdelay(10);
+		}
+		r = 0;
+		if (status & 2)
+			break;
+
+		DRM_ERROR("VCE not responding, trying to reset the

ECPU!!!\n");

drivers/gpu/drm/amd/amdgpu/vce_v1_0.c new file +1 -0
+		WREG32_P(VCE_SOFT_RESET, VCE_ECPU_SOFT_RESET,

~VCE_ECPU_SOFT_RESET);

drivers/gpu/drm/amd/amdgpu/vce_v1_0.c new file +46 -0
+		mdelay(10);
+		WREG32_P(VCE_SOFT_RESET, 0, ~VCE_ECPU_SOFT_RESET);
+		mdelay(10);
+		r = -1;
+	}
+
+	/* clear BUSY flag */
+	WREG32_P(VCE_STATUS, 0, ~1);
+
+	if (r) {
+		DRM_ERROR("VCE not responding, giving up!!!\n");
+		return r;
+	}
+
+	return 0;
+}
+
+int vce_v1_0_init(struct radeon_device *rdev)
+{
+	struct radeon_ring *ring;
+	int r;
+
+	r = vce_v1_0_start(rdev);
+	if (r)
+		return r;
+
+	ring = &rdev->ring[TN_RING_TYPE_VCE1_INDEX];
+	ring->ready = true;
+	r = radeon_ring_test(rdev, TN_RING_TYPE_VCE1_INDEX, ring);
+	if (r) {
+		ring->ready = false;
+		return r;
+	}
+
+	ring = &rdev->ring[TN_RING_TYPE_VCE2_INDEX];
+	ring->ready = true;
+	r = radeon_ring_test(rdev, TN_RING_TYPE_VCE2_INDEX, ring);
+	if (r) {
+		ring->ready = false;
+		return r;
+	}
+
+	DRM_INFO("VCE initialized successfully.\n");
+
+	return 0;
+}
drivers/gpu/drm/amd/amdgpu/vce_v1_0.h new file +5 -0
new file mode 100644
index 000000000000..4ba591897515
@@ -0,0 +1,29 @@
+/*
+ * Copyright 2014 Advanced Micro Devices, Inc.
+ *
+ * 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, sublicense,
+ * 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 above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * 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 NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) 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.
+ *
+ */

drivers/gpu/drm/amd/amdgpu/vce_v1_0.h new file +7 -1
+
+#ifndef __VCE_V1_0_H__
+#define __VCE_V1_0_H__
+
+extern const struct amdgpu_ip_block_version vce_v1_0_ip_block;
+
+#endif
--

2.14.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#5 lore raw

PATCH 2/6 Reorganize, rename, move and split some VCE 1 defines.

In reply to a message not in the archive

For consistency with other files under amdgpu driver.

---
 drivers/gpu/drm/amd/amdgpu/si.c                    | 15 +++-
 drivers/gpu/drm/amd/amdgpu/si_dma.c                |  5 +-
 drivers/gpu/drm/amd/amdgpu/si_ih.c                 | 21 +++---
 drivers/gpu/drm/amd/amdgpu/sid.h                   | 70 -------------------
 .../gpu/drm/amd/include/asic_reg/vce/vce_1_0_d.h   | 80 +++++++++++++---------
 .../drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h | 13 +++-
 6 files changed, 89 insertions(+), 115 deletions(-)
drivers/gpu/drm/amd/amdgpu/si.c +13 -2
index c0b1aabf282f..08998639daeb 100644
@@ -38,15 +38,26 @@
 #include "gmc_v6_0.h"
 #include "si_dma.h"
 #include "dce_v6_0.h"
+#include "vce_v1_0.h"
 #include "si.h"
 #include "dce_virtual.h"
+
 #include "gca/gfx_6_0_d.h"
-#include "oss/oss_1_0_d.h"
+
 #include "gmc/gmc_6_0_d.h"
+
 #include "dce/dce_6_0_d.h"
-#include "uvd/uvd_4_0_d.h"
+
 #include "bif/bif_3_0_d.h"
 
+#include "oss/oss_1_0_d.h"
+#include "oss/oss_1_0_sh_mask.h"
+
+#include "uvd/uvd_4_0_d.h"
+
+#include "smu/smu_7_0_1_d.h"
+#include "smu/smu_7_0_1_sh_mask.h"
+
 static const u32 tahiti_golden_registers[] =
 {
 	mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011,
drivers/gpu/drm/amd/amdgpu/si_dma.c +4 -1
index 112969f3301a..fd50ab9933c7 100644
@@ -26,6 +26,9 @@
 #include "amdgpu_trace.h"
 #include "sid.h"
 
+#include "oss/oss_1_0_d.h"
+#include "oss/oss_1_0_sh_mask.h"
+
 const u32 sdma_offsets[SDMA_MAX_INSTANCE] =
 {
 	DMA0_REGISTER_OFFSET,
@@ -587,7 +590,7 @@ static int si_dma_resume(void *handle)
 static bool si_dma_is_idle(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	u32 tmp = RREG32(SRBM_STATUS2);
+	u32 tmp = RREG32(mmSRBM_STATUS2);
 
 	if (tmp & (DMA_BUSY_MASK | DMA1_BUSY_MASK))
 	    return false;
drivers/gpu/drm/amd/amdgpu/si_ih.c +12 -9
index e66084211c74..8fb9d00beea8 100644
@@ -26,6 +26,9 @@
 #include "sid.h"
 #include "si_ih.h"
 
+#include "oss/oss_1_0_d.h"
+#include "oss/oss_1_0_sh_mask.h"
+
 static void si_ih_set_interrupt_funcs(struct amdgpu_device *adev);
 
 static void si_ih_enable_interrupts(struct amdgpu_device *adev)
@@ -39,7 +42,7 @@ static void si_ih_enable_interrupts(struct amdgpu_device *adev)
 	WREG32(IH_RB_CNTL, ih_rb_cntl);
 	adev->irq.ih.enabled = true;
 }
-  
+
 static void si_ih_disable_interrupts(struct amdgpu_device *adev)
 {
 	u32 ih_rb_cntl = RREG32(IH_RB_CNTL);
@@ -207,7 +210,7 @@ static int si_ih_resume(void *handle)
 static bool si_ih_is_idle(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	u32 tmp = RREG32(SRBM_STATUS);
+	u32 tmp = RREG32(mmSRBM_STATUS);
 
 	if (tmp & SRBM_STATUS__IH_BUSY_MASK)
 		return false;
@@ -233,23 +236,23 @@ static int si_ih_soft_reset(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
 	u32 srbm_soft_reset = 0;
-	u32 tmp = RREG32(SRBM_STATUS);
+	u32 tmp = RREG32(mmSRBM_STATUS);
 
 	if (tmp & SRBM_STATUS__IH_BUSY_MASK)
 		srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_IH_MASK;
 
 	if (srbm_soft_reset) {
-		tmp = RREG32(SRBM_SOFT_RESET);
+		tmp = RREG32(mmSRBM_SOFT_RESET);
 		tmp |= srbm_soft_reset;
-		dev_info(adev->dev, "SRBM_SOFT_RESET=0x%08X\n", tmp);
-		WREG32(SRBM_SOFT_RESET, tmp);
-		tmp = RREG32(SRBM_SOFT_RESET);
+		dev_info(adev->dev, "mmSRBM_SOFT_RESET=0x%08X\n", tmp);
+		WREG32(mmSRBM_SOFT_RESET, tmp);
+		tmp = RREG32(mmSRBM_SOFT_RESET);
 
 		udelay(50);
 
 		tmp &= ~srbm_soft_reset;
-		WREG32(SRBM_SOFT_RESET, tmp);
-		tmp = RREG32(SRBM_SOFT_RESET);
+		WREG32(mmSRBM_SOFT_RESET, tmp);
+		tmp = RREG32(mmSRBM_SOFT_RESET);
 
 		udelay(50);
 	}
drivers/gpu/drm/amd/amdgpu/sid.h +0 -70

112 lines not on this page · raw message

drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_d.h +48 -32

90 lines not on this page · raw message

drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h +12 -1
index ea5b26b11cb1..0653a4e1d59f 100644
@@ -23,6 +23,17 @@
 #ifndef VCE_1_0_SH_MASK_H
 #define VCE_1_0_SH_MASK_H
 
+/* Imported from sid.h or cleaned up */
+#define VCE_CLK_EN				(1 << 0)
+#define VCE_ECPU_SOFT_RESET			(1 << 0)
+#define VCE_FME_SOFT_RESET			(1 << 2)
+#define CGC_DYN_CLOCK_MODE			(1 << 16)
+#define VCE_FW_REG_STATUS_BUSY			(1 << 0)
+#define VCE_FW_REG_STATUS_PASS			(1 << 3)
+#define VCE_FW_REG_STATUS_DONE			(1 << 11)
+
+
+
 #define VCE_LMI_CACHE_CTRL__VCPU_EN_MASK 0x00000001L
 #define VCE_LMI_CACHE_CTRL__VCPU_EN__SHIFT 0x00000000
 #define VCE_LMI_CTRL2__STALL_ARB_UMC_MASK 0x00000100L
@@ -96,4 +107,4 @@
 #define VCE_VCPU_CNTL__RBBM_SOFT_RESET_MASK 0x00040000L
 #define VCE_VCPU_CNTL__RBBM_SOFT_RESET__SHIFT 0x00000012
 
-#endif
+#endif /* VCE_1_0_SH_MASK_H */
Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): 20170908024835.13638-3-alexandre.f.demers-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#7 lore raw

RE: [PATCH 2/6] Reorganize, rename, move and split some VCE 1 defines.

Quoted 42 lines

-----Original Message-----
From: amd-gfx [mailto:[email protected]] On Behalf Of Alexandre Demers
Sent: Thursday, September 07, 2017 10:49 PM
To: [email protected]
Subject: [PATCH 2/6] Reorganize, rename, move and split some VCE 1 defines.

For consistency with other files under amdgpu driver.

---
 drivers/gpu/drm/amd/amdgpu/si.c                    | 15 +++-
 drivers/gpu/drm/amd/amdgpu/si_dma.c                |  5 +-
 drivers/gpu/drm/amd/amdgpu/si_ih.c                 | 21 +++---
 drivers/gpu/drm/amd/amdgpu/sid.h                   | 70 -------------------
 .../gpu/drm/amd/include/asic_reg/vce/vce_1_0_d.h   | 80
+++++++++++++---------
 .../drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h | 13 +++-
 6 files changed, 89 insertions(+), 115 deletions(-)
drivers/gpu/drm/amd/amdgpu/si.c +5 -2
index c0b1aabf282f..08998639daeb 100644
@@ -38,15 +38,26 @@
 #include "gmc_v6_0.h"
 #include "si_dma.h"
 #include "dce_v6_0.h"
+#include "vce_v1_0.h"
 #include "si.h"
 #include "dce_virtual.h"
+
 #include "gca/gfx_6_0_d.h"
-#include "oss/oss_1_0_d.h"
+
 #include "gmc/gmc_6_0_d.h"
+
 #include "dce/dce_6_0_d.h"
-#include "uvd/uvd_4_0_d.h"
+

drivers/gpu/drm/amd/amdgpu/si.c line 60

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/si.c +8 -0
 #include "bif/bif_3_0_d.h"
 
+#include "oss/oss_1_0_d.h"
+#include "oss/oss_1_0_sh_mask.h"
+
+#include "uvd/uvd_4_0_d.h"
+
+#include "smu/smu_7_0_1_d.h"
+#include "smu/smu_7_0_1_sh_mask.h"
+

I'm not sure I understand the point of the changes to this file.

Quoted 19 lines
drivers/gpu/drm/amd/amdgpu/si.c +0 -0
 static const u32 tahiti_golden_registers[] =
 {
 	mmAZALIA_SCLK_CONTROL, 0x00000030, 0x00000011,
drivers/gpu/drm/amd/amdgpu/si_dma.c +3 -0
index 112969f3301a..fd50ab9933c7 100644
@@ -26,6 +26,9 @@
 #include "amdgpu_trace.h"
 #include "sid.h"
 
+#include "oss/oss_1_0_d.h"
+#include "oss/oss_1_0_sh_mask.h"
+
 const u32 sdma_offsets[SDMA_MAX_INSTANCE] =
 {
 	DMA0_REGISTER_OFFSET,

drivers/gpu/drm/amd/amdgpu/si_dma.c static int si_dma_resume(void *handle) · line 596

Quoted 8 lines
drivers/gpu/drm/amd/amdgpu/si_dma.c +1 -1
@@ -587,7 +590,7 @@ static int si_dma_resume(void *handle)
 static bool si_dma_is_idle(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	u32 tmp = RREG32(SRBM_STATUS2);
+	u32 tmp = RREG32(mmSRBM_STATUS2);
 
 	if (tmp & (DMA_BUSY_MASK | DMA1_BUSY_MASK))
 	    return false;

This should be a separate patch.

Quoted 65 lines
drivers/gpu/drm/amd/amdgpu/si_ih.c +4 -1
index e66084211c74..8fb9d00beea8 100644
@@ -26,6 +26,9 @@
 #include "sid.h"
 #include "si_ih.h"
 
+#include "oss/oss_1_0_d.h"
+#include "oss/oss_1_0_sh_mask.h"
+
 static void si_ih_set_interrupt_funcs(struct amdgpu_device *adev);
 
 static void si_ih_enable_interrupts(struct amdgpu_device *adev)
@@ -39,7 +42,7 @@ static void si_ih_enable_interrupts(struct
 amdgpu_device *adev)
 	WREG32(IH_RB_CNTL, ih_rb_cntl);
 	adev->irq.ih.enabled = true;
 }
-
+
 static void si_ih_disable_interrupts(struct amdgpu_device *adev)
 {
drivers/gpu/drm/amd/amdgpu/si_ih.c +8 -8
 	u32 ih_rb_cntl = RREG32(IH_RB_CNTL);
@@ -207,7 +210,7 @@ static int si_ih_resume(void *handle)
 static bool si_ih_is_idle(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-	u32 tmp = RREG32(SRBM_STATUS);
+	u32 tmp = RREG32(mmSRBM_STATUS);
 
 	if (tmp & SRBM_STATUS__IH_BUSY_MASK)
 		return false;
@@ -233,23 +236,23 @@ static int si_ih_soft_reset(void *handle)
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
 
 	u32 srbm_soft_reset = 0;
-	u32 tmp = RREG32(SRBM_STATUS);
+	u32 tmp = RREG32(mmSRBM_STATUS);
 
 	if (tmp & SRBM_STATUS__IH_BUSY_MASK)
 		srbm_soft_reset |=
 SRBM_SOFT_RESET__SOFT_RESET_IH_MASK;
 
 	if (srbm_soft_reset) {
-		tmp = RREG32(SRBM_SOFT_RESET);
+		tmp = RREG32(mmSRBM_SOFT_RESET);
 		tmp |= srbm_soft_reset;
-		dev_info(adev->dev, "SRBM_SOFT_RESET=0x%08X\n", tmp);
-		WREG32(SRBM_SOFT_RESET, tmp);
-		tmp = RREG32(SRBM_SOFT_RESET);
+		dev_info(adev->dev, "mmSRBM_SOFT_RESET=0x%08X\n",
 tmp);
+		WREG32(mmSRBM_SOFT_RESET, tmp);
+		tmp = RREG32(mmSRBM_SOFT_RESET);
 
 		udelay(50);
 
 		tmp &= ~srbm_soft_reset;
-		WREG32(SRBM_SOFT_RESET, tmp);
-		tmp = RREG32(SRBM_SOFT_RESET);
+		WREG32(mmSRBM_SOFT_RESET, tmp);
+		tmp = RREG32(mmSRBM_SOFT_RESET);
 

drivers/gpu/drm/amd/amdgpu/si_ih.c

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/si_ih.c +0 -0
 		udelay(50);
 	}

Same here.

Quoted 157 lines
drivers/gpu/drm/amd/amdgpu/sid.h +0 -2
index c57eff159374..279d183f06c1 100644
@@ -331,7 +331,6 @@
 #       define DMIF_BUFFERS_ALLOCATED(x)                  ((x) << 0)
 #       define DMIF_BUFFERS_ALLOCATED_COMPLETED           (1 << 4)
 
-#define	SRBM_STATUS				        0x394
 #define		GRBM_RQ_PENDING 			(1 << 5)
 #define		VMC_BUSY 				(1 << 8)
 #define		MCB_BUSY 				(1 << 9)
@@ -341,7 +340,6 @@
 #define		SEM_BUSY 				(1 << 14)
 #define		IH_BUSY 				(1 << 17)
 
-#define	SRBM_SOFT_RESET				        0x398
 #define		SOFT_RESET_BIF				(1 <<
 1)
 #define		SOFT_RESET_DC				(1 <<

5)
#define SOFT_RESET_DMA1 (1 <<
6)

drivers/gpu/drm/amd/amdgpu/sid.h +0 -49
@@ -364,7 +362,6 @@
 #define SRBM_INT_CNTL					0x3A8
 #define SRBM_INT_ACK					0x3AA
 
-#define	SRBM_STATUS2				        0x3B1
 #define		DMA_BUSY 				(1 << 5)
 #define		DMA1_BUSY 				(1 << 6)
 
@@ -1941,54 +1938,6 @@
 #define	DMA_PACKET_POLL_REG_MEM
 	  0xe
 #define	DMA_PACKET_NOP					  0xf
 
-#define VCE_STATUS					0x20004
-#define VCE_VCPU_CNTL					0x20014
-#define		VCE_CLK_EN				(1 << 0)
-#define VCE_VCPU_CACHE_OFFSET0				0x20024
-#define VCE_VCPU_CACHE_SIZE0				0x20028
-#define VCE_VCPU_CACHE_OFFSET1				0x2002c
-#define VCE_VCPU_CACHE_SIZE1				0x20030
-#define VCE_VCPU_CACHE_OFFSET2				0x20034
-#define VCE_VCPU_CACHE_SIZE2				0x20038
-#define VCE_SOFT_RESET					0x20120
-#define 	VCE_ECPU_SOFT_RESET			(1 << 0)
-#define 	VCE_FME_SOFT_RESET			(1 << 2)
-#define VCE_RB_BASE_LO2					0x2016c
-#define VCE_RB_BASE_HI2					0x20170
-#define VCE_RB_SIZE2					0x20174
-#define VCE_RB_RPTR2					0x20178
-#define VCE_RB_WPTR2					0x2017c
-#define VCE_RB_BASE_LO					0x20180
-#define VCE_RB_BASE_HI					0x20184
-#define VCE_RB_SIZE					0x20188
-#define VCE_RB_RPTR					0x2018c
-#define VCE_RB_WPTR					0x20190
-#define VCE_CLOCK_GATING_A				0x202f8
-#define VCE_CLOCK_GATING_B				0x202fc
-#define VCE_UENC_CLOCK_GATING				0x205bc
-#define VCE_UENC_REG_CLOCK_GATING			0x205c0
-#define VCE_FW_REG_STATUS				0x20e10
-#	define VCE_FW_REG_STATUS_BUSY			(1 << 0)
-#	define VCE_FW_REG_STATUS_PASS			(1 << 3)
-#	define VCE_FW_REG_STATUS_DONE			(1 << 11)
-#define VCE_LMI_FW_START_KEYSEL				0x20e18
-#define VCE_LMI_FW_PERIODIC_CTRL			0x20e20
-#define VCE_LMI_CTRL2					0x20e74
-#define VCE_LMI_CTRL					0x20e98
-#define VCE_LMI_VM_CTRL					0x20ea0
-#define VCE_LMI_SWAP_CNTL				0x20eb4
-#define VCE_LMI_SWAP_CNTL1				0x20eb8
-#define VCE_LMI_CACHE_CTRL				0x20ef4
-
-#define VCE_CMD_NO_OP					0x00000000
-#define VCE_CMD_END					0x00000001
-#define VCE_CMD_IB					0x00000002
-#define VCE_CMD_FENCE					0x00000003
-#define VCE_CMD_TRAP					0x00000004
-#define VCE_CMD_IB_AUTO					0x00000005
-#define VCE_CMD_SEMAPHORE				0x00000006
-
-
 //#dce stupp
 /* display controller offsets used for crtc/cur/lut/grph/viewport/etc. */

#define SI_CRTC0_REGISTER_OFFSET 0 //(0x6df0 - 0x6df0)/4

drivers/gpu/drm/amd/amdgpu/sid.h +0 -17
@@ -2320,11 +2269,6 @@
 #       define NI_INPUT_GAMMA_XVYCC_222                3
 #       define NI_OVL_INPUT_GAMMA_MODE(x)              (((x) & 0x3) << 4)
 
-#define IH_RB_WPTR__RB_OVERFLOW_MASK	0x1
-#define IH_RB_CNTL__WPTR_OVERFLOW_CLEAR_MASK 0x80000000
-#define SRBM_STATUS__IH_BUSY_MASK	0x20000
-#define SRBM_SOFT_RESET__SOFT_RESET_IH_MASK	0x400
-
 #define	BLACKOUT_MODE_MASK			0x00000007
 #define	VGA_RENDER_CONTROL			0xC0
 #define R_000300_VGA_RENDER_CONTROL             0xC0
@@ -2411,18 +2355,6 @@
 #define MC_SEQ_MISC0__MT__HBM    0x60000000
 #define MC_SEQ_MISC0__MT__DDR3   0xB0000000
 
-#define SRBM_STATUS__MCB_BUSY_MASK 0x200
-#define SRBM_STATUS__MCB_BUSY__SHIFT 0x9
-#define SRBM_STATUS__MCB_NON_DISPLAY_BUSY_MASK 0x400
-#define SRBM_STATUS__MCB_NON_DISPLAY_BUSY__SHIFT 0xa
-#define SRBM_STATUS__MCC_BUSY_MASK 0x800
-#define SRBM_STATUS__MCC_BUSY__SHIFT 0xb
-#define SRBM_STATUS__MCD_BUSY_MASK 0x1000
-#define SRBM_STATUS__MCD_BUSY__SHIFT 0xc
-#define SRBM_STATUS__VMC_BUSY_MASK 0x100
-#define SRBM_STATUS__VMC_BUSY__SHIFT 0x8
-
-
 #define GRBM_STATUS__GUI_ACTIVE_MASK 0x80000000
 #define CP_INT_CNTL_RING__TIME_STAMP_INT_ENABLE_MASK

0x4000000
#define CP_INT_CNTL_RING0__PRIV_REG_INT_ENABLE_MASK 0x800000

drivers/gpu/drm/amd/amdgpu/sid.h +0 -2
@@ -2447,8 +2379,6 @@
 
 #define PCIE_BUS_CLK    10000
 #define TCLK            (PCIE_BUS_CLK / 10)
-#define CC_DRM_ID_STRAPS__ATI_REV_ID_MASK		0xf0000000
-#define CC_DRM_ID_STRAPS__ATI_REV_ID__SHIFT 0x1c
 #define	PCIE_PORT_INDEX					0xe
 #define	PCIE_PORT_DATA					0xf
 #define EVERGREEN_PIF_PHY0_INDEX                        0x8
drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_d.h +3 -15
index 2176548e9203..2e4841a08742 100644
@@ -23,42 +23,58 @@
 #ifndef VCE_1_0_D_H
 #define VCE_1_0_D_H
 
-#define mmVCE_CLOCK_GATING_A 0x80BE
-#define mmVCE_CLOCK_GATING_B 0x80BF
-#define mmVCE_LMI_CACHE_CTRL 0x83BD
-#define mmVCE_LMI_CTRL 0x83A6
-#define mmVCE_LMI_CTRL2 0x839D
-#define mmVCE_LMI_MISC_CTRL 0x83B5
-#define mmVCE_LMI_STATUS 0x83A7
-#define mmVCE_LMI_SWAP_CNTL 0x83AD
-#define mmVCE_LMI_SWAP_CNTL1 0x83AE
-#define mmVCE_LMI_VCPU_CACHE_40BIT_BAR 0x8397
-#define mmVCE_LMI_VM_CTRL 0x83A8
-#define mmVCE_RB_ARB_CTRL 0x809F
-#define mmVCE_RB_BASE_HI 0x8061
-#define mmVCE_RB_BASE_HI2 0x805C
-#define mmVCE_RB_BASE_LO 0x8060
+/* Imported from sid.h or cleaned up */
+// #define VCE_FW_REG_STATUS				0x20e10
+// #define VCE_LMI_FW_START_KEYSEL
 	0x20e18

drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_d.h line 39

Quoted 10 lines
drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_d.h +10 -0
+// #define VCE_LMI_FW_PERIODIC_CTRL			0x20e20
+
+#define VCE_CMD_NO_OP					0x00000000
+#define VCE_CMD_END					0x00000001
+#define VCE_CMD_IB					0x00000002
+#define VCE_CMD_FENCE					0x00000003
+#define VCE_CMD_TRAP					0x00000004
+#define VCE_CMD_IB_AUTO					0x00000005
+#define VCE_CMD_SEMAPHORE				0x00000006
+

Please keep the vce commands in sid.h for consistency.

Quoted 67 lines
drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_d.h +35 -17
+
+
+#define mmVCE_STATUS 0x8001
+#define mmVCE_VCPU_CNTL 0x8005
+#define mmVCE_VCPU_CACHE_OFFSET0 0x8009
+#define mmVCE_VCPU_CACHE_SIZE0 0x800A
+#define mmVCE_VCPU_CACHE_OFFSET1 0x800B
+#define mmVCE_VCPU_CACHE_SIZE1 0x800C
+#define mmVCE_VCPU_CACHE_OFFSET2 0x800D
+#define mmVCE_VCPU_CACHE_SIZE2 0x800E
+#define mmVCE_SOFT_RESET 0x8048
 #define mmVCE_RB_BASE_LO2 0x805B
-#define mmVCE_RB_RPTR 0x8063
+#define mmVCE_RB_BASE_HI2 0x805C
+#define mmVCE_RB_SIZE2 0x805D
 #define mmVCE_RB_RPTR2 0x805E
+#define mmVCE_RB_WPTR2 0x805F
+#define mmVCE_RB_BASE_LO 0x8060
+#define mmVCE_RB_BASE_HI 0x8061
 #define mmVCE_RB_SIZE 0x8062
-#define mmVCE_RB_SIZE2 0x805D
+#define mmVCE_RB_RPTR 0x8063
 #define mmVCE_RB_WPTR 0x8064
-#define mmVCE_RB_WPTR2 0x805F
-#define mmVCE_SOFT_RESET 0x8048
-#define mmVCE_STATUS 0x8001
-#define mmVCE_SYS_INT_ACK 0x8341
-#define mmVCE_SYS_INT_EN 0x8340
-#define mmVCE_SYS_INT_STATUS 0x8341
-#define mmVCE_UENC_CLOCK_GATING 0x816F
+#define mmVCE_RB_ARB_CTRL 0x809F
+#define mmVCE_CLOCK_GATING_A 0x80BE
+#define mmVCE_CLOCK_GATING_B 0x80BF
 #define mmVCE_UENC_DMA_DCLK_CTRL 0x8250
+#define mmVCE_CGTT_CLK_OVERRIDE 0x81e8
+#define mmVCE_UENC_CLOCK_GATING 0x816F
 #define mmVCE_UENC_REG_CLOCK_GATING 0x8170
-#define mmVCE_VCPU_CACHE_OFFSET0 0x8009
-#define mmVCE_VCPU_CACHE_OFFSET1 0x800B
-#define mmVCE_VCPU_CACHE_OFFSET2 0x800D
-#define mmVCE_VCPU_CACHE_SIZE0 0x800A
-#define mmVCE_VCPU_CACHE_SIZE1 0x800C
-#define mmVCE_VCPU_CACHE_SIZE2 0x800E
-#define mmVCE_VCPU_CNTL 0x8005
+#define mmVCE_SYS_INT_EN 0x8340
+#define mmVCE_SYS_INT_STATUS 0x8341
+#define mmVCE_SYS_INT_ACK 0x8341
+#define mmVCE_LMI_VCPU_CACHE_40BIT_BAR 0x8397
+#define mmVCE_LMI_CTRL2 0x839D
+#define mmVCE_LMI_CTRL 0x83A6
+#define mmVCE_LMI_STATUS 0x83A7
+#define mmVCE_LMI_VM_CTRL 0x83A8
+#define mmVCE_LMI_SWAP_CNTL 0x83AD
+#define mmVCE_LMI_SWAP_CNTL1 0x83AE
+#define mmVCE_LMI_MISC_CTRL 0x83B5
+#define mmVCE_LMI_CACHE_CTRL 0x83BD
 
-#endif
+#endif /* VCE_1_0_D_H */
drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h +0 -0
index ea5b26b11cb1..0653a4e1d59f 100644
@@ -23,6 +23,17 @@
 #ifndef VCE_1_0_SH_MASK_H
 #define VCE_1_0_SH_MASK_H

drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h line 34

Quoted 10 lines
drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h +9 -0
 
+/* Imported from sid.h or cleaned up */
+#define VCE_CLK_EN				(1 << 0)
+#define VCE_ECPU_SOFT_RESET			(1 << 0)
+#define VCE_FME_SOFT_RESET			(1 << 2)
+#define CGC_DYN_CLOCK_MODE			(1 << 16)
+#define VCE_FW_REG_STATUS_BUSY			(1 << 0)
+#define VCE_FW_REG_STATUS_PASS			(1 << 3)
+#define VCE_FW_REG_STATUS_DONE			(1 << 11)
+

Please use proper formating for these to match the other bitfield definitions in the file. E.g., __MASK and __SHIFT.

Quoted 14 lines
drivers/gpu/drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h +3 -2
+
+
 #define VCE_LMI_CACHE_CTRL__VCPU_EN_MASK 0x00000001L
 #define VCE_LMI_CACHE_CTRL__VCPU_EN__SHIFT 0x00000000
 #define VCE_LMI_CTRL2__STALL_ARB_UMC_MASK 0x00000100L
@@ -96,4 +107,4 @@
 #define VCE_VCPU_CNTL__RBBM_SOFT_RESET_MASK 0x00040000L
 #define VCE_VCPU_CNTL__RBBM_SOFT_RESET__SHIFT 0x00000012
 
-#endif
+#endif /* VCE_1_0_SH_MASK_H */
--

2.14.1

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#8 lore raw

PATCH 3/6 Small precision when failing to load legacy firmware.

In reply to a message not in the archive
---
 drivers/gpu/drm/radeon/radeon_uvd.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/radeon/radeon_uvd.c +1 -1
index 7431eb4a11b7..b4fb07ad9f4a 100644
@@ -175,7 +175,7 @@ int radeon_uvd_init(struct radeon_device *rdev)
 	if (!fw_name || r) {
 		r = request_firmware(&rdev->uvd_fw, legacy_fw_name, rdev->dev);
 		if (r) {
-			dev_err(rdev->dev, "radeon_uvd: Can't load firmware \"%s\"\n",
+			dev_err(rdev->dev, "radeon_uvd: Can't load legacy firmware \"%s\"\n",
 				legacy_fw_name);
 			return r;
 		}
Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#9 lore raw

PATCH 4/6 Moving read and write pointer functions from radeon to amdgpu

In reply to a message not in the archive
---
 drivers/gpu/drm/amd/amdgpu/vce_v1_0.c | 62 ++++++++++++++++++++---------------
 1 file changed, 36 insertions(+), 26 deletions(-)
drivers/gpu/drm/amd/amdgpu/vce_v1_0.c +36 -26
index f541a4b5ac51..ab3b834758c6 100644
@@ -27,10 +27,20 @@
 
 #include <linux/firmware.h>
 #include <drm/drmP.h>
-#include "radeon.h"
-#include "radeon_asic.h"
+#include "amdgpu.h"
+#include "amdgpu_vce.h"
 #include "sid.h"
 
+#include "vce/vce_1_0_d.h"
+#include "vce/vce_1_0_sh_mask.h"
+
+#include "smu/smu_7_0_1_d.h"
+#include "smu/smu_7_0_1_sh_mask.h"
+
+#include "oss/oss_1_0_d.h"
+#include "oss/oss_1_0_sh_mask.h"
+
+
 #define VCE_V1_0_FW_SIZE	(256 * 1024)
 #define VCE_V1_0_STACK_SIZE	(64 * 1024)
 #define VCE_V1_0_DATA_SIZE	(7808 * (RADEON_MAX_VCE_HANDLES + 1))
@@ -49,54 +59,54 @@ struct vce_v1_0_fw_signature
 };
 
 /**
- * vce_v1_0_get_rptr - get read pointer
+ * vce_v1_0_ring_get_rptr - get read pointer
  *
- * @rdev: radeon_device pointer
- * @ring: radeon_ring pointer
+ * @ring: amdgpu_ring pointer
  *
  * Returns the current hardware read pointer
  */
-uint32_t vce_v1_0_get_rptr(struct radeon_device *rdev,
-			   struct radeon_ring *ring)
+static uint64_t vce_v1_0_ring_get_rptr(struct amdgpu_ring *ring)
 {
-	if (ring->idx == TN_RING_TYPE_VCE1_INDEX)
-		return RREG32(VCE_RB_RPTR);
+	struct amdgpu_device *adev = ring->adev;
+
+	if (ring == &adev->vce.ring[0])
+		return RREG32(mmVCE_RB_RPTR);
 	else
-		return RREG32(VCE_RB_RPTR2);
+		return RREG32(mmVCE_RB_RPTR2);
 }
 
 /**
- * vce_v1_0_get_wptr - get write pointer
+ * vce_v1_0_ring_get_wptr - get write pointer
  *
- * @rdev: radeon_device pointer
- * @ring: radeon_ring pointer
+ * @ring: amdgpu_ring pointer
  *
  * Returns the current hardware write pointer
  */
-uint32_t vce_v1_0_get_wptr(struct radeon_device *rdev,
-			   struct radeon_ring *ring)
+static uint64_t vce_v1_0_ring_get_wptr(struct amdgpu_ring *ring)
 {
-	if (ring->idx == TN_RING_TYPE_VCE1_INDEX)
-		return RREG32(VCE_RB_WPTR);
+	struct amdgpu_device *adev = ring->adev;
+
+	if (ring == &adev->vce.ring[0])
+		return RREG32(mmVCE_RB_WPTR);
 	else
-		return RREG32(VCE_RB_WPTR2);
+		return RREG32(mmVCE_RB_WPTR2);
 }
 
 /**
- * vce_v1_0_set_wptr - set write pointer
+ * vce_v1_0_ring_set_wptr - set write pointer
  *
- * @rdev: radeon_device pointer
- * @ring: radeon_ring pointer
+ * @ring: amdgpu_ring pointer
  *
  * Commits the write pointer to the hardware
  */
-void vce_v1_0_set_wptr(struct radeon_device *rdev,
-		       struct radeon_ring *ring)
+static void vce_v1_0_ring_set_wptr(struct amdgpu_ring *ring)
 {
-	if (ring->idx == TN_RING_TYPE_VCE1_INDEX)
-		WREG32(VCE_RB_WPTR, ring->wptr);
+	struct amdgpu_device *adev = ring->adev;
+
+	if (ring == &adev->vce.ring[0])
+		WREG32(mmVCE_RB_WPTR, lower_32_bits(ring->wptr));
 	else
-		WREG32(VCE_RB_WPTR2, ring->wptr);
+		WREG32(mmVCE_RB_WPTR2, lower_32_bits(ring->wptr));
 }
 
 void vce_v1_0_enable_mgcg(struct radeon_device *rdev, bool enable)
Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#10 lore raw

PATCH 5/6 Add support for SI's VCE firmwares (with and without header)

In reply to a message not in the archive

Inspired on how it is done under radeon for UVD firmwares.

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c | 100 ++++++++++++++++++++++++--------
 1 file changed, 75 insertions(+), 25 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c +75 -25
index 735c38d7db0d..6d65fab6a4af 100644
@@ -39,6 +39,10 @@
 #define VCE_IDLE_TIMEOUT	msecs_to_jiffies(1000)
 
 /* Firmware Names */
+#ifdef CONFIG_DRM_AMDGPU_SI
+#define FIRMWARE_TAHITI_LEGACY	"radeon/TAHITI_vce.bin"
+#define FIRMWARE_TAHITI	"radeon/tahiti_vce.bin"
+#endif
 #ifdef CONFIG_DRM_AMDGPU_CIK
 #define FIRMWARE_BONAIRE	"radeon/bonaire_vce.bin"
 #define FIRMWARE_KABINI	"radeon/kabini_vce.bin"
@@ -56,6 +60,10 @@
 
 #define FIRMWARE_VEGA10		"amdgpu/vega10_vce.bin"
 
+#ifdef CONFIG_DRM_AMDGPU_SI
+MODULE_FIRMWARE(FIRMWARE_TAHITI_LEGACY);
+MODULE_FIRMWARE(FIRMWARE_TAHITI);
+#endif
 #ifdef CONFIG_DRM_AMDGPU_CIK
 MODULE_FIRMWARE(FIRMWARE_BONAIRE);
 MODULE_FIRMWARE(FIRMWARE_KABINI);
@@ -86,12 +94,21 @@ int amdgpu_vce_sw_init(struct amdgpu_device *adev, unsigned long size)
 {
 	struct amdgpu_ring *ring;
 	struct amd_sched_rq *rq;
-	const char *fw_name;
+	const char *fw_name = NULL, *legacy_fw_name = NULL;
 	const struct common_firmware_header *hdr;
 	unsigned ucode_version, version_major, version_minor, binary_id;
 	int i, r;
 
 	switch (adev->asic_type) {
+#ifdef CONFIG_DRM_AMDGPU_SI
+	case CHIP_TAHITI:
+	case CHIP_VERDE:
+	case CHIP_PITCAIRN:
+	case CHIP_OLAND:
+		legacy_fw_name = FIRMWARE_TAHITI_LEGACY;
+		fw_name = FIRMWARE_TAHITI;
+		break;
+#endif
 #ifdef CONFIG_DRM_AMDGPU_CIK
 	case CHIP_BONAIRE:
 		fw_name = FIRMWARE_BONAIRE;
@@ -138,32 +155,55 @@ int amdgpu_vce_sw_init(struct amdgpu_device *adev, unsigned long size)
 		return -EINVAL;
 	}
 
-	r = request_firmware(&adev->vce.fw, fw_name, adev->dev);
-	if (r) {
-		dev_err(adev->dev, "amdgpu_vce: Can't load firmware \"%s\"\n",
-			fw_name);
-		return r;
-	}
+	if (fw_name) {
+		/* Let's try to load the newer firmware first */
+		r = request_firmware(&adev->vce.fw, fw_name, adev->dev);
+		if (r) {
+			dev_err(adev->dev, "amdgpu_vce: Can't load firmware \"%s\"\n",
+				fw_name);
+			// return r;
+		} else {
 
-	r = amdgpu_ucode_validate(adev->vce.fw);
-	if (r) {
-		dev_err(adev->dev, "amdgpu_vce: Can't validate firmware \"%s\"\n",
-			fw_name);
-		release_firmware(adev->vce.fw);
-		adev->vce.fw = NULL;
-		return r;
-	}
+			r = amdgpu_ucode_validate(adev->vce.fw);
+			if (r) {
+				dev_err(adev->dev, "amdgpu_vce: Can't validate firmware \"%s\"\n",
+					fw_name);
+				release_firmware(adev->vce.fw);
+				adev->vce.fw = NULL;
+				return r;
+			}
 
-	hdr = (const struct common_firmware_header *)adev->vce.fw->data;
+			hdr = (const struct common_firmware_header *)adev->vce.fw->data;
 
-	ucode_version = le32_to_cpu(hdr->ucode_version);
-	version_major = (ucode_version >> 20) & 0xfff;
-	version_minor = (ucode_version >> 8) & 0xfff;
-	binary_id = ucode_version & 0xff;
-	DRM_INFO("Found VCE firmware Version: %hhd.%hhd Binary ID: %hhd\n",
-		version_major, version_minor, binary_id);
-	adev->vce.fw_version = ((version_major << 24) | (version_minor << 16) |
+			ucode_version = le32_to_cpu(hdr->ucode_version);
+			version_major = (ucode_version >> 20) & 0xfff;
+			version_minor = (ucode_version >> 8) & 0xfff;
+			binary_id = ucode_version & 0xff;
+			DRM_INFO("Found VCE firmware Version: %hhd.%hhd Binary ID: %hhd\n",
+				version_major, version_minor, binary_id);
+			adev->vce.fw_version = ((version_major << 24) | (version_minor << 16) |
 				(binary_id << 8));
+		}
+	}
+
+	/*
+	 * In case there is only a legacy firmware, or we encountered an error
+	 * while loading the new firmware, we fall back to loading the legacy
+	 * firmware now.
+	 */
+	if (!fw_name || r) {
+		r = request_firmware(&adev->vce.fw, legacy_fw_name, adev->dev);
+		if (r) {
+			dev_err(adev->dev, "amdgpu_vce: Can't load legacy firmware \"%s\"\n",
+				legacy_fw_name);
+			return r;
+		}
+
+		// Portage debug
+		else {
+			DRM_INFO("VCE legacy firmware loaded.\n");
+		}
+	}
 
 	/* allocate firmware, stack and heap BO */
 
@@ -296,9 +336,17 @@ int amdgpu_vce_resume(struct amdgpu_device *adev)
 	}
 
 	hdr = (const struct common_firmware_header *)adev->vce.fw->data;
-	offset = le32_to_cpu(hdr->ucode_array_offset_bytes);
+
+	/* Are we using a legacy firmware with no header? */
+	if ((le32_to_cpu(hdr->ucode_array_offset_bytes) != 256) || (le32_to_cpu(hdr->header_size_bytes) != 32)) {
+		offset = 0;
+	}
+	else {
+		offset = le32_to_cpu(hdr->ucode_array_offset_bytes);
+	}
+
 	memcpy_toio(cpu_addr, adev->vce.fw->data + offset,
-		    adev->vce.fw->size - offset);
+				adev->vce.fw->size - offset);
 
 	amdgpu_bo_kunmap(adev->vce.vcpu_bo);
 
@@ -732,6 +780,8 @@ int amdgpu_vce_ring_parse_cs(struct amdgpu_cs_parser *p, uint32_t ib_idx)
 
 		case 0x0500000c: /* hw config */
 			switch (p->adev->asic_type) {
+#ifdef CONFIG_DRM_AMDGPU_SI
+#endif
 #ifdef CONFIG_DRM_AMDGPU_CIK
 			case CHIP_KAVERI:
 			case CHIP_MULLINS:
Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#11 lore raw

PATCH 6/6 Fix indentation.

In reply to a message not in the archive
---
 drivers/gpu/drm/amd/amdgpu/si.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/si.c +1 -1
index 08998639daeb..bb860faa8a95 100644
@@ -1268,7 +1268,7 @@ static int si_common_early_init(void *handle)
 			AMD_CG_SUPPORT_HDP_LS |
 			AMD_CG_SUPPORT_HDP_MGCG;
 			adev->pg_flags = 0;
-		adev->external_rev_id = (adev->rev_id == 0) ? 1 :
+			adev->external_rev_id = (adev->rev_id == 0) ? 1 :
 					(adev->rev_id == 1) ? 5 : 6;
 		break;
 	case CHIP_PITCAIRN:
Signature · 6 lines
2.14.1

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx
#12 lore raw
In reply to a message not in the archive

First of all please prefix all subject lines for amdgpu kernel patches with drm/amdgpu.

Additional to that I think we won't accept loading firmware files in the old format. Instead please just add the header to the files. If that turns out to be problematic I can start looking into providing those.

Apart from that thanks a lot for this work, this is really welcome. But does it actually work? Have you tested it with mesa?

Thanks,
Christian.

Am 08.09.2017 um 04:48 schrieb Alexandre Demers:

Quoted 30 lines

This is the foundation for VCE 1 implementation, mostly ported from radeon to amdgpu. This should have no impact for now on the usability of the driver. This is the pretty straight-forward part. The heavier part is coming as a RFC.

I'd like to have this first part available to all, since I don't have as much time as I'd like to work on VCE 1 for now, but this could help others to help me on the task.

If you are not satisfied with this first series, this can also be considered as a RFC. Please, comment as needed.

Alexandre Demers (6):
Add initial VCE_V1_0 files.
Reorganize, rename, move and split some VCE 1 defines. Small precision when failing to load legacy firmware. Moving read and write pointer functions from radeon to amdgpu Add support for SI's VCE firmwares (with and without header) Fix indentation.

  drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c            | 100 ++++--
  drivers/gpu/drm/amd/amdgpu/si.c                    |  17 +-
  drivers/gpu/drm/amd/amdgpu/si_dma.c                |   5 +-
  drivers/gpu/drm/amd/amdgpu/si_ih.c                 |  21 +-
  drivers/gpu/drm/amd/amdgpu/sid.h                   |  70 ----
  drivers/gpu/drm/amd/amdgpu/vce_v1_0.c              | 394 +++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/vce_v1_0.h              |  29 ++
  .../gpu/drm/amd/include/asic_reg/vce/vce_1_0_d.h   |  80 +++--
  .../drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h |  13 +-
  drivers/gpu/drm/radeon/radeon_uvd.c                |   2 +-
  10 files changed, 589 insertions(+), 142 deletions(-)
Quoted 3 lines

create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.c create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.h

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): f43717f2-fdbf-91be-1371-38f2102bc202-5C7GfCeVMHo@public.gmane.org

#14 lore raw

Hi Christian!

Quoted 2 lines · Christian König

First of all please prefix all subject lines for amdgpu kernel patches with drm/amdgpu.

You're right, I forgot.

Quoted 5 lines

Additional to that I think we won't accept loading firmware files in the old format. Instead please just add the header to the files. If that turns out to be problematic I can start looking into providing those.

Noted, I'll drop the code and I'll create a temporary firmware with the needed header. However, it would be convenient to see newer firmwares for both VCE and UVD (cheers Trevor) coming from an official source (AMD). Let's remove the old firmware loading patch and propose a glued firmware.

Quoted 3 lines

Apart from that thanks a lot for this work, this is really welcome. But does it actually work? Have you tested it with mesa?

This work doesn't activate any VCE functionality. On the other hand, it shouldn't break anything either. It needs the next series of patches. While the firmware loading and initialization seem to go through correctly, I'm encountering hangs at boot. That's where I'll need some help.

I'll post the next series in the next few days as a RFC so others can help me go through. I just need to split the code in a few patches.

Cheers,
Alex

Quoted 46 lines

Thanks,
Christian.

Am 08.09.2017 um 04:48 schrieb Alexandre Demers:

Quoted 40 lines

This is the foundation for VCE 1 implementation, mostly ported from radeon to
amdgpu. This should have no impact for now on the usability of the driver. This
is the pretty straight-forward part. The heavier part is coming as a RFC.

I'd like to have this first part available to all, since I don't have as much
time as I'd like to work on VCE 1 for now, but this could help others to help me
on the task.

If you are not satisfied with this first series, this can also be considered as
a RFC. Please, comment as needed.

Alexandre Demers (6):
   Add initial VCE_V1_0 files.
   Reorganize, rename, move and split some VCE 1 defines. Small precision when failing to load legacy firmware. Moving read and write pointer functions from radeon to amdgpu Add support for SI's VCE firmwares (with and without header) Fix indentation.

  drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c            | 100 ++++-- drivers/gpu/drm/amd/amdgpu/si.c                    |  17 +- drivers/gpu/drm/amd/amdgpu/si_dma.c                |   5 +- drivers/gpu/drm/amd/amdgpu/si_ih.c                 |  21 +- drivers/gpu/drm/amd/amdgpu/sid.h                   |  70 ---- drivers/gpu/drm/amd/amdgpu/vce_v1_0.c              | 394
+++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/vce_v1_0.h              |  29 ++ .../gpu/drm/amd/include/asic_reg/vce/vce_1_0_d.h   |  80 +++-- .../drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h |  13 +- drivers/gpu/drm/radeon/radeon_uvd.c                |   2 +-

  10 files changed, 589 insertions(+), 142 deletions(-)

  create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.c create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.h

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

A message that is not in the archive (sent off-list or not yet received): c24c47ce-6f83-18f2-6064-b07987501afb-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#16 lore raw

Oh and patch 3 "Small precision when failing to load legacy firmware" should have been a standalone patch, it is related to the radeon driver. I'll send it as so with drm/radeon in the title.

Alexandre Demers

Quoted 22 lines · Alexandre Demers

Hi Christian!

Quoted 2 lines · Christian König

First of all please prefix all subject lines for amdgpu kernel patches with drm/amdgpu.

You're right, I forgot.

Quoted 4 lines

Additional to that I think we won't accept loading firmware files in the old format. Instead please just add the header to the files. If that turns out to be problematic I can start looking into providing those.

Noted, I'll drop the code and I'll create a temporary firmware with the needed header. However, it would be convenient to see newer firmwares for both VCE and UVD (cheers Trevor) coming from an official source (AMD). Let's remove the old firmware loading patch and propose a glued firmware.

Quoted 2 lines

Apart from that thanks a lot for this work, this is really welcome. But does it actually work? Have you tested it with mesa?

This work doesn't activate any VCE functionality. On the other hand, it shouldn't break anything either. It needs the next series of patches. While the firmware loading and initialization seem to go through correctly, I'm encountering hangs at boot. That's where I'll need some help.

Quoted 50 lines

I'll post the next series in the next few days as a RFC so others can help me go through. I just need to split the code in a few patches.

Cheers,
Alex

Quoted 44 lines

Thanks,
Christian.

Am 08.09.2017 um 04:48 schrieb Alexandre Demers:

Quoted 40 lines

This is the foundation for VCE 1 implementation, mostly ported from radeon to
amdgpu. This should have no impact for now on the usability of the driver. This
is the pretty straight-forward part. The heavier part is coming as a RFC.

I'd like to have this first part available to all, since I don't have as much
time as I'd like to work on VCE 1 for now, but this could help others to help me
on the task.

If you are not satisfied with this first series, this can also be considered as
a RFC. Please, comment as needed.

Alexandre Demers (6):
   Add initial VCE_V1_0 files.
   Reorganize, rename, move and split some VCE 1 defines. Small precision when failing to load legacy firmware. Moving read and write pointer functions from radeon to amdgpu Add support for SI's VCE firmwares (with and without header) Fix indentation.

  drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c            | 100 ++++-- drivers/gpu/drm/amd/amdgpu/si.c                    |  17 +- drivers/gpu/drm/amd/amdgpu/si_dma.c                |   5 +- drivers/gpu/drm/amd/amdgpu/si_ih.c                 |  21 +- drivers/gpu/drm/amd/amdgpu/sid.h                   |  70 ---- drivers/gpu/drm/amd/amdgpu/vce_v1_0.c              | 394
+++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/vce_v1_0.h              |  29 ++ .../gpu/drm/amd/include/asic_reg/vce/vce_1_0_d.h   |  80 +++-- .../drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h |  13 +- drivers/gpu/drm/radeon/radeon_uvd.c                |   2 +-

  10 files changed, 589 insertions(+), 142 deletions(-)

  create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.c create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.h

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

#17 lore raw
In reply to a message not in the archive

Am 08.09.2017 um 13:55 schrieb Alexandre Demers:

Quoted 10 lines

Hi Christian!

Quoted 2 lines · Christian König

First of all please prefix all subject lines for amdgpu kernel patches with drm/amdgpu.

You're right, I forgot.

Quoted 4 lines

Additional to that I think we won't accept loading firmware files in the old format. Instead please just add the header to the files. If that turns out to be problematic I can start looking into providing those.

Quoted 5 lines

Noted, I'll drop the code and I'll create a temporary firmware with the needed header. However, it would be convenient to see newer firmwares for both VCE and UVD (cheers Trevor) coming from an official source (AMD). Let's remove the old firmware loading patch and propose a glued firmware.

Yeah, we most likely also want to use the newest VCE firmware supported for SI here and not the old one we used for radeon.

Unfortunately the VCE firmware interface wasn't backward compatible till recently. So the new firmware won't work with radeon any more.

Quoted 9 lines
Quoted 2 lines

Apart from that thanks a lot for this work, this is really welcome. But does it actually work? Have you tested it with mesa?

This work doesn't activate any VCE functionality. On the other hand, it shouldn't break anything either. It needs the next series of patches. While the firmware loading and initialization seem to go through correctly, I'm encountering hangs at boot. That's where I'll need some help.

I'll post the next series in the next few days as a RFC so others can help me go through. I just need to split the code in a few patches.

Ok please send out a complete set of patches. I will ask around on Monday how we can support this work.

Thanks,
Christian.

Quoted 48 lines

Cheers,
Alex

Quoted 44 lines

Thanks,
Christian.

Am 08.09.2017 um 04:48 schrieb Alexandre Demers:

Quoted 40 lines

This is the foundation for VCE 1 implementation, mostly ported from radeon to
amdgpu. This should have no impact for now on the usability of the driver. This
is the pretty straight-forward part. The heavier part is coming as a RFC.

I'd like to have this first part available to all, since I don't have as much
time as I'd like to work on VCE 1 for now, but this could help others to help me
on the task.

If you are not satisfied with this first series, this can also be considered as
a RFC. Please, comment as needed.

Alexandre Demers (6):
Add initial VCE_V1_0 files.
Reorganize, rename, move and split some VCE 1 defines. Small precision when failing to load legacy firmware. Moving read and write pointer functions from radeon to amdgpu Add support for SI's VCE firmwares (with and without header) Fix indentation.

   drivers/gpu/drm/amd/amdgpu/amdgpu_vce.c            | 100 ++++--
   drivers/gpu/drm/amd/amdgpu/si.c                    |  17 +-
   drivers/gpu/drm/amd/amdgpu/si_dma.c                |   5 +-
   drivers/gpu/drm/amd/amdgpu/si_ih.c                 |  21 +-
   drivers/gpu/drm/amd/amdgpu/sid.h                   |  70 ----
   drivers/gpu/drm/amd/amdgpu/vce_v1_0.c              | 394
+++++++++++++++++++++
   drivers/gpu/drm/amd/amdgpu/vce_v1_0.h              |  29 ++
   .../gpu/drm/amd/include/asic_reg/vce/vce_1_0_d.h   |  80 +++--
   .../drm/amd/include/asic_reg/vce/vce_1_0_sh_mask.h |  13 +-
   drivers/gpu/drm/radeon/radeon_uvd.c                |   2 +-
   10 files changed, 589 insertions(+), 142 deletions(-)

create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.c create mode 100644 drivers/gpu/drm/amd/amdgpu/vce_v1_0.h

Quoted 4 lines

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx