2023-05-08 12:30:16

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 0/5] firmware: tegra: Add MRQ support for Tegra264

In Tegra264 the carveouts (GSCs) used to communicate between BPMP and
CPU-NS may reside in DRAM. The location will be signalled using reserved
memory node in DT. Additionally some minor updates to the HSP driver are
done to support the new chip.

Peter De Schrijver (3):
dt-bindings: mailbox: tegra: Document Tegra264 HSP
dt-bindings: Add bindings to support DRAM MRQ GSCs
firmware: tegra: bpmp: Add support for DRAM MRQ GSCs

Stefan Kristiansson (2):
mailbox: tegra: add support for Tegra264
soc: tegra: fuse: add support for Tegra264

.../firmware/nvidia,tegra186-bpmp.yaml | 69 +++++-
.../bindings/mailbox/nvidia,tegra186-hsp.yaml | 1 +
.../nvidia,tegra264-bpmp-shmem.yaml | 40 ++++
drivers/firmware/tegra/bpmp-tegra186.c | 208 +++++++++++++-----
drivers/firmware/tegra/bpmp.c | 4 +-
drivers/mailbox/tegra-hsp.c | 16 +-
drivers/soc/tegra/fuse/tegra-apbmisc.c | 3 +-
include/soc/tegra/fuse.h | 3 +-
8 files changed, 275 insertions(+), 69 deletions(-)
create mode 100644 Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml

--
2.40.0


2023-05-08 12:31:01

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 2/5] mailbox: tegra: add support for Tegra264

From: Stefan Kristiansson <[email protected]>

Tegra264 has a slightly different doorbell register layout than
previous chips.

Signed-off-by: Stefan Kristiansson <[email protected]>
---
drivers/mailbox/tegra-hsp.c | 16 ++++++++++++++--
1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/drivers/mailbox/tegra-hsp.c b/drivers/mailbox/tegra-hsp.c
index 573481e436f5..7f98e7436d94 100644
--- a/drivers/mailbox/tegra-hsp.c
+++ b/drivers/mailbox/tegra-hsp.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
- * Copyright (c) 2016-2018, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2016-2023, NVIDIA CORPORATION. All rights reserved.
*/

#include <linux/delay.h>
@@ -97,6 +97,7 @@ struct tegra_hsp_soc {
const struct tegra_hsp_db_map *map;
bool has_per_mb_ie;
bool has_128_bit_mb;
+ unsigned int reg_stride;
};

struct tegra_hsp {
@@ -279,7 +280,7 @@ tegra_hsp_doorbell_create(struct tegra_hsp *hsp, const char *name,
return ERR_PTR(-ENOMEM);

offset = (1 + (hsp->num_sm / 2) + hsp->num_ss + hsp->num_as) * SZ_64K;
- offset += index * 0x100;
+ offset += index * hsp->soc->reg_stride;

db->channel.regs = hsp->regs + offset;
db->channel.hsp = hsp;
@@ -916,24 +917,35 @@ static const struct tegra_hsp_soc tegra186_hsp_soc = {
.map = tegra186_hsp_db_map,
.has_per_mb_ie = false,
.has_128_bit_mb = false,
+ .reg_stride = 0x100,
};

static const struct tegra_hsp_soc tegra194_hsp_soc = {
.map = tegra186_hsp_db_map,
.has_per_mb_ie = true,
.has_128_bit_mb = false,
+ .reg_stride = 0x100,
};

static const struct tegra_hsp_soc tegra234_hsp_soc = {
.map = tegra186_hsp_db_map,
.has_per_mb_ie = false,
.has_128_bit_mb = true,
+ .reg_stride = 0x100,
+};
+
+static const struct tegra_hsp_soc tegra264_hsp_soc = {
+ .map = tegra186_hsp_db_map,
+ .has_per_mb_ie = false,
+ .has_128_bit_mb = true,
+ .reg_stride = 0x1000,
};

static const struct of_device_id tegra_hsp_match[] = {
{ .compatible = "nvidia,tegra186-hsp", .data = &tegra186_hsp_soc },
{ .compatible = "nvidia,tegra194-hsp", .data = &tegra194_hsp_soc },
{ .compatible = "nvidia,tegra234-hsp", .data = &tegra234_hsp_soc },
+ { .compatible = "nvidia,tegra264-hsp", .data = &tegra264_hsp_soc },
{ }
};

--
2.40.0

2023-05-08 12:33:08

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 5/5] firmware: tegra: bpmp: Add support for DRAM MRQ GSCs

Implement support for DRAM MRQ GSCs.

Signed-off-by: Peter De Schrijver <[email protected]>
---
drivers/firmware/tegra/bpmp-tegra186.c | 208 ++++++++++++++++++-------
drivers/firmware/tegra/bpmp.c | 4 +-
2 files changed, 150 insertions(+), 62 deletions(-)

diff --git a/drivers/firmware/tegra/bpmp-tegra186.c b/drivers/firmware/tegra/bpmp-tegra186.c
index 2e26199041cd..000acf0fe183 100644
--- a/drivers/firmware/tegra/bpmp-tegra186.c
+++ b/drivers/firmware/tegra/bpmp-tegra186.c
@@ -4,8 +4,11 @@
*/

#include <linux/genalloc.h>
+#include <linux/io.h>
#include <linux/mailbox_client.h>
+#include <linux/of_address.h>
#include <linux/platform_device.h>
+#include <linux/range.h>

#include <soc/tegra/bpmp.h>
#include <soc/tegra/bpmp-abi.h>
@@ -13,11 +16,12 @@

#include "bpmp-private.h"

+enum tegra_bpmp_mem_type { TEGRA_INVALID, TEGRA_SRAM, TEGRA_RMEM };
+
struct tegra186_bpmp {
struct tegra_bpmp *parent;

struct {
- struct gen_pool *pool;
void __iomem *virt;
dma_addr_t phys;
} tx, rx;
@@ -26,6 +30,12 @@ struct tegra186_bpmp {
struct mbox_client client;
struct mbox_chan *channel;
} mbox;
+
+ struct {
+ struct gen_pool *tx, *rx;
+ } sram;
+
+ enum tegra_bpmp_mem_type type;
};

static inline struct tegra_bpmp *
@@ -158,64 +168,171 @@ static void mbox_handle_rx(struct mbox_client *client, void *data)
tegra_bpmp_handle_rx(bpmp);
}

