Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Sep 2016 09:10:32 +0000 (UTC)
From:      Alexander Motin <mav@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org
Subject:   svn commit: r305797 - stable/11/sys/dev/ahci
Message-ID:  <201609140910.u8E9AWYX034383@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: mav
Date: Wed Sep 14 09:10:31 2016
New Revision: 305797
URL: https://svnweb.freebsd.org/changeset/base/305797

Log:
  MFC r305536: Fix channel initialization in FBS mode.
  
  Due to reading initialized variable, FIS receive area was always allocated
  as 256 bytes, suitable for command-based switching, instead of 4096 bytes,
  required for FIS-based switching.  This caused memory corruption in case of
  port multipliers used on FBS-capable HBAs (Marvell).

Modified:
  stable/11/sys/dev/ahci/ahci.c
Directory Properties:
  stable/11/   (props changed)

Modified: stable/11/sys/dev/ahci/ahci.c
==============================================================================
--- stable/11/sys/dev/ahci/ahci.c	Wed Sep 14 08:59:13 2016	(r305796)
+++ stable/11/sys/dev/ahci/ahci.c	Wed Sep 14 09:10:31 2016	(r305797)
@@ -715,6 +715,21 @@ ahci_ch_attach(device_t dev)
 	if (!(ch->r_mem = bus_alloc_resource_any(dev, SYS_RES_MEMORY,
 	    &rid, RF_ACTIVE)))
 		return (ENXIO);
+	ch->chcaps = ATA_INL(ch->r_mem, AHCI_P_CMD);
+	version = ATA_INL(ctlr->r_mem, AHCI_VS);
+	if (version < 0x00010200 && (ctlr->caps & AHCI_CAP_FBSS))
+		ch->chcaps |= AHCI_P_CMD_FBSCP;
+	if (ch->caps2 & AHCI_CAP2_SDS)
+		ch->chscaps = ATA_INL(ch->r_mem, AHCI_P_DEVSLP);
+	if (bootverbose) {
+		device_printf(dev, "Caps:%s%s%s%s%s%s\n",
+		    (ch->chcaps & AHCI_P_CMD_HPCP) ? " HPCP":"",
+		    (ch->chcaps & AHCI_P_CMD_MPSP) ? " MPSP":"",
+		    (ch->chcaps & AHCI_P_CMD_CPD) ? " CPD":"",
+		    (ch->chcaps & AHCI_P_CMD_ESP) ? " ESP":"",
+		    (ch->chcaps & AHCI_P_CMD_FBSCP) ? " FBSCP":"",
+		    (ch->chscaps & AHCI_P_DEVSLP_DSP) ? " DSP":"");
+	}
 	ahci_dmainit(dev);
 	ahci_slotsalloc(dev);
 	mtx_lock(&ch->mtx);
@@ -733,21 +748,6 @@ ahci_ch_attach(device_t dev)
 		error = ENXIO;
 		goto err1;
 	}
-	ch->chcaps = ATA_INL(ch->r_mem, AHCI_P_CMD);
-	version = ATA_INL(ctlr->r_mem, AHCI_VS);
-	if (version < 0x00010200 && (ctlr->caps & AHCI_CAP_FBSS))
-		ch->chcaps |= AHCI_P_CMD_FBSCP;
-	if (ch->caps2 & AHCI_CAP2_SDS)
-		ch->chscaps = ATA_INL(ch->r_mem, AHCI_P_DEVSLP);
-	if (bootverbose) {
-		device_printf(dev, "Caps:%s%s%s%s%s%s\n",
-		    (ch->chcaps & AHCI_P_CMD_HPCP) ? " HPCP":"",
-		    (ch->chcaps & AHCI_P_CMD_MPSP) ? " MPSP":"",
-		    (ch->chcaps & AHCI_P_CMD_CPD) ? " CPD":"",
-		    (ch->chcaps & AHCI_P_CMD_ESP) ? " ESP":"",
-		    (ch->chcaps & AHCI_P_CMD_FBSCP) ? " FBSCP":"",
-		    (ch->chscaps & AHCI_P_DEVSLP_DSP) ? " DSP":"");
-	}
 	/* Create the device queue for our SIM. */
 	devq = cam_simq_alloc(ch->numslots);
 	if (devq == NULL) {



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