• Robin Murphy's avatar
    dma-debug: improve search for partial syncs · 2995b800
    Robin Murphy authored
    When bucket_find_contains() tries to find the original entry for a
    partial sync, it manages to constrain its search in a way that is both
    too restrictive and not restrictive enough. A driver which only uses
    single mappings rather than scatterlists might not set max_seg_size, but
    could still technically perform a partial sync at an offset of more than
    64KB into a sufficiently large mapping, so we could stop searching too
    early before reaching a legitimate entry. Conversely, if no valid entry
    is present and max_range is large enough, we can pointlessly search
    buckets that we've already searched, or that represent an impossible
    wrapping around the bottom of the address space. At worst, the
    (legitimate) case of max_seg_size == UINT_MAX can make the loop
    infinite.
    
    Replace the fragile and frankly hard-to-follow "range" logic with a
    simple counted loop for the number of possible hash buckets below the
    given address.
    Reported-by: default avatarYunfei Wang <yf.wang@mediatek.com>
    Signed-off-by: default avatarRobin Murphy <robin.murphy@arm.com>
    Signed-off-by: default avatarChristoph Hellwig <hch@lst.de>
    2995b800
debug.c 41.3 KB