diff mbox

[V6,01/18] scsi: fixing the "type" for well known LUs

Message ID 1411648356-3883-2-git-send-email-draviv@codeaurora.org (mailing list archive)
State Not Applicable, archived
Headers show

Commit Message

Dolev Raviv Sept. 25, 2014, 12:32 p.m. UTC
From: Subhash Jadavani <subhashj@codeaurora.org>

Some devices may respond with wrong type for well-known logical units.
This patch forces well-known type for devices which doesn't report it
correct.

Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
Signed-off-by: Dolev Raviv <draviv@codeaurora.org>

Comments

Christoph Hellwig Sept. 26, 2014, 8:13 a.m. UTC | #1
Robert, I guess this version is okay with you?

On Thu, Sep 25, 2014 at 03:32:19PM +0300, Dolev Raviv wrote:
> From: Subhash Jadavani <subhashj@codeaurora.org>
> 
> Some devices may respond with wrong type for well-known logical units.
> This patch forces well-known type for devices which doesn't report it
> correct.
> 
> Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
> Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
> Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
> 
> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> index 56675db..1095d5a 100644
> --- a/drivers/scsi/scsi_scan.c
> +++ b/drivers/scsi/scsi_scan.c
> @@ -805,6 +805,19 @@ static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
>  	} else {
>  		sdev->type = (inq_result[0] & 0x1f);
>  		sdev->removable = (inq_result[1] & 0x80) >> 7;
> +
> +		/*
> +		 * some devices may respond with wrong type for
> +		 * well-known logical units. Force well-known type
> +		 * to enumerate them correctly.
> +		 */
> +		if (scsi_is_wlun(sdev->lun) && sdev->type != TYPE_WLUN) {
> +			sdev_printk(KERN_WARNING, sdev,
> +				"%s: correcting incorrect peripheral device type 0x%x for W-LUN 0x%16phN\n",
> +				__func__, sdev->type, sdev->lun);
> +			sdev->type = TYPE_WLUN;
> +		}
> +
>  	}
>  
>  	if (sdev->type == TYPE_RBC || sdev->type == TYPE_ROM) {
> diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
> index 261e708..d17178e 100644
> --- a/include/scsi/scsi.h
> +++ b/include/scsi/scsi.h
> @@ -333,6 +333,7 @@ static inline int scsi_status_is_good(int status)
>  #define TYPE_RBC	    0x0e
>  #define TYPE_OSD            0x11
>  #define TYPE_ZBC            0x14
> +#define TYPE_WLUN           0x1e    /* well-known logical unit */
>  #define TYPE_NO_LUN         0x7f
>  
>  /* SCSI protocols; these are taken from SPC-3 section 7.5 */
> -- 
> 1.8.5.2
> -- 
> QUALCOMM ISRAEL, on behalf of Qualcomm Innovation Center, Inc. is a member
> of Code Aurora Forum, hosted by The Linux Foundation
> 
> --
> 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
---end quoted text---
--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Elliott, Robert (Server Storage) Oct. 3, 2014, 6:40 p.m. UTC | #2
> -----Original Message-----
> From: Christoph Hellwig [mailto:hch@infradead.org]
> Sent: Friday, 26 September, 2014 3:14 AM
> To: Dolev Raviv
> Cc: James.Bottomley@HansenPartnership.com; hch@infradead.org; linux-
> scsi@vger.kernel.org; linux-scsi-owner@vger.kernel.org; linux-arm-
> msm@vger.kernel.org; santoshsy@gmail.com; Subhash Jadavani; Sujit Reddy
> Thumma; Elliott, Robert (Server Storage); Martin K. Petersen
> Subject: Re: [PATCH V6 01/18] scsi: fixing the "type" for well known LUs
> 
> Robert, I guess this version is okay with you?
> 
> On Thu, Sep 25, 2014 at 03:32:19PM +0300, Dolev Raviv wrote:
> > From: Subhash Jadavani <subhashj@codeaurora.org>
> >
> > Some devices may respond with wrong type for well-known logical units.
> > This patch forces well-known type for devices which doesn't report it
> > correct.
> >
> > Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
> > Signed-off-by: Sujit Reddy Thumma <sthumma@codeaurora.org>
> > Signed-off-by: Dolev Raviv <draviv@codeaurora.org>
> >
> > diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
> > index 56675db..1095d5a 100644
> > --- a/drivers/scsi/scsi_scan.c
> > +++ b/drivers/scsi/scsi_scan.c
> > @@ -805,6 +805,19 @@ static int scsi_add_lun(struct scsi_device *sdev,
> unsigned char *inq_result,
> >  	} else {
> >  		sdev->type = (inq_result[0] & 0x1f);
> >  		sdev->removable = (inq_result[1] & 0x80) >> 7;
> > +
> > +		/*
> > +		 * some devices may respond with wrong type for
> > +		 * well-known logical units. Force well-known type
> > +		 * to enumerate them correctly.
> > +		 */
> > +		if (scsi_is_wlun(sdev->lun) && sdev->type != TYPE_WLUN) {
> > +			sdev_printk(KERN_WARNING, sdev,
> > +				"%s: correcting incorrect peripheral device type
> 0x%x for W-LUN 0x%16phN\n",
> > +				__func__, sdev->type, sdev->lun);
> > +			sdev->type = TYPE_WLUN;
> > +		}
> > +

Yes, that looks good.

Reviewed-by: Robert Elliott <elliott@hp.com>

--
To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index 56675db..1095d5a 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -805,6 +805,19 @@  static int scsi_add_lun(struct scsi_device *sdev, unsigned char *inq_result,
 	} else {
 		sdev->type = (inq_result[0] & 0x1f);
 		sdev->removable = (inq_result[1] & 0x80) >> 7;
+
+		/*
+		 * some devices may respond with wrong type for
+		 * well-known logical units. Force well-known type
+		 * to enumerate them correctly.
+		 */
+		if (scsi_is_wlun(sdev->lun) && sdev->type != TYPE_WLUN) {
+			sdev_printk(KERN_WARNING, sdev,
+				"%s: correcting incorrect peripheral device type 0x%x for W-LUN 0x%16phN\n",
+				__func__, sdev->type, sdev->lun);
+			sdev->type = TYPE_WLUN;
+		}
+
 	}
 
 	if (sdev->type == TYPE_RBC || sdev->type == TYPE_ROM) {
diff --git a/include/scsi/scsi.h b/include/scsi/scsi.h
index 261e708..d17178e 100644
--- a/include/scsi/scsi.h
+++ b/include/scsi/scsi.h
@@ -333,6 +333,7 @@  static inline int scsi_status_is_good(int status)
 #define TYPE_RBC	    0x0e
 #define TYPE_OSD            0x11
 #define TYPE_ZBC            0x14
+#define TYPE_WLUN           0x1e    /* well-known logical unit */
 #define TYPE_NO_LUN         0x7f
 
 /* SCSI protocols; these are taken from SPC-3 section 7.5 */