]> Git Repo - linux.git/commitdiff
Merge tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi
authorLinus Torvalds <[email protected]>
Wed, 2 Sep 2015 19:22:54 +0000 (12:22 -0700)
committerLinus Torvalds <[email protected]>
Wed, 2 Sep 2015 19:22:54 +0000 (12:22 -0700)
Pull first round of SCSI updates from James Bottomley:
 "This includes one new driver: cxlflash plus the usual grab bag of
  updates for the major drivers: qla2xxx, ipr, storvsc, pm80xx, hptiop,
  plus a few assorted fixes.

  There's another tranch coming, but I want to incubate it another few
  days in the checkers, plus it includes a mpt2sas separated lifetime
  fix, which Avago won't get done testing until Friday"

* tag 'scsi-misc' of git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi: (85 commits)
  aic94xx: set an error code on failure
  storvsc: Set the error code correctly in failure conditions
  storvsc: Allow write_same when host is windows 10
  storvsc: use storage protocol version to determine storage capabilities
  storvsc: use correct defaults for values determined by protocol negotiation
  storvsc: Untangle the storage protocol negotiation from the vmbus protocol negotiation.
  storvsc: Use a single value to track protocol versions
  storvsc: Rather than look for sets of specific protocol versions, make decisions based on ranges.
  cxlflash: Remove unused variable from queuecommand
  cxlflash: shift wrapping bug in afu_link_reset()
  cxlflash: off by one bug in cxlflash_show_port_status()
  cxlflash: Virtual LUN support
  cxlflash: Superpipe support
  cxlflash: Base error recovery support
  qla2xxx: Update driver version to 8.07.00.26-k
  qla2xxx: Add pci device id 0x2261.
  qla2xxx: Fix missing device login retries.
  qla2xxx: do not clear slot in outstanding cmd array
  qla2xxx: Remove decrement of sp reference count in abort handler.
  qla2xxx: Add support to show MPI and PEP FW version for ISP27xx.
  ...

15 files changed:
1  2 
Documentation/ioctl/ioctl-number.txt
MAINTAINERS
drivers/scsi/libfc/fc_fcp.c
drivers/scsi/qla2xxx/qla_attr.c
drivers/scsi/qla2xxx/qla_dbg.c
drivers/scsi/qla2xxx/qla_def.h
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_iocb.c
drivers/scsi/qla2xxx/qla_mbx.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/qla2xxx/qla_sup.c
drivers/scsi/qla2xxx/qla_target.c
drivers/scsi/qla2xxx/tcm_qla2xxx.c
drivers/scsi/scsi_error.c
drivers/scsi/scsi_transport_iscsi.c

index 141f847c76488b61c5ca05503c221a970a3f3396,9bd118d26a8abea8a8ce54eb4fece9412c3b1c9e..64df08db46577e4525cc20c37f8ddfbc4b4c4217
@@@ -124,8 -124,6 +124,8 @@@ Code  Seq#(hex)    Include File            Comment
  'H'   00-7F   linux/hiddev.h          conflict!
  'H'   00-0F   linux/hidraw.h          conflict!
  'H'   01      linux/mei.h             conflict!
 +'H'   02      linux/mei.h             conflict!
 +'H'   03      linux/mei.h             conflict!
  'H'   00-0F   sound/asound.h          conflict!
  'H'   20-40   sound/asound_fm.h       conflict!
  'H'   80-8F   sound/sfnt_info.h       conflict!
  0xB3  00      linux/mmc/ioctl.h
  0xC0  00-0F   linux/usb/iowarrior.h
  0xCA  00-0F   uapi/misc/cxl.h
+ 0xCA  80-8F   uapi/scsi/cxlflash_ioctl.h
  0xCB  00-1F   CBM serial IEC bus      in development:
                                        <mailto:[email protected]>
  0xCD  01      linux/reiserfs_fs.h
diff --combined MAINTAINERS
index 68760a91d399212c138a48010cc4587297d7e1ea,7a41c94d81dc10c628dcd0016a0e12ab6c028e10..4be7e5e7e9f9a879f7d07946df725200fe00e710
@@@ -361,11 -361,11 +361,11 @@@ S:      Supporte
  F:    drivers/input/touchscreen/ad7879.c
  
  ADDRESS SPACE LAYOUT RANDOMIZATION (ASLR)
 -M:    Jiri Kosina <j[email protected]>
 +M:    Jiri Kosina <j[email protected]>
  S:    Maintained
  
  ADM1025 HARDWARE MONITOR DRIVER
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/hwmon/adm1025
@@@ -430,7 -430,7 +430,7 @@@ S: Maintaine
  F:    drivers/macintosh/therm_adt746x.c
  
  ADT7475 HARDWARE MONITOR DRIVER
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/hwmon/adt7475
@@@ -445,7 -445,7 +445,7 @@@ F: drivers/input/misc/adxl34x.
  
  ADVANSYS SCSI DRIVER
  M:    Matthew Wilcox <[email protected]>
 -M:    Hannes Reinecke <hare@suse.de>
 +M:    Hannes Reinecke <hare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/scsi/advansys.txt
@@@ -506,7 -506,7 +506,7 @@@ F: drivers/scsi/aha152x
  F:    drivers/scsi/pcmcia/aha152x*
  
  AIC7XXX / AIC79XX SCSI DRIVER
 -M:    Hannes Reinecke <hare@suse.de>
 +M:    Hannes Reinecke <hare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    drivers/scsi/aic7xxx/
@@@ -556,12 -556,6 +556,12 @@@ S:       Maintaine
  F:    Documentation/i2c/busses/i2c-ali1563
  F:    drivers/i2c/busses/i2c-ali1563.c
  
 +ALLWINNER SECURITY SYSTEM
 +M:    Corentin Labbe <[email protected]>
 +L:    [email protected]
 +S:    Maintained
 +F:    drivers/crypto/sunxi-ss/
 +
  ALPHA PORT
  M:    Richard Henderson <[email protected]>
  M:    Ivan Kokshaysky <[email protected]>
@@@ -752,7 -746,7 +752,7 @@@ S: Maintaine
  F:    sound/aoa/
  
  APM DRIVER
 -M:    Jiri Kosina <j[email protected]>
 +M:    Jiri Kosina <j[email protected]>
  S:    Odd fixes
  F:    arch/x86/kernel/apm_32.c
  F:    include/linux/apm_bios.h
@@@ -1007,7 -1001,6 +1007,7 @@@ ARM/CONEXANT DIGICOLOR MACHINE SUPPOR
  M:    Baruch Siach <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
  S:    Maintained
 +F:    arch/arm/boot/dts/cx92755*
  N:    digicolor
  
  ARM/EBSA110 MACHINE SUPPORT
@@@ -1331,7 -1324,7 +1331,7 @@@ F:      arch/arm/mach-pxa/include/mach/palmt
  F:    arch/arm/mach-pxa/palmtc.c
  
  ARM/PALM TREO SUPPORT
 -M:    Tomas Cech <[email protected]z>
 +M:    Tomas Cech <[email protected]om>
  L:    [email protected]
  W:    http://hackndev.com
  S:    Maintained
@@@ -1471,7 -1464,9 +1471,7 @@@ F:      arch/arm/boot/dts/emev2
  F:    arch/arm/boot/dts/r7s*
  F:    arch/arm/boot/dts/r8a*
  F:    arch/arm/boot/dts/sh*
 -F:    arch/arm/configs/armadillo800eva_defconfig
  F:    arch/arm/configs/bockw_defconfig
 -F:    arch/arm/configs/kzm9g_defconfig
  F:    arch/arm/configs/marzen_defconfig
  F:    arch/arm/configs/shmobile_defconfig
  F:    arch/arm/include/debug/renesas-scif.S
@@@ -1583,10 -1578,7 +1583,10 @@@ ARM/UNIPHIER ARCHITECTUR
  M:    Masahiro Yamada <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
  S:    Maintained
 +F:    arch/arm/boot/dts/uniphier*
  F:    arch/arm/mach-uniphier/
 +F:    drivers/pinctrl/uniphier/
 +F:    drivers/tty/serial/8250/8250_uniphier.c
  N:    uniphier
  
  ARM/Ux500 ARM ARCHITECTURE
@@@ -1681,7 -1673,7 +1681,7 @@@ M:      Michal Simek <[email protected]
  R:    Sören Brinkmann <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
  W:    http://wiki.xilinx.com
 -T:    git git://git.xilinx.com/linux-xlnx.git
 +T:    git https://github.com/Xilinx/linux-xlnx.git
  S:    Supported
  F:    arch/arm/mach-zynq/
  F:    drivers/cpuidle/cpuidle-zynq.c
@@@ -2225,9 -2217,7 +2225,9 @@@ F:      drivers/clocksource/bcm_kona_timer.
  BROADCOM BCM2835 ARM ARCHITECTURE
  M:    Stephen Warren <[email protected]>
  M:    Lee Jones <[email protected]>
 +M:    Eric Anholt <[email protected]>
  L:    [email protected] (moderated for non-subscribers)
 +L:    [email protected] (moderated for non-subscribers)
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/rpi/linux-rpi.git
  S:    Maintained
  N:    bcm2835
@@@ -2415,7 -2405,7 +2415,7 @@@ F:      drivers/gpio/gpio-bt8xx.
  BTRFS FILE SYSTEM
  M:    Chris Mason <[email protected]>
  M:    Josef Bacik <[email protected]>
 -M:    David Sterba <[email protected]z>
 +M:    David Sterba <[email protected]om>
  L:    [email protected]
  W:    http://btrfs.wiki.kernel.org/
  Q:    http://patchwork.kernel.org/project/linux-btrfs/list/
@@@ -2758,7 -2748,7 +2758,7 @@@ COCCINELLE/Semantic Patches (SmPL
  M:    Julia Lawall <[email protected]>
  M:    Gilles Muller <[email protected]>
  M:    Nicolas Palix <[email protected]>
 -M:    Michal Marek <[email protected]z>
 +M:    Michal Marek <[email protected]om>
  L:    [email protected] (moderated for non-subscribers)
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild.git misc
  W:    http://coccinelle.lip6.fr/
@@@ -2874,7 -2864,7 +2874,7 @@@ F:      kernel/cpuset.
  
  CONTROL GROUP - MEMORY RESOURCE CONTROLLER (MEMCG)
  M:    Johannes Weiner <[email protected]>
 -M:    Michal Hocko <mhocko@suse.cz>
 +M:    Michal Hocko <mhocko@kernel.org>
  L:    [email protected]
  L:    [email protected]
  S:    Maintained
@@@ -2955,7 -2945,7 +2955,7 @@@ F:      arch/x86/kernel/cpuid.
  F:    arch/x86/kernel/msr.c
  
  CPU POWER MONITORING SUBSYSTEM
 -M:    Thomas Renninger <trenn@suse.de>
 +M:    Thomas Renninger <trenn@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    tools/power/cpupower/
@@@ -3185,7 -3175,7 +3185,7 @@@ F:      Documentation/networking/dmfe.tx
  F:    drivers/net/ethernet/dec/tulip/dmfe.c
  
  DC390/AM53C974 SCSI driver
 -M:    Hannes Reinecke <hare@suse.de>
 +M:    Hannes Reinecke <hare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    drivers/scsi/am53c974.c
@@@ -3389,7 -3379,7 +3389,7 @@@ W:      http://www.win.tue.nl/~aeb/partition
  S:    Maintained
  
  DISKQUOTA
 -M:    Jan Kara <[email protected]z>
 +M:    Jan Kara <[email protected]om>
  S:    Maintained
  F:    Documentation/filesystems/quota.txt
  F:    fs/quota/
@@@ -3445,7 -3435,7 +3445,7 @@@ F:      Documentation/hwmon/dme173
  F:    drivers/hwmon/dme1737.c
  
  DMI/SMBIOS SUPPORT
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  S:    Maintained
  T:    quilt http://jdelvare.nerim.net/devel/linux/jdelvare-dmi/
  F:    Documentation/ABI/testing/sysfs-firmware-dmi-tables
@@@ -3463,7 -3453,6 +3463,7 @@@ X:      Documentation/devicetree
  X:    Documentation/acpi
  X:    Documentation/power
  X:    Documentation/spi
 +X:    Documentation/DocBook/media
  T:    git git://git.lwn.net/linux-2.6.git docs-next
  
  DOUBLETALK DRIVER
@@@ -3597,15 -3586,6 +3597,15 @@@ S:    Maintaine
  F:    drivers/gpu/drm/rockchip/
  F:    Documentation/devicetree/bindings/video/rockchip*
  
 +DRM DRIVERS FOR STI
 +M:    Benjamin Gaignard <[email protected]>
 +M:    Vincent Abriou <[email protected]>
 +L:    [email protected]
 +T:    git http://git.linaro.org/people/benjamin.gaignard/kernel.git
 +S:    Maintained
 +F:    drivers/gpu/drm/sti
 +F:    Documentation/devicetree/bindings/gpu/st,stih4xx.txt
 +
  DSBR100 USB FM RADIO DRIVER
  M:    Alexey Klimov <[email protected]>
  L:    [email protected]
@@@ -4071,7 -4051,7 +4071,7 @@@ F:      drivers/of/of_mdio.
  F:    drivers/of/of_net.c
  
  EXT2 FILE SYSTEM
 -M:    Jan Kara <[email protected]z>
 +M:    Jan Kara <[email protected]om>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/filesystems/ext2.txt
@@@ -4079,7 -4059,7 +4079,7 @@@ F:      fs/ext2
  F:    include/linux/ext2*
  
  EXT3 FILE SYSTEM
 -M:    Jan Kara <[email protected]z>
 +M:    Jan Kara <[email protected]om>
  M:    Andrew Morton <[email protected]>
  M:    Andreas Dilger <[email protected]>
  L:    [email protected]
@@@ -4129,7 -4109,7 +4129,7 @@@ F:      drivers/video/fbdev/exynos/exynos_mi
  F:    include/video/exynos_mipi*
  
  F71805F HARDWARE MONITORING DRIVER
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/hwmon/f71805f
@@@ -4264,7 -4244,7 +4264,7 @@@ S:      Maintaine
  F:    drivers/block/rsxx/
  
  FLOPPY DRIVER
 -M:    Jiri Kosina <j[email protected]>
 +M:    Jiri Kosina <j[email protected]>
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/floppy.git
  S:    Odd fixes
  F:    drivers/block/floppy.c
@@@ -4685,7 -4665,7 +4685,7 @@@ F:      drivers/media/usb/stk1160
  
  H8/300 ARCHITECTURE
  M:    Yoshinori Sato <[email protected]>
 -L:    [email protected]
 +L:    [email protected] (moderated for non-subscribers)
  W:    http://uclinux-h8.sourceforge.jp
  T:    git git://git.sourceforge.jp/gitroot/uclinux-h8/linux.git
  S:    Maintained
@@@ -4732,7 -4712,7 +4732,7 @@@ S:      Maintaine
  F:    drivers/media/usb/hackrf/
  
  HARDWARE MONITORING
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  M:    Guenter Roeck <[email protected]>
  L:    [email protected]
  W:    http://www.lm-sensors.org/
@@@ -4835,7 -4815,7 +4835,7 @@@ F:      include/linux/pm.
  F:    arch/*/include/asm/suspend*.h
  
  HID CORE LAYER
 -M:    Jiri Kosina <j[email protected]>
 +M:    Jiri Kosina <j[email protected]>
  L:    [email protected]
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid.git
  S:    Maintained
@@@ -4844,7 -4824,7 +4844,7 @@@ F:      include/linux/hid
  F:    include/uapi/linux/hid*
  
  HID SENSOR HUB DRIVERS
 -M:    Jiri Kosina <j[email protected]>
 +M:    Jiri Kosina <j[email protected]>
  M:    Jonathan Cameron <[email protected]>
  M:    Srinivas Pandruvada <[email protected]>
  L:    [email protected]
@@@ -4976,10 -4956,9 +4976,10 @@@ F:    drivers/scsi/storvsc_drv.
  F:    drivers/video/fbdev/hyperv_fb.c
  F:    include/linux/hyperv.h
  F:    tools/hv/
 +F:    Documentation/ABI/stable/sysfs-bus-vmbus
  
  I2C OVER PARALLEL PORT
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/i2c/busses/i2c-parport
@@@ -4988,7 -4967,7 +4988,7 @@@ F:      drivers/i2c/busses/i2c-parport.
  F:    drivers/i2c/busses/i2c-parport-light.c
  
  I2C/SMBUS CONTROLLER DRIVERS FOR PC
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/i2c/busses/i2c-ali1535
@@@ -5029,7 -5008,7 +5029,7 @@@ F:      drivers/i2c/busses/i2c-ismt.
  F:    Documentation/i2c/busses/i2c-ismt
  
  I2C/SMBUS STUB DRIVER
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    drivers/i2c/i2c-stub.c
@@@ -5056,7 -5035,7 +5056,7 @@@ L:      [email protected]
  S:    Maintained
  
  I2C-TAOS-EVM DRIVER
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/i2c/busses/i2c-taos-evm
@@@ -5087,21 -5066,9 +5087,21 @@@ T:    git git://git.kernel.org/pub/scm/lin
  S:    Maintained
  F:    arch/ia64/
  
 +IBM Power VMX Cryptographic instructions
 +M:    Leonidas S. Barbosa <[email protected]>
 +M:    Paulo Flabiano Smorigo <[email protected]>
 +L:    [email protected]
 +S:    Supported
 +F:    drivers/crypto/vmx/Makefile
 +F:    drivers/crypto/vmx/Kconfig
 +F:    drivers/crypto/vmx/vmx.c
 +F:    drivers/crypto/vmx/aes*
 +F:    drivers/crypto/vmx/ghash*
 +F:    drivers/crypto/vmx/ppc-xlate.pl
 +
  IBM Power in-Nest Crypto Acceleration
 -M:    Marcelo Henrique Cerri <mhcerri@linux.vnet.ibm.com>
 -M:    Fionnuala Gunter <fin@linux.vnet.ibm.com>
 +M:    Leonidas S. Barbosa <leosilva@linux.vnet.ibm.com>
 +M:    Paulo Flabiano Smorigo <pfsmorigo@linux.vnet.ibm.com>
  L:    [email protected]
  S:    Supported
  F:    drivers/crypto/nx/Makefile
@@@ -5113,7 -5080,7 +5113,7 @@@ F:      drivers/crypto/nx/nx_csbcpb.
  F:    drivers/crypto/nx/nx_debugfs.h
  
  IBM Power 842 compression accelerator
 -M:    Dan Streetman <ddstreet@us.ibm.com>
 +M:    Dan Streetman <ddstreet@ieee.org>
  S:    Supported
  F:    drivers/crypto/nx/Makefile
  F:    drivers/crypto/nx/Kconfig
@@@ -5597,8 -5564,8 +5597,8 @@@ F:      include/uapi/linux/ip_vs.
  F:    net/netfilter/ipvs/
  
  IPWIRELESS DRIVER
 -M:    Jiri Kosina <j[email protected]>
 -M:    David Sterba <[email protected]z>
 +M:    Jiri Kosina <j[email protected]>
 +M:    David Sterba <[email protected]om>
  S:    Odd Fixes
  F:    drivers/tty/ipwireless/
  
@@@ -5632,7 -5599,6 +5632,7 @@@ F:      kernel/irq
  IRQCHIP DRIVERS
  M:    Thomas Gleixner <[email protected]>
  M:    Jason Cooper <[email protected]>
 +M:    Marc Zyngier <[email protected]>
  L:    [email protected]
  S:    Maintained
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core
@@@ -5641,14 -5607,11 +5641,14 @@@ F:   Documentation/devicetree/bindings/in
  F:    drivers/irqchip/
  
  IRQ DOMAINS (IRQ NUMBER MAPPING LIBRARY)
 -M:    Benjamin Herrenschmidt <[email protected]>
 +M:    Jiang Liu <[email protected]>
 +M:    Marc Zyngier <[email protected]>
  S:    Maintained
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq/core
  F:    Documentation/IRQ-domain.txt
  F:    include/linux/irqdomain.h
  F:    kernel/irq/irqdomain.c
 +F:    kernel/irq/msi.c
  
  ISAPNP
  M:    Jaroslav Kysela <[email protected]>
@@@ -5722,7 -5685,7 +5722,7 @@@ S:      Maintaine
  F:    drivers/isdn/hardware/eicon/
  
  IT87 HARDWARE MONITORING DRIVER
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/hwmon/it87
@@@ -5789,7 -5752,7 +5789,7 @@@ F:      include/uapi/linux/jffs2.
  
  JOURNALLING LAYER FOR BLOCK DEVICES (JBD)
  M:    Andrew Morton <[email protected]>
 -M:    Jan Kara <[email protected]z>
 +M:    Jan Kara <[email protected]om>
  L:    [email protected]
  S:    Maintained
  F:    fs/jbd/
@@@ -5853,7 -5816,7 +5853,7 @@@ S:      Maintaine
  F:    fs/autofs4/
  
  KERNEL BUILD + files below scripts/ (unless maintained elsewhere)
 -M:    Michal Marek <[email protected]z>
 +M:    Michal Marek <[email protected]om>
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild.git for-next
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/mmarek/kbuild.git rc-fixes
  L:    [email protected]
@@@ -5872,7 -5835,6 +5872,7 @@@ S:      Odd Fixe
  
  KERNEL NFSD, SUNRPC, AND LOCKD SERVERS
  M:    "J. Bruce Fields" <[email protected]>
 +M:    Jeff Layton <[email protected]>
  L:    [email protected]
  W:    http://nfs.sourceforge.net/
  S:    Supported
@@@ -5918,7 -5880,7 +5918,7 @@@ F:      arch/x86/include/asm/svm.
  F:    arch/x86/kvm/svm.c
  
  KERNEL VIRTUAL MACHINE (KVM) FOR POWERPC
 -M:    Alexander Graf <agraf@suse.de>
 +M:    Alexander Graf <agraf@suse.com>
  L:    [email protected]
  W:    http://kvm.qumranet.com
  T:    git git://github.com/agraf/linux-2.6.git
@@@ -5929,12 -5891,14 +5929,12 @@@ F:   arch/powerpc/kvm
  KERNEL VIRTUAL MACHINE for s390 (KVM/s390)
  M:    Christian Borntraeger <[email protected]>
  M:    Cornelia Huck <[email protected]>
 -M:    [email protected]
  L:    [email protected]
  W:    http://www.ibm.com/developerworks/linux/linux390/
  S:    Supported
  F:    Documentation/s390/kvm.txt
  F:    arch/s390/include/asm/kvm*
  F:    arch/s390/kvm/
 -F:    drivers/s390/kvm/
  
  KERNEL VIRTUAL MACHINE (KVM) FOR ARM
  M:    Christoffer Dall <[email protected]>
@@@ -6063,16 -6027,17 +6063,16 @@@ F:   Documentation/scsi/53c700.tx
  F:    drivers/scsi/53c700*
  
  LED SUBSYSTEM
 -M:    Bryan Wu <[email protected]>
  M:    Richard Purdie <[email protected]>
  M:    Jacek Anaszewski <[email protected]>
  L:    [email protected]
 -T:    git git://git.kernel.org/pub/scm/linux/kernel/git/cooloney/linux-leds.git
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/j.anaszewski/linux-leds.git
  S:    Maintained
  F:    drivers/leds/
  F:    include/linux/leds.h
  
  LEGACY EEPROM DRIVER
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  S:    Maintained
  F:    Documentation/misc-devices/eeprom
  F:    drivers/misc/eeprom/eeprom.c
@@@ -6125,7 -6090,7 +6125,7 @@@ F:      include/linux/ata.
  F:    include/linux/libata.h
  
  LIBATA PATA ARASAN COMPACT FLASH CONTROLLER
 -M:    Viresh Kumar <viresh[email protected]>
 +M:    Viresh Kumar <viresh[email protected]>
  L:    [email protected]
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata.git
  S:    Maintained
@@@ -6286,8 -6251,8 +6286,8 @@@ F:      drivers/platform/x86/hp_accel.
  LIVE PATCHING
  M:    Josh Poimboeuf <[email protected]>
  M:    Seth Jennings <[email protected]>
 -M:    Jiri Kosina <j[email protected]>
 -M:    Vojtech Pavlik <[email protected]z>
 +M:    Jiri Kosina <j[email protected]>
 +M:    Vojtech Pavlik <[email protected]om>
  S:    Maintained
  F:    kernel/livepatch/
  F:    include/linux/livepatch.h
@@@ -6313,21 -6278,21 +6313,21 @@@ S:   Maintaine
  F:    drivers/hwmon/lm73.c
  
  LM78 HARDWARE MONITOR DRIVER
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/hwmon/lm78
  F:    drivers/hwmon/lm78.c
  
  LM83 HARDWARE MONITOR DRIVER
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/hwmon/lm83
  F:    drivers/hwmon/lm83.c
  
  LM90 HARDWARE MONITOR DRIVER
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/hwmon/lm90
@@@ -6570,13 -6535,6 +6570,13 @@@ S:    Maintaine
  F:    Documentation/hwmon/max16065
  F:    drivers/hwmon/max16065.c
  
 +MAX20751 HARDWARE MONITOR DRIVER
 +M:    Guenter Roeck <[email protected]>
 +L:    [email protected]
 +S:    Maintained
 +F:    Documentation/hwmon/max20751
 +F:    drivers/hwmon/max20751.c
 +
  MAX6650 HARDWARE MONITOR AND FAN CONTROLLER DRIVER
  M:    "Hans J. Koch" <[email protected]>
  L:    [email protected]
@@@ -6721,7 -6679,6 +6721,7 @@@ M:      Johannes Thumshirn <morbidrsa@gmail.
  S:    Maintained
  F:    drivers/mcb/
  F:    include/linux/mcb.h
 +F:    Documentation/men-chameleon-bus.txt
  
  MEN F21BMC (Board Management Controller)
  M:    Andreas Werner <[email protected]>
@@@ -6881,12 -6838,6 +6881,12 @@@ T:    git git://linuxtv.org/anttip/media_t
  S:    Maintained
  F:    drivers/media/usb/msi2500/
  
 +MSYSTEMS DISKONCHIP G3 MTD DRIVER
 +M:    Robert Jarzmik <[email protected]>
 +L:    [email protected]
 +S:    Maintained
 +F:    drivers/mtd/devices/docg3*
 +
  MT9M032 APTINA SENSOR DRIVER
  M:    Laurent Pinchart <[email protected]>
  L:    [email protected]
@@@ -7068,7 -7019,6 +7068,7 @@@ F:      include/uapi/linux/netfilter
  F:    net/*/netfilter.c
  F:    net/*/netfilter/
  F:    net/netfilter/
 +F:    net/bridge/br_netfilter*.c
  
  NETLABEL
  M:    Paul Moore <[email protected]>
@@@ -7327,15 -7277,6 +7327,15 @@@ S:    Supporte
  F:    drivers/block/nvme*
  F:    include/linux/nvme.h
  
 +NVMEM FRAMEWORK
 +M:    Srinivas Kandagatla <[email protected]>
 +M:    Maxime Ripard <[email protected]>
 +S:    Maintained
 +F:    drivers/nvmem/
 +F:    Documentation/devicetree/bindings/nvmem/
 +F:    include/linux/nvmem-consumer.h
 +F:    include/linux/nvmem-provider.h
 +
  NXP-NCI NFC DRIVER
  M:    Clément Perrochaud <[email protected]>
  R:    Charles Gorand <[email protected]>
@@@ -7573,9 -7514,8 +7573,9 @@@ F:      Documentation/i2c/busses/i2c-ocore
  F:    drivers/i2c/busses/i2c-ocores.c
  
  OPEN FIRMWARE AND FLATTENED DEVICE TREE
 -M:    Grant Likely <[email protected]>
  M:    Rob Herring <[email protected]>
 +M:    Frank Rowand <[email protected]>
 +M:    Grant Likely <[email protected]>
  L:    [email protected]
  W:    http://www.devicetree.org/
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/glikely/linux.git
@@@ -7778,7 -7718,7 +7778,7 @@@ S:      Maintaine
  F:    drivers/char/pc8736x_gpio.c
  
  PC87427 HARDWARE MONITORING DRIVER
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/hwmon/pc87427
@@@ -8055,7 -7995,7 +8055,7 @@@ S:      Maintaine
  F:    drivers/pinctrl/samsung/
  
  PIN CONTROLLER - ST SPEAR
 -M:    Viresh Kumar <viresh[email protected]>
 +M:    Viresh Kumar <viresh[email protected]>
  L:    [email protected]
  L:    [email protected] (moderated for non-subscribers)
  W:    http://www.st.com/spear
@@@ -8063,7 -8003,7 +8063,7 @@@ S:      Maintaine
  F:    drivers/pinctrl/spear/
  
  PKTCDVD DRIVER
 -M:    Jiri Kosina <j[email protected]>
 +M:    Jiri Kosina <j[email protected]>
  S:    Maintained
  F:    drivers/block/pktcdvd.c
  F:    include/linux/pktcdvd.h
@@@ -8098,7 -8038,7 +8098,7 @@@ S:      Supporte
  F:    drivers/scsi/pmcraid.*
  
  PMC SIERRA PM8001 DRIVER
- M:    [email protected]
+ M:    Jack Wang <[email protected]>
  M:    [email protected]
  L:    [email protected]
  L:    [email protected]
@@@ -8123,7 -8063,6 +8123,7 @@@ T:      git git://git.infradead.org/battery-
  S:    Maintained
  F:    include/linux/power_supply.h
  F:    drivers/power/
 +X:    drivers/power/avs/
  
  PNP SUPPORT
  M:    "Rafael J. Wysocki" <[email protected]>
@@@ -8522,7 -8461,7 +8522,7 @@@ M:      "Paul E. McKenney" <[email protected]
  M:    Josh Triplett <[email protected]>
  R:    Steven Rostedt <[email protected]>
  R:    Mathieu Desnoyers <[email protected]>
 -R:    Lai Jiangshan <[email protected].com>
 +R:    Lai Jiangshan <jiangshanlai@gmail.com>
  L:    [email protected]
  S:    Supported
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/paulmck/linux-rcu.git
@@@ -8549,7 -8488,7 +8549,7 @@@ M:      "Paul E. McKenney" <[email protected]
  M:    Josh Triplett <[email protected]>
  R:    Steven Rostedt <[email protected]>
  R:    Mathieu Desnoyers <[email protected]>
 -R:    Lai Jiangshan <[email protected].com>
 +R:    Lai Jiangshan <jiangshanlai@gmail.com>
  L:    [email protected]
  W:    http://www.rdrop.com/users/paulmck/RCU/
  S:    Supported
@@@ -8614,7 -8553,6 +8614,7 @@@ M:      Philipp Zabel <[email protected]
  S:    Maintained
  F:    drivers/reset/
  F:    Documentation/devicetree/bindings/reset/
 +F:    include/dt-bindings/reset/
  F:    include/linux/reset.h
  F:    include/linux/reset-controller.h
  
@@@ -8749,6 -8687,7 +8749,6 @@@ F:      drivers/video/fbdev/savage
  S390
  M:    Martin Schwidefsky <[email protected]>
  M:    Heiko Carstens <[email protected]>
 -M:    [email protected]
  L:    [email protected]
  W:    http://www.ibm.com/developerworks/linux/linux390/
  S:    Supported
@@@ -8776,6 -8715,7 +8776,6 @@@ F:      block/partitions/ibm.
  
  S390 NETWORK DRIVERS
  M:    Ursula Braun <[email protected]>
 -M:    [email protected]
  L:    [email protected]
  W:    http://www.ibm.com/developerworks/linux/linux390/
  S:    Supported
@@@ -8792,6 -8732,7 +8792,6 @@@ F:      drivers/pci/hotplug/s390_pci_hpc.
  
  S390 ZCRYPT DRIVER
  M:    Ingo Tuchscherer <[email protected]>
 -M:    [email protected]
  L:    [email protected]
  W:    http://www.ibm.com/developerworks/linux/linux390/
  S:    Supported
@@@ -8799,6 -8740,7 +8799,6 @@@ F:      drivers/s390/crypto
  
  S390 ZFCP DRIVER
  M:    Steffen Maier <[email protected]>
 -M:    [email protected]
  L:    [email protected]
  W:    http://www.ibm.com/developerworks/linux/linux390/
  S:    Supported
@@@ -8806,6 -8748,7 +8806,6 @@@ F:      drivers/s390/scsi/zfcp_
  
  S390 IUCV NETWORK LAYER
  M:    Ursula Braun <[email protected]>
 -M:    [email protected]
  L:    [email protected]
  W:    http://www.ibm.com/developerworks/linux/linux390/
  S:    Supported
@@@ -8951,7 -8894,7 +8951,7 @@@ S:      Maintaine
  F:    drivers/tty/serial/
  
  SYNOPSYS DESIGNWARE DMAC DRIVER
 -M:    Viresh Kumar <viresh[email protected]>
 +M:    Viresh Kumar <viresh[email protected]>
  M:    Andy Shevchenko <[email protected]>
  S:    Maintained
  F:    include/linux/dma/dw.h
@@@ -9118,7 -9061,7 +9118,7 @@@ S:      Maintaine
  F:    drivers/mmc/host/sdhci-s3c*
  
  SECURE DIGITAL HOST CONTROLLER INTERFACE (SDHCI) ST SPEAR DRIVER
 -M:    Viresh Kumar <viresh[email protected]>
 +M:    Viresh Kumar <viresh[email protected]>
  L:    [email protected]
  L:    [email protected]
  S:    Maintained
@@@ -9374,15 -9317,6 +9374,15 @@@ S:    Maintaine
  F:    drivers/media/i2c/ov2659.c
  F:    include/media/ov2659.h
  
 +SILICON MOTION SM712 FRAME BUFFER DRIVER
 +M:    Sudip Mukherjee <[email protected]>
 +M:    Teddy Wang <[email protected]>
 +M:    Sudip Mukherjee <[email protected]>
 +L:    [email protected]
 +S:    Maintained
 +F:    drivers/video/fbdev/sm712*
 +F:    Documentation/fb/sm712fb.txt
 +
  SIS 190 ETHERNET DRIVER
  M:    Francois Romieu <[email protected]>
  L:    [email protected]
@@@ -9422,7 -9356,7 +9422,7 @@@ F:      include/linux/sl?b*.
  F:    mm/sl?b*
  
  SLEEPABLE READ-COPY UPDATE (SRCU)
 -M:    Lai Jiangshan <[email protected].com>
 +M:    Lai Jiangshan <jiangshanlai@gmail.com>
  M:    "Paul E. McKenney" <[email protected]>
  M:    Josh Triplett <[email protected]>
  R:    Steven Rostedt <[email protected]>
@@@ -9489,7 -9423,7 +9489,7 @@@ F:      Documentation/hwmon/sch562
  F:    drivers/hwmon/sch5627.c
  
  SMSC47B397 HARDWARE MONITOR DRIVER
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    Documentation/hwmon/smsc47b397
@@@ -9538,7 -9472,7 +9538,7 @@@ S:      Supporte
  F:    drivers/media/pci/solo6x10/
  
  SOFTWARE RAID (Multiple Disks) SUPPORT
 -M:    Neil Brown <neilb@suse.de>
 +M:    Neil Brown <neilb@suse.com>
  L:    [email protected]
  S:    Supported
  F:    drivers/md/
@@@ -9581,7 -9515,7 +9581,7 @@@ F:      drivers/memstick/core/ms_block.
  
  SOUND
  M:    Jaroslav Kysela <[email protected]>
 -M:    Takashi Iwai <tiwai@suse.de>
 +M:    Takashi Iwai <tiwai@suse.com>
  L:    [email protected] (moderated for non-subscribers)
  W:    http://www.alsa-project.org/
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound.git
@@@ -9665,7 -9599,7 +9665,7 @@@ S:      Maintaine
  F:    include/linux/compiler.h
  
  SPEAR PLATFORM SUPPORT
 -M:    Viresh Kumar <viresh[email protected]>
 +M:    Viresh Kumar <viresh[email protected]>
  M:    Shiraz Hashim <[email protected]>
  L:    [email protected]
  L:    [email protected] (moderated for non-subscribers)
@@@ -9674,7 -9608,7 +9674,7 @@@ S:      Maintaine
  F:    arch/arm/mach-spear/
  
  SPEAR CLOCK FRAMEWORK SUPPORT
 -M:    Viresh Kumar <viresh[email protected]>
 +M:    Viresh Kumar <viresh[email protected]>
  L:    [email protected]
  L:    [email protected] (moderated for non-subscribers)
  W:    http://www.st.com/spear
@@@ -9780,6 -9714,11 +9780,6 @@@ W:     http://wiki.laptop.org/go/DCO
  S:    Maintained
  F:    drivers/staging/olpc_dcon/
  
 -STAGING - OZMO DEVICES USB OVER WIFI DRIVER
 -M:    Shigekatsu Tateno <[email protected]>
 -S:    Maintained
 -F:    drivers/staging/ozwpan/
 -
  STAGING - PARALLEL LCD/KEYPAD PANEL DRIVER
  M:    Willy Tarreau <[email protected]>
  S:    Odd Fixes
  S:    Maintained
  F:    drivers/staging/rtl8723au/
  
 -STAGING - SILICON MOTION SM7XX FRAME BUFFER DRIVER
 -M:    Sudip Mukherjee <[email protected]>
 -M:    Teddy Wang <[email protected]>
 -M:    Sudip Mukherjee <[email protected]>
 -L:    [email protected]
 -S:    Maintained
 -F:    drivers/staging/sm7xxfb/
 -
  STAGING - SILICON MOTION SM750 FRAME BUFFER DRIVER
  M:    Sudip Mukherjee <[email protected]>
  M:    Teddy Wang <[email protected]>
@@@ -9916,9 -9863,8 +9916,9 @@@ SYNOPSYS ARC ARCHITECTUR
  M:    Vineet Gupta <[email protected]>
  S:    Supported
  F:    arch/arc/
 -F:    Documentation/devicetree/bindings/arc/
 +F:    Documentation/devicetree/bindings/arc/*
  F:    drivers/tty/serial/arc_uart.c
 +T:    git git://git.kernel.org/pub/scm/linux/kernel/git/vgupta/arc.git
  
  SYNOPSYS ARC SDP platform support
  M:    Alexey Brodkin <[email protected]>
@@@ -10452,7 -10398,7 +10452,7 @@@ K:   ^Subject:.*(?i)trivia
  
  TTY LAYER
  M:    Greg Kroah-Hartman <[email protected]>
 -M:    Jiri Slaby <[email protected]z>
 +M:    Jiri Slaby <[email protected]om>
  S:    Supported
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/tty.git
  F:    Documentation/serial/
@@@ -10526,7 -10472,7 +10526,7 @@@ F:   arch/m68k/*/*_no.
  F:    arch/m68k/include/asm/*_no.*
  
  UDF FILESYSTEM
 -M:    Jan Kara <[email protected]z>
 +M:    Jan Kara <[email protected]om>
  S:    Maintained
  F:    Documentation/filesystems/udf.txt
  F:    fs/udf/
@@@ -10669,7 -10615,7 +10669,7 @@@ F:   drivers/usb/gadget
  F:    include/linux/usb/gadget*
  
  USB HID/HIDBP DRIVERS (USB KEYBOARDS, MICE, REMOTE CONTROLS, ...)
 -M:    Jiri Kosina <j[email protected]>
 +M:    Jiri Kosina <j[email protected]>
  L:    [email protected]
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/jikos/hid.git
  S:    Maintained
@@@ -10794,7 -10740,7 +10794,7 @@@ S:   Maintaine
  F:    drivers/usb/host/uhci*
  
  USB "USBNET" DRIVER FRAMEWORK
 -M:    Oliver Neukum <oneukum@suse.de>
 +M:    Oliver Neukum <oneukum@suse.com>
  L:    [email protected]
  W:    http://www.linux-usb.org/usbnet
  S:    Maintained
@@@ -10948,15 -10894,6 +10948,15 @@@ F: drivers/block/virtio_blk.
  F:    include/linux/virtio_*.h
  F:    include/uapi/linux/virtio_*.h
  
 +VIRTIO DRIVERS FOR S390
 +M:    Christian Borntraeger <[email protected]>
 +M:    Cornelia Huck <[email protected]>
 +L:    [email protected]
 +L:    [email protected]
 +L:    [email protected]
 +S:    Supported
 +F:    drivers/s390/virtio/
 +
  VIRTIO GPU DRIVER
  M:    David Airlie <[email protected]>
  M:    Gerd Hoffmann <[email protected]>
@@@ -11130,7 -11067,7 +11130,7 @@@ F:   Documentation/hwmon/w8379
  F:    drivers/hwmon/w83793.c
  
  W83795 HARDWARE MONITORING DRIVER
 -M:    Jean Delvare <jdelvare@suse.de>
 +M:    Jean Delvare <jdelvare@suse.com>
  L:    [email protected]
  S:    Maintained
  F:    drivers/hwmon/w83795.c
@@@ -11244,7 -11181,6 +11244,7 @@@ F:   sound/soc/codecs/wm
  
  WORKQUEUE
  M:    Tejun Heo <[email protected]>
 +R:    Lai Jiangshan <[email protected]>
  T:    git git://git.kernel.org/pub/scm/linux/kernel/git/tj/wq.git
  S:    Maintained
  F:    include/linux/workqueue.h
index 2d5909c4685ca63375f5041d960effada171f5fc,4cd49d4f44de1601c3da8b770c206910eae3f80e..5121272f28fd8190b6e599ee9f405504cfa48e8f
@@@ -191,7 -191,7 +191,7 @@@ static void fc_fcp_pkt_hold(struct fc_f
  }
  
  /**
-  * fc_fcp_pkt_destory() - Release hold on a fcp_pkt
+  * fc_fcp_pkt_destroy() - Release hold on a fcp_pkt
   * @seq: The sequence that the FCP packet is on (required by destructor API)
   * @fsp: The FCP packet to be released
   *
@@@ -1039,26 -1039,11 +1039,26 @@@ restart
                fc_fcp_pkt_hold(fsp);
                spin_unlock_irqrestore(&si->scsi_queue_lock, flags);
  
 -              if (!fc_fcp_lock_pkt(fsp)) {
 +              spin_lock_bh(&fsp->scsi_pkt_lock);
 +              if (!(fsp->state & FC_SRB_COMPL)) {
 +                      fsp->state |= FC_SRB_COMPL;
 +                      /*
 +                       * TODO: dropping scsi_pkt_lock and then reacquiring
 +                       * again around fc_fcp_cleanup_cmd() is required,
 +                       * since fc_fcp_cleanup_cmd() calls into
 +                       * fc_seq_set_resp() and that func preempts cpu using
 +                       * schedule. May be schedule and related code should be
 +                       * removed instead of unlocking here to avoid scheduling
 +                       * while atomic bug.
 +                       */
 +                      spin_unlock_bh(&fsp->scsi_pkt_lock);
 +
                        fc_fcp_cleanup_cmd(fsp, error);
 +
 +                      spin_lock_bh(&fsp->scsi_pkt_lock);
                        fc_io_compl(fsp);
 -                      fc_fcp_unlock_pkt(fsp);
                }
 +              spin_unlock_bh(&fsp->scsi_pkt_lock);
  
                fc_fcp_pkt_release(fsp);
                spin_lock_irqsave(&si->scsi_queue_lock, flags);
