Skip to contentSkip to conversation

UVD support for SI in amdgpu

RFC In review Piotr Redlewski 4 participants 17 messages Nov 8, 2017 – Nov 9, 2017 8 messages not in the archive

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

cover UVD support for SI in amdgpu

Hi,

Following series implements UVD support for SI in amdgpu driver. Code is based on CIK's UVD support in amdgpu and SI's UVD support in radeon drivers. To work, it requires tahiti uvd firmware with added header - I've created simple script to produce exactly this, so if anyone is interested it can be found here:
https://gist.github.com/anonymous/6d974a970340f7f64b6fcc4f95267e43

Code is based on amd-staging-drm-next branch in Alex's tree. After applying these patches, uvd boots up and seems to work ok. I've tested it with vdpauinfo and mpv.

Some comments/issues for the patches:
1. To make uvd work, I had to bring back fb location programming. Using location programmed by vbios, vram location is not available for uvd mc (at least on my machine) due to too wide address. Starting address is 40-bit long for fb, but uvd mc supports only 32-bits (judging by comments in amdgpu code and actual code in radeon driver)
2. I don't know why, but I couldn't get the uvd to boot without setting uvd mc offsets before starting other engines. Because of that I set it in .sw_init function. In my opinion this should be fixed as it generally doesn't follow amdgpu driver architecture (hardware setup during software setup stage) and probably will break suspending and resume (I didn't test it). As I mentioned, I couldn't figure out why this is happening, so I count on help with finding fix for this.
3. I found some redefinitions in include/asic_reg/uvd/uvd_4_0_sh_mask.h. I guess this file is generated, so fix should be made wherever it is generated from. For now I removed offending lines just to silence the compiler warnings.
4. I'm not sure whether I choose the right version for the uvd. Existing code in si.c suggested that it should be 3.1, however I went with the 4.0, because for this version there are available new style headers.

Regards,
Piotr

Piotr Redlewski (7):
drm/amdgpu: remove duplicated definitions of some of the SI registers drm/amdgpu/uvd4: fix some register's mask and shift definitions drm/amdgpu/gmc6: don't use vram location programmed by the vbios drm/amdgpu/uvd4: add early init stage functions for uvd 4.0 drm/amdgpu/uvd4: add sw init and fini stages' functions for uvd 4.0 drm/amdgpu/uvd4: add hardware specific functions for uvd 4.0 drm/amdgpu: enable UVD for SI

 drivers/gpu/drm/amd/amdgpu/Makefile                |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h           |   6 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c            |  14 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c              | 114 ++-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.h              |   5 +
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c              |   7 -
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c              |  40 +-
 drivers/gpu/drm/amd/amdgpu/si.c                    | 256 ++++++-
 drivers/gpu/drm/amd/amdgpu/si_ih.c                 |   3 +
 drivers/gpu/drm/amd/amdgpu/sid.h                   |  52 +-
 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c              | 810 +++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h              |  29 +
 .../drm/amd/include/asic_reg/uvd/uvd_4_0_sh_mask.h |   2 -
 13 files changed, 1273 insertions(+), 68 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h
Signature · 6 lines
2.15.0

_______________________________________________
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): 20171108223839.579-1-predlewski-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#2 lore raw

RFC 1/7 drm/amdgpu: remove duplicated definitions of some of the SI registers

Some of the registers are defined both in the sid.h and in the new style headers. Removed definitions from the sid.h

---
 drivers/gpu/drm/amd/amdgpu/si.c    |  1 +
 drivers/gpu/drm/amd/amdgpu/si_ih.c |  3 +++
 drivers/gpu/drm/amd/amdgpu/sid.h   | 16 ----------------
 3 files changed, 4 insertions(+), 16 deletions(-)
drivers/gpu/drm/amd/amdgpu/si.c +1 -0
index 8284d5dbfc30..2ac1c2be8ca4 100644
@@ -42,6 +42,7 @@
 #include "dce_virtual.h"
 #include "gca/gfx_6_0_d.h"
 #include "oss/oss_1_0_d.h"
+#include "oss/oss_1_0_sh_mask.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_ih.c +3 -0
index d2c6b80309c8..ca53ff7e3c56 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)
drivers/gpu/drm/amd/amdgpu/sid.h +0 -16
index c57eff159374..59f8fc944ecb 100644
@@ -2320,10 +2320,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
@@ -2411,16 +2407,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
@@ -2447,8 +2433,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
Signature · 6 lines
2.15.0

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

RFC 2/7 drm/amdgpu/uvd4: fix some register's mask and shift definitions

In reply to a message not in the archive

UVD_LMI_CTRL__RFU_MASK and UVD_LMI_CTRL__RFU__SHIFT are defined twice, each time with different values

---
 drivers/gpu/drm/amd/include/asic_reg/uvd/uvd_4_0_sh_mask.h | 2 --
 1 file changed, 2 deletions(-)
drivers/gpu/drm/amd/include/asic_reg/uvd/uvd_4_0_sh_mask.h +0 -2
index 8ee3149df5b7..2ef1273e65ab 100644
@@ -340,8 +340,6 @@
 #define UVD_LMI_CTRL__REQ_MODE_MASK 0x00000200L
 #define UVD_LMI_CTRL__REQ_MODE__SHIFT 0x00000009
 #define UVD_LMI_CTRL__RFU_MASK 0xf8000000L
-#define UVD_LMI_CTRL__RFU_MASK 0xfc000000L
-#define UVD_LMI_CTRL__RFU__SHIFT 0x0000001a
 #define UVD_LMI_CTRL__RFU__SHIFT 0x0000001b
 #define UVD_LMI_CTRL__VCPU_DATA_COHERENCY_EN_MASK 0x00200000L
 #define UVD_LMI_CTRL__VCPU_DATA_COHERENCY_EN__SHIFT 0x00000015
Signature · 6 lines
2.15.0

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

RFC 3/7 drm/amdgpu/gmc6: don't use vram location programmed by the vbios

In reply to a message not in the archive

On SI chips, fb location programmed by the vbios (40-bit address) is out of reach of the UVD memory controller, which supports only 32-bits.

This partially reverts following commits:
commit e4f6b39e8bcd ("drm/amdgpu: remove *_mc_access from display funcs") commit 71086a3e8470 ("drm/amdgpu/gmc6: drop fb location programming") commit ba3a5b83dd9b ("drm/amdgpu/gmc6: use the vram location programmed by the vbios")

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h |   6 ++
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c    | 114 ++++++++++++++++++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.h    |   5 ++
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c    |  40 ++++++++---
 4 files changed, 155 insertions(+), 10 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +6 -0
index 4069a3b2f55f..0bd916bd4c08 100644
@@ -262,6 +262,12 @@ struct amdgpu_audio {
 	int num_pins;
 };
 
+struct amdgpu_mode_mc_save {
+	u32 vga_render_control;
+	u32 vga_hdp_control;
+	bool crtc_enabled[AMDGPU_MAX_CRTCS];
+};
+
 struct amdgpu_display_funcs {
 	/* display watermarks */
 	void (*bandwidth_update)(struct amdgpu_device *adev);
drivers/gpu/drm/amd/amdgpu/dce_v6_0.c +112 -2

120 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/dce_v6_0.h +5 -0
index 7b546b596de1..35134523f53d 100644
@@ -28,5 +28,10 @@ extern const struct amdgpu_ip_block_version dce_v6_0_ip_block;
 extern const struct amdgpu_ip_block_version dce_v6_4_ip_block;
 
 void dce_v6_0_disable_dce(struct amdgpu_device *adev);
+void dce_v6_0_stop_mc_access(struct amdgpu_device *adev,
+			     struct amdgpu_mode_mc_save *save);
+void dce_v6_0_resume_mc_access(struct amdgpu_device *adev,
+			       struct amdgpu_mode_mc_save *save);
+void dce_v6_0_set_vga_render_state(struct amdgpu_device *adev, bool render);
 
 #endif
drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c +32 -8
index d2a43db22cff..3f891f22af93 100644
@@ -24,6 +24,7 @@
 #include <drm/drmP.h>
 #include "amdgpu.h"
 #include "gmc_v6_0.h"
+#include "dce_v6_0.h"
 #include "amdgpu_ucode.h"
 
 #include "bif/bif_3_0_d.h"
@@ -66,10 +67,14 @@ static const u32 crtc_offsets[6] =
 	SI_CRTC5_REGISTER_OFFSET
 };
 
