From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on sa.local.altlinux.org X-Spam-Level: X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,RP_MATCHES_RCVD autolearn=ham autolearn_force=no version=3.4.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=basealt.ru; s=dkim; t=1777041224; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9r/+LQlHqsrG1dTgO+xMb/D75ne5J+4Pv97eiaLSnus=; b=tTfOLbUYOKvUVSJuC7hTh6Y5KP5XldW7wyQvT2lrhElKzUF3O5qH7JoDNg1C2GkvCraws1 nFH49NUsyZOGEteh/iAFZXn9JmRKML0mmurG3vr3OwPJiFWbnLi2Pmz5dJJUth9j8EiMmg 1481r+GZ15rz0NZ89yL49h78fgPnn6LZ3ekwpSpLt543s1fxkss1qVPllchfPFlr2QAxFP pP2JPV+yyWXpvScst+dnYtn1C2oD7qrf1IhNSO+h+em68lPjd02oPI21yKGObSWMQjHIAI y1/qGayQounST3ATT+Y7zhNad4SblOvMoBn/QXoHLCi5Z3EY+lbqXj04GSHT1g== From: Daniil Gnusarev To: gnusarevda@basealt.ru, devel-kernel@lists.altlinux.org Date: Fri, 24 Apr 2026 18:33:25 +0400 Message-ID: <20260424143329.427971-5-gnusarevda@basealt.ru> X-Mailer: git-send-email 2.42.2 In-Reply-To: <20260424143329.427971-1-gnusarevda@basealt.ru> References: <20260424143329.427971-1-gnusarevda@basealt.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [d-kernel] [PATCH 4/5] pci: baikal-pcie: use raw_spinlock for regmap of gbr registers X-BeenThere: devel-kernel@lists.altlinux.org X-Mailman-Version: 2.1.12 Precedence: list Reply-To: ALT Linux kernel packages development List-Id: ALT Linux kernel packages development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Apr 2026 14:33:52 -0000 Archived-At: List-Archive: List-Post: With the kasan debug options enabled, the following errors are observed in the kernel log: [ 4.564453] ============================= [ 4.568951] [ BUG: Invalid wait context ] [ 4.573451] 6.6.71+ #16 Not tainted [ 4.577368] ----------------------------- [ 4.581864] swapper/0/1 is trying to lock: [ 4.586461] ffff000801ef2018 (syscon:125:(&syscon_config)->lock){....}-{3:3}, at: regmap_lock_spinlock+0x20/0x48 [ 4.597931] other info that might help us debug this: [ 4.603599] context-{5:5} [ 4.606539] 2 locks held by swapper/0/1: [ 4.610943] #0: ffff0008019000f8 (&dev->mutex){....}-{4:4}, at: __driver_attach+0x154/0x308 [ 4.620459] #1: ffff8000841911f8 (pci_lock){....}-{2:2}, at: pci_bus_read_config_dword+0xac/0x160 [ 4.630558] stack backtrace: [ 4.633793] CPU: 1 PID: 1 Comm: swapper/0 Not tainted 6.6.71+ #16 [ 4.640634] Hardware name: Edelweiss TF307-MB-S-D/BM1BM1-D, BIOS 5.6 07/26/2022 [ 4.648836] Call trace: [ 4.651581] dump_backtrace+0xa4/0x130 [ 4.655796] show_stack+0x20/0x38 [ 4.659522] dump_stack_lvl+0x60/0xb0 [ 4.663638] dump_stack+0x1c/0x28 [ 4.667363] __lock_acquire+0xd24/0x2da8 [ 4.671775] lock_acquire+0x308/0x470 [ 4.675892] _raw_spin_lock_irqsave+0x80/0xb8 [ 4.680789] regmap_lock_spinlock+0x20/0x48 [ 4.685490] regmap_read+0x64/0xc0 [ 4.689314] bm1000_pcie_link_up+0x118/0x1b8 [ 4.694112] dw_pcie_link_up+0x44/0x90 [ 4.698324] dw_pcie_other_conf_map_bus+0x44/0x110 [ 4.703707] pci_generic_config_read+0x5c/0xf8 [ 4.708699] dw_pcie_rd_other_conf+0x58/0xf8 [ 4.713495] pci_bus_read_config_dword+0xe0/0x160 [ 4.718777] pci_bus_generic_read_dev_vendor_id+0x3c/0x228 [ 4.724939] pci_scan_single_device+0x114/0x1c0 [ 4.730029] pci_scan_slot+0xdc/0x2c0 [ 4.734144] pci_scan_child_bus_extend+0x58/0x3b0 [ 4.739429] pci_scan_bridge_extend+0x1e8/0x890 [ 4.744519] pci_scan_child_bus_extend+0x158/0x3b0 [ 4.749900] pci_scan_root_bus_bridge+0xa8/0x150 [ 4.755088] pci_host_probe+0x20/0xf0 [ 4.759203] dw_pcie_host_init+0x3e8/0x9e8 [ 4.763804] bm1000_add_pcie_port+0x130/0x3d8 [ 4.768698] baikal_pcie_probe+0x140/0x198 [ 4.773300] platform_probe+0x94/0x150 [ 4.777513] really_probe+0x254/0x5b8 [ 4.781627] __driver_probe_device+0xcc/0x238 [ 4.786520] driver_probe_device+0x64/0x1b0 [ 4.791219] __driver_attach+0x160/0x308 [ 4.795624] bus_for_each_dev+0xe4/0x168 [ 4.800035] driver_attach+0x3c/0x58 [ 4.804054] bus_add_driver+0x188/0x310 [ 4.808364] driver_register+0xb0/0x1f8 [ 4.812673] __platform_driver_register+0x4c/0x68 [ 4.817956] baikal_pcie_driver_init+0x28/0x40 [ 4.822951] do_one_initcall+0xe0/0x4c8 [ 4.827262] kernel_init_freeable+0x394/0x500 [ 4.832160] kernel_init+0x38/0x230 [ 4.836084] ret_from_fork+0x10/0x20 Caused by attempting to take spinlock while raw_spinlock is held. To fix, raw_spinlock is also used for regmap. Signed-off-by: Daniil Gnusarev Do-not-upstream: this is a feature of Baikal-M --- drivers/pci/controller/dwc/pcie-baikal-core.c | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-baikal-core.c b/drivers/pci/controller/dwc/pcie-baikal-core.c index a1de90e0ef6e1..7f597b8a17f94 100644 --- a/drivers/pci/controller/dwc/pcie-baikal-core.c +++ b/drivers/pci/controller/dwc/pcie-baikal-core.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -188,19 +189,39 @@ static int bm1000_get_resources(struct platform_device *pdev, struct bm1000_pcie *bm = platform_get_drvdata(pdev); struct device *dev = pci->dev; struct resource *res; + void __iomem *gpr_base; + struct device_node *gpr_syscon_node; bm->pci = pci; bm->gpr_offset = 0; - bm->gpr = syscon_regmap_lookup_by_compatible("baikal,bm1000-pcie-gpr"); - if (IS_ERR(bm->gpr)) { + gpr_syscon_node = of_find_compatible_node(NULL, NULL, "baikal,bm1000-pcie-gpr"); + if (!gpr_syscon_node) { dev_warn(dev, "failed to find PCIe GPR registers, trying LCRU\n"); - bm->gpr = syscon_regmap_lookup_by_phandle(dev->of_node, "baikal,pcie-lcru"); - if (IS_ERR(bm->gpr)) { + gpr_syscon_node = of_parse_phandle(dev->of_node, "baikal,pcie-lcru", 0); + if (!gpr_syscon_node) { dev_err(dev, "failed to find PCIe LCRU registers\n"); - return PTR_ERR(bm->gpr); + return -EINVAL; } bm->gpr_offset = BM1000_PCIE_GPR_OFFSET; } + if (!of_device_is_compatible(gpr_syscon_node, "syscon")) { + dev_err(dev, "failed to find PCIe GPR registers\n"); + of_node_put(gpr_syscon_node); + return -EINVAL; + } + + gpr_base = of_iomap(gpr_syscon_node, 0); + of_node_put(gpr_syscon_node); + if (!gpr_base) { + dev_err(dev, "failed to remap PCIe GPR registers\n"); + return -EINVAL; + } + + bm->gpr = devm_regmap_init_mmio(dev, gpr_base, &bm1000_pcie_syscon_regmap_config); + if (IS_ERR(bm->gpr)) { + dev_err(dev, "failed to init regmap for PCIe GPR registers\n"); + return PTR_ERR(bm->gpr); + } res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "dbi"); if (!res) { @@ -1117,7 +1138,9 @@ static struct regmap *bm1000_regmap; static const struct regmap_config bm1000_pcie_syscon_regmap_config = { .reg_bits = 32, .val_bits = 32, - .reg_stride = 4 + .reg_stride = 4, + .fast_io = true, + .use_raw_spinlock = true, }; static struct regmap *bm1000_pcie_get_gpr_acpi(struct bm1000_pcie *bm) -- 2.42.2