Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2143030pxk; Sat, 3 Oct 2020 09:31:53 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZmY+rTapTs/KbA5wZIYlUb/7LwACNs+iS6ct0T1aNuiNz7nIhpbhkCqmQz0RU/txY9riB X-Received: by 2002:aa7:cf99:: with SMTP id z25mr4933135edx.139.1601742713374; Sat, 03 Oct 2020 09:31:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601742713; cv=none; d=google.com; s=arc-20160816; b=aoFJ3xRXLrEeGqvvUVDeCd2f87zISc8EYVd0SQ8WLu6fFuK/HKa4QEqQzg6nDbCXcL yT/iLjH3KErQldAoeRFrnHxxYIpeDJfnE2/6Zo6HCjddaBkznrK/qafbRrUwBtZK+EI1 sFlqOgRrDqXLIbLm+gOJ3EDr/eFHsvOLcFg0B+H+H52aMDROdBtSyeKJTUB/rj0BSEiT fuiNdqFjhz+8/Ek6YdEzFoTbO0sHmVV2INPD1xPMJx0vbGigzf/Fm02Zk/QOQPyd41if j1Suq5ZrQWODa6iusBu4kMuVobBSS7T1yphBVxtst0JnqlkDC61vOw8jYu5WB17IpA7F 3Jew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=TA0oD8jJw+LkQ5vHfPBXWjnJlwzWARU2bgJJP02kwPY=; b=BHQZV8Pwgv7Jo+ikdyQBJ6u/a60DSm/KkU+lE5ZGkVAu/Ndpn3b06lJBvh8ueCk3M2 EYw04ZhKp1TevELp9+Xfhzrwu02QMzhrdeqhwXChWNStK96wX0uxDcranDygqQx/YEkR cLOxh2i4qeKMw27YdRJlN7Jd2HFDhjut3Jb0oEFAajfOEB2vQzgTIJaC6cio3f5RXy+V BAujZTH+msgHz0tPPk9Be4v1vOOdjoE4icei36mk7cfkzSD+Q5QQS+gjYvrLeqJ7yGti F+eV3gxOJ/QoLq4wDfXjyIkKMhcywnFFkJL91ER4Mt68yxZEyznl9Z1h3EFg231JdPad +HAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AhPsyEan; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id g12si1202711ejx.495.2020.10.03.09.31.28; Sat, 03 Oct 2020 09:31:53 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=AhPsyEan; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725804AbgJCQ2L (ORCPT + 99 others); Sat, 3 Oct 2020 12:28:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40014 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725797AbgJCQ2L (ORCPT ); Sat, 3 Oct 2020 12:28:11 -0400 Received: from mail-ua1-x941.google.com (mail-ua1-x941.google.com [IPv6:2607:f8b0:4864:20::941]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 17BDEC0613D0 for ; Sat, 3 Oct 2020 09:28:11 -0700 (PDT) Received: by mail-ua1-x941.google.com with SMTP id d18so1216839uav.4 for ; Sat, 03 Oct 2020 09:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TA0oD8jJw+LkQ5vHfPBXWjnJlwzWARU2bgJJP02kwPY=; b=AhPsyEanmy1bCVOGOLncwlr8WBiN5rysP+bzPJ9hn2duKdpOKaUM+7fYOJyuMz8asS JsO1XOC2ZoaaY6mxBS2jUKvi2PqZz5Oene4kc/Hg1xm/BHI+mdc2wURPC3sPweEC/fIg vjpXckxvWxCFmy3+m0uRmtewBwKZyzgLYcNxM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TA0oD8jJw+LkQ5vHfPBXWjnJlwzWARU2bgJJP02kwPY=; b=NnnqiVH5KTh6D62LR0IjfJwCLUDZexd6E69bkciIopqoKHdMd9y3LHEkWUPaiFwaT9 gUTRsFrwj7GNDfbPOoTHnaeOPP5F6cTU+RJ5JxqKaha+ub1wJweHK7aaCtpXJFak/AJP M2WjTHaj5BGTOovQZZd+OSK4angz19S5ho+zk4YDcjWLE0Q4ohJk1JQeBmXGg/O2iHYY gHKBw7n/n5brsdiEi4g6SP0mek7ihz4Fp0yD1+8ZUs0UuARkaE4vRELBsj7IOKvIRQOv dIxB0hxMSZJ5D27zqYAjofJ1sxAPjOp+qMsNOwu3GJmYXzwJ6So/LyYLUrwHmYS3RNS5 tW3g== X-Gm-Message-State: AOAM530lmIYbFyM0YmtEmpfLofMY/zLdbfRy8tl35BVGOTAoixlDJAey +0vxhw8shDU31NYoqhR7RYMOTqkmnENnXw== X-Received: by 2002:ab0:5a22:: with SMTP id l31mr3891342uad.32.1601742489300; Sat, 03 Oct 2020 09:28:09 -0700 (PDT) Received: from mail-vs1-f53.google.com (mail-vs1-f53.google.com. [209.85.217.53]) by smtp.gmail.com with ESMTPSA id h14sm756371vsp.18.2020.10.03.09.28.08 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 03 Oct 2020 09:28:08 -0700 (PDT) Received: by mail-vs1-f53.google.com with SMTP id 5so2032697vsu.5 for ; Sat, 03 Oct 2020 09:28:08 -0700 (PDT) X-Received: by 2002:a05:6102:2f7:: with SMTP id j23mr1525181vsj.37.1601742487724; Sat, 03 Oct 2020 09:28:07 -0700 (PDT) MIME-Version: 1.0 References: <20200902160002.1.I658d1c0db9adfeb9a59bc55e96a19e192c959e55@changeid> <20201003150633.23416-1-michael@walle.cc> In-Reply-To: <20201003150633.23416-1-michael@walle.cc> From: Doug Anderson Date: Sat, 3 Oct 2020 09:27:56 -0700 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH] mtd: spi-nor: Prefer asynchronous probe To: Michael Walle Cc: LKML , linux-mtd@lists.infradead.org, miquel.raynal@bootlin.com, richard@nod.at, tudor.ambarus@microchip.com, vigneshr@ti.com Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Sat, Oct 3, 2020 at 8:22 AM Michael Walle wrote: > > Hi Douglas, > > > On my system the spi_nor_probe() took ~6 ms at bootup. That's not a > > lot, but every little bit adds up to a slow bootup. While we can get > > this out of the boot path by making it a module, there are times where > > it is convenient (or even required) for this to be builtin the kernel. > > Let's set that we prefer async probe so that we don't block other > > drivers from probing while we are probing. > > > > This is a tiny little change that is almost guaranteed to be safe for > > anything that is able to run as a module, which SPI_NOR is. > > Specifically modules are already probed asynchronously. Also: since > > other things in the system may have enabled asynchronous probe the > > system may already be doing other things during our probe. > > > > There is a small possibility that some other driver that was a client > > of SPI_NOR didn't handle -EPROBE_DEFER and was relying on probe > > ordering and only worked when the SPI_NOR and the SPI bus were > > builtin. In that case the other driver has a bug that's waiting to > > hit and the other driver should be fixed. > > linux-next now triggers the following warning in kernel/kmod.c:136 on my > board. I've bisected this to this patch. > > kmod.c: > /* > * We don't allow synchronous module loading from async. Module > * init may invoke async_synchronize_full() which will end up > * waiting for this task which already is waiting for the module > * loading to complete, leading to a deadlock. > */ > WARN_ON_ONCE(wait && current_is_async()); > > [ 1.849801] ------------[ cut here ]------------ > [ 1.854271] mscc_felix 0000:00:00.5: device is disabled, skipping > [ 1.858753] WARNING: CPU: 1 PID: 7 at kernel/kmod.c:136 __request_module+0x3a4/0x568 > [ 1.858755] Modules linked in: > [ 1.865028] fsl_enetc 0000:00:00.0: Adding to iommu group 1 > [ 1.872640] CPU: 1 PID: 7 Comm: kworker/u4:0 Not tainted 5.9.0-rc6-00001-g03edda0e1eda #113 > [ 1.872642] Hardware name: Kontron SMARC-sAL28 (Single PHY) on SMARC Eval 2.0 carrier (DT) > [ 1.872647] Workqueue: events_unbound async_run_entry_fn > [ 1.876013] spi-nor spi0.0: w25q32dw (4096 Kbytes) > [ 1.881294] pstate: 00000005 (nzcv daif -PAN -UAO BTYPE=--) > [ 1.881297] pc : __request_module+0x3a4/0x568 > [ 1.881299] lr : __request_module+0x39c/0x568 > [ 1.881302] sp : ffff8000113a3920 > [ 1.925739] x29: ffff8000113a3920 x28: ffff800010c7b000 > [ 1.931068] x27: ffff00207ae05648 x26: ffff800010a41a88 > [ 1.936397] x25: 0000000000000000 x24: 0000000000000000 > [ 1.941727] x23: ffff800010c35140 x22: 0000000000000001 > [ 1.947055] x21: ffff800011149948 x20: ffff800010615bdc > [ 1.952383] x19: 00000000ffffffff x18: 0000000000000000 > [ 1.957447] fsl_enetc 0000:00:00.0: enabling device (0400 -> 0402) > [ 1.957711] x17: ffff800010a3e618 x16: ffff800010a3e5f8 > [ 1.964175] libphy: Freescale ENETC MDIO Bus: probed > [ 1.969238] x15: ffffffffffffffff x14: ffff800011149948 > [ 1.969241] x13: ffff8000113a3918 x12: 0000000000000018 > [ 1.969245] x11: 0000000000000005 x10: 0101010101010101 > [ 1.975241] 10 fixed-partitions partitions found on MTD device 20c0000.spi > [ 1.979550] x9 : ffff80001005f6a4 x8 : 0000000000000000 > [ 1.979553] x7 : 606f2c6364776865 x6 : 05041c090d431511 > [ 1.979556] x5 : 1115430d091c0405 x4 : 0000000000000000 > [ 1.979558] x3 : 6dac8d8d2dccae00 x2 : ffff800010c956e8 > [ 1.979561] x1 : ffff80001005fa58 x0 : 0000000000000001 > [ 1.979564] Call trace: > [ 1.979571] __request_module+0x3a4/0x568 > [ 1.984914] Creating 10 MTD partitions on "20c0000.spi": > [ 1.990227] parse_mtd_partitions+0x2ec/0x3c0 > [ 1.990232] mtd_device_parse_register+0xdc/0x1c8 > [ 1.997133] 0x000000000000-0x000000010000 : "rcw" > [ 2.002454] spi_nor_probe+0x29c/0x2f0 > [ 2.002458] spi_mem_probe+0x74/0xb0 > [ 2.017759] 0x000000010000-0x000000100000 : "failsafe bootloader" > [ 2.018433] spi_drv_probe+0x88/0xe8 > [ 2.018439] really_probe+0xec/0x3c0 > [ 2.033744] 0x000000100000-0x000000140000 : "failsafe DP firmware" > [ 2.035555] driver_probe_device+0x60/0xc0 > [ 2.035559] __device_attach_driver+0x8c/0xd0 > [ 2.040455] 0x000000140000-0x0000001e0000 : "failsafe trusted firmware" > [ 2.044642] bus_for_each_drv+0x84/0xd8 > [ 2.044645] __device_attach_async_helper+0xc4/0xe8 > [ 2.044648] async_run_entry_fn+0x4c/0x150 > [ 2.044653] process_one_work+0x1f4/0x4b8 > [ 2.057751] 0x0000001e0000-0x000000200000 : "reserved" > [ 2.062814] worker_thread+0x50/0x480 > [ 2.062817] kthread+0x160/0x168 > [ 2.062821] ret_from_fork+0x10/0x34 > [ 2.073748] 0x000000200000-0x000000210000 : "configuration store" > [ 2.076185] ---[ end trace 44224cc02e4e53d2 ]--- > > -michael Thanks for your report! My vote would be to revert my patch and then this would need to be resolved before it could be added back in. Without doing tons of research, maybe the right answer here is that mtd_device_parse_register() should be moved into a separate task so it's not blocking probe? I probably won't try to tackle this immediately, but the eventual goal is that async is default, so I think this would need to be resolved before then. -Doug