-static int tegra186_bpmp_init(struct tegra_bpmp *bpmp)
+static void tegra186_bpmp_channel_deinit(struct tegra_bpmp *bpmp)
+{
+ int i;
+ struct tegra186_bpmp *priv = bpmp->priv;
+
+ for (i = 0; i < bpmp->threaded.count; i++) {
+ if (!bpmp->threaded_channels[i].bpmp)
+ continue;
+
+ tegra186_bpmp_channel_cleanup(&bpmp->threaded_channels[i]);
+ }
+
+ tegra186_bpmp_channel_cleanup(bpmp->rx_channel);
+ tegra186_bpmp_channel_cleanup(bpmp->tx_channel);
+
+ if (priv->type == TEGRA_SRAM) {
+ gen_pool_free(priv->sram.tx, (unsigned long)priv->tx.virt, 4096);
+ gen_pool_free(priv->sram.rx, (unsigned long)priv->rx.virt, 4096);
+ } else if (priv->type == TEGRA_RMEM) {
+ memunmap(priv->tx.virt);
+ }
+}
+
+static int tegra186_bpmp_channel_setup(struct tegra_bpmp *bpmp)
{
- struct tegra186_bpmp *priv;
unsigned int i;
int err;

- priv = devm_kzalloc(bpmp->dev, sizeof(*priv), GFP_KERNEL);
- if (!priv)
- return -ENOMEM;
+ err = tegra186_bpmp_channel_init(bpmp->tx_channel, bpmp,
+ bpmp->soc->channels.cpu_tx.offset);
+ if (err < 0)
+ return err;

- bpmp->priv = priv;
- priv->parent = bpmp;
+ err = tegra186_bpmp_channel_init(bpmp->rx_channel, bpmp,
+ bpmp->soc->channels.cpu_rx.offset);
+ if (err < 0) {
+ tegra186_bpmp_channel_cleanup(bpmp->tx_channel);
+ return err;
+ }
+
+ for (i = 0; i < bpmp->threaded.count; i++) {
+ unsigned int index = bpmp->soc->channels.thread.offset + i;

- priv->tx.pool = of_gen_pool_get(bpmp->dev->of_node, "shmem", 0);
- if (!priv->tx.pool) {
+ err = tegra186_bpmp_channel_init(&bpmp->threaded_channels[i],
+ bpmp, index);
+ if (err < 0)
+ break;
+ }
+
+ if (err < 0)
+ tegra186_bpmp_channel_deinit(bpmp);
+
+ return err;
+}
+
+static void tegra186_bpmp_reset_channels(struct tegra_bpmp *bpmp)
+{
+ unsigned int i;
+
+ tegra186_bpmp_channel_reset(bpmp->tx_channel);
+ tegra186_bpmp_channel_reset(bpmp->rx_channel);
+
+ for (i = 0; i < bpmp->threaded.count; i++)
+ tegra186_bpmp_channel_reset(&bpmp->threaded_channels[i]);
+}
+
+static int tegra186_bpmp_sram_init(struct tegra_bpmp *bpmp)
+{
+ int err;
+ struct tegra186_bpmp *priv = bpmp->priv;
+
+ priv->sram.tx = of_gen_pool_get(bpmp->dev->of_node, "shmem", 0);
+ if (!priv->sram.tx) {
dev_err(bpmp->dev, "TX shmem pool not found\n");
return -EPROBE_DEFER;
}

- priv->tx.virt = (void __iomem *)gen_pool_dma_alloc(priv->tx.pool, 4096, &priv->tx.phys);
+ priv->tx.virt = gen_pool_dma_alloc(priv->sram.tx, 4096, &priv->tx.phys);
if (!priv->tx.virt) {
dev_err(bpmp->dev, "failed to allocate from TX pool\n");
return -ENOMEM;
}

- priv->rx.pool = of_gen_pool_get(bpmp->dev->of_node, "shmem", 1);
- if (!priv->rx.pool) {
+ priv->sram.rx = of_gen_pool_get(bpmp->dev->of_node, "shmem", 1);
+ if (!priv->sram.rx) {
dev_err(bpmp->dev, "RX shmem pool not found\n");
err = -EPROBE_DEFER;
goto free_tx;
}

- priv->rx.virt = (void __iomem *)gen_pool_dma_alloc(priv->rx.pool, 4096, &priv->rx.phys);
+ priv->rx.virt = gen_pool_dma_alloc(priv->sram.rx, 4096, &priv->rx.phys);
if (!priv->rx.virt) {
dev_err(bpmp->dev, "failed to allocate from RX pool\n");
err = -ENOMEM;
goto free_tx;
}

- err = tegra186_bpmp_channel_init(bpmp->tx_channel, bpmp,
- bpmp->soc->channels.cpu_tx.offset);
- if (err < 0)
- goto free_rx;
+ priv->type = TEGRA_SRAM;

- err = tegra186_bpmp_channel_init(bpmp->rx_channel, bpmp,
- bpmp->soc->channels.cpu_rx.offset);
- if (err < 0)
- goto cleanup_tx_channel;
+ return 0;

- for (i = 0; i < bpmp->threaded.count; i++) {
- unsigned int index = bpmp->soc->channels.thread.offset + i;
+free_tx:
+ gen_pool_free(priv->sram.tx, (unsigned long)priv->tx.virt, 4096);

- err = tegra186_bpmp_channel_init(&bpmp->threaded_channels[i],
- bpmp, index);
+ return err;
+}
+
+static enum tegra_bpmp_mem_type tegra186_bpmp_dram_init(struct tegra_bpmp *bpmp)
+{
+ int err;
+ struct resource res;
+ struct device_node *np;
+ struct tegra186_bpmp *priv = bpmp->priv;
+
+ np = of_parse_phandle(bpmp->dev->of_node, "memory-region", 0);
+ if (!np)
+ return TEGRA_INVALID;
+
+ err = of_address_to_resource(np, 0, &res);
+ if (err) {
+ dev_warn(bpmp->dev, "Parsing memory region returned: %d\n", err);
+ return TEGRA_INVALID;
+ }
+
+ if ((res.end - res.start + 1) < 0x2000) {
+ dev_warn(bpmp->dev, "DRAM region less than 0x2000 bytes\n");
+ return TEGRA_INVALID;
+ }
+
+ priv->tx.phys = res.start;
+ priv->rx.phys = res.start + 0x1000;
+
+ priv->tx.virt = memremap(priv->tx.phys, res.end - res.start + 1, MEMREMAP_WC);
+ if (priv->tx.virt == NULL) {
+ dev_warn(bpmp->dev, "DRAM region mapping failed\n");
+ return TEGRA_INVALID;
+ }
+ priv->rx.virt = priv->tx.virt + 0x1000;
+
+ return TEGRA_RMEM;
+}
+
+static int tegra186_bpmp_init(struct tegra_bpmp *bpmp)
+{
+ struct tegra186_bpmp *priv;
+ int err;
+
+ priv = devm_kzalloc(bpmp->dev, sizeof(*priv), GFP_KERNEL);
+ if (!priv)
+ return -ENOMEM;
+
+ bpmp->priv = priv;
+ priv->parent = bpmp;
+
+ priv->type = tegra186_bpmp_dram_init(bpmp);
+ if (priv->type == TEGRA_INVALID) {
+ err = tegra186_bpmp_sram_init(bpmp);
if (err < 0)
- goto cleanup_channels;
+ return err;
}

+ err = tegra186_bpmp_channel_setup(bpmp);
+ if (err < 0)
+ return err;
+
/* mbox registration */
priv->mbox.client.dev = bpmp->dev;
priv->mbox.client.rx_callback = mbox_handle_rx;
@@ -226,51 +343,22 @@ static int tegra186_bpmp_init(struct tegra_bpmp *bpmp)
if (IS_ERR(priv->mbox.channel)) {
err = PTR_ERR(priv->mbox.channel);
dev_err(bpmp->dev, "failed to get HSP mailbox: %d\n", err);
- goto cleanup_channels;
+ tegra186_bpmp_channel_deinit(bpmp);
+ return err;
}

- tegra186_bpmp_channel_reset(bpmp->tx_channel);
- tegra186_bpmp_channel_reset(bpmp->rx_channel);
-
- for (i = 0; i < bpmp->threaded.count; i++)
- tegra186_bpmp_channel_reset(&bpmp->threaded_channels[i]);
+ tegra186_bpmp_reset_channels(bpmp);

return 0;
-
-cleanup_channels:
- for (i = 0; i < bpmp->threaded.count; i++) {
- if (!bpmp->threaded_channels[i].bpmp)
- continue;
-
- tegra186_bpmp_channel_cleanup(&bpmp->threaded_channels[i]);
- }
-
- tegra186_bpmp_channel_cleanup(bpmp->rx_channel);
-cleanup_tx_channel:
- tegra186_bpmp_channel_cleanup(bpmp->tx_channel);
-free_rx:
- gen_pool_free(priv->rx.pool, (unsigned long)priv->rx.virt, 4096);
-free_tx:
- gen_pool_free(priv->tx.pool, (unsigned long)priv->tx.virt, 4096);
-
- return err;
}

static void tegra186_bpmp_deinit(struct tegra_bpmp *bpmp)
{
struct tegra186_bpmp *priv = bpmp->priv;
- unsigned int i;

mbox_free_channel(priv->mbox.channel);

- for (i = 0; i < bpmp->threaded.count; i++)
- tegra186_bpmp_channel_cleanup(&bpmp->threaded_channels[i]);
-
- tegra186_bpmp_channel_cleanup(bpmp->rx_channel);
- tegra186_bpmp_channel_cleanup(bpmp->tx_channel);
-
- gen_pool_free(priv->rx.pool, (unsigned long)priv->rx.virt, 4096);
- gen_pool_free(priv->tx.pool, (unsigned long)priv->tx.virt, 4096);
+ tegra186_bpmp_channel_deinit(bpmp);
}

static int tegra186_bpmp_resume(struct tegra_bpmp *bpmp)
diff --git a/drivers/firmware/tegra/bpmp.c b/drivers/firmware/tegra/bpmp.c
index 8b5e5daa9fae..17bd3590aaa2 100644
--- a/drivers/firmware/tegra/bpmp.c
+++ b/drivers/firmware/tegra/bpmp.c
@@ -735,6 +735,8 @@ static int tegra_bpmp_probe(struct platform_device *pdev)
if (!bpmp->threaded_channels)
return -ENOMEM;

+ platform_set_drvdata(pdev, bpmp);
+
err = bpmp->soc->ops->init(bpmp);
if (err < 0)
return err;
@@ -758,8 +760,6 @@ static int tegra_bpmp_probe(struct platform_device *pdev)

dev_info(&pdev->dev, "firmware: %.*s\n", (int)sizeof(tag), tag);

- platform_set_drvdata(pdev, bpmp);
-
err = of_platform_default_populate(pdev->dev.of_node, NULL, &pdev->dev);
if (err < 0)
goto free_mrq;
--
2.40.0

2023-05-08 12:52:29

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 4/5] dt-bindings: Add bindings to support DRAM MRQ GSCs

Add bindings for DRAM MRQ GSC support.

Co-developed-by: Stefan Kristiansson <[email protected]>
Signed-off-by: Stefan Kristiansson <[email protected]>
Signed-off-by: Peter De Schrijver <[email protected]>
---
.../firmware/nvidia,tegra186-bpmp.yaml | 69 ++++++++++++++++++-
.../nvidia,tegra264-bpmp-shmem.yaml | 40 +++++++++++
2 files changed, 106 insertions(+), 3 deletions(-)
create mode 100644 Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml

diff --git a/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml b/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml
index 833c07f1685c..d818cfe1d783 100644
--- a/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml
+++ b/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml
@@ -57,8 +57,11 @@ description: |
"#address-cells" or "#size-cells" property.

The shared memory area for the IPC TX and RX between CPU and BPMP are
- predefined and work on top of sysram, which is an SRAM inside the
- chip. See ".../sram/sram.yaml" for the bindings.
+ predefined and work on top of either sysram, which is an SRAM inside the
+ chip, or in normal SDRAM.
+ See ".../sram/sram.yaml" for the bindings for the SRAM case.
+ See "../reserved-memory/nvidia,tegra264-bpmp-shmem.yaml" for bindings for
+ the SDRAM case.

properties:
compatible:
@@ -81,6 +84,11 @@ properties:
minItems: 2
maxItems: 2

+ memory-region:
+ description: phandle to reserved memory region used for IPC between
+ CPU-NS and BPMP.
+ maxItems: 1
+
"#clock-cells":
const: 1

@@ -115,10 +123,16 @@ properties:

additionalProperties: false

+allOf:
+ - oneOf:
+ - required:
+ - memory-region
+ - required:
+ - shmem
+
required:
- compatible
- mboxes
- - shmem
- "#clock-cells"
- "#power-domain-cells"
- "#reset-cells"
@@ -184,3 +198,52 @@ examples:
#thermal-sensor-cells = <1>;
};
};
+
+ - |
+ #include <dt-bindings/interrupt-controller/arm-gic.h>
+ #include <dt-bindings/mailbox/tegra186-hsp.h>
+ #include <dt-bindings/memory/tegra186-mc.h>
+
+ hsp_top0: hsp@3c00000 {
+ compatible = "nvidia,tegra186-hsp";
+ reg = <0x03c00000 0xa0000>;
+ interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "doorbell";
+ #mbox-cells = <2>;
+ };
+
+ reserved-memory {
+ dram_cpu_bpmp_mail: shmem@f1be0000 {
+ compatible = "nvidia,tegra264-bpmp-shmem";
+ reg = <0x0 0xf1be0000 0x0 0x2000>;
+ no-map;
+ };
+ };
+
+ bpmp {
+ compatible = "nvidia,tegra186-bpmp";
+ interconnects = <&mc TEGRA186_MEMORY_CLIENT_BPMPR &emc>,
+ <&mc TEGRA186_MEMORY_CLIENT_BPMPW &emc>,
+ <&mc TEGRA186_MEMORY_CLIENT_BPMPDMAR &emc>,
+ <&mc TEGRA186_MEMORY_CLIENT_BPMPDMAW &emc>;
+ interconnect-names = "read", "write", "dma-mem", "dma-write";
+ iommus = <&smmu TEGRA186_SID_BPMP>;
+ mboxes = <&hsp_top0 TEGRA_HSP_MBOX_TYPE_DB
+ TEGRA_HSP_DB_MASTER_BPMP>;
+ memory-region = <&dram_cpu_bpmp_mail>;
+ #clock-cells = <1>;
+ #power-domain-cells = <1>;
+ #reset-cells = <1>;
+
+ i2c {
+ compatible = "nvidia,tegra186-bpmp-i2c";
+ nvidia,bpmp-bus-id = <5>;
+ #address-cells = <1>;
+ #size-cells = <0>;
+ };
+
+ thermal {
+ compatible = "nvidia,tegra186-bpmp-thermal";
+ #thermal-sensor-cells = <1>;
+ };
+ };
diff --git a/Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml b/Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml
new file mode 100644
index 000000000000..6cd9a61cd31f
--- /dev/null
+++ b/Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml
@@ -0,0 +1,40 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: Tegra CPU-NS - BPMP IPC reserved memory binding
+
+maintainers:
+ - Peter De Schrijver <[email protected]>
+
+description: |
+ Define a memory region used for communication between CPU-NS and BPMP.
+ Typically this node is created by the bootloader as the physical address
+ has to be known to both CPU-NS and BPMP for correct IPC operation.
+ The memory region is defined using a child node under /reserved-memory.
+ The sub-node is named shmem@<address>.
+
+properties:
+ compatible:
+ const: nvidia,tegra264-bpmp-shmem
+
+ reg:
+ description: The physical address and size of the shared SDRAM region
+
+required:
+ - compatible
+ - reg
+ - no-map
+
+examples:
+ - |
+ reserved-memory {
+ dram_cpu_bpmp_mail: shmem@f1be0000 {
+ compatible = "nvidia,tegra264-bpmp-shmem";
+ reg = <0x0 0xf1be0000 0x0 0x2000>;
+ no-map;
+ };
+ };
+...
--
2.40.0

