Author: zbb
Date: Tue Jun 20 11:11:42 2017
New Revision: 320142
URL: https://svnweb.freebsd.org/changeset/base/320142

Log:
  Disable PL310 outer cache sync for IO coherent platforms
  
  When a PL310 cache is used on a system that provides hardware
  coherency, the outer cache sync operation is useless, and can be
  skipped. Moreover, on some systems, it is harmful as it causes
  deadlocks between the Marvell coherency mechanism, the Marvell PCIe
  or Crypto controllers and the Cortex-A9.
  
  To avoid this, this commit introduces a new Device Tree property
  'arm,io-coherent' for the L2 cache controller node, valid only for the
  PL310 cache. It identifies the usage of the PL310 cache in an I/O
  coherent configuration. Internally, it makes the driver disable the
  outer cache sync operation.
  
  Note, that other outer-cache operations are not removed, as they may
  be needed for certain situations, such as booting secondary CPUs.
  Moreover, in order to enable IO coherent operation, the decision
  whether to use L2 cache maintenance callbacks is done in busdma
  layer, which was enabled in one of the previous commits.
  
  Submitted by: Michal Mazur <m...@semihalf.com>
              Marcin Wojtas <m...@semihalf.com>
  Reviewed by: mmel
  Obtained from: Semihalf
  Differential revision: https://reviews.freebsd.org/D11245

Modified:
  head/sys/arm/arm/pl310.c
  head/sys/arm/include/pl310.h

Modified: head/sys/arm/arm/pl310.c
==============================================================================
--- head/sys/arm/arm/pl310.c    Tue Jun 20 11:09:38 2017        (r320141)
+++ head/sys/arm/arm/pl310.c    Tue Jun 20 11:11:42 2017        (r320142)
@@ -206,6 +206,10 @@ pl310_cache_sync(void)
        if ((pl310_softc == NULL) || !pl310_softc->sc_enabled)
                return;
 
+       /* Do not sync outer cache on IO coherent platform */
+       if (pl310_softc->sc_io_coherent)
+               return;
+
 #ifdef PL310_ERRATA_753970
        if (pl310_softc->sc_rtl_revision == CACHE_ID_RELEASE_r3p0)
                /* Write uncached PL310 register */
@@ -444,6 +448,7 @@ pl310_attach(device_t dev)
        struct pl310_softc *sc = device_get_softc(dev);
        int rid;
        uint32_t cache_id, debug_ctrl;
+       phandle_t node;
 
        sc->sc_dev = dev;
        rid = 0;
@@ -469,6 +474,15 @@ pl310_attach(device_t dev)
        device_printf(dev, "Part number: 0x%x, release: 0x%x\n",
            (cache_id >> CACHE_ID_PARTNUM_SHIFT) & CACHE_ID_PARTNUM_MASK,
            (cache_id >> CACHE_ID_RELEASE_SHIFT) & CACHE_ID_RELEASE_MASK);
+
+       /*
+        * Test for "arm,io-coherent" property and disable sync operation if
+        * platform is I/O coherent. Outer sync operations are not needed
+        * on coherent platform and may be harmful in certain situations.
+        */
+       node = ofw_bus_get_node(dev);
+       if (OF_hasprop(node, "arm,io-coherent"))
+               sc->sc_io_coherent = true;
 
        /*
         * If L2 cache is already enabled then something has violated the rules,

Modified: head/sys/arm/include/pl310.h
==============================================================================
--- head/sys/arm/include/pl310.h        Tue Jun 20 11:09:38 2017        
(r320141)
+++ head/sys/arm/include/pl310.h        Tue Jun 20 11:11:42 2017        
(r320142)
@@ -148,6 +148,7 @@ struct pl310_softc {
        struct mtx      sc_mtx;
        u_int           sc_rtl_revision;
        struct intr_config_hook *sc_ich;
+       boolean_t       sc_io_coherent;
 };
 
 /**
_______________________________________________
svn-src-head@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to