-static void gmc_v6_0_mc_stop(struct amdgpu_device *adev)
+static void gmc_v6_0_mc_stop(struct amdgpu_device *adev,
+			     struct amdgpu_mode_mc_save *save)
 {
 	u32 blackout;
 
+	if (adev->mode_info.num_crtc)
+		dce_v6_0_stop_mc_access(adev, save);
+
 	gmc_v6_0_wait_for_idle((void *)adev);
 
 	blackout = RREG32(mmMC_SHARED_BLACKOUT_CNTL);
@@ -86,7 +91,8 @@ static void gmc_v6_0_mc_stop(struct amdgpu_device *adev)
 
 }
 
-static void gmc_v6_0_mc_resume(struct amdgpu_device *adev)
+static void gmc_v6_0_mc_resume(struct amdgpu_device *adev,
+			       struct amdgpu_mode_mc_save *save)
 {
 	u32 tmp;
 
@@ -98,6 +104,9 @@ static void gmc_v6_0_mc_resume(struct amdgpu_device *adev)
 	tmp = REG_SET_FIELD(0, BIF_FB_EN, FB_READ_EN, 1);
 	tmp = REG_SET_FIELD(tmp, BIF_FB_EN, FB_WRITE_EN, 1);
 	WREG32(mmBIF_FB_EN, tmp);
+
+	if (adev->mode_info.num_crtc)
+		dce_v6_0_resume_mc_access(adev, save);
 }
 
 static int gmc_v6_0_init_microcode(struct amdgpu_device *adev)
@@ -219,20 +228,19 @@ static int gmc_v6_0_mc_load_microcode(struct amdgpu_device *adev)
 static void gmc_v6_0_vram_gtt_location(struct amdgpu_device *adev,
 				       struct amdgpu_mc *mc)
 {
-	u64 base = RREG32(mmMC_VM_FB_LOCATION) & 0xFFFF;
-	base <<= 24;
-
 	if (mc->mc_vram_size > 0xFFC0000000ULL) {
 		dev_warn(adev->dev, "limiting VRAM\n");
 		mc->real_vram_size = 0xFFC0000000ULL;
 		mc->mc_vram_size = 0xFFC0000000ULL;
 	}
-	amdgpu_vram_location(adev, &adev->mc, base);
+	amdgpu_vram_location(adev, &adev->mc, 0);
 	amdgpu_gart_location(adev, mc);
 }
 
 static void gmc_v6_0_mc_program(struct amdgpu_device *adev)
 {
+	struct amdgpu_mode_mc_save save;
+	u32 tmp;
 	int i, j;
 
 	/* Initialize HDP */
@@ -245,6 +253,11 @@ static void gmc_v6_0_mc_program(struct amdgpu_device *adev)
 	}
 	WREG32(mmHDP_REG_COHERENCY_FLUSH_CNTL, 0);
 
+	if (adev->mode_info.num_crtc)
+		dce_v6_0_set_vga_render_state(adev, false);
+
+	gmc_v6_0_mc_stop(adev, &save);
+
 	if (gmc_v6_0_wait_for_idle((void *)adev)) {
 		dev_warn(adev->dev, "Wait for MC idle timedout !\n");
 	}
@@ -269,6 +282,15 @@ static void gmc_v6_0_mc_program(struct amdgpu_device *adev)
 	       adev->mc.vram_end >> 12);
 	WREG32(mmMC_VM_SYSTEM_APERTURE_DEFAULT_ADDR,
 	       adev->vram_scratch.gpu_addr >> 12);
+
+	tmp = ((adev->mc.vram_end >> 24) & 0xFFFF) << 16;
+	tmp |= ((adev->mc.vram_start >> 24) & 0xFFFF);
+	WREG32(mmMC_VM_FB_LOCATION, tmp);
+	/* XXX double check these! */
+	WREG32(mmHDP_NONSURFACE_BASE, (adev->mc.vram_start >> 8));
+	WREG32(mmHDP_NONSURFACE_INFO, (2 << 7) | (1 << 30));
+	WREG32(mmHDP_NONSURFACE_SIZE, 0x3FFFFFFF);
+
 	WREG32(mmMC_VM_AGP_BASE, 0);
 	WREG32(mmMC_VM_AGP_TOP, 0x0FFFFFFF);
 	WREG32(mmMC_VM_AGP_BOT, 0x0FFFFFFF);
@@ -276,6 +298,7 @@ static void gmc_v6_0_mc_program(struct amdgpu_device *adev)
 	if (gmc_v6_0_wait_for_idle((void *)adev)) {
 		dev_warn(adev->dev, "Wait for MC idle timedout !\n");
 	}
+	gmc_v6_0_mc_resume(adev, &save);
 }
 
 static int gmc_v6_0_mc_init(struct amdgpu_device *adev)
@@ -997,6 +1020,7 @@ static int gmc_v6_0_wait_for_idle(void *handle)
 static int gmc_v6_0_soft_reset(void *handle)
 {
 	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	struct amdgpu_mode_mc_save save;
 	u32 srbm_soft_reset = 0;
 	u32 tmp = RREG32(mmSRBM_STATUS);
 
@@ -1012,7 +1036,7 @@ static int gmc_v6_0_soft_reset(void *handle)
 	}
 
 	if (srbm_soft_reset) {
-		gmc_v6_0_mc_stop(adev);
+		gmc_v6_0_mc_stop(adev, &save);
 		if (gmc_v6_0_wait_for_idle(adev)) {
 			dev_warn(adev->dev, "Wait for GMC idle timed out !\n");
 		}
@@ -1032,7 +1056,7 @@ static int gmc_v6_0_soft_reset(void *handle)
 
 		udelay(50);
 
-		gmc_v6_0_mc_resume(adev);
+		gmc_v6_0_mc_resume(adev, &save);
 		udelay(50);
 	}
 
Signature · 6 lines
2.15.0

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

RFC 4/7 drm/amdgpu/uvd4: add early init stage functions for uvd 4.0

In reply to a message not in the archive

Add uvd ring and interrupt functions

---
 drivers/gpu/drm/amd/amdgpu/sid.h      |  14 +-
 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c | 282 ++++++++++++++++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h |  29 ++++
 3 files changed, 319 insertions(+), 6 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h
drivers/gpu/drm/amd/amdgpu/sid.h +8 -6
index 59f8fc944ecb..42556e2fafd4 100644
@@ -1646,16 +1646,20 @@
 /*
  * PM4
  */
-#define PACKET0(reg, n)	((RADEON_PACKET_TYPE0 << 30) |			\
-			 (((reg) >> 2) & 0xFFFF) |			\
+#define PACKET_TYPE0 0
+#define PACKET_TYPE1 1
+#define PACKET_TYPE2 2
+#define PACKET_TYPE3 3
+
+#define PACKET0(reg, n)	((PACKET_TYPE0 << 30) |				\
+			 ((reg) & 0xFFFF) |				\
 			 ((n) & 0x3FFF) << 16)
 #define CP_PACKET2			0x80000000
 #define		PACKET2_PAD_SHIFT		0
 #define		PACKET2_PAD_MASK		(0x3fffffff << 0)
 
 #define PACKET2(v)	(CP_PACKET2 | REG_SET(PACKET2_PAD, (v)))
-#define RADEON_PACKET_TYPE3 3
-#define PACKET3(op, n)	((RADEON_PACKET_TYPE3 << 30) |			\
+#define PACKET3(op, n)	((PACKET_TYPE3 << 30) |				\
 			 (((op) & 0xFF) << 8) |				\
 			 ((n) & 0x3FFF) << 16)
 
@@ -2407,8 +2411,6 @@
 #define MC_SEQ_MISC0__MT__HBM    0x60000000
 #define MC_SEQ_MISC0__MT__DDR3   0xB0000000
 
-
-
 #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/uvd_v4_0.c new file +282 -0

