dri-devel.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: Jack Xiao <Jack.Xiao@amd.com>
Subject: [PATCH 54/88] drm/amdgpu: allow unaligned memory access (v2)
Date: Tue, 26 May 2015 23:19:53 -0400	[thread overview]
Message-ID: <1432696827-3752-24-git-send-email-alexander.deucher@amd.com> (raw)
In-Reply-To: <1432696827-3752-1-git-send-email-alexander.deucher@amd.com>

From: Jack Xiao <Jack.Xiao@amd.com>

Set up the CP and SDMA for proper unaligned memory access.
Required for OpenCL 2.x

v2: udpate commit message

Signed-off-by: Jack Xiao <Jack.Xiao@amd.com>
Reviewed-by: Monk Liu <monk.liu@amd.com>
Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com>
---
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c  | 6 +++++-
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c  | 6 +++++-
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  | 4 ++++
 drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c | 5 ++++-
 drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c | 5 ++++-
 5 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
index ae2bb26..037e3db 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
@@ -33,6 +33,8 @@
 #include "bif/bif_4_1_sh_mask.h"
 
 #include "gca/gfx_7_2_d.h"
+#include "gca/gfx_7_2_enum.h"
+#include "gca/gfx_7_2_sh_mask.h"
 
 #include "gmc/gmc_7_1_d.h"
 #include "gmc/gmc_7_1_sh_mask.h"
@@ -837,6 +839,8 @@ static void cik_sdma_ring_emit_vm_flush(struct amdgpu_ring *ring,
 {
 	u32 extra_bits = (SDMA_POLL_REG_MEM_EXTRA_OP(0) |
 			  SDMA_POLL_REG_MEM_EXTRA_FUNC(0)); /* always */
+	u32 sh_mem_cfg = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE, 
+				       SH_MEM_ALIGNMENT_MODE_UNALIGNED);
 
 	amdgpu_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_SRBM_WRITE, 0, 0xf000));
 	if (vm_id < 8) {
@@ -857,7 +861,7 @@ static void cik_sdma_ring_emit_vm_flush(struct amdgpu_ring *ring,
 
 	amdgpu_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_SRBM_WRITE, 0, 0xf000));
 	amdgpu_ring_write(ring, mmSH_MEM_CONFIG);
-	amdgpu_ring_write(ring, 0);
+	amdgpu_ring_write(ring, sh_mem_cfg);
 
 	amdgpu_ring_write(ring, SDMA_PACKET(SDMA_OPCODE_SRBM_WRITE, 0, 0xf000));
 	amdgpu_ring_write(ring, mmSH_MEM_APE1_BASE);
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
index 675b096..26df23e 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c
@@ -2022,6 +2022,7 @@ static void gfx_v7_0_gpu_init(struct amdgpu_device *adev)
 	u32 gb_addr_config;
 	u32 mc_shared_chmap, mc_arb_ramcfg;
 	u32 dimm00_addr_map, dimm01_addr_map, dimm10_addr_map, dimm11_addr_map;
+	u32 sh_mem_cfg;
 	u32 tmp;
 	int i;
 
@@ -2214,11 +2215,14 @@ static void gfx_v7_0_gpu_init(struct amdgpu_device *adev)
 
 	/* XXX SH_MEM regs */
 	/* where to put LDS, scratch, GPUVM in FSA64 space */
+	sh_mem_cfg = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE, 
+				   SH_MEM_ALIGNMENT_MODE_UNALIGNED);
+
 	mutex_lock(&adev->srbm_mutex);
 	for (i = 0; i < 16; i++) {
 		cik_srbm_select(adev, 0, 0, 0, i);
 		/* CP and shaders */
-		WREG32(mmSH_MEM_CONFIG, 0);
+		WREG32(mmSH_MEM_CONFIG, sh_mem_cfg);
 		WREG32(mmSH_MEM_APE1_BASE, 1);
 		WREG32(mmSH_MEM_APE1_LIMIT, 0);
 		WREG32(mmSH_MEM_BASES, 0);
diff --git a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
index a8397dd..3762998 100644
--- a/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c
@@ -2050,10 +2050,14 @@ static void gfx_v8_0_gpu_init(struct amdgpu_device *adev)
 		if (i == 0) {
 			tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, DEFAULT_MTYPE, MTYPE_UC);
 			tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, APE1_MTYPE, MTYPE_UC);
