Skip to contentSkip to conversation

misc: bcm-vk: only support ttyVK if CONFIG_TTY is set

PATCH Superseded Scott Branden 3 participants 5 messages Jan 31, 2021 – Feb 3, 2021

Subsystems (2)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Scott Branden

author maintainer
#0 lore raw

PATCH v3 1/1 misc: bcm-vk: only support ttyVK if CONFIG_TTY is set

Correct compile issue if CONFIG_TTY is not set by only adding ttyVK devices if CONFIG_BCM_VK_TTY is set.

---
Changes since v2:
- add CONFIG_BCM_VK_TTY
- add function and stub for bcm_vk_tty_set_irq_enabled Changes since v1:
- add function stubs rather than compiling out code

---
 drivers/misc/bcm-vk/Kconfig      | 16 ++++++++++++
 drivers/misc/bcm-vk/Makefile     |  4 +--
 drivers/misc/bcm-vk/bcm_vk.h     | 42 +++++++++++++++++++++++++++++---
 drivers/misc/bcm-vk/bcm_vk_dev.c |  5 ++--
 drivers/misc/bcm-vk/bcm_vk_tty.c |  6 +++++
 5 files changed, 65 insertions(+), 8 deletions(-)
drivers/misc/bcm-vk/Kconfig +16 -0
index 052f6f28b540..16ce98c964b8 100644
@@ -15,3 +15,19 @@ config BCM_VK
 	  accelerators via /dev/bcm-vk.N devices.
 
 	  If unsure, say N.
+
+if BCM_VK
+
+config BCM_VK_TTY
+	bool "Enable ttyVK"
+	depends on TTY
+	default y
+	help
+	  Select this option to enable ttyVK support to allow console
+	  access to VK 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.
+
+endif # BCM_VK
drivers/misc/bcm-vk/Makefile +2 -2
index e4a1486f7209..1df2ebe851ca 100644
@@ -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
drivers/misc/bcm-vk/bcm_vk.h +39 -3

70 lines not on this page · raw message

drivers/misc/bcm-vk/bcm_vk_dev.c +2 -3
index c3d2bba68ef1..59b4859d68d2 100644
@@ -1396,7 +1396,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);
@@ -1580,8 +1580,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])
drivers/misc/bcm-vk/bcm_vk_tty.c +6 -0
index be3964949b63..4d02692ecfc7 100644
@@ -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);
+}
Signature · 1 line
2.17.1
Acked-by on v3 1/1
#1 lore raw
Quoted 12 lines · Scott Branden

Correct compile issue if CONFIG_TTY is not set by only adding ttyVK devices if CONFIG_BCM_VK_TTY is set.

---
Changes since v2:
- add CONFIG_BCM_VK_TTY
- add function and stub for bcm_vk_tty_set_irq_enabled Changes since v1:
- add function stubs rather than compiling out code

Quoted 7 lines
---
 drivers/misc/bcm-vk/Kconfig      | 16 ++++++++++++
 drivers/misc/bcm-vk/Makefile     |  4 +--
 drivers/misc/bcm-vk/bcm_vk.h     | 42 +++++++++++++++++++++++++++++---
 drivers/misc/bcm-vk/bcm_vk_dev.c |  5 ++--
 drivers/misc/bcm-vk/bcm_vk_tty.c |  6 +++++
 5 files changed, 65 insertions(+), 8 deletions(-)

Thanks.

Signature · 1 line
~Randy
#2 lore raw
In reply to Scott Branden
Quoted 25 lines · Scott Branden

Correct compile issue if CONFIG_TTY is not set by only adding ttyVK devices if CONFIG_BCM_VK_TTY is set.

---
Changes since v2:
- add CONFIG_BCM_VK_TTY
- add function and stub for bcm_vk_tty_set_irq_enabled Changes since v1:
- add function stubs rather than compiling out code

---
 drivers/misc/bcm-vk/Kconfig      | 16 ++++++++++++
 drivers/misc/bcm-vk/Makefile     |  4 +--
 drivers/misc/bcm-vk/bcm_vk.h     | 42 +++++++++++++++++++++++++++++---
 drivers/misc/bcm-vk/bcm_vk_dev.c |  5 ++--
 drivers/misc/bcm-vk/bcm_vk_tty.c |  6 +++++
 5 files changed, 65 insertions(+), 8 deletions(-)
drivers/misc/bcm-vk/Kconfig +0 -0
index 052f6f28b540..16ce98c964b8 100644

drivers/misc/bcm-vk/Kconfig config BCM_VK · line 19

Quoted 5 lines
drivers/misc/bcm-vk/Kconfig +2 -0
@@ -15,3 +15,19 @@ config BCM_VK
 	  accelerators via /dev/bcm-vk.N devices.
 
 	  If unsure, say N.
+
+if BCM_VK

No need for this, just put it on the depends line, right?

drivers/misc/bcm-vk/Kconfig config BCM_VK · line 22

Quoted 3 lines
drivers/misc/bcm-vk/Kconfig +3 -0
+
+config BCM_VK_TTY
+	bool "Enable ttyVK"

Better config help text to explain what this is?

drivers/misc/bcm-vk/Kconfig config BCM_VK · line 24

Quoted 2 lines
drivers/misc/bcm-vk/Kconfig +2 -0
+	depends on TTY
+	default y

Default y is only there if your system can not boot without it, please remove it.

drivers/misc/bcm-vk/Kconfig config BCM_VK · line 27

Quoted 3 lines
drivers/misc/bcm-vk/Kconfig +3 -0
+	help
+	  Select this option to enable ttyVK support to allow console
+	  access to VK cards from host.

Again, more help text, what is a "VK"?

thanks,

greg k-h

author maintainer
#3 lore raw

Hi Greg,,

I need a few clarifications before sending (hopefully) final revisions to the patch.

Quoted 28 lines · Greg Kroah-Hartman
Quoted 27 lines · Scott Branden

Correct compile issue if CONFIG_TTY is not set by only adding ttyVK devices if CONFIG_BCM_VK_TTY is set.

---
Changes since v2:
- add CONFIG_BCM_VK_TTY
- add function and stub for bcm_vk_tty_set_irq_enabled Changes since v1:
- add function stubs rather than compiling out code

---
 drivers/misc/bcm-vk/Kconfig      | 16 ++++++++++++
 drivers/misc/bcm-vk/Makefile     |  4 +--
 drivers/misc/bcm-vk/bcm_vk.h     | 42 +++++++++++++++++++++++++++++---
 drivers/misc/bcm-vk/bcm_vk_dev.c |  5 ++--
 drivers/misc/bcm-vk/bcm_vk_tty.c |  6 +++++
 5 files changed, 65 insertions(+), 8 deletions(-)
drivers/misc/bcm-vk/Kconfig +0 -0
index 052f6f28b540..16ce98c964b8 100644
@@ -15,3 +15,19 @@ config BCM_VK
 	  accelerators via /dev/bcm-vk.N devices.
 
Quoted 4 lines

drivers/misc/bcm-vk/Kconfig config BCM_VK · line 19

Quoted 3 lines
drivers/misc/bcm-vk/Kconfig +2 -0
 	  If unsure, say N.
+
+if BCM_VK

No need for this, just put it on the depends line, right?

If you prefer I can but it on the depends on line.
But, I actually prefer the if syntax in this case as it more clearly shows BCM_VK_TTY is a suboption of BCM_VK.

Please let me know which method is "right"?

Quoted 5 lines

drivers/misc/bcm-vk/Kconfig config BCM_VK · line 22

Quoted 4 lines
drivers/misc/bcm-vk/Kconfig +3 -0
+
+config BCM_VK_TTY
+	bool "Enable ttyVK"

Better config help text to explain what this is?

I'll change it to the following?

"Enable tty's on VK devices"

Quoted 5 lines

drivers/misc/bcm-vk/Kconfig config BCM_VK · line 24

Quoted 3 lines
drivers/misc/bcm-vk/Kconfig +2 -0
+	depends on TTY
+	default y

Default y is only there if your system can not boot without it, please remove it.

I can remove if really needed but I'd like to learn more about such convention. Is there a document I can learn from describing such?

We actually want a full featured driver by default.  Otherwise we'll end up asking people to enable this feature and recompile the driver to get missing features such as this.

Quoted 5 lines

drivers/misc/bcm-vk/Kconfig config BCM_VK · line 27

Quoted 4 lines
drivers/misc/bcm-vk/Kconfig +3 -0
+	help
+	  Select this option to enable ttyVK support to allow console
+	  access to VK cards from host.

