Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit dd86fd8d authored by Hemant Kumar's avatar Hemant Kumar Committed by Mayank Rana
Browse files

usb: dwc3: Remove tasklet bottom half handler



There is a possibility of tasklet bottom half handler racing
with dwc3_msm_suspend(). As a result before disabling the dwc3
irq, dwc3 interrupts are fired and once the suspend routine
disables the clocks bottom half handler gets a chance to run
and tries to access dwc3 register resulting into un-clocked
register access. Since dwc3 interrupt is already running in
threaded irq context, interrupt can be directly handled in
same context and avoid this race.

Change-Id: Ife9e165f6aa2112c1440819d659b97b5502a3f07
Signed-off-by: default avatarHemant Kumar <hemantk@codeaurora.org>
Signed-off-by: default avatarMayank Rana <mrana@codeaurora.org>
parent bb2195e5
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -973,7 +973,6 @@ struct dwc3 {

	/* IRQ timing statistics */
	int			irq;
	struct tasklet_struct	bh;
	unsigned long		irq_cnt;
	unsigned long		ep_cmd_timeout_cnt;
	unsigned                bh_completion_time[MAX_INTR_STATS];
+0 −1
Original line number Diff line number Diff line
@@ -2019,7 +2019,6 @@ static int dwc3_msm_suspend(struct dwc3_msm *mdwc)
	can_suspend_ssphy = !(mdwc->in_host_mode &&
				dwc3_msm_is_host_superspeed(mdwc));

	tasklet_kill(&dwc->bh);
	/* Disable core irq */
	if (dwc->irq)
		disable_irq(dwc->irq);
+2 −17
Original line number Diff line number Diff line
@@ -2247,8 +2247,6 @@ static int dwc3_gadget_stop(struct usb_gadget *g,

	dwc3_gadget_disable_irq(dwc);

	tasklet_kill(&dwc->bh);

	spin_lock_irqsave(&dwc->lock, flags);

	__dwc3_gadget_ep_disable(dwc->eps[0]);
@@ -3531,14 +3529,6 @@ static irqreturn_t dwc3_process_event_buf(struct dwc3 *dwc, u32 buf)
	return ret;
}

static void dwc3_interrupt_bh(unsigned long param)
{
	struct dwc3 *dwc = (struct dwc3 *) param;

	dwc3_thread_interrupt(dwc->irq, dwc);
	enable_irq(dwc->irq);
}

static irqreturn_t dwc3_thread_interrupt(int irq, void *_dwc)
{
	struct dwc3 *dwc = _dwc;
@@ -3633,10 +3623,8 @@ irqreturn_t dwc3_interrupt(int irq, void *_dwc)
	dwc->irq_event_count[dwc->irq_dbg_index] = temp_cnt / 4;
	dwc->irq_dbg_index = (dwc->irq_dbg_index + 1) % MAX_INTR_STATS;

	if (ret == IRQ_WAKE_THREAD) {
		disable_irq_nosync(irq);
		tasklet_schedule(&dwc->bh);
	}
	if (ret == IRQ_WAKE_THREAD)
		dwc3_thread_interrupt(dwc->irq, dwc);

	return IRQ_HANDLED;
}
@@ -3684,9 +3672,6 @@ int dwc3_gadget_init(struct dwc3 *dwc)
		goto err3;
	}

	dwc->bh.func = dwc3_interrupt_bh;
	dwc->bh.data = (unsigned long)dwc;

	dwc->gadget.ops			= &dwc3_gadget_ops;
	dwc->gadget.max_speed		= USB_SPEED_SUPER;
	dwc->gadget.speed		= USB_SPEED_UNKNOWN;