[d-kernel] [PATCH 5/5] pci: baikal-pcie: forced enable dma-coherent for pcie on Baikal-M

Daniil Gnusarev gnusarevda на basealt.ru
Пт Апр 24 17:33:26 MSK 2026


When using the CONFIG_INIT_ON_ALLOC_DEFAULT_ON=Y kernel option or
the init_on_alloc=1 boot parameter, errors are observed when initializing
nvme on the PCIe bus:
    [   71.480815] nvme nvme0: I/O tag 16 (0010) QID 0 timeout, disable controller
    [   71.489912] nvme nvme0: Device not ready; aborting shutdown, CSTS=0x1
    [   71.496838] nvme nvme0: Identify Controller failed (-4)
    [   71.502910] nvme 0000:01:00.0: probe with driver nvme failed with error -5
As a solution, Baikal Electronics proposed to add the 'dma-coherent'
property to the PCIe device description in dts. To support devices with
older firmware versions, this property is forced into the device driver.

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 | 36 ++++++++++++++-----
 1 file changed, 28 insertions(+), 8 deletions(-)

diff --git a/drivers/pci/controller/dwc/pcie-baikal-core.c b/drivers/pci/controller/dwc/pcie-baikal-core.c
index 7f597b8a17f94..6300957b39007 100644
--- a/drivers/pci/controller/dwc/pcie-baikal-core.c
+++ b/drivers/pci/controller/dwc/pcie-baikal-core.c
@@ -162,6 +162,14 @@ struct bm1000_pcie {
 	bool			retrained;
 };
 
+static const struct regmap_config bm1000_pcie_syscon_regmap_config = {
+	.reg_bits = 32,
+	.val_bits = 32,
+	.reg_stride = 4,
+	.fast_io = true,
+	.use_raw_spinlock = true,
+};
+
 void bm1000_pcie_phy_enable(struct dw_pcie *pci)
 {
 	struct bm1000_pcie *bm = dev_get_drvdata(pci->dev);
@@ -1135,14 +1143,6 @@ static int bm1000_pcie_get_irq_acpi(struct device *dev,
 
 static struct regmap *bm1000_regmap;
 
-static const struct regmap_config bm1000_pcie_syscon_regmap_config = {
-	.reg_bits = 32,
-	.val_bits = 32,
-	.reg_stride = 4,
-	.fast_io = true,
-	.use_raw_spinlock = true,
-};
-
 static struct regmap *bm1000_pcie_get_gpr_acpi(struct bm1000_pcie *bm)
 {
 	struct device *dev;
@@ -2250,11 +2250,31 @@ static int baikal_pcie_probe(struct platform_device *pdev)
 	union baikal_pcie *bp;
 	const struct baikal_pcie_of_data *data;
 	int ret;
+	struct of_changeset ocs;
 
 	data = of_device_get_match_data(dev);
 	if (!data)
 		return -EINVAL;
 
+	if (!of_property_present(dev->of_node, "dma-coherent") &&
+		!of_property_present(dev->of_node, "dma-noncoherent")) {
+		dev->dma_coherent = true;
+
+		of_changeset_init(&ocs);
+
+		ret = of_changeset_add_prop_bool(&ocs, dev->of_node, "dma-coherent");
+		if (ret) {
+			dev_err(dev, "failed to append dma-coherent property\n");
+			return ret;
+		}
+
+		ret = of_changeset_apply(&ocs);
+		if (ret) {
+			dev_err(dev, "failed to append dma-coherent property\n");
+			return ret;
+		}
+	}
+
 	bp = devm_kzalloc(dev, sizeof(*bp), GFP_KERNEL);
 	if (!bp)
 		return -ENOMEM;
-- 
2.42.2



Подробная информация о списке рассылки devel-kernel