aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/chipidea
Commit message (Collapse)AuthorAge
...
* usb: chipidea: refine PHY operationPeter Chen2014-04-16
| | | | | | | | | - Delete global_phy due to we can get the phy from phy layer now - using devm_usb_get_phy to instead of usb_get_phy - delete the otg_set_peripheral, which should be handled by otg layer Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* ENGR00301290-5 usb: chipidea: imx: disable dpdm change wakeup at device modePeter Chen2014-04-16
| | | | | | | | | At imx6sx, there is a new feature that we can disable dpdm change wakeup at device mode when the vbus is not there, it can avoid unexpected wakeup when the phy is no power and imx6 is disconnected from host. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00301290-3 usb: chipidea: enable usb for imx6sxPeter Chen2014-04-16
| | | | | | | | Add imx6sx compatible string, and enable bvalid as vbus wakeup source. When vbus as system wakeup source, only bvalid can be vbus wakeup source, the weak2p5 is needed to enable for vbus wakeup. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* usb: chipidea: Reallocate regmap only if lpm is detectedChris Ruehl2014-04-16
| | | | | | | | | The regmap only needs to reallocate if the hw_read on the CAP register shows lpm is used. Therefore the if() statement check the change. Signed-off-by: Chris Ruehl <chris.ruehl@gtsys.com.hk> Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: chipidea: imx: avoid unnecessary probe defer every timePeter Chen2014-04-16
| | | | | | | | The ci_hdrc_imx's probe needs usbmisc_imx to be loadded beforehand, so it is better we load usbmisc_imx first. Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: chipidea: host: Only disable the vbus regulator if it is not NULLFabio Estevam2014-04-16
| | | | | | | | | | | | | | | | Commit 40ed51a4b (usb: chipidea: host: add vbus regulator control) introduced a smatch complaint because regulator_disable() is called without checking whether ci->platdata->reg_vbus is not NULL. Fix this by adding the check. This patch is needed for 3.12 stable Cc: stable <stable@vger.kernel.org> Reported-by: Dan Carpenter <dan.carpenter@oracle.com> Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* USB: chipidea: add guard macro to ci_hdrc_imx.hRahul Bedarkar2014-04-16
| | | | | | | Add guard macro to driver/usb/chipidea/ci_hdrc_imx.h Signed-off-by: Rahul Bedarkar <rahulbedarkar89@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: chipidea: udc: using MultO at TD as real mult value for ISO-TXPeter Chen2014-04-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We have met a bug that the high bandwidth ISO-TX transfer has failed at the last packet if it is less than 1024, the TD status shows it is "Transaction Error". The root cause of this problem is: the mult value at qh is not correct for current TD's transfer length. We use TD list to queue un-transfer TDs, and change mult for new adding TDs. If new adding TDs transfer length less than 1024, but the queued un-transfer TDs transfer length is larger than 1024, the transfer error will occur, and vice versa. Usually, this problem occurs at the last packet, and the first packet for new frame. We fixed this problem by setting Mult at QH as the largest value (3), and set MultO (Multiplier Override) at TD according to every transfer length. It can cover both hardware version less than 2.3 (the real mult is MultO if it is not 0) and 2.3+ (the real mult is min(qh.mult, td.multo)). Since the MultO bits are only existed at TX TD, we keep the ISO-RX behavior unchanged. For stable tree: 3.11+. Cc: stable <stable@vger.kernel.org> Cc: Michael Grzeschik <m.grzeschik@pengutronix.de> Reported-by: Matthieu Vanin <b47495@freescale.com> Tested-by: Matthieu Vanin <b47495@freescale.com> Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: chipidea: put hw_phymode_configure before ci_usb_phy_initChris Ruehl2014-04-16
| | | | | | | | | | | hw_phymode_configure configures the PORTSC registers and allow the following phy_inits to operate on the right parameters. This fix a problem where the UPLI (ISP1504) could not be detected, because the Viewport was not available and read the viewport return 0's only. Signed-off-by: Chris Ruehl <chris.ruehl@gtsys.com.hk> Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: chipidea: Fix Internal error: : 808 [#1] ARM related to STS flagChris Ruehl2014-04-16
| | | | | | | | | | | | | | * init the sts flag to 0 (missed) * fix write the real bit not sts value * Set PORTCS_STS and DEVLC_STS only if sts = 1 [Peter Chen: This one and the next patch fix the problem occurred imx27 and imx31, and imx27 and imx31 usb support are enabled until 3.14, so these two patches isn't needed for -stable] Signed-off-by: Chris Ruehl <chris.ruehl@gtsys.com.hk> Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* ENGR00292062 usb: chipidea: need to mask INT_STATUS when write otgscPeter Chen2014-04-16
| | | | | | | | | | For otgsc, both enable bits and status bits are in it. So we need to make sure the status bits are not be cleared when write enable bits. It can fix one bug that we plug in/out Micro AB cable fast, and sometimes, the IDIS will be cleared wrongly when handle last ID interrupt (ID 0->1), so the current interrupt will not occur. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00292408-2 usb: chipidea: imx: enable different wakeup settingPeter Chen2014-04-16
| | | | | | | | | | | | We have different wakeup setting for different roles: For peripheral-only mode, we may only enable vbus wakeup. The Micro-AB cable should not be considered as wakeup source. For host-only mode, the ID change or vbus change should not be considered as wakeup source. For OTG mode, all wakeup setting should be considered as wakeup source. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00292408-1 usb: chipidea: add query_available_role interfacePeter Chen2014-04-16
| | | | | | | The glue layer may need to know current available role, add ci_hdrc_query_available_role for that. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00291282-4 usb: chipidea: imx: add HSIC supportPeter Chen2014-04-16
| | | | | | Add imx6 HSIC support Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00289855 usb: chipidea: udc: pull down dp before the charger detectionPeter Chen2014-04-16
| | | | | | | If rom code or bootloader has used usb before loading kernel, the dp may still be pulled up, it will cause USB charger detection fail. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00290297 usb: imx6-usb-charger: disable charger if it has not configuratedPeter Chen2014-04-16
| | | | | | | | | | If the user set imx6-usb-charger-detection at dts, but not enable CONFIG_IMX6_USB_CHARGER, the imx6_usb_create_charger will return -ENODEV, and the controlller probe will fail, it is not we want, what we expect is the charger detection has disabled, but controller function should not be affected. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00289645 usb: chipidea: udc: don't do hardware access if gadget has stoppedPeter Chen2014-04-16
| | | | | | | | | | | | | | | | | | | | | After _gadget_stop_activity is executed, we can consider the hardware operation for gadget has finished, and the udc can be stopped and enter low power mode. So, any later hardware operations (from usb_ep_ops APIs or usb_gadget_ops APIs) should be considered invalid, any deinitializatons has been covered at _gadget_stop_activity. I meet this problem when I plug out usb cable from PC (using g_mass_storage), my callstack like: vbus interrupt->.vbus_session->composite_disconnect ->pm_runtime_put_sync(&_gadget->dev), the composite_disconnect will call fsg_disable, but fsg_disable calls usb_ep_disable using async way, there are register accesses for usb_ep_disable. So sometimes, I get system hang due to visit register without clock, sometimes not. The Linux Kernel USB maintainer Alan Stern suggests this kinds of solution. See: http://marc.info/?l=linux-usb&m=138541769810983&w=2. Signed-off-by: Peter Chen <peter.chen@freescale.com> (cherry picked from commit ac760d29366f19eb1a4d4c37899b33019570a447)
* ENGR00288578-5 usb: chipidea: change some output messagePeter Chen2014-04-16
| | | | | | To reduce the message output when unload the module Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00288578-4 usb: chipidea: using timer to delay decreasing power.usage_countPeter Chen2014-04-16
| | | | | | | | We need to keep controller as active until the udc or host driver requests its power.usage_count, otherwise, the system will hang due to access register at low power mode. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00288578-3 usb: chipidea: only update ci->vbus_active at peripheral modePeter Chen2014-04-16
| | | | | | | | | If we connect between otg-host and host pc with Male-A-To-Male-A cable, the ci->vbus_active will be error, and cause the controller run when we load gadget module (ci_udc_start will be run), it causes the kernel panic since no one will handle irq at that mode. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00288578-1 usb: chipidea: using correct low power timingPeter Chen2014-04-16
| | | | | | | After PHY leaves low power mode, the controller needs 2ms to reflect PHY's status correctly. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00287992-6 usb: chipidea: imx: add usb charger detection for imx6Peter Chen2014-04-16
| | | | | | | | The usb controller driver creates usb charger, and notify the charger connect and disconnect using vbus connect and disconnect event. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00287992-5 usb: chipidea: msm: change the return value for msm notify_eventPeter Chen2014-04-16
| | | | | | The return value of .notify_event has changed. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00287992-4 usb: chipidea: Add usb charger detect notifyPeter Chen2014-04-16
| | | | | | | | | | | | | - Change .notify's return value from void to int. - Add CI_HDRC_CONTROLLER_CHARGER_EVENT and CI_HDRC_CONTROLLER_CHARGER_POST_EVENT to finish the USB charger detection flow. - Add usb_gadget_vbus_connect for only notify udc when vbus is on, the main reason we add it is we don't want the first notification when the vbus is off, it causes the dev->power.usage_count equals -1 when do charger detection. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286962-2 usb: chipidea: fix the system will be deadlock with ID wakeupPeter Chen2014-04-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When we plug in Micro B-TO-A cable at OTG port with u-disk connected, and enable USB ID wakeup, then, suspend the system, the system will be deadlock during the resume. See below Sysrq dump. If the flush_work at block layer is called after system resume has completed, this problem has fixed (using pm_mutex at ci_otg_work). It seems if the task is rescheduled before the system resume has completed (after thaw_processes), it will cause the system dead lock. Unless the task has been freezed explicitly before system suspend. The fixes uses wait_event_freezable to wait event, it should call try_to_freeze during the freeze_processes, and task will not be scheduled until thaw_processes has called (for frozen process, it will call wake_up_process explicitly). --------------------------------------Sysrq dump------------------------------------------ sh D 80600860 0 1016 1014 0x00000000 [<80600860>] (__schedule+0x1e0/0x5d8) from [<80601274>] (schedule_preempt_disabled+0xc/0x10) [<80601274>] (schedule_preempt_disabled+0xc/0x10) from [<805ffe00>] (__mutex_lock_slowpath+0x154/0x1f4) [<805ffe00>] (__mutex_lock_slowpath+0x154/0x1f4) from [<805ffef0>] (mutex_lock+0x50/0x54) [<805ffef0>] (mutex_lock+0x50/0x54) from [<802f7f84>] (dpm_complete+0xac/0x1ac) [<802f7f84>] (dpm_complete+0xac/0x1ac) from [<80057a34>] (suspend_devices_and_enter+0x1bc/0x330) [<80057a34>] (suspend_devices_and_enter+0x1bc/0x330) from [<80057d50>] (pm_suspend+0x1a8/0x240) [<80057d50>] (pm_suspend+0x1a8/0x240) from [<80056a8c>] (state_store+0x6c/0xbc) [<80056a8c>] (state_store+0x6c/0xbc) from [<802586c0>] (kobj_attr_store+0x14/0x20) [<802586c0>] (kobj_attr_store+0x14/0x20) from [<80117374>] (sysfs_write_file+0xfc/0x17c) [<80117374>] (sysfs_write_file+0xfc/0x17c) from [<800bdcc0>] (vfs_write+0xbc/0x184) [<800bdcc0>] (vfs_write+0xbc/0x184) from [<800be058>] (SyS_write+0x40/0x68) [<800be058>] (SyS_write+0x40/0x68) from [<8000e040>] (ret_fast_syscall+0x0/0x30) kworker/u8:2 D 80600860 0 16146 2 0x00000000 Workqueue: ci_otg ci_otg_work [<80600860>] (__schedule+0x1e0/0x5d8) from [<805ff374>] (schedule_timeout+0x14c/0x198) [<805ff374>] (schedule_timeout+0x14c/0x198) from [<80600db8>] (wait_for_common+0xc4/0x17c) [<80600db8>] (wait_for_common+0xc4/0x17c) from [<8003bbd0>] (flush_work+0xc0/0x160) [<8003bbd0>] (flush_work+0xc0/0x160) from [<8009d02c>] (bdi_unregister+0x108/0x148) [<8009d02c>] (bdi_unregister+0x108/0x148) from [<8024b5b4>] (del_gendisk+0xf8/0x1c4) [<8024b5b4>] (del_gendisk+0xf8/0x1c4) from [<8031e8e8>] (sd_remove+0x64/0x98) [<8031e8e8>] (sd_remove+0x64/0x98) from [<802f0678>] (__device_release_driver+0x70/0xcc) [<802f0678>] (__device_release_driver+0x70/0xcc) from [<802f06f0>] (device_release_driver+0x1c/0x28) [<802f06f0>] (device_release_driver+0x1c/0x28) from [<802f01e4>] (bus_remove_device+0xd8/0xf8) [<802f01e4>] (bus_remove_device+0xd8/0xf8) from [<802edef8>] (device_del+0xf4/0x178) [<802edef8>] (device_del+0xf4/0x178) from [<8031abbc>] (__scsi_remove_device+0x48/0xa0) [<8031abbc>] (__scsi_remove_device+0x48/0xa0) from [<80319bb8>] (scsi_forget_host+0x5c/0x60) [<80319bb8>] (scsi_forget_host+0x5c/0x60) from [<8031072c>] (scsi_remove_host+0x64/0xf0) [<8031072c>] (scsi_remove_host+0x64/0xf0) from [<803be150>] (usb_stor_disconnect+0x50/0xc8) [<803be150>] (usb_stor_disconnect+0x50/0xc8) from [<803ac020>] (usb_unbind_interface+0x58/0x188) [<803ac020>] (usb_unbind_interface+0x58/0x188) from [<802f0678>] (__device_release_driver+0x70/0xcc) [<802f0678>] (__device_release_driver+0x70/0xcc) from [<802f06f0>] (device_release_driver+0x1c/0x28) [<802f06f0>] (device_release_driver+0x1c/0x28) from [<802f01e4>] (bus_remove_device+0xd8/0xf8) [<802f01e4>] (bus_remove_device+0xd8/0xf8) from [<802edef8>] (device_del+0xf4/0x178) [<802edef8>] (device_del+0xf4/0x178) from [<803a9e8c>] (usb_disable_device+0xa0/0x1c8) [<803a9e8c>] (usb_disable_device+0xa0/0x1c8) from [<803a25fc>] (usb_disconnect+0x88/0x1a0) [<803a25fc>] (usb_disconnect+0x88/0x1a0) from [<803a25e4>] (usb_disconnect+0x70/0x1a0) [<803a25e4>] (usb_disconnect+0x70/0x1a0) from [<803a5940>] (usb_remove_hcd+0xac/0x15c) [<803a5940>] (usb_remove_hcd+0xac/0x15c) from [<803c487c>] (host_stop+0x1c/0x3c) [<803c487c>] (host_stop+0x1c/0x3c) from [<803c1880>] (ci_otg_work+0xc8/0x118) [<803c1880>] (ci_otg_work+0xc8/0x118) from [<8003c62c>] (process_one_work+0x110/0x360) [<8003c62c>] (process_one_work+0x110/0x360) from [<8003d180>] (worker_thread+0x144/0x3ac) [<8003d180>] (worker_thread+0x144/0x3ac) from [<8004272c>] (kthread+0xa4/0xb0) [<8004272c>] (kthread+0xa4/0xb0) from [<8000e0d8>] (ret_from_fork+0x14/0x3c) Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286926 usb: chipidea: imx: add release_bus_freq at failure pathPeter Chen2014-04-16
| | | | | | | If not, the request{release}_bus_freq will be mismatch if fail occurs. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286459 usb: chipidea: imx: add request{release}_bus_freqPeter Chen2014-04-16
| | | | | | | When the usb in idle, it calls release_bus_req. When the usb is going to use, it calls request_bus_req. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286426-22 usb: chipidea: imx: Enable CI_HDRC_IMX_EHCI_QUIRKPeter Chen2014-04-16
| | | | | | Enable CI_HDRC_IMX_EHCI_QUIRK for controllers who use mxs-phy. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286426-21 usb: chipidea: host: add ehci quirk for imx controllerPeter Chen2014-04-16
| | | | | | | | When the port goes to suspend or finishes resme, it needs to notify PHY, it is not a standard EHCI operation, so we add a quirk for it. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286426-20 usb: chipidea: host: add quirk for ehci operationPeter Chen2014-04-16
| | | | | | | | | | | | | | | | | | For chipidea controller, it does not follow ehci spec strictly. Taking resume signal as an example, it will stop resume signal about 20-21ms later automatically, but standard ehci spec says, the resume signal is controlled by software (clear portsc.PORT_RESUME). This operation causes some remote wakeup problems for high speed devices due to host controller does not send SOF in time since software can't guarantee set run/stop bit in time (run/stop bit was cleared at the ehci suspend routine). When software sets run/stop bit, it needs 1 SoF time to make it effect. If we close the PHY clock just after setting run/stop bit, it does not be set in practice, so a software delay is needed. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286426-19 usb: chipidea: imx: Enable runtime pm support for imx6Peter Chen2014-04-16
| | | | | | | Currently, only imx6 SoC series add wakeup logic, so only enable runtime pm for imx6. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286426-18 usb: chipidea: imx: call set_wakeup when necessaryPeter Chen2014-04-16
| | | | | | | | - Disable wakeup after probe - Enable wakeup during the suspend - Disable wakeup after controller is active Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286426-17 usb: chipidea: usbmisc_imx: add set_wakup APIPeter Chen2014-04-16
| | | | | | | It is used to enable USB wakeup, currently only imx6 SoC series usb's wakeup is enabled. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286426-16 usb: chipidea: usbmisc_imx: remove the controller's clock infoPeter Chen2014-04-16
| | | | | | | | | | | Currently, the usbmisc is just an API supplier for controller driver, the controller calls related APIs to handle different things among the SoCs, before calling it, the clock must be on. So the clock operation is useless for usbmisc, it also increases the difficulties to manage the clock, especially at runtime power management situation. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286426-15 usb: chipidea: add wakeup interrupt handlerPeter Chen2014-04-16
| | | | | | | | | | When the controller is at suspend mode, it can be waken up by external events (like vbus, dp/dm or id change). Once we receive the wakeup interrupt, we need to resume the controller first, eg open clocks, disable some wakeup settings, etc. After that, the controller can receive the normal USB interrupts. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286426-14 usb: chipidea: imx: add power management supportPeter Chen2014-04-16
| | | | | | Add system and runtime power management support for imx gluy layer. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286426-13 usb: chipidea: Add power management supportPeter Chen2014-04-16
| | | | | | | | This commit adds runtime and system power management support for chipidea core. The runtime pm support is controlled by glue layer, it can be enabled by flag CI_HDRC_SUPPORTS_RUNTIME_PM. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286418 usb: chipidea: host: fix below build errorPeter Chen2014-04-16
| | | | | | | | /drivers/usb/chipidea/host.c: In function 'host_start': /drivers/usb/chipidea/host.c:67:6: error: 'struct ehci_hcd' has no member named 'has_tdi_phy_lpm' Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286159-2 usb: chipidea: imx: set CI_HDRC_IMX28_WRITE_FIX for imx28Peter Chen2014-04-16
| | | | | | | Due to imx28 needs ARM swp instruction for writing, we set CI_HDRC_IMX28_WRITE_FIX for imx28. Signed-off-by: Peter Chen <peter.chen@freescale.com>
* ENGR00286159-1 usb: chipidea: add freescale imx28 special write register methodPeter Chen2014-04-16
| | | | | | | | | | | | According to Freescale imx28 Errata, "ENGR119653 USB: ARM to USB register error issue", All USB register write operations must use the ARM SWP instruction. So, we implement special hw_write and hw_test_and_clear for imx28. Discussion for it at below: http://marc.info/?l=linux-usb&m=137996395529294&w=2 Signed-off-by: Peter Chen <peter.chen@freescale.com>
* usb: chipidea: only get vbus regulator for non-peripheral modePeter Chen2014-04-16
| | | | | | | | | | If the user chooses peripheral mode for this controller, the vbus regulator doesn't need to get, since the host will supply the vbus, it can save one vbus pin for other usage. Signed-off-by: Peter Chen <peter.chen@freescale.com> Tested-by: Frank Li <frank.li@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: chipidea: host: more enhancement when ci->hcd is NULLPeter Chen2014-04-16
| | | | | | | | | | | | | Like http://marc.info/?l=linux-usb&m=138200449428874&w=2 said: two more things are needed to be done: - If host_start fails, the host_stop should not be called, so we add check that ci->hcd is not NULL. - if the host_start fails at the beginning, we need to consider regulator mismatch issue. Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb/chipidea: fix oops on memory allocation failureRussell King - ARM Linux2014-04-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When CMA fails to initialize in v3.12-rc4, the chipidea driver oopses the kernel while trying to remove and put the HCD which doesn't exist: WARNING: CPU: 0 PID: 6 at /home/rmk/git/linux-rmk/arch/arm/mm/dma-mapping.c:511 __dma_alloc+0x200/0x240() coherent pool not initialised! Modules linked in: CPU: 0 PID: 6 Comm: kworker/u2:0 Tainted: G W 3.12.0-rc4+ #56 Workqueue: deferwq deferred_probe_work_func Backtrace: [<c001218c>] (dump_backtrace+0x0/0x10c) from [<c0012328>] (show_stack+0x18/0x1c) r6:c05fd9cc r5:000001ff r4:00000000 r3:df86ad00 [<c0012310>] (show_stack+0x0/0x1c) from [<c05f3a4c>] (dump_stack+0x70/0x8c) [<c05f39dc>] (dump_stack+0x0/0x8c) from [<c00230a8>] (warn_slowpath_common+0x6c/0x8c) r4:df883a60 r3:df86ad00 [<c002303c>] (warn_slowpath_common+0x0/0x8c) from [<c002316c>] (warn_slowpath_fmt+0x38/0x40) r8:ffffffff r7:00001000 r6:c083b808 r5:00000000 r4:df2efe80 [<c0023134>] (warn_slowpath_fmt+0x0/0x40) from [<c00196bc>] (__dma_alloc+0x200/0x240) r3:00000000 r2:c05fda00 [<c00194bc>] (__dma_alloc+0x0/0x240) from [<c001982c>] (arm_dma_alloc+0x88/0xa0) [<c00197a4>] (arm_dma_alloc+0x0/0xa0) from [<c03e2904>] (ehci_setup+0x1f4/0x438) [<c03e2710>] (ehci_setup+0x0/0x438) from [<c03cbd60>] (usb_add_hcd+0x18c/0x664) [<c03cbbd4>] (usb_add_hcd+0x0/0x664) from [<c03e89f4>] (host_start+0xf0/0x180) [<c03e8904>] (host_start+0x0/0x180) from [<c03e7c34>] (ci_hdrc_probe+0x360/0x670 ) r6:df2ef410 r5:00000000 r4:df2c3010 r3:c03e8904 [<c03e78d4>] (ci_hdrc_probe+0x0/0x670) from [<c0311044>] (platform_drv_probe+0x20/0x24) [<c0311024>] (platform_drv_probe+0x0/0x24) from [<c030fcac>] (driver_probe_device+0x9c/0x234) ... ---[ end trace c88ccaf3969e8422 ]--- Unable to handle kernel NULL pointer dereference at virtual address 00000028 pgd = c0004000 [00000028] *pgd=00000000 Internal error: Oops: 17 [#1] SMP ARM Modules linked in: CPU: 0 PID: 6 Comm: kworker/u2:0 Tainted: G W 3.12.0-rc4+ #56 Workqueue: deferwq deferred_probe_work_func task: df86ad00 ti: df882000 task.ti: df882000 PC is at usb_remove_hcd+0x10/0x150 LR is at host_stop+0x1c/0x3c pc : [<c03cacec>] lr : [<c03e88e4>] psr: 60000013 sp : df883b50 ip : df883b78 fp : df883b74 r10: c11f4c54 r9 : c0836450 r8 : df30c400 r7 : fffffff4 r6 : df2ef410 r5 : 00000000 r4 : df2c3010 r3 : 00000000 r2 : 00000000 r1 : df86b0a0 r0 : 00000000 Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment kernel Control: 10c53c7d Table: 2f29404a DAC: 00000015 Process kworker/u2:0 (pid: 6, stack limit = 0xdf882240) Stack: (0xdf883b50 to 0xdf884000) ... Backtrace: [<c03cacdc>] (usb_remove_hcd+0x0/0x150) from [<c03e88e4>] (host_stop+0x1c/0x3c) r6:df2ef410 r5:00000000 r4:df2c3010 [<c03e88c8>] (host_stop+0x0/0x3c) from [<c03e8aa0>] (ci_hdrc_host_destroy+0x1c/0x20) r5:00000000 r4:df2c3010 [<c03e8a84>] (ci_hdrc_host_destroy+0x0/0x20) from [<c03e7c80>] (ci_hdrc_probe+0x3ac/0x670) [<c03e78d4>] (ci_hdrc_probe+0x0/0x670) from [<c0311044>] (platform_drv_probe+0x20/0x24) [<c0311024>] (platform_drv_probe+0x0/0x24) from [<c030fcac>] (driver_probe_device+0x9c/0x234) [<c030fc10>] (driver_probe_device+0x0/0x234) from [<c030ff28>] (__device_attach+0x44/0x48) ... ---[ end trace c88ccaf3969e8423 ]--- Fix this so at least we can continue booting and get to a shell prompt. Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk> Tested-by: Russell King <rmk+kernel@arm.linux.org.uk> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: chipidea: udc: Fix calling spin_lock_irqsave at sleep contextPeter Chen2014-04-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixing the below dump: root@freescale ~$ modprobe g_serial g_serial gadget: Gadget Serial v2.4 g_serial gadget: g_serial ready BUG: sleeping function called from invalid context at /home/b29397/work/projects/upstream/usb/usb/drivers/base/power/runtime.c:952 in_atomic(): 1, irqs_disabled(): 128, pid: 805, name: modprobe 2 locks held by modprobe/805: #0: (udc_lock){+.+.+.}, at: [<7f000a74>] usb_gadget_probe_driver+0x44/0xb4 [udc_core] #1: (&(&ci->lock)->rlock){......}, at: [<7f033488>] ci_udc_start+0x94/0x110 [ci_hdrc] irq event stamp: 3878 hardirqs last enabled at (3877): [<806b6720>] _raw_spin_unlock_irqrestore+0x40/0x6c hardirqs last disabled at (3878): [<806b6474>] _raw_spin_lock_irqsave+0x2c/0xa8 softirqs last enabled at (3872): [<8002ec0c>] __do_softirq+0x1c8/0x2e8 softirqs last disabled at (3857): [<8002f180>] irq_exit+0xbc/0x110 CPU: 0 PID: 805 Comm: modprobe Not tainted 3.11.0-next-20130910+ #85 [<80016b94>] (unwind_backtrace+0x0/0xf8) from [<80012e0c>] (show_stack+0x20/0x24) [<80012e0c>] (show_stack+0x20/0x24) from [<806af554>] (dump_stack+0x9c/0xc4) [<806af554>] (dump_stack+0x9c/0xc4) from [<8005940c>] (__might_sleep+0xf4/0x134) [<8005940c>] (__might_sleep+0xf4/0x134) from [<803a04a4>] (__pm_runtime_resume+0x94/0xa0) [<803a04a4>] (__pm_runtime_resume+0x94/0xa0) from [<7f0334a4>] (ci_udc_start+0xb0/0x110 [ci_hdrc]) [<7f0334a4>] (ci_udc_start+0xb0/0x110 [ci_hdrc]) from [<7f0009b4>] (udc_bind_to_driver+0x5c/0xd8 [udc_core]) [<7f0009b4>] (udc_bind_to_driver+0x5c/0xd8 [udc_core]) from [<7f000ab0>] (usb_gadget_probe_driver+0x80/0xb4 [udc_core]) [<7f000ab0>] (usb_gadget_probe_driver+0x80/0xb4 [udc_core]) from [<7f008618>] (usb_composite_probe+0xac/0xd8 [libcomposite]) [<7f008618>] (usb_composite_probe+0xac/0xd8 [libcomposite]) from [<7f04b168>] (init+0x8c/0xb4 [g_serial]) [<7f04b168>] (init+0x8c/0xb4 [g_serial]) from [<800088e8>] (do_one_initcall+0x108/0x16c) [<800088e8>] (do_one_initcall+0x108/0x16c) from [<8008e518>] (load_module+0x1b00/0x20a4) [<8008e518>] (load_module+0x1b00/0x20a4) from [<8008eba8>] (SyS_init_module+0xec/0x100) [<8008eba8>] (SyS_init_module+0xec/0x100) from [<8000ec40>] (ret_fast_syscall+0x0/0x48) Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: chipidea: udc: Fix spinlock recursion during bus resetPeter Chen2014-04-16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | After configuration, the host also possible sends bus reset at any time, at such situation, it will trigger below spinlock recursion dump. This commit unlocks the spinlock before calling gadget's disconnect. BUG: spinlock recursion on CPU#0, swapper/0/0 lock: 0xbf128014, .magic: dead4ead, .owner: swapper/0/0, .owner_cpu: 0 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.11.0-next-20130910+ #106 [<80014e20>] (unwind_backtrace+0x0/0xec) from [<80011a6c>] (show_stack+0x10/0x14) [<80011a6c>] (show_stack+0x10/0x14) from [<805c143c>] (dump_stack+0x94/0xbc) [<805c143c>] (dump_stack+0x94/0xbc) from [<80282cf8>] (do_raw_spin_lock+0x16c/0x18c) [<80282cf8>] (do_raw_spin_lock+0x16c/0x18c) from [<805c77e0>] (_raw_spin_lock_irqsave+0x50/0x5c) [<805c77e0>] (_raw_spin_lock_irqsave+0x50/0x5c) from [<803cff88>] (ep_disable+0x24/0x110) [<803cff88>] (ep_disable+0x24/0x110) from [<7f015d50>] (gserial_disconnect+0xa0/0x15c [u_serial]) [<7f015d50>] (gserial_disconnect+0xa0/0x15c [u_serial]) from [<7f01c06c>] (acm_disable+0xc/0x30 [usb_f_acm]) [<7f01c06c>] (acm_disable+0xc/0x30 [usb_f_acm]) from [<7f001478>] (reset_config.isra.10+0x34/0x5c [libcomposite]) [<7f001478>] (reset_config.isra.10+0x34/0x5c [libcomposite]) from [<7f0014d4>] (composite_disconnect+0x34/0x5c [libcomposite]) [<7f0014d4>] (composite_disconnect+0x34/0x5c [libcomposite]) from [<803d1024>] (udc_irq+0x770/0xce4) [<803d1024>] (udc_irq+0x770/0xce4) from [<803cdcc0>] (ci_irq+0x98/0x164) [<803cdcc0>] (ci_irq+0x98/0x164) from [<8007edfc>] (handle_irq_event_percpu+0x50/0x17c) [<8007edfc>] (handle_irq_event_percpu+0x50/0x17c) from [<8007ef64>] (handle_irq_event+0x3c/0x5c) [<8007ef64>] (handle_irq_event+0x3c/0x5c) from [<80081e98>] (handle_fasteoi_irq+0x98/0x168) [<80081e98>] (handle_fasteoi_irq+0x98/0x168) from [<8007e598>] (generic_handle_irq+0x28/0x3c) [<8007e598>] (generic_handle_irq+0x28/0x3c) from [<8000edf4>] (handle_IRQ+0x4c/0xb4) [<8000edf4>] (handle_IRQ+0x4c/0xb4) from [<800085bc>] (gic_handle_irq+0x28/0x5c) [<800085bc>] (gic_handle_irq+0x28/0x5c) from [<800125c0>] (__irq_svc+0x40/0x54) Exception stack(0x8083bf68 to 0x8083bfb0) bf60: 81533b80 00000000 00096234 8001d760 8088e12c 00000000 bf80: 8083a000 8083a000 8084290c 805cb414 808428ac 8083a000 00000001 8083bfb0 bfa0: 8000f138 8000f13c 60000013 ffffffff [<800125c0>] (__irq_svc+0x40/0x54) from [<8000f13c>] (arch_cpu_idle+0x30/0x3c) [<8000f13c>] (arch_cpu_idle+0x30/0x3c) from [<8005eb94>] (cpu_startup_entry+0xf4/0x148) [<8005eb94>] (cpu_startup_entry+0xf4/0x148) from [<807f1a2c>] (start_kernel+0x2c4/0x318) BUG: spinlock lockup suspected on CPU#0, swapper/0/0 lock: 0xbf128014, .magic: dead4ead, .owner: swapper/0/0, .owner_cpu: 0 CPU: 0 PID: 0 Comm: swapper/0 Not tainted 3.11.0-next-20130910+ #106 [<80014e20>] (unwind_backtrace+0x0/0xec) from [<80011a6c>] (show_stack+0x10/0x14) [<80011a6c>] (show_stack+0x10/0x14) from [<805c143c>] (dump_stack+0x94/0xbc) [<805c143c>] (dump_stack+0x94/0xbc) from [<80282c94>] (do_raw_spin_lock+0x108/0x18c) [<80282c94>] (do_raw_spin_lock+0x108/0x18c) from [<805c77e0>] (_raw_spin_lock_irqsave+0x50/0x5c) [<805c77e0>] (_raw_spin_lock_irqsave+0x50/0x5c) from [<803cff88>] (ep_disable+0x24/0x110) [<803cff88>] (ep_disable+0x24/0x110) from [<7f015d50>] (gserial_disconnect+0xa0/0x15c [u_serial]) [<7f015d50>] (gserial_disconnect+0xa0/0x15c [u_serial]) from [<7f01c06c>] (acm_disable+0xc/0x30 [usb_f_acm]) [<7f01c06c>] (acm_disable+0xc/0x30 [usb_f_acm]) from [<7f001478>] (reset_config.isra.10+0x34/0x5c [libcomposite]) [<7f001478>] (reset_config.isra.10+0x34/0x5c [libcomposite]) from [<7f0014d4>] (composite_disconnect+0x34/0x5c [libcomposite]) [<7f0014d4>] (composite_disconnect+0x34/0x5c [libcomposite]) from [<803d1024>] (udc_irq+0x770/0xce4) [<803d1024>] (udc_irq+0x770/0xce4) from [<803cdcc0>] (ci_irq+0x98/0x164) [<803cdcc0>] (ci_irq+0x98/0x164) from [<8007edfc>] (handle_irq_event_percpu+0x50/0x17c) [<8007edfc>] (handle_irq_event_percpu+0x50/0x17c) from [<8007ef64>] (handle_irq_event+0x3c/0x5c) [<8007ef64>] (handle_irq_event+0x3c/0x5c) from [<80081e98>] (handle_fasteoi_irq+0x98/0x168) [<80081e98>] (handle_fasteoi_irq+0x98/0x168) from [<8007e598>] (generic_handle_irq+0x28/0x3c) [<8007e598>] (generic_handle_irq+0x28/0x3c) from [<8000edf4>] (handle_IRQ+0x4c/0xb4) [<8000edf4>] (handle_IRQ+0x4c/0xb4) from [<800085bc>] (gic_handle_irq+0x28/0x5c) [<800085bc>] (gic_handle_irq+0x28/0x5c) from [<800125c0>] (__irq_svc+0x40/0x54) Exception stack(0x8083bf68 to 0x8083bfb0) bf60: 81533b80 00000000 00096234 8001d760 8088e12c 00000000 bf80: 8083a000 8083a000 8084290c 805cb414 808428ac 8083a000 00000001 8083bfb0 bfa0: 8000f138 8000f13c 60000013 ffffffff [<800125c0>] (__irq_svc+0x40/0x54) from [<8000f13c>] (arch_cpu_idle+0x30/0x3c) [<8000f13c>] (arch_cpu_idle+0x30/0x3c) from [<8005eb94>] (cpu_startup_entry+0xf4/0x148) [<8005eb94>] (cpu_startup_entry+0xf4/0x148) from [<807f1a2c>] (start_kernel+0x2c4/0x318) Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: chipidea: add ci_hdrc_enter_lpm APIPeter Chen2014-04-16
| | | | | | | | | | | This API is used to let the PHY enter/leave low power mode. Before the controller going to work(at probe/resume), it needs to let the PHY leave low power mode. After the controller stopping working(at remove/suspend), it needs to let the PHY enter low power mode to save power consumption. Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: chipidea: imx: remove PHY operationsPeter Chen2014-04-16
| | | | | | | | Since the PHY operations are moved to core, delete the related code at glue layer. Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: chipidea: move PHY operation to corePeter Chen2014-04-16
| | | | | | | PHY operations are common, so move them to core. Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: chipidea: imx: Add usb_phy_shutdown at probe's error pathPeter Chen2014-04-16
| | | | | | | | | If not, the PHY will be active even the controller is not in use. We find this issue due to the PHY's clock refcount is not correct due to -EPROBE_DEFER return after phy's init. Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
* usb: chipidea: Fix memleak for ci->hw_bank.regmap when removalPeter Chen2014-04-16
| | | | | | | | It needs to free ci->hw_bank.regmap explicitly since it is not managed resource. Signed-off-by: Peter Chen <peter.chen@freescale.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>