]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commitdiff
misc: bcm-vk: only support ttyVK if CONFIG_TTY is set
authorScott Branden <scott.branden@broadcom.com>
Wed, 3 Feb 2021 22:38:26 +0000 (14:38 -0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 3 Feb 2021 23:48:58 +0000 (00:48 +0100)
Correct compile issue if CONFIG_TTY is not set by
only adding ttyVK devices if CONFIG_BCM_VK_TTY is set.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org> # build-tested
Signed-off-by: Scott Branden <scott.branden@broadcom.com>
Link: https://lore.kernel.org/r/20210203223826.21674-1-scott.branden@broadcom.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/misc/bcm-vk/Kconfig
drivers/misc/bcm-vk/Makefile
drivers/misc/bcm-vk/bcm_vk.h
drivers/misc/bcm-vk/bcm_vk_dev.c
drivers/misc/bcm-vk/bcm_vk_tty.c

index 052f6f28b540e524c47b65e0f0828ad1b689c8fb..68a972772b99b0c87694b6c882c8a5d5927316a4 100644 (file)
@@ -15,3 +15,15 @@ config BCM_VK
          accelerators via /dev/bcm-vk.N devices.
 
          If unsure, say N.
+
+config BCM_VK_TTY
+       bool "Enable tty ports on a Broadcom VK Accelerator device"
+       depends on TTY
+       depends on BCM_VK
+       help
+         Select this option to enable tty support to allow console
+         access to Broadcom VK Accelerator cards from host.
+
+         Device node will in the form /dev/bcm-vk.x_ttyVKy where:
+         x is the instance of the VK card
+         y is the tty device number on the VK card.
index e4a1486f7209b3342139529ce7902d71c2a1609d..1df2ebe851ca0f24377d589229356d20fd57543b 100644 (file)
@@ -7,6 +7,6 @@ obj-$(CONFIG_BCM_VK) += bcm_vk.o
 bcm_vk-objs := \
        bcm_vk_dev.o \
        bcm_vk_msg.o \
-       bcm_vk_sg.o \
-       bcm_vk_tty.o
+       bcm_vk_sg.o
 
+bcm_vk-$(CONFIG_BCM_VK_TTY) += bcm_vk_tty.o
index 3f37c640a814f0098be5f9b59b0560f1f70c29cf..a1338f375589f48aa3006c6136114bec08495161 100644 (file)
@@ -258,7 +258,11 @@ enum pci_barno {
        BAR_2
 };
 
+#ifdef CONFIG_BCM_VK_TTY
 #define BCM_VK_NUM_TTY 2
+#else
+#define BCM_VK_NUM_TTY 0
+#endif
 
 struct bcm_vk_tty {
        struct tty_port port;
@@ -366,11 +370,13 @@ struct bcm_vk {
        struct miscdevice miscdev;
        int devid; /* dev id allocated */
 
+#ifdef CONFIG_BCM_VK_TTY
        struct tty_driver *tty_drv;
        struct timer_list serial_timer;
        struct bcm_vk_tty tty[BCM_VK_NUM_TTY];
        struct workqueue_struct *tty_wq_thread;
        struct work_struct tty_wq_work;
+#endif
 
        /* Reference-counting to handle file operations */
        struct kref kref;
@@ -501,13 +507,43 @@ int bcm_vk_send_shutdown_msg(struct bcm_vk *vk, u32 shut_type,
                             const pid_t pid, const u32 q_num);
 void bcm_to_v_q_doorbell(struct bcm_vk *vk, u32 q_num, u32 db_val);
 int bcm_vk_auto_load_all_images(struct bcm_vk *vk);
-int bcm_vk_tty_init(struct bcm_vk *vk, char *name);
-void bcm_vk_tty_exit(struct bcm_vk *vk);
-void bcm_vk_tty_terminate_tty_user(struct bcm_vk *vk);
 void bcm_vk_hb_init(struct bcm_vk *vk);
 void bcm_vk_hb_deinit(struct bcm_vk *vk);
 void bcm_vk_handle_notf(struct bcm_vk *vk);
 bool bcm_vk_drv_access_ok(struct bcm_vk *vk);
 void bcm_vk_set_host_alert(struct bcm_vk *vk, u32 bit_mask);
 
+#ifdef CONFIG_BCM_VK_TTY
+int bcm_vk_tty_init(struct bcm_vk *vk, char *name);
+void bcm_vk_tty_exit(struct bcm_vk *vk);
+void bcm_vk_tty_terminate_tty_user(struct bcm_vk *vk);
+void bcm_vk_tty_wq_exit(struct bcm_vk *vk);
+
+static inline void bcm_vk_tty_set_irq_enabled(struct bcm_vk *vk, int index)
+{
+       vk->tty[index].irq_enabled = true;
+}
+#else
+static inline int bcm_vk_tty_init(struct bcm_vk *vk, char *name)
+{
+       return 0;
+}
+
+static inline void bcm_vk_tty_exit(struct bcm_vk *vk)
+{
+}
+
+static inline void bcm_vk_tty_terminate_tty_user(struct bcm_vk *vk)
+{
+}
+
+static inline void bcm_vk_tty_wq_exit(struct bcm_vk *vk)
+{
+}
+
+static inline void bcm_vk_tty_set_irq_enabled(struct bcm_vk *vk, int index)
+{
+}
+#endif /* CONFIG_BCM_VK_TTY */
+
 #endif
index a82a8927d92b8a93095dc4ae7b4dab28ab424b2c..6bfea3210389f317391000eabcd20d45db4d6744 100644 (file)
@@ -1397,7 +1397,7 @@ static int bcm_vk_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
                                pdev->irq + vk->num_irqs, vk->num_irqs + 1);
                        goto err_irq;
                }
-               vk->tty[i].irq_enabled = true;
+               bcm_vk_tty_set_irq_enabled(vk, i);
        }
 
        id = ida_simple_get(&bcm_vk_ida, 0, 0, GFP_KERNEL);
@@ -1582,8 +1582,7 @@ static void bcm_vk_remove(struct pci_dev *pdev)
 
        cancel_work_sync(&vk->wq_work);
        destroy_workqueue(vk->wq_thread);
-       cancel_work_sync(&vk->tty_wq_work);
-       destroy_workqueue(vk->tty_wq_thread);
+       bcm_vk_tty_wq_exit(vk);
 
        for (i = 0; i < MAX_BAR; i++) {
                if (vk->bar[i])
index be3964949b631a6c81a68d4e781f912bb7e99b28..4d02692ecfc7b8dfcef5974f477e382f7575df57 100644 (file)
@@ -331,3 +331,9 @@ void bcm_vk_tty_terminate_tty_user(struct bcm_vk *vk)
                        kill_pid(find_vpid(vktty->pid), SIGKILL, 1);
        }
 }
+
+void bcm_vk_tty_wq_exit(struct bcm_vk *vk)
+{
+       cancel_work_sync(&vk->tty_wq_work);
+       destroy_workqueue(vk->tty_wq_thread);
+}