s390/ap: modularize ap bus
authorHolger Dengler <dengler@linux.ibm.com>
Mon, 19 Feb 2024 17:10:19 +0000 (18:10 +0100)
committerAlexander Gordeev <agordeev@linux.ibm.com>
Tue, 9 Apr 2024 15:29:56 +0000 (17:29 +0200)
There is no hard requirement to have the ap bus statically in the
kernel, so add an option to compile it as module.

Cc: Tony Krowiak <akrowiak@linux.ibm.com>
Cc: Halil Pasic <pasic@linux.ibm.com>
Signed-off-by: Holger Dengler <dengler@linux.ibm.com>
Reviewed-by: Harald Freudenberger <freude@linux.ibm.com>
Reviewed-by: Anthony Krowiak <akrowiak@linux.ibm.com>
Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
Documentation/arch/s390/vfio-ap.rst
arch/s390/Kconfig
drivers/crypto/Kconfig
drivers/s390/char/Makefile
drivers/s390/crypto/Makefile
drivers/s390/crypto/ap_bus.c

index 929ee1c1c940072af235b233c9343e38e563be4e..cf8533f2a8b65dd568296121f3cb000dbc34774b 100644 (file)
@@ -550,7 +550,7 @@ These are the steps:
    following Kconfig elements selected:
    * IOMMU_SUPPORT
    * S390
-   * ZCRYPT
+   * AP
    * VFIO
    * KVM
 
index 8f01ada6845e36086d85c32a076c8057208e498c..db7eb4d77d38d826e56c3725ed0260a8c055aa41 100644 (file)
@@ -724,6 +724,19 @@ config EADM_SCH
          To compile this driver as a module, choose M here: the
          module will be called eadm_sch.
 
+config AP
+       def_tristate y
+       prompt "Support for Adjunct Processors (ap)"
+       help
+         This driver allows usage to Adjunct Processor (AP) devices via
+         the ap bus, cards and queues. Supported Adjunct Processors are
+         the CryptoExpress Cards (CEX).
+
+         To compile this driver as a module, choose M here: the
+         module will be called ap.
+
+         If unsure, say Y (default).
+
 config VFIO_CCW
        def_tristate n
        prompt "Support for VFIO-CCW subchannels"
@@ -740,7 +753,7 @@ config VFIO_AP
        prompt "VFIO support for AP devices"
        depends on KVM
        depends on VFIO
-       depends on ZCRYPT
+       depends on AP
        select VFIO_MDEV
        help
          This driver grants access to Adjunct Processor (AP) devices
index 3d02702456a507606572e9fd84ce226d87e3ad9b..16385658fd35d90fe18eda9e471e04d6d6a5a9ca 100644 (file)
@@ -67,6 +67,7 @@ config CRYPTO_DEV_GEODE
 config ZCRYPT
        tristate "Support for s390 cryptographic adapters"
        depends on S390
+       depends on AP
        select HW_RANDOM
        help
          Select this option if you want to enable support for
index b0f6b32016362e6ba810038cd6eea5ce95b4bc35..81d6744e1861fd2c964fe4094985b8d80e876cef 100644 (file)
@@ -32,7 +32,7 @@ obj-$(CONFIG_SCLP_VT220_TTY) += sclp_vt220.o
 
 obj-$(CONFIG_PCI) += sclp_pci.o
 
-obj-$(subst m,y,$(CONFIG_ZCRYPT)) += sclp_ap.o
+obj-$(subst m,y,$(CONFIG_AP)) += sclp_ap.o
 
 obj-$(CONFIG_VMLOGRDR) += vmlogrdr.o
 obj-$(CONFIG_VMCP) += vmcp.o
index 0edacd101c124b0ff7b60845ea08e81ee25d0654..bd94811fd9f1f8c01fff5f93f4ed16e84d3a997c 100644 (file)
@@ -4,7 +4,7 @@
 #
 
 ap-objs := ap_bus.o ap_card.o ap_queue.o
-obj-$(subst m,y,$(CONFIG_ZCRYPT)) += ap.o
+obj-$(CONFIG_AP) += ap.o
 # zcrypt_api.o and zcrypt_msgtype*.o depend on ap.o
 zcrypt-objs := zcrypt_api.o zcrypt_card.o zcrypt_queue.o
 zcrypt-objs += zcrypt_msgtype6.o zcrypt_msgtype50.o
index 9284ae63074d9625180546021b552eff6e431e1c..09059b3a3a42afea64e6bf23391d2f407ba62ca4 100644 (file)
 #include "ap_bus.h"
 #include "ap_debug.h"
 
-/*
- * Module parameters; note though this file itself isn't modular.
- */
+MODULE_AUTHOR("IBM Corporation");
+MODULE_DESCRIPTION("Adjunct Processor Bus driver");
+MODULE_LICENSE("GPL");
+
 int ap_domain_index = -1;      /* Adjunct Processor Domain Index */
 static DEFINE_SPINLOCK(ap_domain_lock);
 module_param_named(domain, ap_domain_index, int, 0440);
@@ -2284,6 +2285,16 @@ static void ap_scan_bus_wq_callback(struct work_struct *unused)
        }
 }
 
+static inline void __exit ap_async_exit(void)
+{
+       if (ap_thread_flag)
+               ap_poll_thread_stop();
+       chsc_notifier_unregister(&ap_bus_nb);
+       cancel_work(&ap_scan_bus_work);
+       hrtimer_cancel(&ap_poll_timer);
+       timer_delete(&ap_scan_bus_timer);
+}
+
 static inline int __init ap_async_init(void)
 {
        int rc;
@@ -2451,4 +2462,15 @@ out:
        ap_debug_exit();
        return rc;
 }
-device_initcall(ap_module_init);
+
+static void __exit ap_module_exit(void)
+{
+       ap_async_exit();
+       ap_irq_exit();
+       root_device_unregister(ap_root_device);
+       bus_unregister(&ap_bus_type);
+       ap_debug_exit();
+}
+
+module_init(ap_module_init);
+module_exit(ap_module_exit);