linux-scsi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/25] usb: gadget: f_tcm: Enhance UASP driver
@ 2022-07-19  1:26 Thinh Nguyen
  2022-07-19  1:26 ` [PATCH v2 01/25] target: Add overlapped response to tmrsp_table Thinh Nguyen
                   ` (26 more replies)
  0 siblings, 27 replies; 47+ messages in thread
From: Thinh Nguyen @ 2022-07-19  1:26 UTC (permalink / raw)
  To: Felipe Balbi, Greg Kroah-Hartman, Thinh Nguyen, linux-usb,
	linux-kernel, linux-scsi, target-devel, Dmitry Bogdanov,
	Nicholas Bellinger, Martin K. Petersen,
	Sebastian Andrzej Siewior
  Cc: John Youn, Alan Stern, Andrzej Pietrasiewicz, Christoph Hellwig

The Linux UASP gadget driver is incomplete and remained broken for a long time.
It was not implemented for performance either. This series adds some of the
required features for the UASP driver to work. It also makes some changes to
the target core.

This is tested against UASP CV and DWC_usb3x controller. It still needs some
fixes in the target core, which will be separated from this series.

There are still more room for performance improvement and fixes. However, this
series should be sufficient to bring up a working UASP device.


Changes in v2:
 - Remove most target core changes from this series and only keep the must-have
   ones
 - Split the task-management patch to smaller patches
 - Don't send failure Task Management response to target core, reducing
   dependency
 - Add UASP bringup script example in cover page
 - Make various small updates according to feedbacks


Example script
==============
To test UASP, here's an example perl script snippet to bring it up.

Note: the script was cut down and quickly rewritten, so sorry if I make
mistakes. :)

    my $MY_UAS_VID = xxxx;
    my $MY_UAS_PID = yyyy;
    my $SERIAL = "1234";
    my $VENDOR = "VENDOR";
    my $MY_VER = "VER";

    my $vendor_id = "my_vid";
    my $product_id = "my_pid";
    my $revision = "my_rev";

    # Must update:
    my $backing_storage = "/tmp/some_file";
    my $backing_storage_size = 1024*1024*16;
    my $use_ramdisk = 0;

    my $g = "/sys/kernel/config/usb_gadget/g1";

    system("modprobe libcomposite");
    system("modprobe usb_f_tcm");
    system("mkdir -p $g");
    system("mkdir -p $g/configs/c.1");
    system("mkdir -p $g/functions/tcm.0");
    system("mkdir -p $g/strings/0x409");
    system("mkdir -p $g/configs/c.1/strings/0x409");

    my $tp = "/sys/kernel/config/target/usb_gadget/naa.0/tpgt_1";

    my $tf;
    my $ctrl;

    if ($use_ramdisk) {
        $tf = "/sys/kernel/config/target/core/rd_mcp_0/ramdisk";
        $ctrl = 'rd_pages=524288';
    } else {
        $tf = "/sys/kernel/config/target/core/fileio_0/fileio";
        $ctrl = 'fd_dev_name=$backing_storage,fd_dev_size=$backing_storage_size,fd_async_io=1';
    }

    system("mkdir -p /etc/target");

    system("mkdir -p $tp");
    system("mkdir -p $tf");
    system("mkdir -p $tp/lun/lun_0");

    system("echo naa.0         > $tp/nexus");
    system("echo $ctrl         > $tf/control");
    system("echo 1             > $tf/attrib/emulate_ua_intlck_ctrl");
    system("echo 123           > $tf/wwn/vpd_unit_serial");
    system("echo $vendor_id    > $tf/wwn/vendor_id");
    system("echo $product_id   > $tf/wwn/product_id");
    system("echo $revision     > $tf/wwn/revision");
    system("echo 1             > $tf/enable");

    system("ln -s $tf $tp/lun/lun_0/virtual_scsi_port");
    system("echo 1             > $tp/enable");

    system("echo $MY_UAS_PID   > $g/idProduct");

    system("ln -s $g/functions/tcm.0 $g/configs/c.1");

    system("echo $MY_UAS_VID   > $g/idVendor");
    system("echo $SERIAL       > $g/strings/0x409/serialnumber");
    system("echo $VENDOR       > $g/strings/0x409/manufacturer");
    system("echo \"$MY_VER\"   > $g/strings/0x409/product");
    system("echo \"Conf 1\"    > $g/configs/c.1/strings/0x409/configuration");

    system("echo super-speed-plus > $g/max_speed");

    # Make sure the UDC is available
    system("echo $my_udc       > $g/UDC");


