Author: bdragon
Date: Wed Sep 23 01:37:01 2020
New Revision: 366047
URL: https://svnweb.freebsd.org/changeset/base/366047

Log:
  [PowerPC64LE] Endian fixes for opal_pci.c.
  
  Since OPAL runs in big endian, any data being passed back and forth
  via memory instead of registers needs to be byteswapped.
  
  From my notes during development:
  
  "A good way to find candidates is to look for vtophys() in opal_call()
  parameters. The memory being passed will be written into in BE."
  
  Sponsored by: Tag1 Consulting, Inc.

Modified:
  head/sys/powerpc/powernv/opal_pci.c

Modified: head/sys/powerpc/powernv/opal_pci.c
==============================================================================
--- head/sys/powerpc/powernv/opal_pci.c Wed Sep 23 01:33:54 2020        
(r366046)
+++ head/sys/powerpc/powernv/opal_pci.c Wed Sep 23 01:37:01 2020        
(r366047)
@@ -524,11 +524,12 @@ opalpci_read_config(device_t dev, u_int bus, u_int slo
        case 2:
                error = opal_call(OPAL_PCI_CONFIG_READ_HALF_WORD, sc->phb_id,
                    config_addr, reg, vtophys(&half));
-               word = half;
+               word = be16toh(half);
                break;
        case 4:
                error = opal_call(OPAL_PCI_CONFIG_READ_WORD, sc->phb_id,
                    config_addr, reg, vtophys(&word));
+               word = be32toh(word);
                break;
        default:
                error = OPAL_SUCCESS;
@@ -547,6 +548,7 @@ opalpci_read_config(device_t dev, u_int bus, u_int slo
                        opal_call(OPAL_PCI_EEH_FREEZE_STATUS, sc->phb_id,
                            OPAL_PCI_DEFAULT_PE, vtophys(&eeh_state),
                            vtophys(&err_type), NULL);
+                       err_type = be16toh(err_type); /* XXX unused */
                        if (eeh_state != OPAL_EEH_STOPPED_NOT_FROZEN)
                                opal_call(OPAL_PCI_EEH_FREEZE_CLEAR,
                                    sc->phb_id, OPAL_PCI_DEFAULT_PE,
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to