2023-05-08 12:53:53

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 3/5] soc: tegra: fuse: add support for Tegra264

From: Stefan Kristiansson <[email protected]>

Add support for Tegra264 to the fuse handling code.

Signed-off-by: Stefan Kristiansson <[email protected]>
---
drivers/soc/tegra/fuse/tegra-apbmisc.c | 3 ++-
include/soc/tegra/fuse.h | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/soc/tegra/fuse/tegra-apbmisc.c b/drivers/soc/tegra/fuse/tegra-apbmisc.c
index 4591c5bcb690..eb0a1d924526 100644
--- a/drivers/soc/tegra/fuse/tegra-apbmisc.c
+++ b/drivers/soc/tegra/fuse/tegra-apbmisc.c
@@ -1,6 +1,6 @@
// SPDX-License-Identifier: GPL-2.0-only
/*
- * Copyright (c) 2014, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2014-2023, NVIDIA CORPORATION. All rights reserved.
*/

#include <linux/export.h>
@@ -62,6 +62,7 @@ bool tegra_is_silicon(void)
switch (tegra_get_chip_id()) {
case TEGRA194:
case TEGRA234:
+ case TEGRA264:
if (tegra_get_platform() == 0)
return true;

diff --git a/include/soc/tegra/fuse.h b/include/soc/tegra/fuse.h
index a63de5da8124..3a513be50243 100644
--- a/include/soc/tegra/fuse.h
+++ b/include/soc/tegra/fuse.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: GPL-2.0-only */
/*
- * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
+ * Copyright (c) 2012-2023, NVIDIA CORPORATION. All rights reserved.
*/

#ifndef __SOC_TEGRA_FUSE_H__
@@ -17,6 +17,7 @@
#define TEGRA186 0x18
#define TEGRA194 0x19
#define TEGRA234 0x23
+#define TEGRA264 0x26

#define TEGRA_FUSE_SKU_CALIB_0 0xf0
#define TEGRA30_FUSE_SATA_CALIB 0x124
--
2.40.0

2023-05-08 12:55:46

by Peter De Schrijver

[permalink] [raw]
Subject: [PATCH 1/5] dt-bindings: mailbox: tegra: Document Tegra264 HSP

Add the compatible string for the HSP block found on the Tegra264 SoC.

Signed-off-by: Peter De Schrijver <[email protected]>
---
.../devicetree/bindings/mailbox/nvidia,tegra186-hsp.yaml | 1 +
1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/mailbox/nvidia,tegra186-hsp.yaml b/Documentation/devicetree/bindings/mailbox/nvidia,tegra186-hsp.yaml
index a3e87516d637..2d14fc948999 100644
--- a/Documentation/devicetree/bindings/mailbox/nvidia,tegra186-hsp.yaml
+++ b/Documentation/devicetree/bindings/mailbox/nvidia,tegra186-hsp.yaml
@@ -66,6 +66,7 @@ properties:
oneOf:
- const: nvidia,tegra186-hsp
- const: nvidia,tegra194-hsp
+ - const: nvidia,tegra264-hsp
- items:
- const: nvidia,tegra234-hsp
- const: nvidia,tegra194-hsp
--
2.40.0

2023-05-08 13:13:36

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH 3/5] soc: tegra: fuse: add support for Tegra264

