Skip to content

Commit 2e379ac

Browse files
paliLorenzo Pieralisi
authored andcommitted
PCI: mvebu: Fix endianness when accessing PCI emul bridge members
PCI emul bridge members iolimitupper, iobaseupper, memlimit and membase are of type __le16, so correctly access these members using le16_to_cpu() macros. Link: https://lore.kernel.org/r/20220812141115.24082-1-pali@kernel.org Fixes: e7a0187 ("PCI: mvebu: Propagate errors when updating PCI_IO_BASE and PCI_MEM_BASE registers") Reported-by: kernel test robot <lkp@intel.com> Signed-off-by: Pali Rohár <pali@kernel.org> Signed-off-by: Lorenzo Pieralisi <lpieralisi@kernel.org>
1 parent 568035b commit 2e379ac

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/pci/controller/pci-mvebu.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -523,7 +523,7 @@ static int mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
523523

524524
/* Are the new iobase/iolimit values invalid? */
525525
if (conf->iolimit < conf->iobase ||
526-
conf->iolimitupper < conf->iobaseupper)
526+
le16_to_cpu(conf->iolimitupper) < le16_to_cpu(conf->iobaseupper))
527527
return mvebu_pcie_set_window(port, port->io_target, port->io_attr,
528528
&desired, &port->iowin);
529529

@@ -535,10 +535,10 @@ static int mvebu_pcie_handle_iobase_change(struct mvebu_pcie_port *port)
535535
* is the CPU address.
536536
*/
537537
desired.remap = ((conf->iobase & 0xF0) << 8) |
538-
(conf->iobaseupper << 16);
538+
(le16_to_cpu(conf->iobaseupper) << 16);
539539
desired.base = port->pcie->io.start + desired.remap;
540540
desired.size = ((0xFFF | ((conf->iolimit & 0xF0) << 8) |
541-
(conf->iolimitupper << 16)) -
541+
(le16_to_cpu(conf->iolimitupper) << 16)) -
542542
desired.remap) +
543543
1;
544544

@@ -552,7 +552,7 @@ static int mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port)
552552
struct pci_bridge_emul_conf *conf = &port->bridge.conf;
553553

554554
/* Are the new membase/memlimit values invalid? */
555-
if (conf->memlimit < conf->membase)
555+
if (le16_to_cpu(conf->memlimit) < le16_to_cpu(conf->membase))
556556
return mvebu_pcie_set_window(port, port->mem_target, port->mem_attr,
557557
&desired, &port->memwin);
558558

@@ -562,8 +562,8 @@ static int mvebu_pcie_handle_membase_change(struct mvebu_pcie_port *port)
562562
* window to setup, according to the PCI-to-PCI bridge
563563
* specifications.
564564
*/
565-
desired.base = ((conf->membase & 0xFFF0) << 16);
566-
desired.size = (((conf->memlimit & 0xFFF0) << 16) | 0xFFFFF) -
565+
desired.base = ((le16_to_cpu(conf->membase) & 0xFFF0) << 16);
566+
desired.size = (((le16_to_cpu(conf->memlimit) & 0xFFF0) << 16) | 0xFFFFF) -
567567
desired.base + 1;
568568

569569
return mvebu_pcie_set_window(port, port->mem_target, port->mem_attr, &desired,

0 commit comments

Comments
 (0)