PCI: designware-ep: Fix find_first_zero_bit() usage
authorNiklas Cassel <niklas.cassel@axis.com>
Thu, 14 Dec 2017 13:01:44 +0000 (14:01 +0100)
committerLorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Tue, 19 Dec 2017 11:05:44 +0000 (11:05 +0000)
commitad4a5becc689c3f32bbbc2b37eff89efe19dc2f9
tree594e1ca0c98e16a9826c94d15566a3c4471c7b07
parent1291a0d5049dbc06baaaf66a9ff3f53db493b19b
PCI: designware-ep: Fix find_first_zero_bit() usage

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: f8aed6ec624f ("PCI: dwc: designware: Add EP mode support")
Signed-off-by: Niklas Cassel <niklas.cassel@axis.com>
Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Acked-by: Kishon Vijay Abraham I <kishon@ti.com>
drivers/pci/dwc/pcie-designware-ep.c
drivers/pci/dwc/pcie-designware.h