1. 18 2月, 2015 2 次提交
  2. 27 1月, 2015 2 次提交
  3. 15 1月, 2015 1 次提交
    • R
      usb: gadget: f_fs: add "no_disconnect" mode · 18d6b32f
      Robert Baldyga 提交于
      Since we can compose gadgets from many functions, there is the problem
      related to gadget breakage while FunctionFS daemon being closed. FFS
      function is userspace code so there is no way to know when it will close
      files (it doesn't matter what is the reason of this situation, it can
      be daemon logic, program breakage, process kill or any other). So when
      we have another function in gadget which, for example, sends some amount
      of data, does some software update or implements some real-time functionality,
      we may want to keep the gadget connected despite FFS function is no longer
      functional.
      
      We can't just remove one of functions from gadget since it has been
      enumerated, so the only way to keep entire gadget working is to make
      broken FFS function deactivated but still visible to host. For this
      purpose this patch introduces "no_disconnect" mode. It can be enabled
      by setting mount option "no_disconnect=1", and results with defering
      function disconnect to the moment of reopen ep0 file or filesystem
      unmount. After closing all endpoint files, FunctionFS is set to state
      FFS_DEACTIVATED.
      
      When ffs->state == FFS_DEACTIVATED:
      - function is still bound and visible to host,
      - setup requests are automatically stalled,
      - transfers on other endpoints are refused,
      - epfiles, except ep0, are deleted from the filesystem,
      - opening ep0 causes the function to be closed, and then FunctionFS
        is ready for descriptors and string write,
      - altsetting change causes the function to be closed - we want to keep
        function alive until another functions are potentialy used, altsetting
        change means that another configuration is being selected or USB cable
        was unplugged, which indicates that we don't need to stay longer in
        FFS_DEACTIVATED state
      - unmounting of the FunctionFS instance causes the function to be closed.
      Tested-by: NDavid Cohen <david.a.cohen@linux.intel.com>
      Acked-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NRobert Baldyga <r.baldyga@samsung.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      18d6b32f
  4. 13 1月, 2015 1 次提交
  5. 23 10月, 2014 2 次提交
  6. 09 10月, 2014 1 次提交
  7. 16 9月, 2014 1 次提交
    • R
      usb: gadget: f_fs: virtual endpoint address mapping · 1b0bf88f
      Robert Baldyga 提交于
      This patch introduces virtual endpoint address mapping. It separates
      function logic form physical endpoint addresses making it more hardware
      independent.
      
      Following modifications changes user space API, so to enable them user
      have to switch on the FUNCTIONFS_VIRTUAL_ADDR flag in descriptors.
      
      Endpoints are now refered using virtual endpoint addresses chosen by
      user in endpoint descpriptors. This applies to each context when endpoint
      address can be used:
      - when accessing endpoint files in FunctionFS filesystemi (in file name),
      - in setup requests directed to specific endpoint (in wIndex field),
      - in descriptors returned by FUNCTIONFS_ENDPOINT_DESC ioctl.
      
      In endpoint file names the endpoint address number is formatted as
      double-digit hexadecimal value ("ep%02x") which has few advantages -
      it is easy to parse, allows to easly recognize endpoint direction basing
      on its name (IN endpoint number starts with digit 8, and OUT with 0)
      which can be useful for debugging purpose, and it makes easier to introduce
      further features allowing to use each endpoint number in both directions
      to have more endpoints available for function if hardware supports this
      (for example we could have ep01 which is endpoint 1 with OUT direction,
      and ep81 which is endpoint 1 with IN direction).
      
      Physical endpoint address can be still obtained using ioctl named
      FUNCTIONFS_ENDPOINT_REVMAP, but now it's not neccesary to handle
      USB transactions properly.
      Signed-off-by: NRobert Baldyga <r.baldyga@samsung.com>
      Acked-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      1b0bf88f
  8. 12 9月, 2014 1 次提交
  9. 09 9月, 2014 2 次提交
  10. 03 9月, 2014 1 次提交
  11. 17 7月, 2014 1 次提交
  12. 10 7月, 2014 2 次提交
  13. 01 7月, 2014 1 次提交
  14. 19 6月, 2014 1 次提交
    • M
      usb: gadget: f_fs: fix NULL pointer dereference when there are no strings · f0688c8b
      Michal Nazarewicz 提交于
      If the descriptors do not need any strings and user space sends empty
      set of strings, the ffs->stringtabs field remains NULL.  Thus
      *ffs->stringtabs in functionfs_bind leads to a NULL pointer
      dereferenece.
      
      The bug was introduced by commit [fd7c9a00: “use usb_string_ids_n()”].
      
      While at it, remove double initialisation of lang local variable in
      that function.
      
      ffs->strings_count does not need to be checked in any way since in
      the above scenario it will remain zero and usb_string_ids_n() is
      a no-operation when colled with 0 argument.
      
      Cc: <stable@vger.kernel.org>  # v2.6.36+
      Signed-off-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      f0688c8b
  15. 14 5月, 2014 1 次提交
  16. 22 4月, 2014 1 次提交
  17. 16 4月, 2014 1 次提交
    • C
      usb: gadget: ffs: race between ffs_epfile_io() and ffs_func_eps_disable() · 97839ca4
      Chao Bi 提交于
      ffs_epfile_io() is called from userspace, while ffs_func_eps_disable() might be
      called from USB disconnect interrupt, the two functions would run in parallel
      but they are not well protected, that epfile->ep would be removed by
      ffs_func_eps_disable() during ffs_epfile_io() is referring this pointer, then
      it leads to kernel PANIC.
      
      The scenario is as below:
      
      Thread 1                                 Thread 2
         |                                        |
      SyS_read                             dwc3_gadget_disconnect_interrupt
         |                                        |
      ffs_epfile_read                         reset_config
         |                                        |
      ffs_epfile_io                       ffs_func_eps_disable
         |                                        |
       -----                      usb_ep_disable():  epfile->ep->ep->desc = NULL
         |                                        |
      usb_ep_align_maybe():                     -----
      it refers ep->desc->wMaxPacketSize        -----
      Signed-off-by: NChao Bi <chao.bi@intel.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      97839ca4
  18. 18 3月, 2014 1 次提交
  19. 08 3月, 2014 1 次提交
  20. 06 3月, 2014 2 次提交
  21. 20 2月, 2014 1 次提交
    • A
      usb: gadget: fix NULL pointer dereference · f0f42204
      Andrzej Pietrasiewicz 提交于
      Fix possible NULL pointer dereference introduced in
      commit 219580e6 (usb: f_fs: check quirk to pad epout
      buf size when not aligned to maxpacketsize)
      
      In cases we do wait with:
      
      wait_event_interruptible(epfile->wait, (ep = epfile->ep));
      
      for endpoint to be enabled, functionfs_bind() has not been called yet
      and epfile->ffs->gadget is still NULL and the automatic variable 'gadget'
      has been initialized with NULL at the point of its definition.
      Later on it is used as a parameter to:
      
      usb_ep_align_maybe(gadget, ep->ep, len)
      
      which in turn dereferences it.
      
      This patch fixes it by moving the actual assignment to the local 'gadget'
      variable after the potential waiting has completed.
      Signed-off-by: NAndrzej Pietrasiewicz <andrzej.p@samsung.com>
      Acked-by: NMichal Nazarewicz <mina86@mina86.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      f0f42204
  22. 19 2月, 2014 9 次提交
  23. 13 12月, 2013 4 次提交