From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756446AbcBCGtX (ORCPT ); Wed, 3 Feb 2016 01:49:23 -0500 Received: from mail-am1on0106.outbound.protection.outlook.com ([157.56.112.106]:24724 "EHLO emea01-am1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753286AbcBCGtW convert rfc822-to-8bit (ORCPT ); Wed, 3 Feb 2016 01:49:22 -0500 From: "Gujulan Elango, Hari Prasath (H.)" To: "gregkh@linuxfoundation.org" , "arve@android.com" , "riandrews@android.com" , "robin.murphy@arm.com" , "tixy@linaro.org" , "sriram@marirs.net.in" CC: "devel@driverdev.osuosl.org" , "linux-kernel@vger.kernel.org" Subject: [PATCHv2] staging: android: ion: use the manged version of DMA memory allocation Thread-Topic: [PATCHv2] staging: android: ion: use the manged version of DMA memory allocation Thread-Index: AQHRXk8BRB6y+C30nkarzlEWsavoTQ== Date: Wed, 3 Feb 2016 06:49:19 +0000 Message-ID: <20160203065029.GA20263@IND12F0122> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: linuxfoundation.org; dkim=none (message not signed) header.d=none;linuxfoundation.org; dmarc=none action=none header.from=visteon.com; x-ms-exchange-messagesentrepresentingtype: 1 x-originating-ip: [91.212.132.118] x-microsoft-exchange-diagnostics: 1;DB5PR06MB1573;5:KHxAZv74RMyRRfGve9lyMJZEaJtWGH7wufy0JLfF6J528p1/8Podus3b7GOjuJkx0asDMT+tl+rVz51CKElLQL8IVjxnDTG8eQ7bEBYoyz6xc3zwk9556w55z5NDNVDzW27LfZseC/Pnm+7XHgDZ8g==;24:/COGyneQtDG00IwkpK4WJuYGyzP9XeNwp68ziWCgPP3Y+OCF9d/ZO57Cg8Nlc8ZDkcxBUItxQ8IaRC9oUghB2sBs2SkutcWR0h/XVptThNg= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:DB5PR06MB1573; x-ms-office365-filtering-correlation-id: 419f5746-df01-40cf-7ede-08d32c66243f x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(208512329853888); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(5005006)(3002001)(10201501046);SRVR:DB5PR06MB1573;BCL:0;PCL:0;RULEID:;SRVR:DB5PR06MB1573; x-forefront-prvs: 08417837C5 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(2906002)(189998001)(19580395003)(11100500001)(33656002)(19580405001)(86362001)(2900100001)(77096005)(2860100001)(5008740100001)(3660700001)(3280700002)(50986999)(4326007)(5001960100002)(54356999)(229853001)(92566002)(2501003)(33716001)(122556002)(10400500002)(87936001)(40100003)(2201001)(5002640100001)(106116001)(66066001)(1220700001)(6116002)(102836003)(586003)(3846002)(5004730100002)(1076002)(5001770100001)(1096002);DIR:OUT;SFP:1102;SCL:1;SRVR:DB5PR06MB1573;H:DB5PR06MB1573.eurprd06.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:23 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="us-ascii" Content-ID: <9D2DF940088E48449FA427EF74E61FB6@eurprd06.prod.outlook.com> Content-Transfer-Encoding: 8BIT MIME-Version: 1.0 X-OriginatorOrg: visteon.com X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Feb 2016 06:49:19.4705 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 7a147aaf-01ec-498c-80a1-e34a8c63c548 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB5PR06MB1573 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hari Prasath Gujulan Elango Use the managed version of the dma_alloc_coherent() i.e. the dmam_alloc_coherent() & accordingly cleanup the error handling part.Also,remove the references to dma_free_coherent Signed-off-by: Hari Prasath Gujulan Elango --- v2:kbuild test robot reported warnings on ununsed variables.Those warnings are fixed. --- drivers/staging/android/ion/ion_cma_heap.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/drivers/staging/android/ion/ion_cma_heap.c b/drivers/staging/android/ion/ion_cma_heap.c index a3446da..8cd720b 100644 --- a/drivers/staging/android/ion/ion_cma_heap.c +++ b/drivers/staging/android/ion/ion_cma_heap.c @@ -61,7 +61,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, if (!info) return ION_CMA_ALLOCATE_FAILED; - info->cpu_addr = dma_alloc_coherent(dev, len, &(info->handle), + info->cpu_addr = dmam_alloc_coherent(dev, len, &(info->handle), GFP_HIGHUSER | __GFP_ZERO); if (!info->cpu_addr) { @@ -71,7 +71,7 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, info->table = kmalloc(sizeof(struct sg_table), GFP_KERNEL); if (!info->table) - goto free_mem; + goto err; if (dma_get_sgtable(dev, info->table, info->cpu_addr, info->handle, len)) @@ -83,8 +83,6 @@ static int ion_cma_allocate(struct ion_heap *heap, struct ion_buffer *buffer, free_table: kfree(info->table); -free_mem: - dma_free_coherent(dev, len, info->cpu_addr, info->handle); err: kfree(info); return ION_CMA_ALLOCATE_FAILED; @@ -92,13 +90,8 @@ err: static void ion_cma_free(struct ion_buffer *buffer) { - struct ion_cma_heap *cma_heap = to_cma_heap(buffer->heap); - struct device *dev = cma_heap->dev; struct ion_cma_buffer_info *info = buffer->priv_virt; - dev_dbg(dev, "Release buffer %p\n", buffer); - /* release memory */ - dma_free_coherent(dev, buffer->size, info->cpu_addr, info->handle); /* release sg table */ sg_free_table(info->table); kfree(info->table); -- 1.9.1