+			tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, ALIGNMENT_MODE, 
+					    SH_MEM_ALIGNMENT_MODE_UNALIGNED);
 			WREG32(mmSH_MEM_CONFIG, tmp);
 		} else {
 			tmp = REG_SET_FIELD(0, SH_MEM_CONFIG, DEFAULT_MTYPE, MTYPE_NC);
 			tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, APE1_MTYPE, MTYPE_NC);
+			tmp = REG_SET_FIELD(tmp, SH_MEM_CONFIG, ALIGNMENT_MODE, 
+					    SH_MEM_ALIGNMENT_MODE_UNALIGNED);
 			WREG32(mmSH_MEM_CONFIG, tmp);
 		}
 
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
index a83029d..389509a 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v2_4.c
@@ -36,6 +36,7 @@
 #include "gmc/gmc_8_1_sh_mask.h"
 
 #include "gca/gfx_8_0_d.h"
+#include "gca/gfx_8_0_enum.h"
 #include "gca/gfx_8_0_sh_mask.h"
 
 #include "bif/bif_5_0_d.h"
@@ -900,6 +901,8 @@ static void sdma_v2_4_ring_emit_vm_flush(struct amdgpu_ring *ring,
 					 unsigned vm_id, uint64_t pd_addr)
 {
 	u32 srbm_gfx_cntl = 0;
+	u32 sh_mem_cfg = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE, 
+				       SH_MEM_ALIGNMENT_MODE_UNALIGNED);
 
 	amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) |
 			  SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf));
@@ -925,7 +928,7 @@ static void sdma_v2_4_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) |
 			  SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf));
 	amdgpu_ring_write(ring, mmSH_MEM_CONFIG);
-	amdgpu_ring_write(ring, 0);
+	amdgpu_ring_write(ring, sh_mem_cfg);
 
 	amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) |
 			  SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf));
diff --git a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
index dd547c7f..d3eda31 100644
--- a/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/sdma_v3_0.c
@@ -36,6 +36,7 @@
 #include "gmc/gmc_8_1_sh_mask.h"
 
 #include "gca/gfx_8_0_d.h"
+#include "gca/gfx_8_0_enum.h"
 #include "gca/gfx_8_0_sh_mask.h"
 
 #include "bif/bif_5_0_d.h"
@@ -963,6 +964,8 @@ static void sdma_v3_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
 					 unsigned vm_id, uint64_t pd_addr)
 {
 	u32 srbm_gfx_cntl = 0;
+	u32 sh_mem_cfg = REG_SET_FIELD(0, SH_MEM_CONFIG, ALIGNMENT_MODE, 
+				       SH_MEM_ALIGNMENT_MODE_UNALIGNED);
 
 	amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) |
 			  SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf));
@@ -988,7 +991,7 @@ static void sdma_v3_0_ring_emit_vm_flush(struct amdgpu_ring *ring,
 	amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) |
 			  SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf));
 	amdgpu_ring_write(ring, mmSH_MEM_CONFIG);
-	amdgpu_ring_write(ring, 0);
+	amdgpu_ring_write(ring, sh_mem_cfg);
 
 	amdgpu_ring_write(ring, SDMA_PKT_HEADER_OP(SDMA_OP_SRBM_WRITE) |
 			  SDMA_PKT_SRBM_WRITE_HEADER_BYTE_EN(0xf));