Thinh Nguyen (25):
  target: Add overlapped response to tmrsp_table
  target: Add common TMR enum
  usb: gadget: f_tcm: Increase stream count
  usb: gadget: f_tcm: Increase bMaxBurst
  usb: gadget: f_tcm: Don't set static stream_id
  usb: gadget: f_tcm: Allocate matching number of commands to streams
  usb: gadget: f_tcm: Limit number of sessions
  usb: gadget: f_tcm: Handle multiple commands in parallel
  usb: gadget: f_tcm: Use extra number of commands
  usb: gadget: f_tcm: Return ATA cmd direction
  usb: gadget: f_tcm: Execute command on write completion
  usb: gadget: f_tcm: Minor cleanup redundant code
  usb: gadget: f_tcm: Don't free command immediately
  usb: gadget: f_tcm: Translate error to sense
  usb: gadget: f_tcm: Cleanup unused variable
  usb: gadget: f_tcm: Update state on data write
  usb: gadget: f_tcm: Handle abort command
  usb: gadget: f_tcm: Cleanup requests on ep disable
  usb: gadget: f_tcm: Decrement command ref count on cleanup
  usb: gadget: f_tcm: Save CPU ID per command
  usb: gadget: f_tcm: Get stream by tag
  usb: gadget: f_tcm: Send sense on cancelled transfer
  usb: gadget: f_tcm: Handle TASK_MANAGEMENT commands
  usb: gadget: f_tcm: Check overlapped command
  usb: gadget: f_tcm: Comply with UAS Task Management requirement

 drivers/target/target_core_transport.c |  10 +
 drivers/usb/gadget/function/f_tcm.c    | 536 +++++++++++++++++++------
 drivers/usb/gadget/function/tcm.h      |  20 +-
 include/target/target_core_base.h      |   5 +
 4 files changed, 436 insertions(+), 135 deletions(-)


base-commit: 88a15fbb47db483d06b12b1ae69f114b96361a96
-- 
2.28.0


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

end of thread, other threads:[~2022-08-30 10:06 UTC | newest]

