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@vger.kernel.org
Cc: torvalds@linux-foundation.org, akpm@linux-foundation.org,
	alan@lxorguk.ukuu.org.uk, Luben Tuikov <ltuikov@yahoo.com>,
	Alan Stern <stern@rowland.harvard.edu>,
	Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Subject: [061/101] USB: storage: Use normalized sense when emulating autosense
Date: Wed, 02 Nov 2011 15:26:45 -0700	[thread overview]
Message-ID: <20111102222745.324713877@clark.kroah.org> (raw)
In-Reply-To: <20111102222755.GA10893@kroah.com>

2.6.33-longterm review patch.  If anyone has any objections, please let us know.

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

From: Luben Tuikov <ltuikov@yahoo.com>

commit e16da02fcdf1c5e824432f88abf42623dafdf191 upstream.

This patch solves two things:
1) Enables autosense emulation code to correctly
interpret descriptor format sense data, and
2) Fixes a bug whereby the autosense emulation
code would overwrite descriptor format sense data
with SENSE KEY HARDWARE ERROR in fixed format, to
incorrectly look like this:

Oct 21 14:11:07 localhost kernel: sd 7:0:0:0: [sdc]  Sense Key : Recovered Error [current] [descriptor]
Oct 21 14:11:07 localhost kernel: Descriptor sense data with sense descriptors (in hex):
Oct 21 14:11:07 localhost kernel:        72 01 04 1d 00 00 00 0e 09 0c 00 00 00 00 00 00
Oct 21 14:11:07 localhost kernel:        00 4f 00 c2 00 50
Oct 21 14:11:07 localhost kernel: sd 7:0:0:0: [sdc]  ASC=0x4 ASCQ=0x1d

Signed-off-by: Luben Tuikov <ltuikov@yahoo.com>
Acked-by: Alan Stern <stern@rowland.harvard.edu>
Acked-by: Matthew Dharm <mdharm-usb@one-eyed-alien.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

---
 drivers/usb/storage/transport.c |   34 +++++++++++++++++++---------------
 1 file changed, 19 insertions(+), 15 deletions(-)

--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -693,6 +693,9 @@ void usb_stor_invoke_transport(struct sc
 		int temp_result;
 		struct scsi_eh_save ses;
 		int sense_size = US_SENSE_SIZE;
+		struct scsi_sense_hdr sshdr;
+		const u8 *scdd;
+		u8 fm_ili;
 
 		/* device supports and needs bigger sense buffer */
 		if (us->fflags & US_FL_SANE_SENSE)
@@ -776,32 +779,30 @@ Retry_Sense:
 			srb->sense_buffer[7] = (US_SENSE_SIZE - 8);
 		}
 
+		scsi_normalize_sense(srb->sense_buffer, SCSI_SENSE_BUFFERSIZE,
+				     &sshdr);
+
 		US_DEBUGP("-- Result from auto-sense is %d\n", temp_result);
 		US_DEBUGP("-- code: 0x%x, key: 0x%x, ASC: 0x%x, ASCQ: 0x%x\n",
-			  srb->sense_buffer[0],
-			  srb->sense_buffer[2] & 0xf,
-			  srb->sense_buffer[12], 
-			  srb->sense_buffer[13]);
+			  sshdr.response_code, sshdr.sense_key,
+			  sshdr.asc, sshdr.ascq);
 #ifdef CONFIG_USB_STORAGE_DEBUG
-		usb_stor_show_sense(
-			  srb->sense_buffer[2] & 0xf,
-			  srb->sense_buffer[12], 
-			  srb->sense_buffer[13]);
+		usb_stor_show_sense(sshdr.sense_key, sshdr.asc, sshdr.ascq);
 #endif
 
 		/* set the result so the higher layers expect this data */
 		srb->result = SAM_STAT_CHECK_CONDITION;
 
+		scdd = scsi_sense_desc_find(srb->sense_buffer,
+					    SCSI_SENSE_BUFFERSIZE, 4);
+		fm_ili = (scdd ? scdd[3] : srb->sense_buffer[2]) & 0xA0;
+
 		/* We often get empty sense data.  This could indicate that
 		 * everything worked or that there was an unspecified
 		 * problem.  We have to decide which.
 		 */
