Browse Source

Merge commit '75eca07' into bfgminer

Conflicts:
	driver-bitforce.c
Luke Dashjr 13 years ago
parent
commit
5819cf5fb5
3 changed files with 11 additions and 17 deletions
  1. 3 13
      driver-bitforce.c
  2. 7 3
      miner.c
  3. 1 1
      miner.h

+ 3 - 13
driver-bitforce.c

@@ -412,17 +412,10 @@ static void biforce_thread_enable(struct thr_info *thr)
 	bitforce_init(bitforce);
 	bitforce_init(bitforce);
 }
 }
 
 
-static void ms_to_timeval(unsigned int mstime, struct timeval *ttime)
-{
-	ttime->tv_sec = mstime / 1000;
-	ttime->tv_usec = mstime * 1000 - (ttime->tv_sec * 1000000);
-}
-
 static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint64_t __maybe_unused max_nonce)
 static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint64_t __maybe_unused max_nonce)
 {
 {
 	struct cgpu_info *bitforce = thr->cgpu;
 	struct cgpu_info *bitforce = thr->cgpu;
 	unsigned int sleep_time;
 	unsigned int sleep_time;
-	struct timeval tdiff;
 	uint64_t ret;
 	uint64_t ret;
 
 
 	bitforce->wait_ms = 0;
 	bitforce->wait_ms = 0;
@@ -432,8 +425,7 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
 		/* Initially wait 2/3 of the average cycle time so we can request more
 		/* Initially wait 2/3 of the average cycle time so we can request more
 		work before full scan is up */
 		work before full scan is up */
 		sleep_time = (2 * bitforce->sleep_ms) / 3;
 		sleep_time = (2 * bitforce->sleep_ms) / 3;
-		ms_to_timeval(sleep_time, &tdiff);
-		if (!restart_wait(&tdiff))
+		if (!restart_wait(sleep_time))
 		{}
 		{}
 
 
 		bitforce->wait_ms += sleep_time;
 		bitforce->wait_ms += sleep_time;
@@ -441,15 +433,13 @@ static uint64_t bitforce_scanhash(struct thr_info *thr, struct work *work, uint6
 
 
 		/* Now wait athe final 1/3rd; no bitforce should be finished by now */
 		/* Now wait athe final 1/3rd; no bitforce should be finished by now */
 		sleep_time = bitforce->sleep_ms - sleep_time;
 		sleep_time = bitforce->sleep_ms - sleep_time;
-		ms_to_timeval(sleep_time, &tdiff);
-		if (!restart_wait(&tdiff))
+		if (!restart_wait(sleep_time))
 		{}
 		{}
 
 
 		bitforce->wait_ms += sleep_time;
 		bitforce->wait_ms += sleep_time;
 	} else {
 	} else {
 		sleep_time = bitforce->sleep_ms;
 		sleep_time = bitforce->sleep_ms;
-		ms_to_timeval(sleep_time, &tdiff);
-		if (!restart_wait(&tdiff))
+		if (!restart_wait(sleep_time))
 		{}
 		{}
 	}
 	}
 
 

+ 7 - 3
miner.c

@@ -2506,19 +2506,23 @@ bool queue_request(struct thr_info *thr, bool needed);
  * work restart is required. Returns the value of pthread_cond_timedwait
  * work restart is required. Returns the value of pthread_cond_timedwait
  * which is zero if the condition was met or ETIMEDOUT if not.
  * which is zero if the condition was met or ETIMEDOUT if not.
  */
  */
-int restart_wait(struct timeval *tdiff)
+int restart_wait(unsigned int mstime)
 {
 {
-	struct timeval now, then;
+	struct timeval now, then, tdiff;
 	struct timespec abstime;
 	struct timespec abstime;
 	int rc;
 	int rc;
 
 
+	tdiff.tv_sec = mstime / 1000;
+	tdiff.tv_usec = mstime * 1000 - (tdiff.tv_sec * 1000000);
 	gettimeofday(&now, NULL);
 	gettimeofday(&now, NULL);
-	timeradd(&now, tdiff, &then);
+	timeradd(&now, &tdiff, &then);
 	abstime.tv_sec = then.tv_sec;
 	abstime.tv_sec = then.tv_sec;
 	abstime.tv_nsec = then.tv_usec * 1000;
 	abstime.tv_nsec = then.tv_usec * 1000;
+
 	mutex_lock(&restart_lock);
 	mutex_lock(&restart_lock);
 	rc = pthread_cond_timedwait(&restart_cond, &restart_lock, &abstime);
 	rc = pthread_cond_timedwait(&restart_cond, &restart_lock, &abstime);
 	mutex_unlock(&restart_lock);
 	mutex_unlock(&restart_lock);
+
 	return rc;
 	return rc;
 }
 }
 	
 	

+ 1 - 1
miner.h

@@ -575,7 +575,7 @@ extern pthread_cond_t restart_cond;
 
 
 extern void thread_reportin(struct thr_info *thr);
 extern void thread_reportin(struct thr_info *thr);
 extern bool queue_request(struct thr_info *thr, bool needed);
 extern bool queue_request(struct thr_info *thr, bool needed);
-extern int restart_wait(struct timeval *tdiff);
+extern int restart_wait(unsigned int mstime);
 
 
 extern void kill_work(void);
 extern void kill_work(void);