Add pm8001 SAS/SATA HBA driver
Subsystems (3)
RFC PATCH v2 1/1 Add pm8001 SAS/SATA HBA driver
Hi, James
Sorry for the late response. Here is our driver next send with review input from Matthew:
1 Big endian support is added but not test because lack of equipment. 2 IOCTL interface is replaced by sysfs.
3 Delete some unused debug info
4 Move Vendor id to pci_ids.h
5 Kconfig && Makefile modification
Any comments and reviews will be appreciated
Best wishes,
Jack
--- MAINTAINERS | 7 + drivers/scsi/Kconfig | 8 + drivers/scsi/Makefile | 1 + drivers/scsi/pm8001/Makefile | 12 + drivers/scsi/pm8001/pm8001_chips.h | 89 + drivers/scsi/pm8001/pm8001_ctl.c | 584 +++++ drivers/scsi/pm8001/pm8001_ctl.h | 67 + drivers/scsi/pm8001/pm8001_defs.h | 114 + drivers/scsi/pm8001/pm8001_hwi.c | 4288 ++++++++++++++++++++++++++++++++++++ drivers/scsi/pm8001/pm8001_hwi.h | 1011 +++++++++ drivers/scsi/pm8001/pm8001_init.c | 885 ++++++++ drivers/scsi/pm8001/pm8001_sas.c | 1107 ++++++++++ drivers/scsi/pm8001/pm8001_sas.h | 487 ++++ include/linux/pci_ids.h | 2 + 14 files changed, 8662 insertions(+), 0 deletions(-) create mode 100644 drivers/scsi/pm8001/Makefile create mode 100644 drivers/scsi/pm8001/pm8001_chips.h create mode 100644 drivers/scsi/pm8001/pm8001_ctl.c create mode 100644 drivers/scsi/pm8001/pm8001_ctl.h create mode 100644 drivers/scsi/pm8001/pm8001_defs.h create mode 100644 drivers/scsi/pm8001/pm8001_hwi.c create mode 100644 drivers/scsi/pm8001/pm8001_hwi.h create mode 100644 drivers/scsi/pm8001/pm8001_init.c create mode 100644 drivers/scsi/pm8001/pm8001_sas.c create mode 100644 drivers/scsi/pm8001/pm8001_sas.h
MAINTAINERS +7 -0
@@ -3978,6 +3978,13 @@ W: http://www.pmc-sierra.com/ S: Supported F: drivers/scsi/pmcraid.* +PMC SIERRA PM8001 DRIVER +M: [email protected] +M: [email protected] +L: [email protected] +S: Supported +F: drivers/scsi/pm8001/*.* + POSIX CLOCKS and TIMERS M: Thomas Gleixner <[email protected]> S: Supported
drivers/scsi/Kconfig +8 -0
@@ -1817,6 +1817,14 @@ config SCSI_PMCRAID ---help--- This driver supports the PMC SIERRA MaxRAID adapters. +config SCSI_PM8001 + tristate "PMC-Sierra SPC 8001 SAS/SATA Based Host Adapter driver" + depends on PCI && SCSI + select SCSI_SAS_LIBSAS + help + This driver supports PMC-Sierra PCIE SAS/SATA 8x6G SPC 8001 chip + based host adapters. + config SCSI_SRP tristate "SCSI RDMA Protocol helper library" depends on SCSI && PCI
drivers/scsi/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_SCSI_AIC79XX) += aic7xxx/ obj-$(CONFIG_SCSI_AACRAID) += aacraid/ obj-$(CONFIG_SCSI_AIC7XXX_OLD) += aic7xxx_old.o obj-$(CONFIG_SCSI_AIC94XX) += aic94xx/ +obj-$(CONFIG_SCSI_PM8001) += pm8001/ obj-$(CONFIG_SCSI_IPS) += ips.o obj-$(CONFIG_SCSI_FD_MCS) += fd_mcs.o obj-$(CONFIG_SCSI_FUTURE_DOMAIN)+= fdomain.o
drivers/scsi/pm8001/Makefile new file +12 -0
@@ -0,0 +1,12 @@ +# +# Kernel configuration file for the PM8001 SAS/SATA 8x6G based HBA driver +# +# Copyright (C) 2008-2009 USI Co., Ltd. + + +obj-$(CONFIG_SCSI_PM8001) += pm8001.o +pm8001-y += pm8001_init.o \ + pm8001_sas.o \ + pm8001_ctl.o \ + pm8001_hwi.o +
drivers/scsi/pm8001/pm8001_chips.h new file +89 -0
89 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.c new file +584 -0
584 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.h new file +67 -0
67 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_defs.h new file +114 -0
114 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.c new file +4288 -0
2,100 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.h new file +1011 -0
1,011 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_init.c new file +885 -0
885 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.c new file +1107 -0
1,107 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.h new file +487 -0
487 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 12 lines · jack wang
Hi, James
Sorry for the late response. Here is our driver next send with review input from Matthew:
1 Big endian support is added but not test because lack of equipment. 2 IOCTL interface is replaced by sysfs.
3 Delete some unused debug info
4 Move Vendor id topci_ids.h
5Kconfig&&Makefilemodification
Any comments and reviews will be appreciated
Best wishes,
Jack
Just a bunch of random things I found, I didn't look into everything yet:
-LOW_32_BITS/HIGH_32_BITS should be replaced by upper_32_bits/lower_32_bits from linux/kernel.h
-there are at least 2 typos where "memory" is written as "memery"
+static void read_inbound_queue_table(struct pm8001_hba_info *pm8001_ha) +{
+ int inbQ_num = 1;
+ u32 offset;
Can be declared inside the loop.
+ int i;
+ dma_addr_t address = pm8001_ha->inb_addr;
+ for (i = 0; i < inbQ_num; i++) {
+ offset = i * 0x24;
+ pm8001_ha->inb_data[i].pi_pci_bar =
+ get_pci_bar_index(pm8001_mr32(address, (offset + 0x14)));
This need more identation as it's a continued line.
+ pm8001_ha->inb_data[i].pi_offset =
+ pm8001_mr32(address, (offset + 0x18));
+ }
+}
-read_outbound_queue_table(): the same
+ * check_fw_ready - The LLDD check if the FW is ready, if not,wait as long
There is a space mising behind the last ","
+ /* wait until scratch pad 1 and 2 registers in ready state */
+ do {
+ mdelay(10);
+ value = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_1)
+ & SCRATCH_PAD1_RDY;
+ value1 = pm8001_cr32(pm8001_ha, 0, MSGU_SCRATCH_PAD_2)
+ & SCRATCH_PAD2_RDY;
+ if ((--max_wait_count) == 0)
+ break;
+ } while ((value != SCRATCH_PAD1_RDY) || (value1 != SCRATCH_PAD2_RDY));
+
+ if (!max_wait_count)
+ return -1;
+ return 0;
Why not directly "return -1" inside the loop?
+ /*This register is a 16-bit timer with a resolution of 1us. This is the
+ timer used for interrupt delay/coalescing in the PCIe Application Layer.
+ Zero is not a valid value.A value of 1 in the register will cause the
^
Space missing
+/**
+ *Function to do BAR shifting function is called to shift BAR base address
+ *
+ * @pm8001_ha handles for this instance of SAS/SATA hardware
+ * @shiftValue shifting value
+ *
+ * return success or fail
+ */
-you should use proper kerneldoc comments
-the description text duplicates itself somehow
+ return 0;
+}
+static int mpi_uninit_check(struct pm8001_hba_info *pm8001_ha) +{
Newline missing.
There are some more of those I bet. I'll have to leave now, I'm sure someone will take care of the rest.
Eike
RFC PATCH v2 1/1 Add pm8001 SAS/SATA HBA driver
Hi James
Here is an update of our driver patch that incorporates the latest review inputs from Eike.
Jack.
MAINTAINERS +7 -0
@@ -3978,6 +3978,13 @@ W: http://www.pmc-sierra.com/ S: Supported F: drivers/scsi/pmcraid.* +PMC SIERRA PM8001 DRIVER +M: [email protected] +M: [email protected] +L: [email protected] +S: Supported +F: drivers/scsi/pm8001/*.* + POSIX CLOCKS and TIMERS M: Thomas Gleixner <[email protected]> S: Supported
drivers/scsi/Kconfig +8 -0
@@ -1817,6 +1817,14 @@ config SCSI_PMCRAID ---help--- This driver supports the PMC SIERRA MaxRAID adapters. +config SCSI_PM8001 + tristate "PMC-Sierra SPC 8001 SAS/SATA Based Host Adapter driver" + depends on PCI && SCSI + select SCSI_SAS_LIBSAS + help + This driver supports PMC-Sierra PCIE SAS/SATA 8x6G SPC 8001 chip + based host adapters. + config SCSI_SRP tristate "SCSI RDMA Protocol helper library" depends on SCSI && PCI
drivers/scsi/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_SCSI_AIC79XX) += aic7xxx/ obj-$(CONFIG_SCSI_AACRAID) += aacraid/ obj-$(CONFIG_SCSI_AIC7XXX_OLD) += aic7xxx_old.o obj-$(CONFIG_SCSI_AIC94XX) += aic94xx/ +obj-$(CONFIG_SCSI_PM8001) += pm8001/ obj-$(CONFIG_SCSI_IPS) += ips.o obj-$(CONFIG_SCSI_FD_MCS) += fd_mcs.o obj-$(CONFIG_SCSI_FUTURE_DOMAIN)+= fdomain.o
drivers/scsi/pm8001/Makefile new file +12 -0
@@ -0,0 +1,12 @@ +# +# Kernel configuration file for the PM8001 SAS/SATA 8x6G based HBA driver +# +# Copyright (C) 2008-2009 USI Co., Ltd. + + +obj-$(CONFIG_SCSI_PM8001) += pm8001.o +pm8001-y += pm8001_init.o \ + pm8001_sas.o \ + pm8001_ctl.o \ + pm8001_hwi.o +
drivers/scsi/pm8001/pm8001_chips.h new file +89 -0
89 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.c new file +584 -0
584 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.h new file +67 -0
67 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_defs.h new file +108 -0
108 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.c new file +4277 -0
2,106 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.h new file +1011 -0
1,011 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_init.c new file +885 -0
885 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.c new file +1107 -0
1,107 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.h new file +487 -0
487 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 2 lines · jack wang
Here is an update of our driver patch that incorporates the latest review inputs from Eike.
I'm afraid this driver has a slightly more serious issue: it uses virt_to_bus() and therefore won't compile on a lot of non-x86 systems:
pm8001_hwi.c: phys_addr = cpu_to_le64(virt_to_bus((void *)(ccb->buf_pr pm8001_hwi.c: phys_addr = cpu_to_le64(virt_to_bus((void *)(ccb->buf_pr
It' looks like MEM_CCB already has the physical address of this region, so you don't need to use virt_to_bus, you can just compute the offset from the MEM_CCB virt address and add the phys address.
James
Quoted 2 lines · jack wang
Here is an update of our driver patch that incorporates the latest review inputs from Eike.
I'm afraid this driver has a slightly more serious issue: it uses virt_to_bus() and therefore won't compile on a lot of non-x86 systems:
pm8001_hwi.c: phys_addr = cpu_to_le64(virt_to_bus((void
*)(ccb->buf_prpm8001_hwi.c: phys_addr = cpu_to_le64(virt_to_bus((void
*)(ccb->buf_pr
It' looks like MEM_CCB already has the physical address of this region, so you don't need to use virt_to_bus, you can just compute the offset from the MEM_CCB virt address and add the phys address.
James
[lindar] Thanks James, we have fixed it as your suggestion. Attachment is an update of our driver patch.
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
MAINTAINERS +7 -0
@@ -3978,6 +3978,13 @@ W: http://www.pmc-sierra.com/ S: Supported F: drivers/scsi/pmcraid.* +PMC SIERRA PM8001 DRIVER +M: [email protected] +M: [email protected] +L: [email protected] +S: Supported +F: drivers/scsi/pm8001/*.* + POSIX CLOCKS and TIMERS M: Thomas Gleixner <[email protected]> S: Supported
drivers/scsi/Kconfig +8 -0
@@ -1817,6 +1817,14 @@ config SCSI_PMCRAID ---help--- This driver supports the PMC SIERRA MaxRAID adapters. +config SCSI_PM8001 + tristate "PMC-Sierra SPC 8001 SAS/SATA Based Host Adapter driver" + depends on PCI && SCSI + select SCSI_SAS_LIBSAS + help + This driver supports PMC-Sierra PCIE SAS/SATA 8x6G SPC 8001 chip + based host adapters. + config SCSI_SRP tristate "SCSI RDMA Protocol helper library" depends on SCSI && PCI
drivers/scsi/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_SCSI_AIC79XX) += aic7xxx/ obj-$(CONFIG_SCSI_AACRAID) += aacraid/ obj-$(CONFIG_SCSI_AIC7XXX_OLD) += aic7xxx_old.o obj-$(CONFIG_SCSI_AIC94XX) += aic94xx/ +obj-$(CONFIG_SCSI_PM8001) += pm8001/ obj-$(CONFIG_SCSI_IPS) += ips.o obj-$(CONFIG_SCSI_FD_MCS) += fd_mcs.o obj-$(CONFIG_SCSI_FUTURE_DOMAIN)+= fdomain.o
drivers/scsi/pm8001/Makefile new file +12 -0
@@ -0,0 +1,12 @@ +# +# Kernel configuration file for the PM8001 SAS/SATA 8x6G based HBA driver +# +# Copyright (C) 2008-2009 USI Co., Ltd. + + +obj-$(CONFIG_SCSI_PM8001) += pm8001.o +pm8001-y += pm8001_init.o \ + pm8001_sas.o \ + pm8001_ctl.o \ + pm8001_hwi.o +
drivers/scsi/pm8001/pm8001_chips.h new file +89 -0
89 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.c new file +584 -0
584 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.h new file +67 -0
67 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_defs.h new file +108 -0
108 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.c new file +4277 -0
2,106 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
+};
+
drivers/scsi/pm8001/pm8001_hwi.h new file +1011 -0
1,011 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_init.c new file +885 -0
885 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
+MODULE_VERSION(DRV_VERSION);
+MODULE_LICENSE("GPL");
+MODULE_DEVICE_TABLE(pci, pm8001_pci_table);
+
drivers/scsi/pm8001/pm8001_sas.c new file +1107 -0
1,107 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.h new file +487 -0
487 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
+
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 12 lines · lindar_liu
Quoted 2 lines · jack wang
Here is an update of our driver patch that incorporates the latest review inputs from Eike.
I'm afraid this driver has a slightly more serious issue: it uses
virt_to_bus()and therefore won't compile on a lot of non-x86 systems:
pm8001_hwi.c:phys_addr= cpu_to_le64(virt_to_bus((void
*)(ccb->buf_prpm8001_hwi.c:phys_addr= cpu_to_le64(virt_to_bus((void
*)(ccb->buf_pr
Quoted 8 lines
It' looks like
MEM_CCBalready has the physical address of this region, so you don't need to usevirt_to_bus, you can just compute the offset from theMEM_CCBvirt address and add the phys address.James
[lindar] Thanks James, we have fixed it as your suggestion. Attachment is an update of our driver patch.
Thanks.
It's heading in the right direction, but it doesn't actually compile:
drivers/scsi/pm8001/pm8001_hwi.c: In function 'pm8001_chip_ssp_io_req':drivers/scsi/pm8001/pm8001_hwi.c:3647: error: 'struct pm8001_ccb_info' has no member named 'ccb_dma_handle' drivers/scsi/pm8001/pm8001_hwi.c: In function 'pm8001_chip_sata_req':drivers/scsi/pm8001/pm8001_hwi.c:3716: error: 'struct pm8001_ccb_info' has no member named 'ccb_dma_handle'
It looks like some of the files in the diff are from the old version and some from the new one.
Plus you've now picked up this conflict from the addition of the new SCSI commands READ_32 and WRITE_32 which went in with the DIF/DIX type 2 work:
drivers/scsi/pm8001/pm8001_chips.h:44:1: warning: "READ_32" redefined In file included from include/scsi/scsi_host.h:9,
from include/linux/libata.h:37,
from include/scsi/libsas.h:33,
from drivers/scsi/pm8001/pm8001_sas.h:54,
from drivers/scsi/pm8001/pm8001_hwi.c:40:include/scsi/scsi.h:133:1: warning: this is the location of the previous definition In file included from drivers/scsi/pm8001/pm8001_hwi.c:42:drivers/scsi/pm8001/pm8001_chips.h:47:1: warning: "WRITE_32" redefined In file included from include/scsi/scsi_host.h:9,
from include/linux/libata.h:37,
from include/scsi/libsas.h:33,
from drivers/scsi/pm8001/pm8001_sas.h:54,
from drivers/scsi/pm8001/pm8001_hwi.c:40:include/scsi/scsi.h:134:1: warning: this is the location of the previous definition
James
Quoted 2 lines · lindar_liu
Quoted 1 line · jack wang
Here is an update of our driver patch that incorporates the latest
review
Quoted 10 lines
Quoted 1 line
inputs from Eike.
I'm afraid this driver has a slightly more serious issue: it uses
virt_to_bus()and therefore won't compile on a lot of non-x86 systems:
pm8001_hwi.c:phys_addr= cpu_to_le64(virt_to_bus((void
*)(ccb->buf_prpm8001_hwi.c:phys_addr= cpu_to_le64(virt_to_bus((void
*)(ccb->buf_pr
Quoted 6 lines
It' looks like
MEM_CCBalready has the physical address of this region, so you don't need to usevirt_to_bus, you can just compute the offset from theMEM_CCBvirt address and add the phys address.James
[lindar] Thanks James, we have fixed it as your suggestion. Attachment is
an
Quoted 2 lines
update of our driver patch.
Thanks.
It's heading in the right direction, but it doesn't actually compile:
drivers/scsi/pm8001/pm8001_hwi.c: In function 'pm8001_chip_ssp_io_req':drivers/scsi/pm8001/pm8001_hwi.c:3647: error: 'struct pm8001_ccb_info' has no member named 'ccb_dma_handle' drivers/scsi/pm8001/pm8001_hwi.c: In function 'pm8001_chip_sata_req':drivers/scsi/pm8001/pm8001_hwi.c:3716: error: 'struct pm8001_ccb_info' has no member named 'ccb_dma_handle'
It looks like some of the files in the diff are from the old version and some from the new one.
Plus you've now picked up this conflict from the addition of the new SCSI commands READ_32 and WRITE_32 which went in with the DIF/DIX type 2 work:
drivers/scsi/pm8001/pm8001_chips.h:44:1: warning: "READ_32" redefined In file included from include/scsi/scsi_host.h:9,
from include/linux/libata.h:37,
from include/scsi/libsas.h:33,
from drivers/scsi/pm8001/pm8001_sas.h:54,
from drivers/scsi/pm8001/pm8001_hwi.c:40:include/scsi/scsi.h:133:1: warning: this is the location of the previous definition
In file included from drivers/scsi/pm8001/pm8001_hwi.c:42:drivers/scsi/pm8001/pm8001_chips.h:47:1: warning: "WRITE_32" redefined In file included from include/scsi/scsi_host.h:9,
from include/linux/libata.h:37,
from include/scsi/libsas.h:33,
from drivers/scsi/pm8001/pm8001_sas.h:54,
from drivers/scsi/pm8001/pm8001_hwi.c:40:include/scsi/scsi.h:134:1: warning: this is the location of the previous definition
James
[Jack] Hi, James
Sorry for the late response because of our National Day leave. Attached please find update patch of our driver. We replace WRITE_32 to PM8001_WRITE_32 , READ_32 to PM8001_READ_32, and fix compile error ,sorry for that.
MAINTAINERS | 7 + drivers/scsi/Kconfig | 8 + drivers/scsi/Makefile | 1 + drivers/scsi/pm8001/Makefile | 12 + drivers/scsi/pm8001/pm8001_chips.h | 89 + drivers/scsi/pm8001/pm8001_ctl.c | 584 +++++ drivers/scsi/pm8001/pm8001_ctl.h | 67 + drivers/scsi/pm8001/pm8001_defs.h | 108 + drivers/scsi/pm8001/pm8001_hwi.c | 4280 ++++++++++++++++++++++++++++++++++++ drivers/scsi/pm8001/pm8001_hwi.h | 1011 +++++++++ drivers/scsi/pm8001/pm8001_init.c | 889 ++++++++ drivers/scsi/pm8001/pm8001_sas.c | 1107 ++++++++++ drivers/scsi/pm8001/pm8001_sas.h | 488 ++++ include/linux/pci_ids.h | 2 + 14 files changed, 8653 insertions(+), 0 deletions(-)
MAINTAINERS +7 -0
@@ -3978,6 +3978,13 @@ W: http://www.pmc-sierra.com/ S: Supported F: drivers/scsi/pmcraid.* +PMC SIERRA PM8001 DRIVER +M: [email protected] +M: [email protected] +L: [email protected] +S: Supported +F: drivers/scsi/pm8001/*.* + POSIX CLOCKS and TIMERS M: Thomas Gleixner <[email protected]> S: Supported
drivers/scsi/Kconfig +8 -0
@@ -1817,6 +1817,14 @@ config SCSI_PMCRAID ---help--- This driver supports the PMC SIERRA MaxRAID adapters. +config SCSI_PM8001 + tristate "PMC-Sierra SPC 8001 SAS/SATA Based Host Adapter driver" + depends on PCI && SCSI + select SCSI_SAS_LIBSAS + help + This driver supports PMC-Sierra PCIE SAS/SATA 8x6G SPC 8001 chip + based host adapters. + config SCSI_SRP tristate "SCSI RDMA Protocol helper library" depends on SCSI && PCI
drivers/scsi/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_SCSI_AIC79XX) += aic7xxx/ obj-$(CONFIG_SCSI_AACRAID) += aacraid/ obj-$(CONFIG_SCSI_AIC7XXX_OLD) += aic7xxx_old.o obj-$(CONFIG_SCSI_AIC94XX) += aic94xx/ +obj-$(CONFIG_SCSI_PM8001) += pm8001/ obj-$(CONFIG_SCSI_IPS) += ips.o obj-$(CONFIG_SCSI_FD_MCS) += fd_mcs.o obj-$(CONFIG_SCSI_FUTURE_DOMAIN)+= fdomain.o
drivers/scsi/pm8001/Makefile new file +12 -0
@@ -0,0 +1,12 @@ +# +# Kernel configuration file for the PM8001 SAS/SATA 8x6G based HBA driver +# +# Copyright (C) 2008-2009 USI Co., Ltd. + + +obj-$(CONFIG_SCSI_PM8001) += pm8001.o +pm8001-y += pm8001_init.o \ + pm8001_sas.o \ + pm8001_ctl.o \ + pm8001_hwi.o +
drivers/scsi/pm8001/pm8001_chips.h new file +89 -0
89 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.c new file +584 -0
584 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.h new file +67 -0
67 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_defs.h new file +108 -0
108 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.c new file +4280 -0
2,106 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.h new file +1011 -0
1,011 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_init.c new file +889 -0
889 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.c new file +1107 -0
1,107 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.h new file +488 -0
488 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 2 lines · lindar_liu
Quoted 1 line · jack wang
Here is an update of our driver patch that incorporates the latest
review
Quoted 10 lines
Quoted 1 line
inputs from Eike.
I'm afraid this driver has a slightly more serious issue: it uses
virt_to_bus()and therefore won't compile on a lot of non-x86 systems:
pm8001_hwi.c:phys_addr= cpu_to_le64(virt_to_bus((void
*)(ccb->buf_prpm8001_hwi.c:phys_addr= cpu_to_le64(virt_to_bus((void
*)(ccb->buf_pr
Quoted 6 lines
It' looks like
MEM_CCBalready has the physical address of this region, so you don't need to usevirt_to_bus, you can just compute the offset from theMEM_CCBvirt address and add the phys address.James
[lindar] Thanks James, we have fixed it as your suggestion. Attachment is
an
Quoted 2 lines
update of our driver patch.
Thanks.
It's heading in the right direction, but it doesn't actually compile:
drivers/scsi/pm8001/pm8001_hwi.c: In function 'pm8001_chip_ssp_io_req':drivers/scsi/pm8001/pm8001_hwi.c:3647: error: 'struct pm8001_ccb_info' has no member named 'ccb_dma_handle' drivers/scsi/pm8001/pm8001_hwi.c: In function 'pm8001_chip_sata_req':drivers/scsi/pm8001/pm8001_hwi.c:3716: error: 'struct pm8001_ccb_info' has no member named 'ccb_dma_handle'
It looks like some of the files in the diff are from the old version and some from the new one.
Plus you've now picked up this conflict from the addition of the new SCSI commands READ_32 and WRITE_32 which went in with the DIF/DIX type 2 work:
drivers/scsi/pm8001/pm8001_chips.h:44:1: warning: "READ_32" redefined In file included from include/scsi/scsi_host.h:9,
from include/linux/libata.h:37,
from include/scsi/libsas.h:33,
from drivers/scsi/pm8001/pm8001_sas.h:54,
from drivers/scsi/pm8001/pm8001_hwi.c:40:include/scsi/scsi.h:133:1: warning: this is the location of the previous definition
In file included from drivers/scsi/pm8001/pm8001_hwi.c:42:drivers/scsi/pm8001/pm8001_chips.h:47:1: warning: "WRITE_32" redefined In file included from include/scsi/scsi_host.h:9,
from include/linux/libata.h:37,
from include/scsi/libsas.h:33,
from drivers/scsi/pm8001/pm8001_sas.h:54,
from drivers/scsi/pm8001/pm8001_hwi.c:40:include/scsi/scsi.h:134:1: warning: this is the location of the previous definition
James
[Jack] Hi, James
Sorry for the late response because of our National Day leave. Attached please find update patch of our driver. We replace WRITE_32 to PM8001_WRITE_32 , READ_32 to PM8001_READ_32, and fix compile error ,sorry for that.
[Jack]
Add sign-off-by && fix bug when do io on some 6g sas disk will cause open-retry-timeout error.
Best wishes,
--- MAINTAINERS | 7 + drivers/scsi/Kconfig | 8 + drivers/scsi/Makefile | 1 + drivers/scsi/pm8001/Makefile | 12 + drivers/scsi/pm8001/pm8001_chips.h | 89 + drivers/scsi/pm8001/pm8001_ctl.c | 584 +++++ drivers/scsi/pm8001/pm8001_ctl.h | 67 + drivers/scsi/pm8001/pm8001_defs.h | 108 + drivers/scsi/pm8001/pm8001_hwi.c | 4373 ++++++++++++++++++++++++++++++++++++ drivers/scsi/pm8001/pm8001_hwi.h | 1011 +++++++++ drivers/scsi/pm8001/pm8001_init.c | 889 ++++++++ drivers/scsi/pm8001/pm8001_sas.c | 1107 +++++++++ drivers/scsi/pm8001/pm8001_sas.h | 488 ++++ include/linux/pci_ids.h | 2 + 14 files changed, 8746 insertions(+), 0 deletions(-)
MAINTAINERS +7 -0
@@ -3978,6 +3978,13 @@ W: http://www.pmc-sierra.com/ S: Supported F: drivers/scsi/pmcraid.* +PMC SIERRA PM8001 DRIVER +M: [email protected] +M: [email protected] +L: [email protected] +S: Supported +F: drivers/scsi/pm8001/*.* + POSIX CLOCKS and TIMERS M: Thomas Gleixner <[email protected]> S: Supported
drivers/scsi/Kconfig +8 -0
@@ -1817,6 +1817,14 @@ config SCSI_PMCRAID ---help--- This driver supports the PMC SIERRA MaxRAID adapters. +config SCSI_PM8001 + tristate "PMC-Sierra SPC 8001 SAS/SATA Based Host Adapter driver" + depends on PCI && SCSI + select SCSI_SAS_LIBSAS + help + This driver supports PMC-Sierra PCIE SAS/SATA 8x6G SPC 8001 chip + based host adapters. + config SCSI_SRP tristate "SCSI RDMA Protocol helper library" depends on SCSI && PCI
drivers/scsi/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_SCSI_AIC79XX) += aic7xxx/ obj-$(CONFIG_SCSI_AACRAID) += aacraid/ obj-$(CONFIG_SCSI_AIC7XXX_OLD) += aic7xxx_old.o obj-$(CONFIG_SCSI_AIC94XX) += aic94xx/ +obj-$(CONFIG_SCSI_PM8001) += pm8001/ obj-$(CONFIG_SCSI_IPS) += ips.o obj-$(CONFIG_SCSI_FD_MCS) += fd_mcs.o obj-$(CONFIG_SCSI_FUTURE_DOMAIN)+= fdomain.o
drivers/scsi/pm8001/Makefile new file +12 -0
@@ -0,0 +1,12 @@ +# +# Kernel configuration file for the PM8001 SAS/SATA 8x6G based HBA driver +# +# Copyright (C) 2008-2009 USI Co., Ltd. + + +obj-$(CONFIG_SCSI_PM8001) += pm8001.o +pm8001-y += pm8001_init.o \ + pm8001_sas.o \ + pm8001_ctl.o \ + pm8001_hwi.o +
drivers/scsi/pm8001/pm8001_chips.h new file +89 -0
89 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.c new file +584 -0
584 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.h new file +67 -0
67 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_defs.h new file +108 -0
108 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.c new file +4373 -0
2,106 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.h new file +1011 -0
1,011 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_init.c new file +889 -0
889 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.c new file +1107 -0
1,107 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.h new file +488 -0
488 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Jack,
Sorry to nit pick after you've posted several updates. But so many still remain that I didn't have time to get past what is posted below.
On Fri, Oct 9, 2009 at 3:01 AM, jack wang <[email protected]> wrote:
...
Quoted 2 lines
Add sign-off-by && fix bug when do io on some 6g sas disk will cause open-retry-timeout error.
MAINTAINERS +0 -0
...
+F: drivers/scsi/pm8001/*.*
This can just be "*". Few people use DOS to store linux source trees. :)
(quoted diff) +0 -0
b/drivers/scsi/pm8001/pm8001_chips.h
...
+#define PM8001_READ_32(ADDR32, DMA_ADDR, OFFSET) \
+ (*((u32 *)ADDR32)) = (*((u32 *)(((u8 *)DMA_ADDR) + (OFFSET))))
+
+#define PM8001_WRITE_32(DMA_ADDR, OFFSET, VALUE32) \
+ (*((u32 *)(((u8 *)DMA_ADDR)+(OFFSET)))) = (u32)(VALUE32)
I really don't like the name of this macro nor the fact that its a macro.
1) "READ_32" implies MMIO access and DMA_ADDR implies it's touching host memory. Something is fundamentally wrong if everything is needed to be cast to u32 to compile correctly.
2) If there were an inline function, we'd have type checking and probably would't need the casts.
The upside is if the macro is only used to touch data that is read/written by the device, then it would be a good place to put cpu_to_le32() (write case) and le32_to_cpu() (read case) calls.
...
+static inline u32 pm8001_mr32(dma_addr_t addr, u32 offset) +{
+ return readl((void *)addr + offset);
+}
+static inline void pm8001_mw32(dma_addr_t addr, u32 offset, u32 val) +{
+ writel(val, (void *)addr + offset);
+}
This is definitely wrong. dma_addr_t is not an MMIO address. Someone didn't understand
that dma_addr_t is ONLY to be used by devices for accessing host memory (ie DMA).
This line in init_pci_device_addresses() seems to be the root of the problem:
+ pm8001_ha->cfg_addr = cfg_addr =
+ (dma_addr_t)pm8001_ha->io_mem[pcibar].memvirtaddr + offset;
cfg_addr is also a poorly named variable since PCI has a config space and I'm sure that's not meant here.
I suggest taking some inspiration (ie copy the coding style and/or code) from drivers/net/bnx2.h:
...
#define REG_ADDR(bp, offset) (bp->regview + offset)
#define REG_RD(bp, offset) readl(REG_ADDR(bp, offset))
#define REG_RD8(bp, offset) readb(REG_ADDR(bp, offset))
...
struct bnx2x {
/* Fields used in the tx and intr/napi performance paths
* are grouped together in the beginning of the structure
*/
struct bnx2x_fastpath fp[MAX_CONTEXT];
void __iomem *regview;
void __iomem *doorbells;...
(even though I wished they had used inline functions instead of macros as well).
+static inline u32 get_pci_bar_index(u32 pcibar)
+{
+ switch (pcibar) {
+ case 0x10:
+ case 0x14:+ return 0;
...
Don't need these two cases. The default case will return 0.
drivers/scsi/pm8001/pm8001_ctl.c +0 -0
...
+/**
+ * pm8001_ctl_fw_version_show - firmware version
+ * @cdev - pointer to embedded class device
+ * @buf - the buffer returned
Almost but not quite docbook correct. See Documentation/kernel-doc-nano-HOWTO.txt
Lots of functions are missing the ":" for the args. "make docbook" shouldn't add any warnings for this driver.
+static ssize_t pm8001_ctl_fw_version_show(struct device *cdev,
+ struct device_attribute *attr, char *buf)
+{
+ struct Scsi_Host *shost = class_to_shost(cdev); + struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); + struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; + + return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n", + (pm8001_ha->cfg_data.firmware_rev & 0xFF000000) >> 24, + (pm8001_ha->cfg_data.firmware_rev & 0x00FF0000) >> 16, + (pm8001_ha->cfg_data.firmware_rev & 0x0000FF00) >> 8, + pm8001_ha->cfg_data.firmware_rev & 0x000000FF);
+}
The "& 0xFF" byte masks aren't needed if the resulting value were cast to u8. e.g. (u8) (foo >> 24)
+ return snprintf(buf, PAGE_SIZE, "%d\n",
+ pm8001_ha->cfg_data.max_out_io);
Continued lines should be indented at least one (or more) tabs from the first line. This shows up in a bunch of places.
Here's another example:
+static ssize_t pm8001_ctl_aap_log_show(struct device *cdev,
...
+ for (i = 0; i < max; i++) {
+ str += sprintf(str, "0x%08x 0x%08x 0x%08x 0x%08x 0x%08x 0x%08x"
+ "0x%08x 0x%08x\n",
+ *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 4 + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 8 + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 12 + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 16 + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 20 + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 24 + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 28 + i * 32));
+ }
Define a macro before the first line with something like this:
#define AAP1_MEMMAP(r,c) (*(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + (r) * 32 + (c)))
Then the code would be:
AAP1_MEMMAP(i,0), AAP1_MEMMAP(i,4), ...
...
+static ssize_t pm8001_store_update_fw(struct device *cdev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
...
+ default:
+ pm8001_ha->fw_status = FAIL_PARAMETERS;
+ break;
+ }
+ release_firmware(pm8001_ha->fw_image);
+out1:
+ kfree(cmd_ptr);
+out:
+ pm8001_ha->fw_status = err;
err will clobber the fw_status set in the default case. Ie the default case should be setting "err" instead.
(quoted diff) +0 -0
b/drivers/scsi/pm8001/pm8001_defs.h
...
+/* unchangeable hardware details */
+enum hardware_details {
+ PM8001_MAX_PHYS = 8, /* max. possible phys */ + PM8001_MAX_PORTS = 8, /* max. possible ports */ + PM8001_MAX_DEVICES = 1024, /* max supported device */
+};
Does it make any sense to declare these as enum?
Later in the patch I see:
+ pm8001_ha->tags = kmalloc(sizeof(unsigned long)*PM8001_MAX_DEVICES,
+ GFP_KERNEL);
What are we limiting to 1024 devices? LUNS?
I noticed the constant was also used in an initialization loop too.
This use needs a more descriptive error:
+ if (dev == PM8001_MAX_DEVICES) {
+ PM8001_FAIL_DBG(pm8001_ha,
+ pm8001_printk("max support %d devices, ignore ..\n",
+ PM8001_MAX_DEVICES));
+ }
The error message should indicate exactly what is getting ignored.
...
+ /*error code*/
+#define MPI_IO_STATUS_SUCCESS 0 +#define MPI_IO_STATUS_BUSY 1 +#define MPI_IO_STATUS_FAIL -1
These look like they should be enum. Just guessing.
drivers/scsi/pm8001/pm8001_hwi.c +0 -0
...
+ pm8001_ha->cfg_data.event_log_size = 128*1024;
Do these need to be hard coded? Isn't there a #define'd constant for them?
...
+update_outbound_queue_table(struct pm8001_hba_info *pm8001_ha, int number) +{
+ dma_addr_t address = pm8001_ha->outb_addr;
...
While "outb" here certainly means "outbound", can the field please be named "outbnd_addr" or "outbound_addr" to avoid any confusion with IO Port space accessors (inb() and outb())?
Ditto for pm8001_ha->inb_addr.
...
+/**
+ * bar4_shift - function is called to shift BAR base address
+ * @pm8001_ha : our hba card infomation
+ * @shiftValue : shifting value in memory bar.
+ */
+static u32 bar4_shift(struct pm8001_hba_info *pm8001_ha, u32 shiftValue) +{
+ u32 regVal; + u32 max_wait_time; + u32 max_wait_count;
+
+ /* program the inbound AXI translation Lower Address */
+ pm8001_cw32(pm8001_ha, 1, SPC_IBW_AXI_TRANSLATION_LOW, shiftValue);
+
+ /* confirm the setting is written */
+ max_wait_time = 1 * 1000 * 1000; /* 1 sec */
+ max_wait_count = max_wait_time;
+ do {+ mdelay(1);
+ regVal = pm8001_cr32(pm8001_ha, 1, SPC_IBW_AXI_TRANSLATION_LOW);
+ } while ((regVal != shiftValue) && (--max_wait_count));
Comment about "1 sec" is definitely wrong.mdelay() is millisecond delay.
Was udelay() meant to be used here? Probably not.
Any hangs for 1000 seconds (< 17 minutes) could be explained....
Can we drop max_wait_time variable? It's not helping in this case.
Is there any guarantee bar4_shift() will never get called from the interrupt context?
I just ran out of time to double check.
Just want to point out it's not OK to spin on the cpu for milliseconds at a time in that context.
....
+static void init_pci_device_addresses(struct pm8001_hba_info *pm8001_ha)
Doesn't this need __devinit since it's being called from pm8001_chip_init() ?
+static int __devinit pm8001_chip_init(struct pm8001_hba_info *pm8001_ha)
sorry...only 1500 lines or so into a 2000 line patch. Gotta run.
hope this helps,
grant
Quoted 6 lines · Grant Grundler
Later in the patch I see:
(quoted diff) +2
-0+ pm8001_ha->tags = kmalloc(sizeof(unsigned long)*PM8001_MAX_DEVICES, + GFP_KERNEL);What are we limiting to 1024 devices? LUNS?
I noticed the constant was also used in an initialization loop too.
There are some other things that I find suspicious at this point:
-for allocations of array kcalloc() is usually the way to go as it does overflow checks for the multiplication result (not needed here with the current values, but doesn't really hurt in init path either) -using sizeof(*pm8001_ha->tags) would make sure it's the correct size no matter what type this will ever be, because ...
-unsigned long has different size on 32 and 64 bit, I don't know if that makes sense here. AFAICT this is sort of bitmap here so this probably doesn't need to double it's size on 64 bit.
Greetings,
Eike
Quoted 2 lines · Grant Grundler
Later in the patch I see:
+pm8001_ha->tags= kmalloc(sizeof(unsigned
long)*PM8001_MAX_DEVICES,
Quoted 4 lines
+
GFP_KERNEL);What are we limiting to 1024 devices? LUNS?
I noticed the constant was also used in an initialization loop too.
There are some other things that I find suspicious at this point:
-for allocations of array kcalloc() is usually the way to go as it does overflow checks for the multiplication result (not needed here with the current values, but doesn't really hurt in init path either) -using sizeof(*pm8001_ha->tags) would make sure it's the correct size no matter what type this will ever be, because ...
-unsigned long has different size on 32 and 64 bit, I don't know if that makes
sense here. AFAICT this is sort of bitmap here so this probably doesn't need
to double it's size on 64 bit.
[Jack] Will use sizeof(*pm8001_ha->tags) instead. Thanks Eike. Greetings,
Eike
Jack,
Sorry to nit pick after you've posted several updates. But so many still remain that I didn't have time to get past what is posted below. [Jack] Grant
Thanks so much for your carefully comments.
On Fri, Oct 9, 2009 at 3:01 AM, jack wang <[email protected]> wrote:
...
Quoted 2 lines
Add sign-off-by && fix bug when do io on some 6g sas disk will cause open-retry-timeout error.
MAINTAINERS +0 -0
...
+F: drivers/scsi/pm8001/*.*
This can just be "*". Few people use DOS to store linux source trees. :) [Jack] Will fix it.
(quoted diff) +0 -0
b/drivers/scsi/pm8001/pm8001_chips.h
...
+#define PM8001_READ_32(ADDR32, DMA_ADDR, OFFSET) \
+ (*((u32 *)ADDR32)) = (*((u32 *)(((u8 *)DMA_ADDR) + (OFFSET))))
+
+#define PM8001_WRITE_32(DMA_ADDR, OFFSET, VALUE32) \
+ (*((u32 *)(((u8 *)DMA_ADDR)+(OFFSET)))) = (u32)(VALUE32)
I really don't like the name of this macro nor the fact that its a macro.
1) "READ_32" implies MMIO access and DMA_ADDR implies it's touching host memory. Something is fundamentally wrong if everything is needed to be cast to u32 to compile correctly.
2) If there were an inline function, we'd have type checking and probably would't need the casts.
The upside is if the macro is only used to touch data that is read/written by the device, then it would be a good place to put cpu_to_le32() (write case) and le32_to_cpu() (read case) calls.
[Jack] Thanks for suggestion .Will replace this by inline function,and rename the parameter function name.
...
+static inline u32 pm8001_mr32(dma_addr_t addr, u32 offset) +{
+ return readl((void *)addr + offset);
+}
+static inline void pm8001_mw32(dma_addr_t addr, u32 offset, u32 val) +{
+ writel(val, (void *)addr + offset);
+}
This is definitely wrong. dma_addr_t is not an MMIO address. Someone didn't understand
that dma_addr_t is ONLY to be used by devices for accessing host memory (ie DMA).
This line in init_pci_device_addresses() seems to be the root of the problem:
+ pm8001_ha->cfg_addr = cfg_addr =
+ (dma_addr_t)pm8001_ha->io_mem[pcibar].memvirtaddr + offset;
cfg_addr is also a poorly named variable since PCI has a config space and I'm sure that's not meant here.
[Jack] yes, cfg_addr means the main config table address of MPI. I suggest taking some inspiration (ie copy the coding style and/or code) from drivers/net/bnx2.h:
...
#define REG_ADDR(bp, offset) (bp->regview + offset)
#define REG_RD(bp, offset) readl(REG_ADDR(bp, offset))
#define REG_RD8(bp, offset) readb(REG_ADDR(bp, offset))
...
struct bnx2x {
/* Fields used in the tx and intr/napi performance paths
* are grouped together in the beginning of the structure
*/
struct bnx2x_fastpath fp[MAX_CONTEXT];
void __iomem *regview;
void __iomem *doorbells;...
(even though I wished they had used inline functions instead of macros as well).
[Jack] Thanks for give a good example. I will follow your suggestion to modify
our patch.
+static inline u32 get_pci_bar_index(u32 pcibar)
+{
+ switch (pcibar) {
+ case 0x10:
+ case 0x14:+ return 0;
...
Don't need these two cases. The default case will return 0. [Jack]Ok.
(quoted diff) +0 -0
b/drivers/scsi/pm8001/pm8001_ctl.c
...
+/**
+ * pm8001_ctl_fw_version_show - firmware version
+ * @cdev - pointer to embedded class device
+ * @buf - the buffer returned
Almost but not quite docbook correct. See Documentation/kernel-doc-nano-HOWTO.txt
Lots of functions are missing the ":" for the args. "make docbook" shouldn't add any warnings for this driver.
[Jack] Sorry ,will fix it.
+static ssize_t pm8001_ctl_fw_version_show(struct device *cdev,
+ struct device_attribute *attr, char *buf)
+{
+ struct Scsi_Host *shost = class_to_shost(cdev); + struct sas_ha_struct *sha = SHOST_TO_SAS_HA(shost); + struct pm8001_hba_info *pm8001_ha = sha->lldd_ha; + + return snprintf(buf, PAGE_SIZE, "%02x.%02x.%02x.%02x\n", + (pm8001_ha->cfg_data.firmware_rev & 0xFF000000) >> 24, + (pm8001_ha->cfg_data.firmware_rev & 0x00FF0000) >> 16, + (pm8001_ha->cfg_data.firmware_rev & 0x0000FF00) >> 8, + pm8001_ha->cfg_data.firmware_rev & 0x000000FF);
+}
The "& 0xFF" byte masks aren't needed if the resulting value were cast to u8.
e.g. (u8) (foo >> 24)
[Jack]Will fix.
+ return snprintf(buf, PAGE_SIZE, "%d\n",
+ pm8001_ha->cfg_data.max_out_io);
Continued lines should be indented at least one (or more) tabs from the first line. This shows up in a bunch of places. [Jack] will fix it.
Here's another example:
+static ssize_t pm8001_ctl_aap_log_show(struct device *cdev,
...
+ for (i = 0; i < max; i++) {
+ str += sprintf(str, "0x%08x 0x%08x 0x%08x 0x%08x 0x%08x
0x%08x"
+ "0x%08x 0x%08x\n",
+ *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 4 + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 8 + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 12 + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 16 + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 20 + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 24 + i * 32), + *(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + + 28 + i * 32));
+ }
Define a macro before the first line with something like this:
#define AAP1_MEMMAP(r,c) (*(u32 *)((u8 *)pm8001_ha->memoryMap.region[AAP1].virt_ptr + (r) * 32 + (c)))
Then the code would be:
AAP1_MEMMAP(i,0), AAP1_MEMMAP(i,4), ...
[Jack] Good suggestion . Will fix it.
...
+static ssize_t pm8001_store_update_fw(struct device *cdev,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
...
+ default:
+ pm8001_ha->fw_status = FAIL_PARAMETERS;
+ break;
+ }
+ release_firmware(pm8001_ha->fw_image);
+out1:
+ kfree(cmd_ptr);
+out:
+ pm8001_ha->fw_status = err;
err will clobber the fw_status set in the default case. Ie the default case should be setting "err" instead. [Jack] Will fix it.
(quoted diff) +0 -0
b/drivers/scsi/pm8001/pm8001_defs.h
...
+/* unchangeable hardware details */
+enum hardware_details {
+ PM8001_MAX_PHYS = 8, /* max. possible phys */ + PM8001_MAX_PORTS = 8, /* max. possible ports */ + PM8001_MAX_DEVICES = 1024, /* max supported device */
+};
Does it make any sense to declare these as enum? [Jack] Yes, maybe move out of enum will be better. Later in the patch I see:
+ pm8001_ha->tags = kmalloc(sizeof(unsigned long)*PM8001_MAX_DEVICES,
+ GFP_KERNEL);
What are we limiting to 1024 devices? LUNS?
I noticed the constant was also used in an initialization loop too. [Jack] tags are used to be a BITMAP to limit the max io.
This use needs a more descriptive error:
+ if (dev == PM8001_MAX_DEVICES) {
+ PM8001_FAIL_DBG(pm8001_ha,
+ pm8001_printk("max support %d devices, ignore ..\n",
+ PM8001_MAX_DEVICES));
+ }
The error message should indicate exactly what is getting ignored. [Jack] Will fix it.
...
+ /*error code*/
+#define MPI_IO_STATUS_SUCCESS 0 +#define MPI_IO_STATUS_BUSY 1 +#define MPI_IO_STATUS_FAIL -1
These look like they should be enum. Just guessing. [Jack] Yes , you are right ,will fix it.
(quoted diff) +0 -0
b/drivers/scsi/pm8001/pm8001_hwi.c
...
+ pm8001_ha->cfg_data.event_log_size = 128*1024;
Do these need to be hard coded? Isn't there a #define'd constant for them? [Jack]The event log size are allocated to save some error event from firmware.
Will define constant to replace the hard code.
...
+update_outbound_queue_table(struct pm8001_hba_info *pm8001_ha, int number) +{
+ dma_addr_t address = pm8001_ha->outb_addr;
...
While "outb" here certainly means "outbound", can the field please be named "outbnd_addr" or "outbound_addr" to avoid any confusion with IO Port space accessors (inb() and outb())?
Ditto for pm8001_ha->inb_addr.
[Jack]Will use more clear name.
...
+/**
+ * bar4_shift - function is called to shift BAR base address
+ * @pm8001_ha : our hba card infomation
+ * @shiftValue : shifting value in memory bar.
+ */
+static u32 bar4_shift(struct pm8001_hba_info *pm8001_ha, u32 shiftValue) +{
+ u32 regVal; + u32 max_wait_time; + u32 max_wait_count;
+
+ /* program the inbound AXI translation Lower Address */
+ pm8001_cw32(pm8001_ha, 1, SPC_IBW_AXI_TRANSLATION_LOW, shiftValue);
+
+ /* confirm the setting is written */
+ max_wait_time = 1 * 1000 * 1000; /* 1 sec */
+ max_wait_count = max_wait_time;
+ do {+ mdelay(1);
+ regVal = pm8001_cr32(pm8001_ha, 1,SPC_IBW_AXI_TRANSLATION_LOW);
+ } while ((regVal != shiftValue) && (--max_wait_count));
Comment about "1 sec" is definitely wrong.mdelay() is millisecond delay.
Was udelay() meant to be used here? Probably not.
Any hangs for 1000 seconds (< 17 minutes) could be explained.... [Jack] Sorry. udelay is what I want.
Can we drop max_wait_time variable? It's not helping in this case. [Jack] will drop it ,and use max_time_count directly. Is there any guarantee bar4_shift() will never get called from the interrupt context?
I just ran out of time to double check.
Just want to point out it's not OK to spin on the
cpu for milliseconds at a time in that context.
[Jack] Yes it only called in process context.
....
+static void init_pci_device_addresses(struct pm8001_hba_info *pm8001_ha)
Doesn't this need __devinit since it's being called from pm8001_chip_init() ?
+static int __devinit pm8001_chip_init(struct pm8001_hba_info *pm8001_ha) [Jack]__devinit will be added.
sorry...only 1500 lines or so into a 2000 line patch. Gotta run. [Jack] Thank once more.
hope this helps,
grant
RFC PATCH v3 1/1 Add pm8001 SAS/SATA HBA driver
In reply to Grant GrundlerHi James
Here is an updated driver patch that incorporates all the latest review inputs from Grant and Eike.
Best wishes,
Jack
--- MAINTAINERS | 7 + drivers/scsi/Kconfig | 8 + drivers/scsi/Makefile | 1 + drivers/scsi/pm8001/Makefile | 12 + drivers/scsi/pm8001/pm8001_chips.h | 89 + drivers/scsi/pm8001/pm8001_ctl.c | 573 +++++ drivers/scsi/pm8001/pm8001_ctl.h | 67 + drivers/scsi/pm8001/pm8001_defs.h | 112 + drivers/scsi/pm8001/pm8001_hwi.c | 4372 ++++++++++++++++++++++++++++++++++++ drivers/scsi/pm8001/pm8001_hwi.h | 1011 +++++++++ drivers/scsi/pm8001/pm8001_init.c | 888 ++++++++ drivers/scsi/pm8001/pm8001_sas.c | 1104 +++++++++ drivers/scsi/pm8001/pm8001_sas.h | 480 ++++ include/linux/pci_ids.h | 2 + 14 files changed, 8726 insertions(+), 0 deletions(-)
MAINTAINERS +7 -0
@@ -3978,6 +3978,13 @@ W: http://www.pmc-sierra.com/ S: Supported F: drivers/scsi/pmcraid.* +PMC SIERRA PM8001 DRIVER +M: [email protected] +M: [email protected] +L: [email protected] +S: Supported +F: drivers/scsi/pm8001/ + POSIX CLOCKS and TIMERS M: Thomas Gleixner <[email protected]> S: Supported
drivers/scsi/Kconfig +8 -0
@@ -1817,6 +1817,14 @@ config SCSI_PMCRAID ---help--- This driver supports the PMC SIERRA MaxRAID adapters. +config SCSI_PM8001 + tristate "PMC-Sierra SPC 8001 SAS/SATA Based Host Adapter driver" + depends on PCI && SCSI + select SCSI_SAS_LIBSAS + help + This driver supports PMC-Sierra PCIE SAS/SATA 8x6G SPC 8001 chip + based host adapters. + config SCSI_SRP tristate "SCSI RDMA Protocol helper library" depends on SCSI && PCI
drivers/scsi/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_SCSI_AIC79XX) += aic7xxx/ obj-$(CONFIG_SCSI_AACRAID) += aacraid/ obj-$(CONFIG_SCSI_AIC7XXX_OLD) += aic7xxx_old.o obj-$(CONFIG_SCSI_AIC94XX) += aic94xx/ +obj-$(CONFIG_SCSI_PM8001) += pm8001/ obj-$(CONFIG_SCSI_IPS) += ips.o obj-$(CONFIG_SCSI_FD_MCS) += fd_mcs.o obj-$(CONFIG_SCSI_FUTURE_DOMAIN)+= fdomain.o
drivers/scsi/pm8001/Makefile new file +12 -0
@@ -0,0 +1,12 @@ +# +# Kernel configuration file for the PM8001 SAS/SATA 8x6G based HBA driver +# +# Copyright (C) 2008-2009 USI Co., Ltd. + + +obj-$(CONFIG_SCSI_PM8001) += pm8001.o +pm8001-y += pm8001_init.o \ + pm8001_sas.o \ + pm8001_ctl.o \ + pm8001_hwi.o +
drivers/scsi/pm8001/pm8001_chips.h new file +89 -0
89 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.c new file +573 -0
573 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.h new file +67 -0
67 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_defs.h new file +112 -0
112 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.c new file +4372 -0
2,113 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.h new file +1011 -0
1,011 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_init.c new file +888 -0
888 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.c new file +1104 -0
1,104 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.h new file +480 -0
480 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
Quoted 5 lines · jack wang
Hi James
Here is an updated driver patch that incorporates all the latest review inputs from Grant and Eike.
Best wishes,
Jack
+static inline u32 pm8001_read_le_32(void *virt_addr) +{
+ return *((u32 *)((u8 *)virt_addr));
+}
The cast to u8* isn't needed.
+static inline void pm8001_write_le_32(void *addr, u32 offset, u32 val) +{
+ *((u32 *)(((u8 *)addr)+(offset))) = val;
+}
void* can be added, it's a gcc extension the Linux kernel uses just everywhere. So at the end this could boil down to:
*((u32 *)(addr + offset)) = val;
And if you have _le_32 the value passed in and returned from pm8001_read_le_32() should probably be le32 instead of u32 so you can get sparse checks for that.
Greetings,
Eike
Hi James
Here is an update patch incorporate latest inputs from Eike. Thanks
Jack
--- MAINTAINERS | 7 + drivers/scsi/Kconfig | 8 + drivers/scsi/Makefile | 1 + drivers/scsi/pm8001/Makefile | 12 + drivers/scsi/pm8001/pm8001_chips.h | 89 + drivers/scsi/pm8001/pm8001_ctl.c | 573 +++++ drivers/scsi/pm8001/pm8001_ctl.h | 67 + drivers/scsi/pm8001/pm8001_defs.h | 112 + drivers/scsi/pm8001/pm8001_hwi.c | 4371 ++++++++++++++++++++++++++++++++++++ drivers/scsi/pm8001/pm8001_hwi.h | 1011 +++++++++ drivers/scsi/pm8001/pm8001_init.c | 888 ++++++++ drivers/scsi/pm8001/pm8001_sas.c | 1104 +++++++++ drivers/scsi/pm8001/pm8001_sas.h | 480 ++++ include/linux/pci_ids.h | 2 + 14 files changed, 8725 insertions(+), 0 deletions(-)
MAINTAINERS +7 -0
@@ -3978,6 +3978,13 @@ W: http://www.pmc-sierra.com/ S: Supported F: drivers/scsi/pmcraid.* +PMC SIERRA PM8001 DRIVER +M: [email protected] +M: [email protected] +L: [email protected] +S: Supported +F: drivers/scsi/pm8001/ + POSIX CLOCKS and TIMERS M: Thomas Gleixner <[email protected]> S: Supported
drivers/scsi/Kconfig +8 -0
@@ -1817,6 +1817,14 @@ config SCSI_PMCRAID ---help--- This driver supports the PMC SIERRA MaxRAID adapters. +config SCSI_PM8001 + tristate "PMC-Sierra SPC 8001 SAS/SATA Based Host Adapter driver" + depends on PCI && SCSI + select SCSI_SAS_LIBSAS + help + This driver supports PMC-Sierra PCIE SAS/SATA 8x6G SPC 8001 chip + based host adapters. + config SCSI_SRP tristate "SCSI RDMA Protocol helper library" depends on SCSI && PCI
drivers/scsi/Makefile +1 -0
@@ -70,6 +70,7 @@ obj-$(CONFIG_SCSI_AIC79XX) += aic7xxx/ obj-$(CONFIG_SCSI_AACRAID) += aacraid/ obj-$(CONFIG_SCSI_AIC7XXX_OLD) += aic7xxx_old.o obj-$(CONFIG_SCSI_AIC94XX) += aic94xx/ +obj-$(CONFIG_SCSI_PM8001) += pm8001/ obj-$(CONFIG_SCSI_IPS) += ips.o obj-$(CONFIG_SCSI_FD_MCS) += fd_mcs.o obj-$(CONFIG_SCSI_FUTURE_DOMAIN)+= fdomain.o
drivers/scsi/pm8001/Makefile new file +12 -0
@@ -0,0 +1,12 @@ +# +# Kernel configuration file for the PM8001 SAS/SATA 8x6G based HBA driver +# +# Copyright (C) 2008-2009 USI Co., Ltd. + + +obj-$(CONFIG_SCSI_PM8001) += pm8001.o +pm8001-y += pm8001_init.o \ + pm8001_sas.o \ + pm8001_ctl.o \ + pm8001_hwi.o +
drivers/scsi/pm8001/pm8001_chips.h new file +89 -0
89 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.c new file +573 -0
573 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_ctl.h new file +67 -0
67 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_defs.h new file +112 -0
112 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.c new file +4371 -0
2,113 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_hwi.h new file +1011 -0
1,011 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_init.c new file +888 -0
888 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.c new file +1104 -0
1,104 lines not on this page · raw message
drivers/scsi/pm8001/pm8001_sas.h new file +480 -0
480 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.