From patchwork Tue Jun 28 01:18:27 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Boyd X-Patchwork-Id: 9201609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id A4B93607D3 for ; Tue, 28 Jun 2016 01:20:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8929128593 for ; Tue, 28 Jun 2016 01:20:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7A688285AD; Tue, 28 Jun 2016 01:20:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id C3E0A28593 for ; Tue, 28 Jun 2016 01:20:47 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bHhfy-0006wG-8S; Tue, 28 Jun 2016 01:18:54 +0000 Received: from mail-pf0-x234.google.com ([2607:f8b0:400e:c00::234]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bHhfu-0006uz-UN for linux-arm-kernel@lists.infradead.org; Tue, 28 Jun 2016 01:18:51 +0000 Received: by mail-pf0-x234.google.com with SMTP id i123so853880pfg.0 for ; Mon, 27 Jun 2016 18:18:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=w+YO+QGA/T4n0UE3qFBJXnzlBp3trj5niInTU23yx3E=; b=UWjiHYb5JjqsjkkBT5EcD5RW57HVeO8Od705JaHOu+dY9ePxSoQbYJZAYfPV2C8oPE W2/F3oRG5u/rOFhZiFq/GFzwBjAIPCZLD/dCLcAumdWQ9k64ibFGtksRm/TkJ2Eg5lK3 w3PJK09qabpIeFgfSbsVoBLwU/tcev0dolfdQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=w+YO+QGA/T4n0UE3qFBJXnzlBp3trj5niInTU23yx3E=; b=gwtQcxa4h3vFGvUYitd/QPdUzH+RexF9IFvM7no8QWFPLdTYo2imquKXLUSAbPO7PB AnHRSTEv5H3kFtAbpYAlxOdANrv9QLx4REP2cHrpKq7JuPAk/g5fST4ka+7sS03s2own ehHdXVnoEGO2mdMruPM5msTwPrSad2ShXFa9lwn6ezsufx9IH2z+yv0Sa75xdqSpl5I/ ROIgia6jfbKRAj79R1QEHvc7a1s6C3W+k3kW0LHEIeDQAm7U5M1GglGiZKd6XHJbC41r r65toK8RciApTXqbR7x9dP4l9WbJP1YJwQI6OWxlHytqIKdKnBkc7xlG53FFimoqBBpJ 295A== X-Gm-Message-State: ALyK8tJl5mRbD96JUHAh5F52icGrGWY2bgyw9G5SPF/co+KOrkOaluY0P/F54S6rS0BqY7jI X-Received: by 10.98.135.193 with SMTP id i184mr443003pfe.3.1467076709601; Mon, 27 Jun 2016 18:18:29 -0700 (PDT) Received: from localhost.localdomain (pat_11.qualcomm.com. [192.35.156.11]) by smtp.gmail.com with ESMTPSA id k22sm2186941pfj.16.2016.06.27.18.18.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 27 Jun 2016 18:18:29 -0700 (PDT) From: Stephen Boyd To: Peter Chen , Felipe Balbi Subject: [PATCH] usb: otg-fsm: Cancel HNP polling work when not used Date: Mon, 27 Jun 2016 18:18:27 -0700 Message-Id: <20160628011827.1688-1-stephen.boyd@linaro.org> X-Mailer: git-send-email 2.9.0.rc2.8.ga28705d X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160627_181851_014936_D108B5F4 X-CRM114-Status: GOOD ( 12.60 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Greg Kroah-Hartman , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Li Jun MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP We setup the HNP polling worker, but we never stop it. The OTG state machine can go round and round and keep reinitializing the worker even while it's actively running. That's bad, and debug objects catches it. Fix this by canceling the work when we leave the A_HOST or B_HOST states. [otg_set_state] Set state: a_wait_bcon usb 2-1: USB disconnect, device number 2 [otg_statemachine] quit statemachine, changed = 1 [otg_set_state] Set state: a_host [otg_statemachine] quit statemachine, changed = 1 usb 2-1: new low-speed USB device number 3 using ci_hdrc usb 2-1: New USB device found, idVendor=03f0, idProduct=134a usb 2-1: New USB device strings: Mfr=1, Product=2, SerialNumber=0 usb 2-1: Product: HP USB Optical Mouse usb 2-1: Manufacturer: PixArt input: PixArt HP USB Optical Mouse as /devices/platform/soc/f9a55000.usb/ci_hdrc.0/usb2/2-1/2-1:1.0/0003:03F0:134A.0002/input/input1 hid-generic 0003:03F0:134A.0002: input: USB HID v1.11 Mouse [PixArt HP USB Optical Mouse] on usb-ci_hdrc.0-1/input0 [otg_set_state] Set state: a_wait_bcon usb 2-1: USB disconnect, device number 3 [otg_statemachine] quit statemachine, changed = 1 [otg_set_state] Set state: a_host ------------[ cut here ]------------ WARNING: CPU: 2 PID: 95 at lib/debugobjects.c:263 debug_print_object+0x98/0xc0 ODEBUG: init active (active state 0) object type: timer_list hint: delayed_work_timer_fn+0x0/0x2c Modules linked in: phy_qcom_usb_hsic phy_qcom_usb_hs ci_hdrc_msm ci_hdrc CPU: 2 PID: 95 Comm: kworker/u8:1 Not tainted 4.7.0-rc1-00043-g1f22f3b65c44-dirty #442 Hardware name: Qualcomm (Flattened Device Tree) Workqueue: ci_otg ci_otg_work [ci_hdrc] [] (unwind_backtrace) from [] (show_stack+0x20/0x24) [] (show_stack) from [] (dump_stack+0x7c/0x9c) [] (dump_stack) from [] (__warn+0xe4/0x110) [] (__warn) from [] (warn_slowpath_fmt+0x48/0x50) [] (warn_slowpath_fmt) from [] (debug_print_object+0x98/0xc0) [] (debug_print_object) from [] (__debug_object_init+0xcc/0x3bc) [] (__debug_object_init) from [] (debug_object_init+0x24/0x2c) [] (debug_object_init) from [] (init_timer_key+0x24/0x120) [] (init_timer_key) from [] (otg_start_hnp_polling+0x7c/0xbc) [] (otg_start_hnp_polling) from [] (otg_set_state+0x740/0xc20) [] (otg_set_state) from [] (otg_statemachine+0x47c/0x4ac) [] (otg_statemachine) from [] (ci_otg_fsm_work+0x48/0x1a0 [ci_hdrc]) [] (ci_otg_fsm_work [ci_hdrc]) from [] (ci_otg_work+0xd4/0x218 [ci_hdrc]) [] (ci_otg_work [ci_hdrc]) from [] (process_one_work+0x154/0x4b4) [] (process_one_work) from [] (worker_thread+0x38/0x4d0) [] (worker_thread) from [] (kthread+0xe8/0x104) [] (kthread) from [] (ret_from_fork+0x14/0x3c) Cc: Li Jun Cc: Greg Kroah-Hartman Fixes: ae57e97a9521 ("usb: common: otg-fsm: add HNP polling support") Signed-off-by: Stephen Boyd Acked-by: Li Jun --- drivers/usb/common/usb-otg-fsm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/drivers/usb/common/usb-otg-fsm.c b/drivers/usb/common/usb-otg-fsm.c index 9059b7dc185e..73eec8c12235 100644 --- a/drivers/usb/common/usb-otg-fsm.c +++ b/drivers/usb/common/usb-otg-fsm.c @@ -61,6 +61,18 @@ static int otg_set_protocol(struct otg_fsm *fsm, int protocol) return 0; } +static void otg_stop_hnp_polling(struct otg_fsm *fsm) +{ + /* + * The memory of host_req_flag should be allocated by + * controller driver, otherwise, hnp polling is not started. + */ + if (!fsm->host_req_flag) + return; + + cancel_delayed_work_sync(&fsm->hnp_polling_work); +} + /* Called when leaving a state. Do state clean up jobs here */ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state) { @@ -84,6 +96,7 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state) fsm->b_ase0_brst_tmout = 0; break; case OTG_STATE_B_HOST: + otg_stop_hnp_polling(fsm); break; case OTG_STATE_A_IDLE: fsm->adp_prb = 0; @@ -97,6 +110,7 @@ static void otg_leave_state(struct otg_fsm *fsm, enum usb_otg_state old_state) fsm->a_wait_bcon_tmout = 0; break; case OTG_STATE_A_HOST: + otg_stop_hnp_polling(fsm); otg_del_timer(fsm, A_WAIT_ENUM); break; case OTG_STATE_A_SUSPEND: