android_kernel_motorola_sm6225/drivers/scsi/qla2xxx/qla_inline.h

98 lines
2 KiB
C
Raw Normal View History

/*
* QLogic Fibre Channel HBA Driver
* Copyright (c) 2003-2008 QLogic Corporation
*
* See LICENSE.qla2xxx for copyright and licensing details.
*/
/*
* qla2x00_debounce_register
* Debounce register.
*
* Input:
* port = register address.
*
* Returns:
* register value.
*/
static __inline__ uint16_t
qla2x00_debounce_register(volatile uint16_t __iomem *addr)
{
volatile uint16_t first;
volatile uint16_t second;
do {
first = RD_REG_WORD(addr);
barrier();
cpu_relax();
second = RD_REG_WORD(addr);
} while (first != second);
return (first);
}
static inline void
qla2x00_poll(scsi_qla_host_t *ha)
{
[SCSI] qla2xxx: Disable local-interrupts while polling for RISC status. Matthew Wilcox <matthew@wil.cx> reported the following lockdep warning: > ================================= > [INFO:inconsistentlockstate] > 2.6.26-rc1-00115-g0340eda-dirty#60 > --------------------------------- > inconsistent{hardirq-on-W}->{in-hardirq-W}usage. > swapper/1[HC1[1]:SC0[0]:HE0:SE1]takes: > (&ha->hardware_lock){+-..},at:[<c035495d>]qla2300_intr_handler+0x35/0x1f5 > {hardirq-on-W}statewasregisteredat: > [<c0139a16>]__lock_acquire+0x459/0xb1d > [<c013a091>]__lock_acquire+0xad4/0xb1d > [<c013a142>]lock_acquire+0x68/0x82 > [<c035495d>]qla2300_intr_handler+0x35/0x1f5 > [<c0506da5>]_spin_lock+0x24/0x4d > [<c035495d>]qla2300_intr_handler+0x35/0x1f5 > [<c035495d>]qla2300_intr_handler+0x35/0x1f5 > [<c01391e4>]trace_hardirqs_on+0xe7/0x10e > [<c034f0a6>]qla2x00_mailbox_command+0x1c6/0x433 ... > other info that might help us debug this: > no locks held by swapper/1. > > stack backtrace: > Pid:1,comm:swapperNottainted2.6.26-rc1-00115-g0340eda-dirty#60 > [<c0138121>]print_usage_bug+0x100/0x10a > [<c0138d37>]mark_lock+0xaa/0x395 > [<c01399af>]__lock_acquire+0x3f2/0xb1d > [<c013a091>]__lock_acquire+0xad4/0xb1d > [<c013a142>]lock_acquire+0x68/0x82 > [<c035495d>]qla2300_intr_handler+0x35/0x1f5 > [<c0506da5>]_spin_lock+0x24/0x4d > [<c035495d>]qla2300_intr_handler+0x35/0x1f5 > [<c035495d>]qla2300_intr_handler+0x35/0x1f5 > [<c014a37b>]handle_IRQ_event+0x13/0x3d > [<c014b366>]handle_fasteoi_irq+0x76/0xab Which shows that lockdep is detecting the driver's interrupt-handler is run in both process and interrupt context with irqs-enabled in the former case. During init-time and error-recovery (after a RISC reset), the driver disables interrupts and 'polls' for completions by calling qla2x00_poll(): static inline void qla2x00_poll(scsi_qla_host_t *ha) { ha->isp_ops->intr_handler(0, ha); } which in-turn calls the ISP registered interrupt handler. This patch corrects it by disabling local interrupts during polling. Reviewed-by: Matthew Wilcox <willy@linux.intel.com> Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2008-05-13 07:21:14 +02:00
unsigned long flags;
local_irq_save(flags);
ha->isp_ops->intr_handler(0, ha);
[SCSI] qla2xxx: Disable local-interrupts while polling for RISC status. Matthew Wilcox <matthew@wil.cx> reported the following lockdep warning: > ================================= > [INFO:inconsistentlockstate] > 2.6.26-rc1-00115-g0340eda-dirty#60 > --------------------------------- > inconsistent{hardirq-on-W}->{in-hardirq-W}usage. > swapper/1[HC1[1]:SC0[0]:HE0:SE1]takes: > (&ha->hardware_lock){+-..},at:[<c035495d>]qla2300_intr_handler+0x35/0x1f5 > {hardirq-on-W}statewasregisteredat: > [<c0139a16>]__lock_acquire+0x459/0xb1d > [<c013a091>]__lock_acquire+0xad4/0xb1d > [<c013a142>]lock_acquire+0x68/0x82 > [<c035495d>]qla2300_intr_handler+0x35/0x1f5 > [<c0506da5>]_spin_lock+0x24/0x4d > [<c035495d>]qla2300_intr_handler+0x35/0x1f5 > [<c035495d>]qla2300_intr_handler+0x35/0x1f5 > [<c01391e4>]trace_hardirqs_on+0xe7/0x10e > [<c034f0a6>]qla2x00_mailbox_command+0x1c6/0x433 ... > other info that might help us debug this: > no locks held by swapper/1. > > stack backtrace: > Pid:1,comm:swapperNottainted2.6.26-rc1-00115-g0340eda-dirty#60 > [<c0138121>]print_usage_bug+0x100/0x10a > [<c0138d37>]mark_lock+0xaa/0x395 > [<c01399af>]__lock_acquire+0x3f2/0xb1d > [<c013a091>]__lock_acquire+0xad4/0xb1d > [<c013a142>]lock_acquire+0x68/0x82 > [<c035495d>]qla2300_intr_handler+0x35/0x1f5 > [<c0506da5>]_spin_lock+0x24/0x4d > [<c035495d>]qla2300_intr_handler+0x35/0x1f5 > [<c035495d>]qla2300_intr_handler+0x35/0x1f5 > [<c014a37b>]handle_IRQ_event+0x13/0x3d > [<c014b366>]handle_fasteoi_irq+0x76/0xab Which shows that lockdep is detecting the driver's interrupt-handler is run in both process and interrupt context with irqs-enabled in the former case. During init-time and error-recovery (after a RISC reset), the driver disables interrupts and 'polls' for completions by calling qla2x00_poll(): static inline void qla2x00_poll(scsi_qla_host_t *ha) { ha->isp_ops->intr_handler(0, ha); } which in-turn calls the ISP registered interrupt handler. This patch corrects it by disabling local interrupts during polling. Reviewed-by: Matthew Wilcox <willy@linux.intel.com> Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com> Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
2008-05-13 07:21:14 +02:00
local_irq_restore(flags);
}
static __inline__ scsi_qla_host_t *
to_qla_parent(scsi_qla_host_t *ha)
{
return ha->parent ? ha->parent : ha;
}
/**
* qla2x00_issue_marker() - Issue a Marker IOCB if necessary.
* @ha: HA context
* @ha_locked: is function called with the hardware lock
*
* Returns non-zero if a failure occured, else zero.
*/
static inline int
qla2x00_issue_marker(scsi_qla_host_t *ha, int ha_locked)
{
/* Send marker if required */
if (ha->marker_needed != 0) {
if (ha_locked) {
if (__qla2x00_marker(ha, 0, 0, MK_SYNC_ALL) !=
QLA_SUCCESS)
return (QLA_FUNCTION_FAILED);
} else {
if (qla2x00_marker(ha, 0, 0, MK_SYNC_ALL) !=
QLA_SUCCESS)
return (QLA_FUNCTION_FAILED);
}
ha->marker_needed = 0;
}
return (QLA_SUCCESS);
}
static inline uint8_t *
host_to_fcp_swap(uint8_t *fcp, uint32_t bsize)
{
uint32_t *ifcp = (uint32_t *) fcp;
uint32_t *ofcp = (uint32_t *) fcp;
uint32_t iter = bsize >> 2;
for (; iter ; iter--)
*ofcp++ = swab32(*ifcp++);
return fcp;
}
static inline int
qla2x00_is_reserved_id(scsi_qla_host_t *ha, uint16_t loop_id)
{
if (IS_FWI2_CAPABLE(ha))
return (loop_id > NPH_LAST_HANDLE);
return ((loop_id > ha->last_loop_id && loop_id < SNS_FIRST_LOOP_ID) ||
loop_id == MANAGEMENT_SERVER || loop_id == BROADCAST);
};