282 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h new file +29 -0
new file mode 100644
index 000000000000..e74147c86643
@@ -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 __UVD_V4_0_H__
+#define __UVD_V4_0_H__
+
+extern const struct amdgpu_ip_block_version uvd_v4_0_ip_block;
+
+#endif
Signature · 6 lines
2.15.0

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

RFC 5/7 drm/amdgpu/uvd4: add sw init and fini stages' functions for uvd 4.0

In reply to a message not in the archive

Load firmware and initialize uvd ring

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c | 14 ++++++++++++
 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c   | 40 +++++++++++++++++++++++++++++++++
 2 files changed, 54 insertions(+)
drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c +14 -0
index be607b2be4e9..59ae2f2012ad 100644
@@ -52,6 +52,9 @@
 #define FW_1_66_16	((1 << 24) | (66 << 16) | (16 << 8))
 
 /* Firmware Names */
+#ifdef CONFIG_DRM_AMDGPU_SI
+#define FIRMWARE_TAHITI		"radeon/tahiti_uvd.bin"
+#endif
 #ifdef CONFIG_DRM_AMDGPU_CIK
 #define FIRMWARE_BONAIRE	"radeon/bonaire_uvd.bin"
 #define FIRMWARE_KABINI	"radeon/kabini_uvd.bin"
@@ -94,6 +97,9 @@ struct amdgpu_uvd_cs_ctx {
 	unsigned *buf_sizes;
 };
 
+#ifdef CONFIG_DRM_AMDGPU_SI
+MODULE_FIRMWARE(FIRMWARE_TAHITI);
+#endif
 #ifdef CONFIG_DRM_AMDGPU_CIK
 MODULE_FIRMWARE(FIRMWARE_BONAIRE);
 MODULE_FIRMWARE(FIRMWARE_KABINI);
@@ -126,6 +132,14 @@ int amdgpu_uvd_sw_init(struct amdgpu_device *adev)
 	INIT_DELAYED_WORK(&adev->uvd.idle_work, amdgpu_uvd_idle_work_handler);
 
 	switch (adev->asic_type) {
+#ifdef CONFIG_DRM_AMDGPU_SI
+	case CHIP_TAHITI:
+	case CHIP_VERDE:
+	case CHIP_PITCAIRN:
+	case CHIP_OLAND:
+		fw_name = FIRMWARE_TAHITI;
+		break;
+#endif
 #ifdef CONFIG_DRM_AMDGPU_CIK
 	case CHIP_BONAIRE:
 		fw_name = FIRMWARE_BONAIRE;
drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c +40 -0
index 127269a0a90c..cfa6959db43d 100644
@@ -91,6 +91,44 @@ static int uvd_v4_0_early_init(void *handle)
 	return 0;
 }
 
+static int uvd_v4_0_sw_init(void *handle)
+{
+	struct amdgpu_ring *ring;
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+	int r;
+
+	/* UVD TRAP */
+	r = amdgpu_irq_add_id(adev, AMDGPU_IH_CLIENTID_LEGACY, 124, &adev->uvd.irq);
+	if (r)
+		return r;
+
+	r = amdgpu_uvd_sw_init(adev);
+	if (r)
+		return r;
+
+	r = amdgpu_uvd_resume(adev);
+	if (r)
+		return r;
+
+	ring = &adev->uvd.ring;
+	sprintf(ring->name, "uvd");
+	r = amdgpu_ring_init(adev, ring, 512, &adev->uvd.irq, 0);
+
+	return r;
+}
+
+static int uvd_v4_0_sw_fini(void *handle)
+{
+	int r;
+	struct amdgpu_device *adev = (struct amdgpu_device *)handle;
+
+	r = amdgpu_uvd_suspend(adev);
+	if (r)
+		return r;
+
+	return amdgpu_uvd_sw_fini(adev);
+}
+
 /**
  * uvd_v4_0_ring_emit_fence - emit an fence & trap command
  *
@@ -229,6 +267,8 @@ static const struct amd_ip_funcs uvd_v4_0_ip_funcs = {
 	.name = "uvd_v4_0",
 	.early_init = uvd_v4_0_early_init,
 	.late_init = NULL,
+	.sw_init = uvd_v4_0_sw_init,
+	.sw_fini = uvd_v4_0_sw_fini,
 };
 
 static const struct amdgpu_ring_funcs uvd_v4_0_ring_funcs = {
Signature · 6 lines
2.15.0

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

RFC 6/7 drm/amdgpu/uvd4: add hardware specific functions for uvd 4.0

In reply to a message not in the archive

Add logic for starting, stopping, suspending and resuming uvd block

---
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c |   7 -
 drivers/gpu/drm/amd/amdgpu/si.c       | 250 ++++++++++++++++-
 drivers/gpu/drm/amd/amdgpu/sid.h      |  22 +-
 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c | 488 ++++++++++++++++++++++++++++++++++
 4 files changed, 736 insertions(+), 31 deletions(-)
drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c +0 -7
index 9430d4809b53..0744117ee7d2 100644
@@ -1695,13 +1695,6 @@ static void gfx_v6_0_gpu_init(struct amdgpu_device *adev)
 	WREG32(mmDMA_TILING_CONFIG + DMA0_REGISTER_OFFSET, gb_addr_config);
 	WREG32(mmDMA_TILING_CONFIG + DMA1_REGISTER_OFFSET, gb_addr_config);
 
-#if 0
-	if (adev->has_uvd) {
-		WREG32(mmUVD_UDEC_ADDR_CONFIG, gb_addr_config);
-		WREG32(mmUVD_UDEC_DB_ADDR_CONFIG, gb_addr_config);
-		WREG32(mmUVD_UDEC_DBW_ADDR_CONFIG, gb_addr_config);
-	}
-#endif
 	gfx_v6_0_tiling_mode_table_init(adev);
 
 	gfx_v6_0_setup_rb(adev);
drivers/gpu/drm/amd/amdgpu/si.c +247 -3

270 lines not on this page · raw message

drivers/gpu/drm/amd/amdgpu/sid.h +1 -21
index 42556e2fafd4..1fbe62e95c94 100644
@@ -1621,27 +1621,7 @@
 /*
  * UVD
  */
-#define UVD_UDEC_ADDR_CONFIG				0x3bd3
-#define UVD_UDEC_DB_ADDR_CONFIG				0x3bd4
-#define UVD_UDEC_DBW_ADDR_CONFIG			0x3bd5
-#define UVD_RBC_RB_RPTR					0x3da4
-#define UVD_RBC_RB_WPTR					0x3da5
-#define UVD_STATUS					0x3daf
-
-#define	UVD_CGC_CTRL					0x3dc2
-#	define DCM					(1 << 0)
-#	define CG_DT(x)					((x) << 2)
-#	define CG_DT_MASK				(0xf << 2)
-#	define CLK_OD(x)				((x) << 6)
-#	define CLK_OD_MASK				(0x1f << 6)
-
- /* UVD CTX indirect */
-#define	UVD_CGC_MEM_CTRL				0xC0
-#define	UVD_CGC_CTRL2					0xC1
-#	define DYN_OR_EN				(1 << 0)
-#	define DYN_RR_EN				(1 << 1)
-#	define G_DIV_ID(x)				((x) << 2)
-#	define G_DIV_ID_MASK				(0x7 << 2)
+#define UVD_VCPU_CHIP_ID				0x3d35
 
 /*
  * PM4
drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c +488 -0

526 lines not on this page · raw message

Signature · 6 lines
2.15.0

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

RFC 7/7 drm/amdgpu: enable UVD for SI

In reply to a message not in the archive
---
 drivers/gpu/drm/amd/amdgpu/Makefile | 3 ++-
 drivers/gpu/drm/amd/amdgpu/si.c     | 5 +++--
 2 files changed, 5 insertions(+), 3 deletions(-)
drivers/gpu/drm/amd/amdgpu/Makefile +2 -1
index 6a025c476b37..5c1bae35d2aa 100644
@@ -38,7 +38,8 @@ amdgpu-$(CONFIG_DRM_AMDGPU_CIK)+= cik.o cik_ih.o kv_smc.o kv_dpm.o \
 	ci_smc.o ci_dpm.o dce_v8_0.o gfx_v7_0.o cik_sdma.o uvd_v4_2.o vce_v2_0.o \
 	amdgpu_amdkfd_gfx_v7.o
 
-amdgpu-$(CONFIG_DRM_AMDGPU_SI)+= si.o gmc_v6_0.o gfx_v6_0.o si_ih.o si_dma.o dce_v6_0.o si_dpm.o si_smc.o
+amdgpu-$(CONFIG_DRM_AMDGPU_SI)+= si.o gmc_v6_0.o gfx_v6_0.o si_ih.o si_dma.o \
+	dce_v6_0.o si_dpm.o si_smc.o uvd_v4_0.o
 
 amdgpu-y += \
 	vi.o mxgpu_vi.o nbio_v6_1.o soc15.o mxgpu_ai.o nbio_v7_0.o
drivers/gpu/drm/amd/amdgpu/si.c +3 -2
index bc6fd1ff4f86..0e0445602215 100644
@@ -38,6 +38,7 @@
 #include "gmc_v6_0.h"
 #include "si_dma.h"
 #include "dce_v6_0.h"
+#include "uvd_v4_0.h"
 #include "si.h"
 #include "dce_virtual.h"
 #include "gca/gfx_6_0_d.h"
@@ -2214,7 +2215,7 @@ int si_set_ip_blocks(struct amdgpu_device *adev)
 			amdgpu_ip_block_add(adev, &dce_v6_0_ip_block);
 		amdgpu_ip_block_add(adev, &gfx_v6_0_ip_block);
 		amdgpu_ip_block_add(adev, &si_dma_ip_block);
-		/* amdgpu_ip_block_add(adev, &uvd_v3_1_ip_block); */
+		amdgpu_ip_block_add(adev, &uvd_v4_0_ip_block);
 		/* amdgpu_ip_block_add(adev, &vce_v1_0_ip_block); */
 		break;
 	case CHIP_OLAND:
