From patchwork Mon Aug 25 11:48:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 4773921 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 275DBC0338 for ; Mon, 25 Aug 2014 11:52:40 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id EADFF200D5 for ; Mon, 25 Aug 2014 11:52:38 +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 AF88B200CA for ; Mon, 25 Aug 2014 11:52:37 +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 1XLsm4-0001u1-6p; Mon, 25 Aug 2014 11:49:24 +0000 Received: from mail-by2lp0243.outbound.protection.outlook.com ([207.46.163.243] helo=na01-by2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XLslz-0001qk-OC for linux-arm-kernel@lists.infradead.org; Mon, 25 Aug 2014 11:49:20 +0000 Received: from BN3PR0301CA0034.namprd03.prod.outlook.com (25.160.180.172) by DM2PR03MB352.namprd03.prod.outlook.com (10.141.54.24) with Microsoft SMTP Server (TLS) id 15.0.1015.9; Mon, 25 Aug 2014 11:48:56 +0000 Received: from BN1BFFO11FD022.protection.gbl (2a01:111:f400:7c10::1:126) by BN3PR0301CA0034.outlook.office365.com (2a01:111:e400:4000::44) with Microsoft SMTP Server (TLS) id 15.0.1015.19 via Frontend Transport; Mon, 25 Aug 2014 11:48:56 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD022.mail.protection.outlook.com (10.58.144.85) with Microsoft SMTP Server (TLS) id 15.0.1010.11 via Frontend Transport; Mon, 25 Aug 2014 11:48:56 +0000 Received: from dragon.ap.freescale.net ([10.192.185.14]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s7PBmhVb004627; Mon, 25 Aug 2014 04:48:52 -0700 From: Shawn Guo To: Russell King Subject: [PATCH v2 2/2] imx-drm: ipuv3-plane: fix kernel Oops in ipu_dp_put() Date: Mon, 25 Aug 2014 19:48:26 +0800 Message-ID: <1408967306-2624-3-git-send-email-shawn.guo@freescale.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1408967306-2624-1-git-send-email-shawn.guo@freescale.com> References: <1408967306-2624-1-git-send-email-shawn.guo@freescale.com> X-EOPAttributedMessage: 0 X-Forefront-Antispam-Report: CIP:192.88.158.2; CTRY:US; IPV:CAL; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(6009001)(199003)(189002)(19580405001)(83072002)(107046002)(229853001)(105606002)(26826002)(85852003)(104016003)(50466002)(69596002)(81156004)(575784001)(19580395003)(48376002)(77982001)(85306004)(62966002)(84676001)(93916002)(76176999)(87936001)(6806004)(68736004)(79102001)(46102001)(102836001)(74502001)(97736001)(89996001)(50986999)(64706001)(88136002)(74662001)(80022001)(110136001)(50226001)(31966008)(87286001)(77156001)(21056001)(92566001)(47776003)(20776003)(33646002)(81542001)(83322001)(99396002)(4396001)(106466001)(76482001)(44976005)(81342001)(92726001)(90102001)(104166001)(36756003)(95666004)(86362001); DIR:OUT; SFP:; SCL:1; SRVR:DM2PR03MB352; H:az84smr01.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; MIME-Version: 1.0 X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:;UriScan:; X-Forefront-PRVS: 03142412E2 Received-SPF: Fail (protection.outlook.com: domain of freescale.com does not designate 192.88.158.2 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.158.2; helo=az84smr01.freescale.net; Authentication-Results: spf=fail (sender IP is 192.88.158.2) smtp.mailfrom=Shawn.Guo@freescale.com; X-OriginatorOrg: freescale.com X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140825_044919_845158_3D25F819 X-CRM114-Status: GOOD ( 16.28 ) X-Spam-Score: -0.8 (/) Cc: kernel@pengutronix.de, Greg Kroah-Hartman , dri-devel@lists.freedesktop.org, Shawn Guo , Philipp Zabel , linux-arm-kernel@lists.infradead.org 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: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 Unbinding imx-hdmi or imx-ldb driver triggers a kernel Oops in function ipu_dp_put() as below. $ echo 120000.hdmi > /sys/devices/soc0/soc/2000000.aips-bus/120000.hdmi/driver/unbind [ 66.411700] Console: switching to colour dummy device 80x30 [ 66.432543] drm_kms_helper: drm: unregistered panic notifier [ 66.515313] Unable to handle kernel NULL pointer dereference at virtual address 00000004 [ 66.523445] pgd = bc494000 [ 66.526161] [00000004] *pgd=4da3b831, *pte=00000000, *ppte=00000000 [ 66.532521] Internal error: Oops: 817 [#1] SMP ARM [ 66.537320] Modules linked in: [ 66.540403] CPU: 1 PID: 1874 Comm: bash Not tainted 3.17.0-rc1-00030-gcbc339c9c4c0-dirty #398 [ 66.548937] task: bc697500 ti: bc468000 task.ti: bc468000 [ 66.554354] PC is at ipu_dp_put+0x10/0x18 [ 66.558376] LR is at ipu_plane_dpms+0x60/0x8c [ 66.562743] pc : [<80360904>] lr : [<804df730>] psr: 20000013 [ 66.562743] sp : bc469d50 ip : bc469d60 fp : bc469d5c [ 66.574227] r10: 00100100 r9 : bd94a474 r8 : 00200200 [ 66.579459] r7 : bd94a3f4 r6 : bd94a400 r5 : 00000003 r4 : bd943c00 [ 66.585992] r3 : 00000000 r2 : 00000000 r1 : bc6979d0 r0 : 00000000 [ 66.592528] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user [ 66.599670] Control: 10c5387d Table: 4c49404a DAC: 00000015 [ 66.605422] Process bash (pid: 1874, stack limit = 0xbc468240) [ 66.611262] Stack: (0xbc469d50 to 0xbc46a000) [ 66.615629] 9d40: bc469d74 bc469d60 804df730 80360900 [ 66.623817] 9d60: bd943c00 bd94a000 bc469d8c bc469d78 804df788 804df6dc 00000000 bd943c00 [ 66.632005] 9d80: bc469da4 bc469d90 804df7e8 804df768 804df7c0 bd943e00 bc469dd4 bc469da8 [ 66.640202] 9da0: 8034e5b8 804df7cc bc697500 bd94a000 bd932a90 be1a3010 806ec3c0 0000000c [ 66.648406] 9dc0: bd5a4a0c bd5a4a00 bc469dec bc469dd8 804dc750 8034e3f4 bd94a000 bd94a000 [ 66.656609] 9de0: bc469e0c bc469df0 80345cdc 804dc718 00000000 bd94a000 80965ec0 be1a3010 [ 66.664813] 9e00: bc469e24 bc469e10 803467a0 80345cbc 804dc6d4 bd930a40 bc469e34 bc469e28 [ 66.673017] 9e20: 804dc6e8 8034677c bc469e4c bc469e38 80362c80 804dc6e0 bd930fc0 bd932100 [ 66.681219] 9e40: bc469e6c bc469e50 80362d28 80362c60 be1a3010 80987574 809661f8 0000000c [ 66.689423] 9e60: bc469e7c bc469e70 804e00f8 80362cac bc469e8c bc469e80 80368ac0 804e00ec [ 66.697627] 9e80: bc469ea4 bc469e90 8036721c 80368aac be1a3044 be1a3010 bc469ebc bc469ea8 [ 66.705831] 9ea0: 80367298 803671b0 be1a3010 80987574 bc469edc bc469ec0 80366398 8036727c [ 66.714033] 9ec0: bd5a4a00 0000000c bd4fc580 bc469f78 bc469eec bc469ee0 80365acc 80366340 [ 66.722237] 9ee0: bc469f0c bc469ef0 8014b224 80365ab0 8014b1d0 00000000 00000000 bd4fc580 [ 66.730439] 9f00: bc469f44 bc469f10 8014a564 8014b1dc 00000000 00000000 00000001 bd66d040 [ 66.738644] 9f20: 0000000c 0032ac08 bc469f78 0000000c bc468000 0032ac08 bc469f74 bc469f48 [ 66.746847] 9f40: 800e7c50 8014a4a8 80102c04 80102b84 00000000 00000000 bd66d040 bd66d040 [ 66.755050] 9f60: 0000000c 0032ac08 bc469fa4 bc469f78 800e8074 800e7bb4 00000000 00000000 [ 66.763253] 9f80: 76ec85e0 0000000c 0032ac08 00000004 8000ed64 00000000 00000000 bc469fa8 [ 66.771455] 9fa0: 8000eba0 800e803c 76ec85e0 0000000c 00000001 0032ac08 0000000c 00000000 [ 66.779659] 9fc0: 76ec85e0 0000000c 0032ac08 00000004 7ee29a9c 000ad08c 00000000 003402e8 [ 66.787862] 9fe0: 0000000c 7ee29a20 76e3796d 76e706bc 40000010 00000001 00000000 00000000 [ 66.796052] Backtrace: [ 66.798558] [<803608f4>] (ipu_dp_put) from [<804df730>] (ipu_plane_dpms+0x60/0x8c) [ 66.806159] [<804df6d0>] (ipu_plane_dpms) from [<804df788>] (ipu_disable_plane+0x2c/0x64) [ 66.814352] r5:bd94a000 r4:bd943c00 [ 66.818002] [<804df75c>] (ipu_disable_plane) from [<804df7e8>] (ipu_plane_destroy+0x28/0x64) [ 66.826456] r4:bd943c00 r3:00000000 [ 66.830112] [<804df7c0>] (ipu_plane_destroy) from [<8034e5b8>] (drm_mode_config_cleanup+0x1d0/0x274) [ 66.839260] r4:bd943e00 r3:804df7c0 [ 66.842921] [<8034e3e8>] (drm_mode_config_cleanup) from [<804dc750>] (imx_drm_driver_unload+0x44/0x58) [ 66.852243] r10:bd5a4a00 r9:bd5a4a0c r8:0000000c r7:806ec3c0 r6:be1a3010 r5:bd932a90 [ 66.860210] r4:bd94a000 r3:bc697500 [ 66.863870] [<804dc70c>] (imx_drm_driver_unload) from [<80345cdc>] (drm_dev_unregister+0x2c/0xa0) [ 66.872758] r5:bd94a000 r4:bd94a000 [ 66.876411] [<80345cb0>] (drm_dev_unregister) from [<803467a0>] (drm_put_dev+0x30/0x6c) [ 66.884431] r6:be1a3010 r5:80965ec0 r4:bd94a000 r3:00000000 [ 66.890214] [<80346770>] (drm_put_dev) from [<804dc6e8>] (imx_drm_unbind+0x14/0x18) [ 66.897886] r4:bd930a40 r3:804dc6d4 [ 66.901542] [<804dc6d4>] (imx_drm_unbind) from [<80362c80>] (take_down_master+0x2c/0x4c) [ 66.909663] [<80362c54>] (take_down_master) from [<80362d28>] (component_del+0x88/0xd0) [ 66.917682] r4:bd932100 r3:bd930fc0 [ 66.921334] [<80362ca0>] (component_del) from [<804e00f8>] (imx_hdmi_platform_remove+0x18/0x24) [ 66.930048] r7:0000000c r6:809661f8 r5:80987574 r4:be1a3010 [ 66.935838] [<804e00e0>] (imx_hdmi_platform_remove) from [<80368ac0>] (platform_drv_remove+0x20/0x24) [ 66.945089] [<80368aa0>] (platform_drv_remove) from [<8036721c>] (__device_release_driver+0x78/0xcc) [ 66.954251] [<803671a4>] (__device_release_driver) from [<80367298>] (device_release_driver+0x28/0x34) [ 66.963572] r5:be1a3010 r4:be1a3044 [ 66.967221] [<80367270>] (device_release_driver) from [<80366398>] (unbind_store+0x64/0x9c) [ 66.975588] r5:80987574 r4:be1a3010 [ 66.979246] [<80366334>] (unbind_store) from [<80365acc>] (drv_attr_store+0x28/0x34) [ 66.987005] r7:bc469f78 r6:bd4fc580 r5:0000000c r4:bd5a4a00 [ 66.992793] [<80365aa4>] (drv_attr_store) from [<8014b224>] (sysfs_kf_write+0x54/0x58) [ 67.000741] [<8014b1d0>] (sysfs_kf_write) from [<8014a564>] (kernfs_fop_write+0xc8/0x188) [ 67.008933] r6:bd4fc580 r5:00000000 r4:00000000 r3:8014b1d0 [ 67.014722] [<8014a49c>] (kernfs_fop_write) from [<800e7c50>] (vfs_write+0xa8/0x1b0) [ 67.022482] r10:0032ac08 r9:bc468000 r8:0000000c r7:bc469f78 r6:0032ac08 r5:0000000c [ 67.030450] r4:bd66d040 [ 67.033037] [<800e7ba8>] (vfs_write) from [<800e8074>] (SyS_write+0x44/0x90) [ 67.040102] r10:0032ac08 r8:0000000c r7:bd66d040 r6:bd66d040 r5:00000000 r4:00000000 [ 67.048092] [<800e8030>] (SyS_write) from [<8000eba0>] (ret_fast_syscall+0x0/0x48) [ 67.055677] r10:00000000 r8:8000ed64 r7:00000004 r6:0032ac08 r5:0000000c r4:76ec85e0 [ 67.063656] Code: e1a0c00d e92dd800 e24cb004 e3a03000 (e5c03004) [ 67.069914] ---[ end trace d739aae75ff0ad16 ]--- From the call stack, the issue is caused by that ipu_dp_put() is called from ipu_plane_dpms() with ipu_plane->dp being NULL. Rather than being called unconditionally, ipu_dp_put() should be called only when ipu_plane->dp is valid, just like what ipu_plane_put_resources() does. Acutally, all those ipu_*_put() calls in ipu_plane_dpms() are unnecessary, because the only occurrence of ipu_plane_dpms() with 'mode' not being DRM_MODE_DPMS_ON is from function ipu_disable_plane(), which already has a ipu_plane_put_resources() call right after ipu_plane_dpms(). The patch fixes above kernel Oops by removing those buggy and unnecessary ipu_*_put() calls from ipu_plane_dpms(). And consequently, function ipu_plane_dpms() can just be completely removed by having callers of ipu_plane_dpms() directly call ipu_plane_enable() and ipu_plane_disable() as needed. Signed-off-by: Philipp Zabel Signed-off-by: Shawn Guo --- drivers/staging/imx-drm/ipuv3-plane.c | 28 ++++------------------------ 1 file changed, 4 insertions(+), 24 deletions(-) diff --git a/drivers/staging/imx-drm/ipuv3-plane.c b/drivers/staging/imx-drm/ipuv3-plane.c index 6f393a11f44d..06a0cb9c6b26 100644 --- a/drivers/staging/imx-drm/ipuv3-plane.c +++ b/drivers/staging/imx-drm/ipuv3-plane.c @@ -263,28 +263,6 @@ void ipu_plane_disable(struct ipu_plane *ipu_plane) ipu_dp_disable(ipu_plane->ipu); } -static void ipu_plane_dpms(struct ipu_plane *ipu_plane, int mode) -{ - bool enable; - - DRM_DEBUG_KMS("mode = %d", mode); - - enable = (mode == DRM_MODE_DPMS_ON); - - if (enable == ipu_plane->enabled) - return; - - if (enable) { - ipu_plane_enable(ipu_plane); - } else { - ipu_plane_disable(ipu_plane); - - ipu_idmac_put(ipu_plane->ipu_ch); - ipu_dmfc_put(ipu_plane->dmfc); - ipu_dp_put(ipu_plane->dp); - } -} - /* * drm_plane API */ @@ -318,7 +296,8 @@ static int ipu_update_plane(struct drm_plane *plane, struct drm_crtc *crtc, plane->crtc, crtc); plane->crtc = crtc; - ipu_plane_dpms(ipu_plane, DRM_MODE_DPMS_ON); + if (!ipu_plane->enabled) + ipu_plane_enable(ipu_plane); return 0; } @@ -329,7 +308,8 @@ static int ipu_disable_plane(struct drm_plane *plane) DRM_DEBUG_KMS("[%d] %s\n", __LINE__, __func__); - ipu_plane_dpms(ipu_plane, DRM_MODE_DPMS_OFF); + if (ipu_plane->enabled) + ipu_plane_disable(ipu_plane); ipu_plane_put_resources(ipu_plane);