On 3/30/26 3:34 PM, Markus Schneider-Pargmann wrote:
Hello Markus,
On Mon Mar 16, 2026 at 12:57 AM CET, Marek Vasut wrote:
Rework dev_phys_to_bus() and dev_bus_to_phys() to respect the size
of the area specified in dma-ranges DT property. The area outside
of ranges is remapped 1:1, while the area in the ranges is remapped
according to the description in the dma-ranges property.
Adjust the test to test the area within the remapped range, not area
outside the remapped range, which was incorrect.
Should this have a Fixes tag?
Signed-off-by: Marek Vasut <[email protected]>
Not a big expert, but this looks good to me:
Reviewed-by: Markus Schneider-Pargmann <[email protected]>
This was broken long enough, so this should go into next so it would get
sufficient testing before the next release.
[...]
+++ b/include/dm/device.h
@@ -166,8 +166,9 @@ enum {
* When CONFIG_DEVRES is enabled, devm_kmalloc() and friends will
* add to this list. Memory so-allocated will be freed
* automatically when the device is removed / unbound
- * @dma_offset: Offset between the physical address space (CPU's) and the
- * device's bus address space
+ * @dma_cpu: DMA physical address space (CPU's)
+ * @dma_bus: DMA device's bus address space
+ * @dma_size: DMA window size
* @iommu: IOMMU device associated with this device
*/
struct udevice {
@@ -196,7 +197,9 @@ struct udevice {
struct list_head devres_head;
#endif
#if CONFIG_IS_ENABLED(DM_DMA)
- ulong dma_offset;
+ phys_addr_t dma_cpu;
+ dma_addr_t dma_bus;
+ u64 dma_size;
#endif
[...]
+++ b/include/phys2bus.h
@@ -21,17 +21,23 @@ static inline unsigned long bus_to_phys(unsigned long bus)
}
#endif
-#if CONFIG_IS_ENABLED(DM)
+#if CONFIG_IS_ENABLED(DM_DMA)
This is not related to the code changes right?
It is, see the matching hunk above and below why this is guarded by DM_DMA .
#include <dm/device.h>
static inline dma_addr_t dev_phys_to_bus(struct udevice *dev, phys_addr_t phys)
{
- return phys - dev_get_dma_offset(dev);
+ /* If the PA is in the remap range, apply remap. */
+ if (phys >= dev->dma_cpu && phys < dev->dma_cpu + dev->dma_size)
+ phys -= dev->dma_cpu - dev->dma_bus;
+ return phys;
[...]