Skip to contentSkip to conversation

Add iProc IDM device support

PATCH In review Ray Jui 4 participants 16 messages Dec 2, 2019 – Dec 16, 2019

Subsystems (2)
lore
Share & tools
lore

Ray Jui

author
#0 lore raw

cover Add iProc IDM device support

The Broadcom iProc IDM device allows control and monitoring of ASIC internal bus transactions. Most importantly, it can be configured to detect bus transaction timeout. In such case, critical information such as transaction address that caused the error, bus master ID of the transaction that caused the error, and etc., are made available from the IDM device.

This patch series adds the binding document and driver support for the iProc IDM devices.

The patch series is based off v5.4 and was tested on Broadcom Stingray combo SVK board. The patch series is available at:
Repo: https://github.com/Broadcom/arm64-linux.git
Branch: iproc-idm-v1

Ray Jui (2):
dt-bindings: soc: Add binding doc for iProc IDM device
soc: bcm: iproc: Add Broadcom iProc IDM driver

 .../bindings/soc/bcm/brcm,iproc-idm.txt       |  44 ++
 drivers/soc/bcm/Kconfig                       |  10 +
 drivers/soc/bcm/Makefile                      |   1 +
 drivers/soc/bcm/iproc/Kconfig                 |   6 +
 drivers/soc/bcm/iproc/Makefile                |   1 +
 drivers/soc/bcm/iproc/iproc-idm.c             | 390 ++++++++++++++++++
 6 files changed, 452 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt
 create mode 100644 drivers/soc/bcm/iproc/Kconfig
 create mode 100644 drivers/soc/bcm/iproc/Makefile
 create mode 100644 drivers/soc/bcm/iproc/iproc-idm.c
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH 1/2 dt-bindings: soc: Add binding doc for iProc IDM device

Add binding document for iProc based IDM devices.

---
 .../bindings/soc/bcm/brcm,iproc-idm.txt       | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt
Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt new file +44 -0
new file mode 100644
index 000000000000..388c6b036d7e
@@ -0,0 +1,44 @@
+Broadcom iProc Interconnect Device Management (IDM) device
+
+The Broadcom iProc IDM device allows control and monitoring of ASIC internal
+bus transactions. Most importantly, it can be configured to detect bus
+transaction timeout. In such case, critical information such as transaction
+address that caused the error, bus master ID of the transaction that caused
+the error, and etc., are made available from the IDM device.
+
+-------------------------------------------------------------------------------
+
+Required properties for IDM device node:
+- compatible: must be "brcm,iproc-idm"
+- reg: base address and length of the IDM register space
+- interrupt: IDM interrupt number
+- brcm,iproc-idm-bus: IDM bus string
+
+Optional properties for IDM device node:
+- brcm,iproc-idm-elog: phandle to the device node of the IDM logging device
+
+-------------------------------------------------------------------------------
+
+Required properties for IDM error logging device node:
+- compatible: must be "brcm,iproc-idm-elog";
+- reg: base address and length of reserved memory location where IDM error
+  events can be saved
+
+-------------------------------------------------------------------------------
+
+Example:
+
+idm {
+	idm-elog {
+		compatible = "brcm,iproc-idm-elog";
+		reg = <0x8f221000 0x1000>;
+	};
+
+	idm-mhb-paxc-axi {
+		compatible = "brcm,iproc-idm";
+		reg = <0x60406900 0x200>;
+		interrupt = <GIC_SPI 516 IRQ_TYPE_LEVEL_HIGH>;
+		brcm,iproc-idm-bus = "idm-mhb-paxc-axi";
+		brcm,iproc-idm-elog = <&idm-elog>;
+	};
+};
Signature · 1 line
2.17.1
#2 lore raw

Re: [PATCH 1/2] dt-bindings: soc: Add binding doc for iProc IDM device

Quoted 3 lines · Ray Jui

Add binding document for iProc based IDM devices.

Looks good to me, it's 2019, nearly 2020, maybe make this a YAML compatible binding since it is a new one?

Quoted 56 lines
---
 .../bindings/soc/bcm/brcm,iproc-idm.txt       | 44 +++++++++++++++++++
 1 file changed, 44 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt
Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt new file +44 -0
new file mode 100644
index 000000000000..388c6b036d7e
@@ -0,0 +1,44 @@
+Broadcom iProc Interconnect Device Management (IDM) device
+
+The Broadcom iProc IDM device allows control and monitoring of ASIC internal
+bus transactions. Most importantly, it can be configured to detect bus
+transaction timeout. In such case, critical information such as transaction
+address that caused the error, bus master ID of the transaction that caused
+the error, and etc., are made available from the IDM device.
+
+-------------------------------------------------------------------------------
+
+Required properties for IDM device node:
+- compatible: must be "brcm,iproc-idm"
+- reg: base address and length of the IDM register space
+- interrupt: IDM interrupt number
+- brcm,iproc-idm-bus: IDM bus string
+
+Optional properties for IDM device node:
+- brcm,iproc-idm-elog: phandle to the device node of the IDM logging device
+
+-------------------------------------------------------------------------------
+
+Required properties for IDM error logging device node:
+- compatible: must be "brcm,iproc-idm-elog";
+- reg: base address and length of reserved memory location where IDM error
+  events can be saved
+
+-------------------------------------------------------------------------------
+
+Example:
+
+idm {
+	idm-elog {
+		compatible = "brcm,iproc-idm-elog";
+		reg = <0x8f221000 0x1000>;
+	};
+
+	idm-mhb-paxc-axi {
+		compatible = "brcm,iproc-idm";
+		reg = <0x60406900 0x200>;
+		interrupt = <GIC_SPI 516 IRQ_TYPE_LEVEL_HIGH>;
+		brcm,iproc-idm-bus = "idm-mhb-paxc-axi";
+		brcm,iproc-idm-elog = <&idm-elog>;
+	};
+};
Signature · 1 line
Florian
author
#3 lore raw

Re: [PATCH 1/2] dt-bindings: soc: Add binding doc for iProc IDM device

Quoted 8 lines · Florian Fainelli
Quoted 3 lines · Ray Jui

Add binding document for iProc based IDM devices.

Looks good to me, it's 2019, nearly 2020, maybe make this a YAML compatible binding since it is a new one?

Sorry I am not aware of this YAML requirement until now.

Is this a new requirement that new DT binding document should be made with YAML format?

Thanks,

Ray

Quoted 58 lines
Quoted 56 lines
---
  .../bindings/soc/bcm/brcm,iproc-idm.txt       | 44 +++++++++++++++++++
  1 file changed, 44 insertions(+)

create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt

Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt new file +44 -0
new file mode 100644
index 000000000000..388c6b036d7e
@@ -0,0 +1,44 @@
+Broadcom iProc Interconnect Device Management (IDM) device
+
+The Broadcom iProc IDM device allows control and monitoring of ASIC internal
+bus transactions. Most importantly, it can be configured to detect bus
+transaction timeout. In such case, critical information such as transaction
+address that caused the error, bus master ID of the transaction that caused
+the error, and etc., are made available from the IDM device.
+
+-------------------------------------------------------------------------------
+
+Required properties for IDM device node:
+- compatible: must be "brcm,iproc-idm"
+- reg: base address and length of the IDM register space
+- interrupt: IDM interrupt number
+- brcm,iproc-idm-bus: IDM bus string
+
+Optional properties for IDM device node:
+- brcm,iproc-idm-elog: phandle to the device node of the IDM logging device
+
+-------------------------------------------------------------------------------
+
+Required properties for IDM error logging device node:
+- compatible: must be "brcm,iproc-idm-elog";
+- reg: base address and length of reserved memory location where IDM error
+  events can be saved
+
+-------------------------------------------------------------------------------
+
+Example:
+
+idm {
+	idm-elog {
+		compatible = "brcm,iproc-idm-elog";
+		reg = <0x8f221000 0x1000>;
+	};
+
+	idm-mhb-paxc-axi {
+		compatible = "brcm,iproc-idm";
+		reg = <0x60406900 0x200>;
+		interrupt = <GIC_SPI 516 IRQ_TYPE_LEVEL_HIGH>;
+		brcm,iproc-idm-bus = "idm-mhb-paxc-axi";
+		brcm,iproc-idm-elog = <&idm-elog>;
+	};
+};
maintainer
#4 lore raw

Re: [PATCH 1/2] dt-bindings: soc: Add binding doc for iProc IDM device

Quoted 8 lines · Ray Jui
Quoted 5 lines · Florian Fainelli
Quoted 3 lines · Ray Jui

Add binding document for iProc based IDM devices.

Quoted 8 lines
Quoted 3 lines

