Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 3 May 2016 19:37:25 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r299000 - head/sys/dev/pci
Message-ID:  <201605031937.u43JbPDf058736@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Tue May  3 19:37:25 2016
New Revision: 299000
URL: https://svnweb.freebsd.org/changeset/base/299000

Log:
  Use the correct location of the SRIOV capability when enabling ARI.
  
  While here, check if ARI was enabled by re-reading the config register
  after writing it and return an error if the write fails.
  
  Reviewed by:	rstone, vangyzen

Modified:
  head/sys/dev/pci/pci_iov.c

Modified: head/sys/dev/pci/pci_iov.c
==============================================================================
--- head/sys/dev/pci/pci_iov.c	Tue May  3 18:54:20 2016	(r298999)
+++ head/sys/dev/pci/pci_iov.c	Tue May  3 19:37:25 2016	(r299000)
@@ -442,6 +442,7 @@ pci_iov_set_ari(device_t bus)
 			}
 		}
 	}
+	free(devlist, M_TEMP);
 
 	/*
 	 * If we called this function some device must have the SR-IOV
@@ -451,10 +452,14 @@ pci_iov_set_ari(device_t bus)
 	    ("Could not find child of %s with SR-IOV capability",
 	    device_get_nameunit(bus)));
 
-	iov_ctl = pci_read_config(lowest, iov_pos + PCIR_SRIOV_CTL, 2);
+	iov_ctl = pci_read_config(lowest, lowest_pos + PCIR_SRIOV_CTL, 2);
 	iov_ctl |= PCIM_SRIOV_ARI_EN;
-	pci_write_config(lowest, iov_pos + PCIR_SRIOV_CTL, iov_ctl, 2);
-	free(devlist, M_TEMP);
+	pci_write_config(lowest, lowest_pos + PCIR_SRIOV_CTL, iov_ctl, 2);
+	if ((pci_read_config(lowest, lowest_pos + PCIR_SRIOV_CTL, 2) &
+	    PCIM_SRIOV_ARI_EN) == 0) {
+		device_printf(lowest, "failed to enable ARI\n");
+		return (ENXIO);
+	}
 	return (0);
 }
 



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