summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormarius <marius@FreeBSD.org>2015-12-27 20:52:32 +0000
committermarius <marius@FreeBSD.org>2015-12-27 20:52:32 +0000
commit1ef54c4f8cd411d3b1cfefbd24dfb2df8934f6b7 (patch)
treef44f36f1bcd145ef28101574713f0446bcfe6554
parent69fca9363a5a9c208239e82836465546ea317579 (diff)
downloadFreeBSD-src-1ef54c4f8cd411d3b1cfefbd24dfb2df8934f6b7.zip
FreeBSD-src-1ef54c4f8cd411d3b1cfefbd24dfb2df8934f6b7.tar.gz
MFC: r285840
- In mpt_send_handshake_cmd(), use bus_space_write_stream_4(9) for writing raw data to the doorbell offset in order to clarify the intent and for avoiding unnecessarily converting the endianess back and forth. Unfortunately, the same can't be done in mpt_recv_handshake_reply() as 16-bit data needs to be read using 32-bit bus accessors. - In mpt_recv_handshake_reply(), get rid of a redundant variable.
-rw-r--r--sys/dev/mpt/mpt.c11
-rw-r--r--sys/dev/mpt/mpt.h12
2 files changed, 14 insertions, 9 deletions
diff --git a/sys/dev/mpt/mpt.c b/sys/dev/mpt/mpt.c
index d5b2a18..9317965 100644
--- a/sys/dev/mpt/mpt.c
+++ b/sys/dev/mpt/mpt.c
@@ -1423,7 +1423,7 @@ mpt_send_handshake_cmd(struct mpt_softc *mpt, size_t len, void *cmd)
/* Send the command */
for (i = 0; i < len; i++) {
- mpt_write(mpt, MPT_OFFSET_DOORBELL, htole32(*data32++));
+ mpt_write_stream(mpt, MPT_OFFSET_DOORBELL, *data32++);
if (mpt_wait_db_ack(mpt) != MPT_OK) {
mpt_prt(mpt,
"mpt_send_handshake_cmd: timeout @ index %d\n", i);
@@ -1457,7 +1457,7 @@ mpt_recv_handshake_reply(struct mpt_softc *mpt, size_t reply_len, void *reply)
*data16++ = le16toh(data & MPT_DB_DATA_MASK);
mpt_write(mpt, MPT_OFFSET_INTR_STATUS, 0);
- /* Get Second Word */
+ /* Get second word */
if (mpt_wait_db_int(mpt) != MPT_OK) {
mpt_prt(mpt, "mpt_recv_handshake_cmd timeout2\n");
return ETIMEDOUT;
@@ -1481,18 +1481,13 @@ mpt_recv_handshake_reply(struct mpt_softc *mpt, size_t reply_len, void *reply)
left = (hdr->MsgLength << 1) - 2;
reply_left = reply_len - 2;
while (left--) {
- u_int16_t datum;
-
if (mpt_wait_db_int(mpt) != MPT_OK) {
mpt_prt(mpt, "mpt_recv_handshake_cmd timeout3\n");
return ETIMEDOUT;
}
data = mpt_read(mpt, MPT_OFFSET_DOORBELL);
- datum = le16toh(data & MPT_DB_DATA_MASK);
-
if (reply_left-- > 0)
- *data16++ = datum;
-
+ *data16++ = le16toh(data & MPT_DB_DATA_MASK);
mpt_write(mpt, MPT_OFFSET_INTR_STATUS, 0);
}
diff --git a/sys/dev/mpt/mpt.h b/sys/dev/mpt/mpt.h
index 1dcd76f..57dbe7b 100644
--- a/sys/dev/mpt/mpt.h
+++ b/sys/dev/mpt/mpt.h
@@ -329,7 +329,6 @@ typedef struct mpt_config_params {
} cfgparms_t;
/**************************** MPI Target State Info ***************************/
-
typedef struct {
uint32_t reply_desc; /* current reply descriptor */
uint32_t resid; /* current data residual */
@@ -784,6 +783,7 @@ mpt_assign_serno(struct mpt_softc *mpt, request_t *req)
/******************************* Register Access ******************************/
static __inline void mpt_write(struct mpt_softc *, size_t, uint32_t);
+static __inline void mpt_write_stream(struct mpt_softc *, size_t, uint32_t);
static __inline uint32_t mpt_read(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);
@@ -794,6 +794,12 @@ mpt_write(struct mpt_softc *mpt, size_t offset, uint32_t val)
bus_space_write_4(mpt->pci_st, mpt->pci_sh, offset, val);
}
+static __inline void
+mpt_write_stream(struct mpt_softc *mpt, size_t offset, uint32_t val)
+{
+ bus_space_write_stream_4(mpt->pci_st, mpt->pci_sh, offset, val);
+}
+
static __inline uint32_t
mpt_read(struct mpt_softc *mpt, int offset)
{
@@ -818,6 +824,7 @@ mpt_pio_read(struct mpt_softc *mpt, int offset)
KASSERT(mpt->pci_pio_reg != NULL, ("no PIO resource"));
return (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) */
#define MPT_REPLY_SIZE 256
@@ -958,6 +965,7 @@ mpt_cdblen(uint8_t cdb0, int maxlen)
return (16);
}
}
+
#ifdef INVARIANTS
static __inline request_t * mpt_tag_2_req(struct mpt_softc *, uint32_t);
static __inline request_t *
@@ -1136,6 +1144,7 @@ mpt_write_cur_cfg_page(struct mpt_softc *mpt, uint32_t PageAddress,
PageAddress, hdr, len, sleep_ok,
timeout_ms));
}
+
/* mpt_debug.c functions */
void mpt_print_reply(void *vmsg);
void mpt_print_db(uint32_t mb);
@@ -1145,4 +1154,5 @@ void mpt_req_state(mpt_req_state_t state);
void mpt_print_config_request(void *vmsg);
void mpt_print_request(void *vmsg);
void mpt_dump_sgl(SGE_IO_UNION *se, int offset);
+
#endif /* _MPT_H_ */
OpenPOWER on IntegriCloud