Looks good to me, it's 2019, nearly 2020, maybe make this a YAML compatible binding since it is a new one?

Sorry I am not aware of this YAML requirement until now.

Is this a new requirement that new DT binding document should be made with YAML format?

The format has been in place in the kernel for a year now and we've moved slowly towards it being required. If you're paying that little attention to upstream, then yes it's definitely required so someone else doesn't get stuck converting your binding later.

BTW, I think all but RPi chips still need their SoC/board bindings converted. One of the few not yet converted...

Quoted 23 lines

Thanks,

Ray

Quoted 18 lines
Quoted 18 lines
---
  .../bindings/soc/bcm/brcm,iproc-idm.txt       | 44 +++++++++++++++++++
  1 file changed, 44 insertions(+)

create mode 100644 Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt

Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt new file +7 -0
new file mode 100644
index 000000000000..388c6b036d7e
@@ -0,0 +1,44 @@
+Broadcom iProc Interconnect Device Management (IDM) device
+
+The Broadcom iProc IDM device allows control and monitoring of ASIC internal
+bus transactions. Most importantly, it can be configured to detect bus
+transaction timeout. In such case, critical information such as transaction
+address that caused the error, bus master ID of the transaction that caused
+the error, and etc., are made available from the IDM device.
Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt line 15

Quoted 8 lines
Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt new file +8 -0
+
+-------------------------------------------------------------------------------
+
+Required properties for IDM device node:
+- compatible: must be "brcm,iproc-idm"
+- reg: base address and length of the IDM register space
+- interrupt: IDM interrupt number
+- brcm,iproc-idm-bus: IDM bus string

What are possible values?

Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt new file +14 -0
+
+Optional properties for IDM device node:
+- brcm,iproc-idm-elog: phandle to the device node of the IDM logging device
+
+-------------------------------------------------------------------------------
+
+Required properties for IDM error logging device node:
+- compatible: must be "brcm,iproc-idm-elog";
+- reg: base address and length of reserved memory location where IDM error
+  events can be saved
+
+-------------------------------------------------------------------------------
+
+Example:
Quoted 8 lines
Quoted 8 lines

Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt line 37

Quoted 8 lines
Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt new file +8 -0
+
+idm {
+	idm-elog {
+		compatible = "brcm,iproc-idm-elog";
+		reg = <0x8f221000 0x1000>;
+	};
+
+	idm-mhb-paxc-axi {

Needs a unit-address.

Quoted 4 lines
Quoted 4 lines

Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt line 41

Quoted 4 lines
Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt new file +4 -0
+		compatible = "brcm,iproc-idm";
+		reg = <0x60406900 0x200>;
+		interrupt = <GIC_SPI 516 IRQ_TYPE_LEVEL_HIGH>;
+		brcm,iproc-idm-bus = "idm-mhb-paxc-axi";

Can't you just use the node name? Though if this is something that can be a standard class of h/w (i.e. EDAC), then we'd want the node name to be generic.

Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
Documentation/devicetree/bindings/soc/bcm/brcm,iproc-idm.txt new file +3 -0
+		brcm,iproc-idm-elog = <&idm-elog>;
+	};
+};
#5 lore raw

Re: [PATCH 1/2] dt-bindings: soc: Add binding doc for iProc IDM device

Quoted 18 lines · Rob Herring
Quoted 8 lines · Ray Jui
Quoted 5 lines · Florian Fainelli
Quoted 3 lines · Ray Jui

Add binding document for iProc based IDM devices.

Quoted 8 lines
Quoted 3 lines

Looks good to me, it's 2019, nearly 2020, maybe make this a YAML compatible binding since it is a new one?

Sorry I am not aware of this YAML requirement until now.

Is this a new requirement that new DT binding document should be made with YAML format?

Quoted 7 lines

The format has been in place in the kernel for a year now and we've moved slowly towards it being required. If you're paying that little attention to upstream, then yes it's definitely required so someone else doesn't get stuck converting your binding later.

BTW, I think all but RPi chips still need their SoC/board bindings converted. One of the few not yet converted...

Is there something more to do than what Stefan did here:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ab06837dd269b600396b298e9f4678d02b11b71d

we could convert other Broadcom SoCs, and there, just found another weekend project!

Signature · 1 line
Florian
maintainer
#6 lore raw

Re: [PATCH 1/2] dt-bindings: soc: Add binding doc for iProc IDM device