On Mon, May 08, 2023 at 03:20:50PM +0300, Peter De Schrijver wrote:
> From: Stefan Kristiansson <[email protected]>
>
> Add support for Tegra264 to the fuse handling code.
>
> Signed-off-by: Stefan Kristiansson <[email protected]>
> ---
> drivers/soc/tegra/fuse/tegra-apbmisc.c | 3 ++-
> include/soc/tegra/fuse.h | 3 ++-
> 2 files changed, 4 insertions(+), 2 deletions(-)

Same comment regarding the Signed-off-by line as for patch 2/5.

Thierry


Attachments:
(No filename) (481.00 B)
signature.asc (849.00 B)
Download all attachments

2023-05-08 13:15:17

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH 2/5] mailbox: tegra: add support for Tegra264

On Mon, May 08, 2023 at 03:20:48PM +0300, Peter De Schrijver wrote:
> From: Stefan Kristiansson <[email protected]>
>
> Tegra264 has a slightly different doorbell register layout than
> previous chips.
>
> Signed-off-by: Stefan Kristiansson <[email protected]>

Technically this needs your Signed-off-by line since your not the author
but forwarding the patch.

Thierry


Attachments:
(No filename) (386.00 B)
signature.asc (849.00 B)
Download all attachments

2023-05-08 13:27:32

by Thierry Reding

[permalink] [raw]
Subject: Re: [PATCH 1/5] dt-bindings: mailbox: tegra: Document Tegra264 HSP

On Mon, May 08, 2023 at 03:20:46PM +0300, Peter De Schrijver wrote:
> Add the compatible string for the HSP block found on the Tegra264 SoC.
>
> Signed-off-by: Peter De Schrijver <[email protected]>
> ---
> .../devicetree/bindings/mailbox/nvidia,tegra186-hsp.yaml | 1 +
> 1 file changed, 1 insertion(+)

Might be a good idea to say in the commit message that this isn't
backwards compatible with Tegra194/Tegra234, hence no fallback
compatible string. That's already in the commit message for the driver,
so either way is fine with me:

Acked-by: Thierry Reding <[email protected]>


Attachments:
(No filename) (614.00 B)
signature.asc (849.00 B)
Download all attachments

2023-05-08 13:34:28

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 4/5] dt-bindings: Add bindings to support DRAM MRQ GSCs

On Mon, 08 May 2023 15:20:52 +0300, Peter De Schrijver wrote:
> Add bindings for DRAM MRQ GSC support.
>
> Co-developed-by: Stefan Kristiansson <[email protected]>
> Signed-off-by: Stefan Kristiansson <[email protected]>
> Signed-off-by: Peter De Schrijver <[email protected]>
> ---
> .../firmware/nvidia,tegra186-bpmp.yaml | 69 ++++++++++++++++++-
> .../nvidia,tegra264-bpmp-shmem.yaml | 40 +++++++++++
> 2 files changed, 106 insertions(+), 3 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml
>

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:
./Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml:10:2: [warning] wrong indentation: expected 2 but found 1 (indentation)

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml: 'oneOf' conditional failed, one must be fixed:
'unevaluatedProperties' is a required property
'additionalProperties' is a required property
hint: Either unevaluatedProperties or additionalProperties must be present
from schema $id: http://devicetree.org/meta-schemas/core.yaml#
Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.example.dts:110.31-116.11: ERROR (duplicate_label): /example-1/hsp@3c00000: Duplicate label 'hsp_top0' on /example-1/hsp@3c00000 and /example-0/hsp@3c00000
ERROR: Input tree has errors, aborting (use -f to force output)
make[1]: *** [scripts/Makefile.lib:419: Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.example.dtb] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1512: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):
Documentation/usb/gadget_uvc.rst: Documentation/userspace-api/media/v4l/pixfmt-packed.yuv.rst
MAINTAINERS: Documentation/devicetree/bindings/pwm/pwm-apple.yaml

