diff options
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/mm_gk20a.c')
-rw-r--r-- | drivers/gpu/nvgpu/gk20a/mm_gk20a.c | 28 |
1 files changed, 20 insertions, 8 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c index 92095162..654938b2 100644 --- a/drivers/gpu/nvgpu/gk20a/mm_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/mm_gk20a.c | |||
@@ -399,8 +399,7 @@ int gk20a_init_mm_support(struct gk20a *g) | |||
399 | return err; | 399 | return err; |
400 | } | 400 | } |
401 | 401 | ||
402 | #ifdef CONFIG_GK20A_PHYS_PAGE_TABLES | 402 | static int alloc_gmmu_phys_pages(struct vm_gk20a *vm, u32 order, |
403 | static int alloc_gmmu_pages(struct vm_gk20a *vm, u32 order, | ||
404 | void **handle, | 403 | void **handle, |
405 | struct sg_table **sgt, | 404 | struct sg_table **sgt, |
406 | size_t *size) | 405 | size_t *size) |
@@ -443,18 +442,17 @@ err_out: | |||
443 | return -ENOMEM; | 442 | return -ENOMEM; |
444 | } | 443 | } |
445 | 444 | ||
446 | void free_gmmu_pages(struct vm_gk20a *vm, void *handle, | 445 | void free_gmmu_phys_pages(struct vm_gk20a *vm, void *handle, |
447 | struct sg_table *sgt, u32 order, | 446 | struct sg_table *sgt, u32 order, |
448 | size_t size) | 447 | size_t size) |
449 | { | 448 | { |
450 | gk20a_dbg_fn(""); | 449 | gk20a_dbg_fn(""); |
451 | BUG_ON(sgt == NULL); | ||
452 | free_pages((unsigned long)handle, order); | 450 | free_pages((unsigned long)handle, order); |
453 | sg_free_table(sgt); | 451 | sg_free_table(sgt); |
454 | kfree(sgt); | 452 | kfree(sgt); |
455 | } | 453 | } |
456 | 454 | ||
457 | int map_gmmu_pages(void *handle, struct sg_table *sgt, | 455 | int map_gmmu_phys_pages(void *handle, struct sg_table *sgt, |
458 | void **va, size_t size) | 456 | void **va, size_t size) |
459 | { | 457 | { |
460 | FLUSH_CPU_DCACHE(handle, sg_phys(sgt->sgl), sgt->sgl->length); | 458 | FLUSH_CPU_DCACHE(handle, sg_phys(sgt->sgl), sgt->sgl->length); |
@@ -462,11 +460,10 @@ int map_gmmu_pages(void *handle, struct sg_table *sgt, | |||
462 | return 0; | 460 | return 0; |
463 | } | 461 | } |
464 | 462 | ||
465 | void unmap_gmmu_pages(void *handle, struct sg_table *sgt, void *va) | 463 | void unmap_gmmu_phys_pages(void *handle, struct sg_table *sgt, void *va) |
466 | { | 464 | { |
467 | FLUSH_CPU_DCACHE(handle, sg_phys(sgt->sgl), sgt->sgl->length); | 465 | FLUSH_CPU_DCACHE(handle, sg_phys(sgt->sgl), sgt->sgl->length); |
468 | } | 466 | } |
469 | #else | ||
470 | 467 | ||
471 | static int alloc_gmmu_pages(struct vm_gk20a *vm, u32 order, | 468 | static int alloc_gmmu_pages(struct vm_gk20a *vm, u32 order, |
472 | void **handle, | 469 | void **handle, |
@@ -484,6 +481,9 @@ static int alloc_gmmu_pages(struct vm_gk20a *vm, u32 order, | |||
484 | 481 | ||
485 | gk20a_dbg_fn(""); | 482 | gk20a_dbg_fn(""); |
486 | 483 | ||
484 | if (tegra_platform_is_linsim()) | ||
485 | return alloc_gmmu_phys_pages(vm, order, handle, sgt, size); | ||
486 | |||
487 | *size = len; | 487 | *size = len; |
488 | 488 | ||
489 | if (IS_ENABLED(CONFIG_ARM64)) { | 489 | if (IS_ENABLED(CONFIG_ARM64)) { |
@@ -545,6 +545,11 @@ void free_gmmu_pages(struct vm_gk20a *vm, void *handle, | |||
545 | gk20a_dbg_fn(""); | 545 | gk20a_dbg_fn(""); |
546 | BUG_ON(sgt == NULL); | 546 | BUG_ON(sgt == NULL); |
547 | 547 | ||
548 | if (tegra_platform_is_linsim()) { | ||
549 | free_gmmu_phys_pages(vm, handle, sgt, order, size); | ||
550 | return; | ||
551 | } | ||
552 | |||
548 | iova = sg_dma_address(sgt->sgl); | 553 | iova = sg_dma_address(sgt->sgl); |
549 | 554 | ||
550 | gk20a_free_sgtable(&sgt); | 555 | gk20a_free_sgtable(&sgt); |
@@ -569,6 +574,9 @@ int map_gmmu_pages(void *handle, struct sg_table *sgt, | |||
569 | struct page **pages; | 574 | struct page **pages; |
570 | gk20a_dbg_fn(""); | 575 | gk20a_dbg_fn(""); |
571 | 576 | ||
577 | if (tegra_platform_is_linsim()) | ||
578 | return map_gmmu_phys_pages(handle, sgt, kva, size); | ||
579 | |||
572 | if (IS_ENABLED(CONFIG_ARM64)) { | 580 | if (IS_ENABLED(CONFIG_ARM64)) { |
573 | *kva = handle; | 581 | *kva = handle; |
574 | } else { | 582 | } else { |
@@ -585,11 +593,15 @@ void unmap_gmmu_pages(void *handle, struct sg_table *sgt, void *va) | |||
585 | { | 593 | { |
586 | gk20a_dbg_fn(""); | 594 | gk20a_dbg_fn(""); |
587 | 595 | ||
596 | if (tegra_platform_is_linsim()) { | ||
597 | unmap_gmmu_phys_pages(handle, sgt, va); | ||
598 | return; | ||
599 | } | ||
600 | |||
588 | if (!IS_ENABLED(CONFIG_ARM64)) | 601 | if (!IS_ENABLED(CONFIG_ARM64)) |
589 | vunmap(va); | 602 | vunmap(va); |
590 | va = NULL; | 603 | va = NULL; |
591 | } | 604 | } |
592 | #endif | ||
593 | 605 | ||
594 | /* allocate a phys contig region big enough for a full | 606 | /* allocate a phys contig region big enough for a full |
595 | * sized gmmu page table for the given gmmu_page_size. | 607 | * sized gmmu page table for the given gmmu_page_size. |