changeset 11048:6da57c1c6564

6895343 pmcs logging enhancements - part 1/2
author dh142964 <David.Hollister@Sun.COM>
date Wed, 11 Nov 2009 19:33:15 -0700
parents dc0bb5e7d98b
children a871ea89ffe5
files usr/src/cmd/mdb/common/modules/pmcs/pmcs.c usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_attach.c usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_fwlog.c usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_intr.c usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_nvram.c usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_sata.c usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_scsa.c usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_smhba.c usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_subr.c usr/src/uts/common/sys/scsi/adapters/pmcs/pmcs_def.h usr/src/uts/common/sys/scsi/adapters/pmcs/pmcs_iomb.h usr/src/uts/common/sys/scsi/adapters/pmcs/pmcs_proto.h
diffstat 12 files changed, 1164 insertions(+), 879 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/mdb/common/modules/pmcs/pmcs.c	Thu Nov 12 10:26:22 2009 +0800
+++ b/usr/src/cmd/mdb/common/modules/pmcs/pmcs.c	Wed Nov 11 19:33:15 2009 -0700
@@ -26,6 +26,7 @@
 #include <limits.h>
 #include <sys/mdb_modapi.h>
 #include <sys/sysinfo.h>
+#include <sys/byteorder.h>
 #include <sys/scsi/scsi.h>
 #include <sys/scsi/adapters/pmcs/pmcs.h>
 
@@ -208,6 +209,52 @@
 	mdb_printf("\n");
 }
 
+/* ARGSUSED */
+static int
+pmcs_utarget_walk_cb(uintptr_t addr, const void *wdata, void *priv)
+{
+	pmcs_phy_t phy;
+
+	if (mdb_vread(&phy, sizeof (pmcs_phy_t), (uintptr_t)addr) == -1) {
+		mdb_warn("pmcs_utarget_walk_cb: Failed to read PHY at %p",
+		    (void *)addr);
+		return (DCMD_ERR);
+	}
+
+	if (phy.configured && (phy.target == NULL)) {
+		mdb_printf("SAS address: ");
+		print_sas_address(&phy);
+		mdb_printf("  DType: ");
+		switch (phy.dtype) {
+		case SAS:
+			mdb_printf("%4s", "SAS");
+			break;
+		case SATA:
+			mdb_printf("%4s", "SATA");
+			break;
+		case EXPANDER:
+			mdb_printf("%4s", "SMP");
+			break;
+		default:
+			mdb_printf("%4s", "N/A");
+			break;
+		}
+		mdb_printf("  Path: %s\n", phy.path);
+	}
+
+	return (0);
+}
+
+static void
+display_unconfigured_targets(uintptr_t addr)
+{
+	mdb_printf("Unconfigured target SAS address:\n\n");
+
+	if (mdb_pwalk("pmcs_phys", pmcs_utarget_walk_cb, NULL, addr) == -1) {
+		mdb_warn("pmcs phys walk failed");
+	}
+}
+
 static void
 display_completion_queue(struct pmcs_hw ss)
 {
@@ -1427,6 +1474,10 @@
 }
 
 /*
+ * filter is used to indicate whether we are filtering log messages based
+ * on "instance".  The other filtering (based on options) depends on the
+ * values that are passed in for "sas_addr" and "phy_path".
+ *
  * MAX_INST_STRLEN is the largest string size from which we will attempt
  * to convert to an instance number.  The string will be formed up as
  * "0t<inst>\0" so that mdb_strtoull can parse it properly.
@@ -1434,7 +1485,8 @@
 #define	MAX_INST_STRLEN	8
 
 static int
-pmcs_dump_tracelog(boolean_t filter, int instance)
+pmcs_dump_tracelog(boolean_t filter, int instance, const char *phy_path,
+    uint64_t sas_address)
 {
 	pmcs_tbuf_t *tbuf_addr;
 	uint_t tbuf_idx;
@@ -1443,6 +1495,8 @@
 	uint_t start_idx, elems_to_print, idx, tbuf_num_elems;
 	char *bufp;
 	char elem_inst[MAX_INST_STRLEN], ei_idx;
+	uint64_t sas_addr;
+	uint8_t *sas_addressp;
 
 	/* Get the address of the first element */
 	if (mdb_readvar(&tbuf_addr, "pmcs_tbuf") == -1) {
@@ -1468,6 +1522,24 @@
 		return (DCMD_ERR);
 	}
 
+	/*
+	 * On little-endian systems, the SAS address passed in will be
+	 * byte swapped.  Take care of that here.
+	 */
+#if defined(_LITTLE_ENDIAN)
+	sas_addr = ((sas_address << 56) |
+	    ((sas_address << 40) & 0xff000000000000ULL) |
+	    ((sas_address << 24) & 0xff0000000000ULL) |
+	    ((sas_address << 8)  & 0xff00000000ULL) |
+	    ((sas_address >> 8)  & 0xff000000ULL) |
+	    ((sas_address >> 24) & 0xff0000ULL) |
+	    ((sas_address >> 40) & 0xff00ULL) |
+	    (sas_address  >> 56));
+#else
+	sas_addr = sas_address;
+#endif
+	sas_addressp = (uint8_t *)&sas_addr;
+
 	/* Figure out where we start and stop */
 	if (wrap) {
 		start_idx = tbuf_idx;
@@ -1487,6 +1559,9 @@
 			return (DCMD_ERR);
 		}
 
+		/*
+		 * Check for filtering on HBA instance
+		 */
 		elem_filtered = B_FALSE;
 
 		if (filter) {
@@ -1511,6 +1586,30 @@
 			}
 		}
 
+		if (!elem_filtered && (phy_path || sas_address)) {
+			/*
+			 * This message is not being filtered by HBA instance.
+			 * Now check to see if we're filtering based on
+			 * PHY path or SAS address.
+			 * Filtering is an "OR" operation.  So, if any of the
+			 * criteria matches, this message will be printed.
+			 */
+			elem_filtered = B_TRUE;
+
+			if (phy_path != NULL) {
+				if (strncmp(phy_path, tbuf.phy_path,
+				    PMCS_TBUF_UA_MAX_SIZE) == 0) {
+					elem_filtered = B_FALSE;
+				}
+			}
+			if (sas_address != 0) {
+				if (memcmp(sas_addressp, tbuf.phy_sas_address,
+				    8) == 0) {
+					elem_filtered = B_FALSE;
+				}
+			}
+		}
+
 		if (!elem_filtered) {
 			mdb_printf("%Y.%09ld %s\n", tbuf.timestamp, tbuf.buf);
 		}
@@ -1900,9 +1999,60 @@
 }
 
 static int
+pmcs_log(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
+{
+	void		*pmcs_state;
+	struct pmcs_hw	ss;
+	struct dev_info	dip;
+	const char	*match_phy_path = NULL;
+	uint64_t 	match_sas_address = 0;
+
+	if (!(flags & DCMD_ADDRSPEC)) {
+		pmcs_state = NULL;
+		if (mdb_readvar(&pmcs_state, "pmcs_softc_state") == -1) {
+			mdb_warn("can't read pmcs_softc_state");
+			return (DCMD_ERR);
+		}
+		if (mdb_pwalk_dcmd("genunix`softstate", "pmcs`pmcs_log", argc,
+		    argv, (uintptr_t)pmcs_state) == -1) {
+			mdb_warn("mdb_pwalk_dcmd failed for pmcs_log");
+			return (DCMD_ERR);
+		}
+		return (DCMD_OK);
+	}
+
+	if (mdb_getopts(argc, argv,
+	    'p', MDB_OPT_STR, &match_phy_path,
+	    's', MDB_OPT_UINT64, &match_sas_address,
+	    NULL) != argc) {
+		return (DCMD_USAGE);
+	}
+
+	if (MDB_RD(&ss, sizeof (ss), addr) == -1) {
+		NOREAD(pmcs_hw_t, addr);
+		return (DCMD_ERR);
+	}
+
+	if (MDB_RD(&dip, sizeof (struct dev_info), ss.dip) == -1) {
+		NOREAD(pmcs_hw_t, addr);
+		return (DCMD_ERR);
+	}
+
+	if (!(flags & DCMD_LOOP)) {
+		return (pmcs_dump_tracelog(B_TRUE, dip.devi_instance,
+		    match_phy_path, match_sas_address));
+	} else if (flags & DCMD_LOOPFIRST) {
+		return (pmcs_dump_tracelog(B_FALSE, 0, match_phy_path,
+		    match_sas_address));
+	} else {
+		return (DCMD_OK);
+	}
+}
+
+static int
 pmcs_dcmd(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
 {
-	struct	pmcs_hw		ss;
+	struct pmcs_hw		ss;
 	uint_t			verbose = FALSE;
 	uint_t			phy_info = FALSE;
 	uint_t			hw_info = FALSE;
@@ -1911,11 +2061,11 @@
 	uint_t			ic_info = FALSE;
 	uint_t			iport_info = FALSE;
 	uint_t			waitqs_info = FALSE;
-	uint_t			tracelog = FALSE;
 	uint_t			ibq = FALSE;
 	uint_t			obq = FALSE;
 	uint_t			tgt_phy_count = FALSE;
 	uint_t			compq = FALSE;
+	uint_t			unconfigured = FALSE;
 	int			rv = DCMD_OK;
 	void			*pmcs_state;
 	char			*state_str;
@@ -1940,12 +2090,12 @@
 	    'h', MDB_OPT_SETBITS, TRUE, &hw_info,
 	    'i', MDB_OPT_SETBITS, TRUE, &ic_info,
 	    'I', MDB_OPT_SETBITS, TRUE, &iport_info,
-	    'l', MDB_OPT_SETBITS, TRUE, &tracelog,
 	    'p', MDB_OPT_SETBITS, TRUE, &phy_info,
 	    'q', MDB_OPT_SETBITS, TRUE, &ibq,
 	    'Q', MDB_OPT_SETBITS, TRUE, &obq,
 	    't', MDB_OPT_SETBITS, TRUE, &target_info,
 	    'T', MDB_OPT_SETBITS, TRUE, &tgt_phy_count,
+	    'u', MDB_OPT_SETBITS, TRUE, &unconfigured,
 	    'v', MDB_OPT_SETBITS, TRUE, &verbose,
 	    'w', MDB_OPT_SETBITS, TRUE, &work_info,
 	    'W', MDB_OPT_SETBITS, TRUE, &waitqs_info,
@@ -1962,32 +2112,12 @@
 		return (DCMD_ERR);
 	}
 
-	/*
-	 * Dumping the trace log is special.  It's global, not per-HBA.
-	 * Thus, a provided address is ignored.  In addition, other options
-	 * cannot be specified at the same time.
-	 */
-	if (tracelog) {
-		if (hw_info || ic_info || iport_info || phy_info || work_info ||
-		    target_info || waitqs_info || ibq || obq || tgt_phy_count ||
-		    compq) {
-			return (DCMD_USAGE);
-		}
-
-		if ((flags & DCMD_ADDRSPEC) && !(flags & DCMD_LOOP)) {
-			return (pmcs_dump_tracelog(B_TRUE, dip.devi_instance));
-		} else if (flags & DCMD_LOOPFIRST) {
-			return (pmcs_dump_tracelog(B_FALSE, 0));
-		} else {
-			return (DCMD_OK);
-		}
-	}
-
 	/* processing completed */
 
 	if (((flags & DCMD_ADDRSPEC) && !(flags & DCMD_LOOP)) ||
 	    (flags & DCMD_LOOPFIRST) || phy_info || target_info || hw_info ||
-	    work_info || waitqs_info || ibq || obq || tgt_phy_count || compq) {
+	    work_info || waitqs_info || ibq || obq || tgt_phy_count || compq ||
+	    unconfigured) {
 		if ((flags & DCMD_LOOP) && !(flags & DCMD_LOOPFIRST))
 			mdb_printf("\n");
 		mdb_printf("%16s %9s %4s B C  WorkFlags wserno DbgMsk %16s\n",
@@ -2051,6 +2181,9 @@
 	if (compq)
 		display_completion_queue(ss);
 
+	if (unconfigured)
+		display_unconfigured_targets(addr);
+
 	mdb_dec_indent(4);
 
 	return (rv);
@@ -2068,14 +2201,25 @@
 	    "    -p: Print information about each attached PHY\n"
 	    "    -q: Dump inbound queues\n"
 	    "    -Q: Dump outbound queues\n"
-	    "    -t: Print information about each known target\n"
+	    "    -t: Print information about each configured target\n"
 	    "    -T: Print target and PHY count summary\n"
+	    "    -u: Show SAS address of all unconfigured targets\n"
 	    "    -w: Dump work structures\n"
 	    "    -W: List pmcs cmds waiting on various queues\n"
 	    "    -v: Add verbosity to the above options\n");
 }
 
 void
+pmcs_log_help()
+{
+	mdb_printf("Dump the pmcs log buffer, possibly with filtering.\n"
+	    "    -p PHY_PATH:            Dump messages matching PHY_PATH\n"
+	    "    -s SAS_ADDRESS:         Dump messages matching SAS_ADDRESS\n\n"
+	    "Where: PHY_PATH can be found with ::pmcs -p (e.g. pp04.18.18.01)\n"
+	    "       SAS_ADDRESS can be found with ::pmcs -t "
+	    "(e.g. 5000c5000358c221)\n");
+}
+void
 pmcs_tag_help()
 {
 	mdb_printf("Print all work structures by matching the tag.\n"
@@ -2086,9 +2230,13 @@
 }
 
 static const mdb_dcmd_t dcmds[] = {
-	{ "pmcs", "?[-chiIpQqtTwWv] | -l", "print pmcs information",
+	{ "pmcs", "?[-chiIpQqtTuwWv]", "print pmcs information",
 	    pmcs_dcmd, pmcs_help
 	},
+	{ "pmcs_log",
+	    "?[-p PHY_PATH | -s SAS_ADDRESS]",
+	    "dump pmcs log file", pmcs_log, pmcs_log_help
+	},
 	{ "pmcs_tag", "?[-t tagtype|-s serialnum|-i index]",
 	    "Find work structures by tag type, serial number or index",
 	    pmcs_tag, pmcs_tag_help
--- a/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_attach.c	Thu Nov 12 10:26:22 2009 +0800
+++ b/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_attach.c	Wed Nov 11 19:33:15 2009 -0700
@@ -263,7 +263,7 @@
 
 	pwp = ddi_get_soft_state(pmcs_softc_state, hba_inst);
 	if (pwp == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: iport%d attach invoked with NULL parent (HBA) node)",
 		    __func__, inst);
 		return (DDI_FAILURE);
@@ -274,21 +274,21 @@
 	}
 
 	if ((iport_ua = scsi_hba_iport_unit_address(dip)) == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: invoked with NULL unit address, inst (%d)",
 		    __func__, inst);
 		return (DDI_FAILURE);
 	}
 
 	if (ddi_soft_state_zalloc(pmcs_iport_softstate, inst) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "Failed to alloc soft state for iport %d", inst);
 		return (DDI_FAILURE);
 	}
 
 	iport = ddi_get_soft_state(pmcs_iport_softstate, inst);
 	if (iport == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "cannot get iport soft state");
 		goto iport_attach_fail1;
 	}
@@ -322,7 +322,8 @@
 		/* Non-NULL private data indicates the unit address is active */
 		iport->ua_state = UA_ACTIVE;
 		if (pmcs_iport_configure_phys(iport) != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: failed to "
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
+			    "%s: failed to "
 			    "configure phys on iport handle (0x%p), "
 			    " unit address [%s]", __func__,
 			    (void *)iport, iport_ua);
@@ -338,14 +339,14 @@
 	iport->tgt_sstate = NULL;
 	if (ddi_soft_state_bystr_init(&iport->tgt_sstate,
 	    sizeof (pmcs_xscsi_t), PMCS_TGT_SSTATE_SZ) != 0) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "cannot get iport tgt soft state");
 		goto iport_attach_fail2;
 	}
 
 	/* Create this iport's target map */
 	if (pmcs_iport_tgtmap_create(iport) == B_FALSE) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "Failed to create tgtmap on iport %d", inst);
 		goto iport_attach_fail3;
 	}
@@ -353,8 +354,8 @@
 	/* Set up the 'initiator-port' DDI property on this iport */
 	init_port = kmem_zalloc(PMCS_MAX_UA_SIZE, KM_SLEEP);
 	if (pwp->separate_ports) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: separate ports not "
-		    "supported", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: separate ports not supported", __func__);
 	} else {
 		/* Set initiator-port value to the HBA's base WWN */
 		(void) scsi_wwn_to_wwnstr(pwp->sas_wwns[0], 1,
@@ -382,7 +383,8 @@
 	pwp->num_iports++;
 	rw_exit(&pwp->iports_lock);
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_IPORT, "iport%d attached", inst);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_IPORT, NULL, NULL,
+	    "iport%d attached", inst);
 	ddi_report_dev(dip);
 	return (DDI_SUCCESS);
 
@@ -573,7 +575,8 @@
 	 * Map registers
 	 */
 	if (pci_config_setup(dip, &pwp->pci_acc_handle)) {
-		pmcs_prt(pwp, PMCS_PRT_WARN, "pci config setup failed");
+		pmcs_prt(pwp, PMCS_PRT_WARN, NULL, NULL,
+		    "pci config setup failed");
 		ddi_soft_state_free(pmcs_softc_state, inst);
 		return (DDI_FAILURE);
 	}
@@ -582,7 +585,7 @@
 	 * Get the size of register set 3.
 	 */
 	if (ddi_dev_regsize(dip, PMCS_REGSET_3, &set3size) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "unable to get size of register set %d", PMCS_REGSET_3);
 		pci_config_teardown(&pwp->pci_acc_handle);
 		ddi_soft_state_free(pmcs_softc_state, inst);
@@ -596,7 +599,7 @@
 
 	if (ddi_regs_map_setup(dip, PMCS_REGSET_0, (caddr_t *)&pwp->msg_regs,
 	    0, 0, &pwp->reg_acc_attr, &pwp->msg_acc_handle)) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "failed to map Message Unit registers");
 		pci_config_teardown(&pwp->pci_acc_handle);
 		ddi_soft_state_free(pmcs_softc_state, inst);
@@ -605,7 +608,8 @@
 
 	if (ddi_regs_map_setup(dip, PMCS_REGSET_1, (caddr_t *)&pwp->top_regs,
 	    0, 0, &pwp->reg_acc_attr, &pwp->top_acc_handle)) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "failed to map TOP registers");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "failed to map TOP registers");
 		ddi_regs_map_free(&pwp->msg_acc_handle);
 		pci_config_teardown(&pwp->pci_acc_handle);
 		ddi_soft_state_free(pmcs_softc_state, inst);
@@ -614,7 +618,8 @@
 
 	if (ddi_regs_map_setup(dip, PMCS_REGSET_2, (caddr_t *)&pwp->gsm_regs,
 	    0, 0, &pwp->reg_acc_attr, &pwp->gsm_acc_handle)) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "failed to map GSM registers");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "failed to map GSM registers");
 		ddi_regs_map_free(&pwp->top_acc_handle);
 		ddi_regs_map_free(&pwp->msg_acc_handle);
 		pci_config_teardown(&pwp->pci_acc_handle);
@@ -624,7 +629,8 @@
 
 	if (ddi_regs_map_setup(dip, PMCS_REGSET_3, (caddr_t *)&pwp->mpi_regs,
 	    0, 0, &pwp->reg_acc_attr, &pwp->mpi_acc_handle)) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "failed to map MPI registers");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "failed to map MPI registers");
 		ddi_regs_map_free(&pwp->top_acc_handle);
 		ddi_regs_map_free(&pwp->gsm_acc_handle);
 		ddi_regs_map_free(&pwp->msg_acc_handle);
@@ -643,13 +649,13 @@
 	switch (pwp->chiprev) {
 	case PMCS_PM8001_REV_A:
 	case PMCS_PM8001_REV_B:
-		pmcs_prt(pwp, PMCS_PRT_ERR,
+		pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL,
 		    "Rev A/B Card no longer supported");
 		goto failure;
 	case PMCS_PM8001_REV_C:
 		break;
 	default:
-		pmcs_prt(pwp, PMCS_PRT_ERR,
+		pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL,
 		    "Unknown chip revision (%d)", pwp->chiprev);
 		goto failure;
 	}
@@ -662,7 +668,7 @@
 	if (pmcs_dma_setup(pwp, &pwp->cip_dma_attr, &pwp->cip_acchdls,
 	    &pwp->cip_handles, ptob(1), (caddr_t *)&pwp->cip,
 	    &pwp->ciaddr) == B_FALSE) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "Failed to setup DMA for index/scratch");
 		goto failure;
 	}
@@ -689,7 +695,7 @@
 		    &pwp->fwlog_hndl, PMCS_FWLOG_SIZE,
 		    (caddr_t *)&pwp->fwlogp,
 		    &pwp->fwaddr) == B_FALSE) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "Failed to setup DMA for fwlog area");
 			pwp->fwlog = 0;
 		} else {
@@ -704,7 +710,7 @@
 		    &pwp->regdump_hndl, PMCS_FLASH_CHUNK_SIZE,
 		    (caddr_t *)&pwp->flash_chunkp, &pwp->flash_chunk_addr) ==
 		    B_FALSE) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "Failed to setup DMA for register dump area");
 			goto failure;
 		}
@@ -716,7 +722,8 @@
 	 */
 	pwp->tq = ddi_taskq_create(dip, "_tq", 4, TASKQ_DEFAULTPRI, 0);
 	if (pwp->tq == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "unable to create worker taskq");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "unable to create worker taskq");
 		goto failure;
 	}
 
@@ -891,7 +898,8 @@
 
 	/* Read VPD - if it exists */
 	if (pmcs_get_nvmd(pwp, PMCS_NVMD_VPD, PMCIN_NVMD_VPD, 0, NULL, 0)) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Unable to read VPD: "
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: Unable to read VPD: "
 		    "attempting to fabricate", __func__);
 		/*
 		 * When we release, this must goto failure and the call
@@ -913,8 +921,8 @@
 	 * if needed and reset.
 	 */
 	if (pmcs_firmware_update(pwp)) {
-		pmcs_prt(pwp, PMCS_PRT_WARN, "%s: Firmware update failed",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_WARN, NULL, NULL,
+		    "%s: Firmware update failed", __func__);
 		goto failure;
 	}
 
@@ -965,8 +973,8 @@
 	if (sas_phymap_create(dip, phymap_usec, PHYMAP_MODE_SIMPLE, NULL,
 	    pwp, pmcs_phymap_activate, pmcs_phymap_deactivate,
 	    &pwp->hss_phymap) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: pmcs%d phymap_create failed",
-		    __func__, inst);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: pmcs%d phymap_create failed", __func__, inst);
 		goto failure;
 	}
 	ASSERT(pwp->hss_phymap);
@@ -976,8 +984,8 @@
 	 */
 	if (scsi_hba_iportmap_create(dip, iportmap_usec, pwp->nphy,
 	    &pwp->hss_iportmap) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: pmcs%d iportmap_create "
-		    "failed", __func__, inst);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: pmcs%d iportmap_create failed", __func__, inst);
 		goto failure;
 	}
 	ASSERT(pwp->hss_iportmap);
@@ -1083,7 +1091,8 @@
 			if (pmcs_iport_unattach(iport)) {
 				return (DDI_FAILURE);
 			}
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "iport%d detached", inst);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+			    "iport%d detached", inst);
 			return (DDI_SUCCESS);
 		} else {
 			/* HBA detach */
@@ -1118,7 +1127,7 @@
 		}
 		pwp->suspended = 1;
 		mutex_exit(&pwp->lock);
-		pmcs_prt(pwp, PMCS_PRT_INFO, "PMC8X6G suspending");
+		pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "PMC8X6G suspending");
 		return (DDI_SUCCESS);
 
 	default:
@@ -1136,8 +1145,9 @@
 	 * iport.  If so, we fail detach.
 	 */
 	if (pmcs_iport_has_targets(pwp, iport)) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_IPORT, "iport%d detach failure: "
-		    "iport has targets (luns)", ddi_get_instance(iport->dip));
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_IPORT, NULL, NULL,
+		    "iport%d detach failure: iport has targets (luns)",
+		    ddi_get_instance(iport->dip));
 		return (DDI_FAILURE);
 	}
 
@@ -1150,7 +1160,8 @@
 	if (iport->ua_state == UA_ACTIVE) {
 		mutex_exit(&iport->lock);
 		rw_exit(&pwp->iports_lock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_IPORT, "iport%d detach failure: "
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_IPORT, NULL, NULL,
+		    "iport%d detach failure: "
 		    "iport unit address active in phymap",
 		    ddi_get_instance(iport->dip));
 		return (DDI_FAILURE);
@@ -1386,7 +1397,8 @@
 	 */
 	if (pwp->regdump_hndl) {
 		if (ddi_dma_unbind_handle(pwp->regdump_hndl) != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "Condition check failed "
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+			    "Condition check failed "
 			    "at %s():%d", __func__, __LINE__);
 		}
 		ddi_dma_free_handle(&pwp->regdump_hndl);
@@ -1395,7 +1407,8 @@
 	}
 	if (pwp->fwlog_hndl) {
 		if (ddi_dma_unbind_handle(pwp->fwlog_hndl) != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "Condition check failed "
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+			    "Condition check failed "
 			    "at %s():%d", __func__, __LINE__);
 		}
 		ddi_dma_free_handle(&pwp->fwlog_hndl);
@@ -1404,7 +1417,8 @@
 	}
 	if (pwp->cip_handles) {
 		if (ddi_dma_unbind_handle(pwp->cip_handles) != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "Condition check failed "
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+			    "Condition check failed "
 			    "at %s():%d", __func__, __LINE__);
 		}
 		ddi_dma_free_handle(&pwp->cip_handles);
@@ -1415,8 +1429,9 @@
 		if (pwp->oqp_handles[i]) {
 			if (ddi_dma_unbind_handle(pwp->oqp_handles[i]) !=
 			    DDI_SUCCESS) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG, "Condition check "
-				    "failed at %s():%d", __func__, __LINE__);
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+				    "Condition check failed at %s():%d",
+				    __func__, __LINE__);
 			}
 			ddi_dma_free_handle(&pwp->oqp_handles[i]);
 			ddi_dma_mem_free(&pwp->oqp_acchdls[i]);
@@ -1427,8 +1442,9 @@
 		if (pwp->iqp_handles[i]) {
 			if (ddi_dma_unbind_handle(pwp->iqp_handles[i]) !=
 			    DDI_SUCCESS) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG, "Condition check "
-				    "failed at %s():%d", __func__, __LINE__);
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+				    "Condition check failed at %s():%d",
+				    __func__, __LINE__);
 			}
 			ddi_dma_free_handle(&pwp->iqp_handles[i]);
 			ddi_dma_mem_free(&pwp->iqp_acchdls[i]);
@@ -1647,7 +1663,8 @@
 	if ((u.nsa[0] >> 4) == 5) {
 		(void) memcpy(pptr->sas_address, u.nsa, 8);
 	}
-	pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: %s has SAS ADDRESS " SAS_ADDR_FMT,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
+	    "%s: %s has SAS ADDRESS " SAS_ADDR_FMT,
 	    __func__, pptr->path, SAS_ADDR_PRT(pptr->sas_address));
 	return (0);
 }
@@ -1659,14 +1676,14 @@
 pmcs_add_new_device(pmcs_hw_t *pwp, pmcs_xscsi_t *target)
 {
 	ASSERT(target != NULL);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: target = 0x%p",
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, target, "%s: target = 0x%p",
 	    __func__, (void *) target);
 
 	switch (target->phy->dtype) {
 	case SATA:
 		if (pmcs_add_sata_device(pwp, target) != 0) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
-			    "%s: add_sata_device failed for tgt 0x%p",
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, target->phy,
+			    target, "%s: add_sata_device failed for tgt 0x%p",
 			    __func__, (void *) target);
 			return (B_FALSE);
 		}
@@ -1769,7 +1786,7 @@
 
 	pchunk = kmem_zalloc(sizeof (pmcs_chunk_t), KM_SLEEP);
 	if (pchunk == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "Not enough memory for DMA chunks");
 		return (-1);
 	}
@@ -1777,7 +1794,8 @@
 	if (pmcs_dma_setup(pwp, &pwp->cip_dma_attr, &pchunk->acc_handle,
 	    &pchunk->dma_handle, nsize, (caddr_t *)&pchunk->addrp,
 	    &pchunk->dma_addr) == B_FALSE) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "Failed to setup DMA for chunks");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "Failed to setup DMA for chunks");
 		kmem_free(pchunk, sizeof (pmcs_chunk_t));
 		return (-1);
 	}
@@ -1856,7 +1874,7 @@
 		 * with it any more.
 		 */
 		if (pwrk->phy == NULL) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "dead command with gone phy being recycled");
 			ASSERT(pwrk->xp == NULL);
 			pmcs_pwork(pwp, pwrk);
@@ -1873,7 +1891,7 @@
 		 * the WAIT_FOR macro.
 		 */
 		if (pwrk->xp == NULL) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: non-SCSA cmd tag 0x%x timed out",
 			    path, pwrk->htag);
 			mutex_exit(&pwrk->lock);
@@ -1889,11 +1907,11 @@
 		CMD2PKT(sp)->pkt_reason = CMD_TIMEOUT;
 		CMD2PKT(sp)->pkt_statistics |= STAT_TIMEOUT;
 #ifdef	DEBUG
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pwrk->phy, pwrk->xp,
 		    "%s: SCSA cmd tag 0x%x timed out (state %x) onwire=%d",
 		    path, pwrk->htag, pwrk->state, pwrk->onwire);
 #else
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pwrk->phy, pwrk->xp,
 		    "%s: SCSA cmd tag 0x%x timed out (state %x)",
 		    path, pwrk->htag, pwrk->state);
 #endif
