drm_prime.c (6bde8ef51c917a657476310728d6cb3de6bac9e4) | drm_prime.c (707d561f77b5e2a6f90c9786bee44ee7a8dedc7e) |
---|---|
1/* 2 * Copyright © 2012 Red Hat 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the --- 788 unchanged lines hidden (view full) --- 797 * @nr_pages: length of the page vector 798 * 799 * This helper creates an sg table object from a set of pages 800 * the driver is responsible for mapping the pages into the 801 * importers address space for use with dma_buf itself. 802 * 803 * This is useful for implementing &drm_gem_object_funcs.get_sg_table. 804 */ | 1/* 2 * Copyright © 2012 Red Hat 3 * 4 * Permission is hereby granted, free of charge, to any person obtaining a 5 * copy of this software and associated documentation files (the "Software"), 6 * to deal in the Software without restriction, including without limitation 7 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 8 * and/or sell copies of the Software, and to permit persons to whom the --- 788 unchanged lines hidden (view full) --- 797 * @nr_pages: length of the page vector 798 * 799 * This helper creates an sg table object from a set of pages 800 * the driver is responsible for mapping the pages into the 801 * importers address space for use with dma_buf itself. 802 * 803 * This is useful for implementing &drm_gem_object_funcs.get_sg_table. 804 */ |
805struct sg_table *drm_prime_pages_to_sg(struct page **pages, unsigned int nr_pages) | 805struct sg_table *drm_prime_pages_to_sg(struct drm_device *dev, 806 struct page **pages, unsigned int nr_pages) |
806{ 807 struct sg_table *sg = NULL; | 807{ 808 struct sg_table *sg = NULL; |
809 size_t max_segment = 0; |
|
808 int ret; 809 810 sg = kmalloc(sizeof(struct sg_table), GFP_KERNEL); 811 if (!sg) { 812 ret = -ENOMEM; 813 goto out; 814 } 815 | 810 int ret; 811 812 sg = kmalloc(sizeof(struct sg_table), GFP_KERNEL); 813 if (!sg) { 814 ret = -ENOMEM; 815 goto out; 816 } 817 |
816 ret = sg_alloc_table_from_pages(sg, pages, nr_pages, 0, 817 nr_pages << PAGE_SHIFT, GFP_KERNEL); | 818 if (dev) 819 max_segment = dma_max_mapping_size(dev->dev); 820 if (max_segment == 0 || max_segment > SCATTERLIST_MAX_SEGMENT) 821 max_segment = SCATTERLIST_MAX_SEGMENT; 822 ret = __sg_alloc_table_from_pages(sg, pages, nr_pages, 0, 823 nr_pages << PAGE_SHIFT, 824 max_segment, GFP_KERNEL); |
818 if (ret) 819 goto out; 820 821 return sg; 822out: 823 kfree(sg); 824 return ERR_PTR(ret); 825} --- 201 unchanged lines hidden --- | 825 if (ret) 826 goto out; 827 828 return sg; 829out: 830 kfree(sg); 831 return ERR_PTR(ret); 832} --- 201 unchanged lines hidden --- |