aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/s390/cio/chsc.c13
-rw-r--r--drivers/s390/cio/vfio_ccw_drv.c8
-rw-r--r--drivers/s390/crypto/ap_bus.c19
-rw-r--r--drivers/s390/crypto/ap_bus.h2
-rw-r--r--drivers/s390/crypto/ap_queue.c26
-rw-r--r--drivers/s390/crypto/zcrypt_api.c30
6 files changed, 78 insertions, 20 deletions
diff --git a/drivers/s390/cio/chsc.c b/drivers/s390/cio/chsc.c
index 4159c63a5fd2..a835b31aad99 100644
--- a/drivers/s390/cio/chsc.c
+++ b/drivers/s390/cio/chsc.c
@@ -24,6 +24,7 @@
24#include <asm/crw.h> 24#include <asm/crw.h>
25#include <asm/isc.h> 25#include <asm/isc.h>
26#include <asm/ebcdic.h> 26#include <asm/ebcdic.h>
27#include <asm/ap.h>
27 28
28#include "css.h" 29#include "css.h"
29#include "cio.h" 30#include "cio.h"
@@ -586,6 +587,15 @@ static void chsc_process_sei_scm_avail(struct chsc_sei_nt0_area *sei_area)
586 " failed (rc=%d).\n", ret); 587 " failed (rc=%d).\n", ret);
587} 588}
588 589
590static void chsc_process_sei_ap_cfg_chg(struct chsc_sei_nt0_area *sei_area)
591{
592 CIO_CRW_EVENT(3, "chsc: ap config changed\n");
593 if (sei_area->rs != 5)
594 return;
595
596 ap_bus_cfg_chg();
597}
598
589static void chsc_process_sei_nt2(struct chsc_sei_nt2_area *sei_area) 599static void chsc_process_sei_nt2(struct chsc_sei_nt2_area *sei_area)
590{ 600{
591 switch (sei_area->cc) { 601 switch (sei_area->cc) {
@@ -612,6 +622,9 @@ static void chsc_process_sei_nt0(struct chsc_sei_nt0_area *sei_area)
612 case 2: /* i/o resource accessibility */ 622 case 2: /* i/o resource accessibility */
613 chsc_process_sei_res_acc(sei_area); 623 chsc_process_sei_res_acc(sei_area);
614 break; 624 break;
625 case 3: /* ap config changed */
626 chsc_process_sei_ap_cfg_chg(sei_area);
627 break;
615 case 7: /* channel-path-availability information */ 628 case 7: /* channel-path-availability information */
616 chsc_process_sei_chp_avail(sei_area); 629 chsc_process_sei_chp_avail(sei_area);
617 break; 630 break;
diff --git a/drivers/s390/cio/vfio_ccw_drv.c b/drivers/s390/cio/vfio_ccw_drv.c
index a10cec0e86eb..0b3b9de45c60 100644
--- a/drivers/s390/cio/vfio_ccw_drv.c
+++ b/drivers/s390/cio/vfio_ccw_drv.c
@@ -72,20 +72,24 @@ static void vfio_ccw_sch_io_todo(struct work_struct *work)
72{ 72{
73 struct vfio_ccw_private *private; 73 struct vfio_ccw_private *private;
74 struct irb *irb; 74 struct irb *irb;
75 bool is_final;
75 76
76 private = container_of(work, struct vfio_ccw_private, io_work); 77 private = container_of(work, struct vfio_ccw_private, io_work);
77 irb = &private->irb; 78 irb = &private->irb;
78 79
80 is_final = !(scsw_actl(&irb->scsw) &
81 (SCSW_ACTL_DEVACT | SCSW_ACTL_SCHACT));
79 if (scsw_is_solicited(&irb->scsw)) { 82 if (scsw_is_solicited(&irb->scsw)) {
80 cp_update_scsw(&private->cp, &irb->scsw); 83 cp_update_scsw(&private->cp, &irb->scsw);
81 cp_free(&private->cp); 84 if (is_final)
85 cp_free(&private->cp);
82 } 86 }
83 memcpy(private->io_region->irb_area, irb, sizeof(*irb)); 87 memcpy(private->io_region->irb_area, irb, sizeof(*irb));
84 88
85 if (private->io_trigger) 89 if (private->io_trigger)
86 eventfd_signal(private->io_trigger, 1); 90 eventfd_signal(private->io_trigger, 1);
87 91
88 if (private->mdev) 92 if (private->mdev && is_final)
89 private->state = VFIO_CCW_STATE_IDLE; 93 private->state = VFIO_CCW_STATE_IDLE;
90} 94}
91 95
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index e15816ff1265..1546389d71db 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -810,11 +810,18 @@ static int ap_device_remove(struct device *dev)
810 struct ap_device *ap_dev = to_ap_dev(dev); 810 struct ap_device *ap_dev = to_ap_dev(dev);
811 struct ap_driver *ap_drv = ap_dev->drv; 811 struct ap_driver *ap_drv = ap_dev->drv;
812 812
813 /* prepare ap queue device removal */
813 if (is_queue_dev(dev)) 814 if (is_queue_dev(dev))
814 ap_queue_remove(to_ap_queue(dev)); 815 ap_queue_prepare_remove(to_ap_queue(dev));
816
817 /* driver's chance to clean up gracefully */
815 if (ap_drv->remove) 818 if (ap_drv->remove)
816 ap_drv->remove(ap_dev); 819 ap_drv->remove(ap_dev);
817 820
821 /* now do the ap queue device remove */
822 if (is_queue_dev(dev))
823 ap_queue_remove(to_ap_queue(dev));
824
818 /* Remove queue/card from list of active queues/cards */ 825 /* Remove queue/card from list of active queues/cards */
819 spin_lock_bh(&ap_list_lock); 826 spin_lock_bh(&ap_list_lock);
820 if (is_card_dev(dev)) 827 if (is_card_dev(dev))
@@ -861,6 +868,16 @@ void ap_bus_force_rescan(void)
861EXPORT_SYMBOL(ap_bus_force_rescan); 868EXPORT_SYMBOL(ap_bus_force_rescan);
862 869
863/* 870/*
871* A config change has happened, force an ap bus rescan.
872*/
873void ap_bus_cfg_chg(void)
874{
875 AP_DBF(DBF_INFO, "%s config change, forcing bus rescan\n", __func__);
876
877 ap_bus_force_rescan();
878}
879
880/*
864 * hex2bitmap() - parse hex mask string and set bitmap. 881 * hex2bitmap() - parse hex mask string and set bitmap.
865 * Valid strings are "0x012345678" with at least one valid hex number. 882 * Valid strings are "0x012345678" with at least one valid hex number.
866 * Rest of the bitmap to the right is padded with 0. No spaces allowed 883 * Rest of the bitmap to the right is padded with 0. No spaces allowed
diff --git a/drivers/s390/crypto/ap_bus.h b/drivers/s390/crypto/ap_bus.h
index d0059eae5d94..15a98a673c5c 100644
--- a/drivers/s390/crypto/ap_bus.h
+++ b/drivers/s390/crypto/ap_bus.h
@@ -91,6 +91,7 @@ enum ap_state {
91 AP_STATE_WORKING, 91 AP_STATE_WORKING,
92 AP_STATE_QUEUE_FULL, 92 AP_STATE_QUEUE_FULL,
93 AP_STATE_SUSPEND_WAIT, 93 AP_STATE_SUSPEND_WAIT,
94 AP_STATE_REMOVE, /* about to be removed from driver */
94 AP_STATE_UNBOUND, /* momentary not bound to a driver */ 95 AP_STATE_UNBOUND, /* momentary not bound to a driver */
95 AP_STATE_BORKED, /* broken */ 96 AP_STATE_BORKED, /* broken */
96 NR_AP_STATES 97 NR_AP_STATES
@@ -252,6 +253,7 @@ void ap_bus_force_rescan(void);
252 253
253void ap_queue_init_reply(struct ap_queue *aq, struct ap_message *ap_msg); 254void ap_queue_init_reply(struct ap_queue *aq, struct ap_message *ap_msg);
254struct ap_queue *ap_queue_create(ap_qid_t qid, int device_type); 255struct ap_queue *ap_queue_create(ap_qid_t qid, int device_type);
256void ap_queue_prepare_remove(struct ap_queue *aq);
255void ap_queue_remove(struct ap_queue *aq); 257void ap_queue_remove(struct ap_queue *aq);
256void ap_queue_suspend(struct ap_device *ap_dev); 258void ap_queue_suspend(struct ap_device *ap_dev);
257void ap_queue_resume(struct ap_device *ap_dev); 259void ap_queue_resume(struct ap_device *ap_dev);
diff --git a/drivers/s390/crypto/ap_queue.c b/drivers/s390/crypto/ap_queue.c
index ba261210c6da..6a340f2c3556 100644
--- a/drivers/s390/crypto/ap_queue.c
+++ b/drivers/s390/crypto/ap_queue.c
@@ -420,6 +420,10 @@ static ap_func_t *ap_jumptable[NR_AP_STATES][NR_AP_EVENTS] = {
420 [AP_EVENT_POLL] = ap_sm_suspend_read, 420 [AP_EVENT_POLL] = ap_sm_suspend_read,
421 [AP_EVENT_TIMEOUT] = ap_sm_nop, 421 [AP_EVENT_TIMEOUT] = ap_sm_nop,
422 }, 422 },
423 [AP_STATE_REMOVE] = {
424 [AP_EVENT_POLL] = ap_sm_nop,
425 [AP_EVENT_TIMEOUT] = ap_sm_nop,
426 },
423 [AP_STATE_UNBOUND] = { 427 [AP_STATE_UNBOUND] = {
424 [AP_EVENT_POLL] = ap_sm_nop, 428 [AP_EVENT_POLL] = ap_sm_nop,
425 [AP_EVENT_TIMEOUT] = ap_sm_nop, 429 [AP_EVENT_TIMEOUT] = ap_sm_nop,
@@ -740,18 +744,31 @@ void ap_flush_queue(struct ap_queue *aq)
740} 744}
741EXPORT_SYMBOL(ap_flush_queue); 745EXPORT_SYMBOL(ap_flush_queue);
742 746
743void ap_queue_remove(struct ap_queue *aq) 747void ap_queue_prepare_remove(struct ap_queue *aq)
744{ 748{
745 ap_flush_queue(aq); 749 spin_lock_bh(&aq->lock);
750 /* flush queue */
751 __ap_flush_queue(aq);
752 /* set REMOVE state to prevent new messages are queued in */
753 aq->state = AP_STATE_REMOVE;
746 del_timer_sync(&aq->timeout); 754 del_timer_sync(&aq->timeout);
755 spin_unlock_bh(&aq->lock);
756}
747 757
748 /* reset with zero, also clears irq registration */ 758void ap_queue_remove(struct ap_queue *aq)
759{
760 /*
761 * all messages have been flushed and the state is
762 * AP_STATE_REMOVE. Now reset with zero which also
763 * clears the irq registration and move the state
764 * to AP_STATE_UNBOUND to signal that this queue
765 * is not used by any driver currently.
766 */
749 spin_lock_bh(&aq->lock); 767 spin_lock_bh(&aq->lock);
750 ap_zapq(aq->qid); 768 ap_zapq(aq->qid);
751 aq->state = AP_STATE_UNBOUND; 769 aq->state = AP_STATE_UNBOUND;
752 spin_unlock_bh(&aq->lock); 770 spin_unlock_bh(&aq->lock);
753} 771}
754EXPORT_SYMBOL(ap_queue_remove);
755 772
756void ap_queue_reinit_state(struct ap_queue *aq) 773void ap_queue_reinit_state(struct ap_queue *aq)
757{ 774{
@@ -760,4 +777,3 @@ void ap_queue_reinit_state(struct ap_queue *aq)
760 ap_wait(ap_sm_event(aq, AP_EVENT_POLL)); 777 ap_wait(ap_sm_event(aq, AP_EVENT_POLL));
761 spin_unlock_bh(&aq->lock); 778 spin_unlock_bh(&aq->lock);
762} 779}
763EXPORT_SYMBOL(ap_queue_reinit_state);
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
index eb93c2d27d0a..689c2af7026a 100644
--- a/drivers/s390/crypto/zcrypt_api.c
+++ b/drivers/s390/crypto/zcrypt_api.c
@@ -586,6 +586,7 @@ static inline bool zcrypt_check_queue(struct ap_perms *perms, int queue)
586 586
587static inline struct zcrypt_queue *zcrypt_pick_queue(struct zcrypt_card *zc, 587static inline struct zcrypt_queue *zcrypt_pick_queue(struct zcrypt_card *zc,
588 struct zcrypt_queue *zq, 588 struct zcrypt_queue *zq,
589 struct module **pmod,
589 unsigned int weight) 590 unsigned int weight)
590{ 591{
591 if (!zq || !try_module_get(zq->queue->ap_dev.drv->driver.owner)) 592 if (!zq || !try_module_get(zq->queue->ap_dev.drv->driver.owner))
@@ -595,15 +596,15 @@ static inline struct zcrypt_queue *zcrypt_pick_queue(struct zcrypt_card *zc,
595 atomic_add(weight, &zc->load); 596 atomic_add(weight, &zc->load);
596 atomic_add(weight, &zq->load); 597 atomic_add(weight, &zq->load);
597 zq->request_count++; 598 zq->request_count++;
599 *pmod = zq->queue->ap_dev.drv->driver.owner;
598 return zq; 600 return zq;
599} 601}
600 602
601static inline void zcrypt_drop_queue(struct zcrypt_card *zc, 603static inline void zcrypt_drop_queue(struct zcrypt_card *zc,
602 struct zcrypt_queue *zq, 604 struct zcrypt_queue *zq,
605 struct module *mod,
603 unsigned int weight) 606 unsigned int weight)
604{ 607{
605 struct module *mod = zq->queue->ap_dev.drv->driver.owner;
606
607 zq->request_count--; 608 zq->request_count--;
608 atomic_sub(weight, &zc->load); 609 atomic_sub(weight, &zc->load);
609 atomic_sub(weight, &zq->load); 610 atomic_sub(weight, &zq->load);
@@ -653,6 +654,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms,
653 unsigned int weight, pref_weight; 654 unsigned int weight, pref_weight;
654 unsigned int func_code; 655 unsigned int func_code;
655 int qid = 0, rc = -ENODEV; 656 int qid = 0, rc = -ENODEV;
657 struct module *mod;
656 658
657 trace_s390_zcrypt_req(mex, TP_ICARSAMODEXPO); 659 trace_s390_zcrypt_req(mex, TP_ICARSAMODEXPO);
658 660
@@ -706,7 +708,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms,
706 pref_weight = weight; 708 pref_weight = weight;
707 } 709 }
708 } 710 }
709 pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, weight); 711 pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, &mod, weight);
710 spin_unlock(&zcrypt_list_lock); 712 spin_unlock(&zcrypt_list_lock);
711 713
712 if (!pref_zq) { 714 if (!pref_zq) {
@@ -718,7 +720,7 @@ static long zcrypt_rsa_modexpo(struct ap_perms *perms,
718 rc = pref_zq->ops->rsa_modexpo(pref_zq, mex); 720 rc = pref_zq->ops->rsa_modexpo(pref_zq, mex);
719 721
720 spin_lock(&zcrypt_list_lock); 722 spin_lock(&zcrypt_list_lock);
721 zcrypt_drop_queue(pref_zc, pref_zq, weight); 723 zcrypt_drop_queue(pref_zc, pref_zq, mod, weight);
722 spin_unlock(&zcrypt_list_lock); 724 spin_unlock(&zcrypt_list_lock);
723 725
724out: 726out:
@@ -735,6 +737,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms,
735 unsigned int weight, pref_weight; 737 unsigned int weight, pref_weight;
736 unsigned int func_code; 738 unsigned int func_code;
737 int qid = 0, rc = -ENODEV; 739 int qid = 0, rc = -ENODEV;
740 struct module *mod;
738 741
739 trace_s390_zcrypt_req(crt, TP_ICARSACRT); 742 trace_s390_zcrypt_req(crt, TP_ICARSACRT);
740 743
@@ -788,7 +791,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms,
788 pref_weight = weight; 791 pref_weight = weight;
789 } 792 }
790 } 793 }
791 pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, weight); 794 pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, &mod, weight);
792 spin_unlock(&zcrypt_list_lock); 795 spin_unlock(&zcrypt_list_lock);
793 796
794 if (!pref_zq) { 797 if (!pref_zq) {
@@ -800,7 +803,7 @@ static long zcrypt_rsa_crt(struct ap_perms *perms,
800 rc = pref_zq->ops->rsa_modexpo_crt(pref_zq, crt); 803 rc = pref_zq->ops->rsa_modexpo_crt(pref_zq, crt);
801 804
802 spin_lock(&zcrypt_list_lock); 805 spin_lock(&zcrypt_list_lock);
803 zcrypt_drop_queue(pref_zc, pref_zq, weight); 806 zcrypt_drop_queue(pref_zc, pref_zq, mod, weight);
804 spin_unlock(&zcrypt_list_lock); 807 spin_unlock(&zcrypt_list_lock);
805 808
806out: 809out:
@@ -819,6 +822,7 @@ static long _zcrypt_send_cprb(struct ap_perms *perms,
819 unsigned int func_code; 822 unsigned int func_code;
820 unsigned short *domain; 823 unsigned short *domain;
821 int qid = 0, rc = -ENODEV; 824 int qid = 0, rc = -ENODEV;
825 struct module *mod;
822 826
823 trace_s390_zcrypt_req(xcRB, TB_ZSECSENDCPRB); 827 trace_s390_zcrypt_req(xcRB, TB_ZSECSENDCPRB);
824 828
@@ -865,7 +869,7 @@ static long _zcrypt_send_cprb(struct ap_perms *perms,
865 pref_weight = weight; 869 pref_weight = weight;
866 } 870 }
867 } 871 }
868 pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, weight); 872 pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, &mod, weight);
869 spin_unlock(&zcrypt_list_lock); 873 spin_unlock(&zcrypt_list_lock);
870 874
871 if (!pref_zq) { 875 if (!pref_zq) {
@@ -881,7 +885,7 @@ static long _zcrypt_send_cprb(struct ap_perms *perms,
881 rc = pref_zq->ops->send_cprb(pref_zq, xcRB, &ap_msg); 885 rc = pref_zq->ops->send_cprb(pref_zq, xcRB, &ap_msg);
882 886
883 spin_lock(&zcrypt_list_lock); 887 spin_lock(&zcrypt_list_lock);
884 zcrypt_drop_queue(pref_zc, pref_zq, weight); 888 zcrypt_drop_queue(pref_zc, pref_zq, mod, weight);
885 spin_unlock(&zcrypt_list_lock); 889 spin_unlock(&zcrypt_list_lock);
886 890
887out: 891out:
@@ -932,6 +936,7 @@ static long zcrypt_send_ep11_cprb(struct ap_perms *perms,
932 unsigned int func_code; 936 unsigned int func_code;
933 struct ap_message ap_msg; 937 struct ap_message ap_msg;
934 int qid = 0, rc = -ENODEV; 938 int qid = 0, rc = -ENODEV;
939 struct module *mod;
935 940
936 trace_s390_zcrypt_req(xcrb, TP_ZSENDEP11CPRB); 941 trace_s390_zcrypt_req(xcrb, TP_ZSENDEP11CPRB);
937 942
@@ -1000,7 +1005,7 @@ static long zcrypt_send_ep11_cprb(struct ap_perms *perms,
1000 pref_weight = weight; 1005 pref_weight = weight;
1001 } 1006 }
1002 } 1007 }
1003 pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, weight); 1008 pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, &mod, weight);
1004 spin_unlock(&zcrypt_list_lock); 1009 spin_unlock(&zcrypt_list_lock);
1005 1010
1006 if (!pref_zq) { 1011 if (!pref_zq) {
@@ -1012,7 +1017,7 @@ static long zcrypt_send_ep11_cprb(struct ap_perms *perms,
1012 rc = pref_zq->ops->send_ep11_cprb(pref_zq, xcrb, &ap_msg); 1017 rc = pref_zq->ops->send_ep11_cprb(pref_zq, xcrb, &ap_msg);
1013 1018
1014 spin_lock(&zcrypt_list_lock); 1019 spin_lock(&zcrypt_list_lock);
1015 zcrypt_drop_queue(pref_zc, pref_zq, weight); 1020 zcrypt_drop_queue(pref_zc, pref_zq, mod, weight);
1016 spin_unlock(&zcrypt_list_lock); 1021 spin_unlock(&zcrypt_list_lock);
1017 1022
1018out_free: 1023out_free:
@@ -1033,6 +1038,7 @@ static long zcrypt_rng(char *buffer)
1033 struct ap_message ap_msg; 1038 struct ap_message ap_msg;
1034 unsigned int domain; 1039 unsigned int domain;
1035 int qid = 0, rc = -ENODEV; 1040 int qid = 0, rc = -ENODEV;
1041 struct module *mod;
1036 1042
1037 trace_s390_zcrypt_req(buffer, TP_HWRNGCPRB); 1043 trace_s390_zcrypt_req(buffer, TP_HWRNGCPRB);
1038 1044
@@ -1064,7 +1070,7 @@ static long zcrypt_rng(char *buffer)
1064 pref_weight = weight; 1070 pref_weight = weight;
1065 } 1071 }
1066 } 1072 }
1067 pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, weight); 1073 pref_zq = zcrypt_pick_queue(pref_zc, pref_zq, &mod, weight);
1068 spin_unlock(&zcrypt_list_lock); 1074 spin_unlock(&zcrypt_list_lock);
1069 1075
1070 if (!pref_zq) { 1076 if (!pref_zq) {
@@ -1076,7 +1082,7 @@ static long zcrypt_rng(char *buffer)
1076 rc = pref_zq->ops->rng(pref_zq, buffer, &ap_msg); 1082 rc = pref_zq->ops->rng(pref_zq, buffer, &ap_msg);
1077 1083
1078 spin_lock(&zcrypt_list_lock); 1084 spin_lock(&zcrypt_list_lock);
1079 zcrypt_drop_queue(pref_zc, pref_zq, weight); 1085 zcrypt_drop_queue(pref_zc, pref_zq, mod, weight);
1080 spin_unlock(&zcrypt_list_lock); 1086 spin_unlock(&zcrypt_list_lock);
1081 1087
1082out: 1088out: