Lines Matching refs:ibmvtpm
107 struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); in tpm_ibmvtpm_recv() local
110 if (!ibmvtpm->rtce_buf) { in tpm_ibmvtpm_recv()
111 dev_err(ibmvtpm->dev, "ibmvtpm device is not ready\n"); in tpm_ibmvtpm_recv()
115 len = ibmvtpm->res_len; in tpm_ibmvtpm_recv()
118 dev_err(ibmvtpm->dev, in tpm_ibmvtpm_recv()
124 spin_lock(&ibmvtpm->rtce_lock); in tpm_ibmvtpm_recv()
125 memcpy((void *)buf, (void *)ibmvtpm->rtce_buf, len); in tpm_ibmvtpm_recv()
126 memset(ibmvtpm->rtce_buf, 0, len); in tpm_ibmvtpm_recv()
127 ibmvtpm->res_len = 0; in tpm_ibmvtpm_recv()
128 spin_unlock(&ibmvtpm->rtce_lock); in tpm_ibmvtpm_recv()
140 static int ibmvtpm_crq_send_init(struct ibmvtpm_dev *ibmvtpm) in ibmvtpm_crq_send_init() argument
144 rc = ibmvtpm_send_crq_word(ibmvtpm->vdev, INIT_CRQ_CMD); in ibmvtpm_crq_send_init()
146 dev_err(ibmvtpm->dev, in ibmvtpm_crq_send_init()
162 struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); in tpm_ibmvtpm_resume() local
169 ibmvtpm->vdev->unit_address); in tpm_ibmvtpm_resume()
177 rc = vio_enable_interrupts(ibmvtpm->vdev); in tpm_ibmvtpm_resume()
183 rc = ibmvtpm_crq_send_init(ibmvtpm); in tpm_ibmvtpm_resume()
202 struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); in tpm_ibmvtpm_send() local
206 if (!ibmvtpm->rtce_buf) { in tpm_ibmvtpm_send()
207 dev_err(ibmvtpm->dev, "ibmvtpm device is not ready\n"); in tpm_ibmvtpm_send()
211 if (count > ibmvtpm->rtce_size) { in tpm_ibmvtpm_send()
212 dev_err(ibmvtpm->dev, in tpm_ibmvtpm_send()
214 count, ibmvtpm->rtce_size); in tpm_ibmvtpm_send()
218 if (ibmvtpm->tpm_processing_cmd) { in tpm_ibmvtpm_send()
219 dev_info(ibmvtpm->dev, in tpm_ibmvtpm_send()
222 sig = wait_event_interruptible(ibmvtpm->wq, !ibmvtpm->tpm_processing_cmd); in tpm_ibmvtpm_send()
227 spin_lock(&ibmvtpm->rtce_lock); in tpm_ibmvtpm_send()
228 ibmvtpm->res_len = 0; in tpm_ibmvtpm_send()
229 memcpy((void *)ibmvtpm->rtce_buf, (void *)buf, count); in tpm_ibmvtpm_send()
235 ibmvtpm->tpm_processing_cmd = 1; in tpm_ibmvtpm_send()
238 rc = ibmvtpm_send_crq(ibmvtpm->vdev, in tpm_ibmvtpm_send()
240 count, ibmvtpm->rtce_dma_handle); in tpm_ibmvtpm_send()
248 tpm_ibmvtpm_resume(ibmvtpm->dev); in tpm_ibmvtpm_send()
252 dev_err(ibmvtpm->dev, "tpm_ibmvtpm_send failed rc=%d\n", rc); in tpm_ibmvtpm_send()
253 ibmvtpm->tpm_processing_cmd = 0; in tpm_ibmvtpm_send()
256 spin_unlock(&ibmvtpm->rtce_lock); in tpm_ibmvtpm_send()
267 struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); in tpm_ibmvtpm_status() local
269 return ibmvtpm->tpm_processing_cmd; in tpm_ibmvtpm_status()
281 static int ibmvtpm_crq_get_rtce_size(struct ibmvtpm_dev *ibmvtpm) in ibmvtpm_crq_get_rtce_size() argument
285 rc = ibmvtpm_send_crq(ibmvtpm->vdev, in ibmvtpm_crq_get_rtce_size()
288 dev_err(ibmvtpm->dev, in ibmvtpm_crq_get_rtce_size()
304 static int ibmvtpm_crq_get_version(struct ibmvtpm_dev *ibmvtpm) in ibmvtpm_crq_get_version() argument
308 rc = ibmvtpm_send_crq(ibmvtpm->vdev, in ibmvtpm_crq_get_version()
311 dev_err(ibmvtpm->dev, in ibmvtpm_crq_get_version()
325 static int ibmvtpm_crq_send_init_complete(struct ibmvtpm_dev *ibmvtpm) in ibmvtpm_crq_send_init_complete() argument
329 rc = ibmvtpm_send_crq_word(ibmvtpm->vdev, INIT_CRQ_COMP_CMD); in ibmvtpm_crq_send_init_complete()
331 dev_err(ibmvtpm->dev, in ibmvtpm_crq_send_init_complete()
346 struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); in tpm_ibmvtpm_remove() local
351 free_irq(vdev->irq, ibmvtpm); in tpm_ibmvtpm_remove()
359 dma_unmap_single(ibmvtpm->dev, ibmvtpm->crq_dma_handle, in tpm_ibmvtpm_remove()
361 free_page((unsigned long)ibmvtpm->crq_queue.crq_addr); in tpm_ibmvtpm_remove()
363 if (ibmvtpm->rtce_buf) { in tpm_ibmvtpm_remove()
364 dma_unmap_single(ibmvtpm->dev, ibmvtpm->rtce_dma_handle, in tpm_ibmvtpm_remove()
365 ibmvtpm->rtce_size, DMA_BIDIRECTIONAL); in tpm_ibmvtpm_remove()
366 kfree(ibmvtpm->rtce_buf); in tpm_ibmvtpm_remove()
369 kfree(ibmvtpm); in tpm_ibmvtpm_remove()
384 struct ibmvtpm_dev *ibmvtpm; in tpm_ibmvtpm_get_desired_dma() local
392 ibmvtpm = dev_get_drvdata(&chip->dev); in tpm_ibmvtpm_get_desired_dma()
396 return CRQ_RES_BUF_SIZE + ibmvtpm->rtce_size; in tpm_ibmvtpm_get_desired_dma()
408 struct ibmvtpm_dev *ibmvtpm = dev_get_drvdata(&chip->dev); in tpm_ibmvtpm_suspend() local
411 rc = ibmvtpm_send_crq(ibmvtpm->vdev, in tpm_ibmvtpm_suspend()
414 dev_err(ibmvtpm->dev, in tpm_ibmvtpm_suspend()
429 static int ibmvtpm_reset_crq(struct ibmvtpm_dev *ibmvtpm) in ibmvtpm_reset_crq() argument
437 ibmvtpm->vdev->unit_address); in ibmvtpm_reset_crq()
440 memset(ibmvtpm->crq_queue.crq_addr, 0, CRQ_RES_BUF_SIZE); in ibmvtpm_reset_crq()
441 ibmvtpm->crq_queue.index = 0; in ibmvtpm_reset_crq()
443 return plpar_hcall_norets(H_REG_CRQ, ibmvtpm->vdev->unit_address, in ibmvtpm_reset_crq()
444 ibmvtpm->crq_dma_handle, CRQ_RES_BUF_SIZE); in ibmvtpm_reset_crq()
474 static struct ibmvtpm_crq *ibmvtpm_crq_get_next(struct ibmvtpm_dev *ibmvtpm) in ibmvtpm_crq_get_next() argument
476 struct ibmvtpm_crq_queue *crq_q = &ibmvtpm->crq_queue; in ibmvtpm_crq_get_next()
496 struct ibmvtpm_dev *ibmvtpm) in ibmvtpm_crq_process() argument
504 dev_info(ibmvtpm->dev, "CRQ initialized\n"); in ibmvtpm_crq_process()
505 rc = ibmvtpm_crq_send_init_complete(ibmvtpm); in ibmvtpm_crq_process()
507 dev_err(ibmvtpm->dev, "Unable to send CRQ init complete rc=%d\n", rc); in ibmvtpm_crq_process()
510 dev_info(ibmvtpm->dev, in ibmvtpm_crq_process()
514 dev_err(ibmvtpm->dev, "Unknown crq message type: %d\n", crq->msg); in ibmvtpm_crq_process()
521 dev_err(ibmvtpm->dev, "Invalid rtce size\n"); in ibmvtpm_crq_process()
524 ibmvtpm->rtce_size = be16_to_cpu(crq->len); in ibmvtpm_crq_process()
525 ibmvtpm->rtce_buf = kmalloc(ibmvtpm->rtce_size, in ibmvtpm_crq_process()
527 if (!ibmvtpm->rtce_buf) { in ibmvtpm_crq_process()
528 dev_err(ibmvtpm->dev, "Failed to allocate memory for rtce buffer\n"); in ibmvtpm_crq_process()
532 ibmvtpm->rtce_dma_handle = dma_map_single(ibmvtpm->dev, in ibmvtpm_crq_process()
533 ibmvtpm->rtce_buf, ibmvtpm->rtce_size, in ibmvtpm_crq_process()
536 if (dma_mapping_error(ibmvtpm->dev, in ibmvtpm_crq_process()
537 ibmvtpm->rtce_dma_handle)) { in ibmvtpm_crq_process()
538 kfree(ibmvtpm->rtce_buf); in ibmvtpm_crq_process()
539 ibmvtpm->rtce_buf = NULL; in ibmvtpm_crq_process()
540 dev_err(ibmvtpm->dev, "Failed to dma map rtce buffer\n"); in ibmvtpm_crq_process()
545 ibmvtpm->vtpm_version = be32_to_cpu(crq->data); in ibmvtpm_crq_process()
549 ibmvtpm->res_len = be16_to_cpu(crq->len); in ibmvtpm_crq_process()
550 ibmvtpm->tpm_processing_cmd = 0; in ibmvtpm_crq_process()
551 wake_up_interruptible(&ibmvtpm->wq); in ibmvtpm_crq_process()
571 struct ibmvtpm_dev *ibmvtpm = (struct ibmvtpm_dev *) vtpm_instance; in ibmvtpm_interrupt() local
578 while ((crq = ibmvtpm_crq_get_next(ibmvtpm)) != NULL) { in ibmvtpm_interrupt()
579 ibmvtpm_crq_process(crq, ibmvtpm); in ibmvtpm_interrupt()
580 wake_up_interruptible(&ibmvtpm->crq_queue.wq); in ibmvtpm_interrupt()
601 struct ibmvtpm_dev *ibmvtpm; in tpm_ibmvtpm_probe() local
611 ibmvtpm = kzalloc(sizeof(struct ibmvtpm_dev), GFP_KERNEL); in tpm_ibmvtpm_probe()
612 if (!ibmvtpm) { in tpm_ibmvtpm_probe()
617 ibmvtpm->dev = dev; in tpm_ibmvtpm_probe()
618 ibmvtpm->vdev = vio_dev; in tpm_ibmvtpm_probe()
620 crq_q = &ibmvtpm->crq_queue; in tpm_ibmvtpm_probe()
629 ibmvtpm->crq_dma_handle = dma_map_single(dev, crq_q->crq_addr, in tpm_ibmvtpm_probe()
633 if (dma_mapping_error(dev, ibmvtpm->crq_dma_handle)) { in tpm_ibmvtpm_probe()
639 ibmvtpm->crq_dma_handle, CRQ_RES_BUF_SIZE); in tpm_ibmvtpm_probe()
641 rc = ibmvtpm_reset_crq(ibmvtpm); in tpm_ibmvtpm_probe()
649 tpm_ibmvtpm_driver_name, ibmvtpm); in tpm_ibmvtpm_probe()
661 init_waitqueue_head(&ibmvtpm->wq); in tpm_ibmvtpm_probe()
665 dev_set_drvdata(&chip->dev, ibmvtpm); in tpm_ibmvtpm_probe()
667 spin_lock_init(&ibmvtpm->rtce_lock); in tpm_ibmvtpm_probe()
669 rc = ibmvtpm_crq_send_init(ibmvtpm); in tpm_ibmvtpm_probe()
673 rc = ibmvtpm_crq_get_version(ibmvtpm); in tpm_ibmvtpm_probe()
677 rc = ibmvtpm_crq_get_rtce_size(ibmvtpm); in tpm_ibmvtpm_probe()
681 if (!wait_event_timeout(ibmvtpm->crq_queue.wq, in tpm_ibmvtpm_probe()
682 ibmvtpm->rtce_buf != NULL, in tpm_ibmvtpm_probe()
709 dma_unmap_single(dev, ibmvtpm->crq_dma_handle, CRQ_RES_BUF_SIZE, in tpm_ibmvtpm_probe()
712 if (ibmvtpm) { in tpm_ibmvtpm_probe()
715 kfree(ibmvtpm); in tpm_ibmvtpm_probe()