aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/s390/crypto
diff options
context:
space:
mode:
authorHolger Dengler <hd@linux.vnet.ibm.com>2012-05-16 08:08:22 -0400
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2012-05-16 08:42:52 -0400
commit54a8f5611d9189b3a8fbc9ace59a7a276eee58d8 (patch)
tree02c5bab3a0601b70faf8977d1e4eadd110c97d49 /drivers/s390/crypto
parent505e5ecfd3930bd1b429c36f10403d32a6c3c951 (diff)
s390/ap: move receive callback to message struct
Move the receive callback from zdev_driver to ap_message structure to get a more flexible asynchronous ap message handling. Signed-off-by: Holger Dengler <hd@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
Diffstat (limited to 'drivers/s390/crypto')
-rw-r--r--drivers/s390/crypto/ap_bus.c16
-rw-r--r--drivers/s390/crypto/ap_bus.h7
-rw-r--r--drivers/s390/crypto/zcrypt_cex2a.c3
-rw-r--r--drivers/s390/crypto/zcrypt_pcica.c3
-rw-r--r--drivers/s390/crypto/zcrypt_pcicc.c3
-rw-r--r--drivers/s390/crypto/zcrypt_pcixcc.c5
6 files changed, 24 insertions, 13 deletions
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index 7e9a72eb2fe0..cd2103c1d915 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -836,12 +836,12 @@ static void __ap_flush_queue(struct ap_device *ap_dev)
836 list_for_each_entry_safe(ap_msg, next, &ap_dev->pendingq, list) { 836 list_for_each_entry_safe(ap_msg, next, &ap_dev->pendingq, list) {
837 list_del_init(&ap_msg->list); 837 list_del_init(&ap_msg->list);
838 ap_dev->pendingq_count--; 838 ap_dev->pendingq_count--;
839 ap_dev->drv->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV)); 839 ap_msg->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV));
840 } 840 }
841 list_for_each_entry_safe(ap_msg, next, &ap_dev->requestq, list) { 841 list_for_each_entry_safe(ap_msg, next, &ap_dev->requestq, list) {
842 list_del_init(&ap_msg->list); 842 list_del_init(&ap_msg->list);
843 ap_dev->requestq_count--; 843 ap_dev->requestq_count--;
844 ap_dev->drv->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV)); 844 ap_msg->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV));
845 } 845 }
846} 846}
847 847
@@ -1329,7 +1329,7 @@ static int ap_poll_read(struct ap_device *ap_dev, unsigned long *flags)
1329 continue; 1329 continue;
1330 list_del_init(&ap_msg->list); 1330 list_del_init(&ap_msg->list);
1331 ap_dev->pendingq_count--; 1331 ap_dev->pendingq_count--;
1332 ap_dev->drv->receive(ap_dev, ap_msg, ap_dev->reply); 1332 ap_msg->receive(ap_dev, ap_msg, ap_dev->reply);
1333 break; 1333 break;
1334 } 1334 }
1335 if (ap_dev->queue_count > 0) 1335 if (ap_dev->queue_count > 0)
@@ -1450,10 +1450,10 @@ static int __ap_queue_message(struct ap_device *ap_dev, struct ap_message *ap_ms
1450 return -EBUSY; 1450 return -EBUSY;
1451 case AP_RESPONSE_REQ_FAC_NOT_INST: 1451 case AP_RESPONSE_REQ_FAC_NOT_INST:
1452 case AP_RESPONSE_MESSAGE_TOO_BIG: 1452 case AP_RESPONSE_MESSAGE_TOO_BIG:
1453 ap_dev->drv->receive(ap_dev, ap_msg, ERR_PTR(-EINVAL)); 1453 ap_msg->receive(ap_dev, ap_msg, ERR_PTR(-EINVAL));
1454 return -EINVAL; 1454 return -EINVAL;
1455 default: /* Device is gone. */ 1455 default: /* Device is gone. */
1456 ap_dev->drv->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV)); 1456 ap_msg->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV));
1457 return -ENODEV; 1457 return -ENODEV;
1458 } 1458 }
1459 } else { 1459 } else {
@@ -1471,6 +1471,10 @@ void ap_queue_message(struct ap_device *ap_dev, struct ap_message *ap_msg)
1471 unsigned long flags; 1471 unsigned long flags;
1472 int rc; 1472 int rc;
1473 1473
1474 /* For asynchronous message handling a valid receive-callback
1475 * is required. */
1476 BUG_ON(!ap_msg->receive);
1477
1474 spin_lock_bh(&ap_dev->lock); 1478 spin_lock_bh(&ap_dev->lock);
1475 if (!ap_dev->unregistered) { 1479 if (!ap_dev->unregistered) {
1476 /* Make room on the queue by polling for finished requests. */ 1480 /* Make room on the queue by polling for finished requests. */
@@ -1482,7 +1486,7 @@ void ap_queue_message(struct ap_device *ap_dev, struct ap_message *ap_msg)
1482 if (rc == -ENODEV) 1486 if (rc == -ENODEV)
1483 ap_dev->unregistered = 1; 1487 ap_dev->unregistered = 1;
1484 } else { 1488 } else {
1485 ap_dev->drv->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV)); 1489 ap_msg->receive(ap_dev, ap_msg, ERR_PTR(-ENODEV));
1486 rc = -ENODEV; 1490 rc = -ENODEV;
1487 } 1491 }
1488 spin_unlock_bh(&ap_dev->lock); 1492 spin_unlock_bh(&ap_dev->lock);
diff --git a/drivers/s390/crypto/ap_bus.h b/drivers/s390/crypto/ap_bus.h
index d960a6309eec..726fc65809d8 100644
--- a/drivers/s390/crypto/ap_bus.h
+++ b/drivers/s390/crypto/ap_bus.h
@@ -136,9 +136,6 @@ struct ap_driver {
136 136
137 int (*probe)(struct ap_device *); 137 int (*probe)(struct ap_device *);
138 void (*remove)(struct ap_device *); 138 void (*remove)(struct ap_device *);
139 /* receive is called from tasklet context */
140 void (*receive)(struct ap_device *, struct ap_message *,
141 struct ap_message *);
142 int request_timeout; /* request timeout in jiffies */ 139 int request_timeout; /* request timeout in jiffies */
143}; 140};
144 141
@@ -183,6 +180,9 @@ struct ap_message {
183 180
184 void *private; /* ap driver private pointer. */ 181 void *private; /* ap driver private pointer. */
185 unsigned int special:1; /* Used for special commands. */ 182 unsigned int special:1; /* Used for special commands. */
183 /* receive is called from tasklet context */
184 void (*receive)(struct ap_device *, struct ap_message *,
185 struct ap_message *);
186}; 186};
187 187
188#define AP_DEVICE(dt) \ 188#define AP_DEVICE(dt) \
@@ -199,6 +199,7 @@ static inline void ap_init_message(struct ap_message *ap_msg)
199 ap_msg->psmid = 0; 199 ap_msg->psmid = 0;
200 ap_msg->length = 0; 200 ap_msg->length = 0;
201 ap_msg->special = 0; 201 ap_msg->special = 0;
202 ap_msg->receive = NULL;
202} 203}
203 204
204/* 205/*
diff --git a/drivers/s390/crypto/zcrypt_cex2a.c b/drivers/s390/crypto/zcrypt_cex2a.c
index 084286728166..46812440425a 100644
--- a/drivers/s390/crypto/zcrypt_cex2a.c
+++ b/drivers/s390/crypto/zcrypt_cex2a.c
@@ -77,7 +77,6 @@ static void zcrypt_cex2a_receive(struct ap_device *, struct ap_message *,
77static struct ap_driver zcrypt_cex2a_driver = { 77static struct ap_driver zcrypt_cex2a_driver = {
78 .probe = zcrypt_cex2a_probe, 78 .probe = zcrypt_cex2a_probe,
79 .remove = zcrypt_cex2a_remove, 79 .remove = zcrypt_cex2a_remove,
80 .receive = zcrypt_cex2a_receive,
81 .ids = zcrypt_cex2a_ids, 80 .ids = zcrypt_cex2a_ids,
82 .request_timeout = CEX2A_CLEANUP_TIME, 81 .request_timeout = CEX2A_CLEANUP_TIME,
83}; 82};
@@ -349,6 +348,7 @@ static long zcrypt_cex2a_modexpo(struct zcrypt_device *zdev,
349 ap_msg.message = kmalloc(CEX3A_MAX_MESSAGE_SIZE, GFP_KERNEL); 348 ap_msg.message = kmalloc(CEX3A_MAX_MESSAGE_SIZE, GFP_KERNEL);
350 if (!ap_msg.message) 349 if (!ap_msg.message)
351 return -ENOMEM; 350 return -ENOMEM;
351 ap_msg.receive = zcrypt_cex2a_receive;
352 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 352 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
353 atomic_inc_return(&zcrypt_step); 353 atomic_inc_return(&zcrypt_step);
354 ap_msg.private = &work; 354 ap_msg.private = &work;
@@ -390,6 +390,7 @@ static long zcrypt_cex2a_modexpo_crt(struct zcrypt_device *zdev,
390 ap_msg.message = kmalloc(CEX3A_MAX_MESSAGE_SIZE, GFP_KERNEL); 390 ap_msg.message = kmalloc(CEX3A_MAX_MESSAGE_SIZE, GFP_KERNEL);
391 if (!ap_msg.message) 391 if (!ap_msg.message)
392 return -ENOMEM; 392 return -ENOMEM;
393 ap_msg.receive = zcrypt_cex2a_receive;
393 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 394 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
394 atomic_inc_return(&zcrypt_step); 395 atomic_inc_return(&zcrypt_step);
395 ap_msg.private = &work; 396 ap_msg.private = &work;
diff --git a/drivers/s390/crypto/zcrypt_pcica.c b/drivers/s390/crypto/zcrypt_pcica.c
index 0effca925451..ad7951c21b79 100644
--- a/drivers/s390/crypto/zcrypt_pcica.c
+++ b/drivers/s390/crypto/zcrypt_pcica.c
@@ -67,7 +67,6 @@ static void zcrypt_pcica_receive(struct ap_device *, struct ap_message *,
67static struct ap_driver zcrypt_pcica_driver = { 67static struct ap_driver zcrypt_pcica_driver = {
68 .probe = zcrypt_pcica_probe, 68 .probe = zcrypt_pcica_probe,
69 .remove = zcrypt_pcica_remove, 69 .remove = zcrypt_pcica_remove,
70 .receive = zcrypt_pcica_receive,
71 .ids = zcrypt_pcica_ids, 70 .ids = zcrypt_pcica_ids,
72 .request_timeout = PCICA_CLEANUP_TIME, 71 .request_timeout = PCICA_CLEANUP_TIME,
73}; 72};
@@ -284,6 +283,7 @@ static long zcrypt_pcica_modexpo(struct zcrypt_device *zdev,
284 ap_msg.message = kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); 283 ap_msg.message = kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL);
285 if (!ap_msg.message) 284 if (!ap_msg.message)
286 return -ENOMEM; 285 return -ENOMEM;
286 ap_msg.receive = zcrypt_pcica_receive;
287 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 287 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
288 atomic_inc_return(&zcrypt_step); 288 atomic_inc_return(&zcrypt_step);
289 ap_msg.private = &work; 289 ap_msg.private = &work;
@@ -322,6 +322,7 @@ static long zcrypt_pcica_modexpo_crt(struct zcrypt_device *zdev,
322 ap_msg.message = kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL); 322 ap_msg.message = kmalloc(PCICA_MAX_MESSAGE_SIZE, GFP_KERNEL);
323 if (!ap_msg.message) 323 if (!ap_msg.message)
324 return -ENOMEM; 324 return -ENOMEM;
325 ap_msg.receive = zcrypt_pcica_receive;
325 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 326 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
326 atomic_inc_return(&zcrypt_step); 327 atomic_inc_return(&zcrypt_step);
327 ap_msg.private = &work; 328 ap_msg.private = &work;
diff --git a/drivers/s390/crypto/zcrypt_pcicc.c b/drivers/s390/crypto/zcrypt_pcicc.c
index f9523c0cc8d2..e5dd335fda53 100644
--- a/drivers/s390/crypto/zcrypt_pcicc.c
+++ b/drivers/s390/crypto/zcrypt_pcicc.c
@@ -79,7 +79,6 @@ static void zcrypt_pcicc_receive(struct ap_device *, struct ap_message *,
79static struct ap_driver zcrypt_pcicc_driver = { 79static struct ap_driver zcrypt_pcicc_driver = {
80 .probe = zcrypt_pcicc_probe, 80 .probe = zcrypt_pcicc_probe,
81 .remove = zcrypt_pcicc_remove, 81 .remove = zcrypt_pcicc_remove,
82 .receive = zcrypt_pcicc_receive,
83 .ids = zcrypt_pcicc_ids, 82 .ids = zcrypt_pcicc_ids,
84 .request_timeout = PCICC_CLEANUP_TIME, 83 .request_timeout = PCICC_CLEANUP_TIME,
85}; 84};
@@ -488,6 +487,7 @@ static long zcrypt_pcicc_modexpo(struct zcrypt_device *zdev,
488 ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL); 487 ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL);
489 if (!ap_msg.message) 488 if (!ap_msg.message)
490 return -ENOMEM; 489 return -ENOMEM;
490 ap_msg.receive = zcrypt_pcicc_receive;
491 ap_msg.length = PAGE_SIZE; 491 ap_msg.length = PAGE_SIZE;
492 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 492 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
493 atomic_inc_return(&zcrypt_step); 493 atomic_inc_return(&zcrypt_step);
@@ -527,6 +527,7 @@ static long zcrypt_pcicc_modexpo_crt(struct zcrypt_device *zdev,
527 ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL); 527 ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL);
528 if (!ap_msg.message) 528 if (!ap_msg.message)
529 return -ENOMEM; 529 return -ENOMEM;
530 ap_msg.receive = zcrypt_pcicc_receive;
530 ap_msg.length = PAGE_SIZE; 531 ap_msg.length = PAGE_SIZE;
531 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 532 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
532 atomic_inc_return(&zcrypt_step); 533 atomic_inc_return(&zcrypt_step);
diff --git a/drivers/s390/crypto/zcrypt_pcixcc.c b/drivers/s390/crypto/zcrypt_pcixcc.c
index cf1cbd4747f4..f7cc43401816 100644
--- a/drivers/s390/crypto/zcrypt_pcixcc.c
+++ b/drivers/s390/crypto/zcrypt_pcixcc.c
@@ -89,7 +89,6 @@ static void zcrypt_pcixcc_receive(struct ap_device *, struct ap_message *,
89static struct ap_driver zcrypt_pcixcc_driver = { 89static struct ap_driver zcrypt_pcixcc_driver = {
90 .probe = zcrypt_pcixcc_probe, 90 .probe = zcrypt_pcixcc_probe,
91 .remove = zcrypt_pcixcc_remove, 91 .remove = zcrypt_pcixcc_remove,
92 .receive = zcrypt_pcixcc_receive,
93 .ids = zcrypt_pcixcc_ids, 92 .ids = zcrypt_pcixcc_ids,
94 .request_timeout = PCIXCC_CLEANUP_TIME, 93 .request_timeout = PCIXCC_CLEANUP_TIME,
95}; 94};
@@ -698,6 +697,7 @@ static long zcrypt_pcixcc_modexpo(struct zcrypt_device *zdev,
698 ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL); 697 ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL);
699 if (!ap_msg.message) 698 if (!ap_msg.message)
700 return -ENOMEM; 699 return -ENOMEM;
700 ap_msg.receive = zcrypt_pcixcc_receive;
701 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 701 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
702 atomic_inc_return(&zcrypt_step); 702 atomic_inc_return(&zcrypt_step);
703 ap_msg.private = &resp_type; 703 ap_msg.private = &resp_type;
@@ -738,6 +738,7 @@ static long zcrypt_pcixcc_modexpo_crt(struct zcrypt_device *zdev,
738 ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL); 738 ap_msg.message = (void *) get_zeroed_page(GFP_KERNEL);
739 if (!ap_msg.message) 739 if (!ap_msg.message)
740 return -ENOMEM; 740 return -ENOMEM;
741 ap_msg.receive = zcrypt_pcixcc_receive;
741 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 742 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
742 atomic_inc_return(&zcrypt_step); 743 atomic_inc_return(&zcrypt_step);
743 ap_msg.private = &resp_type; 744 ap_msg.private = &resp_type;
@@ -778,6 +779,7 @@ static long zcrypt_pcixcc_send_cprb(struct zcrypt_device *zdev,
778 ap_msg.message = kmalloc(PCIXCC_MAX_XCRB_MESSAGE_SIZE, GFP_KERNEL); 779 ap_msg.message = kmalloc(PCIXCC_MAX_XCRB_MESSAGE_SIZE, GFP_KERNEL);
779 if (!ap_msg.message) 780 if (!ap_msg.message)
780 return -ENOMEM; 781 return -ENOMEM;
782 ap_msg.receive = zcrypt_pcixcc_receive;
781 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 783 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
782 atomic_inc_return(&zcrypt_step); 784 atomic_inc_return(&zcrypt_step);
783 ap_msg.private = &resp_type; 785 ap_msg.private = &resp_type;
@@ -818,6 +820,7 @@ static long zcrypt_pcixcc_rng(struct zcrypt_device *zdev,
818 ap_msg.message = kmalloc(PCIXCC_MAX_XCRB_MESSAGE_SIZE, GFP_KERNEL); 820 ap_msg.message = kmalloc(PCIXCC_MAX_XCRB_MESSAGE_SIZE, GFP_KERNEL);
819 if (!ap_msg.message) 821 if (!ap_msg.message)
820 return -ENOMEM; 822 return -ENOMEM;
823 ap_msg.receive = zcrypt_pcixcc_receive;
821 ap_msg.psmid = (((unsigned long long) current->pid) << 32) + 824 ap_msg.psmid = (((unsigned long long) current->pid) << 32) +
822 atomic_inc_return(&zcrypt_step); 825 atomic_inc_return(&zcrypt_step);
823 ap_msg.private = &resp_type; 826 ap_msg.private = &resp_type;