linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Recognize missing LUNs for non-standard devices
@ 2006-02-06 21:59 Alan Stern
  2006-02-06 22:55 ` Brian King
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Stern @ 2006-02-06 21:59 UTC (permalink / raw)
  To: James Bottomley; +Cc: SCSI development list

Some protocols (like USB UFI) or devices that don't adhere to the SCSI
standard may indicate a nonexistent LUN by returning INQUIRY information
with Peripheral Device Type set to 0x1f (unknown or none) and Peripheral
Qualifier set to 0 instead of 3 as the spec requires.  This patch (as650)
causes PDT = 0x1f to be recognized as no LUN present regardless of the
qualifier value, if the SCSI level is equal to 0.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

---
James:

Since nobody objected when I proposed this last week, I'm now submitting 
it as a real patch.

Alan Stern


Index: usb-2.6/drivers/scsi/scsi_scan.c
===================================================================
--- usb-2.6.orig/drivers/scsi/scsi_scan.c
+++ usb-2.6/drivers/scsi/scsi_scan.c
@@ -873,6 +873,19 @@ static int scsi_probe_and_add_lun(struct
 		goto out_free_result;
 	}
 
+	/*
+	 * Non-standard SCSI devices may set the PDT to 0x1f (unknown or
+	 * no device type) instead of using the peripheral qualifier to
+	 * indicate that no LUN is present.  For example, USB UFI does this.
+	 */
+	if (sdev->scsi_level == 0 && (result[0] & 0x1f) == 0x1f) {
+		SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO
+					"scsi scan: peripheral device type"
+					" of 31, no device added\n"));
+		res = SCSI_SCAN_TARGET_PRESENT;
+		goto out_free_result;
+	}
+
 	res = scsi_add_lun(sdev, result, &bflags);
 	if (res == SCSI_SCAN_LUN_PRESENT) {
 		if (bflags & BLIST_KEY) {


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Recognize missing LUNs for non-standard devices
  2006-02-06 21:59 [PATCH] Recognize missing LUNs for non-standard devices Alan Stern
@ 2006-02-06 22:55 ` Brian King
  2006-02-07 14:53   ` Alan Stern
  0 siblings, 1 reply; 9+ messages in thread
From: Brian King @ 2006-02-06 22:55 UTC (permalink / raw)
  To: Alan Stern; +Cc: James Bottomley, SCSI development list

Alan Stern wrote:
> Some protocols (like USB UFI) or devices that don't adhere to the SCSI
> standard may indicate a nonexistent LUN by returning INQUIRY information
> with Peripheral Device Type set to 0x1f (unknown or none) and Peripheral
> Qualifier set to 0 instead of 3 as the spec requires.  This patch (as650)
> causes PDT = 0x1f to be recognized as no LUN present regardless of the
> qualifier value, if the SCSI level is equal to 0.

This patch will break the ipr driver. The ipr adapter firmware reports a
logical scsi device which is used for RAID configuration. It reports
a Peripheral Device Type of 0x1f and a scsi level of 0, since it does
not claim compliance with any scsi level. 

Brian

> 
> Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
> 
> ---
> James:
> 
> Since nobody objected when I proposed this last week, I'm now submitting 
> it as a real patch.
> 
> Alan Stern
> 
> 
> Index: usb-2.6/drivers/scsi/scsi_scan.c
> ===================================================================
> --- usb-2.6.orig/drivers/scsi/scsi_scan.c
> +++ usb-2.6/drivers/scsi/scsi_scan.c
> @@ -873,6 +873,19 @@ static int scsi_probe_and_add_lun(struct
>  		goto out_free_result;
>  	}
>  
> +	/*
> +	 * Non-standard SCSI devices may set the PDT to 0x1f (unknown or
> +	 * no device type) instead of using the peripheral qualifier to
> +	 * indicate that no LUN is present.  For example, USB UFI does this.
> +	 */
> +	if (sdev->scsi_level == 0 && (result[0] & 0x1f) == 0x1f) {
> +		SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO
> +					"scsi scan: peripheral device type"
> +					" of 31, no device added\n"));
> +		res = SCSI_SCAN_TARGET_PRESENT;
> +		goto out_free_result;
> +	}
> +
>  	res = scsi_add_lun(sdev, result, &bflags);
>  	if (res == SCSI_SCAN_LUN_PRESENT) {
>  		if (bflags & BLIST_KEY) {
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 


-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Recognize missing LUNs for non-standard devices
  2006-02-06 22:55 ` Brian King
@ 2006-02-07 14:53   ` Alan Stern
  2006-02-07 15:16     ` Brian King
  0 siblings, 1 reply; 9+ messages in thread
From: Alan Stern @ 2006-02-07 14:53 UTC (permalink / raw)
  To: Brian King; +Cc: James Bottomley, SCSI development list

On Mon, 6 Feb 2006, Brian King wrote:

