Skip to contentSkip to conversation

uas: leave can_queue as MAX_CMNDS if device reports larger qdepth

PATCH In review [email protected] 3 participants 6 messages May 23, 2016 2 messages not in the archive

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 uas: leave can_queue as MAX_CMNDS if device reports larger qdepth

From: Tom Yan <[email protected]>

Commit 198de51dbc34 ("USB: uas: Limit qdepth at the scsi-host level") made qdepth limit set in host template (.can_queue = MAX_CMNDS) useless.

Instead of removing the template limit, now we only change limit according to the qdepth reported by the device if it is smaller than MAX_CMNDS.

drivers/usb/storage/uas.c +2 -1
index 4d49fce..d7790e6 100644
@@ -972,7 +972,8 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	 * 1 tag is reserved for untagged commands +
 	 * 1 tag to avoid off by one errors in some bridge firmwares
 	 */
-	shost->can_queue = devinfo->qdepth - 2;
+	if (devinfo->qdepth - 2 < MAX_CMNDS)
+		shost->can_queue = devinfo->qdepth - 2;
 
 	usb_set_intfdata(intf, shost);
 	result = scsi_add_host(shost, &intf->dev);
Signature · 6 lines
2.8.2

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
maintainer
#1 lore raw
Quoted 15 lines · On Tue, May 24, 2016 at 12:02:43AM +0800, [email protected] wrote:

From: Tom Yan <[email protected]>

Commit 198de51dbc34 ("USB: uas: Limit qdepth at the scsi-host level") made qdepth limit set in host template (.can_queue = MAX_CMNDS) useless.

Instead of removing the template limit, now we only change limit according to the qdepth reported by the device if it is smaller than MAX_CMNDS.

drivers/usb/storage/uas.c +0 -0
index 4d49fce..d7790e6 100644

drivers/usb/storage/uas.c static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id) · line 976

Quoted 6 lines
drivers/usb/storage/uas.c +2 -1
@@ -972,7 +972,8 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
 	 * 1 tag is reserved for untagged commands +
 	 * 1 tag to avoid off by one errors in some bridge firmwares
 	 */
-	shost->can_queue = devinfo->qdepth - 2;
+	if (devinfo->qdepth - 2 < MAX_CMNDS)
+		shost->can_queue = devinfo->qdepth - 2;

What's wrong with Hans's patch for this issue instead?

A message that is not in the archive (sent off-list or not yet received): [email protected]

author
#3 lore raw

Nothing wrong. It's just .can_queue = MAX_CMNDS in the host template is no longer neceesary, since with his patch, uas will set can_queue again later (to devinfo->qdepth - 2).

Originally I thought .can_queue = MAX_CMNDS can hence be removed; but after a second thought, I think it might probably be better if we leave it there and make use of it, in case certain device somehow inapproriately reports an enormous qdepth (i.e. larger than MAX_CMNDS). (According to the commit message of 55ff8cfbc4e1 ("USB:
uas: Reduce can_queue to MAX_CMNDS"), "The uas driver can never queue more then MAX_CMNDS...")

Quoted 11 lines · Greg KH
Quoted 10 lines · On Tue, May 24, 2016 at 12:02:43AM +0800…

From: Tom Yan <[email protected]>

Commit 198de51dbc34 ("USB: uas: Limit qdepth at the scsi-host level") made qdepth limit set in host template (.can_queue = MAX_CMNDS) useless.

Instead of removing the template limit, now we only change limit according to the qdepth reported by the device if it is smaller than MAX_CMNDS.

Quoted 14 lines

drivers/usb/storage/uas.c static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id) · line 976

Quoted 11 lines
drivers/usb/storage/uas.c +2 -1
index 4d49fce..d7790e6 100644
@@ -972,7 +972,8 @@ static int uas_probe(struct usb_interface *intf, const struct usb_device_id *id)
       * 1 tag is reserved for untagged commands +
       * 1 tag to avoid off by one errors in some bridge firmwares
       */
-     shost->can_queue = devinfo->qdepth - 2;
+     if (devinfo->qdepth - 2 < MAX_CMNDS)
+             shost->can_queue = devinfo->qdepth - 2;

What's wrong with Hans's patch for this issue instead?

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

maintainer
#4 lore raw
Quoted 11 lines · Tom Yan

Nothing wrong. It's just .can_queue = MAX_CMNDS in the host template is no longer neceesary, since with his patch, uas will set can_queue again later (to devinfo->qdepth - 2).

Originally I thought .can_queue = MAX_CMNDS can hence be removed; but after a second thought, I think it might probably be better if we leave it there and make use of it, in case certain device somehow inapproriately reports an enormous qdepth (i.e. larger than MAX_CMNDS). (According to the commit message of 55ff8cfbc4e1 ("USB:
uas: Reduce can_queue to MAX_CMNDS"), "The uas driver can never queue more then MAX_CMNDS...")

OK, so try this as an exercise: Why would this not be the right thing to do after the host is prepared: It has to do with the streams resources the driver has already created.

James

A message that is not in the archive (sent off-list or not yet received): 1464024457.2331.10.camel-d9PhHud1JfjCXq6kfMZ53/[email protected]

author
#6 lore raw

I don't quite get what you mean. Are you saying that it is impossible that UAS devices would report inappropriately high qdepth, because of this?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/drivers/usb/storage/uas.c?h=v4.6#n908

In that case should I send another patch that simply has .can_queue = MAX_CMNDS in the host template removed?

Quoted 13 lines · James Bottomley
Quoted 11 lines · Tom Yan

Nothing wrong. It's just .can_queue = MAX_CMNDS in the host template is no longer neceesary, since with his patch, uas will set can_queue again later (to devinfo->qdepth - 2).

Originally I thought .can_queue = MAX_CMNDS can hence be removed; but after a second thought, I think it might probably be better if we leave it there and make use of it, in case certain device somehow inapproriately reports an enormous qdepth (i.e. larger than MAX_CMNDS). (According to the commit message of 55ff8cfbc4e1 ("USB:
uas: Reduce can_queue to MAX_CMNDS"), "The uas driver can never queue more then MAX_CMNDS...")

Quoted 7 lines

OK, so try this as an exercise: Why would this not be the right thing to do after the host is prepared: It has to do with the streams resources the driver has already created.

James

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

maintainer
#7 lore raw
Quoted 5 lines · Tom Yan

I don't quite get what you mean. Are you saying that it is impossible that UAS devices would report inappropriately high qdepth, because of this?
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/
drivers/usb/storage/uas.c?h=v4.6#n908

OK, you found the statement, now translate what it means to resource allocation and it will show you why the if you proposed to add would always be true.

James

Quoted 38 lines

In that case should I send another patch that simply has `.can_queue =
MAX_CMNDS` in the host template removed?

Quoted 18 lines · James Bottomley
Quoted 6 lines · Tom Yan

Nothing wrong. It's just .can_queue = MAX_CMNDS in the host template
is no longer neceesary, since with his patch, uas will set can_queue
again later (to devinfo->qdepth - 2).

Quoted 10 lines

Originally I thought .can_queue = MAX_CMNDS can hence be removed; but
after a second thought, I think it might probably be better if we leave it there and make use of it, in case certain device somehow inapproriately reports an enormous qdepth (i.e. larger than MAX_CMNDS). (According to the commit message of 55ff8cfbc4e1 ("USB:
uas: Reduce can_queue to MAX_CMNDS"), "The uas driver can never queue
more then MAX_CMNDS...")

Quoted 8 lines

OK, so try this as an exercise: Why would this not be the right thing
to do after the host is prepared: It has to do with the streams resources the driver has already created.

James

--
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