mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	drm: Remove SCATTERLIST_MAX_SEGMENT
Since commit 9a40401cfa ("lib/scatterlist: Do not limit max_segment to
PAGE_ALIGNED values") the max_segment input to sg_alloc_table_from_pages()
does not have to be any special value. The new algorithm will always
create something less than what the user provides. Thus eliminate this
confusing constant.
- vmwgfx should use the HW capability, not mix in the OS page size for
  calling dma_set_max_seg_size()
- i915 uses i915_sg_segment_size() both for sg_alloc_table_from_pages
  and for some open coded sgl construction. This doesn't change the value
  since rounddown(size, UINT_MAX) == SCATTERLIST_MAX_SEGMENT
- drm_prime_pages_to_sg uses it as a default if max_segment is zero,
  UINT_MAX is fine to use directly.
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Thomas Hellstrom <thellstrom@vmware.com>
Cc: Qian Cai <cai@lca.pw>
Cc: "Ursulin, Tvrtko" <tvrtko.ursulin@intel.com>
Suggested-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Jason Gunthorpe <jgg@nvidia.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: https://patchwork.freedesktop.org/patch/msgid/0-v1-44733fccd781+13d-rm_scatterlist_max_jgg@nvidia.com
			
			
This commit is contained in:
		
							parent
							
								
									95d7a1a6f8
								
							
						
					
					
						commit
						7a60c2dd0f
					
				
					 5 changed files with 5 additions and 12 deletions
				
			
		| 
						 | 
				
			
			@ -820,8 +820,8 @@ struct sg_table *drm_prime_pages_to_sg(struct drm_device *dev,
 | 
			
		|||
 | 
			
		||||
	if (dev)
 | 
			
		||||
		max_segment = dma_max_mapping_size(dev->dev);
 | 
			
		||||
	if (max_segment == 0 || max_segment > SCATTERLIST_MAX_SEGMENT)
 | 
			
		||||
		max_segment = SCATTERLIST_MAX_SEGMENT;
 | 
			
		||||
	if (max_segment == 0)
 | 
			
		||||
		max_segment = UINT_MAX;
 | 
			
		||||
	sge = __sg_alloc_table_from_pages(sg, pages, nr_pages, 0,
 | 
			
		||||
					  nr_pages << PAGE_SHIFT,
 | 
			
		||||
					  max_segment,
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -112,7 +112,7 @@ static inline unsigned int i915_sg_segment_size(void)
 | 
			
		|||
	unsigned int size = swiotlb_max_segment();
 | 
			
		||||
 | 
			
		||||
	if (size == 0)
 | 
			
		||||
		return SCATTERLIST_MAX_SEGMENT;
 | 
			
		||||
		size = UINT_MAX;
 | 
			
		||||
 | 
			
		||||
	size = rounddown(size, PAGE_SIZE);
 | 
			
		||||
	/* swiotlb_max_segment_size can return 1 byte when it means one page. */
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -794,8 +794,7 @@ static int vmw_driver_load(struct drm_device *dev, unsigned long chipset)
 | 
			
		|||
	if (unlikely(ret != 0))
 | 
			
		||||
		goto out_err0;
 | 
			
		||||
 | 
			
		||||
	dma_set_max_seg_size(dev->dev, min_t(unsigned int, U32_MAX & PAGE_MASK,
 | 
			
		||||
					     SCATTERLIST_MAX_SEGMENT));
 | 
			
		||||
	dma_set_max_seg_size(dev->dev, U32_MAX);
 | 
			
		||||
 | 
			
		||||
	if (dev_priv->capabilities & SVGA_CAP_GMR2) {
 | 
			
		||||
		DRM_INFO("Max GMR ids is %u\n",
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -18,12 +18,6 @@ struct scatterlist {
 | 
			
		|||
#endif
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * Since the above length field is an unsigned int, below we define the maximum
 | 
			
		||||
 * length in bytes that can be stored in one scatterlist entry.
 | 
			
		||||
 */
 | 
			
		||||
#define SCATTERLIST_MAX_SEGMENT (UINT_MAX & PAGE_MASK)
 | 
			
		||||
 | 
			
		||||
/*
 | 
			
		||||
 * These macros should be used after a dma_map_sg call has been done
 | 
			
		||||
 * to get bus addresses of each of the SG entries and their lengths.
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -50,7 +50,7 @@ static void fail(struct test *test, struct sg_table *st, const char *cond)
 | 
			
		|||
 | 
			
		||||
int main(void)
 | 
			
		||||
{
 | 
			
		||||
	const unsigned int sgmax = SCATTERLIST_MAX_SEGMENT;
 | 
			
		||||
	const unsigned int sgmax = UINT_MAX;
 | 
			
		||||
	struct test *test, tests[] = {
 | 
			
		||||
		{ -EINVAL, 1, pfn(0), PAGE_SIZE, PAGE_SIZE + 1, 1 },
 | 
			
		||||
		{ -EINVAL, 1, pfn(0), PAGE_SIZE, 0, 1 },
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
		Reference in a new issue