From V1 comment:
Suggest to add a statement on 3 different types of IMR: General IMR, Host Memory
I/O Boundary IMR & System Management Mode IMR. Then, call out that this patch
is meant to support general IMR type only.
+ ret = imr_check_range(base, size);I believe this is redundant because imr_check_range() has test for (size & IMR_MASK)
+ if (ret)
+ return ret;
+
+ if (size < IMR_ALIGN)
+ return -EINVAL;
which means if the size is indeed smaller than 0x400, the test will caught it anyway.
+Do we want to account for the 'size fixup' above on 'end'
+ /* Tweak the size value */
+ size = imr_fixup_size(size);
+ pr_debug("IMR %d phys 0x%08lx-0x%08lx rmask 0x%08x wmask
0x%08x\n",
+ reg, base, end, rmask, wmask);
+
+ /* Allocate IMR */
+ imr.addr_lo = phys_to_imr(base);
+ imr.addr_hi = phys_to_imr(end);
The fix-up size above is never factored here ...
'end-size' should be the correct one
+ } else {A serious bug here.... 'reg' should be 'i' . We enter this branch if reg=-1
+ /* Search for match based on address range */
+ for (i = 0; i < imr_dev.max_imr; i++) {
+ ret = imr_read(reg, &imr);
Is there a miss in your test case?