Commit 473865db5039aec3417c0ba206af3923ba2b7e41

James Z.M. Gao 2013-04-18T08:48:48

Merge remote-tracking branch 'upstream/master'

diff --git a/README b/README
index deb88d7..55fb74f 100644
--- a/README
+++ b/README
@@ -920,7 +920,8 @@ Q: Which AMD driver is the best?
 A: Unfortunately AMD has a history of having quite a few releases with issues
 when it comes to mining, either in terms of breaking mining, increasing CPU
 usage or very low hashrates. Only experimentation can tell you for sure, but
-some good releases were 11.6, 11.12, 12.4 and 12.8
+some good releases were 11.6, 11.12, 12.4 and 12.8. Note that older cards may
+not work with the newer drivers.
 
 Q: I have multiple SDKs installed, can I choose which one it uses?
 A: Run cgminer with the -n option and it will list all the platforms currently
@@ -959,6 +960,14 @@ their various features. Linux offers much better long term stability and
 remote monitoring and security, while windows offers you overclocking tools
 that can achieve much more than cgminer can do on linux.
 
+Q: Can I mine with cgminer on a MAC?
+A: cgminer will compile on OSX, but the performance of GPU mining is
+compromised due to the opencl implementation on OSX, there is no temperature
+or fanspeed monitoring, and the cooling design of most MACs, despite having
+powerful GPUs, will usually not cope with constant usage leading to a high
+risk of thermal damage. It is highly recommended not to mine on a MAC unless
+it is to a USB device.
+
 Q: Cgminer cannot see any of my GPUs even though I have configured them all
 to be enabled and installed OpenCL (+/- Xorg is running and the DISPLAY
 variable is exported on linux)?
@@ -1048,7 +1057,8 @@ you are running. However if you change SDKs you should delete any generated
 
 Q: I switch users on windows and my mining stops working?
 A: That's correct, it does. It's a permissions issue that there is no known
-fix for.
+fix for due to monitoring of GPU fanspeeds and temperatures. If you disable
+the monitoring with --no-adl it should switch okay.
 
 Q: My network gets slower and slower and then dies for a minute?
 A; Try the --net-delay option.
diff --git a/cgminer.c b/cgminer.c
index f2840f0..c6fef3b 100644
--- a/cgminer.c
+++ b/cgminer.c
@@ -3648,6 +3648,7 @@ static int block_sort(struct block *blocka, struct block *blockb)
 static void set_blockdiff(const struct work *work)
 {
 	uint64_t *data64, d64, diff64;
+	double previous_diff;
 	uint32_t diffhash[8];
 	uint32_t difficulty;
 	uint32_t diffbytes;
@@ -3683,9 +3684,12 @@ static void set_blockdiff(const struct work *work)
 	if (unlikely(!d64))
 		d64 = 1;
 
+	previous_diff = current_diff;
 	diff64 = diffone / d64;
 	suffix_string(diff64, block_diff, 0);
 	current_diff = (double)diffone / (double)d64;
+	if (unlikely(current_diff != previous_diff))
+		applog(LOG_NOTICE, "Network diff set to %s", block_diff);
 }
 
 static bool test_work_current(struct work *work)
@@ -5910,13 +5914,13 @@ void hash_queued_work(struct thr_info *mythr)
 			memcpy(&tv_start, &tv_end, sizeof(struct timeval));
 		}
 
+		if (unlikely(mythr->pause || cgpu->deven != DEV_ENABLED))
+			mt_disable(mythr, thr_id, drv);
+
 		if (unlikely(mythr->work_restart)) {
 			flush_queue(cgpu);
 			drv->flush_work(cgpu);
 		}
-
-		if (unlikely(mythr->pause || cgpu->deven != DEV_ENABLED))
-			mt_disable(mythr, thr_id, drv);
 	}
 }
 
diff --git a/driver-avalon.c b/driver-avalon.c
index 4ca3952..7e14a21 100644
--- a/driver-avalon.c
+++ b/driver-avalon.c
@@ -929,22 +929,21 @@ static int64_t avalon_scanhash(struct thr_info *thr)
 			       elapsed.tv_sec, elapsed.tv_usec);
 		}
 	}
-	if (hash_count) {
-		if (avalon->results < AVALON_ARRAY_SIZE)
-			avalon->results++;
-	} else if (unlikely((result_wrong >= avalon_get_work_count ) ||
-		   (ret != AVA_GETS_RESTART && --avalon->results < 0))) {
-			/* Look for all invalid results, or consecutive failure
-			 * to generate any results suggesting the FPGA
-			 * controller has screwed up. */
-			do_avalon_close(thr);
-			applog(LOG_ERR,
-			       "AVA%i: FPGA controller messed up, %d wrong results",
-			       avalon->device_id, result_wrong);
-			dev_error(avalon, REASON_DEV_COMMS_ERROR);
-			sleep(1);
-			avalon_init(avalon);
-			return 0;
+	if (hash_count && avalon->results < AVALON_ARRAY_SIZE)
+		avalon->results++;
+	if (unlikely((result_wrong >= avalon_get_work_count) ||
+	    (!hash_count && ret != AVA_GETS_RESTART && --avalon->results < 0))) {
+		/* Look for all invalid results, or consecutive failure
+		 * to generate any results suggesting the FPGA
+		 * controller has screwed up. */
+		do_avalon_close(thr);
+		applog(LOG_ERR,
+			"AVA%i: FPGA controller messed up, %d wrong results",
+			avalon->device_id, result_wrong);
+		dev_error(avalon, REASON_DEV_COMMS_ERROR);
+		sleep(1);
+		avalon_init(avalon);
+		return 0;
 	}
 
 	avalon_rotate_array(avalon);
diff --git a/ocl.c b/ocl.c
index 81ecaa4..2d66971 100644
--- a/ocl.c
+++ b/ocl.c
@@ -121,7 +121,7 @@ int clDevicesNum(void) {
 			applog(LOG_INFO, "CL Platform %d version: %s", i, pbuff);
 		status = clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices);
 		if (status != CL_SUCCESS) {
-			applog(LOG_ERR, "Error %d: Getting Device IDs (num)", status);
+			applog(LOG_INFO, "Error %d: Getting Device IDs (num)", status);
 			continue;
 		}
 		applog(LOG_INFO, "Platform %d devices: %d", i, numDevices);
@@ -131,7 +131,6 @@ int clDevicesNum(void) {
 		}
 		if (numDevices) {
 			unsigned int j;
-			char pbuff[256];
 			cl_device_id *devices = (cl_device_id *)malloc(numDevices*sizeof(cl_device_id));
 
 			clGetDeviceIDs(platform, CL_DEVICE_TYPE_GPU, numDevices, devices, NULL);