See https://patchwork.ozlabs.org/patch/1778345

This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit.

2023-05-08 14:14:15

by Peter De Schrijver

[permalink] [raw]
Subject: Re: [PATCH 4/5] dt-bindings: Add bindings to support DRAM MRQ GSCs

No idea what the second error is about. Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml does not have a oneOf conditional?

Peter.

________________________________________
From: Krzysztof Kozlowski <[email protected]>
Sent: 08 May 2023 16:33
To: Peter De Schrijver
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Jonathan Hunter; [email protected]; [email protected]; Stefan Kristiansson
Subject: Re: [PATCH 4/5] dt-bindings: Add bindings to support DRAM MRQ GSCs

On Mon, 08 May 2023 15:20:52 +0300, Peter De Schrijver wrote:
> Add bindings for DRAM MRQ GSC support.
>
> Co-developed-by: Stefan Kristiansson <[email protected]>
> Signed-off-by: Stefan Kristiansson <[email protected]>
> Signed-off-by: Peter De Schrijver <[email protected]>
> ---
> .../firmware/nvidia,tegra186-bpmp.yaml | 69 ++++++++++++++++++-
> .../nvidia,tegra264-bpmp-shmem.yaml | 40 +++++++++++
> 2 files changed, 106 insertions(+), 3 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml
>

My bot found errors running 'make DT_CHECKER_FLAGS=-m dt_binding_check'
on your patch (DT_CHECKER_FLAGS is new in v5.13):

yamllint warnings/errors:
./Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml:10:2: [warning] wrong indentation: expected 2 but found 1 (indentation)

dtschema/dtc warnings/errors:
/builds/robherring/dt-review-ci/linux/Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml: 'oneOf' conditional failed, one must be fixed:
'unevaluatedProperties' is a required property
'additionalProperties' is a required property
hint: Either unevaluatedProperties or additionalProperties must be present
from schema $id: http://devicetree.org/meta-schemas/core.yaml#
Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.example.dts:110.31-116.11: ERROR (duplicate_label): /example-1/hsp@3c00000: Duplicate label 'hsp_top0' on /example-1/hsp@3c00000 and /example-0/hsp@3c00000
ERROR: Input tree has errors, aborting (use -f to force output)
make[1]: *** [scripts/Makefile.lib:419: Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.example.dtb] Error 2
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:1512: dt_binding_check] Error 2

doc reference errors (make refcheckdocs):
Documentation/usb/gadget_uvc.rst: Documentation/userspace-api/media/v4l/pixfmt-packed.yuv.rst
MAINTAINERS: Documentation/devicetree/bindings/pwm/pwm-apple.yaml

See https://patchwork.ozlabs.org/patch/1778345

This check can fail if there are any dependencies. The base for a patch
series is generally the most recent rc1.

If you already ran 'make dt_binding_check' and didn't see the above
error(s), then make sure 'yamllint' is installed and dt-schema is up to
date:

pip3 install dtschema --upgrade

Please check and re-submit.

--
nvpublic

2023-05-08 14:18:44

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 4/5] dt-bindings: Add bindings to support DRAM MRQ GSCs

On 08/05/2023 14:20, Peter De Schrijver wrote:
> Add bindings for DRAM MRQ GSC support.
>
> Co-developed-by: Stefan Kristiansson <[email protected]>
> Signed-off-by: Stefan Kristiansson <[email protected]>
> Signed-off-by: Peter De Schrijver <[email protected]>
> ---
> .../firmware/nvidia,tegra186-bpmp.yaml | 69 ++++++++++++++++++-
> .../nvidia,tegra264-bpmp-shmem.yaml | 40 +++++++++++

Why touching two files?

> 2 files changed, 106 insertions(+), 3 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml
>
> diff --git a/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml b/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml
> index 833c07f1685c..d818cfe1d783 100644
> --- a/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml
> +++ b/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml
> @@ -57,8 +57,11 @@ description: |
> "#address-cells" or "#size-cells" property.
>
> The shared memory area for the IPC TX and RX between CPU and BPMP are
> - predefined and work on top of sysram, which is an SRAM inside the
> - chip. See ".../sram/sram.yaml" for the bindings.
> + predefined and work on top of either sysram, which is an SRAM inside the
> + chip, or in normal SDRAM.
> + See ".../sram/sram.yaml" for the bindings for the SRAM case.
> + See "../reserved-memory/nvidia,tegra264-bpmp-shmem.yaml" for bindings for
> + the SDRAM case.
>
> properties:
> compatible:
> @@ -81,6 +84,11 @@ properties:
> minItems: 2
> maxItems: 2
>
> + memory-region:
> + description: phandle to reserved memory region used for IPC between
> + CPU-NS and BPMP.
> + maxItems: 1
> +
> "#clock-cells":
> const: 1
>
> @@ -115,10 +123,16 @@ properties:
>
> additionalProperties: false
>
> +allOf:
> + - oneOf:

Keep just oneOf and drop allOf.

> + - required:
> + - memory-region
> + - required:
> + - shmem
> +
> required:
> - compatible
> - mboxes
> - - shmem
> - "#clock-cells"
> - "#power-domain-cells"
> - "#reset-cells"
> @@ -184,3 +198,52 @@ examples:
> #thermal-sensor-cells = <1>;
> };
> };
> +
> + - |
> + #include <dt-bindings/interrupt-controller/arm-gic.h>
> + #include <dt-bindings/mailbox/tegra186-hsp.h>
> + #include <dt-bindings/memory/tegra186-mc.h>
> +
> + hsp_top0: hsp@3c00000 {
> + compatible = "nvidia,tegra186-hsp";
> + reg = <0x03c00000 0xa0000>;
> + interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
> + interrupt-names = "doorbell";
> + #mbox-cells = <2>;

Why HSP example is here?

> + };
> +
> + reserved-memory {
> + dram_cpu_bpmp_mail: shmem@f1be0000 {
> + compatible = "nvidia,tegra264-bpmp-shmem";
> + reg = <0x0 0xf1be0000 0x0 0x2000>;
> + no-map;
> + };
> + };

Drop, fairly obvious and should be in that binding, not here.

> +
> + bpmp {
> + compatible = "nvidia,tegra186-bpmp";
> + interconnects = <&mc TEGRA186_MEMORY_CLIENT_BPMPR &emc>,
> + <&mc TEGRA186_MEMORY_CLIENT_BPMPW &emc>,
> + <&mc TEGRA186_MEMORY_CLIENT_BPMPDMAR &emc>,
> + <&mc TEGRA186_MEMORY_CLIENT_BPMPDMAW &emc>;
> + interconnect-names = "read", "write", "dma-mem", "dma-write";
> + iommus = <&smmu TEGRA186_SID_BPMP>;
> + mboxes = <&hsp_top0 TEGRA_HSP_MBOX_TYPE_DB
> + TEGRA_HSP_DB_MASTER_BPMP>;
> + memory-region = <&dram_cpu_bpmp_mail>;
> + #clock-cells = <1>;
> + #power-domain-cells = <1>;
> + #reset-cells = <1>;
> +
> + i2c {
> + compatible = "nvidia,tegra186-bpmp-i2c";
> + nvidia,bpmp-bus-id = <5>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + };
> +
> + thermal {
> + compatible = "nvidia,tegra186-bpmp-thermal";
> + #thermal-sensor-cells = <1>;
> + };
> + };
> diff --git a/Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml b/Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml
> new file mode 100644
> index 000000000000..6cd9a61cd31f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml
> @@ -0,0 +1,40 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Tegra CPU-NS - BPMP IPC reserved memory binding

