Author: cognet
Date: Wed Apr 26 16:13:22 2017
New Revision: 317441
URL: https://svnweb.freebsd.org/changeset/base/317441

Log:
  Check if the device is marked as dma-coherent in the FDT, and if so, let
  busdma know, so that on architectures where dma isn't always coherent, we
  know we don't have to write-back/invalidates cachelines on DMA operations.
  
  Reviewed by:  andrew, mav

Modified:
  head/sys/dev/ahci/ahci.c
  head/sys/dev/ahci/ahci.h
  head/sys/dev/ahci/ahci_generic.c

Modified: head/sys/dev/ahci/ahci.c
==============================================================================
--- head/sys/dev/ahci/ahci.c    Wed Apr 26 14:50:06 2017        (r317440)
+++ head/sys/dev/ahci/ahci.c    Wed Apr 26 16:13:22 2017        (r317441)
@@ -249,7 +249,8 @@ ahci_attach(device_t dev)
            (ctlr->caps & AHCI_CAP_64BIT) ? BUS_SPACE_MAXADDR :
            BUS_SPACE_MAXADDR_32BIT, BUS_SPACE_MAXADDR, NULL, NULL,
            BUS_SPACE_MAXSIZE, BUS_SPACE_UNRESTRICTED, BUS_SPACE_MAXSIZE,
-           0, NULL, NULL, &ctlr->dma_tag)) {
+           ctlr->dma_coherent ? BUS_DMA_COHERENT : 0, NULL, NULL, 
+           &ctlr->dma_tag)) {
                ahci_free_mem(dev);
                rman_fini(&ctlr->sc_iomem);
                return (ENXIO);

Modified: head/sys/dev/ahci/ahci.h
==============================================================================
--- head/sys/dev/ahci/ahci.h    Wed Apr 26 14:50:06 2017        (r317440)
+++ head/sys/dev/ahci/ahci.h    Wed Apr 26 16:13:22 2017        (r317441)
@@ -519,6 +519,7 @@ struct ahci_controller {
                void                    *argument;
        } interrupt[AHCI_MAX_PORTS];
        void                    (*ch_start)(struct ahci_channel *);
+       int                     dma_coherent;   /* DMA is cache-coherent */
 };
 
 enum ahci_err_type {

Modified: head/sys/dev/ahci/ahci_generic.c
==============================================================================
--- head/sys/dev/ahci/ahci_generic.c    Wed Apr 26 14:50:06 2017        
(r317440)
+++ head/sys/dev/ahci/ahci_generic.c    Wed Apr 26 16:13:22 2017        
(r317441)
@@ -68,6 +68,8 @@ static struct ofw_compat_data compat_dat
 static int
 ahci_fdt_probe(device_t dev)
 {
+       struct ahci_controller *ctlr = device_get_softc(dev);
+       phandle_t node;
 
        if (!ofw_bus_status_okay(dev))
                return (ENXIO);
@@ -76,6 +78,8 @@ ahci_fdt_probe(device_t dev)
                return (ENXIO);
 
        device_set_desc_copy(dev, "AHCI SATA controller");
+       node = ofw_bus_get_node(dev);
+       ctlr->dma_coherent = OF_hasprop(node, "dma-coherent");
        return (BUS_PROBE_DEFAULT);
 }
 #endif
_______________________________________________
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