@@ -2228,7 +2229,7 @@ int si_set_ip_blocks(struct amdgpu_device *adev)
 			amdgpu_ip_block_add(adev, &dce_v6_4_ip_block);
 		amdgpu_ip_block_add(adev, &gfx_v6_0_ip_block);
 		amdgpu_ip_block_add(adev, &si_dma_ip_block);
-		/* amdgpu_ip_block_add(adev, &uvd_v3_1_ip_block); */
+		amdgpu_ip_block_add(adev, &uvd_v4_0_ip_block);
 		/* amdgpu_ip_block_add(adev, &vce_v1_0_ip_block); */
 		break;
 	case CHIP_HAINAN:
Signature · 6 lines
2.15.0

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

Hi,

Following series implements UVD support for SI in amdgpu driver. Code is based on CIK's UVD support in amdgpu and SI's UVD support in radeon drivers. To work, it requires tahiti uvd firmware with added header - I've created simple script to produce exactly this, so if anyone is interested it can be found here:
https://gist.github.com/anonymous/6d974a970340f7f64b6fcc4f95267e43

Code is based on amd-staging-drm-next branch in Alex's tree. After applying these patches, uvd boots up and seems to work ok. I've tested it with vdpauinfo and mpv.

Quoted 6 lines

Some comments/issues for the patches:
1. To make uvd work, I had to bring back fb location programming. Using location programmed by vbios, vram location is not available for uvd mc (at least on my machine) due to too wide address. Starting address is 40-bit long for fb, but uvd mc supports only 32-bits (judging by comments in amdgpu code and actual code in radeon driver)

Something else must be going on. The vram location is irrelevant with respect to the limitations of UVD. I think the limitations with UVD are more to do with the location of the active buffers relative to each other rather than the absolute location of some aperture in the GPU's address space. CI has the same limitation as I recall so there is probably a bug somewhere. Windows has used the fb location as set by the vbios since evergreen, so it definitely should work.

Quoted 5 lines

2. I don't know why, but I couldn't get the uvd to boot without setting uvd mc offsets before starting other engines. Because of that I set it in .sw_init function. In my opinion this should be fixed as it generally doesn't follow amdgpu driver architecture (hardware setup during software setup stage) and probably will break suspending and resume (I didn't test it). As I mentioned,

Quoted 8 lines

I couldn't figure out why this is happening, so I count on help with finding fix for this.
3. I found some redefinitions in include/asic_reg/uvd/uvd_4_0_sh_mask.h. I guess this file is generated, so fix should be made wherever it is generated from. For now I removed offending lines just to silence the compiler warnings.
4. I'm not sure whether I choose the right version for the uvd. Existing code in si.c suggested that it should be 3.1, however I went with the 4.0, because for this version there are available new style headers.

I think the regs are pretty much the same between 3.x and 4.x so it should be fine.

Alex

Quoted 30 lines

Regards,
Piotr

Piotr Redlewski (7):
drm/amdgpu: remove duplicated definitions of some of the SI registers drm/amdgpu/uvd4: fix some register's mask and shift definitions drm/amdgpu/gmc6: don't use vram location programmed by the vbios drm/amdgpu/uvd4: add early init stage functions for uvd 4.0 drm/amdgpu/uvd4: add sw init and fini stages' functions for uvd 4.0 drm/amdgpu/uvd4: add hardware specific functions for uvd 4.0 drm/amdgpu: enable UVD for SI

 drivers/gpu/drm/amd/amdgpu/Makefile                |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h           |   6 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c            |  14 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c              | 114 ++-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.h              |   5 +
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c              |   7 -
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c              |  40 +-
 drivers/gpu/drm/amd/amdgpu/si.c                    | 256 ++++++-
 drivers/gpu/drm/amd/amdgpu/si_ih.c                 |   3 +
 drivers/gpu/drm/amd/amdgpu/sid.h                   |  52 +-
 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c              | 810 +++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h              |  29 +
 .../drm/amd/include/asic_reg/uvd/uvd_4_0_sh_mask.h |   2 -
 13 files changed, 1273 insertions(+), 68 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h
Quoted 7 lines

--
2.15.0

_______________________________________________
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

A message that is not in the archive (sent off-list or not yet received): CADnq5_Oc98DJ8+d-qAv5Q4GQ5aasw0s+tXgHjyMFtG4KCR1Z5w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org

#11 lore raw

Am 09.11.2017 um 00:54 schrieb Alex Deucher:

Quoted 19 lines · Piotr Redlewski
Quoted 12 lines

Hi,

Following series implements UVD support for SI in amdgpu driver. Code is based on CIK's UVD support in amdgpu and SI's UVD support in radeon drivers. To work, it requires tahiti uvd firmware with added header - I've created simple script to produce exactly this, so if anyone is interested it can be found here:
https://gist.github.com/anonymous/6d974a970340f7f64b6fcc4f95267e43

Code is based on amd-staging-drm-next branch in Alex's tree. After applying these patches, uvd boots up and seems to work ok. I've tested it with vdpauinfo and mpv.

Quoted 6 lines

Some comments/issues for the patches:
1. To make uvd work, I had to bring back fb location programming. Using location programmed by vbios, vram location is not available for uvd mc (at least on my machine) due to too wide address. Starting address is 40-bit long for fb, but uvd mc supports only 32-bits (judging by comments in amdgpu code and actual code in radeon driver)

Quoted 15 lines

Something else must be going on. The vram location is irrelevant with respect to the limitations of UVD. I think the limitations with UVD are more to do with the location of the active buffers relative to each other rather than the absolute location of some aperture in the GPU's address space. CI has the same limitation as I recall so there is probably a bug somewhere. Windows has used the fb location as set by the vbios since evergreen, so it definitely should work.

Quoted 7 lines

2. I don't know why, but I couldn't get the uvd to boot without setting uvd mc offsets before starting other engines. Because of that I set it in .sw_init function. In my opinion this should be fixed as it generally doesn't follow amdgpu driver architecture (hardware setup during software setup stage) and probably will break suspending and resume (I didn't test it). As I mentioned, I couldn't figure out why this is happening, so I count on help with finding fix for this.

It's just that your initialization order is incorrect.

Try to add the UVD block a bit earlier (before the PP lib block I think) in si_set_ip_blocks.

Regards,
Christian.

Quoted 44 lines
Quoted 6 lines