Thread overview: 47+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-07-19  1:26 [PATCH v2 00/25] usb: gadget: f_tcm: Enhance UASP driver Thinh Nguyen
2022-07-19  1:26 ` [PATCH v2 01/25] target: Add overlapped response to tmrsp_table Thinh Nguyen
2022-07-19  1:26 ` [PATCH v2 02/25] target: Add common TMR enum Thinh Nguyen
2022-07-19  1:26 ` [PATCH v2 03/25] usb: gadget: f_tcm: Increase stream count Thinh Nguyen
2022-07-19  9:02   ` Sergei Shtylyov
2022-07-19  1:26 ` [PATCH v2 04/25] usb: gadget: f_tcm: Increase bMaxBurst Thinh Nguyen
2022-07-19  1:26 ` [PATCH v2 05/25] usb: gadget: f_tcm: Don't set static stream_id Thinh Nguyen
2022-07-19  1:26 ` [PATCH v2 06/25] usb: gadget: f_tcm: Allocate matching number of commands to streams Thinh Nguyen
2022-07-19  1:26 ` [PATCH v2 07/25] usb: gadget: f_tcm: Limit number of sessions Thinh Nguyen
2022-07-19  1:26 ` [PATCH v2 08/25] usb: gadget: f_tcm: Handle multiple commands in parallel Thinh Nguyen
2022-07-19  1:27 ` [PATCH v2 09/25] usb: gadget: f_tcm: Use extra number of commands Thinh Nguyen
2022-07-19  1:27 ` [PATCH v2 10/25] usb: gadget: f_tcm: Return ATA cmd direction Thinh Nguyen
2022-07-19  1:27 ` [PATCH v2 11/25] usb: gadget: f_tcm: Execute command on write completion Thinh Nguyen
2022-08-26  7:00   ` Sebastian Andrzej Siewior
2022-08-26 18:37     ` Thinh Nguyen
2022-08-29 19:49       ` Sebastian Andrzej Siewior
2022-08-29 21:47         ` Thinh Nguyen
2022-08-30 10:03           ` Sebastian Andrzej Siewior
2022-07-19  1:27 ` [PATCH v2 12/25] usb: gadget: f_tcm: Minor cleanup redundant code Thinh Nguyen
2022-07-19  1:27 ` [PATCH v2 13/25] usb: gadget: f_tcm: Don't free command immediately Thinh Nguyen
2022-07-19  1:27 ` [PATCH v2 14/25] usb: gadget: f_tcm: Translate error to sense Thinh Nguyen
2022-07-19  1:27 ` [PATCH v2 15/25] usb: gadget: f_tcm: Cleanup unused variable Thinh Nguyen
2022-08-26  7:17   ` Sebastian Andrzej Siewior
2022-08-26 18:41     ` Thinh Nguyen
2022-07-19  1:27 ` [PATCH v2 16/25] usb: gadget: f_tcm: Update state on data write Thinh Nguyen
2022-08-26  7:22   ` Sebastian Andrzej Siewior
2022-08-26 19:01     ` Thinh Nguyen
2022-07-19  1:27 ` [PATCH v2 17/25] usb: gadget: f_tcm: Handle abort command Thinh Nguyen
2022-08-26  7:48   ` Sebastian Andrzej Siewior
2022-08-26 19:04     ` Thinh Nguyen
2022-07-19  1:27 ` [PATCH v2 18/25] usb: gadget: f_tcm: Cleanup requests on ep disable Thinh Nguyen
2022-07-19  1:28 ` [PATCH v2 19/25] usb: gadget: f_tcm: Decrement command ref count on cleanup Thinh Nguyen
2022-07-19  1:28 ` [PATCH v2 20/25] usb: gadget: f_tcm: Save CPU ID per command Thinh Nguyen
2022-07-19  1:28 ` [PATCH v2 21/25] usb: gadget: f_tcm: Get stream by tag Thinh Nguyen
2022-08-26  9:06   ` Sebastian Andrzej Siewior
2022-08-26 19:05     ` Thinh Nguyen
2022-07-19  1:28 ` [PATCH v2 22/25] usb: gadget: f_tcm: Send sense on cancelled transfer Thinh Nguyen
2022-07-19  1:28 ` [PATCH v2 23/25] usb: gadget: f_tcm: Handle TASK_MANAGEMENT commands Thinh Nguyen
2022-07-19  1:28 ` [PATCH v2 24/25] usb: gadget: f_tcm: Check overlapped command Thinh Nguyen
2022-08-26 10:46   ` Sebastian Andrzej Siewior
2022-08-26 19:27     ` Thinh Nguyen
2022-07-19  1:28 ` [PATCH v2 25/25] usb: gadget: f_tcm: Comply with UAS Task Management requirement Thinh Nguyen
2022-08-19  8:31 ` [PATCH v2 00/25] usb: gadget: f_tcm: Enhance UASP driver Greg Kroah-Hartman
2022-08-19 17:18   ` Thinh Nguyen
2022-08-26  2:34     ` Thinh Nguyen
2022-08-26 10:52 ` Sebastian Andrzej Siewior
2022-08-26 19:36   ` Thinh Nguyen

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