| .. | .. |
|---|
| 91 | 91 | struct optee_supp_req *req = kzalloc(sizeof(*req), GFP_KERNEL); |
|---|
| 92 | 92 | bool interruptable; |
|---|
| 93 | 93 | u32 ret; |
|---|
| 94 | + unsigned long timeleft; |
|---|
| 95 | + int id; |
|---|
| 96 | + struct optee_supp_req *get_req; |
|---|
| 94 | 97 | |
|---|
| 95 | 98 | if (!req) |
|---|
| 96 | 99 | return TEEC_ERROR_OUT_OF_MEMORY; |
|---|
| .. | .. |
|---|
| 115 | 118 | * exclusive access again. |
|---|
| 116 | 119 | */ |
|---|
| 117 | 120 | while (wait_for_completion_interruptible(&req->c)) { |
|---|
| 121 | + pr_err("Warning, Interrupting an RPC to supplicant!\n"); |
|---|
| 122 | + timeleft = wait_for_completion_timeout(&req->c, msecs_to_jiffies(2000)); |
|---|
| 123 | + if (timeleft) { |
|---|
| 124 | + /* get completion, it means tee-supplicant is alive. */ |
|---|
| 125 | + break; |
|---|
| 126 | + } else { |
|---|
| 127 | + /* timeout, it means tee-supplicant is dead, interrupting an RPC. */ |
|---|
| 128 | + interruptable = true; |
|---|
| 129 | + } |
|---|
| 130 | + |
|---|
| 118 | 131 | mutex_lock(&supp->mutex); |
|---|
| 119 | | - interruptable = !supp->ctx; |
|---|
| 120 | 132 | if (interruptable) { |
|---|
| 121 | 133 | /* |
|---|
| 122 | 134 | * There's no supplicant available and since the |
|---|
| .. | .. |
|---|
| 135 | 147 | list_del(&req->link); |
|---|
| 136 | 148 | req->in_queue = false; |
|---|
| 137 | 149 | } |
|---|
| 150 | + |
|---|
| 151 | + idr_for_each_entry(&supp->idr, get_req, id) { |
|---|
| 152 | + if (get_req == req) { |
|---|
| 153 | + idr_remove(&supp->idr, id); |
|---|
| 154 | + supp->req_id = -1; |
|---|
| 155 | + break; |
|---|
| 156 | + } |
|---|
| 157 | + } |
|---|
| 138 | 158 | } |
|---|
| 139 | 159 | mutex_unlock(&supp->mutex); |
|---|
| 140 | 160 | |
|---|