Skip to contentSkip to conversation

fdomain: Resurrect driver (modular version)

RFC PATCH In review Ondrej Zary 2 participants 9 messages Apr 22, 2019 – Apr 29, 2019 SCSI

lore
Share & tools
lore
#0 lore raw

cover fdomain: Resurrect driver (modular version)

Resurrect previously removed fdomain driver, in modern style. Initialization is rewritten completely, with support for multiple cards, no more global state variables.
Most of the code from interrupt handler is moved to a workqueue.

This is a modularized version with core separated from bus-specific drivers (PCI, ISA and PCMCIA). Only PCI driver is tested for now. The other two could be dropped until they get tested.

Signature · 1 line
Ondrej Zary
#1 lore raw

RFC PATCH 1/4 fdomain: Resurrect driver (core)

Future Domain TMC-16xx/TMC-3260 SCSI driver.

This is the core driver, common for PCI, ISA and PCMCIA cards.

---
 drivers/scsi/Kconfig   |   4 +
 drivers/scsi/Makefile  |   1 +
 drivers/scsi/fdomain.c | 666 +++++++++++++++++++++++++++++++++++++++++++++++++
 drivers/scsi/fdomain.h |  25 ++
 4 files changed, 696 insertions(+)
 create mode 100644 drivers/scsi/fdomain.c
 create mode 100644 drivers/scsi/fdomain.h
drivers/scsi/Kconfig +4 -0
index d528018e6fa8..3d6b1f47cbb5 100644
@@ -663,6 +663,10 @@ config SCSI_DMX3191D
 	  To compile this driver as a module, choose M here: the
 	  module will be called dmx3191d.
 
+config SCSI_FDOMAIN
+	tristate
+	depends on SCSI
+
 config SCSI_GDTH
 	tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support"
 	depends on PCI && SCSI
drivers/scsi/Makefile +1 -0
index 8826111fdf4a..b8fbc6d2de54 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_SCSI_AIC94XX)	+= aic94xx/
 obj-$(CONFIG_SCSI_PM8001)	+= pm8001/
 obj-$(CONFIG_SCSI_ISCI)		+= isci/
 obj-$(CONFIG_SCSI_IPS)		+= ips.o
+obj-$(CONFIG_SCSI_FDOMAIN)	+= fdomain.o
 obj-$(CONFIG_SCSI_GENERIC_NCR5380) += g_NCR5380.o
 obj-$(CONFIG_SCSI_QLOGIC_FAS)	+= qlogicfas408.o	qlogicfas.o
 obj-$(CONFIG_PCMCIA_QLOGIC)	+= qlogicfas408.o
drivers/scsi/fdomain.c new file +666 -0

666 lines not on this page · raw message

drivers/scsi/fdomain.h new file +25 -0
new file mode 100644
index 000000000000..ab1a65d7db1f
@@ -0,0 +1,25 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+#define FDOMAIN_REGION_SIZE	0x10
+#define FDOMAIN_BIOS_SIZE	0x2000
+
+#ifdef CONFIG_PM_SLEEP
+static const struct dev_pm_ops fdomain_pm_ops;
+#define FDOMAIN_PM_OPS	(&fdomain_pm_ops)
+#else
+#define FDOMAIN_PM_OPS	NULL
+#endif /* CONFIG_PM_SLEEP */
+
+struct signature {
+	const char *signature;
+	int offset;
+	int length;
+	int bios_major;
+	int bios_minor;
+	int flag; /* 1 = PCI_bus, 2 = ISA_200S, 3 = ISA_250MG, 4 = ISA_200S */
+};
+
+struct Scsi_Host *fdomain_create(int base, int irq, int this_id,
+				 unsigned long bios_base, struct signature *sig,
+				 struct device *dev);
+int fdomain_destroy(struct Scsi_Host *sh);
Signature · 1 line
Ondrej Zary
#2 lore raw

Re: [RFC PATCH 1/4] fdomain: Resurrect driver (core)

Quoted 7 lines

