From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756226AbcINDUo (ORCPT ); Tue, 13 Sep 2016 23:20:44 -0400 Received: from bh-25.webhostbox.net ([208.91.199.152]:35153 "EHLO bh-25.webhostbox.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751091AbcINDUm (ORCPT ); Tue, 13 Sep 2016 23:20:42 -0400 From: Guenter Roeck Subject: Crashing 'kzm' target in next-20160913 due to 'gpio: mxc: shift gpio_mxc_init() to subsys_initcall level' Cc: "linux-kernel@vger.kernel.org" , Greg Kroah-Hartman , Vladimir Zapolskiy , Shawn Guo , Linus Walleij To: Vladimir Zapolskiy Message-ID: <9befb559-499a-dd70-cd44-60d5fce2e5d6@roeck-us.net> Date: Tue, 13 Sep 2016 20:20:35 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Authenticated_sender: linux@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - vger.kernel.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: linux@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: linux@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Vladimir, your commit e188cbf7564f ("gpio: mxc: shift gpio_mxc_init() to subsys_initcall level") in -next causes the following crash when running the 'kzm' target (and most likely the real thing) with qemu. [ 1.211426] Unable to handle kernel NULL pointer dereference at virtual address 0000000c [ 1.211600] pgd = c0004000 [ 1.211680] [0000000c] *pgd=00000000 [ 1.212067] Internal error: Oops: 5 [#1] SMP ARM [ 1.212245] Modules linked in: [ 1.212542] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.8.0-rc6-next-20160913 #1 [ 1.212671] Hardware name: Kyoto Microcomputer Co., Ltd. KZM-ARM11-01 [ 1.212825] task: c6848000 task.stack: c683e000 [ 1.213231] PC is at platform_get_irq+0xc0/0xe8 See http://kerneltests.org/builders/qemu-arm-next/builds/525/steps/qemubuildcommand/logs/stdio for a complete log. Problem is quite subtle. The change causes the gpio driver to be installed later. As a result, kzm_init_smsc9118() fails to initialize the gpio pins correctly. gpio_request() in that function returns -EPROBE_DEFER, which is ignored, gpio_to_irq() then returns -22 which is unconditionally assigned as interrupt number. platform_get_irq(), as called from the smsc driver, gets this negative interrupt number, and passes it unconditionally to irq_get_irq_data(), which returns NULL. The NULL pointer is then passed to irqd_set_trigger_type() which, not entirely surprisingly, crashes. So, in other words, lots of bugs here. Nevertheless, I would suggest to keep using postcore_initcall(), at least until it is sure that all gpio clients handle -EPROBE_DEFER correctly. Thanks, Guenter