summaryrefslogtreecommitdiffstats
path: root/sys/pci
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1998-03-30 09:56:58 +0000
committerphk <phk@FreeBSD.org>1998-03-30 09:56:58 +0000
commit9b703b14551addf9806978973e2ddc427d4908b4 (patch)
tree91f2de8432f719153d0de9465a9ebeee33c29077 /sys/pci
parentadd2782c4ec0d7c4447da2b33d1413a2754f8a3e (diff)
downloadFreeBSD-src-9b703b14551addf9806978973e2ddc427d4908b4.zip
FreeBSD-src-9b703b14551addf9806978973e2ddc427d4908b4.tar.gz
Eradicate the variable "time" from the kernel, using various measures.
"time" wasn't a atomic variable, so splfoo() protection were needed around any access to it, unless you just wanted the seconds part. Most uses of time.tv_sec now uses the new variable time_second instead. gettime() changed to getmicrotime(0. Remove a couple of unneeded splfoo() protections, the new getmicrotime() is atomic, (until Bruce sets a breakpoint in it). A couple of places needed random data, so use read_random() instead of mucking about with time which isn't random. Add a new nfs_curusec() function. Mark a couple of bogosities involving the now disappeard time variable. Update ffs_update() to avoid the weird "== &time" checks, by fixing the one remaining call that passwd &time as args. Change profiling in ncr.c to use ticks instead of time. Resolution is the same. Add new function "tvtohz()" to avoid the bogus "splfoo(), add time, call hzto() which subtracts time" sequences. Reviewed by: bde
Diffstat (limited to 'sys/pci')
-rw-r--r--sys/pci/ncr.c67
1 files changed, 33 insertions, 34 deletions
diff --git a/sys/pci/ncr.c b/sys/pci/ncr.c
index 9a95889..88ae79e 100644
--- a/sys/pci/ncr.c
+++ b/sys/pci/ncr.c
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** $Id: ncr.c,v 1.114 1998/02/04 03:47:16 eivind Exp $
+** $Id: ncr.c,v 1.115 1998/02/09 06:10:56 eivind Exp $
**
** Device driver for the NCR 53C810 PCI-SCSI-Controller.
**
@@ -498,14 +498,14 @@ struct usrcmd {
*/
struct tstamp {
- struct timeval start;
- struct timeval end;
- struct timeval select;
- struct timeval command;
- struct timeval data;
- struct timeval status;
- struct timeval disconnect;
- struct timeval reselect;
+ int start;
+ int end;
+ int select;
+ int command;
+ int data;
+ int status;
+ int disconnect;
+ int reselect;
};
/*
@@ -1287,7 +1287,7 @@ struct scripth {
#ifdef KERNEL
static void ncr_alloc_ccb (ncb_p np, u_long target, u_long lun);
static void ncr_complete (ncb_p np, ccb_p cp);
-static int ncr_delta (struct timeval * from, struct timeval * to);
+static int ncr_delta (int * from, int * to);
static void ncr_exception (ncb_p np);
static void ncr_free_ccb (ncb_p np, ccb_p cp, int flags);
static void ncr_selectclock (ncb_p np, u_char scntl3);
@@ -1342,7 +1342,7 @@ static void ncr_attach (pcici_t tag, int unit);
static char ident[] =
- "\n$Id: ncr.c,v 1.114 1998/02/04 03:47:16 eivind Exp $\n";
+ "\n$Id: ncr.c,v 1.115 1998/02/09 06:10:56 eivind Exp $\n";
static const u_long ncr_version = NCR_VERSION * 11
+ (u_long) sizeof (struct ncb) * 7
@@ -1471,8 +1471,8 @@ static char *ncr_name (ncb_p np)
#define FADDR(label,ofs)(RELOC_REGISTER | ((REG(label))+(ofs)))
#define KVAR(which) (RELOC_KVAR | (which))
-#define KVAR_TIME_TV_SEC (0)
-#define KVAR_TIME (1)
+#define KVAR_SECOND (0)
+#define KVAR_TICKS (1)
#define KVAR_NCR_CACHE (2)
#define SCRIPT_KVAR_FIRST (0)
@@ -1483,7 +1483,7 @@ static char *ncr_name (ncb_p np)
* THESE MUST ALL BE ALIGNED TO A 4-BYTE BOUNDARY.
*/
static void *script_kvars[] =
- { &time.tv_sec, &time, &ncr_cache };
+ { &time_second, &ticks, &ncr_cache };
static struct script script0 = {
/*--------------------------< START >-----------------------*/ {
@@ -1491,7 +1491,7 @@ static struct script script0 = {
** Claim to be still alive ...
*/
SCR_COPY (sizeof (((struct ncb *)0)->heartbeat)),
- KVAR (KVAR_TIME_TV_SEC),
+ KVAR (KVAR_SECOND),
NADDR (heartbeat),
/*
** Make data structure address invalid.
@@ -1710,7 +1710,7 @@ static struct script script0 = {
** Set a time stamp for this selection
*/
SCR_COPY (sizeof (struct timeval)),
- KVAR (KVAR_TIME),
+ KVAR (KVAR_TICKS),
NADDR (header.stamp.select),
/*
** load the savep (saved pointer) into
@@ -1892,7 +1892,7 @@ static struct script script0 = {
** ... set a timestamp ...
*/
SCR_COPY (sizeof (struct timeval)),
- KVAR (KVAR_TIME),
+ KVAR (KVAR_TICKS),
NADDR (header.stamp.command),
/*
** ... and send the command
@@ -1914,7 +1914,7 @@ static struct script script0 = {
** set the timestamp.
*/
SCR_COPY (sizeof (struct timeval)),
- KVAR (KVAR_TIME),
+ KVAR (KVAR_TICKS),
NADDR (header.stamp.status),
/*
** If this is a GETCC transfer,
@@ -2219,7 +2219,7 @@ static struct script script0 = {
** and count the disconnects.
*/
SCR_COPY (sizeof (struct timeval)),
- KVAR (KVAR_TIME),
+ KVAR (KVAR_TICKS),
NADDR (header.stamp.disconnect),
SCR_COPY (4),
NADDR (disc_phys),
@@ -2462,7 +2462,7 @@ static struct script script0 = {
** SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN)),
** PADDR (no_data),
** SCR_COPY (sizeof (struct timeval)),
-** KVAR (KVAR_TIME),
+** KVAR (KVAR_TICKS),
** NADDR (header.stamp.data),
** SCR_MOVE_TBL ^ SCR_DATA_IN,
** offsetof (struct dsb, data[ 0]),
@@ -2489,7 +2489,7 @@ static struct script script0 = {
** SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_OUT)),
** PADDR (no_data),
** SCR_COPY (sizeof (struct timeval)),
-** KVAR (KVAR_TIME),
+** KVAR (KVAR_TICKS),
** NADDR (header.stamp.data),
** SCR_MOVE_TBL ^ SCR_DATA_OUT,
** offsetof (struct dsb, data[ 0]),
@@ -3058,7 +3058,7 @@ void ncr_script_fill (struct script * scr, struct scripth * scrh)
*p++ =SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_IN));
*p++ =PADDR (no_data);
*p++ =SCR_COPY (sizeof (struct timeval));
- *p++ =(ncrcmd) KVAR (KVAR_TIME);
+ *p++ =(ncrcmd) KVAR (KVAR_TICKS);
*p++ =NADDR (header.stamp.data);
*p++ =SCR_MOVE_TBL ^ SCR_DATA_IN;
*p++ =offsetof (struct dsb, data[ 0]);
@@ -3082,7 +3082,7 @@ void ncr_script_fill (struct script * scr, struct scripth * scrh)
*p++ =SCR_JUMP ^ IFFALSE (WHEN (SCR_DATA_OUT));
*p++ =PADDR (no_data);
*p++ =SCR_COPY (sizeof (struct timeval));
- *p++ =(ncrcmd) KVAR (KVAR_TIME);
+ *p++ =(ncrcmd) KVAR (KVAR_TICKS);
*p++ =NADDR (header.stamp.data);
*p++ =SCR_MOVE_TBL ^ SCR_DATA_OUT;
*p++ =offsetof (struct dsb, data[ 0]);
@@ -4180,7 +4180,7 @@ static int32_t ncr_start (struct scsi_xfer * xp)
*/
bzero (&cp->phys.header.stamp, sizeof (struct tstamp));
- gettime(&cp->phys.header.stamp.start);
+ cp->phys.header.stamp.start = ticks;
/*----------------------------------------------------
**
@@ -4475,7 +4475,7 @@ static int32_t ncr_start (struct scsi_xfer * xp)
*/
cp->jump_ccb.l_cmd = (SCR_JUMP ^ IFFALSE (DATA (cp->tag)));
- cp->tlimit = time.tv_sec + xp->timeout / 1000 + 2;
+ cp->tlimit = time_second + xp->timeout / 1000 + 2;
cp->magic = CCB_MAGIC;
/*
@@ -5443,7 +5443,7 @@ static void ncr_usercmd (ncb_p np)
static void ncr_timeout (void *arg)
{
ncb_p np = arg;
- u_long thistime = time.tv_sec;
+ u_long thistime = time_second;
u_long step = np->ticks;
u_long count = 0;
long signed t;
@@ -5760,9 +5760,9 @@ void ncr_exception (ncb_p np)
**========================================
*/
- if (time.tv_sec - np->regtime.tv_sec>10) {
+ if (time_second - np->regtime.tv_sec>10) {
int i;
- gettime(&np->regtime);
+ getmicrotime(&np->regtime);
for (i=0; i<sizeof(np->regdump); i++)
((char*)&np->regdump)[i] = INB_OFF(i);
np->regdump.nc_dstat = dstat;
@@ -7326,12 +7326,11 @@ static int ncr_snooptest (struct ncb* np)
** Compute the difference in milliseconds.
**/
-static int ncr_delta (struct timeval * from, struct timeval * to)
+static int ncr_delta (int *from, int *to)
{
- if (!from->tv_sec) return (-1);
- if (!to ->tv_sec) return (-2);
- return ( (to->tv_sec - from->tv_sec - 2)*1000+
- +(to->tv_usec - from->tv_usec + 2000000)/1000);
+ if (!from) return (-1);
+ if (!to) return (-2);
+ return ((to - from) * 1000 / hz);
}
#define PROFILE cp->phys.header.stamp
@@ -7340,7 +7339,7 @@ static void ncb_profile (ncb_p np, ccb_p cp)
int co, da, st, en, di, se, post,work,disc;
u_long diff;
- gettime(&PROFILE.end);
+ PROFILE.end = ticks;
st = ncr_delta (&PROFILE.start,&PROFILE.status);
if (st<0) return; /* status not reached */
OpenPOWER on IntegriCloud