> Alan Stern wrote:
> > Some protocols (like USB UFI) or devices that don't adhere to the SCSI
> > standard may indicate a nonexistent LUN by returning INQUIRY information
> > with Peripheral Device Type set to 0x1f (unknown or none) and Peripheral
> > Qualifier set to 0 instead of 3 as the spec requires.  This patch (as650)
> > causes PDT = 0x1f to be recognized as no LUN present regardless of the
> > qualifier value, if the SCSI level is equal to 0.
> 
> This patch will break the ipr driver. The ipr adapter firmware reports a
> logical scsi device which is used for RAID configuration. It reports
> a Peripheral Device Type of 0x1f and a scsi level of 0, since it does
> not claim compliance with any scsi level. 

I was afraid that might happen.  Okay, forget the patch.

How come you didn't mention the ipr driver before when I first raised the 
possibility of making this change?

Alan Stern


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Recognize missing LUNs for non-standard devices
  2006-02-07 14:53   ` Alan Stern
@ 2006-02-07 15:16     ` Brian King
  2006-02-07 15:29       ` Alan Stern
  0 siblings, 1 reply; 9+ messages in thread
From: Brian King @ 2006-02-07 15:16 UTC (permalink / raw)
  To: Alan Stern; +Cc: James Bottomley, SCSI development list

Alan Stern wrote:
> On Mon, 6 Feb 2006, Brian King wrote:
> 
>> Alan Stern wrote:
>>> Some protocols (like USB UFI) or devices that don't adhere to the SCSI
>>> standard may indicate a nonexistent LUN by returning INQUIRY information
>>> with Peripheral Device Type set to 0x1f (unknown or none) and Peripheral
>>> Qualifier set to 0 instead of 3 as the spec requires.  This patch (as650)
>>> causes PDT = 0x1f to be recognized as no LUN present regardless of the
>>> qualifier value, if the SCSI level is equal to 0.
>> This patch will break the ipr driver. The ipr adapter firmware reports a
>> logical scsi device which is used for RAID configuration. It reports
>> a Peripheral Device Type of 0x1f and a scsi level of 0, since it does
>> not claim compliance with any scsi level. 
> 
> I was afraid that might happen.  Okay, forget the patch.
> 
> How come you didn't mention the ipr driver before when I first raised the 
> possibility of making this change?

Sorry about that... I wanted to verify on my end that the scsi level getting
returned was 0 before doing so. Your repost was a reminder...

Brian

-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Recognize missing LUNs for non-standard devices
  2006-02-07 15:16     ` Brian King
@ 2006-02-07 15:29       ` Alan Stern
  2006-02-07 15:40         ` Brian King
  2006-02-07 20:44         ` David Wysochanski
  0 siblings, 2 replies; 9+ messages in thread
From: Alan Stern @ 2006-02-07 15:29 UTC (permalink / raw)
  To: Brian King; +Cc: James Bottomley, SCSI development list

On Tue, 7 Feb 2006, Brian King wrote:

> > I was afraid that might happen.  Okay, forget the patch.
> > 
> > How come you didn't mention the ipr driver before when I first raised the 
> > possibility of making this change?
> 
> Sorry about that... I wanted to verify on my end that the scsi level getting
> returned was 0 before doing so. Your repost was a reminder...

Maybe there's a way around this.  Would it be okay to add a flag to the 
target structure, to indicate that PDT = 0x1f should be interpreted as "No 
LUN present"?

Alan Stern


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Recognize missing LUNs for non-standard devices
  2006-02-07 15:29       ` Alan Stern
@ 2006-02-07 15:40         ` Brian King
  2006-02-09 20:26           ` Alan Stern
  2006-02-07 20:44         ` David Wysochanski
  1 sibling, 1 reply; 9+ messages in thread
From: Brian King @ 2006-02-07 15:40 UTC (permalink / raw)
  To: Alan Stern; +Cc: James Bottomley, SCSI development list

Alan Stern wrote:
> On Tue, 7 Feb 2006, Brian King wrote:
> 
>>> I was afraid that might happen.  Okay, forget the patch.
>>>
>>> How come you didn't mention the ipr driver before when I first raised the 
>>> possibility of making this change?
>> Sorry about that... I wanted to verify on my end that the scsi level getting
>> returned was 0 before doing so. Your repost was a reminder...
> 
> Maybe there's a way around this.  Would it be okay to add a flag to the 
> target structure, to indicate that PDT = 0x1f should be interpreted as "No 
> LUN present"?

Works for me.

-- 
Brian King
eServer Storage I/O
IBM Linux Technology Center

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Recognize missing LUNs for non-standard devices
  2006-02-07 15:29       ` Alan Stern
  2006-02-07 15:40         ` Brian King
@ 2006-02-07 20:44         ` David Wysochanski
  2006-02-07 21:22           ` Alan Stern
  1 sibling, 1 reply; 9+ messages in thread
From: David Wysochanski @ 2006-02-07 20:44 UTC (permalink / raw)
  To: Alan Stern; +Cc: Brian King, James Bottomley, SCSI development list

Alan Stern wrote:
> On Tue, 7 Feb 2006, Brian King wrote:
> 
>  > > I was afraid that might happen.  Okay, forget the patch.
>  > >
>  > > How come you didn't mention the ipr driver before when I first raised the
>  > > possibility of making this change?
>  >
>  > Sorry about that... I wanted to verify on my end that the scsi level getting
>  > returned was 0 before doing so. Your repost was a reminder...
> 
> Maybe there's a way around this.  Would it be okay to add a flag to the
> target structure, to indicate that PDT = 0x1f should be interpreted as "No
> LUN present"?
> 
> Alan Stern
> 

I have this same problem for netapp targets (different scsi_level)
and have been meaning to submit a patch so I'm interested in any
patch you might have.

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Recognize missing LUNs for non-standard devices
  2006-02-07 20:44         ` David Wysochanski