@@ -1914,15 +1932,15 @@
 		if (pwrk->xp->dev_gone) {
 			mutex_exit(&target->statlock);
 			pmcs_unlock_phy(phyp);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, phyp, target,
 			    "%s: tgt(0x%p) is gone. Returning CMD_DEV_GONE "
 			    "for htag 0x%08x", __func__,
 			    (void *)pwrk->xp, pwrk->htag);
 			mutex_enter(&pwrk->lock);
 			if (!PMCS_COMMAND_DONE(pwrk)) {
 				/* Complete this command here */
-				pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: "
-				    "Completing cmd (htag 0x%08x) "
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, phyp, target,
+				    "%s: Completing cmd (htag 0x%08x) "
 				    "anyway", __func__, pwrk->htag);
 				pwrk->dead = 1;
 				CMD2PKT(sp)->pkt_reason = CMD_DEV_GONE;
@@ -1938,7 +1956,7 @@
 		 * See if we're already waiting for device state recovery
 		 */
 		if (target->recover_wait) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, phyp, target,
 			    "%s: Target %p already in recovery", __func__,
 			    (void *)target);
 			mutex_exit(&target->statlock);
@@ -1974,7 +1992,7 @@
 	if (atomic_cas_ulong(&pwp->work_flags, 0, 0) != 0) {
 		if (ddi_taskq_dispatch(pwp->tq, pmcs_worker, pwp,
 		    DDI_NOSLEEP) != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "Could not dispatch to worker thread");
 		}
 	}
@@ -1994,7 +2012,7 @@
 		if (r == DDI_SUCCESS) {
 			continue;
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: unable to remove interrupt handler %d", __func__, i);
 		rslt = -1;
 		break;
@@ -2009,7 +2027,7 @@
 		int r = ddi_intr_block_disable(&pwp->ih_table[0],
 		    pwp->intr_cnt);
 		if (r != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "unable to disable interrupt block");
 			return (-1);
 		}
@@ -2019,7 +2037,7 @@
 			if (ddi_intr_disable(pwp->ih_table[i]) == DDI_SUCCESS) {
 				continue;
 			}
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "unable to disable interrupt %d", i);
 			return (-1);
 		}
@@ -2035,7 +2053,8 @@
 		if (ddi_intr_free(pwp->ih_table[i]) == DDI_SUCCESS) {
 			continue;
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "unable to free interrupt %d", i);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "unable to free interrupt %d", i);
 		return (-1);
 	}
 	kmem_free(pwp->ih_table, pwp->ih_table_size);
@@ -2054,24 +2073,24 @@
 
 	rval = ddi_intr_get_nintrs(pwp->dip, type, &count);
 	if ((rval != DDI_SUCCESS) || (count < min)) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 		    "%s: get_nintrs failed; type: %d rc: %d count: %d min: %d",
 		    __func__, type, rval, count, min);
 		return;
 	}
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 	    "%s: nintrs = %d for type: %d", __func__, count, type);
 
 	rval = ddi_intr_get_navail(pwp->dip, type, &avail);
 	if ((rval != DDI_SUCCESS) || (avail < min)) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 		    "%s: get_navail failed; type: %d rc: %d avail: %d min: %d",
 		    __func__, type, rval, avail, min);
 		return;
 	}
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 	    "%s: navail = %d for type: %d", __func__, avail, type);
 
 	pwp->ih_table_size = avail * sizeof (ddi_intr_handle_t);
@@ -2096,7 +2115,7 @@
 	rval = ddi_intr_alloc(pwp->dip, pwp->ih_table, type, 0, max, &actual,
 	    DDI_INTR_ALLOC_NORMAL);
 	if (rval != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 		    "%s: ddi_intr_alloc failed; type: %d rc: %d",
 		    __func__, type, rval);
 		kmem_free(pwp->ih_table, pwp->ih_table_size);
@@ -2129,7 +2148,8 @@
 	uint_t pri;
 
 	if (ddi_intr_get_supported_types(pwp->dip, &itypes) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "cannot get interrupt types");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "cannot get interrupt types");
 		return (EAGAIN);
 	}
 
@@ -2173,7 +2193,8 @@
 	}
 
 	if (pwp->intr_cnt == 0) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, "No interrupts available");
+		pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL,
+		    "No interrupts available");
 		return (EAGAIN);
 	}
 
@@ -2198,7 +2219,7 @@
 		iv_table[PMCS_MSIX_FATAL] = pmcs_fatal_ix;
 		break;
 	default:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: intr_cnt = %d - unexpected", __func__, pwp->intr_cnt);
 		kmem_free(iv_table, iv_table_size);
 		return (EAGAIN);
@@ -2223,7 +2244,8 @@
 	kmem_free(iv_table, iv_table_size);
 
 	if (ddi_intr_get_cap(pwp->ih_table[0], &pwp->intr_cap) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "unable to get int capabilities");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "unable to get int capabilities");
 		if (pmcs_remove_ihandlers(pwp, pwp->intr_cnt)) {
 			return (EIO);
 		}
@@ -2237,7 +2259,8 @@
 	if (pwp->intr_cap & DDI_INTR_FLAG_BLOCK) {
 		r = ddi_intr_block_enable(&pwp->ih_table[0], pwp->intr_cnt);
 		if (r != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "intr blk enable failed");
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+			    "intr blk enable failed");
 			if (pmcs_remove_ihandlers(pwp, pwp->intr_cnt)) {
 				return (EIO);
 			}
@@ -2253,7 +2276,7 @@
 			if (r == DDI_SUCCESS) {
 				continue;
 			}
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "unable to enable interrupt %d", i);
 			if (pmcs_disable_intrs(pwp, i)) {
 				return (EIO);
@@ -2273,7 +2296,7 @@
 	 * Set up locks.
 	 */
 	if (ddi_intr_get_pri(pwp->ih_table[0], &pri) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "unable to get interrupt priority");
 		if (pmcs_disable_intrs(pwp, pwp->intr_cnt)) {
 			return (EIO);
@@ -2316,7 +2339,7 @@
 		    CV_DRIVER, NULL);
 	}
 
-	pmcs_prt(pwp, PMCS_PRT_INFO, "%d %s interrup%s configured",
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "%d %s interrup%s configured",
 	    pwp->intr_cnt, (pwp->int_type == PMCS_INT_MSIX)? "MSI-X" :
 	    ((pwp->int_type == PMCS_INT_MSI)? "MSI" : "INT-X"),
 	    pwp->intr_cnt == 1? "t" : "ts");
@@ -2483,7 +2506,7 @@
 		pmcs_event_intr(pwp);
 	}
 	if (obdb) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "interrupt bits not handled (0x%x)", obdb);
 		pmcs_wr_msgunit(pwp, PMCS_MSGU_OBDB_CLEAR, obdb);
 		handled++;
@@ -2497,7 +2520,7 @@
 void
 pmcs_fatal_handler(pmcs_hw_t *pwp)
 {
-	pmcs_prt(pwp, PMCS_PRT_ERR, "Fatal Interrupt caught");
+	pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL, "Fatal Interrupt caught");
 	mutex_enter(&pwp->lock);
 	pwp->state = STATE_DEAD;
 	pmcs_register_dump_int(pwp);
@@ -2528,7 +2551,7 @@
 		tgt->ca = 1;
 		break;
 	default:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, tgt,
 		    "%s: Target %p has PHY %p with invalid dtype",
 		    __func__, (void *)tgt, (void *)pptr);
 		return (B_FALSE);
@@ -2538,12 +2561,12 @@
 	tgt->dev_gone = 0;
 	tgt->recover_wait = 0;
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, tgt,
 	    "%s: config %s vtgt %u for " SAS_ADDR_FMT, __func__,
 	    pptr->path, tgt->target_num, SAS_ADDR_PRT(pptr->sas_address));
 
 	if (pmcs_add_new_device(pwp, tgt) != B_TRUE) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, tgt,
 		    "%s: Failed for vtgt %u / WWN " SAS_ADDR_FMT, __func__,
 		    tgt->target_num, SAS_ADDR_PRT(pptr->sas_address));
 		mutex_destroy(&tgt->statlock);
@@ -2576,11 +2599,11 @@
 		if (xp->phy == pptr) {
 			if (xp->new) {
 				xp->new = 0;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, xp,
 				    "cancel config of vtgt %u", vtgt);
 			} else {
 				pmcs_clear_xp(pwp, xp);
-				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, xp,
 				    "Removed tgt 0x%p vtgt %u",
 				    (void *)xp, vtgt);
 			}
@@ -2592,7 +2615,8 @@
 }
 
 void
-pmcs_prt_impl(pmcs_hw_t *pwp, pmcs_prt_level_t level, const char *fmt, ...)
+pmcs_prt_impl(pmcs_hw_t *pwp, pmcs_prt_level_t level,
+    pmcs_phy_t *phyp, pmcs_xscsi_t *target, const char *fmt, ...)
 {
 	va_list	ap;
 	int written = 0;
@@ -2635,6 +2659,30 @@
 	mutex_enter(&pmcs_trace_lock);
 	gethrestime(&pmcs_tbuf_ptr->timestamp);
 	ptr = pmcs_tbuf_ptr->buf;
+
+	/*
+	 * Store the pertinent PHY and target information if there is any
+	 */
+	if (target == NULL) {
+		pmcs_tbuf_ptr->target_num = PMCS_INVALID_TARGET_NUM;
+		pmcs_tbuf_ptr->target_ua[0] = '\0';
+	} else {
+		pmcs_tbuf_ptr->target_num = target->target_num;
+		(void) strncpy(pmcs_tbuf_ptr->target_ua, target->ua,
+		    PMCS_TBUF_UA_MAX_SIZE);
+	}
+
+	if (phyp == NULL) {
+		(void) memset(pmcs_tbuf_ptr->phy_sas_address, 0, 8);
+		pmcs_tbuf_ptr->phy_path[0] = '\0';
+		pmcs_tbuf_ptr->phy_dtype = NOTHING;
+	} else {
+		(void) memcpy(pmcs_tbuf_ptr->phy_sas_address,
+		    phyp->sas_address, 8);
+		(void) strncpy(pmcs_tbuf_ptr->phy_path, phyp->path, 32);
+		pmcs_tbuf_ptr->phy_dtype = phyp->dtype;
+	}
+
 	written += snprintf(ptr, elem_size, "pmcs%d:%d: ",
 	    ddi_get_instance(pwp->dip), level);
 	ptr += strlen(ptr);
@@ -2773,7 +2821,7 @@
 
 		if (phyp->phy_stats == NULL) {
 			pmcs_unlock_phy(phyp);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, phyp, NULL,
 			    "%s: Failed to create %s kstats", __func__,
 			    ks_name);
 			continue;
@@ -2972,7 +3020,7 @@
 	if (adr == 0) {
 		static const char foo[] = __DATE__ __TIME__;
 		/* Oh, dear, we're toast */
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: No serial number available to fabricate WWN",
 		    __func__);
 		for (i = 0; foo[i]; i++) {
--- a/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_fwlog.c	Thu Nov 12 10:26:22 2009 +0800
+++ b/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_fwlog.c	Wed Nov 11 19:33:15 2009 -0700
@@ -53,16 +53,16 @@
 	uint8_t slice = 0;
 	caddr_t buf = NULL;
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG, "pmcs%d: Internal register dump",
-	    ddi_get_instance(pwp->dip));
+	pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+	    "pmcs%d: Internal register dump", ddi_get_instance(pwp->dip));
 	ASSERT(mutex_owned(&pwp->lock));
 
 	if (pwp->regdumpp == NULL) {
 		pwp->regdumpp =
 		    kmem_zalloc(PMCS_REG_DUMP_SIZE, KM_NOSLEEP);
 		if (pwp->regdumpp == NULL) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: register"
-			    " dump memory not allocated", __func__);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+			    "%s: register dump memory not allocated", __func__);
 			return;
 		}
 	}
@@ -239,7 +239,7 @@
 			log_is_current = B_TRUE;
 		} else {
 			++retries;
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: event log is still being updated... waiting",
 			    __func__);
 			evlog_latest_idx = evl_hdr->fw_el_latest_idx;
@@ -806,7 +806,8 @@
 
 	if (ddi_get32(pwp->top_acc_handle,
 	    &pwp->top_regs[PMCS_AXI_TRANS >> 2]) != newaxil) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "AXIL register update failed");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "AXIL register update failed");
 		return (B_FALSE);
 	}
 	return (B_TRUE);
@@ -833,7 +834,8 @@
 
 	if (ddi_get32(pwp->top_acc_handle,
 	    &pwp->top_regs[PMCS_AXI_TRANS >> 2]) != oldaxil) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "AXIL register restore failed");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "AXIL register restore failed");
 	}
 	mutex_exit(&pwp->axil_lock);
 }
@@ -852,7 +854,7 @@
 
 	local_buf = kmem_zalloc(GSM_SM_BLKSZ, KM_NOSLEEP);
 	if (local_buf == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: local_buf memory not allocated", __func__);
 		return (0);
 	}
@@ -956,7 +958,8 @@
 	uint32_t size_left = pwp->iqpt->size_left;
 
 	if (tbuf == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: trace buffer is not ready,"
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: trace buffer is not ready,"
 		    " Inbound Message from host to SPC is not traced",
 		    __func__);
 		return;
@@ -1010,8 +1013,8 @@
 			length = pmcs_rd_mpi_tbl(pwp, PMCS_FERDLIOP);
 			break;
 		default:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "UNKNOWN NVMD DEVICE"
-			    "%s():%d", __func__, __LINE__);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+			    "UNKNOWN NVMD DEVICE %s():%d", __func__, __LINE__);
 			return (0);
 	}
 
--- a/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_intr.c	Thu Nov 12 10:26:22 2009 +0800
+++ b/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_intr.c	Wed Nov 11 19:33:15 2009 -0700
@@ -41,7 +41,7 @@
 	}
 #define	WRONG_OBID_CHECK(pwp, w, q)	\
 	if (((w & PMCS_IOMB_OBID_MASK) >> PMCS_IOMB_OBID_SHIFT) != q) {	\
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,				\
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,		\
 		    "%s: COMPLETION WITH WRONG OBID (0x%x)", __func__,	\
 		    (w & PMCS_IOMB_OBID_MASK) >> PMCS_IOMB_OBID_SHIFT);	\
 	}
@@ -52,7 +52,7 @@
 
 #define	OQLIM_CHECK(p, l)				\
 	if (++l == (p)->ioq_depth) {			\
-		pmcs_prt(p, PMCS_PRT_DEBUG,		\
+		pmcs_prt(p, PMCS_PRT_DEBUG, NULL, NULL,	\
 		    "%s: possible ob queue overflow",	\
 		    __func__);				\
 		break;					\
@@ -67,12 +67,12 @@
 		(void) memcpy(&l[PMCS_QENTRY_SIZE],			\
 		    GET_OQ_ENTRY(p, q, c, 1), PMCS_QENTRY_SIZE);	\
 	}								\
-	pmcs_prt(p, PMCS_PRT_DEBUG3,					\
+	pmcs_prt(p, PMCS_PRT_DEBUG3, NULL, NULL,			\
 	    "%s: ptr %p ci %d w0 %x nbuf %d",				\
 	    __func__, (void *)x, ci, w0, n)
 
 #define	EVT_PRT(hwp, msg, phy)	\
-	pmcs_prt(hwp, PMCS_PRT_INFO, "Phy 0x%x: %s", phy, # msg)
+	pmcs_prt(hwp, PMCS_PRT_INFO, NULL, NULL, "Phy 0x%x: %s", phy, # msg)
 
 
 /*
@@ -139,12 +139,12 @@
 	for (i = 0; i < 256; i++) {
 		mutex_enter(&pwp->dbglock);
 		if (pwp->ltags[i] == htag) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "same tag already completed (%llu us ago)",
 			    (unsigned long long) (now - pwp->ltime[i]));
 		}
 		if (pwp->ftags[i] == htag) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "same tag started (line %d) (%llu ns ago)",
 			    pwp->ftag_lines[i], (unsigned long long)
 			    (now - pwp->ftime[i]));
@@ -282,7 +282,7 @@
 	pmcs_unlock_phy(pptr);
 
 	RESTART_DISCOVERY(pwp);
-	pmcs_prt(pwp, PMCS_PRT_INFO, "PortID 0x%x Cleared", portid);
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "PortID 0x%x Cleared", portid);
 }
 
 void
@@ -301,12 +301,12 @@
 	switch (IOP_EVENT_EVENT(w1)) {
 	case IOP_EVENT_PHY_STOP_STATUS:
 		if (IOP_EVENT_STATUS(w1)) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "PORT %d failed to stop (0x%x)",
 			    phynum, IOP_EVENT_STATUS(w1));
 		} else {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "PHY 0x%x Stopped",
-			    phynum);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
+			    "PHY 0x%x Stopped", phynum);
 			mutex_enter(&pwp->lock);
 			pptr = pwp->root_phys + phynum;
 			pmcs_lock_phy(pptr);
@@ -365,9 +365,9 @@
 					pmcs_unlock_phy(rp);
 				}
 				pmcs_unlock_phy(pptr);
-				pmcs_prt(pwp, PMCS_PRT_DEBUG, "PortID 0x%x"
-				    ": PHY 0x%x SAS LINK UP IS FOR A "
-				    "DIFFERENT PORTID 0x%x", rp->portid,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
+				    "PortID 0x%x: PHY 0x%x SAS LINK UP IS FOR "
+				    "A DIFFERENT PORTID 0x%x", rp->portid,
 				    phynum, portid);
 				break;
 			}
@@ -397,7 +397,7 @@
 			    pwp->sas_wwns[0],
 			    pmcs_barray2wwn(pptr->sas_address)) !=
 			    DDI_SUCCESS) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 				    "Unable to add phy %u for 0x%" PRIx64 ".0x%"
 				    PRIx64, phynum, pwp->sas_wwns[rp->phynum],
 				    pmcs_barray2wwn(pptr->sas_address));
@@ -423,9 +423,9 @@
 				pmcs_rele_iport(iport);
 			}
 
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "PortID 0x%x: PHY"
-			    " 0x%x SAS LINK UP WIDENS PORT TO %d PHYS",
-			    portid, phynum, rp->width);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
+			    "PortID 0x%x: PHY 0x%x SAS LINK UP WIDENS PORT "
+			    "TO %d PHYS", portid, phynum, rp->width);
 
 			if (pptr != rp) {
 				pmcs_unlock_phy(pptr);
@@ -439,15 +439,15 @@
 		 */
 		if (pptr->dtype != NOTHING && pptr->configured) {
 			pmcs_unlock_phy(pptr);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
-			    "PortID 0x%x: SAS PHY 0x%x "
-			    "UP HITS EXISTING CONFIGURED TREE", portid, phynum);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
+			    "PortID 0x%x: SAS PHY 0x%x UP HITS EXISTING "
+			    "CONFIGURED TREE", portid, phynum);
 			break;
 		}
 
 		if (af.address_frame_type != SAS_AF_IDENTIFY) {
 			pmcs_unlock_phy(pptr);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "SAS link up on phy 0x%x, "
 			    "but unexpected frame type 0x%x found", phynum,
 			    af.address_frame_type);
@@ -472,7 +472,7 @@
 			pptr->dtype = EXPANDER;
 			break;
 		default:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "unknown device type 0x%x", af.device_type);
 			pptr->pend_dtype = NOTHING;
 			pptr->dtype = NOTHING;
@@ -486,17 +486,19 @@
 		if (pptr->dtype == SAS) {
 			pptr->spinup_hold = 1;
 			pmcs_spinup_release(pwp, pptr);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 			    "Release spinup hold on PHY 0x%x", phynum);
 		}
 
 		pmcs_set_changed(pwp, pptr, B_TRUE, 0);
 		if (pptr->width > 1) {
-			pmcs_prt(pwp, PMCS_PRT_INFO, "PortID 0x%x: PHY 0x%x SAS"
+			pmcs_prt(pwp, PMCS_PRT_INFO, pptr, NULL,
+			    "PortID 0x%x: PHY 0x%x SAS"
 			    " LINK UP @ %s Gb with %d phys/s", portid, phynum,
 			    pmcs_get_rate(pptr->link_rate), pptr->width);
 		} else {
-			pmcs_prt(pwp, PMCS_PRT_INFO, "PortID 0x%x: PHY 0x%x SAS"
+			pmcs_prt(pwp, PMCS_PRT_INFO, pptr, NULL,
+			    "PortID 0x%x: PHY 0x%x SAS"
 			    " LINK UP @ %s Gb/s", portid, phynum,
 			    pmcs_get_rate(pptr->link_rate));
 		}
@@ -506,7 +508,7 @@
 		if (sas_phymap_phy_add(pwp->hss_phymap, phynum,
 		    pwp->sas_wwns[0],
 		    pmcs_barray2wwn(pptr->sas_address)) != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "Unable to add phy %u for 0x%" PRIx64 ".0x%"
 			    PRIx64, phynum, pwp->sas_wwns[pptr->phynum],
 			    pmcs_barray2wwn(pptr->sas_address));
@@ -560,7 +562,7 @@
 
 		if (pptr->dtype != NOTHING && pptr->configured) {
 			pmcs_unlock_phy(pptr);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "PortID 0x%x: SATA PHY 0x%x"
 			    " UP HITS EXISTING CONFIGURED TREE",
 			    portid, phynum);
@@ -590,7 +592,7 @@
 		pptr->link_rate = pmcs_link_rate(IOP_EVENT_LINK_RATE(w1));
 		pptr->dtype = SATA;
 		pmcs_set_changed(pwp, pptr, B_TRUE, 0);
-		pmcs_prt(pwp, PMCS_PRT_INFO,
+		pmcs_prt(pwp, PMCS_PRT_INFO, pptr, NULL,
 		    "PortID 0x%x: PHY 0x%x SATA LINK UP @ %s Gb/s",
 		    pptr->portid, phynum, pmcs_get_rate(pptr->link_rate));
 		pmcs_unlock_phy(pptr);
@@ -599,7 +601,7 @@
 		if (sas_phymap_phy_add(pwp->hss_phymap, phynum,
 		    pwp->sas_wwns[0],
 		    pmcs_barray2wwn(pptr->sas_address)) != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "Unable to add phy %u for 0x%" PRIx64 ".0x%"
 			    PRIx64, phynum, pwp->sas_wwns[pptr->phynum],
 			    pmcs_barray2wwn(pptr->sas_address));
@@ -664,25 +666,26 @@
 		mutex_exit(&pwp->lock);
 
 		if (pptr == NULL) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "PortID 0x%x: PHY 0x%x "
-			    "LINK DOWN- no portid pointer", portid, phynum);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+			    "PortID 0x%x: PHY 0x%x LINK DOWN- no portid ptr",
+			    portid, phynum);
 			break;
 		}
 		if (IOP_EVENT_PORT_STATE(w3) == IOP_EVENT_PS_NIL) {
-			pmcs_prt(pwp, PMCS_PRT_INFO,
+			pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
 			    "PortID 0x%x: PHY 0x%x NOT VALID YET",
 			    portid, phynum);
 			need_ack = 1;
 			break;
 		}
 		if (IOP_EVENT_PORT_STATE(w3) == IOP_EVENT_PS_IN_RESET) {
-			pmcs_prt(pwp, PMCS_PRT_INFO,
+			pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
 			    "PortID 0x%x: PHY 0x%x IN RESET",
 			    portid, phynum);
 			break;
 		}
 		if (IOP_EVENT_PORT_STATE(w3) == IOP_EVENT_PS_LOSTCOMM) {
-			pmcs_prt(pwp, PMCS_PRT_INFO,
+			pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
 			    "PortID 0x%x: PHY 0x%x TEMPORARILY DOWN",
 			    portid, phynum);
 			need_ack = 1;
@@ -722,7 +725,7 @@
 			/* Remove this PHY from the phymap */
 			if (sas_phymap_phy_rem(pwp->hss_phymap, phynum) !=
 			    DDI_SUCCESS) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 				    "Unable to remove phy %u for 0x%" PRIx64
 				    ".0x%" PRIx64, phynum,
 				    pwp->sas_wwns[pptr->phynum],
@@ -730,22 +733,23 @@
 				    pptr->phynum)-> sas_address));
 			}
 
-			pmcs_prt(pwp, PMCS_PRT_INFO, "PortID 0x%x: PHY 0x%x "
-			    "LINK DOWN NARROWS PORT TO %d PHYS",
-			    portid, phynum, pptr->width);
+			pmcs_prt(pwp, PMCS_PRT_INFO, pptr, NULL,
+			    "PortID 0x%x: PHY 0x%x LINK DOWN NARROWS PORT "
+			    "TO %d PHYS", portid, phynum, pptr->width);
 			break;
 		}
 		if (IOP_EVENT_PORT_STATE(w3) != IOP_EVENT_PS_INVALID) {
-			pmcs_prt(pwp, PMCS_PRT_INFO, "PortID 0x%x: PHY 0x"
-			    "%x LINK DOWN NOT HANDLED (state 0x%x)",
-			    portid, phynum, IOP_EVENT_PORT_STATE(w3));
+			pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
+			    "PortID 0x%x: PHY 0x%x LINK DOWN NOT HANDLED "
+			    "(state 0x%x)", portid, phynum,
+			    IOP_EVENT_PORT_STATE(w3));
 			need_ack = 1;
 			break;
 		}
 		/* Remove this PHY from the phymap */
 		if (sas_phymap_phy_rem(pwp->hss_phymap, phynum) !=
 		    DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "Unable to remove phy %u for 0x%" PRIx64
 			    ".0x%" PRIx64, phynum,
 			    pwp->sas_wwns[pptr->phynum],
@@ -753,7 +757,7 @@
 			    (pwp->root_phys + pptr->phynum)->sas_address));
 		}
 
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "PortID 0x%x: PHY 0x%x LINK DOWN (port invalid)",
 		    portid, phynum);
 
@@ -803,7 +807,7 @@
 
 		break;
 	case IOP_EVENT_BROADCAST_CHANGE:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 		    "PortID 0x%x: PHY 0x%x Broadcast Change", portid, phynum);
 		need_ack = 1;
 		mutex_enter(&pwp->lock);
@@ -846,7 +850,7 @@
 		EVT_PRT(pwp, IOP_EVENT_EVENT_ID_FRAME_TIMO, phynum);
 		break;
 	case IOP_EVENT_BROADCAST_EXP:
-		pmcs_prt(pwp, PMCS_PRT_INFO,
+		pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
 		    "PortID 0x%x: PHY 0x%x Broadcast Exp Change",
 		    portid, phynum);
 		/*
@@ -867,24 +871,25 @@
 	case IOP_EVENT_PHY_START_STATUS:
 		switch (IOP_EVENT_STATUS(w1)) {
 		case IOP_PHY_START_OK:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "PHY 0x%x Started",
-			    phynum);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
+			    "PHY 0x%x Started", phynum);
 			break;
 		case IOP_PHY_START_ALREADY:
-			pmcs_prt(pwp, PMCS_PRT_INFO,
+			pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
 			    "PHY 0x%x Started (Already)", phynum);
 			break;
 		case IOP_PHY_START_INVALID:
-			pmcs_prt(pwp, PMCS_PRT_WARN,
+			pmcs_prt(pwp, PMCS_PRT_WARN, NULL, NULL,
 			    "PHY 0x%x failed to start (invalid phy)", phynum);
 			break;
 		case IOP_PHY_START_ERROR:
-			pmcs_prt(pwp, PMCS_PRT_WARN,
+			pmcs_prt(pwp, PMCS_PRT_WARN, NULL, NULL,
 			    "PHY 0x%x Start Error", phynum);
 			break;
 		default:
-			pmcs_prt(pwp, PMCS_PRT_WARN, "PHY 0x%x failed to start "
-			    "(0x%x)", phynum, IOP_EVENT_STATUS(w1));
+			pmcs_prt(pwp, PMCS_PRT_WARN, NULL, NULL,
+			    "PHY 0x%x failed to start (0x%x)", phynum,
+			    IOP_EVENT_STATUS(w1));
 			break;
 		}
 		/* Reposition htag to the 'expected' position. */
@@ -925,8 +930,8 @@
 		}
 		mutex_exit(&pwp->lock);
 		pmcs_kill_port(pwp, portid);
-		pmcs_prt(pwp, PMCS_PRT_INFO, "PortID 0x%x: PORT Now Invalid",
-		    portid);
+		pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
+		    "PortID 0x%x: PORT Now Invalid", portid);
 		break;
 	case IOP_EVENT_PORT_RESET_TIMER_TMO:
 		EVT_PRT(pwp, IOP_EVENT_PORT_RESET_TIMER_TMO, phynum);
@@ -996,6 +1001,7 @@
 	_NOTE(ARGUNUSED(amt));
 	uint32_t status, htag, *w;
 	pmcwork_t *pwrk;
+	pmcs_phy_t *phyp = NULL;
 	char *path;
 
 	w = iomb;
@@ -1007,6 +1013,7 @@
 	if (pwrk == NULL) {
 		path = "????";
 	} else {
+		phyp = pwrk->phy;
 		path = pwrk->phy->path;
 	}
 