3. I found some redefinitions in include/asic_reg/uvd/uvd_4_0_sh_mask.h. I guess this file is generated, so fix should be made wherever it is generated from. For now I removed offending lines just to silence the compiler warnings.
4. I'm not sure whether I choose the right version for the uvd. Existing code in si.c suggested that it should be 3.1, however I went with the 4.0, because for this version there are available new style headers.

I think the regs are pretty much the same between 3.x and 4.x so it should be fine.

Alex

Quoted 32 lines

Regards,
Piotr

Piotr Redlewski (7):
drm/amdgpu: remove duplicated definitions of some of the SI registers drm/amdgpu/uvd4: fix some register's mask and shift definitions drm/amdgpu/gmc6: don't use vram location programmed by the vbios drm/amdgpu/uvd4: add early init stage functions for uvd 4.0 drm/amdgpu/uvd4: add sw init and fini stages' functions for uvd 4.0 drm/amdgpu/uvd4: add hardware specific functions for uvd 4.0 drm/amdgpu: enable UVD for SI

  drivers/gpu/drm/amd/amdgpu/Makefile                |   3 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h           |   6 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c            |  14 +
  drivers/gpu/drm/amd/amdgpu/dce_v6_0.c              | 114 ++-
  drivers/gpu/drm/amd/amdgpu/dce_v6_0.h              |   5 +
  drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c              |   7 -
  drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c              |  40 +-
  drivers/gpu/drm/amd/amdgpu/si.c                    | 256 ++++++-
  drivers/gpu/drm/amd/amdgpu/si_ih.c                 |   3 +
  drivers/gpu/drm/amd/amdgpu/sid.h                   |  52 +-
  drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c              | 810 +++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h              |  29 +
  .../drm/amd/include/asic_reg/uvd/uvd_4_0_sh_mask.h |   2 -
  13 files changed, 1273 insertions(+), 68 deletions(-)

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

--
2.15.0

Quoted 8 lines
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

_______________________________________________
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): c2e6d813-401b-2bfc-6118-3df1c3e7c046-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#13 lore raw
Quoted 36 lines · Christian König

Am 09.11.2017 um 00:54 schrieb Alex Deucher:

Quoted 19 lines · Piotr Redlewski
Quoted 12 lines

Hi,

Following series implements UVD support for SI in amdgpu driver. Code is based on CIK's UVD support in amdgpu and SI's UVD support in radeon drivers. To work, it requires tahiti uvd firmware with added header - I've created simple script to produce exactly this, so if anyone is interested it can be found here:
https://gist.github.com/anonymous/6d974a970340f7f64b6fcc4f95267e43

Code is based on amd-staging-drm-next branch in Alex's tree. After applying these patches, uvd boots up and seems to work ok. I've tested it with vdpauinfo and mpv.

Quoted 6 lines

Some comments/issues for the patches:
1. To make uvd work, I had to bring back fb location programming. Using location programmed by vbios, vram location is not available for uvd mc (at least on my machine) due to too wide address. Starting address is 40-bit long for fb, but uvd mc supports only 32-bits (judging by comments in amdgpu code and actual code in radeon driver)

Quoted 15 lines

Something else must be going on. The vram location is irrelevant with respect to the limitations of UVD. I think the limitations with UVD are more to do with the location of the active buffers relative to each other rather than the absolute location of some aperture in the GPU's address space. CI has the same limitation as I recall so there is probably a bug somewhere. Windows has used the fb location as set by the vbios since evergreen, so it definitely should work.

Quoted 7 lines

2. I don't know why, but I couldn't get the uvd to boot without setting uvd mc offsets before starting other engines. Because of that I set it in .sw_init function. In my opinion this should be fixed as it generally doesn't follow amdgpu driver architecture (hardware setup during software setup stage) and probably will break suspending and resume (I didn't test it). As I mentioned, I couldn't figure out why this is happening, so I count on help with finding fix for this.

Quoted 4 lines

It's just that your initialization order is incorrect.

Try to add the UVD block a bit earlier (before the PP lib block I think) in si_set_ip_blocks.

Unfortunately it looks that's not it. I've tried to move up the UVD block in the blocks' list, and no matter where it is put it won't boot without configuring UVD mc in the software init phase. Moreover, even with UVD mc initialization in the software init, UVD won't boot when placed before gfx block. I don't know whether this means anything.

Any other ideas?

Regards,
Piotr

Quoted 58 lines

Regards,
Christian.

Quoted 44 lines
Quoted 6 lines

3. I found some redefinitions in include/asic_reg/uvd/uvd_4_0_sh_mask.h. I guess this file is generated, so fix should be made wherever it is generated from. For now I removed offending lines just to silence the compiler warnings.
4. I'm not sure whether I choose the right version for the uvd. Existing code in si.c suggested that it should be 3.1, however I went with the 4.0, because for this version there are available new style headers.

I think the regs are pretty much the same between 3.x and 4.x so it should be fine.

Alex

Quoted 32 lines

Regards,
Piotr

Piotr Redlewski (7):
drm/amdgpu: remove duplicated definitions of some of the SI registers drm/amdgpu/uvd4: fix some register's mask and shift definitions drm/amdgpu/gmc6: don't use vram location programmed by the vbios drm/amdgpu/uvd4: add early init stage functions for uvd 4.0 drm/amdgpu/uvd4: add sw init and fini stages' functions for uvd 4.0 drm/amdgpu/uvd4: add hardware specific functions for uvd 4.0 drm/amdgpu: enable UVD for SI

  drivers/gpu/drm/amd/amdgpu/Makefile                |   3 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h           |   6 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c            |  14 +
  drivers/gpu/drm/amd/amdgpu/dce_v6_0.c              | 114 ++-
  drivers/gpu/drm/amd/amdgpu/dce_v6_0.h              |   5 +
  drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c              |   7 -
  drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c              |  40 +-
  drivers/gpu/drm/amd/amdgpu/si.c                    | 256 ++++++-
  drivers/gpu/drm/amd/amdgpu/si_ih.c                 |   3 +
  drivers/gpu/drm/amd/amdgpu/sid.h                   |  52 +-
  drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c              | 810 +++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h              |  29 +
  .../drm/amd/include/asic_reg/uvd/uvd_4_0_sh_mask.h |   2 -
  13 files changed, 1273 insertions(+), 68 deletions(-)

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

--
2.15.0

Quoted 8 lines
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

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

A message that is not in the archive (sent off-list or not yet received): 20171109143743.GB547-vEgOWn/6yzlBufL/[email protected]

#15 lore raw

Am 09.11.2017 um 15:37 schrieb Piotr Redlewski:

Quoted 40 lines · Christian König
Quoted 35 lines

Am 09.11.2017 um 00:54 schrieb Alex Deucher:

Quoted 19 lines · Piotr Redlewski
Quoted 12 lines

Hi,

Following series implements UVD support for SI in amdgpu driver. Code is based on CIK's UVD support in amdgpu and SI's UVD support in radeon drivers. To work, it requires tahiti uvd firmware with added header - I've created simple script to produce exactly this, so if anyone is interested it can be found here:
https://gist.github.com/anonymous/6d974a970340f7f64b6fcc4f95267e43

Code is based on amd-staging-drm-next branch in Alex's tree. After applying these patches, uvd boots up and seems to work ok. I've tested it with vdpauinfo and mpv.

Quoted 6 lines

Some comments/issues for the patches:
1. To make uvd work, I had to bring back fb location programming. Using location programmed by vbios, vram location is not available for uvd mc (at least on my machine) due to too wide address. Starting address is 40-bit long for fb, but uvd mc supports only 32-bits (judging by comments in amdgpu code and actual code in radeon driver)

Quoted 15 lines

Something else must be going on. The vram location is irrelevant with respect to the limitations of UVD. I think the limitations with UVD are more to do with the location of the active buffers relative to each other rather than the absolute location of some aperture in the GPU's address space. CI has the same limitation as I recall so there is probably a bug somewhere. Windows has used the fb location as set by the vbios since evergreen, so it definitely should work.

Quoted 7 lines

