1. 19 6月, 2014 9 次提交
    • A
      usb: gadget: OS descriptors configfs cleanup · fe00b138
      Andrzej Pietrasiewicz 提交于
      A number of variables serve a generic purpose of handling
      "compatible id" and "subcompatible id", but the names suggest they
      are for rndis only. Rename to reflect variables' purpose.
      Signed-off-by: NAndrzej Pietrasiewicz <andrzej.p@samsung.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      fe00b138
    • 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
    • L
      usb: musb: ux500: don't propagate the OF node · 82363cf2
      Linus Walleij 提交于
      There is a regression in the upcoming v3.16-rc1, that is caused
      by a problem that has been around for a while but now finally
      hangs the system. The bootcrawl looks like this:
      
      pinctrl-nomadik soc:pinctrl: pin GPIO256_AF28 already
      requested by a03e0000.usb_per5; cannot claim for musb-hdrc.0.auto
      pinctrl-nomadik soc:pinctrl: pin-256 (musb-hdrc.0.auto) status -22
      pinctrl-nomadik soc:pinctrl: could not request pin 256
      (GPIO256_AF28) from group usb_a_1  on device pinctrl-nomadik
      musb-hdrc musb-hdrc.0.auto: Error applying setting, reverse
      things back
      HS USB OTG: no transceiver configured
      musb-hdrc musb-hdrc.0.auto: musb_init_controller failed
      with status -517
      platform musb-hdrc.0.auto: Driver musb-hdrc requests
      probe deferral
      (...)
      
      The ux500 MUSB driver propagates the OF node to the dynamically
      created musb-hdrc device, which is incorrect as it makes the OF
      core believe there are two devices spun from the very same
      DT node, which confuses other parts of the device core, notably
      the pin control subsystem, which will try to apply all the pin
      control settings also to the HDRC device as it gets
      instantiated. (The OMAP2430 for example, does not set the
      of_node member.)
      
      Cc: <stable@vger.kernel.org>
      Cc: Arnd Bergmann <arnd@arndb.de>
      Acked-by: NLee Jones <lee.jones@linaro.org>
      Signed-off-by: NLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      82363cf2
    • K
      usb: renesas: gadget: fixup: complete STATUS stage after receiving · 3fe15505
      Kuninori Morimoto 提交于
      Current usbhs gadget driver didn't complete STATUS stage after receiving.
      It wasn't problem for us before, because some USB class doesn't use
      DATA OUT stage in control transfer.
      But, it is required on some device.
      Signed-off-by: NYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Signed-off-by: NKuninori Morimoto <kuninori.morimoto.gx@renesas.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      3fe15505
    • J
      usb: gadget: u_ether: synchronize with transmit when stopping queue · a9232076
      Jeff Westfahl 提交于
      When disconnecting, it's possible that another thread has already made it
      into eth_start_xmit before we call netif_stop_queue. This can lead to a
      crash as eth_start_xmit tries to use resources that gether_disconnect is
      freeing. Use netif_tx_lock/unlock around netif_stop_queue to ensure no
      threads are executing during the remainder of gether_disconnect.
      Signed-off-by: NJeff Westfahl <jeff.westfahl@ni.com>
      Tested-by: NJaeden Amero <jaeden.amero@ni.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      a9232076
    • G
      usb: dwc3: dwc3-omap: Disable/Enable only wrapper interrupts in prepare/complete · 02dae36a
      George Cherian 提交于
      The dwc3 wrapper driver should not be fiddling with the core interrupts.
      Disabling the core interrupts in prepare stops xhci from proper operation.
      So remove disable/enable of core interrupts from prepare/complete.
      Signed-off-by: NGeorge Cherian <george.cherian@ti.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      02dae36a
    • G
      usb: dwc3: dwc3-omap: Fix the crash on module removal · c5a1fbca
      George Cherian 提交于
      Following crash is seen on dwc3_omap removal
      Unable to handle kernel NULL pointer dereference at virtual address 00000018
      pgd = ec098000
      [00000018] *pgd=ad1f9831, *pte=00000000, *ppte=00000000
      Internal error: Oops: 17 [#1] SMP ARM
      Modules linked in: usb_f_ss_lb g_zero usb_f_acm u_serial usb_f_ecm u_ether libcomposite configfs snd_usb_audio snd_usbmidi_lib snd_rawmidi snd_hwdep snd_soc_omap snd_pcm_dmaengine snd_soc_core snd_compress snd_pcm snd_tim]
      CPU: 0 PID: 1296 Comm: rmmod Tainted: G        W     3.15.0-rc4-02716-g95c4e18-dirty #10
      task: ed05a080 ti: ec368000 task.ti: ec368000
      PC is at release_resource+0x14/0x7c
      LR is at release_resource+0x10/0x7c
      pc : [<c0044724>]    lr : [<c0044720>]    psr: 60000013
      sp : ec369ec0  ip : 60000013  fp : 00021008
      r10: 00000000  r9 : ec368000  r8 : c000e7a4
      r7 : 00000081  r6 : bf0062c0  r5 : ed7cd000  r4 : ed7d85c0
      r3 : 00000000  r2 : 00000000  r1 : 00000011  r0 : c086d08c
      Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment user
      Control: 10c5387d  Table: ac098059  DAC: 00000015
      Process rmmod (pid: 1296, stack limit = 0xec368248)
      Stack: (0xec369ec0 to 0xec36a000)
      9ec0: 00000000 00000001 ed7cd000 c034de94 ed7cd010 ed7cd000 00000000 c034e194
      9ee0: 00000000 bf0062cc ed7cd010 c03490b0 ed154cc0 ed4c2570 ed2b8410 ed156810
      ed156810 bf006d24 c034db9c c034db84 c034c518
      9f20: bf006d24 ed156810 bf006d24 c034cd2c bf006d24 bf006d68 00000800 c034c340
      9f40: 00000000 c00a9e5c 00000020 00000000 bf006d68 00000800 ec369f4c 33637764
      9f60: 616d6f5f 00000070 00000001 ec368000 ed05a080 c000e670 00000001 c0084010
      9f80: 00021088 00000800 00021088 00000081 80000010 0000e6f4 00021088 00000800
      9fa0: 00021088 c000e5e0 00021088 00000800 000210b8 00000800 e04f6d00 e04f6d00
      9fc0: 00021088 00000800 00021088 00000081 00000001 00000000 be91de08 00021008
      9fe0: 4d768880 be91dbb4 b6fc5984 4d76888c 80000010 000210b8 00000000 00000000
      [<c0044724>] (release_resource) from [<c034de94>] (platform_device_del+0x6c/0x9c)
      [<c034de94>] (platform_device_del) from [<c034e194>] (platform_device_unregister+0xc/0x18)
      [<c034e194>] (platform_device_unregister) from [<bf0062cc>] (dwc3_omap_remove_core+0xc/0x14 [dwc3_omap])
      [<bf0062cc>] (dwc3_omap_remove_core [dwc3_omap]) from [<c03490b0>] (device_for_each_child+0x34/0x74)
      [<c03490b0>] (device_for_each_child) from [<bf0062b4>] (dwc3_omap_remove+0x6c/0x78 [dwc3_omap])
      [<bf0062b4>] (dwc3_omap_remove [dwc3_omap]) from [<c034db9c>] (platform_drv_remove+0x18/0x1c)
      [<c034db9c>] (platform_drv_remove) from [<c034c518>] (__device_release_driver+0x70/0xc8)
      [<c034c518>] (__device_release_driver) from [<c034cd2c>] (driver_detach+0xb4/0xb8)
      [<c034cd2c>] (driver_detach) from [<c034c340>] (bus_remove_driver+0x4c/0x90)
      [<c034c340>] (bus_remove_driver) from [<c00a9e5c>] (SyS_delete_module+0x10c/0x198)
      [<c00a9e5c>] (SyS_delete_module) from [<c000e5e0>] (ret_fast_syscall+0x0/0x48)
      Code: e1a04000 e59f0068 eb14505e e5943010 (e5932018)
      ---[ end trace 7e2a8746ff4fc811 ]---
      Segmentation fault
      
      [ balbi@ti.com : add CONFIG_OF dependency ]
      Signed-off-by: NGeorge Cherian <george.cherian@ti.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      c5a1fbca
    • D
      usb: gadget: f_rndis: fix an error code on allocation failure · 4683ae86
      Dan Carpenter 提交于
      This should be return -ENOMEM.  The current code returns successs.
      
      Fixes: de7a8d2d ('usb: gadget: f_rndis: OS descriptors support')
      Acked-by: NAndrzej Pietrasiewicz <andrzej.p@samsung.com>
      Signed-off-by: NDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      4683ae86
    • Z
      usb: dwc3: gadget: check link trb after free_slot is increased · 5cd8c48d
      Zhuang Jin Can 提交于
      In ISOC transfers, when free_slot points to the last TRB (i.e. Link
      TRB), and all queued requests meet Missed Interval Isoc error, busy_slot
      points to trb0.
      	busy_slot->trb0
      		   trb1
      		   ...
      	free_slot->trb31(Link TRB)
      
      After end transfer and receiving the XferNotReady event, trb_left is
      caculated as 1 which is wrong, and no TRB will be primed to the
      endpoint.
      
      The root cause is free_slot is not increased the same way as busy_slot.
      When busy_slot is increased by one, it checks if points to a link TRB
      after increasement, but free_slot checks it before increasement.
      free_slot should behave the same as busy_slot to make the trb_left
      caculation correct.
      Reviewed-by: NPratyush Anand <pratyush.anand@st.com>
      Signed-off-by: NZhuang Jin Can <jin.can.zhuang@intel.com>
      Signed-off-by: NJiebing Li <jiebing.li@intel.com>
      Signed-off-by: NFelipe Balbi <balbi@ti.com>
      5cd8c48d
  2. 03 6月, 2014 1 次提交
  3. 30 5月, 2014 4 次提交
  4. 29 5月, 2014 7 次提交
  5. 28 5月, 2014 19 次提交
    • D
      usb: resume child device when port is powered on · 7027df36
      Dan Williams 提交于
      Unconditionally wake up the child device when the power session is
      recovered.
      
      This addresses the following scenarios:
      
      1/ The device may need a reset on power-session loss, without this
         change port power-on recovery exposes khubd to scenarios that
         usb_port_resume() is set to handle.  Prior to port power control the
         only time a power session would be lost is during dpm_suspend of the
         hub.  In that scenario usb_port_resume() is guaranteed to be called
         prior to khubd running for that port.  With this change we wakeup the
         child device as soon as possible (prior to khubd running again for this
         port).
      
         Although khubd has facilities to wake a child device it will only do
         so if the portstatus / portchange indicates a suspend state.  In the
         case of port power control we are not coming from a hub-port-suspend
         state.  This implementation simply uses pm_request_resume() to wake the
         device and relies on the port_dev->status_lock to prevent any collisions
         between khubd and usb_port_resume().
      
      2/ This mechanism rate limits port power toggling.  The minimum port
         power on/off period is now gated by the child device suspend/resume
         latency.  Empirically this mitigates devices downgrading their connection
         on perceived instability of the host connection.  This ratelimiting is
         really only relevant to port power control testing, but it is a nice
         side effect of closing the above race.  Namely, the race of khubd for
         the given port running while a usb_port_resume() event is pending.
      
      3/ Going forward we are finding that power-session recovery requires
         warm-resets (http://marc.info/?t=138659232900003&r=1&w=2).  This
         mechanism allows for warm-resets to be requested at the same point in
         the resume path for hub dpm_suspend power session losses, or port
         rpm_suspend power session losses.
      
      4/ If the device *was* disconnected the only time we'll know for sure is
         after a failed resume, so it's necessary for usb_port_runtime_resume()
         to expedite a usb_port_resume() to clean up the removed device.  The
         reasoning for this is "least surprise" for the user. Turning on a port
         means that hotplug detection is again enabled for the port, it is
         surprising that devices that were removed while the port was off are not
         disconnected until they are attempted to be used.  As a user "why would
         I try to use a device I removed from the system?"
      
      1, 2, and 4 are not a problem in the system dpm_resume() case because,
      although the power-session is lost, khubd is frozen until after device
      resume.  For the rpm_resume() case pm_request_resume() is used to
      request re-validation of the device, and if it happens to collide with a
      khubd run we rely on the port_dev->status_lock to synchronize those
      operations.
      
      Besides testing, the primary scenario where this mechanism is expected
      to be triggered is when the user changes the port power policy
      (control/pm_qos_no_poweroff, or power/control).   Each time power is
      enabled want to revalidate the child device, where the revalidation is
      handled by usb_port_resume().
      
      Given that this arranges for port_dev->child to be de-referenced in
      usb_port_runtime_resume() we need to make sure not to collide with
      usb_disconnect() that frees the usb_device.  To this end we hold the
      port active with the "child_usage" reference across the disconnect
      event.  Subsequently, the need to access hub->child_usage_bits lead to
      the creation of hub_disconnect_children() to remove any ambiguity of
      which "hub" is being acted on in usb_disconnect() (prompted-by sharp
      eyes from Alan).
      
      Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7027df36
    • D
      usb: hub_handle_remote_wakeup() depends on CONFIG_PM_RUNTIME=y · 7e73be22
      Dan Williams 提交于
      Per Alan:
      "You mean from within hub_handle_remote_wakeup()?  That routine will
      never get called if CONFIG_PM_RUNTIME isn't enabled, because khubd
      never sees wakeup requests if they arise during system suspend.
      
      In fact, that routine ought to go inside the "#ifdef CONFIG_PM_RUNTIME"
      portion of hub.c, along with the other suspend/resume code."
      Suggested-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7e73be22
    • D
      usb: introduce port status lock · 5c79a1e3
      Dan Williams 提交于
      In general we do not want khubd to act on port status changes that are
      the result of in progress resets or USB runtime PM operations.
      Specifically port power control testing has been able to trigger an
      unintended disconnect in hub_port_connect_change(), paraphrasing:
      
      	if ((portstatus & USB_PORT_STAT_CONNECTION) && udev &&
      	    udev->state != USB_STATE_NOTATTACHED) {
      		if (portstatus & USB_PORT_STAT_ENABLE) {
      			/* Nothing to do */
      		} else if (udev->state == USB_STATE_SUSPENDED &&
      				udev->persist_enabled) {
      			...
      		} else {
      			/* Don't resuscitate */;
      		}
      	}
      
      ...by falling to the "Don't resuscitate" path or missing
      USB_PORT_STAT_CONNECTION because usb_port_resume() was in the middle of
      modifying the port status.
      
      So, we want a new lock to hold off khubd for a given port while the
      child device is being suspended, resumed, or reset.  The lock ordering
      rules are now usb_lock_device() => usb_lock_port().  This is mandated by
      the device core which may hold the device_lock on the usb_device before
      invoking usb_port_{suspend|resume} which in turn take the status_lock on
      the usb_port.  We attempt to hold the status_lock for the duration of a
      port_event() run, and drop/re-acquire it when needing to take the
      device_lock.  The lock is also dropped/re-acquired during
      hub_port_reconnect().
      
      This patch also deletes hub->busy_bits as all use cases are now covered
      by port PM runtime synchronization or the port->status_lock and it
      pushes down usb_device_lock() into usb_remote_wakeup().
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      5c79a1e3
    • D
      usb: synchronize port poweroff and khubd · 097a155f
      Dan Williams 提交于
      If a port is powered-off, or in the process of being powered-off, prevent
      khubd from operating on it.  Otherwise, the following sequence of events
      leading to an unintended disconnect may occur:
      
      Events:
      (0) <set pm_qos_no_poweroff to '0' for port1>
      (1) hub 2-2:1.0: hub_resume
      (2) hub 2-2:1.0: port 1: status 0301 change 0000
      (3) hub 2-2:1.0: state 7 ports 4 chg 0002 evt 0000
      (4) hub 2-2:1.0: port 1, power off status 0000, change 0000, 12 Mb/s
      (5) usb 2-2.1: USB disconnect, device number 5
      
      Description:
      (1) hub is resumed before sending a ClearPortFeature request
      (2) hub_activate() notices the port is connected and sets
          hub->change_bits for the port
      (3) hub_events() starts, but at the same time the port suspends
      (4) hub_connect_change() sees the disabled port and triggers disconnect
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      097a155f
    • D
      usb: refactor port handling in hub_events() · af376a46
      Dan Williams 提交于
      In preparation for synchronizing port handling with pm_runtime
      transitions refactor port handling into its own subroutine.
      
      We expect that clearing some status flags will be required regardless of
      the port state, so handle those first and group all non-trivial actions
      at the bottom of the routine.
      
      This also splits off the bottom half of hub_port_connect_change() into
      hub_port_reconnect() in prepartion for introducing a port->status_lock.
      hub_port_reconnect() will expect the port lock to not be held while
      hub_port_connect_change() expects to enter with it held.
      
      Other cleanups include:
      1/ reflowing to 80 columns
      2/ replacing redundant usages of 'hub->hdev' with 'hdev'
      3/ consolidate clearing of ->change_bits() in hub_port_connect_change
      4/ consolidate calls to usb_reset_device
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      af376a46
    • D
      usb: usb3 ports do not support FEAT_C_ENABLE · 69080584
      Dan Williams 提交于
      The port pm_runtime implementation unconditionally clears FEAT_C_ENABLE
      after clearing PORT_POWER, but the bit is reserved on usb3 hub ports.
      We expect khubd to be prevented from running because the port state is
      not RPM_ACTIVE, so we need to clear any errors for usb2 ports.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      69080584
    • D
      usb: don't clear FEAT_C_ENABLE on usb_port_runtime_resume failure · 7c604079
      Dan Williams 提交于
      Three reasons:
      1/ It's an invalid operation on usb3 ports
      2/ There's no guarantee of when / if a usb2 port has entered an error
         state relative to PORT_POWER request
      3/ The port is active / powered at this point, so khubd will clear it as
         a matter of course
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7c604079
    • D
      usb: block suspension of superspeed port while hispeed peer is active · 7ad3c470
      Dan Williams 提交于
      ClearPortFeature(PORT_POWER) on a usb3 port places the port in either a
      DSPORT.Powered-off-detect / DSPORT.Powered-off-reset loop, or the
      DSPORT.Powered-off state.  There is no way to ensure that RX
      terminations will persist in this state, so it is possible a device will
      degrade to its usb2 connection.  Prevent this by blocking power-off of a
      usb3 port while its usb2 peer is active, and powering on a usb3 port
      before its usb2 peer.
      
      By default the latency between peer power-on events is 0.  In order for
      the device to not see usb2 active while usb3 is still powering up inject
      the hub recommended power_on_good delay.  In support of satisfying the
      power_on_good delay outside of hub_power_on() refactor the places where
      the delay is consumed to call a new hub_power_on_good_delay() helper.
      
      Finally, because this introduces several new checks for whether a port
      is_superspeed, cache that disctinction at port creation so that we don't
      need to keep looking up the parent hub device.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      [alan]: add a 'superspeed' flag to the port
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      7ad3c470
    • D
      usb: make usb_port flags atomic, rename did_runtime_put to child_usage · d5c3834e
      Dan Williams 提交于
      We want to manipulate ->did_runtime_put in usb_port_runtime_resume(),
      but we don't want that to collide with other updates.  Move usb_port
      flags to new port-bitmap fields in usb_hub. "did_runtime_put" is renamed
      "child_usage_bits" to reflect that it is strictly standing in for the
      fact that usb_devices are not the device_model children of their parent
      port.
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d5c3834e
    • D
      usb: sysfs link peer ports · b7e38eac
      Dan Williams 提交于
      The usb topology after this change will have symlinks between usb3 ports
      and their usb2 peers, for example:
      
      usb2/2-1/2-1:1.0/2-1-port1/peer => ../../../../usb3/3-1/3-1:1.0/3-1-port1
      usb2/2-1/2-1:1.0/2-1-port2/peer => ../../../../usb3/3-1/3-1:1.0/3-1-port2
      usb2/2-1/2-1:1.0/2-1-port3/peer => ../../../../usb3/3-1/3-1:1.0/3-1-port3
      usb2/2-1/2-1:1.0/2-1-port4/peer => ../../../../usb3/3-1/3-1:1.0/3-1-port4
      usb2/2-0:1.0/usb2-port1/peer    => ../../../usb3/3-0:1.0/usb3-port1
      usb2/2-0:1.0/usb2-port2/peer    => ../../../usb3/3-0:1.0/usb3-port2
      usb2/2-0:1.0/usb2-port3/peer    => ../../../usb3/3-0:1.0/usb3-port3
      usb2/2-0:1.0/usb2-port4/peer    => ../../../usb3/3-0:1.0/usb3-port4
      
      usb3/3-1/3-1:1.0/usb3-1-port1/peer => ../../../../usb2/2-1/2-1:1.0/2-1-port1
      usb3/3-1/3-1:1.0/usb3-1-port2/peer => ../../../../usb2/2-1/2-1:1.0/2-1-port2
      usb3/3-1/3-1:1.0/usb3-1-port3/peer => ../../../../usb2/2-1/2-1:1.0/2-1-port3
      usb3/3-1/3-1:1.0/usb3-1-port4/peer => ../../../../usb2/2-1/2-1:1.0/2-1-port4
      usb3/3-0:1.0/usb3-port1/peer       => ../../../usb2/2-0:1.0/usb2-port1
      usb3/3-0:1.0/usb3-port2/peer       => ../../../usb2/2-0:1.0/usb2-port2
      usb3/3-0:1.0/usb3-port3/peer       => ../../../usb2/2-0:1.0/usb2-port3
      usb3/3-0:1.0/usb3-port4/peer       => ../../../usb2/2-0:1.0/usb2-port4
      
      Introduce link_peers_report() to notify on all link_peers() failure
      cases.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      b7e38eac
    • D
      usb: find internal hub tier mismatch via acpi · 3bfd659b
      Dan Williams 提交于
      ACPI identifies peer ports by setting their 'group_token' and
      'group_position' _PLD data to the same value.  If a platform has tier
      mismatch [1] , ACPI can override the default (USB3 defined) peer port
      association for internal hubs.  External hubs follow the default peer
      association scheme.
      
      Location data is cached as an opaque cookie in usb_port_location data.
      
      Note that we only consider the group_token and group_position attributes
      from the _PLD data as ACPI specifies that group_token is a unique
      identifier.
      
      When we find port location data for a port then we assume that the
      firmware will also describe its peer port.  This allows the
      implementation to only ever set the peer once.  This leads to a question
      about what happens when a pm runtime event occurs while the peer
      associations are still resolving.  Since we only ever set the peer
      information once, a USB3 port needs to be prevented from suspending
      while its ->peer pointer is NULL (implemented in a subsequent patch).
      
      There is always the possibility that firmware mis-identifies the ports,
      but there is not much the kernel can do in that case.
      
      [1]: xhci 1.1 appendix D figure 131
      [2]: acpi 5 section 6.1.8
      
      [alan]: don't do default peering when acpi data present
      Suggested-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      3bfd659b
    • D
      usb: assign usb3 external hub port peers · 8b1ba80c
      Dan Williams 提交于
      Given that root hub port peers are already established, external hub peer
      ports can be determined by traversing the device topology:
      
      1/ ascend to the parent hub and find the upstream port_dev
      
      2/ walk ->peer to find the peer port
      
      3/ descend to the peer hub via ->child
      
      4/ find the port with the matching port id
      
      Note that this assumes the port labeling scheme required by the
      specification [1].
      
      [1]: usb3 3.1 section 10.3.3
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      8b1ba80c
    • D
      usb: assign default peer ports for root hubs · d8521afe
      Dan Williams 提交于
      Assume that the peer of a superspeed port is the port with the same id
      on the shared_hcd root hub.  This identification scheme is required of
      external hubs by the USB3 spec [1].  However, for root hubs, tier mismatch
      may be in effect [2].  Tier mismatch can only be enumerated via platform
      firmware.  For now, simply perform the nominal association.
      
      A new lock 'usb_port_peer_mutex' is introduced to synchronize port
      device add/remove with peer lookups.  It protects peering against
      changes to hcd->shared_hcd, hcd->self.root_hub, hdev->maxchild, and
      port_dev->child pointers.
      
      [1]: usb 3.1 section 10.3.3
      [2]: xhci 1.1 appendix D
      
      Cc: Alan Stern <stern@rowland.harvard.edu>
      [alan: usb_port_peer_mutex locking scheme]
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d8521afe
    • D
      usb: cleanup setting udev->removable from port_dev->connect_type · a4204ff0
      Dan Williams 提交于
      Once usb-acpi has set the port's connect type the usb_device's
      ->removable attribute can be set in the standard location
      set_usb_port_removable().
      
      This also changes behavior in the case where the firmware says that the
      port connect type is unknown.  In that case just use the default setting
      determined from the hub descriptor.
      
      Note, we no longer pass udev->portnum to acpi_find_child_device() in the
      root hub case since:
      1/ the usb-core sets this to zero
      2/ acpi always expects zero
      ...just pass zero.
      Suggested-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      a4204ff0
    • D
      usb: rename usb_port device objects · d99f6b41
      Dan Williams 提交于
      The current port name "portX" is ambiguous.  Before adding more port
      messages rename ports to "<hub-device-name>-portX"
      
      This is an ABI change, but the suspicion is that it will go unnoticed as
      the port power control implementation has been broken since its
      introduction.  If however, someone was relying on the old name we can
      add sysfs links from the old name to the new name.
      
      Additionally, it unifies/simplifies port dev_printk messages and modifies
      instances of:
      	dev_XXX(hub->intfdev, ..."port %d"...
      	dev_XXX(&hdev->dev, ..."port%d"...
      into:
      	dev_XXX(&port_dev->dev, ...
      
      Now that the names are unique usb_port devices it would be nice if they
      could be included in /sys/bus/usb.  However, it turns out that this
      breaks 'lsusb -t'.  For now, create a dummy port driver so that print
      messages are prefixed "usb 1-1-port3" rather than the
      subsystem-ambiguous " 1-1-port3".
      
      Finally, it corrects an odd usage of sscanf("port%d") in usb-acpi.c.
      Suggested-by: NAlan Stern <stern@rowland.harvard.edu>
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d99f6b41
    • D
      usb: disable port power control if not supported in wHubCharacteristics · 9262c19d
      Dan Williams 提交于
      A hub indicates whether it supports per-port power control via the
      wHubCharacteristics field in its descriptor.  If it is not supported
      a hub will still emulate ClearPortPower(PORT_POWER) requests by
      stopping the link state machine.  However, since this does not save
      power do not bother suspending.
      
      This also consolidates support checks into a
      hub_is_port_power_switchable() helper.
      Acked-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      9262c19d
    • A
      USB: mutual exclusion for resetting a hub and power-managing a port · 600856c2
      Alan Stern 提交于
      The USB core doesn't properly handle mutual exclusion between
      resetting a hub and changing the power states of the hub's ports.  We
      need to avoid sending port-power requests to the hub while it is being
      reset, because such requests cannot succeed.
      
      This patch fixes the problem by keeping track of when a reset is in
      progress.  At such times, attempts to suspend (power-off) a port will
      fail immediately with -EBUSY, and calls to usb_port_runtime_resume()
      will update the power_is_on flag and return immediately.  When the
      reset is complete, hub_activate() will automatically restore each port
      to the proper power state.
      Signed-off-by: NAlan Stern <stern@rowland.harvard.edu>
      Signed-off-by: NDan Williams <dan.j.williams@intel.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      600856c2
    • K
      usb: pci_quirks: fix sparse 'symbol not declared' warning · 342a7493
      Konrad Zapalowicz 提交于
      This commit fixes the following sparse warning:
      
      drivers/usb/host/pci-quirks.c:
          - 252: warning: symbol 'usb_hcd_amd_remote_wakeup_quirk' was not
            declared. Should it be static?
      
      This function is exported so the fix was to add it's declaration to the
      header file.
      Signed-off-by: NKonrad Zapalowicz <bergo.torino@gmail.com>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      342a7493
    • P
      usb: gadget: rename CONFIG_USB_GADGET_PXA25X · d30f2065
      Paul Bolle 提交于
      Commit 193ab2a6 ("usb: gadget: allow multiple gadgets to be built")
      basically renamed the Kconfig symbol USB_GADGET_PXA25X to USB_PXA25X. It
      did not rename the related macros in use at that time. Commit
      c0a39151 ("ARM: pxa: fix inconsistent CONFIG_USB_PXA27X") did so for
      all but one macro. Rename that last macro too now.
      
      Fixes: 193ab2a6 ("usb: gadget: allow multiple gadgets to be built")
      Signed-off-by: NPaul Bolle <pebolle@tiscali.nl>
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      d30f2065