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: 70968 Delivered-To: patch@linaro.org Received: by 10.140.28.4 with SMTP id 4csp1333401qgy; Mon, 27 Jun 2016 18:18:46 -0700 (PDT) X-Received: by 10.66.246.135 with SMTP id xw7mr366962pac.141.1467076726404; Mon, 27 Jun 2016 18:18:46 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u87si29920988pfj.142.2016.06.27.18.18.46; Mon, 27 Jun 2016 18:18:46 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-usb-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-usb-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752018AbcF1BSb (ORCPT + 5 others); Mon, 27 Jun 2016 21:18:31 -0400 Received: from mail-pf0-f170.google.com ([209.85.192.170]:35217 "EHLO mail-pf0-f170.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751942AbcF1BSa (ORCPT ); Mon, 27 Jun 2016 21:18:30 -0400 Received: by mail-pf0-f170.google.com with SMTP id c2so829358pfa.2 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=kJaPro4bZzBSt/so622Z+wOfHbbE04ore5eFMdxPuLH1sBkl7BMeWZP719omwCDT4e mYaa3ivOw/E9raCJfv7Kn0S+mmPRZZ44vX1LaoID4uC6hukDYo6ApASpDW84yHZA65w2 yQQdmdWzNHsI/351qbiTWW9UGI+SBMjppq20mnFjTq/naxVO8j17PhenKEOehVHJTQG2 iuMxHDrtoHFTHxmxJfvFzKP91/zj62klhuswjtsjGenkAkZlzlXVOfZkPFPo2ECXCFRO kC8FcuwIdMzxJsZ3ITbia/ghSGM/BgeL94SX8KFVMA0hWItmXM0p/rRMNOx+pvNWYvxF X25A== X-Gm-Message-State: ALyK8tKW6jIo8nMcd6FQQgB/Cd8WyJbGmP9maLUCOp/3BmTzyyivKNGrr3H1W3QSeIfNjUkV 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 Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org, Li Jun , Greg Kroah-Hartman 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 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org 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 --- drivers/usb/common/usb-otg-fsm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) -- 2.9.0.rc2.8.ga28705d -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html 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: