PERFORCE change 101260 for review

Christian S.J. Peron csjp at FreeBSD.org
Tue Jul 11 05:41:14 UTC 2006


http://perforce.freebsd.org/chv.cgi?CH=101260

Change 101260 by csjp at csjp_rnd01 on 2006/07/11 05:40:55

	Submit first pass on making mpt(4) big endian safe. Currently, there is some
	issues with allocating interrupts, however, it boots and does not hand
	indefinately, also, it detects the chip, so there is some progress here,
	but there needs to be some work done here yet.
	
	Submitted by:	Scott Long

Affected files ...

.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_cnfg.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_fc.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_inb.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_init.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_ioc.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_lan.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_log_fc.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_log_sas.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_raid.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_sas.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_targ.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_tool.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_type.h#2 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt.c#3 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt.h#3 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_cam.c#3 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_cam.h#3 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_debug.c#3 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_pci.c#5 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_raid.c#3 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_raid.h#3 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_reg.h#3 edit

Differences ...

==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_cnfg.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_fc.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_inb.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_init.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_ioc.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_lan.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_log_fc.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_log_sas.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_raid.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_sas.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_targ.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_tool.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpilib/mpi_type.h#2 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt.c#3 (text+ko) ====

@@ -535,7 +535,7 @@
 			request_t *ack_req;
 			uint32_t context;
 
-			context = htole32(req->index|MPT_REPLY_HANDLER_EVENTS);
+			context = req->index | MPT_REPLY_HANDLER_EVENTS;
 			ack_req = mpt_get_request(mpt, FALSE);
 			if (ack_req == NULL) {
 				struct mpt_evtf_record *evtf;
@@ -652,9 +652,9 @@
 	ackp = (MSG_EVENT_ACK *)ack_req->req_vbuf;
 	memset(ackp, 0, sizeof (*ackp));
 	ackp->Function = MPI_FUNCTION_EVENT_ACK;
-	ackp->Event = msg->Event;
-	ackp->EventContext = msg->EventContext;
-	ackp->MsgContext = context;
+	ackp->Event = htole32(msg->Event);
+	ackp->EventContext = htole32(msg->EventContext);
+	ackp->MsgContext = htole32(context);
 	mpt_check_doorbell(mpt);
 	mpt_send_cmd(mpt, ack_req);
 }
@@ -1521,9 +1521,9 @@
 	cfgp->Header.PageLength = PageLength;
 	cfgp->Header.PageNumber = PageNumber;
 	cfgp->Header.PageType = PageType;
-	cfgp->PageAddress = PageAddress;
+	cfgp->PageAddress = htole32(PageAddress);
 	se = (SGE_SIMPLE32 *)&cfgp->PageBufferSGE;
