From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-0.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, T_DKIMWL_WL_HIGH,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by aws-us-west-2-korg-lkml-1.web.codeaurora.org (Postfix) with ESMTP id CD8F0C07D5C for ; Thu, 14 Jun 2018 10:03:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F47D208D8 for ; Thu, 14 Jun 2018 10:03:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=samsung.com header.i=@samsung.com header.b="KtT27ABz" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 5F47D208D8 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=samsung.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754905AbeFNKDV (ORCPT ); Thu, 14 Jun 2018 06:03:21 -0400 Received: from mailout4.samsung.com ([203.254.224.34]:17380 "EHLO mailout4.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754719AbeFNKDS (ORCPT ); Thu, 14 Jun 2018 06:03:18 -0400 Received: from epcas1p3.samsung.com (unknown [182.195.41.47]) by mailout4.samsung.com (KnoxPortal) with ESMTP id 20180614100316epoutp0474baa7cb6057a51b4d3f288810b6ed7a~3-qgCTJ7R2490724907epoutp04A; Thu, 14 Jun 2018 10:03:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout4.samsung.com 20180614100316epoutp0474baa7cb6057a51b4d3f288810b6ed7a~3-qgCTJ7R2490724907epoutp04A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1528970596; bh=c4kSHnYBqOEcy0bR9B0ETfcMvzucjO8Rj+BSbwAhQ0A=; h=Date:From:To:Cc:Subject:In-reply-to:References:From; b=KtT27ABzShiNST0LfsNkmQZZwHfAX1iS0gvRFgqydL9YuSMQ5gbgF0yCzngEbTNfv tTU7Q7GXW0gXSx94pAgzwdYWf2KoqlLxj/H1svPBcDcN5IbfVJ0ISXWRbi+IJ6vzxX eOW+FrcIe9SSTREHEA/0p5PzjtWvAyezue/N53NU= Received: from epsmges2p3.samsung.com (unknown [182.195.40.152]) by epcas1p4.samsung.com (KnoxPortal) with ESMTP id 20180614100313epcas1p4595abf1ecd8b22581d7c876a0e4c9018~3-qeE-8uK2854528545epcas1p4E; Thu, 14 Jun 2018 10:03:13 +0000 (GMT) Received: from epcas2p2.samsung.com ( [182.195.41.54]) by epsmges2p3.samsung.com (Symantec Messaging Gateway) with SMTP id B7.B8.04186.16D322B5; Thu, 14 Jun 2018 19:03:13 +0900 (KST) Received: from epsmgms2p2new.samsung.com (unknown [182.195.42.143]) by epcas2p3.samsung.com (KnoxPortal) with ESMTP id 20180614100313epcas2p35bb417763b93407bc60b3956d510e2e3~3-qd21kxS2484324843epcas2p31; Thu, 14 Jun 2018 10:03:13 +0000 (GMT) X-AuditID: b6c32a47-9afff7000000105a-f3-5b223d61c944 Received: from epmmp2 ( [203.254.227.17]) by epsmgms2p2new.samsung.com (Symantec Messaging Gateway) with SMTP id 0A.C4.04192.16D322B5; Thu, 14 Jun 2018 19:03:13 +0900 (KST) MIME-version: 1.0 Content-transfer-encoding: 8BIT Content-type: text/plain; charset="utf-8" Received: from [10.113.63.77] by mmp2.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0PAB00BRT59D2U50@mmp2.samsung.com>; Thu, 14 Jun 2018 19:03:13 +0900 (KST) Message-id: <5B223D61.3030303@samsung.com> Date: Thu, 14 Jun 2018 19:03:13 +0900 From: Chanwoo Choi Organization: Samsung Electronics User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.6.0 To: "H. Nikolaus Schaller" , Roger Quadros Cc: Tony Lindgren , Kishon Vijay Abraham I , Discussions about the Letux Kernel , kernel@pyra-handheld.com, linux-omap , "linux-kernel@vger.kernel.org" Subject: Re: Bug with dwc3 id detect and regulators In-reply-to: <6A5F47F7-FDB8-4181-BE88-0D82A3053D9D@goldelico.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGKsWRmVeSWpSXmKPExsWy7bCmmW6irVK0weH9FhY/tn1lsrj0tcbi wtMeNoutfy6xWVzeNYfNYvaSfhaLnkdaFvuveDlweHz7OonFY837U8weLZN2sXt8aWlm9jh+ YzuTx+dNcgFsUak2GamJKalFCql5yfkpmXnptkrewfHO8aZmBoa6hpYW5koKeYm5qbZKLj4B um6ZOUDXKCmUJeaUAoUCEouLlfTtbIryS0tSFTLyi0uAbjM0NNIzNDDXMzIC0saxVkamQCUJ qRmPzn5jL/hhWfH0yDWmBsathl2MnBwSAiYSz3cvZQexhQR2MEo8/2zZxcgFZH8HsptPsMEU fTl0jAUisYFR4n3/BLAEr4CgxI/J94ASHBzMAvISRy5lg4SZBTQlXnyZBFV/l1Fi3pMPrBD1 WhLbjjWwgtSzCKhKtH5UAAmzAYX3v7gBNpJfQFHi6o/HjCC2qECExM7539hBykUE/CUaHhSD jGQWmMkksffoXLCRwgLGEituv2cBsTkFHCXefV/BCFIkIXCdTWLm3otQD7hItN24wwhhC0u8 Or6FHcKWlni2aiNUQzujxJcXzawQzgRGiQ+nNjNBVBlLPFvYxQTxGp9Ex+G/YCdJCPBKdLQJ QZR4SHw/0c4I8fEpJomPL2cxTWCUnYUUSLMQgTQLKZAWM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gL1azZeUZA8/bbRnukwIFTv27E+W/Ymucj6nHqTnP7li97H+lPzH3UIe+ 3avJDXWfmFLZ8reu6d22vihl6YMGnqd9oT35/xad3qt32s/dzlpMiaU4I9FQi7moOBEAlZMH K3YCAAA= X-CMS-MailID: 20180614100313epcas2p35bb417763b93407bc60b3956d510e2e3 X-Msg-Generator: CA CMS-TYPE: 102P DLP-Filter: Pass X-CFilter-Loop: Reflected X-CMS-RootMailID: 20180611085358epcas2p31227dd481046041532c7fc7a00c8e088 References: <941bfd38-e975-e460-81aa-ce8d90c7a3f5@ti.com> <5B21C2E5.2090004@samsung.com> <6A5F47F7-FDB8-4181-BE88-0D82A3053D9D@goldelico.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Nikolaus, On 2018년 06월 14일 18:58, H. Nikolaus Schaller wrote: > Hi Roger and Chanwoo, > >> Am 14.06.2018 um 10:34 schrieb Roger Quadros : >> >> On 14/06/18 04:20, Chanwoo Choi wrote: >>> Hi Roger, >>> >>> On 2018년 06월 11일 17:53, Roger Quadros wrote: >>>> Chanwoo, >>>> >>>> On 11/06/18 11:33, H. Nikolaus Schaller wrote: >>>>> Hi Tony, >>>>> another bug... >>>>> >>>>> [ 174.540313] BUG: scheduling while atomic: kworker/0:4/1327/0x00000002 >>>>> [ 174.547353] Modules linked in: omapdrm drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops drm drm_panel_orientation_quirks bnep bluetooth ecdh_generic usb_f_ecm g_ether usb_f_rndis u_ether libcomposite configfs ipv6 arc4 wl18xx wlcore mac80211 panel_boe_w677l snd_soc_omap_hdmi_audio snd_soc_dmic cfg80211 dwc3 snd_soc_omap_abe_twl6040 snd_soc_twl6040 leds_gpio wwan_on_off connector_hdmi omapdss encoder_tpd12s015 cec pwm_omap_dmtimer omapdss_base pwm_bl generic_adc_battery ehci_omap wlcore_sdio dwc3_omap bmp280_spi snd_soc_ts3a227e crtouch_mt leds_is31fl319x tsc2007 bq2429x_charger bq27xxx_battery_i2c bq27xxx_battery ina2xx as5013 tca8418_keypad twl6040_vibra palmas_pwrbutton gpio_twl6040 palmas_gpadc usb3503 bmp280_i2c bmc150_accel_i2c w2cbw003_bluetooth bmc150_magn_i2c bmp280 bmc150_accel_core >>>>> [ 174.624601] bmc150_magn bno055 industrialio_triggered_buffer kfifo_buf industrialio snd_soc_omap_mcbsp snd_soc_omap_mcpdm snd_soc_omap snd_pcm_dmaengine [last unloaded: syscopyarea] >>>>> [ 174.642327] CPU: 0 PID: 1327 Comm: kworker/0:4 Tainted: G W 4.17.0-letux+ #2408 >>>>> [ 174.651541] Hardware name: Generic OMAP5 (Flattened Device Tree) >>>>> [ 174.658004] Workqueue: events_power_efficient palmas_gpio_id_detect >>>>> [ 174.664780] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) >>>>> [ 174.673109] [] (show_stack) from [] (dump_stack+0x7c/0x9c) >>>>> [ 174.680881] [] (dump_stack) from [] (__schedule_bug+0x60/0x84) >>>>> [ 174.689006] [] (__schedule_bug) from [] (__schedule+0x50/0x694) >>>>> [ 174.697217] [] (__schedule) from [] (schedule+0xb0/0xcc) >>>>> [ 174.704790] [] (schedule) from [] (schedule_timeout+0x354/0x3d4) >>>>> [ 174.713100] [] (schedule_timeout) from [] (wait_for_common+0x118/0x158) >>>>> [ 174.722064] [] (wait_for_common) from [] (omap_i2c_xfer+0x354/0x48c) >>>>> [ 174.730749] [] (omap_i2c_xfer) from [] (__i2c_transfer+0x238/0x550) >>>>> [ 174.739350] [] (__i2c_transfer) from [] (i2c_transfer+0x84/0xb4) >>>>> [ 174.747685] [] (i2c_transfer) from [] (bq24296_i2c_reg8_read.constprop.8+0x54/0x64 [bq2429x_charger]) >>>>> [ 174.759465] [] (bq24296_i2c_reg8_read.constprop.8 [bq2429x_charger]) from [] (bq24296_update_reg+0x28/0xf8 [bq2429x_charger]) >>>>> [ 174.773437] [] (bq24296_update_reg [bq2429x_charger]) from [] (_regulator_do_disable+0x100/0x238) >>>>> [ 174.784804] [] (_regulator_do_disable) from [] (_regulator_disable+0x88/0x120) >>>>> [ 174.794404] [] (_regulator_disable) from [] (regulator_disable+0x30/0x60) >>>>> [ 174.803556] [] (regulator_disable) from [] (dwc3_omap_set_mailbox+0x84/0xf8 [dwc3_omap]) >>>>> [ 174.814124] [] (dwc3_omap_set_mailbox [dwc3_omap]) from [] (dwc3_omap_id_notifier+0x14/0x1c [dwc3_omap]) >>>>> [ 174.826149] [] (dwc3_omap_id_notifier [dwc3_omap]) from [] (notifier_call_chain+0x40/0x68) >>>>> [ 174.836867] [] (notifier_call_chain) from [] (raw_notifier_call_chain+0x14/0x1c) >>>>> [ 174.846661] [] (raw_notifier_call_chain) from [] (extcon_sync+0x54/0x19c) >>>>> [ 174.855804] [] (extcon_sync) from [] (process_one_work+0x244/0x464) >>>>> [ 174.864386] [] (process_one_work) from [] (worker_thread+0x2c0/0x3ec) >>>>> [ 174.873156] [] (worker_thread) from [] (kthread+0x134/0x150) >>>>> [ 174.881087] [] (kthread) from [] (ret_from_fork+0x14/0x2c) >>>>> >>>>> It turns out that extcon_sync() holds a spinlock while sending its notifiers and this >>>>> is ending up in our regulator.en/disable() which wants to use blocking i2c. >>>>> >>>>> Do you see similar things on the OMAP5EVM when using OTG mode? >>>>> The Palmas SMPS10 is also handled through i2c. Or is this magically hidden by regmap? >>>>> >>>>> Well, as a workaround, I can make the regulator.en/disable() in the bq2429x driver >>>>> just trigger a worker, but IMHO it is not expected for regulator ops to be spinlock safe. >>>>> >>>>> So I think extcon should not spinlock (which might be against the extcon design) or >>>> >>>> I think this something that should be addressed in the Extcon layer. >>>> Do you really need to call the raw_notifier_call_chain() function with spinlock held in extcon_sync()? >>>> if yes why? >>> >>> To reduce the latency of notification is important of extcon. >>> >>> So, extcon used the spinlock before calling the notifier_call_chain >>> to prevent the scheduled out for a moment. Also, the notifier_call >>> calls the registered notifier function sequentially. It means that >>> if some registered notifier function spends a lot of time, >>> the next registered notifier might receive the notification >>> with a delay. So, extcon used the spinlock. Unitl now, >>> >>> But, as you commented and previously, sometimes it caused the similar issues. >>> (To fix similar issues, the consumer device used the workqueue) >>> >>> I will call notifier function without spinlock as following >>> and I'll consider the other way to notify the changed state to consumer device >>> with broadcasting way. >>> >>> diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c >>> index 8bff5fd18185..1e35b8ca3951 100644 >>> --- a/drivers/extcon/extcon.c >>> +++ b/drivers/extcon/extcon.c >>> @@ -433,8 +433,8 @@ int extcon_sync(struct extcon_dev *edev, unsigned int id) >>> return index; >>> >>> spin_lock_irqsave(&edev->lock, flags); >>> - >>> state = !!(edev->state & BIT(index)); >>> + spin_unlock_irqrestore(&edev->lock, flags); >>> >>> /* >>> * Call functions in a raw notifier chain for the specific one >>> @@ -448,6 +448,8 @@ int extcon_sync(struct extcon_dev *edev, unsigned int id) >>> */ >>> raw_notifier_call_chain(&edev->nh_all, state, edev); >>> >>> + spin_lock_irqsave(&edev->lock, flags); >>> + >>> >> >> Thanks Chanwoo. >> >> Nikolaus, could you please test this patch and give your Reported-by/Tested-by sign off? Thanks. >> >> https://lkml.org/lkml/2018/6/14/2 > > I have tested on the Pyra handheld prototype and now it works. Plugging in an OTG cable > enables/disables OTG power as expected and there are no kernel oops any more. > > So you can add my Reported-by/Tested-by. Thanks for the test. But, you have to reply your reported/tested-by tag to patch[1] because all tags should be remained on lkml. [1] https://lkml.org/lkml/2018/6/14/2 -- Best Regards, Chanwoo Choi Samsung Electronics