ckolivas/cgminer — pull request #250 by pshep (2012-07-03 00:04:16+00:00)
Title: Massive update to BFL code

Changes include (but not limited to):
- Timeout to restart work if it's taking too long
A nonce range should take just over 5s. Any longer and device is throttling.
(Fixes issue where BFL appears to stall in cgminer)
- Temp taken in watchdog thread
Now a disabled device will still return a current temperature, rather than the last value before disabling.
- Work restart on new work
This was cause very high stale rate.
Previously on a work restart, cgminer would allow the BFL to continue with the stale block. Now this is checked, work will be discarded and new work will be started immediately.
- Timing adjustments
The 'wait for results' was hard-set to 4500ms before polling at 10ms intervals. With variation of systems and new firmwares of differing hash rates, a hard set timer could be either inefficient (starts polling way before necessary) or wasteful (starts polling way after result is ready). The auto-adjustment will find the correct wait time to minimize polling and and delay retrieving results.
- Device re-initialization
When a device is disabled (for whatever reason - user or by cgminer) then re-enabled, the device is re-initialized, rather then assuming communications are still working.
- Sick / Dead monitoring
As with OpenCL devices, BFL devices will be checked for sickness (60s no response) or dead (10 mins no response) and try to re-initialize them.
- Improved logging
Most logs now include the device in question, i.e.: "BFL0: took longer than 10s", and more human readable.
- Device start offset
Delays the start of each device by a random time between 0 and 100ms so that they don't all make calls at exactly the same time.
- Error handling overhaul.
Errors are now handled much more gracefully. In particular, on work send/retrieve, an empty string indicates the device is busy (throttling); this is no-longer considered an error. In these cases the command is re-attempted up until the timeout.