Quoted 27 lines · Florian Fainelli
Quoted 23 lines · Rob Herring
Quoted 8 lines · Ray Jui
Quoted 5 lines · Florian Fainelli
Quoted 3 lines · Ray Jui

Add binding document for iProc based IDM devices.

Quoted 8 lines
Quoted 3 lines

Looks good to me, it's 2019, nearly 2020, maybe make this a YAML compatible binding since it is a new one?

Sorry I am not aware of this YAML requirement until now.

Is this a new requirement that new DT binding document should be made with YAML format?

The format has been in place in the kernel for a year now and we've moved slowly towards it being required. If you're paying that little attention to upstream, then yes it's definitely required so someone else doesn't get stuck converting your binding later.

Quoted 6 lines
Quoted 2 lines

BTW, I think all but RPi chips still need their SoC/board bindings converted. One of the few not yet converted...

Is there something more to do than what Stefan did here:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ab06837dd269b600396b298e9f4678d02b11b71d

No, that's it.

Quoted 4 lines

we could convert other Broadcom SoCs, and there, just found another weekend project!
--
Florian

author
#7 lore raw

PATCH 2/2 soc: bcm: iproc: Add Broadcom iProc IDM driver

In reply to Ray Jui

Add Broadcom iProc IDM driver that controls that IDM devices available on various iProc based SoCs for bus transaction timeout monitoring and error logging.

---
 drivers/soc/bcm/Kconfig           |  10 +
 drivers/soc/bcm/Makefile          |   1 +
 drivers/soc/bcm/iproc/Kconfig     |   6 +
 drivers/soc/bcm/iproc/Makefile    |   1 +
 drivers/soc/bcm/iproc/iproc-idm.c | 390 ++++++++++++++++++++++++++++++
 5 files changed, 408 insertions(+)
 create mode 100644 drivers/soc/bcm/iproc/Kconfig
 create mode 100644 drivers/soc/bcm/iproc/Makefile
 create mode 100644 drivers/soc/bcm/iproc/iproc-idm.c
drivers/soc/bcm/Kconfig +10 -0
index 648e32693b7e..30cf0c390c4e 100644
@@ -33,6 +33,16 @@ config SOC_BRCMSTB
 
 	  If unsure, say N.
 
+config SOC_BRCM_IPROC
+	bool "Broadcom iProc SoC drivers"
+	depends on ARCH_BCM_IPROC || COMPILE_TEST
+	default ARCH_BCM_IPROC
+	help
+	  Enable SoC drivers for Broadcom iProc based chipsets
+
+	  If unsure, say N.
+
 source "drivers/soc/bcm/brcmstb/Kconfig"
+source "drivers/soc/bcm/iproc/Kconfig"
 
 endmenu
drivers/soc/bcm/Makefile +1 -0
index d92268a829a9..9db23ab5dacc 100644
@@ -2,3 +2,4 @@
 obj-$(CONFIG_BCM2835_POWER)	+= bcm2835-power.o
 obj-$(CONFIG_RASPBERRYPI_POWER)	+= raspberrypi-power.o
 obj-$(CONFIG_SOC_BRCMSTB)	+= brcmstb/
+obj-$(CONFIG_SOC_BRCM_IPROC)	+= iproc/
drivers/soc/bcm/iproc/Kconfig new file +6 -0
new file mode 100644
index 000000000000..205e0ebbf99c
@@ -0,0 +1,6 @@
+config IPROC_IDM
+	bool "Broadcom iProc IDM driver"
+	depends on (ARCH_BCM_IPROC || COMPILE_TEST) && OF
+	default ARCH_BCM_IPROC
+	help
+	  Enables support for iProc Interconnect and Device Management (IDM) control and monitoring
drivers/soc/bcm/iproc/Makefile new file +1 -0
new file mode 100644
index 000000000000..de54aef66097
@@ -0,0 +1 @@
+obj-$(CONFIG_IPROC_IDM)	+= iproc-idm.o
drivers/soc/bcm/iproc/iproc-idm.c new file +390 -0

390 lines not on this page · raw message

Signature · 1 line
2.17.1
#8 lore raw

Re: [PATCH 2/2] soc: bcm: iproc: Add Broadcom iProc IDM driver

Quoted 7 lines · Ray Jui

Add Broadcom iProc IDM driver that controls that IDM devices available on various iProc based SoCs for bus transaction timeout monitoring and error logging.

