aboutsummaryrefslogtreecommitdiff
path: root/drivers/usb/dwc2/gadget.c
AgeCommit message (Collapse)AuthorFilesLines
2016-11-18usb: dwc2: gadget: Transfer length limit checking for DDMAVahram Aharonyan1-1/+31
Add dwc2_gadget_get_chain_limit() function and its call in transfer start routine to correctly estimate one go on transfer size if descriptor DMA mode is selected. Signed-off-by: Vahram Aharonyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-11-18usb: dwc2: gadget: Add DMA descriptor chains for EP 0Vahram Aharonyan1-0/+54
Update dwc2_hsotg structure to add descriptor chains for EP 0: two DMA descriptors for Setup phase, per one for IN/OUT data and status phases. Add their allocation function dwc2_gadget_alloc_ctrl_desc_chains() and its call during gadget probe. Signed-off-by: Vahram Aharonyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-11-18usb: dwc2: gadget: Add descriptor DMA parameterVahram Aharonyan1-0/+11
Add a parameter for descriptor DMA and set it based on hardware capabilities. This won't actually be used by the gadget until later, when the descriptor DMA code is in place. Signed-off-by: Vahram Aharonyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-11-18usb: dwc2: gadget: Update for new usb_endpoint_maxp()Vardan Mikayelyan1-19/+23
Update the dwc2 driver for the new behavior of the usb_endpoint_maxp() and also use the new usb_endpoint_maxp_mult() helper function. This commit fixes failures in high-badwith ISOC transfer tests. Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-11-18usb: dwc2: Move gadget settings into core_paramsJohn Youn1-79/+14
Move the gadget devicetree settings into the core_params structure and document them. Then set and check them in params.c, with the addition of some helper functions, and remove the equivalent code in gadget.c. Because these parameters came from the standalone s3c driver, they have a fixed default value rather than an autodetected one. Preserve and document this behavior to avoid any compatibility issues. Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-11-18usb: dwc2: Declare the core params struct staticallyJohn Youn1-1/+1
This makes it consistent with the hw_params struct and simplifies the memory management for future refactoring. Fix up usage in all files. Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-11-03usb: dwc2: cleanup with list_first_entry_or_null()Masahiro Yamada1-4/+2
The combo of list_empty() check and return list_first_entry() can be replaced with list_first_entry_or_null(). Signed-off-by: Masahiro Yamada <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-10-18Revert "usb: dwc2: gadget: fix TX FIFO size and address initialization"John Youn1-8/+39
This reverts commit aa381a7259c3 ("usb: dwc2: gadget: fix TX FIFO size and address initialization"). The original commit removed the FIFO size programming per endpoint. The DPTXFSIZn register is also used for DIEPTXFn and the SIZE field is r/w in dedicated fifo mode. So it isn't appropriate to simply remove this initialization as it might break existing behavior. Also, some cores might not have enough fifo space to handle the programming method used in the reverted patch, resulting in fifo initialization failure. Signed-off-by: John Youn <[email protected]> Cc: Robert Baldyga <[email protected]> Cc: Stefan Wahren <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-10-18Revert "usb: dwc2: gadget: change variable name to more meaningful"John Youn1-4/+4
This reverts commit ba48eab8866c ("usb: dwc2: gadget: change variable name to more meaningful"). This is needed to cleanly revert commit aa381a7259c3 ("usb: dwc2: gadget: fix TX FIFO size and address initialization") which may cause regressions on some platforms. Signed-off-by: John Youn <[email protected]> Cc: Robert Baldyga <[email protected]> Cc: Stefan Wahren <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-09-08usb: dwc2: gadget: Only initialize device if in device modeJohn Youn1-2/+5
In dwc2_hsotg_udc_start(), don't initialize the controller for device mode unless we are actually in device mode. Tested-by: Heiko Stuebner <[email protected]> Tested-by: Stefan Wahren <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-08-31usb: dwc2: gadget: free TX FIFO after killing requestsRobert Baldyga1-4/+4
As kill_all_requests() potentially flushes TX FIFO, we should should free FIFO after calling it. Otherwise FIFO could stay unflushed properly. Signed-off-by: Robert Baldyga <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-08-31usb: dwc2: gadget: remove dead code from dwc2_hsotg_ep_enable()Robert Baldyga1-12/+1
Since FIFO is always freed in dwc2_hsotg_ep_disable(), ep->fifo_index is always 0 in dwc2_hsotg_ep_enable(), hence code inside if() block is never executed. Signed-off-by: Robert Baldyga <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-08-31usb: dwc2: gadget: change variable name to more meaningfulRobert Baldyga1-4/+4
Since we handle FIFOs and endpoint separately, using variable named 'ep' in context of FIFO is misleading, hence we rename it to 'fifo'. Signed-off-by: Robert Baldyga <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-08-31usb: dwc2: gadget: fix TX FIFO size and address initializationRobert Baldyga1-39/+8
According to DWC2 documentation, DPTxFSize field of DPTXFSIZn register is read only, which means that software cannot change FIFO size. Register description says: "The value of this register is the Largest Device Mode Periodic Tx Data FIFO Depth (parameter OTG_TX_DPERIO_DFIFO_DEPTH_n), as specified during coreConsultant configuration." That means, that we have to setup only FIFO start addresses (DPTxFStAddr), taking into account reset values of DPTxFSize. Initialize FIFO start addresses properly and remove unneeded core related to incorrect FIFO size initialization. Signed-off-by: Robert Baldyga <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-08-31usb: dwc2: gadget: use ep->fifo_index in context of FIFO registersRobert Baldyga1-2/+3
In context of FIFO registers we use ep->fifo_index instead of ep->index. Signed-off-by: Robert Baldyga <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-08-29usb: dwc2: gadget: don't print on ENOMEMWolfram Sang1-6/+2
All kmalloc-based functions print enough information on failures. Signed-off-by: Wolfram Sang <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-06-21usb: dwc2: gadget: Final fixes for BDMA ISOCVardan Mikayelyan1-27/+70
Done fixes and tested hsotg gadget's BDMA mode. Tested Control, Bulk, Isoc, Inter transfers. Added code for isoc transfers, removed unusable code, done minor fixes. Affected functions and IRQ handlers: - dwc2_hsotg_start_req(), - dwc2_hsotg_ep_enable(), - dwc2_hsotg_ep_queue(), - dwc2_hsotg_handle_outdone(), - GINTSTS_GOUTNAKEFF handler, Removed 'has_correct_parity' flag from 'dwc2_hsotg_ep' struct. Before this patch series, to set the data pid the DWC2 gadget driver was toggling the even/odd until it match, then were leaving it set. But now I have added mechanism to set pid and excluded all code where this flag was set. Tested-by: John Keeping <[email protected]> Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-06-21usb: dwc2: gadget: Add EP disabled interrupt handlerVardan Mikayelyan1-17/+70
Reimplemented EP disabled interrupt handler and moved to corresponding function. This interrupt indicates that the endpoint has been disabled per the application's request. For IN endpoints flushes txfifo, in case of BULK clears DCTL_CGNPINNAK, in case of ISOC completes current request. For ISOC-OUT endpoints completes expired requests. If there is remaining request starts it. This is the part of ISOC-OUT transfer drop flow. When ISOC-OUT transfer expired we must disable ep to drop ongoing transfer. Tested-by: John Keeping <[email protected]> Reviewed-by: Vahram Aharonyan <[email protected]> Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-06-21usb: dwc2: gadget: Add Incomplete ISO IN/OUT Interrupt handlersVardan Mikayelyan1-49/+124
Incomplete ISO IN interrupt indicates one of the following conditions occurred while transmitting an ISOC transaction. - Corrupted IN Token for ISOC EP. - Packet not complete in FIFO. Incomplete ISO OUT indicates that there is at least one isochronous OUT endpoint on which the transfer is not completed in the current microframe. The following actions will be taken: In case of EP-IN - Determine the EP - Disable EP directly from this handler; when "Endpoint Disabled" interrupt is received flush FIFO In case of EP-OUT - Determine the EP - If target frame elapsed set DCTL_SGOUTNAK, unmask GOUTNAKEFF and proceed as described in section 7.5.1 of DWC-HSOTG Programming Guide Also added dwc2_gadget_target_frame_elapsed() helper function which will be used in Incomplete ISO IN/OUT Interrupt handlers. Tested-by: John Keeping <[email protected]> Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-06-21usb: dwc2: gadget: Add OUTTKNEPDIS and NAKINTRPT handlersVardan Mikayelyan1-0/+94
NAKINTRPT interrupt is starting point for isoc-in transfer, synchronization done with first in token received from host, core asserts this interrupt when responds with 0 length data to in token, received from host. The first IN token is asynchronous for device - device does not know when first one token will arrive from host. On first token arrival HW generates 2 interrupts: 'in token received while FIFO empty' and 'NAK'. NAK interrupt for ISOC in means that token has arrived and ZLP was sent in response to that as there was no data in FIFO. SW is basing on this interrupt to obtain frame in which token has come and then based on the interval calculates next frame for transfer. OUTTKNEPDIS interrupt is starting point for isoc-out transfer, synchronization done with first out token received from host while corresponding ep is disabled. For OUTs the reason is same - device does not know initial frame in which out token will come. For this HW generates OUTTKNEPDIS - out token is received while EP is disabled. Upon getting this interrupt SW starts calculation for next transfer frame. Tested-by: John Keeping <[email protected]> Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-06-21usb: dwc2: gadget: Add dwc2_gadget_start_next_request functionVardan Mikayelyan1-13/+38
Replaced repeating code with function call. Starts next request from ep queue. If queue is empty and ep is isoc -In case of OUT-EP unmasks OUTTKNEPDIS. OUTTKNEPDIS is masked in it's handler, so we need to unmask it here to be able to do resynchronization. Tested-by: John Keeping <[email protected]> Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-06-21usb: dwc2: gadget: Add dwc2_gadget_read_ep_interrupts functionVardan Mikayelyan1-1/+29
Reads and returns interrupts for given endpoint, by masking epint_reg with corresponding mask. Tested-by: John Keeping <[email protected]> Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-06-21usb: dwc2: gadget: Corrected interval calculationVardan Mikayelyan1-4/+4
Calculate the interval according to the USB 2.0 specification section 9.6.6. Tested-by: John Keeping <[email protected]> Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-06-21usb: dwc2: gadget: Add dwc2_gadget_incr_frame_num()Vardan Mikayelyan1-0/+19
Increases and checks targeted frame number of current ep if overrun happened, sets flag and masks with DSTS_SOFFN_LIMIT Added following fields to struct dwc2_hsotg_ep -target_frame: Targeted frame num to setup next ISOC transfer -frame_overrun: Indicates SOF number overrun in DSTS Tested-by: John Keeping <[email protected]> Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-06-21usb: dwc2: gadget: Fix transfer stop programming for out endpointVardan Mikayelyan1-4/+2
According DWC-OTG databook, "GOUTNakEff" is read only and can be cleared only by "DCTL.CGOUTNak", but here we do not need to clear it because DWC-OTG programming guide says that before disabling any OUT endpoint, the application must enable Global OUT NAK mode, so if this mode is enabled we can continue without this step. Tested-by: John Keeping <[email protected]> Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-06-21usb: dwc2: gadget: Corrected field namesVardan Mikayelyan1-3/+3
No-op change. Changed field names to prevent misunderstanding. Tested-by: John Keeping <[email protected]> Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-06-21usb: dwc2: gadget: Remove unnecessary codeVardan Mikayelyan1-8/+0
This chunk is not needed here. There is no functionality depend on this, so if no-op, I think we do not need to have this interrupt unmasked. Tested-by: John Keeping <[email protected]> Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-06-21usb: dwc2: gadget: Remove unnecessary lineVardan Mikayelyan1-1/+0
Removed "ctrl |= DXEPCTL_USBACTEP" from dwc2_hsotg_start_req() function because this step is done in dwc2_hsotg_ep_enable(). Tested-by: John Keeping <[email protected]> Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-05-31usb: dwc2: gadget: Do not halt isochronous endpointsVahram Aharonyan1-0/+5
Add a check in dwc2_hsotg_ep_sethalt() so that it does not halt isochronous endpoints. Signed-off-by: Vahram Aharonyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-05-31usb: dwc2: gadget: Do not halt endpoint if activeVahram Aharonyan1-4/+15
The gadget API function usb_ep_set_halt() expects the gadget to return -EAGAIN if the ep is active. Add support for this behavior. Otherwise this may break mass storage protocol if a STALL is attempted on the endpoint. Signed-off-by: Vahram Aharonyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-04-28usb: dwc2: gadget: Prevent handling of host interruptsVardan Mikayelyan1-0/+3
In host slave mode, the core asserts the rxready, txfifoempty interrupts that get serviced in the gadget irq handler. Prevent servicing of these when not in the gadget mode of operation. Signed-off-by: Vardan Mikayelyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-04-28usb: dwc2: gadget: Check for ep0 in enableVahram Aharonyan1-1/+4
Replaced the WARN_ON with a check and return of -EINVAL in the dwc2_hsotg_ep_enable function if ep0 is passed in. Signed-off-by: Vahram Aharonyan <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-04-04usb: dwc2: do not override forced dr_mode in gadget setupPrzemek Rudy1-5/+18
The host/device mode set with dr_mode should be kept all the time, not being changed to OTG in gadget setup (by overriding CFGUSB_FORCEDEVMODE and CFGUSB_FORCEHOSTMODE bits). Acked-by: John Youn <[email protected]> Tested-by: John Youn <[email protected]> Signed-off-by: Przemek Rudy <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2016-03-04usb: dwc2: Move register save and restore functionsJohn Youn1-0/+102
Move the register save and restore functions into the host and gadget specific files. Tested-by: Douglas Anderson <[email protected]> Reviewed-by: Douglas Anderson <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-12-22usb: dwc2: gadget: Repair DSTS register decodingMarek Vasut1-1/+1
The "enumspd" field is located in register DSTS[2:1], but the code which checks the bitfield does not shift the value accordingly. This in turn causes incorrect detection of gadget link partner speed in dwc2_hsotg_irq_enumdone() . Shift the value accordingly to fix the problem with speed detection. Acked-by: John Youn <[email protected]> Signed-off-by: Marek Vasut <[email protected]> Cc: Felipe Balbi <[email protected]> Cc: Greg Kroah-Hartman <[email protected]> Cc: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-12-22usb: dwc2: gadget: Remove call to dwc2_hsotg_init()John Youn1-2/+0
Remove call to dwc2_hsotg_init() from dwc2_gadget_init(). The gadget_init function should not access any device registers because the mode isn't guaranteed here. Also, this is already called elsewhere before anything starts on the gadget so it is not necessary here. Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-12-22usb: dwc2: gadget: Replace dwc2_hsotg_corereset()John Youn1-49/+1
The dwc2_core_reset() function exists in the core so use that one instead. Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-12-22usb: dwc2: gadget: Use hw params from coreJohn Youn1-25/+16
Use the previously cached hw params in the gadget. This saves a reset and force mode in the gadget initialization during probe and makes getting the hardware parameters consistent between gadget and host. Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-12-22usb: dwc2: gadget: don't overwrite DCTL register on NAKEFF interruptsGregory Herrero1-2/+2
When receiving GINTSTS_GINNAKEFF or GINTSTS_GOUTNAKEFF interrupt, DCTL will be overwritten with DCTL_CGOUTNAK or DCTL_CGNPINNAK values. Instead of overwriting it, write only needed bits. It could cause an issue if GINTSTS_GINNAKEFF or GINTSTS_GOUTNAKEFF interrupt is received after dwc2 disabled pullup by writing DCTL_SFTDISCON bit. Pullup will then be re-enabled whereas it should not. Acked-by: John Youn <[email protected]> Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-12-22usb: dwc2: fix transfer stop programming for out endpointDu, Changbin1-5/+5
To stop an out endpoint, software should set sets the Global OUT NAK, but not the Global Non-periodic IN NAK. This driver bug leads the out-ep failed be in disabled state with below error. dwc2_hsotg_ep_stop_xfr: timeout DOEPCTL.EPDisable Acked-by: John Youn <[email protected]> Signed-off-by: Du, Changbin <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-14usb: dwc2: refactor common low-level hw code to platform.cMarek Szyprowski1-169/+17
DWC2 module on some platforms needs three additional hardware resources: phy controller, clock and power supply. All of them must be enabled/activated to properly initialize and operate. This was initially handled in s3c-hsotg driver, which has been converted to 'gadget' part of dwc2 driver. Unfortunately, not all of this code got moved to common platform code, what resulted in accessing DWC2 registers without enabling low-level hardware resources. This fails for example on Exynos SoCs. This patch moves all the code for managing those resources to common platform.c file and provides convenient wrappers for controlling them. Signed-off-by: Marek Szyprowski <[email protected]> Acked-by: John Youn <[email protected]> Tested-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-14usb: dwc2: remove no longer needed init_mutexMarek Szyprowski1-17/+0
init_mutex is a leftover from the time, when s3c-hsotg driver did not implement proper pull up/down control and emulated it by enabling enabling/disabling usb phy. Proper pull up/down control has been added by commit 5b9451f8c4fbaf0549139755fb45ff2b57975b7f ("usb: dwc2: gadget: use soft-disconnect udc feature in pullup() method"), so init_muxtex can be removed now to avoid potential deadlocks with other locks. Signed-off-by: Marek Szyprowski <[email protected]> Acked-by: John Youn <[email protected]> Tested-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-02usb: dwc2: gadget: parity fix in isochronous modeRoman Bacik1-8/+63
USB OTG driver in isochronous mode has to set the parity of the receiving microframe. The parity is set to even by default. This causes problems for an audio gadget, if the host starts transmitting on odd microframes. This fix uses Incomplete Periodic Transfer interrupt to toggle between even and odd parity until the Transfer Complete interrupt is received. Signed-off-by: Roman Bacik <[email protected]> Reviewed-by: Abhinav Ratna <[email protected]> Reviewed-by: Srinath Mannam <[email protected]> Signed-off-by: Scott Branden <[email protected]> Signed-off-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-01usb: dwc2: remove non-functional clock gatingMarek Szyprowski1-6/+0
During typical gadget operation, dwc2 clock was enabled 3 times: from dwc2_gadget_init(), dwc2_hsotg_udc_start() and dwc2_hsotg_pullup(), and then disabled in s3c_hsotg_pullup(), s3c_hsotg_udc_stop() and dwc2_hsotg_remove(). This really makes no sense, so leave clock control code only in dwc2_gadget_init/remove functions. Tested-by: John Youn <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Marek Szyprowski <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-01usb: dwc2: remove double call to dwc2_hsotg_of_probeMarek Szyprowski1-2/+0
This patch removes doubled call to dwc2_hsotg_of_probe() function. Tested-by: John Youn <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Marek Szyprowski <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-01usb: dwc2: gadget: fix a memory use-after-free bugYunzhi Li1-3/+3
When dwc2_hsotg_handle_unaligned_buf_complete() hs_req->req.buf already destroyed, in dwc2_hsotg_unmap_dma(), it touches hs_req->req.dma again, so dwc2_hsotg_unmap_dma() should be called before dwc2_hsotg_handle_unaligned_buf_complete(). Otherwise, it will cause a bad_page BUG, when allocate this memory page next time. This bug led to the following crash: BUG: Bad page state in process swapper/0 pfn:2bdbc [ 26.820440] page:eed76780 count:0 mapcount:0 mapping: (null) index:0x0 [ 26.854710] page flags: 0x200(arch_1) [ 26.885836] page dumped because: PAGE_FLAGS_CHECK_AT_PREP flag set [ 26.919179] bad because of flags: [ 26.948917] page flags: 0x200(arch_1) [ 26.979100] Modules linked in: [ 27.008401] CPU: 0 PID: 0 Comm: swapper/0 Tainted: G W3.14.0 #17 [ 27.041816] [<c010e1f8>] (unwind_backtrace) from [<c010a704>] (show_stack+0x20/0x24) [ 27.076108] [<c010a704>] (show_stack) from [<c087eea8>] (dump_stack+0x70/0x8c) [ 27.110246] [<c087eea8>] (dump_stack) from [<c01ce0b8>] (bad_page+0xfc/0x12c) [ 27.143958] [<c01ce0b8>] (bad_page) from [<c01ce65c>] (get_page_from_freelist+0x3e4/0x50c) [ 27.179298] [<c01ce65c>] (get_page_from_freelist) from [<c01ce9a0>] (__alloc_pages_nodemask) [ 27.216296] [<c01ce9a0>] (__alloc_pages_nodemask) from [<c01cf00c>] (__get_free_pages+0x20/) [ 27.252326] [<c01cf00c>] (__get_free_pages) from [<c01e5bec>] (kmalloc_order_trace+0x34/0xa) [ 27.288295] [<c01e5bec>] (kmalloc_order_trace) from [<c0203304>] (__kmalloc+0x40/0x1ac) [ 27.323751] [<c0203304>] (__kmalloc) from [<c052abc0>] (dwc2_hsotg_ep_queue.isra.12+0x7c/0x1) [ 27.359937] [<c052abc0>] (dwc2_hsotg_ep_queue.isra.12) from [<c052af88>] (dwc2_hsotg_ep_queue) [ 27.397478] [<c052af88>] (dwc2_hsotg_ep_queue_lock) from [<c0554110>] (rx_submit+0xfc/0x164) [ 27.433619] [<c0554110>] (rx_submit) from [<c05546e8>] (rx_complete+0x22c/0x230) [ 27.468872] [<c05546e8>] (rx_complete) from [<c052b528>] (dwc2_hsotg_complete_request+0xfc/0) [ 27.506240] [<c052b528>] (dwc2_hsotg_complete_request) from [<c052bba0>] (dwc2_hsotg_handle_o) [ 27.545401] [<c052bba0>] (dwc2_hsotg_handle_outdone) from [<c052be70>] (dwc2_hsotg_epint+0x2c) [ 27.583689] [<c052be70>] (dwc2_hsotg_epint) from [<c052c750>] (dwc2_hsotg_irq+0x1dc/0x4ac) [ 27.621041] [<c052c750>] (dwc2_hsotg_irq) from [<c01682e0>] (handle_irq_event_percpu+0x70/0x) [ 27.659066] [<c01682e0>] (handle_irq_event_percpu) from [<c01684ec>] (handle_irq_event+0x4c) [ 27.697322] [<c01684ec>] (handle_irq_event) from [<c016bae0>] (handle_fasteoi_irq+0xc8/0x11) [ 27.735451] [<c016bae0>] (handle_fasteoi_irq) from [<c0167b8c>] (generic_handle_irq+0x30/0x) [ 27.773918] [<c0167b8c>] (generic_handle_irq) from [<c0167ca4>] (__handle_domain_irq+0x84/0) [ 27.812018] [<c0167ca4>] (__handle_domain_irq) from [<c01003b0>] (gic_handle_irq+0x48/0x6c) [ 27.849695] [<c01003b0>] (gic_handle_irq) from [<c010b340>] (__irq_svc+0x40/0x50) [ 27.886907] Exception stack(0xc0d01ee0 to 0xc0d01f28) Acked-by: John Youn <[email protected]> Tested-by: Heiko Stuebner <[email protected]> Tested-by: Jeffy Chen <[email protected]> Signed-off-by: Yunzhi Li <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-01usb: dwc2: gadget: handle reset interrupt before endpoint interruptsMian Yousaf Kaukab1-30/+30
If system is loaded, reset, enum-done and setup interrupts can occur at the same time. Current interrupt handling sequence will handle setup packet's interrupt before handling reset interrupt. Which will break the enumeration process. Correct sequence is to handle reset, enum-done and then any other endpoint interrupts. Signed-off-by: Mian Yousaf Kaukab <[email protected]> Tested-by: Robert Baldyga <[email protected]> Tested-by: Dinh Nguyen <[email protected]> Tested-by: John Youn <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-01usb: dwc2: gadget: exit hibernation before power downGregory Herrero1-6/+7
When disconnecting cable, controller will detect a suspend condition and enter partial power down. If vbus_session is called by the phy driver during hibernation, make sure controller exit hibernation before it is accessed. Signed-off-by: Jianqiang Tang <[email protected]> Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Tested-by: Robert Baldyga <[email protected]> Tested-by: Dinh Nguyen <[email protected]> Tested-by: John Youn <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-01usb: dwc2: gadget: unmask idstschng interrupt only if controller supports itGregory Herrero1-7/+10
idstschng interrupt should not be used when id pin control is external. This is already handled on dwc2 host part. Fix it on gadget part as well. Signed-off-by: Gregory Herrero <[email protected]> Signed-off-by: Mian Yousaf Kaukab <[email protected]> Tested-by: Robert Baldyga <[email protected]> Tested-by: Dinh Nguyen <[email protected]> Tested-by: John Youn <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
2015-10-01usb: dwc2: gadget: only reset core after addressed stateMian Yousaf Kaukab1-8/+3
There is a 200ms guard period to avoid unnecessary resets of the dwc2 ip. This delay sometimes prove to be too large when usbcv is run with an ehci host. dwc2 only needs to be reset after addressed state. Change the logic to reset ip after addressed state. Signed-off-by: Mian Yousaf Kaukab <[email protected]> Tested-by: Robert Baldyga <[email protected]> Tested-by: Dinh Nguyen <[email protected]> Tested-by: John Youn <[email protected]> Acked-by: John Youn <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>