Skip to contentSkip to conversation

scsi: support well known logical units

PATCH [email protected] 2 participants 3 messages Aug 22, 2014 – Aug 25, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw
Quoted 4 lines · Dolev Raviv
Quoted 3 lines

From: Subhash Jadavani <[email protected]>
REPORT LUNS command has "SELECT REPORT" field which controls what type of logical units to be reported by device server. According to UFS device

standard, if this field is set to 0, REPORT LUNS would report only report

Quoted 1 line
Quoted 1 line

standard logical units. If it's set to 1 then it would report only well

known logical unit and if it's set to 2 then device would report both standard and well known logical units.

Quoted 2 lines
Quoted 2 lines

Some well-known logical units might not have scsi upper-layer drivers. In such cases, the runtime PM reference count increased during device

enumeration will not be decreased, causing the parent device (host) to always be on even during idle.

Quoted 1 line
Quoted 1 line

This change allows the SCSI LLD (Low Level Driver) to choose which type

of logical units should be detected.

Quoted 4 lines

drivers/scsi/scsi_scan.c index

Quoted 4 lines
drivers/scsi/scsi_scan.c index renamed from drivers/scsi/scsi_scan.c +0 -0

4a6e4ba..5a0e164 100644

Quoted 3 lines

drivers/scsi/scsi_scan.c static int scsi_add_lun(struct scsi_device *sdev,

Quoted 3 lines
drivers/scsi/scsi_scan.c +0 -0
@@ -802,6 +802,14 @@ static int scsi_add_lun(struct scsi_device *sdev,

unsigned char *inq_result,

Quoted 4 lines
Quoted 4 lines
drivers/scsi/scsi_scan.c +1 -0
 	} else {
 		sdev->type = (inq_result[0] & 0x1f);
 		sdev->removable = (inq_result[1] & 0x80) >> 7;
+
Quoted 8 lines

drivers/scsi/scsi_scan.c static int scsi_add_lun(struct scsi_device *sdev, · line 812

Quoted 7 lines
drivers/scsi/scsi_scan.c +7 -0
+		/*
+		 * 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->type = TYPE_WLUN;

no need to test for TYPE_WLUN here.]

Agreed, will fix it.

Quoted 2 lines

drivers/scsi/scsi_scan.c static int scsi_add_lun(struct scsi_device *sdev,

Quoted 2 lines
drivers/scsi/scsi_scan.c +0 -0
 	switch (sdev->type) {
@@ -817,6 +825,7 @@ static int scsi_add_lun(struct scsi_device *sdev,

unsigned char *inq_result,

Quoted 8 lines

drivers/scsi/scsi_scan.c static int scsi_add_lun(struct scsi_device *sdev, · line 831

Quoted 7 lines
drivers/scsi/scsi_scan.c +1 -0
 	case TYPE_COMM:
 	case TYPE_RAID:
 	case TYPE_OSD:
+	case TYPE_WLUN:
 		sdev->writeable = 1;
 		break;
 	case TYPE_ROM:

This switch statements has been removed in 3.17-rc1, please rebase your

series on top of it.

Sure.

Quoted 2 lines

While you're at it please make this patch, which introduceѕ core scsi changes first in the series.

Ok. Will move these core changes first in the current patch series.

Quoted 7 lines

drivers/scsi/scsi_scan.c static int scsi_report_lun_scan(struct · line 1426

Quoted 7 lines
drivers/scsi/scsi_scan.c +3 -0
@@ -1412,6 +1421,13 @@ static int scsi_report_lun_scan(struct
 scsi_target *starget, int bflags,
 	 */
 	memset(&scsi_cmd[1], 0, 5);
+	if (shost->report_wlus)
+		/*
+		 * Set "SELECT REPORT" field to 0x2 which will make device to +		 *

report well known logical units along with standard LUs.

Quoted 3 lines

drivers/scsi/scsi_scan.c static int scsi_report_lun_scan(struct · line 1428

Quoted 2 lines
drivers/scsi/scsi_scan.c +2 -0
+		 */
+		scsi_cmd[2] = 0x2;

So we're finally getting well known LUN support. I think we should key

this

Quoted 1 line

off the SBC compliance level and not have the drivers opt in.

If i understood this correctly, we want to make all devices report well known LUs irrespective of device driver (LLD)'s preference? If yes then i will knock off "if (shost->report_wlus)" check.

Quoted 1 line

drivers/scsi/scsi_sysfs.c

Quoted 1 line
drivers/scsi/scsi_sysfs.c +0 -0

index 5f36788..ba9d0f0 100644

Quoted 3 lines

drivers/scsi/scsi_sysfs.c int scsi_sysfs_add_sdev(struct scsi_device

Quoted 3 lines
drivers/scsi/scsi_sysfs.c +0 -0
@@ -1060,6 +1060,13 @@ int scsi_sysfs_add_sdev(struct scsi_device

*sdev)

Quoted 9 lines

drivers/scsi/scsi_sysfs.c int scsi_sysfs_add_sdev(struct scsi_device · line 1067

Quoted 8 lines
drivers/scsi/scsi_sysfs.c +6 -0
 		}
 	}
+	/*
+	 * put runtime pm reference for well-known logical units,
+	 * drivers are expected to _get_* again during probe.
+	 */
+	if (scsi_is_wlun(sdev->lun))
+		scsi_autopm_put_device(sdev);

Special casing the well known LUNs here seems wrong. Shouldn't we do

this

Quoted 1 line

for any devices that don't get a driver attached to them?

Agreed, i will replace "if (scsi_is_wlun(sdev->lun))" check with "if (sdev->sdev_gendev.driver)".

Regards,
Subhash

#1 lore raw
Quoted 7 lines · On Fri, Aug 22, 2014 at 12:02:30AM -0000, [email protected] wrote:
Quoted 7 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+	/*
+	 * put runtime pm reference for well-known logical units,
+	 * drivers are expected to _get_* again during probe.
+	 */
+	if (scsi_is_wlun(sdev->lun))
+		scsi_autopm_put_device(sdev);

Special casing the well known LUNs here seems wrong. Shouldn't we do

Quoted 5 lines

this

Quoted 1 line

for any devices that don't get a driver attached to them?

Agreed, i will replace "if (scsi_is_wlun(sdev->lun))" check with "if (sdev->sdev_gendev.driver)".

I would really prefer the callers of autopm get/put to be symmetric to issues with later than probe driver attach or similar. Think of the case say the CDROM or tape driver only gets loaded after we already did a bus scan. A quick check of the autopm code and it's underlying implementation seems to suggest that nesting them is okay. If that's indeed the case I would suggest to restructure it the following way:

- make the scsi_autopm_put_device call you add at the end of scsi_sysfs_add_sdev unconditional to make it balance out the get earlier in the function (and delete the now incorrect comment above the scsi_autopm_get_device call).
- let drivers do paired get/put calls in their probe/remove methods.

If you still need any wlun changes after that please send them as a separate patch with a detailed description on why you need it.

All in all the autopm code and it's underlying implementation is highly confusing, so additional documentation on it would also be very welcome.

#2 lore raw
Quoted 21 lines · On Fri, Aug 22, 2014 at 12:02:30AM -0000, [email protected] wrote:
Quoted 7 lines
Quoted 7 lines

Review

Quoted 6 lines
(quoted diff) +6 -0
+	/*
+	 * put runtime pm reference for well-known logical units,
+	 * drivers are expected to _get_* again during probe.
+	 */
+	if (scsi_is_wlun(sdev->lun))
+		scsi_autopm_put_device(sdev);

Special casing the well known LUNs here seems wrong. Shouldn't we do

Quoted 5 lines

this

Quoted 1 line

for any devices that don't get a driver attached to them?

Agreed, i will replace "if (scsi_is_wlun(sdev->lun))" check with "if (sdev->sdev_gendev.driver)".

I would really prefer the callers of autopm get/put to be symmetric to issues with later than probe driver attach or similar. Think of the case say the CDROM or tape driver only gets loaded after we already did a bus scan. A quick check of the autopm code and it's underlying implementation seems to suggest that nesting them is okay. If that's indeed the case I would suggest to restructure it the following way:

Quoted 8 lines

- make the scsi_autopm_put_device call you add at the end of scsi_sysfs_add_sdev unconditional to make it balance out the get earlier in the function (and delete the now incorrect comment above the scsi_autopm_get_device call).
- let drivers do paired get/put calls in their probe/remove methods.

If you still need any wlun changes after that please send them as a separate patch with a detailed description on why you need it.

Thanks, yes I was also thinking on same lines but was not sure if it would work or not. But let me check this more and if it works, will make a different patch for it.

Quoted 2 lines

All in all the autopm code and it's underlying implementation is highly confusing, so additional documentation on it would also be very welcome.

I would agree but not sure if I would be able to add it now, hopefully some time in future.

Quoted 5 lines

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html