summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c
diff options
context:
space:
mode:
authorseshendra Gadagottu <sgadagottu@nvidia.com>2016-11-22 12:09:39 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2017-05-26 17:07:17 -0400
commit1f78355c5c909e2f678a60420c0abd8ec5adbc98 (patch)
treeb922a84947af7199c41c823287654afffd246be8 /drivers/gpu/nvgpu/gv11b/fifo_gv11b.c
parent9b95bb9c4ed56b8bd8028d38d0705181076f04e3 (diff)
gpu: nvgpu: gv11b: add support for sync points
In t19x, host1x supports sync point through memory mapped shim layer. So sync-point operations implemented through semphore methods signaling to this sync-point shim layer. Added relevant hal functions for this in fifo hal. JIRA GPUT19X-2 Change-Id: Ia514637d046ba093f4e5afa6cbd06673672fd189 Signed-off-by: seshendra Gadagottu <sgadagottu@nvidia.com> Reviewed-on: http://git-master/r/1258235 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gv11b/fifo_gv11b.c')
-rw-r--r--drivers/gpu/nvgpu/gv11b/fifo_gv11b.c136
1 files changed, 135 insertions, 1 deletions
diff --git a/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c b/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c
index a153de7c..4b4c97b4 100644
--- a/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c
+++ b/drivers/gpu/nvgpu/gv11b/fifo_gv11b.c
@@ -14,11 +14,17 @@
14 */ 14 */
15#include <linux/delay.h> 15#include <linux/delay.h>
16#include <linux/types.h> 16#include <linux/types.h>
17#ifdef CONFIG_TEGRA_GK20A_NVHOST
18#include <linux/nvhost.h>
19#include <linux/nvhost_t194.h>
20#endif
17 21
18#include <nvgpu/semaphore.h> 22#include <nvgpu/semaphore.h>
19#include <nvgpu/timers.h> 23#include <nvgpu/timers.h>
20#include <nvgpu/log.h> 24#include <nvgpu/log.h>
21 25#include <nvgpu/dma.h>
26#include <nvgpu/nvgpu_mem.h>
27#include <nvgpu/gmmu.h>
22 28
23#include "gk20a/gk20a.h" 29#include "gk20a/gk20a.h"
24#include "gk20a/fifo_gk20a.h" 30#include "gk20a/fifo_gk20a.h"
@@ -1411,6 +1417,123 @@ static unsigned int gv11b_fifo_handle_pbdma_intr_0(struct gk20a *g,
1411 return rc_type; 1417 return rc_type;
1412} 1418}
1413 1419
1420#ifdef CONFIG_TEGRA_GK20A_NVHOST
1421static int gv11b_fifo_alloc_syncpt_buf(struct channel_gk20a *c,
1422 u32 syncpt_id, struct nvgpu_mem *syncpt_buf)
1423{
1424 struct page **pages;
1425 u32 nr_pages;
1426 u32 i;
1427 int err = 0;
1428 struct gk20a *g = c->g;
1429
1430 /*
1431 * Add rw mapping for entire syncpt shim for current channel vm
1432 * TODO : This needs to replaced with a new mecahnism where
1433 * only current syncpoint range will be rw and other sync
1434 * points range is read only for current channel vm. Also share
1435 * these mapping accross channels if they share same vm
1436 */
1437 nr_pages = DIV_ROUND_UP(g->syncpt_unit_size, PAGE_SIZE);
1438 pages = nvgpu_kzalloc(g, sizeof(struct page *) * nr_pages);
1439 for (i = 0; i < nr_pages; i++)
1440 pages[i] = phys_to_page(g->syncpt_unit_base +
1441 PAGE_SIZE * i);
1442 __nvgpu_mem_create_from_pages(g, syncpt_buf, pages, nr_pages);
1443 nvgpu_kfree(g, pages);
1444 syncpt_buf->gpu_va = nvgpu_gmmu_map(c->vm, syncpt_buf,
1445 g->syncpt_unit_size, 0, gk20a_mem_flag_none,
1446 false, APERTURE_SYSMEM);
1447
1448 if (!syncpt_buf->gpu_va) {
1449 nvgpu_err(c->g, "failed to map syncpt buffer");
1450 nvgpu_dma_free(c->g, syncpt_buf);
1451 err = -ENOMEM;
1452 }
1453 return err;
1454}
1455
1456static void gv11b_fifo_free_syncpt_buf(struct channel_gk20a *c,
1457 struct nvgpu_mem *syncpt_buf)
1458{
1459 nvgpu_gmmu_unmap(c->vm, syncpt_buf, syncpt_buf->gpu_va);
1460 nvgpu_dma_free(c->g, syncpt_buf);
1461}
1462
1463static void gv11b_fifo_add_syncpt_wait_cmd(struct gk20a *g,
1464 struct priv_cmd_entry *cmd, u32 off,
1465 u32 id, u32 thresh, u64 gpu_va_base)
1466{
1467 u64 gpu_va = gpu_va_base +
1468 nvhost_syncpt_unit_interface_get_byte_offset(id);
1469
1470 gk20a_dbg_fn("");
1471
1472 off = cmd->off + off;
1473
1474 /* semaphore_a */
1475 nvgpu_mem_wr32(g, cmd->mem, off++, 0x20010004);
1476 nvgpu_mem_wr32(g, cmd->mem, off++,
1477 (gpu_va >> 32) & 0xff);
1478 /* semaphore_b */
1479 nvgpu_mem_wr32(g, cmd->mem, off++, 0x20010005);
1480 /* offset */
1481 nvgpu_mem_wr32(g, cmd->mem, off++, gpu_va & 0xffffffff);
1482
1483 /* semaphore_c */
1484 nvgpu_mem_wr32(g, cmd->mem, off++, 0x20010006);
1485 /* payload */
1486 nvgpu_mem_wr32(g, cmd->mem, off++, 0x0);
1487 /* semaphore_d */
1488 nvgpu_mem_wr32(g, cmd->mem, off++, 0x20010007);
1489 /* operation: acq_geq, switch_en */
1490 nvgpu_mem_wr32(g, cmd->mem, off++, 0x4 | (0x1 << 12));
1491}
1492
1493static u32 gv11b_fifo_get_syncpt_wait_cmd_size(void)
1494{
1495 return 8;
1496}
1497
1498static void gv11b_fifo_add_syncpt_incr_cmd(struct gk20a *g,
1499 bool wfi_cmd, struct priv_cmd_entry *cmd,
1500 u32 id, u64 gpu_va_base)
1501{
1502 u32 off = cmd->off;
1503 u64 gpu_va = gpu_va_base +
1504 nvhost_syncpt_unit_interface_get_byte_offset(id);
1505
1506 gk20a_dbg_fn("");
1507
1508 /* semaphore_a */
1509 nvgpu_mem_wr32(g, cmd->mem, off++, 0x20010004);
1510 nvgpu_mem_wr32(g, cmd->mem, off++,
1511 (gpu_va >> 32) & 0xff);
1512 /* semaphore_b */
1513 nvgpu_mem_wr32(g, cmd->mem, off++, 0x20010005);
1514 /* offset */
1515 nvgpu_mem_wr32(g, cmd->mem, off++, gpu_va & 0xffffffff);
1516
1517 /* semaphore_c */
1518 nvgpu_mem_wr32(g, cmd->mem, off++, 0x20010006);
1519 /* payload */
1520 nvgpu_mem_wr32(g, cmd->mem, off++, 0x0);
1521 /* semaphore_d */
1522 nvgpu_mem_wr32(g, cmd->mem, off++, 0x20010007);
1523
1524 /* operation: release, wfi */
1525 nvgpu_mem_wr32(g, cmd->mem, off++,
1526 0x2 | ((wfi_cmd ? 0x0 : 0x1) << 20));
1527 /* ignored */
1528 nvgpu_mem_wr32(g, cmd->mem, off++, 0);
1529}
1530
1531static u32 gv11b_fifo_get_syncpt_incr_cmd_size(bool wfi_cmd)
1532{
1533 return 9;
1534}
1535#endif /* CONFIG_TEGRA_GK20A_NVHOST */
1536
1414void gv11b_init_fifo(struct gpu_ops *gops) 1537void gv11b_init_fifo(struct gpu_ops *gops)
1415{ 1538{
1416 gp10b_init_fifo(gops); 1539 gp10b_init_fifo(gops);
@@ -1446,4 +1569,15 @@ void gv11b_init_fifo(struct gpu_ops *gops)
1446 gops->fifo.handle_ctxsw_timeout = gv11b_fifo_handle_ctxsw_timeout; 1569 gops->fifo.handle_ctxsw_timeout = gv11b_fifo_handle_ctxsw_timeout;
1447 gops->fifo.handle_pbdma_intr_0 = 1570 gops->fifo.handle_pbdma_intr_0 =
1448 gv11b_fifo_handle_pbdma_intr_0; 1571 gv11b_fifo_handle_pbdma_intr_0;
1572#ifdef CONFIG_TEGRA_GK20A_NVHOST
1573 gops->fifo.alloc_syncpt_buf = gv11b_fifo_alloc_syncpt_buf;
1574 gops->fifo.free_syncpt_buf = gv11b_fifo_free_syncpt_buf;
1575 gops->fifo.add_syncpt_wait_cmd = gv11b_fifo_add_syncpt_wait_cmd;
1576 gops->fifo.get_syncpt_wait_cmd_size =
1577 gv11b_fifo_get_syncpt_wait_cmd_size;
1578 gops->fifo.add_syncpt_incr_cmd = gv11b_fifo_add_syncpt_incr_cmd;
1579 gops->fifo.get_syncpt_incr_cmd_size =
1580 gv11b_fifo_get_syncpt_incr_cmd_size;
1581#endif
1582
1449} 1583}