Skip to contentSkip to conversation

Add Keystone2 Remoteproc driver

PATCH In review Suman Anna 3 participants 11 messages Jun 13, 2017 – Sep 6, 2022

Subsystems (2)
lore
Share & tools
lore

Suman Anna

author
#0 lore raw

v3 cover Add Keystone2 Remoteproc driver

Hi Bjorn,

This is v3 of the patchset that adds the DT binding and the driver for loading and booting the DSP devices present on various Keystone2 SoC families. The binding and driver patches have already been acked by Rob Herring and Santosh Shilimkar respectively, and this is just a minor refresh with one small comment from Rob addressed in the binding (Patch 1). There are no code changes in remaining patches. I have picked up their Acks in all the relevant patches.

Appreciate it if you can pick up the series for v4.13.

v2:
http://marc.info/?l=linux-kernel&m=149688154304565&w=2
v1:
http://marc.info/?t=149581802500004&r=1&w=2

regards
Suman

Andrew F. Davis (1):
remoteproc/keystone: Ensure the DSPs are in reset in probe

Suman Anna (2):
dt-bindings: remoteproc: Add Keystone DSP remoteproc binding remoteproc/keystone: Add a remoteproc driver for Keystone 2 DSPs

 .../bindings/remoteproc/ti,keystone-rproc.txt      | 133 ++++++
 drivers/remoteproc/Kconfig                         |  13 +
 drivers/remoteproc/Makefile                        |   1 +
 drivers/remoteproc/keystone_remoteproc.c           | 525 +++++++++++++++++++++
 4 files changed, 672 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/remoteproc/ti,keystone-rproc.txt
 create mode 100644 drivers/remoteproc/keystone_remoteproc.c
Signature · 1 line
2.13.1
author
#1 lore raw

PATCH v3 1/3 dt-bindings: remoteproc: Add Keystone DSP remoteproc binding

Add the device tree bindings document for the Texas Instrument's Keystone 2 DSP remoteproc devices.

---
v3:
- Picked up the Acks from Rob and Santosh, and addressed the one minor comment from Rob - removing the label property usage from example
v2: https://patchwork.kernel.org/patch/9773681/

 .../bindings/remoteproc/ti,keystone-rproc.txt      | 133 +++++++++++++++++++++
 1 file changed, 133 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/remoteproc/ti,keystone-rproc.txt
