mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
	akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
	Lalit Chandivade <lalit.chandivade@qlogic.com>,
	Michael Hernandez <michael.hernandez@qlogic.com>,
	Ravi Anand <ravi.anand@qlogic.com>,
	Andrew Vasquez <andrew.vasquez@qlogic.com>,
	Giridhar Malavali <giridhar.malavali@qlogic.com>,
	James Bottomley <James.Bottomley@suse.de>
Subject: [79/98] [SCSI] qla2xxx: Properly handle UNDERRUN completion statuses.
Date: Mon, 10 May 2010 15:35:31 -0700	[thread overview]
Message-ID: <20100510223541.503627465@kvm.kroah.org> (raw)
In-Reply-To: <20100510223714.GA18416@kroah.com>

2.6.32-stable review patch.  If anyone has any objections, please let us know.

------------------

From: Lalit Chandivade <lalit.chandivade@qlogic.com>

commit 0f00a206ccb1dc644b6770ef25f185610fee6962 upstream.

Correct issues where the lower scsi-status would be improperly
cleared, instead, allow the midlayer to process the status after
the proper residual-count checks are performed.  Finally,
validate firmware status flags prior to assigning values from the
FCP_RSP frame.

Signed-off-by: Lalit Chandivade <lalit.chandivade@qlogic.com>
Signed-off-by: Michael Hernandez <michael.hernandez@qlogic.com>
Signed-off-by: Ravi Anand <ravi.anand@qlogic.com>
Signed-off-by: Andrew Vasquez <andrew.vasquez@qlogic.com>
Signed-off-by: Giridhar Malavali <giridhar.malavali@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/scsi/qla2xxx/qla_isr.c |  120 +++++++++++++++++++----------------------
 1 file changed, 57 insertions(+), 63 deletions(-)