Again, more help text, what is a "VK"?

VK is already described in BCM_VK.  Why would I need to add the same information again to a suboption? Perhaps you would like "config BCM_VK" changed to "menuconfig BCM_VK"

Quoted 4 lines

thanks,

greg k-h

Thanks,
 Scott

#4 lore raw
Quoted 33 lines · Scott Branden

Hi Greg,,

I need a few clarifications before sending (hopefully) final revisions to the patch.

Quoted 28 lines · Greg Kroah-Hartman
Quoted 27 lines · Scott Branden

Correct compile issue if CONFIG_TTY is not set by only adding ttyVK devices if CONFIG_BCM_VK_TTY is set.

---
Changes since v2:
- add CONFIG_BCM_VK_TTY
- add function and stub for bcm_vk_tty_set_irq_enabled Changes since v1:
- add function stubs rather than compiling out code

---
 drivers/misc/bcm-vk/Kconfig      | 16 ++++++++++++
 drivers/misc/bcm-vk/Makefile     |  4 +--
 drivers/misc/bcm-vk/bcm_vk.h     | 42 +++++++++++++++++++++++++++++---
 drivers/misc/bcm-vk/bcm_vk_dev.c |  5 ++--
 drivers/misc/bcm-vk/bcm_vk_tty.c |  6 +++++
 5 files changed, 65 insertions(+), 8 deletions(-)
drivers/misc/bcm-vk/Kconfig +0 -0
index 052f6f28b540..16ce98c964b8 100644
@@ -15,3 +15,19 @@ config BCM_VK
 	  accelerators via /dev/bcm-vk.N devices.
 
Quoted 5 lines
Quoted 4 lines

drivers/misc/bcm-vk/Kconfig config BCM_VK · line 19

Quoted 3 lines
drivers/misc/bcm-vk/Kconfig +2 -0
 	  If unsure, say N.
+
+if BCM_VK

No need for this, just put it on the depends line, right?

If you prefer I can but it on the depends on line.

If you do, it will help in that the default value might be inherited from there. I think, maybe, can't remember, try it out!

Quoted 4 lines

But, I actually prefer the if syntax in this case as it more clearly shows BCM_VK_TTY is a suboption of BCM_VK.

Please let me know which method is "right"?

Either is fine, depends seems like the cleaner thing.

Quoted 7 lines
Quoted 4 lines

drivers/misc/bcm-vk/Kconfig config BCM_VK · line 22

Quoted 3 lines
drivers/misc/bcm-vk/Kconfig +3 -0
+
+config BCM_VK_TTY
+	bool "Enable ttyVK"

Better config help text to explain what this is?

I'll change it to the following?

"Enable tty's on VK devices"

"Enable tty ports on a Broadcom VK Accelerator device" is better, right?

Quoted 6 lines
Quoted 4 lines

drivers/misc/bcm-vk/Kconfig config BCM_VK · line 24

Quoted 2 lines
drivers/misc/bcm-vk/Kconfig +2 -0
+	depends on TTY
+	default y

Default y is only there if your system can not boot without it, please remove it.

I can remove if really needed but I'd like to learn more about such convention. Is there a document I can learn from describing such?

Again, if your machine can not boot without it, it should be 'y', otherwise the default is n and don't list it.

Quoted 2 lines

We actually want a full featured driver by default.  Otherwise we'll end up asking people to enable this feature and recompile the driver to get missing features such as this.

No one does that, they all use distro kernels who will enable this on their own.

And even if they do, if they built their own kernel with your driver, and enabled that option, then they can enable this one, there's nothing "special" about your tiny driver here compared to the many thousands of other ones in the tree :)

Quoted 5 lines
Quoted 4 lines

drivers/misc/bcm-vk/Kconfig config BCM_VK · line 27

Quoted 3 lines
drivers/misc/bcm-vk/Kconfig +3 -0
+	help
+	  Select this option to enable ttyVK support to allow console
+	  access to VK cards from host.

Again, more help text, what is a "VK"?

VK is already described in BCM_VK.  Why would I need to add the same information again to a suboption?

Context is everything, why not be verbose so that people know what is happening.

Quoted 1 line

Perhaps you would like "config BCM_VK" changed to "menuconfig BCM_VK"

No, that's overkill for a single sub-option, right?

thanks,

greg k-h