ivshmem: avoid infinite loop when concatenating segments
This patch aligns the logic used to check for the presence of adjacent segments in has_adjacent_segments() with the logic used in cleanup_segments() when actually deciding to concatenate or not a pair of segments. Additionally, adjacent segments are no longer considered overlapping to avoid generating errors for segments that can happily coexist together. This fixes an infinite loop that happened when segments where adjacent in their physical or virtual addresses but not in their ioremap addresses: has_adjacent_segments() reported the presence of adjacent segments while cleanup_segments() was not considering them for concatenation, resulting in an infinite loop since the result of has_adjacent_segments() is used in the decision to continue looping in cleanup_segments(). Signed-off-by: David Verbeiren <david.verbeiren@intel.com> Signed-off-by: Anatoly Burakov <anatoly.burakov@intel.com>
This commit is contained in:
parent
7d78841754
commit
d6cf31419e
@ -184,21 +184,21 @@ overlap(const struct rte_memzone * mz1, const struct rte_memzone * mz2)
|
||||
i_end2 = mz2->ioremap_addr + mz2->len;
|
||||
|
||||
/* check for overlap in virtual addresses */
|
||||
if (start1 >= start2 && start1 < end2)
|
||||
if (start1 > start2 && start1 < end2)
|
||||
result |= VIRT;
|
||||
if (start2 >= start1 && start2 < end1)
|
||||
result |= VIRT;
|
||||
|
||||
/* check for overlap in physical addresses */
|
||||
if (p_start1 >= p_start2 && p_start1 < p_end2)
|
||||
if (p_start1 > p_start2 && p_start1 < p_end2)
|
||||
result |= PHYS;
|
||||
if (p_start2 >= p_start1 && p_start2 < p_end1)
|
||||
if (p_start2 > p_start1 && p_start2 < p_end1)
|
||||
result |= PHYS;
|
||||
|
||||
/* check for overlap in ioremap addresses */
|
||||
if (i_start1 >= i_start2 && i_start1 < i_end2)
|
||||
if (i_start1 > i_start2 && i_start1 < i_end2)
|
||||
result |= IOREMAP;
|
||||
if (i_start2 >= i_start1 && i_start2 < i_end1)
|
||||
if (i_start2 > i_start1 && i_start2 < i_end1)
|
||||
result |= IOREMAP;
|
||||
|
||||
return result;
|
||||
@ -254,17 +254,14 @@ adjacent(const struct rte_memzone * mz1, const struct rte_memzone * mz2)
|
||||
static int
|
||||
has_adjacent_segments(struct ivshmem_segment * ms, int len)
|
||||
{
|
||||
int i, j, a;
|
||||
int i, j;
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
for (j = i + 1; j < len; j++) {
|
||||
a = adjacent(&ms[i].entry.mz, &ms[j].entry.mz);
|
||||
|
||||
/* check if segments are adjacent virtually and/or physically but
|
||||
* not ioremap (since that would indicate that they are from
|
||||
* different PCI devices and thus don't need to be concatenated.
|
||||
/* we're only interested in fully adjacent segments; partially
|
||||
* adjacent segments can coexist.
|
||||
*/
|
||||
if ((a & (VIRT|PHYS)) > 0 && (a & IOREMAP) == 0)
|
||||
if (adjacent(&ms[i].entry.mz, &ms[j].entry.mz) == FULL)
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
|
Loading…
Reference in New Issue
Block a user