summaryrefslogtreecommitdiff
path: root/include/dm
diff options
context:
space:
mode:
authorNicolas Saenz Julienne <nsaenzjulienne@suse.de>2021-01-12 13:55:24 +0100
committerMatthias Brugger <mbrugger@suse.com>2021-02-18 11:56:25 +0100
commit4abf68d57d495674e521b693191be1dcada46ecd (patch)
tree6471b542fbfc4730c539778640611cb5c96c2b15 /include/dm
parent283628c412a2b98bdb22093a732aef4d5668e106 (diff)
downloadu-boot-4abf68d57d495674e521b693191be1dcada46ecd.tar.gz
dm: Introduce DMA constraints into the core device model
Calculating the DMA offset between a bus address space and CPU's every time we call phys_to_bus() and bus_to_phys() isn't ideal performance wise, as it implies traversing the device tree from the device's node up to the root. Since this information is static and available before the device's initialization, parse it before the probe call an provide the DMA offset in 'struct udevice' for the address translation code to use it. Signed-off-by: Nicolas Saenz Julienne <nsaenzjulienne@suse.de> Reviewed-by: Simon Glass <sjg@chromium.org> Tested-by: Peter Robinson <pbrobinson@gmail.com> Signed-off-by: Matthias Brugger <mbrugger@suse.com>
Diffstat (limited to 'include/dm')
-rw-r--r--include/dm/device.h13
1 files changed, 13 insertions, 0 deletions
diff --git a/include/dm/device.h b/include/dm/device.h
index 28533ce0b6..bb9faa0ed9 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -159,6 +159,8 @@ 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
*/
struct udevice {
const struct driver *driver;
@@ -183,6 +185,9 @@ struct udevice {
#ifdef CONFIG_DEVRES
struct list_head devres_head;
#endif
+#if CONFIG_IS_ENABLED(DM_DMA)
+ ulong dma_offset;
+#endif
};
/* Maximum sequence number supported */
@@ -224,6 +229,14 @@ static inline ofnode dev_ofnode(const struct udevice *dev)
/* Returns non-zero if the device is active (probed and not removed) */
#define device_active(dev) (dev_get_flags(dev) & DM_FLAG_ACTIVATED)
+#if CONFIG_IS_ENABLED(DM_DMA)
+#define dev_set_dma_offset(_dev, _offset) _dev->dma_offset = _offset
+#define dev_get_dma_offset(_dev) _dev->dma_offset
+#else
+#define dev_set_dma_offset(_dev, _offset)
+#define dev_get_dma_offset(_dev) 0
+#endif
+
static inline int dev_of_offset(const struct udevice *dev)
{
#if !CONFIG_IS_ENABLED(OF_PLATDATA)