index 437254e1c4dee0c9972ff723ad31575911002993,b352d234b70a336d50e095b3b0fa90584883c408..6b942d9e5b74f2709b39e458885c5abf2b72ef84
@@@ -738,7 -738,7 +738,7 @@@ qla2x00_sysfs_write_reset(struct file *
                ql_log(ql_log_info, vha, 0x706f,
                    "Issuing MPI reset.\n");
  
 -              if (IS_QLA83XX(ha)) {
 +              if (IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
                        uint32_t idc_control;
  
                        qla83xx_idc_lock(vha, 0);
@@@ -884,7 -884,6 +884,6 @@@ qla2x00_sysfs_read_dcbx_tlv(struct fil
            struct device, kobj)));
        struct qla_hw_data *ha = vha->hw;
        int rval;
-       uint16_t actual_size;
  
        if (!capable(CAP_SYS_ADMIN) || off != 0 || count > DCBX_TLV_DATA_SIZE)
                return 0;
        }
  
  do_read:
-       actual_size = 0;
        memset(ha->dcbx_tlv, 0, DCBX_TLV_DATA_SIZE);
  
        rval = qla2x00_get_dcbx_params(vha, ha->dcbx_tlv_dma,
@@@ -1079,8 -1077,7 +1077,7 @@@ qla2x00_model_desc_show(struct device *
                        char *buf)
  {
        scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
-       return scnprintf(buf, PAGE_SIZE, "%s\n",
-           vha->hw->model_desc ? vha->hw->model_desc : "");
+       return scnprintf(buf, PAGE_SIZE, "%s\n", vha->hw->model_desc);
  }
  
  static ssize_t
@@@ -1348,7 -1345,8 +1345,8 @@@ qla2x00_mpi_version_show(struct device 
        scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
        struct qla_hw_data *ha = vha->hw;
  
-       if (!IS_QLA81XX(ha) && !IS_QLA8031(ha) && !IS_QLA8044(ha))
+       if (!IS_QLA81XX(ha) && !IS_QLA8031(ha) && !IS_QLA8044(ha) &&
+           !IS_QLA27XX(ha))
                return scnprintf(buf, PAGE_SIZE, "\n");
  
        return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d (%x)\n",
@@@ -1537,6 -1535,20 +1535,20 @@@ qla2x00_allow_cna_fw_dump_store(struct 
        return strlen(buf);
  }
  
+ static ssize_t
+ qla2x00_pep_version_show(struct device *dev, struct device_attribute *attr,
+       char *buf)
+ {
+       scsi_qla_host_t *vha = shost_priv(class_to_shost(dev));
+       struct qla_hw_data *ha = vha->hw;
+       if (!IS_QLA27XX(ha))
+               return scnprintf(buf, PAGE_SIZE, "\n");
+       return scnprintf(buf, PAGE_SIZE, "%d.%02d.%02d\n",
+           ha->pep_version[0], ha->pep_version[1], ha->pep_version[2]);
+ }
  static DEVICE_ATTR(driver_version, S_IRUGO, qla2x00_drvr_version_show, NULL);
  static DEVICE_ATTR(fw_version, S_IRUGO, qla2x00_fw_version_show, NULL);
  static DEVICE_ATTR(serial_num, S_IRUGO, qla2x00_serial_num_show, NULL);
@@@ -1581,6 -1593,7 +1593,7 @@@ static DEVICE_ATTR(fw_dump_size, S_IRUG
  static DEVICE_ATTR(allow_cna_fw_dump, S_IRUGO | S_IWUSR,
                   qla2x00_allow_cna_fw_dump_show,
                   qla2x00_allow_cna_fw_dump_store);
+ static DEVICE_ATTR(pep_version, S_IRUGO, qla2x00_pep_version_show, NULL);
  
  struct device_attribute *qla2x00_host_attrs[] = {
        &dev_attr_driver_version,
        &dev_attr_diag_megabytes,
        &dev_attr_fw_dump_size,
        &dev_attr_allow_cna_fw_dump,
+       &dev_attr_pep_version,
        NULL,
  };
  
index 8b011aef12bd5ec6e72f5d7a57bfa2285ae64404,c6e51c6cd3dca4cf1a813d3db476875964af4ca3..34dc9a35670b9b1cb458bef2e20128370704ff33
   * | Device Discovery             |       0x2016       | 0x2020-0x2022, |
   * |                              |                    | 0x2011-0x2012, |
   * |                              |                    | 0x2099-0x20a4  |
-  * | Queue Command and IO tracing |       0x3059       | 0x300b         |
+  * | Queue Command and IO tracing |       0x3075       | 0x300b         |
   * |                              |                    | 0x3027-0x3028  |
   * |                              |                    | 0x303d-0x3041  |
   * |                              |                    | 0x302d,0x3033  |
   * |                              |                    | 0x3036,0x3038  |
   * |                              |                    | 0x303a               |
   * | DPC Thread                   |       0x4023       | 0x4002,0x4013  |
-  * | Async Events                 |       0x5087       | 0x502b-0x502f  |
+  * | Async Events                 |       0x508a       | 0x502b-0x502f  |
   * |                              |                    | 0x5047               |
   * |                              |                    | 0x5084,0x5075        |
   * |                              |                    | 0x503d,0x5044  |
   * |                              |                    | 0xd031-0xd0ff        |
   * |                              |                    | 0xd101-0xd1fe        |
   * |                              |                    | 0xd214-0xd2fe        |
 - * | Target Mode                |       0xe079       |                |
 - * | Target Mode Management     |       0xf072       | 0xf002         |
 + * | Target Mode                |       0xe080       |                |
 + * | Target Mode Management     |       0xf096       | 0xf002         |
   * |                              |                    | 0xf046-0xf049  |
 - * | Target Mode Task Management  |     0x1000b      |                |
 + * | Target Mode Task Management  |     0x1000d      |                |
   * ----------------------------------------------------------------------
   */
  
@@@ -117,7 -117,7 +117,7 @@@ qla27xx_dump_mpi_ram(struct qla_hw_dat
  {
        int rval;
        uint32_t cnt, stat, timer, dwords, idx;
-       uint16_t mb0, mb1;
+       uint16_t mb0;
        struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
        dma_addr_t dump_dma = ha->gid_list_dma;
        uint32_t *dump = (uint32_t *)ha->gid_list;
                                            &ha->mbx_cmd_flags);
  
                                        mb0 = RD_REG_WORD(&reg->mailbox0);
-                                       mb1 = RD_REG_WORD(&reg->mailbox1);
+                                       RD_REG_WORD(&reg->mailbox1);
  
                                        WRT_REG_DWORD(&reg->hccr,
                                            HCCRX_CLR_RISC_INT);
@@@ -486,7 -486,7 +486,7 @@@ qla25xx_copy_fce(struct qla_hw_data *ha
                return ptr;
  
        *last_chain = &fcec->type;
-       fcec->type = __constant_htonl(DUMP_CHAIN_FCE);
+       fcec->type = htonl(DUMP_CHAIN_FCE);
        fcec->chain_size = htonl(sizeof(struct qla2xxx_fce_chain) +
            fce_calc_size(ha->fce_bufs));
        fcec->size = htonl(fce_calc_size(ha->fce_bufs));
@@@ -527,7 -527,7 +527,7 @@@ qla2xxx_copy_atioqueues(struct qla_hw_d
                /* aqp = ha->atio_q_map[que]; */
                q = ptr;
                *last_chain = &q->type;
-               q->type = __constant_htonl(DUMP_CHAIN_QUEUE);
+               q->type = htonl(DUMP_CHAIN_QUEUE);
                q->chain_size = htonl(
                    sizeof(struct qla2xxx_mqueue_chain) +
                    sizeof(struct qla2xxx_mqueue_header) +
  
                /* Add header. */
                qh = ptr;
-               qh->queue = __constant_htonl(TYPE_ATIO_QUEUE);
+               qh->queue = htonl(TYPE_ATIO_QUEUE);
                qh->number = htonl(que);
                qh->size = htonl(aqp->length * sizeof(request_t));
                ptr += sizeof(struct qla2xxx_mqueue_header);
@@@ -571,7 -571,7 +571,7 @@@ qla25xx_copy_mqueues(struct qla_hw_dat
                /* Add chain. */
                q = ptr;
                *last_chain = &q->type;
-               q->type = __constant_htonl(DUMP_CHAIN_QUEUE);
+               q->type = htonl(DUMP_CHAIN_QUEUE);
                q->chain_size = htonl(
                    sizeof(struct qla2xxx_mqueue_chain) +
                    sizeof(struct qla2xxx_mqueue_header) +
  
                /* Add header. */
                qh = ptr;
-               qh->queue = __constant_htonl(TYPE_REQUEST_QUEUE);
+               qh->queue = htonl(TYPE_REQUEST_QUEUE);
                qh->number = htonl(que);
                qh->size = htonl(req->length * sizeof(request_t));
                ptr += sizeof(struct qla2xxx_mqueue_header);
                /* Add chain. */
                q = ptr;
                *last_chain = &q->type;
-               q->type = __constant_htonl(DUMP_CHAIN_QUEUE);
+               q->type = htonl(DUMP_CHAIN_QUEUE);
                q->chain_size = htonl(
                    sizeof(struct qla2xxx_mqueue_chain) +
                    sizeof(struct qla2xxx_mqueue_header) +
  
                /* Add header. */
                qh = ptr;
-               qh->queue = __constant_htonl(TYPE_RESPONSE_QUEUE);
+               qh->queue = htonl(TYPE_RESPONSE_QUEUE);
                qh->number = htonl(que);
                qh->size = htonl(rsp->length * sizeof(response_t));
                ptr += sizeof(struct qla2xxx_mqueue_header);
@@@ -627,15 -627,15 +627,15 @@@ qla25xx_copy_mq(struct qla_hw_data *ha
        uint32_t cnt, que_idx;
        uint8_t que_cnt;
        struct qla2xxx_mq_chain *mq = ptr;
-       device_reg_t __iomem *reg;
+       device_reg_t *reg;
  
        if (!ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha))
                return ptr;
  
        mq = ptr;
        *last_chain = &mq->type;
-       mq->type = __constant_htonl(DUMP_CHAIN_MQ);
-       mq->chain_size = __constant_htonl(sizeof(struct qla2xxx_mq_chain));
+       mq->type = htonl(DUMP_CHAIN_MQ);
+       mq->chain_size = htonl(sizeof(struct qla2xxx_mq_chain));
  
        que_cnt = ha->max_req_queues > ha->max_rsp_queues ?
                ha->max_req_queues : ha->max_rsp_queues;
@@@ -695,8 -695,10 +695,10 @@@ qla2300_fw_dump(scsi_qla_host_t *vha, i
  
        flags = 0;
  
+ #ifndef __CHECKER__
        if (!hardware_locked)
                spin_lock_irqsave(&ha->hardware_lock, flags);
+ #endif
  
        if (!ha->fw_dump) {
                ql_log(ql_log_warn, vha, 0xd002,
        qla2xxx_dump_post_process(base_vha, rval);
  
  qla2300_fw_dump_failed:
+ #ifndef __CHECKER__
        if (!hardware_locked)
                spin_unlock_irqrestore(&ha->hardware_lock, flags);
+ #else
+       ;
+ #endif
  }
  
  /**
@@@ -859,8 -865,10 +865,10 @@@ qla2100_fw_dump(scsi_qla_host_t *vha, i
        mb0 = mb2 = 0;
        flags = 0;
  
+ #ifndef __CHECKER__
        if (!hardware_locked)
                spin_lock_irqsave(&ha->hardware_lock, flags);
+ #endif
  
        if (!ha->fw_dump) {
                ql_log(ql_log_warn, vha, 0xd004,
        qla2xxx_dump_post_process(base_vha, rval);
  
  qla2100_fw_dump_failed:
+ #ifndef __CHECKER__
        if (!hardware_locked)
                spin_unlock_irqrestore(&ha->hardware_lock, flags);
+ #else
+       ;
+ #endif
  }
  
  void
@@@ -1039,7 -1051,6 +1051,6 @@@ qla24xx_fw_dump(scsi_qla_host_t *vha, i
  {
        int             rval;
        uint32_t        cnt;
-       uint32_t        risc_address;
        struct qla_hw_data *ha = vha->hw;
        struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
        uint32_t __iomem *dmp_reg;
        uint16_t __iomem *mbx_reg;
        unsigned long   flags;
        struct qla24xx_fw_dump *fw;
-       uint32_t        ext_mem_cnt;
        void            *nxt;
        void            *nxt_chain;
        uint32_t        *last_chain = NULL;
        if (IS_P3P_TYPE(ha))
                return;
  
-       risc_address = ext_mem_cnt = 0;
        flags = 0;
        ha->fw_dump_cap_flags = 0;
  
+ #ifndef __CHECKER__
        if (!hardware_locked)
                spin_lock_irqsave(&ha->hardware_lock, flags);
+ #endif
  
        if (!ha->fw_dump) {
                ql_log(ql_log_warn, vha, 0xd006,
        nxt_chain = (void *)ha->fw_dump + ha->chain_offset;
        nxt_chain = qla2xxx_copy_atioqueues(ha, nxt_chain, &last_chain);
        if (last_chain) {
-               ha->fw_dump->version |= __constant_htonl(DUMP_CHAIN_VARIANT);
-               *last_chain |= __constant_htonl(DUMP_CHAIN_LAST);
+               ha->fw_dump->version |= htonl(DUMP_CHAIN_VARIANT);
+               *last_chain |= htonl(DUMP_CHAIN_LAST);
        }
  
        /* Adjust valid length. */
@@@ -1285,8 -1296,12 +1296,12 @@@ qla24xx_fw_dump_failed_0
        qla2xxx_dump_post_process(base_vha, rval);
  
  qla24xx_fw_dump_failed:
+ #ifndef __CHECKER__
        if (!hardware_locked)
                spin_unlock_irqrestore(&ha->hardware_lock, flags);
+ #else
+       ;
+ #endif
  }
  
  void
@@@ -1294,7 -1309,6 +1309,6 @@@ qla25xx_fw_dump(scsi_qla_host_t *vha, i
  {
        int             rval;
        uint32_t        cnt;
-       uint32_t        risc_address;
        struct qla_hw_data *ha = vha->hw;
        struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
        uint32_t __iomem *dmp_reg;
        uint16_t __iomem *mbx_reg;
        unsigned long   flags;
        struct qla25xx_fw_dump *fw;
-       uint32_t        ext_mem_cnt;
        void            *nxt, *nxt_chain;
        uint32_t        *last_chain = NULL;
        struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
  
-       risc_address = ext_mem_cnt = 0;
        flags = 0;
        ha->fw_dump_cap_flags = 0;
  
+ #ifndef __CHECKER__
        if (!hardware_locked)
                spin_lock_irqsave(&ha->hardware_lock, flags);
+ #endif
  
        if (!ha->fw_dump) {
                ql_log(ql_log_warn, vha, 0xd008,
        }
        fw = &ha->fw_dump->isp.isp25;
        qla2xxx_prep_dump(ha, ha->fw_dump);
-       ha->fw_dump->version = __constant_htonl(2);
+       ha->fw_dump->version = htonl(2);
  
        fw->host_status = htonl(RD_REG_DWORD(&reg->host_status));
  
        nxt_chain = qla25xx_copy_mqueues(ha, nxt_chain, &last_chain);
        nxt_chain = qla2xxx_copy_atioqueues(ha, nxt_chain, &last_chain);
        if (last_chain) {
-               ha->fw_dump->version |= __constant_htonl(DUMP_CHAIN_VARIANT);
-               *last_chain |= __constant_htonl(DUMP_CHAIN_LAST);
+               ha->fw_dump->version |= htonl(DUMP_CHAIN_VARIANT);
+               *last_chain |= htonl(DUMP_CHAIN_LAST);
        }
  
        /* Adjust valid length. */
@@@ -1604,8 -1618,12 +1618,12 @@@ qla25xx_fw_dump_failed_0
        qla2xxx_dump_post_process(base_vha, rval);
  
  qla25xx_fw_dump_failed:
+ #ifndef __CHECKER__
        if (!hardware_locked)
                spin_unlock_irqrestore(&ha->hardware_lock, flags);
+ #else
+       ;
+ #endif
  }
  
  void
@@@ -1613,7 -1631,6 +1631,6 @@@ qla81xx_fw_dump(scsi_qla_host_t *vha, i
  {
        int             rval;
        uint32_t        cnt;
-       uint32_t        risc_address;
        struct qla_hw_data *ha = vha->hw;
        struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
        uint32_t __iomem *dmp_reg;
        uint16_t __iomem *mbx_reg;
        unsigned long   flags;
        struct qla81xx_fw_dump *fw;
-       uint32_t        ext_mem_cnt;
        void            *nxt, *nxt_chain;
        uint32_t        *last_chain = NULL;
        struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
  
-       risc_address = ext_mem_cnt = 0;
        flags = 0;
        ha->fw_dump_cap_flags = 0;
  
+ #ifndef __CHECKER__
        if (!hardware_locked)
                spin_lock_irqsave(&ha->hardware_lock, flags);
+ #endif
  
        if (!ha->fw_dump) {
                ql_log(ql_log_warn, vha, 0xd00a,
        nxt_chain = qla25xx_copy_mqueues(ha, nxt_chain, &last_chain);
        nxt_chain = qla2xxx_copy_atioqueues(ha, nxt_chain, &last_chain);
        if (last_chain) {
-               ha->fw_dump->version |= __constant_htonl(DUMP_CHAIN_VARIANT);
-               *last_chain |= __constant_htonl(DUMP_CHAIN_LAST);
+               ha->fw_dump->version |= htonl(DUMP_CHAIN_VARIANT);
+               *last_chain |= htonl(DUMP_CHAIN_LAST);
        }
  
        /* Adjust valid length. */
@@@ -1925,16 -1942,19 +1942,19 @@@ qla81xx_fw_dump_failed_0
        qla2xxx_dump_post_process(base_vha, rval);
  
  qla81xx_fw_dump_failed:
+ #ifndef __CHECKER__
        if (!hardware_locked)
                spin_unlock_irqrestore(&ha->hardware_lock, flags);
+ #else
+       ;
+ #endif
  }
  
  void
  qla83xx_fw_dump(scsi_qla_host_t *vha, int hardware_locked)
  {
        int             rval;
-       uint32_t        cnt, reg_data;
-       uint32_t        risc_address;
+       uint32_t        cnt;
        struct qla_hw_data *ha = vha->hw;
        struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
        uint32_t __iomem *dmp_reg;
        uint16_t __iomem *mbx_reg;
        unsigned long   flags;
        struct qla83xx_fw_dump *fw;
-       uint32_t        ext_mem_cnt;
        void            *nxt, *nxt_chain;
        uint32_t        *last_chain = NULL;
        struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
  
-       risc_address = ext_mem_cnt = 0;
        flags = 0;
        ha->fw_dump_cap_flags = 0;
  
+ #ifndef __CHECKER__
        if (!hardware_locked)
                spin_lock_irqsave(&ha->hardware_lock, flags);
+ #endif
  
        if (!ha->fw_dump) {
                ql_log(ql_log_warn, vha, 0xd00c,
  
        WRT_REG_DWORD(&reg->iobase_addr, 0x6000);
        dmp_reg = &reg->iobase_window;
-       reg_data = RD_REG_DWORD(dmp_reg);
+       RD_REG_DWORD(dmp_reg);
        WRT_REG_DWORD(dmp_reg, 0);
  
        dmp_reg = &reg->unused_4_1[0];
-       reg_data = RD_REG_DWORD(dmp_reg);
+       RD_REG_DWORD(dmp_reg);
        WRT_REG_DWORD(dmp_reg, 0);
  
        WRT_REG_DWORD(&reg->iobase_addr, 0x6010);
        dmp_reg = &reg->unused_4_1[2];
-       reg_data = RD_REG_DWORD(dmp_reg);
+       RD_REG_DWORD(dmp_reg);
        WRT_REG_DWORD(dmp_reg, 0);
  
        /* select PCR and disable ecc checking and correction */
@@@ -2420,8 -2440,8 +2440,8 @@@ copy_queue
        nxt_chain = qla25xx_copy_mqueues(ha, nxt_chain, &last_chain);
        nxt_chain = qla2xxx_copy_atioqueues(ha, nxt_chain, &last_chain);
        if (last_chain) {
-               ha->fw_dump->version |= __constant_htonl(DUMP_CHAIN_VARIANT);
-               *last_chain |= __constant_htonl(DUMP_CHAIN_LAST);
+               ha->fw_dump->version |= htonl(DUMP_CHAIN_VARIANT);
+               *last_chain |= htonl(DUMP_CHAIN_LAST);
        }
  
        /* Adjust valid length. */
@@@ -2431,8 -2451,12 +2451,12 @@@ qla83xx_fw_dump_failed_0
        qla2xxx_dump_post_process(base_vha, rval);
  
  qla83xx_fw_dump_failed:
+ #ifndef __CHECKER__
        if (!hardware_locked)
                spin_unlock_irqrestore(&ha->hardware_lock, flags);
+ #else
+       ;
+ #endif
  }
  
  /****************************************************************************/
index 9ad819edcd67af2c73ca5a0a85a8863398b3c6f7,a72b29f4dd79d944ee08d194bfd1fd4586f3005c..388d79088b5990a13705bd66f60663d884cc828c
  #define RESPONSE_ENTRY_CNT_FX00               256     /* Number of response entries.*/
  
  struct req_que;
 +struct qla_tgt_sess;
  
  /*
   * (sd.h is not exported, hence local inclusion)
@@@ -2027,7 -2026,6 +2027,7 @@@ typedef struct fc_port 
        uint16_t port_id;
  
        unsigned long retry_delay_timestamp;
 +      struct qla_tgt_sess *tgt_session;
  } fc_port_t;
  
  #include "qla_mr.h"
@@@ -3061,6 -3059,7 +3061,7 @@@ struct qla_hw_data 
  #define PCI_DEVICE_ID_QLOGIC_ISP2031  0x2031
  #define PCI_DEVICE_ID_QLOGIC_ISP2071  0x2071
  #define PCI_DEVICE_ID_QLOGIC_ISP2271  0x2271
+ #define PCI_DEVICE_ID_QLOGIC_ISP2261  0x2261
  
        uint32_t        device_type;
  #define DT_ISP2100                      BIT_0
  #define DT_ISP8044                    BIT_18
  #define DT_ISP2071                    BIT_19
  #define DT_ISP2271                    BIT_20
- #define DT_ISP_LAST                   (DT_ISP2271 << 1)
+ #define DT_ISP2261                    BIT_21
+ #define DT_ISP_LAST                   (DT_ISP2261 << 1)
  
  #define DT_T10_PI                       BIT_25
  #define DT_IIDMA                        BIT_26
  #define IS_QLAFX00(ha)        (DT_MASK(ha) & DT_ISPFX00)
  #define IS_QLA2071(ha)        (DT_MASK(ha) & DT_ISP2071)
  #define IS_QLA2271(ha)        (DT_MASK(ha) & DT_ISP2271)
+ #define IS_QLA2261(ha)        (DT_MASK(ha) & DT_ISP2261)
  
  #define IS_QLA23XX(ha)  (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA2322(ha) || \
                        IS_QLA6312(ha) || IS_QLA6322(ha))
  #define IS_QLA25XX(ha)  (IS_QLA2532(ha))
  #define IS_QLA83XX(ha)        (IS_QLA2031(ha) || IS_QLA8031(ha))
  #define IS_QLA84XX(ha)  (IS_QLA8432(ha))
- #define IS_QLA27XX(ha)  (IS_QLA2071(ha) || IS_QLA2271(ha))
+ #define IS_QLA27XX(ha)  (IS_QLA2071(ha) || IS_QLA2271(ha) || IS_QLA2261(ha))
  #define IS_QLA24XX_TYPE(ha)     (IS_QLA24XX(ha) || IS_QLA54XX(ha) || \
                                IS_QLA84XX(ha))
  #define IS_CNA_CAPABLE(ha)    (IS_QLA81XX(ha) || IS_QLA82XX(ha) || \
  /* Bit 21 of fw_attributes decides the MCTP capabilities */
  #define IS_MCTP_CAPABLE(ha)   (IS_QLA2031(ha) && \
                                ((ha)->fw_attributes_ext[0] & BIT_0))
 -#define IS_PI_UNINIT_CAPABLE(ha)      (IS_QLA83XX(ha))
 -#define IS_PI_IPGUARD_CAPABLE(ha)     (IS_QLA83XX(ha))
 +#define IS_PI_UNINIT_CAPABLE(ha)      (IS_QLA83XX(ha) || IS_QLA27XX(ha))
 +#define IS_PI_IPGUARD_CAPABLE(ha)     (IS_QLA83XX(ha) || IS_QLA27XX(ha))
  #define IS_PI_DIFB_DIX0_CAPABLE(ha)   (0)
 -#define IS_PI_SPLIT_DET_CAPABLE_HBA(ha)       (IS_QLA83XX(ha))
 +#define IS_PI_SPLIT_DET_CAPABLE_HBA(ha)       (IS_QLA83XX(ha) || IS_QLA27XX(ha))
  #define IS_PI_SPLIT_DET_CAPABLE(ha)   (IS_PI_SPLIT_DET_CAPABLE_HBA(ha) && \
      (((ha)->fw_attributes_h << 16 | (ha)->fw_attributes) & BIT_22))
 -#define IS_ATIO_MSIX_CAPABLE(ha) (IS_QLA83XX(ha))
 +#define IS_ATIO_MSIX_CAPABLE(ha) (IS_QLA83XX(ha) || IS_QLA27XX(ha))
  #define IS_TGT_MODE_CAPABLE(ha)       (ha->tgt.atio_q_length)
  #define IS_SHADOW_REG_CAPABLE(ha)  (IS_QLA27XX(ha))
  #define IS_DPORT_CAPABLE(ha)  (IS_QLA83XX(ha) || IS_QLA27XX(ha))
+ #define IS_FAWWN_CAPABLE(ha)  (IS_QLA83XX(ha) || IS_QLA27XX(ha))
  
        /* HBA serial number */
        uint8_t         serial0;
        uint8_t         mpi_version[3];
        uint32_t        mpi_capabilities;
        uint8_t         phy_version[3];
+       uint8_t         pep_version[3];
  
        /* Firmware dump template */
        void            *fw_dump_template;
        mempool_t       *ctx_mempool;
  #define FCP_CMND_DMA_POOL_SIZE 512
  
-       unsigned long   nx_pcibase;             /* Base I/O address */
-       uint8_t         *nxdb_rd_ptr;           /* Doorbell read pointer */
-       unsigned long   nxdb_wr_ptr;            /* Door bell write pointer */
+       void __iomem    *nx_pcibase;            /* Base I/O address */
+       void __iomem    *nxdb_rd_ptr;           /* Doorbell read pointer */
+       void __iomem    *nxdb_wr_ptr;           /* Door bell write pointer */
  
        uint32_t        crb_win;
        uint32_t        curr_window;
@@@ -3581,16 -3584,6 +3586,16 @@@ typedef struct scsi_qla_host 
        uint16_t        fcoe_fcf_idx;
        uint8_t         fcoe_vn_port_mac[6];
  
 +      /* list of commands waiting on workqueue */
 +      struct list_head        qla_cmd_list;
 +      struct list_head        qla_sess_op_cmd_list;
 +      spinlock_t              cmd_list_lock;
 +
 +      /* Counter to detect races between ELS and RSCN events */
 +      atomic_t                generation_tick;
 +      /* Time when global fcport update has been scheduled */
 +      int                     total_fcport_update_gen;
 +
        uint32_t        vp_abort_cnt;
  
        struct fc_vport *fc_vport;      /* holds fc_vport * for each vport */
index 11f2f3279eab2984fe131510cc669b329f149bae,014f44f7a7c44689ec4b023287a25da05e2c7bed..16a1935cc9c1131359e514befb04b6a7bb155f9b
@@@ -115,8 -115,6 +115,8 @@@ qla2x00_async_iocb_timeout(void *data
                        QLA_LOGIO_LOGIN_RETRIED : 0;
                qla2x00_post_async_login_done_work(fcport->vha, fcport,
                        lio->u.logio.data);
 +      } else if (sp->type == SRB_LOGOUT_CMD) {
 +              qlt_logo_completion_handler(fcport, QLA_FUNCTION_TIMEOUT);
        }
  }
  
@@@ -499,10 -497,7 +499,10 @@@ voi
  qla2x00_async_logout_done(struct scsi_qla_host *vha, fc_port_t *fcport,
      uint16_t *data)
  {
 -      qla2x00_mark_device_lost(vha, fcport, 1, 0);
 +      /* Don't re-login in target mode */
 +      if (!fcport->tgt_session)
 +              qla2x00_mark_device_lost(vha, fcport, 1, 0);
 +      qlt_logo_completion_handler(fcport, data[0]);
        return;
  }
  
@@@ -1132,7 -1127,7 +1132,7 @@@ qla24xx_reset_risc(scsi_qla_host_t *vha
        unsigned long flags = 0;
        struct qla_hw_data *ha = vha->hw;
        struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
-       uint32_t cnt, d2;
+       uint32_t cnt;
        uint16_t wd;
        static int abts_cnt; /* ISP abort retry counts */
        int rval = QLA_SUCCESS;
        udelay(100);
  
        /* Wait for firmware to complete NVRAM accesses. */
-       d2 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
+       RD_REG_WORD(&reg->mailbox0);
        for (cnt = 10000; RD_REG_WORD(&reg->mailbox0) != 0 &&
            rval == QLA_SUCCESS; cnt--) {
                barrier();
            RD_REG_DWORD(&reg->mailbox0));
  
        /* Wait for soft-reset to complete. */
-       d2 = RD_REG_DWORD(&reg->ctrl_status);
+       RD_REG_DWORD(&reg->ctrl_status);
        for (cnt = 0; cnt < 6000000; cnt++) {
                barrier();
                if ((RD_REG_DWORD(&reg->ctrl_status) &
        WRT_REG_DWORD(&reg->hccr, HCCRX_CLR_RISC_RESET);
        RD_REG_DWORD(&reg->hccr);
  
-       d2 = (uint32_t) RD_REG_WORD(&reg->mailbox0);
+       RD_REG_WORD(&reg->mailbox0);
        for (cnt = 6000000; RD_REG_WORD(&reg->mailbox0) != 0 &&
            rval == QLA_SUCCESS; cnt--) {
                barrier();
@@@ -1277,16 -1272,19 +1277,19 @@@ qla25xx_write_risc_sema_reg(scsi_qla_ho
  static void
  qla25xx_manipulate_risc_semaphore(scsi_qla_host_t *vha)
  {
-       struct qla_hw_data *ha = vha->hw;
        uint32_t wd32 = 0;
        uint delta_msec = 100;
        uint elapsed_msec = 0;
        uint timeout_msec;
        ulong n;
  
-       if (!IS_QLA25XX(ha) && !IS_QLA2031(ha))
+       if (vha->hw->pdev->subsystem_device != 0x0175 &&
+           vha->hw->pdev->subsystem_device != 0x0240)
                return;
  
+       WRT_REG_DWORD(&vha->hw->iobase->isp24.hccr, HCCRX_SET_RISC_PAUSE);
+       udelay(100);
  attempt:
        timeout_msec = TIMEOUT_SEMAPHORE;
        n = timeout_msec / delta_msec;
@@@ -1543,7 -1541,7 +1546,7 @@@ qla2x00_alloc_fw_dump(scsi_qla_host_t *
                mem_size = (ha->fw_memory_size - 0x11000 + 1) *
                    sizeof(uint16_t);
        } else if (IS_FWI2_CAPABLE(ha)) {
 -              if (IS_QLA83XX(ha))
 +              if (IS_QLA83XX(ha) || IS_QLA27XX(ha))
                        fixed_size = offsetof(struct qla83xx_fw_dump, ext_mem);
                else if (IS_QLA81XX(ha))
                        fixed_size = offsetof(struct qla81xx_fw_dump, ext_mem);
                mem_size = (ha->fw_memory_size - 0x100000 + 1) *
                    sizeof(uint32_t);
                if (ha->mqenable) {
 -                      if (!IS_QLA83XX(ha))
 +                      if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
                                mq_size = sizeof(struct qla2xxx_mq_chain);
                        /*
                         * Allocate maximum buffer size for all queues.
@@@ -1690,7 -1688,7 +1693,7 @@@ allocate
        ha->fw_dump->signature[1] = 'L';
        ha->fw_dump->signature[2] = 'G';
        ha->fw_dump->signature[3] = 'C';
-       ha->fw_dump->version = __constant_htonl(1);
+       ha->fw_dump->version = htonl(1);
  
        ha->fw_dump->fixed_size = htonl(fixed_size);
        ha->fw_dump->mem_size = htonl(mem_size);
@@@ -2070,8 -2068,8 +2073,8 @@@ qla2x00_config_rings(struct scsi_qla_ho
        struct rsp_que *rsp = ha->rsp_q_map[0];
  
        /* Setup ring parameters in initialization control block. */
-       ha->init_cb->request_q_outpointer = __constant_cpu_to_le16(0);
-       ha->init_cb->response_q_inpointer = __constant_cpu_to_le16(0);
+       ha->init_cb->request_q_outpointer = cpu_to_le16(0);
+       ha->init_cb->response_q_inpointer = cpu_to_le16(0);
        ha->init_cb->request_q_length = cpu_to_le16(req->length);
        ha->init_cb->response_q_length = cpu_to_le16(rsp->length);
        ha->init_cb->request_q_address[0] = cpu_to_le32(LSD(req->dma));
@@@ -2090,7 -2088,7 +2093,7 @@@ voi
  qla24xx_config_rings(struct scsi_qla_host *vha)
  {
        struct qla_hw_data *ha = vha->hw;
-       device_reg_t __iomem *reg = ISP_QUE_REG(ha, 0);
+       device_reg_t *reg = ISP_QUE_REG(ha, 0);
        struct device_reg_2xxx __iomem *ioreg = &ha->iobase->isp;
        struct qla_msix_entry *msix;
        struct init_cb_24xx *icb;
  
        /* Setup ring parameters in initialization control block. */
        icb = (struct init_cb_24xx *)ha->init_cb;
-       icb->request_q_outpointer = __constant_cpu_to_le16(0);
-       icb->response_q_inpointer = __constant_cpu_to_le16(0);
+       icb->request_q_outpointer = cpu_to_le16(0);
+       icb->response_q_inpointer = cpu_to_le16(0);
        icb->request_q_length = cpu_to_le16(req->length);
        icb->response_q_length = cpu_to_le16(rsp->length);
        icb->request_q_address[0] = cpu_to_le32(LSD(req->dma));
        icb->response_q_address[1] = cpu_to_le32(MSD(rsp->dma));
  
        /* Setup ATIO queue dma pointers for target mode */
-       icb->atio_q_inpointer = __constant_cpu_to_le16(0);
+       icb->atio_q_inpointer = cpu_to_le16(0);
        icb->atio_q_length = cpu_to_le16(ha->tgt.atio_q_length);
        icb->atio_q_address[0] = cpu_to_le32(LSD(ha->tgt.atio_dma));
        icb->atio_q_address[1] = cpu_to_le32(MSD(ha->tgt.atio_dma));
  
        if (IS_SHADOW_REG_CAPABLE(ha))
-               icb->firmware_options_2 |=
-                   __constant_cpu_to_le32(BIT_30|BIT_29);
+               icb->firmware_options_2 |= cpu_to_le32(BIT_30|BIT_29);
  
        if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
-               icb->qos = __constant_cpu_to_le16(QLA_DEFAULT_QUE_QOS);
-               icb->rid = __constant_cpu_to_le16(rid);
+               icb->qos = cpu_to_le16(QLA_DEFAULT_QUE_QOS);
+               icb->rid = cpu_to_le16(rid);
                if (ha->flags.msix_enabled) {
                        msix = &ha->msix_entries[1];
                        ql_dbg(ql_dbg_init, vha, 0x00fd,
                }
                /* Use alternate PCI bus number */
                if (MSB(rid))
-                       icb->firmware_options_2 |=
-                               __constant_cpu_to_le32(BIT_19);
+                       icb->firmware_options_2 |= cpu_to_le32(BIT_19);
                /* Use alternate PCI devfn */
                if (LSB(rid))
-                       icb->firmware_options_2 |=
-                               __constant_cpu_to_le32(BIT_18);
+                       icb->firmware_options_2 |= cpu_to_le32(BIT_18);
  
                /* Use Disable MSIX Handshake mode for capable adapters */
                if ((ha->fw_attributes & BIT_6) && (IS_MSIX_NACK_CAPABLE(ha)) &&
                    (ha->flags.msix_enabled)) {
-                       icb->firmware_options_2 &=
-                               __constant_cpu_to_le32(~BIT_22);
+                       icb->firmware_options_2 &= cpu_to_le32(~BIT_22);
                        ha->flags.disable_msix_handshake = 1;
                        ql_dbg(ql_dbg_init, vha, 0x00fe,
                            "MSIX Handshake Disable Mode turned on.\n");
                } else {
-                       icb->firmware_options_2 |=
-                               __constant_cpu_to_le32(BIT_22);
+                       icb->firmware_options_2 |= cpu_to_le32(BIT_22);
                }
-               icb->firmware_options_2 |= __constant_cpu_to_le32(BIT_23);
+               icb->firmware_options_2 |= cpu_to_le32(BIT_23);
  
                WRT_REG_DWORD(&reg->isp25mq.req_q_in, 0);
                WRT_REG_DWORD(&reg->isp25mq.req_q_out, 0);
@@@ -2248,7 -2241,7 +2246,7 @@@ qla2x00_init_rings(scsi_qla_host_t *vha
        }
  
        if (IS_FWI2_CAPABLE(ha)) {
-               mid_init_cb->options = __constant_cpu_to_le16(BIT_1);
+               mid_init_cb->options = cpu_to_le16(BIT_1);
                mid_init_cb->init_cb.execution_throttle =
                    cpu_to_le16(ha->fw_xcb_count);
                /* D-Port Status */
@@@ -2677,8 -2670,8 +2675,8 @@@ qla2x00_nvram_config(scsi_qla_host_t *v
                        nv->frame_payload_size = 1024;
                }
  
-               nv->max_iocb_allocation = __constant_cpu_to_le16(256);
-               nv->execution_throttle = __constant_cpu_to_le16(16);
+               nv->max_iocb_allocation = cpu_to_le16(256);
+               nv->execution_throttle = cpu_to_le16(16);
                nv->retry_count = 8;
                nv->retry_delay = 1;
  
                nv->host_p[1] = BIT_2;
                nv->reset_delay = 5;
                nv->port_down_retry_count = 8;
-               nv->max_luns_per_target = __constant_cpu_to_le16(8);
+               nv->max_luns_per_target = cpu_to_le16(8);
                nv->link_down_timeout = 60;
  
                rval = 1;
        memcpy(vha->node_name, icb->node_name, WWN_SIZE);
        memcpy(vha->port_name, icb->port_name, WWN_SIZE);
  
-       icb->execution_throttle = __constant_cpu_to_le16(0xFFFF);
+       icb->execution_throttle = cpu_to_le16(0xFFFF);
  
        ha->retry_count = nv->retry_count;
  
        if (ql2xloginretrycount)
                ha->login_retry_count = ql2xloginretrycount;
  
-       icb->lun_enables = __constant_cpu_to_le16(0);
+       icb->lun_enables = cpu_to_le16(0);
        icb->command_resource_count = 0;
        icb->immediate_notify_resource_count = 0;
-       icb->timeout = __constant_cpu_to_le16(0);
+       icb->timeout = cpu_to_le16(0);
  
        if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
                /* Enable RIO */
@@@ -2927,14 -2920,21 +2925,14 @@@ qla2x00_rport_del(void *data
  {
        fc_port_t *fcport = data;
        struct fc_rport *rport;
 -      scsi_qla_host_t *vha = fcport->vha;
        unsigned long flags;
  
        spin_lock_irqsave(fcport->vha->host->host_lock, flags);
        rport = fcport->drport ? fcport->drport: fcport->rport;
        fcport->drport = NULL;
        spin_unlock_irqrestore(fcport->vha->host->host_lock, flags);
 -      if (rport) {
 +      if (rport)
                fc_remote_port_delete(rport);
 -              /*
 -               * Release the target mode FC NEXUS in qla_target.c code
 -               * if target mod is enabled.
 -               */
 -              qlt_fc_port_deleted(vha, fcport);
 -      }
  }
  
  /**
@@@ -3301,7 -3301,6 +3299,7 @@@ qla2x00_reg_remote_port(scsi_qla_host_
         * Create target mode FC NEXUS in qla_target.c if target mode is
         * enabled..
         */
 +
        qlt_fc_port_added(vha, fcport);
  
        spin_lock_irqsave(fcport->vha->host->host_lock, flags);
@@@ -3340,7 -3339,8 +3338,7 @@@ qla2x00_update_fcport(scsi_qla_host_t *
  
        if (IS_QLAFX00(vha->hw)) {
                qla2x00_set_fcport_state(fcport, FCS_ONLINE);
 -              qla2x00_reg_remote_port(vha, fcport);
 -              return;
 +              goto reg_port;
        }
        fcport->login_retry = 0;
        fcport->flags &= ~(FCF_LOGIN_NEEDED | FCF_ASYNC_SENT);
        qla2x00_set_fcport_state(fcport, FCS_ONLINE);
        qla2x00_iidma_fcport(vha, fcport);
        qla24xx_update_fcport_fcp_prio(vha, fcport);
 -      qla2x00_reg_remote_port(vha, fcport);
 +
 +reg_port:
 +      if (qla_ini_mode_enabled(vha))
 +              qla2x00_reg_remote_port(vha, fcport);
 +      else {
 +              /*
 +               * Create target mode FC NEXUS in qla_target.c
 +               */
 +              qlt_fc_port_added(vha, fcport);
 +      }
  }
  
  /*
@@@ -3382,7 -3373,6 +3380,7 @@@ qla2x00_configure_fabric(scsi_qla_host_
        LIST_HEAD(new_fcports);
        struct qla_hw_data *ha = vha->hw;
        struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
 +      int             discovery_gen;
  
        /* If FL port exists, then SNS is present */
        if (IS_FWI2_CAPABLE(ha))
                        fcport->scan_state = QLA_FCPORT_SCAN;
                }
  
 +              /* Mark the time right before querying FW for connected ports.
 +               * This process is long, asynchronous and by the time it's done,
 +               * collected information might not be accurate anymore. E.g.
 +               * disconnected port might have re-connected and a brand new
 +               * session has been created. In this case session's generation
 +               * will be newer than discovery_gen. */
 +              qlt_do_generation_tick(vha, &discovery_gen);
 +
                rval = qla2x00_find_all_fabric_devs(vha, &new_fcports);
                if (rval != QLA_SUCCESS)
                        break;
                        if ((fcport->flags & FCF_FABRIC_DEVICE) == 0)
                                continue;
  
 -                      if (fcport->scan_state == QLA_FCPORT_SCAN &&
 -                          atomic_read(&fcport->state) == FCS_ONLINE) {
 -                              qla2x00_mark_device_lost(vha, fcport,
 -                                  ql2xplogiabsentdevice, 0);
 -                              if (fcport->loop_id != FC_NO_LOOP_ID &&
 -                                  (fcport->flags & FCF_FCP2_DEVICE) == 0 &&
 -                                  fcport->port_type != FCT_INITIATOR &&
 -                                  fcport->port_type != FCT_BROADCAST) {
 -                                      ha->isp_ops->fabric_logout(vha,
 -                                          fcport->loop_id,
 -                                          fcport->d_id.b.domain,
 -                                          fcport->d_id.b.area,
 -                                          fcport->d_id.b.al_pa);
 -                                      qla2x00_clear_loop_id(fcport);
 +                      if (fcport->scan_state == QLA_FCPORT_SCAN) {
 +                              if (qla_ini_mode_enabled(base_vha) &&
 +                                  atomic_read(&fcport->state) == FCS_ONLINE) {
 +                                      qla2x00_mark_device_lost(vha, fcport,
 +                                          ql2xplogiabsentdevice, 0);
 +                                      if (fcport->loop_id != FC_NO_LOOP_ID &&
 +                                          (fcport->flags & FCF_FCP2_DEVICE) == 0 &&
 +                                          fcport->port_type != FCT_INITIATOR &&
 +                                          fcport->port_type != FCT_BROADCAST) {
 +                                              ha->isp_ops->fabric_logout(vha,
 +                                                  fcport->loop_id,
 +                                                  fcport->d_id.b.domain,
 +                                                  fcport->d_id.b.area,
 +                                                  fcport->d_id.b.al_pa);
 +                                              qla2x00_clear_loop_id(fcport);
 +                                      }
 +                              } else if (!qla_ini_mode_enabled(base_vha)) {
 +                                      /*
 +                                       * In target mode, explicitly kill
 +                                       * sessions and log out of devices
 +                                       * that are gone, so that we don't
 +                                       * end up with an initiator using the
 +                                       * wrong ACL (if the fabric recycles
 +                                       * an FC address and we have a stale
 +                                       * session around) and so that we don't
 +                                       * report initiators that are no longer
 +                                       * on the fabric.
 +                                       */
 +                                      ql_dbg(ql_dbg_tgt_mgt, vha, 0xf077,
 +                                          "port gone, logging out/killing session: "
 +                                          "%8phC state 0x%x flags 0x%x fc4_type 0x%x "
 +                                          "scan_state %d\n",
 +                                          fcport->port_name,
 +                                          atomic_read(&fcport->state),
 +                                          fcport->flags, fcport->fc4_type,
 +                                          fcport->scan_state);
 +                                      qlt_fc_port_deleted(vha, fcport,
 +                                          discovery_gen);
                                }
                        }
                }
                            (fcport->flags & FCF_LOGIN_NEEDED) == 0)
                                continue;
  
 +                      /*
 +                       * If we're not an initiator, skip looking for devices
 +                       * and logging in.  There's no reason for us to do it,
 +                       * and it seems to actively cause problems in target
 +                       * mode if we race with the initiator logging into us
 +                       * (we might get the "port ID used" status back from
 +                       * our login command and log out the initiator, which
 +                       * seems to cause havoc).
 +                       */
 +                      if (!qla_ini_mode_enabled(base_vha)) {
 +                              if (fcport->scan_state == QLA_FCPORT_FOUND) {
 +                                      ql_dbg(ql_dbg_tgt_mgt, vha, 0xf078,
 +                                          "port %8phC state 0x%x flags 0x%x fc4_type 0x%x "
 +                                          "scan_state %d (initiator mode disabled; skipping "
 +                                          "login)\n", fcport->port_name,
 +                                          atomic_read(&fcport->state),
 +                                          fcport->flags, fcport->fc4_type,
 +                                          fcport->scan_state);
 +                              }
 +                              continue;
 +                      }
 +
                        if (fcport->loop_id == FC_NO_LOOP_ID) {
                                fcport->loop_id = next_loopid;
                                rval = qla2x00_find_new_loop_id(
                            test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
                                break;
  
 -                      /* Find a new loop ID to use. */
 -                      fcport->loop_id = next_loopid;
 -                      rval = qla2x00_find_new_loop_id(base_vha, fcport);
 -                      if (rval != QLA_SUCCESS) {
 -                              /* Ran out of IDs to use */
 -                              break;
 -                      }
 +                      /*
 +                       * If we're not an initiator, skip looking for devices
 +                       * and logging in.  There's no reason for us to do it,
 +                       * and it seems to actively cause problems in target
 +                       * mode if we race with the initiator logging into us
 +                       * (we might get the "port ID used" status back from
 +                       * our login command and log out the initiator, which
 +                       * seems to cause havoc).
 +                       */
 +                      if (qla_ini_mode_enabled(base_vha)) {
 +                              /* Find a new loop ID to use. */
 +                              fcport->loop_id = next_loopid;
 +                              rval = qla2x00_find_new_loop_id(base_vha,
 +                                  fcport);
 +                              if (rval != QLA_SUCCESS) {
 +                                      /* Ran out of IDs to use */
 +                                      break;
 +                              }
  
 -                      /* Login and update database */
 -                      qla2x00_fabric_dev_login(vha, fcport, &next_loopid);
 +                              /* Login and update database */
 +                              qla2x00_fabric_dev_login(vha, fcport,
 +                                  &next_loopid);
 +                      } else {
 +                              ql_dbg(ql_dbg_tgt_mgt, vha, 0xf079,
 +                                      "new port %8phC state 0x%x flags 0x%x fc4_type "
 +                                      "0x%x scan_state %d (initiator mode disabled; "
 +                                      "skipping login)\n",
 +                                      fcport->port_name,
 +                                      atomic_read(&fcport->state),
 +                                      fcport->flags, fcport->fc4_type,
 +                                      fcport->scan_state);
 +                      }
  
                        list_move_tail(&fcport->list, &vha->vp_fcports);
                }
@@@ -3809,12 -3723,11 +3807,12 @@@ qla2x00_find_all_fabric_devs(scsi_qla_h
                        fcport->fp_speed = new_fcport->fp_speed;
  
                        /*
 -                       * If address the same and state FCS_ONLINE, nothing
 -                       * changed.
 +                       * If address the same and state FCS_ONLINE
 +                       * (or in target mode), nothing changed.
                         */
                        if (fcport->d_id.b24 == new_fcport->d_id.b24 &&
 -                          atomic_read(&fcport->state) == FCS_ONLINE) {
 +                          (atomic_read(&fcport->state) == FCS_ONLINE ||
 +                           !qla_ini_mode_enabled(base_vha))) {
                                break;
                        }
  
                         * Log it out if still logged in and mark it for
                         * relogin later.
                         */
 +                      if (!qla_ini_mode_enabled(base_vha)) {
 +                              ql_dbg(ql_dbg_tgt_mgt, vha, 0xf080,
 +                                       "port changed FC ID, %8phC"
 +                                       " old %x:%x:%x (loop_id 0x%04x)-> new %x:%x:%x\n",
 +                                       fcport->port_name,
 +                                       fcport->d_id.b.domain,
 +                                       fcport->d_id.b.area,
 +                                       fcport->d_id.b.al_pa,
 +                                       fcport->loop_id,
 +                                       new_fcport->d_id.b.domain,
 +                                       new_fcport->d_id.b.area,
 +                                       new_fcport->d_id.b.al_pa);
 +                              fcport->d_id.b24 = new_fcport->d_id.b24;
 +                              break;
 +                      }
 +
                        fcport->d_id.b24 = new_fcport->d_id.b24;
                        fcport->flags |= FCF_LOGIN_NEEDED;
                        if (fcport->loop_id != FC_NO_LOOP_ID &&
                if (found)
                        continue;
                /* If device was not in our fcports list, then add it. */
 +              new_fcport->scan_state = QLA_FCPORT_FOUND;
                list_add_tail(&new_fcport->list, new_fcports);
  
                /* Allocate a new replacement fcport. */
@@@ -3958,12 -3854,10 +3956,10 @@@ qla2x00_fabric_dev_login(scsi_qla_host_
      uint16_t *next_loopid)
  {
        int     rval;
-       int     retry;
        uint8_t opts;
        struct qla_hw_data *ha = vha->hw;
  
        rval = QLA_SUCCESS;
-       retry = 0;
  
        if (IS_ALOGIO_CAPABLE(ha)) {
                if (fcport->flags & FCF_ASYNC_SENT)
@@@ -4290,14 -4184,6 +4286,14 @@@ qla2x00_update_fcports(scsi_qla_host_t 
                            atomic_read(&fcport->state) != FCS_UNCONFIGURED) {
                                spin_unlock_irqrestore(&ha->vport_slock, flags);
                                qla2x00_rport_del(fcport);
 +
 +                              /*
 +                               * Release the target mode FC NEXUS in
 +                               * qla_target.c, if target mod is enabled.
 +                               */
 +                              qlt_fc_port_deleted(vha, fcport,
 +                                  base_vha->total_fcport_update_gen);
 +
                                spin_lock_irqsave(&ha->vport_slock, flags);
                        }
                }
@@@ -5117,7 -5003,7 +5113,7 @@@ qla24xx_nvram_config(scsi_qla_host_t *v
        /* Bad NVRAM data, set defaults parameters. */
        if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P'
            || nv->id[3] != ' ' ||
-           nv->nvram_version < __constant_cpu_to_le16(ICB_VERSION)) {
+           nv->nvram_version < cpu_to_le16(ICB_VERSION)) {
                /* Reset NVRAM data. */
                ql_log(ql_log_warn, vha, 0x006b,
                    "Inconsistent NVRAM detected: checksum=0x%x id=%c "
                 * Set default initialization control block.
                 */
                memset(nv, 0, ha->nvram_size);
-               nv->nvram_version = __constant_cpu_to_le16(ICB_VERSION);
-               nv->version = __constant_cpu_to_le16(ICB_VERSION);
+               nv->nvram_version = cpu_to_le16(ICB_VERSION);
+               nv->version = cpu_to_le16(ICB_VERSION);
                nv->frame_payload_size = 2048;
-               nv->execution_throttle = __constant_cpu_to_le16(0xFFFF);
-               nv->exchange_count = __constant_cpu_to_le16(0);
-               nv->hard_address = __constant_cpu_to_le16(124);
+               nv->execution_throttle = cpu_to_le16(0xFFFF);
+               nv->exchange_count = cpu_to_le16(0);
+               nv->hard_address = cpu_to_le16(124);
                nv->port_name[0] = 0x21;
                nv->port_name[1] = 0x00 + ha->port_no + 1;
                nv->port_name[2] = 0x00;
                nv->node_name[6] = 0x55;
                nv->node_name[7] = 0x86;
                qla24xx_nvram_wwn_from_ofw(vha, nv);
-               nv->login_retry_count = __constant_cpu_to_le16(8);
-               nv->interrupt_delay_timer = __constant_cpu_to_le16(0);
-               nv->login_timeout = __constant_cpu_to_le16(0);
+               nv->login_retry_count = cpu_to_le16(8);
+               nv->interrupt_delay_timer = cpu_to_le16(0);
+               nv->login_timeout = cpu_to_le16(0);
                nv->firmware_options_1 =
-                   __constant_cpu_to_le32(BIT_14|BIT_13|BIT_2|BIT_1);
-               nv->firmware_options_2 = __constant_cpu_to_le32(2 << 4);
-               nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_12);
-               nv->firmware_options_3 = __constant_cpu_to_le32(2 << 13);
-               nv->host_p = __constant_cpu_to_le32(BIT_11|BIT_10);
-               nv->efi_parameters = __constant_cpu_to_le32(0);
+                   cpu_to_le32(BIT_14|BIT_13|BIT_2|BIT_1);
+               nv->firmware_options_2 = cpu_to_le32(2 << 4);
+               nv->firmware_options_2 |= cpu_to_le32(BIT_12);
+               nv->firmware_options_3 = cpu_to_le32(2 << 13);
+               nv->host_p = cpu_to_le32(BIT_11|BIT_10);
+               nv->efi_parameters = cpu_to_le32(0);
                nv->reset_delay = 5;
-               nv->max_luns_per_target = __constant_cpu_to_le16(128);
-               nv->port_down_retry_count = __constant_cpu_to_le16(30);
-               nv->link_down_timeout = __constant_cpu_to_le16(30);
+               nv->max_luns_per_target = cpu_to_le16(128);
+               nv->port_down_retry_count = cpu_to_le16(30);
+               nv->link_down_timeout = cpu_to_le16(30);
  
                rval = 1;
        }
  
        if (!qla_ini_mode_enabled(vha)) {
                /* Don't enable full login after initial LIP */
-               nv->firmware_options_1 &= __constant_cpu_to_le32(~BIT_13);
+               nv->firmware_options_1 &= cpu_to_le32(~BIT_13);
                /* Don't enable LIP full login for initiator */
-               nv->host_p &= __constant_cpu_to_le32(~BIT_10);
+               nv->host_p &= cpu_to_le32(~BIT_10);
        }
  
        qlt_24xx_config_nvram_stage1(vha, nv);
  
        qlt_24xx_config_nvram_stage2(vha, icb);
  
-       if (nv->host_p & __constant_cpu_to_le32(BIT_15)) {
+       if (nv->host_p & cpu_to_le32(BIT_15)) {
                /* Use alternate WWN? */
                memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE);
                memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE);
        }
  
        /* Prepare nodename */
-       if ((icb->firmware_options_1 & __constant_cpu_to_le32(BIT_14)) == 0) {
+       if ((icb->firmware_options_1 & cpu_to_le32(BIT_14)) == 0) {
                /*
                 * Firmware will apply the following mask if the nodename was
                 * not provided.
        memcpy(vha->node_name, icb->node_name, WWN_SIZE);
        memcpy(vha->port_name, icb->port_name, WWN_SIZE);
  
-       icb->execution_throttle = __constant_cpu_to_le16(0xFFFF);
+       icb->execution_throttle = cpu_to_le16(0xFFFF);
  
        ha->retry_count = le16_to_cpu(nv->login_retry_count);
  
        if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout)
                nv->login_timeout = cpu_to_le16(ql2xlogintimeout);
        if (le16_to_cpu(nv->login_timeout) < 4)
-               nv->login_timeout = __constant_cpu_to_le16(4);
+               nv->login_timeout = cpu_to_le16(4);
        ha->login_timeout = le16_to_cpu(nv->login_timeout);
        icb->login_timeout = nv->login_timeout;
  
                ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ?
                    le16_to_cpu(icb->interrupt_delay_timer): 2;
        }
-       icb->firmware_options_2 &= __constant_cpu_to_le32(
+       icb->firmware_options_2 &= cpu_to_le32(
            ~(BIT_3 | BIT_2 | BIT_1 | BIT_0));
        vha->flags.process_response_queue = 0;
        if (ha->zio_mode != QLA_ZIO_DISABLED) {
@@@ -6063,7 -5949,7 +6059,7 @@@ qla81xx_nvram_config(scsi_qla_host_t *v
        /* Bad NVRAM data, set defaults parameters. */
        if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P'
            || nv->id[3] != ' ' ||
-           nv->nvram_version < __constant_cpu_to_le16(ICB_VERSION)) {
+           nv->nvram_version < cpu_to_le16(ICB_VERSION)) {
                /* Reset NVRAM data. */
                ql_log(ql_log_info, vha, 0x0073,
                    "Inconsistent NVRAM detected: checksum=0x%x id=%c "
                 * Set default initialization control block.
                 */
                memset(nv, 0, ha->nvram_size);
-               nv->nvram_version = __constant_cpu_to_le16(ICB_VERSION);
-               nv->version = __constant_cpu_to_le16(ICB_VERSION);
+               nv->nvram_version = cpu_to_le16(ICB_VERSION);
+               nv->version = cpu_to_le16(ICB_VERSION);
                nv->frame_payload_size = 2048;
-               nv->execution_throttle = __constant_cpu_to_le16(0xFFFF);
-               nv->exchange_count = __constant_cpu_to_le16(0);
+               nv->execution_throttle = cpu_to_le16(0xFFFF);
+               nv->exchange_count = cpu_to_le16(0);
                nv->port_name[0] = 0x21;
                nv->port_name[1] = 0x00 + ha->port_no + 1;
                nv->port_name[2] = 0x00;
                nv->node_name[5] = 0x1c;
                nv->node_name[6] = 0x55;
                nv->node_name[7] = 0x86;
-               nv->login_retry_count = __constant_cpu_to_le16(8);
-               nv->interrupt_delay_timer = __constant_cpu_to_le16(0);
-               nv->login_timeout = __constant_cpu_to_le16(0);
+               nv->login_retry_count = cpu_to_le16(8);
+               nv->interrupt_delay_timer = cpu_to_le16(0);
+               nv->login_timeout = cpu_to_le16(0);
                nv->firmware_options_1 =
-                   __constant_cpu_to_le32(BIT_14|BIT_13|BIT_2|BIT_1);
-               nv->firmware_options_2 = __constant_cpu_to_le32(2 << 4);
-               nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_12);
-               nv->firmware_options_3 = __constant_cpu_to_le32(2 << 13);
-               nv->host_p = __constant_cpu_to_le32(BIT_11|BIT_10);
-               nv->efi_parameters = __constant_cpu_to_le32(0);
+                   cpu_to_le32(BIT_14|BIT_13|BIT_2|BIT_1);
+               nv->firmware_options_2 = cpu_to_le32(2 << 4);
+               nv->firmware_options_2 |= cpu_to_le32(BIT_12);
+               nv->firmware_options_3 = cpu_to_le32(2 << 13);
+               nv->host_p = cpu_to_le32(BIT_11|BIT_10);
+               nv->efi_parameters = cpu_to_le32(0);
                nv->reset_delay = 5;
-               nv->max_luns_per_target = __constant_cpu_to_le16(128);
-               nv->port_down_retry_count = __constant_cpu_to_le16(30);
-               nv->link_down_timeout = __constant_cpu_to_le16(180);
+               nv->max_luns_per_target = cpu_to_le16(128);
+               nv->port_down_retry_count = cpu_to_le16(30);
+               nv->link_down_timeout = cpu_to_le16(180);
                nv->enode_mac[0] = 0x00;
                nv->enode_mac[1] = 0xC0;
                nv->enode_mac[2] = 0xDD;
        qlt_81xx_config_nvram_stage2(vha, icb);
  
        /* Use alternate WWN? */
-       if (nv->host_p & __constant_cpu_to_le32(BIT_15)) {
+       if (nv->host_p & cpu_to_le32(BIT_15)) {
                memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE);
                memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE);
        }
  
        /* Prepare nodename */
-       if ((icb->firmware_options_1 & __constant_cpu_to_le32(BIT_14)) == 0) {
+       if ((icb->firmware_options_1 & cpu_to_le32(BIT_14)) == 0) {
                /*
                 * Firmware will apply the following mask if the nodename was
                 * not provided.
        memcpy(vha->node_name, icb->node_name, WWN_SIZE);
        memcpy(vha->port_name, icb->port_name, WWN_SIZE);
  
-       icb->execution_throttle = __constant_cpu_to_le16(0xFFFF);
+       icb->execution_throttle = cpu_to_le16(0xFFFF);
  
        ha->retry_count = le16_to_cpu(nv->login_retry_count);
  
        if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout)
                nv->login_timeout = cpu_to_le16(ql2xlogintimeout);
        if (le16_to_cpu(nv->login_timeout) < 4)
-               nv->login_timeout = __constant_cpu_to_le16(4);
+               nv->login_timeout = cpu_to_le16(4);
        ha->login_timeout = le16_to_cpu(nv->login_timeout);
        icb->login_timeout = nv->login_timeout;
  
  
        /* if not running MSI-X we need handshaking on interrupts */
        if (!vha->hw->flags.msix_enabled && (IS_QLA83XX(ha) || IS_QLA27XX(ha)))
-               icb->firmware_options_2 |= __constant_cpu_to_le32(BIT_22);
+               icb->firmware_options_2 |= cpu_to_le32(BIT_22);
  
        /* Enable ZIO. */
        if (!vha->flags.init_done) {
                ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ?
                    le16_to_cpu(icb->interrupt_delay_timer): 2;
        }
-       icb->firmware_options_2 &= __constant_cpu_to_le32(
+       icb->firmware_options_2 &= cpu_to_le32(
            ~(BIT_3 | BIT_2 | BIT_1 | BIT_0));
        vha->flags.process_response_queue = 0;
        if (ha->zio_mode != QLA_ZIO_DISABLED) {
index 6f02b26a35cff5b06916273a0bf1c8643f523689,e07161c1eda1cb506dd6bcf2cebfaf7ccdcfd8ca..c49df34e9b351c350f13bfa2e8e98c4a1bf2a695
@@@ -108,8 -108,7 +108,7 @@@ qla2x00_prep_cont_type0_iocb(struct scs
        cont_pkt = (cont_entry_t *)req->ring_ptr;
  
        /* Load packet defaults. */
-       *((uint32_t *)(&cont_pkt->entry_type)) =
-           __constant_cpu_to_le32(CONTINUE_TYPE);
+       *((uint32_t *)(&cont_pkt->entry_type)) = cpu_to_le32(CONTINUE_TYPE);
  
        return (cont_pkt);
  }
@@@ -138,8 -137,8 +137,8 @@@ qla2x00_prep_cont_type1_iocb(scsi_qla_h
  
        /* Load packet defaults. */
        *((uint32_t *)(&cont_pkt->entry_type)) = IS_QLAFX00(vha->hw) ?
-           __constant_cpu_to_le32(CONTINUE_A64_TYPE_FX00) :
-           __constant_cpu_to_le32(CONTINUE_A64_TYPE);
+           cpu_to_le32(CONTINUE_A64_TYPE_FX00) :
+           cpu_to_le32(CONTINUE_A64_TYPE);
  
        return (cont_pkt);
  }
@@@ -204,11 -203,11 +203,11 @@@ void qla2x00_build_scsi_iocbs_32(srb_t 
  
        /* Update entry type to indicate Command Type 2 IOCB */
        *((uint32_t *)(&cmd_pkt->entry_type)) =
-           __constant_cpu_to_le32(COMMAND_TYPE);
+           cpu_to_le32(COMMAND_TYPE);
  
        /* No data transfer */
        if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
-               cmd_pkt->byte_count = __constant_cpu_to_le32(0);
+               cmd_pkt->byte_count = cpu_to_le32(0);
                return;
        }
  
@@@ -261,12 -260,11 +260,11 @@@ void qla2x00_build_scsi_iocbs_64(srb_t 
        cmd = GET_CMD_SP(sp);
  
        /* Update entry type to indicate Command Type 3 IOCB */
-       *((uint32_t *)(&cmd_pkt->entry_type)) =
-           __constant_cpu_to_le32(COMMAND_A64_TYPE);
+       *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_A64_TYPE);
  
        /* No data transfer */
        if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
-               cmd_pkt->byte_count = __constant_cpu_to_le32(0);
+               cmd_pkt->byte_count = cpu_to_le32(0);
                return;
        }
  
  int
  qla2x00_start_scsi(srb_t *sp)
  {
-       int             ret, nseg;
+       int             nseg;
        unsigned long   flags;
        scsi_qla_host_t *vha;
        struct scsi_cmnd *cmd;
        struct rsp_que *rsp;
  
        /* Setup device pointers. */
-       ret = 0;
        vha = sp->fcport->vha;
        ha = vha->hw;
        reg = &ha->iobase->isp;
        /* Set target ID and LUN number*/
        SET_TARGET_ID(ha, cmd_pkt->target, sp->fcport->loop_id);
        cmd_pkt->lun = cpu_to_le16(cmd->device->lun);
-       cmd_pkt->control_flags = __constant_cpu_to_le16(CF_SIMPLE_TAG);
+       cmd_pkt->control_flags = cpu_to_le16(CF_SIMPLE_TAG);
  
        /* Load SCSI command packet. */
        memcpy(cmd_pkt->scsi_cdb, cmd->cmnd, cmd->cmd_len);
@@@ -454,7 -451,7 +451,7 @@@ voi
  qla2x00_start_iocbs(struct scsi_qla_host *vha, struct req_que *req)
  {
        struct qla_hw_data *ha = vha->hw;
-       device_reg_t __iomem *reg = ISP_QUE_REG(ha, req->id);
+       device_reg_t *reg = ISP_QUE_REG(ha, req->id);
  
        if (IS_P3P_TYPE(ha)) {
                qla82xx_start_iocbs(vha);
@@@ -597,12 -594,11 +594,11 @@@ qla24xx_build_scsi_type_6_iocbs(srb_t *
        cmd = GET_CMD_SP(sp);
  
        /* Update entry type to indicate Command Type 3 IOCB */
-       *((uint32_t *)(&cmd_pkt->entry_type)) =
-               __constant_cpu_to_le32(COMMAND_TYPE_6);
+       *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_6);
  
        /* No data transfer */
        if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
-               cmd_pkt->byte_count = __constant_cpu_to_le32(0);
+               cmd_pkt->byte_count = cpu_to_le32(0);
                return 0;
        }
  
  
        /* Set transfer direction */
        if (cmd->sc_data_direction == DMA_TO_DEVICE) {
-               cmd_pkt->control_flags =
-                   __constant_cpu_to_le16(CF_WRITE_DATA);
+               cmd_pkt->control_flags = cpu_to_le16(CF_WRITE_DATA);
                vha->qla_stats.output_bytes += scsi_bufflen(cmd);
                vha->qla_stats.output_requests++;
        } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
-               cmd_pkt->control_flags =
-                   __constant_cpu_to_le16(CF_READ_DATA);
+               cmd_pkt->control_flags = cpu_to_le16(CF_READ_DATA);
                vha->qla_stats.input_bytes += scsi_bufflen(cmd);
                vha->qla_stats.input_requests++;
        }
   *
   * Returns the number of dsd list needed to store @dsds.
   */
- inline uint16_t
static inline uint16_t
  qla24xx_calc_dsd_lists(uint16_t dsds)
  {
        uint16_t dsd_lists = 0;
   * @cmd_pkt: Command type 3 IOCB
   * @tot_dsds: Total number of segments to transfer
   */
- inline void
static inline void
  qla24xx_build_scsi_iocbs(srb_t *sp, struct cmd_type_7 *cmd_pkt,
      uint16_t tot_dsds)
  {
        struct scsi_cmnd *cmd;
        struct scatterlist *sg;
        int i;
-       struct req_que *req;
  
        cmd = GET_CMD_SP(sp);
  
        /* Update entry type to indicate Command Type 3 IOCB */
-       *((uint32_t *)(&cmd_pkt->entry_type)) =
-           __constant_cpu_to_le32(COMMAND_TYPE_7);
+       *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_7);
  
        /* No data transfer */
        if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) {
-               cmd_pkt->byte_count = __constant_cpu_to_le32(0);
+               cmd_pkt->byte_count = cpu_to_le32(0);
                return;
        }
  
        vha = sp->fcport->vha;
-       req = vha->req;
  
        /* Set transfer direction */
        if (cmd->sc_data_direction == DMA_TO_DEVICE) {
-               cmd_pkt->task_mgmt_flags =
-                   __constant_cpu_to_le16(TMF_WRITE_DATA);
+               cmd_pkt->task_mgmt_flags = cpu_to_le16(TMF_WRITE_DATA);
                vha->qla_stats.output_bytes += scsi_bufflen(cmd);
                vha->qla_stats.output_requests++;
        } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
-               cmd_pkt->task_mgmt_flags =
-                   __constant_cpu_to_le16(TMF_READ_DATA);
+               cmd_pkt->task_mgmt_flags = cpu_to_le16(TMF_READ_DATA);
                vha->qla_stats.input_bytes += scsi_bufflen(cmd);
                vha->qla_stats.input_requests++;
        }
@@@ -809,7 -798,7 +798,7 @@@ qla24xx_set_t10dif_tags(srb_t *sp, stru
         * match LBA in CDB + N
         */
        case SCSI_PROT_DIF_TYPE2:
-               pkt->app_tag = __constant_cpu_to_le16(0);
+               pkt->app_tag = cpu_to_le16(0);
                pkt->app_tag_mask[0] = 0x0;
                pkt->app_tag_mask[1] = 0x0;
  
        case SCSI_PROT_DIF_TYPE1:
                pkt->ref_tag = cpu_to_le32((uint32_t)
                    (0xffffffff & scsi_get_lba(cmd)));
-               pkt->app_tag = __constant_cpu_to_le16(0);
+               pkt->app_tag = cpu_to_le16(0);
                pkt->app_tag_mask[0] = 0x0;
                pkt->app_tag_mask[1] = 0x0;
  
@@@ -933,11 -922,9 +922,9 @@@ qla24xx_walk_and_build_sglist_no_difb(s
        dma_addr_t      sle_dma;
        uint32_t        sle_dma_len, tot_prot_dma_len = 0;
        struct scsi_cmnd *cmd;
-       struct scsi_qla_host *vha;
  
        memset(&sgx, 0, sizeof(struct qla2_sgx));
        if (sp) {
-               vha = sp->fcport->vha;
                cmd = GET_CMD_SP(sp);
                prot_int = cmd->device->sector_size;
  
  
                sg_prot = scsi_prot_sglist(cmd);
        } else if (tc) {
-               vha = tc->vha;
                prot_int      = tc->blk_sz;
                sgx.tot_bytes = tc->bufflen;
                sgx.cur_sg    = tc->sg;
@@@ -1047,15 -1033,12 +1033,12 @@@ qla24xx_walk_and_build_sglist(struct ql
        int     i;
        uint16_t        used_dsds = tot_dsds;
        struct scsi_cmnd *cmd;
-       struct scsi_qla_host *vha;
  
        if (sp) {
                cmd = GET_CMD_SP(sp);
                sgl = scsi_sglist(cmd);
-               vha = sp->fcport->vha;
        } else if (tc) {
                sgl = tc->sg;
-               vha = tc->vha;
        } else {
                BUG();
                return 1;
@@@ -1231,7 -1214,6 +1214,6 @@@ qla24xx_build_scsi_crc_2_iocbs(srb_t *s
        uint32_t                *cur_dsd, *fcp_dl;
        scsi_qla_host_t         *vha;
        struct scsi_cmnd        *cmd;
-       int                     sgc;
        uint32_t                total_bytes = 0;
        uint32_t                data_bytes;
        uint32_t                dif_bytes;
  
        cmd = GET_CMD_SP(sp);
  
-       sgc = 0;
        /* Update entry type to indicate Command Type CRC_2 IOCB */
-       *((uint32_t *)(&cmd_pkt->entry_type)) =
-           __constant_cpu_to_le32(COMMAND_TYPE_CRC_2);
+       *((uint32_t *)(&cmd_pkt->entry_type)) = cpu_to_le32(COMMAND_TYPE_CRC_2);
  
        vha = sp->fcport->vha;
        ha = vha->hw;
        /* No data transfer */
        data_bytes = scsi_bufflen(cmd);
        if (!data_bytes || cmd->sc_data_direction == DMA_NONE) {
-               cmd_pkt->byte_count = __constant_cpu_to_le32(0);
+               cmd_pkt->byte_count = cpu_to_le32(0);
                return QLA_SUCCESS;
        }
  
        /* Set transfer direction */
        if (cmd->sc_data_direction == DMA_TO_DEVICE) {
                cmd_pkt->control_flags =
-                   __constant_cpu_to_le16(CF_WRITE_DATA);
+                   cpu_to_le16(CF_WRITE_DATA);
        } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) {
                cmd_pkt->control_flags =
-                   __constant_cpu_to_le16(CF_READ_DATA);
+                   cpu_to_le16(CF_READ_DATA);
        }
  
        if ((scsi_get_prot_op(cmd) == SCSI_PROT_READ_INSERT) ||
        crc_ctx_pkt->blk_size = cpu_to_le16(blk_size);
        crc_ctx_pkt->prot_opts = cpu_to_le16(fw_prot_opts);
        crc_ctx_pkt->byte_count = cpu_to_le32(data_bytes);
-       crc_ctx_pkt->guard_seed = __constant_cpu_to_le16(0);
+       crc_ctx_pkt->guard_seed = cpu_to_le16(0);
        /* Fibre channel byte count */
        cmd_pkt->byte_count = cpu_to_le32(total_bytes);
        fcp_dl = (uint32_t *)(crc_ctx_pkt->fcp_cmnd.cdb + 16 +
        *fcp_dl = htonl(total_bytes);
  
        if (!data_bytes || cmd->sc_data_direction == DMA_NONE) {
-               cmd_pkt->byte_count = __constant_cpu_to_le32(0);
+               cmd_pkt->byte_count = cpu_to_le32(0);
                return QLA_SUCCESS;
        }
        /* Walks data segments */
  
-       cmd_pkt->control_flags |=
-           __constant_cpu_to_le16(CF_DATA_SEG_DESCR_ENABLE);
+       cmd_pkt->control_flags |= cpu_to_le16(CF_DATA_SEG_DESCR_ENABLE);
  
        if (!bundling && tot_prot_dsds) {
                if (qla24xx_walk_and_build_sglist_no_difb(ha, sp,
  
        if (bundling && tot_prot_dsds) {
                /* Walks dif segments */
-               cmd_pkt->control_flags |=
-                       __constant_cpu_to_le16(CF_DIF_SEG_DESCR_ENABLE);
+               cmd_pkt->control_flags |= cpu_to_le16(CF_DIF_SEG_DESCR_ENABLE);
                cur_dsd = (uint32_t *) &crc_ctx_pkt->u.bundling.dif_address;
                if (qla24xx_walk_and_build_prot_sglist(ha, sp, cur_dsd,
                                tot_prot_dsds, NULL))
@@@ -1442,7 -1420,7 +1420,7 @@@ crc_queuing_error
  int
  qla24xx_start_scsi(srb_t *sp)
  {
-       int             ret, nseg;
+       int             nseg;
        unsigned long   flags;
        uint32_t        *clr_ptr;
        uint32_t        index;
        struct qla_hw_data *ha = vha->hw;
  
        /* Setup device pointers. */
-       ret = 0;
        qla25xx_set_que(sp, &rsp);
        req = vha->req;
  
@@@ -1753,7 -1729,7 +1729,7 @@@ qla24xx_dif_start_scsi(srb_t *sp
        cmd_pkt->entry_count = (uint8_t)req_cnt;
        /* Specify response queue number where completion should happen */
        cmd_pkt->entry_status = (uint8_t) rsp->id;
-       cmd_pkt->timeout = __constant_cpu_to_le16(0);
+       cmd_pkt->timeout = cpu_to_le16(0);
        wmb();
  
        /* Adjust ring index. */
@@@ -1819,7 -1795,7 +1795,7 @@@ qla2x00_alloc_iocbs(scsi_qla_host_t *vh
  {
        struct qla_hw_data *ha = vha->hw;
        struct req_que *req = ha->req_q_map[0];
-       device_reg_t __iomem *reg = ISP_QUE_REG(ha, req->id);
+       device_reg_t *reg = ISP_QUE_REG(ha, req->id);
        uint32_t index, handle;
        request_t *pkt;
        uint16_t cnt, req_cnt;
@@@ -1943,9 -1919,6 +1919,9 @@@ qla24xx_logout_iocb(srb_t *sp, struct l
        logio->entry_type = LOGINOUT_PORT_IOCB_TYPE;
        logio->control_flags =
            cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO);
 +      if (!sp->fcport->tgt_session ||
 +          !sp->fcport->tgt_session->keep_nport_handle)
 +              logio->control_flags |= cpu_to_le16(LCF_FREE_NPORT);
        logio->nport_handle = cpu_to_le16(sp->fcport->loop_id);
        logio->port_id[0] = sp->fcport->d_id.b.al_pa;
        logio->port_id[1] = sp->fcport->d_id.b.area;
@@@ -2044,10 -2017,10 +2020,10 @@@ qla24xx_els_iocb(srb_t *sp, struct els_
          els_iocb->entry_status = 0;
          els_iocb->handle = sp->handle;
          els_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id);
-         els_iocb->tx_dsd_count = __constant_cpu_to_le16(bsg_job->request_payload.sg_cnt);
+       els_iocb->tx_dsd_count = cpu_to_le16(bsg_job->request_payload.sg_cnt);
        els_iocb->vp_index = sp->fcport->vha->vp_idx;
          els_iocb->sof_type = EST_SOFI3;
-         els_iocb->rx_dsd_count = __constant_cpu_to_le16(bsg_job->reply_payload.sg_cnt);
+       els_iocb->rx_dsd_count = cpu_to_le16(bsg_job->reply_payload.sg_cnt);
  
        els_iocb->opcode =
            sp->type == SRB_ELS_CMD_RPT ?
@@@ -2091,7 -2064,6 +2067,6 @@@ qla2x00_ct_iocb(srb_t *sp, ms_iocb_entr
        struct qla_hw_data *ha = vha->hw;
        struct fc_bsg_job *bsg_job = sp->u.bsg_job;
        int loop_iterartion = 0;
-       int cont_iocb_prsnt = 0;
        int entry_count = 1;
  
        memset(ct_iocb, 0, sizeof(ms_iocb_entry_t));
        ct_iocb->entry_status = 0;
        ct_iocb->handle1 = sp->handle;
        SET_TARGET_ID(ha, ct_iocb->loop_id, sp->fcport->loop_id);
-       ct_iocb->status = __constant_cpu_to_le16(0);
-       ct_iocb->control_flags = __constant_cpu_to_le16(0);
+       ct_iocb->status = cpu_to_le16(0);
+       ct_iocb->control_flags = cpu_to_le16(0);
        ct_iocb->timeout = 0;
        ct_iocb->cmd_dsd_count =
-           __constant_cpu_to_le16(bsg_job->request_payload.sg_cnt);
+           cpu_to_le16(bsg_job->request_payload.sg_cnt);
        ct_iocb->total_dsd_count =
-           __constant_cpu_to_le16(bsg_job->request_payload.sg_cnt + 1);
+           cpu_to_le16(bsg_job->request_payload.sg_cnt + 1);
        ct_iocb->req_bytecount =
            cpu_to_le32(bsg_job->request_payload.payload_len);
        ct_iocb->rsp_bytecount =
                            vha->hw->req_q_map[0]);
                        cur_dsd = (uint32_t *) cont_pkt->dseg_0_address;
                        avail_dsds = 5;
-                       cont_iocb_prsnt = 1;
                        entry_count++;
                }
  
@@@ -2170,7 -2141,6 +2144,6 @@@ qla24xx_ct_iocb(srb_t *sp, struct ct_en
        struct qla_hw_data *ha = vha->hw;
        struct fc_bsg_job *bsg_job = sp->u.bsg_job;
        int loop_iterartion = 0;
-       int cont_iocb_prsnt = 0;
        int entry_count = 1;
  
        ct_iocb->entry_type = CT_IOCB_TYPE;
  
        ct_iocb->nport_handle = cpu_to_le16(sp->fcport->loop_id);
        ct_iocb->vp_index = sp->fcport->vha->vp_idx;
-         ct_iocb->comp_status = __constant_cpu_to_le16(0);
+       ct_iocb->comp_status = cpu_to_le16(0);
  
        ct_iocb->cmd_dsd_count =
-             __constant_cpu_to_le16(bsg_job->request_payload.sg_cnt);
+               cpu_to_le16(bsg_job->request_payload.sg_cnt);
          ct_iocb->timeout = 0;
          ct_iocb->rsp_dsd_count =
-             __constant_cpu_to_le16(bsg_job->reply_payload.sg_cnt);
+               cpu_to_le16(bsg_job->reply_payload.sg_cnt);
          ct_iocb->rsp_byte_count =
              cpu_to_le32(bsg_job->reply_payload.payload_len);
          ct_iocb->cmd_byte_count =
                            ha->req_q_map[0]);
                        cur_dsd = (uint32_t *) cont_pkt->dseg_0_address;
                        avail_dsds = 5;
-                       cont_iocb_prsnt = 1;
                        entry_count++;
                }
  
  int
  qla82xx_start_scsi(srb_t *sp)
  {
-       int             ret, nseg;
+       int             nseg;
        unsigned long   flags;
        struct scsi_cmnd *cmd;
        uint32_t        *clr_ptr;
        struct rsp_que *rsp = NULL;
  
        /* Setup device pointers. */
-       ret = 0;
        reg = &ha->iobase->isp82;
        cmd = GET_CMD_SP(sp);
        req = vha->req;
@@@ -2539,16 -2507,12 +2510,12 @@@ sufficient_dsds
        /* write, read and verify logic */
        dbval = dbval | (req->id << 8) | (req->ring_index << 16);
        if (ql2xdbwr)
-               qla82xx_wr_32(ha, ha->nxdb_wr_ptr, dbval);
+               qla82xx_wr_32(ha, (uintptr_t __force)ha->nxdb_wr_ptr, dbval);
        else {
-               WRT_REG_DWORD(
-                       (unsigned long __iomem *)ha->nxdb_wr_ptr,
-                       dbval);
+               WRT_REG_DWORD(ha->nxdb_wr_ptr, dbval);
                wmb();
-               while (RD_REG_DWORD((void __iomem *)ha->nxdb_rd_ptr) != dbval) {
-                       WRT_REG_DWORD(
-                               (unsigned long __iomem *)ha->nxdb_wr_ptr,
-                               dbval);
+               while (RD_REG_DWORD(ha->nxdb_rd_ptr) != dbval) {
+                       WRT_REG_DWORD(ha->nxdb_wr_ptr, dbval);
                        wmb();
                }
        }
@@@ -2682,7 -2646,7 +2649,7 @@@ qla25xx_build_bidir_iocb(srb_t *sp, str
  
        /*Update entry type to indicate bidir command */
        *((uint32_t *)(&cmd_pkt->entry_type)) =
-               __constant_cpu_to_le32(COMMAND_BIDIRECTIONAL);
+               cpu_to_le32(COMMAND_BIDIRECTIONAL);
  
        /* Set the transfer direction, in this set both flags
         * Also set the BD_WRAP_BACK flag, firmware will take care
         */
        cmd_pkt->wr_dseg_count = cpu_to_le16(bsg_job->request_payload.sg_cnt);
        cmd_pkt->rd_dseg_count = cpu_to_le16(bsg_job->reply_payload.sg_cnt);
-       cmd_pkt->control_flags =
-                       __constant_cpu_to_le16(BD_WRITE_DATA | BD_READ_DATA |
+       cmd_pkt->control_flags = cpu_to_le16(BD_WRITE_DATA | BD_READ_DATA |
                                                        BD_WRAP_BACK);
  
        req_data_len = rsp_data_len = bsg_job->request_payload.payload_len;
index b2f713ad90346093b40b515b70be4062666c6b80,97b5bd569d036601e2dcdd1226bc2f323df3d92c..cb11e04be5685fc42d4dc5c6afa89635835be63e
@@@ -555,7 -555,9 +555,9 @@@ qla2x00_get_fw_version(scsi_qla_host_t 
        if (IS_FWI2_CAPABLE(ha))
                mcp->in_mb |= MBX_17|MBX_16|MBX_15;
        if (IS_QLA27XX(ha))
-               mcp->in_mb |= MBX_21|MBX_20|MBX_19|MBX_18;
+               mcp->in_mb |= MBX_23 | MBX_22 | MBX_21 | MBX_20 | MBX_19 |
+                   MBX_18 | MBX_14 | MBX_13 | MBX_11 | MBX_10 | MBX_9 | MBX_8;
        mcp->flags = 0;
        mcp->tov = MBX_TOV_SECONDS;
        rval = qla2x00_mailbox_command(vha, mcp);
                ha->fw_memory_size = 0x1FFFF;           /* Defaults to 128KB. */
        else
                ha->fw_memory_size = (mcp->mb[5] << 16) | mcp->mb[4];
        if (IS_QLA81XX(vha->hw) || IS_QLA8031(vha->hw) || IS_QLA8044(ha)) {
                ha->mpi_version[0] = mcp->mb[10] & 0xff;
                ha->mpi_version[1] = mcp->mb[11] >> 8;
                ha->phy_version[1] = mcp->mb[9] >> 8;
                ha->phy_version[2] = mcp->mb[9] & 0xff;
        }
        if (IS_FWI2_CAPABLE(ha)) {
                ha->fw_attributes_h = mcp->mb[15];
                ha->fw_attributes_ext[0] = mcp->mb[16];
                    "%s: Ext_FwAttributes Upper: 0x%x, Lower: 0x%x.\n",
                    __func__, mcp->mb[17], mcp->mb[16]);
        }
        if (IS_QLA27XX(ha)) {
+               ha->mpi_version[0] = mcp->mb[10] & 0xff;
+               ha->mpi_version[1] = mcp->mb[11] >> 8;
+               ha->mpi_version[2] = mcp->mb[11] & 0xff;
+               ha->pep_version[0] = mcp->mb[13] & 0xff;
+               ha->pep_version[1] = mcp->mb[14] >> 8;
+               ha->pep_version[2] = mcp->mb[14] & 0xff;
                ha->fw_shared_ram_start = (mcp->mb[19] << 16) | mcp->mb[18];
                ha->fw_shared_ram_end = (mcp->mb[21] << 16) | mcp->mb[20];
        }
@@@ -1135,20 -1146,22 +1146,22 @@@ qla2x00_get_adapter_id(scsi_qla_host_t 
                        vha->fcoe_vn_port_mac[0] = mcp->mb[13] & 0xff;
                }
                /* If FA-WWN supported */
-               if (mcp->mb[7] & BIT_14) {
-                       vha->port_name[0] = MSB(mcp->mb[16]);
-                       vha->port_name[1] = LSB(mcp->mb[16]);
-                       vha->port_name[2] = MSB(mcp->mb[17]);
-                       vha->port_name[3] = LSB(mcp->mb[17]);
-                       vha->port_name[4] = MSB(mcp->mb[18]);
-                       vha->port_name[5] = LSB(mcp->mb[18]);
-                       vha->port_name[6] = MSB(mcp->mb[19]);
-                       vha->port_name[7] = LSB(mcp->mb[19]);
-                       fc_host_port_name(vha->host) =
-                           wwn_to_u64(vha->port_name);
-                       ql_dbg(ql_dbg_mbx, vha, 0x10ca,
-                           "FA-WWN acquired %016llx\n",
-                           wwn_to_u64(vha->port_name));
+               if (IS_FAWWN_CAPABLE(vha->hw)) {
+                       if (mcp->mb[7] & BIT_14) {
+                               vha->port_name[0] = MSB(mcp->mb[16]);
+                               vha->port_name[1] = LSB(mcp->mb[16]);
+                               vha->port_name[2] = MSB(mcp->mb[17]);
+                               vha->port_name[3] = LSB(mcp->mb[17]);
+                               vha->port_name[4] = MSB(mcp->mb[18]);
+                               vha->port_name[5] = LSB(mcp->mb[18]);
+                               vha->port_name[6] = MSB(mcp->mb[19]);
+                               vha->port_name[7] = LSB(mcp->mb[19]);
+                               fc_host_port_name(vha->host) =
+                                   wwn_to_u64(vha->port_name);
+                               ql_dbg(ql_dbg_mbx, vha, 0x10ca,
+                                   "FA-WWN acquired %016llx\n",
+                                   wwn_to_u64(vha->port_name));
+                       }
                }
        }
  
@@@ -1239,7 -1252,7 +1252,7 @@@ qla2x00_init_firmware(scsi_qla_host_t *
            "Entered %s.\n", __func__);
  
        if (IS_P3P_TYPE(ha) && ql2xdbwr)
-               qla82xx_wr_32(ha, ha->nxdb_wr_ptr,
+               qla82xx_wr_32(ha, (uintptr_t __force)ha->nxdb_wr_ptr,
                        (0x04 | (ha->portnum << 5) | (0 << 8) | (0 << 16)));
  
        if (ha->flags.npiv_supported)
@@@ -1865,7 -1878,6 +1878,6 @@@ qla24xx_login_fabric(scsi_qla_host_t *v
        uint32_t        iop[2];
        struct qla_hw_data *ha = vha->hw;
        struct req_que *req;
-       struct rsp_que *rsp;
  
        ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1061,
            "Entered %s.\n", __func__);
                req = ha->req_q_map[0];
        else
                req = vha->req;
-       rsp = req->rsp;
  
        lg = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, &lg_dma);
        if (lg == NULL) {
        lg->entry_count = 1;
        lg->handle = MAKE_HANDLE(req->id, lg->handle);
        lg->nport_handle = cpu_to_le16(loop_id);
-       lg->control_flags = __constant_cpu_to_le16(LCF_COMMAND_PLOGI);
+       lg->control_flags = cpu_to_le16(LCF_COMMAND_PLOGI);
        if (opt & BIT_0)
-               lg->control_flags |= __constant_cpu_to_le16(LCF_COND_PLOGI);
+               lg->control_flags |= cpu_to_le16(LCF_COND_PLOGI);
        if (opt & BIT_1)
-               lg->control_flags |= __constant_cpu_to_le16(LCF_SKIP_PRLI);
+               lg->control_flags |= cpu_to_le16(LCF_SKIP_PRLI);
        lg->port_id[0] = al_pa;
        lg->port_id[1] = area;
        lg->port_id[2] = domain;
                    "Failed to complete IOCB -- error status (%x).\n",
                    lg->entry_status);
                rval = QLA_FUNCTION_FAILED;
-       } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
+       } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) {
                iop[0] = le32_to_cpu(lg->io_parameter[0]);
                iop[1] = le32_to_cpu(lg->io_parameter[1]);
  
                        mb[10] |= BIT_0;        /* Class 2. */
                if (lg->io_parameter[9] || lg->io_parameter[10])
                        mb[10] |= BIT_1;        /* Class 3. */
-               if (lg->io_parameter[0] & __constant_cpu_to_le32(BIT_7))
+               if (lg->io_parameter[0] & cpu_to_le32(BIT_7))
                        mb[10] |= BIT_7;        /* Confirmed Completion
                                                 * Allowed
                                                 */
@@@ -2142,7 -2153,6 +2153,6 @@@ qla24xx_fabric_logout(scsi_qla_host_t *
        dma_addr_t      lg_dma;
        struct qla_hw_data *ha = vha->hw;
        struct req_que *req;
-       struct rsp_que *rsp;
  
        ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x106d,
            "Entered %s.\n", __func__);
                req = ha->req_q_map[0];
        else
                req = vha->req;
-       rsp = req->rsp;
        lg->entry_type = LOGINOUT_PORT_IOCB_TYPE;
        lg->entry_count = 1;
        lg->handle = MAKE_HANDLE(req->id, lg->handle);
        lg->nport_handle = cpu_to_le16(loop_id);
        lg->control_flags =
-           __constant_cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO|
+           cpu_to_le16(LCF_COMMAND_LOGO|LCF_IMPL_LOGO|
                LCF_FREE_NPORT);
        lg->port_id[0] = al_pa;
        lg->port_id[1] = area;
                    "Failed to complete IOCB -- error status (%x).\n",
                    lg->entry_status);
                rval = QLA_FUNCTION_FAILED;
-       } else if (lg->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
+       } else if (lg->comp_status != cpu_to_le16(CS_COMPLETE)) {
                ql_dbg(ql_dbg_mbx, vha, 0x1071,
                    "Failed to complete IOCB -- completion status (%x) "
                    "ioparam=%x/%x.\n", le16_to_cpu(lg->comp_status),
@@@ -2415,8 -2424,7 +2424,8 @@@ qla2x00_get_resource_cnts(scsi_qla_host
                        *orig_iocb_cnt = mcp->mb[10];
                if (vha->hw->flags.npiv_supported && max_npiv_vports)
                        *max_npiv_vports = mcp->mb[11];
 -              if ((IS_QLA81XX(vha->hw) || IS_QLA83XX(vha->hw)) && max_fcfs)
 +              if ((IS_QLA81XX(vha->hw) || IS_QLA83XX(vha->hw) ||
 +                  IS_QLA27XX(vha->hw)) && max_fcfs)
                        *max_fcfs = mcp->mb[12];
        }
  
@@@ -2673,7 -2681,7 +2682,7 @@@ qla24xx_abort_command(srb_t *sp
                    "Failed to complete IOCB -- error status (%x).\n",
                    abt->entry_status);
                rval = QLA_FUNCTION_FAILED;
-       } else if (abt->nport_handle != __constant_cpu_to_le16(0)) {
+       } else if (abt->nport_handle != cpu_to_le16(0)) {
                ql_dbg(ql_dbg_mbx, vha, 0x1090,
                    "Failed to complete IOCB -- completion status (%x).\n",
                    le16_to_cpu(abt->nport_handle));
@@@ -2756,8 -2764,7 +2765,7 @@@ __qla24xx_issue_tmf(char *name, uint32_
                    "Failed to complete IOCB -- error status (%x).\n",
                    sts->entry_status);
                rval = QLA_FUNCTION_FAILED;
-       } else if (sts->comp_status !=
-           __constant_cpu_to_le16(CS_COMPLETE)) {
+       } else if (sts->comp_status != cpu_to_le16(CS_COMPLETE)) {
                ql_dbg(ql_dbg_mbx, vha, 0x1096,
                    "Failed to complete IOCB -- completion status (%x).\n",
                    le16_to_cpu(sts->comp_status));
@@@ -2853,7 -2860,8 +2861,8 @@@ qla2x00_write_serdes_word(scsi_qla_host
        mbx_cmd_t mc;
        mbx_cmd_t *mcp = &mc;
  
-       if (!IS_QLA2031(vha->hw) && !IS_QLA27XX(vha->hw))
+       if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) &&
+           !IS_QLA27XX(vha->hw))
                return QLA_FUNCTION_FAILED;
  
        ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1182,
@@@ -2891,7 -2899,8 +2900,8 @@@ qla2x00_read_serdes_word(scsi_qla_host_
        mbx_cmd_t mc;
        mbx_cmd_t *mcp = &mc;
  
-       if (!IS_QLA2031(vha->hw) && !IS_QLA27XX(vha->hw))
+       if (!IS_QLA25XX(vha->hw) && !IS_QLA2031(vha->hw) &&
+           !IS_QLA27XX(vha->hw))
                return QLA_FUNCTION_FAILED;
  
        ql_dbg(ql_dbg_mbx + ql_dbg_verbose, vha, 0x1185,
@@@ -3483,7 -3492,7 +3493,7 @@@ qla24xx_modify_vp_config(scsi_qla_host_
                    "Failed to complete IOCB -- error status (%x).\n",
                    vpmod->comp_status);
                rval = QLA_FUNCTION_FAILED;
-       } else if (vpmod->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
+       } else if (vpmod->comp_status != cpu_to_le16(CS_COMPLETE)) {
                ql_dbg(ql_dbg_mbx, vha, 0x10bf,
                    "Failed to complete IOCB -- completion status (%x).\n",
                    le16_to_cpu(vpmod->comp_status));
@@@ -3542,7 -3551,7 +3552,7 @@@ qla24xx_control_vp(scsi_qla_host_t *vha
        vce->entry_type = VP_CTRL_IOCB_TYPE;
        vce->entry_count = 1;
        vce->command = cpu_to_le16(cmd);
-       vce->vp_count = __constant_cpu_to_le16(1);
+       vce->vp_count = cpu_to_le16(1);
  
        /* index map in firmware starts with 1; decrement index
         * this is ok as we never use index 0
                    "Failed to complete IOCB -- error status (%x).\n",
                    vce->entry_status);
                rval = QLA_FUNCTION_FAILED;
-       } else if (vce->comp_status != __constant_cpu_to_le16(CS_COMPLETE)) {
+       } else if (vce->comp_status != cpu_to_le16(CS_COMPLETE)) {
                ql_dbg(ql_dbg_mbx, vha, 0x10c5,
                    "Failed to complet IOCB -- completion status (%x).\n",
                    le16_to_cpu(vce->comp_status));
@@@ -3899,7 -3908,7 +3909,7 @@@ qla25xx_init_rsp_que(struct scsi_qla_ho
        spin_lock_irqsave(&ha->hardware_lock, flags);
        if (!(rsp->options & BIT_0)) {
                WRT_REG_DWORD(rsp->rsp_q_out, 0);
 -              if (!IS_QLA83XX(ha))
 +              if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
                        WRT_REG_DWORD(rsp->rsp_q_in, 0);
        }
  
@@@ -5346,7 -5355,7 +5356,7 @@@ qla83xx_restart_nic_firmware(scsi_qla_h
        mbx_cmd_t *mcp = &mc;
        struct qla_hw_data *ha = vha->hw;
  
 -      if (!IS_QLA83XX(ha))
 +      if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
                return QLA_FUNCTION_FAILED;
  
        ql_dbg(ql_dbg_mbx, vha, 0x1143, "Entered %s.\n", __func__);
index 8a5cac8448c76518107d95744b39ea76717958f5,913a72506748a9e346316c02af09d23cae352a57..c2dd17b1d26fa6b275268256623a167a8682019d
@@@ -656,7 -656,7 +656,7 @@@ qla2x00_sp_compl(void *data, void *ptr
                    "SP reference-count to ZERO -- sp=%p cmd=%p.\n",
                    sp, GET_CMD_SP(sp));
                if (ql2xextended_error_logging & ql_dbg_io)
-                       BUG();
+                       WARN_ON(atomic_read(&sp->ref_count) == 0);
                return;
        }
        if (!atomic_dec_and_test(&sp->ref_count))
@@@ -958,8 -958,8 +958,8 @@@ qla2xxx_eh_abort(struct scsi_cmnd *cmd
        }
  
        ql_dbg(ql_dbg_taskm, vha, 0x8002,
-           "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p\n",
-           vha->host_no, id, lun, sp, cmd);
+           "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n",
+           vha->host_no, id, lun, sp, cmd, sp->handle);
  
        /* Get a reference to the sp and drop the lock.*/
        sp_get(sp);
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
        rval = ha->isp_ops->abort_command(sp);
        if (rval) {
-               if (rval == QLA_FUNCTION_PARAMETER_ERROR) {
-                       /*
-                        * Decrement the ref_count since we can't find the
-                        * command
-                        */
-                       atomic_dec(&sp->ref_count);
+               if (rval == QLA_FUNCTION_PARAMETER_ERROR)
                        ret = SUCCESS;
-               else
+               else
                        ret = FAILED;
  
                ql_dbg(ql_dbg_taskm, vha, 0x8003,
        }
  
        spin_lock_irqsave(&ha->hardware_lock, flags);
-       /*
-        * Clear the slot in the oustanding_cmds array if we can't find the
-        * command to reclaim the resources.
-        */
-       if (rval == QLA_FUNCTION_PARAMETER_ERROR)
-               vha->req->outstanding_cmds[sp->handle] = NULL;
        sp->done(ha, sp, 0);
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
  
@@@ -2219,6 -2208,13 +2208,13 @@@ qla2x00_set_isp_flags(struct qla_hw_dat
                ha->device_type |= DT_IIDMA;
                ha->fw_srisc_address = RISC_START_ADDRESS_2400;
                break;
+       case PCI_DEVICE_ID_QLOGIC_ISP2261:
+               ha->device_type |= DT_ISP2261;
+               ha->device_type |= DT_ZIO_SUPPORTED;
+               ha->device_type |= DT_FWI2;
+               ha->device_type |= DT_IIDMA;
+               ha->fw_srisc_address = RISC_START_ADDRESS_2400;
+               break;
        }
  
        if (IS_QLA82XX(ha))
@@@ -2296,7 -2292,8 +2292,8 @@@ qla2x00_probe_one(struct pci_dev *pdev
            pdev->device == PCI_DEVICE_ID_QLOGIC_ISPF001 ||
            pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8044 ||
            pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2071 ||
-           pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2271) {
+           pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2271 ||
+           pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2261) {
                bars = pci_select_bars(pdev, IORESOURCE_MEM);
                mem_only = 1;
                ql_dbg_pci(ql_dbg_init, pdev, 0x0007,
                ha->mbx_count = MAILBOX_REGISTER_COUNT;
                req_length = REQUEST_ENTRY_CNT_24XX;
                rsp_length = RESPONSE_ENTRY_CNT_2300;
 +              ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX;
                ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
                ha->init_cb_size = sizeof(struct mid_init_cb_81xx);
                ha->gid_list_info_size = 8;
@@@ -2974,7 -2970,6 +2971,6 @@@ qla2x00_shutdown(struct pci_dev *pdev
  static void
  qla2x00_delete_all_vps(struct qla_hw_data *ha, scsi_qla_host_t *base_vha)
  {
-       struct Scsi_Host *scsi_host;
        scsi_qla_host_t *vha;
        unsigned long flags;
  
                BUG_ON(base_vha->list.next == &ha->vp_list);
                /* This assumes first entry in ha->vp_list is always base vha */
                vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list);
-               scsi_host = scsi_host_get(vha->host);
+               scsi_host_get(vha->host);
  
                spin_unlock_irqrestore(&ha->vport_slock, flags);
                mutex_unlock(&ha->vport_lock);
@@@ -3230,15 -3225,11 +3226,15 @@@ qla2x00_schedule_rport_del(struct scsi_
                spin_lock_irqsave(vha->host->host_lock, flags);
                fcport->drport = rport;
                spin_unlock_irqrestore(vha->host->host_lock, flags);
 +              qlt_do_generation_tick(vha, &base_vha->total_fcport_update_gen);
                set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags);
                qla2xxx_wake_dpc(base_vha);
        } else {
 -              fc_remote_port_delete(rport);
 -              qlt_fc_port_deleted(vha, fcport);
 +              int now;
 +              if (rport)
 +                      fc_remote_port_delete(rport);
 +              qlt_do_generation_tick(vha, &now);
 +              qlt_fc_port_deleted(vha, fcport, now);
        }
  }
  
@@@ -3275,9 -3266,10 +3271,10 @@@ void qla2x00_mark_device_lost(scsi_qla_
        if (!do_login)
                return;
  
+       set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
        if (fcport->login_retry == 0) {
                fcport->login_retry = vha->hw->login_retry_count;
-               set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
  
                ql_dbg(ql_dbg_disc, vha, 0x2067,
                    "Port login retry %8phN, id = 0x%04x retry cnt=%d.\n",
@@@ -3768,11 -3760,8 +3765,11 @@@ struct scsi_qla_host *qla2x00_create_ho
        INIT_LIST_HEAD(&vha->vp_fcports);
        INIT_LIST_HEAD(&vha->work_list);
        INIT_LIST_HEAD(&vha->list);
 +      INIT_LIST_HEAD(&vha->qla_cmd_list);
 +      INIT_LIST_HEAD(&vha->qla_sess_op_cmd_list);
  
        spin_lock_init(&vha->work_lock);
 +      spin_lock_init(&vha->cmd_list_lock);
  
        sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no);
        ql_dbg(ql_dbg_init, vha, 0x0041,
@@@ -4801,7 -4790,6 +4798,6 @@@ qla2x00_disable_board_on_pci_error(stru
  static int
  qla2x00_do_dpc(void *data)
  {
-       int             rval;
        scsi_qla_host_t *base_vha;
        struct qla_hw_data *ha;
  
@@@ -5033,7 -5021,7 +5029,7 @@@ loop_resync_check
                        if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE,
                            &base_vha->dpc_flags))) {
  
-                               rval = qla2x00_loop_resync(base_vha);
+                               qla2x00_loop_resync(base_vha);
  
                                clear_bit(LOOP_RESYNC_ACTIVE,
                                                &base_vha->dpc_flags);
@@@ -5717,6 -5705,7 +5713,7 @@@ static struct pci_device_id qla2xxx_pci
        { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8044) },
        { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2071) },
        { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2271) },
+       { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2261) },
        { 0 },
  };
  MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl);
index 2feb5f38edcd98ec3607f18a020d1cedee5bfc40,e44d54231cdc06a86609891d0da1a491bd3f51b1..3272ed5bbcc7108d7aa245fe7d1e45068d54dc35
@@@ -316,7 -316,7 +316,7 @@@ qla2x00_clear_nvram_protection(struct q
  
        wprot_old = cpu_to_le16(qla2x00_get_nvram_word(ha, ha->nvram_base));
        stat = qla2x00_write_nvram_word_tmo(ha, ha->nvram_base,
-           __constant_cpu_to_le16(0x1234), 100000);
+                                           cpu_to_le16(0x1234), 100000);
        wprot = cpu_to_le16(qla2x00_get_nvram_word(ha, ha->nvram_base));
        if (stat != QLA_SUCCESS || wprot != 0x1234) {
                /* Write enable. */
@@@ -691,9 -691,9 +691,9 @@@ qla2xxx_get_flt_info(scsi_qla_host_t *v
        region = (struct qla_flt_region *)&flt[1];
        ha->isp_ops->read_optrom(vha, (uint8_t *)req->ring,
            flt_addr << 2, OPTROM_BURST_SIZE);
-       if (*wptr == __constant_cpu_to_le16(0xffff))
+       if (*wptr == cpu_to_le16(0xffff))
                goto no_flash_data;
-       if (flt->version != __constant_cpu_to_le16(1)) {
+       if (flt->version != cpu_to_le16(1)) {
                ql_log(ql_log_warn, vha, 0x0047,
                    "Unsupported FLT detected: version=0x%x length=0x%x checksum=0x%x.\n",
                    le16_to_cpu(flt->version), le16_to_cpu(flt->length),
@@@ -892,7 -892,7 +892,7 @@@ qla2xxx_get_fdt_info(scsi_qla_host_t *v
        fdt = (struct qla_fdt_layout *)req->ring;
        ha->isp_ops->read_optrom(vha, (uint8_t *)req->ring,
            ha->flt_region_fdt << 2, OPTROM_BURST_SIZE);
-       if (*wptr == __constant_cpu_to_le16(0xffff))
+       if (*wptr == cpu_to_le16(0xffff))
                goto no_flash_data;
        if (fdt->sig[0] != 'Q' || fdt->sig[1] != 'L' || fdt->sig[2] != 'I' ||
            fdt->sig[3] != 'D')
@@@ -991,7 -991,7 +991,7 @@@ qla2xxx_get_idc_param(scsi_qla_host_t *
        ha->isp_ops->read_optrom(vha, (uint8_t *)req->ring,
                QLA82XX_IDC_PARAM_ADDR , 8);
  
-       if (*wptr == __constant_cpu_to_le32(0xffffffff)) {
+       if (*wptr == cpu_to_le32(0xffffffff)) {
                ha->fcoe_dev_init_timeout = QLA82XX_ROM_DEV_INIT_TIMEOUT;
                ha->fcoe_reset_timeout = QLA82XX_ROM_DRV_RESET_ACK_TIMEOUT;
        } else {
@@@ -1051,9 -1051,9 +1051,9 @@@ qla2xxx_flash_npiv_conf(scsi_qla_host_
  
        ha->isp_ops->read_optrom(vha, (uint8_t *)&hdr,
            ha->flt_region_npiv_conf << 2, sizeof(struct qla_npiv_header));
-       if (hdr.version == __constant_cpu_to_le16(0xffff))
+       if (hdr.version == cpu_to_le16(0xffff))
                return;
-       if (hdr.version != __constant_cpu_to_le16(1)) {
+       if (hdr.version != cpu_to_le16(1)) {
                ql_dbg(ql_dbg_user, vha, 0x7090,
                    "Unsupported NPIV-Config "
                    "detected: version=0x%x entries=0x%x checksum=0x%x.\n",
@@@ -1697,7 -1697,7 +1697,7 @@@ qla83xx_select_led_port(struct qla_hw_d
  {
        uint32_t led_select_value = 0;
  
 -      if (!IS_QLA83XX(ha))
 +      if (!IS_QLA83XX(ha) && !IS_QLA27XX(ha))
                goto out;
  
        if (ha->port_no == 0)
index 58651ecbd88c206e0be3b996c007baeaddc8cb19,6b7736d02534d577e52d7113eadebc5a5e5f3f29..75514a15bea03ebcf8929ff317f97aeb17b59ae5
@@@ -113,11 -113,6 +113,11 @@@ static void qlt_abort_cmd_on_host_reset
  static void qlt_alloc_qfull_cmd(struct scsi_qla_host *vha,
        struct atio_from_isp *atio, uint16_t status, int qfull);
  static void qlt_disable_vha(struct scsi_qla_host *vha);
 +static void qlt_clear_tgt_db(struct qla_tgt *tgt);
 +static void qlt_send_notify_ack(struct scsi_qla_host *vha,
 +      struct imm_ntfy_from_isp *ntfy,
 +      uint32_t add_flags, uint16_t resp_code, int resp_code_valid,
 +      uint16_t srr_flags, uint16_t srr_reject_code, uint8_t srr_explan);
  /*
   * Global Variables
   */
@@@ -127,16 -122,6 +127,16 @@@ static struct workqueue_struct *qla_tgt
  static DEFINE_MUTEX(qla_tgt_mutex);
  static LIST_HEAD(qla_tgt_glist);
  
 +/* This API intentionally takes dest as a parameter, rather than returning
 + * int value to avoid caller forgetting to issue wmb() after the store */
 +void qlt_do_generation_tick(struct scsi_qla_host *vha, int *dest)
 +{
 +      scsi_qla_host_t *base_vha = pci_get_drvdata(vha->hw->pdev);
 +      *dest = atomic_inc_return(&base_vha->generation_tick);
 +      /* memory barrier */
 +      wmb();
 +}
 +
  /* ha->hardware_lock supposed to be held on entry (to protect tgt->sess_list) */
  static struct qla_tgt_sess *qlt_find_sess_by_port_name(
        struct qla_tgt *tgt,
@@@ -396,73 -381,14 +396,73 @@@ static void qlt_free_session_done(struc
        struct qla_tgt *tgt = sess->tgt;
        struct scsi_qla_host *vha = sess->vha;
        struct qla_hw_data *ha = vha->hw;
 +      unsigned long flags;
 +      bool logout_started = false;
 +      fc_port_t fcport;
 +
 +      ql_dbg(ql_dbg_tgt_mgt, vha, 0xf084,
 +              "%s: se_sess %p / sess %p from port %8phC loop_id %#04x"
 +              " s_id %02x:%02x:%02x logout %d keep %d plogi %d\n",
 +              __func__, sess->se_sess, sess, sess->port_name, sess->loop_id,
 +              sess->s_id.b.domain, sess->s_id.b.area, sess->s_id.b.al_pa,
 +              sess->logout_on_delete, sess->keep_nport_handle,
 +              sess->plogi_ack_needed);
  
        BUG_ON(!tgt);
 +
 +      if (sess->logout_on_delete) {
 +              int rc;
 +
 +              memset(&fcport, 0, sizeof(fcport));
 +              fcport.loop_id = sess->loop_id;
 +              fcport.d_id = sess->s_id;
 +              memcpy(fcport.port_name, sess->port_name, WWN_SIZE);
 +              fcport.vha = vha;
 +              fcport.tgt_session = sess;
 +
 +              rc = qla2x00_post_async_logout_work(vha, &fcport, NULL);
 +              if (rc != QLA_SUCCESS)
 +                      ql_log(ql_log_warn, vha, 0xf085,
 +                             "Schedule logo failed sess %p rc %d\n",
 +                             sess, rc);
 +              else
 +                      logout_started = true;
 +      }
 +
        /*
         * Release the target session for FC Nexus from fabric module code.
         */
        if (sess->se_sess != NULL)
                ha->tgt.tgt_ops->free_session(sess);
  
 +      if (logout_started) {
 +              bool traced = false;
 +
 +              while (!ACCESS_ONCE(sess->logout_completed)) {
 +                      if (!traced) {
 +                              ql_dbg(ql_dbg_tgt_mgt, vha, 0xf086,
 +                                      "%s: waiting for sess %p logout\n",
 +                                      __func__, sess);
 +                              traced = true;
 +                      }
 +                      msleep(100);
 +              }
 +
 +              ql_dbg(ql_dbg_tgt_mgt, vha, 0xf087,
 +                      "%s: sess %p logout completed\n",
 +                      __func__, sess);
 +      }
 +
 +      spin_lock_irqsave(&ha->hardware_lock, flags);
 +
 +      if (sess->plogi_ack_needed)
 +              qlt_send_notify_ack(vha, &sess->tm_iocb,
 +                                  0, 0, 0, 0, 0, 0);
 +
 +      list_del(&sess->sess_list_entry);
 +
 +      spin_unlock_irqrestore(&ha->hardware_lock, flags);
 +
        ql_dbg(ql_dbg_tgt_mgt, vha, 0xf001,
            "Unregistration of sess %p finished\n", sess);
  
@@@ -483,9 -409,9 +483,9 @@@ void qlt_unreg_sess(struct qla_tgt_ses
  
        vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess);
  
 -      list_del(&sess->sess_list_entry);
 -      if (sess->deleted)
 -              list_del(&sess->del_list_entry);
 +      if (!list_empty(&sess->del_list_entry))
 +              list_del_init(&sess->del_list_entry);
 +      sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
  
        INIT_WORK(&sess->free_work, qlt_free_session_done);
        schedule_work(&sess->free_work);
@@@ -505,10 -431,10 +505,10 @@@ static int qlt_reset(struct scsi_qla_ho
  
        loop_id = le16_to_cpu(n->u.isp24.nport_handle);
        if (loop_id == 0xFFFF) {
 -#if 0 /* FIXME: Re-enable Global event handling.. */
                /* Global event */
 -              atomic_inc(&ha->tgt.qla_tgt->tgt_global_resets_count);
 -              qlt_clear_tgt_db(ha->tgt.qla_tgt);
 +              atomic_inc(&vha->vha_tgt.qla_tgt->tgt_global_resets_count);
 +              qlt_clear_tgt_db(vha->vha_tgt.qla_tgt);
 +#if 0 /* FIXME: do we need to choose a session here? */
                if (!list_empty(&ha->tgt.qla_tgt->sess_list)) {
                        sess = list_entry(ha->tgt.qla_tgt->sess_list.next,
                            typeof(*sess), sess_list_entry);
@@@ -563,38 -489,27 +563,38 @@@ static void qlt_schedule_sess_for_delet
        struct qla_tgt *tgt = sess->tgt;
        uint32_t dev_loss_tmo = tgt->ha->port_down_retry_count + 5;
  
 -      if (sess->deleted)
 -              return;
 +      if (sess->deleted) {
 +              /* Upgrade to unconditional deletion in case it was temporary */
 +              if (immediate && sess->deleted == QLA_SESS_DELETION_PENDING)
 +                      list_del(&sess->del_list_entry);
 +              else
 +                      return;
 +      }
  
        ql_dbg(ql_dbg_tgt, sess->vha, 0xe001,
            "Scheduling sess %p for deletion\n", sess);
 -      list_add_tail(&sess->del_list_entry, &tgt->del_sess_list);
 -      sess->deleted = 1;
  
 -      if (immediate)
 +      if (immediate) {
                dev_loss_tmo = 0;
 +              sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
 +              list_add(&sess->del_list_entry, &tgt->del_sess_list);
 +      } else {
 +              sess->deleted = QLA_SESS_DELETION_PENDING;
 +              list_add_tail(&sess->del_list_entry, &tgt->del_sess_list);
 +      }
  
        sess->expires = jiffies + dev_loss_tmo * HZ;
  
        ql_dbg(ql_dbg_tgt, sess->vha, 0xe048,
 -          "qla_target(%d): session for port %8phC (loop ID %d) scheduled for "
 -          "deletion in %u secs (expires: %lu) immed: %d\n",
 -          sess->vha->vp_idx, sess->port_name, sess->loop_id, dev_loss_tmo,
 -          sess->expires, immediate);
 +          "qla_target(%d): session for port %8phC (loop ID %d s_id %02x:%02x:%02x)"
 +          " scheduled for deletion in %u secs (expires: %lu) immed: %d, logout: %d, gen: %#x\n",
 +          sess->vha->vp_idx, sess->port_name, sess->loop_id,
 +          sess->s_id.b.domain, sess->s_id.b.area, sess->s_id.b.al_pa,
 +          dev_loss_tmo, sess->expires, immediate, sess->logout_on_delete,
 +          sess->generation);
  
        if (immediate)
 -              schedule_delayed_work(&tgt->sess_del_work, 0);
 +              mod_delayed_work(system_wq, &tgt->sess_del_work, 0);
        else
                schedule_delayed_work(&tgt->sess_del_work,
                    sess->expires - jiffies);
@@@ -663,9 -578,9 +663,9 @@@ out_free_id_list
  /* ha->hardware_lock supposed to be held on entry */
  static void qlt_undelete_sess(struct qla_tgt_sess *sess)
  {
 -      BUG_ON(!sess->deleted);
 +      BUG_ON(sess->deleted != QLA_SESS_DELETION_PENDING);
  
 -      list_del(&sess->del_list_entry);
 +      list_del_init(&sess->del_list_entry);
        sess->deleted = 0;
  }
  
@@@ -684,9 -599,7 +684,9 @@@ static void qlt_del_sess_work_fn(struc
                    del_list_entry);
                elapsed = jiffies;
                if (time_after_eq(elapsed, sess->expires)) {
 -                      qlt_undelete_sess(sess);
 +                      /* No turning back */
 +                      list_del_init(&sess->del_list_entry);
 +                      sess->deleted = QLA_SESS_DELETION_IN_PROGRESS;
  
                        ql_dbg(ql_dbg_tgt_mgt, vha, 0xf004,
                            "Timeout: sess %p about to be deleted\n",
@@@ -730,13 -643,6 +730,13 @@@ static struct qla_tgt_sess *qlt_create_
                            fcport->d_id.b.al_pa, fcport->d_id.b.area,
                            fcport->loop_id);
  
 +                      /* Cannot undelete at this point */
 +                      if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
 +                              spin_unlock_irqrestore(&ha->hardware_lock,
 +                                  flags);
 +                              return NULL;
 +                      }
 +
                        if (sess->deleted)
                                qlt_undelete_sess(sess);
  
  
                        if (sess->local && !local)
                                sess->local = 0;
 +
 +                      qlt_do_generation_tick(vha, &sess->generation);
 +
                        spin_unlock_irqrestore(&ha->hardware_lock, flags);
  
                        return sess;
        sess->s_id = fcport->d_id;
        sess->loop_id = fcport->loop_id;
        sess->local = local;
 +      INIT_LIST_HEAD(&sess->del_list_entry);
 +
 +      /* Under normal circumstances we want to logout from firmware when
 +       * session eventually ends and release corresponding nport handle.
 +       * In the exception cases (e.g. when new PLOGI is waiting) corresponding
 +       * code will adjust these flags as necessary. */
 +      sess->logout_on_delete = 1;
 +      sess->keep_nport_handle = 0;
  
        ql_dbg(ql_dbg_tgt_mgt, vha, 0xf006,
            "Adding sess %p to tgt %p via ->check_initiator_node_acl()\n",
        spin_lock_irqsave(&ha->hardware_lock, flags);
        list_add_tail(&sess->sess_list_entry, &vha->vha_tgt.qla_tgt->sess_list);
        vha->vha_tgt.qla_tgt->sess_count++;
 +      qlt_do_generation_tick(vha, &sess->generation);
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
  
        ql_dbg(ql_dbg_tgt_mgt, vha, 0xf04b,
  }
  
  /*
 - * Called from drivers/scsi/qla2xxx/qla_init.c:qla2x00_reg_remote_port()
 + * Called from qla2x00_reg_remote_port()
   */
  void qlt_fc_port_added(struct scsi_qla_host *vha, fc_port_t *fcport)
  {
                mutex_unlock(&vha->vha_tgt.tgt_mutex);
  
                spin_lock_irqsave(&ha->hardware_lock, flags);
 +      } else if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
 +              /* Point of no return */
 +              spin_unlock_irqrestore(&ha->hardware_lock, flags);
 +              return;
        } else {
                kref_get(&sess->se_sess->sess_kref);
  
        spin_unlock_irqrestore(&ha->hardware_lock, flags);
  }
  
 -void qlt_fc_port_deleted(struct scsi_qla_host *vha, fc_port_t *fcport)
 +/*
 + * max_gen - specifies maximum session generation
 + * at which this deletion requestion is still valid
 + */
 +void
 +qlt_fc_port_deleted(struct scsi_qla_host *vha, fc_port_t *fcport, int max_gen)
  {
 -      struct qla_hw_data *ha = vha->hw;
        struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
        struct qla_tgt_sess *sess;
 -      unsigned long flags;
  
        if (!vha->hw->tgt.tgt_ops)
                return;
  
 -      if (!tgt || (fcport->port_type != FCT_INITIATOR))
 +      if (!tgt)
                return;
  
 -      spin_lock_irqsave(&ha->hardware_lock, flags);
        if (tgt->tgt_stop) {
 -              spin_unlock_irqrestore(&ha->hardware_lock, flags);
                return;
        }
        sess = qlt_find_sess_by_port_name(tgt, fcport->port_name);
        if (!sess) {
 -              spin_unlock_irqrestore(&ha->hardware_lock, flags);
 +              return;
 +      }
 +
 +      if (max_gen - sess->generation < 0) {
 +              ql_dbg(ql_dbg_tgt_mgt, vha, 0xf092,
 +                  "Ignoring stale deletion request for se_sess %p / sess %p"
 +                  " for port %8phC, req_gen %d, sess_gen %d\n",
 +                  sess->se_sess, sess, sess->port_name, max_gen,
 +                  sess->generation);
                return;
        }
  
  
        sess->local = 1;
        qlt_schedule_sess_for_deletion(sess, false);
 -      spin_unlock_irqrestore(&ha->hardware_lock, flags);
  }
  
  static inline int test_tgt_sess_count(struct qla_tgt *tgt)
@@@ -1141,7 -1023,7 +1141,7 @@@ static void qlt_send_notify_ack(struct 
        nack->u.isp24.nport_handle = ntfy->u.isp24.nport_handle;
        if (le16_to_cpu(ntfy->u.isp24.status) == IMM_NTFY_ELS) {
                nack->u.isp24.flags = ntfy->u.isp24.flags &
-                       __constant_cpu_to_le32(NOTIFY24XX_FLAGS_PUREX_IOCB);
+                       cpu_to_le32(NOTIFY24XX_FLAGS_PUREX_IOCB);
        }
        nack->u.isp24.srr_rx_id = ntfy->u.isp24.srr_rx_id;
        nack->u.isp24.status = ntfy->u.isp24.status;
@@@ -1199,7 -1081,7 +1199,7 @@@ static void qlt_24xx_send_abts_resp(str
        resp->sof_type = abts->sof_type;
        resp->exchange_address = abts->exchange_address;
        resp->fcp_hdr_le = abts->fcp_hdr_le;
-       f_ctl = __constant_cpu_to_le32(F_CTL_EXCH_CONTEXT_RESP |
+       f_ctl = cpu_to_le32(F_CTL_EXCH_CONTEXT_RESP |
            F_CTL_LAST_SEQ | F_CTL_END_SEQ |
            F_CTL_SEQ_INITIATIVE);
        p = (uint8_t *)&f_ctl;
@@@ -1274,15 -1156,14 +1274,14 @@@ static void qlt_24xx_retry_term_exchang
        ctio->entry_count = 1;
        ctio->nport_handle = entry->nport_handle;
        ctio->handle = QLA_TGT_SKIP_HANDLE |    CTIO_COMPLETION_HANDLE_MARK;
-       ctio->timeout = __constant_cpu_to_le16(QLA_TGT_TIMEOUT);
+       ctio->timeout = cpu_to_le16(QLA_TGT_TIMEOUT);
        ctio->vp_index = vha->vp_idx;
        ctio->initiator_id[0] = entry->fcp_hdr_le.d_id[0];
        ctio->initiator_id[1] = entry->fcp_hdr_le.d_id[1];
        ctio->initiator_id[2] = entry->fcp_hdr_le.d_id[2];
        ctio->exchange_addr = entry->exchange_addr_to_abort;
-       ctio->u.status1.flags =
-           __constant_cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1 |
-               CTIO7_FLAGS_TERMINATE);
+       ctio->u.status1.flags = cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1 |
+                                           CTIO7_FLAGS_TERMINATE);
        ctio->u.status1.ox_id = cpu_to_le16(entry->fcp_hdr_le.ox_id);
  
        /* Memory Barrier */
            FCP_TMF_CMPL, true);
  }
  
 +static int abort_cmd_for_tag(struct scsi_qla_host *vha, uint32_t tag)
 +{
 +      struct qla_tgt_sess_op *op;
 +      struct qla_tgt_cmd *cmd;
 +
 +      spin_lock(&vha->cmd_list_lock);
 +
 +      list_for_each_entry(op, &vha->qla_sess_op_cmd_list, cmd_list) {
 +              if (tag == op->atio.u.isp24.exchange_addr) {
 +                      op->aborted = true;
 +                      spin_unlock(&vha->cmd_list_lock);
 +                      return 1;
 +              }
 +      }
 +
 +      list_for_each_entry(cmd, &vha->qla_cmd_list, cmd_list) {
 +              if (tag == cmd->atio.u.isp24.exchange_addr) {
 +                      cmd->state = QLA_TGT_STATE_ABORTED;
 +                      spin_unlock(&vha->cmd_list_lock);
 +                      return 1;
 +              }
 +      }
 +
 +      spin_unlock(&vha->cmd_list_lock);
 +      return 0;
 +}
 +
 +/* drop cmds for the given lun
 + * XXX only looks for cmds on the port through which lun reset was recieved
 + * XXX does not go through the list of other port (which may have cmds
 + *     for the same lun)
 + */
 +static void abort_cmds_for_lun(struct scsi_qla_host *vha,
 +                              uint32_t lun, uint8_t *s_id)
 +{
 +      struct qla_tgt_sess_op *op;
 +      struct qla_tgt_cmd *cmd;
 +      uint32_t key;
 +
 +      key = sid_to_key(s_id);
 +      spin_lock(&vha->cmd_list_lock);
 +      list_for_each_entry(op, &vha->qla_sess_op_cmd_list, cmd_list) {
 +              uint32_t op_key;
 +              uint32_t op_lun;
 +
 +              op_key = sid_to_key(op->atio.u.isp24.fcp_hdr.s_id);
 +              op_lun = scsilun_to_int(
 +                      (struct scsi_lun *)&op->atio.u.isp24.fcp_cmnd.lun);
 +              if (op_key == key && op_lun == lun)
 +                      op->aborted = true;
 +      }
 +      list_for_each_entry(cmd, &vha->qla_cmd_list, cmd_list) {
 +              uint32_t cmd_key;
 +              uint32_t cmd_lun;
 +
 +              cmd_key = sid_to_key(cmd->atio.u.isp24.fcp_hdr.s_id);
 +              cmd_lun = scsilun_to_int(
 +                      (struct scsi_lun *)&cmd->atio.u.isp24.fcp_cmnd.lun);
 +              if (cmd_key == key && cmd_lun == lun)
 +                      cmd->state = QLA_TGT_STATE_ABORTED;
 +      }
 +      spin_unlock(&vha->cmd_list_lock);
 +}
 +
  /* ha->hardware_lock supposed to be held on entry */
  static int __qlt_24xx_handle_abts(struct scsi_qla_host *vha,
        struct abts_recv_from_24xx *abts, struct qla_tgt_sess *sess)
        }
        spin_unlock(&se_sess->sess_cmd_lock);
  
 -      if (!found_lun)
 -              return -ENOENT;
 +      /* cmd not in LIO lists, look in qla list */
 +      if (!found_lun) {
 +              if (abort_cmd_for_tag(vha, abts->exchange_addr_to_abort)) {
 +                      /* send TASK_ABORT response immediately */
 +                      qlt_24xx_send_abts_resp(vha, abts, FCP_TMF_CMPL, false);
 +                      return 0;
 +              } else {
 +                      ql_dbg(ql_dbg_tgt_mgt, vha, 0xf081,
 +                          "unable to find cmd in driver or LIO for tag 0x%x\n",
 +                          abts->exchange_addr_to_abort);
 +                      return -ENOENT;
 +              }
 +      }
  
        ql_dbg(ql_dbg_tgt_mgt, vha, 0xf00f,
            "qla_target(%d): task abort (tag=%d)\n",
@@@ -1477,11 -1283,6 +1476,11 @@@ static void qlt_24xx_handle_abts(struc
                return;
        }
  
 +      if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
 +              qlt_24xx_send_abts_resp(vha, abts, FCP_TMF_REJECTED, false);
 +              return;
 +      }
 +
        rc = __qlt_24xx_handle_abts(vha, abts, sess);
        if (rc != 0) {
                ql_dbg(ql_dbg_tgt_mgt, vha, 0xf054,
@@@ -1522,20 -1323,19 +1521,19 @@@ static void qlt_24xx_send_task_mgmt_cti
        ctio->entry_count = 1;
        ctio->handle = QLA_TGT_SKIP_HANDLE | CTIO_COMPLETION_HANDLE_MARK;
        ctio->nport_handle = mcmd->sess->loop_id;
-       ctio->timeout = __constant_cpu_to_le16(QLA_TGT_TIMEOUT);
+       ctio->timeout = cpu_to_le16(QLA_TGT_TIMEOUT);
        ctio->vp_index = ha->vp_idx;
        ctio->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2];
        ctio->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
        ctio->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
        ctio->exchange_addr = atio->u.isp24.exchange_addr;
        ctio->u.status1.flags = (atio->u.isp24.attr << 9) |
-           __constant_cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1 |
-               CTIO7_FLAGS_SEND_STATUS);
+           cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_SEND_STATUS);
        temp = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id);
        ctio->u.status1.ox_id = cpu_to_le16(temp);
        ctio->u.status1.scsi_status =
-           __constant_cpu_to_le16(SS_RESPONSE_INFO_LEN_VALID);
-       ctio->u.status1.response_len = __constant_cpu_to_le16(8);
+           cpu_to_le16(SS_RESPONSE_INFO_LEN_VALID);
+       ctio->u.status1.response_len = cpu_to_le16(8);
        ctio->u.status1.sense_data[0] = resp_code;
  
        /* Memory Barrier */
@@@ -1786,7 -1586,7 +1784,7 @@@ static int qlt_24xx_build_ctio_pkt(stru
  
        pkt->handle = h | CTIO_COMPLETION_HANDLE_MARK;
        pkt->nport_handle = prm->cmd->loop_id;
-       pkt->timeout = __constant_cpu_to_le16(QLA_TGT_TIMEOUT);
+       pkt->timeout = cpu_to_le16(QLA_TGT_TIMEOUT);
        pkt->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2];
        pkt->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
        pkt->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
@@@ -1924,6 -1724,20 +1922,6 @@@ static int qlt_pre_xmit_response(struc
        struct qla_hw_data *ha = vha->hw;
        struct se_cmd *se_cmd = &cmd->se_cmd;
  
 -      if (unlikely(cmd->aborted)) {
 -              ql_dbg(ql_dbg_tgt_mgt, vha, 0xf014,
 -                     "qla_target(%d): terminating exchange for aborted cmd=%p (se_cmd=%p, tag=%lld)",
 -                     vha->vp_idx, cmd, se_cmd, se_cmd->tag);
 -
 -              cmd->state = QLA_TGT_STATE_ABORTED;
 -              cmd->cmd_flags |= BIT_6;
 -
 -              qlt_send_term_exchange(vha, cmd, &cmd->atio, 0);
 -
 -              /* !! At this point cmd could be already freed !! */
 -              return QLA_TGT_PRE_XMIT_RESP_CMD_ABORTED;
 -      }
 -
        prm->cmd = cmd;
        prm->tgt = tgt;
        prm->rq_result = scsi_status;
@@@ -2087,10 -1901,9 +2085,9 @@@ static void qlt_24xx_init_ctio_to_isp(s
  {
        prm->sense_buffer_len = min_t(uint32_t, prm->sense_buffer_len,
            (uint32_t)sizeof(ctio->u.status1.sense_data));
-       ctio->u.status0.flags |=
-           __constant_cpu_to_le16(CTIO7_FLAGS_SEND_STATUS);
+       ctio->u.status0.flags |= cpu_to_le16(CTIO7_FLAGS_SEND_STATUS);
        if (qlt_need_explicit_conf(prm->tgt->ha, prm->cmd, 0)) {
-               ctio->u.status0.flags |= __constant_cpu_to_le16(
+               ctio->u.status0.flags |= cpu_to_le16(
                    CTIO7_FLAGS_EXPLICIT_CONFORM |
                    CTIO7_FLAGS_CONFORM_REQ);
        }
                                    "non GOOD status\n");
                                goto skip_explict_conf;
                        }
-                       ctio->u.status1.flags |= __constant_cpu_to_le16(
+                       ctio->u.status1.flags |= cpu_to_le16(
                            CTIO7_FLAGS_EXPLICIT_CONFORM |
                            CTIO7_FLAGS_CONFORM_REQ);
                }
  skip_explict_conf:
                ctio->u.status1.flags &=
-                   ~__constant_cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_0);
+                   ~cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_0);
                ctio->u.status1.flags |=
-                   __constant_cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1);
+                   cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1);
                ctio->u.status1.scsi_status |=
-                   __constant_cpu_to_le16(SS_SENSE_LEN_VALID);
+                   cpu_to_le16(SS_SENSE_LEN_VALID);
                ctio->u.status1.sense_length =
                    cpu_to_le16(prm->sense_buffer_len);
                for (i = 0; i < prm->sense_buffer_len/4; i++)
  #endif
        } else {
                ctio->u.status1.flags &=
-                   ~__constant_cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_0);
+                   ~cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_0);
                ctio->u.status1.flags |=
-                   __constant_cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1);
+                   cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1);
                ctio->u.status1.sense_length = 0;
                memset(ctio->u.status1.sense_data, 0,
                    sizeof(ctio->u.status1.sense_data));
@@@ -2261,7 -2074,6 +2258,6 @@@ static inline in
  qlt_build_ctio_crc2_pkt(struct qla_tgt_prm *prm, scsi_qla_host_t *vha)
  {
        uint32_t                *cur_dsd;
-       int                     sgc;
        uint32_t                transfer_length = 0;
        uint32_t                data_bytes;
        uint32_t                dif_bytes;
        struct atio_from_isp *atio = &prm->cmd->atio;
        uint16_t t16;
  
-       sgc = 0;
        ha = vha->hw;
  
        pkt = (struct ctio_crc2_to_fw *)vha->req->ring_ptr;
  
        pkt->handle  = h | CTIO_COMPLETION_HANDLE_MARK;
        pkt->nport_handle = prm->cmd->loop_id;
-       pkt->timeout = __constant_cpu_to_le16(QLA_TGT_TIMEOUT);
+       pkt->timeout = cpu_to_le16(QLA_TGT_TIMEOUT);
        pkt->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2];
        pkt->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
        pkt->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
  
        /* Set transfer direction */
        if (cmd->dma_data_direction == DMA_TO_DEVICE)
-               pkt->flags = __constant_cpu_to_le16(CTIO7_FLAGS_DATA_IN);
+               pkt->flags = cpu_to_le16(CTIO7_FLAGS_DATA_IN);
        else if (cmd->dma_data_direction == DMA_FROM_DEVICE)
-               pkt->flags = __constant_cpu_to_le16(CTIO7_FLAGS_DATA_OUT);
+               pkt->flags = cpu_to_le16(CTIO7_FLAGS_DATA_OUT);
  
  
        pkt->dseg_count = prm->tot_dsds;
        crc_ctx_pkt->blk_size   = cpu_to_le16(cmd->blk_sz);
        crc_ctx_pkt->prot_opts  = cpu_to_le16(fw_prot_opts);
        crc_ctx_pkt->byte_count = cpu_to_le32(data_bytes);
-       crc_ctx_pkt->guard_seed = __constant_cpu_to_le16(0);
+       crc_ctx_pkt->guard_seed = cpu_to_le16(0);
  
  
        /* Walks data segments */
-       pkt->flags |= __constant_cpu_to_le16(CTIO7_FLAGS_DSD_PTR);
+       pkt->flags |= cpu_to_le16(CTIO7_FLAGS_DSD_PTR);
  
        if (!bundling && prm->prot_seg_cnt) {
                if (qla24xx_walk_and_build_sglist_no_difb(ha, NULL, cur_dsd,
@@@ -2485,19 -2296,6 +2480,19 @@@ int qlt_xmit_response(struct qla_tgt_cm
        unsigned long flags = 0;
        int res;
  
 +      spin_lock_irqsave(&ha->hardware_lock, flags);
 +      if (cmd->sess && cmd->sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
 +              cmd->state = QLA_TGT_STATE_PROCESSED;
 +              if (cmd->sess->logout_completed)
 +                      /* no need to terminate. FW already freed exchange. */
 +                      qlt_abort_cmd_on_host_reset(cmd->vha, cmd);
 +              else
 +                      qlt_send_term_exchange(vha, cmd, &cmd->atio, 1);
 +              spin_unlock_irqrestore(&ha->hardware_lock, flags);
 +              return 0;
 +      }
 +      spin_unlock_irqrestore(&ha->hardware_lock, flags);
 +
        memset(&prm, 0, sizeof(prm));
        qlt_check_srr_debug(cmd, &xmit_type);
  
        res = qlt_pre_xmit_response(cmd, &prm, xmit_type, scsi_status,
            &full_req_cnt);
        if (unlikely(res != 0)) {
 -              if (res == QLA_TGT_PRE_XMIT_RESP_CMD_ABORTED)
 -                      return 0;
 -
                return res;
        }
  
                res = qlt_build_ctio_crc2_pkt(&prm, vha);
        else
                res = qlt_24xx_build_ctio_pkt(&prm, vha);
 -      if (unlikely(res != 0))
 +      if (unlikely(res != 0)) {
 +              vha->req->cnt += full_req_cnt;
                goto out_unmap_unlock;
 -
 +      }
  
        pkt = (struct ctio7_to_24xx *)prm.pkt;
  
        if (qlt_has_data(cmd) && (xmit_type & QLA_TGT_XMIT_DATA)) {
                pkt->u.status0.flags |=
-                   __constant_cpu_to_le16(CTIO7_FLAGS_DATA_IN |
+                   cpu_to_le16(CTIO7_FLAGS_DATA_IN |
                        CTIO7_FLAGS_STATUS_MODE_0);
  
                if (cmd->se_cmd.prot_op == TARGET_PROT_NORMAL)
                                    cpu_to_le16(prm.rq_result);
                                pkt->u.status0.residual =
                                    cpu_to_le32(prm.residual);
-                               pkt->u.status0.flags |= __constant_cpu_to_le16(
+                               pkt->u.status0.flags |= cpu_to_le16(
                                    CTIO7_FLAGS_SEND_STATUS);
                                if (qlt_need_explicit_conf(ha, cmd, 0)) {
                                        pkt->u.status0.flags |=
-                                           __constant_cpu_to_le16(
+                                           cpu_to_le16(
                                                CTIO7_FLAGS_EXPLICIT_CONFORM |
                                                CTIO7_FLAGS_CONFORM_REQ);
                                }
                        ctio->entry_count = 1;
                        ctio->entry_type = CTIO_TYPE7;
                        ctio->dseg_count = 0;
-                       ctio->u.status1.flags &= ~__constant_cpu_to_le16(
+                       ctio->u.status1.flags &= ~cpu_to_le16(
                            CTIO7_FLAGS_DATA_IN);
  
                        /* Real finish is ctio_m1's finish */
                        pkt->handle |= CTIO_INTERMEDIATE_HANDLE_MARK;
-                       pkt->u.status0.flags |= __constant_cpu_to_le16(
+                       pkt->u.status0.flags |= cpu_to_le16(
                            CTIO7_FLAGS_DONT_RET_CTIO);
  
                        /* qlt_24xx_init_ctio_to_isp will correct
@@@ -2656,8 -2456,7 +2651,8 @@@ int qlt_rdy_to_xfer(struct qla_tgt_cmd 
  
        spin_lock_irqsave(&ha->hardware_lock, flags);
  
 -      if (qla2x00_reset_active(vha) || cmd->reset_count != ha->chip_reset) {
 +      if (qla2x00_reset_active(vha) || (cmd->reset_count != ha->chip_reset) ||
 +          (cmd->sess && cmd->sess->deleted == QLA_SESS_DELETION_IN_PROGRESS)) {
                /*
                 * Either a chip reset is active or this request was from
                 * previous life, just abort the processing.
        else
                res = qlt_24xx_build_ctio_pkt(&prm, vha);
  
 -      if (unlikely(res != 0))
 +      if (unlikely(res != 0)) {
 +              vha->req->cnt += prm.req_cnt;
                goto out_unlock_free_unmap;
 +      }
 +
        pkt = (struct ctio7_to_24xx *)prm.pkt;
-       pkt->u.status0.flags |= __constant_cpu_to_le16(CTIO7_FLAGS_DATA_OUT |
+       pkt->u.status0.flags |= cpu_to_le16(CTIO7_FLAGS_DATA_OUT |
            CTIO7_FLAGS_STATUS_MODE_0);
  
        if (cmd->se_cmd.prot_op == TARGET_PROT_NORMAL)
@@@ -2762,7 -2558,7 +2757,7 @@@ qlt_handle_dif_error(struct scsi_qla_ho
  
                /* Update protection tag */
                if (cmd->prot_sg_cnt) {
-                       uint32_t i, j = 0, k = 0, num_ent;
+                       uint32_t i, k = 0, num_ent;
                        struct scatterlist *sg, *sgl;
  
  
                                        k += num_ent;
                                        continue;
                                }
-                               j = blocks_done - k - 1;
                                k = blocks_done;
                                break;
                        }
  }
  
  
 +/* If hardware_lock held on entry, might drop it, then reaquire */
 +/* This function sends the appropriate CTIO to ISP 2xxx or 24xx */
 +static int __qlt_send_term_imm_notif(struct scsi_qla_host *vha,
 +      struct imm_ntfy_from_isp *ntfy)
 +{
 +      struct nack_to_isp *nack;
 +      struct qla_hw_data *ha = vha->hw;
 +      request_t *pkt;
 +      int ret = 0;
 +
 +      ql_dbg(ql_dbg_tgt_tmr, vha, 0xe01c,
 +          "Sending TERM ELS CTIO (ha=%p)\n", ha);
 +
 +      pkt = (request_t *)qla2x00_alloc_iocbs_ready(vha, NULL);
 +      if (pkt == NULL) {
 +              ql_dbg(ql_dbg_tgt, vha, 0xe080,
 +                  "qla_target(%d): %s failed: unable to allocate "
 +                  "request packet\n", vha->vp_idx, __func__);
 +              return -ENOMEM;
 +      }
 +
 +      pkt->entry_type = NOTIFY_ACK_TYPE;
 +      pkt->entry_count = 1;
 +      pkt->handle = QLA_TGT_SKIP_HANDLE | CTIO_COMPLETION_HANDLE_MARK;
 +
 +      nack = (struct nack_to_isp *)pkt;
 +      nack->ox_id = ntfy->ox_id;
 +
 +      nack->u.isp24.nport_handle = ntfy->u.isp24.nport_handle;
 +      if (le16_to_cpu(ntfy->u.isp24.status) == IMM_NTFY_ELS) {
 +              nack->u.isp24.flags = ntfy->u.isp24.flags &
 +                      __constant_cpu_to_le32(NOTIFY24XX_FLAGS_PUREX_IOCB);
 +      }
 +
 +      /* terminate */
 +      nack->u.isp24.flags |=
 +              __constant_cpu_to_le16(NOTIFY_ACK_FLAGS_TERMINATE);
 +
 +      nack->u.isp24.srr_rx_id = ntfy->u.isp24.srr_rx_id;
 +      nack->u.isp24.status = ntfy->u.isp24.status;
 +      nack->u.isp24.status_subcode = ntfy->u.isp24.status_subcode;
 +      nack->u.isp24.fw_handle = ntfy->u.isp24.fw_handle;
 +      nack->u.isp24.exchange_address = ntfy->u.isp24.exchange_address;
 +      nack->u.isp24.srr_rel_offs = ntfy->u.isp24.srr_rel_offs;
 +      nack->u.isp24.srr_ui = ntfy->u.isp24.srr_ui;
 +      nack->u.isp24.vp_index = ntfy->u.isp24.vp_index;
 +
 +      qla2x00_start_iocbs(vha, vha->req);
 +      return ret;
 +}
 +
 +static void qlt_send_term_imm_notif(struct scsi_qla_host *vha,
 +      struct imm_ntfy_from_isp *imm, int ha_locked)
 +{
 +      unsigned long flags = 0;
 +      int rc;
 +
 +      if (qlt_issue_marker(vha, ha_locked) < 0)
 +              return;
 +
 +      if (ha_locked) {
 +              rc = __qlt_send_term_imm_notif(vha, imm);
 +
 +#if 0 /* Todo  */
 +              if (rc == -ENOMEM)
 +                      qlt_alloc_qfull_cmd(vha, imm, 0, 0);
 +#endif
 +              goto done;
 +      }
 +
 +      spin_lock_irqsave(&vha->hw->hardware_lock, flags);
 +      rc = __qlt_send_term_imm_notif(vha, imm);
 +
 +#if 0 /* Todo */
 +      if (rc == -ENOMEM)
 +              qlt_alloc_qfull_cmd(vha, imm, 0, 0);
 +#endif
 +
 +done:
 +      if (!ha_locked)
 +              spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
 +}
 +
  /* If hardware_lock held on entry, might drop it, then reaquire */
  /* This function sends the appropriate CTIO to ISP 2xxx or 24xx */
  static int __qlt_send_term_exchange(struct scsi_qla_host *vha,
        ctio24 = (struct ctio7_to_24xx *)pkt;
        ctio24->entry_type = CTIO_TYPE7;
        ctio24->nport_handle = cmd ? cmd->loop_id : CTIO7_NHANDLE_UNRECOGNIZED;
-       ctio24->timeout = __constant_cpu_to_le16(QLA_TGT_TIMEOUT);
+       ctio24->timeout = cpu_to_le16(QLA_TGT_TIMEOUT);
        ctio24->vp_index = vha->vp_idx;
        ctio24->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2];
        ctio24->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
        ctio24->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
        ctio24->exchange_addr = atio->u.isp24.exchange_addr;
        ctio24->u.status1.flags = (atio->u.isp24.attr << 9) |
-           __constant_cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1 |
+           cpu_to_le16(CTIO7_FLAGS_STATUS_MODE_1 |
                CTIO7_FLAGS_TERMINATE);
        temp = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id);
        ctio24->u.status1.ox_id = cpu_to_le16(temp);
  static void qlt_send_term_exchange(struct scsi_qla_host *vha,
        struct qla_tgt_cmd *cmd, struct atio_from_isp *atio, int ha_locked)
  {
 -      unsigned long flags;
 +      unsigned long flags = 0;
        int rc;
  
        if (qlt_issue_marker(vha, ha_locked) < 0)
        rc = __qlt_send_term_exchange(vha, cmd, atio);
        if (rc == -ENOMEM)
                qlt_alloc_qfull_cmd(vha, atio, 0, 0);
 -      spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
  
  done:
        if (cmd && ((cmd->state != QLA_TGT_STATE_ABORTED) ||
            !cmd->cmd_sent_to_fw)) {
 -              if (!ha_locked && !in_interrupt())
 -                      msleep(250); /* just in case */
 -
 -              qlt_unmap_sg(vha, cmd);
 +              if (cmd->sg_mapped)
 +                      qlt_unmap_sg(vha, cmd);
                vha->hw->tgt.tgt_ops->free_cmd(cmd);
        }
 +
 +      if (!ha_locked)
 +              spin_unlock_irqrestore(&vha->hw->hardware_lock, flags);
 +
        return;
  }
  
@@@ -3075,24 -2786,6 +3069,24 @@@ static void qlt_chk_exch_leak_thresh_ho
  
  }
  
 +void qlt_abort_cmd(struct qla_tgt_cmd *cmd)
 +{
 +      struct qla_tgt *tgt = cmd->tgt;
 +      struct scsi_qla_host *vha = tgt->vha;
 +      struct se_cmd *se_cmd = &cmd->se_cmd;
 +
 +      ql_dbg(ql_dbg_tgt_mgt, vha, 0xf014,
 +          "qla_target(%d): terminating exchange for aborted cmd=%p "
 +          "(se_cmd=%p, tag=%llu)", vha->vp_idx, cmd, &cmd->se_cmd,
 +          se_cmd->tag);
 +
 +      cmd->state = QLA_TGT_STATE_ABORTED;
 +      cmd->cmd_flags |= BIT_6;
 +
 +      qlt_send_term_exchange(vha, cmd, &cmd->atio, 0);
 +}
 +EXPORT_SYMBOL(qlt_abort_cmd);
 +
  void qlt_free_cmd(struct qla_tgt_cmd *cmd)
  {
        struct qla_tgt_sess *sess = cmd->sess;
@@@ -3216,7 -2909,7 +3210,7 @@@ static int qlt_term_ctio_exchange(struc
        if (ctio != NULL) {
                struct ctio7_from_24xx *c = (struct ctio7_from_24xx *)ctio;
                term = !(c->flags &
-                   __constant_cpu_to_le16(OF_TERM_EXCH));
+                   cpu_to_le16(OF_TERM_EXCH));
        } else
                term = 1;
  
@@@ -3316,7 -3009,7 +3310,7 @@@ qlt_abort_cmd_on_host_reset(struct scsi
                dump_stack();
        }
  
 -      cmd->cmd_flags |= BIT_12;
 +      cmd->cmd_flags |= BIT_17;
        ha->tgt.tgt_ops->free_cmd(cmd);
  }
  
@@@ -3364,7 -3057,6 +3358,6 @@@ static void qlt_do_ctio_completion(stru
  {
        struct qla_hw_data *ha = vha->hw;
        struct se_cmd *se_cmd;
-       const struct target_core_fabric_ops *tfo;
        struct qla_tgt_cmd *cmd;
  
        if (handle & CTIO_INTERMEDIATE_HANDLE_MARK) {
                return;
  
        se_cmd = &cmd->se_cmd;
-       tfo = se_cmd->se_tfo;
        cmd->cmd_sent_to_fw = 0;
  
        qlt_unmap_sg(vha, cmd);
  skip_term:
  
        if (cmd->state == QLA_TGT_STATE_PROCESSED) {
 -              ;
 +              cmd->cmd_flags |= BIT_12;
        } else if (cmd->state == QLA_TGT_STATE_NEED_DATA) {
-               int rx_status = 0;
                cmd->state = QLA_TGT_STATE_DATA_IN;
  
-               if (unlikely(status != CTIO_SUCCESS))
-                       rx_status = -EIO;
-               else
+               if (status == CTIO_SUCCESS)
                        cmd->write_data_transferred = 1;
  
                ha->tgt.tgt_ops->handle_data(cmd);
                return;
        } else if (cmd->state == QLA_TGT_STATE_ABORTED) {
 +              cmd->cmd_flags |= BIT_18;
                ql_dbg(ql_dbg_tgt_mgt, vha, 0xf01e,
                  "Aborted command %p (tag %lld) finished\n", cmd, se_cmd->tag);
        } else {
 +              cmd->cmd_flags |= BIT_19;
                ql_dbg(ql_dbg_tgt_mgt, vha, 0xf05c,
                    "qla_target(%d): A command in state (%d) should "
                    "not return a CTIO complete\n", vha->vp_idx, cmd->state);
                dump_stack();
        }
  
 -
        ha->tgt.tgt_ops->free_cmd(cmd);
  }
  
@@@ -3565,13 -3251,6 +3553,13 @@@ static void __qlt_do_work(struct qla_tg
        if (tgt->tgt_stop)
                goto out_term;
  
 +      if (cmd->state == QLA_TGT_STATE_ABORTED) {
 +              ql_dbg(ql_dbg_tgt_mgt, vha, 0xf082,
 +                  "cmd with tag %u is aborted\n",
 +                  cmd->atio.u.isp24.exchange_addr);
 +              goto out_term;
 +      }
 +
        cdb = &atio->u.isp24.fcp_cmnd.cdb[0];
        cmd->se_cmd.tag = atio->u.isp24.exchange_addr;
        cmd->unpacked_lun = scsilun_to_int(
@@@ -3625,12 -3304,6 +3613,12 @@@ out_term
  static void qlt_do_work(struct work_struct *work)
  {
        struct qla_tgt_cmd *cmd = container_of(work, struct qla_tgt_cmd, work);
 +      scsi_qla_host_t *vha = cmd->vha;
 +      unsigned long flags;
 +
 +      spin_lock_irqsave(&vha->cmd_list_lock, flags);
 +      list_del(&cmd->cmd_list);
 +      spin_unlock_irqrestore(&vha->cmd_list_lock, flags);
  
        __qlt_do_work(cmd);
  }
@@@ -3660,11 -3333,6 +3648,11 @@@ static struct qla_tgt_cmd *qlt_get_tag(
        cmd->loop_id = sess->loop_id;
        cmd->conf_compl_supported = sess->conf_compl_supported;
  
 +      cmd->cmd_flags = 0;
 +      cmd->jiffies_at_alloc = get_jiffies_64();
 +
 +      cmd->reset_count = vha->hw->chip_reset;
 +
        return cmd;
  }
  
@@@ -3682,25 -3350,14 +3670,25 @@@ static void qlt_create_sess_from_atio(s
        unsigned long flags;
        uint8_t *s_id = op->atio.u.isp24.fcp_hdr.s_id;
  
 +      spin_lock_irqsave(&vha->cmd_list_lock, flags);
 +      list_del(&op->cmd_list);
 +      spin_unlock_irqrestore(&vha->cmd_list_lock, flags);
 +
 +      if (op->aborted) {
 +              ql_dbg(ql_dbg_tgt_mgt, vha, 0xf083,
 +                  "sess_op with tag %u is aborted\n",
 +                  op->atio.u.isp24.exchange_addr);
 +              goto out_term;
 +      }
 +
        ql_dbg(ql_dbg_tgt_mgt, vha, 0xf022,
 -              "qla_target(%d): Unable to find wwn login"
 -              " (s_id %x:%x:%x), trying to create it manually\n",
 -              vha->vp_idx, s_id[0], s_id[1], s_id[2]);
 +          "qla_target(%d): Unable to find wwn login"
 +          " (s_id %x:%x:%x), trying to create it manually\n",
 +          vha->vp_idx, s_id[0], s_id[1], s_id[2]);
  
        if (op->atio.u.raw.entry_count > 1) {
                ql_dbg(ql_dbg_tgt_mgt, vha, 0xf023,
 -                      "Dropping multy entry atio %p\n", &op->atio);
 +                  "Dropping multy entry atio %p\n", &op->atio);
                goto out_term;
        }
  
@@@ -3765,25 -3422,10 +3753,25 @@@ static int qlt_handle_cmd_for_atio(stru
  
                memcpy(&op->atio, atio, sizeof(*atio));
                op->vha = vha;
 +
 +              spin_lock(&vha->cmd_list_lock);
 +              list_add_tail(&op->cmd_list, &vha->qla_sess_op_cmd_list);
 +              spin_unlock(&vha->cmd_list_lock);
 +
                INIT_WORK(&op->work, qlt_create_sess_from_atio);
                queue_work(qla_tgt_wq, &op->work);
                return 0;
        }
 +
 +      /* Another WWN used to have our s_id. Our PLOGI scheduled its
 +       * session deletion, but it's still in sess_del_work wq */
 +      if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
 +              ql_dbg(ql_dbg_io, vha, 0x3061,
 +                  "New command while old session %p is being deleted\n",
 +                  sess);
 +              return -EFAULT;
 +      }
 +
        /*
         * Do kref_get() before returning + dropping qla_hw_data->hardware_lock.
         */
                return -ENOMEM;
        }
  
 -      cmd->cmd_flags = 0;
 -      cmd->jiffies_at_alloc = get_jiffies_64();
 -
 -      cmd->reset_count = vha->hw->chip_reset;
 -
        cmd->cmd_in_wq = 1;
        cmd->cmd_flags |= BIT_0;
 +
 +      spin_lock(&vha->cmd_list_lock);
 +      list_add_tail(&cmd->cmd_list, &vha->qla_cmd_list);
 +      spin_unlock(&vha->cmd_list_lock);
 +
        INIT_WORK(&cmd->work, qlt_do_work);
        queue_work(qla_tgt_wq, &cmd->work);
        return 0;
@@@ -3817,7 -3459,6 +3805,7 @@@ static int qlt_issue_task_mgmt(struct q
        struct scsi_qla_host *vha = sess->vha;
        struct qla_hw_data *ha = vha->hw;
        struct qla_tgt_mgmt_cmd *mcmd;
 +      struct atio_from_isp *a = (struct atio_from_isp *)iocb;
        int res;
        uint8_t tmr_func;
  
                ql_dbg(ql_dbg_tgt_tmr, vha, 0x10002,
                    "qla_target(%d): LUN_RESET received\n", sess->vha->vp_idx);
                tmr_func = TMR_LUN_RESET;
 +              abort_cmds_for_lun(vha, lun, a->u.isp24.fcp_hdr.s_id);
                break;
  
        case QLA_TGT_CLEAR_TS:
@@@ -3928,12 -3568,11 +3916,11 @@@ static int qlt_handle_task_mgmt(struct 
        struct qla_tgt *tgt;
        struct qla_tgt_sess *sess;
        uint32_t lun, unpacked_lun;
-       int lun_size, fn;
+       int fn;
  
        tgt = vha->vha_tgt.qla_tgt;
  
        lun = a->u.isp24.fcp_cmnd.lun;
-       lun_size = sizeof(a->u.isp24.fcp_cmnd.lun);
        fn = a->u.isp24.fcp_cmnd.task_mgmt_flags;
        sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha,
            a->u.isp24.fcp_hdr.s_id);
                    sizeof(struct atio_from_isp));
        }
  
 +      if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS)
 +              return -EFAULT;
 +
        return qlt_issue_task_mgmt(sess, unpacked_lun, fn, iocb, 0);
  }
  
@@@ -4015,280 -3651,22 +4002,280 @@@ static int qlt_abort_task(struct scsi_q
        return __qlt_abort_task(vha, iocb, sess);
  }
  
 +void qlt_logo_completion_handler(fc_port_t *fcport, int rc)
 +{
 +      if (fcport->tgt_session) {
 +              if (rc != MBS_COMMAND_COMPLETE) {
 +                      ql_dbg(ql_dbg_tgt_mgt, fcport->vha, 0xf093,
 +                              "%s: se_sess %p / sess %p from"
 +                              " port %8phC loop_id %#04x s_id %02x:%02x:%02x"
 +                              " LOGO failed: %#x\n",
 +                              __func__,
 +                              fcport->tgt_session->se_sess,
 +                              fcport->tgt_session,
 +                              fcport->port_name, fcport->loop_id,
 +                              fcport->d_id.b.domain, fcport->d_id.b.area,
 +                              fcport->d_id.b.al_pa, rc);
 +              }
 +
 +              fcport->tgt_session->logout_completed = 1;
 +      }
 +}
 +
 +static void qlt_swap_imm_ntfy_iocb(struct imm_ntfy_from_isp *a,
 +    struct imm_ntfy_from_isp *b)
 +{
 +      struct imm_ntfy_from_isp tmp;
 +      memcpy(&tmp, a, sizeof(struct imm_ntfy_from_isp));
 +      memcpy(a, b, sizeof(struct imm_ntfy_from_isp));
 +      memcpy(b, &tmp, sizeof(struct imm_ntfy_from_isp));
 +}
 +
 +/*
 +* ha->hardware_lock supposed to be held on entry (to protect tgt->sess_list)
 +*
 +* Schedules sessions with matching port_id/loop_id but different wwn for
 +* deletion. Returns existing session with matching wwn if present.
 +* Null otherwise.
 +*/
 +static struct qla_tgt_sess *
 +qlt_find_sess_invalidate_other(struct qla_tgt *tgt, uint64_t wwn,
 +    port_id_t port_id, uint16_t loop_id)
 +{
 +      struct qla_tgt_sess *sess = NULL, *other_sess;
 +      uint64_t other_wwn;
 +
 +      list_for_each_entry(other_sess, &tgt->sess_list, sess_list_entry) {
 +
 +              other_wwn = wwn_to_u64(other_sess->port_name);
 +
 +              if (wwn == other_wwn) {
 +                      WARN_ON(sess);
 +                      sess = other_sess;
 +                      continue;
 +              }
 +
 +              /* find other sess with nport_id collision */
 +              if (port_id.b24 == other_sess->s_id.b24) {
 +                      if (loop_id != other_sess->loop_id) {
 +                              ql_dbg(ql_dbg_tgt_tmr, tgt->vha, 0x1000c,
 +                                  "Invalidating sess %p loop_id %d wwn %llx.\n",
 +                                  other_sess, other_sess->loop_id, other_wwn);
 +
 +                              /*
 +                               * logout_on_delete is set by default, but another
 +                               * session that has the same s_id/loop_id combo
 +                               * might have cleared it when requested this session
 +                               * deletion, so don't touch it
 +                               */
 +                              qlt_schedule_sess_for_deletion(other_sess, true);
 +                      } else {
 +                              /*
 +                               * Another wwn used to have our s_id/loop_id
 +                               * combo - kill the session, but don't log out
 +                               */
 +                              sess->logout_on_delete = 0;
 +                              qlt_schedule_sess_for_deletion(other_sess,
 +                                  true);
 +                      }
 +                      continue;
 +              }
 +
 +              /* find other sess with nport handle collision */
 +              if (loop_id == other_sess->loop_id) {
 +                      ql_dbg(ql_dbg_tgt_tmr, tgt->vha, 0x1000d,
 +                             "Invalidating sess %p loop_id %d wwn %llx.\n",
 +                             other_sess, other_sess->loop_id, other_wwn);
 +
 +                      /* Same loop_id but different s_id
 +                       * Ok to kill and logout */
 +                      qlt_schedule_sess_for_deletion(other_sess, true);
 +              }
 +      }
 +
 +      return sess;
 +}
 +
 +/* Abort any commands for this s_id waiting on qla_tgt_wq workqueue */
 +static int abort_cmds_for_s_id(struct scsi_qla_host *vha, port_id_t *s_id)
 +{
 +      struct qla_tgt_sess_op *op;
 +      struct qla_tgt_cmd *cmd;
 +      uint32_t key;
 +      int count = 0;
 +
 +      key = (((u32)s_id->b.domain << 16) |
 +             ((u32)s_id->b.area   <<  8) |
 +             ((u32)s_id->b.al_pa));
 +
 +      spin_lock(&vha->cmd_list_lock);
 +      list_for_each_entry(op, &vha->qla_sess_op_cmd_list, cmd_list) {
 +              uint32_t op_key = sid_to_key(op->atio.u.isp24.fcp_hdr.s_id);
 +              if (op_key == key) {
 +                      op->aborted = true;
 +                      count++;
 +              }
 +      }
 +      list_for_each_entry(cmd, &vha->qla_cmd_list, cmd_list) {
 +              uint32_t cmd_key = sid_to_key(cmd->atio.u.isp24.fcp_hdr.s_id);
 +              if (cmd_key == key) {
 +                      cmd->state = QLA_TGT_STATE_ABORTED;
 +                      count++;
 +              }
 +      }
 +      spin_unlock(&vha->cmd_list_lock);
 +
 +      return count;
 +}
 +
  /*
   * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
   */
  static int qlt_24xx_handle_els(struct scsi_qla_host *vha,
        struct imm_ntfy_from_isp *iocb)
  {
 +      struct qla_tgt *tgt = vha->vha_tgt.qla_tgt;
 +      struct qla_hw_data *ha = vha->hw;
 +      struct qla_tgt_sess *sess = NULL;
 +      uint64_t wwn;
 +      port_id_t port_id;
 +      uint16_t loop_id;
 +      uint16_t wd3_lo;
        int res = 0;
  
 +      wwn = wwn_to_u64(iocb->u.isp24.port_name);
 +
 +      port_id.b.domain = iocb->u.isp24.port_id[2];
 +      port_id.b.area   = iocb->u.isp24.port_id[1];
 +      port_id.b.al_pa  = iocb->u.isp24.port_id[0];
 +      port_id.b.rsvd_1 = 0;
 +
 +      loop_id = le16_to_cpu(iocb->u.isp24.nport_handle);
 +
        ql_dbg(ql_dbg_tgt_mgt, vha, 0xf026,
            "qla_target(%d): Port ID: 0x%3phC ELS opcode: 0x%02x\n",
            vha->vp_idx, iocb->u.isp24.port_id, iocb->u.isp24.status_subcode);
  
 +      /* res = 1 means ack at the end of thread
 +       * res = 0 means ack async/later.
 +       */
        switch (iocb->u.isp24.status_subcode) {
        case ELS_PLOGI:
 -      case ELS_FLOGI:
 +
 +              /* Mark all stale commands in qla_tgt_wq for deletion */
 +              abort_cmds_for_s_id(vha, &port_id);
 +
 +              if (wwn)
 +                      sess = qlt_find_sess_invalidate_other(tgt, wwn,
 +                          port_id, loop_id);
 +
 +              if (!sess || IS_SW_RESV_ADDR(sess->s_id)) {
 +                      res = 1;
 +                      break;
 +              }
 +
 +              if (sess->plogi_ack_needed) {
 +                      /*
 +                       * Initiator sent another PLOGI before last PLOGI could
 +                       * finish. Swap plogi iocbs and terminate old one
 +                       * without acking, new one will get acked when session
 +                       * deletion completes.
 +                       */
 +                      ql_log(ql_log_warn, sess->vha, 0xf094,
 +                          "sess %p received double plogi.\n", sess);
 +
 +                      qlt_swap_imm_ntfy_iocb(iocb, &sess->tm_iocb);
 +
 +                      qlt_send_term_imm_notif(vha, iocb, 1);
 +
 +                      res = 0;
 +                      break;
 +              }
 +
 +              res = 0;
 +
 +              /*
 +               * Save immediate Notif IOCB for Ack when sess is done
 +               * and being deleted.
 +               */
 +              memcpy(&sess->tm_iocb, iocb, sizeof(sess->tm_iocb));
 +              sess->plogi_ack_needed  = 1;
 +
 +               /*
 +                * Under normal circumstances we want to release nport handle
 +                * during LOGO process to avoid nport handle leaks inside FW.
 +                * The exception is when LOGO is done while another PLOGI with
 +                * the same nport handle is waiting as might be the case here.
 +                * Note: there is always a possibily of a race where session
 +                * deletion has already started for other reasons (e.g. ACL
 +                * removal) and now PLOGI arrives:
 +                * 1. if PLOGI arrived in FW after nport handle has been freed,
 +                *    FW must have assigned this PLOGI a new/same handle and we
 +                *    can proceed ACK'ing it as usual when session deletion
 +                *    completes.
 +                * 2. if PLOGI arrived in FW before LOGO with LCF_FREE_NPORT
 +                *    bit reached it, the handle has now been released. We'll
 +                *    get an error when we ACK this PLOGI. Nothing will be sent
 +                *    back to initiator. Initiator should eventually retry
 +                *    PLOGI and situation will correct itself.
 +                */
 +              sess->keep_nport_handle = ((sess->loop_id == loop_id) &&
 +                                         (sess->s_id.b24 == port_id.b24));
 +              qlt_schedule_sess_for_deletion(sess, true);
 +              break;
 +
        case ELS_PRLI:
 +              wd3_lo = le16_to_cpu(iocb->u.isp24.u.prli.wd3_lo);
 +
 +              if (wwn)
 +                      sess = qlt_find_sess_invalidate_other(tgt, wwn, port_id,
 +                          loop_id);
 +
 +              if (sess != NULL) {
 +                      if (sess->deleted) {
 +                              /*
 +                               * Impatient initiator sent PRLI before last
 +                               * PLOGI could finish. Will force him to re-try,
 +                               * while last one finishes.
 +                               */
 +                              ql_log(ql_log_warn, sess->vha, 0xf095,
 +                                  "sess %p PRLI received, before plogi ack.\n",
 +                                  sess);
 +                              qlt_send_term_imm_notif(vha, iocb, 1);
 +                              res = 0;
 +                              break;
 +                      }
 +
 +                      /*
 +                       * This shouldn't happen under normal circumstances,
 +                       * since we have deleted the old session during PLOGI
 +                       */
 +                      ql_dbg(ql_dbg_tgt_mgt, vha, 0xf096,
 +                          "PRLI (loop_id %#04x) for existing sess %p (loop_id %#04x)\n",
 +                          sess->loop_id, sess, iocb->u.isp24.nport_handle);
 +
 +                      sess->local = 0;
 +                      sess->loop_id = loop_id;
 +                      sess->s_id = port_id;
 +
 +                      if (wd3_lo & BIT_7)
 +                              sess->conf_compl_supported = 1;
 +
 +              }
 +              res = 1; /* send notify ack */
 +
 +              /* Make session global (not used in fabric mode) */
 +              if (ha->current_topology != ISP_CFG_F) {
 +                      set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
 +                      set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
 +                      qla2xxx_wake_dpc(vha);
 +              } else {
 +                      /* todo: else - create sess here. */
 +                      res = 1; /* send notify ack */
 +              }
 +
 +              break;
 +
        case ELS_LOGO:
        case ELS_PRLO:
                res = qlt_reset(vha, iocb, QLA_TGT_NEXUS_LOSS_SESS);
                break;
        }
  
 +      case ELS_FLOGI: /* should never happen */
        default:
                ql_dbg(ql_dbg_tgt_mgt, vha, 0xf061,
                    "qla_target(%d): Unsupported ELS command %x "
@@@ -4578,16 -3955,20 +4565,20 @@@ static void qlt_reject_free_srr_imm(str
        struct qla_hw_data *ha = vha->hw;
        unsigned long flags = 0;
  
+ #ifndef __CHECKER__
        if (!ha_locked)
                spin_lock_irqsave(&ha->hardware_lock, flags);
+ #endif
  
        qlt_send_notify_ack(vha, (void *)&imm->imm_ntfy, 0, 0, 0,
            NOTIFY_ACK_SRR_FLAGS_REJECT,
            NOTIFY_ACK_SRR_REJECT_REASON_UNABLE_TO_PERFORM,
            NOTIFY_ACK_SRR_FLAGS_REJECT_EXPL_NO_EXPL);
  
+ #ifndef __CHECKER__
        if (!ha_locked)
                spin_unlock_irqrestore(&ha->hardware_lock, flags);
+ #endif
  
        kfree(imm);
  }
@@@ -4931,14 -4312,14 +4922,14 @@@ static int __qlt_send_busy(struct scsi_
        ctio24 = (struct ctio7_to_24xx *)pkt;
        ctio24->entry_type = CTIO_TYPE7;
        ctio24->nport_handle = sess->loop_id;
-       ctio24->timeout = __constant_cpu_to_le16(QLA_TGT_TIMEOUT);
+       ctio24->timeout = cpu_to_le16(QLA_TGT_TIMEOUT);
        ctio24->vp_index = vha->vp_idx;
        ctio24->initiator_id[0] = atio->u.isp24.fcp_hdr.s_id[2];
        ctio24->initiator_id[1] = atio->u.isp24.fcp_hdr.s_id[1];
        ctio24->initiator_id[2] = atio->u.isp24.fcp_hdr.s_id[0];
        ctio24->exchange_addr = atio->u.isp24.exchange_addr;
        ctio24->u.status1.flags = (atio->u.isp24.attr << 9) |
-           __constant_cpu_to_le16(
+           cpu_to_le16(
                CTIO7_FLAGS_STATUS_MODE_1 | CTIO7_FLAGS_SEND_STATUS |
                CTIO7_FLAGS_DONT_RET_CTIO);
        /*
@@@ -5266,7 -4647,7 +5257,7 @@@ static void qlt_response_pkt(struct scs
                struct atio_from_isp *atio = (struct atio_from_isp *)pkt;
                int rc;
                if (atio->u.isp2x.status !=
-                   __constant_cpu_to_le16(ATIO_CDB_VALID)) {
+                   cpu_to_le16(ATIO_CDB_VALID)) {
                        ql_dbg(ql_dbg_tgt, vha, 0xe05e,
                            "qla_target(%d): ATIO with error "
                            "status %x received\n", vha->vp_idx,
                            le16_to_cpu(entry->u.isp2x.status));
                        tgt->notify_ack_expected--;
                        if (entry->u.isp2x.status !=
-                           __constant_cpu_to_le16(NOTIFY_ACK_SUCCESS)) {
+                           cpu_to_le16(NOTIFY_ACK_SUCCESS)) {
                                ql_dbg(ql_dbg_tgt, vha, 0xe061,
                                    "qla_target(%d): NOTIFY_ACK "
                                    "failed %x\n", vha->vp_idx,
@@@ -5622,11 -5003,6 +5613,11 @@@ static void qlt_abort_work(struct qla_t
                if (!sess)
                        goto out_term;
        } else {
 +              if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
 +                      sess = NULL;
 +                      goto out_term;
 +              }
 +
                kref_get(&sess->se_sess->sess_kref);
        }
  
@@@ -5659,7 -5035,7 +5650,7 @@@ static void qlt_tmr_work(struct qla_tg
        uint8_t *s_id = NULL; /* to hide compiler warnings */
        int rc;
        uint32_t lun, unpacked_lun;
-       int lun_size, fn;
+       int fn;
        void *iocb;
  
        spin_lock_irqsave(&ha->hardware_lock, flags);
                if (!sess)
                        goto out_term;
        } else {
 +              if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) {
 +                      sess = NULL;
 +                      goto out_term;
 +              }
 +
                kref_get(&sess->se_sess->sess_kref);
        }
  
        iocb = a;
        lun = a->u.isp24.fcp_cmnd.lun;
-       lun_size = sizeof(lun);
        fn = a->u.isp24.fcp_cmnd.task_mgmt_flags;
        unpacked_lun = scsilun_to_int((struct scsi_lun *)&lun);
  
@@@ -6172,7 -5542,6 +6162,7 @@@ qlt_24xx_process_atio_queue(struct scsi
  
        /* Adjust ring index */
        WRT_REG_DWORD(ISP_ATIO_Q_OUT(vha), ha->tgt.atio_ring_index);
 +      RD_REG_DWORD_RELAXED(ISP_ATIO_Q_OUT(vha));
  }
  
  void
@@@ -6215,19 -5584,19 +6205,19 @@@ qlt_24xx_config_nvram_stage1(struct scs
                        ha->tgt.saved_set = 1;
                }
  
-               nv->exchange_count = __constant_cpu_to_le16(0xFFFF);
+               nv->exchange_count = cpu_to_le16(0xFFFF);
  
                /* Enable target mode */
-               nv->firmware_options_1 |= __constant_cpu_to_le32(BIT_4);
+               nv->firmware_options_1 |= cpu_to_le32(BIT_4);
  
                /* Disable ini mode, if requested */
                if (!qla_ini_mode_enabled(vha))
-                       nv->firmware_options_1 |= __constant_cpu_to_le32(BIT_5);
+                       nv->firmware_options_1 |= cpu_to_le32(BIT_5);
  
                /* Disable Full Login after LIP */
-               nv->firmware_options_1 &= __constant_cpu_to_le32(~BIT_13);
+               nv->firmware_options_1 &= cpu_to_le32(~BIT_13);
                /* Enable initial LIP */
-               nv->firmware_options_1 &= __constant_cpu_to_le32(~BIT_9);
+               nv->firmware_options_1 &= cpu_to_le32(~BIT_9);
                if (ql2xtgt_tape_enable)
                        /* Enable FC Tape support */
                        nv->firmware_options_2 |= cpu_to_le32(BIT_12);
                        nv->firmware_options_2 &= cpu_to_le32(~BIT_12);
  
                /* Disable Full Login after LIP */
-               nv->host_p &= __constant_cpu_to_le32(~BIT_10);
+               nv->host_p &= cpu_to_le32(~BIT_10);
                /* Enable target PRLI control */
-               nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_14);
+               nv->firmware_options_2 |= cpu_to_le32(BIT_14);
        } else {
                if (ha->tgt.saved_set) {
                        nv->exchange_count = ha->tgt.saved_exchange_count;
                        fc_host_supported_classes(vha->host) =
                                FC_COS_CLASS2 | FC_COS_CLASS3;
  
-               nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_8);
+               nv->firmware_options_2 |= cpu_to_le32(BIT_8);
        } else {
                if (vha->flags.init_done)
                        fc_host_supported_classes(vha->host) = FC_COS_CLASS3;
  
-               nv->firmware_options_2 &= ~__constant_cpu_to_le32(BIT_8);
+               nv->firmware_options_2 &= ~cpu_to_le32(BIT_8);
        }
  }
  
@@@ -6277,7 -5646,7 +6267,7 @@@ qlt_24xx_config_nvram_stage2(struct scs
  
        if (ha->tgt.node_name_set) {
                memcpy(icb->node_name, ha->tgt.tgt_node_name, WWN_SIZE);
-               icb->firmware_options_1 |= __constant_cpu_to_le32(BIT_14);
+               icb->firmware_options_1 |= cpu_to_le32(BIT_14);
        }
  }
  
@@@ -6302,20 -5671,19 +6292,19 @@@ qlt_81xx_config_nvram_stage1(struct scs
                        ha->tgt.saved_set = 1;
                }
  
-               nv->exchange_count = __constant_cpu_to_le16(0xFFFF);
+               nv->exchange_count = cpu_to_le16(0xFFFF);
  
                /* Enable target mode */
-               nv->firmware_options_1 |= __constant_cpu_to_le32(BIT_4);
+               nv->firmware_options_1 |= cpu_to_le32(BIT_4);
  
                /* Disable ini mode, if requested */
                if (!qla_ini_mode_enabled(vha))
-                       nv->firmware_options_1 |=
-                           __constant_cpu_to_le32(BIT_5);
+                       nv->firmware_options_1 |= cpu_to_le32(BIT_5);
  
                /* Disable Full Login after LIP */
-               nv->firmware_options_1 &= __constant_cpu_to_le32(~BIT_13);
+               nv->firmware_options_1 &= cpu_to_le32(~BIT_13);
                /* Enable initial LIP */
-               nv->firmware_options_1 &= __constant_cpu_to_le32(~BIT_9);
+               nv->firmware_options_1 &= cpu_to_le32(~BIT_9);
                if (ql2xtgt_tape_enable)
                        /* Enable FC tape support */
                        nv->firmware_options_2 |= cpu_to_le32(BIT_12);
                        nv->firmware_options_2 &= cpu_to_le32(~BIT_12);
  
                /* Disable Full Login after LIP */
-               nv->host_p &= __constant_cpu_to_le32(~BIT_10);
+               nv->host_p &= cpu_to_le32(~BIT_10);
                /* Enable target PRLI control */
-               nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_14);
+               nv->firmware_options_2 |= cpu_to_le32(BIT_14);
        } else {
                if (ha->tgt.saved_set) {
                        nv->exchange_count = ha->tgt.saved_exchange_count;
                        fc_host_supported_classes(vha->host) =
                                FC_COS_CLASS2 | FC_COS_CLASS3;
  
-               nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_8);
+               nv->firmware_options_2 |= cpu_to_le32(BIT_8);
        } else {
                if (vha->flags.init_done)
                        fc_host_supported_classes(vha->host) = FC_COS_CLASS3;
  
-               nv->firmware_options_2 &= ~__constant_cpu_to_le32(BIT_8);
+               nv->firmware_options_2 &= ~cpu_to_le32(BIT_8);
        }
  }
  
@@@ -6368,7 -5736,7 +6357,7 @@@ qlt_81xx_config_nvram_stage2(struct scs
  
        if (ha->tgt.node_name_set) {
                memcpy(icb->node_name, ha->tgt.tgt_node_name, WWN_SIZE);
-               icb->firmware_options_1 |= __constant_cpu_to_le32(BIT_14);
+               icb->firmware_options_1 |= cpu_to_le32(BIT_14);
        }
  }
  
@@@ -6414,7 -5782,7 +6403,7 @@@ qlt_probe_one_stage1(struct scsi_qla_ho
        if (!QLA_TGT_MODE_ENABLED())
                return;
  
 -      if  (ha->mqenable || IS_QLA83XX(ha)) {
 +      if  (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) {
                ISP_ATIO_Q_IN(base_vha) = &ha->mqiobase->isp25mq.atio_q_in;
                ISP_ATIO_Q_OUT(base_vha) = &ha->mqiobase->isp25mq.atio_q_out;
        } else {
index 9224a06646e6af420139ae29cba4802cf2663637,e8595867bb8d242030feaed08955070d2420fc84..7ed7bae6172b21ab43453ebfc3af7f2d72aec200
@@@ -374,7 -374,7 +374,7 @@@ static int tcm_qla2xxx_write_pending(st
  {
        struct qla_tgt_cmd *cmd = container_of(se_cmd,
                                struct qla_tgt_cmd, se_cmd);
 -
 +      cmd->cmd_flags |= BIT_3;
        cmd->bufflen = se_cmd->data_length;
        cmd->dma_data_direction = target_reverse_dma_direction(se_cmd);
  
@@@ -405,7 -405,7 +405,7 @@@ static int tcm_qla2xxx_write_pending_st
            se_cmd->t_state == TRANSPORT_COMPLETE_QF_WP) {
                spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
                wait_for_completion_timeout(&se_cmd->t_transport_stop_comp,
 -                                              3000);
 +                                          3 * HZ);
                return 0;
        }
        spin_unlock_irqrestore(&se_cmd->t_state_lock, flags);
@@@ -420,6 -420,12 +420,12 @@@ static void tcm_qla2xxx_set_default_nod
  
  static int tcm_qla2xxx_get_cmd_state(struct se_cmd *se_cmd)
  {
+       if (!(se_cmd->se_cmd_flags & SCF_SCSI_TMR_CDB)) {
+               struct qla_tgt_cmd *cmd = container_of(se_cmd,
+                               struct qla_tgt_cmd, se_cmd);
+               return cmd->state;
+       }
        return 0;
  }
  
@@@ -541,10 -547,12 +547,10 @@@ static int tcm_qla2xxx_queue_data_in(st
        cmd->cmd_flags |= BIT_4;
        cmd->bufflen = se_cmd->data_length;
        cmd->dma_data_direction = target_reverse_dma_direction(se_cmd);
 -      cmd->aborted = (se_cmd->transport_state & CMD_T_ABORTED);
  
        cmd->sg_cnt = se_cmd->t_data_nents;
        cmd->sg = se_cmd->t_data_sg;
        cmd->offset = 0;
 -      cmd->cmd_flags |= BIT_3;
  
        cmd->prot_sg_cnt = se_cmd->t_prot_nents;
        cmd->prot_sg = se_cmd->t_prot_sg;
@@@ -569,6 -577,7 +575,6 @@@ static int tcm_qla2xxx_queue_status(str
        cmd->sg_cnt = 0;
        cmd->offset = 0;
        cmd->dma_data_direction = target_reverse_dma_direction(se_cmd);
 -      cmd->aborted = (se_cmd->transport_state & CMD_T_ABORTED);
        if (cmd->cmd_flags &  BIT_5) {
                pr_crit("Bit_5 already set for cmd = %p.\n", cmd);
                dump_stack();
@@@ -633,7 -642,14 +639,7 @@@ static void tcm_qla2xxx_aborted_task(st
  {
        struct qla_tgt_cmd *cmd = container_of(se_cmd,
                                struct qla_tgt_cmd, se_cmd);
 -      struct scsi_qla_host *vha = cmd->vha;
 -      struct qla_hw_data *ha = vha->hw;
 -
 -      if (!cmd->sg_mapped)
 -              return;
 -
 -      pci_unmap_sg(ha->pdev, cmd->sg, cmd->sg_cnt, cmd->dma_data_direction);
 -      cmd->sg_mapped = 0;
 +      qlt_abort_cmd(cmd);
  }
  
  static void tcm_qla2xxx_clear_sess_lookup(struct tcm_qla2xxx_lport *,
@@@ -1139,7 -1155,9 +1145,7 @@@ static struct qla_tgt_sess *tcm_qla2xxx
                return NULL;
        }
  
 -      key = (((unsigned long)s_id[0] << 16) |
 -             ((unsigned long)s_id[1] << 8) |
 -             (unsigned long)s_id[2]);
 +      key = sid_to_key(s_id);
        pr_debug("find_sess_by_s_id: 0x%06x\n", key);
  
        se_nacl = btree_lookup32(&lport->lport_fcport_map, key);
@@@ -1174,7 -1192,9 +1180,7 @@@ static void tcm_qla2xxx_set_sess_by_s_i
        void *slot;
        int rc;
  
 -      key = (((unsigned long)s_id[0] << 16) |
 -             ((unsigned long)s_id[1] << 8) |
 -             (unsigned long)s_id[2]);
 +      key = sid_to_key(s_id);
        pr_debug("set_sess_by_s_id: %06x\n", key);
  
        slot = btree_lookup32(&lport->lport_fcport_map, key);
@@@ -1530,10 -1550,6 +1536,10 @@@ static void tcm_qla2xxx_update_sess(str
        }
  
        sess->conf_compl_supported = conf_compl_supported;
 +
 +      /* Reset logout parameters to default */
 +      sess->logout_on_delete = 1;
 +      sess->keep_nport_handle = 0;
  }
  
  /*
index 6457a8a0db9c37ed8892c28effe768a533f2e7f3,3aacd96d63f3f3f45ce2bfb67747ca5eb3cabd67..afd34a608fe7eb8758457cc05d5aa05825a34476
@@@ -26,6 -26,7 +26,6 @@@
  #include <linux/blkdev.h>
  #include <linux/delay.h>
  #include <linux/jiffies.h>
 -#include <asm/unaligned.h>
  
  #include <scsi/scsi.h>
  #include <scsi/scsi_cmnd.h>
@@@ -420,6 -421,10 +420,10 @@@ static void scsi_report_sense(struct sc
                        evt_type = SDEV_EVT_MODE_PARAMETER_CHANGE_REPORTED;
                        sdev_printk(KERN_WARNING, sdev,
                                    "Mode parameters changed");
+               } else if (sshdr->asc == 0x2a && sshdr->ascq == 0x06) {
+                       evt_type = SDEV_EVT_ALUA_STATE_CHANGE_REPORTED;
+                       sdev_printk(KERN_WARNING, sdev,
+                                   "Asymmetric access state changed");
                } else if (sshdr->asc == 0x2a && sshdr->ascq == 0x09) {
                        evt_type = SDEV_EVT_CAPACITY_CHANGE_REPORTED;
                        sdev_printk(KERN_WARNING, sdev,
@@@ -1155,8 -1160,13 +1159,13 @@@ int scsi_eh_get_sense(struct list_head 
        struct Scsi_Host *shost;
        int rtn;
  
+       /*
+        * If SCSI_EH_ABORT_SCHEDULED has been set, it is timeout IO,
+        * should not get sense.
+        */
        list_for_each_entry_safe(scmd, next, work_q, eh_entry) {
                if ((scmd->eh_eflags & SCSI_EH_CANCEL_CMD) ||
+                   (scmd->eh_eflags & SCSI_EH_ABORT_SCHEDULED) ||
                    SCSI_SENSE_VALID(scmd))
                        continue;
  
@@@ -2522,3 -2532,33 +2531,3 @@@ void scsi_build_sense_buffer(int desc, 
        }
  }
  EXPORT_SYMBOL(scsi_build_sense_buffer);
 -
 -/**
 - * scsi_set_sense_information - set the information field in a
 - *            formatted sense data buffer
 - * @buf:      Where to build sense data
 - * @info:     64-bit information value to be set
 - *
 - **/
 -void scsi_set_sense_information(u8 *buf, u64 info)
 -{
 -      if ((buf[0] & 0x7f) == 0x72) {
 -              u8 *ucp, len;
 -
 -              len = buf[7];
 -              ucp = (char *)scsi_sense_desc_find(buf, len + 8, 0);
 -              if (!ucp) {
 -                      buf[7] = len + 0xa;
 -                      ucp = buf + 8 + len;
 -              }
 -              ucp[0] = 0;
 -              ucp[1] = 0xa;
 -              ucp[2] = 0x80; /* Valid bit */
 -              ucp[3] = 0;
 -              put_unaligned_be64(info, &ucp[4]);
 -      } else if ((buf[0] & 0x7f) == 0x70) {
 -              buf[0] |= 0x80;
 -              put_unaligned_be64(info, &buf[3]);
 -      }
 -}
 -EXPORT_SYMBOL(scsi_set_sense_information);
index da73d5524602236dd17d43362d8c8a44b8389f84,4c25539abc8441a817ca31bcf27359bdaff9d748..e4b3d8f4fd85e25f09c19af401476a261d457b49
@@@ -2042,6 -2042,7 +2042,7 @@@ iscsi_alloc_session(struct Scsi_Host *s
        session->transport = transport;
        session->creator = -1;
        session->recovery_tmo = 120;
+       session->recovery_tmo_sysfs_override = false;
        session->state = ISCSI_SESSION_FREE;
        INIT_DELAYED_WORK(&session->recovery_work, session_recovery_timedout);
        INIT_LIST_HEAD(&session->sess_list);
@@@ -2786,7 -2787,8 +2787,8 @@@ iscsi_set_param(struct iscsi_transport 
        switch (ev->u.set_param.param) {
        case ISCSI_PARAM_SESS_RECOVERY_TMO:
                sscanf(data, "%d", &value);
-               session->recovery_tmo = value;
+               if (!session->recovery_tmo_sysfs_override)
+                       session->recovery_tmo = value;
                break;
        default:
                err = transport->set_param(conn, ev->u.set_param.param,
@@@ -3037,7 -3039,7 +3039,7 @@@ iscsi_get_chap(struct iscsi_transport *
  
        shost = scsi_host_lookup(ev->u.get_chap.host_no);
        if (!shost) {
 -              printk(KERN_ERR "%s: failed. Cound not find host no %u\n",
 +              printk(KERN_ERR "%s: failed. Could not find host no %u\n",
                       __func__, ev->u.get_chap.host_no);
                return -ENODEV;
        }
@@@ -4049,13 -4051,15 +4051,15 @@@ store_priv_session_##field(struct devic
        if ((session->state == ISCSI_SESSION_FREE) ||                   \
            (session->state == ISCSI_SESSION_FAILED))                   \
                return -EBUSY;                                          \
-       if (strncmp(buf, "off", 3) == 0)                                \
+       if (strncmp(buf, "off", 3) == 0) {                              \
                session->field = -1;                                    \
-       else {                                                          \
+               session->field##_sysfs_override = true;                 \
+       } else {                                                        \
                val = simple_strtoul(buf, &cp, 0);                      \
                if (*cp != '\0' && *cp != '\n')                         \
                        return -EINVAL;                                 \
                session->field = val;                                   \
+               session->field##_sysfs_override = true;                 \
        }                                                               \
        return count;                                                   \
  }
  static ISCSI_CLASS_ATTR(priv_sess, field, S_IRUGO | S_IWUSR,          \
                        show_priv_session_##field,                      \
                        store_priv_session_##field)
  iscsi_priv_session_rw_attr(recovery_tmo, "%d");
  
  static struct attribute *iscsi_session_attrs[] = {
This page took 0.378158 seconds and 4 git commands to generate.