summaryrefslogtreecommitdiff
path: root/drivers/net
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net')
-rw-r--r--drivers/net/ipa/ipa_table.c20
1 files changed, 12 insertions, 8 deletions
diff --git a/drivers/net/ipa/ipa_table.c b/drivers/net/ipa/ipa_table.c
index dd07fe9dd87a..988f2c2886b9 100644
--- a/drivers/net/ipa/ipa_table.c
+++ b/drivers/net/ipa/ipa_table.c
@@ -118,14 +118,6 @@
/* Check things that can be validated at build time. */
static void ipa_table_validate_build(void)
{
- /* IPA hardware accesses memory 128 bytes at a time. Addresses
- * referred to by entries in filter and route tables must be
- * aligned on 128-byte byte boundaries. The only rule address
- * ever use is the "zero rule", and it's aligned at the base
- * of a coherent DMA allocation.
- */
- BUILD_BUG_ON(ARCH_DMA_MINALIGN % IPA_TABLE_ALIGN);
-
/* Filter and route tables contain DMA addresses that refer
* to filter or route rules. But the size of a table entry
* is 64 bits regardless of what the size of an AP DMA address
@@ -665,6 +657,18 @@ int ipa_table_init(struct ipa *ipa)
if (!virt)
return -ENOMEM;
+ /* We put the "zero rule" at the base of our table area. The IPA
+ * hardware requires rules to be aligned on a 128-byte boundary.
+ * Make sure the allocation satisfies this constraint.
+ */
+ if (addr % IPA_TABLE_ALIGN) {
+ dev_err(dev, "table address %pad not %u-byte aligned\n",
+ &addr, IPA_TABLE_ALIGN);
+ dma_free_coherent(dev, size, virt, addr);
+
+ return -ERANGE;
+ }
+
ipa->table_virt = virt;
ipa->table_addr = addr;