xref: /onnv-gate/usr/src/uts/intel/io/intel_nhm/intel_nhmdrv.c (revision 9783:1085b5bb283f)
18472SSean.Ye@Sun.COM /*
28472SSean.Ye@Sun.COM  * CDDL HEADER START
38472SSean.Ye@Sun.COM  *
48472SSean.Ye@Sun.COM  * The contents of this file are subject to the terms of the
58472SSean.Ye@Sun.COM  * Common Development and Distribution License (the "License").
68472SSean.Ye@Sun.COM  * You may not use this file except in compliance with the License.
78472SSean.Ye@Sun.COM  *
88472SSean.Ye@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
98472SSean.Ye@Sun.COM  * or http://www.opensolaris.org/os/licensing.
108472SSean.Ye@Sun.COM  * See the License for the specific language governing permissions
118472SSean.Ye@Sun.COM  * and limitations under the License.
128472SSean.Ye@Sun.COM  *
138472SSean.Ye@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
148472SSean.Ye@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
158472SSean.Ye@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
168472SSean.Ye@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
178472SSean.Ye@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
188472SSean.Ye@Sun.COM  *
198472SSean.Ye@Sun.COM  * CDDL HEADER END
208472SSean.Ye@Sun.COM  */
218472SSean.Ye@Sun.COM 
228472SSean.Ye@Sun.COM /*
238472SSean.Ye@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
248472SSean.Ye@Sun.COM  * Use is subject to license terms.
258472SSean.Ye@Sun.COM  */
268472SSean.Ye@Sun.COM 
278472SSean.Ye@Sun.COM #include <sys/types.h>
288472SSean.Ye@Sun.COM #include <sys/time.h>
298472SSean.Ye@Sun.COM #include <sys/nvpair.h>
308472SSean.Ye@Sun.COM #include <sys/cmn_err.h>
318472SSean.Ye@Sun.COM #include <sys/cred.h>
328472SSean.Ye@Sun.COM #include <sys/open.h>
338472SSean.Ye@Sun.COM #include <sys/ddi.h>
348472SSean.Ye@Sun.COM #include <sys/sunddi.h>
358472SSean.Ye@Sun.COM #include <sys/conf.h>
368472SSean.Ye@Sun.COM #include <sys/modctl.h>
378472SSean.Ye@Sun.COM #include <sys/cyclic.h>
388472SSean.Ye@Sun.COM #include <sys/errorq.h>
398472SSean.Ye@Sun.COM #include <sys/stat.h>
408472SSean.Ye@Sun.COM #include <sys/cpuvar.h>
418472SSean.Ye@Sun.COM #include <sys/mc_intel.h>
428472SSean.Ye@Sun.COM #include <sys/mc.h>
438472SSean.Ye@Sun.COM #include <sys/fm/protocol.h>
448472SSean.Ye@Sun.COM #include "nhm_log.h"
458472SSean.Ye@Sun.COM #include "intel_nhm.h"
468472SSean.Ye@Sun.COM 
478472SSean.Ye@Sun.COM int max_bus_number = 0xff;
488472SSean.Ye@Sun.COM 
498472SSean.Ye@Sun.COM nvlist_t *inhm_mc_nvl[MAX_CPU_NODES];
508472SSean.Ye@Sun.COM krwlock_t inhm_mc_lock;
518472SSean.Ye@Sun.COM 
528472SSean.Ye@Sun.COM char *inhm_mc_snapshot[MAX_CPU_NODES];
538472SSean.Ye@Sun.COM uint_t nhm_config_gen;
548472SSean.Ye@Sun.COM uint_t inhm_mc_snapshotgen;
558472SSean.Ye@Sun.COM size_t inhm_mc_snapshotsz[MAX_CPU_NODES];
568472SSean.Ye@Sun.COM static dev_info_t *inhm_dip;
578472SSean.Ye@Sun.COM int nhm_allow_detach = 0;
588472SSean.Ye@Sun.COM 
598472SSean.Ye@Sun.COM extern int nhm_patrol_scrub;
608472SSean.Ye@Sun.COM extern int nhm_demand_scrub;
618472SSean.Ye@Sun.COM extern int nhm_no_smbios;
628472SSean.Ye@Sun.COM extern int nhm_smbios_serial;
638472SSean.Ye@Sun.COM extern int nhm_smbios_manufacturer;
648472SSean.Ye@Sun.COM extern int nhm_smbios_part_number;
658472SSean.Ye@Sun.COM extern int nhm_smbios_version;
668472SSean.Ye@Sun.COM extern int nhm_smbios_label;
678472SSean.Ye@Sun.COM 
688472SSean.Ye@Sun.COM extern void inhm_create_nvl(int);
698472SSean.Ye@Sun.COM extern char *inhm_mc_name(void);
708472SSean.Ye@Sun.COM extern void init_dimms(void);
718472SSean.Ye@Sun.COM extern void nhm_smbios();
728472SSean.Ye@Sun.COM 
738472SSean.Ye@Sun.COM static void
inhm_mc_snapshot_destroy()748472SSean.Ye@Sun.COM inhm_mc_snapshot_destroy()
758472SSean.Ye@Sun.COM {
768472SSean.Ye@Sun.COM 	int i;
778472SSean.Ye@Sun.COM 
788472SSean.Ye@Sun.COM 	ASSERT(RW_LOCK_HELD(&inhm_mc_lock));
798472SSean.Ye@Sun.COM 
808472SSean.Ye@Sun.COM 	for (i = 0; i < MAX_CPU_NODES; i++) {
818472SSean.Ye@Sun.COM 		if (inhm_mc_snapshot[i] == NULL)
828472SSean.Ye@Sun.COM 			continue;
838472SSean.Ye@Sun.COM 
848472SSean.Ye@Sun.COM 		kmem_free(inhm_mc_snapshot[i], inhm_mc_snapshotsz[i]);
858472SSean.Ye@Sun.COM 			inhm_mc_snapshot[i] = NULL;
868472SSean.Ye@Sun.COM 			inhm_mc_snapshotsz[i] = 0;
878472SSean.Ye@Sun.COM 	}
888472SSean.Ye@Sun.COM 	inhm_mc_snapshotgen++;
898472SSean.Ye@Sun.COM }
908472SSean.Ye@Sun.COM 
918472SSean.Ye@Sun.COM static int
inhm_mc_snapshot_update()928472SSean.Ye@Sun.COM inhm_mc_snapshot_update()
938472SSean.Ye@Sun.COM {
948472SSean.Ye@Sun.COM 	int i;
958472SSean.Ye@Sun.COM 	int rt = 0;
968472SSean.Ye@Sun.COM 
978472SSean.Ye@Sun.COM 	ASSERT(RW_LOCK_HELD(&inhm_mc_lock));
988472SSean.Ye@Sun.COM 
998472SSean.Ye@Sun.COM 	for (i = 0; i < MAX_CPU_NODES; i++) {
1008472SSean.Ye@Sun.COM 		if (inhm_mc_snapshot[i] != NULL)
1018472SSean.Ye@Sun.COM 			continue;
1028472SSean.Ye@Sun.COM 
1038472SSean.Ye@Sun.COM 		if (nvlist_pack(inhm_mc_nvl[i], &inhm_mc_snapshot[i],
1048472SSean.Ye@Sun.COM 		    &inhm_mc_snapshotsz[i], NV_ENCODE_XDR, KM_SLEEP) != 0)
1058472SSean.Ye@Sun.COM 			rt = -1;
1068472SSean.Ye@Sun.COM 	}
1078472SSean.Ye@Sun.COM 
1088472SSean.Ye@Sun.COM 	return (rt);
1098472SSean.Ye@Sun.COM }
1108472SSean.Ye@Sun.COM 
1118472SSean.Ye@Sun.COM /*ARGSUSED*/
1128472SSean.Ye@Sun.COM static int
inhm_mc_ioctl(dev_t dev,int cmd,intptr_t arg,int mode,cred_t * credp,int * rvalp)1138472SSean.Ye@Sun.COM inhm_mc_ioctl(dev_t dev, int cmd, intptr_t arg, int mode, cred_t *credp,
1148472SSean.Ye@Sun.COM     int *rvalp)
1158472SSean.Ye@Sun.COM {
1168472SSean.Ye@Sun.COM 	int rc = 0;
1178472SSean.Ye@Sun.COM 	int chip;
1188472SSean.Ye@Sun.COM 	mc_snapshot_info_t mcs;
1198472SSean.Ye@Sun.COM 
1208472SSean.Ye@Sun.COM 	if (cmd != MC_IOC_SNAPSHOT_INFO && cmd != MC_IOC_SNAPSHOT)
1218472SSean.Ye@Sun.COM 		return (EINVAL);
1228472SSean.Ye@Sun.COM 
1238472SSean.Ye@Sun.COM 	rw_enter(&inhm_mc_lock, RW_READER);
1248472SSean.Ye@Sun.COM 	chip = getminor(dev) % MAX_CPU_NODES;
1258472SSean.Ye@Sun.COM 	if (inhm_mc_nvl[chip] == NULL ||
1268472SSean.Ye@Sun.COM 	    inhm_mc_snapshotgen != nhm_config_gen) {
1278472SSean.Ye@Sun.COM 		if (!rw_tryupgrade(&inhm_mc_lock)) {
1288472SSean.Ye@Sun.COM 			rw_exit(&inhm_mc_lock);
1298472SSean.Ye@Sun.COM 			return (EAGAIN);
1308472SSean.Ye@Sun.COM 		}
1318472SSean.Ye@Sun.COM 		if (inhm_mc_nvl[chip])
1328472SSean.Ye@Sun.COM 			inhm_mc_snapshot_destroy();
1338472SSean.Ye@Sun.COM 		inhm_create_nvl(chip);
1348472SSean.Ye@Sun.COM 		nhm_config_gen = inhm_mc_snapshotgen;
1358472SSean.Ye@Sun.COM 		(void) inhm_mc_snapshot_update();
1368472SSean.Ye@Sun.COM 	}
1378472SSean.Ye@Sun.COM 	switch (cmd) {
1388472SSean.Ye@Sun.COM 	case MC_IOC_SNAPSHOT_INFO:
1398472SSean.Ye@Sun.COM 		mcs.mcs_size = (uint32_t)inhm_mc_snapshotsz[chip];
1408472SSean.Ye@Sun.COM 		mcs.mcs_gen = inhm_mc_snapshotgen;
1418472SSean.Ye@Sun.COM 
1428472SSean.Ye@Sun.COM 		if (ddi_copyout(&mcs, (void *)arg, sizeof (mc_snapshot_info_t),
1438472SSean.Ye@Sun.COM 		    mode) < 0)
1448472SSean.Ye@Sun.COM 			rc = EFAULT;
1458472SSean.Ye@Sun.COM 		break;
1468472SSean.Ye@Sun.COM 	case MC_IOC_SNAPSHOT:
1478472SSean.Ye@Sun.COM 		if (ddi_copyout(inhm_mc_snapshot[chip], (void *)arg,
1488472SSean.Ye@Sun.COM 		    inhm_mc_snapshotsz[chip], mode) < 0)
1498472SSean.Ye@Sun.COM 			rc = EFAULT;
1508472SSean.Ye@Sun.COM 		break;
1518472SSean.Ye@Sun.COM 	}
1528472SSean.Ye@Sun.COM 	rw_exit(&inhm_mc_lock);
1538472SSean.Ye@Sun.COM 	return (rc);
1548472SSean.Ye@Sun.COM }
1558472SSean.Ye@Sun.COM 
1568472SSean.Ye@Sun.COM /*ARGSUSED*/
1578472SSean.Ye@Sun.COM static int
inhm_mc_getinfo(dev_info_t * dip,ddi_info_cmd_t infocmd,void * arg,void ** result)1588472SSean.Ye@Sun.COM inhm_mc_getinfo(dev_info_t *dip, ddi_info_cmd_t infocmd, void *arg,
1598472SSean.Ye@Sun.COM     void **result)
1608472SSean.Ye@Sun.COM {
1618472SSean.Ye@Sun.COM 	if ((infocmd != DDI_INFO_DEVT2DEVINFO &&
1628472SSean.Ye@Sun.COM 	    infocmd != DDI_INFO_DEVT2INSTANCE) || inhm_dip == NULL) {
1638472SSean.Ye@Sun.COM 		*result = NULL;
1648472SSean.Ye@Sun.COM 		return (DDI_FAILURE);
1658472SSean.Ye@Sun.COM 	}
1668472SSean.Ye@Sun.COM 	if (infocmd == DDI_INFO_DEVT2DEVINFO)
1678472SSean.Ye@Sun.COM 		*result = inhm_dip;
1688472SSean.Ye@Sun.COM 	else
1698472SSean.Ye@Sun.COM 		*result = (void *)(uintptr_t)ddi_get_instance(inhm_dip);
1708472SSean.Ye@Sun.COM 	return (0);
1718472SSean.Ye@Sun.COM }
1728472SSean.Ye@Sun.COM 
1738472SSean.Ye@Sun.COM static int
inhm_mc_attach(dev_info_t * dip,ddi_attach_cmd_t cmd)1748472SSean.Ye@Sun.COM inhm_mc_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
1758472SSean.Ye@Sun.COM {
1768472SSean.Ye@Sun.COM 	int i;
1778472SSean.Ye@Sun.COM 	char buf[64];
1788472SSean.Ye@Sun.COM 
1798472SSean.Ye@Sun.COM 	if (cmd == DDI_RESUME) {
1808472SSean.Ye@Sun.COM 		nhm_dev_reinit();
1818472SSean.Ye@Sun.COM 		nhm_scrubber_enable();
1828472SSean.Ye@Sun.COM 		nhm_smbios();
1838472SSean.Ye@Sun.COM 		return (DDI_SUCCESS);
1848472SSean.Ye@Sun.COM 	}
1858472SSean.Ye@Sun.COM 	if (cmd != DDI_ATTACH)
1868472SSean.Ye@Sun.COM 		return (DDI_FAILURE);
1878472SSean.Ye@Sun.COM 	if (inhm_dip == NULL) {
1888472SSean.Ye@Sun.COM 		inhm_dip = dip;
189*9783SAdrian.Frost@Sun.COM 		nhm_pci_cfg_setup(dip);
1908472SSean.Ye@Sun.COM 		(void) ddi_prop_update_string(DDI_DEV_T_NONE, dip, "model",
1918472SSean.Ye@Sun.COM 		    inhm_mc_name());
1928472SSean.Ye@Sun.COM 		if (nhm_dev_init()) {
1938472SSean.Ye@Sun.COM 			nhm_pci_cfg_free();
1948472SSean.Ye@Sun.COM 			inhm_dip = NULL;
1958472SSean.Ye@Sun.COM 			return (DDI_FAILURE);
1968472SSean.Ye@Sun.COM 		}
1978472SSean.Ye@Sun.COM 		ddi_set_name_addr(dip, "1");
1988472SSean.Ye@Sun.COM 		for (i = 0; i < MAX_CPU_NODES; i++) {
1998472SSean.Ye@Sun.COM 			(void) snprintf(buf, sizeof (buf), "mc-intel-%d", i);
2008472SSean.Ye@Sun.COM 			if (ddi_create_minor_node(dip, buf, S_IFCHR,
2018472SSean.Ye@Sun.COM 			    i, "ddi_mem_ctrl", 0) != DDI_SUCCESS) {
2028472SSean.Ye@Sun.COM 				cmn_err(CE_WARN, "failed to create minor node"
2038472SSean.Ye@Sun.COM 				    " for memory controller %d\n", i);
2048472SSean.Ye@Sun.COM 			}
2058472SSean.Ye@Sun.COM 		}
2068472SSean.Ye@Sun.COM 		cmi_hdl_walk(inhm_mc_register, NULL, NULL, NULL);
2078472SSean.Ye@Sun.COM 		nhm_patrol_scrub = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
2088472SSean.Ye@Sun.COM 		    DDI_PROP_DONTPASS, "patrol-scrub", 0);
2098472SSean.Ye@Sun.COM 		nhm_demand_scrub = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
2108472SSean.Ye@Sun.COM 		    DDI_PROP_DONTPASS, "demand-scrub", 0);
2118472SSean.Ye@Sun.COM 		nhm_no_smbios = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
2128472SSean.Ye@Sun.COM 		    DDI_PROP_DONTPASS, "no-smbios", 0);
2138472SSean.Ye@Sun.COM 		nhm_smbios_serial = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
2148472SSean.Ye@Sun.COM 		    DDI_PROP_DONTPASS, "smbios-dimm-serial", 1);
2158472SSean.Ye@Sun.COM 		nhm_smbios_manufacturer = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
2168472SSean.Ye@Sun.COM 		    DDI_PROP_DONTPASS, "smbios-dimm-manufacturer", 1);
2178472SSean.Ye@Sun.COM 		nhm_smbios_part_number = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
2188472SSean.Ye@Sun.COM 		    DDI_PROP_DONTPASS, "smbios-dimm-part-number", 1);
2198472SSean.Ye@Sun.COM 		nhm_smbios_version = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
2208472SSean.Ye@Sun.COM 		    DDI_PROP_DONTPASS, "smbios-dimme-version", 1);
2218472SSean.Ye@Sun.COM 		nhm_smbios_label = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
2228472SSean.Ye@Sun.COM 		    DDI_PROP_DONTPASS, "smbios-dimm-label", 1);
2238472SSean.Ye@Sun.COM 		nhm_scrubber_enable();
2248472SSean.Ye@Sun.COM 		nhm_smbios();
2258472SSean.Ye@Sun.COM 	}
2268472SSean.Ye@Sun.COM 
2278472SSean.Ye@Sun.COM 	return (DDI_SUCCESS);
2288472SSean.Ye@Sun.COM }
2298472SSean.Ye@Sun.COM 
2308472SSean.Ye@Sun.COM /*ARGSUSED*/
2318472SSean.Ye@Sun.COM static int
inhm_mc_detach(dev_info_t * dip,ddi_detach_cmd_t cmd)2328472SSean.Ye@Sun.COM inhm_mc_detach(dev_info_t *dip, ddi_detach_cmd_t cmd)
2338472SSean.Ye@Sun.COM {
2348472SSean.Ye@Sun.COM 	if (nhm_allow_detach && cmd == DDI_DETACH && dip == inhm_dip) {
2358472SSean.Ye@Sun.COM 		rw_enter(&inhm_mc_lock, RW_WRITER);
2368472SSean.Ye@Sun.COM 		inhm_mc_snapshot_destroy();
2378472SSean.Ye@Sun.COM 		rw_exit(&inhm_mc_lock);
2388472SSean.Ye@Sun.COM 		inhm_dip = NULL;
2398472SSean.Ye@Sun.COM 		return (DDI_SUCCESS);
2408472SSean.Ye@Sun.COM 	} else if (cmd == DDI_SUSPEND || cmd == DDI_PM_SUSPEND) {
2418472SSean.Ye@Sun.COM 		return (DDI_SUCCESS);
2428472SSean.Ye@Sun.COM 	} else {
2438472SSean.Ye@Sun.COM 		return (DDI_FAILURE);
2448472SSean.Ye@Sun.COM 	}
2458472SSean.Ye@Sun.COM }
2468472SSean.Ye@Sun.COM 
2478472SSean.Ye@Sun.COM /*ARGSUSED*/
2488472SSean.Ye@Sun.COM static int
inhm_mc_open(dev_t * devp,int flag,int otyp,cred_t * credp)2498472SSean.Ye@Sun.COM inhm_mc_open(dev_t *devp, int flag, int otyp, cred_t *credp)
2508472SSean.Ye@Sun.COM {
2518472SSean.Ye@Sun.COM 	if (otyp != OTYP_CHR)
2528472SSean.Ye@Sun.COM 		return (EINVAL);
2538472SSean.Ye@Sun.COM 
2548472SSean.Ye@Sun.COM 	rw_enter(&inhm_mc_lock, RW_READER);
2558472SSean.Ye@Sun.COM 	if (getminor(*devp) >= MAX_CPU_NODES) {
2568472SSean.Ye@Sun.COM 		rw_exit(&inhm_mc_lock);
2578472SSean.Ye@Sun.COM 		return (EINVAL);
2588472SSean.Ye@Sun.COM 	}
2598472SSean.Ye@Sun.COM 	rw_exit(&inhm_mc_lock);
2608472SSean.Ye@Sun.COM 
2618472SSean.Ye@Sun.COM 	return (0);
2628472SSean.Ye@Sun.COM }
2638472SSean.Ye@Sun.COM 
2648472SSean.Ye@Sun.COM /*ARGSUSED*/
2658472SSean.Ye@Sun.COM static int
inhm_mc_close(dev_t dev,int flag,int otyp,cred_t * credp)2668472SSean.Ye@Sun.COM inhm_mc_close(dev_t dev, int flag, int otyp, cred_t *credp)
2678472SSean.Ye@Sun.COM {
2688472SSean.Ye@Sun.COM 	return (0);
2698472SSean.Ye@Sun.COM }
2708472SSean.Ye@Sun.COM 
2718472SSean.Ye@Sun.COM 
2728472SSean.Ye@Sun.COM static struct cb_ops inhm_mc_cb_ops = {
2738472SSean.Ye@Sun.COM 	inhm_mc_open,
2748472SSean.Ye@Sun.COM 	inhm_mc_close,
2758472SSean.Ye@Sun.COM 	nodev,		/* not a block driver */
2768472SSean.Ye@Sun.COM 	nodev,		/* no print routine */
2778472SSean.Ye@Sun.COM 	nodev,		/* no dump routine */
2788472SSean.Ye@Sun.COM 	nodev,		/* no read routine */
2798472SSean.Ye@Sun.COM 	nodev,		/* no write routine */
2808472SSean.Ye@Sun.COM 	inhm_mc_ioctl,
2818472SSean.Ye@Sun.COM 	nodev,		/* no devmap routine */
2828472SSean.Ye@Sun.COM 	nodev,		/* no mmap routine */
2838472SSean.Ye@Sun.COM 	nodev,		/* no segmap routine */
2848472SSean.Ye@Sun.COM 	nochpoll,	/* no chpoll routine */
2858472SSean.Ye@Sun.COM 	ddi_prop_op,
2868472SSean.Ye@Sun.COM 	0,		/* not a STREAMS driver */
2878472SSean.Ye@Sun.COM 	D_NEW | D_MP,	/* safe for multi-thread/multi-processor */
2888472SSean.Ye@Sun.COM };
2898472SSean.Ye@Sun.COM 
2908472SSean.Ye@Sun.COM static struct dev_ops inhm_mc_ops = {
2918472SSean.Ye@Sun.COM 	DEVO_REV,		/* devo_rev */
2928472SSean.Ye@Sun.COM 	0,			/* devo_refcnt */
2938472SSean.Ye@Sun.COM 	inhm_mc_getinfo,		/* devo_getinfo */
2948472SSean.Ye@Sun.COM 	nulldev,		/* devo_identify */
2958472SSean.Ye@Sun.COM 	nulldev,		/* devo_probe */
2968472SSean.Ye@Sun.COM 	inhm_mc_attach,		/* devo_attach */
2978472SSean.Ye@Sun.COM 	inhm_mc_detach,		/* devo_detach */
2988472SSean.Ye@Sun.COM 	nodev,			/* devo_reset */
2998472SSean.Ye@Sun.COM 	&inhm_mc_cb_ops,		/* devo_cb_ops */
3008472SSean.Ye@Sun.COM 	NULL,			/* devo_bus_ops */
3018657SAdrian.Frost@Sun.COM 	NULL,			/* devo_power */
3028657SAdrian.Frost@Sun.COM 	ddi_quiesce_not_needed,	/* devo_quiesce */
3038472SSean.Ye@Sun.COM };
3048472SSean.Ye@Sun.COM 
3058472SSean.Ye@Sun.COM static struct modldrv modldrv = {
3068472SSean.Ye@Sun.COM 	&mod_driverops,
3078472SSean.Ye@Sun.COM 	"Intel QuickPath Memory Controller Hub Module",
3088472SSean.Ye@Sun.COM 	&inhm_mc_ops
3098472SSean.Ye@Sun.COM };
3108472SSean.Ye@Sun.COM 
3118472SSean.Ye@Sun.COM static struct modlinkage modlinkage = {
3128472SSean.Ye@Sun.COM 	MODREV_1,
3138472SSean.Ye@Sun.COM 	(void *)&modldrv,
3148472SSean.Ye@Sun.COM 	NULL
3158472SSean.Ye@Sun.COM };
3168472SSean.Ye@Sun.COM 
3178472SSean.Ye@Sun.COM int
_init(void)3188472SSean.Ye@Sun.COM _init(void)
3198472SSean.Ye@Sun.COM {
3208472SSean.Ye@Sun.COM 	int err;
3218472SSean.Ye@Sun.COM 
3228472SSean.Ye@Sun.COM 	err = nhm_init();
3238472SSean.Ye@Sun.COM 	if (err == 0 && (err = mod_install(&modlinkage)) == 0) {
3248472SSean.Ye@Sun.COM 		rw_init(&inhm_mc_lock, NULL, RW_DRIVER, NULL);
3258472SSean.Ye@Sun.COM 		init_dimms();
3268472SSean.Ye@Sun.COM 	}
3278472SSean.Ye@Sun.COM 
3288472SSean.Ye@Sun.COM 	return (err);
3298472SSean.Ye@Sun.COM }
3308472SSean.Ye@Sun.COM 
3318472SSean.Ye@Sun.COM int
_info(struct modinfo * modinfop)3328472SSean.Ye@Sun.COM _info(struct modinfo *modinfop)
3338472SSean.Ye@Sun.COM {
3348472SSean.Ye@Sun.COM 	return (mod_info(&modlinkage, modinfop));
3358472SSean.Ye@Sun.COM }
3368472SSean.Ye@Sun.COM 
3378472SSean.Ye@Sun.COM int
_fini(void)3388472SSean.Ye@Sun.COM _fini(void)
3398472SSean.Ye@Sun.COM {
3408472SSean.Ye@Sun.COM 	int err;
3418472SSean.Ye@Sun.COM 
3428472SSean.Ye@Sun.COM 	if ((err = mod_remove(&modlinkage)) == 0) {
3438472SSean.Ye@Sun.COM 		nhm_unload();
3448472SSean.Ye@Sun.COM 		rw_destroy(&inhm_mc_lock);
3458472SSean.Ye@Sun.COM 	}
3468472SSean.Ye@Sun.COM 
3478472SSean.Ye@Sun.COM 	return (err);
3488472SSean.Ye@Sun.COM }
349