mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	of: Calculate device DMA masks based on DT dma-range size
Calculate the dma_mask and coherent_dma_mask based on the dma-range values set in DT for the device. Limit the mask to lower of the default mask and mask calculated. Signed-off-by: Murali Karicheri <m-karicheri2@ti.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Reviewed-by: Catalin Marinas <catalin.marinas@arm.com> CC: Joerg Roedel <joro@8bytes.org> CC: Grant Likely <grant.likely@linaro.org> CC: Rob Herring <robh+dt@kernel.org> CC: Will Deacon <will.deacon@arm.com> CC: Russell King <linux@arm.linux.org.uk> CC: Arnd Bergmann <arnd@arndb.de> CC: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
This commit is contained in:
		
							parent
							
								
									22b3c181c6
								
							
						
					
					
						commit
						9a6d7298b0
					
				
					 1 changed files with 13 additions and 3 deletions
				
			
		| 
						 | 
					@ -90,10 +90,11 @@ void of_dma_configure(struct device *dev, struct device_node *np)
 | 
				
			||||||
	struct iommu_ops *iommu;
 | 
						struct iommu_ops *iommu;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Set default dma-mask to 32 bit.  Drivers are expected to setup
 | 
						 * Set default coherent_dma_mask to 32 bit.  Drivers are expected to
 | 
				
			||||||
	 * the correct supported dma_mask.
 | 
						 * setup the correct supported mask.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	dev->coherent_dma_mask = DMA_BIT_MASK(32);
 | 
						if (!dev->coherent_dma_mask)
 | 
				
			||||||
 | 
							dev->coherent_dma_mask = DMA_BIT_MASK(32);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
	 * Set it to coherent_dma_mask by default if the architecture
 | 
						 * Set it to coherent_dma_mask by default if the architecture
 | 
				
			||||||
| 
						 | 
					@ -128,6 +129,15 @@ void of_dma_configure(struct device *dev, struct device_node *np)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dev->dma_pfn_offset = offset;
 | 
						dev->dma_pfn_offset = offset;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						/*
 | 
				
			||||||
 | 
						 * Limit coherent and dma mask based on size and default mask
 | 
				
			||||||
 | 
						 * set by the driver.
 | 
				
			||||||
 | 
						 */
 | 
				
			||||||
 | 
						dev->coherent_dma_mask = min(dev->coherent_dma_mask,
 | 
				
			||||||
 | 
									     DMA_BIT_MASK(ilog2(dma_addr + size)));
 | 
				
			||||||
 | 
						*dev->dma_mask = min((*dev->dma_mask),
 | 
				
			||||||
 | 
								     DMA_BIT_MASK(ilog2(dma_addr + size)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	coherent = of_dma_is_coherent(np);
 | 
						coherent = of_dma_is_coherent(np);
 | 
				
			||||||
	dev_dbg(dev, "device is%sdma coherent\n",
 | 
						dev_dbg(dev, "device is%sdma coherent\n",
 | 
				
			||||||
		coherent ? " " : " not ");
 | 
							coherent ? " " : " not ");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in a new issue