• Niklas Cassel's avatar
    PCI: designware-ep: Fix find_first_zero_bit() usage · ad4a5bec
    Niklas Cassel authored
    find_first_zero_bit()'s parameter 'size' is defined in bits,
    not in bytes.
    
    find_first_zero_bit() is called with size in bytes rather than bits,
    which thus defines a too low upper limit, causing
    dw_pcie_ep_inbound_atu() to assign iatu index #4 to both bar 4
    and bar 5, which makes bar 5 overwrite the settings set by bar 4.
    
    Since the sizes of the bitmaps are known, dynamically allocate the
    bitmaps, and use the correct size when calling find_first_zero_bit().
    
    Additionally, make sure that ep->num_ob_windows and ep->num_ib_windows,
    which are obtained from device tree, are smaller than the maximum number
    of iATUs (MAX_IATU_IN/MAX_IATU_OUT).
    
    Fixes: f8aed6ec ("PCI: dwc: designware: Add EP mode support")
    Signed-off-by: default avatarNiklas Cassel <niklas.cassel@axis.com>
    Signed-off-by: default avatarLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
    Acked-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
    ad4a5bec
pcie-designware.h 9.77 KB