Skip to contentSkip to conversation

add spi attributes to qla1280

PATCH In review Jeremy Higdon 3 participants 9 messages Aug 10, 2004 – Aug 12, 2004

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 add spi attributes to qla1280

This patch adds SPI attributes to the qla1280 driver.

It is similar to a patch submitted back in March by mort, except that it has been updated to the current API.

Jes, can you confirm that this is okay?

Thanks,
jeremy

drivers/scsi/Kconfig +1 -0
diff -ur -X /home/jeremy/dontdiff linux-2.6.8-rc2/drivers/scsi/Kconfig linux-2.6.8-rc2.new/drivers/scsi/Kconfig
@@ -1258,6 +1258,7 @@
 config SCSI_QLOGIC_1280
 	tristate "Qlogic QLA 1280 SCSI support"
 	depends on PCI && SCSI
+	select SCSI_SPI_ATTRS
 	help
 	  Say Y if you have a QLogic ISP1x80/1x160 SCSI host adapter.
 
drivers/scsi/qla1280.c +32 -0
diff -ur -X /home/jeremy/dontdiff linux-2.6.8-rc2/drivers/scsi/qla1280.c linux-2.6.8-rc2.new/drivers/scsi/qla1280.c
@@ -353,6 +353,8 @@
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_tcq.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_spi.h>
 #include "scsi.h"
 #else
 #include <linux/blk.h>
@@ -1447,6 +1449,7 @@
 	int status = 0;
 	struct nvram *nv;
 	unsigned long flags;
+	int is1x160;
 
 	ha = (struct scsi_qla_host *)device->host->hostdata;
 	nv = &ha->nvram;
@@ -1489,6 +1492,21 @@
 		status = qla1280_set_target_parameters(ha, bus, target);
 	qla1280_get_target_parameters(ha, device);
 	spin_unlock_irqrestore(HOST_LOCK, flags);
+
+	if (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
+	    ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP10160)
+		is1x160 = 1;
+	else
+		is1x160 = 0;
+
+	spi_period(device) = nv->bus[bus].target[target].sync_period;
+	if (is1x160)
+		spi_offset(device) = nv->bus[bus].target[target].flags.
+			flags1x160.sync_offset;
+	else
+		spi_offset(device) = nv->bus[bus].target[target].flags.
+			flags1x80.sync_offset;
+
 	return status;
 }
 
@@ -4670,6 +4688,8 @@
 };
 #endif
 
+static struct scsi_transport_template *qla1280_transport_template = NULL;
+
 static int __devinit
 qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 {
@@ -4758,6 +4778,7 @@
 	host->max_id = MAX_TARGETS;
 	host->max_sectors = 1024;
 	host->unique_id = host->host_no;
+	host->transportt = qla1280_transport_template;
 
 #if LINUX_VERSION_CODE < 0x020545
 	host->select_queue_depths = qla1280_select_queue_depth;
@@ -4890,6 +4911,12 @@
 	.remove		= __devexit_p(qla1280_remove_one),
 };
 
+static struct spi_function_template qla1280_transport_functions = {
+	.show_period = 1,
+	.show_offset = 1,
+};
+
+
 static int __init
 qla1280_init(void)
 {
@@ -4899,6 +4926,10 @@
 		return -EINVAL;
 	}
 