-		if (	/* Filemark 0, ignore EOM, ILI 0, no sense */
-				(srb->sense_buffer[2] & 0xaf) == 0 &&
-			/* No ASC or ASCQ */
-				srb->sense_buffer[12] == 0 &&
-				srb->sense_buffer[13] == 0) {
-
+		if (sshdr.sense_key == 0 && sshdr.asc == 0 && sshdr.ascq == 0 &&
+		    fm_ili == 0) {
 			/* If things are really okay, then let's show that.
 			 * Zero out the sense buffer so the higher layers
 			 * won't realize we did an unsolicited auto-sense.
@@ -816,7 +817,10 @@ Retry_Sense:
 			 */
 			} else {
 				srb->result = DID_ERROR << 16;
-				srb->sense_buffer[2] = HARDWARE_ERROR;
+				if ((sshdr.response_code & 0x72) == 0x72)
+					srb->sense_buffer[1] = HARDWARE_ERROR;
+				else
+					srb->sense_buffer[2] = HARDWARE_ERROR;
 			}
 		}
 	}



  parent reply	other threads:[~2011-11-03  1:41 UTC|newest]

Thread overview: 103+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-11-02 22:27 [000/101] 2.6.33.20-longterm review Greg KH
2011-11-02 22:25 ` [001/101] USB: ftdi_sio: add Calao reference board support Greg KH
2011-11-02 22:25 ` [002/101] USB: EHCI: Do not rely on PORT_SUSPEND to stop USB resuming in ehci_bus_resume() Greg KH
2011-11-02 22:25 ` [003/101] rt2x00: do not drop usb dev reference counter on suspend Greg KH
2011-11-02 22:25 ` [004/101] atm: br2684: Fix oops due to skb->dev being NULL Greg KH
2011-11-02 22:25 ` [005/101] sparc64: remove unnecessary macros from spinlock_64.h Greg KH
2011-11-02 22:25 ` [006/101] sparc32: unbreak arch_write_unlock() Greg KH
2011-11-02 22:25 ` [007/101] sparc: fix array bounds error setting up PCIC NMI trap Greg KH
2011-11-02 22:25 ` [008/101] ipv6: Add GSO support on forwarding path Greg KH
2011-11-02 22:25 ` [009/101] Revert "x86, hotplug: Use mwait to offline a processor, fix the legacy case" Greg KH
2011-11-02 22:25 ` [010/101] GRO: fix merging a paged skb after non-paged skbs Greg KH
2011-11-02 22:25 ` [011/101] xen-blkfront: fix data size for xenbus_gather in blkfront_connect Greg KH
2011-11-02 22:25 ` [012/101] md/linear: avoid corrupting structure while waiting for rcu_free to complete Greg KH
2011-11-02 22:25 ` [013/101] powerpc/pci: Check devices status property when scanning OF tree Greg KH
2011-11-02 22:25 ` [014/101] xen: x86_32: do not enable iterrupts when returning from exception in interrupt context Greg KH
2011-11-02 22:25 ` [015/101] xen/smp: Warn user why they keel over - nosmp or noapic and what to use instead Greg KH
2011-11-02 22:26 ` [016/101] ARM: davinci: da850 EVM: read mac address from SPI flash Greg KH
2011-11-02 22:26 ` [017/101] md: Fix handling for devices from 2TB to 4TB in 0.90 metadata Greg KH
2011-11-02 22:26 ` [018/101] net/9p: fix client code to fail more gracefully on protocol error Greg KH
2011-11-02 22:26 ` [019/101] fs/9p: Fid is not valid after a failed clunk Greg KH
2011-11-02 22:26 ` [020/101] fs/9p: Fix invalid mount options/args Greg KH
2011-11-02 22:26 ` [021/101] net/9p: Fix the msize calculation Greg KH
2011-11-02 22:26 ` [022/101] irda: fix smsc-ircc2 section mismatch warning Greg KH
2011-11-02 22:26 ` [023/101] [SCSI] qla2xxx: Correct inadvertent loop state transitions during port-update handling Greg KH
2011-11-02 22:26 ` [024/101] e1000: Fix driver to be used on PA RISC C8000 workstations Greg KH
2011-11-02 22:26 ` [025/101] ASoC: Fix reporting of partial jack updates Greg KH
2011-11-02 22:26 ` [026/101] ALSA: HDA: Cirrus - fix "Surround Speaker" volume control name Greg KH
2011-11-02 22:26 ` [027/101] drm/radeon/kms: fix typo in r100_blit_copy Greg KH
2011-11-03 13:01   ` Deucher, Alexander
2011-11-02 22:26 ` [028/101] cifs: fix possible memory corruption in CIFSFindNext Greg KH
2011-11-02 22:26 ` [029/101] b43: Fix beacon problem in ad-hoc mode Greg KH
2011-11-02 22:26 ` [030/101] wireless: Reset beacon_found while updating regulatory Greg KH
2011-11-02 22:26 ` [031/101] rtl2800usb: Fix incorrect storage of MAC address on big-endian platforms Greg KH
2011-11-02 22:26 ` [032/101] USB: PL2303: correctly handle baudrates above 115200 Greg KH
2011-11-02 22:26 ` [033/101] ASIX: Add AX88772B USB ID Greg KH
2011-11-02 22:26 ` [034/101] [SCSI] fcoe: Unable to select the exchangeID from offload pool for storage targets Greg KH
2011-11-02 22:26 ` [035/101] hvc_console: Improve tty/console put_chars handling Greg KH
2011-11-02 22:26 ` [036/101] TPM: Call tpm_transmit with correct size Greg KH
2011-11-02 22:26 ` [037/101] TPM: Zero buffer after copying to userspace Greg KH
2011-11-02 22:26 ` [038/101] [SCSI] libiscsi_tcp: fix LLD data allocation Greg KH
2011-11-02 22:26 ` [039/101] cnic: Improve NETDEV_UP event handling Greg KH
2011-11-02 22:26 ` [040/101] ALSA: hda/realtek - Avoid bogus HP-pin assignment Greg KH
2011-11-02 22:26 ` [041/101] [SCSI] 3w-9xxx: fix iommu_iova leak Greg KH
2011-11-02 22:26 ` [042/101] [SCSI] aacraid: reset should disable MSI interrupt Greg KH
2011-11-02 22:26 ` [043/101] [SCSI] libsas: fix failure to revalidate domain for anything but the first expander child Greg KH
2011-11-02 22:26 ` [044/101] cfg80211: Fix validation of AKM suites Greg KH
2011-11-02 22:26 ` [045/101] splice: direct_splice_actor() should not use pos in sd Greg KH
2011-11-02 22:26 ` [046/101] [SCSI] libsas: fix panic when single phy is disabled on a wide port Greg KH
2011-11-02 22:26 ` [047/101] ahci: Enable SB600 64bit DMA on Asus M3A Greg KH
2011-11-02 22:26 ` [048/101] HID: usbhid: Add support for SiGma Micro chip Greg KH
2011-11-02 22:26 ` [049/101] hwmon: (w83627ehf) Properly report thermal diode sensors Greg KH
2011-11-02 22:26 ` [050/101] x25: Prevent skb overreads when checking call user data Greg KH
2011-11-02 22:26 ` [051/101] block: check for proper length of iov entries earlier in blk_rq_map_user_iov() Greg KH
2011-11-02 22:26 ` [052/101] staging: quatech_usb2: Potential lost wakeup scenario in TIOCMIWAIT Greg KH
2011-11-02 22:26 ` [053/101] USB: qcserial: add device ID for "HP un2430 Mobile Broadband Module" Greg KH
2011-11-02 22:26 ` [054/101] xhci-mem.c: Check for ring->first_seg != NULL Greg KH
2011-11-02 22:26 ` [055/101] [SCSI] ipr: Always initiate hard reset in kdump kernel Greg KH
2011-11-02 22:26 ` [056/101] [SCSI] libsas: set sas_address and device type of rphy Greg KH
2011-11-02 22:26 ` [057/101] ALSA: HDA: Add new revision for ALC662 Greg KH
2011-11-02 22:26 ` [058/101] x86: Fix compilation bug in kprobes twobyte_is_boostable Greg KH
2011-11-02 22:26 ` [059/101] epoll: fix spurious lockdep warnings Greg KH
2011-11-02 22:26 ` [060/101] usbmon vs. tcpdump: fix dropped packet count Greg KH
2011-11-02 22:26 ` Greg KH [this message]
2011-11-02 22:26 ` [062/101] usb/core/devio.c: Check for printer class specific request Greg KH
2011-11-02 22:26 ` [063/101] USB: pid_ns: ensure pid is not freed during kill_pid_info_as_uid Greg KH
2011-11-02 22:26 ` [064/101] usb: cdc-acm: Owen SI-30 support Greg KH
2011-11-02 22:26 ` [065/101] USB: pl2303: add id for SMART device Greg KH
2011-11-02 22:26 ` [066/101] USB: ftdi_sio: add PID for Sony Ericsson Urban Greg KH
2011-11-02 22:26 ` [067/101] USB: ftdi_sio: Support TI/Luminary Micro Stellaris BD-ICDI Board Greg KH
2011-11-02 22:26 ` [068/101] QE/FHCI: fixed the CONTROL bug Greg KH
2011-11-02 22:26 ` [069/101] Update email address for stable patch submission Greg KH
2011-11-02 22:26 ` [070/101] kobj_uevent: Ignore if some listeners cannot handle message Greg KH
2011-11-02 22:26 ` [071/101] kmod: prevent kmod_loop_msg overflow in __request_module() Greg KH
2011-11-02 22:26 ` [072/101] time: Change jiffies_to_clock_t() argument type to unsigned long Greg KH
2011-11-02 22:26 ` [073/101] tracing: Fix returning of duplicate data after EOF in trace_pipe_raw Greg KH
2011-11-02 22:26 ` [074/101] nfsd4: Remove check for a 32-bit cookie in nfsd4_readdir() Greg KH
2011-11-02 22:26 ` [075/101] nfsd4: fix seqid_mutating_error Greg KH
2011-11-02 22:27 ` [076/101] nfsd4: ignore WANT bits in open downgrade Greg KH
2011-11-02 22:27 ` [077/101] ASoC: ak4642: fixup cache register table Greg KH
2011-11-02 22:27 ` [078/101] ASoC: ak4535: " Greg KH
2011-11-02 22:27 ` [079/101] KVM: s390: check cpu_id prior to using it Greg KH
2011-11-02 22:27 ` [080/101] [S390] ccwgroup: move attributes to attribute group Greg KH
2011-11-02 22:27 ` [081/101] iommu/amd: Fix wrong shift direction Greg KH
2011-11-02 22:27 ` [082/101] carminefb: Fix module parameters permissions Greg KH
2011-11-02 22:27 ` [083/101] [media] uvcvideo: Set alternate setting 0 on resume if the bus has been reset Greg KH
2011-11-02 22:27 ` [084/101] [media] tuner_xc2028: Allow selection of the frequency adjustment code for XC3028 Greg KH
2011-11-02 22:27 ` [085/101] plat-mxc: iomux-v3.h: implicitly enable pull-up/down when thats desired Greg KH
2011-11-02 22:27 ` [086/101] net: Fix a memmove bug in dev_gro_receive() Greg KH
2011-11-02 22:27 ` [087/101] gro: fix different skb headrooms Greg KH
2011-11-02 22:27 ` [088/101] gro: Re-fix " Greg KH
2011-11-02 22:27 ` [089/101] Revert "MIPS: MTX-1: Make au1000_eth probe all PHY Greg KH
2011-11-02 22:27 ` [090/101] Revert "usb: musb: restore INDEX register in resume path" Greg KH
2011-11-02 22:27 ` [091/101] watchdog: mtx1-wdt: fix build failure Greg KH
2011-11-02 22:27 ` [092/101] kcore: fix test for end of list Greg KH
2011-11-02 22:27 ` [093/101] thinkpad-acpi: module autoloading for newer Lenovo ThinkPads Greg KH
2011-11-02 22:27 ` [094/101] scm: lower SCM_MAX_FD Greg KH
2011-11-02 22:27 ` [095/101] NLM: Dont hang forever on NLM unlock requests Greg KH
2011-11-02 22:27 ` [096/101] Bluetooth: l2cap and rfcomm: fix 1 byte infoleak to userspace Greg KH
2011-11-02 22:27 ` [097/101] vm: fix vm_pgoff wrap in stack expansion Greg KH
2011-11-02 22:27 ` [098/101] vm: fix vm_pgoff wrap in upward expansion Greg KH
2011-11-02 22:27 ` [099/101] Bluetooth: Prevent buffer overflow in l2cap config request Greg KH
2011-11-02 22:27 ` [100/101] nl80211: fix overflow in ssid_len Greg KH
2011-11-02 22:27 ` [101/101] net_sched: Fix qdisc_notify() 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=20111102222745.324713877@clark.kroah.org \
    --to=gregkh@suse.de \
    --cc=akpm@linux-foundation.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ltuikov@yahoo.com \
    --cc=mdharm-usb@one-eyed-alien.net \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --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

all inboxes | Powered by JetHome®