From 6f231dda68080759f1aed3769896e94c73099f0f Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Sat, 2 Jul 2011 22:56:22 -0700 Subject: isci: Intel(R) C600 Series Chipset Storage Control Unit Driver Support for the up to 2x4-port 6Gb/s SAS controllers embedded in the chipset. This is a snapshot of the first publicly available version of the driver, commit 4c1db2d0 in the 'historical' branch. git://git.kernel.org/pub/scm/linux/kernel/git/djbw/isci.git historical Signed-off-by: Maciej Trela Signed-off-by: Dave Jiang Signed-off-by: Edmund Nadolski Signed-off-by: Dan Williams --- drivers/scsi/isci/firmware/create_fw.c | 177 +++++++++++++++++++++++++++++++++ 1 file changed, 177 insertions(+) create mode 100644 drivers/scsi/isci/firmware/create_fw.c (limited to 'drivers/scsi/isci/firmware/create_fw.c') diff --git a/drivers/scsi/isci/firmware/create_fw.c b/drivers/scsi/isci/firmware/create_fw.c new file mode 100644 index 00000000000..442caac9675 --- /dev/null +++ b/drivers/scsi/isci/firmware/create_fw.c @@ -0,0 +1,177 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +char blob_name[] = "isci_firmware.bin"; +char id[] = "#SCU MAGIC#"; +unsigned char version = 1; +unsigned char sub_version = 0; + + +/* + * For all defined arrays: + * elements 0-3 are for SCU0, ports 0-3 + * elements 4-7 are for SCU1, ports 0-3 + * + * valid configurations for one SCU are: + * P0 P1 P2 P3 + * ---------------- + * 0xF,0x0,0x0,0x0 # 1 x4 port + * 0x3,0x0,0x4,0x8 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are each x1 + * # ports + * 0x1,0x2,0xC,0x0 # Phys 0 and 1 are each x1 ports, phy 2 and phy 3 are a x2 + * # port + * 0x3,0x0,0xC,0x0 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are a x2 port + * 0x1,0x2,0x4,0x8 # Each phy is a x1 port (this is the default configuration) + * + * if there is a port/phy on which you do not wish to override the default + * values, use the value assigned to UNINIT_PARAM (255). + */ +unsigned int phy_mask[] = { 1, 2, 4, 8, 1, 2, 4, 8 }; + + +/* denotes SAS generation. i.e. 3: SAS Gen 3 6G */ +unsigned int phy_gen[] = { 3, 3, 3, 3, 3, 3, 3, 3 }; + +/* + * if there is a port/phy on which you do not wish to override the default + * values, use the value "0000000000000000". SAS address of zero's is + * considered invalid and will not be used. + */ +unsigned long long sas_addr[] = { 0x5FCFFFFFF0000000ULL, + 0x5FCFFFFFF1000000ULL, + 0x5FCFFFFFF2000000ULL, + 0x5FCFFFFFF3000000ULL, + 0x5FCFFFFFF4000000ULL, + 0x5FCFFFFFF5000000ULL, + 0x5FCFFFFFF6000000ULL, + 0x5FCFFFFFF7000000ULL }; + +int write_blob(void) +{ + FILE *fd; + int err; + + fd = fopen(blob_name, "w+"); + if (!fd) { + perror("Open file for write failed"); + return -EIO; + } + + /* write id */ + err = fwrite((void *)id, sizeof(char), strlen(id)+1, fd); + if (err == 0) { + perror("write id failed"); + return err; + } + + /* write version */ + err = fwrite((void *)&version, sizeof(version), 1, fd); + if (err == 0) { + perror("write version failed"); + return err; + } + + /* write sub version */ + err = fwrite((void *)&sub_version, sizeof(sub_version), 1, fd); + if (err == 0) { + perror("write subversion failed"); + return err; + } + + /* write phy mask header */ + err = fputc(0x1, fd); + if (err == EOF) { + perror("write phy mask header failed"); + return -EIO; + } + + /* write size */ + err = fputc(8, fd); + if (err == EOF) { + perror("write phy mask size failed"); + return -EIO; + } + + /* write phy masks */ + err = fwrite((void *)phy_mask, 1, sizeof(phy_mask), fd); + if (err == 0) { + perror("write phy_mask failed"); + return err; + } + + /* write phy gen header */ + err = fputc(0x2, fd); + if (err == EOF) { + perror("write phy gen header failed"); + return -EIO; + } + + /* write size */ + err = fputc(8, fd); + if (err == EOF) { + perror("write phy gen size failed"); + return -EIO; + } + + /* write phy_gen */ + err = fwrite((void *)phy_gen, + 1, + sizeof(phy_gen), + fd); + if (err == 0) { + perror("write phy_gen failed"); + return err; + } + + /* write phy gen header */ + err = fputc(0x3, fd); + if (err == EOF) { + perror("write sas addr header failed"); + return -EIO; + } + + /* write size */ + err = fputc(8, fd); + if (err == EOF) { + perror("write sas addr size failed"); + return -EIO; + } + + /* write sas_addr */ + err = fwrite((void *)sas_addr, + 1, + sizeof(sas_addr), + fd); + if (err == 0) { + perror("write sas_addr failed"); + return err; + } + + /* write end header */ + err = fputc(0xff, fd); + if (err == EOF) { + perror("write end header failed"); + return -EIO; + } + + fclose(fd); + + return 0; +} + +int main(void) +{ + int err; + + err = write_blob(); + if (err < 0) + return err; + + return 0; +} -- cgit v1.2.3-70-g09d2 From d044af17aacd03a1f4fced1af4b7570d205c8fd9 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Tue, 8 Mar 2011 09:52:49 -0800 Subject: isci: Add support for probing OROM for OEM params We need to scan the OROM for signature and grab the OEM parameters. We also need to do the same for EFI. If all fails then we resort to user binary blob, and if that fails then we go to the defaults. Share the format with the create_fw utility so that all possible sources of the parameters are in-sync. Signed-off-by: Dave Jiang Signed-off-by: Dan Williams --- drivers/scsi/isci/Makefile | 2 +- drivers/scsi/isci/core/scic_config_parameters.h | 41 +---- drivers/scsi/isci/core/scic_sds_controller.c | 6 +- drivers/scsi/isci/firmware/create_fw.c | 197 +++++++----------------- drivers/scsi/isci/firmware/create_fw.h | 67 ++++++++ drivers/scsi/isci/host.c | 47 +++--- drivers/scsi/isci/host.h | 2 +- drivers/scsi/isci/init.c | 191 ++++------------------- drivers/scsi/isci/isci.h | 39 ----- drivers/scsi/isci/probe_roms.c | 133 ++++++++++++++++ drivers/scsi/isci/probe_roms.h | 130 ++++++++++++++++ firmware/isci/isci_firmware.bin.ihex | 25 +-- 12 files changed, 453 insertions(+), 427 deletions(-) create mode 100644 drivers/scsi/isci/firmware/create_fw.h create mode 100644 drivers/scsi/isci/probe_roms.c create mode 100644 drivers/scsi/isci/probe_roms.h (limited to 'drivers/scsi/isci/firmware/create_fw.c') diff --git a/drivers/scsi/isci/Makefile b/drivers/scsi/isci/Makefile index d402d679a31..1252d768c42 100644 --- a/drivers/scsi/isci/Makefile +++ b/drivers/scsi/isci/Makefile @@ -9,7 +9,7 @@ EXTRA_CFLAGS += -Idrivers/scsi/isci/core/ -Idrivers/scsi/isci/ obj-$(CONFIG_SCSI_ISCI) += isci.o isci-objs := init.o phy.o request.o sata.o \ remote_device.o port.o timers.o \ - host.o task.o events.o \ + host.o task.o events.o probe_roms.o \ core/scic_sds_controller.o \ core/scic_sds_remote_device.o \ core/scic_sds_request.o \ diff --git a/drivers/scsi/isci/core/scic_config_parameters.h b/drivers/scsi/isci/core/scic_config_parameters.h index 485fefc0888..5e1345daf01 100644 --- a/drivers/scsi/isci/core/scic_config_parameters.h +++ b/drivers/scsi/isci/core/scic_config_parameters.h @@ -68,6 +68,7 @@ #include "sci_status.h" #include "intel_sas.h" #include "sci_controller_constants.h" +#include "probe_roms.h" struct scic_sds_controller; @@ -223,44 +224,6 @@ union scic_user_parameters { */ #define SCIC_SDS_PARM_PHY_MASK_MAX 0xF -/** - * struct scic_sds_oem_parameters - This structure delineates the various OEM - * parameters that must be set the core user. - * - * - */ -struct scic_sds_oem_parameters { - struct { - /** - * This field indicates whether Spread Spectrum Clocking (SSC) - * should be enabled or disabled. - */ - bool do_enable_ssc; - - } controller; - - struct { - /** - * This field specifies the phys to be contained inside a port. - * The bit position in the mask specifies the index of the phy - * to be contained in the port. Multiple bits (i.e. phys) - * can be contained in a single port. - */ - u8 phy_mask; - - } ports[SCI_MAX_PORTS]; - - struct sci_phy_oem_params { - /** - * This field specifies the SAS address to be transmitted on - * for this phy index. - */ - struct sci_sas_address sas_address; - - } phys[SCI_MAX_PHYS]; - -}; - /** * This structure/union specifies the various different OEM parameter sets * available. Each type is specific to a hardware controller version. @@ -273,7 +236,7 @@ union scic_oem_parameters { * Storage Controller Unit (SCU) Driver Standard (SDS) version * 1. */ - struct scic_sds_oem_parameters sds1; + struct scic_sds_oem_params sds1; }; diff --git a/drivers/scsi/isci/core/scic_sds_controller.c b/drivers/scsi/isci/core/scic_sds_controller.c index 799a04bc093..e7f3711b4af 100644 --- a/drivers/scsi/isci/core/scic_sds_controller.c +++ b/drivers/scsi/isci/core/scic_sds_controller.c @@ -2039,10 +2039,8 @@ static void scic_sds_controller_set_default_config_parameters(struct scic_sds_co /* Initialize all of the phy parameter information. */ for (index = 0; index < SCI_MAX_PHYS; index++) { - /* - * Default to 3G (i.e. Gen 2) for now. User can override if - * they choose. */ - scic->user_parameters.sds1.phys[index].max_speed_generation = 2; + /* Default to 6G (i.e. Gen 3) for now. */ + scic->user_parameters.sds1.phys[index].max_speed_generation = 3; /* the frequencies cannot be 0 */ scic->user_parameters.sds1.phys[index].align_insertion_frequency = 0x7f; diff --git a/drivers/scsi/isci/firmware/create_fw.c b/drivers/scsi/isci/firmware/create_fw.c index 442caac9675..f8f96d6eb7d 100644 --- a/drivers/scsi/isci/firmware/create_fw.c +++ b/drivers/scsi/isci/firmware/create_fw.c @@ -6,157 +6,30 @@ #include #include #include +#include +#include +#include -char blob_name[] = "isci_firmware.bin"; -char id[] = "#SCU MAGIC#"; -unsigned char version = 1; -unsigned char sub_version = 0; - - -/* - * For all defined arrays: - * elements 0-3 are for SCU0, ports 0-3 - * elements 4-7 are for SCU1, ports 0-3 - * - * valid configurations for one SCU are: - * P0 P1 P2 P3 - * ---------------- - * 0xF,0x0,0x0,0x0 # 1 x4 port - * 0x3,0x0,0x4,0x8 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are each x1 - * # ports - * 0x1,0x2,0xC,0x0 # Phys 0 and 1 are each x1 ports, phy 2 and phy 3 are a x2 - * # port - * 0x3,0x0,0xC,0x0 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are a x2 port - * 0x1,0x2,0x4,0x8 # Each phy is a x1 port (this is the default configuration) - * - * if there is a port/phy on which you do not wish to override the default - * values, use the value assigned to UNINIT_PARAM (255). - */ -unsigned int phy_mask[] = { 1, 2, 4, 8, 1, 2, 4, 8 }; - - -/* denotes SAS generation. i.e. 3: SAS Gen 3 6G */ -unsigned int phy_gen[] = { 3, 3, 3, 3, 3, 3, 3, 3 }; - -/* - * if there is a port/phy on which you do not wish to override the default - * values, use the value "0000000000000000". SAS address of zero's is - * considered invalid and will not be used. - */ -unsigned long long sas_addr[] = { 0x5FCFFFFFF0000000ULL, - 0x5FCFFFFFF1000000ULL, - 0x5FCFFFFFF2000000ULL, - 0x5FCFFFFFF3000000ULL, - 0x5FCFFFFFF4000000ULL, - 0x5FCFFFFFF5000000ULL, - 0x5FCFFFFFF6000000ULL, - 0x5FCFFFFFF7000000ULL }; - -int write_blob(void) +#include "create_fw.h" +#include "../probe_roms.h" + +int write_blob(struct isci_orom *isci_orom) { FILE *fd; int err; + size_t count; fd = fopen(blob_name, "w+"); if (!fd) { perror("Open file for write failed"); + fclose(fd); return -EIO; } - /* write id */ - err = fwrite((void *)id, sizeof(char), strlen(id)+1, fd); - if (err == 0) { - perror("write id failed"); - return err; - } - - /* write version */ - err = fwrite((void *)&version, sizeof(version), 1, fd); - if (err == 0) { - perror("write version failed"); - return err; - } - - /* write sub version */ - err = fwrite((void *)&sub_version, sizeof(sub_version), 1, fd); - if (err == 0) { - perror("write subversion failed"); - return err; - } - - /* write phy mask header */ - err = fputc(0x1, fd); - if (err == EOF) { - perror("write phy mask header failed"); - return -EIO; - } - - /* write size */ - err = fputc(8, fd); - if (err == EOF) { - perror("write phy mask size failed"); - return -EIO; - } - - /* write phy masks */ - err = fwrite((void *)phy_mask, 1, sizeof(phy_mask), fd); - if (err == 0) { - perror("write phy_mask failed"); - return err; - } - - /* write phy gen header */ - err = fputc(0x2, fd); - if (err == EOF) { - perror("write phy gen header failed"); - return -EIO; - } - - /* write size */ - err = fputc(8, fd); - if (err == EOF) { - perror("write phy gen size failed"); - return -EIO; - } - - /* write phy_gen */ - err = fwrite((void *)phy_gen, - 1, - sizeof(phy_gen), - fd); - if (err == 0) { - perror("write phy_gen failed"); - return err; - } - - /* write phy gen header */ - err = fputc(0x3, fd); - if (err == EOF) { - perror("write sas addr header failed"); - return -EIO; - } - - /* write size */ - err = fputc(8, fd); - if (err == EOF) { - perror("write sas addr size failed"); - return -EIO; - } - - /* write sas_addr */ - err = fwrite((void *)sas_addr, - 1, - sizeof(sas_addr), - fd); - if (err == 0) { - perror("write sas_addr failed"); - return err; - } - - /* write end header */ - err = fputc(0xff, fd); - if (err == EOF) { - perror("write end header failed"); + count = fwrite(isci_orom, sizeof(struct isci_orom), 1, fd); + if (count != 1) { + perror("Write data failed"); + fclose(fd); return -EIO; } @@ -165,13 +38,53 @@ int write_blob(void) return 0; } +void set_binary_values(struct isci_orom *isci_orom) +{ + int ctrl_idx, phy_idx, port_idx; + + /* setting OROM signature */ + strncpy(isci_orom->hdr.signature, sig, strlen(sig)); + isci_orom->hdr.version = 0x10; + isci_orom->hdr.total_block_length = sizeof(struct isci_orom); + isci_orom->hdr.hdr_length = sizeof(struct sci_bios_oem_param_block_hdr); + isci_orom->hdr.num_elements = num_elements; + + for (ctrl_idx = 0; ctrl_idx < 2; ctrl_idx++) { + isci_orom->ctrl[ctrl_idx].controller.mode_type = mode_type; + isci_orom->ctrl[ctrl_idx].controller.max_concurrent_dev_spin_up = + max_num_concurrent_dev_spin_up; + isci_orom->ctrl[ctrl_idx].controller.do_enable_ssc = + enable_ssc; + + for (port_idx = 0; port_idx < 4; port_idx++) + isci_orom->ctrl[ctrl_idx].ports[port_idx].phy_mask = + phy_mask[ctrl_idx][port_idx]; + + for (phy_idx = 0; phy_idx < 4; phy_idx++) { + isci_orom->ctrl[ctrl_idx].phys[phy_idx].sas_address.high = + (__u32)(sas_addr[ctrl_idx][phy_idx] >> 32); + isci_orom->ctrl[ctrl_idx].phys[phy_idx].sas_address.low = + (__u32)(sas_addr[ctrl_idx][phy_idx]); + } + } +} + int main(void) { int err; + struct isci_orom *isci_orom; + + isci_orom = malloc(sizeof(struct isci_orom)); + memset(isci_orom, 0, sizeof(struct isci_orom)); - err = write_blob(); - if (err < 0) + set_binary_values(isci_orom); + + err = write_blob(isci_orom); + if (err < 0) { + free(isci_orom); return err; + } + free(isci_orom); return 0; } diff --git a/drivers/scsi/isci/firmware/create_fw.h b/drivers/scsi/isci/firmware/create_fw.h new file mode 100644 index 00000000000..bedbe4fad18 --- /dev/null +++ b/drivers/scsi/isci/firmware/create_fw.h @@ -0,0 +1,67 @@ +#ifndef _CREATE_FW_H_ +#define _CREATE_FW_H_ + + +/* we are configuring for 2 SCUs */ +static const int num_elements = 2; + +/* + * For all defined arrays: + * elements 0-3 are for SCU0, ports 0-3 + * elements 4-7 are for SCU1, ports 0-3 + * + * valid configurations for one SCU are: + * P0 P1 P2 P3 + * ---------------- + * 0xF,0x0,0x0,0x0 # 1 x4 port + * 0x3,0x0,0x4,0x8 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are each x1 + * # ports + * 0x1,0x2,0xC,0x0 # Phys 0 and 1 are each x1 ports, phy 2 and phy 3 are a x2 + * # port + * 0x3,0x0,0xC,0x0 # Phys 0 and 1 are a x2 port, phy 2 and phy 3 are a x2 port + * 0x1,0x2,0x4,0x8 # Each phy is a x1 port (this is the default configuration) + * + * if there is a port/phy on which you do not wish to override the default + * values, use the value assigned to UNINIT_PARAM (255). + */ +#ifdef MPC +static const __u8 phy_mask[2][4] = { {1, 2, 4, 8}, + {1, 2, 4, 8} }; +#else /* APC (default) */ +static const __u8 phy_mask[2][4]; +#endif + +/* discovery mode type (port auto config mode by default ) */ +static const int mode_type; + +/* Maximum number of concurrent device spin up */ +static const int max_num_concurrent_dev_spin_up = 1; + +/* enable of ssc operation */ +static const int enable_ssc; + +/* AFE_TX_AMP_CONTROL */ +static const unsigned int afe_tx_amp_control0 = 0x000e7c03; +static const unsigned int afe_tx_amp_control1 = 0x000e7c03; +static const unsigned int afe_tx_amp_control2 = 0x000e7c03; +static const unsigned int afe_tx_amp_control3 = 0x000e7c03; + +/* + * if there is a port/phy on which you do not wish to override the default + * values, use the value "0000000000000000". SAS address of zero's is + * considered invalid and will not be used. + */ +static const unsigned long long sas_addr[2][4] = { { 0x5FCFFFFFF0000000ULL, + 0x5FCFFFFFF1000000ULL, + 0x5FCFFFFFF2000000ULL, + 0x5FCFFFFFF3000000ULL }, + { 0x5FCFFFFFF4000000ULL, + 0x5FCFFFFFF5000000ULL, + 0x5FCFFFFFF6000000ULL, + 0x5FCFFFFFF7000000ULL } }; + +static const char blob_name[] = "isci_firmware.bin"; +static const char sig[] = "ISCUOEMB"; +static const unsigned char version = 1; + +#endif diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c index dc231c22ea9..bb5b54d361b 100644 --- a/drivers/scsi/isci/host.c +++ b/drivers/scsi/isci/host.c @@ -61,6 +61,7 @@ #include "port.h" #include "request.h" #include "host.h" +#include "probe_roms.h" irqreturn_t isci_msix_isr(int vec, void *data) { @@ -419,6 +420,7 @@ int isci_host_init(struct isci_host *isci_host) struct scic_sds_controller *controller; union scic_oem_parameters scic_oem_params; union scic_user_parameters scic_user_params; + struct isci_pci_info *pci_info = to_pci_info(isci_host->pdev); isci_timer_list_construct(isci_host); @@ -461,31 +463,32 @@ int isci_host_init(struct isci_host *isci_host) sci_object_set_association(isci_host->core_controller, (void *)isci_host); - /* grab initial values stored in the controller object for OEM and USER - * parameters */ - scic_oem_parameters_get(controller, &scic_oem_params); + /* + * grab initial values stored in the controller object for OEM and USER + * parameters + */ scic_user_parameters_get(controller, &scic_user_params); + status = scic_user_parameters_set(isci_host->core_controller, + &scic_user_params); + if (status != SCI_SUCCESS) { + dev_warn(&isci_host->pdev->dev, + "%s: scic_user_parameters_set failed\n", + __func__); + return -ENODEV; + } + + scic_oem_parameters_get(controller, &scic_oem_params); - if (isci_firmware) { - /* grab any OEM and USER parameters specified in binary blob */ + /* grab any OEM parameters specified in orom */ + if (pci_info->orom) { status = isci_parse_oem_parameters(&scic_oem_params, - isci_host->id, - isci_firmware); + pci_info->orom, + isci_host->id); if (status != SCI_SUCCESS) { dev_warn(&isci_host->pdev->dev, "parsing firmware oem parameters failed\n"); return -EINVAL; } - - status = isci_parse_user_parameters(&scic_user_params, - isci_host->id, - isci_firmware); - if (status != SCI_SUCCESS) { - dev_warn(&isci_host->pdev->dev, - "%s: isci_parse_user_parameters" - " failed\n", __func__); - return -EINVAL; - } } else { status = scic_oem_parameters_set(isci_host->core_controller, &scic_oem_params); @@ -495,16 +498,6 @@ int isci_host_init(struct isci_host *isci_host) __func__); return -ENODEV; } - - - status = scic_user_parameters_set(isci_host->core_controller, - &scic_user_params); - if (status != SCI_SUCCESS) { - dev_warn(&isci_host->pdev->dev, - "%s: scic_user_parameters_set failed\n", - __func__); - return -ENODEV; - } } tasklet_init(&isci_host->completion_tasklet, diff --git a/drivers/scsi/isci/host.h b/drivers/scsi/isci/host.h index 889a7850255..d012b69d8d6 100644 --- a/drivers/scsi/isci/host.h +++ b/drivers/scsi/isci/host.h @@ -140,8 +140,8 @@ static inline struct isci_remote_device *idev_by_id(struct isci_host *ihost, int struct isci_pci_info { struct msix_entry msix_entries[SCI_MAX_MSIX_INT]; - int core_lib_array_index; struct isci_host *hosts[SCI_MAX_CONTROLLERS]; + struct isci_orom *orom; }; static inline struct isci_pci_info *to_pci_info(struct pci_dev *pdev) diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index 3f2bb137bcb..65519321e1c 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c @@ -56,12 +56,15 @@ #include #include #include +#include +#include #include #include "isci.h" #include "task.h" #include "sci_controller_constants.h" #include "scic_remote_device.h" #include "sci_environment.h" +#include "probe_roms.h" static struct scsi_transport_template *isci_transport_template; @@ -373,85 +376,6 @@ static int isci_setup_interrupts(struct pci_dev *pdev) return err; } -/** - * isci_parse_oem_parameters() - This method will take OEM parameters - * from the module init parameters and copy them to oem_params. This will - * only copy values that are not set to the module parameter default values - * @oem_parameters: This parameter specifies the controller default OEM - * parameters. It is expected that this has been initialized to the default - * parameters for the controller - * - * - */ -enum sci_status isci_parse_oem_parameters(union scic_oem_parameters *oem_params, - int scu_index, - struct isci_firmware *fw) -{ - int i; - - /* check for valid inputs */ - if (!(scu_index >= 0 - && scu_index < SCI_MAX_CONTROLLERS - && oem_params != NULL)) { - return SCI_FAILURE; - } - - for (i = 0; i < SCI_MAX_PHYS; i++) { - int array_idx = i + (SCI_MAX_PHYS * scu_index); - u64 sas_addr = fw->sas_addrs[array_idx]; - - if (sas_addr != 0) { - oem_params->sds1.phys[i].sas_address.low = - (u32)(sas_addr & 0xffffffff); - oem_params->sds1.phys[i].sas_address.high = - (u32)((sas_addr >> 32) & 0xffffffff); - } - } - - for (i = 0; i < SCI_MAX_PORTS; i++) { - int array_idx = i + (SCI_MAX_PORTS * scu_index); - u32 pmask = fw->phy_masks[array_idx]; - - oem_params->sds1.ports[i].phy_mask = pmask; - } - - return SCI_SUCCESS; -} - -/** - * isci_parse_user_parameters() - This method will take user parameters - * from the module init parameters and copy them to user_params. This will - * only copy values that are not set to the module parameter default values - * @user_parameters: This parameter specifies the controller default user - * parameters. It is expected that this has been initialized to the default - * parameters for the controller - * - * - */ -enum sci_status isci_parse_user_parameters( - union scic_user_parameters *user_params, - int scu_index, - struct isci_firmware *fw) -{ - int i; - - if (!(scu_index >= 0 - && scu_index < SCI_MAX_CONTROLLERS - && user_params != NULL)) { - return SCI_FAILURE; - } - - for (i = 0; i < SCI_MAX_PORTS; i++) { - int array_idx = i + (SCI_MAX_PORTS * scu_index); - u32 gen = fw->phy_gens[array_idx]; - - user_params->sds1.phys[i].max_speed_generation = gen; - - } - - return SCI_SUCCESS; -} - static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id) { struct isci_host *isci_host; @@ -535,73 +459,13 @@ static void check_si_rev(struct pci_dev *pdev) } -static int isci_verify_firmware(const struct firmware *fw, - struct isci_firmware *isci_fw) -{ - const u8 *tmp; - - if (fw->size < ISCI_FIRMWARE_MIN_SIZE) - return -EINVAL; - - tmp = fw->data; - - /* 12th char should be the NULL terminate for the ID string */ - if (tmp[11] != '\0') - return -EINVAL; - - if (strncmp("#SCU MAGIC#", tmp, 11) != 0) - return -EINVAL; - - isci_fw->id = tmp; - isci_fw->version = fw->data[ISCI_FW_VER_OFS]; - isci_fw->subversion = fw->data[ISCI_FW_SUBVER_OFS]; - - tmp = fw->data + ISCI_FW_DATA_OFS; - - while (*tmp != ISCI_FW_HDR_EOF) { - switch (*tmp) { - case ISCI_FW_HDR_PHYMASK: - tmp++; - isci_fw->phy_masks_size = *tmp; - tmp++; - isci_fw->phy_masks = (const u32 *)tmp; - tmp += sizeof(u32) * isci_fw->phy_masks_size; - break; - - case ISCI_FW_HDR_PHYGEN: - tmp++; - isci_fw->phy_gens_size = *tmp; - tmp++; - isci_fw->phy_gens = (const u32 *)tmp; - tmp += sizeof(u32) * isci_fw->phy_gens_size; - break; - - case ISCI_FW_HDR_SASADDR: - tmp++; - isci_fw->sas_addrs_size = *tmp; - tmp++; - isci_fw->sas_addrs = (const u64 *)tmp; - tmp += sizeof(u64) * isci_fw->sas_addrs_size; - break; - - default: - pr_err("bad field in firmware binary blob\n"); - return -EINVAL; - } - } - - pr_info("isci firmware v%u.%u loaded.\n", - isci_fw->version, isci_fw->subversion); - - return SCI_SUCCESS; -} - static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) { struct isci_pci_info *pci_info; int err, i; struct isci_host *isci_host; const struct firmware *fw = NULL; + struct isci_orom *orom; check_si_rev(pdev); @@ -610,33 +474,32 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic return -ENOMEM; pci_set_drvdata(pdev, pci_info); - err = request_firmware(&fw, ISCI_FW_NAME, &pdev->dev); - if (err) { - dev_warn(&pdev->dev, - "Loading firmware failed, using default values\n"); - dev_warn(&pdev->dev, - "Default OEM configuration being used:" - " 4 narrow ports, and default SAS Addresses\n"); - } else { - isci_firmware = devm_kzalloc(&pdev->dev, - sizeof(struct isci_firmware), - GFP_KERNEL); - if (isci_firmware) { - err = isci_verify_firmware(fw, isci_firmware); - if (err != SCI_SUCCESS) { - dev_warn(&pdev->dev, - "firmware verification failed\n"); - dev_warn(&pdev->dev, - "Default OEM configuration being used:" - " 4 narrow ports, and default SAS " - "Addresses\n"); - devm_kfree(&pdev->dev, isci_firmware); - isci_firmware = NULL; - } + if (efi_enabled) { + /* do EFI parsing here */ + orom = NULL; + } else + orom = isci_request_oprom(pdev); + + if (!orom) { + orom = isci_request_firmware(pdev, fw); + if (!orom) { + /* TODO convert this to WARN_TAINT_ONCE once the + * orom/efi parameter support is widely available + */ + dev_warn(&pdev->dev, + "Loading user firmware failed, using default " + "values\n"); + dev_warn(&pdev->dev, + "Default OEM configuration being used: 4 " + "narrow ports, and default SAS Addresses\n"); } - release_firmware(fw); } + if (orom) + dev_info(&pdev->dev, "sas parameters (version: %#x) loaded\n", + orom->hdr.version); + pci_info->orom = orom; + err = isci_pci_init(pdev); if (err) return err; diff --git a/drivers/scsi/isci/isci.h b/drivers/scsi/isci/isci.h index b3f63f1a46c..83422d43c1d 100644 --- a/drivers/scsi/isci/isci.h +++ b/drivers/scsi/isci/isci.h @@ -61,7 +61,6 @@ #include #include #include -#include #include #include #include @@ -76,34 +75,6 @@ #include "task.h" #include "sata.h" -extern struct isci_firmware *isci_firmware; - -#define ISCI_FW_NAME "isci/isci_firmware.bin" - -#define ISCI_FIRMWARE_MIN_SIZE 149 - -#define ISCI_FW_IDSIZE 12 -#define ISCI_FW_VER_OFS ISCI_FW_IDSIZE -#define ISCI_FW_SUBVER_OFS ISCI_FW_VER_OFS + 1 -#define ISCI_FW_DATA_OFS ISCI_FW_SUBVER_OFS + 1 - -#define ISCI_FW_HDR_PHYMASK 0x1 -#define ISCI_FW_HDR_PHYGEN 0x2 -#define ISCI_FW_HDR_SASADDR 0x3 -#define ISCI_FW_HDR_EOF 0xff - -struct isci_firmware { - const u8 *id; - u8 version; - u8 subversion; - const u32 *phy_masks; - u8 phy_masks_size; - const u32 *phy_gens; - u8 phy_gens_size; - const u64 *sas_addrs; - u8 sas_addrs_size; -}; - irqreturn_t isci_msix_isr(int vec, void *data); irqreturn_t isci_intx_isr(int vec, void *data); irqreturn_t isci_error_isr(int vec, void *data); @@ -113,14 +84,4 @@ void scic_sds_controller_completion_handler(struct scic_sds_controller *scic); bool scic_sds_controller_error_isr(struct scic_sds_controller *scic); void scic_sds_controller_error_handler(struct scic_sds_controller *scic); -enum sci_status isci_parse_oem_parameters( - union scic_oem_parameters *oem_params, - int scu_index, - struct isci_firmware *fw); - -enum sci_status isci_parse_user_parameters( - union scic_user_parameters *user_params, - int scu_index, - struct isci_firmware *fw); - #endif /* __ISCI_H__ */ diff --git a/drivers/scsi/isci/probe_roms.c b/drivers/scsi/isci/probe_roms.c new file mode 100644 index 00000000000..0b90e7c546c --- /dev/null +++ b/drivers/scsi/isci/probe_roms.c @@ -0,0 +1,133 @@ +/* + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + */ + +/* probe_roms - scan for oem parameters */ + +#include +#include +#include +#include + +#include "isci.h" +#include "task.h" +#include "sci_controller_constants.h" +#include "scic_remote_device.h" +#include "sci_environment.h" +#include "probe_roms.h" + +struct isci_orom *isci_request_oprom(struct pci_dev *pdev) +{ + void __iomem *oprom = pci_map_biosrom(pdev); + struct isci_orom *rom = NULL; + size_t len, i; + + if (!oprom) + return NULL; + + len = pci_biosrom_size(pdev); + rom = devm_kzalloc(&pdev->dev, sizeof(*rom), GFP_KERNEL); + + for (i = 0; i < len && rom; i += ISCI_ROM_SIG_SIZE) { + memcpy_fromio(rom->hdr.signature, oprom + i, ISCI_ROM_SIG_SIZE); + if (memcmp(rom->hdr.signature, ISCI_ROM_SIG, + ISCI_ROM_SIG_SIZE) == 0) { + size_t copy_len = min(len - i, sizeof(*rom)); + + memcpy_fromio(rom, oprom + i, copy_len); + break; + } + } + + if (i >= len) { + dev_err(&pdev->dev, "oprom parse error\n"); + devm_kfree(&pdev->dev, rom); + rom = NULL; + } + pci_unmap_biosrom(oprom); + + return rom; +} + +/** + * isci_parse_oem_parameters() - This method will take OEM parameters + * from the module init parameters and copy them to oem_params. This will + * only copy values that are not set to the module parameter default values + * @oem_parameters: This parameter specifies the controller default OEM + * parameters. It is expected that this has been initialized to the default + * parameters for the controller + * + * + */ +enum sci_status isci_parse_oem_parameters(union scic_oem_parameters *oem_params, + struct isci_orom *orom, int scu_index) +{ + int i; + + /* check for valid inputs */ + if (!(scu_index >= 0 + && scu_index < SCI_MAX_CONTROLLERS + && oem_params != NULL)) + return -EINVAL; + + for (i = 0; i < SCI_MAX_PHYS; i++) { + oem_params->sds1.phys[i].sas_address.low = + orom->ctrl[scu_index].phys[i].sas_address.low; + oem_params->sds1.phys[i].sas_address.high = + orom->ctrl[scu_index].phys[i].sas_address.high; + } + + for (i = 0; i < SCI_MAX_PORTS; i++) + oem_params->sds1.ports[i].phy_mask = + orom->ctrl[scu_index].ports[i].phy_mask; + + return 0; +} + +struct isci_orom *isci_request_firmware(struct pci_dev *pdev, const struct firmware *fw) +{ + struct isci_orom *orom = NULL, *data; + + if (request_firmware(&fw, ISCI_FW_NAME, &pdev->dev) != 0) + return NULL; + + if (fw->size < sizeof(*orom)) + goto out; + + data = (struct isci_orom *)fw->data; + + if (strncmp(ISCI_ROM_SIG, data->hdr.signature, + strlen(ISCI_ROM_SIG)) != 0) + goto out; + + orom = devm_kzalloc(&pdev->dev, fw->size, GFP_KERNEL); + if (!orom) + goto out; + + memcpy(orom, fw->data, fw->size); + + out: + release_firmware(fw); + + return orom; +} diff --git a/drivers/scsi/isci/probe_roms.h b/drivers/scsi/isci/probe_roms.h new file mode 100644 index 00000000000..76651c01895 --- /dev/null +++ b/drivers/scsi/isci/probe_roms.h @@ -0,0 +1,130 @@ +/* + * This file is provided under a dual BSD/GPLv2 license. When using or + * redistributing this file, you may do so under either license. + * + * GPL LICENSE SUMMARY + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of version 2 of the GNU General Public License as + * published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St - Fifth Floor, Boston, MA 02110-1301 USA. + * The full GNU General Public License is included in this distribution + * in the file called LICENSE.GPL. + * + * BSD LICENSE + * + * Copyright(c) 2008 - 2011 Intel Corporation. All rights reserved. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Intel Corporation nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _ISCI_PROBE_ROMS_H_ +#define _ISCI_PROBE_ROMS_H_ + +#ifdef __KERNEL__ +#include +#include + +struct isci_orom *isci_request_oprom(struct pci_dev *pdev); + +union scic_oem_parameters; +struct isci_orom; + +enum sci_status isci_parse_oem_parameters( + union scic_oem_parameters *oem_params, + struct isci_orom *orom, + int scu_index); +struct isci_orom *isci_request_firmware(struct pci_dev *pdev, const struct firmware *fw); +int isci_get_efi_var(struct pci_dev *pdev); +#else +#define SCI_MAX_PORTS 4 +#define SCI_MAX_PHYS 4 +#endif + +#define ISCI_FW_NAME "isci/isci_firmware.bin" + +#define ROMSIGNATURE 0xaa55 + +#define ISCI_ROM_SIG "ISCUOEMB" +#define ISCI_ROM_SIG_SIZE 8 + +#define ISCI_EFI_VENDOR_GUID NULL_GUID +#define ISCI_EFI_ATTRIBUTES 0 +#define ISCI_EFI_VAR_NAME "isci_oemb" + +struct sci_bios_oem_param_block_hdr { + uint8_t signature[ISCI_ROM_SIG_SIZE]; + uint16_t total_block_length; + uint8_t hdr_length; + uint8_t version; + uint8_t preboot_source; + uint8_t num_elements; + uint8_t element_length; + uint8_t reserved[8]; +} __attribute__ ((packed)); + +struct scic_sds_oem_params { + struct { + uint8_t mode_type; + uint8_t max_concurrent_dev_spin_up; + uint8_t do_enable_ssc; + uint8_t reserved; + } controller; + + struct { + uint8_t phy_mask; + } ports[SCI_MAX_PORTS]; + + struct sci_phy_oem_params { + struct { + uint32_t high; + uint32_t low; + } sas_address; + + uint32_t afe_tx_amp_control0; + uint32_t afe_tx_amp_control1; + uint32_t afe_tx_amp_control2; + uint32_t afe_tx_amp_control3; + } phys[SCI_MAX_PHYS]; +} __attribute__ ((packed)); + +struct isci_orom { + struct sci_bios_oem_param_block_hdr hdr; + struct scic_sds_oem_params ctrl[2]; +} __attribute__ ((packed)); + +#endif diff --git a/firmware/isci/isci_firmware.bin.ihex b/firmware/isci/isci_firmware.bin.ihex index 9fc9e60f399..7f12b39e791 100644 --- a/firmware/isci/isci_firmware.bin.ihex +++ b/firmware/isci/isci_firmware.bin.ihex @@ -1,11 +1,16 @@ -:1000000023534355204D4147494323000100010834 -:1000100001000000020000000400000008000000D1 -:1000200001000000020000000400000008000000C1 -:1000300002080300000003000000030000000300AA -:1000400000000300000003000000030000000300A4 -:1000500000000308000000F0FFFFCF5F000000F188 -:10006000FFFFCF5F000000F2FFFFCF5F000000F353 -:10007000FFFFCF5F000000F4FFFFCF5F000000F53F -:10008000FFFFCF5F000000F6FFFFCF5F000000F72B -:05009000FFFFCF5FFF40 +:10000000495343554F454D42E70017100002000089 +:10001000000000000000000001000000000000FFE0 +:10002000FFCF5F000000F0000000000000000000B3 +:1000300000000000000000FFFFCF5F000000F100A3 +:10004000000000000000000000000000000000FFB1 +:10005000FFCF5F000000F200000000000000000081 +:1000600000000000000000FFFFCF5F000000F30071 +:100070000000000000000000000000000000000080 +:1000800001000000000000FFFFCF5F000000F4004F +:10009000000000000000000000000000000000FF61 +:1000A000FFCF5F000000F50000000000000000002E +:1000B00000000000000000FFFFCF5F000000F6001E +:1000C000000000000000000000000000000000FF31 +:1000D000FFCF5F000000F7000000000000000000FC +:0700E0000000000000000019 :00000001FF -- cgit v1.2.3-70-g09d2 From 4711ba10b13891edf228944a9d0a21dfe7fe90f0 Mon Sep 17 00:00:00 2001 From: Dan Williams Date: Fri, 11 Mar 2011 10:43:57 -0800 Subject: isci: fix oem parameter initialization and mode detection 1/ Since commit 858d4aa7 "isci: Move firmware loading to per PCI device" we have been silently falling back to built-in defaults for the parameter settings by skipping the call to scic_oem_parameters_set(). 2/ The afe parameters from the firmware were not being honored 3/ The latest oem parameter definition flips the mode_type values which are now 0: for APC 1: for MPC. For APC we need to make sure all the phys default to the same address otherwise strict_wide_ports will cause duplicate domains. 4/ Fix up the driver announcement to indicate the source of the parameters. 5/ Fix up the sas addresses to be unique per controller (in the fallback case) Signed-off-by: Dave Jiang Signed-off-by: Dan Williams --- drivers/scsi/isci/core/sci_base_controller.h | 2 -- drivers/scsi/isci/core/scic_sds_controller.c | 30 +++++++++++---------- drivers/scsi/isci/firmware/create_fw.c | 11 +++++++- drivers/scsi/isci/firmware/create_fw.h | 39 +++++++++++++++++----------- drivers/scsi/isci/host.c | 30 +++++++++------------ drivers/scsi/isci/init.c | 6 +++-- drivers/scsi/isci/probe_roms.c | 5 +--- drivers/scsi/isci/probe_roms.h | 8 ++++-- firmware/isci/isci_firmware.bin.ihex | 28 ++++++++++---------- 9 files changed, 87 insertions(+), 72 deletions(-) (limited to 'drivers/scsi/isci/firmware/create_fw.c') diff --git a/drivers/scsi/isci/core/sci_base_controller.h b/drivers/scsi/isci/core/sci_base_controller.h index 36c53406ea5..8e0c46f8b22 100644 --- a/drivers/scsi/isci/core/sci_base_controller.h +++ b/drivers/scsi/isci/core/sci_base_controller.h @@ -289,8 +289,6 @@ static inline void sci_base_controller_construct( u32 mde_count, struct sci_base_memory_descriptor_list *next_mdl) { - scic_base->parent.private = NULL; - sci_base_state_machine_construct( &scic_base->state_machine, &scic_base->parent, diff --git a/drivers/scsi/isci/core/scic_sds_controller.c b/drivers/scsi/isci/core/scic_sds_controller.c index 12b2ad5a28b..b0edd8408fe 100644 --- a/drivers/scsi/isci/core/scic_sds_controller.c +++ b/drivers/scsi/isci/core/scic_sds_controller.c @@ -595,6 +595,7 @@ void scic_sds_controller_enable_port_task_scheduler( */ void scic_sds_controller_afe_initialization(struct scic_sds_controller *scic) { + const struct scic_sds_oem_params *oem = &scic->oem_parameters.sds1; u32 afe_status; u32 phy_id; @@ -632,6 +633,8 @@ void scic_sds_controller_afe_initialization(struct scic_sds_controller *scic) } for (phy_id = 0; phy_id < SCI_MAX_PHYS; phy_id++) { + const struct sci_phy_oem_params *oem_phy = &oem->phys[phy_id]; + if (is_b0()) { /* Configure transmitter SSC parameters */ scu_afe_txreg_write(scic, phy_id, afe_tx_ssc_control, 0x00030000); @@ -691,16 +694,16 @@ void scic_sds_controller_afe_initialization(struct scic_sds_controller *scic) } udelay(AFE_REGISTER_WRITE_DELAY); - scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control0, 0x000E7C03); + scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control0, oem_phy->afe_tx_amp_control0); udelay(AFE_REGISTER_WRITE_DELAY); - scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control1, 0x000E7C03); + scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control0, oem_phy->afe_tx_amp_control1); udelay(AFE_REGISTER_WRITE_DELAY); - scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control2, 0x000E7C03); + scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control0, oem_phy->afe_tx_amp_control2); udelay(AFE_REGISTER_WRITE_DELAY); - scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control3, 0x000E7C03); + scu_afe_txreg_write(scic, phy_id, afe_tx_amp_control0, oem_phy->afe_tx_amp_control3); udelay(AFE_REGISTER_WRITE_DELAY); } @@ -2027,6 +2030,7 @@ void scic_sds_controller_release_frame( */ static void scic_sds_controller_set_default_config_parameters(struct scic_sds_controller *scic) { + struct isci_host *ihost = sci_object_get_association(scic); u16 index; /* Default to APC mode. */ @@ -2058,7 +2062,7 @@ static void scic_sds_controller_set_default_config_parameters(struct scic_sds_co * is worked around by having the upper 32-bits of SAS address * with a value greater then the Vitesse company identifier. * Hence, usage of 0x5FCFFFFF. */ - scic->oem_parameters.sds1.phys[index].sas_address.low = 0x00000001; + scic->oem_parameters.sds1.phys[index].sas_address.low = 0x1 + ihost->id; scic->oem_parameters.sds1.phys[index].sas_address.high = 0x5FCFFFFF; } @@ -2604,14 +2608,11 @@ enum sci_status scic_oem_parameters_set( struct scic_sds_controller *scic, union scic_oem_parameters *scic_parms) { - if ( - (scic->parent.state_machine.current_state_id - == SCI_BASE_CONTROLLER_STATE_RESET) - || (scic->parent.state_machine.current_state_id - == SCI_BASE_CONTROLLER_STATE_INITIALIZING) - || (scic->parent.state_machine.current_state_id - == SCI_BASE_CONTROLLER_STATE_INITIALIZED) - ) { + u32 state = scic->parent.state_machine.current_state_id; + + if (state == SCI_BASE_CONTROLLER_STATE_RESET || + state == SCI_BASE_CONTROLLER_STATE_INITIALIZING || + state == SCI_BASE_CONTROLLER_STATE_INITIALIZED) { u16 index; u8 combined_phy_mask = 0; @@ -2651,7 +2652,8 @@ enum sci_status scic_oem_parameters_set( if (scic_parms->sds1.controller.max_concurrent_dev_spin_up > MAX_CONCURRENT_DEVICE_SPIN_UP_COUNT) return SCI_FAILURE_INVALID_PARAMETER_VALUE; - memcpy(&scic->oem_parameters, scic_parms, sizeof(*scic_parms)); + scic->oem_parameters.sds1 = scic_parms->sds1; + return SCI_SUCCESS; } diff --git a/drivers/scsi/isci/firmware/create_fw.c b/drivers/scsi/isci/firmware/create_fw.c index f8f96d6eb7d..c7a2887a7e9 100644 --- a/drivers/scsi/isci/firmware/create_fw.c +++ b/drivers/scsi/isci/firmware/create_fw.c @@ -44,7 +44,7 @@ void set_binary_values(struct isci_orom *isci_orom) /* setting OROM signature */ strncpy(isci_orom->hdr.signature, sig, strlen(sig)); - isci_orom->hdr.version = 0x10; + isci_orom->hdr.version = version; isci_orom->hdr.total_block_length = sizeof(struct isci_orom); isci_orom->hdr.hdr_length = sizeof(struct sci_bios_oem_param_block_hdr); isci_orom->hdr.num_elements = num_elements; @@ -65,6 +65,15 @@ void set_binary_values(struct isci_orom *isci_orom) (__u32)(sas_addr[ctrl_idx][phy_idx] >> 32); isci_orom->ctrl[ctrl_idx].phys[phy_idx].sas_address.low = (__u32)(sas_addr[ctrl_idx][phy_idx]); + + isci_orom->ctrl[ctrl_idx].phys[phy_idx].afe_tx_amp_control0 = + afe_tx_amp_control0; + isci_orom->ctrl[ctrl_idx].phys[phy_idx].afe_tx_amp_control1 = + afe_tx_amp_control1; + isci_orom->ctrl[ctrl_idx].phys[phy_idx].afe_tx_amp_control2 = + afe_tx_amp_control2; + isci_orom->ctrl[ctrl_idx].phys[phy_idx].afe_tx_amp_control3 = + afe_tx_amp_control3; } } } diff --git a/drivers/scsi/isci/firmware/create_fw.h b/drivers/scsi/isci/firmware/create_fw.h index 788a8de0c2b..9f9afbd97d6 100644 --- a/drivers/scsi/isci/firmware/create_fw.h +++ b/drivers/scsi/isci/firmware/create_fw.h @@ -25,14 +25,37 @@ static const int num_elements = 2; * if there is a port/phy on which you do not wish to override the default * values, use the value assigned to UNINIT_PARAM (255). */ + /* discovery mode type (port auto config mode by default ) */ + +/* + * if there is a port/phy on which you do not wish to override the default + * values, use the value "0000000000000000". SAS address of zero's is + * considered invalid and will not be used. + */ #ifdef MPC static const int mode_type = SCIC_PORT_MANUAL_CONFIGURATION_MODE; static const __u8 phy_mask[2][4] = { {1, 2, 4, 8}, {1, 2, 4, 8} }; +static const unsigned long long sas_addr[2][4] = { { 0x5FCFFFFFF0000001ULL, + 0x5FCFFFFFF0000002ULL, + 0x5FCFFFFFF0000003ULL, + 0x5FCFFFFFF0000004ULL }, + { 0x5FCFFFFFF0000005ULL, + 0x5FCFFFFFF0000006ULL, + 0x5FCFFFFFF0000007ULL, + 0x5FCFFFFFF0000008ULL } }; #else /* APC (default) */ static const int mode_type = SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE; static const __u8 phy_mask[2][4]; +static const unsigned long long sas_addr[2][4] = { { 0x5FCFFFFF00000001ULL, + 0x5FCFFFFF00000001ULL, + 0x5FCFFFFF00000001ULL, + 0x5FCFFFFF00000001ULL }, + { 0x5FCFFFFF00000002ULL, + 0x5FCFFFFF00000002ULL, + 0x5FCFFFFF00000002ULL, + 0x5FCFFFFF00000002ULL } }; #endif /* Maximum number of concurrent device spin up */ @@ -47,22 +70,8 @@ static const unsigned int afe_tx_amp_control1 = 0x000e7c03; static const unsigned int afe_tx_amp_control2 = 0x000e7c03; static const unsigned int afe_tx_amp_control3 = 0x000e7c03; -/* - * if there is a port/phy on which you do not wish to override the default - * values, use the value "0000000000000000". SAS address of zero's is - * considered invalid and will not be used. - */ -static const unsigned long long sas_addr[2][4] = { { 0x5FCFFFFFF0000000ULL, - 0x5FCFFFFFF1000000ULL, - 0x5FCFFFFFF2000000ULL, - 0x5FCFFFFFF3000000ULL }, - { 0x5FCFFFFFF4000000ULL, - 0x5FCFFFFFF5000000ULL, - 0x5FCFFFFFF6000000ULL, - 0x5FCFFFFFF7000000ULL } }; - static const char blob_name[] = "isci_firmware.bin"; static const char sig[] = "ISCUOEMB"; -static const unsigned char version = 1; +static const unsigned char version = 0x10; #endif diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c index bb5b54d361b..d6e2a73e797 100644 --- a/drivers/scsi/isci/host.c +++ b/drivers/scsi/isci/host.c @@ -418,7 +418,7 @@ int isci_host_init(struct isci_host *isci_host) int err = 0, i; enum sci_status status; struct scic_sds_controller *controller; - union scic_oem_parameters scic_oem_params; + union scic_oem_parameters oem; union scic_user_parameters scic_user_params; struct isci_pci_info *pci_info = to_pci_info(isci_host->pdev); @@ -435,6 +435,7 @@ int isci_host_init(struct isci_host *isci_host) } isci_host->core_controller = controller; + sci_object_set_association(isci_host->core_controller, isci_host); spin_lock_init(&isci_host->state_lock); spin_lock_init(&isci_host->scic_lock); spin_lock_init(&isci_host->queue_lock); @@ -457,12 +458,6 @@ int isci_host_init(struct isci_host *isci_host) isci_host->sas_ha.dev = &isci_host->pdev->dev; isci_host->sas_ha.lldd_ha = isci_host; - /*----------- SCIC controller Initialization Stuff ------------------ - * set association host adapter struct in core controller. - */ - sci_object_set_association(isci_host->core_controller, - (void *)isci_host); - /* * grab initial values stored in the controller object for OEM and USER * parameters @@ -477,11 +472,11 @@ int isci_host_init(struct isci_host *isci_host) return -ENODEV; } - scic_oem_parameters_get(controller, &scic_oem_params); + scic_oem_parameters_get(controller, &oem); /* grab any OEM parameters specified in orom */ if (pci_info->orom) { - status = isci_parse_oem_parameters(&scic_oem_params, + status = isci_parse_oem_parameters(&oem, pci_info->orom, isci_host->id); if (status != SCI_SUCCESS) { @@ -489,15 +484,14 @@ int isci_host_init(struct isci_host *isci_host) "parsing firmware oem parameters failed\n"); return -EINVAL; } - } else { - status = scic_oem_parameters_set(isci_host->core_controller, - &scic_oem_params); - if (status != SCI_SUCCESS) { - dev_warn(&isci_host->pdev->dev, - "%s: scic_oem_parameters_set failed\n", - __func__); - return -ENODEV; - } + } + + status = scic_oem_parameters_set(isci_host->core_controller, &oem); + if (status != SCI_SUCCESS) { + dev_warn(&isci_host->pdev->dev, + "%s: scic_oem_parameters_set failed\n", + __func__); + return -ENODEV; } tasklet_init(&isci_host->completion_tasklet, diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index ef0c49a0c0a..51a7bce20da 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c @@ -466,6 +466,7 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic struct isci_host *isci_host; const struct firmware *fw = NULL; struct isci_orom *orom; + char *source = "(platform)"; check_si_rev(pdev); @@ -480,6 +481,7 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic orom = isci_request_oprom(pdev); if (!orom) { + source = "(firmware)"; orom = isci_request_firmware(pdev, fw); if (!orom) { /* TODO convert this to WARN_TAINT_ONCE once the @@ -496,9 +498,9 @@ static int __devinit isci_pci_probe(struct pci_dev *pdev, const struct pci_devic if (orom) dev_info(&pdev->dev, - "OEM SAS parameters (version: %u.%u) loaded\n", + "OEM SAS parameters (version: %u.%u) loaded %s\n", (orom->hdr.version & 0xf0) >> 4, - (orom->hdr.version & 0xf)); + (orom->hdr.version & 0xf), source); pci_info->orom = orom; diff --git a/drivers/scsi/isci/probe_roms.c b/drivers/scsi/isci/probe_roms.c index 0d968d3b334..1697487f908 100644 --- a/drivers/scsi/isci/probe_roms.c +++ b/drivers/scsi/isci/probe_roms.c @@ -138,10 +138,7 @@ enum sci_status isci_parse_oem_parameters(union scic_oem_parameters *oem_params, scu_index > orom->hdr.num_elements || !oem_params) return -EINVAL; - memcpy(oem_params, - &orom->ctrl[scu_index], - sizeof(struct scic_sds_oem_params)); - + oem_params->sds1 = orom->ctrl[scu_index]; return 0; } diff --git a/drivers/scsi/isci/probe_roms.h b/drivers/scsi/isci/probe_roms.h index c2162cf1205..1b444838779 100644 --- a/drivers/scsi/isci/probe_roms.h +++ b/drivers/scsi/isci/probe_roms.h @@ -96,6 +96,10 @@ struct isci_oem_hdr { #define ISCI_ROM_SIG "ISCUOEMB" #define ISCI_ROM_SIG_SIZE 8 +#define ISCI_PREBOOT_SOURCE_INIT (0x00) +#define ISCI_PREBOOT_SOURCE_OROM (0x80) +#define ISCI_PREBOOT_SOURCE_EFI (0x81) + #define ISCI_EFI_VENDOR_GUID \ EFI_GUID(0x193dfefa, 0xa445, 0x4302, 0x99, 0xd8, 0xef, 0x3a, 0xad, \ 0x1a, 0x04, 0xc6) @@ -112,8 +116,8 @@ struct isci_oem_hdr { * being assigned is sufficient to declare manual PORT configuration. */ enum SCIC_PORT_CONFIGURATION_MODE { - SCIC_PORT_MANUAL_CONFIGURATION_MODE = 0, - SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE = 1 + SCIC_PORT_AUTOMATIC_CONFIGURATION_MODE = 0, + SCIC_PORT_MANUAL_CONFIGURATION_MODE = 1 }; struct sci_bios_oem_param_block_hdr { diff --git a/firmware/isci/isci_firmware.bin.ihex b/firmware/isci/isci_firmware.bin.ihex index b1bb5cf4499..4f8767cc60f 100644 --- a/firmware/isci/isci_firmware.bin.ihex +++ b/firmware/isci/isci_firmware.bin.ihex @@ -1,16 +1,16 @@ :10000000495343554F454D42E70017100002000089 -:10001000000000000000000101000000000000FFDF -:10002000FFCF5F000000F0000000000000000000B3 -:1000300000000000000000FFFFCF5F000000F100A3 -:10004000000000000000000000000000000000FFB1 -:10005000FFCF5F000000F200000000000000000081 -:1000600000000000000000FFFFCF5F000000F30071 -:10007000000000000000000000000000000000017F -:1000800001000000000000FFFFCF5F000000F4004F -:10009000000000000000000000000000000000FF61 -:1000A000FFCF5F000000F50000000000000000002E -:1000B00000000000000000FFFFCF5F000000F6001E -:1000C000000000000000000000000000000000FF31 -:1000D000FFCF5F000000F7000000000000000000FC -:0700E0000000000000000019 +:10001000000000000000000001000000000000FFE0 +:10002000FFCF5F01000000037C0E00037C0E000385 +:100030007C0E00037C0E00FFFFCF5F010000000379 +:100040007C0E00037C0E00037C0E00037C0E00FF80 +:10005000FFCF5F01000000037C0E00037C0E000355 +:100060007C0E00037C0E00FFFFCF5F010000000349 +:100070007C0E00037C0E00037C0E00037C0E00004F +:1000800001000000000000FFFFCF5F02000000033E +:100090007C0E00037C0E00037C0E00037C0E00FF30 +:1000A000FFCF5F02000000037C0E00037C0E000304 +:1000B0007C0E00037C0E00FFFFCF5F0200000003F8 +:1000C0007C0E00037C0E00037C0E00037C0E00FF00 +:1000D000FFCF5F02000000037C0E00037C0E0003D4 +:0700E0007C0E00037C0E0002 :00000001FF -- cgit v1.2.3-70-g09d2