---

Looks good to me, just a few suggestions below

[snip]

drivers/soc/bcm/iproc/Kconfig

Quoted 3 lines
drivers/soc/bcm/iproc/Kconfig new file +0 -0
@@ -0,0 +1,6 @@

You would want an

if SOC_BRCM_IPROC

drivers/soc/bcm/iproc/Kconfig line 6

Quoted 6 lines
drivers/soc/bcm/iproc/Kconfig new file +6 -0
+config IPROC_IDM
+	bool "Broadcom iProc IDM driver"
+	depends on (ARCH_BCM_IPROC || COMPILE_TEST) && OF
+	default ARCH_BCM_IPROC
+	help
+	  Enables support for iProc Interconnect and Device Management (IDM) control and monitoring

and endif here to make this a nice menu.

[snip]

Quoted 28 lines
drivers/soc/bcm/iproc/Kconfig new file +28 -0
+
+static int iproc_idm_dev_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+	struct platform_device *elog_pdev;
+	struct device_node *elog_np;
+	struct iproc_idm *idm;
+	const char *name;
+	int ret;
+	u32 val;
+
+	idm = devm_kzalloc(dev, sizeof(*idm), GFP_KERNEL);
+	if (!idm)
+		return -ENOMEM;
+
+	ret = of_property_read_string(np, "brcm,iproc-idm-bus", &name);
+	if (ret) {
+		dev_err(dev, "Unable to parse IDM bus name\n");
+		return ret;
+	}
+	idm->name = name;
+
+	platform_set_drvdata(pdev, idm);
+	idm->dev = dev;
+
+	idm->base = of_iomap(np, 0);
+	if (!idm->base) {

drivers/soc/bcm/iproc/Kconfig

Quoted 10 lines
drivers/soc/bcm/iproc/Kconfig new file +10 -0
+		dev_err(dev, "Unable to map I/O\n");
+		ret = -ENOMEM;
+		goto err_exit;
+	}
+
+	ret = of_irq_get(np, 0);
+	if (ret <= 0) {
+		dev_err(dev, "Unable to find IRQ number. ret=%d\n", ret);
+		goto err_iounmap;
+	}

Since this is a standard platform device, you can use the standard platform_get_resource() and platform_get_irq(). If you ever needed to support ACPI in the future, that would make it transparent and almost already ready.

Quoted 30 lines
drivers/soc/bcm/iproc/Kconfig new file +30 -0
+
+	ret = devm_request_irq(dev, ret, iproc_idm_irq_handler, IRQF_SHARED,
+			       idm->name, idm);
+	if (ret < 0) {
+		dev_err(dev, "Unable to request irq. ret=%d\n", ret);
+		goto err_iounmap;
+	}
+
+	/*
+	 * ELOG phandle is optional. If ELOG phandle is specified, it indicates
+	 * ELOG logging needs to be enabled
+	 */
+	elog_np = of_parse_phandle(dev->of_node, ELOG_IDM_COMPAT_STR, 0);
+	if (elog_np) {
+		elog_pdev = of_find_device_by_node(elog_np);
+		if (!elog_pdev) {
+			dev_err(dev, "Unable to find IDM ELOG device\n");
+			ret = -ENODEV;
+			goto err_iounmap;
+		}
+
+		idm->elog = platform_get_drvdata(elog_pdev);
+		if (!idm->elog) {
+			dev_err(dev, "Unable to get IDM ELOG driver data\n");
+			ret = -EINVAL;
+			goto err_iounmap;
+		}
+	}
+
+	/* enable IDM timeout and its interrupt */

drivers/soc/bcm/iproc/Kconfig

Quoted 10 lines
drivers/soc/bcm/iproc/Kconfig new file +10 -0
+	val = readl(idm->base + IDM_CTRL_OFFSET);
+	val |= IDM_CTRL_TIMEOUT_EXP_MASK | IDM_CTRL_TIMEOUT_ENABLE |
+	       IDM_CTRL_TIMEOUT_IRQ;
+	writel(val, idm->base + IDM_CTRL_OFFSET);
+
+	ret = device_create_file(dev, &dev_attr_no_panic);
+	if (ret < 0)
+		goto err_iounmap;
+
+	of_node_put(np);

Did not you intend to drop the reference count on elog_np here?

[snip]