+/* FIFO_COUNT: The host adapter has an 8K cache (host adapters based on the
+ * 18C30 chip have a 2k cache). When this many 512 byte blocks are filled by
+ * the SCSI device, an interrupt will be raised. Therefore, this could be as
+ * low as 0, or as high as 16. Note, however, that values which are too high
+ * or too low seem to prevent any interrupts from occurring, and thereby lock
+ * up the machine.
+ */

Normally we use

/*
* ...
*/

style comments. I'm not sure it is worth bothering to change it in this driver, though.

drivers/scsi/fdomain.c line 273

Quoted 6 lines
drivers/scsi/fdomain.c new file +6 -0
+		cmd->SCp.ptr += len;
+		cmd->SCp.this_residual -= len;
+		if (!cmd->SCp.this_residual && cmd->SCp.buffers_residual) {
+			--cmd->SCp.buffers_residual;
+			++cmd->SCp.buffer;
+			cmd->SCp.ptr = sg_virt(cmd->SCp.buffer);

This isn't safe on highmem systems. At very least we need a depends on !HIGHMEM for the drivers selecting this core driver. If you feel like doing the work it should use scsi_kmap_atomic_sg and scsi_kunmap_atomic_sg.

drivers/scsi/fdomain.c line 312

Quoted 5 lines
drivers/scsi/fdomain.c new file +5 -0
+static void fdomain_work(struct work_struct *work)
+{
+	struct fdomain *fd = container_of(work, struct fdomain, work);
+	struct Scsi_Host *sh = container_of((void *)fd, struct Scsi_Host,
+					    hostdata);

This looks odd. We should never need a void cast for container_of.

drivers/scsi/fdomain.c line 320

Quoted 3 lines
drivers/scsi/fdomain.c new file +3 -0
+	/* Abort calls fdomain_finish_cmd, so we do nothing here. */
+	if (cmd->SCp.phase & aborted)
+		;

This is a no-op..

drivers/scsi/fdomain.c line 392

Quoted 2 lines
drivers/scsi/fdomain.c new file +2 -0
+	if (fd->chip == tmc1800 && !cmd->SCp.have_data_in
+	    && (cmd->SCp.sent_command >= cmd->cmd_len)) {

&& goes on the first line, no need for the inner braces on the second line.

Quoted 1 line

+int fdomain_host_reset(struct scsi_cmnd *cmd)

Should be static.

Quoted 1 line

+struct scsi_host_template fdomain_template = {

Should be marked const.

drivers/scsi/fdomain.c line 584

Quoted 9 lines
drivers/scsi/fdomain.c new file +9 -0
+	if (fdomain_test_loopback(base))
+		return NULL;
+
+	if (!irq) {
+		if (dev_is_pci(dev)) {
+			dev_err(dev, "PCI card has no IRQ assigned");
+			return NULL;
+		}
+		irq = irqs[(inb(base + Configuration1) & 0x0e) >> 1];

The irqs lookup should probably go into the callers that need it.

drivers/scsi/fdomain.c line 593

Quoted 1 line
drivers/scsi/fdomain.c new file +1 -0
+	else if (sig && (sig->bios_major > 0) &&

No need for the inner braces.

Quoted 1 line

+EXPORT_SYMBOL(fdomain_create);

EXPORT_SYMBOL_GPL for internals like this and fdomain_destroy.

#3 lore raw

Re: [RFC PATCH 1/4] fdomain: Resurrect driver (core)

Quoted 7 lines · On Wednesday 24 April 2019 08:02:12 Christoph Hellwig wrote:

drivers/scsi/fdomain.c line 312

Quoted 5 lines
drivers/scsi/fdomain.c new file +5 -0
+static void fdomain_work(struct work_struct *work)
+{
+	struct fdomain *fd = container_of(work, struct fdomain, work);
+	struct Scsi_Host *sh = container_of((void *)fd, struct Scsi_Host,
+					    hostdata);

This looks odd. We should never need a void cast for container_of.

This cast is present in all drivers involving container_of, struct Scsi_Host and hostdata. hostdata in struct Scsi_Host is defined as "unsigned long hostdata[0]"...

Signature · 1 line
Ondrej Zary
#4 lore raw

Re: [RFC PATCH 1/4] fdomain: Resurrect driver (core)

Quoted 10 lines · Ondrej Zary
Quoted 7 lines · On Wednesday 24 April 2019 08:02:12 Christoph Hellwig wrote:

drivers/scsi/fdomain.c line 312

Quoted 5 lines
drivers/scsi/fdomain.c new file +5 -0
+static void fdomain_work(struct work_struct *work)
+{
+	struct fdomain *fd = container_of(work, struct fdomain, work);
+	struct Scsi_Host *sh = container_of((void *)fd, struct Scsi_Host,
+					    hostdata);

This looks odd. We should never need a void cast for container_of.

This cast is present in all drivers involving container_of, struct Scsi_Host and hostdata. hostdata in struct Scsi_Host is defined as "unsigned long hostdata[0]"...

Oh, right - it is the hostdata mess. Sorry for the noise!

#5 lore raw

RFC PATCH 2/4 fdomain: Resurrect driver (PCI support)

In reply to Ondrej Zary

Future Domain TMC-3260/AHA-2920A PCI card support.

Tested on Adaptec AHA-2920A PCI card.

---
 drivers/scsi/Kconfig       | 17 ++++++++++++
 drivers/scsi/Makefile      |  1 +
 drivers/scsi/fdomain_pci.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+)
 create mode 100644 drivers/scsi/fdomain_pci.c
drivers/scsi/Kconfig +17 -0
index 3d6b1f47cbb5..f9d058a07e2a 100644
@@ -667,6 +667,23 @@ config SCSI_FDOMAIN
 	tristate
 	depends on SCSI
 
+config SCSI_FDOMAIN_PCI
+	tristate "Future Domain TMC-3260/AHA-2920A PCI SCSI support"
+	depends on PCI && SCSI
+	select SCSI_FDOMAIN
+	help
+	  This is support for Future Domain's PCI SCSI host adapters (TMC-3260)
+	  and other adapters with PCI bus based on the Future Domain chipsets
+	  (Adaptec AHA-2920A).
+
+	  NOTE: Newer Adaptec AHA-2920C boards use the Adaptec AIC-7850 chip
+	  and should use the aic7xxx driver ("Adaptec AIC7xxx chipset SCSI
+	  controller support"). This Future Domain driver works with the older
+	  Adaptec AHA-2920A boards with a Future Domain chip on them.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called fdomain_pci.
+
 config SCSI_GDTH
 	tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support"
 	depends on PCI && SCSI
drivers/scsi/Makefile +1 -0
index b8fbc6d2de54..f6cc4fbe6957 100644
@@ -77,6 +77,7 @@ obj-$(CONFIG_SCSI_PM8001)	+= pm8001/
 obj-$(CONFIG_SCSI_ISCI)		+= isci/
 obj-$(CONFIG_SCSI_IPS)		+= ips.o
 obj-$(CONFIG_SCSI_FDOMAIN)	+= fdomain.o
+obj-$(CONFIG_SCSI_FDOMAIN_PCI)	+= fdomain_pci.o
 obj-$(CONFIG_SCSI_GENERIC_NCR5380) += g_NCR5380.o
 obj-$(CONFIG_SCSI_QLOGIC_FAS)	+= qlogicfas408.o	qlogicfas.o
 obj-$(CONFIG_PCMCIA_QLOGIC)	+= qlogicfas408.o
drivers/scsi/fdomain_pci.c new file +68 -0

68 lines not on this page · raw message

Signature · 1 line
Ondrej Zary
#7 lore raw

RFC PATCH 3/4 fdomain: Resurrect driver (ISA support)

In reply to Ondrej Zary

Future Domain 16xx ISA SCSI support card support.

Currently untested.

---
 drivers/scsi/Kconfig       |  14 +++
 drivers/scsi/Makefile      |   1 +
 drivers/scsi/fdomain_isa.c | 227 +++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 242 insertions(+)
 create mode 100644 drivers/scsi/fdomain_isa.c
drivers/scsi/Kconfig +14 -0
index f9d058a07e2a..2ea77dafbc00 100644
@@ -684,6 +684,20 @@ config SCSI_FDOMAIN_PCI
 	  To compile this driver as a module, choose M here: the
 	  module will be called fdomain_pci.
 
+config SCSI_FDOMAIN_ISA
+	tristate "Future Domain 16xx ISA SCSI support"
+	depends on ISA && SCSI
+	select CHECK_SIGNATURE
+	select SCSI_FDOMAIN
+	help
+	  This is support for Future Domain's 16-bit SCSI host adapters
+	  (TMC-1660/1680, TMC-1650/1670, TMC-1610M/MER/MEX) and other adapters
+	  with ISA bus based on the Future Domain chipsets (Quantum ISA-200S,
+	  ISA-250MG; and at least one IBM board).
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called fdomain_isa.
+
 config SCSI_GDTH
 	tristate "Intel/ICP (former GDT SCSI Disk Array) RAID Controller support"
 	depends on PCI && SCSI
drivers/scsi/Makefile +1 -0
index f6cc4fbe6957..2e2cffff777d 100644
@@ -78,6 +78,7 @@ obj-$(CONFIG_SCSI_ISCI)		+= isci/
 obj-$(CONFIG_SCSI_IPS)		+= ips.o
 obj-$(CONFIG_SCSI_FDOMAIN)	+= fdomain.o
 obj-$(CONFIG_SCSI_FDOMAIN_PCI)	+= fdomain_pci.o
+obj-$(CONFIG_SCSI_FDOMAIN_ISA)	+= fdomain_isa.o
 obj-$(CONFIG_SCSI_GENERIC_NCR5380) += g_NCR5380.o
 obj-$(CONFIG_SCSI_QLOGIC_FAS)	+= qlogicfas408.o	qlogicfas.o
 obj-$(CONFIG_PCMCIA_QLOGIC)	+= qlogicfas408.o
drivers/scsi/fdomain_isa.c new file +227 -0

227 lines not on this page · raw message

Signature · 1 line
Ondrej Zary
#8 lore raw

RFC PATCH 4/4 fdomain: Resurrect driver (PCMCIA support)

In reply to Ondrej Zary

Future Domain PCMCIA SCSI support card support.

Currently untested.

---
 drivers/scsi/pcmcia/Kconfig      | 10 +++++
 drivers/scsi/pcmcia/Makefile     |  1 +
 drivers/scsi/pcmcia/fdomain_cs.c | 89 ++++++++++++++++++++++++++++++++++++++++
 3 files changed, 100 insertions(+)
 create mode 100644 drivers/scsi/pcmcia/fdomain_cs.c
drivers/scsi/pcmcia/Kconfig +10 -0
index 2d435f105b16..169d93f90a30 100644
@@ -19,6 +19,16 @@ config PCMCIA_AHA152X
 	  To compile this driver as a module, choose M here: the
 	  module will be called aha152x_cs.
 
+config PCMCIA_FDOMAIN
+	tristate "Future Domain PCMCIA support"
+	select SCSI_FDOMAIN
+	help
+	  Say Y here if you intend to attach this type of PCMCIA SCSI host
+	  adapter to your computer.
+
+	  To compile this driver as a module, choose M here: the
+	  module will be called fdomain_cs.
+
 config PCMCIA_NINJA_SCSI
 	tristate "NinjaSCSI-3 / NinjaSCSI-32Bi (16bit) PCMCIA support"
 	depends on !64BIT
drivers/scsi/pcmcia/Makefile +1 -0
index a5a24dd44e7e..02f5b44a2685 100644
@@ -4,6 +4,7 @@ ccflags-y		:= -I $(srctree)/drivers/scsi
 
 # 16-bit client drivers
 obj-$(CONFIG_PCMCIA_QLOGIC)	+= qlogic_cs.o
+obj-$(CONFIG_PCMCIA_FDOMAIN)	+= fdomain_cs.o
 obj-$(CONFIG_PCMCIA_AHA152X)	+= aha152x_cs.o
 obj-$(CONFIG_PCMCIA_NINJA_SCSI)	+= nsp_cs.o
 obj-$(CONFIG_PCMCIA_SYM53C500)	+= sym53c500_cs.o
drivers/scsi/pcmcia/fdomain_cs.c new file +89 -0

89 lines not on this page · raw message

Signature · 1 line
Ondrej Zary