2. I don't know why, but I couldn't get the uvd to boot without setting uvd mc offsets before starting other engines. Because of that I set it in .sw_init function. In my opinion this should be fixed as it generally doesn't follow amdgpu driver architecture (hardware setup during software setup stage) and probably will break suspending and resume (I didn't test it). As I mentioned, I couldn't figure out why this is happening, so I count on help with finding fix for this.

Quoted 4 lines

It's just that your initialization order is incorrect.

Try to add the UVD block a bit earlier (before the PP lib block I think) in si_set_ip_blocks.

Quoted 7 lines

Unfortunately it looks that's not it. I've tried to move up the UVD block in the blocks' list, and no matter where it is put it won't boot without configuring UVD mc in the software init phase. Moreover, even with UVD mc initialization in the software init, UVD won't boot when placed before gfx block. I don't know whether this means anything.

Any other ideas?

Yeah, I see this won't work without further modifications.

Need to discuss internally how we want to fix this.

Going to leave you a note when I know more,
Christian.

Quoted 64 lines

Regards,
Piotr

Quoted 60 lines

Regards,
Christian.

Quoted 44 lines
Quoted 6 lines

3. I found some redefinitions in include/asic_reg/uvd/uvd_4_0_sh_mask.h. I guess this file is generated, so fix should be made wherever it is generated from. For now I removed offending lines just to silence the compiler warnings.
4. I'm not sure whether I choose the right version for the uvd. Existing code in si.c suggested that it should be 3.1, however I went with the 4.0, because for this version there are available new style headers.

I think the regs are pretty much the same between 3.x and 4.x so it should be fine.

Alex

Quoted 32 lines

Regards,
Piotr

Piotr Redlewski (7):
drm/amdgpu: remove duplicated definitions of some of the SI registers drm/amdgpu/uvd4: fix some register's mask and shift definitions drm/amdgpu/gmc6: don't use vram location programmed by the vbios drm/amdgpu/uvd4: add early init stage functions for uvd 4.0 drm/amdgpu/uvd4: add sw init and fini stages' functions for uvd 4.0 drm/amdgpu/uvd4: add hardware specific functions for uvd 4.0 drm/amdgpu: enable UVD for SI

   drivers/gpu/drm/amd/amdgpu/Makefile                |   3 +-
   drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h           |   6 +
   drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c            |  14 +
   drivers/gpu/drm/amd/amdgpu/dce_v6_0.c              | 114 ++-
   drivers/gpu/drm/amd/amdgpu/dce_v6_0.h              |   5 +
   drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c              |   7 -
   drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c              |  40 +-
   drivers/gpu/drm/amd/amdgpu/si.c                    | 256 ++++++-
   drivers/gpu/drm/amd/amdgpu/si_ih.c                 |   3 +
   drivers/gpu/drm/amd/amdgpu/sid.h                   |  52 +-
   drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c              | 810 +++++++++++++++++++++
   drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h              |  29 +
   .../drm/amd/include/asic_reg/uvd/uvd_4_0_sh_mask.h |   2 -
   13 files changed, 1273 insertions(+), 68 deletions(-)

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

--
2.15.0

Quoted 8 lines
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

_______________________________________________
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

#16 lore raw
In reply to a message not in the archive
Quoted 20 lines · Alex Deucher
Quoted 12 lines · Piotr Redlewski

Hi,

Following series implements UVD support for SI in amdgpu driver. Code is based on CIK's UVD support in amdgpu and SI's UVD support in radeon drivers. To work, it requires tahiti uvd firmware with added header - I've created simple script to produce exactly this, so if anyone is interested it can be found here:
https://gist.github.com/anonymous/6d974a970340f7f64b6fcc4f95267e43

Code is based on amd-staging-drm-next branch in Alex's tree. After applying these patches, uvd boots up and seems to work ok. I've tested it with vdpauinfo and mpv.

Quoted 6 lines

Some comments/issues for the patches:
1. To make uvd work, I had to bring back fb location programming. Using location programmed by vbios, vram location is not available for uvd mc (at least on my machine) due to too wide address. Starting address is 40-bit long for fb, but uvd mc supports only 32-bits (judging by comments in amdgpu code and actual code in radeon driver)

Quoted 8 lines

Something else must be going on. The vram location is irrelevant with respect to the limitations of UVD. I think the limitations with UVD are more to do with the location of the active buffers relative to each other rather than the absolute location of some aperture in the GPU's address space. CI has the same limitation as I recall so there is probably a bug somewhere. Windows has used the fb location as set by the vbios since evergreen, so it definitely should work.

If this is the case, then there must be something missing in UVD mc controller programming. When using vbios, I get following location:
amdgpu 0000:01:00.0: VRAM: 2048M 0x000000F400000000 - 0x000000F47FFFFFFF (2048M used)

When UVD bo is created, it starts at address 0xf400243000 and this value is used for programming UVD mc offsets. Programming is done in the following way:
addr = (adev->uvd.gpu_addr + AMDGPU_UVD_FIRMWARE_OFFSET) >> 3; WREG32(mmUVD_VCPU_CACHE_OFFSET0, addr);

Because address of the bo is wider than 32-bit, this won't work. It would be the same if UVD bo would be created at the beginning of the VRAM.

Any ideas how to handle this?

Quoted 14 lines
Quoted 5 lines

2. I don't know why, but I couldn't get the uvd to boot without setting uvd mc offsets before starting other engines. Because of that I set it in .sw_init function. In my opinion this should be fixed as it generally doesn't follow amdgpu driver architecture (hardware setup during software setup stage) and probably will break suspending and resume (I didn't test it). As I mentioned,

Quoted 8 lines

I couldn't figure out why this is happening, so I count on help with finding fix for this.
3. I found some redefinitions in include/asic_reg/uvd/uvd_4_0_sh_mask.h. I guess this file is generated, so fix should be made wherever it is generated from. For now I removed offending lines just to silence the compiler warnings.
4. I'm not sure whether I choose the right version for the uvd. Existing code in si.c suggested that it should be 3.1, however I went with the 4.0, because for this version there are available new style headers.

Quoted 2 lines

I think the regs are pretty much the same between 3.x and 4.x so it should be fine.

Great.

Regards,
Piotr

Quoted 37 lines

Alex

Quoted 33 lines

Regards,
Piotr

Piotr Redlewski (7):
drm/amdgpu: remove duplicated definitions of some of the SI registers drm/amdgpu/uvd4: fix some register's mask and shift definitions drm/amdgpu/gmc6: don't use vram location programmed by the vbios drm/amdgpu/uvd4: add early init stage functions for uvd 4.0 drm/amdgpu/uvd4: add sw init and fini stages' functions for uvd 4.0 drm/amdgpu/uvd4: add hardware specific functions for uvd 4.0 drm/amdgpu: enable UVD for SI

 drivers/gpu/drm/amd/amdgpu/Makefile                |   3 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h           |   6 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c            |  14 +
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.c              | 114 ++-
 drivers/gpu/drm/amd/amdgpu/dce_v6_0.h              |   5 +
 drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c              |   7 -
 drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c              |  40 +-
 drivers/gpu/drm/amd/amdgpu/si.c                    | 256 ++++++-
 drivers/gpu/drm/amd/amdgpu/si_ih.c                 |   3 +
 drivers/gpu/drm/amd/amdgpu/sid.h                   |  52 +-
 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c              | 810 +++++++++++++++++++++
 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h              |  29 +
 .../drm/amd/include/asic_reg/uvd/uvd_4_0_sh_mask.h |   2 -
 13 files changed, 1273 insertions(+), 68 deletions(-)
 create mode 100644 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c
 create mode 100644 drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h

--
2.15.0

Quoted 8 lines
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

_______________________________________________
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): 20171109095407.GA1481-vEgOWn/6yzlBufL/[email protected]

#18 lore raw

Am 09.11.2017 um 10:54 schrieb Piotr Redlewski:

Quoted 37 lines · Alex Deucher
Quoted 19 lines · Piotr Redlewski
Quoted 12 lines

Hi,

Following series implements UVD support for SI in amdgpu driver. Code is based on CIK's UVD support in amdgpu and SI's UVD support in radeon drivers. To work, it requires tahiti uvd firmware with added header - I've created simple script to produce exactly this, so if anyone is interested it can be found here:
https://gist.github.com/anonymous/6d974a970340f7f64b6fcc4f95267e43