@@ -1019,8 +1026,8 @@
 			    status);
 			emsg = buf;
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Bad SAS Status (tag 0x%x) "
-		    "%s on %s", __func__, htag, emsg, path);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, phyp, NULL, "%s: Bad SAS Status "
+		    "(tag 0x%x) %s on %s", __func__, htag, emsg, path);
 		if (pwrk != NULL) {
 			/*
 			 * There may be pending command on a target device.
@@ -1029,7 +1036,7 @@
 			pmcs_start_ssp_event_recovery(pwp, pwrk, iomb, amt);
 		}
 	} else {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG2, phyp, NULL,
 		    "%s: tag %x put onto the wire for %s",
 		    __func__, htag, path);
 		if (pwrk) {
@@ -1101,8 +1108,9 @@
 		} else {
 			pptr->abort_pending = 1;
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Bad SATA Status (tag 0x%x) "
-		    "%s on %s", __func__, htag, emsg, path);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
+		    "%s: Bad SATA Status (tag 0x%x) %s on %s",
+		    __func__, htag, emsg, path);
 		SCHEDULE_WORK(pwp, PMCS_WORK_ABORT_HANDLE);
 		/*
 		 * Unlike SSP devices, we let the abort we
@@ -1113,7 +1121,7 @@
 			mutex_exit(&pwrk->lock);
 		}
 	} else if (status == PMCOUT_STATUS_XFER_CMD_FRAME_ISSUED) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG2, pptr, NULL,
 		    "%s: tag %x put onto the wire for %s",
 		    __func__, htag, path);
 		if (pwrk) {
@@ -1132,7 +1140,6 @@
 {
 	pmcs_phy_t *pptr;
 	struct pmcwork *pwrk;
-	uint32_t rtag;
 	uint32_t htag = LE_32(((uint32_t *)iomb)[1]);
 	uint32_t status = LE_32(((uint32_t *)iomb)[2]);
 	uint32_t scp = LE_32(((uint32_t *)iomb)[3]) & 0x1;
@@ -1140,15 +1147,10 @@
 
 	pwrk = pmcs_tag2wp(pwp, htag);
 	if (pwrk == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: cannot find work structure for ABORT", __func__);
 		return;
 	}
-	if (pwrk->ptr) {
-		rtag = *((uint32_t *)pwrk->ptr);
-	} else {
-		rtag = 0;
-	}
 
 	pptr = pwrk->phy;
 	if (pptr) {
@@ -1173,24 +1175,24 @@
 	switch (status) {
 	case PMCOUT_STATUS_OK:
 		if (scp) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "%s: abort all succeeded for %s. (htag=0x%x)",
 			    __func__, path, htag);
 		} else {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "%s: abort tag 0x%x succeeded for %s. (htag=0x%x)",
-			    __func__, rtag, path, htag);
+			    __func__, pwrk->abt_htag, path, htag);
 		}
 		break;
 
 	case PMCOUT_STATUS_IO_NOT_VALID:
 		if (scp) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "%s: ABORT %s failed (DEV NOT VALID) for %s. "
 			    "(htag=0x%x)", __func__, scp ? "all" : "tag",
 			    path, htag);
 		} else {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "%s: ABORT %s failed (I/O NOT VALID) for %s. "
 			    "(htag=0x%x)", __func__, scp ? "all" : "tag",
 			    path, htag);
@@ -1198,14 +1200,14 @@
 		break;
 
 	case PMCOUT_STATUS_IO_ABORT_IN_PROGRESS:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: ABORT %s failed for "
-		    "%s, htag 0x%x (ABORT IN PROGRESS)", __func__,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL, "%s: ABORT %s failed "
+		    "for %s, htag 0x%x (ABORT IN PROGRESS)", __func__,
 		    scp ? "all" : "tag", path, htag);
 		break;
 
 	default:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Unknown status %d for ABORT"
-		    " %s, htag 0x%x, PHY %s", __func__, status,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL, "%s: Unknown status "
+		    "%d for ABORT %s, htag 0x%x, PHY %s", __func__, status,
 		    scp ? "all" : "tag", htag, path);
 		break;
 	}
@@ -1298,7 +1300,7 @@
 			break;
 		case PMCOUT_SAS_HW_EVENT_ACK_ACK:
 			if (LE_32(ptr[2]) != SAS_HW_EVENT_ACK_OK) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 				    "SAS H/W EVENT ACK/ACK Status=0x%b",
 				    LE_32(ptr[2]), "\020\4InvParm\3"
 				    "InvPort\2InvPhy\1InvSEA");
@@ -1306,8 +1308,8 @@
 			pmcs_process_completion(pwp, local, amt);
 			break;
 		case PMCOUT_SKIP_ENTRIES:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG3, "%s: skip %d entries",
-			    __func__, nbuf);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG3, NULL, NULL,
+			    "%s: skip %d entries", __func__, nbuf);
 			break;
 		default:
 			(void) snprintf(local, sizeof (local),
@@ -1485,8 +1487,8 @@
 			ioccb =
 			    kmem_cache_alloc(pwp->iocomp_cb_cache, KM_NOSLEEP);
 			if (ioccb == NULL) {
-				pmcs_prt(pwp, PMCS_PRT_WARN, "%s: "
-				    "kmem_cache_alloc failed", __func__);
+				pmcs_prt(pwp, PMCS_PRT_WARN, NULL, NULL,
+				    "%s: kmem_cache_alloc failed", __func__);
 				break;
 			}
 
@@ -1510,7 +1512,7 @@
 				pmcs_process_ssp_event(pwp, local, amt);
 				break;
 			case PMCOUT_SKIP_ENTRIES:
-				pmcs_prt(pwp, PMCS_PRT_DEBUG3,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG3, NULL, NULL,
 				    "%s: skip %d entries", __func__, nbuf);
 				break;
 			default:
@@ -1594,13 +1596,13 @@
 		{
 			uint32_t port = IOP_EVENT_PORTID(LE_32(ptr[1]));
 			uint32_t did = LE_32(ptr[2]);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "PortID 0x%x device_id 0x%x removed", port, did);
 			break;
 		}
 		case PMCOUT_SAS_HW_EVENT:
 			if (nbuf > 1) {
-				pmcs_prt(pwp, PMCS_PRT_INFO,
+				pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
 				    "multiple SAS HW_EVENT (%d) responses "
 				    "in EVENT OQ", nbuf);
 			}
@@ -1614,8 +1616,8 @@
 			pmcs_process_completion(pwp, local, amt);
 			break;
 		case PMCOUT_SKIP_ENTRIES:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG3, "%s: skip %d entries",
-			    __func__, nbuf);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG3, NULL, NULL,
+			    "%s: skip %d entries", __func__, nbuf);
 			break;
 		default:
 			(void) snprintf(local, sizeof (local),
@@ -1639,7 +1641,7 @@
 
 	for (i = 0; i < 256; i++) {
 		if (pwp->ftags[i] == htag) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "Inbound msg (tag 0x%8x) timed out - "
 			    "was started %llu ns ago in %s:%d",
 			    htag, (unsigned long long) (now - pwp->ftime[i]),
@@ -1648,7 +1650,7 @@
 		}
 	}
 #endif
-	pmcs_prt(pwp, PMCS_PRT_DEBUG,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 	    "Inbound Message (tag 0x%08x) timed out- was started in %s",
 	    htag, func);
 }
--- a/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_nvram.c	Thu Nov 12 10:26:22 2009 +0800
+++ b/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_nvram.c	Wed Nov 11 19:33:15 2009 -0700
@@ -59,7 +59,7 @@
 	 * If updating is disabled, we're done.
 	 */
 	if (pwp->fw_disable_update) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "Firmware update disabled by conf file");
 		return (0);
 	}
@@ -72,17 +72,17 @@
 			return (0);
 		}
 
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "Firmware version matches, but still forcing update");
 	} else {
-		pmcs_prt(pwp, PMCS_PRT_WARN,
+		pmcs_prt(pwp, PMCS_PRT_WARN, NULL, NULL,
 		    "Upgrading firmware on card from 0x%x to 0x%x",
 		    pwp->fw, PMCS_FIRMWARE_VERSION);
 	}
 
 	modhp = ddi_modopen(PMCS_FIRMWARE_FILENAME, KRTLD_MODE_FIRST, &errno);
 	if (errno) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: Firmware module not available; will not upgrade",
 		    __func__);
 		return (defret);
@@ -90,7 +90,8 @@
 
 	fwvp = ddi_modsym(modhp, PMCS_FIRMWARE_VERSION_NAME, &errno);
 	if (errno) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: unable to find symbol '%s'",
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: unable to find symbol '%s'",
 		    __func__, PMCS_FIRMWARE_VERSION_NAME);
 		(void) ddi_modclose(modhp);
 		return (defret);
@@ -103,13 +104,13 @@
 	 */
 	if (*fwvp != PMCS_FIRMWARE_VERSION) {
 		if (pwp->fw_force_update == 0) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: firmware module version wrong (0x%x)",
 			    __func__, *fwvp);
 			(void) ddi_modclose(modhp);
 			return (defret);
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: firmware module version wrong (0x%x) - update forced",
 		    __func__, *fwvp);
 	}
@@ -118,8 +119,8 @@
 	    PMCS_FIRMWARE_CODE_NAME PMCS_FIRMWARE_START_SUF);
 	cstart = ddi_modsym(modhp, buf, &errno);
 	if (errno) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: unable to find symbol '%s'",
-		    __func__, buf);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: unable to find symbol '%s'", __func__, buf);
 		(void) ddi_modclose(modhp);
 		return (defret);
 	}
@@ -128,8 +129,8 @@
 	    PMCS_FIRMWARE_CODE_NAME PMCS_FIRMWARE_END_SUF);
 	cend = ddi_modsym(modhp, buf, &errno);
 	if (errno) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: unable to find symbol '%s'",
-		    __func__, buf);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: unable to find symbol '%s'", __func__, buf);
 		(void) ddi_modclose(modhp);
 		return (defret);
 	}
@@ -138,8 +139,8 @@
 	    PMCS_FIRMWARE_ILA_NAME PMCS_FIRMWARE_START_SUF);
 	istart = ddi_modsym(modhp, buf, &errno);
 	if (errno) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: unable to find symbol '%s'",
-		    __func__, buf);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: unable to find symbol '%s'", __func__, buf);
 		(void) ddi_modclose(modhp);
 		return (defret);
 	}
@@ -148,8 +149,8 @@
 	    PMCS_FIRMWARE_ILA_NAME PMCS_FIRMWARE_END_SUF);
 	iend = ddi_modsym(modhp, buf, &errno);
 	if (errno) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: unable to find symbol '%s'",
-		    __func__, buf);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: unable to find symbol '%s'", __func__, buf);
 		(void) ddi_modclose(modhp);
 		return (defret);
 	}
@@ -158,8 +159,8 @@
 	    PMCS_FIRMWARE_SPCBOOT_NAME PMCS_FIRMWARE_START_SUF);
 	sstart = ddi_modsym(modhp, buf, &errno);
 	if (errno) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: unable to find symbol '%s'",
-		    __func__, buf);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: unable to find symbol '%s'", __func__, buf);
 		(void) ddi_modclose(modhp);
 		return (defret);
 	}
@@ -168,8 +169,8 @@
 	    PMCS_FIRMWARE_SPCBOOT_NAME PMCS_FIRMWARE_END_SUF);
 	send = ddi_modsym(modhp, buf, &errno);
 	if (errno) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: unable to find symbol '%s'",
-		    __func__, buf);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: unable to find symbol '%s'", __func__, buf);
 		(void) ddi_modclose(modhp);
 		return (defret);
 	}
@@ -180,7 +181,7 @@
 	 */
 	if (pmcs_set_nvmd(pwp, PMCS_NVMD_SPCBOOT, sstart,
 	    (size_t)((size_t)send - (size_t)sstart)) == B_FALSE) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: unable to flash '%s' segment",
 		    __func__, PMCS_FIRMWARE_SPCBOOT_NAME);
 		(void) ddi_modclose(modhp);
@@ -189,7 +190,7 @@
 
 	if (pmcs_fw_flash(pwp, (void *)istart,
 	    (uint32_t)((size_t)iend - (size_t)istart))) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: unable to flash '%s' segment",
 		    __func__, PMCS_FIRMWARE_ILA_NAME);
 		(void) ddi_modclose(modhp);
@@ -198,7 +199,7 @@
 
 	if (pmcs_fw_flash(pwp, (void *)cstart,
 	    (uint32_t)((size_t)cend - (size_t)cstart))) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: unable to flash '%s' segment",
 		    __func__, PMCS_FIRMWARE_CODE_NAME);
 		(void) ddi_modclose(modhp);
@@ -208,11 +209,11 @@
 	(void) ddi_modclose(modhp);
 
 	if (pmcs_soft_reset(pwp, B_FALSE)) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: soft reset after flash update failed", __func__);
 		return (-1);
 	} else {
-		pmcs_prt(pwp, PMCS_PRT_WARN,
+		pmcs_prt(pwp, PMCS_PRT_WARN, NULL, NULL,
 		    "%s: Firmware successfully upgraded.", __func__);
 	}
 	return (0);
@@ -235,11 +236,11 @@
 	wrk = (uint8_t *)hdr;
 	base = wrk;
 	for (;;) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG1,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG1, NULL, NULL,
 		    "%s: partition 0x%x, Length 0x%x", __func__,
 		    hp->destination_partition, ntohl(hp->firmware_length));
 		if (ntohl(hp->firmware_length) == 0) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: bad firmware length 0x%x",
 			    __func__, ntohl(hp->firmware_length));
 			return (EINVAL);
@@ -249,7 +250,7 @@
 			break;
 		}
 		if (wrk > base + length) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: out of bounds firmware length", __func__);
 			return (EINVAL);
 		}
@@ -299,7 +300,7 @@
 		if (off + amt > len) {
 			amt = len - off;
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG1,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG1, NULL, NULL,
 		    "%s: segment %d offset %u length %u",
 		    __func__, seg, off, amt);
 		(void) memcpy(pwp->scratch, &chunk[off], amt);
@@ -334,7 +335,8 @@
 		if (ptr == NULL) {
 			mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 			pmcs_pwork(pwp, pwrk);
-			pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nomsg, __func__);
+			pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL,
+			    pmcs_nomsg, __func__);
 			return (ENOMEM);
 		}
 		COPY_MESSAGE(ptr, msg, PMCS_MSG_SIZE);
@@ -344,51 +346,52 @@
 		WAIT_FOR(pwrk, 5000, result);
 		pmcs_pwork(pwp, pwrk);
 		if (result) {
-			pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_timeo, __func__);
+			pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL,
+			    pmcs_timeo, __func__);
 			return (EIO);
 		}
 		switch (LE_32(msg[2])) {
 		case FLASH_UPDATE_COMPLETE_PENDING_REBOOT:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG1,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG1, NULL, NULL,
 			    "%s: segment %d complete pending reboot",
 			    __func__, seg);
 			break;
 		case FLASH_UPDATE_IN_PROGRESS:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG1,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG1, NULL, NULL,
 			    "%s: segment %d downloaded", __func__, seg);
 			break;
 		case FLASH_UPDATE_HDR_ERR:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: segment %d header error", __func__, seg);
 			return (EIO);
 		case FLASH_UPDATE_OFFSET_ERR:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: segment %d offset error", __func__, seg);
 			return (EIO);
 		case FLASH_UPDATE_UPDATE_CRC_ERR:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: segment %d update crc error", __func__, seg);
 			return (EIO);
 		case FLASH_UPDATE_LENGTH_ERR:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: segment %d length error", __func__, seg);
 			return (EIO);
 		case FLASH_UPDATE_HW_ERR:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: segment %d hw error", __func__, seg);
 			return (EIO);
 		case FLASH_UPDATE_DNLD_NOT_SUPPORTED:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: segment %d download not supported error",
 			    __func__, seg);
 			return (EIO);
 		case FLASH_UPDATE_DISABLED:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: segment %d update disabled error",
 			    __func__, seg);
 			return (EIO);
 		default:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: segment %d unknown error %x",
 			    __func__, seg, msg[2]);
 			return (EIO);
@@ -424,14 +427,14 @@
 	 */
 
 	if (vpd_header->eeprom_version < PMCS_VPD_VERSION) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: VPD version(%d) out-of-date; (%d) required."
 		    " Thebe card needs to be flashed.",
 		    __func__, vpd_header->eeprom_version, PMCS_VPD_VERSION);
 	}
 	if ((vpd_header->eeprom_version != PMCS_VPD_VERSION) &&
 	    (vpd_header->eeprom_version != (PMCS_VPD_VERSION - 1))) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: VPD version mismatch (%d != %d)",
 		    __func__, vpd_header->eeprom_version, PMCS_VPD_VERSION);
 		return (B_FALSE);
@@ -441,7 +444,7 @@
 	 * Do we have a valid SAS WWID?
 	 */
 	if (((vpd_header->hba_sas_wwid[0] & 0xf0) >> 4) != NAA_IEEE_REG) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: SAS WWN has invalid NAA (%d)", __func__,
 		    ((vpd_header->hba_sas_wwid[0] & 0xf0) >> 4));
 		return (B_FALSE);
@@ -452,7 +455,7 @@
 	}
 
 	if (vpd_header->vpd_start_byte != PMCS_VPD_START) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: Didn't see VPD start byte", __func__);
 		return (B_FALSE);
 	}
@@ -478,8 +481,8 @@
 	}
 	ASSERT (*chksump == PMCS_VPD_END);
 	if (chksum) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: VPD checksum(%d) non-zero."
-		    " Checksum validation failed.", __func__, chksum);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL, "%s: VPD checksum(%d)"
+		    " non-zero. Checksum validation failed.", __func__, chksum);
 	}
 
 	/*
@@ -500,7 +503,7 @@
 	bcopy(bufp, tbuf, strid_length);
 	tbuf[strid_length] = 0;
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL,
 	    "%s: Product Name: '%s'", __func__, tbuf);
 	pmcs_smhba_add_hba_prop(pwp, DATA_TYPE_STRING, PMCS_MODEL_NAME, tbuf);
 
@@ -527,7 +530,8 @@
 		str_len += kv_len;
 		tbuf[str_len] = '>';
 		tbuf[str_len + 1] = 0;
-		pmcs_prt(pwp, PMCS_PRT_DEBUG2, "%s (Len: 0x%x)", tbuf, kv_len);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "%s (Len: 0x%x)",
+		    tbuf, kv_len);
 
 		/* Keyword is Manufacturer */
 		if ((vkvp->keyword[0] == 'M') && (vkvp->keyword[1] == 'N')) {
@@ -611,14 +615,14 @@
 		doa[2] = (offset >> 16) & 0xff;
 		break;
 	default:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: Invalid nvmd type: %d", __func__, nvmd_type);
 		return (-1);
 	}
 
 	workp = pmcs_gwork(pwp, PMCS_TAG_TYPE_WAIT, NULL);
 	if (workp == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_WARN,
+		pmcs_prt(pwp, PMCS_PRT_WARN, NULL, NULL,
 		    "%s: Unable to get work struct", __func__);
 		return (-1);
 	}
@@ -644,8 +648,8 @@
 	 */
 	GET_IO_IQ_ENTRY(pwp, ptr, 0, ibq);
 	if (ptr == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, "!%s: Unable to get IQ entry",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL,
+		    "!%s: Unable to get IQ entry", __func__);
 		pmcs_pwork(pwp, workp);
 		return (-1);
 	}
@@ -665,8 +669,8 @@
 	}
 	status = LE_32(*(ptr + 3)) & 0xffff;
 	if (status != PMCS_NVMD_STAT_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Error, status = 0x%04x",
-		    __func__, status);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: Error, status = 0x%04x", __func__, status);
 		pmcs_pwork(pwp, workp);
 		return (-1);
 	}
@@ -675,8 +679,8 @@
 
 	if (ddi_dma_sync(pwp->cip_handles, 0, 0,
 	    DDI_DMA_SYNC_FORKERNEL) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "Condition check failed at "
-		    "%s():%d", __func__, __LINE__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "Condition check failed at %s():%d", __func__, __LINE__);
 	}
 	chunkp = (uint8_t *)pwp->flash_chunkp;
 
@@ -706,7 +710,8 @@
 		result = i;
 		break;
 	default:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "UNKNOWN NVMD DEVICE");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "UNKNOWN NVMD DEVICE");
 		return (-1);
 	}
 
@@ -748,17 +753,17 @@
 		dlen = LE_32(len);
 		break;
 	default:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: Invalid nvmd type: %d", __func__, nvmd_type);
 		return (B_FALSE);
 	}
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_DEVEL, "%s: Request for nvmd type: %d",
-	    __func__, nvmd_type);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_DEVEL, NULL, NULL,
+	    "%s: Request for nvmd type: %d", __func__, nvmd_type);
 
 	workp = pmcs_gwork(pwp, PMCS_TAG_TYPE_WAIT, NULL);
 	if (workp == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_WARN,
+		pmcs_prt(pwp, PMCS_PRT_WARN, NULL, NULL,
 		    "%s: Unable to get work struct", __func__);
 		return (B_FALSE);
 	}
@@ -781,8 +786,8 @@
 	bcopy(buf, pwp->flash_chunkp, len);
 	if (ddi_dma_sync(pwp->cip_handles, 0, 0,
 	    DDI_DMA_SYNC_FORDEV) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "Condition check failed at "
-		    "%s():%d", __func__, __LINE__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "Condition check failed at %s():%d", __func__, __LINE__);
 	}
 
 	/*
@@ -790,8 +795,8 @@
 	 */
 	GET_IO_IQ_ENTRY(pwp, ptr, 0, ibq);
 	if (ptr == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, "!%s: Unable to get IQ entry",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL,
+		    "!%s: Unable to get IQ entry", __func__);
 		pmcs_pwork(pwp, workp);
 		return (B_FALSE);
 	}
@@ -814,8 +819,8 @@
 
 	status = LE_32(*(ptr + 3)) & 0xffff;
 	if (status != PMCS_NVMD_STAT_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Error, status = 0x%04x",
-		    __func__, status);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: Error, status = 0x%04x", __func__, status);
 		return (B_FALSE);
 	}
 
--- a/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_sata.c	Thu Nov 12 10:26:22 2009 +0800
+++ b/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_sata.c	Wed Nov 11 19:33:15 2009 -0700
@@ -71,12 +71,13 @@
 	uint8_t status = STATUS_GOOD;
 
 	if (xp->actv_cnt) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG1, "%s: target %p actv count %u",
+		pmcs_prt(pwp, PMCS_PRT_DEBUG1, NULL, xp,
+		    "%s: target %p actv count %u",
 		    __func__, (void *)xp, xp->actv_cnt);
 		return (-1);
 	}
 	if (xp->special_running) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, xp,
 		    "%s: target %p special running already",
 		    __func__, (void *)xp);
 		return (-1);
@@ -96,7 +97,7 @@
 	}
 
 	pkt = CMD2PKT(sp);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, pptr, xp,
 	    "%s: target %p cmd %p cdb0 %x with actv_cnt %u",
 	    __func__, (void *)xp, (void *)sp, pkt->pkt_cdbp[0], xp->actv_cnt);
 
@@ -118,7 +119,7 @@
 			pmcs_release_scratch(pwp);
 			xp->special_running = 0;
 
-			pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG2, pptr, xp,
 			    "%s: target %p identify failed %x",
 			    __func__, (void *)xp, retval);
 			/*
@@ -128,7 +129,7 @@
 			 * fail current command.
 			 */
 			if (retval == ENOMEM) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 				    "%s: sata identify failed (ENOMEM) for "
 				    "cmd %p", __func__, (void *)sp);
 				return (-1);
@@ -167,7 +168,7 @@
 			    (LE_16(id->word76) & (1 << 8))) {
 				xp->ncq = 1;
 				xp->qdepth = (LE_16(id->word75) & 0x1f) + 1;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, xp,
 				    "%s: device %s supports NCQ %u deep",
 				    __func__, xp->phy->path, xp->qdepth);
 			} else {
@@ -179,7 +180,7 @@
 				 * not NCQ it's safest to assume PIO.
 				 */
 				xp->pio = 1;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, xp,
 				    "%s: device %s assumed PIO",
 				    __func__, xp->phy->path);
 			}
@@ -322,8 +323,8 @@
 			if (xp->actv_cnt) {
 				xp->special_needed = 1;
 				xp->special_running = 0;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: @ line %d",
-				    __func__, __LINE__);
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
+				    "%s: @ line %d", __func__, __LINE__);
 				if (saq) {
 					pmcs_release_scratch(pwp);
 				}
@@ -375,8 +376,8 @@
 			if (xp->actv_cnt) {
 				xp->special_needed = 1;
 				xp->special_running = 0;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: @ line %d",
-				    __func__, __LINE__);
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
+				    "%s: @ line %d", __func__, __LINE__);
 				if (saq) {
 					pmcs_release_scratch(pwp);
 				}
@@ -407,8 +408,8 @@
 			if (xp->actv_cnt) {
 				xp->special_needed = 1;
 				xp->special_running = 0;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: @ line %d",
-				    __func__, __LINE__);
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
+				    "%s: @ line %d", __func__, __LINE__);
 				if (saq) {
 					pmcs_release_scratch(pwp);
 				}
@@ -434,8 +435,8 @@
 			if (xp->actv_cnt) {
 				xp->special_needed = 1;
 				xp->special_running = 0;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: @ line %d",
-				    __func__, __LINE__);
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
+				    "%s: @ line %d", __func__, __LINE__);
 				if (saq) {
 					pmcs_release_scratch(pwp);
 				}
@@ -496,7 +497,7 @@
 
 out:
 	STAILQ_REMOVE_HEAD(&xp->sq, cmd_next);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, pptr, xp,
 	    "%s: pkt %p tgt %u done reason=%x state=%x resid=%ld status=%x",
 	    __func__, (void *)pkt, xp->target_num, pkt->pkt_reason,
 	    pkt->pkt_state, pkt->pkt_resid, status);
@@ -506,7 +507,7 @@
 	}
 
 	if (xp->draining) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: waking up drain waiters", __func__);
 		cv_signal(&pwp->drain_cv);
 	}
@@ -573,7 +574,7 @@
 		}
 		if (xp->actv_cnt) {
 			xp->special_needed = 1;
-			pmcs_prt(pwp, PMCS_PRT_DEBUG1,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG1, NULL, xp,
 			    "%s: deferring until drained", __func__);
 			spinagain++;
 		} else {
@@ -643,8 +644,9 @@
 		if (ddir == PMCIN_DATADIR_2_DEV) {
 			if (ddi_dma_sync(pwp->cip_handles, 0, 0,
 			    DDI_DMA_SYNC_FORDEV) != DDI_SUCCESS) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG, "Condition check "
-				    "failed at %s():%d", __func__, __LINE__);
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
+				    "Condition check failed at %s():%d",
+				    __func__, __LINE__);
 			}
 		}
 		msg[12] = LE_32(DWORD0(pwp->scratch_dma));
@@ -701,8 +703,9 @@
 	if (dlen && ddir == PMCIN_DATADIR_2_INI) {
 		if (ddi_dma_sync(pwp->cip_handles, 0, 0,
 		    DDI_DMA_SYNC_FORKERNEL) != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "Condition check "
-			    "failed at %s():%d", __func__, __LINE__);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
+			    "Condition check failed at %s():%d",
+			    __func__, __LINE__);
 		}
 	}
 	return (0);
--- a/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_scsa.c	Thu Nov 12 10:26:22 2009 +0800
+++ b/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_scsa.c	Wed Nov 11 19:33:15 2009 -0700
@@ -85,7 +85,8 @@
 	 */
 	tran = scsi_hba_tran_alloc(pwp->dip, SCSI_HBA_CANSLEEP);
 	if (tran == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "scsi_hba_tran_alloc failed");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "scsi_hba_tran_alloc failed");
 		return (DDI_FAILURE);
 	}
 
@@ -114,7 +115,8 @@
 
 	if (scsi_hba_attach_setup(pwp->dip, &pmcs_scsa_dattr, tran, flags)) {
 		scsi_hba_tran_free(tran);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "scsi_hba_attach failed");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "scsi_hba_attach failed");
 		return (DDI_FAILURE);
 	}
 	pwp->tran = tran;
@@ -131,7 +133,8 @@
 	pwp->smp_tran->tran_smp_free = pmcs_smp_free;
 
 	if (sas_hba_attach_setup(pwp->dip, pwp->smp_tran) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "sas_hba_attach failed");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "sas_hba_attach failed");
 		sas_hba_tran_free(pwp->smp_tran);
 		pwp->smp_tran = NULL;
 		scsi_hba_tran_free(tran);
@@ -165,7 +168,7 @@
 	 * node's softstate
 	 */
 	if (scsi_hba_iport_unit_address(hba_dip) == NULL) {
-		pmcs_prt(TRAN2PMC(tran), PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(TRAN2PMC(tran), PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 		    "%s: We don't enumerate devices on the HBA node", __func__);
 		goto tgt_init_fail;
 	}
@@ -179,17 +182,19 @@
 	rval = scsi_device_prop_lookup_string(sd, SCSI_DEVICE_PROP_PATH,
 	    SCSI_ADDR_PROP_TARGET_PORT, &tgt_port);
 	if (rval != DDI_PROP_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "Couldn't get target UA");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
+		    "Couldn't get target UA");
 		pwp = NULL;
 		goto tgt_init_fail;
 	}
-	pmcs_prt(pwp, PMCS_PRT_DEBUG3, "got tgt_port '%s'", tgt_port);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG3, NULL, NULL,
+	    "got tgt_port '%s'", tgt_port);
 
 	/*
 	 * Validate that this tran_tgt_init is for an active iport.
 	 */
 	if (iport->ua_state == UA_INACTIVE) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: Got tran_tgt_init on inactive iport for '%s'",
 		    __func__, tgt_port);
 		pwp = NULL;
@@ -220,7 +225,7 @@
 	}
 	ASSERT(mutex_owned(&phyp->phy_lock));
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "tgt = 0x%p, dip = 0x%p",
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, phyp, tgt, "tgt = 0x%p, dip = 0x%p",
 	    (void *)tgt, (void *)tgt_dip);
 
 	/*
@@ -228,34 +233,34 @@
 	 */
 	ua = scsi_device_unit_address(sd);
 	if (ua == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, tgt,
 		    "Couldn't get LU unit address");
 		goto tgt_init_fail;
 	}
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "got lun ua '%s'", ua);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, tgt, "got lun ua '%s'", ua);
 
 	lun_num = scsi_device_prop_get_int64(sd, SCSI_DEVICE_PROP_PATH,
 	    SCSI_ADDR_PROP_LUN64, SCSI_LUN64_ILLEGAL);
 	if (lun_num == SCSI_LUN64_ILLEGAL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "No LUN for tgt %p",
-		    (void *)tgt);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, tgt,
+		    "No LUN for tgt %p", (void *)tgt);
 		goto tgt_init_fail;
 	}
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: @%s tgt 0x%p phy 0x%p (%s)",
-	    __func__, ua, (void *)tgt, (void *)phyp, phyp->path);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, tgt, "%s: @%s tgt 0x%p phy "
+	    "0x%p (%s)", __func__, ua, (void *)tgt, (void *)phyp, phyp->path);
 
 	mutex_enter(&tgt->statlock);
 	tgt->dtype = phyp->dtype;
 	if (tgt->dtype != SAS && tgt->dtype != SATA) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "PHY 0x%p went away?",
-		    (void *)phyp);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, tgt,
+		    "PHY 0x%p went away?", (void *)phyp);
 		goto tgt_init_fail;
 	}
 
 	/* We don't support SATA devices at LUN > 0. */
 	if ((tgt->dtype == SATA) && (lun_num > 0)) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, tgt,
 		    "%s: No support for SATA devices at LUN > 0 "
 		    "(target = 0x%p)", __func__, (void *)tgt);
 		goto tgt_init_fail;
@@ -268,14 +273,15 @@
 	 * structures with the same unit-address at the same time.
 	 */
 	if (ddi_soft_state_bystr_zalloc(tgt->lun_sstate, ua) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG2, phyp, tgt,
 		    "Couldn't allocate LU soft state");
 		goto tgt_init_fail;
 	}
 
 	lun = ddi_soft_state_bystr_get(tgt->lun_sstate, ua);
 	if (lun == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG2, "Couldn't get LU soft state");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG2, phyp, tgt,
+		    "Couldn't get LU soft state");
 		goto tgt_init_fail;
 	}
 	scsi_device_hba_private_set(sd, lun);
@@ -305,7 +311,7 @@
 		}
 
 		if (target == pwp->max_dev) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, tgt,
 			    "Target list full.");
 			goto tgt_init_fail;
 		}
@@ -318,7 +324,7 @@
 		pwp->targets[tgt->target_num] = NULL;
 		tgt->target_num = PMCS_INVALID_TARGET_NUM;
 		tgt->phy = NULL;
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, tgt,
 		    "%s: pmcs_assign_device failed for target 0x%p",
 		    __func__, (void *)tgt);
 		goto tgt_init_fail;
@@ -397,7 +403,7 @@
 
 	if (scsi_hba_iport_unit_address(hba_dip) == NULL) {
 		pwp = TRAN2PMC(tran);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 		    "%s: We don't enumerate devices on the HBA node", __func__);
 		return;
 	}
@@ -434,7 +440,7 @@
 		 * with the hardware unless/until we're told the device
 		 * physically went away.
 		 */
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, target,
 		    "%s: Free target 0x%p (vtgt %d)", __func__, (void *)target,
 		    target->target_num);
 		pwp->targets[target->target_num] = NULL;
@@ -463,13 +469,14 @@
 	boolean_t blocked;
 	uint32_t hba_state;
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "%s: pkt %p sd %p cdb0=0x%02x dl=%lu",
-	    __func__, (void *)pkt,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL,
+	    "%s: pkt %p sd %p cdb0=0x%02x dl=%lu", __func__, (void *)pkt,
 	    (void *)scsi_address_device(&pkt->pkt_address),
 	    pkt->pkt_cdbp[0] & 0xff, pkt->pkt_dma_len);
 
 	if (pkt->pkt_flags & FLAG_NOINTR) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG3, "%s: nointr pkt", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG3, NULL, NULL,
+		    "%s: nointr pkt", __func__);
 		return (TRAN_BADPKT);
 	}
 
@@ -483,13 +490,14 @@
 	mutex_exit(&pwp->lock);
 
 	if (hba_state != STATE_RUNNING) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: hba dead", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: hba dead", __func__);
 		return (TRAN_FATAL_ERROR);
 	}
 
 	xp = pmcs_addr2xp(ap, NULL, sp);
 	if (xp == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL,
 		    "%s: dropping due to null target", __func__);
 		goto dead_target;
 	}
@@ -500,7 +508,7 @@
 	 */
 	if (xp->dev_gone) {
 		mutex_exit(&xp->statlock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG3,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG3, NULL, xp,
 		    "%s: dropping due to dead target 0x%p",
 		    __func__, (void *)xp);
 		goto dead_target;
@@ -510,7 +518,8 @@
 	 * If we're blocked (quiesced) just return.
 	 */
 	if (blocked) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: hba blocked", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: hba blocked", __func__);
 		mutex_exit(&xp->statlock);
 		mutex_enter(&xp->wqlock);
 		STAILQ_INSERT_TAIL(&xp->wq, sp, cmd_next);
@@ -526,7 +535,7 @@
 		mutex_enter(&xp->wqlock);
 		STAILQ_INSERT_TAIL(&xp->wq, sp, cmd_next);
 		mutex_exit(&xp->wqlock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG1,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG1, NULL, xp,
 		    "%s: draining/resetting/recovering (cnt %u)",
 		    __func__, xp->actv_cnt);
 		/*
@@ -580,7 +589,8 @@
 	mutex_enter(&pwp->lock);
 	if (pwp->state != STATE_RUNNING) {
 		mutex_exit(&pwp->lock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: hba dead", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: hba dead", __func__);
 		return (0);
 	}
 	mutex_exit(&pwp->lock);
@@ -674,7 +684,8 @@
 	mutex_enter(&pwp->lock);
 	if (pwp->state != STATE_RUNNING) {
 		mutex_exit(&pwp->lock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: hba dead", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: hba dead", __func__);
 		return (0);
 	}
 	mutex_exit(&pwp->lock);
@@ -693,14 +704,14 @@
 	case RESET_TARGET:
 		xp = pmcs_addr2xp(ap, lp, NULL);
 		if (xp == NULL) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: no xp found for this scsi address", __func__);
 			return (0);
 		}
 
 		if (xp->dev_gone) {
 			mutex_exit(&xp->statlock);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, xp,
 			    "%s: Target 0x%p has gone away", __func__,
 			    (void *)xp);
 			return (0);
@@ -835,7 +846,7 @@
 		break;
 	}
 	mutex_exit(&xp->statlock);
-	pmcs_prt(ADDR2PMC(ap), PMCS_PRT_DEBUG3,
+	pmcs_prt(ADDR2PMC(ap), PMCS_PRT_DEBUG3, NULL, NULL,
 	    "%s: cap %s val %d set %d rval %d",
 	    __func__, cap, val, set, rval);
 	return (rval);
@@ -952,8 +963,8 @@
 
 	bcopy(pktp->pkt_address->a_wwn, &wwn, SAS_WWN_BYTE_SIZE);
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG1, "%s: starting for wwn 0x%" PRIx64,
-	    __func__, wwn);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG1, NULL, NULL,
+	    "%s: starting for wwn 0x%" PRIx64, __func__, wwn);
 
 	will_retry = pktp->pkt_will_retry;
 
@@ -983,8 +994,8 @@
 			pmcs_unlock_phy(pptr);
 		}
 		pmcs_release_scratch(pwp);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: could not find phy",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: could not find phy", __func__);
 		pktp->pkt_reason = ENXIO;
 		return (DDI_FAILURE);
 	}
@@ -993,7 +1004,7 @@
 	if (pwrk == NULL) {
 		pmcs_unlock_phy(pptr);
 		pmcs_release_scratch(pwp);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 		    "%s: could not get work structure", __func__);
 		pktp->pkt_reason = will_retry ? EAGAIN :EBUSY;
 		return (DDI_FAILURE);
@@ -1008,8 +1019,8 @@
 		mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 		pmcs_unlock_phy(pptr);
 		pmcs_release_scratch(pwp);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: could not get IQ entry",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: could not get IQ entry", __func__);
 		pktp->pkt_reason = will_retry ? EAGAIN :EBUSY;
 		return (DDI_FAILURE);
 	}
@@ -1039,11 +1050,11 @@
 	if (result) {
 		pmcs_timed_out(pwp, htag, __func__);
 		if (pmcs_abort(pwp, pptr, htag, 0, 0)) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 			    "%s: Unable to issue SMP ABORT for htag 0x%08x",
 			    __func__, htag);
 		} else {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 			    "%s: Issuing SMP ABORT for htag 0x%08x",
 			    __func__, htag);
 		}
@@ -1060,10 +1071,10 @@
 	if (status != PMCOUT_STATUS_OK) {
 		const char *emsg = pmcs_status_str(status);
 		if (emsg == NULL) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 			    "SMP operation failed (0x%x)", status);
 		} else {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 			    "SMP operation failed (%s)", emsg);
 		}
 
@@ -1083,7 +1094,7 @@
 			    PMCS_DEVICE_STATE_NON_OPERATIONAL) {
 				xp->dev_state =
 				    PMCS_DEVICE_STATE_NON_OPERATIONAL;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, xp,
 				    "%s: Got _IT_NEXUS_LOSS SMP status. "
 				    "Tgt(0x%p) dev_state set to "
 				    "_NON_OPERATIONAL", __func__,
@@ -1136,15 +1147,15 @@
 	ASSERT(pwp);
 	if (pwp == NULL)
 		return (DDI_FAILURE);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: %s", __func__,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL, "%s: %s", __func__,
 	    ddi_get_name(child));
 
 	/* Get "target-port" prop from devinfo node */
 	if (ddi_prop_lookup_string(DDI_DEV_T_ANY, child,
 	    DDI_PROP_DONTPASS | DDI_PROP_NOTPROM,
 	    SCSI_ADDR_PROP_TARGET_PORT, &tgt_port) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Failed to lookup prop ("
-		    SCSI_ADDR_PROP_TARGET_PORT")", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL, "%s: Failed to "
+		    "lookup prop ("SCSI_ADDR_PROP_TARGET_PORT")", __func__);
 		/* Dont fail _smp_init() because we couldnt get/set a prop */
 		return (DDI_SUCCESS);
 	}
@@ -1153,9 +1164,8 @@
 	 * Validate that this tran_tgt_init is for an active iport.
 	 */
 	if (iport->ua_state == UA_INACTIVE) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
-		    "%s: Init on inactive iport for '%s'",
-		    __func__, tgt_port);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: Init on inactive iport for '%s'", __func__, tgt_port);
 		ddi_prop_free(tgt_port);
 		return (DDI_FAILURE);
 	}
@@ -1165,8 +1175,8 @@
 	/* Retrieve softstate using unit-address */
 	tgt = pmcs_get_target(iport, tgt_port);
 	if (tgt == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: tgt softstate not found",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: tgt softstate not found", __func__);
 		ddi_prop_free(tgt_port);
 		mutex_exit(&pwp->lock);
 		return (DDI_FAILURE);
@@ -1213,7 +1223,7 @@
 		}
 
 		if (target == pwp->max_dev) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 			    "Target list full.");
 			goto smp_init_fail;
 		}
@@ -1221,7 +1231,7 @@
 
 	if (!pmcs_assign_device(pwp, tgt)) {
 		pwp->targets[tgt->target_num] = NULL;
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, tgt,
 		    "%s: pmcs_assign_device failed for target 0x%p",
 		    __func__, (void *)tgt);
 		goto smp_init_fail;
@@ -1237,8 +1247,8 @@
 	/* XXX: Update smp devinfo node using ndi_xxx */
 	if (ndi_prop_update_string(DDI_DEV_T_NONE, child,
 	    SCSI_ADDR_PROP_ATTACHED_PORT, addr) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Failed to set prop ("
-		    SCSI_ADDR_PROP_ATTACHED_PORT")", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL, "%s: Failed to set "
+		    "prop ("SCSI_ADDR_PROP_ATTACHED_PORT")", __func__);
 	}
 	(void) scsi_free_wwnstr(addr);
 	ddi_prop_free(tgt_port);
@@ -1278,15 +1288,15 @@
 	if (pwp == NULL)
 		return;
 	ASSERT(pwp);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: %s", __func__,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL, "%s: %s", __func__,
 	    ddi_get_name(child));
 
 	/* Get "target-port" prop from devinfo node */
 	if (ddi_prop_lookup_string(DDI_DEV_T_ANY, child,
 	    DDI_PROP_DONTPASS | DDI_PROP_NOTPROM,
 	    SCSI_ADDR_PROP_TARGET_PORT, &tgt_port) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Failed to lookup prop ("
-		    SCSI_ADDR_PROP_TARGET_PORT")", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL, "%s: Failed to "
+		    "lookup prop ("SCSI_ADDR_PROP_TARGET_PORT")", __func__);
 		return;
 	}
 	/* Retrieve softstate using unit-address */
@@ -1294,8 +1304,8 @@
 	ddi_prop_free(tgt_port);
 
 	if (tgt == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: tgt softstate not found",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: tgt softstate not found", __func__);
 		return;
 	}
 
@@ -1314,7 +1324,7 @@
 		 * with the hardware unless/until we're told that the
 		 * device physically went away.
 		 */
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, tgt,
 		    "Removing target 0x%p (vtgt %d) from target list",
 		    (void *)tgt, tgt->target_num);
 		pwp->targets[tgt->target_num] = NULL;
@@ -1348,7 +1358,7 @@
 		return (-1);
 	}
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s called", __func__);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL, "%s called", __func__);
 	pwp->blocked = 1;
 	while (totactive) {
 		totactive = 0;
@@ -1385,7 +1395,8 @@
 
 	mutex_exit(&pwp->lock);
 	if (totactive == 0) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s drain complete", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, xp,
+		    "%s drain complete", __func__);
 	}
 	return (0);
 }
@@ -1407,7 +1418,7 @@
 		mutex_exit(&pwp->lock);
 		return (-1);
 	}
-	pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s called", __func__);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL, "%s called", __func__);
 	pwp->blocked = 0;
 	mutex_exit(&pwp->lock);
 
@@ -1480,7 +1491,7 @@
 	 * Next, check to see if the target is gone.
 	 */
 	if (xp->dev_gone) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, xp,
 		    "%s: Flushing wait queue for dead tgt 0x%p", __func__,
 		    (void *)xp);
 		pmcs_flush_target_queues(pwp, xp, PMCS_TGT_WAIT_QUEUE);
@@ -1502,7 +1513,7 @@
 	while ((sp = STAILQ_FIRST(&xp->wq)) != NULL) {
 		pwrk = pmcs_gwork(pwp, PMCS_TAG_TYPE_CBACK, phyp);
 		if (pwrk == NULL) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: out of work structures", __func__);
 			SCHEDULE_WORK(pwp, PMCS_WORK_RUN_QUEUES);
 			break;
@@ -1672,7 +1683,7 @@
 		while (sp) {
 			nxt = STAILQ_NEXT(sp, cmd_next);
 			pkt = CMD2PKT(sp);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG3,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG3, NULL, sp->cmd_target,
 			    "%s: calling completion on %p for tgt %p", __func__,
 			    (void *)sp, (void *)sp->cmd_target);
 			scsi_hba_pkt_comp(pkt);
@@ -1729,7 +1740,7 @@
 		mutex_enter(&xp->wqlock);
 		STAILQ_INSERT_HEAD(&xp->wq, sp, cmd_next);
 		mutex_exit(&xp->wqlock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, xp,
 		    "%s: Failed to get IO IQ entry for tgt %d",
 		    __func__, xp->target_num);
 		return (PMCS_WQ_RUN_FAIL_RES);
@@ -1765,7 +1776,7 @@
 				mutex_enter(&pwp->cq_lock);
 				STAILQ_INSERT_TAIL(&pwp->cq, sp, cmd_next);
 				mutex_exit(&pwp->cq_lock);
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, xp,
 				    "%s: Failed to dma_load for tgt %d (QF)",
 				    __func__, xp->target_num);
 			}
@@ -1778,8 +1789,8 @@
 	xp->actv_cnt++;
 	if (xp->actv_cnt > xp->maxdepth) {
 		xp->maxdepth = xp->actv_cnt;
-		pmcs_prt(pwp, PMCS_PRT_DEBUG2, "%s: max depth now %u",
-		    pwrk->phy->path, xp->maxdepth);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG2, pwrk->phy, xp, "%s: max depth "
+		    "now %u", pwrk->phy->path, xp->maxdepth);
 	}
 	mutex_exit(&xp->statlock);
 
@@ -1815,7 +1826,7 @@
 	(void) memcpy(&ptr[5], &sc, sizeof (sas_ssp_cmd_iu_t));
 	pwrk->state = PMCS_WORK_STATE_ONCHIP;
 	mutex_exit(&pwrk->lock);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL,
 	    "%s: giving pkt %p (tag %x) to the hardware", __func__,
 	    (void *)pkt, pwrk->htag);
 #ifdef DEBUG
@@ -1875,8 +1886,8 @@
 	}
 
 	if (dead != 0) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: dead cmd tag 0x%x for %s",
-		    __func__, pwrk->htag, pptr->path);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp, "%s: dead cmd tag "
+		    "0x%x for %s", __func__, pwrk->htag, pptr->path);
 		goto out;
 	}
 
@@ -1885,7 +1896,7 @@
 	}
 
 	if (pwrk->state == PMCS_WORK_STATE_TIMED_OUT) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: cmd 0x%p (tag 0x%x) timed out for %s",
 		    __func__, (void *)sp, pwrk->htag, pptr->path);
 		goto out;
@@ -1908,14 +1919,14 @@
 	case PMCOUT_STATUS_OPEN_CNX_ERROR_IT_NEXUS_LOSS:
 	case PMCOUT_STATUS_IO_DS_NON_OPERATIONAL:
 	case PMCOUT_STATUS_IO_DS_IN_RECOVERY:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: PHY %s requires device state recovery (status=%d)",
 		    __func__, pptr->path, sts);
 		do_ds_recovery = B_TRUE;
 		break;
 	case PMCOUT_STATUS_UNDERFLOW:
 		(void) pmcs_set_resid(pkt, pkt->pkt_dma_len, LE_32(msg[3]));
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_UNDERFLOW,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_UNDERFLOW, NULL, NULL,
 		    "%s: underflow %u for cdb 0x%x",
 		    __func__, LE_32(msg[3]), pkt->pkt_cdbp[0] & 0xff);
 		sts = PMCOUT_STATUS_OK;
@@ -1966,13 +1977,13 @@
 				 * here is an INVALID FRAME response code.
 				 */
 				if (sts == SAS_RSP_INVALID_FRAME) {
-					pmcs_prt(pwp, PMCS_PRT_DEBUG,
+					pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 					    "%s: pkt %p tgt %u path %s "
 					    "completed: INVALID FRAME response",
 					    __func__, (void *)pkt,
 					    xp->target_num, pptr->path);
 				} else {
-					pmcs_prt(pwp, PMCS_PRT_DEBUG,
+					pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 					    "%s: pkt %p tgt %u path %s "
 					    "completed: illegal response 0x%x",
 					    __func__, (void *)pkt,
@@ -2009,13 +2020,13 @@
 			pkt->pkt_state |= STATE_XFERRED_DATA;
 		}
 	}
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, pptr, xp,
 	    "%s: pkt %p tgt %u done reason=%x state=%x resid=%ld status=%x",
 	    __func__, (void *)pkt, xp->target_num, pkt->pkt_reason,
 	    pkt->pkt_state, pkt->pkt_resid, pkt->pkt_scbp[0]);
 
 	if (pwrk->state == PMCS_WORK_STATE_ABORTED) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: scsi_pkt 0x%p aborted for PHY %s; work = 0x%p",
 		    __func__, (void *)pkt, pptr->path, (void *)pwrk);
 		aborted = B_TRUE;
@@ -2028,7 +2039,7 @@
 	mutex_enter(&xp->statlock);
 	if (xp->dev_gone) {
 		mutex_exit(&xp->statlock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG2, pptr, xp,
 		    "%s: Completing command for dead target 0x%p", __func__,
 		    (void *)xp);
 		return;
@@ -2037,7 +2048,7 @@
 	ASSERT(xp->actv_cnt > 0);
 	if (--(xp->actv_cnt) == 0) {
 		if (xp->draining) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG1,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG1, pptr, xp,
 			    "%s: waking up drain waiters", __func__);
 			cv_signal(&pwp->drain_cv);
 		}
@@ -2058,7 +2069,7 @@
 #endif
 		STAILQ_REMOVE(&xp->aq, sp, pmcs_cmd, cmd_next);
 		if (aborted) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 			    "%s: Aborted cmd for tgt 0x%p, signaling waiters",
 			    __func__, (void *)xp);
 			cv_signal(&xp->abort_cv);
@@ -2075,9 +2086,9 @@
 		mutex_enter(&xp->statlock);
 		pmcs_start_dev_state_recovery(xp, pptr);
 		mutex_exit(&xp->statlock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG1, "%s: Putting cmd 0x%p back on "
-		    "wq during recovery for tgt 0x%p", __func__, (void *)sp,
-		    (void *)xp);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG1, pptr, xp, "%s: Putting cmd 0x%p "
+		    "back on wq during recovery for tgt 0x%p", __func__,
+		    (void *)sp, (void *)xp);
 		mutex_enter(&xp->wqlock);
 		if (xp->wq_recovery_tail == NULL) {
 			STAILQ_INSERT_HEAD(&xp->wq, sp, cmd_next);
@@ -2135,8 +2146,8 @@
 	 */
 	cdb_base = pkt->pkt_cdbp[0] & 0x1f;
 	if (cdb_base != SCMD_READ && cdb_base != SCMD_WRITE) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG1, "%s: special SATA cmd %p",
-		    __func__, (void *)sp);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG1, NULL, NULL,
+		    "%s: special SATA cmd %p", __func__, (void *)sp);
 
 		ASSERT(xp->phy != NULL);
 		pmcs_pwork(pwp, pwrk);
@@ -2153,7 +2164,7 @@
 		return (PMCS_WQ_RUN_SUCCESS);
 	}
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "%s: regular cmd", __func__);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "%s: regular cmd", __func__);
 
 	mutex_enter(&xp->statlock);
 	if (!xp->assigned) {
@@ -2232,7 +2243,7 @@
 		mutex_exit(&xp->wqlock);
 		pmcs_dma_unload(pwp, sp);
 		SCHEDULE_WORK(pwp, PMCS_WORK_RUN_QUEUES);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, xp,
 		    "%s: Failed to get IO IQ entry for tgt %d",
 		    __func__, xp->target_num);
 		return (PMCS_WQ_RUN_FAIL_RES);
@@ -2326,7 +2337,7 @@
 		mutex_enter(&xp->wqlock);
 		STAILQ_INSERT_HEAD(&xp->wq, sp, cmd_next);
 		mutex_exit(&xp->wqlock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, xp,
 		    "%s: Failed to dma_load for tgt %d",
 		    __func__, xp->target_num);
 		return (PMCS_WQ_RUN_FAIL_RES);
@@ -2339,15 +2350,15 @@
 	xp->actv_cnt++;
 	if (xp->actv_cnt > xp->maxdepth) {
 		xp->maxdepth = xp->actv_cnt;
-		pmcs_prt(pwp, PMCS_PRT_DEBUG2, "%s: max depth now %u",
-		    pwrk->phy->path, xp->maxdepth);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG2, pwrk->phy, xp,
+		    "%s: max depth now %u", pwrk->phy->path, xp->maxdepth);
 	}
 	mutex_exit(&xp->statlock);
 	mutex_enter(&xp->aqlock);
 	STAILQ_INSERT_TAIL(&xp->aq, sp, cmd_next);
 	mutex_exit(&xp->aqlock);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "%s: giving pkt %p to hardware",
-	    __func__, (void *)pkt);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL,
+	    "%s: giving pkt %p to hardware", __func__, (void *)pkt);
 #ifdef DEBUG
 	pmcs_print_entry(pwp, PMCS_PRT_DEBUG3, "SATA INI Message", ptr);
 #endif
@@ -2386,13 +2397,13 @@
 	}
 
 	if (dead != 0) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: dead cmd tag 0x%x for %s",
-		    __func__, pwrk->htag, pptr->path);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp, "%s: dead cmd tag "
+		    "0x%x for %s", __func__, pwrk->htag, pptr->path);
 		goto out;
 	}
 	if ((pwrk->state == PMCS_WORK_STATE_TIMED_OUT) &&
 	    (sts != PMCOUT_STATUS_ABORTED)) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: cmd 0x%p (tag 0x%x) timed out for %s",
 		    __func__, (void *)sp, pwrk->htag, pptr->path);
 		CMD2PKT(sp)->pkt_scbp[0] = STATUS_GOOD;
@@ -2404,7 +2415,7 @@
 		goto out;
 	}
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "%s: pkt %p tgt %u done",
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, pptr, xp, "%s: pkt %p tgt %u done",
 	    __func__, (void *)pkt, xp->target_num);
 
 	/*
@@ -2434,10 +2445,10 @@
 				mutex_exit(&xp->statlock);
 				if (pmcs_reset_phy(pwp, pptr,
 				    PMCS_PHYOP_LINK_RESET) != 0) {
-					pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: PHY "
-					    "(%s) Local Control/Link Reset "
-					    "FAILED as part of error recovery",
-					    __func__, pptr->path);
+					pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
+					    "%s: PHY (%s) Local Control/Link "
+					    "Reset FAILED as part of error "
+					    "recovery", __func__, pptr->path);
 				}
 				mutex_enter(&xp->statlock);
 			}
@@ -2453,13 +2464,13 @@
 		pkt->pkt_resid = 0;
 	}
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, pptr, xp,
 	    "%s: pkt %p tgt %u done reason=%x state=%x resid=%ld status=%x",
 	    __func__, (void *)pkt, xp->target_num, pkt->pkt_reason,
 	    pkt->pkt_state, pkt->pkt_resid, pkt->pkt_scbp[0]);
 
 	if (pwrk->state == PMCS_WORK_STATE_ABORTED) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: scsi_pkt 0x%p aborted for PHY %s; work = 0x%p",
 		    __func__, (void *)pkt, pptr->path, (void *)pwrk);
 		aborted = B_TRUE;
@@ -2474,7 +2485,7 @@
 
 	if (xp->dev_gone) {
 		mutex_exit(&xp->statlock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG2, pptr, xp,
 		    "%s: Completing command for dead target 0x%p", __func__,
 		    (void *)xp);
 		return;
@@ -2483,7 +2494,7 @@
 	ASSERT(xp->actv_cnt > 0);
 	if (--(xp->actv_cnt) == 0) {
 		if (xp->draining) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG1,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG1, pptr, xp,
 			    "%s: waking up drain waiters", __func__);
 			cv_signal(&pwp->drain_cv);
 		} else if (xp->special_needed) {
@@ -2507,7 +2518,7 @@
 #endif
 		STAILQ_REMOVE(&xp->aq, sp, pmcs_cmd, cmd_next);
 		if (aborted) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 			    "%s: Aborted cmd for tgt 0x%p, signaling waiters",
 			    __func__, (void *)xp);
 			cv_signal(&xp->abort_cv);
@@ -2630,7 +2641,7 @@
 	}
 
 	if (status != PMCOUT_STATUS_OK) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG2, phyp, NULL,
 		    "%s: device %s tag 0x%x status %s @ %llu", __func__,
 		    phyp->path, pwrk->htag, msg,
 		    (unsigned long long)gethrtime());
@@ -2647,10 +2658,11 @@
 				fis[i] = LE_32(w[4+i]);
 			}
 			if ((fis[0] & 0xff) != FIS_REG_D2H) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, phyp, NULL,
 				    "unexpected fis code 0x%x", fis[0] & 0xff);
 			} else {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG, "FIS ERROR");
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, phyp, NULL,
+				    "FIS ERROR");
 				pmcs_fis_dump(pwp, fis);
 			}
 			pkt->pkt_reason = CMD_TRAN_ERR;
@@ -2814,8 +2826,8 @@
 		if (amt > snslen) {
 			amt = snslen;
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_SCSI_STATUS, c1, path, status,
-		    CMD2PKT(sp)->pkt_cdbp[0] & 0xff, key, asc, ascq,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_SCSI_STATUS, NULL, NULL, c1, path,
+		    status, CMD2PKT(sp)->pkt_cdbp[0] & 0xff, key, asc, ascq,
 		    sp->cmd_tag, (unsigned long long)gethrtime());
 		CMD2PKT(sp)->pkt_state |= STATE_ARQ_DONE;
 		(*(uint8_t *)&aqp->sts_rqpkt_status) = STATUS_GOOD;
@@ -2835,7 +2847,7 @@
 			    sizeof (struct scsi_extended_sense) - amt;
 		}
 	} else if (status) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_SCSI_STATUS, c2,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_SCSI_STATUS, NULL, NULL, c2,
 		    path, status, CMD2PKT(sp)->pkt_cdbp[0] & 0xff,
 		    sp->cmd_tag, (unsigned long long)gethrtime());
 	}
@@ -2880,8 +2892,8 @@
 	 */
 	phyp = pmcs_find_phy_by_sas_address(pwp, iport, NULL, tgt_port);
 	if (phyp == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG3, "%s: No PHY for target @ %s",
-		    __func__, tgt_port);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG3, NULL, NULL,
+		    "%s: No PHY for target @ %s", __func__, tgt_port);
 		return (NULL);
 	}
 
@@ -2893,7 +2905,7 @@
 		 * if we need to clear the old linkages
 		 */
 		if (tgt->phy && (tgt->phy != phyp)) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, tgt,
 			    "%s: Target PHY updated from %p to %p", __func__,
 			    (void *)tgt->phy, (void *)phyp);
 			if (!IS_ROOT_PHY(tgt->phy)) {
@@ -2912,7 +2924,7 @@
 	 * Make sure the PHY we found is on the correct iport
 	 */
 	if (phyp->iport != iport) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, phyp, NULL,
 		    "%s: No target at %s on this iport", __func__, tgt_port);
 		pmcs_unlock_phy(phyp);
 		return (NULL);
@@ -2926,7 +2938,7 @@
 
 	if (ddi_soft_state_bystr_zalloc(iport->tgt_sstate, unit_address) !=
 	    DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, tgt,
 		    "%s: Couldn't alloc softstate for device at %s",
 		    __func__, unit_address);
 		pmcs_unlock_phy(phyp);
@@ -2965,7 +2977,7 @@
 
 	if (ddi_soft_state_bystr_init(&tgt->lun_sstate,
 	    sizeof (pmcs_lun_t), PMCS_LUN_SSTATE_SZ) != 0) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, tgt,
 		    "%s: LUN soft_state_bystr_init failed", __func__);
 		ddi_soft_state_bystr_free(iport->tgt_sstate, tgt_port);
 		pmcs_unlock_phy(phyp);
