PERFORCE change 101343 for review

Kip Macy kmacy at FreeBSD.org
Wed Jul 12 09:05:52 UTC 2006


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

Change 101343 by kmacy at kmacy_storage:sun4v_work_stable on 2006/07/12 09:04:57

	back out the rubbish I put in earlier
	
	make sure we do byte swapping when reading structures from the card to
	compensate for the fact that the bus space routines don't DTRT in this 
	instance	

Affected files ...

.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt.c#7 edit
.. //depot/projects/kmacy_sun4v_stable/src/sys/dev/mpt/mpt.h#8 edit

Differences ...

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

@@ -824,19 +824,19 @@
 }
 
 /******************************* Doorbell Access ******************************/
-static __inline uint16_t mpt_rd_db(struct mpt_softc *mpt);
-static __inline  uint16_t mpt_rd_intr(struct mpt_softc *mpt);
+static __inline uint32_t mpt_rd_db(struct mpt_softc *mpt);
+static __inline uint32_t mpt_rd_intr(struct mpt_softc *mpt);
 
-static __inline uint16_t
+static __inline uint32_t
 mpt_rd_db(struct mpt_softc *mpt)
 {
-	return mpt_read_16(mpt, MPT_OFFSET_DOORBELL);
+	return mpt_read(mpt, MPT_OFFSET_DOORBELL);
 }
 
-static __inline uint16_t
+static __inline uint32_t
 mpt_rd_intr(struct mpt_softc *mpt)
 {
-	return mpt_read_16(mpt, MPT_OFFSET_INTR_STATUS);
+	return mpt_read(mpt, MPT_OFFSET_INTR_STATUS);
 }
 
 /* Busy wait for a door bell to be read by IOC */
@@ -1343,7 +1343,7 @@
 
 	/* Send the command */
 	for (i = 0; i < len; i++) {
-		mpt_write(mpt, MPT_OFFSET_DOORBELL, *data32++);
+		mpt_write(mpt, MPT_OFFSET_DOORBELL, htole32(*data32++));
 		if (mpt_wait_db_ack(mpt) != MPT_OK) {
 			mpt_prt(mpt,
 				"mpt_send_handshake_cmd timeout! index = %d\n",
@@ -1360,6 +1360,7 @@
 {
 	int left, reply_left;
 	uint16_t *data16;
+	uint32_t data;
 	MSG_DEFAULT_REPLY *hdr;
 
 	/* We move things out in 16 bit chunks */
@@ -1373,7 +1374,9 @@
 		mpt_prt(mpt, "mpt_recv_handshake_cmd timeout1\n");
 		return ETIMEDOUT;
 	}
-	*data16++ = mpt_read_16(mpt, MPT_OFFSET_DOORBELL) & MPT_DB_DATA_MASK;
+	data = mpt_read(mpt, MPT_OFFSET_DOORBELL);
+
+	*data16++ = le16toh(data & MPT_DB_DATA_MASK);
 	mpt_write(mpt, MPT_OFFSET_INTR_STATUS, 0);
 
 	/* Get Second Word */
@@ -1381,15 +1384,16 @@
 		mpt_prt(mpt, "mpt_recv_handshake_cmd timeout2\n");
 		return ETIMEDOUT;
 	}
-	*data16++ = mpt_read_16(mpt, MPT_OFFSET_DOORBELL) & MPT_DB_DATA_MASK;
+	data = mpt_read(mpt, MPT_OFFSET_DOORBELL);
+	*data16++ = le16toh(data & MPT_DB_DATA_MASK);
 	mpt_write(mpt, MPT_OFFSET_INTR_STATUS, 0);
 
 	/*
 	 * With the second word, we can now look at the length.
 	 * Warn about a reply that's too short (except for IOC FACTS REPLY)
 	 */
-	if ((reply_len >> 1) != hdr->MsgLength &&
-	    (hdr->Function != MPI_FUNCTION_IOC_FACTS)){
+	if ((reply_len >> 1) != hdr->MsgLength && 
+	    (hdr->Function != MPI_FUNCTION_IOC_FACTS)) {
 #if __FreeBSD_version >= 500000
 		mpt_prt(mpt, "reply length does not match message length: "
 			"got %x; expected %zx for function %x\n",
@@ -1411,10 +1415,11 @@
 			mpt_prt(mpt, "mpt_recv_handshake_cmd timeout3\n");
 			return ETIMEDOUT;
 		}
-		datum = mpt_read_16(mpt, MPT_OFFSET_DOORBELL);
+		data = mpt_read(mpt, MPT_OFFSET_DOORBELL);
+		datum = le16toh(data & MPT_DB_DATA_MASK);
 
 		if (reply_left-- > 0)
-			*data16++ = datum & MPT_DB_DATA_MASK;
+			*data16++ = datum;
 
 		mpt_write(mpt, MPT_OFFSET_INTR_STATUS, 0);
 	}
@@ -1456,7 +1461,6 @@
 {
 	MSG_PORT_FACTS f_req;
 	int error;
-	
 	/* XXX: Only getting PORT FACTS for Port 0 */
 	memset(&f_req, 0, sizeof f_req);
 	f_req.Function = MPI_FUNCTION_PORT_FACTS;

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

@@ -819,7 +819,6 @@
 /******************************* Register Access ******************************/
 static __inline void mpt_write(struct mpt_softc *, size_t, uint32_t);
 static __inline uint32_t mpt_read(struct mpt_softc *, int);
-static __inline uint16_t mpt_read_16(struct mpt_softc *, int);
 static __inline void mpt_pio_write(struct mpt_softc *, size_t, uint32_t);
 static __inline uint32_t mpt_pio_read(struct mpt_softc *, int);
 
@@ -835,12 +834,6 @@
 	return (bus_space_read_4(mpt->pci_st, mpt->pci_sh, offset));
 }
 
-static __inline uint16_t
-mpt_read_16(struct mpt_softc *mpt, int offset)
-{
-	return (bus_space_read_2(mpt->pci_st, mpt->pci_sh, offset));
-}
-
 /*
  * Some operations (e.g. diagnostic register writes while the ARM proccessor
  * is disabled), must be performed using "PCI pio" operations.  On non-PCI
@@ -1017,7 +1010,7 @@
 static __inline request_t *
 mpt_tag_2_req(struct mpt_softc *mpt, uint32_t tag)
 {
-	uint16_t rtg = (uint16_t)(tag >> 18);
+	uint16_t rtg = tag >> 18;
 	KASSERT(rtg < mpt->tgt_cmds_allocated, ("bad tag %d\n", tag));
 	KASSERT(mpt->tgt_cmd_ptrs, ("no cmd backpointer array"));
 	KASSERT(mpt->tgt_cmd_ptrs[rtg], ("no cmd backpointer"));


More information about the p4-projects mailing list