···11+===============================================================22+Synopsys DesignWare Core SuperSpeed USB 3.0 Controller33+===============================================================44+55+:Author: Felipe Balbi <felipe.balbi@linux.intel.com>66+:Date: April 201777+88+Introduction99+============1010+1111+The *Synopsys DesignWare Core SuperSpeed USB 3.0 Controller*1212+(hereinafter referred to as *DWC3*) is a USB SuperSpeed compliant1313+controller which can be configured in one of 4 ways:1414+1515+ 1. Peripheral-only configuration1616+ 2. Host-only configuration1717+ 3. Dual-Role configuration1818+ 4. Hub configuration1919+2020+Linux currently supports several versions of this controller. In all2121+likelyhood, the version in your SoC is already supported. At the time2222+of this writing, known tested versions range from 2.02a to 3.10a. As a2323+rule of thumb, anything above 2.02a should work reliably well.2424+2525+Currently, we have many known users for this driver. In alphabetical2626+order:2727+2828+ 1. Cavium2929+ 2. Intel Corporation3030+ 3. Qualcomm3131+ 4. Rockchip3232+ 5. ST3333+ 6. Samsung3434+ 7. Texas Instruments3535+ 8. Xilinx3636+3737+Summary of Features3838+======================3939+4040+For details about features supported by your version of DWC3, consult4141+your IP team and/or *Synopsys DesignWare Core SuperSpeed USB 3.04242+Controller Databook*. Following is a list of features supported by the4343+driver at the time of this writing:4444+4545+ 1. Up to 16 bidirectional endpoints (including the control4646+ pipe - ep0)4747+ 2. Flexible endpoint configuration4848+ 3. Simultaneous IN and OUT transfer support4949+ 4. Scatter-list support5050+ 5. Up to 256 TRBs [#trb]_ per endpoint5151+ 6. Support for all transfer types (*Control*, *Bulk*,5252+ *Interrupt*, and *Isochronous*)5353+ 7. SuperSpeed Bulk Streams5454+ 8. Link Power Management5555+ 9. Trace Events for debugging5656+ 10. DebugFS [#debugfs]_ interface5757+5858+These features have all been exercised with many of the **in-tree**5959+gadget drivers. We have verified both *ConfigFS* [#configfs]_ and6060+legacy gadget drivers.6161+6262+Driver Design6363+==============6464+6565+The DWC3 driver sits on the *drivers/usb/dwc3/* directory. All files6666+related to this driver are in this one directory. This makes it easy6767+for new-comers to read the code and understand how it behaves.6868+6969+Because of DWC3's configuration flexibility, the driver is a little7070+complex in some places but it should be rather straightforward to7171+understand.7272+7373+The biggest part of the driver refers to the Gadget API.7474+7575+Known Limitations7676+===================7777+7878+Like any other HW, DWC3 has its own set of limitations. To avoid7979+constant questions about such problems, we decided to document them8080+here and have a single location to where we could point users.8181+8282+OUT Transfer Size Requirements8383+---------------------------------8484+8585+According to Synopsys Databook, all OUT transfer TRBs [#trb]_ must8686+have their *size* field set to a value which is integer divisible by8787+the endpoint's *wMaxPacketSize*. This means that *e.g.* in order to8888+receive a Mass Storage *CBW* [#cbw]_, req->length must either be set8989+to a value that's divisible by *wMaxPacketSize* (1024 on SuperSpeed,9090+512 on HighSpeed, etc), or DWC3 driver must add a Chained TRB pointing9191+to a throw-away buffer for the remaining length. Without this, OUT9292+transfers will **NOT** start.9393+9494+Note that as of this writing, this won't be a problem because DWC3 is9595+fully capable of appending a chained TRB for the remaining length and9696+completely hide this detail from the gadget driver. It's still worth9797+mentioning because this seems to be the largest source of queries9898+about DWC3 and *non-working transfers*.9999+100100+TRB Ring Size Limitation101101+-------------------------102102+103103+We, currently, have a hard limit of 256 TRBs [#trb]_ per endpoint,104104+with the last TRB being a Link TRB [#link_trb]_ pointing back to the105105+first. This limit is arbitrary but it has the benefit of adding up to106106+exactly 4096 bytes, or 1 Page.107107+108108+DWC3 driver will try its best to cope with more than 255 requests and,109109+for the most part, it should work normally. However this is not110110+something that has been exercised very frequently. If you experience111111+any problems, see section **Reporting Bugs** below.112112+113113+Reporting Bugs114114+================115115+116116+Whenever you encounter a problem with DWC3, first and foremost you117117+should make sure that:118118+119119+ 1. You're running latest tag from `Linus' tree`_120120+ 2. You can reproduce the error without any out-of-tree changes121121+ to DWC3122122+ 3. You have checked that it's not a fault on the host machine123123+124124+After all these are verified, then here's how to capture enough125125+information so we can be of any help to you.126126+127127+Required Information128128+---------------------129129+130130+DWC3 relies exclusively on Trace Events for debugging. Everything is131131+exposed there, with some extra bits being exposed to DebugFS132132+[#debugfs]_.133133+134134+In order to capture DWC3's Trace Events you should run the following135135+commands **before** plugging the USB cable to a host machine:136136+137137+.. code-block:: sh138138+139139+ # mkdir -p /d140140+ # mkdir -p /t141141+ # mount -t debugfs none /d142142+ # mount -t tracefs none /t143143+ # echo 81920 > /t/buffer_size_kb144144+ # echo 1 > /t/events/dwc3/enable145145+146146+After this is done, you can connect your USB cable and reproduce the147147+problem. As soon as the fault is reproduced, make a copy of files148148+``trace`` and ``regdump``, like so:149149+150150+.. code-block:: sh151151+152152+ # cp /t/trace /root/trace.txt153153+ # cat /d/*dwc3*/regdump > /root/regdump.txt154154+155155+Make sure to compress ``trace.txt`` and ``regdump.txt`` in a tarball156156+and email it to `me`_ with `linux-usb`_ in Cc. If you want to be extra157157+sure that I'll help you, write your subject line in the following158158+format:159159+160160+ **[BUG REPORT] usb: dwc3: Bug while doing XYZ**161161+162162+On the email body, make sure to detail what you doing, which gadget163163+driver you were using, how to reproduce the problem, what SoC you're164164+using, which OS (and its version) was running on the Host machine.165165+166166+With all this information, we should be able to understand what's167167+going on and be helpful to you.168168+169169+Debugging170170+===========171171+172172+First and foremost a disclaimer::173173+174174+ DISCLAIMER: The information available on DebugFS and/or TraceFS can175175+ change at any time at any Major Linux Kernel Release. If writing176176+ scripts, do **NOT** assume information to be available in the177177+ current format.178178+179179+With that out of the way, let's carry on.180180+181181+If you're willing to debug your own problem, you deserve a round of182182+applause :-)183183+184184+Anyway, there isn't much to say here other than Trace Events will be185185+really helpful in figuring out issues with DWC3. Also, access to186186+Synopsys Databook will be **really** valuable in this case.187187+188188+A USB Sniffer can be helpful at times but it's not entirely required,189189+there's a lot that can be understood without looking at the wire.190190+191191+Feel free to email `me`_ and Cc `linux-usb`_ if you need any help.192192+193193+``DebugFS``194194+-------------195195+196196+``DebugFS`` is very good for gathering snapshots of what's going on197197+with DWC3 and/or any endpoint.198198+199199+On DWC3's ``DebugFS`` directory, you will find the following files and200200+directories:201201+202202+``ep[0..15]{in,out}/``203203+``link_state``204204+``regdump``205205+``testmode``206206+207207+``link_state``208208+``````````````209209+210210+When read, ``link_state`` will print out one of ``U0``, ``U1``,211211+``U2``, ``U3``, ``SS.Disabled``, ``RX.Detect``, ``SS.Inactive``,212212+``Polling``, ``Recovery``, ``Hot Reset``, ``Compliance``,213213+``Loopback``, ``Reset``, ``Resume`` or ``UNKNOWN link state``.214214+215215+This file can also be written to in order to force link to one of the216216+states above.217217+218218+``regdump``219219+`````````````220220+221221+File name is self-explanatory. When read, ``regdump`` will print out a222222+register dump of DWC3. Note that this file can be grepped to find the223223+information you want.224224+225225+``testmode``226226+``````````````227227+228228+When read, ``testmode`` will print out a name of one of the specified229229+USB 2.0 Testmodes (``test_j``, ``test_k``, ``test_se0_nak``,230230+``test_packet``, ``test_force_enable``) or the string ``no test`` in231231+case no tests are currently being executed.232232+233233+In order to start any of these test modes, the same strings can be234234+written to the file and DWC3 will enter the requested test mode.235235+236236+237237+``ep[0..15]{in,out}``238238+``````````````````````239239+240240+For each endpoint we expose one directory following the naming241241+convention ``ep$num$dir`` *(ep0in, ep0out, ep1in, ...)*. Inside each242242+of these directories you will find the following files:243243+244244+``descriptor_fetch_queue``245245+``event_queue``246246+``rx_fifo_queue``247247+``rx_info_queue``248248+``rx_request_queue``249249+``transfer_type``250250+``trb_ring``251251+``tx_fifo_queue``252252+``tx_request_queue``253253+254254+With access to Synopsys Databook, you can decode the information on255255+them.256256+257257+``transfer_type``258258+~~~~~~~~~~~~~~~~~~259259+260260+When read, ``transfer_type`` will print out one of ``control``,261261+``bulk``, ``interrupt`` or ``isochronous`` depending on what the262262+endpoint descriptor says. If the endpoint hasn't been enabled yet, it263263+will print ``--``.264264+265265+``trb_ring``266266+~~~~~~~~~~~~~267267+268268+When read, ``trb_ring`` will print out details about all TRBs on the269269+ring. It will also tell you where our enqueue and dequeue pointers are270270+located in the ring:271271+272272+.. code-block:: sh273273+274274+ buffer_addr,size,type,ioc,isp_imi,csp,chn,lst,hwo275275+ 000000002c754000,481,normal,1,0,1,0,0,0 276276+ 000000002c75c000,481,normal,1,0,1,0,0,0 277277+ 000000002c780000,481,normal,1,0,1,0,0,0 278278+ 000000002c788000,481,normal,1,0,1,0,0,0 279279+ 000000002c78c000,481,normal,1,0,1,0,0,0 280280+ 000000002c754000,481,normal,1,0,1,0,0,0 281281+ 000000002c75c000,481,normal,1,0,1,0,0,0 282282+ 000000002c784000,481,normal,1,0,1,0,0,0 283283+ 000000002c788000,481,normal,1,0,1,0,0,0 284284+ 000000002c78c000,481,normal,1,0,1,0,0,0 285285+ 000000002c790000,481,normal,1,0,1,0,0,0 286286+ 000000002c758000,481,normal,1,0,1,0,0,0 287287+ 000000002c780000,481,normal,1,0,1,0,0,0 288288+ 000000002c788000,481,normal,1,0,1,0,0,0 289289+ 000000002c790000,481,normal,1,0,1,0,0,0 290290+ 000000002c758000,481,normal,1,0,1,0,0,0 291291+ 000000002c780000,481,normal,1,0,1,0,0,0 292292+ 000000002c784000,481,normal,1,0,1,0,0,0 293293+ 000000002c788000,481,normal,1,0,1,0,0,0 294294+ 000000002c78c000,481,normal,1,0,1,0,0,0 295295+ 000000002c754000,481,normal,1,0,1,0,0,0 296296+ 000000002c758000,481,normal,1,0,1,0,0,0 297297+ 000000002c780000,481,normal,1,0,1,0,0,0 298298+ 000000002c784000,481,normal,1,0,1,0,0,0 299299+ 000000002c78c000,481,normal,1,0,1,0,0,0 300300+ 000000002c790000,481,normal,1,0,1,0,0,0 301301+ 000000002c758000,481,normal,1,0,1,0,0,0 302302+ 000000002c780000,481,normal,1,0,1,0,0,0 303303+ 000000002c788000,481,normal,1,0,1,0,0,0 304304+ 000000002c790000,481,normal,1,0,1,0,0,0 305305+ 000000002c758000,481,normal,1,0,1,0,0,0 306306+ 000000002c780000,481,normal,1,0,1,0,0,0 307307+ 000000002c788000,481,normal,1,0,1,0,0,0 308308+ 000000002c790000,481,normal,1,0,1,0,0,0 309309+ 000000002c758000,481,normal,1,0,1,0,0,0 310310+ 000000002c780000,481,normal,1,0,1,0,0,0 311311+ 000000002c788000,481,normal,1,0,1,0,0,0 312312+ 000000002c790000,481,normal,1,0,1,0,0,0 313313+ 000000002c758000,481,normal,1,0,1,0,0,0 314314+ 000000002c780000,481,normal,1,0,1,0,0,0 315315+ 000000002c788000,481,normal,1,0,1,0,0,0 316316+ 000000002c790000,481,normal,1,0,1,0,0,0 317317+ 000000002c758000,481,normal,1,0,1,0,0,0 318318+ 000000002c780000,481,normal,1,0,1,0,0,0 319319+ 000000002c788000,481,normal,1,0,1,0,0,0 320320+ 000000002c790000,481,normal,1,0,1,0,0,0 321321+ 000000002c758000,481,normal,1,0,1,0,0,0 322322+ 000000002c780000,481,normal,1,0,1,0,0,0 323323+ 000000002c788000,481,normal,1,0,1,0,0,0 324324+ 000000002c790000,481,normal,1,0,1,0,0,0 325325+ 000000002c758000,481,normal,1,0,1,0,0,0 326326+ 000000002c780000,481,normal,1,0,1,0,0,0 327327+ 000000002c788000,481,normal,1,0,1,0,0,0 328328+ 000000002c790000,481,normal,1,0,1,0,0,0 329329+ 000000002c758000,481,normal,1,0,1,0,0,0 330330+ 000000002c780000,481,normal,1,0,1,0,0,0 331331+ 000000002c78c000,481,normal,1,0,1,0,0,0 332332+ 000000002c784000,481,normal,1,0,1,0,0,0 333333+ 000000002c788000,481,normal,1,0,1,0,0,0 334334+ 000000002c78c000,481,normal,1,0,1,0,0,0 335335+ 000000002c754000,481,normal,1,0,1,0,0,0 336336+ 000000002c758000,481,normal,1,0,1,0,0,0 337337+ 000000002c780000,481,normal,1,0,1,0,0,0 338338+ 000000002c788000,481,normal,1,0,1,0,0,0 339339+ 000000002c790000,481,normal,1,0,1,0,0,0 340340+ 000000002c758000,481,normal,1,0,1,0,0,0 341341+ 000000002c780000,481,normal,1,0,1,0,0,0 342342+ 000000002c758000,481,normal,1,0,1,0,0,0 343343+ 000000002c780000,481,normal,1,0,1,0,0,0 344344+ 000000002c78c000,481,normal,1,0,1,0,0,0 345345+ 000000002c75c000,481,normal,1,0,1,0,0,0 346346+ 000000002c78c000,481,normal,1,0,1,0,0,0 347347+ 000000002c780000,481,normal,1,0,1,0,0,0 348348+ 000000002c754000,481,normal,1,0,1,0,0,0 349349+ 000000002c788000,481,normal,1,0,1,0,0,0 350350+ 000000002c754000,481,normal,1,0,1,0,0,0 351351+ 000000002c780000,481,normal,1,0,1,0,0,0 352352+ 000000002c788000,481,normal,1,0,1,0,0,0 353353+ 000000002c78c000,481,normal,1,0,1,0,0,0 354354+ 000000002c790000,481,normal,1,0,1,0,0,0 355355+ 000000002c754000,481,normal,1,0,1,0,0,0 356356+ 000000002c758000,481,normal,1,0,1,0,0,0 357357+ 000000002c75c000,481,normal,1,0,1,0,0,0 358358+ 000000002c780000,481,normal,1,0,1,0,0,0 359359+ 000000002c784000,481,normal,1,0,1,0,0,0 360360+ 000000002c788000,481,normal,1,0,1,0,0,0 361361+ 000000002c78c000,481,normal,1,0,1,0,0,0 362362+ 000000002c790000,481,normal,1,0,1,0,0,0 363363+ 000000002c754000,481,normal,1,0,1,0,0,0 364364+ 000000002c758000,481,normal,1,0,1,0,0,0 365365+ 000000002c75c000,512,normal,1,0,1,0,0,1 D366366+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 E 367367+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 368368+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 369369+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 370370+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 371371+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 372372+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 373373+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 374374+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 375375+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 376376+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 377377+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 378378+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 379379+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 380380+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 381381+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 382382+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 383383+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 384384+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 385385+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 386386+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 387387+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 388388+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 389389+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 390390+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 391391+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 392392+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 393393+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 394394+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 395395+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 396396+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 397397+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 398398+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 399399+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 400400+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 401401+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 402402+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 403403+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 404404+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 405405+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 406406+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 407407+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 408408+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 409409+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 410410+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 411411+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 412412+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 413413+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 414414+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 415415+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 416416+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 417417+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 418418+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 419419+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 420420+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 421421+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 422422+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 423423+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 424424+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 425425+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 426426+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 427427+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 428428+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 429429+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 430430+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 431431+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 432432+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 433433+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 434434+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 435435+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 436436+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 437437+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 438438+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 439439+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 440440+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 441441+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 442442+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 443443+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 444444+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 445445+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 446446+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 447447+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 448448+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 449449+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 450450+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 451451+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 452452+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 453453+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 454454+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 455455+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 456456+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 457457+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 458458+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 459459+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 460460+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 461461+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 462462+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 463463+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 464464+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 465465+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 466466+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 467467+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 468468+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 469469+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 470470+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 471471+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 472472+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 473473+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 474474+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 475475+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 476476+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 477477+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 478478+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 479479+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 480480+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 481481+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 482482+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 483483+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 484484+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 485485+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 486486+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 487487+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 488488+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 489489+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 490490+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 491491+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 492492+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 493493+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 494494+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 495495+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 496496+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 497497+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 498498+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 499499+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 500500+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 501501+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 502502+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 503503+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 504504+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 505505+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 506506+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 507507+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 508508+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 509509+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 510510+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 511511+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 512512+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 513513+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 514514+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 515515+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 516516+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 517517+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 518518+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 519519+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 520520+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 521521+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 522522+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 523523+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 524524+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 525525+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 526526+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 527527+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 528528+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 529529+ 0000000000000000,0,UNKNOWN,0,0,0,0,0,0 530530+ 00000000381ab000,0,link,0,0,0,0,0,1531531+532532+533533+Trace Events534534+-------------535535+536536+DWC3 also provides several trace events which help us gathering537537+information about the behavior of the driver during runtime.538538+539539+In order to use these events, you must enable ``CONFIG_FTRACE`` in540540+your kernel config.541541+542542+For details about how enable DWC3 events, see section **Reporting543543+Bugs**.544544+545545+The following subsections will give details about each Event Class and546546+each Event defined by DWC3.547547+548548+MMIO549549+```````550550+551551+It is sometimes useful to look at every MMIO access when looking for552552+bugs. Because of that, DWC3 offers two Trace Events (one for553553+dwc3_readl() and one for dwc3_writel()). ``TP_printk`` follows::554554+555555+ TP_printk("addr %p value %08x", __entry->base + __entry->offset,556556+ __entry->value)557557+558558+Interrupt Events559559+````````````````560560+561561+Every IRQ event can be logged and decoded into a human readable562562+string. Because every event will be different, we don't give an563563+example other than the ``TP_printk`` format used::564564+565565+ TP_printk("event (%08x): %s", __entry->event,566566+ dwc3_decode_event(__entry->event, __entry->ep0state))567567+568568+Control Request569569+`````````````````570570+571571+Every USB Control Request can be logged to the trace buffer. The572572+output format is::573573+574574+ TP_printk("%s", dwc3_decode_ctrl(__entry->bRequestType,575575+ __entry->bRequest, __entry->wValue,576576+ __entry->wIndex, __entry->wLength)577577+ )578578+579579+Note that Standard Control Requests will be decoded into580580+human-readable strings with their respective arguments. Class and581581+Vendor requests will be printed out a sequence of 8 bytes in hex582582+format.583583+584584+Lifetime of a ``struct usb_request``585585+```````````````````````````````````````586586+587587+The entire lifetime of a ``struct usb_request`` can be tracked on the588588+trace buffer. We have one event for each of allocation, free,589589+queueing, dequeueing, and giveback. Output format is::590590+591591+ TP_printk("%s: req %p length %u/%u %s%s%s ==> %d",592592+ __get_str(name), __entry->req, __entry->actual, __entry->length,593593+ __entry->zero ? "Z" : "z",594594+ __entry->short_not_ok ? "S" : "s",595595+ __entry->no_interrupt ? "i" : "I",596596+ __entry->status597597+ )598598+599599+Generic Commands600600+````````````````````601601+602602+We can log and decode every Generic Command with its completion603603+code. Format is::604604+605605+ TP_printk("cmd '%s' [%x] param %08x --> status: %s",606606+ dwc3_gadget_generic_cmd_string(__entry->cmd),607607+ __entry->cmd, __entry->param,608608+ dwc3_gadget_generic_cmd_status_string(__entry->status)609609+ )610610+611611+Endpoint Commands612612+````````````````````613613+614614+Endpoints commands can also be logged together with completion615615+code. Format is::616616+617617+ TP_printk("%s: cmd '%s' [%d] params %08x %08x %08x --> status: %s",618618+ __get_str(name), dwc3_gadget_ep_cmd_string(__entry->cmd),619619+ __entry->cmd, __entry->param0,620620+ __entry->param1, __entry->param2,621621+ dwc3_ep_cmd_status_string(__entry->cmd_status)622622+ )623623+624624+Lifetime of a ``TRB``625625+``````````````````````626626+627627+A ``TRB`` Lifetime is simple. We are either preparing a ``TRB`` or628628+completing it. With these two events, we can see how a ``TRB`` changes629629+over time. Format is::630630+631631+ TP_printk("%s: %d/%d trb %p buf %08x%08x size %s%d ctrl %08x (%c%c%c%c:%c%c:%s)",632632+ __get_str(name), __entry->queued, __entry->allocated,633633+ __entry->trb, __entry->bph, __entry->bpl,634634+ ({char *s;635635+ int pcm = ((__entry->size >> 24) & 3) + 1;636636+ switch (__entry->type) {637637+ case USB_ENDPOINT_XFER_INT:638638+ case USB_ENDPOINT_XFER_ISOC:639639+ switch (pcm) {640640+ case 1:641641+ s = "1x ";642642+ break;643643+ case 2:644644+ s = "2x ";645645+ break;646646+ case 3:647647+ s = "3x ";648648+ break;649649+ }650650+ default:651651+ s = "";652652+ } s; }),653653+ DWC3_TRB_SIZE_LENGTH(__entry->size), __entry->ctrl,654654+ __entry->ctrl & DWC3_TRB_CTRL_HWO ? 'H' : 'h',655655+ __entry->ctrl & DWC3_TRB_CTRL_LST ? 'L' : 'l',656656+ __entry->ctrl & DWC3_TRB_CTRL_CHN ? 'C' : 'c',657657+ __entry->ctrl & DWC3_TRB_CTRL_CSP ? 'S' : 's',658658+ __entry->ctrl & DWC3_TRB_CTRL_ISP_IMI ? 'S' : 's',659659+ __entry->ctrl & DWC3_TRB_CTRL_IOC ? 'C' : 'c',660660+ dwc3_trb_type_string(DWC3_TRBCTL_TYPE(__entry->ctrl))661661+ ) 662662+663663+Lifetime of an Endpoint664664+```````````````````````665665+666666+And endpoint's lifetime is summarized with enable and disable667667+operations, both of which can be traced. Format is::668668+669669+ TP_printk("%s: mps %d/%d streams %d burst %d ring %d/%d flags %c:%c%c%c%c%c:%c:%c",670670+ __get_str(name), __entry->maxpacket,671671+ __entry->maxpacket_limit, __entry->max_streams,672672+ __entry->maxburst, __entry->trb_enqueue,673673+ __entry->trb_dequeue,674674+ __entry->flags & DWC3_EP_ENABLED ? 'E' : 'e',675675+ __entry->flags & DWC3_EP_STALL ? 'S' : 's',676676+ __entry->flags & DWC3_EP_WEDGE ? 'W' : 'w',677677+ __entry->flags & DWC3_EP_BUSY ? 'B' : 'b',678678+ __entry->flags & DWC3_EP_PENDING_REQUEST ? 'P' : 'p',679679+ __entry->flags & DWC3_EP_MISSED_ISOC ? 'M' : 'm',680680+ __entry->flags & DWC3_EP_END_TRANSFER_PENDING ? 'E' : 'e',681681+ __entry->direction ? '<' : '>'682682+ )683683+684684+685685+Structures, Methods and Definitions686686+====================================687687+688688+.. kernel-doc:: drivers/usb/dwc3/core.h689689+ :doc: main data structures690690+ :internal:691691+692692+.. kernel-doc:: drivers/usb/dwc3/gadget.h693693+ :doc: gadget-only helpers694694+ :internal:695695+696696+.. kernel-doc:: drivers/usb/dwc3/gadget.c697697+ :doc: gadget-side implementation698698+ :internal:699699+700700+.. kernel-doc:: drivers/usb/dwc3/core.c701701+ :doc: core driver (probe, PM, etc)702702+ :internal:703703+704704+.. [#trb] Transfer Request Block705705+.. [#link_trb] Transfer Request Block pointing to another Transfer706706+ Request Block.707707+.. [#debugfs] The Debug File System708708+.. [#configfs] The Config File System709709+.. [#cbw] Command Block Wrapper710710+.. _Linus' tree: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/711711+.. _me: felipe.balbi@linux.intel.com712712+.. _linux-usb: linux-usb@vger.kernel.org
+1
Documentation/driver-api/usb/index.rst
···1616 persist1717 error-codes1818 writing_usb_driver1919+ dwc31920 writing_musb_glue_layer20212122.. only:: subproject and html