-- 
1.8.3.1

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2015-05-27  3:20 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-27  3:19 [PATCH 00/88] amdgpu driver updates Alex Deucher
2015-05-27  3:19 ` [PATCH 29/88] drm/amdgpu: add amdgpu uapi header (v4) Alex Deucher
2015-06-05 18:57   ` Jerome Glisse
2015-06-09  2:51     ` Alex Deucher
2015-06-09  9:13       ` Marek Olšák
2015-05-27  3:19 ` [PATCH 30/88] drm/amdgpu: add atombios headers Alex Deucher
2015-05-27  3:19 ` [PATCH 31/88] drm/amdgpu: add clearstate_defs.h Alex Deucher
2015-05-27  3:19 ` [PATCH 32/88] drm/amdgpu: add ppsmc.h Alex Deucher
2015-05-27  3:19 ` [PATCH 33/88] drm/amdgpu: add amdgpu_family.h Alex Deucher
2015-05-27  3:19 ` [PATCH 34/88] drm/amdgpu: add amdgpu.h (v2) Alex Deucher
2015-05-27  3:19 ` [PATCH 36/88] drm/amdgpu: fix const warnings in amdgpu_connectors.c Alex Deucher
2015-05-27  3:19 ` [PATCH 37/88] drm/amdgpu: Do not directly dereference pointers to BIOS area Alex Deucher
2015-05-27  3:19 ` [PATCH 40/88] drm/amdgpu: add CIK pci ids Alex Deucher
2015-05-27  3:19 ` [PATCH 41/88] drm/amdgpu: add VI " Alex Deucher
2015-05-27  3:19 ` [PATCH 42/88] drm/amdgpu: drop ttm two ended allocation Alex Deucher
2015-05-27  3:19 ` [PATCH 43/88] drm/amdgpu: fix error check issue in amdgpu_mn_invalidate_range_start Alex Deucher
2015-05-27  3:19 ` [PATCH 44/88] drm/amdgpu: fix bug occurs when bo_list is NULL Alex Deucher
2015-05-27  3:19 ` [PATCH 45/88] drm/amdgpu: let bo_list handler start from 1 Alex Deucher
2015-05-27  3:19 ` [PATCH 46/88] drm/amdgpu: fix error handling in cz_dpm_hw_fini/cz_dpm_suspend Alex Deucher
2015-05-27  3:19 ` [PATCH 47/88] drm/amdgpu: memset gds_info struct in info ioctl Alex Deucher
2015-05-27  3:19 ` [PATCH 48/88] drm/amdgpu fix amdgpu.dpm=0 (v2) Alex Deucher
2015-05-27  3:19 ` [PATCH 49/88] drm/amdgpu: remove AMDGPU_GEM_CREATE_CPU_GTT_UC Alex Deucher
2015-06-06 17:08   ` Oded Gabbay
2015-06-06 19:09     ` Christian König
2015-06-06 19:32       ` Oded Gabbay
2015-06-12 15:47   ` Emil Velikov
2015-06-12 16:41     ` Bridgman, John
2015-06-12 16:57       ` Emil Velikov
2015-05-27  3:19 ` [PATCH 50/88] drm/amdgpu: fix userptr BO unpin bug (v2) Alex Deucher
2015-05-27  3:19 ` [PATCH 51/88] drm/amdgpu: fix userptr lockup Alex Deucher
2015-05-27  3:19 ` [PATCH 52/88] drm/amdgpu: remove unsafe context releasing Alex Deucher
2015-05-27  3:19 ` [PATCH 53/88] drm/amdgpu: make the CTX ioctl thread-safe Alex Deucher
2015-05-27  3:19 ` Alex Deucher [this message]
2015-05-27  3:19 ` [PATCH 55/88] drm/amdgpu: add ctx_id to the WAIT_CS IOCTL (v4) Alex Deucher
2015-05-27  3:19 ` [PATCH 56/88] drm/amdgpu: check context id for context switching (v2) Alex Deucher
2015-05-27  3:19 ` [PATCH 57/88] drm/amdgpu: add flags for amdgpu_ib structure Alex Deucher
2015-05-27  3:19 ` [PATCH 58/88] drm/amdgpu: add CE preamble flag v3 Alex Deucher
2015-05-27  3:19 ` [PATCH 59/88] drm/amdgpu: always emit GDS switch Alex Deucher
2015-05-27  3:19 ` [PATCH 60/88] drm/amdgpu: cleanup HDP flush handling Alex Deucher
2015-05-27  3:20 ` [PATCH 61/88] drm/amdgpu: fix dereference before check Alex Deucher
2015-05-27  3:20 ` [PATCH 62/88] drm/amdgpu: fix context switch Alex Deucher
2015-05-27  3:20 ` [PATCH 63/88] drm/amdgpu: expose the max virtual address Alex Deucher
2015-05-27  3:20 ` [PATCH 64/88] drm/amdgpu: do necessary NULL check Alex Deucher
2015-05-27  3:20 ` [PATCH 65/88] drm/amdgpu: switch to amdgpu folder for firmware files v2 Alex Deucher
2015-05-27  3:20 ` [PATCH 66/88] drm/amdgpu: rewording some left radeons Alex Deucher
2015-05-27  3:20 ` [PATCH 67/88] drm/amdgpu: add new bonaire pci id Alex Deucher
2015-05-27  3:20 ` [PATCH 68/88] drm/amdgpu: add some new tonga pci ids Alex Deucher
2015-05-27  3:20 ` [PATCH 69/88] drm/amdgpu: add and implement the GPU reset status query Alex Deucher
2015-05-27  3:20 ` [PATCH 70/88] drm/amdgpu: take the mode_config mutex when handling hpds Alex Deucher
2015-05-27  3:20 ` [PATCH 71/88] drm/amdgpu: make some DP parameters const Alex Deucher
2015-05-27  3:20 ` [PATCH 72/88] drm/amdgpu: simplify DPCD debug output Alex Deucher
2015-05-27  3:20 ` [PATCH 73/88] drm/amdgpu: retry dcpd fetch Alex Deucher
2015-05-27  3:20 ` [PATCH 74/88] drm/amdgpu: fix VM_CONTEXT*_PAGE_TABLE_END_ADDR handling Alex Deucher
2015-05-27  3:20 ` [PATCH 75/88] drm/amdgpu: enforce AMDGPU_GEM_CREATE_NO_CPU_ACCESS Alex Deucher
2015-05-27  3:20 ` [PATCH 76/88] drm/amdgpu: validate amdgpu_vm_bo_map parameters Alex Deucher
2015-05-27  3:20 ` [PATCH 77/88] drm/amdgpu: actually use the VM map parameters Alex Deucher
2015-05-27  3:20 ` [PATCH 78/88] drm/amdgpu: don't set unused tiling flags Alex Deucher
2015-05-27  3:20 ` [PATCH 79/88] drm/amdgpu: rework " Alex Deucher
2015-05-27  3:20 ` [PATCH 80/88] drm/amdgpu: remove unused TRACE_SYSTEM_STRING define Alex Deucher
2015-05-27  3:20 ` [PATCH 81/88] drm/amdgpu: recalculate VCE firmware BO size Alex Deucher
2015-05-27  3:20 ` [PATCH 82/88] drm/amdgpu: implement VCE two instances support Alex Deucher
2015-05-27  3:20 ` [PATCH 83/88] drm/amdgpu: enable uvd dpm and powergating Alex Deucher
2015-05-27  3:20 ` [PATCH 84/88] drm/amdgpu: port fault_reserve_notify changes from radeon Alex Deucher
2015-05-27  3:20 ` [PATCH 85/88] drm/amdgpu: drop AMDGPU_FENCE_SIGNALED_SEQ Alex Deucher
2015-05-27  3:20 ` [PATCH 86/88] drm/amdgpu: drop allocation flag masks Alex Deucher
2015-05-27  3:20 ` [PATCH 87/88] drm/amdgpu: rename amdgpu_ip_funcs to amd_ip_funcs (v2) Alex Deucher
2015-05-27  3:20 ` [PATCH 88/88] drm/amdgpu: implement the allocation range (v2) Alex Deucher

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1432696827-3752-24-git-send-email-alexander.deucher@amd.com \
    --to=alexdeucher@gmail.com \
    --cc=Jack.Xiao@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).