Re: [PATCH] lib/logic_pio: Fix overlap check for pio registery

From: John Garry
Date: Fri Dec 18 2020 - 05:41:41 EST


On 18/12/2020 06:23, Jiahui Cen wrote:
Since the [start, end) is a half-open interval, a range with the end equal
to the start of another range should not be considered as overlapped.

Signed-off-by: Jiahui Cen <cenjiahui@xxxxxxxxxx>
---
lib/logic_pio.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lib/logic_pio.c b/lib/logic_pio.c
index f32fe481b492..445d611f1dc1 100644
--- a/lib/logic_pio.c
+++ b/lib/logic_pio.c
@@ -57,7 +57,7 @@ int logic_pio_register_range(struct logic_pio_hwaddr *new_range)
new_range->flags == LOGIC_PIO_CPU_MMIO) {
/* for MMIO ranges we need to check for overlap */
if (start >= range->hw_start + range->size ||
- end < range->hw_start) {
+ end <= range->hw_start) {

It looks like your change is correct, but should not really have an impact in practice since:
a: BIOSes generally list ascending IO port CPU addresses
b. there is space between IO port CPU address regions

Have you seen a problem here?

Thanks,
John