Drop "binding"

> +
> +maintainers:
> + - Peter De Schrijver <[email protected]>
> +
> +description: |
> + Define a memory region used for communication between CPU-NS and BPMP.
> + Typically this node is created by the bootloader as the physical address
> + has to be known to both CPU-NS and BPMP for correct IPC operation.
> + The memory region is defined using a child node under /reserved-memory.
> + The sub-node is named shmem@<address>.
> +

Open other files there and implement it similar way. I really wonder why
this should be done differently than for example other nvidia stuff -
without reserved-memory schema?

> +properties:
> + compatible:
> + const: nvidia,tegra264-bpmp-shmem
> +
> + reg:
> + description: The physical address and size of the shared SDRAM region
> +
> +required:
> + - compatible
> + - reg
> + - no-map
> +

Does not look like you tested the bindings. Please run `make
dt_binding_check` (see
Documentation/devicetree/bindings/writing-schema.rst for instructions).

> +examples:
> + - |
> + reserved-memory {
> + dram_cpu_bpmp_mail: shmem@f1be0000 {
> + compatible = "nvidia,tegra264-bpmp-shmem";
> + reg = <0x0 0xf1be0000 0x0 0x2000>;
> + no-map;
> + };
> + };
> +...

Best regards,
Krzysztof

2023-05-08 14:24:57

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 1/5] dt-bindings: mailbox: tegra: Document Tegra264 HSP

On 08/05/2023 14:20, Peter De Schrijver wrote:
> Add the compatible string for the HSP block found on the Tegra264 SoC.
>
> Signed-off-by: Peter De Schrijver <[email protected]>
> ---
> .../devicetree/bindings/mailbox/nvidia,tegra186-hsp.yaml | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/mailbox/nvidia,tegra186-hsp.yaml b/Documentation/devicetree/bindings/mailbox/nvidia,tegra186-hsp.yaml
> index a3e87516d637..2d14fc948999 100644
> --- a/Documentation/devicetree/bindings/mailbox/nvidia,tegra186-hsp.yaml
> +++ b/Documentation/devicetree/bindings/mailbox/nvidia,tegra186-hsp.yaml
> @@ -66,6 +66,7 @@ properties:
> oneOf:
> - const: nvidia,tegra186-hsp
> - const: nvidia,tegra194-hsp
> + - const: nvidia,tegra264-hsp

I didn't get other patches, so I assume you know what you are doing and
the device is not compatible with others (see entire context of that diff).

Acked-by: Krzysztof Kozlowski <[email protected]>

Best regards,
Krzysztof

2023-05-08 14:25:10

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 4/5] dt-bindings: Add bindings to support DRAM MRQ GSCs

On 08/05/2023 15:52, Peter De Schrijver wrote:
> No idea what the second error is about. Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml does not have a oneOf conditional?
>

Are you talking about the one with following explanation:

'unevaluatedProperties' is a required property
'additionalProperties' is a required property
hint: Either unevaluatedProperties or additionalProperties must be present

? Isn't it self-explanatory?

Best regards,
Krzysztof

2023-05-08 14:25:28

by Krzysztof Kozlowski

[permalink] [raw]
Subject: Re: [PATCH 4/5] dt-bindings: Add bindings to support DRAM MRQ GSCs

On 08/05/2023 16:12, Peter De Schrijver wrote:
>
>
> ________________________________________
> From: Krzysztof Kozlowski <[email protected]>
> Sent: 08 May 2023 17:04
> To: Peter De Schrijver; [email protected]; Jonathan Hunter
> Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Stefan Kristiansson
> Subject: Re: [PATCH 4/5] dt-bindings: Add bindings to support DRAM MRQ GSCs
>
> On 08/05/2023 14:20, Peter De Schrijver wrote:
>> Add bindings for DRAM MRQ GSC support.
>>
>> Co-developed-by: Stefan Kristiansson <[email protected]>
>> Signed-off-by: Stefan Kristiansson <[email protected]>
>> Signed-off-by: Peter De Schrijver <[email protected]>
>> ---
>> .../firmware/nvidia,tegra186-bpmp.yaml | 69 ++++++++++++++++++-
>> .../nvidia,tegra264-bpmp-shmem.yaml | 40 +++++++++++
>
>> Why touching two files?
>
> Because both are needed to support having MRQ GSCs in DRAM.

Yeah, but why two in one commit? All patches are needed for full support
and they are not squashed into one.

>
>> 2 files changed, 106 insertions(+), 3 deletions(-)
>> create mode 100644 Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml
>>
>> diff --git a/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml b/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml
>> index 833c07f1685c..d818cfe1d783 100644
>> --- a/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml
>> +++ b/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml
>> @@ -57,8 +57,11 @@ description: |
>> "#address-cells" or "#size-cells" property.
>>
>> The shared memory area for the IPC TX and RX between CPU and BPMP are
>> - predefined and work on top of sysram, which is an SRAM inside the
>> - chip. See ".../sram/sram.yaml" for the bindings.
>> + predefined and work on top of either sysram, which is an SRAM inside the
>> + chip, or in normal SDRAM.
>> + See ".../sram/sram.yaml" for the bindings for the SRAM case.
>> + See "../reserved-memory/nvidia,tegra264-bpmp-shmem.yaml" for bindings for
>> + the SDRAM case.
>>
>> properties:
>> compatible:
>> @@ -81,6 +84,11 @@ properties:
>> minItems: 2
>> maxItems: 2
>>
>> + memory-region:
>> + description: phandle to reserved memory region used for IPC between
>> + CPU-NS and BPMP.
>> + maxItems: 1
>> +
>> "#clock-cells":
>> const: 1
>>
>> @@ -115,10 +123,16 @@ properties:
>>
>> additionalProperties: false
>>
>> +allOf:
>> + - oneOf:
>
> Keep just oneOf and drop allOf.

???

I wrote this. Fix your mailer.

>
>> + - required:
>> + - memory-region
>> + - required:
>> + - shmem
>> +
>> required:
>> - compatible
>> - mboxes
>> - - shmem
>> - "#clock-cells"
>> - "#power-domain-cells"
>> - "#reset-cells"
>> @@ -184,3 +198,52 @@ examples:
>> #thermal-sensor-cells = <1>;
>> };
>> };
>> +
>> + - |
>> + #include <dt-bindings/interrupt-controller/arm-gic.h>
>> + #include <dt-bindings/mailbox/tegra186-hsp.h>
>> + #include <dt-bindings/memory/tegra186-mc.h>
>> +
>> + hsp_top0: hsp@3c00000 {
>> + compatible = "nvidia,tegra186-hsp";
>> + reg = <0x03c00000 0xa0000>;
>> + interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
>> + interrupt-names = "doorbell";
>> + #mbox-cells = <2>;
>
>> Why HSP example is here?
>
> Because it's referred to further down the example.

Not needed.

>
>> + };
>> +
>> + reserved-memory {
>> + dram_cpu_bpmp_mail: shmem@f1be0000 {
>> + compatible = "nvidia,tegra264-bpmp-shmem";
>> + reg = <0x0 0xf1be0000 0x0 0x2000>;
>> + no-map;
>> + };
>> + };
>
> Drop, fairly obvious and should be in that binding, not here.