--- a/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_smhba.c	Thu Nov 12 10:26:22 2009 +0800
+++ b/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_smhba.c	Wed Nov 11 19:33:15 2009 -0700
@@ -39,20 +39,21 @@
 	case DATA_TYPE_INT32:
 		if (ddi_prop_update_int(DDI_DEV_T_NONE, pwp->dip,
 		    prop_name, *(int *)prop_val)) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: %s prop update failed", __func__, prop_name);
 		}
 		break;
 	case DATA_TYPE_STRING:
 		if (ddi_prop_update_string(DDI_DEV_T_NONE, pwp->dip,
 		    prop_name, (char *)prop_val)) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: %s prop update failed", __func__, prop_name);
 		}
 		break;
 	default:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Unhandled datatype(%d) for "
-		    "(%s). Skipping prop update.", __func__, dt, prop_name);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL, "%s: "
+		    "Unhandled datatype(%d) for (%s). Skipping prop update.",
+		    __func__, dt, prop_name);
 	}
 }
 
@@ -67,20 +68,20 @@
 	case DATA_TYPE_INT32:
 		if (ddi_prop_update_int(DDI_DEV_T_NONE, iport->dip,
 		    prop_name, *(int *)prop_val)) {
-			pmcs_prt(iport->pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(iport->pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: %s prop update failed", __func__, prop_name);
 		}
 		break;
 	case DATA_TYPE_STRING:
 		if (ddi_prop_update_string(DDI_DEV_T_NONE, iport->dip,
 		    prop_name, (char *)prop_val)) {
-			pmcs_prt(iport->pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(iport->pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: %s prop update failed", __func__, prop_name);
 		}
 		break;
 	default:
-		pmcs_prt(iport->pwp, PMCS_PRT_DEBUG, "%s: Unhandled "
-		    "datatype(%d) for(%s). Skipping prop update.",
+		pmcs_prt(iport->pwp, PMCS_PRT_DEBUG, NULL, NULL, "%s: "
+		    "Unhandled datatype(%d) for(%s). Skipping prop update.",
 		    __func__, dt, prop_name);
 	}
 }
@@ -96,20 +97,21 @@
 	case DATA_TYPE_INT32:
 		if (ddi_prop_update_int(DDI_DEV_T_NONE, tgt->dip,
 		    prop_name, *(int *)prop_val)) {
-			pmcs_prt(tgt->pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(tgt->pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: %s prop update failed", __func__, prop_name);
 		}
 		break;
 	case DATA_TYPE_STRING:
 		if (ddi_prop_update_string(DDI_DEV_T_NONE, tgt->dip,
 		    prop_name, (char *)prop_val)) {
-			pmcs_prt(tgt->pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(tgt->pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: %s prop update failed", __func__, prop_name);
 		}
 		break;
 	default:
-		pmcs_prt(tgt->pwp, PMCS_PRT_DEBUG, "%s: Unhandled datatype(%d) "
-		    "for (%s). Skipping prop update.", __func__, dt, prop_name);
+		pmcs_prt(tgt->pwp, PMCS_PRT_DEBUG, NULL, NULL, "%s: "
+		    "Unhandled datatype(%d) for (%s). Skipping prop update.",
+		    __func__, dt, prop_name);
 	}
 }
 
@@ -162,8 +164,8 @@
 	}
 
 	if (nvlist_alloc(&nvl, NV_UNIQUE_NAME, 0) != 0) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: nvlist_alloc() failed",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: nvlist_alloc() failed", __func__);
 	}
 
 	phy_props = kmem_zalloc(sizeof (nvlist_t *) * iport->nphy, KM_SLEEP);
@@ -251,8 +253,8 @@
 	}
 
 	if (nvlist_alloc(&attr_list, NV_UNIQUE_NAME_TYPE, 0) != 0) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Failed to post sysevent",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: Failed to post sysevent", __func__);
 		kmem_free(pname, MAXPATHLEN);
 		return;
 	}
--- a/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_subr.c	Thu Nov 12 10:26:22 2009 +0800
+++ b/usr/src/uts/common/io/scsi/adapters/pmcs/pmcs_subr.c	Wed Nov 11 19:33:15 2009 -0700
@@ -94,7 +94,8 @@
 	 */
 	scratch = pmcs_rd_msgunit(pwp, PMCS_MSGU_SCRATCH1);
 	if ((scratch & PMCS_MSGU_AAP_STATE_MASK) == PMCS_MSGU_AAP_STATE_ERROR) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: AAP Error State (0x%x)",
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: AAP Error State (0x%x)",
 		    __func__, pmcs_rd_msgunit(pwp, PMCS_MSGU_SCRATCH1) &
 		    PMCS_MSGU_AAP_ERROR_MASK);
 		pmcs_fm_ereport(pwp, DDI_FM_DEVICE_INVAL_STATE);
@@ -102,7 +103,7 @@
 		return (-1);
 	}
 	if ((scratch & PMCS_MSGU_AAP_STATE_MASK) != PMCS_MSGU_AAP_STATE_READY) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: AAP unit not ready (state 0x%x)",
 		    __func__, scratch & PMCS_MSGU_AAP_STATE_MASK);
 		pmcs_fm_ereport(pwp, DDI_FM_DEVICE_INVAL_STATE);
@@ -125,27 +126,27 @@
 	regoff &= PMCS_MSGU_MPI_OFFSET_MASK;
 
 	if (regoff > baroff) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: bad MPI Table Length "
-		    "(register offset=0x%08x, passed offset=0x%08x)", __func__,
-		    regoff, baroff);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: bad MPI Table Length (register offset=0x%08x, "
+		    "passed offset=0x%08x)", __func__, regoff, baroff);
 		return (-1);
 	}
 	if (regbar != barbar) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: bad MPI BAR (register "
-		    "BAROFF=0x%08x, passed BAROFF=0x%08x)", __func__,
-		    regbar, barbar);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: bad MPI BAR (register BAROFF=0x%08x, "
+		    "passed BAROFF=0x%08x)", __func__, regbar, barbar);
 		return (-1);
 	}
 	pwp->mpi_offset = regoff;
 	if (pmcs_rd_mpi_tbl(pwp, PMCS_MPI_AS) != PMCS_SIGNATURE) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: Bad MPI Configuration Table Signature 0x%x", __func__,
 		    pmcs_rd_mpi_tbl(pwp, PMCS_MPI_AS));
 		return (-1);
 	}
 
 	if (pmcs_rd_mpi_tbl(pwp, PMCS_MPI_IR) != PMCS_MPI_REVISION1) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: Bad MPI Configuration Revision 0x%x", __func__,
 		    pmcs_rd_mpi_tbl(pwp, PMCS_MPI_IR));
 		return (-1);
@@ -172,20 +173,20 @@
 	pwp->max_oq = PMCS_MNOQ(pmcs_rd_mpi_tbl(pwp, PMCS_MPI_INFO1));
 	pwp->nphy = PMCS_NPHY(pmcs_rd_mpi_tbl(pwp, PMCS_MPI_INFO1));
 	if (pwp->max_iq <= PMCS_NIQ) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: not enough Inbound Queues "
-		    "supported (need %d, max_oq=%d)", __func__, pwp->max_iq,
-		    PMCS_NIQ);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: not enough Inbound Queues supported "
+		    "(need %d, max_oq=%d)", __func__, pwp->max_iq, PMCS_NIQ);
 		return (-1);
 	}
 	if (pwp->max_oq <= PMCS_NOQ) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: not enough Outbound Queues "
-		    "supported (need %d, max_oq=%d)", __func__, pwp->max_oq,
-		    PMCS_NOQ);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: not enough Outbound Queues supported "
+		    "(need %d, max_oq=%d)", __func__, pwp->max_oq, PMCS_NOQ);
 		return (-1);
 	}
 	if (pwp->nphy == 0) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: zero phys reported",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: zero phys reported", __func__);
 		return (-1);
 	}
 	if (PMCS_HPIQ(pmcs_rd_mpi_tbl(pwp, PMCS_MPI_INFO1))) {
@@ -207,14 +208,14 @@
 	 * would cause us to overrun the chip with commands).
 	 */
 	if (pwp->ioq_depth == 0) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: I/O queue depth set to 0. Setting to %d",
 		    __func__, PMCS_NQENTRY);
 		pwp->ioq_depth = PMCS_NQENTRY;
 	}
 
 	if (pwp->ioq_depth < PMCS_MIN_NQENTRY) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: I/O queue depth set too low (%d). Setting to %d",
 		    __func__, pwp->ioq_depth, PMCS_MIN_NQENTRY);
 		pwp->ioq_depth = PMCS_MIN_NQENTRY;
@@ -222,7 +223,7 @@
 
 	if (pwp->ioq_depth > (pwp->max_cmd / (PMCS_IO_IQ_MASK + 1))) {
 		new_ioq_depth = pwp->max_cmd / (PMCS_IO_IQ_MASK + 1);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: I/O queue depth set too high (%d). Setting to %d",
 		    __func__, pwp->ioq_depth, new_ioq_depth);
 		pwp->ioq_depth = new_ioq_depth;
@@ -248,7 +249,7 @@
 		    &pwp->iqp_acchdls[i],
 		    &pwp->iqp_handles[i], PMCS_QENTRY_SIZE * pwp->ioq_depth,
 		    (caddr_t *)&pwp->iqp[i], &pwp->iqaddr[i]) == B_FALSE) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "Failed to setup DMA for iqp[%d]", i);
 			return (-1);
 		}
@@ -260,7 +261,7 @@
 		    &pwp->oqp_acchdls[i],
 		    &pwp->oqp_handles[i], PMCS_QENTRY_SIZE * pwp->ioq_depth,
 		    (caddr_t *)&pwp->oqp[i], &pwp->oqaddr[i]) == B_FALSE) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "Failed to setup DMA for oqp[%d]", i);
 			return (-1);
 		}
@@ -434,8 +435,8 @@
 	 */
 	if (PMCS_MPI_S(pmcs_rd_gst_tbl(pwp, PMCS_GST_BASE)) !=
 	    PMCS_MPI_STATE_INIT) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: MPI launch failed (GST 0x%x "
-		    "DBCLR 0x%x)", __func__,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: MPI launch failed (GST 0x%x DBCLR 0x%x)", __func__,
 		    pmcs_rd_gst_tbl(pwp, PMCS_GST_BASE),
 		    pmcs_rd_msgunit(pwp, PMCS_MSGU_IBDB_CLEAR));
 		return (-1);
@@ -477,7 +478,8 @@
 		drv_usecwait(1000);
 	}
 	if (pmcs_rd_msgunit(pwp, PMCS_MSGU_IBDB) & PMCS_MSGU_IBDB_MPICTU) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: MPI stop failed", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: MPI stop failed", __func__);
 		return (-1);
 	}
 	return (0);
@@ -512,7 +514,8 @@
 	while (count < iterations) {
 		pwrk = pmcs_gwork(pwp, PMCS_TAG_TYPE_WAIT, NULL);
 		if (pwrk == NULL) {
-			pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nowrk, __func__);
+			pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL,
+			    pmcs_nowrk, __func__);
 			rval = -1;
 			break;
 		}
@@ -522,7 +525,8 @@
 		if (msg == NULL) {
 			mutex_exit(&pwp->iqp_lock[iqe]);
 			pmcs_pwork(pwp, pwrk);
-			pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nomsg, __func__);
+			pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL,
+			    pmcs_nomsg, __func__);
 			rval = -1;
 			break;
 		}
@@ -565,7 +569,7 @@
 
 		pmcs_pwork(pwp, pwrk);
 		if (result) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 			    "%s: command timed out on echo test #%d",
 			    __func__, count);
 			rval = -1;
@@ -605,8 +609,8 @@
 	pptr = pwp->root_phys + phynum;
 	if (pptr == NULL) {
 		mutex_exit(&pwp->lock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: cannot find port %d",
-		    __func__, phynum);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: cannot find port %d", __func__, phynum);
 		return (0);
 	}
 
@@ -616,7 +620,7 @@
 	pwrk = pmcs_gwork(pwp, PMCS_TAG_TYPE_WAIT, pptr);
 	if (pwrk == NULL) {
 		pmcs_unlock_phy(pptr);
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nowrk, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_nowrk, __func__);
 		return (-1);
 	}
 
@@ -627,7 +631,7 @@
 		mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 		pmcs_unlock_phy(pptr);
 		pmcs_pwork(pwp, pwrk);
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nomsg, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_nomsg, __func__);
 		return (-1);
 	}
 	msg[0] = LE_32(PMCS_HIPRI(pwp, PMCS_OQ_EVENTS, PMCIN_PHY_START));
@@ -659,7 +663,7 @@
 	pmcs_pwork(pwp, pwrk);
 
 	if (result) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_timeo, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_timeo, __func__);
 	} else {
 		mutex_enter(&pwp->lock);
 		pwp->phys_started |= (1 << phynum);
@@ -682,8 +686,9 @@
 				return (-1);
 			}
 			if (pmcs_clear_diag_counters(pwp, i)) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: failed to "
-				    "reset counters on PHY (%d)", __func__, i);
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+				    "%s: failed to reset counters on PHY (%d)",
+				    __func__, i);
 			}
 		}
 	}
@@ -719,7 +724,7 @@
 	pwrk = pmcs_gwork(pwp, PMCS_TAG_TYPE_WAIT, pptr);
 
 	if (pwrk == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nowrk, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_nowrk, __func__);
 		return (ENOMEM);
 	}
 
@@ -753,7 +758,7 @@
 			iomb[6] = BE_32((phynum << 24) |
 			    (PMCS_PHYOP_LINK_RESET << 16));
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 		    "%s: sending %s to %s for phy 0x%x",
 		    __func__, mbar, pptr->parent->path, pptr->phynum);
 		amt = 7;
@@ -773,7 +778,7 @@
 			mbar = "LOCAL PHY HARD RESET";
 			iomb[2] = LE_32((PMCS_PHYOP_HARD_RESET << 8) | phynum);
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 		    "%s: sending %s to %s", __func__, mbar, pptr->path);
 		amt = 3;
 	}
@@ -783,7 +788,7 @@
 	if (msg == NULL) {
 		mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 		pmcs_pwork(pwp, pwrk);
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nomsg, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_nomsg, __func__);
 		return (ENOMEM);
 	}
 	COPY_MESSAGE(msg, iomb, amt);
@@ -797,14 +802,14 @@
 	pmcs_lock_phy(pptr);
 
 	if (result) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_timeo, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_timeo, __func__);
 
 		if (pmcs_abort(pwp, pptr, htag, 0, 0)) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 			    "%s: Unable to issue SMP abort for htag 0x%08x",
 			    __func__, htag);
 		} else {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 			    "%s: Issuing SMP ABORT for htag 0x%08x",
 			    __func__, htag);
 		}
@@ -820,7 +825,7 @@
 			    status);
 			es = buf;
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 		    "%s: %s action returned %s for %s", __func__, mbar, es,
 		    pptr->path);
 		return (EIO);
@@ -843,7 +848,7 @@
 
 	pptr =  pwp->root_phys + phynum;
 	if (pptr == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: unable to find port %d", __func__, phynum);
 		return;
 	}
@@ -852,7 +857,8 @@
 		pwrk = pmcs_gwork(pwp, PMCS_TAG_TYPE_WAIT, pptr);
 
 		if (pwrk == NULL) {
-			pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nowrk, __func__);
+			pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL,
+			    pmcs_nowrk, __func__);
 			return;
 		}
 
@@ -862,7 +868,8 @@
 		if (msg == NULL) {
 			mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 			pmcs_pwork(pwp, pwrk);
-			pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nomsg, __func__);
+			pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL,
+			    pmcs_nomsg, __func__);
 			return;
 		}
 
@@ -878,7 +885,8 @@
 
 		pmcs_pwork(pwp, pwrk);
 		if (result) {
-			pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_timeo, __func__);
+			pmcs_prt(pwp, PMCS_PRT_ERR,
+			    pptr, NULL, pmcs_timeo, __func__);
 		}
 
 		pwp->phys_started &= ~(1 << phynum);
@@ -916,7 +924,7 @@
 
 	pwrk = pmcs_gwork(pwp, PMCS_TAG_TYPE_WAIT, NULL);
 	if (pwrk == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nowrk, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL, pmcs_nowrk, __func__);
 		return (DDI_FAILURE);
 	}
 	pwrk->arg = msg;
@@ -931,7 +939,7 @@
 	if (ptr == NULL) {
 		mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 		pmcs_pwork(pwp, pwrk);
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nomsg, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL, pmcs_nomsg, __func__);
 		return (DDI_FAILURE);
 	}
 	COPY_MESSAGE(ptr, msg, 3);
@@ -955,8 +963,8 @@
 
 	/* Return for counter value */
 	if (status) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: failed, status (0x%x)",
-		    __func__, status);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: failed, status (0x%x)", __func__, status);
 		return (DDI_FAILURE);
 	}
 	return (LE_32(msg[4]));
@@ -1007,7 +1015,7 @@
 
 	pwrk = pmcs_gwork(pwp, PMCS_TAG_TYPE_WAIT, NULL);
 	if (pwrk == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nowrk, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL, pmcs_nowrk, __func__);
 		return (-1);
 	}
 	pwrk->arg = msg;
@@ -1020,7 +1028,7 @@
 	if (ptr == NULL) {
 		mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 		pmcs_pwork(pwp, pwrk);
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nomsg, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL, pmcs_nomsg, __func__);
 		return (-1);
 	}
 	COPY_MESSAGE(ptr, msg, 2);
@@ -1049,41 +1057,41 @@
 	int i;
 	uint32_t val;
 
-	pmcs_prt(pwp, PMCS_PRT_INFO, "pmcs%d: Register dump start",
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "pmcs%d: Register dump start",
 	    ddi_get_instance(pwp->dip));
-	pmcs_prt(pwp, PMCS_PRT_INFO,
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
 	    "OBDB (intr): 0x%08x (mask): 0x%08x (clear): 0x%08x",
 	    pmcs_rd_msgunit(pwp, PMCS_MSGU_OBDB),
 	    pmcs_rd_msgunit(pwp, PMCS_MSGU_OBDB_MASK),
 	    pmcs_rd_msgunit(pwp, PMCS_MSGU_OBDB_CLEAR));
-	pmcs_prt(pwp, PMCS_PRT_INFO, "SCRATCH0: 0x%08x",
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "SCRATCH0: 0x%08x",
 	    pmcs_rd_msgunit(pwp, PMCS_MSGU_SCRATCH0));
-	pmcs_prt(pwp, PMCS_PRT_INFO, "SCRATCH1: 0x%08x",
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "SCRATCH1: 0x%08x",
 	    pmcs_rd_msgunit(pwp, PMCS_MSGU_SCRATCH1));
-	pmcs_prt(pwp, PMCS_PRT_INFO, "SCRATCH2: 0x%08x",
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "SCRATCH2: 0x%08x",
 	    pmcs_rd_msgunit(pwp, PMCS_MSGU_SCRATCH2));
-	pmcs_prt(pwp, PMCS_PRT_INFO, "SCRATCH3: 0x%08x",
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "SCRATCH3: 0x%08x",
 	    pmcs_rd_msgunit(pwp, PMCS_MSGU_SCRATCH3));
 	for (i = 0; i < PMCS_NIQ; i++) {
-		pmcs_prt(pwp, PMCS_PRT_INFO, "IQ %d: CI %u PI %u",
+		pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "IQ %d: CI %u PI %u",
 		    i, pmcs_rd_iqci(pwp, i), pmcs_rd_iqpi(pwp, i));
 	}
 	for (i = 0; i < PMCS_NOQ; i++) {
-		pmcs_prt(pwp, PMCS_PRT_INFO, "OQ %d: CI %u PI %u",
+		pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "OQ %d: CI %u PI %u",
 		    i, pmcs_rd_oqci(pwp, i), pmcs_rd_oqpi(pwp, i));
 	}
 	val = pmcs_rd_gst_tbl(pwp, PMCS_GST_BASE);
-	pmcs_prt(pwp, PMCS_PRT_INFO,
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
 	    "GST TABLE BASE: 0x%08x (STATE=0x%x QF=%d GSTLEN=%d HMI_ERR=0x%x)",
 	    val, PMCS_MPI_S(val), PMCS_QF(val), PMCS_GSTLEN(val) * 4,
 	    PMCS_HMI_ERR(val));
-	pmcs_prt(pwp, PMCS_PRT_INFO, "GST TABLE IQFRZ0: 0x%08x",
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "GST TABLE IQFRZ0: 0x%08x",
 	    pmcs_rd_gst_tbl(pwp, PMCS_GST_IQFRZ0));
-	pmcs_prt(pwp, PMCS_PRT_INFO, "GST TABLE IQFRZ1: 0x%08x",
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "GST TABLE IQFRZ1: 0x%08x",
 	    pmcs_rd_gst_tbl(pwp, PMCS_GST_IQFRZ1));
-	pmcs_prt(pwp, PMCS_PRT_INFO, "GST TABLE MSGU TICK: 0x%08x",
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "GST TABLE MSGU TICK: 0x%08x",
 	    pmcs_rd_gst_tbl(pwp, PMCS_GST_MSGU_TICK));
-	pmcs_prt(pwp, PMCS_PRT_INFO, "GST TABLE IOP TICK: 0x%08x",
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "GST TABLE IOP TICK: 0x%08x",
 	    pmcs_rd_gst_tbl(pwp, PMCS_GST_IOP_TICK));
 	for (i = 0; i < pwp->nphy; i++) {
 		uint32_t rerrf, pinfo, started = 0, link = 0;
@@ -1093,11 +1101,11 @@
 			link = pinfo & 2;
 		}
 		rerrf = pmcs_rd_gst_tbl(pwp, PMCS_GST_RERR_INFO(i));
-		pmcs_prt(pwp, PMCS_PRT_INFO,
+		pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
 		    "GST TABLE PHY%d STARTED=%d LINK=%d RERR=0x%08x",
 		    i, started, link, rerrf);
 	}
-	pmcs_prt(pwp, PMCS_PRT_INFO, "pmcs%d: Register dump end",
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "pmcs%d: Register dump end",
 	    ddi_get_instance(pwp->dip));
 }
 
@@ -1110,7 +1118,7 @@
 	pmcs_phy_t *pptr, *pnext, *pnext_uplevel[PMCS_MAX_XPND];
 	int r, level = 0;
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s", __func__);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL, "%s", __func__);
 
 	mutex_enter(&pwp->lock);
 	pptr = pwp->root_phys;
@@ -1230,7 +1238,7 @@
 	pmcs_pwork(pwp, pwrk);
 
 	if (result) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_timeo, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_timeo, __func__);
 		result = ETIMEDOUT;
 		goto out;
 	}
@@ -1245,27 +1253,28 @@
 			goto out;
 		} else if (status != PMCS_DEVREG_OK) {
 			if (tmp == 0xffffffff) {	/* F/W bug */
-				pmcs_prt(pwp, PMCS_PRT_INFO,
+				pmcs_prt(pwp, PMCS_PRT_INFO, pptr, NULL,
 				    "%s: phy %s already has bogus devid 0x%x",
 				    __func__, pptr->path, tmp);
 				result = EIO;
 				goto out;
 			} else {
-				pmcs_prt(pwp, PMCS_PRT_INFO,
+				pmcs_prt(pwp, PMCS_PRT_INFO, pptr, NULL,
 				    "%s: phy %s already has a device id 0x%x",
 				    __func__, pptr->path, tmp);
 			}
 		}
 		break;
 	default:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: status 0x%x when trying to "
-		    "register device %s", __func__, status, pptr->path);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
+		    "%s: status 0x%x when trying to register device %s",
+		    __func__, status, pptr->path);
 		result = EIO;
 		goto out;
 	}
 	pptr->device_id = tmp;
 	pptr->valid_device_id = 1;
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "Phy %s/" SAS_ADDR_FMT
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL, "Phy %s/" SAS_ADDR_FMT
 	    " registered with device_id 0x%x (portid %d)", pptr->path,
 	    SAS_ADDR_PRT(pptr->sas_address), tmp, pptr->portid);
 out:
@@ -1312,16 +1321,17 @@
 	pmcs_lock_phy(pptr);
 
 	if (result) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_timeo, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_timeo, __func__);
 		return;
 	}
 	status = LE_32(iomb[2]);
 	if (status != PMCOUT_STATUS_OK) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: status 0x%x when trying to "
-		    "deregister device %s", __func__, status, pptr->path);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
+		    "%s: status 0x%x when trying to deregister device %s",
+		    __func__, status, pptr->path);
 	} else {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: device %s deregistered",
-		    __func__, pptr->path);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
+		    "%s: device %s deregistered", __func__, pptr->path);
 		pptr->valid_device_id = 0;
 		pptr->device_id = PMCS_INVALID_DEVICE_ID;
 	}
@@ -1366,7 +1376,7 @@
 	pmcs_wr_msgunit(pwp, PMCS_MSGU_OBDB_MASK, 0xffffffff);
 	pmcs_wr_msgunit(pwp, PMCS_MSGU_OBDB_CLEAR, 0xffffffff);
 
-	pmcs_prt(pwp, PMCS_PRT_INFO, "%s", __func__);
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL, "%s", __func__);
 
 	if (pwp->locks_initted) {
 		mutex_enter(&pwp->lock);
@@ -1391,8 +1401,9 @@
 		s2 = pmcs_rd_msgunit(pwp, PMCS_MSGU_SCRATCH2) &
 		    PMCS_MSGU_HOST_SOFT_RESET_READY;
 		if (s2 == 0) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: PMCS_MSGU_HOST_"
-			    "SOFT_RESET_READY never came ready", __func__);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+			    "%s: PMCS_MSGU_HOST_SOFT_RESET_READY never came "
+			    "ready", __func__);
 			pmcs_register_dump(pwp);
 			if ((pmcs_rd_msgunit(pwp, PMCS_MSGU_SCRATCH1) &
 			    PMCS_MSGU_CPU_SOFT_RESET_READY) == 0 ||
@@ -1429,15 +1440,16 @@
 	sfrbits = pmcs_rd_msgunit(pwp, PMCS_MSGU_SCRATCH1) &
 	    PMCS_MSGU_AAP_SFR_PROGRESS;
 	sfrbits ^= PMCS_MSGU_AAP_SFR_PROGRESS;
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "PMCS_MSGU_HOST_SCRATCH0 %08x -> %08x",
-	    pmcs_rd_msgunit(pwp, PMCS_MSGU_HOST_SCRATCH0), HST_SFT_RESET_SIG);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "PMCS_MSGU_HOST_SCRATCH0 "
+	    "%08x -> %08x", pmcs_rd_msgunit(pwp, PMCS_MSGU_HOST_SCRATCH0),
+	    HST_SFT_RESET_SIG);
 	pmcs_wr_msgunit(pwp, PMCS_MSGU_HOST_SCRATCH0, HST_SFT_RESET_SIG);
 
 	/*
 	 * Step 3
 	 */
 	gsm = pmcs_rd_gsm_reg(pwp, GSM_CFG_AND_RESET);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "GSM %08x -> %08x", gsm,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "GSM %08x -> %08x", gsm,
 	    gsm & ~PMCS_SOFT_RESET_BITS);
 	pmcs_wr_gsm_reg(pwp, GSM_CFG_AND_RESET, gsm & ~PMCS_SOFT_RESET_BITS);
 
@@ -1445,16 +1457,16 @@
 	 * Step 4
 	 */
 	rapchk = pmcs_rd_gsm_reg(pwp, READ_ADR_PARITY_CHK_EN);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "READ_ADR_PARITY_CHK_EN %08x -> %08x",
-	    rapchk, 0);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "READ_ADR_PARITY_CHK_EN "
+	    "%08x -> %08x", rapchk, 0);
 	pmcs_wr_gsm_reg(pwp, READ_ADR_PARITY_CHK_EN, 0);
 	wapchk = pmcs_rd_gsm_reg(pwp, WRITE_ADR_PARITY_CHK_EN);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "WRITE_ADR_PARITY_CHK_EN %08x -> %08x",
-	    wapchk, 0);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "WRITE_ADR_PARITY_CHK_EN "
+	    "%08x -> %08x", wapchk, 0);
 	pmcs_wr_gsm_reg(pwp, WRITE_ADR_PARITY_CHK_EN, 0);
 	wdpchk = pmcs_rd_gsm_reg(pwp, WRITE_DATA_PARITY_CHK_EN);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "WRITE_DATA_PARITY_CHK_EN %08x -> %08x",
-	    wdpchk, 0);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "WRITE_DATA_PARITY_CHK_EN "
+	    "%08x -> %08x", wdpchk, 0);
 	pmcs_wr_gsm_reg(pwp, WRITE_DATA_PARITY_CHK_EN, 0);
 
 	/*
@@ -1466,8 +1478,8 @@
 	 * Step 5.5 (Temporary workaround for 1.07.xx Beta)
 	 */
 	tsmode = pmcs_rd_gsm_reg(pwp, PMCS_GPIO_TRISTATE_MODE_ADDR);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "GPIO TSMODE %08x -> %08x", tsmode,
-	    tsmode & ~(PMCS_GPIO_TSMODE_BIT0|PMCS_GPIO_TSMODE_BIT1));
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "GPIO TSMODE %08x -> %08x",
+	    tsmode, tsmode & ~(PMCS_GPIO_TSMODE_BIT0|PMCS_GPIO_TSMODE_BIT1));
 	pmcs_wr_gsm_reg(pwp, PMCS_GPIO_TRISTATE_MODE_ADDR,
 	    tsmode & ~(PMCS_GPIO_TSMODE_BIT0|PMCS_GPIO_TSMODE_BIT1));
 	drv_usecwait(10);
@@ -1476,8 +1488,8 @@
 	 * Step 6
 	 */
 	spc = pmcs_rd_topunit(pwp, PMCS_SPC_RESET);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "SPC_RESET %08x -> %08x", spc,
-	    spc & ~(PCS_IOP_SS_RSTB|PCS_AAP1_SS_RSTB));
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "SPC_RESET %08x -> %08x",
+	    spc, spc & ~(PCS_IOP_SS_RSTB|PCS_AAP1_SS_RSTB));
 	pmcs_wr_topunit(pwp, PMCS_SPC_RESET,
 	    spc & ~(PCS_IOP_SS_RSTB|PCS_AAP1_SS_RSTB));
 	drv_usecwait(10);
