[rtems-libbsd commit] pci_mpc85xx: Ensure access order for config-regs

Christian Mauderer christianm at rtems.org
Wed Jan 31 09:00:59 UTC 2024


Module:    rtems-libbsd
Branch:    6-freebsd-12
Commit:    97962443eea891a4451d40bf34f15a6c9219625f
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=97962443eea891a4451d40bf34f15a6c9219625f

Author:    Christian Mauderer <christian.mauderer at embedded-brains.de>
Date:      Fri Oct 20 10:52:14 2023 +0200

pci_mpc85xx: Ensure access order for config-regs

The CFG_ADDR has to be written before reading or writing the CFG_DATA.

---

 freebsd/sys/powerpc/mpc85xx/pci_mpc85xx.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/freebsd/sys/powerpc/mpc85xx/pci_mpc85xx.c b/freebsd/sys/powerpc/mpc85xx/pci_mpc85xx.c
index 47879e68..b479eb33 100644
--- a/freebsd/sys/powerpc/mpc85xx/pci_mpc85xx.c
+++ b/freebsd/sys/powerpc/mpc85xx/pci_mpc85xx.c
@@ -80,6 +80,7 @@ __FBSDID("$FreeBSD$");
 #include <powerpc/mpc85xx/mpc85xx.h>
 #ifdef __rtems__
 #include <rtems/score/memory.h>
+#include <libcpu/powerpc-utility.h>
 #endif /* __rtems__ */
 
 #define	REG_CFG_ADDR	0x0000
@@ -460,6 +461,9 @@ fsl_pcib_cfgread(struct fsl_pcib_softc *sc, u_int bus, u_int slot, u_int func,
 
 	mtx_lock_spin(&sc->sc_cfg_mtx);
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, REG_CFG_ADDR, addr);
+#ifdef __rtems__
+	ppc_enforce_in_order_execution_of_io();
+#endif
 
 	switch (bytes) {
 	case 1:
@@ -498,6 +502,9 @@ fsl_pcib_cfgwrite(struct fsl_pcib_softc *sc, u_int bus, u_int slot, u_int func,
 
 	mtx_lock_spin(&sc->sc_cfg_mtx);
 	bus_space_write_4(sc->sc_bst, sc->sc_bsh, REG_CFG_ADDR, addr);
+#ifdef __rtems__
+	ppc_enforce_in_order_execution_of_io();
+#endif
 
 	switch (bytes) {
 	case 1:



More information about the vc mailing list