???

Please use mailing list style of replies.

Best regards,
Krzysztof

2023-05-08 14:37:43

by Peter De Schrijver

[permalink] [raw]
Subject: Re: [PATCH 4/5] dt-bindings: Add bindings to support DRAM MRQ GSCs



________________________________________
From: Krzysztof Kozlowski <[email protected]>
Sent: 08 May 2023 17:04
To: Peter De Schrijver; [email protected]; Jonathan Hunter
Cc: [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; [email protected]; Stefan Kristiansson
Subject: Re: [PATCH 4/5] dt-bindings: Add bindings to support DRAM MRQ GSCs

On 08/05/2023 14:20, Peter De Schrijver wrote:
> Add bindings for DRAM MRQ GSC support.
>
> Co-developed-by: Stefan Kristiansson <[email protected]>
> Signed-off-by: Stefan Kristiansson <[email protected]>
> Signed-off-by: Peter De Schrijver <[email protected]>
> ---
> .../firmware/nvidia,tegra186-bpmp.yaml | 69 ++++++++++++++++++-
> .../nvidia,tegra264-bpmp-shmem.yaml | 40 +++++++++++

> Why touching two files?

Because both are needed to support having MRQ GSCs in DRAM.

> 2 files changed, 106 insertions(+), 3 deletions(-)
> create mode 100644 Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml
>
> diff --git a/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml b/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml
> index 833c07f1685c..d818cfe1d783 100644
> --- a/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml
> +++ b/Documentation/devicetree/bindings/firmware/nvidia,tegra186-bpmp.yaml
> @@ -57,8 +57,11 @@ description: |
> "#address-cells" or "#size-cells" property.
>
> The shared memory area for the IPC TX and RX between CPU and BPMP are
> - predefined and work on top of sysram, which is an SRAM inside the
> - chip. See ".../sram/sram.yaml" for the bindings.
> + predefined and work on top of either sysram, which is an SRAM inside the
> + chip, or in normal SDRAM.
> + See ".../sram/sram.yaml" for the bindings for the SRAM case.
> + See "../reserved-memory/nvidia,tegra264-bpmp-shmem.yaml" for bindings for
> + the SDRAM case.
>
> properties:
> compatible:
> @@ -81,6 +84,11 @@ properties:
> minItems: 2
> maxItems: 2
>
> + memory-region:
> + description: phandle to reserved memory region used for IPC between
> + CPU-NS and BPMP.
> + maxItems: 1
> +
> "#clock-cells":
> const: 1
>
> @@ -115,10 +123,16 @@ properties:
>
> additionalProperties: false
>
> +allOf:
> + - oneOf:

Keep just oneOf and drop allOf.

> + - required:
> + - memory-region
> + - required:
> + - shmem
> +
> required:
> - compatible
> - mboxes
> - - shmem
> - "#clock-cells"
> - "#power-domain-cells"
> - "#reset-cells"
> @@ -184,3 +198,52 @@ examples:
> #thermal-sensor-cells = <1>;
> };
> };
> +
> + - |
> + #include <dt-bindings/interrupt-controller/arm-gic.h>
> + #include <dt-bindings/mailbox/tegra186-hsp.h>
> + #include <dt-bindings/memory/tegra186-mc.h>
> +
> + hsp_top0: hsp@3c00000 {
> + compatible = "nvidia,tegra186-hsp";
> + reg = <0x03c00000 0xa0000>;
> + interrupts = <GIC_SPI 176 IRQ_TYPE_LEVEL_HIGH>;
> + interrupt-names = "doorbell";
> + #mbox-cells = <2>;

> Why HSP example is here?

Because it's referred to further down the example.

> + };
> +
> + reserved-memory {
> + dram_cpu_bpmp_mail: shmem@f1be0000 {
> + compatible = "nvidia,tegra264-bpmp-shmem";
> + reg = <0x0 0xf1be0000 0x0 0x2000>;
> + no-map;
> + };
> + };

Drop, fairly obvious and should be in that binding, not here.

> +
> + bpmp {
> + compatible = "nvidia,tegra186-bpmp";
> + interconnects = <&mc TEGRA186_MEMORY_CLIENT_BPMPR &emc>,
> + <&mc TEGRA186_MEMORY_CLIENT_BPMPW &emc>,
> + <&mc TEGRA186_MEMORY_CLIENT_BPMPDMAR &emc>,
> + <&mc TEGRA186_MEMORY_CLIENT_BPMPDMAW &emc>;
> + interconnect-names = "read", "write", "dma-mem", "dma-write";
> + iommus = <&smmu TEGRA186_SID_BPMP>;
> + mboxes = <&hsp_top0 TEGRA_HSP_MBOX_TYPE_DB

^^^ refers to hsp_top0.

> + TEGRA_HSP_DB_MASTER_BPMP>;
> + memory-region = <&dram_cpu_bpmp_mail>;
> + #clock-cells = <1>;
> + #power-domain-cells = <1>;
> + #reset-cells = <1>;
> +
> + i2c {
> + compatible = "nvidia,tegra186-bpmp-i2c";
> + nvidia,bpmp-bus-id = <5>;
> + #address-cells = <1>;
> + #size-cells = <0>;
> + };
> +
> + thermal {
> + compatible = "nvidia,tegra186-bpmp-thermal";
> + #thermal-sensor-cells = <1>;
> + };
> + };
> diff --git a/Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml b/Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml
> new file mode 100644
> index 000000000000..6cd9a61cd31f
> --- /dev/null
> +++ b/Documentation/devicetree/bindings/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml
> @@ -0,0 +1,40 @@
> +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
> +%YAML 1.2
> +---
> +$id: http://devicetree.org/schemas/reserved-memory/nvidia,tegra264-bpmp-shmem.yaml#
> +$schema: http://devicetree.org/meta-schemas/core.yaml#
> +
> +title: Tegra CPU-NS - BPMP IPC reserved memory binding

Drop "binding"

> +
> +maintainers:
> + - Peter De Schrijver <[email protected]>
> +
> +description: |
> + Define a memory region used for communication between CPU-NS and BPMP.
> + Typically this node is created by the bootloader as the physical address
> + has to be known to both CPU-NS and BPMP for correct IPC operation.
> + The memory region is defined using a child node under /reserved-memory.
> + The sub-node is named shmem@<address>.
> +

> Open other files there and implement it similar way. I really wonder why
> this should be done differently than for example other nvidia stuff -
> without reserved-memory schema?

Because up to now, the GSC was kept in sysram which is considered to be a device by the kernel. Now part of the DRAM will be reserved for this, so the kernel needs to know about it.

> +properties:
> + compatible:
> + const: nvidia,tegra264-bpmp-shmem
> +
> + reg:
> + description: The physical address and size of the shared SDRAM region
> +
> +required:
> + - compatible
> + - reg
> + - no-map
> +

Does not look like you tested the bindings. Please run `make
dt_binding_check` (see
Documentation/devicetree/bindings/writing-schema.rst for instructions).

> +examples:
> + - |
> + reserved-memory {
> + dram_cpu_bpmp_mail: shmem@f1be0000 {
> + compatible = "nvidia,tegra264-bpmp-shmem";
> + reg = <0x0 0xf1be0000 0x0 0x2000>;
> + no-map;
> + };
> + };
> +...

