Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 26 Apr 2017 16:13:23 +0000 (UTC)
From:      Olivier Houchard <cognet@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r317441 - head/sys/dev/ahci
Message-ID:  <201704261613.v3QGDN37050300@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201704261613.v3QGDN37050300>