@@ -1486,8 +1498,8 @@
 	 * Step 7
 	 */
 	spc = pmcs_rd_topunit(pwp, PMCS_SPC_RESET);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "SPC_RESET %08x -> %08x", spc,
-	    spc & ~(BDMA_CORE_RSTB|OSSP_RSTB));
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "SPC_RESET %08x -> %08x",
+	    spc, spc & ~(BDMA_CORE_RSTB|OSSP_RSTB));
 	pmcs_wr_topunit(pwp, PMCS_SPC_RESET, spc & ~(BDMA_CORE_RSTB|OSSP_RSTB));
 
 	/*
@@ -1499,8 +1511,8 @@
 	 * Step 9
 	 */
 	spc = pmcs_rd_topunit(pwp, PMCS_SPC_RESET);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "SPC_RESET %08x -> %08x", spc,
-	    spc | (BDMA_CORE_RSTB|OSSP_RSTB));
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "SPC_RESET %08x -> %08x",
+	    spc, spc | (BDMA_CORE_RSTB|OSSP_RSTB));
 	pmcs_wr_topunit(pwp, PMCS_SPC_RESET, spc | (BDMA_CORE_RSTB|OSSP_RSTB));
 
 	/*
@@ -1512,7 +1524,7 @@
 	 * Step 11
 	 */
 	gsm = pmcs_rd_gsm_reg(pwp, GSM_CFG_AND_RESET);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "GSM %08x -> %08x", gsm,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "GSM %08x -> %08x", gsm,
 	    gsm | PMCS_SOFT_RESET_BITS);
 	pmcs_wr_gsm_reg(pwp, GSM_CFG_AND_RESET, gsm | PMCS_SOFT_RESET_BITS);
 	drv_usecwait(10);
@@ -1520,16 +1532,19 @@
 	/*
 	 * Step 12
 	 */
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "READ_ADR_PARITY_CHK_EN %08x -> %08x",
-	    pmcs_rd_gsm_reg(pwp, READ_ADR_PARITY_CHK_EN), rapchk);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "READ_ADR_PARITY_CHK_EN "
+	    "%08x -> %08x", pmcs_rd_gsm_reg(pwp, READ_ADR_PARITY_CHK_EN),
+	    rapchk);
 	pmcs_wr_gsm_reg(pwp, READ_ADR_PARITY_CHK_EN, rapchk);
 	drv_usecwait(10);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "WRITE_ADR_PARITY_CHK_EN %08x -> %08x",
-	    pmcs_rd_gsm_reg(pwp, WRITE_ADR_PARITY_CHK_EN), wapchk);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "WRITE_ADR_PARITY_CHK_EN "
+	    "%08x -> %08x", pmcs_rd_gsm_reg(pwp, WRITE_ADR_PARITY_CHK_EN),
+	    wapchk);
 	pmcs_wr_gsm_reg(pwp, WRITE_ADR_PARITY_CHK_EN, wapchk);
 	drv_usecwait(10);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "WRITE_DATA_PARITY_CHK_EN %08x -> %08x",
-	    pmcs_rd_gsm_reg(pwp, WRITE_DATA_PARITY_CHK_EN), wapchk);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "WRITE_DATA_PARITY_CHK_EN "
+	    "%08x -> %08x", pmcs_rd_gsm_reg(pwp, WRITE_DATA_PARITY_CHK_EN),
+	    wapchk);
 	pmcs_wr_gsm_reg(pwp, WRITE_DATA_PARITY_CHK_EN, wdpchk);
 	drv_usecwait(10);
 
@@ -1537,8 +1552,8 @@
 	 * Step 13
 	 */
 	spc = pmcs_rd_topunit(pwp, PMCS_SPC_RESET);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "SPC_RESET %08x -> %08x", spc,
-	    spc | (PCS_IOP_SS_RSTB|PCS_AAP1_SS_RSTB));
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL, "SPC_RESET %08x -> %08x",
+	    spc, spc | (PCS_IOP_SS_RSTB|PCS_AAP1_SS_RSTB));
 	pmcs_wr_topunit(pwp, PMCS_SPC_RESET,
 	    spc | (PCS_IOP_SS_RSTB|PCS_AAP1_SS_RSTB));
 
@@ -1559,7 +1574,7 @@
 	}
 
 	if ((spc & PMCS_MSGU_AAP_SFR_PROGRESS) != sfrbits) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "SFR didn't toggle (sfr 0x%x)", spc);
 		pwp->state = STATE_DEAD;
 		pwp->blocked = 0;
@@ -1589,7 +1604,7 @@
 	}
 	spc = pmcs_rd_msgunit(pwp, PMCS_MSGU_SCRATCH1);
 	if ((spc & PMCS_MSGU_AAP_STATE_MASK) != PMCS_MSGU_AAP_STATE_READY) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "soft reset failed (state 0x%x)", spc);
 		pwp->state = STATE_DEAD;
 		pwp->blocked = 0;
@@ -1747,7 +1762,8 @@
 	mutex_enter(&pwp->lock);
 	pwp->state = STATE_DEAD;
 	mutex_exit(&pwp->lock);
-	pmcs_prt(pwp, PMCS_PRT_ERR, "%s: Failed: %s", __func__, msg);
+	pmcs_prt(pwp, PMCS_PRT_ERR, NULL, NULL,
+	    "%s: Failed: %s", __func__, msg);
 	return (-1);
 }
 
@@ -1789,7 +1805,7 @@
 		rval = pmcs_reset_phy(pwp, pptr, PMCS_PHYOP_LINK_RESET);
 	} else {
 		pmcs_unlock_phy(pptr);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 		    "%s: cannot reset a SMP device yet (%s)",
 		    __func__, pptr->path);
 		return (EINVAL);
@@ -1848,7 +1864,7 @@
 				PHY_CHANGED(pwp, pptr);
 				RESTART_DISCOVERY(pwp);
 			} else {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 				    "%s: Retries exhausted for %s, killing",
 				    __func__, pptr->path);
 				pptr->config_stop = 0;
@@ -1861,8 +1877,9 @@
 		 * preclude a future action.
 		 */
 		if (result || pptr->valid_device_id == 0) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: %s could not "
-			    "be registered", __func__,  pptr->path);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
+			    "%s: %s could not be registered", __func__,
+			    pptr->path);
 			return (-1);
 		}
 	}
@@ -1876,12 +1893,12 @@
 	if (iport == NULL)
 		return (B_FALSE);
 
-	pmcs_prt(iport->pwp, PMCS_PRT_DEBUG_MAP, "%s", __func__);
+	pmcs_prt(iport->pwp, PMCS_PRT_DEBUG_MAP, NULL, NULL, "%s", __func__);
 
 	/* create target map */
 	if (scsi_hba_tgtmap_create(iport->dip, SCSI_TM_FULLSET, tgtmap_usec,
 	    2048, NULL, NULL, NULL, &iport->iss_tgtmap) != DDI_SUCCESS) {
-		pmcs_prt(iport->pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(iport->pwp, PMCS_PRT_DEBUG, NULL, NULL,
 		    "%s: failed to create tgtmap", __func__);
 		return (B_FALSE);
 	}
@@ -1895,7 +1912,7 @@
 	if ((iport == NULL) || (iport->iss_tgtmap == NULL))
 		return (B_FALSE);
 
-	pmcs_prt(iport->pwp, PMCS_PRT_DEBUG_MAP, "%s", __func__);
+	pmcs_prt(iport->pwp, PMCS_PRT_DEBUG_MAP, NULL, NULL, "%s", __func__);
 
 	/* destroy target map */
 	scsi_hba_tgtmap_destroy(iport->iss_tgtmap);
@@ -1958,8 +1975,8 @@
 		pmcs_add_phy_to_iport(iport, pptr);
 		pmcs_unlock_phy(pptr);
 
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: found phy %d [0x%p] "
-		    "on iport%d, refcnt(%d)", __func__, phynum,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL, "%s: found "
+		    "phy %d [0x%p] on iport%d, refcnt(%d)", __func__, phynum,
 		    (void *)pptr, inst, iport->refcnt);
 	}
 	mutex_exit(&pwp->lock);
@@ -2013,7 +2030,7 @@
 		if (iport) {
 			mutex_enter(&iport->lock);
 			iport->ua_state = UA_ACTIVE;
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: "
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL, "%s: "
 			    "found iport [0x%p] on ua (%s) for phy [0x%p], "
 			    "refcnt (%d)", __func__, (void *)iport, ua,
 			    (void *)pptr, iport->refcnt);
@@ -2038,8 +2055,8 @@
 	if (iport->refcnt == 0) {
 		cv_signal(&iport->refcnt_cv);
 	}
-	pmcs_prt(iport->pwp, PMCS_PRT_DEBUG_CONFIG, "%s: iport [0x%p] "
-	    "refcnt (%d)", __func__, (void *)iport, iport->refcnt);
+	pmcs_prt(iport->pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL, "%s: iport "
+	    "[0x%p] refcnt (%d)", __func__, (void *)iport, iport->refcnt);
 }
 
 void
@@ -2059,12 +2076,12 @@
 
 	if (scsi_hba_iportmap_iport_add(pwp->hss_iportmap, ua, NULL) !=
 	    DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP, "%s: failed to add "
-		    "iport handle on unit address [%s]", __func__, ua);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP, NULL, NULL, "%s: failed to "
+		    "add iport handle on unit address [%s]", __func__, ua);
 	} else {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP, "%s: phymap_active count "
-		    "(%d), added iport handle on unit address [%s]", __func__,
-		    pwp->phymap_active, ua);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP, NULL, NULL, "%s: "
+		    "phymap_active count (%d), added iport handle on unit "
+		    "address [%s]", __func__, pwp->phymap_active, ua);
 	}
 
 	/* Set the HBA softstate as our private data for this unit address */
@@ -2080,7 +2097,7 @@
 	if (iport) {
 		mutex_enter(&iport->lock);
 		if (pmcs_iport_configure_phys(iport) != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: "
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL, "%s: "
 			    "failed to configure phys on iport [0x%p] at "
 			    "unit address (%s)", __func__, (void *)iport, ua);
 		}
@@ -2106,19 +2123,19 @@
 
 	if (scsi_hba_iportmap_iport_remove(pwp->hss_iportmap, ua) !=
 	    DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP, "%s: failed to remove "
-		    "iport handle on unit address [%s]", __func__, ua);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP, NULL, NULL, "%s: failed to "
+		    "remove iport handle on unit address [%s]", __func__, ua);
 	} else {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP, "%s: phymap_active "
-		    "count (%d), removed iport handle on unit address [%s]",
-		    __func__, pwp->phymap_active, ua);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP, NULL, NULL, "%s: "
+		    "phymap_active count (%d), removed iport handle on unit "
+		    "address [%s]", __func__, pwp->phymap_active, ua);
 	}
 
 	iport = pmcs_get_iport_by_ua(pwp, ua);
 
 	if (iport == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: failed lookup of "
-		    "iport handle on unit address (%s)", __func__, ua);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL, "%s: failed "
+		    "lookup of iport handle on unit addr (%s)", __func__, ua);
 		return;
 	}
 
@@ -2153,7 +2170,7 @@
 	/* Ensure we have at least one phymap active */
 	if (pwp->phymap_active == 0) {
 		mutex_exit(&pwp->lock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 		    "%s: phymap inactive, exiting", __func__);
 		return;
 	}
@@ -2167,7 +2184,7 @@
 	rw_enter(&pwp->iports_lock, RW_READER);
 	if (!pwp->iports_attached) {
 		rw_exit(&pwp->iports_lock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 		    "%s: no iports attached, retry discovery", __func__);
 		SCHEDULE_WORK(pwp, PMCS_WORK_DISCOVER);
 		return;
@@ -2177,14 +2194,14 @@
 	mutex_enter(&pwp->config_lock);
 	if (pwp->configuring) {
 		mutex_exit(&pwp->config_lock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 		    "%s: configuration already in progress", __func__);
 		return;
 	}
 
 	if (pmcs_acquire_scratch(pwp, B_FALSE)) {
 		mutex_exit(&pwp->config_lock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 		    "%s: cannot allocate scratch", __func__);
 		SCHEDULE_WORK(pwp, PMCS_WORK_DISCOVER);
 		return;
@@ -2194,7 +2211,7 @@
 	pwp->config_changed = B_FALSE;
 	mutex_exit(&pwp->config_lock);
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "Discovery begin");
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL, "Discovery begin");
 
 	/*
 	 * The order of the following traversals is important.
@@ -2282,7 +2299,7 @@
 out:
 	DTRACE_PROBE2(pmcs__discover__exit, ulong_t, pwp->work_flags,
 	    boolean_t, pwp->config_changed);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "Discovery end");
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL, "Discovery end");
 
 	mutex_enter(&pwp->config_lock);
 
@@ -2302,7 +2319,7 @@
 		 * If config_changed is TRUE, we need to reschedule
 		 * discovery now.
 		 */
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 		    "%s: Config has changed, will re-run discovery", __func__);
 		SCHEDULE_WORK(pwp, PMCS_WORK_DISCOVER);
 	}
@@ -2315,7 +2332,7 @@
 	pptr = pmcs_find_phy_needing_work(pwp, pwp->root_phys);
 	if (pptr != NULL) {
 		if (!WORK_IS_SCHEDULED(pwp, PMCS_WORK_DISCOVER)) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "PHY %s dead=%d changed=%d configured=%d "
 			    "but no work scheduled", pptr->path, pptr->dead,
 			    pptr->changed, pptr->configured);
@@ -2407,14 +2424,13 @@
 		tgtmap = iport->iss_tgtmap;
 		ASSERT(tgtmap);
 		if (scsi_hba_tgtmap_set_begin(tgtmap) != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP, NULL, NULL,
 			    "%s: cannot set_begin tgtmap ", __func__);
 			rw_exit(&pwp->iports_lock);
 			return (B_FALSE);
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP,
-		    "%s: set begin on tgtmap [0x%p]", __func__,
-		    (void *)tgtmap);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP, NULL, NULL,
+		    "%s: set begin on tgtmap [0x%p]", __func__, (void *)tgtmap);
 	}
 	rw_exit(&pwp->iports_lock);
 
@@ -2437,7 +2453,7 @@
 		}
 
 		if (pptr->changed) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 			    "%s: oops, PHY %s changed; restart discovery",
 			    __func__, pptr->path);
 			pmcs_unlock_phy(pptr);
@@ -2451,9 +2467,8 @@
 		iport = pmcs_get_iport_by_phy(pwp, pptr);
 		if (iport == NULL) {
 			/* No iport for this tgt */
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
-			    "%s: no iport for this target",
-			    __func__);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
+			    "%s: no iport for this target", __func__);
 			pmcs_unlock_phy(pptr);
 			pptr = pptr->sibling;
 			continue;
@@ -2488,14 +2503,13 @@
 		tgtmap = iport->iss_tgtmap;
 		ASSERT(tgtmap);
 		if (scsi_hba_tgtmap_set_end(tgtmap, 0) != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP, NULL, NULL,
 			    "%s: cannot set_end tgtmap ", __func__);
 			rw_exit(&pwp->iports_lock);
 			return (B_FALSE);
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP,
-		    "%s: set end on tgtmap [0x%p]", __func__,
-		    (void *)tgtmap);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP, NULL, NULL,
+		    "%s: set end on tgtmap [0x%p]", __func__, (void *)tgtmap);
 	}
 
 	/*
@@ -2528,8 +2542,8 @@
 		}
 		if (ndi_prop_update_string(DDI_DEV_T_NONE, iport->dip,
 		    SCSI_ADDR_PROP_ATTACHED_PORT,  ap) != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Failed to "
-			    "set prop ("SCSI_ADDR_PROP_ATTACHED_PORT")",
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL, "%s: Failed "
+			    "to set prop ("SCSI_ADDR_PROP_ATTACHED_PORT")",
 			    __func__);
 		}
 		kmem_free(ap, PMCS_MAX_UA_SIZE);
@@ -2581,13 +2595,13 @@
 		wwn = pmcs_barray2wwn(lphyp->sas_address);
 		ua = scsi_wwn_to_wwnstr(wwn, 1, NULL);
 
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP, lphyp, NULL,
 		    "iport_observation: adding %s on tgtmap [0x%p] phy [0x%p]",
 		    ua, (void *)tgtmap, (void*)lphyp);
 
 		if (scsi_hba_tgtmap_set_add(tgtmap, tgt_type, ua, NULL) !=
 		    DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_MAP,  NULL, NULL,
 			    "%s: failed to add address %s", __func__, ua);
 			scsi_free_wwnstr(ua);
 			return (B_FALSE);
@@ -2662,7 +2676,7 @@
 		iport = pmcs_get_iport_by_phy(pwp, root_phy);
 		if (iport == NULL) {
 			/* No iport for this tgt, restart */
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, NULL,
 			    "%s: iport not yet configured, "
 			    "retry discovery", __func__);
 			pnext = NULL;
@@ -2849,7 +2863,8 @@
 void
 pmcs_clear_phy(pmcs_hw_t *pwp, pmcs_phy_t *pptr)
 {
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: %s", __func__, pptr->path);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL, "%s: %s",
+	    __func__, pptr->path);
 	ASSERT(mutex_owned(&pptr->phy_lock));
 	/* keep sibling */
 	/* keep children */
@@ -2897,15 +2912,15 @@
 static void
 pmcs_new_tport(pmcs_hw_t *pwp, pmcs_phy_t *pptr)
 {
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: phy 0x%p @ %s", __func__,
-	    (void *)pptr, pptr->path);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL, "%s: phy 0x%p @ %s",
+	    __func__, (void *)pptr, pptr->path);
 
 	if (pmcs_configure_phy(pwp, pptr) == B_FALSE) {
 		/*
 		 * If the config failed, mark the PHY as changed.
 		 */
 		PHY_CHANGED(pwp, pptr);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 		    "%s: pmcs_configure_phy failed for phy 0x%p", __func__,
 		    (void *)pptr);
 		return;
@@ -2937,7 +2952,7 @@
 			if (!IS_ROOT_PHY(pptr)) {
 				pmcs_dec_phy_ref_count(pptr);
 			}
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "%s: Not assigning existing tgt %p for PHY %p "
 			    "(WWN mismatch)", __func__, (void *)pptr->target,
 			    (void *)pptr);
@@ -2946,7 +2961,7 @@
 		}
 
 		if (!pmcs_assign_device(pwp, pptr->target)) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, pptr->target,
 			    "%s: pmcs_assign_device failed for target 0x%p",
 			    __func__, (void *)pptr->target);
 		}
@@ -2992,8 +3007,8 @@
 		dtype = "???";
 	}
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "config_dev: %s dev %s "
-	    SAS_ADDR_FMT " dev id 0x%x lr 0x%x", dtype, pptr->path,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL, "config_dev: %s "
+	    "dev %s " SAS_ADDR_FMT " dev id 0x%x lr 0x%x", dtype, pptr->path,
 	    SAS_ADDR_PRT(pptr->sas_address), pptr->device_id, pptr->link_rate);
 
 	return (B_TRUE);
@@ -3028,7 +3043,7 @@
 	 * Step 2- make sure we don't overflow
 	 */
 	if (pptr->level == PMCS_MAX_XPND-1) {
-		pmcs_prt(pwp, PMCS_PRT_WARN,
+		pmcs_prt(pwp, PMCS_PRT_WARN, pptr, NULL,
 		    "%s: SAS expansion tree too deep", __func__);
 		return;
 	}
@@ -3097,10 +3112,10 @@
 			if (widephy) {
 				ctmp->width++;
 				pptr->subsidiary = 1;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: PHY "
-				    "%s part of wide PHY %s (now %d wide)",
-				    __func__, pptr->path, ctmp->path,
-				    ctmp->width);
+				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
+				    "%s: PHY %s part of wide PHY %s "
+				    "(now %d wide)", __func__, pptr->path,
+				    ctmp->path, ctmp->width);
 				if (root_phy) {
 					mutex_exit(&ctmp->phy_lock);
 				}
@@ -3123,7 +3138,7 @@
 	if (pmcs_get_device_handle(pwp, pptr)) {
 		goto out;
 	}
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "Config expander %s "
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL, "Config expander %s "
 	    SAS_ADDR_FMT " dev id 0x%x lr 0x%x", pptr->path,
 	    SAS_ADDR_PRT(pptr->sas_address), pptr->device_id, pptr->link_rate);
 
@@ -3136,7 +3151,7 @@
 			PHY_CHANGED(pwp, pptr);
 			RESTART_DISCOVERY(pwp);
 		} else {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 			    "%s: Retries exhausted for %s, killing", __func__,
 			    pptr->path);
 			pptr->config_stop = 0;
@@ -3206,7 +3221,7 @@
 				RESTART_DISCOVERY(pwp);
 			} else {
 				pptr->config_stop = 0;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 				    "%s: Retries exhausted for %s, killing",
 				    __func__, pptr->path);
 				pmcs_kill_changed(pwp, pptr, 0);
@@ -3225,9 +3240,9 @@
 	 */
 	ASSERT(pptr->children == NULL);
 	if (pptr->children != NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Already child PHYs attached "
-		    " to PHY %s: This should never happen", __func__,
-		    pptr->path);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL, "%s: Already child "
+		    "PHYs attached  to PHY %s: This should never happen",
+		    __func__, pptr->path);
 		goto out;
 	} else {
 		pptr->children = clist;
@@ -3280,7 +3295,7 @@
 	pmcs_phy_t *ctmp, *local, *local_list = NULL, *local_tail = NULL;
 	boolean_t kill_changed, changed;
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 	    "%s: check %s", __func__, pptr->path);
 
 	/*
@@ -3310,7 +3325,7 @@
 			RESTART_DISCOVERY(pwp);
 		} else {
 			pptr->config_stop = 0;
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 			    "%s: Retries exhausted for %s, killing", __func__,
 			    pptr->path);
 			pmcs_kill_changed(pwp, pptr, 0);
@@ -3322,7 +3337,7 @@
 	 * Step 3: If the number of phys don't agree, kill the old sub-tree.
 	 */
 	if (nphy != pptr->ncphy) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 		    "%s: number of contained phys for %s changed from %d to %d",
 		    __func__, pptr->path, pptr->ncphy, nphy);
 		/*
@@ -3349,7 +3364,7 @@
 	ctmp = pptr->children;
 	ASSERT(ctmp);
 	if (ctmp == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 		    "%s: No children attached to expander @ %s?", __func__,
 		    pptr->path);
 		return;
@@ -3385,7 +3400,7 @@
 				RESTART_DISCOVERY(pwp);
 			} else {
 				pptr->config_stop = 0;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 				    "%s: Retries exhausted for %s, killing",
 				    __func__, pptr->path);
 				pmcs_kill_changed(pwp, pptr, 0);
@@ -3431,10 +3446,10 @@
 
 		if (ctmp->dtype != local->dtype) {
 			if (ctmp->dtype != NOTHING) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: %s "
-				    "type changed from %s to %s (killing)",
-				    __func__, ctmp->path, PHY_TYPE(ctmp),
-				    PHY_TYPE(local));
+				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, ctmp, NULL,
+				    "%s: %s type changed from %s to %s "
+				    "(killing)", __func__, ctmp->path,
+				    PHY_TYPE(ctmp), PHY_TYPE(local));
 				/*
 				 * Force a rescan of this expander after dead
 				 * contents are cleared and removed.
@@ -3443,15 +3458,16 @@
 				kill_changed = B_TRUE;
 			} else {
 				changed = B_TRUE;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, ctmp, NULL,
 				    "%s: %s type changed from NOTHING to %s",
 				    __func__, ctmp->path, PHY_TYPE(local));
 			}
 
 		} else if (ctmp->atdt != local->atdt) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: %s attached "
-			    "device type changed from %d to %d (killing)",
-			    __func__, ctmp->path, ctmp->atdt, local->atdt);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, ctmp, NULL, "%s: "
+			    "%s attached device type changed from %d to %d "
+			    "(killing)", __func__, ctmp->path, ctmp->atdt,
+			    local->atdt);
 			/*
 			 * Force a rescan of this expander after dead
 			 * contents are cleared and removed.
@@ -3462,8 +3478,8 @@
 				kill_changed = B_TRUE;
 			}
 		} else if (ctmp->link_rate != local->link_rate) {
-			pmcs_prt(pwp, PMCS_PRT_INFO, "%s: %s changed speed from"
-			    " %s to %s", __func__, ctmp->path,
+			pmcs_prt(pwp, PMCS_PRT_INFO, ctmp, NULL, "%s: %s "
+			    "changed speed from %s to %s", __func__, ctmp->path,
 			    pmcs_get_rate(ctmp->link_rate),
 			    pmcs_get_rate(local->link_rate));
 			/* If the speed changed from invalid, force rescan */
@@ -3480,9 +3496,9 @@
 			}
 		} else if (memcmp(ctmp->sas_address, local->sas_address,
 		    sizeof (ctmp->sas_address)) != 0) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: SASAddr "
-			    "for %s changed from " SAS_ADDR_FMT " to "
-			    SAS_ADDR_FMT " (kill old tree)", __func__,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, ctmp, NULL,
+			    "%s: SAS Addr for %s changed from " SAS_ADDR_FMT
+			    "to " SAS_ADDR_FMT " (kill old tree)", __func__,
 			    ctmp->path, SAS_ADDR_PRT(ctmp->sas_address),
 			    SAS_ADDR_PRT(local->sas_address));
 			/*
@@ -3491,7 +3507,7 @@
 			 */
 			changed = B_TRUE;
 		} else {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, ctmp, NULL,
 			    "%s: %s looks the same (type %s)",
 			    __func__, ctmp->path, PHY_TYPE(ctmp));
 			/*
@@ -3532,8 +3548,8 @@
 
 				if (ctmp->dead) {
 					pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
-					    "%s: Unmarking PHY %s dead, "
-					    "restarting discovery",
+					    ctmp, NULL, "%s: Unmarking PHY %s "
+					    "dead, restarting discovery",
 					    __func__, ctmp->path);
 					ctmp->dead = 0;
 					RESTART_DISCOVERY(pwp);
@@ -3588,7 +3604,8 @@
 	pmcs_phy_t *phyp, *pnext, *pchild;
 	boolean_t config_changed = B_FALSE;
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: %s", __func__, pptr->path);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
+	    "%s: %s", __func__, pptr->path);
 
 	/*
 	 * Check each expander at this level
@@ -3656,8 +3673,8 @@
 	ASSERT(mutex_owned(&pptr->phy_lock));
 	ASSERT(pptr->level < PMCS_MAX_XPND - 1);
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: checking %s", __func__,
-	    pptr->path);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
+	    "%s: checking %s", __func__, pptr->path);
 
 	ctmp = pptr->children;
 	while (ctmp) {
@@ -3686,7 +3703,7 @@
 	ctmp = pptr->children;
 	while (ctmp) {
 		pmcs_phy_t *nxt = ctmp->sibling;
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, ctmp, NULL,
 		    "%s: dead PHY 0x%p (%s) (ref_count %d)", __func__,
 		    (void *)ctmp, ctmp->path, ctmp->ref_count);
 		/*
@@ -3742,8 +3759,8 @@
 			ctmp = ctmp->sibling;
 			continue;
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: subsidiary %s",
-		    __func__, ctmp->path);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, ctmp, NULL,
+		    "%s: subsidiary %s", __func__, ctmp->path);
 		pmcs_clear_phy(pwp, ctmp);
 		if (level == 0) {
 			pmcs_unlock_phy(ctmp);
@@ -3788,8 +3805,8 @@
 	ptr = GET_IQ_ENTRY(pwp, PMCS_IQ_OTHER);
 	if (ptr == NULL) {
 		mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG2, "%s: GET_IQ_ENTRY failed",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG2, pptr, NULL,
+		    "%s: GET_IQ_ENTRY failed", __func__);
 		pmcs_pwork(pwp, pwrk);
 		result = 0;
 		goto out;
@@ -3836,14 +3853,14 @@
 
 	if (result) {
 		pmcs_timed_out(pwp, htag, __func__);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 		    "%s: Issuing SMP ABORT for htag 0x%08x", __func__, htag);
 		if (pmcs_abort(pwp, pptr, htag, 0, 0)) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 			    "%s: Unable to issue SMP ABORT for htag 0x%08x",
 			    __func__, htag);
 		} else {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 			    "%s: Issuing SMP ABORT for htag 0x%08x",
 			    __func__, htag);
 		}
@@ -3854,7 +3871,7 @@
 	status = LE_32(ptr[2]);
 	if (status == PMCOUT_STATUS_UNDERFLOW ||
 	    status == PMCOUT_STATUS_OVERFLOW) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_UNDERFLOW,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_UNDERFLOW, pptr, NULL,
 		    "%s: over/underflow", __func__);
 		status = PMCOUT_STATUS_OK;
 	}
@@ -3887,7 +3904,7 @@
 			/* FALLTHROUGH */
 		case PMCOUT_STATUS_SMP_RESP_CONNECTION_ERROR:
 			DFM(nag, "Response Connection Error");
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "%s: expander %s SMP operation failed (%s)",
 			    __func__, pptr->path, nag);
 			break;
@@ -3900,14 +3917,14 @@
 		case PMCOUT_STATUS_IO_DS_NON_OPERATIONAL: {
 			pmcs_xscsi_t *xp = pptr->target;
 
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, xp,
 			    "%s: expander %s device state non-operational",
 			    __func__, pptr->path);
 
 			if (xp == NULL) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
-				    "%s: No target to do DS recovery for PHY "
-				    "%p (%s), attempting PHY hard reset",
+				pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr,
+				    xp, "%s: No target to do DS recovery for "
+				    "PHY %p (%s), attempting PHY hard reset",
 				    __func__, (void *)pptr, pptr->path);
 				(void) pmcs_reset_phy(pwp, pptr,
 				    PMCS_PHYOP_HARD_RESET);
