aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/s390/crypto/ap_bus.c424
-rw-r--r--drivers/s390/crypto/ap_bus.h13
-rw-r--r--drivers/s390/crypto/zcrypt_cex4.c2
3 files changed, 239 insertions, 200 deletions
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index 3ba611419759..559a9dcdb15d 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -60,7 +60,7 @@ static int __ap_poll_device(struct ap_device *ap_dev, unsigned long *flags);
60static int ap_device_remove(struct device *dev); 60static int ap_device_remove(struct device *dev);
61static int ap_device_probe(struct device *dev); 61static int ap_device_probe(struct device *dev);
62static void ap_interrupt_handler(struct airq_struct *airq); 62static void ap_interrupt_handler(struct airq_struct *airq);
63static void ap_reset(struct ap_device *ap_dev); 63static void ap_reset(struct ap_device *ap_dev, unsigned long *flags);
64static void ap_config_timeout(unsigned long ptr); 64static void ap_config_timeout(unsigned long ptr);
65static int ap_select_domain(void); 65static int ap_select_domain(void);
66static void ap_query_configuration(void); 66static void ap_query_configuration(void);
@@ -310,35 +310,26 @@ static inline int __ap_query_configuration(struct ap_config_info *config)
310static int ap_query_functions(ap_qid_t qid, unsigned int *functions) 310static int ap_query_functions(ap_qid_t qid, unsigned int *functions)
311{ 311{
312 struct ap_queue_status status; 312 struct ap_queue_status status;
313 int i; 313
314 status = __ap_query_functions(qid, functions); 314 status = __ap_query_functions(qid, functions);
315 315
316 for (i = 0; i < AP_MAX_RESET; i++) { 316 if (ap_queue_status_invalid_test(&status))
317 if (ap_queue_status_invalid_test(&status)) 317 return -ENODEV;
318 return -ENODEV;
319 318
320 switch (status.response_code) { 319 switch (status.response_code) {
321 case AP_RESPONSE_NORMAL: 320 case AP_RESPONSE_NORMAL:
322 return 0; 321 return 0;
323 case AP_RESPONSE_RESET_IN_PROGRESS: 322 case AP_RESPONSE_Q_NOT_AVAIL:
324 case AP_RESPONSE_BUSY: 323 case AP_RESPONSE_DECONFIGURED:
325 break; 324 case AP_RESPONSE_CHECKSTOPPED:
326 case AP_RESPONSE_Q_NOT_AVAIL: 325 case AP_RESPONSE_INVALID_ADDRESS:
327 case AP_RESPONSE_DECONFIGURED: 326 return -ENODEV;
328 case AP_RESPONSE_CHECKSTOPPED: 327 case AP_RESPONSE_RESET_IN_PROGRESS:
329 case AP_RESPONSE_INVALID_ADDRESS: 328 case AP_RESPONSE_BUSY:
330 return -ENODEV; 329 case AP_RESPONSE_OTHERWISE_CHANGED:
331 case AP_RESPONSE_OTHERWISE_CHANGED: 330 default:
332 break; 331 return -EBUSY;
333 default:
334 break;
335 }
336 if (i < AP_MAX_RESET - 1) {
337 udelay(5);
338 status = __ap_query_functions(qid, functions);
339 }
340 } 332 }
341 return -EBUSY;
342} 333}
343 334
344/** 335/**
@@ -350,47 +341,25 @@ static int ap_query_functions(ap_qid_t qid, unsigned int *functions)
350 * on the return value it waits a while and tests the AP queue if interrupts 341 * on the return value it waits a while and tests the AP queue if interrupts
351 * have been switched on using ap_test_queue(). 342 * have been switched on using ap_test_queue().
352 */ 343 */
353static int ap_queue_enable_interruption(ap_qid_t qid, void *ind) 344static int ap_queue_enable_interruption(struct ap_device *ap_dev, void *ind)
354{ 345{
355 struct ap_queue_status status; 346 struct ap_queue_status status;
356 int t_depth, t_device_type, rc, i;
357 347
358 rc = -EBUSY; 348 status = ap_queue_interruption_control(ap_dev->qid, ind);
359 status = ap_queue_interruption_control(qid, ind); 349 switch (status.response_code) {
360 350 case AP_RESPONSE_NORMAL:
361 for (i = 0; i < AP_MAX_RESET; i++) { 351 case AP_RESPONSE_OTHERWISE_CHANGED:
362 switch (status.response_code) { 352 return 0;
363 case AP_RESPONSE_NORMAL: 353 case AP_RESPONSE_Q_NOT_AVAIL:
364 if (status.int_enabled) 354 case AP_RESPONSE_DECONFIGURED:
365 return 0; 355 case AP_RESPONSE_CHECKSTOPPED:
366 break; 356 case AP_RESPONSE_INVALID_ADDRESS:
367 case AP_RESPONSE_RESET_IN_PROGRESS: 357 return -ENODEV;
368 case AP_RESPONSE_BUSY: 358 case AP_RESPONSE_RESET_IN_PROGRESS:
369 if (i < AP_MAX_RESET - 1) { 359 case AP_RESPONSE_BUSY:
370 udelay(5); 360 default:
371 status = ap_queue_interruption_control(qid, 361 return -EBUSY;
372 ind);
373 continue;
374 }
375 break;
376 case AP_RESPONSE_Q_NOT_AVAIL:
377 case AP_RESPONSE_DECONFIGURED:
378 case AP_RESPONSE_CHECKSTOPPED:
379 case AP_RESPONSE_INVALID_ADDRESS:
380 return -ENODEV;
381 case AP_RESPONSE_OTHERWISE_CHANGED:
382 if (status.int_enabled)
383 return 0;
384 break;
385 default:
386 break;
387 }
388 if (i < AP_MAX_RESET - 1) {
389 udelay(5);
390 status = ap_test_queue(qid, &t_depth, &t_device_type);
391 }
392 } 362 }
393 return rc;
394} 363}
395 364
396/** 365/**
@@ -511,109 +480,94 @@ int ap_recv(ap_qid_t qid, unsigned long long *psmid, void *msg, size_t length)
511EXPORT_SYMBOL(ap_recv); 480EXPORT_SYMBOL(ap_recv);
512 481
513/** 482/**
483 * __ap_schedule_poll_timer(): Schedule poll timer.
484 *
485 * Set up the timer to run the poll tasklet
486 */
487static inline void __ap_schedule_poll_timer(void)
488{
489 ktime_t hr_time;
490
491 spin_lock_bh(&ap_poll_timer_lock);
492 if (!hrtimer_is_queued(&ap_poll_timer) && !ap_suspend_flag) {
493 hr_time = ktime_set(0, poll_timeout);
494 hrtimer_forward_now(&ap_poll_timer, hr_time);
495 hrtimer_restart(&ap_poll_timer);
496 }
497 spin_unlock_bh(&ap_poll_timer_lock);
498}
499
500/**
501 * ap_schedule_poll_timer(): Schedule poll timer.
502 *
503 * Set up the timer to run the poll tasklet
504 */
505static inline void ap_schedule_poll_timer(void)
506{
507 if (ap_using_interrupts())
508 return;
509 __ap_schedule_poll_timer();
510}
511
512
513/**
514 * ap_query_queue(): Check if an AP queue is available. 514 * ap_query_queue(): Check if an AP queue is available.
515 * @qid: The AP queue number 515 * @qid: The AP queue number
516 * @queue_depth: Pointer to queue depth value 516 * @queue_depth: Pointer to queue depth value
517 * @device_type: Pointer to device type value 517 * @device_type: Pointer to device type value
518 *
519 * The test is repeated for AP_MAX_RESET times.
520 */ 518 */
521static int ap_query_queue(ap_qid_t qid, int *queue_depth, int *device_type) 519static int ap_query_queue(ap_qid_t qid, int *queue_depth, int *device_type)
522{ 520{
523 struct ap_queue_status status; 521 struct ap_queue_status status;
524 int t_depth, t_device_type, rc, i; 522 int t_depth, t_device_type;
525 523
526 rc = -EBUSY; 524 status = ap_test_queue(qid, &t_depth, &t_device_type);
527 for (i = 0; i < AP_MAX_RESET; i++) { 525 switch (status.response_code) {
528 status = ap_test_queue(qid, &t_depth, &t_device_type); 526 case AP_RESPONSE_NORMAL:
529 switch (status.response_code) { 527 *queue_depth = t_depth + 1;
530 case AP_RESPONSE_NORMAL: 528 *device_type = t_device_type;
531 *queue_depth = t_depth + 1; 529 return 0;
532 *device_type = t_device_type; 530 case AP_RESPONSE_Q_NOT_AVAIL:
533 rc = 0; 531 case AP_RESPONSE_DECONFIGURED:
534 break; 532 case AP_RESPONSE_CHECKSTOPPED:
535 case AP_RESPONSE_Q_NOT_AVAIL: 533 case AP_RESPONSE_INVALID_ADDRESS:
536 rc = -ENODEV; 534 return -ENODEV;
537 break; 535 case AP_RESPONSE_RESET_IN_PROGRESS:
538 case AP_RESPONSE_RESET_IN_PROGRESS: 536 case AP_RESPONSE_OTHERWISE_CHANGED:
539 break; 537 case AP_RESPONSE_BUSY:
540 case AP_RESPONSE_DECONFIGURED: 538 return -EBUSY;
541 rc = -ENODEV; 539 default:
542 break; 540 BUG();
543 case AP_RESPONSE_CHECKSTOPPED:
544 rc = -ENODEV;
545 break;