From: Daniil Gnusarev <gnusarevda@basealt.ru>
To: gnusarevda@basealt.ru, devel-kernel@lists.altlinux.org
Subject: [d-kernel] [PATCH 4/5] pci: baikal-pcie: use raw_spinlock for regmap of gbr registers
Date: Fri, 24 Apr 2026 18:33:25 +0400
Message-ID: <20260424143329.427971-5-gnusarevda@basealt.ru> (raw)
In-Reply-To: <20260424143329.427971-1-gnusarevda@basealt.ru>
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 <gnusarevda@basealt.ru>
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 <linux/of_device.h>
#include <linux/pci.h>
#include <linux/pci-ecam.h>
+#include <linux/of_address.h>
#include <linux/platform_device.h>
#include <linux/regmap.h>
@@ -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
next prev parent reply other threads:[~2026-04-24 14:33 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-04-24 14:33 [d-kernel] [PATCH 0/5] Kernel 6.18 with support for the Baikal-M SoC Daniil Gnusarev
2026-04-24 14:33 ` [d-kernel] [PATCH 1/5] pci: baikal-pcie: add support for PCIe controller for Baikal BE-M1000 Daniil Gnusarev
2026-04-24 14:33 ` [d-kernel] [PATCH 2/5] pci: baikal-pcie: driver compatibility with SDK earlier than 5.7 Daniil Gnusarev
2026-04-24 14:33 ` [d-kernel] [PATCH 3/5] pci: baikal-pcie: driver compatibility with SDK versions 5.4 Daniil Gnusarev
2026-04-24 14:33 ` Daniil Gnusarev [this message]
2026-04-24 14:33 ` [d-kernel] [PATCH 5/5] pci: baikal-pcie: forced enable dma-coherent for pcie on Baikal-M Daniil Gnusarev
2026-04-26 6:06 ` [d-kernel] [PATCH 0/5] Kernel 6.18 with support for the Baikal-M SoC Vitaly Chikunov
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260424143329.427971-5-gnusarevda@basealt.ru \
--to=gnusarevda@basealt.ru \
--cc=devel-kernel@lists.altlinux.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
ALT Linux kernel packages development
This inbox may be cloned and mirrored by anyone:
git clone --mirror http://lore.altlinux.org/devel-kernel/0 devel-kernel/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 devel-kernel devel-kernel/ http://lore.altlinux.org/devel-kernel \
devel-kernel@altlinux.org devel-kernel@altlinux.ru devel-kernel@altlinux.com
public-inbox-index devel-kernel
Example config snippet for mirrors.
Newsgroup available over NNTP:
nntp://lore.altlinux.org/org.altlinux.lists.devel-kernel
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git