Date: Mon, 2 Jan 2017 12:06:15 -0700 From: Warner Losh <imp@bsdimp.com> To: Gary Palmer <gpalmer@freebsd.org> Cc: "Marat N.Afanasyev" <amarat@li.ru>, FreeBSD stable <freebsd-stable@freebsd.org> Subject: Re: usb 3.0 thumb drive speed limit Message-ID: <CANCZdfrKjvahSvTv-RQtGWJ_%2B1-Qs%2BZyehpp5_Qg5dJ89VirGg@mail.gmail.com> In-Reply-To: <20170102184104.GA95857@in-addr.com> References: <586A0F05.6050504@li.ru> <20170102184104.GA95857@in-addr.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Mon, Jan 2, 2017 at 11:42 AM, Gary Palmer <gpalmer@freebsd.org> wrote: > On Mon, Jan 02, 2017 at 11:27:49AM +0300, Marat N.Afanasyev wrote: >> I wonder is there a speed limit on usb 3.0? I've bought >> >> ugen0.4: <SanDisk> at usbus0 >> umass2 on uhub7 >> umass2: <SanDisk Extreme, class 0/0, rev 2.10/0.10, addr 4> on usbus0 >> da2 at umass-sim2 bus 2 scbus9 target 0 lun 0 >> da2: <SanDisk Extreme 0001> Removable Direct Access SPC-4 SCSI device >> da2: Serial Number AA010808161609220143 >> da2: 40.000MB/s transfers >> da2: 59840MB (122552320 512 byte sectors) >> da2: quirks=0x2<NO_6_BYTE> >> >> that claims 'Up to 245 MBytes/sec read speed' > > I don't think the speed reported by the SCSI layer (CAM) is correct > for USB, although it seems from an experiment here that if you > plug a USB3 drive into a USB2 port it reports "40.000MB/s transfers" > and on a USB3 port it reports "400.000MB/s transfers". SCSI doesn't > really have any direct mapping to the USB speeds so I suspect the > USB stack uses the closest value. The tests I did were with 10.3. > Other releases may behave differently. > > Check with usbconfig what the negotiated USB speed is (the "spd=" value > with the Mbps or Gbps value in brackets afterwards) > > FULL = USB1 > HIGH = USB2 > SUPER = USB3 40MB/s is just a number that's reported. It's not a speed limit. Our USB stack reports that we understand SCSI protocol rev 2, but we use the XPORT_USB for the transport. This means the code that prints those numbers in scsi_xpt.c will use base_transfer_speed from the XPT_PATH_INQ command. umass.c sets this to either 40MB/s or 400MB/s in a decision that boils down to if that code thinks the transfer is over USB 2.0 or 3.0. The fact that we're reporting 40MB/s rather than 400MB/s suggests to me that it was attached on a USB 2.0 hub rather than a USB 3.0 hub, or it was attached with HIGH speed to a 3.0 hub because the signals needed to do the SUPER speed were missing. On many computers, only the "blue" USB ports are 3.0 speed, and only then when wired correctly (as I discovered the hard way with a recent mobo I put into service). For reference, for USB connected umass devices, the driver returns 20kB/s for devices claiming to be floppies, 1MB/s for FULL speed transfers, 40MB/s for HIGH speed and 400MB/s for SUPER speed. Looking at the latest code, it sure looks like USB speeds are reported correctly, or nearly correctly, up to the CAM layer as a good first order estimate for how fast the drive can code. They do assume a 33% overhead on USB (which is typical), so that's consistent with getting just over 40MB/s from dd for a HIGH speed device. Warner
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfrKjvahSvTv-RQtGWJ_%2B1-Qs%2BZyehpp5_Qg5dJ89VirGg>