@@ -3926,12 +3943,13 @@
 			break;
 		}
 	} else if (srf->srf_frame_type != SMP_FRAME_TYPE_RESPONSE) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 		    "%s: bad response frame type 0x%x",
 		    __func__, srf->srf_frame_type);
 		result = -EINVAL;
 	} else if (srf->srf_function != SMP_FUNC_REPORT_GENERAL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: bad response function 0x%x",
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
+		    "%s: bad response function 0x%x",
 		    __func__, srf->srf_function);
 		result = -EINVAL;
 	} else if (srf->srf_result != 0) {
@@ -3942,16 +3960,16 @@
 		 */
 		if (srf->srf_result == 3 && (ival & 0xff00)) {
 			ival &= ~0xff00;
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "%s: err 0x%x with SAS2 request- retry with SAS1",
 			    __func__, srf->srf_result);
 			goto again;
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: bad response 0x%x",
-		    __func__, srf->srf_result);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
+		    "%s: bad response 0x%x", __func__, srf->srf_result);
 		result = -EINVAL;
 	} else if (srgr->srgr_configuring) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 		    "%s: expander at phy %s is still configuring",
 		    __func__, pptr->path);
 		result = 0;
@@ -3960,7 +3978,7 @@
 		if (ival & 0xff00) {
 			pptr->tolerates_sas2 = 1;
 		}
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 		    "%s has %d phys and %s SAS2", pptr->path, result,
 		    pptr->tolerates_sas2? "tolerates" : "does not tolerate");
 	}
@@ -4057,13 +4075,13 @@
 	mutex_exit(&pwp->config_lock);
 
 	if (result) {
-		pmcs_prt(pwp, PMCS_PRT_WARN, pmcs_timeo, __func__);
+		pmcs_prt(pwp, PMCS_PRT_WARN, pptr, NULL, pmcs_timeo, __func__);
 		if (pmcs_abort(pwp, expander, htag, 0, 0)) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 			    "%s: Unable to issue SMP ABORT for htag 0x%08x",
 			    __func__, htag);
 		} else {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 			    "%s: Issuing SMP ABORT for htag 0x%08x",
 			    __func__, htag);
 		}
@@ -4081,7 +4099,7 @@
 	status = LE_32(ptr[2]);
 	if (status == PMCOUT_STATUS_UNDERFLOW ||
 	    status == PMCOUT_STATUS_OVERFLOW) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_UNDERFLOW,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_UNDERFLOW, pptr, NULL,
 		    "%s: over/underflow", __func__);
 		status = PMCOUT_STATUS_OK;
 	}
@@ -4107,7 +4125,7 @@
 			/* FALLTHROUGH */
 		case PMCOUT_STATUS_SMP_RESP_CONNECTION_ERROR:
 			DFM(nag, "Response Connection Error");
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "%s: expander %s SMP operation failed (%s)",
 			    __func__, pptr->path, nag);
 			break;
@@ -4118,13 +4136,14 @@
 		}
 		goto out;
 	} else if (srf->srf_frame_type != SMP_FRAME_TYPE_RESPONSE) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 		    "%s: bad response frame type 0x%x",
 		    __func__, srf->srf_frame_type);
 		result = -EINVAL;
 		goto out;
 	} else if (srf->srf_function != SMP_FUNC_DISCOVER) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: bad response function 0x%x",
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
+		    "%s: bad response function 0x%x",
 		    __func__, srf->srf_function);
 		result = -EINVAL;
 		goto out;
@@ -4152,7 +4171,7 @@
 
 	switch (sdr->sdr_attached_device_type) {
 	case SAS_IF_DTYPE_ENDPOINT:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 		    "exp_content: %s atdt=0x%x lr=%x is=%x ts=%x SAS="
 		    SAS_ADDR_FMT " attSAS=" SAS_ADDR_FMT " atPHY=%x",
 		    pptr->path,
@@ -4170,14 +4189,14 @@
 		} else if (sdr->sdr_attached_ssp_target) {
 			pptr->dtype = SAS;
 		} else if (tgt_support || ini_support) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s: %s has "
-			    "tgt support=%x init support=(%x)",
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
+			    "%s: %s has tgt support=%x init support=(%x)",
 			    __func__, pptr->path, tgt_support, ini_support);
 		}
 		break;
 	case SAS_IF_DTYPE_EDGE:
 	case SAS_IF_DTYPE_FANOUT:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 		    "exp_content: %s atdt=0x%x lr=%x is=%x ts=%x SAS="
 		    SAS_ADDR_FMT " attSAS=" SAS_ADDR_FMT " atPHY=%x",
 		    pptr->path,
@@ -4197,7 +4216,7 @@
 			    memcmp(expander->parent->sas_address,
 			    att_sas_address,
 			    sizeof (expander->parent->sas_address)) == 0) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG3,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG3, pptr, NULL,
 				    "%s: skipping port back to parent "
 				    "expander (%s)", __func__, pptr->path);
 				pptr->dtype = NOTHING;
@@ -4206,8 +4225,8 @@
 			pptr->dtype = EXPANDER;
 
 		} else if (tgt_support || ini_support) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s has "
-			    "tgt support=%x init support=(%x)",
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
+			    "%s has tgt support=%x init support=(%x)",
 			    pptr->path, tgt_support, ini_support);
 			pptr->dtype = EXPANDER;
 		}
@@ -4240,7 +4259,7 @@
 		for (ctmp = expander->parent; ctmp; ctmp = ctmp->parent) {
 			if (ctmp->link_rate <
 			    sdr->sdr_negotiated_logical_link_rate) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, pptr, NULL,
 				    "%s: derating link rate from %x to %x due "
 				    "to %s being slower", pptr->path,
 				    sdr->sdr_negotiated_logical_link_rate,
@@ -4348,6 +4367,7 @@
 	p->ptr = NULL;
 	p->arg = NULL;
 	p->phy = NULL;
+	p->abt_htag = 0;
 	p->timer = 0;
 	mutex_exit(&p->lock);
 
@@ -4379,8 +4399,8 @@
 		return (p);
 	}
 	mutex_exit(&p->lock);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2, "INDEX 0x%x HTAG 0x%x got p->htag 0x%x",
-	    idx, htag, p->htag);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL,
+	    "INDEX 0x%x HTAG 0x%x got p->htag 0x%x", idx, htag, p->htag);
 	return (NULL);
 }
 
@@ -4403,8 +4423,8 @@
 	uint32_t abt_htag, status;
 
 	if (pptr->abort_all_start) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: ABORT_ALL for (%s) already"
-		    " in progress.", __func__, pptr->path);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL, "%s: ABORT_ALL for "
+		    "(%s) already in progress.", __func__, pptr->path);
 		return (EBUSY);
 	}
 
@@ -4426,7 +4446,7 @@
 	    pptr);
 
 	if (pwrk == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nowrk, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_nowrk, __func__);
 		return (ENOMEM);
 	}
 
@@ -4436,7 +4456,8 @@
 	}
 	if (pptr->valid_device_id == 0) {
 		pmcs_pwork(pwp, pwrk);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Invalid DeviceID", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
+		    "%s: Invalid DeviceID", __func__);
 		return (ENODEV);
 	}
 	msg[0] = LE_32(PMCS_HIPRI(pwp, PMCS_OQ_GENERAL, abt_type));
@@ -4450,25 +4471,25 @@
 	} else {
 		msg[3] = LE_32(tag);
 		msg[4] = 0;
-		pwrk->ptr = &tag;
+		pwrk->abt_htag = tag;
 	}
 	mutex_enter(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 	ptr = GET_IQ_ENTRY(pwp, PMCS_IQ_OTHER);
 	if (ptr == NULL) {
 		mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 		pmcs_pwork(pwp, pwrk);
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nomsg, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_nomsg, __func__);
 		return (ENOMEM);
 	}
 
 	COPY_MESSAGE(ptr, msg, 5);
 	if (all_cmds) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 		    "%s: aborting all commands for %s device %s. (htag=0x%x)",
 		    __func__, pmcs_get_typename(pptr->dtype), pptr->path,
 		    msg[1]);
 	} else {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 		    "%s: aborting tag 0x%x for %s device %s. (htag=0x%x)",
 		    __func__, tag, pmcs_get_typename(pptr->dtype), pptr->path,
 		    msg[1]);
@@ -4492,7 +4513,7 @@
 	if (tgt != NULL) {
 		mutex_enter(&tgt->aqlock);
 		if (!STAILQ_EMPTY(&tgt->aq)) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
 			    "%s: Abort complete (result=0x%x), but "
 			    "aq not empty (tgt 0x%p), waiting",
 			    __func__, result, (void *)tgt);
@@ -4507,7 +4528,7 @@
 	}
 
 	if (result) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
 		    "%s: Abort (htag 0x%08x) request timed out",
 		    __func__, abt_htag);
 		if (tgt != NULL) {
@@ -4515,7 +4536,7 @@
 			if ((tgt->dev_state != PMCS_DEVICE_STATE_IN_RECOVERY) &&
 			    (tgt->dev_state !=
 			    PMCS_DEVICE_STATE_NON_OPERATIONAL)) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
 				    "%s: Trying DS error recovery for tgt 0x%p",
 				    __func__, (void *)tgt);
 				(void) pmcs_send_err_recovery_cmd(pwp,
@@ -4540,8 +4561,8 @@
 		 * as IO_NOT_VALID really means that the IO or device is
 		 * not there. So, discovery process will take of the cleanup.
 		 */
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: abort result 0x%x",
-		    __func__, LE_32(msg[2]));
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
+		    "%s: abort result 0x%x", __func__, LE_32(msg[2]));
 		if (all_cmds) {
 			PHY_CHANGED(pwp, pptr);
 			RESTART_DISCOVERY(pwp);
@@ -4555,7 +4576,7 @@
 	if (tgt != NULL) {
 		mutex_enter(&tgt->statlock);
 		if (tgt->dev_state == PMCS_DEVICE_STATE_IN_RECOVERY) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
 			    "%s: Restoring OPERATIONAL dev_state for tgt 0x%p",
 			    __func__, (void *)tgt);
 			(void) pmcs_send_err_recovery_cmd(pwp,
@@ -4589,7 +4610,7 @@
 
 	pwrk = pmcs_gwork(pwp, PMCS_TAG_TYPE_WAIT, pptr);
 	if (pwrk == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nowrk, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_nowrk, __func__);
 		return (ENOMEM);
 	}
 	/*
@@ -4616,7 +4637,7 @@
 	if (ptr == NULL) {
 		mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 		pmcs_pwork(pwp, pwrk);
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nomsg, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_nomsg, __func__);
 		return (ENOMEM);
 	}
 	COPY_MESSAGE(ptr, msg, 7);
@@ -4630,16 +4651,16 @@
 			mutex_exit(&xp->statlock);
 			mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 			pmcs_pwork(pwp, pwrk);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Not sending '%s'"
-			    " because DS is '%s'", __func__, pmcs_tmf2str(tmf),
-			    pmcs_status_str
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp, "%s: Not "
+			    "sending '%s' because DS is '%s'", __func__,
+			    pmcs_tmf2str(tmf), pmcs_status_str
 			    (PMCOUT_STATUS_IO_DS_NON_OPERATIONAL));
 			return (EIO);
 		}
 		mutex_exit(&xp->statlock);
 	}
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 	    "%s: sending '%s' to %s (lun %llu) tag 0x%x", __func__,
 	    pmcs_tmf2str(tmf), pptr->path, (unsigned long long) lun, tag);
 	pwrk->state = PMCS_WORK_STATE_ONCHIP;
@@ -4668,7 +4689,7 @@
 
 	status = LE_32(msg[2]);
 	if (status != PMCOUT_STATUS_OK) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: status %s for TMF %s action to %s, lun %llu",
 		    __func__, pmcs_status_str(status),  pmcs_tmf2str(tmf),
 		    pptr->path, (unsigned long long) lun);
@@ -4690,7 +4711,7 @@
 		if (xp != NULL) {
 			mutex_enter(&xp->statlock);
 			if (xp->dev_state != ds) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 				    "%s: Sending err recovery cmd"
 				    " for tgt 0x%p (status = %s)",
 				    __func__, (void *)xp,
@@ -4705,7 +4726,7 @@
 		if (xp != NULL) {
 			mutex_enter(&xp->statlock);
 			if (xp->dev_state != ds) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 				    "%s: Sending err recovery cmd"
 				    " for tgt 0x%p (status = %s)",
 				    __func__, (void *)xp,
@@ -4716,14 +4737,15 @@
 		}
 	}
 	if (LE_32(msg[3]) == 0) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "TMF completed with no response");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
+		    "TMF completed with no response");
 		return (EIO);
 	}
 	pmcs_endian_transform(pwp, local, &msg[5], ssp_rsp_evec);
 	xd = (uint8_t *)(&msg[5]);
 	xd += SAS_RSP_HDR_SIZE;
 	if (rptr->datapres != SAS_RSP_DATAPRES_RESPONSE_DATA) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: TMF response not RESPONSE DATA (0x%x)",
 		    __func__, rptr->datapres);
 		return (EIO);
@@ -4746,41 +4768,43 @@
 	 */
 	switch (status & 0xff) {
 	case SAS_RSP_TMF_COMPLETE:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: TMF complete", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
+		    "%s: TMF complete", __func__);
 		result = 0;
 		break;
 	case SAS_RSP_TMF_SUCCEEDED:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: TMF succeeded", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
+		    "%s: TMF succeeded", __func__);
 		result = 0;
 		break;
 	case SAS_RSP_INVALID_FRAME:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: TMF returned INVALID FRAME", __func__);
 		result = EIO;
 		break;
 	case SAS_RSP_TMF_NOT_SUPPORTED:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: TMF returned TMF NOT SUPPORTED", __func__);
 		result = EIO;
 		break;
 	case SAS_RSP_TMF_FAILED:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: TMF returned TMF FAILED", __func__);
 		result = EIO;
 		break;
 	case SAS_RSP_TMF_INCORRECT_LUN:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: TMF returned INCORRECT LUN", __func__);
 		result = EIO;
 		break;
 	case SAS_RSP_OVERLAPPED_OIPTTA:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: TMF returned OVERLAPPED INITIATOR PORT TRANSFER TAG "
 		    "ATTEMPTED", __func__);
 		result = EIO;
 		break;
 	default:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, xp,
 		    "%s: TMF returned unknown code 0x%x", __func__, status);
 		result = EIO;
 		break;
@@ -4842,15 +4866,15 @@
 	pmcs_lock_phy(pptr);
 	pmcs_pwork(pwp, pwrk);
 
+	tgt = pptr->target;
 	if (result) {
-		pmcs_prt(pwp, PMCS_PRT_INFO, pmcs_timeo, __func__);
+		pmcs_prt(pwp, PMCS_PRT_INFO, pptr, tgt, pmcs_timeo, __func__);
 		return (EIO);
 	}
 	status = LE_32(msg[2]);
 	if (status != PMCOUT_STATUS_OK || LE_32(msg[3])) {
-		tgt = pptr->target;
 		if (tgt == NULL) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
 			    "%s: cannot find target for phy 0x%p for "
 			    "dev state recovery", __func__, (void *)pptr);
 			return (EIO);
@@ -4867,8 +4891,8 @@
 			ds = PMCS_DEVICE_STATE_IN_RECOVERY;
 		}
 		if (tgt->dev_state != ds) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Trying SATA DS Error"
-			    " Recovery for tgt(0x%p) for status(%s)",
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt, "%s: Trying "
+			    "SATA DS Recovery for tgt(0x%p) for status(%s)",
 			    __func__, (void *)tgt, pmcs_status_str(status));
 			(void) pmcs_send_err_recovery_cmd(pwp, ds, tgt);
 		}
@@ -4882,10 +4906,11 @@
 	fis[3] = (fp[16] << 24) | (fp[15] << 16) | (fp[14] << 8) | fp[13];
 	fis[4] = 0;
 	if (fp[0] & 0x80) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, utag_fail_fmt, __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
+		    utag_fail_fmt, __func__);
 	} else {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, tag_fail_fmt, __func__,
-		    fp[0] & 0x1f);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
+		    tag_fail_fmt, __func__, fp[0] & 0x1f);
 	}
 	pmcs_fis_dump(pwp, fis);
 	pptr->need_rl_ext = 0;
@@ -4922,15 +4947,18 @@
 	uint8_t c, *out = orig_out, *in = orig_in;
 
 	if (xfvec == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: null xfvec", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: null xfvec", __func__);
 		return;
 	}
 	if (out == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: null out", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: null out", __func__);
 		return;
 	}
 	if (in == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: null in", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: null in", __func__);
 		return;
 	}
 	while ((c = *xfvec++) != 0) {
@@ -4979,7 +5007,8 @@
 			break;
 		}
 		default:
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: bad size", __func__);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+			    "%s: bad size", __func__);
 			return;
 		}
 	}
@@ -5204,7 +5233,7 @@
 		fwsupport = "Special";
 		break;
 	}
-	pmcs_prt(pwp, PMCS_PRT_INFO,
+	pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
 	    "Chip Revision: %c; F/W Revision %x.%x.%x %s", 'A' + pwp->chiprev,
 	    PMCS_FW_MAJOR(pwp), PMCS_FW_MINOR(pwp), PMCS_FW_MICRO(pwp),
 	    fwsupport);
@@ -5299,7 +5328,7 @@
 	while (pptr) {
 		if (pptr->valid_device_id && (pptr != phyp) &&
 		    (pptr->device_id == device_id)) {
-			pmcs_prt(pptr->pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pptr->pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "%s: phy %s already exists as %s with "
 			    "device id 0x%x", __func__, phyp->path,
 			    pptr->path, device_id);
@@ -5456,7 +5485,8 @@
 {
 	switch (fis[0] & 0xff) {
 	case FIS_REG_H2DEV:
-		pmcs_prt(pwp, PMCS_PRT_INFO, "FIS REGISTER HOST TO DEVICE: "
+		pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
+		    "FIS REGISTER HOST TO DEVICE: "
 		    "OP=0x%02x Feature=0x%04x Count=0x%04x Device=0x%02x "
 		    "LBA=%llu", BYTE2(fis[0]), BYTE3(fis[2]) << 8 |
 		    BYTE3(fis[0]), WORD0(fis[3]), BYTE3(fis[1]),
@@ -5465,15 +5495,16 @@
 		    ((uint64_t)fis[1] & 0x00ffffff)));
 		break;
 	case FIS_REG_D2H:
-		pmcs_prt(pwp, PMCS_PRT_INFO, "FIS REGISTER DEVICE TO HOST: Stat"
-		    "us=0x%02x Error=0x%02x Dev=0x%02x Count=0x%04x LBA=%llu",
+		pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
+		    "FIS REGISTER DEVICE TO HOST: Status=0x%02x "
+		    "Error=0x%02x Dev=0x%02x Count=0x%04x LBA=%llu",
 		    BYTE2(fis[0]), BYTE3(fis[0]), BYTE3(fis[1]), WORD0(fis[3]),
 		    (unsigned long long)(((uint64_t)fis[2] & 0x00ffffff) << 24 |
 		    ((uint64_t)fis[1] & 0x00ffffff)));
 		break;
 	default:
-		pmcs_prt(pwp, PMCS_PRT_INFO, "FIS: 0x%08x 0x%08x 0x%08x 0x%08x "
-		    "0x%08x 0x%08x 0x%08x",
+		pmcs_prt(pwp, PMCS_PRT_INFO, NULL, NULL,
+		    "FIS: 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x",
 		    fis[0], fis[1], fis[2], fis[3], fis[4], fis[5], fis[6]);
 		break;
 	}
@@ -5485,12 +5516,12 @@
 	uint32_t *mb = arg;
 	size_t i;
 
-	pmcs_prt(pwp, level, msg);
+	pmcs_prt(pwp, level, NULL, NULL, msg);
 	for (i = 0; i < (PMCS_QENTRY_SIZE / sizeof (uint32_t)); i += 4) {
-		pmcs_prt(pwp, level, "Offset %2lu: 0x%08x 0x%08x 0x%08"
-		    "x 0x%08x", i * sizeof (uint32_t), LE_32(mb[i]),
-		    LE_32(mb[i+1]), LE_32(mb[i+2]),
-		    LE_32(mb[i+3]));
+		pmcs_prt(pwp, level, NULL, NULL,
+		    "Offset %2lu: 0x%08x 0x%08x 0x%08x 0x%08x",
+		    i * sizeof (uint32_t), LE_32(mb[i]),
+		    LE_32(mb[i+1]), LE_32(mb[i+2]), LE_32(mb[i+3]));
 	}
 }
 
@@ -5510,7 +5541,7 @@
 
 	if (phyp != NULL) {
 		ASSERT(mutex_owned(&phyp->phy_lock));
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, NULL,
 		    "%s: Issuing spinup release only for PHY %s", __func__,
 		    phyp->path);
 		mutex_enter(&pwp->iqp_lock[PMCS_IQ_OTHER]);
@@ -5547,7 +5578,7 @@
 			continue;
 		}
 
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, phyp, NULL,
 		    "%s: Issuing spinup release for PHY %s", __func__,
 		    phyp->path);
 
@@ -5644,7 +5675,7 @@
 	uint32_t msg[PMCS_MSG_SIZE], *ptr, status;
 	struct pmcwork *pwrk;
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG, "kill %s device @ %s",
+	pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL, "kill %s device @ %s",
 	    pmcs_get_typename(pptr->dtype), pptr->path);
 
 	/*
@@ -5656,7 +5687,7 @@
 	 */
 	if (pptr->abort_all_start) {
 		while (pptr->abort_all_start) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "%s: Waiting for outstanding ABORT_ALL on PHY 0x%p",
 			    __func__, (void *)pptr);
 			cv_wait(&pptr->abort_all_cv, &pptr->phy_lock);
@@ -5665,7 +5696,7 @@
 		r = pmcs_abort(pwp, pptr, pptr->device_id, 1, 1);
 
 		if (r) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 			    "%s: ABORT_ALL returned non-zero status (%d) for "
 			    "PHY 0x%p", __func__, r, (void *)pptr);
 			return (r);
@@ -5678,7 +5709,7 @@
 	}
 
 	if ((pwrk = pmcs_gwork(pwp, PMCS_TAG_TYPE_WAIT, pptr)) == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nowrk, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_nowrk, __func__);
 		return (ENOMEM);
 	}
 	pwrk->arg = msg;
@@ -5693,7 +5724,7 @@
 	if (ptr == NULL) {
 		mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 		mutex_exit(&pwrk->lock);
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nomsg, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, pptr, NULL, pmcs_nomsg, __func__);
 		return (ENOMEM);
 	}
 
@@ -5711,7 +5742,7 @@
 	}
 	status = LE_32(msg[2]);
 	if (status != PMCOUT_STATUS_OK) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, NULL,
 		    "%s: status 0x%x when trying to deregister device %s",
 		    __func__, status, pptr->path);
 	}
@@ -5810,7 +5841,8 @@
 	if (tc == NULL) {
 		SCHEDULE_WORK(pwp, PMCS_WORK_ADD_DMA_CHUNKS);
 		mutex_exit(&pwp->dma_lock);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG2, "%s: out of SG lists", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL,
+		    "%s: out of SG lists", __func__);
 		return (-1);
 	}
 	pwp->dma_freelist = tc->nxt;
@@ -5852,7 +5884,7 @@
 				SCHEDULE_WORK(pwp, PMCS_WORK_ADD_DMA_CHUNKS);
 				mutex_exit(&pwp->dma_lock);
 				pmcs_dma_unload(pwp, sp);
-				pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL,
 				    "%s: out of SG lists", __func__);
 				return (-1);
 			}
@@ -5939,7 +5971,7 @@
 	}
 	np->nxt = pwp->dma_freelist;
 	pwp->dma_freelist = dcp;
-	pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG2, NULL, NULL,
 	    "added %lu DMA chunks ", n);
 }
 
@@ -6036,8 +6068,8 @@
 
 	if (ddi_dma_sync(pwp->cip_handles, 0, 0, DDI_DMA_SYNC_FORKERNEL) !=
 	    DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: ddi_dma_sync failed?",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: ddi_dma_sync failed?", __func__);
 	}
 
 	iqci = LE_32(
@@ -6053,8 +6085,8 @@
 
 	if (ddi_dma_sync(pwp->cip_handles, 0, 0, DDI_DMA_SYNC_FORKERNEL) !=
 	    DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: ddi_dma_sync failed?",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: ddi_dma_sync failed?", __func__);
 	}
 
 	oqpi = LE_32(
@@ -6078,7 +6110,8 @@
 	drv_usecwait(10);
 	if (ddi_get32(pwp->top_acc_handle,
 	    &pwp->top_regs[PMCS_AXI_TRANS >> 2]) != newaxil) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "AXIL register update failed");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "AXIL register update failed");
 	}
 	rv = ddi_get32(pwp->gsm_acc_handle, &pwp->gsm_regs[off >> 2]);
 	ddi_put32(pwp->top_acc_handle,
@@ -6086,7 +6119,8 @@
 	drv_usecwait(10);
 	if (ddi_get32(pwp->top_acc_handle,
 	    &pwp->top_regs[PMCS_AXI_TRANS >> 2]) != oldaxil) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "AXIL register restore failed");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "AXIL register restore failed");
 	}
 	mutex_exit(&pwp->axil_lock);
 	return (rv);
@@ -6107,7 +6141,8 @@
 	drv_usecwait(10);
 	if (ddi_get32(pwp->top_acc_handle,
 	    &pwp->top_regs[PMCS_AXI_TRANS >> 2]) != newaxil) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "AXIL register update failed");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "AXIL register update failed");
 	}
 	ddi_put32(pwp->gsm_acc_handle, &pwp->gsm_regs[off >> 2], val);
 	ddi_put32(pwp->top_acc_handle,
@@ -6115,7 +6150,8 @@
 	drv_usecwait(10);
 	if (ddi_get32(pwp->top_acc_handle,
 	    &pwp->top_regs[PMCS_AXI_TRANS >> 2]) != oldaxil) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "AXIL register restore failed");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "AXIL register restore failed");
 	}
 	mutex_exit(&pwp->axil_lock);
 }
@@ -6240,8 +6276,8 @@
 	((uint32_t *)((void *)pwp->cip))[IQ_OFFSET(qnum) >> 2] = val;
 	if (ddi_dma_sync(pwp->cip_handles, 0, 0, DDI_DMA_SYNC_FORDEV) !=
 	    DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: ddi_dma_sync failed?",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: ddi_dma_sync failed?", __func__);
 	}
 }
 
@@ -6265,8 +6301,8 @@
 	((uint32_t *)((void *)pwp->cip))[OQ_OFFSET(qnum) >> 2] = val;
 	if (ddi_dma_sync(pwp->cip_handles, 0, 0, DDI_DMA_SYNC_FORDEV) !=
 	    DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: ddi_dma_sync failed?",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: ddi_dma_sync failed?", __func__);
 	}
 }
 
@@ -6367,8 +6403,8 @@
 
 	ASSERT(mutex_owned(&xp->statlock));
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Device 0x%p is gone.", __func__,
-	    (void *)xp);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, xp, "%s: Device 0x%p is gone.",
+	    __func__, (void *)xp);
 
 	/*
 	 * Clear the dip now.  This keeps pmcs_remove_device from attempting
@@ -6406,37 +6442,44 @@
 
 	switch (result) {
 	case SMP_RES_UNKNOWN_FUNCTION:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: SMP DISCOVER Response "
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: SMP DISCOVER Response "
 		    "Function Result: Unknown SMP Function(0x%x)",
 		    __func__, result);
 		break;
 	case SMP_RES_FUNCTION_FAILED:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: SMP DISCOVER Response "
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: SMP DISCOVER Response "
 		    "Function Result: SMP Function Failed(0x%x)",
 		    __func__, result);
 		break;
 	case SMP_RES_INVALID_REQUEST_FRAME_LENGTH:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: SMP DISCOVER Response "
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: SMP DISCOVER Response "
 		    "Function Result: Invalid Request Frame Length(0x%x)",
 		    __func__, result);
 		break;
 	case SMP_RES_INCOMPLETE_DESCRIPTOR_LIST:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: SMP DISCOVER Response "
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: SMP DISCOVER Response "
 		    "Function Result: Incomplete Descriptor List(0x%x)",
 		    __func__, result);
 		break;
 	case SMP_RES_PHY_DOES_NOT_EXIST:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: SMP DISCOVER Response "
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: SMP DISCOVER Response "
 		    "Function Result: PHY does not exist(0x%x)",
 		    __func__, result);
 		break;
 	case SMP_RES_PHY_VACANT:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: SMP DISCOVER Response "
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: SMP DISCOVER Response "
 		    "Function Result: PHY Vacant(0x%x)",
 		    __func__, result);
 		break;
 	default:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: SMP DISCOVER Response "
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: SMP DISCOVER Response "
 		    "Function Result: (0x%x)",
 		    __func__, result);
 		break;
@@ -6478,13 +6521,15 @@
 
 	if (ddi_dma_alloc_handle(dip, dma_attr, DDI_DMA_SLEEP, NULL, dmah) !=
 	    DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "Failed to allocate DMA handle");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "Failed to allocate DMA handle");
 		return (B_FALSE);
 	}
 
 	if (ddi_dma_mem_alloc(*dmah, length, &mattr, ddma_flag, DDI_DMA_SLEEP,
 	    NULL, kvp, &real_length, acch) != DDI_SUCCESS) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "Failed to allocate DMA mem");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "Failed to allocate DMA mem");
 		ddi_dma_free_handle(dmah);
 		*dmah = NULL;
 		return (B_FALSE);
@@ -6493,7 +6538,7 @@
 	if (ddi_dma_addr_bind_handle(*dmah, NULL, *kvp, real_length,
 	    ddabh_flag, DDI_DMA_SLEEP, NULL, &cookie, &cookie_cnt)
 	    != DDI_DMA_MAPPED) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "Failed to bind DMA");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL, "Failed to bind DMA");
 		ddi_dma_free_handle(dmah);
 		ddi_dma_mem_free(acch);
 		*dmah = NULL;
@@ -6502,10 +6547,10 @@
 	}
 
 	if (cookie_cnt != 1) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "Multiple cookies");
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL, "Multiple cookies");
 		if (ddi_dma_unbind_handle(*dmah) != DDI_SUCCESS) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG, "Condition failed at "
-			    "%s():%d", __func__, __LINE__);
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL, "Condition "
+			    "failed at %s():%d", __func__, __LINE__);
 		}
 		ddi_dma_free_handle(dmah);
 		ddi_dma_mem_free(acch);
@@ -6531,7 +6576,7 @@
 	ASSERT(pwp != NULL);
 	ASSERT(tgt != NULL);
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, tgt,
 	    "%s: Flushing queues (%d) for target 0x%p", __func__,
 	    queues, (void *)tgt);
 
@@ -6543,7 +6588,7 @@
 		mutex_enter(&tgt->wqlock);
 		while ((sp = STAILQ_FIRST(&tgt->wq)) != NULL) {
 			STAILQ_REMOVE(&tgt->wq, sp, pmcs_cmd, cmd_next);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG1,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG1, NULL, tgt,
 			    "%s: Removing cmd 0x%p from wq for target 0x%p",
 			    __func__, (void *)sp, (void *)tgt);
 			CMD2PKT(sp)->pkt_reason = CMD_DEV_GONE;
@@ -6579,7 +6624,7 @@
 				CMD2PKT(sp)->pkt_state = STATE_GOT_BUS;
 				pmcs_complete_work_impl(pwp, pwrk, NULL, 0);
 			}
-			pmcs_prt(pwp, PMCS_PRT_DEBUG1,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG1, NULL, tgt,
 			    "%s: Removing cmd 0x%p from aq for target 0x%p",
 			    __func__, (void *)sp, (void *)tgt);
 			pmcs_dma_unload(pwp, sp);
@@ -6595,7 +6640,7 @@
 	if (queues & PMCS_TGT_SPECIAL_QUEUE) {
 		while ((sp = STAILQ_FIRST(&tgt->sq)) != NULL) {
 			STAILQ_REMOVE(&tgt->sq, sp, pmcs_cmd, cmd_next);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG1,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG1, NULL, tgt,
 			    "%s: Removing cmd 0x%p from sq for target 0x%p",
 			    __func__, (void *)sp, (void *)tgt);
 			CMD2PKT(sp)->pkt_reason = CMD_DEV_GONE;
@@ -6637,7 +6682,8 @@
 		 * We will leak a structure here if we don't know
 		 * what happened
 		 */
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Unknown PMCS_TAG_TYPE (%x)",
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: Unknown PMCS_TAG_TYPE (%x)",
 		    __func__, PMCS_TAG_TYPE(pwrk->htag));
 		break;
 	}