Best regards,
Krzysztof

2023-05-09 10:53:49

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH 5/5] firmware: tegra: bpmp: Add support for DRAM MRQ GSCs

Hi Peter,

kernel test robot noticed the following build warnings:

[auto build test WARNING on tegra/for-next]
[also build test WARNING on robh/for-next linus/master v6.4-rc1 next-20230509]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Peter-De-Schrijver/dt-bindings-mailbox-tegra-Document-Tegra264-HSP/20230508-203107
base: https://git.kernel.org/pub/scm/linux/kernel/git/tegra/linux.git for-next
patch link: https://lore.kernel.org/r/20230508122048.99953-6-pdeschrijver%40nvidia.com
patch subject: [PATCH 5/5] firmware: tegra: bpmp: Add support for DRAM MRQ GSCs
config: arm64-randconfig-s032-20230507 (https://download.01.org/0day-ci/archive/20230509/[email protected]/config)
compiler: aarch64-linux-gcc (GCC) 12.1.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# apt-get install sparse
# sparse version: v0.6.4-39-gce1a6720-dirty
# https://github.com/intel-lab-lkp/linux/commit/37f37c8af4622908dd3a8ca43d23c4e2310bdc20
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Peter-De-Schrijver/dt-bindings-mailbox-tegra-Document-Tegra264-HSP/20230508-203107
git checkout 37f37c8af4622908dd3a8ca43d23c4e2310bdc20
# save the config file
mkdir build_dir && cp config build_dir/.config
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm64 olddefconfig
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arm64 SHELL=/bin/bash drivers/firmware/tegra/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <[email protected]>
| Link: https://lore.kernel.org/oe-kbuild-all/[email protected]/

sparse warnings: (new ones prefixed by >>)
>> drivers/firmware/tegra/bpmp-tegra186.c:190:34: sparse: sparse: incorrect type in argument 1 (different address spaces) @@ expected void *addr @@ got void [noderef] __iomem *virt @@
drivers/firmware/tegra/bpmp-tegra186.c:190:34: sparse: expected void *addr
drivers/firmware/tegra/bpmp-tegra186.c:190:34: sparse: got void [noderef] __iomem *virt
>> drivers/firmware/tegra/bpmp-tegra186.c:248:23: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void [noderef] __iomem *virt @@ got void * @@
drivers/firmware/tegra/bpmp-tegra186.c:248:23: sparse: expected void [noderef] __iomem *virt
drivers/firmware/tegra/bpmp-tegra186.c:248:23: sparse: got void *
drivers/firmware/tegra/bpmp-tegra186.c:261:23: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void [noderef] __iomem *virt @@ got void * @@
drivers/firmware/tegra/bpmp-tegra186.c:261:23: sparse: expected void [noderef] __iomem *virt
drivers/firmware/tegra/bpmp-tegra186.c:261:23: sparse: got void *
drivers/firmware/tegra/bpmp-tegra186.c:303:23: sparse: sparse: incorrect type in assignment (different address spaces) @@ expected void [noderef] __iomem *virt @@ got void * @@
drivers/firmware/tegra/bpmp-tegra186.c:303:23: sparse: expected void [noderef] __iomem *virt
drivers/firmware/tegra/bpmp-tegra186.c:303:23: sparse: got void *

vim +190 drivers/firmware/tegra/bpmp-tegra186.c

170
171 static void tegra186_bpmp_channel_deinit(struct tegra_bpmp *bpmp)
172 {
173 int i;
174 struct tegra186_bpmp *priv = bpmp->priv;
175
176 for (i = 0; i < bpmp->threaded.count; i++) {
177 if (!bpmp->threaded_channels[i].bpmp)
178 continue;
179
180 tegra186_bpmp_channel_cleanup(&bpmp->threaded_channels[i]);
181 }
182
183 tegra186_bpmp_channel_cleanup(bpmp->rx_channel);
184 tegra186_bpmp_channel_cleanup(bpmp->tx_channel);
185
186 if (priv->type == TEGRA_SRAM) {
187 gen_pool_free(priv->sram.tx, (unsigned long)priv->tx.virt, 4096);
188 gen_pool_free(priv->sram.rx, (unsigned long)priv->rx.virt, 4096);
189 } else if (priv->type == TEGRA_RMEM) {
> 190 memunmap(priv->tx.virt);
191 }
192 }
193
194 static int tegra186_bpmp_channel_setup(struct tegra_bpmp *bpmp)
195 {
196 unsigned int i;
197 int err;
198
199 err = tegra186_bpmp_channel_init(bpmp->tx_channel, bpmp,
200 bpmp->soc->channels.cpu_tx.offset);
201 if (err < 0)
202 return err;
203
204 err = tegra186_bpmp_channel_init(bpmp->rx_channel, bpmp,
205 bpmp->soc->channels.cpu_rx.offset);
206 if (err < 0) {
207 tegra186_bpmp_channel_cleanup(bpmp->tx_channel);
208 return err;
209 }
210
211 for (i = 0; i < bpmp->threaded.count; i++) {
212 unsigned int index = bpmp->soc->channels.thread.offset + i;
213
214 err = tegra186_bpmp_channel_init(&bpmp->threaded_channels[i],
215 bpmp, index);
216 if (err < 0)
217 break;
218 }
219
220 if (err < 0)
221 tegra186_bpmp_channel_deinit(bpmp);
222
223 return err;
224 }
225
226 static void tegra186_bpmp_reset_channels(struct tegra_bpmp *bpmp)
227 {
228 unsigned int i;
229
230 tegra186_bpmp_channel_reset(bpmp->tx_channel);
231 tegra186_bpmp_channel_reset(bpmp->rx_channel);
232
233 for (i = 0; i < bpmp->threaded.count; i++)
234 tegra186_bpmp_channel_reset(&bpmp->threaded_channels[i]);
235 }
236
237 static int tegra186_bpmp_sram_init(struct tegra_bpmp *bpmp)
238 {
239 int err;
240 struct tegra186_bpmp *priv = bpmp->priv;
241
242 priv->sram.tx = of_gen_pool_get(bpmp->dev->of_node, "shmem", 0);
243 if (!priv->sram.tx) {
244 dev_err(bpmp->dev, "TX shmem pool not found\n");
245 return -EPROBE_DEFER;
246 }
247
> 248 priv->tx.virt = gen_pool_dma_alloc(priv->sram.tx, 4096, &priv->tx.phys);
249 if (!priv->tx.virt) {
250 dev_err(bpmp->dev, "failed to allocate from TX pool\n");
251 return -ENOMEM;
252 }
253
254 priv->sram.rx = of_gen_pool_get(bpmp->dev->of_node, "shmem", 1);
255 if (!priv->sram.rx) {
256 dev_err(bpmp->dev, "RX shmem pool not found\n");
257 err = -EPROBE_DEFER;
258 goto free_tx;
259 }
260
261 priv->rx.virt = gen_pool_dma_alloc(priv->sram.rx, 4096, &priv->rx.phys);
262 if (!priv->rx.virt) {
263 dev_err(bpmp->dev, "failed to allocate from RX pool\n");
264 err = -ENOMEM;
265 goto free_tx;
266 }
267
268 priv->type = TEGRA_SRAM;
269
270 return 0;
271
272 free_tx:
273 gen_pool_free(priv->sram.tx, (unsigned long)priv->tx.virt, 4096);
274
275 return err;
276 }
277

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests