From 17d4cdf5fb28cbcf2a7f35a2029314c30369a46f Mon Sep 17 00:00:00 2001 From: mjacob Date: Fri, 14 Dec 2001 00:20:56 +0000 Subject: Major restructuring for swizzling to the request queue and unswizzling from the response queue. Instead of the ad hoc ISP_SWIZZLE_REQUEST, we now have a complete set of inline functions in isp_inline.h. Each platform is responsible for providing just one of a set of ISP_IOX_{GET,PUT}{8,16,32} macros. The reason this needs to be done is that we need to have a single set of functions that will work correctly on multiple architectures for both little and big endian machines. It also needs to work correctly in the case that we have the request or response queues in memory that has to be treated specially (e.g., have ddi_dma_sync called on it for Solaris after we update it or before we read from it). One thing that falls out of this is that we no longer build requests in the request queue itself. Instead, we build the request locally (e.g., on the stack) and then as part of the swizzling operation, copy it to the request queue entry we've allocated. I thought long and hard about whether this was too expensive a change to make as it in a lot of cases requires an extra copy. On balance, the flexbility is worth it. With any luck, the entry that we build locally stays in a processor writeback cache (after all, it's only 64 bytes) so that the cost of actually flushing it to the memory area that is the shared queue with the PCI device is not all that expensive. We may examine this again and try to get clever in the future to try and avoid copies. Another change that falls out of this is that MEMORYBARRIER should be taken a lot more seriously. The macro ISP_ADD_REQUEST does a MEMORYBARRIER on the entry being added. But there had been many other places this had been missing. It's now very important that it be done. For OpenSD, it does a ddi_dmamap_sync as appropriate. This gets us out of the explicit ddi_dmamap_sync on the whole response queue that we did for SBus cards at each interrupt. Now, because SBus/sparc doesn't use bus_dma, some shenanigans were done to support this. But Jason was nice enough to test the SBus/sparcv9 changes for me, and they did the right thing as well. Set things up so that platforms that cannot have an SBus don't get a lot of the SBus code checks (dead coded out). Additional changes: Fix a longstanding buglet of sorts. When we get an entry via isp_getrqentry, the iptr value that gets returned is the value we intend to eventually plug into the ISP registers as the entry *one past* the last one we've written- *not* the current entry we're updating. All along we've been calling sync functions on the wrong index value. Argh. The 'fix' here is to rename all 'iptr' variables as 'nxti' to remember that this is the 'next' pointer- not the current pointer. Devote a single bit to mboxbsy- and set aside bits for output mbox registers that we need to pick up- we can have at least one command which does not have any defined output registers (MBOX_EXECUTE_FIRMWARE). Explicitly decode GetAllNext SNS Response back *as* a GetAllNext response. Otherwise, we won't unswizzle it correctly. Nuke some additional __P macros. --- sys/dev/ic/isp_openbsd.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'sys/dev/ic/isp_openbsd.c') diff --git a/sys/dev/ic/isp_openbsd.c b/sys/dev/ic/isp_openbsd.c index 4ea4399d73e..59f60a1fdac 100644 --- a/sys/dev/ic/isp_openbsd.c +++ b/sys/dev/ic/isp_openbsd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: isp_openbsd.c,v 1.21 2001/12/13 00:15:40 nordin Exp $ */ +/* $OpenBSD: isp_openbsd.c,v 1.22 2001/12/14 00:20:55 mjacob Exp $ */ /* * Platform (OpenBSD) dependent common attachment code for Qlogic adapters. * @@ -529,8 +529,8 @@ isp_wdog(void *arg) XS_CMD_S_CLEAR(xs); isp_done(xs); } else { - u_int16_t iptr, optr; - ispreq_t *mp; + u_int16_t nxti, optr; + ispreq_t local, *mp = &local, *qe; isp_prt(isp, ISP_LOGWARN, "possible command timeout on handle %x", handle); @@ -538,7 +538,7 @@ isp_wdog(void *arg) XS_CMD_C_WDOG(xs); timeout_add(&xs->stimeout, _XT(xs)); XS_CMD_S_TIMER(xs); - if (isp_getrqentry(isp, &iptr, &optr, (void **) &mp)) { + if (isp_getrqentry(isp, &nxti, &optr, (void **) &qe)) { ISP_UNLOCK(isp); return; } @@ -548,8 +548,8 @@ isp_wdog(void *arg) mp->req_header.rqs_entry_type = RQSTYPE_MARKER; mp->req_modifier = SYNC_ALL; mp->req_target = XS_CHANNEL(xs) << 7; - ISP_SWIZZLE_REQUEST(isp, mp); - ISP_ADD_REQUEST(isp, iptr); + isp_put_request(isp, mp, qe); + ISP_ADD_REQUEST(isp, nxti); } } else if (isp->isp_dblev) { isp_prt(isp, ISP_LOGDEBUG1, "watchdog with no command"); -- cgit v1.2.3