@@ -6689,20 +6735,20 @@
 	ASSERT(mutex_owned(&pwp->lock));
 
 	if (!target->ua) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
-		    "%s: target %p iport addres is null",
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, target,
+		    "%s: target %p iport address is null",
 		    __func__, (void *)target);
 	}
 
 	iport = pmcs_get_iport_by_ua(pwp, target->ua);
 	if (iport == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, target,
 		    "%s: no iport associated with tgt(0x%p)",
 		    __func__, (void *)target);
 		return;
 	}
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, NULL, target,
 	    "%s: free target %p", __func__, (void *)target);
 	if (target->ua) {
 		strfree(target->ua);
@@ -6729,9 +6775,11 @@
 	struct pmcwork *pwrk;
 	pmcs_phy_t *phyp;
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG3, "%s: tgt(0x%p)", __func__, (void *)xp);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG3, NULL, xp, "%s: tgt(0x%p)", __func__,
+	    (void *)xp);
 	if (xp == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Target is NULL", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, xp,
+		    "%s: Target is NULL", __func__);
 		return (-1);
 	}
 
@@ -6741,7 +6789,7 @@
 
 	pwrk = pmcs_gwork(pwp, PMCS_TAG_TYPE_WAIT, phyp);
 	if (pwrk == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nowrk, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, phyp, xp, pmcs_nowrk, __func__);
 		return (-1);
 	}
 	pwrk->arg = msg;
@@ -6749,7 +6797,8 @@
 
 	if (phyp->valid_device_id == 0) {
 		pmcs_pwork(pwp, pwrk);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Invalid DeviceID", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, phyp, xp,
+		    "%s: Invalid DeviceID", __func__);
 		return (-1);
 	}
 	htag = pwrk->htag;
@@ -6763,7 +6812,7 @@
 	if (ptr == NULL) {
 		mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 		pmcs_pwork(pwp, pwrk);
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nomsg, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, phyp, xp, pmcs_nomsg, __func__);
 		return (-1);
 	}
 	COPY_MESSAGE(ptr, msg, PMCS_MSG_SIZE);
@@ -6778,20 +6827,20 @@
 
 	if (result) {
 		pmcs_timed_out(pwp, htag, __func__);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: cmd timed out, returning ",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, phyp, xp,
+		    "%s: cmd timed out, returning ", __func__);
 		return (-1);
 	}
 	if (LE_32(msg[2]) == 0) {
 		*ds = (uint8_t)(LE_32(msg[4]));
 		if (*ds !=  xp->dev_state) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, phyp, xp,
 			    "%s: retrieved_ds=0x%x, target_ds=0x%x", __func__,
 			    *ds, xp->dev_state);
 		}
 		return (0);
 	} else {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, phyp, xp,
 		    "%s: cmd failed Status(0x%x), returning ", __func__,
 		    LE_32(msg[2]));
 		return (-1);
@@ -6810,28 +6859,29 @@
 	struct pmcwork *pwrk;
 	pmcs_phy_t *phyp;
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, "%s: ds(0x%x), tgt(0x%p)",
-	    __func__, ds, (void *)xp);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, NULL, xp,
+	    "%s: ds(0x%x), tgt(0x%p)", __func__, ds, (void *)xp);
 	if (xp == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Target is Null", __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, xp,
+		    "%s: Target is Null", __func__);
 		return (-1);
 	}
 
 	phyp = xp->phy;
 	pwrk = pmcs_gwork(pwp, PMCS_TAG_TYPE_WAIT, phyp);
 	if (pwrk == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nowrk, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, phyp, xp, pmcs_nowrk, __func__);
 		return (-1);
 	}
 	if (phyp == NULL) {
 		pmcs_pwork(pwp, pwrk);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, "%s: PHY is Null",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, phyp, xp,
+		    "%s: PHY is Null", __func__);
 		return (-1);
 	}
 	if (phyp->valid_device_id == 0) {
 		pmcs_pwork(pwp, pwrk);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, phyp, xp,
 		    "%s: Invalid DeviceID", __func__);
 		return (-1);
 	}
@@ -6849,7 +6899,7 @@
 	if (ptr == NULL) {
 		mutex_exit(&pwp->iqp_lock[PMCS_IQ_OTHER]);
 		pmcs_pwork(pwp, pwrk);
-		pmcs_prt(pwp, PMCS_PRT_ERR, pmcs_nomsg, __func__);
+		pmcs_prt(pwp, PMCS_PRT_ERR, phyp, xp, pmcs_nomsg, __func__);
 		return (-1);
 	}
 	COPY_MESSAGE(ptr, msg, PMCS_MSG_SIZE);
@@ -6865,19 +6915,19 @@
 
 	if (result) {
 		pmcs_timed_out(pwp, htag, __func__);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, phyp, xp,
 		    "%s: cmd timed out, returning", __func__);
 		return (-1);
 	}
 	if (LE_32(msg[2]) == 0) {
 		pds = (uint8_t)(LE_32(msg[4]) >> 4);
 		nds = (uint8_t)(LE_32(msg[4]) & 0x0000000f);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, "%s: previous_ds=0x%x, "
-		    "new_ds=0x%x", __func__, pds, nds);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, phyp, xp,
+		    "%s: previous_ds=0x%x, new_ds=0x%x", __func__, pds, nds);
 		xp->dev_state = nds;
 		return (0);
 	} else {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, phyp, xp,
 		    "%s: cmd failed Status(0x%x), returning ", __func__,
 		    LE_32(msg[2]));
 		return (-1);
@@ -6934,7 +6984,7 @@
 		tgt = pptr->target;
 		if (tgt == NULL || tgt->dev_gone) {
 			if (pptr->dtype != NOTHING) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG2,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG2, pptr, tgt,
 				    "%s: no target for DS error recovery for "
 				    "PHY 0x%p", __func__, (void *)pptr);
 			}
@@ -6952,7 +7002,7 @@
 		 */
 		rc = pmcs_get_dev_state(pwp, tgt, &ds);
 		if (rc != 0) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
 			    "%s: pmcs_get_dev_state on PHY %s "
 			    "failed (rc=%d)",
 			    __func__, pptr->path, rc);
@@ -6965,20 +7015,20 @@
 
 		if ((tgt->dev_state == ds) &&
 		    (ds == PMCS_DEVICE_STATE_IN_RECOVERY)) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, tgt,
 			    "%s: Target 0x%p already IN_RECOVERY", __func__,
 			    (void *)tgt);
 		} else {
 			tgt->dev_state = ds;
 			ds = PMCS_DEVICE_STATE_IN_RECOVERY;
 			rc = pmcs_send_err_recovery_cmd(pwp, ds, tgt);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, tgt,
 			    "%s: pmcs_send_err_recovery_cmd "
 			    "result(%d) tgt(0x%p) ds(0x%x) tgt->ds(0x%x)",
 			    __func__, rc, (void *)tgt, ds, tgt->dev_state);
 
 			if (rc) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
 				    "%s: pmcs_send_err_recovery_cmd to PHY %s "
 				    "failed (rc=%d)",
 				    __func__, pptr->path, rc);
@@ -6994,7 +7044,7 @@
 		/*
 		 * Step 2: Perform a hard reset on the PHY
 		 */
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, tgt,
 		    "%s: Issue HARD_RESET to PHY %s", __func__, pptr->path);
 		/*
 		 * Must release statlock here because pmcs_reset_phy will
@@ -7004,7 +7054,7 @@
 		rc = pmcs_reset_phy(pwp, pptr, PMCS_PHYOP_HARD_RESET);
 		mutex_enter(&tgt->statlock);
 		if (rc) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
 			    "%s: HARD_RESET to PHY %s failed (rc=%d)",
 			    __func__, pptr->path, rc);
 
@@ -7019,7 +7069,7 @@
 		 */
 		if (pptr->abort_all_start) {
 			while (pptr->abort_all_start) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
 				    "%s: Waiting for outstanding ABORT_ALL on "
 				    "PHY 0x%p", __func__, (void *)pptr);
 				cv_wait(&pptr->abort_all_cv, &pptr->phy_lock);
@@ -7030,7 +7080,7 @@
 			mutex_enter(&tgt->statlock);
 			if (rc != 0) {
 				pptr->abort_pending = 1;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
 				    "%s: pmcs_abort to PHY %s failed (rc=%d)",
 				    __func__, pptr->path, rc);
 
@@ -7044,7 +7094,7 @@
 		/*
 		 * Step 4: Set the device back to OPERATIONAL state
 		 */
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, tgt,
 		    "%s: Set PHY/tgt 0x%p/0x%p to OPERATIONAL state",
 		    __func__, (void *)pptr, (void *)tgt);
 		rc = pmcs_set_dev_state(pwp, tgt,
@@ -7062,7 +7112,7 @@
 				    pwp, DDI_NOSLEEP);
 			}
 		} else {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, tgt,
 			    "%s: Failed to SET tgt 0x%p to OPERATIONAL state",
 			    __func__, (void *)tgt);
 
@@ -7111,20 +7161,20 @@
 	pptr = tgt->phy;
 
 	if (pptr == NULL) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, "%s: PHY is Null",
-		    __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, tgt,
+		    "%s: PHY is Null", __func__);
 		return (-1);
 	}
 
 	ASSERT(mutex_owned(&pptr->phy_lock));
 
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, "%s: ds: 0x%x, tgt ds(0x%x)",
-	    __func__, dev_state, tgt->dev_state);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, tgt,
+	    "%s: ds: 0x%x, tgt ds(0x%x)", __func__, dev_state, tgt->dev_state);
 
 	switch (dev_state) {
 	case PMCS_DEVICE_STATE_IN_RECOVERY:
 		if (tgt->dev_state == PMCS_DEVICE_STATE_IN_RECOVERY) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, tgt,
 			    "%s: Target 0x%p already IN_RECOVERY", __func__,
 			    (void *)tgt);
 			rc = 0;	/* This is not an error */
@@ -7134,7 +7184,7 @@
 		rc = pmcs_set_dev_state(pwp, tgt,
 		    PMCS_DEVICE_STATE_IN_RECOVERY);
 		if (rc != 0) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, tgt,
 			    "%s(1): Failed to SET tgt(0x%p) to _IN_RECOVERY",
 			    __func__, (void *)tgt);
 		}
@@ -7143,7 +7193,7 @@
 
 	case PMCS_DEVICE_STATE_OPERATIONAL:
 		if (tgt->dev_state != PMCS_DEVICE_STATE_IN_RECOVERY) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, tgt,
 			    "%s: Target 0x%p not ready to go OPERATIONAL",
 			    __func__, (void *)tgt);
 			goto no_action;
@@ -7153,7 +7203,7 @@
 		    PMCS_DEVICE_STATE_OPERATIONAL);
 		tgt->reset_success = 1;
 		if (rc != 0) {
-			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, tgt,
 			    "%s(2): Failed to SET tgt(0x%p) to OPERATIONAL",
 			    __func__, (void *)tgt);
 			tgt->reset_success = 0;
@@ -7164,7 +7214,7 @@
 	case PMCS_DEVICE_STATE_NON_OPERATIONAL:
 		PHY_CHANGED(pwp, pptr);
 		RESTART_DISCOVERY(pwp);
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, tgt,
 		    "%s: Device at %s is non-operational",
 		    __func__, pptr->path);
 		tgt->dev_state = PMCS_DEVICE_STATE_NON_OPERATIONAL;
@@ -7173,7 +7223,7 @@
 		break;
 
 	default:
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_DEV_STATE, pptr, tgt,
 		    "%s: Invalid state requested (%d)", __func__,
 		    dev_state);
 		break;
@@ -7221,8 +7271,8 @@
 		 * at level > 0, traverse children while locking everything.
 		 */
 		if ((level > 0) || (tphyp == phyp)) {
-			pmcs_prt(tphyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING,
-			    "%s: PHY 0x%p parent 0x%p path %s lvl %d",
+			pmcs_prt(tphyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING, tphyp,
+			    NULL, "%s: PHY 0x%p parent 0x%p path %s lvl %d",
 			    __func__, (void *)tphyp, (void *)tphyp->parent,
 			    tphyp->path, level);
 			mutex_enter(&tphyp->phy_lock);
@@ -7257,16 +7307,16 @@
 	callername = modgetsymname((uintptr_t)caller(), &off);
 
 	if (callername == NULL) {
-		pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING,
+		pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING, phyp, NULL,
 		    "%s: PHY 0x%p path %s caller: unknown", __func__,
 		    (void *)phyp, phyp->path);
 	} else {
-		pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING,
+		pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING, phyp, NULL,
 		    "%s: PHY 0x%p path %s caller: %s+%lx", __func__,
 		    (void *)phyp, phyp->path, callername, off);
 	}
 #else
-	pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING,
+	pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING, phyp, NULL,
 	    "%s: PHY 0x%p path %s", __func__, (void *)phyp, phyp->path);
 #endif
 	pmcs_lock_phy_impl(phyp, 0);
@@ -7310,6 +7360,7 @@
 	while (phy_next) {
 		if ((level > 0) || (phy_next == phyp)) {
 			pmcs_prt(phy_next->pwp, PMCS_PRT_DEBUG_PHY_LOCKING,
+			    phy_next, NULL,
 			    "%s: PHY 0x%p parent 0x%p path %s lvl %d",
 			    __func__, (void *)phy_next,
 			    (void *)phy_next->parent, phy_next->path, level);
@@ -7341,16 +7392,16 @@
 	callername = modgetsymname((uintptr_t)caller(), &off);
 
 	if (callername == NULL) {
-		pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING,
+		pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING, phyp, NULL,
 		    "%s: PHY 0x%p path %s caller: unknown", __func__,
 		    (void *)phyp, phyp->path);
 	} else {
-		pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING,
+		pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING, phyp, NULL,
 		    "%s: PHY 0x%p path %s caller: %s+%lx", __func__,
 		    (void *)phyp, phyp->path, callername, off);
 	}
 #else
-	pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING,
+	pmcs_prt(phyp->pwp, PMCS_PRT_DEBUG_PHY_LOCKING, phyp, NULL,
 	    "%s: PHY 0x%p path %s", __func__, (void *)phyp, phyp->path);
 #endif
 	pmcs_unlock_phy_impl(phyp, 0);
@@ -7393,8 +7444,9 @@
 		if (pchunk->dma_handle) {
 			if (ddi_dma_unbind_handle(pchunk->dma_handle) !=
 			    DDI_SUCCESS) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG, "Condition failed"
-				    " at %s():%d", __func__, __LINE__);
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+				    "Condition failed at %s():%d",
+				    __func__, __LINE__);
 			}
 			ddi_dma_free_handle(&pchunk->dma_handle);
 			ddi_dma_mem_free(&pchunk->acc_handle);
@@ -7444,8 +7496,9 @@
 		 * as changed, killing of a target would take care of aborting
 		 * commands for the device.
 		 */
-		pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: No valid target for event "
-		    "processing found. Scheduling RECONFIGURE",  __func__);
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, NULL, NULL,
+		    "%s: No valid target for event processing found. "
+		    "Scheduling RECONFIGURE",  __func__);
 		pmcs_pwork(pwp, pwrk);
 		RESTART_DISCOVERY(pwp);
 		return;
@@ -7455,9 +7508,9 @@
 		if (event == PMCOUT_STATUS_OPEN_CNX_ERROR_IT_NEXUS_LOSS) {
 			if (tgt->dev_state !=
 			    PMCS_DEVICE_STATE_NON_OPERATIONAL) {
-				pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: Device at "
-				    "%s is non-operational", __func__,
-				    pptr->path);
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
+				    "%s: Device at %s is non-operational",
+				    __func__, pptr->path);
 				tgt->dev_state =
 				    PMCS_DEVICE_STATE_NON_OPERATIONAL;
 			}
@@ -7496,7 +7549,7 @@
 		mutex_exit(&tgt->statlock);
 		pmcs_unlock_phy(pptr);
 		pwrk->ssp_event = event;
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
 		    "%s: Scheduling SSP event recovery for tgt(0x%p) "
 		    "pwrk(%p) tag(0x%x)", __func__, (void *)tgt, (void *)pwrk,
 		    pwrk->htag);
@@ -7530,7 +7583,7 @@
 
 	ASSERT(pwrk->arg != NULL);
 	ASSERT(pwrk->xp != NULL);
-	pmcs_prt(pwp, PMCS_PRT_DEBUG, "%s: event recovery for "
+	pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt, "%s: event recovery for "
 	    "target 0x%p", __func__, (void *)pwrk->xp);
 	htag = pwrk->htag;
 	event = pwrk->ssp_event;
@@ -7546,7 +7599,7 @@
 		}
 		if (status == SAS_RSP_TMF_COMPLETE) {
 			/* Command NOT pending on a device */
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
 			    "%s: No pending command for tgt 0x%p",
 			    __func__, (void *)tgt);
 			/* Nothing more to do, just abort it on chip */
@@ -7576,7 +7629,7 @@
 
 	if ((tgt->dev_state != PMCS_DEVICE_STATE_IN_RECOVERY) &&
 	    (tgt->dev_state != PMCS_DEVICE_STATE_NON_OPERATIONAL)) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, pptr, tgt,
 		    "%s: Setting IN_RECOVERY for tgt 0x%p",
 		    __func__, (void *)tgt);
 		(void) pmcs_send_err_recovery_cmd(pwp,
@@ -7616,7 +7669,7 @@
 			if (pphy != NULL && er_flag != 0) {
 				pmcs_lock_phy(pphy);
 				mutex_enter(&tgt->statlock);
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pphy, tgt,
 				    "%s: found target(0x%p)", __func__,
 				    (void *) tgt);
 
@@ -7643,7 +7696,7 @@
 					    pwrk->ssp_event !=
 					    PMCS_REC_EVENT) {
 						pmcs_prt(pwp,
-						    PMCS_PRT_DEBUG,
+						    PMCS_PRT_DEBUG, pphy, tgt,
 						    "%s: pwrk(%p) ctag(0x%x)",
 						    __func__, (void *) pwrk,
 						    cp->cmd_tag);
@@ -7661,7 +7714,7 @@
 				}
 				mutex_exit(&tgt->aqlock);
 				tgt->event_recovery = 0;
-				pmcs_prt(pwp, PMCS_PRT_DEBUG,
+				pmcs_prt(pwp, PMCS_PRT_DEBUG, pphy, tgt,
 				    "%s: end of SSP event recovery for "
 				    "target(0x%p)", __func__, (void *) tgt);
 				mutex_exit(&tgt->statlock);
@@ -7669,9 +7722,8 @@
 			}
 		}
 	}
-	pmcs_prt(pwp, PMCS_PRT_DEBUG,
-	    "%s: end of SSP event recovery for pwp(0x%p)", __func__,
-	    (void *) pwp);
+	pmcs_prt(pwp, PMCS_PRT_DEBUG, pphy, tgt, "%s: "
+	    "end of SSP event recovery for pwp(0x%p)", __func__, (void *) pwp);
 }
 
 /*ARGSUSED2*/
@@ -7945,7 +7997,7 @@
 			pphyp = phyp;	/* This PHY becomes "previous" */
 		} else if (phyp->target) {
 			pmcs_unlock_phy(phyp);
-			pmcs_prt(pwp, PMCS_PRT_DEBUG1,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG1, phyp, phyp->target,
 			    "%s: Not freeing PHY 0x%p: target 0x%p is not free",
 			    __func__, (void *)phyp, (void *)phyp->target);
 			pphyp = phyp;
@@ -7954,7 +8006,7 @@
 			 * No outstanding work or target references. Remove it
 			 * from the list and free it
 			 */
-			pmcs_prt(pwp, PMCS_PRT_DEBUG,
+			pmcs_prt(pwp, PMCS_PRT_DEBUG, phyp, phyp->target,
 			    "%s: Freeing inactive dead PHY 0x%p @ %s "
 			    "target = 0x%p", __func__, (void *)phyp,
 			    phyp->path, (void *)phyp->target);
@@ -8062,7 +8114,7 @@
 	 * on the new PHY to compensate.
 	 */
 	if (ctmp) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, ctmp, NULL,
 		    "%s: Found match in dead PHY list for new PHY %s",
 		    __func__, phyp->path);
 		if (ctmp->target) {
@@ -8183,7 +8235,7 @@
 	ASSERT(xp->pwp != NULL);
 
 	if (xp->recover_wait == 0) {
-		pmcs_prt(xp->pwp, PMCS_PRT_DEBUG_DEV_STATE,
+		pmcs_prt(xp->pwp, PMCS_PRT_DEBUG_DEV_STATE, phyp, xp,
 		    "%s: Start ds_recovery for tgt 0x%p/PHY 0x%p (%s)",
 		    __func__, (void *)xp, (void *)phyp, phyp->path);
 		xp->recover_wait = 1;
@@ -8212,7 +8264,7 @@
 	phyp->ds_recovery_retries++;
 
 	if (phyp->ds_recovery_retries > PMCS_MAX_DS_RECOVERY_RETRIES) {
-		pmcs_prt(pwp, PMCS_PRT_DEBUG,
+		pmcs_prt(pwp, PMCS_PRT_DEBUG, phyp, tgt,
 		    "%s: retry limit reached after %s to PHY %s failed",
 		    func_name, reason_string, phyp->path);
 		tgt->recover_wait = 0;
--- a/usr/src/uts/common/sys/scsi/adapters/pmcs/pmcs_def.h	Thu Nov 12 10:26:22 2009 +0800
+++ b/usr/src/uts/common/sys/scsi/adapters/pmcs/pmcs_def.h	Wed Nov 11 19:33:15 2009 -0700
@@ -192,6 +192,7 @@
 	pmcs_phy_t 		*phy;	/* phy who owns this command */
 	pmcs_xscsi_t		*xp;	/* Back pointer to xscsi struct */
 	volatile uint32_t	htag;	/* tag for this structure */
+	uint32_t		abt_htag; /* Tag of command to be aborted */
 	uint32_t
 			timer	:	27,
 			onwire	:	1,
@@ -357,13 +358,13 @@
 	SCHEDULE_WORK(pwp, PMCS_WORK_DISCOVER);
 
 #define	PHY_CHANGED(pwp, p)						\
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s changed in %s line %d", \
-	    p->path, __func__, __LINE__);				\
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, p, NULL, "%s changed in "  \
+	    "%s line %d", p->path, __func__, __LINE__); 		\
 	p->changed = 1
 
 #define	PHY_CHANGED_AT_LOCATION(pwp, p, func, line)			\
-	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, "%s changed in %s line %d", \
-	    p->path, func, line);					\
+	pmcs_prt(pwp, PMCS_PRT_DEBUG_CONFIG, p, NULL, "%s changed in "  \
+	    "%s line %d", p->path, func, line);				\
 	p->changed = 1
 
 #define	PHY_TYPE(pptr)					\
@@ -485,7 +486,16 @@
 #define	PMCS_TBUF_NUM_ELEMS_DEF	15000
 #endif
 
+#define	PMCS_TBUF_UA_MAX_SIZE	32
 typedef struct {
+	/* Target-specific data */
+	uint16_t	target_num;
+	char		target_ua[PMCS_TBUF_UA_MAX_SIZE];
+	/* PHY-specific data */
+	uint8_t 	phy_sas_address[8];
+	char		phy_path[32];
+	pmcs_dtype_t	phy_dtype;
+	/* Log data */
 	timespec_t	timestamp;
 	char		buf[PMCS_TBUF_ELEM_SIZE];
 } pmcs_tbuf_t;
--- a/usr/src/uts/common/sys/scsi/adapters/pmcs/pmcs_iomb.h	Thu Nov 12 10:26:22 2009 +0800
+++ b/usr/src/uts/common/sys/scsi/adapters/pmcs/pmcs_iomb.h	Wed Nov 11 19:33:15 2009 -0700
@@ -651,14 +651,14 @@
 	INCQI(hwp->shadow_iqpi[qnum], hwp->ioq_depth);			\
 	if (ddi_dma_sync(hwp->cip_handles, 0, 0,			\
 	    DDI_DMA_SYNC_FORDEV) != DDI_SUCCESS) {			\
-		pmcs_prt(hwp, PMCS_PRT_DEBUG, "Condition failed at "	\
-		    " %s():%d", __func__, __LINE__);			\
+		pmcs_prt(hwp, PMCS_PRT_DEBUG, NULL, NULL, "Condition "	\
+		    "failed at %s():%d", __func__, __LINE__);		\
 	}								\
+	hwp->ftime[hwp->fti] = gethrtime();				\
 	pmcs_wr_iqpi(hwp, qnum, hwp->shadow_iqpi[qnum]);		\
 	mutex_exit(&(hwp)->iqp_lock[qnum]);				\
 	mutex_enter(&(hwp)->dbglock);					\
 	hwp->ftag_lines[hwp->fti] = __LINE__;				\
-	hwp->ftime[hwp->fti] = gethrtime();				\
 	hwp->ftags[hwp->fti++] = htag;					\
 	mutex_exit(&(hwp)->dbglock);					\
 }
@@ -667,8 +667,8 @@
 	INCQI(hwp->shadow_iqpi[qnum], hwp->ioq_depth);			\
 	if (ddi_dma_sync(hwp->cip_handles, 0, 0,			\
 	    DDI_DMA_SYNC_FORDEV) != DDI_SUCCESS) {			\
-		pmcs_prt(hwp, PMCS_PRT_DEBUG, "Condition failed at "	\
-		    " %s():%d", __func__, __LINE__);			\
+		pmcs_prt(hwp, PMCS_PRT_DEBUG, NULL, NULL, "Condition "	\
+		    "failed at %s():%d", __func__, __LINE__);		\
 	}								\
 	pmcs_wr_iqpi(hwp, qnum, hwp->shadow_iqpi[qnum]);		\
 	mutex_exit(&(hwp)->iqp_lock[qnum])
--- a/usr/src/uts/common/sys/scsi/adapters/pmcs/pmcs_proto.h	Thu Nov 12 10:26:22 2009 +0800
+++ b/usr/src/uts/common/sys/scsi/adapters/pmcs/pmcs_proto.h	Wed Nov 11 19:33:15 2009 -0700
@@ -50,18 +50,18 @@
 	PMCS_PRT_ERR
 } pmcs_prt_level_t;
 
-#define	pmcs_prt(pwp, level, fmt...) {			\
-	int lvl = level;				\
-	if (((pwp->debug_mask & (1 << lvl)) != 0) ||	\
-	    (lvl > PMCS_PRT_DEBUG_DEVEL)) {		\
-		pmcs_prt_impl(pwp, lvl, fmt);		\
-	}						\
+#define	pmcs_prt(pwp, level, phy, tgt, fmt...) {		\
+	int lvl = level;					\
+	if (((pwp->debug_mask & (1 << lvl)) != 0) ||		\
+	    (lvl > PMCS_PRT_DEBUG_DEVEL)) {			\
+		pmcs_prt_impl(pwp, lvl, phy, tgt, fmt);	\
+	}							\
 }
 
-/*PRINTFLIKE3*/
+/*PRINTFLIKE5*/
 void
-pmcs_prt_impl(pmcs_hw_t *, pmcs_prt_level_t, const char *, ...)
-    __KPRINTFLIKE(3);
+pmcs_prt_impl(pmcs_hw_t *, pmcs_prt_level_t, pmcs_phy_t *, pmcs_xscsi_t *,
+    const char *, ...) __KPRINTFLIKE(5);
 
 boolean_t pmcs_assign_device(pmcs_hw_t *, pmcs_xscsi_t *);
 void pmcs_remove_device(pmcs_hw_t *, pmcs_phy_t *);