From patchwork Mon Aug 25 11:48:25 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shawn Guo X-Patchwork-Id: 4777221 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D0AFF9F2A9 for ; Tue, 26 Aug 2014 00:53:47 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 5EF38201C0 for ; Tue, 26 Aug 2014 00:53:45 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 0E853201DC for ; Tue, 26 Aug 2014 00:53:44 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id E2FE86E427; Mon, 25 Aug 2014 17:53:42 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from na01-bl2-obe.outbound.protection.outlook.com (mail-bl2lp0209.outbound.protection.outlook.com [207.46.163.209]) by gabe.freedesktop.org (Postfix) with ESMTP id D71046E351 for ; Mon, 25 Aug 2014 04:49:02 -0700 (PDT) Received: from CH1PR03CA011.namprd03.prod.outlook.com (10.255.156.156) by DM2PR03MB351.namprd03.prod.outlook.com (10.141.54.22) with Microsoft SMTP Server (TLS) id 15.0.1005.8; Mon, 25 Aug 2014 11:48:54 +0000 Received: from BN1BFFO11FD047.protection.gbl (10.255.156.132) by CH1PR03CA011.outlook.office365.com (10.255.156.156) with Microsoft SMTP Server (TLS) id 15.0.1015.19 via Frontend Transport; Mon, 25 Aug 2014 11:48:53 +0000 Received: from az84smr01.freescale.net (192.88.158.2) by BN1BFFO11FD047.mail.protection.outlook.com (10.58.145.2) with Microsoft SMTP Server (TLS) id 15.0.1010.11 via Frontend Transport; Mon, 25 Aug 2014 11:48:53 +0000 Received: from dragon.ap.freescale.net ([10.192.185.14]) by az84smr01.freescale.net (8.14.3/8.14.0) with ESMTP id s7PBmhVa004627; Mon, 25 Aug 2014 04:48:50 -0700 From: Shawn Guo To: Russell King Subject: [PATCH v2 1/2] imx-drm: imx-ldb: fix kernel Oops in imx_ldb_unbind() Date: Mon, 25 Aug 2014 19:48:25 +0800 Message-ID: <1408967306-2624-2-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)(189002)(199003)(21056001)(87936001)(4396001)(50226001)(26826002)(93916002)(69596002)(86362001)(68736004)(79102001)(106466001)(90102001)(64706001)(48376002)(97736001)(81342001)(83072002)(81156004)(88136002)(6806004)(80022001)(87286001)(19580395003)(20776003)(85306004)(19580405001)(84676001)(76176999)(575784001)(76482001)(105606002)(95666004)(104166001)(36756003)(47776003)(229853001)(102836001)(62966002)(46102001)(33646002)(85852003)(99396002)(74502001)(50986999)(81542001)(104016003)(83322001)(74662001)(31966008)(89996001)(44976005)(92726001)(50466002)(77982001)(110136001)(107046002)(92566001)(77156001); DIR:OUT; SFP:; SCL:1; SRVR:DM2PR03MB351; H:az84smr01.freescale.net; FPR:; MLV:ovrnspm; PTR:InfoDomainNonexistent; MX:1; A: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-Mailman-Approved-At: Mon, 25 Aug 2014 17:53:42 -0700 Cc: linux-arm-kernel@lists.infradead.org, Greg Kroah-Hartman , dri-devel@lists.freedesktop.org, kernel@pengutronix.de, Shawn Guo X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, 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-ldb driver on imx6q-sabresd board triggers a kernel Oops as below. $ echo 2000000.aips-bus\:ldb\@020e0008 > unbind [ 423.031003] Console: switching to colour dummy device 80x30 [ 423.052505] drm_kms_helper: drm: unregistered panic notifier [ 423.137082] Unable to handle kernel NULL pointer dereference at virtual address 0000001c [ 423.145185] pgd = bd6cc000 [ 423.147937] [0000001c] *pgd=4cd23831, *pte=00000000, *ppte=00000000 [ 423.154271] Internal error: Oops: 17 [#1] SMP ARM [ 423.158983] Modules linked in: [ 423.162067] CPU: 1 PID: 1854 Comm: bash Not tainted 3.17.0-rc1-00029-gd7473b0c2e59-dirty #397 [ 423.170599] task: be21f500 ti: bd446000 task.ti: bd446000 [ 423.176021] PC is at imx_ldb_unbind+0x28/0x50 [ 423.180393] LR is at component_unbind+0x38/0x70 [ 423.184932] pc : [<804dddd0>] lr : [<80362e5c>] psr: 20000013 [ 423.184932] sp : bd447d78 ip : bd447d98 fp : bd447d94 [ 423.196416] r10: bd7cbc00 r9 : bd7cbc0c r8 : 0000001e [ 423.201648] r7 : bd84d010 r6 : 000003a8 r5 : 00000001 r4 : bd84d010 [ 423.208181] r3 : 00000000 r2 : bd942000 r1 : be1a8410 r0 : bd84d020 [ 423.214717] Flags: nzCv IRQs on FIQs on Mode SVC_32 ISA ARM Segment user [ 423.221858] Control: 10c5387d Table: 4d6cc04a DAC: 00000015 [ 423.227611] Process bash (pid: 1854, stack limit = 0xbd446240) [ 423.233450] Stack: (0xbd447d78 to 0xbd448000) [ 423.237815] 7d60: bd931dc0 bd931b80 [ 423.246003] 7d80: bd942000 806ec058 bd447db4 bd447d98 80362e5c 804dddb4 bd8df400 be1a2c10 [ 423.254190] 7da0: bd931b80 bd931dc0 bd447dd4 bd447db8 80362f0c 80362e30 be21f500 bd942000 [ 423.262376] 7dc0: bd8ed910 be1a2c10 bd447dec bd447dd8 804dc740 80362ea0 bd942000 bd942000 [ 423.270563] 7de0: bd447e0c bd447df0 80345cdc 804dc718 00000000 bd942000 80965ec0 be1a2c10 [ 423.278749] 7e00: bd447e24 bd447e10 803467a0 80345cbc 804dc6d4 bd931b80 bd447e34 bd447e28 [ 423.286936] 7e20: 804dc6e8 8034677c bd447e4c bd447e38 80362c80 804dc6e0 80965ec0 bd931dc0 [ 423.295123] 7e40: bd447e6c bd447e50 80362d28 80362c60 be1a2c10 80987418 809661f8 0000001e [ 423.303310] 7e60: bd447e7c bd447e70 804dde10 80362cac bd447e8c bd447e80 80368ac0 804dde04 [ 423.311497] 7e80: bd447ea4 bd447e90 8036721c 80368aac be1a2c44 be1a2c10 bd447ebc bd447ea8 [ 423.319683] 7ea0: 80367298 803671b0 be1a2c10 80987418 bd447edc bd447ec0 80366398 8036727c [ 423.327870] 7ec0: bd7cbc00 0000001e bd7760c0 bd447f78 bd447eec bd447ee0 80365acc 80366340 [ 423.336056] 7ee0: bd447f0c bd447ef0 8014b224 80365ab0 8014b1d0 00000000 00000000 bd7760c0 [ 423.344254] 7f00: bd447f44 bd447f10 8014a564 8014b1dc 00000000 00000000 00000001 bd4d5900 [ 423.352457] 7f20: 0000001e 01a35c08 bd447f78 0000001e bd446000 01a35c08 bd447f74 bd447f48 [ 423.360660] 7f40: 800e7c50 8014a4a8 80102c04 80102b84 00000000 00000000 bd4d5900 bd4d5900 [ 423.368863] 7f60: 0000001e 01a35c08 bd447fa4 bd447f78 800e8074 800e7bb4 00000000 00000000 [ 423.377066] 7f80: 76f825e0 0000001e 01a35c08 00000004 8000ed64 00000000 00000000 bd447fa8 [ 423.385269] 7fa0: 8000eba0 800e803c 76f825e0 0000001e 00000001 01a35c08 0000001e 00000000 [ 423.393472] 7fc0: 76f825e0 0000001e 01a35c08 00000004 7eeb6a9c 000ad08c 00000000 01a4b888 [ 423.401674] 7fe0: 0000001e 7eeb6a20 76ef196d 76f2a6bc 40000010 00000001 00000000 00000000 [ 423.409864] Backtrace: [ 423.412372] [<804ddda8>] (imx_ldb_unbind) from [<80362e5c>] (component_unbind+0x38/0x70) [ 423.420479] r7:806ec058 r6:bd942000 r5:bd931b80 r4:bd931dc0 [ 423.426265] [<80362e24>] (component_unbind) from [<80362f0c>] (component_unbind_all+0x78/0xb0) [ 423.434893] r5:bd931dc0 r4:bd931b80 [ 423.438548] [<80362e94>] (component_unbind_all) from [<804dc740>] (imx_drm_driver_unload+0x34/0x58) [ 423.447610] r6:be1a2c10 r5:bd8ed910 r4:bd942000 r3:be21f500 [ 423.453401] [<804dc70c>] (imx_drm_driver_unload) from [<80345cdc>] (drm_dev_unregister+0x2c/0xa0) [ 423.462289] r5:bd942000 r4:bd942000 [ 423.465942] [<80345cb0>] (drm_dev_unregister) from [<803467a0>] (drm_put_dev+0x30/0x6c) [ 423.473963] r6:be1a2c10 r5:80965ec0 r4:bd942000 r3:00000000 [ 423.479748] [<80346770>] (drm_put_dev) from [<804dc6e8>] (imx_drm_unbind+0x14/0x18) [ 423.487420] r4:bd931b80 r3:804dc6d4 [ 423.491072] [<804dc6d4>] (imx_drm_unbind) from [<80362c80>] (take_down_master+0x2c/0x4c) [ 423.499195] [<80362c54>] (take_down_master) from [<80362d28>] (component_del+0x88/0xd0) [ 423.507214] r4:bd931dc0 r3:80965ec0 [ 423.510868] [<80362ca0>] (component_del) from [<804dde10>] (imx_ldb_remove+0x18/0x24) [ 423.518714] r7:0000001e r6:809661f8 r5:80987418 r4:be1a2c10 [ 423.524501] [<804dddf8>] (imx_ldb_remove) from [<80368ac0>] (platform_drv_remove+0x20/0x24) [ 423.532884] [<80368aa0>] (platform_drv_remove) from [<8036721c>] (__device_release_driver+0x78/0xcc) [ 423.542045] [<803671a4>] (__device_release_driver) from [<80367298>] (device_release_driver+0x28/0x34) [ 423.551367] r5:be1a2c10 r4:be1a2c44 [ 423.555015] [<80367270>] (device_release_driver) from [<80366398>] (unbind_store+0x64/0x9c) [ 423.563381] r5:80987418 r4:be1a2c10 [ 423.567034] [<80366334>] (unbind_store) from [<80365acc>] (drv_attr_store+0x28/0x34) [ 423.574794] r7:bd447f78 r6:bd7760c0 r5:0000001e r4:bd7cbc00 [ 423.580580] [<80365aa4>] (drv_attr_store) from [<8014b224>] (sysfs_kf_write+0x54/0x58) [ 423.588526] [<8014b1d0>] (sysfs_kf_write) from [<8014a564>] (kernfs_fop_write+0xc8/0x188) [ 423.596720] r6:bd7760c0 r5:00000000 r4:00000000 r3:8014b1d0 [ 423.602508] [<8014a49c>] (kernfs_fop_write) from [<800e7c50>] (vfs_write+0xa8/0x1b0) [ 423.610268] r10:01a35c08 r9:bd446000 r8:0000001e r7:bd447f78 r6:01a35c08 r5:0000001e [ 423.618234] r4:bd4d5900 [ 423.620819] [<800e7ba8>] (vfs_write) from [<800e8074>] (SyS_write+0x44/0x90) [ 423.627884] r10:01a35c08 r8:0000001e r7:bd4d5900 r6:bd4d5900 r5:00000000 r4:00000000 [ 423.635873] [<800e8030>] (SyS_write) from [<8000eba0>] (ret_fast_syscall+0x0/0x48) [ 423.643459] r10:00000000 r8:8000ed64 r7:00000004 r6:01a35c08 r5:0000001e r4:76f825e0 [ 423.651433] Code: e0247596 e2855001 e2840010 e59430a0 (e593301c) [ 423.657672] ---[ end trace 8e42829dfb82309e ]--- It's caused by that function imx_ldb_unbind() always tries to destroy both LDB channels without checking if both channels are created in imx_ldb_bind(). It's pretty often that only one of the LDB channels is created just like the case of imx6q-sabresd board, and the connector/encoder's destroy() function pointer of the other channel will be invalid. Fix the issue by checking if the LDB channel is actually created/valid before calling into its connector/encoder's destroy() function. Signed-off-by: Shawn Guo Acked-by: Philipp Zabel --- drivers/staging/imx-drm/imx-ldb.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/staging/imx-drm/imx-ldb.c b/drivers/staging/imx-drm/imx-ldb.c index 7e3f019d7e72..795794fff034 100644 --- a/drivers/staging/imx-drm/imx-ldb.c +++ b/drivers/staging/imx-drm/imx-ldb.c @@ -574,6 +574,8 @@ static void imx_ldb_unbind(struct device *dev, struct device *master, for (i = 0; i < 2; i++) { struct imx_ldb_channel *channel = &imx_ldb->channel[i]; + if (channel->ldb == NULL) + continue; channel->connector.funcs->destroy(&channel->connector); channel->encoder.funcs->destroy(&channel->encoder); }