Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp766261pxk; Wed, 9 Sep 2020 19:41:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyJUux11h5etnEp2s4dbOED4oFotNccBFT8jkSOx8MYO46j3fN1W7976uCLf9CVXwgKeZNm X-Received: by 2002:a05:6402:1110:: with SMTP id u16mr7155510edv.253.1599705712157; Wed, 09 Sep 2020 19:41:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1599705712; cv=none; d=google.com; s=arc-20160816; b=AhSRopYdKJ3N/TEFbwkM3oSLQF3TlXm0uXquzahelYnGjy4Si3e3k7Jhyka6KPQku/ WrgrV3aKK/tt/H/atJF+X/JrKH/fa/sRYBuUZlEGuKNUtbRhit1Nr1LmMVNL98lDKUz0 yCoPpJOtw5opvBHdQwSI3yYgDwip9u7wM8Dfw48CD1SBg//2bTpt0blGqcWJ9P4Ast/x kPXK/X8NOzbunRhZIntlJjHJF5hE/gGCqIfxQcKJmEsVJfoJNdaDqPAmj7k4/0cRun9Q JeGaFY9k6+4D8EtViuKuR+wpVXbhmMO+FK9neb2nGZvf9aQVWnH9I/VcTSwDuwtf030n ogeQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=wVRc5EUIeLIUeZBaPeJVhufwCu6sGOiho/gh6Y61R0w=; b=j8Ma2SIq/vqeM/JyOBNaPa9LWTXCb7NgrZaYbMIh82w3Lxy4QOSUmA3KnNjVUwnPe4 p8JHXSnrdQA4X8e2IzbCF0RmkHhrs93ideQHKXAMvxwa92OrEehzCtIHoaVGuaCrci8e Gfrl4DkHhTEht8mhrLuy7b1abytm17BzwxBH3NC1vS/JrGJF7JHU/I6+wM/FyRJ/1/aV y0auhQBhfx4ulCuIVUZcT+8VBU7fceeVLgz96/s9tnjqUEWbSTQCzfZBRsBsyQY65PBC f+GUKK8iYdTwEZgKdDqYUvRn7hV4ovkwUodRkHL8Oicqdq5VVx8mQNkbGx7vD1aRuJcN PGXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="VYv3I/Yh"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id o21si2612360ejg.255.2020.09.09.19.41.29; Wed, 09 Sep 2020 19:41:52 -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=@kernel.org header.s=default header.b="VYv3I/Yh"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730665AbgIJCkm (ORCPT + 99 others); Wed, 9 Sep 2020 22:40:42 -0400 Received: from mail.kernel.org ([198.145.29.99]:48580 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727900AbgIJCH4 (ORCPT ); Wed, 9 Sep 2020 22:07:56 -0400 Received: from localhost (52.sub-72-107-123.myvzw.com [72.107.123.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 95A38207DE; Thu, 10 Sep 2020 02:07:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1599703663; bh=PzCYZ+ZLKI2hK96aTswj9Z4sauc8GxoDp1F2TjE+tOE=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=VYv3I/YhstRPVnokLdnVWzdsNEB1ztLKHEoSNek/X1wbb9C75U5e2kFDdYoRfUh6n 7wV0ZLeq204viip6RzvDMtL16b9T2WBMuOt7N+VUsi6oWmZVTm3Nm2Wk5DxCHha3RO e3qnBmRwYaZnRS0AYmbRxrGXRSF5b4vKevxvbnYg= Date: Wed, 9 Sep 2020 21:07:42 -0500 From: Bjorn Helgaas To: Xingxing Su Cc: Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, Mark Tomlinson , Florian Fainelli , Rob Herring , Scott Branden Subject: Re: [PATCH] PCI: Don't use Printk in raw_spinlocks Message-ID: <20200910020742.GA748627@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1596245149-28628-1-git-send-email-suxingxing@loongson.cn> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org [+cc Mark, Florian, Rob, Scott] On Sat, Aug 01, 2020 at 09:25:49AM +0800, Xingxing Su wrote: > Do not use printk in raw_spinlocks, > it will cause BUG: Invalid wait context. > > The trace reported by lockdep follows. > > [ 2.986113] ============================= > [ 2.986115] [ BUG: Invalid wait context ] > [ 2.986116] 5.8.0-rc1+ #11 Not tainted > [ 2.986118] ----------------------------- > [ 2.986120] swapper/0/1 is trying to lock: > [ 2.986122] ffffffff80f5ddd8 (console_owner){....}-{3:3}, at: console_unlock+0x284/0x820 > [ 2.986130] other info that might help us debug this: > [ 2.986132] context-{5:5} > [ 2.986134] 3 locks held by swapper/0/1: > [ 2.986135] #0: 98000007fa03c990 (&dev->mutex){....}-{0:0}, at: device_driver_attach+0x28/0x90 > [ 2.986144] #1: ffffffff80fb83a8 (pci_lock){....}-{2:2}, at: pci_bus_write_config_word+0x60/0xb8 > [ 2.986152] #2: ffffffff80f5ded0 (console_lock){+.+.}-{0:0}, at: vprintk_emit+0x1b0/0x3b8 > [ 2.986161] stack backtrace: > [ 2.986163] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 5.8.0-rc1+ #11 > [ 2.986164] Stack : 0000000000001d67 98000000030be9b0 0000000000000001 7b2aba74f6c4785b > [ 2.986172] 7b2aba74f6c4785b 0000000000000000 98000007f89cb438 ffffffff80e7dc80 > [ 2.986181] 0000000000000001 000000000000000a 0000000000000001 0000000000000001 > [ 2.986189] ffffffff80f4e156 fffffffffffffffd ffffffff80cc2d98 fffffffff8000000 > [ 2.986197] 0000000024000000 ffffffff80f40000 0000000000000000 0000000000000000 > [ 2.986205] ffffffff9500cce0 0000000000000000 ffffffff80f50000 ffffffff81546318 > [ 2.986213] ffffffff81c4c3c0 0000000000000018 ffffffffbc000000 0000000000000000 > [ 2.986221] ffffffff81340000 98000007f89c8000 98000007f89cb430 98000007f8a00000 > [ 2.986229] ffffffff806be568 0000000000000000 0000000000000000 0000000000000000 > [ 2.986237] 0000000000000000 0000000000000000 ffffffff80211c1c 7b2aba74f6c4785b > [ 2.986245] ... > [ 2.986250] Call Trace: > [ 2.986251] [] show_stack+0x9c/0x130 > [ 2.986253] [] dump_stack+0xe8/0x150 > [ 2.986255] [] __lock_acquire+0x570/0x3250 > [ 2.986257] [] lock_acquire+0x118/0x558 > [ 2.986259] [] console_unlock+0x2e4/0x820 > [ 2.986261] [] vprintk_emit+0x1c0/0x3b8 > [ 2.986263] [] dev_vprintk_emit+0x1c8/0x210 > [ 2.986265] [] dev_printk_emit+0x3c/0x60 > [ 2.986267] [] _dev_warn+0x5c/0x80 > [ 2.986269] [] pci_generic_config_write32+0x154/0x160 > [ 2.986271] [] pci_bus_write_config_word+0x84/0xb8 > [ 2.986273] [] pci_setup_device+0x22c/0x768 > [ 2.986275] [] pci_scan_single_device+0xc8/0x100 > [ 2.986277] [] pci_scan_slot+0xb0/0x178 > [ 2.986279] [] pci_scan_child_bus_extend+0x5c/0x370 > [ 2.986281] [] pci_scan_root_bus_bridge+0x6c/0xf0 > [ 2.986283] [] pci_host_probe+0x1c/0xd8 > [ 2.986285] [] platform_drv_probe+0x54/0xb8 > [ 2.986287] [] really_probe+0x130/0x388 > [ 2.986289] [] driver_probe_device+0x64/0xd8 > [ 2.986291] [] device_driver_attach+0x84/0x90 > [ 2.986293] [] __driver_attach+0xc8/0x128 > [ 2.986295] [] bus_for_each_dev+0x74/0xd8 > [ 2.986297] [] bus_add_driver+0x170/0x250 > [ 2.986299] [] driver_register+0x84/0x150 > [ 2.986301] [] do_one_initcall+0x98/0x458 > [ 2.986303] [] kernel_init_freeable+0x2c0/0x36c > [ 2.986305] [] kernel_init+0x10/0x128 > [ 2.986307] [] ret_from_kernel_thread+0x14/0x1c > > Signed-off-by: Xingxing Su > --- > drivers/pci/access.c | 3 --- > 1 file changed, 3 deletions(-) > > diff --git a/drivers/pci/access.c b/drivers/pci/access.c > index 79c4a2e..b3fc164 100644 > --- a/drivers/pci/access.c > +++ b/drivers/pci/access.c > @@ -160,9 +160,6 @@ int pci_generic_config_write32(struct pci_bus *bus, unsigned int devfn, > * write happen to have any RW1C (write-one-to-clear) bits set, we > * just inadvertently cleared something we shouldn't have. > */ > - dev_warn_ratelimited(&bus->dev, "%d-byte config write to %04x:%02x:%02x.%d offset %#x may corrupt adjacent RW1C bits\n", > - size, pci_domain_nr(bus), bus->number, > - PCI_SLOT(devfn), PCI_FUNC(devfn), where); We just changed this printk (see [1]), but I think we still have this lockdep problem even after Mark's change. So I guess we need another think about this. Maybe we can print something when registering pci_ops that use pci_generic_config_write32()? [1] https://git.kernel.org/pub/scm/linux/kernel/git/helgaas/pci.git/commit/?h=pci/enumeration&id=92ff4b49c2a9 > mask = ~(((1 << (size * 8)) - 1) << ((where & 0x3) * 8)); > tmp = readl(addr) & mask; > -- > 2.1.0 >