Code is based on amd-staging-drm-next branch in Alex's tree. After applying these patches, uvd boots up and seems to work ok. I've tested it with vdpauinfo and mpv.

Quoted 6 lines

Some comments/issues for the patches:
1. To make uvd work, I had to bring back fb location programming. Using location programmed by vbios, vram location is not available for uvd mc (at least on my machine) due to too wide address. Starting address is 40-bit long for fb, but uvd mc supports only 32-bits (judging by comments in amdgpu code and actual code in radeon driver)

Quoted 8 lines

Something else must be going on. The vram location is irrelevant with respect to the limitations of UVD. I think the limitations with UVD are more to do with the location of the active buffers relative to each other rather than the absolute location of some aperture in the GPU's address space. CI has the same limitation as I recall so there is probably a bug somewhere. Windows has used the fb location as set by the vbios since evergreen, so it definitely should work.

If this is the case, then there must be something missing in UVD mc controller programming. When using vbios, I get following location:
amdgpu 0000:01:00.0: VRAM: 2048M 0x000000F400000000 - 0x000000F47FFFFFFF (2048M used)

When UVD bo is created, it starts at address 0xf400243000 and this value is used for programming UVD mc offsets. Programming is done in the following way:
addr = (adev->uvd.gpu_addr + AMDGPU_UVD_FIRMWARE_OFFSET) >> 3; WREG32(mmUVD_VCPU_CACHE_OFFSET0, addr);

Quoted 4 lines

Because address of the bo is wider than 32-bit, this won't work. It would be the same if UVD bo would be created at the beginning of the VRAM.

Any ideas how to handle this?

Are you programming UVD_LMI_EXT40_ADDR?

But I'm not sure if we ever handled that correctly in the SI code.

Regards,
Christian.

Quoted 59 lines
Quoted 14 lines
Quoted 14 lines

2. I don't know why, but I couldn't get the uvd to boot without setting uvd mc offsets before starting other engines. Because of that I set it in .sw_init function. In my opinion this should be fixed as it generally doesn't follow amdgpu driver architecture (hardware setup during software setup stage) and probably will break suspending and resume (I didn't test it). As I mentioned, I couldn't figure out why this is happening, so I count on help with finding fix for this.
3. I found some redefinitions in include/asic_reg/uvd/uvd_4_0_sh_mask.h. I guess this file is generated, so fix should be made wherever it is generated from. For now I removed offending lines just to silence the compiler warnings.
4. I'm not sure whether I choose the right version for the uvd. Existing code in si.c suggested that it should be 3.1, however I went with the 4.0, because for this version there are available new style headers.

Quoted 2 lines

I think the regs are pretty much the same between 3.x and 4.x so it should be fine.

Great.

Regards,
Piotr

Quoted 39 lines

Alex

Quoted 36 lines

Regards,
Piotr

Piotr Redlewski (7):
drm/amdgpu: remove duplicated definitions of some of the SI registers drm/amdgpu/uvd4: fix some register's mask and shift definitions drm/amdgpu/gmc6: don't use vram location programmed by the vbios drm/amdgpu/uvd4: add early init stage functions for uvd 4.0 drm/amdgpu/uvd4: add sw init and fini stages' functions for uvd 4.0 drm/amdgpu/uvd4: add hardware specific functions for uvd 4.0 drm/amdgpu: enable UVD for SI

  drivers/gpu/drm/amd/amdgpu/Makefile                |   3 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h           |   6 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c            |  14 +
  drivers/gpu/drm/amd/amdgpu/dce_v6_0.c              | 114 ++-
  drivers/gpu/drm/amd/amdgpu/dce_v6_0.h              |   5 +
  drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c              |   7 -
  drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c              |  40 +-
  drivers/gpu/drm/amd/amdgpu/si.c                    | 256 ++++++-
  drivers/gpu/drm/amd/amdgpu/si_ih.c                 |   3 +
  drivers/gpu/drm/amd/amdgpu/sid.h                   |  52 +-
  drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c              | 810 +++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h              |  29 +
  .../drm/amd/include/asic_reg/uvd/uvd_4_0_sh_mask.h |   2 -
  13 files changed, 1273 insertions(+), 68 deletions(-)

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

--
2.15.0

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

Quoted 8 lines
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

_______________________________________________
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): 77b5d341-42e2-91bd-f586-747451cfe6d6-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

#20 lore raw
Quoted 38 lines · Christian König

Am 09.11.2017 um 10:54 schrieb Piotr Redlewski:

Quoted 37 lines · Alex Deucher
Quoted 19 lines · Piotr Redlewski
Quoted 12 lines

Hi,

Following series implements UVD support for SI in amdgpu driver. Code is based on CIK's UVD support in amdgpu and SI's UVD support in radeon drivers. To work, it requires tahiti uvd firmware with added header - I've created simple script to produce exactly this, so if anyone is interested it can be found here:
https://gist.github.com/anonymous/6d974a970340f7f64b6fcc4f95267e43

Code is based on amd-staging-drm-next branch in Alex's tree. After applying these patches, uvd boots up and seems to work ok. I've tested it with vdpauinfo and mpv.

Quoted 6 lines

Some comments/issues for the patches:
1. To make uvd work, I had to bring back fb location programming. Using location programmed by vbios, vram location is not available for uvd mc (at least on my machine) due to too wide address. Starting address is 40-bit long for fb, but uvd mc supports only 32-bits (judging by comments in amdgpu code and actual code in radeon driver)

Quoted 8 lines

Something else must be going on. The vram location is irrelevant with respect to the limitations of UVD. I think the limitations with UVD are more to do with the location of the active buffers relative to each other rather than the absolute location of some aperture in the GPU's address space. CI has the same limitation as I recall so there is probably a bug somewhere. Windows has used the fb location as set by the vbios since evergreen, so it definitely should work.

If this is the case, then there must be something missing in UVD mc controller programming. When using vbios, I get following location:
amdgpu 0000:01:00.0: VRAM: 2048M 0x000000F400000000 - 0x000000F47FFFFFFF (2048M used)

When UVD bo is created, it starts at address 0xf400243000 and this value is used for programming UVD mc offsets. Programming is done in the following way:
addr = (adev->uvd.gpu_addr + AMDGPU_UVD_FIRMWARE_OFFSET) >> 3; WREG32(mmUVD_VCPU_CACHE_OFFSET0, addr);

Quoted 8 lines
Quoted 4 lines

Because address of the bo is wider than 32-bit, this won't work. It would be the same if UVD bo would be created at the beginning of the VRAM.

Any ideas how to handle this?

Are you programming UVD_LMI_EXT40_ADDR?

But I'm not sure if we ever handled that correctly in the SI code.

Yes, I do it exactly the same as it is done in radeon (and CIK in amdgpu):
/* bits 32-39 */
addr = (adev->uvd.gpu_addr >> 32) & 0xFF; WREG32(mmUVD_LMI_EXT40_ADDR, addr | (0x9 << 16) | (0x1 << 31));

Regards,
Piotr

Quoted 73 lines

Regards,
Christian.

Quoted 59 lines
Quoted 14 lines
Quoted 14 lines

2. I don't know why, but I couldn't get the uvd to boot without setting uvd mc offsets before starting other engines. Because of that I set it in .sw_init function. In my opinion this should be fixed as it generally doesn't follow amdgpu driver architecture (hardware setup during software setup stage) and probably will break suspending and resume (I didn't test it). As I mentioned, I couldn't figure out why this is happening, so I count on help with finding fix for this.
3. I found some redefinitions in include/asic_reg/uvd/uvd_4_0_sh_mask.h. I guess this file is generated, so fix should be made wherever it is generated from. For now I removed offending lines just to silence the compiler warnings.
4. I'm not sure whether I choose the right version for the uvd. Existing code in si.c suggested that it should be 3.1, however I went with the 4.0, because for this version there are available new style headers.

Quoted 2 lines

I think the regs are pretty much the same between 3.x and 4.x so it should be fine.

Great.

Regards,
Piotr

Quoted 39 lines

Alex

Quoted 36 lines

Regards,
Piotr

Piotr Redlewski (7):
drm/amdgpu: remove duplicated definitions of some of the SI registers drm/amdgpu/uvd4: fix some register's mask and shift definitions drm/amdgpu/gmc6: don't use vram location programmed by the vbios drm/amdgpu/uvd4: add early init stage functions for uvd 4.0 drm/amdgpu/uvd4: add sw init and fini stages' functions for uvd 4.0 drm/amdgpu/uvd4: add hardware specific functions for uvd 4.0 drm/amdgpu: enable UVD for SI

  drivers/gpu/drm/amd/amdgpu/Makefile                |   3 +-
  drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h           |   6 +
  drivers/gpu/drm/amd/amdgpu/amdgpu_uvd.c            |  14 +
  drivers/gpu/drm/amd/amdgpu/dce_v6_0.c              | 114 ++-
  drivers/gpu/drm/amd/amdgpu/dce_v6_0.h              |   5 +
  drivers/gpu/drm/amd/amdgpu/gfx_v6_0.c              |   7 -
  drivers/gpu/drm/amd/amdgpu/gmc_v6_0.c              |  40 +-
  drivers/gpu/drm/amd/amdgpu/si.c                    | 256 ++++++-
  drivers/gpu/drm/amd/amdgpu/si_ih.c                 |   3 +
  drivers/gpu/drm/amd/amdgpu/sid.h                   |  52 +-
  drivers/gpu/drm/amd/amdgpu/uvd_v4_0.c              | 810 +++++++++++++++++++++
  drivers/gpu/drm/amd/amdgpu/uvd_v4_0.h              |  29 +
  .../drm/amd/include/asic_reg/uvd/uvd_4_0_sh_mask.h |   2 -
  13 files changed, 1273 insertions(+), 68 deletions(-)

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

--
2.15.0

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

Quoted 8 lines
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

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

A message that is not in the archive (sent off-list or not yet received): 20171109105316.GA616-vEgOWn/6yzlBufL/[email protected]

#22 lore raw

Am 09.11.2017 um 11:53 schrieb Piotr Redlewski:

Quoted 42 lines · Christian König
Quoted 41 lines

Am 09.11.2017 um 10:54 schrieb Piotr Redlewski:

Quoted 40 lines · Alex Deucher
Quoted 19 lines · Piotr Redlewski
Quoted 12 lines

Hi,

Following series implements UVD support for SI in amdgpu driver. Code is based on CIK's UVD support in amdgpu and SI's UVD support in radeon drivers. To work, it requires tahiti uvd firmware with added header - I've created simple script to produce exactly this, so if anyone is interested it can be found here:
https://gist.github.com/anonymous/6d974a970340f7f64b6fcc4f95267e43

Code is based on amd-staging-drm-next branch in Alex's tree. After applying these patches, uvd boots up and seems to work ok. I've tested it with vdpauinfo and mpv.

Quoted 6 lines

Some comments/issues for the patches:
1. To make uvd work, I had to bring back fb location programming. Using location programmed by vbios, vram location is not available for uvd mc (at least on my machine) due to too wide address. Starting address is 40-bit long for fb, but uvd mc supports only 32-bits (judging by comments in amdgpu code and actual code in radeon driver)

Quoted 8 lines

Something else must be going on. The vram location is irrelevant with respect to the limitations of UVD. I think the limitations with UVD are more to do with the location of the active buffers relative to each other rather than the absolute location of some aperture in the GPU's address space. CI has the same limitation as I recall so there is probably a bug somewhere. Windows has used the fb location as set by the vbios since evergreen, so it definitely should work.

If this is the case, then there must be something missing in UVD mc controller programming. When using vbios, I get following location:
amdgpu 0000:01:00.0: VRAM: 2048M 0x000000F400000000 - 0x000000F47FFFFFFF (2048M used)

When UVD bo is created, it starts at address 0xf400243000 and this value is used for programming UVD mc offsets. Programming is done in the following way:
addr = (adev->uvd.gpu_addr + AMDGPU_UVD_FIRMWARE_OFFSET) >> 3; WREG32(mmUVD_VCPU_CACHE_OFFSET0, addr);

Because address of the bo is wider than 32-bit, this won't work. It would be the same if UVD bo would be created at the beginning of the VRAM.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Any ideas how to handle this?

Are you programming UVD_LMI_EXT40_ADDR?

But I'm not sure if we ever handled that correctly in the SI code.

Yes, I do it exactly the same as it is done in radeon (and CIK in amdgpu):
/* bits 32-39 */
addr = (adev->uvd.gpu_addr >> 32) & 0xFF; WREG32(mmUVD_LMI_EXT40_ADDR, addr | (0x9 << 16) | (0x1 << 31));

Ok, I've checked the firmware in the meantime and found that we never released firmware which supports the full 40bit addressing.

That's why this will never work correctly. Going to check if we can get updated firmware out of the door.

Regards,
Christian.

Quoted 3 lines

Regards,
Piotr

_______________________________________________
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): ffb4d853-1ec8-af2c-8622-26fc0e3a373b-5C7GfCeVMHo@public.gmane.org

#24 lore raw
Quoted 52 lines · Christian König

Am 09.11.2017 um 11:53 schrieb Piotr Redlewski:

Quoted 42 lines · Christian König
Quoted 41 lines

Am 09.11.2017 um 10:54 schrieb Piotr Redlewski:

Quoted 40 lines · Alex Deucher
Quoted 19 lines · Piotr Redlewski
Quoted 12 lines

Hi,

Following series implements UVD support for SI in amdgpu driver. Code is based on CIK's UVD support in amdgpu and SI's UVD support in radeon drivers. To work, it requires tahiti uvd firmware with added header - I've created simple script to produce exactly this, so if anyone is interested it can be found here:
https://gist.github.com/anonymous/6d974a970340f7f64b6fcc4f95267e43

Code is based on amd-staging-drm-next branch in Alex's tree. After applying these patches, uvd boots up and seems to work ok. I've tested it with vdpauinfo and mpv.

Quoted 6 lines

Some comments/issues for the patches:
1. To make uvd work, I had to bring back fb location programming. Using location programmed by vbios, vram location is not available for uvd mc (at least on my machine) due to too wide address. Starting address is 40-bit long for fb, but uvd mc supports only 32-bits (judging by comments in amdgpu code and actual code in radeon driver)

Quoted 8 lines

Something else must be going on. The vram location is irrelevant with respect to the limitations of UVD. I think the limitations with UVD are more to do with the location of the active buffers relative to each other rather than the absolute location of some aperture in the GPU's address space. CI has the same limitation as I recall so there is probably a bug somewhere. Windows has used the fb location as set by the vbios since evergreen, so it definitely should work.

If this is the case, then there must be something missing in UVD mc controller programming. When using vbios, I get following location:
amdgpu 0000:01:00.0: VRAM: 2048M 0x000000F400000000 - 0x000000F47FFFFFFF (2048M used)

When UVD bo is created, it starts at address 0xf400243000 and this value is used for programming UVD mc offsets. Programming is done in the following way:
addr = (adev->uvd.gpu_addr + AMDGPU_UVD_FIRMWARE_OFFSET) >> 3; WREG32(mmUVD_VCPU_CACHE_OFFSET0, addr);

Because address of the bo is wider than 32-bit, this won't work. It would be the same if UVD bo would be created at the beginning of the VRAM.

Quoted 8 lines
Quoted 4 lines
Quoted 1 line

Any ideas how to handle this?

Are you programming UVD_LMI_EXT40_ADDR?

But I'm not sure if we ever handled that correctly in the SI code.

Yes, I do it exactly the same as it is done in radeon (and CIK in amdgpu):
/* bits 32-39 */
addr = (adev->uvd.gpu_addr >> 32) & 0xFF; WREG32(mmUVD_LMI_EXT40_ADDR, addr | (0x9 << 16) | (0x1 << 31));

Quoted 5 lines

Ok, I've checked the firmware in the meantime and found that we never released firmware which supports the full 40bit addressing.

That's why this will never work correctly. Going to check if we can get updated firmware out of the door.

Ok, so let's wait for the new firmware. Thanks for your help Christian.

Regards,
Piotr

Quoted 5 lines

Regards,
Christian.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

Regards,
Piotr

_______________________________________________
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