--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -1347,16 +1347,22 @@ qla2x00_status_entry(scsi_qla_host_t *vh
 
 	sense_len = rsp_info_len = resid_len = fw_resid_len = 0;
 	if (IS_FWI2_CAPABLE(ha)) {
-		sense_len = le32_to_cpu(sts24->sense_len);
-		rsp_info_len = le32_to_cpu(sts24->rsp_data_len);
-		resid_len = le32_to_cpu(sts24->rsp_residual_count);
-		fw_resid_len = le32_to_cpu(sts24->residual_len);
+		if (scsi_status & SS_SENSE_LEN_VALID)
+			sense_len = le32_to_cpu(sts24->sense_len);
+		if (scsi_status & SS_RESPONSE_INFO_LEN_VALID)
+			rsp_info_len = le32_to_cpu(sts24->rsp_data_len);
+		if (scsi_status & (SS_RESIDUAL_UNDER | SS_RESIDUAL_OVER))
+			resid_len = le32_to_cpu(sts24->rsp_residual_count);
+		if (comp_status == CS_DATA_UNDERRUN)
+			fw_resid_len = le32_to_cpu(sts24->residual_len);
 		rsp_info = sts24->data;
 		sense_data = sts24->data;
 		host_to_fcp_swap(sts24->data, sizeof(sts24->data));
 	} else {
-		sense_len = le16_to_cpu(sts->req_sense_length);
-		rsp_info_len = le16_to_cpu(sts->rsp_info_len);
+		if (scsi_status & SS_SENSE_LEN_VALID)
+			sense_len = le16_to_cpu(sts->req_sense_length);
+		if (scsi_status & SS_RESPONSE_INFO_LEN_VALID)
+			rsp_info_len = le16_to_cpu(sts->rsp_info_len);
 		resid_len = le32_to_cpu(sts->residual_length);
 		rsp_info = sts->rsp_info;
 		sense_data = sts->req_sense_data;
@@ -1443,38 +1449,62 @@ qla2x00_status_entry(scsi_qla_host_t *vh
 		break;
 
 	case CS_DATA_UNDERRUN:
-		resid = resid_len;
+		DEBUG2(printk(KERN_INFO
+		    "scsi(%ld:%d:%d) UNDERRUN status detected 0x%x-0x%x. "
+		    "resid=0x%x fw_resid=0x%x cdb=0x%x os_underflow=0x%x\n",
+		    vha->host_no, cp->device->id, cp->device->lun, comp_status,
+		    scsi_status, resid_len, fw_resid_len, cp->cmnd[0],
+		    cp->underflow));
+
 		/* Use F/W calculated residual length. */
-		if (IS_FWI2_CAPABLE(ha)) {
-			if (!(scsi_status & SS_RESIDUAL_UNDER)) {
-				lscsi_status = 0;
-			} else if (resid != fw_resid_len) {
-				scsi_status &= ~SS_RESIDUAL_UNDER;
-				lscsi_status = 0;
+		resid = IS_FWI2_CAPABLE(ha) ? fw_resid_len : resid_len;
+		scsi_set_resid(cp, resid);
+		if (scsi_status & SS_RESIDUAL_UNDER) {
+			if (IS_FWI2_CAPABLE(ha) && fw_resid_len != resid_len) {
+				DEBUG2(printk(
+				    "scsi(%ld:%d:%d:%d) Dropped frame(s) "
+				    "detected (%x of %x bytes)...residual "
+				    "length mismatch...retrying command.\n",
+				    vha->host_no, cp->device->channel,
+				    cp->device->id, cp->device->lun, resid,
+				    scsi_bufflen(cp)));
+
+				cp->result = DID_ERROR << 16 | lscsi_status;
+				break;
 			}
-			resid = fw_resid_len;
-		}
 
-		if (scsi_status & SS_RESIDUAL_UNDER) {
-			scsi_set_resid(cp, resid);
-		} else {
-			DEBUG2(printk(KERN_INFO
-			    "scsi(%ld:%d:%d) UNDERRUN status detected "
-			    "0x%x-0x%x. resid=0x%x fw_resid=0x%x cdb=0x%x "
-			    "os_underflow=0x%x\n", vha->host_no,
-			    cp->device->id, cp->device->lun, comp_status,
-			    scsi_status, resid_len, resid, cp->cmnd[0],
-			    cp->underflow));
+			if (!lscsi_status &&
+			    ((unsigned)(scsi_bufflen(cp) - resid) <
+			    cp->underflow)) {
+				qla_printk(KERN_INFO, ha,
+				    "scsi(%ld:%d:%d:%d): Mid-layer underflow "
+				    "detected (%x of %x bytes)...returning "
+				    "error status.\n", vha->host_no,
+				    cp->device->channel, cp->device->id,
+				    cp->device->lun, resid, scsi_bufflen(cp));
 
+				cp->result = DID_ERROR << 16;
+				break;
+			}
+		} else if (!lscsi_status) {
+			DEBUG2(printk(
+			    "scsi(%ld:%d:%d:%d) Dropped frame(s) detected "
+			    "(%x of %x bytes)...firmware reported underrun..."
+			    "retrying command.\n", vha->host_no,
+			    cp->device->channel, cp->device->id,
+			    cp->device->lun, resid, scsi_bufflen(cp)));
+
+			cp->result = DID_ERROR << 16;
+			break;
 		}
 
+		cp->result = DID_OK << 16 | lscsi_status;
+
 		/*
 		 * Check to see if SCSI Status is non zero. If so report SCSI
 		 * Status.
 		 */
 		if (lscsi_status != 0) {
-			cp->result = DID_OK << 16 | lscsi_status;
-
 			if (lscsi_status == SAM_STAT_TASK_SET_FULL) {
 				DEBUG2(printk(KERN_INFO
 				    "scsi(%ld): QUEUE FULL status detected "
@@ -1501,42 +1531,6 @@ qla2x00_status_entry(scsi_qla_host_t *vh
 				break;
 
 			qla2x00_handle_sense(sp, sense_data, sense_len, rsp);
-		} else {
-			/*
-			 * If RISC reports underrun and target does not report
-			 * it then we must have a lost frame, so tell upper
-			 * layer to retry it by reporting an error.
-			 */
-			if (!(scsi_status & SS_RESIDUAL_UNDER)) {
-				DEBUG2(printk("scsi(%ld:%d:%d:%d) Dropped "
-					      "frame(s) detected (%x of %x bytes)..."
-					      "retrying command.\n",
-					vha->host_no, cp->device->channel,
-					cp->device->id, cp->device->lun, resid,
-					scsi_bufflen(cp)));
-
-				scsi_set_resid(cp, resid);
-				cp->result = DID_ERROR << 16;
-				break;
-			}
-
-			/* Handle mid-layer underflow */
-			if ((unsigned)(scsi_bufflen(cp) - resid) <
-			    cp->underflow) {
-				qla_printk(KERN_INFO, ha,
-					   "scsi(%ld:%d:%d:%d): Mid-layer underflow "
-					   "detected (%x of %x bytes)...returning "
-					   "error status.\n", vha->host_no,
-					   cp->device->channel, cp->device->id,
-					   cp->device->lun, resid,
-					   scsi_bufflen(cp));
-
-				cp->result = DID_ERROR << 16;
-				break;
-			}
-
-			/* Everybody online, looking good... */
-			cp->result = DID_OK << 16;
 		}
 		break;
 



  parent reply	other threads:[~2010-05-10 23:04 UTC|newest]

Thread overview: 106+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-05-10 22:37 [00/98] 2.6.32.13-stable review Greg KH
2010-05-10 22:34 ` [01/98] USB: EHCI: defer reclamation of siTDs Greg KH
2010-05-10 22:34 ` [02/98] p54usb: Add usbid for Corega CG-WLUSB2GT Greg KH
2010-05-10 22:34 ` [03/98] md/raid5: allow for more than 2^31 chunks Greg KH
2010-05-10 22:34 ` [04/98] md/raid5: fix previous patch Greg KH
2010-05-10 22:34 ` [05/98] libata: fix locking around blk_abort_request() Greg KH
2010-05-10 22:34 ` [06/98] libata: ensure NCQ error result taskfile is fully initialized Greg KH
2010-05-10 22:34 ` [07/98] w1: w1 temp: fix negative termperature calculation Greg KH
2010-05-10 22:34 ` [08/98] memcg: fix prepare migration Greg KH
2010-05-10 22:34 ` [09/98] mac80211: remove bogus TX agg state assignment Greg KH
2010-05-10 22:34 ` [10/98] flex_array: fix the panic when calling flex_array_alloc() without __GFP_ZERO Greg KH
2010-05-10 22:34 ` [11/98] core, x86: make LIST_POISON less deadly Greg KH
2010-05-10 22:34 ` [12/98] hugetlb: fix infinite loop in get_futex_key() when backed by huge pages Greg KH
2010-05-10 22:34 ` [13/98] reiserfs: fix permissions on .reiserfs_priv Greg KH
2010-05-10 22:34 ` [14/98] reiserfs: fix corruption during shrinking of xattrs Greg KH
2010-05-10 22:34 ` [15/98] nfsd4: bug in read_buf Greg KH
2010-05-10 22:34 ` [16/98] keys: the request_key() syscall should link an existing key to the dest keyring Greg KH
2010-05-10 22:34 ` [17/98] staging: usbip: Fix deadlock Greg KH
2010-05-10 22:34 ` [18/98] USB: fix remote wakeup settings during system sleep Greg KH
2010-05-10 22:34 ` [19/98] USB: Add id for HP ev2210 a.k.a Sierra MC5725 miniPCI-e Cell Modem Greg KH
2010-05-10 22:34 ` [20/98] USB: fix testing the wrong variable in fs_create_by_name() Greg KH
2010-05-10 22:34 ` [21/98] USB: dont choose configs with no interfaces Greg KH
2010-05-10 22:34 ` [22/98] USB: OHCI: dont look at the root hub to get the number of ports Greg KH
2010-05-10 22:34 ` [23/98] USB: xhci: properly set the "Mult" field of the endpoint context Greg KH
2010-05-10 22:34 ` [24/98] USB: xhci: properly set endpoint context fields for periodic eps Greg KH
2010-05-10 22:34 ` [25/98] procfs: fix tid fdinfo Greg KH
2010-05-10 22:34 ` [26/98] ocfs2: Update VFS inodes id info after reflink Greg KH
2010-05-10 22:34 ` [27/98] ocfs2: potential ERR_PTR dereference on error paths Greg KH
2010-05-10 22:34 ` [28/98] ocfs2: Compute metaecc for superblocks during online resize Greg KH
2010-05-10 22:34 ` [29/98] ocfs2_dlmfs: Fix math error when reading LVB Greg KH
2010-05-10 22:34 ` [30/98] powernow-k8: Fix frequency reporting Greg KH
2010-05-10 22:34 ` [31/98] nfs d_revalidate() is too trigger-happy with d_drop() Greg KH
2010-05-10 22:34 ` [32/98] NFS: rsize and wsize settings ignored on v4 mounts Greg KH
2010-05-10 22:34 ` [33/98] Staging: hv: Fix a bug affecting IPv6 Greg KH
2010-05-10 22:34 ` [34/98] Staging: hv: Fix up memory leak on HvCleanup Greg KH
2010-05-10 22:34 ` [35/98] Staging: hv: name network device ethX rather than sethX Greg KH
2010-05-10 22:34 ` [36/98] i2c: Fix probing of FSC hardware monitoring chips Greg KH
2010-05-10 22:34 ` [37/98] perf: Fix resource leak in failure path of perf_event_open() Greg KH
2010-05-10 22:34 ` [38/98] raid6: fix recovery performance regression Greg KH
2010-05-10 22:34 ` [39/98] serial: 8250_pnp - add Fujitsu Wacom device Greg KH
2010-05-10 22:34 ` [40/98] block: ensure jiffies wrap is handled correctly in blk_rq_timed_out_timer Greg KH
2010-05-10 22:34 ` [41/98] dm9601: fix phy/eeprom write routine Greg KH
2010-05-10 22:34 ` [42/98] p54pci: fix bugs in p54p_check_tx_ring Greg KH
2010-05-10 22:34 ` [43/98] edac, mce: Fix wrong mask and macro usage Greg KH
2010-05-10 22:34 ` [44/98] x86-64: Clear a 64-bit FS/GS base on fork if selector is nonzero Greg KH
2010-05-10 22:34 ` [45/98] x86: Disable large pages on CPUs with Atom erratum AAE44 Greg KH
2010-05-10 22:34 ` [46/98] x86, k8 nb: Fix boot crash: enable k8_northbridges unconditionally on AMD systems Greg KH
2010-05-10 22:34 ` [47/98] x86, AMD: Fix stale cpuid4_info shared_map data in shared_cpu_map cpumasks Greg KH
2010-05-10 22:35 ` [48/98] ALSA: hda: Use LPIB quirk for DG965OT board version AAD63733-203 Greg KH
2010-05-10 22:35 ` [49/98] ALSA: hda - Add PCI quirk for HP dv6-1110ax Greg KH
2010-05-10 22:35 ` [50/98] ALSA: hda: Use STAC_DELL_M6_BOTH quirk for Dell Studio XPS 1645 Greg KH
2010-05-10 22:35 ` [51/98] ALSA: hda: Use STAC_DELL_M6_BOTH quirk for Dell Studio 1558 Greg KH
2010-05-10 23:31   ` Nigel Cunningham
2010-05-10 22:35 ` [52/98] ALSA: hda: Use ALC880_F1734 quirk for Fujitsu Siemens AMILO Xi 1526 Greg KH
2010-05-10 22:35 ` [53/98] ALSA: snd-meastro3: Add amp_gpio quirk for Compaq EVO N600C Greg KH
2010-05-10 22:35 ` [54/98] ALSA: snd-meastro3: Ignore spurious HV interrupts during suspend / resume Greg KH
2010-05-10 22:35 ` [55/98] ALSA: hda: Fix max PCM level to 0 dB for Fujitsu-Siemens laptops using CX20549 (Venice) Greg KH
2010-05-10 22:35 ` [56/98] ALSA: hda: Fix 0 dB for Packard Bell models using Conexant " Greg KH
2010-05-10 22:35 ` [57/98] ALSA: hda: Use olpc-xo-1_5 quirk for Toshiba Satellite Pro T130-15F Greg KH
2010-05-10 22:35 ` [58/98] ALSA: hda: Use olpc-xo-1_5 quirk for Toshiba Satellite P500-PSPGSC-01800T Greg KH
2010-05-10 22:35 ` [59/98] libata: Fix accesses at LBA28 boundary (old bug, but nasty) (v2) Greg KH
2010-05-10 22:35 ` [60/98] ext4: correctly calculate number of blocks for fiemap Greg KH
2010-05-10 22:35 ` [61/98] initramfs: handle unrecognised decompressor when unpacking Greg KH
2010-05-10 22:35 ` [62/98] drm/i915: fix tiling limits for i915 class hw v2 Greg KH
2010-05-10 22:35 ` [63/98] CRED: Fix a race in creds_are_invalid() in credentials debugging Greg KH
2010-05-10 22:35 ` [64/98] jfs: fix diAllocExt error in resizing filesystem Greg KH
2010-05-10 22:35 ` [65/98] ACPI: introduce kernel parameter acpi_sleep=sci_force_enable Greg KH
2010-05-10 22:35 ` [66/98] p54pci: rx frame length check Greg KH
2010-05-10 22:35 ` [67/98] drivers/net/wireless/p54/txrx.c Fix off by one error Greg KH
2010-05-10 22:35 ` [68/98] dccp_probe: Fix module load dependencies between dccp and dccp_probe Greg KH
2010-05-10 22:35 ` [69/98] KVM: remove unused load_segment_descriptor_to_kvm_desct Greg KH
2010-05-10 22:35 ` [70/98] kgdb: dont needlessly skip PAGE_USER test for Fsl booke Greg KH
2010-05-10 22:35 ` [71/98] r8169: use correct barrier between cacheable and non-cacheable memory Greg KH
2010-05-10 22:35 ` [72/98] r8169: fix broken register writes Greg KH
2010-05-10 22:35 ` [73/98] r8169: more broken register writes workaround Greg KH
2010-05-10 22:35 ` [74/98] PCI: Ensure we re-enable devices on resume Greg KH
2010-05-10 22:35 ` [75/98] [SCSI] skip sense logging for some ATA PASS-THROUGH cdbs Greg KH
2010-05-10 22:35 ` [76/98] tg3: Fix INTx fallback when MSI fails Greg KH
2010-05-10 22:35 ` [77/98] xfs: add a shrinker to background inode reclaim Greg KH
2010-05-11 14:47   ` Alex Elder
2010-05-11 15:12     ` Greg KH
2010-05-10 22:35 ` [78/98] parisc: Set PCI CLS early in boot Greg KH
2010-05-10 22:35 ` Greg KH [this message]
2010-05-10 22:35 ` [80/98] bnx2: Fix lost MSI-X problem on 5709 NICs Greg KH
2010-05-10 22:35 ` [81/98] tracing: Fix ftrace_event_call alignment for use with gcc 4.5 Greg KH
2010-05-10 22:35 ` [82/98] security: testing the wrong variable in create_by_name() Greg KH
2010-05-10 22:35 ` [83/98] md: restore ability of spare drives to spin down Greg KH
2010-05-10 22:35 ` [84/98] virtio: initialize earlier Greg KH
2010-05-10 22:35 ` [85/98] md/raid6: Fix raid-6 read-error correction in degraded state Greg KH
2010-05-10 22:35 ` [86/98] V4L/DVB: budget: Oops: "BUG: unable to handle kernel NULL pointer dereference" Greg KH
2010-05-10 22:35 ` [87/98] ACPI: DMI init_set_sci_en_on_resume for multiple Lenovo ThinkPads Greg KH
2010-05-11  3:39   ` Alex Chiang
2010-05-10 22:35 ` [88/98] power_meter: acpi_device_class "power_meter_resource" too long Greg KH
2010-05-10 22:35 ` [89/98] ACPI: sleep: init_set_sci_en_on_resume for Dell Studio 155x Greg KH
2010-05-10 22:35 ` [90/98] cpuidle: Fix incorrect optimization Greg KH
2010-05-10 22:35 ` [91/98] [ARM] pxa/colibri: fix missing #include <mach/mfp.h> in colibri.h Greg KH
2010-05-10 22:35 ` [92/98] SCSI: fix locking around blk_abort_request() Greg KH
2010-05-10 22:35 ` [93/98] SCSI: libiscsi: regression: fix header digest errors Greg KH
2010-05-10 22:35 ` [94/98] [SCSI] scsi_debug: virtual_gb ignores sector_size Greg KH
2010-05-10 22:35 ` [95/98] [SCSI] Enable retries for SYNCRONIZE_CACHE commands to fix I/O error Greg KH
2010-05-10 22:35 ` [96/98] SCSI: Retry commands with UNIT_ATTENTION sense codes to fix ext3/ext4 " Greg KH
2010-05-10 22:35 ` [97/98] MIPS: Sibyte: Apply M3 workaround only on affected chip types and versions Greg KH
2010-05-10 22:35 ` [98/98] MIPS: uasm: Add OR instruction Greg KH
2010-05-11 11:53   ` [Stable-review] " Stefan Bader
2010-05-11 12:00     ` Stefan Bader
2010-05-11 15:02     ` Greg KH

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20100510223541.503627465@kvm.kroah.org \
    --to=gregkh@suse.de \
    --cc=James.Bottomley@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=andrew.vasquez@qlogic.com \
    --cc=giridhar.malavali@qlogic.com \
    --cc=lalit.chandivade@qlogic.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michael.hernandez@qlogic.com \
    --cc=ravi.anand@qlogic.com \
    --cc=stable-review@kernel.org \
    --cc=stable@kernel.org \
    --cc=torvalds@linux-foundation.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome