static int quicktest2(unsigned long arg) { static DECLARE_COMPLETION(cmp); unsigned long han; int blade_id = 0; int numcb = 4; int ret = 0; unsigned long *buf; void *cb0, *cb; int i, k, istatus, bytes; bytes = numcb * 4 * 8; buf = kmalloc(bytes, GFP_KERNEL); if (!buf) return -ENOMEM; ret = -EBUSY; han = gru_reserve_async_resources(blade_id, numcb, 0, &cmp); if (!han) goto done; gru_lock_async_resource(han, &cb0, NULL); memset(buf, 0xee, bytes); for (i = 0; i < numcb; i++) gru_vset(cb0 + i * GRU_HANDLE_STRIDE, uv_gpa(&buf[i * 4]), 0, XTYPE_DW, 4, 1, IMA_INTERRUPT); ret = 0; for (k = 0; k < numcb; k++) { gru_wait_async_cbr(han); for (i = 0; i < numcb; i++) { cb = cb0 + i * GRU_HANDLE_STRIDE; istatus = gru_check_status(cb); if (istatus == CBS_ACTIVE) continue; if (istatus == CBS_EXCEPTION) ret = -EFAULT; else if (buf[i] || buf[i + 1] || buf[i + 2] || buf[i + 3]) ret = -EIO; } } BUG_ON(cmp.done); gru_unlock_async_resource(han); gru_release_async_resources(han); done: kfree(buf); return ret; }
static int quicktest2(unsigned long arg) { static DECLARE_COMPLETION(cmp); unsigned long han; int blade_id = 0; int numcb = 4; int ret = 0; unsigned long *buf; void *cb0, *cb; struct gru_control_block_status *gen; int i, k, istatus, bytes; bytes = numcb * 4 * 8; buf = kmalloc(bytes, GFP_KERNEL); if (!buf) return -ENOMEM; ret = -EBUSY; han = gru_reserve_async_resources(blade_id, numcb, 0, &cmp); if (!han) goto done; gru_lock_async_resource(han, &cb0, NULL); memset(buf, 0xee, bytes); for (i = 0; i < numcb; i++) gru_vset(cb0 + i * GRU_HANDLE_STRIDE, uv_gpa(&buf[i * 4]), 0, XTYPE_DW, 4, 1, IMA_INTERRUPT); ret = 0; k = numcb; do { gru_wait_async_cbr(han); for (i = 0; i < numcb; i++) { cb = cb0 + i * GRU_HANDLE_STRIDE; istatus = gru_check_status(cb); if (istatus != CBS_ACTIVE && istatus != CBS_CALL_OS) break; } if (i == numcb) continue; if (istatus != CBS_IDLE) { ; ret = -EFAULT; } else if (buf[4 * i] || buf[4 * i + 1] || buf[4 * i + 2] || buf[4 * i + 3]) { // printk(KERN_DEBUG "GRU:%d quicktest2:cb %d, buf 0x%lx, 0x%lx, 0x%lx, 0x%lx\n", ; ret = -EIO; } k--; gen = cb; gen->istatus = CBS_CALL_OS; /* don't handle this CBR again */ } while (k); BUG_ON(cmp.done); gru_unlock_async_resource(han); gru_release_async_resources(han); done: kfree(buf); return ret; }