Ejemplo n.º 1
0
static bool hfa_detect_common(struct cgpu_info *hashfast)
{
    struct hashfast_info *info;
    bool ret;

    info = calloc(sizeof(struct hashfast_info), 1);
    if (!info)
        quit(1, "Failed to calloc hashfast_info in hfa_detect_common");
    hashfast->device_data = info;
    /* hashfast_reset should fill in details for info */
    ret = hfa_reset(hashfast, info);
    if (!ret) {
        hfa_send_shutdown(hashfast);
        hfa_clear_readbuf(hashfast);
        free(info);
        hashfast->device_data = NULL;
        return false;
    }

    // The per-die status array
    info->die_status = calloc(info->asic_count, sizeof(struct hf_g1_die_data));
    if (unlikely(!(info->die_status)))
        quit(1, "Failed to calloc die_status");

    // The per-die statistics array
    info->die_statistics = calloc(info->asic_count, sizeof(struct hf_long_statistics));
    if (unlikely(!(info->die_statistics)))
        quit(1, "Failed to calloc die_statistics");

    info->works = calloc(sizeof(struct work *), info->num_sequence);
    if (!info->works)
        quit(1, "Failed to calloc info works in hfa_detect_common");

    return true;
}
Ejemplo n.º 2
0
static void hfa_shutdown(struct thr_info *thr)
{
	struct cgpu_info *hashfast = thr->cgpu;
	struct hashfast_info *info = hashfast->device_data;

	hfa_send_shutdown(hashfast);
	pthread_join(info->read_thr, NULL);
	hfa_free_all_work(info);
	hfa_clear_readbuf(hashfast);
	free(info->works);
	free(info->die_statistics);
	free(info->die_status);
	free(info);
}
Ejemplo n.º 3
0
static void hfa_shutdown(struct thr_info *thr)
{
    struct cgpu_info *hashfast = thr->cgpu;
    struct hashfast_info *info = hashfast->device_data;

    hfa_send_shutdown(hashfast);
    pthread_join(info->read_thr, NULL);
    hfa_free_all_work(info);
    hfa_clear_readbuf(hashfast);
    free(info->works);
    free(info->die_statistics);
    free(info->die_status);
    /* Don't free info here since it will be accessed by statline before
     * if a device is removed. */
}
Ejemplo n.º 4
0
static void hfa_parse_gwq_status(struct cgpu_info *hashfast, struct hashfast_info *info,
                                 struct hf_header *h)
{
    struct hf_gwq_data *g = (struct hf_gwq_data *)(h + 1);
    struct work *work;

    applog(LOG_DEBUG, "HFA %d: OP_GWQ_STATUS, device_head %4d tail %4d my tail %4d shed %3d inflight %4d",
           hashfast->device_id, g->sequence_head, g->sequence_tail, info->hash_sequence_tail,
           g->shed_count, HF_SEQUENCE_DISTANCE(info->hash_sequence_head,g->sequence_tail));

    /* This is a special flag that the thermal overload has been tripped */
    if (unlikely(h->core_address & 0x80)) {
        applog(LOG_WARNING, "HFA %d Thermal overload tripped! Resetting device",
               hashfast->device_id);
        hfa_send_shutdown(hashfast);
        if (hfa_reset(hashfast, info)) {
            applog(LOG_NOTICE, "HFA %d: Succesfully reset, continuing operation",
                   hashfast->device_id);
            return;
        }
        applog(LOG_WARNING, "HFA %d Failed to reset device, killing off thread to allow re-hotplug",
               hashfast->device_id);
        usb_nodev(hashfast);
        return;
    }

    mutex_lock(&info->lock);
    info->hash_count += g->hash_count;
    info->device_sequence_head = g->sequence_head;
    info->device_sequence_tail = g->sequence_tail;
    info->shed_count = g->shed_count;
    /* Free any work that is no longer required */
    while (info->device_sequence_tail != info->hash_sequence_tail) {
        if (++info->hash_sequence_tail >= info->num_sequence)
            info->hash_sequence_tail = 0;
        if (unlikely(!(work = info->works[info->hash_sequence_tail]))) {
            applog(LOG_ERR, "HFA %d: Bad work sequence tail",
                   hashfast->device_id);
            hashfast->shutdown = true;
            break;
        }
        applog(LOG_DEBUG, "HFA %d: Completing work on hash_sequence_tail %d",
               hashfast->device_id, info->hash_sequence_tail);
        free_work(work);
        info->works[info->hash_sequence_tail] = NULL;
    }
    mutex_unlock(&info->lock);
}