@ 2006-02-07 21:22           ` Alan Stern
  0 siblings, 0 replies; 9+ messages in thread
From: Alan Stern @ 2006-02-07 21:22 UTC (permalink / raw)
  To: David Wysochanski; +Cc: Brian King, James Bottomley, SCSI development list

On Tue, 7 Feb 2006, David Wysochanski wrote:

> > Maybe there's a way around this.  Would it be okay to add a flag to the
> > target structure, to indicate that PDT = 0x1f should be interpreted as "No
> > LUN present"?
> > 
> > Alan Stern
> > 
> 
> I have this same problem for netapp targets (different scsi_level)
> and have been meaning to submit a patch so I'm interested in any
> patch you might have.

Okay, when I write it I'll let you know.  But first I would like to add a
bflags field to the scsi_target and fix up the flags in scsi_device.

Alan Stern


^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH] Recognize missing LUNs for non-standard devices
  2006-02-07 15:40         ` Brian King
@ 2006-02-09 20:26           ` Alan Stern
  0 siblings, 0 replies; 9+ messages in thread
From: Alan Stern @ 2006-02-09 20:26 UTC (permalink / raw)
  To: James Bottomley
  Cc: Brian King, David Wysochanski, SCSI development list,
	USB Storage list

Some non-standard SCSI targets or protocols, such as USB UFI, report "no
LUN present" by setting the Peripheral Device Type to 0x1f and the
Peripheral Qualifier to 0 (not 3 as the standard requires) in the INQUIRY
response.  This patch (as650b) adds a new target flag and code to
accomodate such targets.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>

---

This is a revised version of an earlier patch.  By adding a new flag to
the target structure, this version can avoid any conflicts with devices
that use PDT = 0x1f to represent a legitimate LUN.

After this patch has been merged, I will add code to the usb-storage 
slave_alloc routine to set the pdt_1f_for_no_lun flag for all devices 
using the UFI protocol.

Alan Stern

Index: usb-2.6/drivers/scsi/scsi_scan.c
===================================================================
--- usb-2.6.orig/drivers/scsi/scsi_scan.c
+++ usb-2.6/drivers/scsi/scsi_scan.c
@@ -873,6 +873,19 @@ static int scsi_probe_and_add_lun(struct
 		goto out_free_result;
 	}
 
+	/*
+	 * Non-standard SCSI targets may set the PDT to 0x1f (unknown or
+	 * no device type) instead of using the Peripheral Qualifier to
+	 * indicate that no LUN is present.  For example, USB UFI does this.
+	 */
+	if (starget->pdt_1f_for_no_lun && (result[0] & 0x1f) == 0x1f) {
+		SCSI_LOG_SCAN_BUS(3, printk(KERN_INFO
+					"scsi scan: peripheral device type"
+					" of 31, no device added\n"));
+		res = SCSI_SCAN_TARGET_PRESENT;
+		goto out_free_result;
+	}
+
 	res = scsi_add_lun(sdev, result, &bflags);
 	if (res == SCSI_SCAN_LUN_PRESENT) {
 		if (bflags & BLIST_KEY) {
Index: usb-2.6/include/scsi/scsi_device.h
===================================================================
--- usb-2.6.orig/include/scsi/scsi_device.h
+++ usb-2.6/include/scsi/scsi_device.h
@@ -167,7 +167,10 @@ struct scsi_target {
 	unsigned int		channel;
 	unsigned int		id; /* target id ... replace
 				     * scsi_device.id eventually */
-	unsigned long		create:1; /* signal that it needs to be added */
+	unsigned int		create:1; /* signal that it needs to be added */
+	unsigned int		pdt_1f_for_no_lun;	/* PDT = 0x1f */
+						/* means no lun present */
+
 	char			scsi_level;
 	void 			*hostdata; /* available to low-level driver */
 	unsigned long		starget_data[0]; /* for the transport */


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2006-02-09 20:26 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-02-06 21:59 [PATCH] Recognize missing LUNs for non-standard devices Alan Stern
2006-02-06 22:55 ` Brian King
2006-02-07 14:53   ` Alan Stern
2006-02-07 15:16     ` Brian King
2006-02-07 15:29       ` Alan Stern
2006-02-07 15:40         ` Brian King
2006-02-09 20:26           ` Alan Stern
2006-02-07 20:44         ` David Wysochanski
2006-02-07 21:22           ` Alan Stern

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).