From 6ecb9f2aff758b45a7e42bddf72176063ac4042b Mon Sep 17 00:00:00 2001 From: Bart Van Assche Date: Sun, 29 Jul 2012 14:23:58 +0000 Subject: [PATCH] qla2x00t: Fix a deadlock crash The symptom of the crash is that one finds the system deadlocked spinning on scsi_qla_host_t.hardware_lock in qla2x00_enable_tgt_mode with a stack something like this: crash> bt PID: 6155 TASK: ffff88006e4bc3c0 CPU: 1 COMMAND: "scst_uid" #0 [ffff88007b915b28] machine_kexec at ffffffff8103163b #1 [ffff88007b915b88] crash_kexec at ffffffff810b8e52 #2 [ffff88007b915c58] panic at ffffffff814ed0ab #3 [ffff88007b915cd8] spin_bug at ffffffff8127cd46 #4 [ffff88007b915d18] _raw_spin_lock at ffffffff8127d015 #5 [ffff88007b915d68] _spin_lock_irqsave at ffffffff814f02e4 #6 [ffff88007b915d88] qla2x00_enable_tgt_mode at ffffffffa047b672 [qla2xxx] #7 [ffff88007b915db8] q2t_host_action at ffffffffa06db6a6 [qla2x00tgt] #8 [ffff88007b915df8] q2t_enable_tgt at ffffffffa06db6ea [qla2x00tgt] #9 [ffff88007b915e18] scst_process_tgt_enable_store at ffffffffa04f102e [scst] #10 [ffff88007b915e48] scst_tgt_enable_store_work_fn at ffffffffa04f1176 [scst] #11 [ffff88007b915e58] scst_process_sysfs_works at ffffffffa04e8bbe [scst] #12 [ffff88007b915e78] sysfs_work_thread_fn at ffffffffa04e8db5 [scst] #13 [ffff88007b915ed8] kthread at ffffffff8108f976 #14 [ffff88007b915f48] kernel_thread at ffffffff8100c20a I was pulling my hair out on this one, because with the spinlock debugging (enhanced to capture the PID along with the task pointer), I figured out that the task (and process) that originally locked the lock was gone! It got really confusing when I added more spinlock debug code to the kernel to detect locks held in the task switching and task/process termination paths -- and didn't catch anything terminating with locks held! I finally tracked the problem down to two things: 1. When qla24xx_create_vhost creates a new virtual scsi_qla_host_t it does it by copying the physical (aka parent) scsi_qla_host_t. Under the right unlucky conditions, this can happen with the hardware_lock held (the spinlock is embedded in the structure). 2. The code should only be locking the hardware_lock of the physical scsi_qla_host_t, because the lock is associated with the hardware. Unfortunately, quite a few places are not using to_qla_parent to make sure they lock the correct lock. One of those places is qla2x00_enable_tgt_mode. Along with the deadlock, this has the potential to leave the hardware and driver structures in unpredictable states, because the lock isn't always providing serialization. The fix entails two things: 1. Zeroing the lock after copying the scsi_qla_host_t structure: This won't stop the deadlock, but will enable the spinlock debug code to easily catch anything that misbehaves and locks the wrong lock. I also initialized the other locks because they could have the same problem. I also initialized the list heads, because they could end up holding dangling references. I did not initialize all pointers, because there are quite a few that point to read only data and are OK (and I didn't have time to research all of them). 2. Using to_qla_parent everywhere when locking and the scsi_qla_host_t structure might be virtual. This is a lot of changes, but they are the same thing over and over again. I did not make an effort to look for scalar or pointer fields that are being picked from the wrong structure. That's getting to be as much pain as merging up to the latest QLogic driver (which would have gotten rid of this problem). From "Robinson, Herbie" (Merge r4420 from trunk) git-svn-id: http://svn.code.sf.net/p/scst/svn/branches/2.2.x@4438 d57e44dd-8a1f-0410-8b47-8ef2f437770f --- qla2x00t/qla2x_tgt.h | 5 +++-- qla2x00t/qla_attr.c | 19 +++++++++++-------- qla2x00t/qla_init.c | 5 +++-- qla2x00t/qla_iocb.c | 14 ++++++++------ qla2x00t/qla_isr.c | 5 +++-- qla2x00t/qla_mbx.c | 11 ++++++----- qla2x00t/qla_mid.c | 7 +++++++ qla2x00t/qla_os.c | 20 ++++++++++++-------- qla2x00t/qla_sup.c | 41 +++++++++++++++++++++++++---------------- 9 files changed, 78 insertions(+), 49 deletions(-) diff --git a/qla2x00t/qla2x_tgt.h b/qla2x00t/qla2x_tgt.h index abb0c4e8e..7b113a002 100644 --- a/qla2x00t/qla2x_tgt.h +++ b/qla2x00t/qla2x_tgt.h @@ -122,9 +122,10 @@ qla2x00_send_enable_lun(scsi_qla_host_t *ha, bool enable) { if (!IS_FWI2_CAPABLE(ha)) { unsigned long flags; - spin_lock_irqsave(&ha->hardware_lock, flags); + scsi_qla_host_t *pha = to_qla_parent(ha); + spin_lock_irqsave(&pha->hardware_lock, flags); __qla2x00_send_enable_lun(ha, enable); - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); } } diff --git a/qla2x00t/qla_attr.c b/qla2x00t/qla_attr.c index 62a70b1de..176ddb869 100644 --- a/qla2x00t/qla_attr.c +++ b/qla2x00t/qla_attr.c @@ -36,6 +36,7 @@ qla2x00_store_class2_enabled(struct device *dev, struct device_attribute *attr, const char *buffer, size_t size) { struct scsi_qla_host *ha = shost_priv(class_to_shost(dev)); + scsi_qla_host_t *pha = to_qla_parent(ha); int reset = 0; unsigned long flags; int res = size; @@ -43,7 +44,7 @@ qla2x00_store_class2_enabled(struct device *dev, if (buffer == NULL) goto out; - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); switch (buffer[0]) { case '0': @@ -76,7 +77,7 @@ qla2x00_store_class2_enabled(struct device *dev, goto out_unlock; } - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); if (reset) set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); @@ -85,7 +86,7 @@ out: return size; out_unlock: - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); goto out; } @@ -176,12 +177,13 @@ qla2x00_store_expl_conf_enabled(struct device *dev, struct device_attribute *attr, const char *buffer, size_t size) { struct scsi_qla_host *ha = shost_priv(class_to_shost(dev)); + scsi_qla_host_t *pha = to_qla_parent(ha); unsigned long flags; if (buffer == NULL) return size; - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); switch (buffer[0]) { case '0': @@ -202,7 +204,7 @@ qla2x00_store_expl_conf_enabled(struct device *dev, break; } - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); return size; } @@ -232,12 +234,13 @@ qla2x00_store_ini_mode_force_reverse(struct device *dev, struct device_attribute *attr, const char *buffer, size_t size) { struct scsi_qla_host *ha = shost_priv(class_to_shost(dev)); + scsi_qla_host_t *pha = to_qla_parent(ha); unsigned long flags; if (buffer == NULL) return size; - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); switch (buffer[0]) { case '0': @@ -264,7 +267,7 @@ qla2x00_store_ini_mode_force_reverse(struct device *dev, break; } - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); qla2xxx_wake_dpc(ha); @@ -274,7 +277,7 @@ out: return size; out_unlock: - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); goto out; } diff --git a/qla2x00t/qla_init.c b/qla2x00t/qla_init.c index c8bf7810c..16e75c734 100644 --- a/qla2x00t/qla_init.c +++ b/qla2x00t/qla_init.c @@ -4143,10 +4143,11 @@ void qla2x00_enable_tgt_mode(scsi_qla_host_t *ha) { unsigned long flags; + scsi_qla_host_t *pha = to_qla_parent(ha); - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); qla_set_tgt_mode(ha); - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); if (ha->parent) ha = ha->parent; diff --git a/qla2x00t/qla_iocb.c b/qla2x00t/qla_iocb.c index 3507b7447..432a3600e 100644 --- a/qla2x00t/qla_iocb.c +++ b/qla2x00t/qla_iocb.c @@ -268,7 +268,7 @@ qla2x00_start_scsi(srb_t *sp) { int ret, nseg; unsigned long flags; - scsi_qla_host_t *ha; + scsi_qla_host_t *ha, *pha; struct scsi_cmnd *cmd; uint32_t *clr_ptr; uint32_t index; @@ -282,6 +282,7 @@ qla2x00_start_scsi(srb_t *sp) /* Setup device pointers. */ ret = 0; ha = sp->ha; + pha = to_qla_parent(ha); reg = &ha->iobase->isp; cmd = sp->cmd; /* So we know we haven't pci_map'ed anything yet */ @@ -296,7 +297,7 @@ qla2x00_start_scsi(srb_t *sp) } /* Acquire ring specific lock */ - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); /* Check for room in outstanding command list. */ handle = ha->current_outstanding_cmd; @@ -385,14 +386,14 @@ qla2x00_start_scsi(srb_t *sp) ha->response_ring_ptr->signature != RESPONSE_PROCESSED) qla2x00_process_response_queue(ha); - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); return (QLA_SUCCESS); queuing_error: if (tot_dsds) scsi_dma_unmap(cmd); - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); return (QLA_FUNCTION_FAILED); } @@ -477,6 +478,7 @@ request_t * qla2x00_req_pkt(scsi_qla_host_t *ha) { device_reg_t __iomem *reg = ha->iobase; + scsi_qla_host_t *pha = to_qla_parent(ha); request_t *pkt = NULL; uint16_t cnt; uint32_t *dword_ptr; @@ -519,7 +521,7 @@ qla2x00_req_pkt(scsi_qla_host_t *ha) } /* Release ring specific lock */ - spin_unlock(&ha->hardware_lock); + spin_unlock(&pha->hardware_lock); udelay(2); /* 2 us */ @@ -528,7 +530,7 @@ qla2x00_req_pkt(scsi_qla_host_t *ha) if (!ha->marker_needed && !ha->flags.init_done) qla2x00_poll(ha); - spin_lock_irq(&ha->hardware_lock); + spin_lock_irq(&pha->hardware_lock); } if (!pkt) { DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__)); diff --git a/qla2x00t/qla_isr.c b/qla2x00t/qla_isr.c index d1d9e7a2d..0f16b72a6 100644 --- a/qla2x00t/qla_isr.c +++ b/qla2x00t/qla_isr.c @@ -2018,6 +2018,7 @@ qla2x00_request_irqs(scsi_qla_host_t *ha) { int ret; device_reg_t __iomem *reg = ha->iobase; + scsi_qla_host_t *pha = to_qla_parent(ha); /* If possible, enable MSI-X. */ if (!IS_QLA2432(ha) && !IS_QLA2532(ha) && !IS_QLA8432(ha)) @@ -2078,7 +2079,7 @@ skip_msi: clear_risc_ints: ha->isp_ops->disable_intrs(ha); - spin_lock_irq(&ha->hardware_lock); + spin_lock_irq(&pha->hardware_lock); if (IS_FWI2_CAPABLE(ha)) { WRT_REG_DWORD(®->isp24.hccr, HCCRX_CLR_HOST_INT); WRT_REG_DWORD(®->isp24.hccr, HCCRX_CLR_RISC_INT); @@ -2087,7 +2088,7 @@ clear_risc_ints: WRT_REG_WORD(®->isp.hccr, HCCR_CLR_RISC_INT); WRT_REG_WORD(®->isp.hccr, HCCR_CLR_HOST_INT); } - spin_unlock_irq(&ha->hardware_lock); + spin_unlock_irq(&pha->hardware_lock); fail: return ret; diff --git a/qla2x00t/qla_mbx.c b/qla2x00t/qla_mbx.c index ee3668001..e736152da 100644 --- a/qla2x00t/qla_mbx.c +++ b/qla2x00t/qla_mbx.c @@ -742,6 +742,7 @@ int qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp) { unsigned long flags = 0; + scsi_qla_host_t *pha = to_qla_parent(ha); fc_port_t *fcport; int rval; uint32_t handle; @@ -752,12 +753,12 @@ qla2x00_abort_command(scsi_qla_host_t *ha, srb_t *sp) fcport = sp->fcport; - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { if (ha->outstanding_cmds[handle] == sp) break; } - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); if (handle == MAX_OUTSTANDING_COMMANDS) { /* command not found */ @@ -2309,7 +2310,7 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp) int rval; fc_port_t *fcport; unsigned long flags = 0; - + scsi_qla_host_t *pha = to_qla_parent(ha); struct abort_entry_24xx *abt; dma_addr_t abt_dma; uint32_t handle; @@ -2318,12 +2319,12 @@ qla24xx_abort_command(scsi_qla_host_t *ha, srb_t *sp) fcport = sp->fcport; - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); for (handle = 1; handle < MAX_OUTSTANDING_COMMANDS; handle++) { if (ha->outstanding_cmds[handle] == sp) break; } - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); if (handle == MAX_OUTSTANDING_COMMANDS) { /* Command not found. */ return QLA_FUNCTION_FAILED; diff --git a/qla2x00t/qla_mid.c b/qla2x00t/qla_mid.c index 4e3c9e2f8..34d6e2e2f 100644 --- a/qla2x00t/qla_mid.c +++ b/qla2x00t/qla_mid.c @@ -385,6 +385,13 @@ qla24xx_create_vhost(struct fc_vport *fc_vport) /* clone the parent hba */ memcpy(vha, ha, sizeof (scsi_qla_host_t)); + memset(&vha->hardware_lock, 0, sizeof(spinlock_t)); + INIT_LIST_HEAD(&vha->vp_list); + spin_lock_init(&vha->dpc_lock); + mutex_init(&vha->tgt_mutex); + mutex_init(&vha->tgt_host_action_mutex); + INIT_LIST_HEAD(&vha->ha_list_entry); + fc_vport->dd_data = vha; vha->node_name = kmalloc(WWN_SIZE * sizeof(char), GFP_KERNEL); diff --git a/qla2x00t/qla_os.c b/qla2x00t/qla_os.c index 242cbac64..1e832f350 100644 --- a/qla2x00t/qla_os.c +++ b/qla2x00t/qla_os.c @@ -1307,14 +1307,15 @@ static void qla2x00_enable_intrs(scsi_qla_host_t *ha) { unsigned long flags = 0; + scsi_qla_host_t *pha = to_qla_parent(ha); struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); ha->interrupts_on = 1; /* enable risc and host interrupts */ WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); RD_REG_WORD(®->ictrl); - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); } @@ -1322,40 +1323,43 @@ static void qla2x00_disable_intrs(scsi_qla_host_t *ha) { unsigned long flags = 0; + scsi_qla_host_t *pha = to_qla_parent(ha); struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); ha->interrupts_on = 0; /* disable risc and host interrupts */ WRT_REG_WORD(®->ictrl, 0); RD_REG_WORD(®->ictrl); - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); } static void qla24xx_enable_intrs(scsi_qla_host_t *ha) { unsigned long flags = 0; + scsi_qla_host_t *pha = to_qla_parent(ha); struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); ha->interrupts_on = 1; WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); RD_REG_DWORD(®->ictrl); - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); } static void qla24xx_disable_intrs(scsi_qla_host_t *ha) { unsigned long flags = 0; + scsi_qla_host_t *pha = to_qla_parent(ha); struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); ha->interrupts_on = 0; WRT_REG_DWORD(®->ictrl, 0); RD_REG_DWORD(®->ictrl); - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); } static struct isp_operations qla2100_isp_ops = { diff --git a/qla2x00t/qla_sup.c b/qla2x00t/qla_sup.c index d83b02028..4caa560b8 100644 --- a/qla2x00t/qla_sup.c +++ b/qla2x00t/qla_sup.c @@ -836,10 +836,11 @@ qla2x00_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, uint32_t i; uint16_t *wptr; unsigned long flags; + scsi_qla_host_t *pha = to_qla_parent(ha); ret = QLA_SUCCESS; - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); qla2x00_lock_nvram_access(ha); /* Disable NVRAM write-protection. */ @@ -856,7 +857,7 @@ qla2x00_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, qla2x00_set_nvram_protection(ha, stat); qla2x00_unlock_nvram_access(ha); - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); return ret; } @@ -870,10 +871,11 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, uint32_t *dwptr; struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; unsigned long flags; + scsi_qla_host_t *pha = to_qla_parent(ha); ret = QLA_SUCCESS; - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); /* Enable flash write. */ WRT_REG_DWORD(®->ctrl_status, RD_REG_DWORD(®->ctrl_status) | CSRX_FLASH_ENABLE); @@ -907,7 +909,7 @@ qla24xx_write_nvram_data(scsi_qla_host_t *ha, uint8_t *buf, uint32_t naddr, WRT_REG_DWORD(®->ctrl_status, RD_REG_DWORD(®->ctrl_status) & ~CSRX_FLASH_ENABLE); RD_REG_DWORD(®->ctrl_status); /* PCI Posting. */ - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); return ret; } @@ -986,8 +988,9 @@ qla2x00_beacon_blink(struct scsi_qla_host *ha) uint16_t led_color = 0; unsigned long flags; struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; + scsi_qla_host_t *pha = to_qla_parent(ha); - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); /* Save the Original GPIOE. */ if (ha->pio_address) { @@ -1024,7 +1027,7 @@ qla2x00_beacon_blink(struct scsi_qla_host *ha) RD_REG_WORD(®->gpiod); } - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); } int @@ -1034,6 +1037,7 @@ qla2x00_beacon_on(struct scsi_qla_host *ha) uint16_t gpio_data; unsigned long flags; struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; + scsi_qla_host_t *pha = to_qla_parent(ha); ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING; ha->fw_options[1] |= FO1_DISABLE_GPIO6_7; @@ -1045,7 +1049,7 @@ qla2x00_beacon_on(struct scsi_qla_host *ha) } /* Turn off LEDs. */ - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); if (ha->pio_address) { gpio_enable = RD_REG_WORD_PIO(PIO_REG(ha, gpioe)); gpio_data = RD_REG_WORD_PIO(PIO_REG(ha, gpiod)); @@ -1071,7 +1075,7 @@ qla2x00_beacon_on(struct scsi_qla_host *ha) WRT_REG_WORD(®->gpiod, gpio_data); RD_REG_WORD(®->gpiod); } - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); /* * Let the per HBA timer kick off the blinking process based on @@ -1131,9 +1135,10 @@ qla24xx_beacon_blink(struct scsi_qla_host *ha) uint32_t gpio_data; unsigned long flags; struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; + scsi_qla_host_t *pha = to_qla_parent(ha); /* Save the Original GPIOD. */ - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); gpio_data = RD_REG_DWORD(®->gpiod); /* Enable the gpio_data reg for update. */ @@ -1154,7 +1159,7 @@ qla24xx_beacon_blink(struct scsi_qla_host *ha) /* Set the modified gpio_data values. */ WRT_REG_DWORD(®->gpiod, gpio_data); gpio_data = RD_REG_DWORD(®->gpiod); - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); } int @@ -1165,6 +1170,8 @@ qla24xx_beacon_on(struct scsi_qla_host *ha) struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; if (ha->beacon_blink_led == 0) { + scsi_qla_host_t *pha = to_qla_parent(ha); + /* Enable firmware for update */ ha->fw_options[1] |= ADD_FO1_DISABLE_GPIO_LED_CTRL; @@ -1178,7 +1185,7 @@ qla24xx_beacon_on(struct scsi_qla_host *ha) return QLA_FUNCTION_FAILED; } - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); gpio_data = RD_REG_DWORD(®->gpiod); /* Enable the gpio_data reg for update. */ @@ -1186,7 +1193,7 @@ qla24xx_beacon_on(struct scsi_qla_host *ha) WRT_REG_DWORD(®->gpiod, gpio_data); RD_REG_DWORD(®->gpiod); - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); } /* So all colors blink together. */ @@ -1204,6 +1211,7 @@ qla24xx_beacon_off(struct scsi_qla_host *ha) uint32_t gpio_data; unsigned long flags; struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; + scsi_qla_host_t *pha = to_qla_parent(ha); ha->beacon_blink_led = 0; ha->beacon_color_state = QLA_LED_ALL_ON; @@ -1211,14 +1219,14 @@ qla24xx_beacon_off(struct scsi_qla_host *ha) ha->isp_ops->beacon_blink(ha); /* Will flip to all off. */ /* Give control back to firmware. */ - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); gpio_data = RD_REG_DWORD(®->gpiod); /* Disable the gpio_data reg for update. */ gpio_data &= ~GPDX_LED_UPDATE_MASK; WRT_REG_DWORD(®->gpiod, gpio_data); RD_REG_DWORD(®->gpiod); - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); ha->fw_options[1] &= ~ADD_FO1_DISABLE_GPIO_LED_CTRL; @@ -1591,6 +1599,7 @@ qla2x00_suspend_hba(struct scsi_qla_host *ha) int cnt; unsigned long flags; struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; + scsi_qla_host_t *pha = to_qla_parent(ha); /* Suspend HBA. */ scsi_block_requests(ha->host); @@ -1598,7 +1607,7 @@ qla2x00_suspend_hba(struct scsi_qla_host *ha) set_bit(MBX_UPDATE_FLASH_ACTIVE, &ha->mbx_cmd_flags); /* Pause RISC. */ - spin_lock_irqsave(&ha->hardware_lock, flags); + spin_lock_irqsave(&pha->hardware_lock, flags); WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC); RD_REG_WORD(®->hccr); if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) { @@ -1610,7 +1619,7 @@ qla2x00_suspend_hba(struct scsi_qla_host *ha) } else { udelay(10); } - spin_unlock_irqrestore(&ha->hardware_lock, flags); + spin_unlock_irqrestore(&pha->hardware_lock, flags); } static inline void