From: Kevin Barnett Date: Thu, 10 Aug 2017 18:46:57 +0000 (-0500) Subject: scsi: smartpqi: cleanup doorbell register usage. X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=4f078e24080626764896055d857719cd886e6321;p=GitHub%2Fmoto-9609%2Fandroid_kernel_motorola_exynos9610.git scsi: smartpqi: cleanup doorbell register usage. Reviewed-by: Scott Benesh Signed-off-by: Kevin Barnett Signed-off-by: Don Brace Signed-off-by: Martin K. Petersen --- diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index 3b05f282802b..70b1f97daee8 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -3008,11 +3008,9 @@ static void pqi_change_irq_mode(struct pqi_ctrl_info *ctrl_info, break; case IRQ_MODE_INTX: pqi_configure_legacy_intx(ctrl_info, true); - sis_disable_msix(ctrl_info); sis_enable_intx(ctrl_info); break; case IRQ_MODE_NONE: - sis_disable_msix(ctrl_info); break; } break; @@ -3020,14 +3018,12 @@ static void pqi_change_irq_mode(struct pqi_ctrl_info *ctrl_info, switch (new_mode) { case IRQ_MODE_MSIX: pqi_configure_legacy_intx(ctrl_info, false); - sis_disable_intx(ctrl_info); sis_enable_msix(ctrl_info); break; case IRQ_MODE_INTX: break; case IRQ_MODE_NONE: pqi_configure_legacy_intx(ctrl_info, false); - sis_disable_intx(ctrl_info); break; } break; @@ -6046,7 +6042,12 @@ static int pqi_revert_to_sis_mode(struct pqi_ctrl_info *ctrl_info) rc = pqi_reset(ctrl_info); if (rc) return rc; - sis_reenable_sis_mode(ctrl_info); + rc = sis_reenable_sis_mode(ctrl_info); + if (rc) { + dev_err(&ctrl_info->pci_dev->dev, + "re-enabling SIS mode failed with error %d\n", rc); + return rc; + } pqi_save_ctrl_mode(ctrl_info, SIS_MODE); return 0; diff --git a/drivers/scsi/smartpqi/smartpqi_sis.c b/drivers/scsi/smartpqi/smartpqi_sis.c index 9abbaced4b33..5141bd4c9f06 100644 --- a/drivers/scsi/smartpqi/smartpqi_sis.c +++ b/drivers/scsi/smartpqi/smartpqi_sis.c @@ -34,12 +34,13 @@ #define SIS_REENABLE_SIS_MODE 0x1 #define SIS_ENABLE_MSIX 0x40 #define SIS_ENABLE_INTX 0x80 -#define SIS_SOFT_RESET 0x100 +#define SIS_CMD_READY 0x200 #define SIS_TRIGGER_SHUTDOWN 0x800000 #define SIS_PQI_RESET_QUIESCE 0x1000000 -#define SIS_CMD_READY 0x200 + #define SIS_CMD_COMPLETE 0x1000 #define SIS_CLEAR_CTRL_TO_HOST_DOORBELL 0x1000 + #define SIS_CMD_STATUS_SUCCESS 0x1 #define SIS_CMD_COMPLETE_TIMEOUT_SECS 30 #define SIS_CMD_COMPLETE_POLL_INTERVAL_MSECS 10 @@ -373,66 +374,21 @@ static int sis_wait_for_doorbell_bit_to_clear( return rc; } -/* Enable MSI-X interrupts on the controller. */ - -void sis_enable_msix(struct pqi_ctrl_info *ctrl_info) +static inline int sis_set_doorbell_bit(struct pqi_ctrl_info *ctrl_info, u32 bit) { - u32 doorbell_register; - - doorbell_register = - readl(&ctrl_info->registers->sis_host_to_ctrl_doorbell); - doorbell_register |= SIS_ENABLE_MSIX; + writel(bit, &ctrl_info->registers->sis_host_to_ctrl_doorbell); - writel(doorbell_register, - &ctrl_info->registers->sis_host_to_ctrl_doorbell); - - sis_wait_for_doorbell_bit_to_clear(ctrl_info, SIS_ENABLE_MSIX); + return sis_wait_for_doorbell_bit_to_clear(ctrl_info, bit); } -/* Disable MSI-X interrupts on the controller. */ - -void sis_disable_msix(struct pqi_ctrl_info *ctrl_info) +void sis_enable_msix(struct pqi_ctrl_info *ctrl_info) { - u32 doorbell_register; - - doorbell_register = - readl(&ctrl_info->registers->sis_host_to_ctrl_doorbell); - doorbell_register &= ~SIS_ENABLE_MSIX; - - writel(doorbell_register, - &ctrl_info->registers->sis_host_to_ctrl_doorbell); + sis_set_doorbell_bit(ctrl_info, SIS_ENABLE_MSIX); } void sis_enable_intx(struct pqi_ctrl_info *ctrl_info) { - u32 doorbell_register; - - doorbell_register = - readl(&ctrl_info->registers->sis_host_to_ctrl_doorbell); - doorbell_register |= SIS_ENABLE_INTX; - - writel(doorbell_register, - &ctrl_info->registers->sis_host_to_ctrl_doorbell); - - sis_wait_for_doorbell_bit_to_clear(ctrl_info, SIS_ENABLE_INTX); -} - -void sis_disable_intx(struct pqi_ctrl_info *ctrl_info) -{ - u32 doorbell_register; - - doorbell_register = - readl(&ctrl_info->registers->sis_host_to_ctrl_doorbell); - doorbell_register &= ~SIS_ENABLE_INTX; - - writel(doorbell_register, - &ctrl_info->registers->sis_host_to_ctrl_doorbell); -} - -void sis_soft_reset(struct pqi_ctrl_info *ctrl_info) -{ - writel(SIS_SOFT_RESET, - &ctrl_info->registers->sis_host_to_ctrl_doorbell); + sis_set_doorbell_bit(ctrl_info, SIS_ENABLE_INTX); } void sis_shutdown_ctrl(struct pqi_ctrl_info *ctrl_info) @@ -447,51 +403,12 @@ void sis_shutdown_ctrl(struct pqi_ctrl_info *ctrl_info) int sis_pqi_reset_quiesce(struct pqi_ctrl_info *ctrl_info) { - u32 doorbell_register; - - doorbell_register = - readl(&ctrl_info->registers->sis_host_to_ctrl_doorbell); - doorbell_register |= SIS_PQI_RESET_QUIESCE; - - writel(doorbell_register, - &ctrl_info->registers->sis_host_to_ctrl_doorbell); - - return sis_wait_for_doorbell_bit_to_clear(ctrl_info, - SIS_PQI_RESET_QUIESCE); + return sis_set_doorbell_bit(ctrl_info, SIS_PQI_RESET_QUIESCE); } -#define SIS_MODE_READY_TIMEOUT_SECS 30 - int sis_reenable_sis_mode(struct pqi_ctrl_info *ctrl_info) { - int rc; - unsigned long timeout; - struct pqi_ctrl_registers __iomem *registers; - u32 doorbell; - - registers = ctrl_info->registers; - - writel(SIS_REENABLE_SIS_MODE, - ®isters->sis_host_to_ctrl_doorbell); - - rc = 0; - timeout = (SIS_MODE_READY_TIMEOUT_SECS * HZ) + jiffies; - - while (1) { - doorbell = readl(®isters->sis_ctrl_to_host_doorbell); - if ((doorbell & SIS_REENABLE_SIS_MODE) == 0) - break; - if (time_after(jiffies, timeout)) { - rc = -ETIMEDOUT; - break; - } - } - - if (rc) - dev_err(&ctrl_info->pci_dev->dev, - "re-enabling SIS mode failed\n"); - - return rc; + return sis_set_doorbell_bit(ctrl_info, SIS_REENABLE_SIS_MODE); } void sis_write_driver_scratch(struct pqi_ctrl_info *ctrl_info, u32 value) diff --git a/drivers/scsi/smartpqi/smartpqi_sis.h b/drivers/scsi/smartpqi/smartpqi_sis.h index 394b16eb4c77..2bf889dbf5ab 100644 --- a/drivers/scsi/smartpqi/smartpqi_sis.h +++ b/drivers/scsi/smartpqi/smartpqi_sis.h @@ -27,10 +27,7 @@ int sis_get_ctrl_properties(struct pqi_ctrl_info *ctrl_info); int sis_get_pqi_capabilities(struct pqi_ctrl_info *ctrl_info); int sis_init_base_struct_addr(struct pqi_ctrl_info *ctrl_info); void sis_enable_msix(struct pqi_ctrl_info *ctrl_info); -void sis_disable_msix(struct pqi_ctrl_info *ctrl_info); void sis_enable_intx(struct pqi_ctrl_info *ctrl_info); -void sis_disable_intx(struct pqi_ctrl_info *ctrl_info); -void sis_soft_reset(struct pqi_ctrl_info *ctrl_info); void sis_shutdown_ctrl(struct pqi_ctrl_info *ctrl_info); int sis_pqi_reset_quiesce(struct pqi_ctrl_info *ctrl_info); int sis_reenable_sis_mode(struct pqi_ctrl_info *ctrl_info);