From 835aee8692074f693e6db20a13a8ca11277e1fd5 Mon Sep 17 00:00:00 2001 From: Jianqun Xu Date: Mon, 26 Apr 2021 10:03:11 +0800 Subject: [PATCH] Revert "staging: android: ion: set dma ops for platform device" This reverts commit 6a40ead69f0f09fdef583b2f901537e904a088e8. The old patch only do sync for pages first allocated from system to page pools which have memset operation. In that case, the sg table hasn't been created, so the sg_phy should be filled extra. After this revert, a new patch will push to do sync after sg table created, and use a common device from ion driver, which is required by dma_sync api. Change-Id: I9712136a532f64ff3224308f48d59efb87fd5be2 Signed-off-by: Jianqun Xu --- drivers/staging/android/ion/ion.h | 2 - drivers/staging/android/ion/ion_page_pool.c | 59 +-------------------- 2 files changed, 2 insertions(+), 59 deletions(-) diff --git a/drivers/staging/android/ion/ion.h b/drivers/staging/android/ion/ion.h index 9ab64bae4d1c..7e9d096a6fe7 100644 --- a/drivers/staging/android/ion/ion.h +++ b/drivers/staging/android/ion/ion.h @@ -294,7 +294,6 @@ size_t ion_heap_freelist_size(struct ion_heap *heap); * @gfp_mask: gfp_mask to use from alloc * @order: order of pages in the pool * @list: plist node for list of pools - * @dev: device for the pool * * Allows you to keep a pool of pre allocated pages to use from your heap. * Keeping a pool of pages that is ready for dma, ie any cached mapping have @@ -310,7 +309,6 @@ struct ion_page_pool { gfp_t gfp_mask; unsigned int order; struct plist_node list; - struct device *dev; }; struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order); diff --git a/drivers/staging/android/ion/ion_page_pool.c b/drivers/staging/android/ion/ion_page_pool.c index a136a8593061..0ad1fb37408c 100644 --- a/drivers/staging/android/ion/ion_page_pool.c +++ b/drivers/staging/android/ion/ion_page_pool.c @@ -5,10 +5,7 @@ * Copyright (C) 2011 Google, Inc. */ -#include #include -#include -#include #include #include #include @@ -73,20 +70,6 @@ static struct page *ion_page_pool_remove(struct ion_page_pool *pool, bool high) return page; } -static void page_sync_for_device(struct device *dev, struct page *page, - size_t size, enum dma_data_direction dir) -{ - struct scatterlist sg; - - if (!dev || !page) - return; - - sg_init_table(&sg, 1); - sg_set_page(&sg, page, size, 0); - sg_dma_address(&sg) = page_to_phys(page); - dma_sync_sg_for_device(dev, &sg, 1, dir); -} - struct page *ion_page_pool_alloc(struct ion_page_pool *pool) { struct page *page = NULL; @@ -100,12 +83,8 @@ struct page *ion_page_pool_alloc(struct ion_page_pool *pool) page = ion_page_pool_remove(pool, false); mutex_unlock(&pool->mutex); - if (!page) { + if (!page) page = ion_page_pool_alloc_pages(pool); - page_sync_for_device(pool->dev, page, - PAGE_SIZE << pool->order, - DMA_BIDIRECTIONAL); - } return page; } @@ -169,33 +148,9 @@ int ion_page_pool_shrink(struct ion_page_pool *pool, gfp_t gfp_mask, return freed; } -static const struct platform_device_info ion_dev_info = { - .name = "ion-pool", - .id = PLATFORM_DEVID_AUTO, - .dma_mask = DMA_BIT_MASK(32), -}; - -static struct platform_device *platform_device_register_dma(const char *name) -{ - struct platform_device *pdev; - int ret; - - pdev = platform_device_register_full(&ion_dev_info); - if (pdev) { - ret = of_dma_configure(&pdev->dev, NULL, true); - if (ret) { - platform_device_unregister(pdev); - pdev = NULL; - } - } - - return pdev; -} - struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order) { - struct platform_device *pdev; - struct ion_page_pool *pool = kzalloc(sizeof(*pool), GFP_KERNEL); + struct ion_page_pool *pool = kmalloc(sizeof(*pool), GFP_KERNEL); if (!pool) return NULL; @@ -208,20 +163,10 @@ struct ion_page_pool *ion_page_pool_create(gfp_t gfp_mask, unsigned int order) mutex_init(&pool->mutex); plist_node_init(&pool->list, order); - pdev = platform_device_register_dma("ion_pool"); - if (!IS_ERR(pdev)) - pool->dev = &pdev->dev; - return pool; } void ion_page_pool_destroy(struct ion_page_pool *pool) { - if (pool->dev) { - struct platform_device *pdev = to_platform_device(pool->dev); - - of_dma_deconfigure(&pdev->dev); - platform_device_unregister(pdev); - } kfree(pool); }