diff options
author | Jörg Wagner <jorwag@google.com> | 2023-03-28 08:07:27 +0000 |
---|---|---|
committer | Joerg Wagner <jorwag@google.com> | 2023-03-29 09:57:57 +0000 |
commit | a84b45557cc7e12d21a8caddd047140e3b4dbc47 (patch) | |
tree | 9566284e8ebdcda82aabd50eeacfa6c1f8ffd742 /mali_pixel | |
parent | a1a6abced856836855d73b0d7004ed1087733389 (diff) | |
download | gpu-a84b45557cc7e12d21a8caddd047140e3b4dbc47.tar.gz |
mali-pma: Defer probing until the dma_heap is found
mali-pma requires a specific, named heap which is
provided by a different .ko. To enable parallel
module loading check for the heap's presence and
defer the loading if not found instead of failing.
Bug: 269978060
Change-Id: Iac3d9d8a6b45ff2405a4b8a26bcc86ac00778fe3
Diffstat (limited to 'mali_pixel')
-rw-r--r-- | mali_pixel/protected_memory_allocator.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/mali_pixel/protected_memory_allocator.c b/mali_pixel/protected_memory_allocator.c index 30ed56f..6d1e555 100644 --- a/mali_pixel/protected_memory_allocator.c +++ b/mali_pixel/protected_memory_allocator.c @@ -476,16 +476,28 @@ static void mali_pma_slab_remove( */ static int protected_memory_allocator_probe(struct platform_device *pdev) { + struct dma_heap *pma_heap; struct mali_pma_dev *mali_pma_dev; struct protected_memory_allocator_device *pma_dev; int ret = 0; + /* Try locating a PMA heap, defer if not present (yet). */ + pma_heap = dma_heap_find(MALI_PMA_DMA_HEAP_NAME); + if (!pma_heap) { + dev_warn(&(pdev->dev), + "Failed to find \"%s\" DMA buffer heap. Deferring.\n", + MALI_PMA_DMA_HEAP_NAME); + ret = -EPROBE_DEFER; + goto out; + } + /* Create a Mali protected memory allocator device record. */ mali_pma_dev = kzalloc(sizeof(*mali_pma_dev), GFP_KERNEL); if (!mali_pma_dev) { dev_err(&(pdev->dev), "Failed to create a Mali protected memory allocator " "device record\n"); + dma_heap_put(pma_heap); ret = -ENOMEM; goto out; } @@ -503,26 +515,14 @@ static int protected_memory_allocator_probe(struct platform_device *pdev) pma_dev->ops.pma_get_phys_addr = mali_pma_get_phys_addr; pma_dev->ops.pma_free_page = mali_pma_free_page; - /* Get the DMA buffer heap. */ - mali_pma_dev->dma_heap = dma_heap_find(MALI_PMA_DMA_HEAP_NAME); - if (!mali_pma_dev->dma_heap) { - dev_err(&(pdev->dev), - "Failed to find \"%s\" DMA buffer heap\n", - MALI_PMA_DMA_HEAP_NAME); - ret = -ENODEV; - goto out; - } + /* Assign the DMA buffer heap. */ + mali_pma_dev->dma_heap = pma_heap; /* Log that the protected memory allocator was successfully probed. */ dev_info(&(pdev->dev), "Protected memory allocator probed successfully\n"); out: - /* Clean up on error. */ - if (ret) { - protected_memory_allocator_remove(pdev); - } - return ret; } |