]> git.baikalelectronics.ru Git - uboot.git/commit
serial: ns16550: Move PCI access from ofdata_to_platdata() to probe()
authorWolfgang Wallner <wolfgang.wallner@br-automation.com>
Mon, 2 Mar 2020 13:41:14 +0000 (14:41 +0100)
committerBin Meng <bmeng.cn@gmail.com>
Thu, 5 Mar 2020 10:25:10 +0000 (18:25 +0800)
commitfa90b82e44566d8bd31c3ffaa1f769e6cbe3db2b
tree3fcae81685eca204abd14e305fcd3c57bd19cd02
parente5456d776cc3bff96382ce7d1c25fd0260b7d559
serial: ns16550: Move PCI access from ofdata_to_platdata() to probe()

Currently the ofdata_to_platdata() method calls dev_read_addr_pci(),
which potentially accesses the parent PCI bus. If this happens before
the parent PCI bus is probed the resulting address will be wrong.

This behavior was triggered by commit 332eecf72d7b ("dm: core:
Allocate parent data separate from probing parent").

According to a comment in drivers/pci/pci-uclass.c [1] accessing
the PCI parent bus in ofdata_to_platdata() is not allowed, and the
access should be moved to the probe() function.

Move the call to dev_read_addr_pci() and the related handling of the
'addr' value from the ofdata_to_platdata() to its own function,
which is then called from the probe() method.

While moving the code, the comment /* try Processor Local Bus device
first */ was dropped. It was initially added with commit 3db886a5bf38
("serial: ns16550: Support ns16550 compatible pci uart devices") and
later made obsolete with commit 458f7d4f17b6 ("dm: pci: Add a function
to read a PCI BAR").

[1] Comment in drivers/pci/pci-uclass.c:
"A common cause of this problem is that this function is called in the
ofdata_to_platdata() method of @dev. Accessing the PCI bus in that
method is not allowed, since it has not yet been probed. To fix this,
move that access to the probe() method of @dev instead."

Fixes: 332eecf72d7b ("dm: core: Allocate parent data separate from probing parent")
Signed-off-by: Wolfgang Wallner <wolfgang.wallner@br-automation.com>
Reviewed-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Bin Meng <bmeng.cn@gmail.com>
Tested-by: Bin Meng <bmeng.cn@gmail.com> # Tested on Intel Galileo
drivers/serial/ns16550.c