summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/hisi_sas/hisi_sas_v1_hw.c
AgeCommit message (Collapse)Author
2017-03-23scsi: hisi_sas: move PHY init to hisi_sas_scan_start()John Garry
Relocate the PHY init code from LLDD hw init path to hisi_sas_scan_start(). Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2017-03-23scsi: hisi_sas: add to_hisi_sas_port()John Garry
Introduce function to get hisi_sas_port from asd_sas_port. Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2017-01-05scsi: hisi_sas: lock sensitive regions when servicing CQ interruptJohn Garry
There is a bug in the current driver in that certain hisi_hba and port structure elements which we access when servicing the CQ interrupt do not use thread-safe accesses; these include hisi_sas_port linked-list of active slots (hisi_sas_port.entry), bitmap of currently allocated IPTT (in hisi_hba.slot_index_tags), and completion queue read pointer. As a solution, lock these elements with the hisi_hba.lock. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Xiang Chen <chenxiang66@hisilicon.com> Reviewed-by: Zhangfei Gao <zhangfei.gao@linaro.org> Tested-by: Hanjun Guo <hanjun.guo@linaro.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-11-25scsi: hisi_sas: add PHY set linkrate support for v1 and v2 hwXiang Chen
Add the function to set PHY min and max linkrate through sysfs interface. Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com> Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Zhangfei Gao <zhangfei.gao@linaro.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-11-25scsi: hisi_sas: use atomic64_t for hisi_sas_device.running_reqJohn Garry
Sometimes the value of hisi_sas_device.running_req would go negative unless we have the check for running_req >= 0 before trying to decrement. This is because using running_req is not thread-safe. As such, the value for running_req may be actually incorrect, so use atomic64_t instead. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Xiang Chen <chenxiang66@hisilicon.com> Reviewed-by: Zhangfei Gao <zhangfei.gao@linaro.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-11-25scsi: hisi_sas: alloc queue id of slot according to device idXiang Chen
Currently slots are allocated from queues in a round-robin fashion. This causes a problem for internal commands in device mode. For this mode, we should ensure that the internal abort command is the last command seen in the host for that device. We can only ensure this when we place the internal abort command after the preceding commands for device that in the same queue, as there is no order in which the host will select a queue to execute the next command. This queue restriction makes supporting scsi mq more tricky in the future, but should not be a blocker. Note: Even though v1 hw does not support internal abort, the allocation method is chosen to be the same for consistency. Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com> Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Zhangfei Gao <zhangfei.gao@linaro.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-09-14scsi: hisi_sas: remove init_id_frame_v1_hw()John Garry
Function config_id_frame_v1_hw() is called twice for each PHY during initialisation, which is unneeded. So remove init_id_frame_v1_hw(), which only calls config_id_frame_v1_hw(). We will keep the call to config_id_frame_v1_hw() in start_phy_v1_hw() since it will be used for PHY reset functions. Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-09-14scsi: hisi_sas: fix HBA SAS addr endianness for v1 hwJohn Garry
The endianness for the SAS address in the TX_ID_DWORD registers is set incorrectly. We see errors like this in the boot log for v2 hw (which would have the same issue as v1 hw): [ 7.583284] sas: target proto 0x0 at 50000d1108e7923f:0x1f not handled This is due to the host SAS addr not matching the PHY SAS addr in the expander host-attached phy discovery responses. To fix, we byte swap the SAS addr from BE to LE (which is the endianness of the SAS controller). Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Xiang Chen <chenxiang66@hisilicon.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-09-14scsi: hisi_sas: save delivery queue write pointerJohn Garry
Optimise by saving an avoidable read in the get_free_slot function. The delivery queue write pointer will only be updated by software, so don't bother re-reading what was already written in the previous call to start_delivery function. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-09-14scsi: hisi_sas: save completion queue read pointerJohn Garry
Optimise by saving an avoidable read in the cq interrupt. The queue read pointer will only be updated by software, so don't bother re-reading what was already written in the previous interrupt. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-02-29hisi_sas: use slot abort in v1 hwJohn Garry
When TRANS_TX_CREDIT_TIMEOUT_ERR or TRANS_TX_CLOSE_NORMAL_ERR error occur in a slot, the command should be re-attempted. This error is equivalent to meaning that the queue is full in the sdev (and not the host). Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Hannes Reinecke <hare@suse.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-02-23hisi_sas: add v1 hw ACPI supportJohn Garry
Add support in v1 hw driver for ACPI. A check on whether an ACPI handle is available for the device is used to decide on whether to use ACPI reset handler or syscon for hw reset. Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-02-23hisi_sas: add hisi_sas_err_record_v1John Garry
Since the error record structure is different for v2 hw, make hisi_sas_err_record opaque and add hisi_sas_err_record_v1. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-02-23hisi_sas: set max commands as configurableJohn Garry
Since v2 hardware permits different numbers of commands to v1, set this as configurable in hisi_sas_hw. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-02-04Merge remote-tracking branch 'mkp-scsi/4.5/scsi-fixes' into fixesJames Bottomley
2016-01-26hisi_sas: fix v1 hw check for slot errorJohn Garry
Completion header bit CMPLT_HDR_RSPNS_XFRD flags whether the response frame is received into host memory, and not whether the response frame has an error. As such, change the decision on whether a slot has an error. Also redundant check on CMPLT_HDR_CMD_CMPLT_MSK is removed. Fixes: 27a3f229 ("hisi_sas: Add cq interrupt handler") Signed-off-by: John Garry <john.garry@huawei.com> Tested-by: Ricardo Salveti <ricardo.salveti@linaro.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-08hisi_sas: Use u64 for qw0 in free_device_v1_hw()John Garry
By reading in itct.qw0 into a 32b variable the top 32 bits were being lost. In practice this was OK as they were zeroes. Fixes: 27a3f229 ("hisi_sas: Add cq interrupt") Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> Reviewed-by: Shane Seymour <shane.seymour@hpe.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-08hisi_sas: Fix typo in setup_itct_v1_hw()John Garry
We were doing a arithmetic comparison instead of logical shift by accident. Mis-programming the itct did not seem to make a difference to operation. Fixes: abda97c2fe874 ("hisi_sas: Add dev_found") Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> Reviewed-by: Shane Seymour <shane.seymour@hpe.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2016-01-08hisi_sas: Fix v1 itct masksJohn Garry
The mask fields are for quad-words, so add ULL suffix. Also unreferenced ITCT_HDR_BREAK_REPLY and ITCT_HDR_MAX_BURST are removed. Fixes: 50af155b6c ("hisi_sas: Add v1 hardware reg") Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Shane Seymour <shane.seymour@hpe.com> Reviewed-by: Matthew R. Ochs <mrochs@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-12-16hisi_sas: use platform_get_irq()John Garry
It is preferred that drivers use platform_get_irq() instead of irq_of_parse_and_map(), so replace. Signed-off-by: John Garry <john.garry@huawei.com> Acked-by: Rob Herring <robh@kernel.org> Reviewed-by: Johannes Thumshirn <jthumshirn@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Remove dependency on of_irq_countJohn Garry
Originally the driver would use of_irq_count to calculate how much memory is required for storing the interrupt names, since the number of interrupt sources for the controller is variable. Since of_irq_count cannot be used by the driver, use fixed names. Signed-off-by: John Garry <john.garry@huawei.com> Signed-off-by: Zhangfei Gao <zhangfei.gao@linaro.org> Acked-by: Rob Herring <robh@kernel.org> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Add fatal irq handlerJohn Garry
Add handlers for fatal interrupts. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Add control phy handlerJohn Garry
Add method for lldd_control_phy. Currently link rate control and spinup hold is unsupported. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Add smp protocol supportJohn Garry
Add support for smp function, which allows devices attached by expander to be controlled. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Add bcast interrupt handlerJohn Garry
This is for expander broadcast event. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Add abnormal irq handlerJohn Garry
Add abnormal irq handler. This handler is concerned with phy down event. Also add port formed and port deformed handlers. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Add dev_found and dev_goneJohn Garry
Add functions to deal with lldd_dev_found and lldd_dev_gone. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Add cq interrupt handlerJohn Garry
Add cq interrupt handler and also slot error handler function. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Add ssp command functionJohn Garry
Add path to send ssp command to HW. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Add path from phyup irq to SAS frameworkJohn Garry
Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Add v1 hardware interrupt initJohn Garry
Add code to interrupts, so now we can get a phy up interrupt when a disk is connected. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Add v1 hardware initialisation codeJohn Garry
Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Add v1 hardware register definitionsJohn Garry
Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
2015-11-25hisi_sas: Add v1 hw module initJohn Garry
Add module init code for v1 hw. Signed-off-by: John Garry <john.garry@huawei.com> Reviewed-by: Arnd Bergmann <arnd@arndb.de> Reviewed-by: Hannes Reinecke <hare@suse.de> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>