@@ -205,19 +205,16 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
205205 goto err2 ;
206206 }
207207
208- buffer -> dev = dev ;
209- buffer -> size = len ;
210-
211- table = heap -> ops -> map_dma (heap , buffer );
212- if (WARN_ONCE (table == NULL ,
213- "heap->ops->map_dma should return ERR_PTR on error" ))
214- table = ERR_PTR (- EINVAL );
215- if (IS_ERR (table )) {
208+ if (buffer -> sg_table == NULL ) {
209+ WARN_ONCE (1 , "This heap needs to set the sgtable" );
216210 ret = - EINVAL ;
217211 goto err1 ;
218212 }
219213
220- buffer -> sg_table = table ;
214+ table = buffer -> sg_table ;
215+ buffer -> dev = dev ;
216+ buffer -> size = len ;
217+
221218 if (ion_buffer_fault_user_mappings (buffer )) {
222219 int num_pages = PAGE_ALIGN (buffer -> size ) / PAGE_SIZE ;
223220 struct scatterlist * sg ;
@@ -226,7 +223,7 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
226223 buffer -> pages = vmalloc (sizeof (struct page * ) * num_pages );
227224 if (!buffer -> pages ) {
228225 ret = - ENOMEM ;
229- goto err ;
226+ goto err1 ;
230227 }
231228
232229 for_each_sg (table -> sgl , sg , table -> nents , i ) {
@@ -260,8 +257,6 @@ static struct ion_buffer *ion_buffer_create(struct ion_heap *heap,
260257 mutex_unlock (& dev -> buffer_lock );
261258 return buffer ;
262259
263- err :
264- heap -> ops -> unmap_dma (heap , buffer );
265260err1 :
266261 heap -> ops -> free (buffer );
267262err2 :
@@ -273,7 +268,6 @@ void ion_buffer_destroy(struct ion_buffer *buffer)
273268{
274269 if (WARN_ON (buffer -> kmap_cnt > 0 ))
275270 buffer -> heap -> ops -> unmap_kernel (buffer -> heap , buffer );
276- buffer -> heap -> ops -> unmap_dma (buffer -> heap , buffer );
277271 buffer -> heap -> ops -> free (buffer );
278272 vfree (buffer -> pages );
279273 kfree (buffer );
@@ -551,7 +545,8 @@ struct ion_handle *ion_alloc(struct ion_client *client, size_t len,
551545}
552546EXPORT_SYMBOL (ion_alloc );
553547
554- static void ion_free_nolock (struct ion_client * client , struct ion_handle * handle )
548+ static void ion_free_nolock (struct ion_client * client ,
549+ struct ion_handle * handle )
555550{
556551 bool valid_handle ;
557552
@@ -576,32 +571,6 @@ void ion_free(struct ion_client *client, struct ion_handle *handle)
576571}
577572EXPORT_SYMBOL (ion_free );
578573
579- int ion_phys (struct ion_client * client , struct ion_handle * handle ,
580- ion_phys_addr_t * addr , size_t * len )
581- {
582- struct ion_buffer * buffer ;
583- int ret ;
584-
585- mutex_lock (& client -> lock );
586- if (!ion_handle_validate (client , handle )) {
587- mutex_unlock (& client -> lock );
588- return - EINVAL ;
589- }
590-
591- buffer = handle -> buffer ;
592-
593- if (!buffer -> heap -> ops -> phys ) {
594- pr_err ("%s: ion_phys is not implemented by this heap (name=%s, type=%d).\n" ,
595- __func__ , buffer -> heap -> name , buffer -> heap -> type );
596- mutex_unlock (& client -> lock );
597- return - ENODEV ;
598- }
599- mutex_unlock (& client -> lock );
600- ret = buffer -> heap -> ops -> phys (buffer -> heap , buffer , addr , len );
601- return ret ;
602- }
603- EXPORT_SYMBOL (ion_phys );
604-
605574static void * ion_buffer_kmap_get (struct ion_buffer * buffer )
606575{
607576 void * vaddr ;
@@ -917,26 +886,6 @@ void ion_client_destroy(struct ion_client *client)
917886}
918887EXPORT_SYMBOL (ion_client_destroy );
919888
920- struct sg_table * ion_sg_table (struct ion_client * client ,
921- struct ion_handle * handle )
922- {
923- struct ion_buffer * buffer ;
924- struct sg_table * table ;
925-
926- mutex_lock (& client -> lock );
927- if (!ion_handle_validate (client , handle )) {
928- pr_err ("%s: invalid handle passed to map_dma.\n" ,
929- __func__ );
930- mutex_unlock (& client -> lock );
931- return ERR_PTR (- EINVAL );
932- }
933- buffer = handle -> buffer ;
934- table = buffer -> sg_table ;
935- mutex_unlock (& client -> lock );
936- return table ;
937- }
938- EXPORT_SYMBOL (ion_sg_table );
939-
940889static void ion_buffer_sync_for_device (struct ion_buffer * buffer ,
941890 struct device * dev ,
942891 enum dma_data_direction direction );
@@ -1358,7 +1307,8 @@ static long ion_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
13581307 struct ion_handle * handle ;
13591308
13601309 mutex_lock (& client -> lock );
1361- handle = ion_handle_get_by_id_nolock (client , data .handle .handle );
1310+ handle = ion_handle_get_by_id_nolock (client ,
1311+ data .handle .handle );
13621312 if (IS_ERR (handle )) {
13631313 mutex_unlock (& client -> lock );
13641314 return PTR_ERR (handle );
@@ -1588,8 +1538,7 @@ void ion_device_add_heap(struct ion_device *dev, struct ion_heap *heap)
15881538{
15891539 struct dentry * debug_file ;
15901540
1591- if (!heap -> ops -> allocate || !heap -> ops -> free || !heap -> ops -> map_dma ||
1592- !heap -> ops -> unmap_dma )
1541+ if (!heap -> ops -> allocate || !heap -> ops -> free )
15931542 pr_err ("%s: can not add heap with invalid ops struct.\n" ,
15941543 __func__ );
15951544
@@ -1703,37 +1652,3 @@ void ion_device_destroy(struct ion_device *dev)
17031652}
17041653EXPORT_SYMBOL (ion_device_destroy );
17051654
1706- void __init ion_reserve (struct ion_platform_data * data )
1707- {
1708- int i ;
1709-
1710- for (i = 0 ; i < data -> nr ; i ++ ) {
1711- if (data -> heaps [i ].size == 0 )
1712- continue ;
1713-
1714- if (data -> heaps [i ].base == 0 ) {
1715- phys_addr_t paddr ;
1716-
1717- paddr = memblock_alloc_base (data -> heaps [i ].size ,
1718- data -> heaps [i ].align ,
1719- MEMBLOCK_ALLOC_ANYWHERE );
1720- if (!paddr ) {
1721- pr_err ("%s: error allocating memblock for heap %d\n" ,
1722- __func__ , i );
1723- continue ;
1724- }
1725- data -> heaps [i ].base = paddr ;
1726- } else {
1727- int ret = memblock_reserve (data -> heaps [i ].base ,
1728- data -> heaps [i ].size );
1729- if (ret )
1730- pr_err ("memblock reserve of %zx@%lx failed\n" ,
1731- data -> heaps [i ].size ,
1732- data -> heaps [i ].base );
1733- }
1734- pr_info ("%s: %s reserved base %lx size %zu\n" , __func__ ,
1735- data -> heaps [i ].name ,
1736- data -> heaps [i ].base ,
1737- data -> heaps [i ].size );
1738- }
1739- }
0 commit comments