From patchwork Sat Jun 13 17:45:51 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Wahren X-Patchwork-Id: 6603201 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 150919F326 for ; Sat, 13 Jun 2015 17:51:39 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id E6110206BE for ; Sat, 13 Jun 2015 17:51:37 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 9DAB5206BD for ; Sat, 13 Jun 2015 17:51:36 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z3pXG-0004ak-Qi; Sat, 13 Jun 2015 17:48:02 +0000 Received: from mout.kundenserver.de ([212.227.17.10]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1Z3pXD-0004Zt-Gg for linux-arm-kernel@lists.infradead.org; Sat, 13 Jun 2015 17:48:00 +0000 Received: from oxbsltgw09.schlund.de ([172.19.249.26]) by mrelayeu.kundenserver.de (mreue103) with ESMTPSA (Nemesis) id 0LoaZ0-1ZX7uN2zBC-00gV4w; Sat, 13 Jun 2015 19:45:53 +0200 Date: Sat, 13 Jun 2015 19:45:51 +0200 (CEST) From: Stefan Wahren To: peter.chen@freescale.com Message-ID: <1882113151.65839.1434217551960.JavaMail.open-xchange@oxbsltgw09.schlund.de> Subject: usb: phy: phy-mxs-usb: suspend to RAM causes NULL pointer dereference MIME-Version: 1.0 X-Priority: 3 Importance: Medium X-Mailer: Open-Xchange Mailer v7.6.2-Rev17 X-Originating-Client: com.openexchange.ox.gui.dhtml X-Provags-ID: V03:K0:mUaT4uNrEGgvfYz0ELsvNMscdW1n4m6tm8g8UJRy1KT2XBVPIrj eX1y0y2Y9NzXPRGsWlPa85JpSiMQSrcZOG11iK67vMh4qpOEd4/SHiNthaFGU2e+5T7EdcM g5epkTVXxDxHDip+gtQuW9QGuKlSpj/xix4fvQtbzFFb4AIBZvqnOsxN54HP7UZEgUjrR83 pveYlk2Axr6vMvzGL3rGg== X-UI-Out-Filterresults: notjunk:1; V01:K0:abHyAa+V1ag=:+Z9aS6WypOOdRKCkouPDxJ d0uML/JLaan92ls4vK22ZjfqJyXKe22R0NVF5DiYO91gzdOduudmKZift3pg7EQJUIsfbYc7z KNC6PdAkHNA4a3se8oTFxeh1abvk6fTZ7r6x2YmXYWmxv4VmIDONP6uPUdkHk1nJCGNEVfKJw CW2Dz7SvTKx4N24HoEq34pgL8YuQ5JbYfvBMtujAYMNjw+wVLMt1Darf7KYKPlYqNPJRjcbE2 T5yMOHefvmhG0EnNRWtr29v06kahxIpO4q+KyCLNDvUvMyfCMPwl92Iq3SshUOfwPbuK4gDOX h8PuehJGSGw0HsuW1d1rS38taGUCZu7FYz1mA9fbhYSltV0nAp5ahSQcxv9UMviCIjxYjK4fe oZSzz6tndJA0PqOx14D4+U8cHdG404LKeH9ev1fO0MvkLss8QMxk88ug6JVEt1FdjIf4aEvwJ AUvV5WZDlXpmzPSyjNaihj7XxgMcrIwEH0GMOOIrqM60hdY/GUMwx7IL3xPEot585f292H2sX b4d+5L7HAyVjJFrpaPLVrymcGoHTQqLXoHiteLBPPa2ZHv9JVZJPIXbPqZELPRZgP3Vn4a79E CrECrM/Wgx1r0nvERRjNWxfzDtlh4IofEMh+X8Qdb7pt4BA+0cfxGXJsiDwiEjXpykMvAG6SR TbVna7vi6YL2X4Kjzz2HQk3J37xcfyWudrJNsdViiZoeF5A== X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20150613_104759_918710_CA48BB29 X-CRM114-Status: GOOD ( 16.81 ) X-Spam-Score: -1.1 (-) Cc: marex@denx.de, fabio.estevam@freescale.com, linux-usb@vger.kernel.org, j.uzycki@elproma.com.pl, linux-arm-kernel@lists.infradead.org, LW@karo-electronics.de X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Stefan Wahren Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, triggering suspend to RAM via sysfs on a i.MX28 causes a NULL pointer dereference. This regression seems to be introduced with commit efdbd3a5d6e ("usb: phy: mxs: do not set PWD.RXPWD1PT1 for low speed connection"): root@duckbill:/sys/power# echo mem > state [ 83.677575] PM: Syncing filesystems ... done. [ 83.872011] Freezing user space processes ... (elapsed 0.006 seconds) done. [ 83.886817] Freezing remaining freezable tasks ... (elapsed 0.003 seconds) done. [ 83.909215] Unable to handle kernel NULL pointer dereference at virtual address 0000017c [ 83.917520] pgd = c6d88000 [ 83.920277] [0000017c] *pgd=46ed9831, *pte=00000000, *ppte=00000000 [ 83.926795] Internal error: Oops: 17 [#1] ARM [ 83.931191] Modules linked in: [ 83.934306] CPU: 0 PID: 435 Comm: bash Not tainted 4.0.0-rc4-next-20150320-gb8f4f66-dirty #163 [ 83.942940] Hardware name: Freescale MXS (Device Tree) [ 83.948102] task: c4954d00 ti: c6d20000 task.ti: c6d20000 [ 83.953544] PC is at regmap_read+0x10/0x5c [ 83.957695] LR is at mxs_phy_get_vbus_status+0x40/0x58 [ 83.962865] pc : [] lr : [] psr: 60000013 [ 83.962865] sp : c6d21d20 ip : 00800000 fp : 00000002 [ 83.974368] r10: c0340180 r9 : c07c15b0 r8 : 00000002 [ 83.979615] r7 : c06c6ad4 r6 : 00000000 r5 : 000001c0 r4 : 00000000 [ 83.986166] r3 : 00000000 r2 : c6d21d34 r1 : 000001c0 r0 : 000001c0 [ 83.992718] Flags: nZCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user [ 83.999876] Control: 0005317f Table: 46d88000 DAC: 00000015 [ 84.005644] Process bash (pid: 435, stack limit = 0xc6d20190) [ 84.011413] Stack: (0xc6d21d20 to 0xc6d22000) [ 84.015813] 1d20: c7833f10 00000001 00000000 c03d8ac4 00000002 c00601c8 00001074 c03d8ca4 [ 84.024030] 1d40: c0537268 60000013 c7a6bc10 c7aea010 c7a6bc10 00001074 c06c6ad4 c03d924c [ 84.032245] 1d60: c7aea010 c03d93dc c7a6bc10 c0fcf05c c07e165c c03401ac c7a6bc10 c0348818 [ 84.040459] 1d80: 00000000 c0051864 60000013 c07c15d0 00000000 c7a6bc10 c0fcf05c c7a6bc10 [ 84.048674] 1da0: c0fcf05c c7a6bc44 00000002 00000000 c07c1564 c03494d0 c07c1590 00536bb0 [ 84.056888] 1dc0: c7a6bc10 c0fcf05c 00000000 c07c1564 00000000 c0349c14 00000000 c07e1684 [ 84.065102] 1de0: 8061885f 00000013 8061885f 00000013 00000000 c005dec4 00000000 00000002 [ 84.073316] 1e00: c0f91cc0 00000003 c0f91cc0 c07e1684 c069b6d8 c069b6fc c069b6fc c07e3d18 [ 84.081529] 1e20: 00000000 c00599f8 00000003 00000000 00000000 c07a275c 60000013 00000004 [ 84.089741] 1e40: 00000001 00000000 00000000 00000000 00000000 00000000 00000000 c07e1684 [ 84.097956] 1e60: c07e1678 c069b6fc c6d20000 c07e3d18 00000000 c005e178 c06e4fbc c6d21e9c [ 84.106168] 1e80: 00000002 c053539c 00000000 00000003 00000000 c07e1684 c069b6d8 c069b6fc [ 84.114383] 1ea0: c069b6fc c07e3d18 00000000 c005a358 00000000 00000001 00000000 c07e1468 [ 84.122596] 1ec0: 00000000 c0054efc 00000000 00000000 00000000 c0165f00 00000000 60000013 [ 84.130812] 1ee0: c6d8c5c0 00000003 00000003 c0f91cc4 00000004 c6d20000 c0696b14 c0058d1c [ 84.139027] 1f00: c6d15b80 00000004 c6d8c5c0 c6d8c5c0 c6d15b8c c6d20000 c6d21f88 c02c7b38 [ 84.147240] 1f20: c6d15b80 c0166da4 c6d15b80 01f8e408 00000004 c0165f74 00000000 00000000 [ 84.155455] 1f40: 00000004 c6c39120 00000004 01f8e408 c6d21f88 c000f648 00000000 c010090c [ 84.163671] 1f60: c6e17da0 c6c39120 c6c39120 c6c39120 c6c39120 00000004 01f8e408 c000f648 [ 84.171884] 1f80: 00000000 c0100b10 00000000 00000000 b6ef5b40 00000004 01f8e408 b6ef5b40 [ 84.180097] 1fa0: 00000004 c000f460 00000004 01f8e408 00000001 01f8e408 00000004 00000000 [ 84.188311] 1fc0: 00000004 01f8e408 b6ef5b40 00000004 00000004 01f8e408 00000004 00000000 [ 84.196525] 1fe0: 00000000 bec9595c b6e2143c b6e7716c 60000010 00000001 00000000 00000000 [ 84.204762] [] (regmap_read) from [] (mxs_phy_get_vbus_status+0x40/0x58) [ 84.213258] [] (mxs_phy_get_vbus_status) from [] (mxs_phy_suspend+0x54/0x120) [ 84.222185] [] (mxs_phy_suspend) from [] (ci_controller_suspend+0x40/0x60) [ 84.230847] [] (ci_controller_suspend) from [] (ci_suspend+0x7c/0xbc) [ 84.239081] [] (ci_suspend) from [] (platform_pm_suspend+0x2c/0x54) [ 84.247145] [] (platform_pm_suspend) from [] (dpm_run_callback+0x48/0x12c) [ 84.255809] [] (dpm_run_callback) from [] (__device_suspend+0x12c/0x370) [ 84.264294] [] (__device_suspend) from [] (dpm_suspend+0x134/0x2fc) [ 84.272350] [] (dpm_suspend) from [] (suspend_devices_and_enter+0x8c/0x6e4) [ 84.281094] [] (suspend_devices_and_enter) from [] (pm_suspend+0x308/0x434) [ 84.289836] [] (pm_suspend) from [] (state_store+0x80/0xcc) [ 84.297192] [] (state_store) from [] (kobj_attr_store+0x18/0x1c) [ 84.304979] [] (kobj_attr_store) from [] (sysfs_kf_write+0x48/0x4c) [ 84.313046] [] (sysfs_kf_write) from [] (kernfs_fop_write+0xe0/0x188) [ 84.321282] [] (kernfs_fop_write) from [] (vfs_write+0xb8/0x1e8) [ 84.329074] [] (vfs_write) from [] (SyS_write+0x44/0x88) [ 84.336178] [] (SyS_write) from [] (ret_fast_syscall+0x0/0x48) [ 84.343791] Code: e92d4070 e1a04000 e1a05001 e1a00001 (e594117c) [ 84.350165] ---[ end trace 6acb90b2c2dd8be9 ]--- The following patch fixed the issue for me, but i'm not sure that is the right fix for this issue since there are more platforms involved. -----------------------------------%<---------------------------------------------- [PATCH] usb: phy: phy-mxs-usb: fix oops on suspend to RAM This patch avoids the oops in mxs_phy_get_vbus_status() by aborting since there is no syscon available. Signed-off-by: Stefan Wahren Fixes: efdbd3a5d6e ("usb: phy: mxs: do not set PWD.RXPWD1PT1 for low speed connection") CC: # 4.0 Acked-by: Peter Chen --- drivers/usb/phy/phy-mxs-usb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c index 8f7cb06..3fcc048 100644 --- a/drivers/usb/phy/phy-mxs-usb.c +++ b/drivers/usb/phy/phy-mxs-usb.c @@ -217,6 +217,9 @@ static bool mxs_phy_get_vbus_status(struct mxs_phy *mxs_phy) { unsigned int vbus_value; + if (!mxs_phy->regmap_anatop) + return false; + if (mxs_phy->port_id == 0) regmap_read(mxs_phy->regmap_anatop, ANADIG_USB1_VBUS_DET_STAT,