Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 14 Sep 2017 15:34:45 +0000 (UTC)
From:      Conrad Meyer <cem@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r323586 - in head/sys/dev: amdsmn amdtemp intpm ioat ntb/ntb_hw
Message-ID:  <201709141534.v8EFYjKh074090@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: cem
Date: Thu Sep 14 15:34:45 2017
New Revision: 323586
URL: https://svnweb.freebsd.org/changeset/base/323586

Log:
  Add PNP metadata to a few drivers
  
  An eventual devd(8) or other component should be able to scan buses and
  automatically load drivers that match device ids described in this metadata.
  
  Reviewed by:	imp
  Sponsored by:	Dell EMC Isilon
  Differential Revision:	https://reviews.freebsd.org/D12364

Modified:
  head/sys/dev/amdsmn/amdsmn.c
  head/sys/dev/amdtemp/amdtemp.c
  head/sys/dev/intpm/intpm.c
  head/sys/dev/ioat/ioat.c
  head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c

Modified: head/sys/dev/amdsmn/amdsmn.c
==============================================================================
--- head/sys/dev/amdsmn/amdsmn.c	Thu Sep 14 15:34:29 2017	(r323585)
+++ head/sys/dev/amdsmn/amdsmn.c	Thu Sep 14 15:34:45 2017	(r323586)
@@ -89,6 +89,8 @@ static driver_t amdsmn_driver = {
 static devclass_t amdsmn_devclass;
 DRIVER_MODULE(amdsmn, hostb, amdsmn_driver, amdsmn_devclass, NULL, NULL);
 MODULE_VERSION(amdsmn, 1);
+MODULE_PNP_INFO("W32:vendor/device", pci, amdsmn, amdsmn_ids,
+    sizeof(amdsmn_ids[0]), nitems(amdsmn_ids));
 
 static bool
 amdsmn_match(device_t parent)

Modified: head/sys/dev/amdtemp/amdtemp.c
==============================================================================
--- head/sys/dev/amdtemp/amdtemp.c	Thu Sep 14 15:34:29 2017	(r323585)
+++ head/sys/dev/amdtemp/amdtemp.c	Thu Sep 14 15:34:45 2017	(r323586)
@@ -100,7 +100,6 @@ static struct amdtemp_product {
 	{ VENDORID_AMD,	DEVICEID_AMD_MISC16_M30H },
 	{ VENDORID_AMD,	DEVICEID_AMD_MISC17 },
 	{ VENDORID_AMD,	DEVICEID_AMD_HOSTB17H },
-	{ 0, 0 }
 };
 
 /*
@@ -165,6 +164,8 @@ static devclass_t amdtemp_devclass;
 DRIVER_MODULE(amdtemp, hostb, amdtemp_driver, amdtemp_devclass, NULL, NULL);
 MODULE_VERSION(amdtemp, 1);
 MODULE_DEPEND(amdtemp, amdsmn, 1, 1, 1);
+MODULE_PNP_INFO("U16:vendor;U16:device", pci, amdtemp, amdtemp_products,
+    sizeof(amdtemp_products[0]), nitems(amdtemp_products));
 
 static int
 amdtemp_match(device_t dev)
@@ -175,7 +176,7 @@ amdtemp_match(device_t dev)
 	vendor = pci_get_vendor(dev);
 	devid = pci_get_device(dev);
 
-	for (i = 0; amdtemp_products[i].amdtemp_vendorid != 0; i++) {
+	for (i = 0; i < nitems(amdtemp_products); i++) {
 		if (vendor == amdtemp_products[i].amdtemp_vendorid &&
 		    devid == amdtemp_products[i].amdtemp_deviceid)
 			return (1);

Modified: head/sys/dev/intpm/intpm.c
==============================================================================
--- head/sys/dev/intpm/intpm.c	Thu Sep 14 15:34:29 2017	(r323585)
+++ head/sys/dev/intpm/intpm.c	Thu Sep 14 15:34:45 2017	(r323586)
@@ -88,34 +88,38 @@ static int intsmb_stop_poll(struct intsmb_softc *sc);
 static int intsmb_free(struct intsmb_softc *sc);
 static void intsmb_rawintr(void *arg);
 
+const struct intsmb_device {
+	uint32_t devid;
+	const char *description;
+} intsmb_products[] = {
+	{ 0x71138086, "Intel PIIX4 SMBUS Interface" },
+	{ 0x719b8086, "Intel PIIX4 SMBUS Interface" },
+#if 0
+	/* Not a good idea yet, this stops isab0 functioning */
+	{ 0x02001166, "ServerWorks OSB4" },
+#endif
+	{ 0x43721002, "ATI IXP400 SMBus Controller" },
+	{ AMDSB_SMBUS_DEVID, "AMD SB600/7xx/8xx/9xx SMBus Controller" },
+	{ AMDFCH_SMBUS_DEVID, "AMD FCH SMBus Controller" },
+	{ AMDCZ_SMBUS_DEVID, "AMD FCH SMBus Controller" },
+};
+
 static int
 intsmb_probe(device_t dev)
 {
+	const struct intsmb_device *isd;
+	uint32_t devid;
+	size_t i;
 
-	switch (pci_get_devid(dev)) {
-	case 0x71138086:	/* Intel 82371AB */
-	case 0x719b8086:	/* Intel 82443MX */
-#if 0
-	/* Not a good idea yet, this stops isab0 functioning */
-	case 0x02001166:	/* ServerWorks OSB4 */
-#endif
-		device_set_desc(dev, "Intel PIIX4 SMBUS Interface");
-		break;
-	case 0x43721002:
-		device_set_desc(dev, "ATI IXP400 SMBus Controller");
-		break;
-	case AMDSB_SMBUS_DEVID:
-		device_set_desc(dev, "AMD SB600/7xx/8xx/9xx SMBus Controller");
-		break;
-	case AMDFCH_SMBUS_DEVID:	/* AMD FCH */
-	case AMDCZ_SMBUS_DEVID:		/* AMD Carizzo FCH */
-		device_set_desc(dev, "AMD FCH SMBus Controller");
-		break;
-	default:
-		return (ENXIO);
+	devid = pci_get_devid(dev);
+	for (i = 0; i < nitems(intsmb_products); i++) {
+		isd = &intsmb_products[i];
+		if (isd->devid == devid) {
+			device_set_desc(dev, isd->description);
+			return (BUS_PROBE_DEFAULT);
+		}
 	}
-
-	return (BUS_PROBE_DEFAULT);
+	return (ENXIO);
 }
 
 static uint8_t
@@ -891,3 +895,5 @@ DRIVER_MODULE_ORDERED(intsmb, pci, intsmb_driver, ints
 DRIVER_MODULE(smbus, intsmb, smbus_driver, smbus_devclass, 0, 0);
 MODULE_DEPEND(intsmb, smbus, SMBUS_MINVER, SMBUS_PREFVER, SMBUS_MAXVER);
 MODULE_VERSION(intsmb, 1);
+MODULE_PNP_INFO("W32:vendor/device;D:human", pci, intpm, intsmb_products,
+    sizeof(intsmb_products[0]), nitems(intsmb_products));

Modified: head/sys/dev/ioat/ioat.c
==============================================================================
--- head/sys/dev/ioat/ioat.c	Thu Sep 14 15:34:29 2017	(r323585)
+++ head/sys/dev/ioat/ioat.c	Thu Sep 14 15:34:45 2017	(r323586)
@@ -236,10 +236,11 @@ static struct _pcsid
 	{ 0x6f278086, "BDX IOAT Ch7" },
 	{ 0x6f2e8086, "BDX IOAT Ch0 (RAID)" },
 	{ 0x6f2f8086, "BDX IOAT Ch1 (RAID)" },
-
-	{ 0x00000000, NULL           }
 };
 
+MODULE_PNP_INFO("W32:vendor/device;D:human", pci, ioat, pci_ids,
+    sizeof(pci_ids[0]), nitems(pci_ids));
+
 /*
  * OS <-> Driver linkage functions
  */
@@ -250,7 +251,7 @@ ioat_probe(device_t device)
 	u_int32_t type;
 
 	type = pci_get_devid(device);
-	for (ep = pci_ids; ep->type; ep++) {
+	for (ep = pci_ids; ep < &pci_ids[nitems(pci_ids)]; ep++) {
 		if (ep->type == type) {
 			device_set_desc(device, ep->desc);
 			return (0);

Modified: head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c
==============================================================================
--- head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c	Thu Sep 14 15:34:29 2017	(r323585)
+++ head/sys/dev/ntb/ntb_hw/ntb_hw_intel.c	Thu Sep 14 15:34:45 2017	(r323586)
@@ -495,8 +495,6 @@ static struct ntb_hw_info pci_ids[] = {
 	{ 0x6F0D8086, "BDX Xeon E5 V4 Non-Transparent Bridge B2B", NTB_XEON,
 		NTB_SDOORBELL_LOCKUP | NTB_B2BDOORBELL_BIT14 |
 		    NTB_SB01BASE_LOCKUP },
-
-	{ 0x00000000, NULL, NTB_ATOM, 0 }
 };
 
 static const struct ntb_reg atom_reg = {
@@ -1390,12 +1388,11 @@ intel_ntb_get_msix_info(struct ntb_softc *ntb)
 static struct ntb_hw_info *
 intel_ntb_get_device_info(uint32_t device_id)
 {
-	struct ntb_hw_info *ep = pci_ids;
+	struct ntb_hw_info *ep;
 
-	while (ep->device_id) {
+	for (ep = pci_ids; ep < &pci_ids[nitems(pci_ids)]; ep++) {
 		if (ep->device_id == device_id)
 			return (ep);
-		++ep;
 	}
 	return (NULL);
 }
@@ -3122,3 +3119,5 @@ static DEFINE_CLASS_0(ntb_hw, ntb_intel_driver, ntb_in
 DRIVER_MODULE(ntb_hw_intel, pci, ntb_intel_driver, ntb_hw_devclass, NULL, NULL);
 MODULE_DEPEND(ntb_hw_intel, ntb, 1, 1, 1);
 MODULE_VERSION(ntb_hw_intel, 1);
+MODULE_PNP_INFO("W32:vendor/device;D:human", pci, ntb_hw_intel, pci_ids,
+    sizeof(pci_ids[0]), nitems(pci_ids));



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