Documentation/devicetree/bindings/remoteproc/ti,keystone-rproc.txt new file +133 -0
new file mode 100644
index 000000000000..2aac1aa4123d
@@ -0,0 +1,133 @@
+TI Keystone DSP devices
+=======================
+
+The TI Keystone 2 family of SoCs usually have one or more (upto 8) TI DSP Core
+sub-systems that are used to offload some of the processor-intensive tasks or
+algorithms, for achieving various system level goals.
+
+These processor sub-systems usually contain additional sub-modules like L1
+and/or L2 caches/SRAMs, an Interrupt Controller, an external memory controller,
+a dedicated local power/sleep controller etc. The DSP processor core in
+Keystone 2 SoCs is usually a TMS320C66x CorePac processor.
+
+DSP Device Node:
+================
+Each DSP Core sub-system is represented as a single DT node, and should also
+have an alias with the stem 'rproc' defined. Each node has a number of required
+or optional properties that enable the OS running on the host processor (ARM
+CorePac) to perform the device management of the remote processor and to
+communicate with the remote processor.
+
+Required properties:
+--------------------
+The following are the mandatory properties:
+
+- compatible:		Should be one of the following,
+			    "ti,k2hk-dsp" for DSPs on Keystone 2 66AK2H/K SoCs
+			    "ti,k2l-dsp" for DSPs on Keystone 2 66AK2L SoCs
+			    "ti,k2e-dsp" for DSPs on Keystone 2 66AK2E SoCs
+
+- reg:			Should contain an entry for each value in 'reg-names'.
+			Each entry should have the memory region's start address
+			and the size of the region, the representation matching
+			the parent node's '#address-cells' and '#size-cells' values.
+
+- reg-names:		Should contain strings with the following names, each
+			representing a specific internal memory region, and
+			should be defined in this order,
+			     "l2sram", "l1pram", "l1dram"
+
+- clocks: 		Should contain the device's input clock, and should be
+			defined as per the bindings in,
+			Documentation/devicetree/bindings/clock/keystone-gate.txt
+
+- ti,syscon-dev:	Should be a pair of the phandle to the Keystone Device
+			State Control node, and the register offset of the DSP
+			boot address register within that node's address space.
+
+- resets:		Should contain the phandle to the reset controller node
+			managing the resets for this device, and a reset
+			specifier. Please refer to the following reset bindings
+			for the reset argument specifier as per SoC,
+			Documentation/devicetree/bindings/reset/ti-syscon-reset.txt
+			    for 66AK2HK/66AK2L/66AK2E SoCs
+
+- interrupt-parent:	Should contain a phandle to the Keystone 2 IRQ controller
+			IP node that is used by the ARM CorePac processor to
+			receive interrupts from the DSP remote processors. See
+			Documentation/devicetree/bindings/interrupt-controller/ti,keystone-irq.txt
+			for details.
+
+- interrupts: 		Should contain an entry for each value in 'interrupt-names'.
+			Each entry should have the interrupt source number used by
+			the remote processor to the host processor. The values should
+			follow the interrupt-specifier format as dictated by the
+			'interrupt-parent' node. The purpose of each is as per the
+			description in the 'interrupt-names' property.
+
+- interrupt-names:	Should contain strings with the following names, each
+			representing a specific interrupt,
+			    "vring" - interrupt for virtio based IPC
+			    "exception" - interrupt for exception notification
+
+- kick-gpios: 		Should specify the gpio device needed for the virtio IPC
+			stack. This will be used to interrupt the remote processor.
+			The gpio device to be used is as per the bindings in,
+			Documentation/devicetree/bindings/gpio/gpio-dsp-keystone.txt
+
+Optional properties:
+--------------------
+
+- memory-region:	phandle to the reserved memory node to be associated
+			with the remoteproc device. The reserved memory node
+			can be a CMA memory node, and should be defined as
+			per the bindings in
+			Documentation/devicetree/bindings/reserved-memory/reserved-memory.txt
+
+
+Example:
+--------
+	/* 66AK2H/K DSP aliases */
+	aliases {
+		rproc0 = &dsp0;
+		rproc1 = &dsp1;
+		rproc2 = &dsp2;
+		rproc3 = &dsp3;
+		rproc4 = &dsp4;
+		rproc5 = &dsp5;
+		rproc6 = &dsp6;
+		rproc7 = &dsp7;
+	};
+
+	/* 66AK2H/K DSP memory node */
+	reserved-memory {
+		#address-cells = <2>;
+		#size-cells = <2>;
+		ranges;
+
+		dsp_common_memory: dsp-common-memory at 81f800000 {
+			compatible = "shared-dma-pool";
+			reg = <0x00000008 0x1f800000 0x00000000 0x800000>;
+			reusable;
+		};
+	};
+
+	/* 66AK2H/K DSP node */
+	soc {
+		dsp0: dsp at 10800000 {
+			compatible = "ti,k2hk-dsp";
+			reg = <0x10800000 0x00100000>,
+			      <0x10e00000 0x00008000>,
+			      <0x10f00000 0x00008000>;
+			reg-names = "l2sram", "l1pram", "l1dram";
+			clocks = <&clkgem0>;
+			ti,syscon-dev = <&devctrl 0x40>;
+			resets = <&pscrst 0>;
+			interrupt-parent = <&kirq0>;
+			interrupts = <0 8>;
+			interrupt-names = "vring", "exception";
+			kick-gpios = <&dspgpio0 27 0>;
+			memory-region = <&dsp_common_memory>;
+		};
+
+	};
Signature · 1 line
2.13.1
author
#2 lore raw

PATCH v3 2/3 remoteproc/keystone: Add a remoteproc driver for Keystone 2 DSPs

In reply to Suman Anna

The Texas Instrument's Keystone 2 family of SoCs has 1 or more TMS320C66x DSP Core Subsystems (C66x CorePacs). Each subsystem has a C66x Fixed/Floating-Point DSP Core, with 32KB of L1P and L1D SRAMs, that can be configured and partitioned as either RAM and/or Cache, and 1 MB of L2 SRAM. The CorePac also includes an Internal DMA (IDMA), External Memory Controller (EMC), Extended Memory Controller (XMC) with a Memory Protection and Address Extension (MPAX) unit, a Bandwidth Management (BWM) unit, an Interrupt Controller (INTC) and a Powerdown Controller (PDC).