-	se->Address = addr;
+	se->Address = htole32(addr);
 	MPI_pSGE_SET_LENGTH(se, len);
 	MPI_pSGE_SET_FLAGS(se, (MPI_SGE_FLAGS_SIMPLE_ELEMENT |
 	    MPI_SGE_FLAGS_LAST_ELEMENT | MPI_SGE_FLAGS_END_OF_BUFFER |

==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt.h#3 (text+ko) ====

@@ -120,6 +120,7 @@
 #include <sys/proc.h>
 #include <sys/bus.h>
 #include <sys/module.h>
+#include <sys/taskqueue.h>
 
 #include <machine/cpu.h>
 #include <machine/resource.h>
@@ -623,6 +624,8 @@
 	struct req_queue	request_pending_list;
 	struct req_queue	request_timeout_list;
 
+	struct task		intr_task;
+	struct taskqueue	*tq;
 
 	struct cam_sim	       *sim;
 	struct cam_path	       *path;
@@ -822,13 +825,13 @@
 static __inline void
 mpt_write(struct mpt_softc *mpt, size_t offset, uint32_t val)
 {
-	bus_space_write_4(mpt->pci_st, mpt->pci_sh, offset, val);
+	bus_space_write_4(mpt->pci_st, mpt->pci_sh, offset, htole32(val));
 }
 
 static __inline uint32_t
 mpt_read(struct mpt_softc *mpt, int offset)
 {
-	return (bus_space_read_4(mpt->pci_st, mpt->pci_sh, offset));
+	return (le32toh(bus_space_read_4(mpt->pci_st, mpt->pci_sh, offset)));
 }
 
 /*
@@ -839,13 +842,15 @@
 static __inline void
 mpt_pio_write(struct mpt_softc *mpt, size_t offset, uint32_t val)
 {
-	bus_space_write_4(mpt->pci_pio_st, mpt->pci_pio_sh, offset, val);
+	bus_space_write_4(mpt->pci_pio_st, mpt->pci_pio_sh, offset,
+	    htole32(val));
 }
 
 static __inline uint32_t
 mpt_pio_read(struct mpt_softc *mpt, int offset)
 {
-	return (bus_space_read_4(mpt->pci_pio_st, mpt->pci_pio_sh, offset));
+	return (le32toh(bus_space_read_4(mpt->pci_pio_st, mpt->pci_pio_sh,
+	    offset)));
 }
 /*********************** Reply Frame/Request Management ***********************/
 /* Max MPT Reply we are willing to accept (must be power of 2) */

==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_cam.c#3 (text+ko) ====

@@ -992,9 +992,9 @@
 		uint32_t tf;
 
 		memset(se, 0, sizeof (*se));
-		se->Address.Low = dm_segs->ds_addr;
+		se->Address.Low = htole32(dm_segs->ds_addr & 0xffffffff);
 		if (sizeof(bus_addr_t) > 4) {
-			se->Address.High = ((uint64_t) dm_segs->ds_addr) >> 32;
+			se->Address.High = ((uint64_t)dm_segs->ds_addr) >> 32;
 		}
 		MPI_pSGE_SET_LENGTH(se, dm_segs->ds_len);
 		tf = flags;
@@ -1068,9 +1068,9 @@
 		chain_list_addr += cur_off;
 		if (sizeof (bus_addr_t) > 4) {
 			ce->Address.High =
-			    (uint32_t) ((uint64_t)chain_list_addr >> 32);
+			    htole32((uint64_t)chain_list_addr >> 32);
 		}
-		ce->Address.Low = (uint32_t) chain_list_addr;
+		ce->Address.Low = htole32(chain_list_addr & 0xffffffff);
 		ce->Flags = MPI_SGE_FLAGS_CHAIN_ELEMENT |
 			    MPI_SGE_FLAGS_64_BIT_ADDRESSING;
 
@@ -1107,10 +1107,11 @@
 		 */
 		while (seg < this_seg_lim) {
 			memset(se, 0, sizeof (*se));
-			se->Address.Low = dm_segs->ds_addr;
+			se->Address.Low =
+			    htole32(dm_segs->ds_addr & 0xffffffff);
 			if (sizeof (bus_addr_t) > 4) {
 				se->Address.High =
-				    ((uint64_t)dm_segs->ds_addr) >> 32;
+				    htole32(((uint64_t)dm_segs->ds_addr) >>32);
 			}
 			MPI_pSGE_SET_LENGTH(se, dm_segs->ds_len);
 			tf = flags;
@@ -1765,8 +1766,8 @@
 	}
 
 	mpt_req->CDBLength = csio->cdb_len;
-	mpt_req->DataLength = csio->dxfer_len;
-	mpt_req->SenseBufferLowAddr = req->sense_pbuf;
+	mpt_req->DataLength = htole32((uint32_t)csio->dxfer_len);
+	mpt_req->SenseBufferLowAddr = htole32(req->sense_pbuf & 0xffffffff);
 
 	/*
 	 * Do a *short* print here if we're set to MPT_PRT_DEBUG
@@ -2209,6 +2210,7 @@
 {
 	MSG_LINK_SERVICE_RSP_REQUEST tmp;
 	PTR_MSG_LINK_SERVICE_RSP_REQUEST rsp;
+	uint32_t fl;
 
 	/*
 	 * We are going to reuse the ELS request to send this response back.
@@ -2246,15 +2248,16 @@
 	bus_addr_t paddr = req->req_pbuf;
 	paddr += MPT_RQSL(mpt);
 
-	se->FlagsLength =
+	fl =
 		MPI_SGE_FLAGS_HOST_TO_IOC	|
 		MPI_SGE_FLAGS_SIMPLE_ELEMENT	|
 		MPI_SGE_FLAGS_LAST_ELEMENT	|
 		MPI_SGE_FLAGS_END_OF_LIST	|
 		MPI_SGE_FLAGS_END_OF_BUFFER;
-	se->FlagsLength <<= MPI_SGE_FLAGS_SHIFT;
-	se->FlagsLength |= (length);
-	se->Address = (uint32_t) paddr;
+	fl <<= MPI_SGE_FLAGS_SHIFT;
+	fl |= (length);
+	se->FlagsLength = htole32(fl);
+	se->Address = htole32(paddr & 0xffffffff);
 }
 #endif
 
@@ -3613,6 +3616,7 @@
 	PTR_SGE_TRANSACTION32 tep;
 	PTR_SGE_SIMPLE32 se;
 	bus_addr_t paddr;
+	uint32_t fl;
 
 	paddr = req->req_pbuf;
 	paddr += MPT_RQSL(mpt);
@@ -3637,15 +3641,16 @@
 	tep->TransactionContext[0] = htole32(ioindex);
 
 	se = (PTR_SGE_SIMPLE32) &tep->TransactionDetails[0];
-	se->FlagsLength =
+	fl =
 		MPI_SGE_FLAGS_HOST_TO_IOC	|
 		MPI_SGE_FLAGS_SIMPLE_ELEMENT	|
 		MPI_SGE_FLAGS_LAST_ELEMENT	|
 		MPI_SGE_FLAGS_END_OF_LIST	|
 		MPI_SGE_FLAGS_END_OF_BUFFER;
-	se->FlagsLength <<= MPI_SGE_FLAGS_SHIFT;
-	se->FlagsLength |= (MPT_NRFM(mpt) - MPT_RQSL(mpt));
-	se->Address = (uint32_t) paddr;
+	fl <<= MPI_SGE_FLAGS_SHIFT;
+	fl |= (MPT_NRFM(mpt) - MPT_RQSL(mpt));
+	se->FlagsLength = htole32(fl);
+	se->Address = htole32(paddr & 0xffffffff);
 	mpt_lprt(mpt, MPT_PRT_DEBUG,
 	    "add ELS index %d ioindex %d for %p:%u\n",
 	    req->index, ioindex, req, req->serno);
@@ -3673,7 +3678,7 @@
 
 	cb = &fc->Buffer[0];
 	cb->IoIndex = htole16(ioindex);
-	cb->u.PhysicalAddress32 = (U32) paddr;
+	cb->u.PhysicalAddress32 = htole32(paddr & 0xffffffff);
 
 	mpt_check_doorbell(mpt);
 	mpt_send_cmd(mpt, req);
@@ -4143,6 +4148,7 @@
 	PTR_MSG_TARGET_STATUS_SEND_REQUEST tp;
 	request_t *req;
 	bus_addr_t paddr;
+	uint32_t fl;
 	int resplen = 0;
 
 	cmd_vbuf = cmd_req->req_vbuf;
@@ -4263,15 +4269,16 @@
 	if (status == SCSI_STATUS_OK && resplen == 0) {
 		tp->MsgFlags |= TARGET_STATUS_SEND_FLAGS_AUTO_GOOD_STATUS;
 	} else {
-		tp->StatusDataSGE.u.Address32 = (uint32_t) paddr;
-		tp->StatusDataSGE.FlagsLength =
+		tp->StatusDataSGE.u.Address32 = htole32(paddr & 0xffffffff);
+		fl =
 			MPI_SGE_FLAGS_HOST_TO_IOC	|
 			MPI_SGE_FLAGS_SIMPLE_ELEMENT	|
 			MPI_SGE_FLAGS_LAST_ELEMENT	|
 			MPI_SGE_FLAGS_END_OF_LIST	|
 			MPI_SGE_FLAGS_END_OF_BUFFER;
-		tp->StatusDataSGE.FlagsLength <<= MPI_SGE_FLAGS_SHIFT;
-		tp->StatusDataSGE.FlagsLength |= resplen;
+		fl <<= MPI_SGE_FLAGS_SHIFT;
+		fl |= resplen;
+		tp->StatusDataSGE.FlagsLength = htole32(fl);
 	}
 
 	mpt_lprt(mpt, MPT_PRT_DEBUG, 

==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_cam.h#3 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_debug.c#3 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_pci.c#5 (text+ko) ====

@@ -190,7 +190,8 @@
 static int mpt_dma_mem_alloc(struct mpt_softc *mpt);
 static void mpt_dma_mem_free(struct mpt_softc *mpt);
 static void mpt_read_config_regs(struct mpt_softc *mpt);
-static void mpt_pci_intr(void *);
+static void mpt_pci_fastintr(void *);
+static void mpt_pci_handle_intr(void *, int);
 
 static device_method_t mpt_methods[] = {
 	/* Device interface */
@@ -496,8 +497,13 @@
 	mpt_disable_ints(mpt);
 
 	/* Register the interrupt handler */
-	if (bus_setup_intr(dev, mpt->pci_irq, MPT_IFLAGS, mpt_pci_intr,
-	    mpt, &mpt->ih)) {
+	TASK_INIT(&mpt->intr_task, 0, mpt_pci_handle_intr, mpt);
+	mpt->tq = taskqueue_create_fast("mpt_taskq", M_NOWAIT,
+	    taskqueue_thread_enqueue, &mpt->tq);
+	taskqueue_start_threads(&mpt->tq, 1, PI_DISK, "%s taskq",
+	    device_get_nameunit(dev));
+	if (bus_setup_intr(dev, mpt->pci_irq, INTR_TYPE_CAM|INTR_FAST,
+	    mpt_pci_fastintr, mpt, &mpt->ih)) {
 		device_printf(dev, "could not setup interrupt\n");
 		goto bad;
 	}
@@ -893,12 +899,26 @@
 }
 
 static void
-mpt_pci_intr(void *arg)
+mpt_pci_fastintr(void *arg)
+{
+	struct mpt_softc *mpt;
+
+	mpt = (struct mpt_softc *)arg;
+	mpt_disable_ints(mpt);
+	taskqueue_enqueue(mpt->tq, &mpt->intr_task);
+	return;
+}
+
+static void
+mpt_pci_handle_intr(void *arg, int pending)
 {
 	struct mpt_softc *mpt;
 
 	mpt = (struct mpt_softc *)arg;
+	mtx_lock(&Giant);
 	MPT_LOCK(mpt);
 	mpt_intr(mpt);
 	MPT_UNLOCK(mpt);
+	mtx_unlock(&Giant);
+	mpt_enable_ints(mpt);
 }

==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_raid.c#3 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_raid.h#3 (text+ko) ====


==== //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt_reg.h#3 (text+ko) ====



More information about the p4-projects mailing list