Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754625AbdGCPal convert rfc822-to-8bit (ORCPT ); Mon, 3 Jul 2017 11:30:41 -0400 Received: from us-smtp-delivery-107.mimecast.com ([63.128.21.107]:21592 "EHLO us-smtp-delivery-107.mimecast.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753959AbdGCPag (ORCPT ); Mon, 3 Jul 2017 11:30:36 -0400 Subject: Re: [PATCH v9 2/3] PCI: Add tango PCIe host bridge support From: Marc Gonzalez To: Bjorn Helgaas CC: Marc Zyngier , Thomas Gleixner , linux-pci , Linux ARM , LKML , Mason , Thibaud Cornic , Mark Rutland , Ard Biesheuvel , Greg Kroah-Hartman , Ingo Molnar , Peter Zijlstra References: <987fac41-80dc-f1d0-ec0b-91ae57b91bfd@sigmadesigns.com> <20170702231811.GJ18324@bhelgaas-glaptop.roam.corp.google.com> <79382219-c730-da78-3e5f-5abf3173d7ac@sigmadesigns.com> Message-ID: Date: Mon, 3 Jul 2017 17:30:28 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Firefox/52.0 SeaMonkey/2.49.1 MIME-Version: 1.0 In-Reply-To: X-Originating-IP: [172.27.0.114] X-MC-Unique: PomGeTOTPQuEx-6O5QKQdg-1 Content-Type: text/plain; charset=WINDOWS-1252 Content-Transfer-Encoding: 8BIT Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 7129 Lines: 113 On 03/07/2017 15:13, Marc Gonzalez wrote: > On 03/07/2017 11:54, Marc Gonzalez wrote: > >> Mark Rutland points out stop_machine. I will test this solution. > > I must be misunderstanding some of the requirements for > calling stop_machine() because my kernel panics, after > many warnings. Enabling several kernel debugging features: +CONFIG_DEBUG_KERNEL=y +CONFIG_DEBUG_RT_MUTEXES=y +CONFIG_DEBUG_WW_MUTEX_SLOWPATH=y +CONFIG_PROVE_LOCKING=y And at the end of smp8759_config_read: printk("in_atomic_preempt_off = %d\n", in_atomic_preempt_off()); stop_machine(do_nothing, NULL, NULL); panic("STOP HERE FOR NOW\n"); The kernel outputs: [ 1.022725] in_atomic_preempt_off = 0 [ 1.026568] BUG: scheduling while atomic: swapper/0/1/0x00000002 [ 1.032625] 5 locks held by swapper/0/1: [ 1.036575] #0: (&dev->mutex){......}, at: [] __driver_attach+0x50/0xd0 [ 1.044319] #1: (&dev->mutex){......}, at: [] __driver_attach+0x60/0xd0 [ 1.052050] #2: (pci_lock){+.+...}, at: [] pci_bus_read_config_dword+0x44/0x94 [ 1.060398] #3: (cpu_hotplug.dep_map){++++++}, at: [] get_online_cpus+0x2c/0xa0 [ 1.068843] #4: (stop_cpus_mutex){+.+...}, at: [] stop_cpus+0x20/0x48 [ 1.076404] Modules linked in: [ 1.079483] Preemption disabled at:[ 1.082820] [< (null)>] (null) [ 1.086165] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.9.23-1-rc4 #13 [ 1.092723] Hardware name: Sigma Tango DT [ 1.096765] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 1.104558] [] (show_stack) from [] (dump_stack+0x98/0xc4) [ 1.111823] [] (dump_stack) from [] (__schedule_bug+0x94/0xec) [ 1.119436] [] (__schedule_bug) from [] (__schedule+0x4a4/0x5f0) [ 1.127220] [] (__schedule) from [] (schedule+0x4c/0xac) [ 1.134308] [] (schedule) from [] (schedule_timeout+0x1f4/0x30c) [ 1.142093] [] (schedule_timeout) from [] (wait_for_common+0x8c/0x13c) [ 1.150401] [] (wait_for_common) from [] (wait_for_completion+0x10/0x14) [ 1.158886] [] (wait_for_completion) from [] (__stop_cpus+0x50/0x64) [ 1.167021] [] (__stop_cpus) from [] (stop_cpus+0x30/0x48) [ 1.174282] [] (stop_cpus) from [] (stop_machine+0x84/0x118) [ 1.181719] [] (stop_machine) from [] (smp8759_config_read+0x84/0x90) [ 1.189942] [] (smp8759_config_read) from [] (pci_bus_read_config_dword+0x6c/0x94) [ 1.199301] [] (pci_bus_read_config_dword) from [] (pci_bus_read_dev_vendor_id+0x24/0xe8) [ 1.209270] [] (pci_bus_read_dev_vendor_id) from [] (pci_scan_single_device+0x40/0xb0) [ 1.218977] [] (pci_scan_single_device) from [] (pci_scan_slot+0x58/0x100) [ 1.227636] [] (pci_scan_slot) from [] (pci_scan_child_bus+0x20/0xf8) [ 1.235858] [] (pci_scan_child_bus) from [] (pci_scan_root_bus_msi+0xcc/0xd8) [ 1.244779] [] (pci_scan_root_bus_msi) from [] (pci_scan_root_bus+0x18/0x20) [ 1.253612] [] (pci_scan_root_bus) from [] (pci_host_common_probe+0xc8/0x314) [ 1.262533] [] (pci_host_common_probe) from [] (tango_pcie_probe+0x148/0x350) [ 1.271455] [] (tango_pcie_probe) from [] (platform_drv_probe+0x34/0x6c) [ 1.279939] [] (platform_drv_probe) from [] (really_probe+0x1c4/0x250) [ 1.288248] [] (really_probe) from [] (__driver_attach+0xcc/0xd0) [ 1.296121] [] (__driver_attach) from [] (bus_for_each_dev+0x68/0x9c) [ 1.304342] [] (bus_for_each_dev) from [] (driver_attach+0x1c/0x20) [ 1.312389] [] (driver_attach) from [] (bus_add_driver+0x108/0x214) [ 1.320436] [] (bus_add_driver) from [] (driver_register+0x78/0xf4) [ 1.328483] [] (driver_register) from [] (__platform_driver_register+0x40/0x48) [ 1.337583] [] (__platform_driver_register) from [] (tango_pcie_driver_init+0x14/0x18) [ 1.347291] [] (tango_pcie_driver_init) from [] (do_one_initcall+0x44/0x174) [ 1.356128] [] (do_one_initcall) from [] (kernel_init_freeable+0x154/0x1e0) [ 1.364875] [] (kernel_init_freeable) from [] (kernel_init+0x8/0x10c) [ 1.373097] [] (kernel_init) from [] (ret_from_fork+0x14/0x24) [ 1.380799] Kernel panic - not syncing: STOP HERE FOR NOW [ 1.380799] [ 1.387714] CPU: 0 PID: 1 Comm: swapper/0 Tainted: G W 4.9.23-1-rc4 #13 [ 1.395495] Hardware name: Sigma Tango DT [ 1.399529] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 1.407317] [] (show_stack) from [] (dump_stack+0x98/0xc4) [ 1.414582] [] (dump_stack) from [] (panic+0xe0/0x258) [ 1.421494] [] (panic) from [] (tango_check_pcie_link+0x0/0x48) [ 1.429192] [] (tango_check_pcie_link) from [] (smp8759_config_read+0x0/0x90) [ 1.438114] [] (smp8759_config_read) from [<00241105>] (0x241105) [ 1.445191] CPU1: stopping [ 1.447910] CPU: 1 PID: 0 Comm: swapper/1 Tainted: G W 4.9.23-1-rc4 #13 [ 1.455690] Hardware name: Sigma Tango DT [ 1.459724] [] (unwind_backtrace) from [] (show_stack+0x10/0x14) [ 1.467512] [] (show_stack) from [] (dump_stack+0x98/0xc4) [ 1.474774] [] (dump_stack) from [] (handle_IPI+0x19c/0x1b0) [ 1.482210] [] (handle_IPI) from [] (gic_handle_irq+0x88/0x8c) [ 1.489819] [] (gic_handle_irq) from [] (__irq_svc+0x70/0xb0) [ 1.497339] Exception stack(0xdf46ff80 to 0xdf46ffc8) [ 1.502415] ff80: 00000001 00000001 00000000 df468180 df46e000 c1004be4 c1004c48 00000002 [ 1.510636] ffa0: c100f990 413fc090 00000000 00000000 00000000 df46ffd0 c0165ee0 c0108240 [ 1.518853] ffc0: 20000113 ffffffff [ 1.522358] [] (__irq_svc) from [] (arch_cpu_idle+0x24/0x3c) [ 1.529795] [] (arch_cpu_idle) from [] (default_idle_call+0x20/0x30) [ 1.537934] [] (default_idle_call) from [] (cpu_startup_entry+0xd0/0x150) [ 1.546504] [] (cpu_startup_entry) from [] (secondary_start_kernel+0x158/0x164) [ 1.555599] [] (secondary_start_kernel) from [<801015ac>] (0x801015ac) [ 1.563063] ---[ end Kernel panic - not syncing: STOP HERE FOR NOW The panic call stack looks suspicious. smp8759_config_read() never calls tango_check_pcie_link(). (I compile with -fno-optimize-sibling-calls to get more accurate call stacks.) in_atomic_preempt_off is false before calling stop_machine() I suppose I'm doing something wrong, but I'm not sure what yet. Regards.