From owner-freebsd-stable@freebsd.org Mon Jan 2 19:06:16 2017 Return-Path: Delivered-To: freebsd-stable@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D0428C9B42E for ; Mon, 2 Jan 2017 19:06:16 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: from mail-io0-x22c.google.com (mail-io0-x22c.google.com [IPv6:2607:f8b0:4001:c06::22c]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A37001DCE for ; Mon, 2 Jan 2017 19:06:16 +0000 (UTC) (envelope-from wlosh@bsdimp.com) Received: by mail-io0-x22c.google.com with SMTP id p42so417332682ioo.1 for ; Mon, 02 Jan 2017 11:06:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=mime-version:sender:in-reply-to:references:from:date:message-id :subject:to:cc; bh=v1Pt78Rb+oSIiwFQcPi2u4lcLyPGQI+mR+1GPrMx3b0=; b=GxaZEFIpzQDb8Q08DMTy+oHwpM860ScvWewlkQ+njHV+DvJ66HCMHp8O9bGfHvR6Np 6sqqNkXpCSZhtsvFgHiS4YxKAdO7oqgHI4i/haVlRpZxAF4x3zmlLoYOXpnJUvu7IXdn fUYoPY9ASOtVcLWzfrW0Q0wZ6qHxuy0JXZny9GF3z/HpApvFb4Oehc6LLtNov87VdkWx 3/jXKdgw1Nxc8/peg018UIlc+2yFzyX7OrrHegjxzFrgl5en4hml9h8bauuFTQ+VEtBc e0CRONil+ijCP2BdKmPxtFu1GC8PnOUfvxogOFsKVA1BhrfhmPG+hpiz5eJ8ODNN0xRk lBwQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:sender:in-reply-to:references:from :date:message-id:subject:to:cc; bh=v1Pt78Rb+oSIiwFQcPi2u4lcLyPGQI+mR+1GPrMx3b0=; b=L27YEXaC/0RhaQZz12EKXoA4fJkWTLEfbzbr0OVYe73Kkq0V7KsnE996/5MBThMxlc cSW4AYjZLjfA+v+QVCYLdYgwiYVlwzoMNTrZNpJBSaO74vfnDttS646EQh+lrgpPVOVz II876sCbl3Y7OatOTdSU7Ju2ee30xtVtu/z23WaeRqwqOsjV6YhiCKkVu+uEFQV4WP7W mlSUkSy86j/wOUAx/2TXSLLvoHp/IVKqGsNqPKdUXeCR60akwk92iNlvmPhQrzl1aYQW aiG2MQXHMoqk6/v6FFuF6/kZE8cWThycWFzfkx/o9YARpX58PxAQNQQVlrZjGwbg+3If B62Q== X-Gm-Message-State: AIkVDXJRmo54K8Yk3WK/OTw4r/kstj0naS5+GOG2l2sx9an9aW2p0hTZVk0jGYkEZ1Tcood6a6V53YyYOJwDkQ== X-Received: by 10.107.154.14 with SMTP id c14mr43929803ioe.0.1483383975824; Mon, 02 Jan 2017 11:06:15 -0800 (PST) MIME-Version: 1.0 Sender: wlosh@bsdimp.com Received: by 10.79.22.135 with HTTP; Mon, 2 Jan 2017 11:06:15 -0800 (PST) X-Originating-IP: [50.253.99.174] In-Reply-To: <20170102184104.GA95857@in-addr.com> References: <586A0F05.6050504@li.ru> <20170102184104.GA95857@in-addr.com> From: Warner Losh Date: Mon, 2 Jan 2017 12:06:15 -0700 X-Google-Sender-Auth: jNyL_VEiAYrTH1MNG2A5_4e-fO4 Message-ID: Subject: Re: usb 3.0 thumb drive speed limit To: Gary Palmer Cc: "Marat N.Afanasyev" , FreeBSD stable Content-Type: text/plain; charset=UTF-8 X-BeenThere: freebsd-stable@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Production branch of FreeBSD source code List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 02 Jan 2017 19:06:16 -0000 On Mon, Jan 2, 2017 at 11:42 AM, Gary Palmer 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: at usbus0 >> umass2 on uhub7 >> umass2: on usbus0 >> da2 at umass-sim2 bus 2 scbus9 target 0 lun 0 >> da2: 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 >> >> 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