A new remoteproc module is added to perform the device management of these DSP devices. The driver expects the firmware names to be of the form "keystone-dsp<X>-fw", where X is the corresponding DSP number, and uses the standard remoteproc core ELF loader. The support is limited to images only using the DSP internal memories at the moment. This remoteproc driver is also designed to work with virtio, and uses the IPC Generation registers for performing the virtio signalling and getting notified of exceptions.

The driver currently supports the 66AK2H/66AK2K, 66AK2L and 66AK2E SoCs.

---
v3: No code changes, picked up Santosh's Ack
v2: https://patchwork.kernel.org/patch/9773685/

 drivers/remoteproc/Kconfig               |  13 +
 drivers/remoteproc/Makefile              |   1 +
 drivers/remoteproc/keystone_remoteproc.c | 515 +++++++++++++++++++++++++++++++
 3 files changed, 529 insertions(+)
 create mode 100644 drivers/remoteproc/keystone_remoteproc.c
drivers/remoteproc/Kconfig +13 -0
index faad69a1a597..9839b35b6ab3 100644
@@ -71,6 +71,19 @@ config DA8XX_REMOTEPROC
 	  It's safe to say n here if you're not interested in multimedia
 	  offloading.
 
+config KEYSTONE_REMOTEPROC
+	tristate "Keystone Remoteproc support"
+	depends on ARCH_KEYSTONE
+	depends on RESET_CONTROLLER
+	depends on REMOTEPROC
+	select RPMSG_VIRTIO
+	help
+	  Say Y here here to support Keystone remote processors (DSP)
+	  via the remote processor framework.
+
+	  It's safe to say N here if you're not interested in the Keystone
+	  DSPs or just want to use a bare minimum kernel.
+
 config QCOM_ADSP_PIL
 	tristate "Qualcomm ADSP Peripheral Image Loader"
 	depends on OF && ARCH_QCOM
drivers/remoteproc/Makefile +1 -0
index ffc5e430df27..f1ce5fc8a2f3 100644
@@ -11,6 +11,7 @@ remoteproc-y				+= remoteproc_elf_loader.o
 obj-$(CONFIG_OMAP_REMOTEPROC)		+= omap_remoteproc.o
 obj-$(CONFIG_WKUP_M3_RPROC)		+= wkup_m3_rproc.o
 obj-$(CONFIG_DA8XX_REMOTEPROC)		+= da8xx_remoteproc.o
+obj-$(CONFIG_KEYSTONE_REMOTEPROC)	+= keystone_remoteproc.o
 obj-$(CONFIG_QCOM_ADSP_PIL)		+= qcom_adsp_pil.o
 obj-$(CONFIG_QCOM_RPROC_COMMON)		+= qcom_common.o
 obj-$(CONFIG_QCOM_Q6V5_PIL)		+= qcom_q6v5_pil.o
drivers/remoteproc/keystone_remoteproc.c new file +515 -0

515 lines not on this page · raw message

Signature · 1 line
2.13.1
author
#9 lore raw

PATCH v3 3/3 remoteproc/keystone: Ensure the DSPs are in reset in probe

In reply to Suman Anna

From: "Andrew F. Davis" <[email protected]>

The DSPs are expected to be in reset when the driver probes a device. If the DSPs are out of reset in probe, the system may crash when the firmware is being loaded. So, add a check to make sure the DSP resets are asserted, and if not, throw a eye-catchy warning and assert the resets specifically.

[s-anna at ti.com: replace warning with a WARN]

---
v3: No code changes, picked up Santosh's Ack
v2: https://patchwork.kernel.org/patch/9773679/

 drivers/remoteproc/keystone_remoteproc.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/remoteproc/keystone_remoteproc.c +10 -0
index 6e09ef76f7c7..5f776bfd674a 100644
@@ -456,6 +456,16 @@ static int keystone_rproc_probe(struct platform_device *pdev)
 	if (of_reserved_mem_device_init(dev))
 		dev_warn(dev, "device does not have specific CMA pool\n");
 
+	/* ensure the DSP is in reset before loading firmware */
+	ret = reset_control_status(ksproc->reset);
+	if (ret < 0) {
+		dev_err(dev, "failed to get reset status, status = %d\n", ret);
+		goto release_mem;
+	} else if (ret == 0) {
+		WARN(1, "device is not in reset\n");
+		keystone_rproc_dsp_reset(ksproc);
+	}
+
 	ret = rproc_add(rproc);
 	if (ret) {
 		dev_err(dev, "failed to add register device with remoteproc core, status = %d\n",
Signature · 1 line
2.13.1
author
#10 lore raw
In reply to Suman Anna
Quoted 10 lines · Suman Anna

Hi Bjorn,

This is v3 of the patchset that adds the DT binding and the driver for loading and booting the DSP devices present on various Keystone2 SoC families. The binding and driver patches have already been acked by Rob Herring and Santosh Shilimkar respectively, and this is just a minor refresh with one small comment from Rob addressed in the binding (Patch 1). There are no code changes in remaining patches. I have picked up their Acks in all the relevant patches.

Appreciate it if you can pick up the series for v4.13.

Gentle reminder for picking this up for v4.13 merge window.

Thanks
Suman

Quoted 24 lines

v2:
http://marc.info/?l=linux-kernel&m=149688154304565&w=2
v1:
http://marc.info/?t=149581802500004&r=1&w=2

regards
Suman

Andrew F. Davis (1):
remoteproc/keystone: Ensure the DSPs are in reset in probe

Suman Anna (2):
dt-bindings: remoteproc: Add Keystone DSP remoteproc binding remoteproc/keystone: Add a remoteproc driver for Keystone 2 DSPs

 .../bindings/remoteproc/ti,keystone-rproc.txt      | 133 ++++++
 drivers/remoteproc/Kconfig                         |  13 +
 drivers/remoteproc/Makefile                        |   1 +
 drivers/remoteproc/keystone_remoteproc.c           | 525 +++++++++++++++++++++
 4 files changed, 672 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/remoteproc/ti,keystone-rproc.txt
 create mode 100644 drivers/remoteproc/keystone_remoteproc.c
#3 lore raw

Re: [PATCH v3 2/3] remoteproc/keystone: Add a remoteproc driver for Keystone 2 DSPs

In reply to Suman Anna
Quoted 12 lines · Suman Anna
drivers/remoteproc/keystone_remoteproc.c new file +12 -0
+static int keystone_rproc_start(struct rproc *rproc)
+{
+	struct keystone_rproc *ksproc = rproc->priv;
+	int ret;
+
+	INIT_WORK(&ksproc->workqueue, handle_event);
+
+	ret = request_irq(ksproc->irq_ring, keystone_rproc_vring_interrupt, 0,
+			  dev_name(ksproc->dev), ksproc);
+	if (ret) {
+		dev_err(ksproc->dev, "failed to enable vring interrupt, ret = %d\n",
+			ret);

drivers/remoteproc/keystone_remoteproc.c line 198

Quoted 10 lines
drivers/remoteproc/keystone_remoteproc.c new file +10 -0
+		goto out;
+	}
+
+	ret = request_irq(ksproc->irq_fault, keystone_rproc_exception_interrupt,
+			  0, dev_name(ksproc->dev), ksproc);
+	if (ret) {
+		dev_err(ksproc->dev, "failed to enable exception interrupt, ret = %d\n",
+			ret);
+		goto free_vring_irq;
+	}

I do prefer that your request any resources during probe() and potentially enable/disable them here. If below concern about using a GPIO driver is cleared already I'll take it as is though.

[..]

drivers/remoteproc/keystone_remoteproc.c line 248

Quoted 10 lines
drivers/remoteproc/keystone_remoteproc.c new file +10 -0
+static void keystone_rproc_kick(struct rproc *rproc, int vqid)
+{
+	struct keystone_rproc *ksproc = rproc->priv;
+
+	if (WARN_ON(ksproc->kick_gpio < 0))
+		return;
+
+	gpio_set_value(ksproc->kick_gpio, 1);
+}
+

This doesn't sound like a gpio-controller and the GPIO maintainer did reject an attempt by me to use the GPIO framework to abstract a similar thing. Do you already have this driver upstream or have you clarified with the maintainer that the GPIO framework is an acceptable abstraction for this?

It looks equivalent to the "APCS IPC" register found in Qualcomm platforms, previously implemented through a syscon but in v4.13 being pushed to being a mailbox driver.

Apart from this I think the series looks good.

Regards,
Bjorn

author
#4 lore raw

Re: [PATCH v3 2/3] remoteproc/keystone: Add a remoteproc driver for Keystone 2 DSPs

Hi Bjorn,

Quoted 30 lines · Bjorn Andersson
Quoted 12 lines · Suman Anna
drivers/remoteproc/keystone_remoteproc.c new file +12 -0
+static int keystone_rproc_start(struct rproc *rproc)
+{
+	struct keystone_rproc *ksproc = rproc->priv;
+	int ret;
+
+	INIT_WORK(&ksproc->workqueue, handle_event);
+
+	ret = request_irq(ksproc->irq_ring, keystone_rproc_vring_interrupt, 0,
+			  dev_name(ksproc->dev), ksproc);
+	if (ret) {
+		dev_err(ksproc->dev, "failed to enable vring interrupt, ret = %d\n",
+			ret);

drivers/remoteproc/keystone_remoteproc.c line 198

Quoted 10 lines
drivers/remoteproc/keystone_remoteproc.c new file +10 -0
+		goto out;
+	}
+
+	ret = request_irq(ksproc->irq_fault, keystone_rproc_exception_interrupt,
+			  0, dev_name(ksproc->dev), ksproc);
+	if (ret) {
+		dev_err(ksproc->dev, "failed to enable exception interrupt, ret = %d\n",
+			ret);
+		goto free_vring_irq;
+	}

I do prefer that your request any resources during probe() and potentially enable/disable them here. If below concern about using a GPIO driver is cleared already I'll take it as is though.

[..]

Quoted 16 lines

drivers/remoteproc/keystone_remoteproc.c line 248

Quoted 10 lines
drivers/remoteproc/keystone_remoteproc.c new file +10 -0
+static void keystone_rproc_kick(struct rproc *rproc, int vqid)
+{
+	struct keystone_rproc *ksproc = rproc->priv;
+
+	if (WARN_ON(ksproc->kick_gpio < 0))
+		return;
+
+	gpio_set_value(ksproc->kick_gpio, 1);
+}
+

This doesn't sound like a gpio-controller and the GPIO maintainer did reject an attempt by me to use the GPIO framework to abstract a similar thing. Do you already have this driver upstream or have you clarified with the maintainer that the GPIO framework is an acceptable abstraction for this?

Yeah, this has been upstream since quite some time. See commit 2134cb997f2f ("gpio: syscon: reuse for keystone 2 socs").

regards
Suman

Quoted 15 lines

It looks equivalent to the "APCS IPC" register found in Qualcomm platforms, previously implemented through a syscon but in v4.13 being pushed to being a mailbox driver.

Apart from this I think the series looks good.

Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in the body of a message to majordomo at vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html

#5 lore raw

Re: [PATCH v3 2/3] remoteproc/keystone: Add a remoteproc driver for Keystone 2 DSPs

Quoted 50 lines · Suman Anna

Hi Bjorn,

Quoted 30 lines · Bjorn Andersson
Quoted 12 lines · Suman Anna
drivers/remoteproc/keystone_remoteproc.c new file +12 -0
+static int keystone_rproc_start(struct rproc *rproc)
+{
+	struct keystone_rproc *ksproc = rproc->priv;
+	int ret;
+
+	INIT_WORK(&ksproc->workqueue, handle_event);
+
+	ret = request_irq(ksproc->irq_ring, keystone_rproc_vring_interrupt, 0,
+			  dev_name(ksproc->dev), ksproc);
+	if (ret) {
+		dev_err(ksproc->dev, "failed to enable vring interrupt, ret = %d\n",
+			ret);

drivers/remoteproc/keystone_remoteproc.c line 198

Quoted 10 lines
drivers/remoteproc/keystone_remoteproc.c new file +10 -0
+		goto out;
+	}
+
+	ret = request_irq(ksproc->irq_fault, keystone_rproc_exception_interrupt,
+			  0, dev_name(ksproc->dev), ksproc);
+	if (ret) {
+		dev_err(ksproc->dev, "failed to enable exception interrupt, ret = %d\n",
+			ret);
+		goto free_vring_irq;
+	}

I do prefer that your request any resources during probe() and potentially enable/disable them here. If below concern about using a GPIO driver is cleared already I'll take it as is though.

[..]

Quoted 16 lines

drivers/remoteproc/keystone_remoteproc.c line 248

Quoted 10 lines
drivers/remoteproc/keystone_remoteproc.c new file +10 -0
+static void keystone_rproc_kick(struct rproc *rproc, int vqid)
+{
+	struct keystone_rproc *ksproc = rproc->priv;
+
+	if (WARN_ON(ksproc->kick_gpio < 0))
+		return;
+
+	gpio_set_value(ksproc->kick_gpio, 1);
+}
+

This doesn't sound like a gpio-controller and the GPIO maintainer did reject an attempt by me to use the GPIO framework to abstract a similar thing. Do you already have this driver upstream or have you clarified with the maintainer that the GPIO framework is an acceptable abstraction for this?

Quoted 3 lines

Yeah, this has been upstream since quite some time. See commit 2134cb997f2f ("gpio: syscon: reuse for keystone 2 socs").

Okay, sounds good. I have merged the series.

I still would like to have resources allocated at probe() time, so I would appreciate a follow up patch moving the request_irq()s to probe, per above comment (but we can take that after v4.13).

Regards,
Bjorn

author
#6 lore raw

Re: [PATCH v3 2/3] remoteproc/keystone: Add a remoteproc driver for Keystone 2 DSPs

Quoted 56 lines · Bjorn Andersson
Quoted 50 lines · Suman Anna

Hi Bjorn,

Quoted 30 lines · Bjorn Andersson
Quoted 12 lines · Suman Anna
drivers/remoteproc/keystone_remoteproc.c new file +12 -0
+static int keystone_rproc_start(struct rproc *rproc)
+{
+	struct keystone_rproc *ksproc = rproc->priv;
+	int ret;
+
+	INIT_WORK(&ksproc->workqueue, handle_event);
+
+	ret = request_irq(ksproc->irq_ring, keystone_rproc_vring_interrupt, 0,
+			  dev_name(ksproc->dev), ksproc);
+	if (ret) {
+		dev_err(ksproc->dev, "failed to enable vring interrupt, ret = %d\n",
+			ret);

drivers/remoteproc/keystone_remoteproc.c line 198

Quoted 10 lines
drivers/remoteproc/keystone_remoteproc.c new file +10 -0
+		goto out;
+	}
+
+	ret = request_irq(ksproc->irq_fault, keystone_rproc_exception_interrupt,
+			  0, dev_name(ksproc->dev), ksproc);
+	if (ret) {
+		dev_err(ksproc->dev, "failed to enable exception interrupt, ret = %d\n",
+			ret);
+		goto free_vring_irq;
+	}

I do prefer that your request any resources during probe() and potentially enable/disable them here. If below concern about using a GPIO driver is cleared already I'll take it as is though.

[..]

Quoted 16 lines

drivers/remoteproc/keystone_remoteproc.c line 248

Quoted 10 lines
drivers/remoteproc/keystone_remoteproc.c new file +10 -0
+static void keystone_rproc_kick(struct rproc *rproc, int vqid)
+{
+	struct keystone_rproc *ksproc = rproc->priv;
+
+	if (WARN_ON(ksproc->kick_gpio < 0))
+		return;
+
+	gpio_set_value(ksproc->kick_gpio, 1);
+}
+

This doesn't sound like a gpio-controller and the GPIO maintainer did reject an attempt by me to use the GPIO framework to abstract a similar thing. Do you already have this driver upstream or have you clarified with the maintainer that the GPIO framework is an acceptable abstraction for this?

Quoted 3 lines

Yeah, this has been upstream since quite some time. See commit 2134cb997f2f ("gpio: syscon: reuse for keystone 2 socs").

Quoted 6 lines

Okay, sounds good. I have merged the series.

I still would like to have resources allocated at probe() time, so I would appreciate a follow up patch moving the request_irq()s to probe, per above comment (but we can take that after v4.13).

OK thanks. This is a common theme across all the remoteproc drivers supporting rpmsg, and I definitely need to disable them in probe since the boot or the virtio/rpmsg devices are not guaranteed to be present in the probe.

regards
Suman

#7 lore raw

Re: [PATCH v3 2/3] remoteproc/keystone: Add a remoteproc driver for Keystone 2 DSPs

Quoted 3 lines · Suman Anna
Quoted 2 lines · Bjorn Andersson
Quoted 1 line · Suman Anna

On 06/25/2017 03:15 PM, Bjorn Andersson wrote:

[..]

Quoted 9 lines
Quoted 3 lines

I still would like to have resources allocated at probe() time, so I would appreciate a follow up patch moving the request_irq()s to probe, per above comment (but we can take that after v4.13).

OK thanks. This is a common theme across all the remoteproc drivers supporting rpmsg, and I definitely need to disable them in probe since the boot or the virtio/rpmsg devices are not guaranteed to be present in the probe.

We have a consistent struct rproc after rproc_alloc(). So before the virtio device (rpmsg in your case) calls virtio_find_vqs() rvring->vq will be NULL and rproc_vq_interrupt() is a nop.

So AFAICT it should be fine to register this at probe time and leave it enabled...but there's a lot of moving parts involved here, so it's possible that I'm missing something.

But in for both interrupts it's important to disable them before calling rproc_free(), as this will free the memory passed to the interrupt handler.

Regards,
Bjorn

#8 lore raw

Re: [PATCH v3 2/3] remoteproc/keystone: Add a remoteproc driver for Keystone 2 DSPs

In reply to Suman Anna

Hi,

Quoted 51 lines · Suman Anna

Hi Bjorn,

Quoted 30 lines · Bjorn Andersson
Quoted 12 lines · Suman Anna
drivers/remoteproc/keystone_remoteproc.c new file +12 -0
+static int keystone_rproc_start(struct rproc *rproc)
+{
+    struct keystone_rproc *ksproc = rproc->priv;
+    int ret;
+
+    INIT_WORK(&ksproc->workqueue, handle_event);
+
+    ret = request_irq(ksproc->irq_ring, keystone_rproc_vring_interrupt, 0,
+                      dev_name(ksproc->dev), ksproc);
+    if (ret) {
+            dev_err(ksproc->dev, "failed to enable vring interrupt, ret = %d\n",
+                    ret);

drivers/remoteproc/keystone_remoteproc.c line 198

Quoted 10 lines
drivers/remoteproc/keystone_remoteproc.c new file +10 -0
+            goto out;
+    }
+
+    ret = request_irq(ksproc->irq_fault, keystone_rproc_exception_interrupt,
+                      0, dev_name(ksproc->dev), ksproc);
+    if (ret) {
+            dev_err(ksproc->dev, "failed to enable exception interrupt, ret = %d\n",
+                    ret);
+            goto free_vring_irq;
+    }

I do prefer that your request any resources during probe() and potentially enable/disable them here. If below concern about using a GPIO driver is cleared already I'll take it as is though.

[..]

Quoted 16 lines

drivers/remoteproc/keystone_remoteproc.c line 248

Quoted 10 lines
drivers/remoteproc/keystone_remoteproc.c new file +10 -0
+static void keystone_rproc_kick(struct rproc *rproc, int vqid)
+{
+    struct keystone_rproc *ksproc = rproc->priv;
+
+    if (WARN_ON(ksproc->kick_gpio < 0))
+            return;
+
+    gpio_set_value(ksproc->kick_gpio, 1);
+}
+

This doesn't sound like a gpio-controller and the GPIO maintainer did reject an attempt by me to use the GPIO framework to abstract a similar thing. Do you already have this driver upstream or have you clarified with the maintainer that the GPIO framework is an acceptable abstraction for this?

Quoted 2 lines

Yeah, this has been upstream since quite some time. See commit 2134cb997f2f ("gpio: syscon: reuse for keystone 2 socs").

Sorry for the thread necromancy, but was it intentional that the driver only parses DT to find this "GPIO" but never requests/reserves it? I would like to drop of_get_named_gpio_flags() in favor of a more standard dev_get_gpiod().

Thanks.

Signature · 1 line
Dmitry