drivers/soc/bcm/iproc/Kconfig

Quoted 2 lines
drivers/soc/bcm/iproc/Kconfig new file +2 -0
+static struct platform_driver iproc_idm_driver = {
+	.probe = iproc_idm_probe,

Do not you need a remove function in order to unregister the sysfs file that you created in iproc_idm_dev_probe() to avoid bind/unbind (or rmmod/modprobe) to spit out an existing sysfs entry warning?

Signature · 1 line
Florian
author
#9 lore raw

Re: [PATCH 2/2] soc: bcm: iproc: Add Broadcom iProc IDM driver

Quoted 21 lines · Florian Fainelli
Quoted 7 lines · Ray Jui

Add Broadcom iProc IDM driver that controls that IDM devices available on various iProc based SoCs for bus transaction timeout monitoring and error logging.

---

Looks good to me, just a few suggestions below

[snip]

drivers/soc/bcm/iproc/Kconfig

Quoted 3 lines
drivers/soc/bcm/iproc/Kconfig new file +0 -0
@@ -0,0 +1,6 @@

You would want an

if SOC_BRCM_IPROC

Quoted 9 lines

drivers/soc/bcm/iproc/Kconfig line 6

Quoted 6 lines
drivers/soc/bcm/iproc/Kconfig new file +6 -0
+config IPROC_IDM
+	bool "Broadcom iProc IDM driver"
+	depends on (ARCH_BCM_IPROC || COMPILE_TEST) && OF
+	default ARCH_BCM_IPROC
+	help
+	  Enables support for iProc Interconnect and Device Management (IDM) control and monitoring

and endif here to make this a nice menu.

Sure I'll add SOC_BRCM_IPROC at one layer higher and use the if here.

Quoted 37 lines

[snip]

Quoted 35 lines
drivers/soc/bcm/iproc/Kconfig new file +35 -0
+
+static int iproc_idm_dev_probe(struct platform_device *pdev)
+{
+	struct device *dev = &pdev->dev;
+	struct device_node *np = dev->of_node;
+	struct platform_device *elog_pdev;
+	struct device_node *elog_np;
+	struct iproc_idm *idm;
+	const char *name;
+	int ret;
+	u32 val;
+
+	idm = devm_kzalloc(dev, sizeof(*idm), GFP_KERNEL);
+	if (!idm)
+		return -ENOMEM;
+
+	ret = of_property_read_string(np, "brcm,iproc-idm-bus", &name);
+	if (ret) {
+		dev_err(dev, "Unable to parse IDM bus name\n");
+		return ret;
+	}
+	idm->name = name;
+
+	platform_set_drvdata(pdev, idm);
+	idm->dev = dev;
+
+	idm->base = of_iomap(np, 0);
+	if (!idm->base) {
+		dev_err(dev, "Unable to map I/O\n");
+		ret = -ENOMEM;
+		goto err_exit;
+	}
+
+	ret = of_irq_get(np, 0);
+	if (ret <= 0) {
Quoted 9 lines

drivers/soc/bcm/iproc/Kconfig

Quoted 3 lines
drivers/soc/bcm/iproc/Kconfig new file +3 -0
+		dev_err(dev, "Unable to find IRQ number. ret=%d\n", ret);
+		goto err_iounmap;
+	}

Since this is a standard platform device, you can use the standard platform_get_resource() and platform_get_irq(). If you ever needed to support ACPI in the future, that would make it transparent and almost already ready.

Will do, thanks!

Quoted 34 lines
Quoted 34 lines
drivers/soc/bcm/iproc/Kconfig new file +34 -0
+
+	ret = devm_request_irq(dev, ret, iproc_idm_irq_handler, IRQF_SHARED,
+			       idm->name, idm);
+	if (ret < 0) {
+		dev_err(dev, "Unable to request irq. ret=%d\n", ret);
+		goto err_iounmap;
+	}
+
+	/*
+	 * ELOG phandle is optional. If ELOG phandle is specified, it indicates
+	 * ELOG logging needs to be enabled
+	 */
+	elog_np = of_parse_phandle(dev->of_node, ELOG_IDM_COMPAT_STR, 0);
+	if (elog_np) {
+		elog_pdev = of_find_device_by_node(elog_np);
+		if (!elog_pdev) {
+			dev_err(dev, "Unable to find IDM ELOG device\n");
+			ret = -ENODEV;
+			goto err_iounmap;
+		}
+
+		idm->elog = platform_get_drvdata(elog_pdev);
+		if (!idm->elog) {
+			dev_err(dev, "Unable to get IDM ELOG driver data\n");
+			ret = -EINVAL;
+			goto err_iounmap;
+		}
+	}
+
+	/* enable IDM timeout and its interrupt */
+	val = readl(idm->base + IDM_CTRL_OFFSET);
+	val |= IDM_CTRL_TIMEOUT_EXP_MASK | IDM_CTRL_TIMEOUT_ENABLE |
+	       IDM_CTRL_TIMEOUT_IRQ;
+	writel(val, idm->base + IDM_CTRL_OFFSET);
Quoted 9 lines

drivers/soc/bcm/iproc/Kconfig

Quoted 6 lines
drivers/soc/bcm/iproc/Kconfig new file +6 -0
+
+	ret = device_create_file(dev, &dev_attr_no_panic);
+	if (ret < 0)
+		goto err_iounmap;
+
+	of_node_put(np);

Did not you intend to drop the reference count on elog_np here?

Sorry, I'm not following this comment. Could you please help to clarify for me a bit more? Thanks!

Quoted 9 lines

[snip]

drivers/soc/bcm/iproc/Kconfig

Quoted 2 lines
drivers/soc/bcm/iproc/Kconfig new file +2 -0
+static struct platform_driver iproc_idm_driver = {
+	.probe = iproc_idm_probe,

Do not you need a remove function in order to unregister the sysfs file that you created in iproc_idm_dev_probe() to avoid bind/unbind (or rmmod/modprobe) to spit out an existing sysfs entry warning?

This driver should never be compiled as a module. It's meant to be always there to capture IDM bus timeouts.

But you are right that I cannot prevent user from trying to unbind it for whatever reason. I'll add a remove routine to take care of this.

Thanks!

Ray

#10 lore raw

Re: [PATCH 2/2] soc: bcm: iproc: Add Broadcom iProc IDM driver

Quoted 6 lines · Ray Jui
Quoted 3 lines

Did not you intend to drop the reference count on elog_np here?

Sorry, I'm not following this comment. Could you please help to clarify for me a bit more? Thanks!

I meant that you drop the reference count on 'np' but you called functions that incremented the reference count on 'elog_np', so maybe you are not doing the of_node_put() on the appropriate device_node reference?

Quoted 11 lines
Quoted 10 lines

[snip]

Quoted 2 lines

+static struct platform_driver iproc_idm_driver = { +    .probe = iproc_idm_probe,

Do not you need a remove function in order to unregister the sysfs file that you created in iproc_idm_dev_probe() to avoid bind/unbind (or rmmod/modprobe) to spit out an existing sysfs entry warning?

Quoted 5 lines

This driver should never be compiled as a module. It's meant to be always there to capture IDM bus timeouts.

But you are right that I cannot prevent user from trying to unbind it for whatever reason. I'll add a remove routine to take care of this.

You can also set suppress_bind_attrs to your platform_driver structure to prevent unbind/bind from happening.

Signature · 1 line
Florian
author
#11 lore raw

Re: [PATCH 2/2] soc: bcm: iproc: Add Broadcom iProc IDM driver

Quoted 7 lines · Florian Fainelli
Quoted 4 lines · Ray Jui
Quoted 3 lines

Did not you intend to drop the reference count on elog_np here?

Quoted 8 lines
Quoted 2 lines

Sorry, I'm not following this comment. Could you please help to clarify for me a bit more? Thanks!

I meant that you drop the reference count on 'np' but you called functions that incremented the reference count on 'elog_np', so maybe you are not doing the of_node_put() on the appropriate device_node reference?

Okay thanks. I'll look into this in more details and make corrections if needed.

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines

[snip]

Quoted 2 lines

+static struct platform_driver iproc_idm_driver = { +    .probe = iproc_idm_probe,

Do not you need a remove function in order to unregister the sysfs file that you created in iproc_idm_dev_probe() to avoid bind/unbind (or rmmod/modprobe) to spit out an existing sysfs entry warning?

Quoted 9 lines
Quoted 5 lines

This driver should never be compiled as a module. It's meant to be always there to capture IDM bus timeouts.

But you are right that I cannot prevent user from trying to unbind it for whatever reason. I'll add a remove routine to take care of this.

You can also set suppress_bind_attrs to your platform_driver structure to prevent unbind/bind from happening.

Great. This is what I'll do then. I meant to have this driver stays loaded/binded all the time once probed.

Thanks,

Ray

#12 lore raw
In reply to Ray Jui
Quoted 5 lines · On Mon, 2 Dec 2019 15:31:25 -0800 Ray Jui <[email protected]> wrote:

The Broadcom iProc IDM device allows control and monitoring of ASIC internal bus transactions. Most importantly, it can be configured to detect bus transaction timeout. In such case, critical information such as transaction address that caused the error, bus master ID of the transaction that caused the error, and etc., are made available from the IDM device.

This seems to have many of the features of an EDAC device reporting uncorrectable errors.

Is there any reason why it is not implemented as such?

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
author
#13 lore raw
Quoted 9 lines · Marc Zyngier
Quoted 5 lines · On Mon, 2 Dec 2019 15:31:25 -0800 Ray Jui <[email protected]> wrote:

The Broadcom iProc IDM device allows control and monitoring of ASIC internal bus transactions. Most importantly, it can be configured to detect bus transaction timeout. In such case, critical information such as transaction address that caused the error, bus master ID of the transaction that caused the error, and etc., are made available from the IDM device.

Quoted 9 lines

This seems to have many of the features of an EDAC device reporting uncorrectable errors.

Is there any reason why it is not implemented as such?

Thanks,

	M.

I thought EDAC errors (in fact, in our case, that's fatal rather than uncorrectable) are mostly for DDR. Is my understanding incorrect?

Thanks,

Ray

#14 lore raw
Quoted 15 lines · On Mon, 9 Dec 2019 10:02:53 -0800 Ray Jui <[email protected]> wrote:
Quoted 14 lines · Marc Zyngier
Quoted 5 lines · On Mon, 2 Dec 2019 15:31:25 -0800 Ray Jui <[email protected]> wrote:

The Broadcom iProc IDM device allows control and monitoring of ASIC internal bus transactions. Most importantly, it can be configured to detect bus transaction timeout. In such case, critical information such as transaction address that caused the error, bus master ID of the transaction that caused the error, and etc., are made available from the IDM device.

This seems to have many of the features of an EDAC device reporting uncorrectable errors.

Is there any reason why it is not implemented as such?

Quoted 7 lines
Quoted 4 lines

Thanks,

	M.

I thought EDAC errors (in fact, in our case, that's fatal rather than uncorrectable) are mostly for DDR. Is my understanding incorrect?

No, they are for HW errors in general. There is no real limitation of scope, as far as I understand. Recently, the Annapurna guys came up with a similar HW block, and were convinced to make it an EDAC device.

See [1] for details.

Thanks,

	M.

[1] https://lore.kernel.org/linux-devicetree/[email protected]/

Signature · 1 line
Jazz is not dead. It just smells funny...
author
#15 lore raw
Quoted 30 lines · Marc Zyngier
Quoted 15 lines · On Mon, 9 Dec 2019 10:02:53 -0800 Ray Jui <[email protected]> wrote:
Quoted 14 lines · Marc Zyngier
Quoted 5 lines · On Mon, 2 Dec 2019 15:31:25 -0800 Ray Jui <[email protected]> wrote:

The Broadcom iProc IDM device allows control and monitoring of ASIC internal bus transactions. Most importantly, it can be configured to detect bus transaction timeout. In such case, critical information such as transaction address that caused the error, bus master ID of the transaction that caused the error, and etc., are made available from the IDM device.

This seems to have many of the features of an EDAC device reporting uncorrectable errors.

Is there any reason why it is not implemented as such?

Quoted 7 lines
Quoted 4 lines

Thanks,

	M.

I thought EDAC errors (in fact, in our case, that's fatal rather than uncorrectable) are mostly for DDR. Is my understanding incorrect?

No, they are for HW errors in general. There is no real limitation of scope, as far as I understand. Recently, the Annapurna guys came up with a similar HW block, and were convinced to make it an EDAC device.

Quoted 8 lines

See [1] for details.

Thanks,

	M.

[1] https://lore.kernel.org/linux-devicetree/[email protected]/

Ah I see. It looks like memory controllers are the primary devices supported by EDAC. In addition to that, EDAC also does seem to provide a generic data structure to support other types of HW devices and error events. I'll look into this and get back.

Thanks,

Ray