+	qla1280_transport_template = spi_attach_transport(&qla1280_transport_functions);
+	if (!qla1280_transport_template)
+		return -ENODEV;
+
 #ifdef MODULE
 	/*
 	 * If we are called as a module, the qla1280 pointer may not be null
@@ -4923,6 +4954,7 @@
 qla1280_exit(void)
 {
 	pci_unregister_driver(&qla1280_pci_driver);
+	spi_release_transport(qla1280_transport_template);
 }
 
 module_init(qla1280_init);
#1 lore raw
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Jeremy" == Jeremy Higdon <[email protected]> writes:

Jeremy> This patch adds SPI attributes to the qla1280 driver. It is Jeremy> similar to a patch submitted back in March by mort, except Jeremy> that it has been updated to the current API.

Jeremy> Jes, can you confirm that this is okay?

Jeremy,

Patch looks good to me! James, feel free to push this.

Cheers,
Jes

#2 lore raw
In reply to Jeremy Higdon

drivers/scsi/qla1280.c line 1500

Quoted 5 lines
drivers/scsi/qla1280.c +5 -0
+	if (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
+	    ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP10160)
+		is1x160 = 1;
+	else
+		is1x160 = 0;

The driver in James' tree has most of my 1040-support patches merged, sp please use the apporpinquate IS_ISP* macros like the rest of the drivers does, and please handle the 1040 aswell in that code.

Quoted 1 line

+static struct scsi_transport_template *qla1280_transport_template = NULL;

No need to initialize to NULL here.

Quoted 12 lines

static int __devinit
qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) {

drivers/scsi/qla1280.c +1 -0
@@ -4758,6 +4778,7 @@
 	host->max_id = MAX_TARGETS;
 	host->max_sectors = 1024;
 	host->unique_id = host->host_no;
+	host->transportt = qla1280_transport_template;
 
 #if LINUX_VERSION_CODE < 0x020545
 	host->select_queue_depths = qla1280_select_queue_depth;

drivers/scsi/qla1280.c line 4917

Quoted 7 lines
drivers/scsi/qla1280.c +4 -0
@@ -4890,6 +4911,12 @@
 	.remove		= __devexit_p(qla1280_remove_one),
 };
 
+static struct spi_function_template qla1280_transport_functions = {
+	.show_period = 1,
+	.show_offset = 1,
+};

Any chance you could declare this just below the host template? that keeps the code better organized.

#3 lore raw
Quoted 9 lines · Christoph Hellwig

drivers/scsi/qla1280.c line 1500

Quoted 5 lines
drivers/scsi/qla1280.c +5 -0
+	if (ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP12160 ||
+	    ha->pdev->device == PCI_DEVICE_ID_QLOGIC_ISP10160)
+		is1x160 = 1;
+	else
+		is1x160 = 0;

The driver in James' tree has most of my 1040-support patches merged, sp please use the apporpinquate IS_ISP* macros like the rest of the drivers does, and please handle the 1040 aswell in that code.

The above is consistent with the rest of the driver in 2.6.8-rc2. So are you asking that I submit a patch to the driver in James's tree instead of to 2.6.8-rc2?

To avoid possibility of error, can you give me the URL for James's tree? Is it a bk tree or a kernel.org tree?

Quoted 3 lines
Quoted 1 line

+static struct scsi_transport_template *qla1280_transport_template = NULL;

No need to initialize to NULL here.

I thought about that. What I did was take a patch that Martin Hicks submitted on March 10th and then make changes based on what I saw that James had done for the 53c700 driver, which has:

drivers/scsi/53c700.c:STATIC struct scsi_transport_template *NCR_700_transport_template = NULL;

I will remove the initializer if I don't need it.

Quoted 15 lines
Quoted 15 lines

static int __devinit
qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) {

drivers/scsi/qla1280.c +1 -0
@@ -4758,6 +4778,7 @@
 	host->max_id = MAX_TARGETS;
 	host->max_sectors = 1024;
 	host->unique_id = host->host_no;
+	host->transportt = qla1280_transport_template;
 
 #if LINUX_VERSION_CODE < 0x020545
 	host->select_queue_depths = qla1280_select_queue_depth;
@@ -4890,6 +4911,12 @@
 	.remove		= __devexit_p(qla1280_remove_one),
 };
 
Quoted 7 lines

drivers/scsi/qla1280.c line 4917

Quoted 4 lines
drivers/scsi/qla1280.c +4 -0
+static struct spi_function_template qla1280_transport_functions = {
+	.show_period = 1,
+	.show_offset = 1,
+};

Any chance you could declare this just below the host template? that keeps the code better organized.

Sure.

jeremy

#4 lore raw
Quoted 3 lines · Jeremy Higdon

The above is consistent with the rest of the driver in 2.6.8-rc2. So are you asking that I submit a patch to the driver in James's tree instead of to 2.6.8-rc2?

Yes.

Quoted 2 lines

To avoid possibility of error, can you give me the URL for James's tree? Is it a bk tree or a kernel.org tree?

bk://linux-scsi.bkbits.net/scsi-misc-2.6, it's also part of the latest -mm tree.

Quoted 7 lines
Quoted 1 line

No need to initialize to NULL here.

I thought about that. What I did was take a patch that Martin Hicks submitted on March 10th and then make changes based on what I saw that James had done for the 53c700 driver, which has:

drivers/scsi/53c700.c:STATIC struct scsi_transport_template *NCR_700_transport_template = NULL;

needs fixing aswell :)

#5 lore raw
Quoted 5 lines · Christoph Hellwig
Quoted 3 lines · Jeremy Higdon

The above is consistent with the rest of the driver in 2.6.8-rc2. So are you asking that I submit a patch to the driver in James's tree instead of to 2.6.8-rc2?

Quoted 7 lines

Yes.

Quoted 2 lines

To avoid possibility of error, can you give me the URL for James's tree? Is it a bk tree or a kernel.org tree?

bk://linux-scsi.bkbits.net/scsi-misc-2.6, it's also part of the latest -mm tree.

So I'll submit a patch to 2.6.8-rc4-mm1 then, if that's okay.

Thanks,

Jeremy

#6 lore raw
Quoted 5 lines · Jeremy Higdon
Quoted 2 lines

bk://linux-scsi.bkbits.net/scsi-misc-2.6, it's also part of the latest -mm tree.

So I'll submit a patch to 2.6.8-rc4-mm1 then, if that's okay.

Sounds good. While you're at it can you also fix the compilation error when the driver is compiled for port I/O instead of normal mmio (e.g. SGI ViswW), you broke that with your readb_relaxed changes.

#7 lore raw
Quoted 7 lines · Christoph Hellwig
Quoted 2 lines · Jeremy Higdon

So I'll submit a patch to 2.6.8-rc4-mm1 then, if that's okay.

Sounds good. While you're at it can you also fix the compilation error when the driver is compiled for port I/O instead of normal mmio (e.g. SGI ViswW), you broke that with your readb_relaxed changes.

Okay. Here is the new rendition, based on 2.6.8-rc4-mm1, with the fix for port I/O. For sync period and offset, it seems that the isp1040 is the same as the isp1280.

Thanks,

jeremy

drivers/scsi/Kconfig +1 -0
diff -ur -X /home/jeremy/dontdiff linux-2.6.8-rc4/drivers/scsi/Kconfig linux-2.6.8-rc4.new/drivers/scsi/Kconfig
@@ -1276,6 +1276,7 @@
 config SCSI_QLOGIC_1280
 	tristate "Qlogic QLA 1280 SCSI support"
 	depends on PCI && SCSI
+	select SCSI_SPI_ATTRS
 	help
 	  Say Y if you have a QLogic ISP1x80/1x160 SCSI host adapter.
 
drivers/scsi/qla1280.c +23 -0
diff -ur -X /home/jeremy/dontdiff linux-2.6.8-rc4/drivers/scsi/qla1280.c linux-2.6.8-rc4.new/drivers/scsi/qla1280.c
@@ -356,6 +356,8 @@
 #include <scsi/scsi_device.h>
 #include <scsi/scsi_host.h>
 #include <scsi/scsi_tcq.h>
+#include <scsi/scsi_transport.h>
+#include <scsi/scsi_transport_spi.h>
 #include "scsi.h"
 #else
 #include <linux/blk.h>
@@ -1490,6 +1492,15 @@
 		status = qla1280_set_target_parameters(ha, bus, target);
 	qla1280_get_target_parameters(ha, device);
 	spin_unlock_irqrestore(HOST_LOCK, flags);
+
+	spi_period(device) = nv->bus[bus].target[target].sync_period;
+	if (IS_ISP1x160(ha))
+		spi_offset(device) = nv->bus[bus].target[target].flags.
+			flags1x160.sync_offset;
+	else
+		spi_offset(device) = nv->bus[bus].target[target].flags.
+			flags1x80.sync_offset;
+
 	return status;
 }
 
@@ -4681,6 +4692,12 @@
 };
 #endif
 
+static struct scsi_transport_template *qla1280_transport_template;
+static struct spi_function_template qla1280_transport_functions = {
+	.show_period = 1,
+	.show_offset = 1,
+};
+
 static int __devinit
 qla1280_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
 {
@@ -4769,6 +4786,7 @@
 	host->max_id = MAX_TARGETS;
 	host->max_sectors = 1024;
 	host->unique_id = host->host_no;
+	host->transportt = qla1280_transport_template;
 
 #if LINUX_VERSION_CODE < 0x020545
 	host->select_queue_depths = qla1280_select_queue_depth;
@@ -4910,6 +4928,10 @@
 		return -EINVAL;
 	}
 
+	qla1280_transport_template = spi_attach_transport(&qla1280_transport_functions);
+	if (!qla1280_transport_template)
+		return -ENODEV;
+
 #ifdef MODULE
 	/*
 	 * If we are called as a module, the qla1280 pointer may not be null
@@ -4934,6 +4956,7 @@
 qla1280_exit(void)
 {
 	pci_unregister_driver(&qla1280_pci_driver);
+	spi_release_transport(qla1280_transport_template);
 }
 
 module_init(qla1280_init);
drivers/scsi/qla1280.h +1 -0
diff -ur -X /home/jeremy/dontdiff linux-2.6.8-rc4/drivers/scsi/qla1280.h linux-2.6.8-rc4.new/drivers/scsi/qla1280.h
@@ -62,6 +62,7 @@
 #define WRT_REG_WORD(addr, data)	writew(data, addr)
 #else				/* MEMORY_MAPPED_IO */
 #define RD_REG_WORD(addr)		inw((unsigned long)addr)
+#define RD_REG_WORD_dmasync(addr)	inw((unsigned long)addr)
 #define WRT_REG_WORD(addr, data)	outw(data, (unsigned long)addr)
 #endif				/* MEMORY_MAPPED_IO */
 
#8 lore raw
Quoted 5 lines · Jeremy Higdon
Quoted 4 lines · Christoph Hellwig
Quoted 2 lines · Jeremy Higdon

So I'll submit a patch to 2.6.8-rc4-mm1 then, if that's okay.

Quoted 7 lines
Quoted 3 lines

Sounds good. While you're at it can you also fix the compilation error when the driver is compiled for port I/O instead of normal mmio (e.g. SGI ViswW), you broke that with your readb_relaxed changes.

Okay. Here is the new rendition, based on 2.6.8-rc4-mm1, with the fix for port I/O. For sync period and offset, it seems that the isp1040 is the same as the isp1280.

Looks good to me.