Skip to contentSkip to conversation

dma: add Qualcomm Technologies HIDMA driver

PATCH Superseded Sinan Kaya 3 participants 31 messages Jan 11, 2016 – Jan 22, 2016

Subsystems (5)

v12 of 18 Superseded Latest is v18 →

lore
Share & tools
lore

Sinan Kaya

author
#0 lore raw

v12 cover dma: add Qualcomm Technologies HIDMA driver

The Qualcomm Technologies HIDMA device has been designed to support virtualization technology. The driver has been divided into two to follow the hardware design.

1. HIDMA Management driver
2. HIDMA Channel driver

Each HIDMA HW consists of multiple channels. These channels share some set of common parameters. These parameters are initialized by the management driver during power up. Same management driver is used for monitoring the execution of the channels. Management driver can change the performance behavior dynamically such as bandwidth allocation and prioritization in the future.

The management driver is executed in hypervisor context and is the main management entity for all channels provided by the device.

Creating a QCOM directory for all QCOM DMA source files. Changes from V11: (https://lkml.org/lkml/2016/1/3/249)
* none

dma: hidma: Add Device Tree support
Changes from V11: (https://lkml.org/lkml/2016/1/3/243)
* none

dma: add Qualcomm Technologies HIDMA management driver Changes from V11: (https://lkml.org/lkml/2016/1/3/248)
* Correct range check in the sysfs.
* increase the print array in sysfs.

dma: add Qualcomm Technologies HIDMA channel driver Changes from V11: (https://lkml.org/lkml/2016/1/3/244)
* none

dma: qcom_hidma: implement lower level hardware interface Changes from V11: (https://lkml.org/lkml/2016/1/3/247)
* introduce HIDMA_CH_STATE macro to simplify testing conditions.
* introduce HIDMA_INCREMENT_ITERATOR macro to simplify code
* replace devm_kzalloc with devm_kcalloc in certain places.

dma: qcom_hidma: add debugfs hooks
Changes from V11: (https://lkml.org/lkml/2016/1/3/245)
* none

dma: qcom_hidma: add support for object hierarchy Changes from V11: (https://lkml.org/lkml/2016/1/3/246)
* none

Sinan Kaya (7):
dma: qcom_bam_dma: move to qcom directory
dma: hidma: Add Device Tree support
dma: add Qualcomm Technologies HIDMA management driver
dma: add Qualcomm Technologies HIDMA channel driver
dma: qcom_hidma: implement lower level hardware interface
dma: qcom_hidma: add debugfs hooks
dma: qcom_hidma: add support for object hierarchy

 Documentation/ABI/testing/sysfs-platform-hidma     |   9 +
 .../ABI/testing/sysfs-platform-hidma-mgmt          |  97 +++
 .../devicetree/bindings/dma/qcom_hidma_mgmt.txt    |  79 ++
 drivers/dma/Kconfig                                |  11 +-
 drivers/dma/Makefile                               |   2 +-
 drivers/dma/qcom/Kconfig                           |  29 +
 drivers/dma/qcom/Makefile                          |   5 +
 drivers/dma/{qcom_bam_dma.c => qcom/bam_dma.c}     |   4 +-
 drivers/dma/qcom/hidma.c                           | 784 +++++++++++++++++
 drivers/dma/qcom/hidma.h                           | 162 ++++
 drivers/dma/qcom/hidma_dbg.c                       | 219 +++++
 drivers/dma/qcom/hidma_ll.c                        | 927 +++++++++++++++++++++
 drivers/dma/qcom/hidma_mgmt.c                      | 400 +++++++++
 drivers/dma/qcom/hidma_mgmt.h                      |  39 +
 drivers/dma/qcom/hidma_mgmt_sys.c                  | 295 +++++++
 15 files changed, 3050 insertions(+), 12 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-hidma
 create mode 100644 Documentation/ABI/testing/sysfs-platform-hidma-mgmt
 create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
 create mode 100644 drivers/dma/qcom/Kconfig
 create mode 100644 drivers/dma/qcom/Makefile
 rename drivers/dma/{qcom_bam_dma.c => qcom/bam_dma.c} (99%)
 create mode 100644 drivers/dma/qcom/hidma.c
 create mode 100644 drivers/dma/qcom/hidma.h
 create mode 100644 drivers/dma/qcom/hidma_dbg.c
 create mode 100644 drivers/dma/qcom/hidma_ll.c
 create mode 100644 drivers/dma/qcom/hidma_mgmt.c
 create mode 100644 drivers/dma/qcom/hidma_mgmt.h
 create mode 100644 drivers/dma/qcom/hidma_mgmt_sys.c
Signature · 2 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
author
#1 lore raw

PATCH v12 1/7 dma: qcom_bam_dma: move to qcom directory

Creating a QCOM directory for all QCOM DMA source files.

---
 drivers/dma/Kconfig                            | 11 ++---------
 drivers/dma/Makefile                           |  2 +-
 drivers/dma/qcom/Kconfig                       |  8 ++++++++
 drivers/dma/qcom/Makefile                      |  1 +
 drivers/dma/{qcom_bam_dma.c => qcom/bam_dma.c} |  4 ++--
 5 files changed, 14 insertions(+), 12 deletions(-)
 create mode 100644 drivers/dma/qcom/Kconfig
 create mode 100644 drivers/dma/qcom/Makefile
 rename drivers/dma/{qcom_bam_dma.c => qcom/bam_dma.c} (99%)
drivers/dma/Kconfig +2 -9
index b458475..47b1b98 100644
@@ -408,15 +408,6 @@ config PXA_DMA
 	  16 to 32 channels for peripheral to memory or memory to memory
 	  transfers.
 
-config QCOM_BAM_DMA
-	tristate "QCOM BAM DMA support"
-	depends on ARCH_QCOM || (COMPILE_TEST && OF && ARM)
-	select DMA_ENGINE
-	select DMA_VIRTUAL_CHANNELS
-	---help---
-	  Enable support for the QCOM BAM DMA controller.  This controller
-	  provides DMA capabilities for a variety of on-chip devices.
-
 config SIRF_DMA
 	tristate "CSR SiRFprimaII/SiRFmarco DMA support"
 	depends on ARCH_SIRF
@@ -527,6 +518,8 @@ config ZX_DMA
 # driver files
 source "drivers/dma/bestcomm/Kconfig"
 
+source "drivers/dma/qcom/Kconfig"
+
 source "drivers/dma/dw/Kconfig"
 
 source "drivers/dma/hsu/Kconfig"
drivers/dma/Makefile +1 -1
index 7711a71..8dba90d 100644
@@ -52,7 +52,6 @@ obj-$(CONFIG_PCH_DMA) += pch_dma.o
 obj-$(CONFIG_PL330_DMA) += pl330.o
 obj-$(CONFIG_PPC_BESTCOMM) += bestcomm/
 obj-$(CONFIG_PXA_DMA) += pxa_dma.o
-obj-$(CONFIG_QCOM_BAM_DMA) += qcom_bam_dma.o
 obj-$(CONFIG_RENESAS_DMA) += sh/
 obj-$(CONFIG_SIRF_DMA) += sirf-dma.o
 obj-$(CONFIG_STE_DMA40) += ste_dma40.o ste_dma40_ll.o
@@ -66,4 +65,5 @@ obj-$(CONFIG_TI_EDMA) += edma.o
 obj-$(CONFIG_XGENE_DMA) += xgene-dma.o
 obj-$(CONFIG_ZX_DMA) += zx296702_dma.o
 
+obj-y += qcom/
 obj-y += xilinx/
drivers/dma/qcom/Kconfig new file +8 -0
new file mode 100644
index 0000000..f17c272
@@ -0,0 +1,8 @@
+config QCOM_BAM_DMA
+	tristate "QCOM BAM DMA support"
+	depends on ARCH_QCOM || (COMPILE_TEST && OF && ARM)
+	select DMA_ENGINE
+	select DMA_VIRTUAL_CHANNELS
+	---help---
+	  Enable support for the QCOM BAM DMA controller.  This controller
+	  provides DMA capabilities for a variety of on-chip devices.
drivers/dma/qcom/Makefile new file +1 -0
new file mode 100644
index 0000000..f612ae3
@@ -0,0 +1 @@
+obj-$(CONFIG_QCOM_BAM_DMA) += bam_dma.o
drivers/dma/qcom/bam_dma.c renamed from drivers/dma/qcom_bam_dma.c +2 -2
similarity index 99%
rename from drivers/dma/qcom_bam_dma.c
rename to drivers/dma/qcom/bam_dma.c
index 5a250cd..b6f053d 100644
@@ -49,8 +49,8 @@
 #include <linux/clk.h>
 #include <linux/dmaengine.h>
 
-#include "dmaengine.h"
-#include "virt-dma.h"
+#include "../dmaengine.h"
+#include "../virt-dma.h"
 
 struct bam_desc_hw {
 	u32 addr;		/* Buffer physical address */
Signature · 2 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
author
#2 lore raw

PATCH v12 2/7 dma: hidma: Add Device Tree support

In reply to Sinan Kaya

Add documentation for the Qualcomm Technologies HIDMA driver.

---
 .../devicetree/bindings/dma/qcom_hidma_mgmt.txt    | 79 ++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +79 -0
new file mode 100644
index 0000000..0e6ed1f
@@ -0,0 +1,79 @@
+Qualcomm Technologies HIDMA Management interface
+
+Qualcomm Technologies HIDMA is a high speed DMA device. It only supports
+memcpy and memset capabilities. It has been designed for virtualized
+environments.
+
+Each HIDMA HW instance consists of multiple DMA channels. These channels
+share the same bandwidth. The bandwidth utilization can be parititioned
+among channels based on the priority and weight assignments.
+
+There are only two priority levels and 15 weigh assignments possible.
+
+Other parameters here determine how much of the system bus this HIDMA
+instance can use like maximum read/write request and and number of bytes to
+read/write in a single burst.
+
+Main node required properties:
+- compatible: "qcom,hidma-mgmt-1.0";
+- reg: Address range for DMA device
+- dma-channels: Number of channels supported by this DMA controller.
+- max-write-burst-bytes: Maximum write burst in bytes. A memcpy requested is
+  fragmented to multiples of this amount.
+- max-read-burst-bytes: Maximum read burst in bytes. A memcpy request is
+  fragmented to multiples of this amount.
+- max-write-transactions: Maximum write transactions to perform in a burst
+- max-read-transactions: Maximum read transactions to perform in a burst
+- channel-reset-timeout-cycles: Channel reset timeout in cycles for this SOC.
+
+Sub-nodes:
+
+HIDMA has one or more DMA channels that are used to move data from one
+memory location to another.
+
+Each DMA channel is described as a sub-node under the management object.
+When a transfer channel is given to the guest operating system, only the channel
+object is created. The drivers have support for both flat and hierarchical
+configuration.
+
+Required properties:
+- compatible: must contain "qcom,hidma-1.0"
+- reg: Addresses for the transfer and event channel
+- interrupts: Should contain the event interrupt
+- desc-count: Number of asynchronous requests this channel can handle
+- channel-index: The HW event channel completions will be delivered.
+
+Example:
+
+Hypervisor OS configuration:
+
+	hidma-mgmt at f9984000 = {
+		compatible = "qcom,hidma-mgmt-1.0";
+		reg = <0xf9984000 0x15000>;
+		dma-channels = <6>;
+		max-write-burst-bytes = <1024>;
+		max-read-burst-bytes = <1024>;
+		max-write-transactions = <31>;
+		max-read-transactions = <31>;
+		channel-reset-timeout-cycles = <0x500>;
+
+		hidma_24: dma-controller at 0x5c050000 {
+			compatible = "qcom,hidma-1.0";
+			reg = <0 0x5c050000 0x0 0x1000>,
+			      <0 0x5c0b0000 0x0 0x1000>;
+			interrupts = <0 389 0>;
+			desc-count = <10>;
+			channel-index = <4>;
+		};
+	};
+
+Guest OS configuration:
+
+	hidma_24: dma-controller at 0x5c050000 {
+		compatible = "qcom,hidma-1.0";
+		reg = <0 0x5c050000 0x0 0x1000>,
+		      <0 0x5c0b0000 0x0 0x1000>;
+		interrupts = <0 389 0>;
+		desc-count = <10>;
+		channel-index = <4>;
+	};
Signature · 2 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#3 lore raw

Re: [PATCH V12 2/7] dma: hidma: Add Device Tree support

Quoted 1 line · Sinan Kaya

Add documentation for the Qualcomm Technologies HIDMA driver.

s/driver/binding/

Quoted 29 lines
---
 .../devicetree/bindings/dma/qcom_hidma_mgmt.txt    | 79 ++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +16 -0
new file mode 100644
index 0000000..0e6ed1f
@@ -0,0 +1,79 @@
+Qualcomm Technologies HIDMA Management interface
+
+Qualcomm Technologies HIDMA is a high speed DMA device. It only supports
+memcpy and memset capabilities. It has been designed for virtualized
+environments.
+
+Each HIDMA HW instance consists of multiple DMA channels. These channels
+share the same bandwidth. The bandwidth utilization can be parititioned
+among channels based on the priority and weight assignments.
+
+There are only two priority levels and 15 weigh assignments possible.
+
+Other parameters here determine how much of the system bus this HIDMA
+instance can use like maximum read/write request and and number of bytes to
+read/write in a single burst.
+

Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt line 26

Quoted 10 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +10 -0
+Main node required properties:
+- compatible: "qcom,hidma-mgmt-1.0";
+- reg: Address range for DMA device
+- dma-channels: Number of channels supported by this DMA controller.
+- max-write-burst-bytes: Maximum write burst in bytes. A memcpy requested is
+  fragmented to multiples of this amount.
+- max-read-burst-bytes: Maximum read burst in bytes. A memcpy request is
+  fragmented to multiples of this amount.
+- max-write-transactions: Maximum write transactions to perform in a burst
+- max-read-transactions: Maximum read transactions to perform in a burst

Just to check, where do these max-* values come from?

Are they some correctness requirement of the bus this is attached to?

Are they tuning values?

The latter doesn't really belong in the DT. Given they're writeable from the driver, it seems like that's what they are...

Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt line 27

Quoted 1 line
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +1 -0
+- channel-reset-timeout-cycles: Channel reset timeout in cycles for this SOC.

I'm not sure what this means. Could you elaborate on this is?

Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt line 37

Quoted 10 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +10 -0
+
+Sub-nodes:
+
+HIDMA has one or more DMA channels that are used to move data from one
+memory location to another.
+
+Each DMA channel is described as a sub-node under the management object.
+When a transfer channel is given to the guest operating system, only the channel
+object is created. The drivers have support for both flat and hierarchical
+configuration.

Don't mention drivers here.

All you need to state is that when the OS is not in control of the management interface (i.e. it's a guest), the channel nodes appear on their own, not under a management node.

Other than the above questions, this looks ok to me.

Thanks,
Mark.

Quoted 46 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +42 -0
+
+Required properties:
+- compatible: must contain "qcom,hidma-1.0"
+- reg: Addresses for the transfer and event channel
+- interrupts: Should contain the event interrupt
+- desc-count: Number of asynchronous requests this channel can handle
+- channel-index: The HW event channel completions will be delivered.
+
+Example:
+
+Hypervisor OS configuration:
+
+	hidma-mgmt at f9984000 = {
+		compatible = "qcom,hidma-mgmt-1.0";
+		reg = <0xf9984000 0x15000>;
+		dma-channels = <6>;
+		max-write-burst-bytes = <1024>;
+		max-read-burst-bytes = <1024>;
+		max-write-transactions = <31>;
+		max-read-transactions = <31>;
+		channel-reset-timeout-cycles = <0x500>;
+
+		hidma_24: dma-controller at 0x5c050000 {
+			compatible = "qcom,hidma-1.0";
+			reg = <0 0x5c050000 0x0 0x1000>,
+			      <0 0x5c0b0000 0x0 0x1000>;
+			interrupts = <0 389 0>;
+			desc-count = <10>;
+			channel-index = <4>;
+		};
+	};
+
+Guest OS configuration:
+
+	hidma_24: dma-controller at 0x5c050000 {
+		compatible = "qcom,hidma-1.0";
+		reg = <0 0x5c050000 0x0 0x1000>,
+		      <0 0x5c0b0000 0x0 0x1000>;
+		interrupts = <0 389 0>;
+		desc-count = <10>;
+		channel-index = <4>;
+	};
Signature · 2 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#4 lore raw

Re: [PATCH V12 2/7] dma: hidma: Add Device Tree support

Quoted 8 lines · Mark Rutland
Quoted 1 line · Sinan Kaya

Add documentation for the Qualcomm Technologies HIDMA driver.

s/driver/binding/

Quoted 2 lines

Further to my reply below, I'm generally uncomfortable with some properties (max-* need a better description if they are a HW requirement, and probably should not be present otherwise). I'm also concerned that information necessary for the advertised use-case of the device (e.g. IOMMUs) is missing [1], and we're missing parts of the story necessary to review this for correctness.

Until that's settled, I don't think this is ready yet, and I don't think this should be picked up.

I'm sorry to say that at this stage, as I realise that may sound obstructive. That's not my intention, and I hope we can figure out those details quickly.

Thanks,
Mark.

[1] http://lists.infradead.org/pipermail/linux-arm-kernel/2016-January/399850.html

Quoted 124 lines
Quoted 27 lines
---
 .../devicetree/bindings/dma/qcom_hidma_mgmt.txt    | 79 ++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +16 -0
new file mode 100644
index 0000000..0e6ed1f
@@ -0,0 +1,79 @@
+Qualcomm Technologies HIDMA Management interface
+
+Qualcomm Technologies HIDMA is a high speed DMA device. It only supports
+memcpy and memset capabilities. It has been designed for virtualized
+environments.
+
+Each HIDMA HW instance consists of multiple DMA channels. These channels
+share the same bandwidth. The bandwidth utilization can be parititioned
+among channels based on the priority and weight assignments.
+
+There are only two priority levels and 15 weigh assignments possible.
+
+Other parameters here determine how much of the system bus this HIDMA
+instance can use like maximum read/write request and and number of bytes to
+read/write in a single burst.
+

Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt line 26

Quoted 10 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +10 -0
+Main node required properties:
+- compatible: "qcom,hidma-mgmt-1.0";
+- reg: Address range for DMA device
+- dma-channels: Number of channels supported by this DMA controller.
+- max-write-burst-bytes: Maximum write burst in bytes. A memcpy requested is
+  fragmented to multiples of this amount.
+- max-read-burst-bytes: Maximum read burst in bytes. A memcpy request is
+  fragmented to multiples of this amount.
+- max-write-transactions: Maximum write transactions to perform in a burst
+- max-read-transactions: Maximum read transactions to perform in a burst

Just to check, where do these max-* values come from?

Are they some correctness requirement of the bus this is attached to?

Are they tuning values?

The latter doesn't really belong in the DT. Given they're writeable from the driver, it seems like that's what they are...

Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt line 27

Quoted 1 line
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +1 -0
+- channel-reset-timeout-cycles: Channel reset timeout in cycles for this SOC.

I'm not sure what this means. Could you elaborate on this is?

Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt line 37

Quoted 10 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +10 -0
+
+Sub-nodes:
+
+HIDMA has one or more DMA channels that are used to move data from one
+memory location to another.
+
+Each DMA channel is described as a sub-node under the management object.
+When a transfer channel is given to the guest operating system, only the channel
+object is created. The drivers have support for both flat and hierarchical
+configuration.

Don't mention drivers here.

All you need to state is that when the OS is not in control of the management interface (i.e. it's a guest), the channel nodes appear on their own, not under a management node.

Other than the above questions, this looks ok to me.

Thanks,
Mark.

Quoted 46 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +42 -0
+
+Required properties:
+- compatible: must contain "qcom,hidma-1.0"
+- reg: Addresses for the transfer and event channel
+- interrupts: Should contain the event interrupt
+- desc-count: Number of asynchronous requests this channel can handle
+- channel-index: The HW event channel completions will be delivered.
+
+Example:
+
+Hypervisor OS configuration:
+
+	hidma-mgmt at f9984000 = {
+		compatible = "qcom,hidma-mgmt-1.0";
+		reg = <0xf9984000 0x15000>;
+		dma-channels = <6>;
+		max-write-burst-bytes = <1024>;
+		max-read-burst-bytes = <1024>;
+		max-write-transactions = <31>;
+		max-read-transactions = <31>;
+		channel-reset-timeout-cycles = <0x500>;
+
+		hidma_24: dma-controller at 0x5c050000 {
+			compatible = "qcom,hidma-1.0";
+			reg = <0 0x5c050000 0x0 0x1000>,
+			      <0 0x5c0b0000 0x0 0x1000>;
+			interrupts = <0 389 0>;
+			desc-count = <10>;
+			channel-index = <4>;
+		};
+	};
+
+Guest OS configuration:
+
+	hidma_24: dma-controller at 0x5c050000 {
+		compatible = "qcom,hidma-1.0";
+		reg = <0 0x5c050000 0x0 0x1000>,
+		      <0 0x5c0b0000 0x0 0x1000>;
+		interrupts = <0 389 0>;
+		desc-count = <10>;
+		channel-index = <4>;
+	};
Signature · 2 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project

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

author
#5 lore raw

Re: [PATCH V12 2/7] dma: hidma: Add Device Tree support

Quoted 3 lines · Mark Rutland

Further to my reply below, I'm generally uncomfortable with some properties (max-* need a better description if they are a HW requirement, and probably should not be present otherwise).

I'll add more description.

Quoted 4 lines

I'm also
concerned that information necessary for the advertised use-case of the device (e.g. IOMMUs) is missing [1], and we're missing parts of the story necessary to review this for correctness.

OK. Let me work on this. I tried to capture as much documentation as possible into the series before. One reviewer said I should add it. Another reviewer said I should remove it.

Where would be the best place to document the use case?
- In the source file?
- In the commit message?
- In the device-tree documentation?

I'll try to write up something based on your and Mark Zyngier's questions for the next release.

Quoted 7 lines

Until that's settled, I don't think this is ready yet, and I don't think this should be picked up.

I'm sorry to say that at this stage, as I realise that may sound obstructive. That's not my intention, and I hope we can figure out those details quickly.

I hope so too. I'm going towards V20 with small nitpicks rather than the good feedback like yours.

Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#6 lore raw

Re: [PATCH V12 2/7] dma: hidma: Add Device Tree support

Quoted 12 lines · Sinan Kaya
Quoted 3 lines · Mark Rutland

Further to my reply below, I'm generally uncomfortable with some properties (max-* need a better description if they are a HW requirement, and probably should not be present otherwise).

I'll add more description.

Quoted 4 lines

I'm also
concerned that information necessary for the advertised use-case of the device (e.g. IOMMUs) is missing [1], and we're missing parts of the story necessary to review this for correctness.

Quoted 8 lines

OK. Let me work on this. I tried to capture as much documentation as possible into the series before. One reviewer said I should add it. Another reviewer said I should remove it.

Where would be the best place to document the use case?
- In the source file?
- In the commit message?
- In the device-tree documentation?

Mostly the cover letter, but to varying degrees some information should appear in the commit messages, documentation, and code.

The cover letter should give a high-level overview sufficient to get reviewing (e.g. that should point out we expect isolation by IOMMUs). There should also be pointers to related components (i.e. the QEMU driver intended to communicate with this).

Things subject to change should go in the cover letter, as it's not permanent.

If something strongly influences the design in a way that's non-obvious, then that will probably remain non-obvious. For that, there should certainly be something in the commit message. If it's something that will be hit in general usage of the binding (or forms part of the contract of the binding), that should be described in the binding documentation.

If there's some caveat other developers need to be aware of, drop a comment in the code.

Thanks,
Mark.

author
#7 lore raw

Re: [PATCH V12 2/7] dma: hidma: Add Device Tree support

In reply to Mark Rutland
Quoted 4 lines · Mark Rutland
Quoted 1 line · Sinan Kaya

Add documentation for the Qualcomm Technologies HIDMA driver.

s/driver/binding/

Changed.

Quoted 35 lines
Quoted 35 lines
---
 .../devicetree/bindings/dma/qcom_hidma_mgmt.txt    | 79 ++++++++++++++++++++++
 1 file changed, 79 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +20 -0
new file mode 100644
index 0000000..0e6ed1f
@@ -0,0 +1,79 @@
+Qualcomm Technologies HIDMA Management interface
+
+Qualcomm Technologies HIDMA is a high speed DMA device. It only supports
+memcpy and memset capabilities. It has been designed for virtualized
+environments.
+
+Each HIDMA HW instance consists of multiple DMA channels. These channels
+share the same bandwidth. The bandwidth utilization can be parititioned
+among channels based on the priority and weight assignments.
+
+There are only two priority levels and 15 weigh assignments possible.
+
+Other parameters here determine how much of the system bus this HIDMA
+instance can use like maximum read/write request and and number of bytes to
+read/write in a single burst.
+
+Main node required properties:
+- compatible: "qcom,hidma-mgmt-1.0";
+- reg: Address range for DMA device
+- dma-channels: Number of channels supported by this DMA controller.
Quoted 8 lines

Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt line 26

Quoted 6 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +6 -0
+- max-write-burst-bytes: Maximum write burst in bytes. A memcpy requested is
+  fragmented to multiples of this amount.
+- max-read-burst-bytes: Maximum read burst in bytes. A memcpy request is
+  fragmented to multiples of this amount.
+- max-write-transactions: Maximum write transactions to perform in a burst
+- max-read-transactions: Maximum read transactions to perform in a burst

Just to check, where do these max-* values come from?

These are HW bus parameters like the burst count and
size of each burst. These values change based on the SoC this IP is in use.

Quoted 2 lines

Are they some correctness requirement of the bus this is attached to?

You can starve other peripherals if you use incorrect values as the bus is shared with other peripherals. Yes, correctness is required.

Quoted 2 lines

Are they tuning values?

Correct value is necessary for functioning. I'd consider weight and priority as the only tuning parameters.

Quoted 3 lines

The latter doesn't really belong in the DT. Given they're writeable from the driver, it seems like that's what they are...

Good catch. Those should have been read-only. I wanted to be able to export these information to the userspace app. I'll fix the sysfs to make them read-only.

Quoted 4 lines

Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt line 27

Quoted 2 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +1 -0
+- channel-reset-timeout-cycles: Channel reset timeout in cycles for this SOC.

I'm not sure what this means. Could you elaborate on this is?

After each reset command, HW starts a timer. This is the time HW waits before it declares reset failed.

Quoted 14 lines

Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt line 37

Quoted 11 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +10 -0
+
+Sub-nodes:
+
+HIDMA has one or more DMA channels that are used to move data from one
+memory location to another.
+
+Each DMA channel is described as a sub-node under the management object.
+When a transfer channel is given to the guest operating system, only the channel
+object is created. The drivers have support for both flat and hierarchical
+configuration.

Don't mention drivers here.

Quoted 3 lines

All you need to state is that when the OS is not in control of the management interface (i.e. it's a guest), the channel nodes appear on their own, not under a management node.

Replaced the above paragraph with yours.

Quoted 52 lines

Other than the above questions, this looks ok to me.

Thanks,
Mark.

Quoted 46 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +42 -0
+
+Required properties:
+- compatible: must contain "qcom,hidma-1.0"
+- reg: Addresses for the transfer and event channel
+- interrupts: Should contain the event interrupt
+- desc-count: Number of asynchronous requests this channel can handle
+- channel-index: The HW event channel completions will be delivered.
+
+Example:
+
+Hypervisor OS configuration:
+
+	hidma-mgmt at f9984000 = {
+		compatible = "qcom,hidma-mgmt-1.0";
+		reg = <0xf9984000 0x15000>;
+		dma-channels = <6>;
+		max-write-burst-bytes = <1024>;
+		max-read-burst-bytes = <1024>;
+		max-write-transactions = <31>;
+		max-read-transactions = <31>;
+		channel-reset-timeout-cycles = <0x500>;
+
+		hidma_24: dma-controller at 0x5c050000 {
+			compatible = "qcom,hidma-1.0";
+			reg = <0 0x5c050000 0x0 0x1000>,
+			      <0 0x5c0b0000 0x0 0x1000>;
+			interrupts = <0 389 0>;
+			desc-count = <10>;
+			channel-index = <4>;
+		};
+	};
+
+Guest OS configuration:
+
+	hidma_24: dma-controller at 0x5c050000 {
+		compatible = "qcom,hidma-1.0";
+		reg = <0 0x5c050000 0x0 0x1000>,
+		      <0 0x5c0b0000 0x0 0x1000>;
+		interrupts = <0 389 0>;
+		desc-count = <10>;
+		channel-index = <4>;
+	};
Signature · 2 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#8 lore raw

Re: [PATCH V12 2/7] dma: hidma: Add Device Tree support

Quoted 11 lines
Quoted 11 lines
Quoted 10 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +10 -0
+Main node required properties:
+- compatible: "qcom,hidma-mgmt-1.0";
+- reg: Address range for DMA device
+- dma-channels: Number of channels supported by this DMA controller.
+- max-write-burst-bytes: Maximum write burst in bytes. A memcpy requested is
+  fragmented to multiples of this amount.
+- max-read-burst-bytes: Maximum read burst in bytes. A memcpy request is
+  fragmented to multiples of this amount.
+- max-write-transactions: Maximum write transactions to perform in a burst
+- max-read-transactions: Maximum read transactions to perform in a burst
Quoted 8 lines
Quoted 1 line

Just to check, where do these max-* values come from?

These are HW bus parameters like the burst count and
size of each burst. These values change based on the SoC this IP is in use.

Quoted 2 lines

Are they some correctness requirement of the bus this is attached to?

You can starve other peripherals if you use incorrect values as the bus is shared with other peripherals. Yes, correctness is required.

Is that a property of the system known statically, or one determined by testing the system under particular workloads? It feels like the latter (though I appreciate that not starving other masters is certainly a correctness property regardless of how this is derived).

I'd have expected the bus this is plugged into to have appropriate QoS settings pre-configured so as to avoid starvation, though it sounds like that's not possible here?

Quoted 12 lines
Quoted 1 line

Are they tuning values?

Correct value is necessary for functioning. I'd consider weight and priority as the only tuning parameters.

Quoted 3 lines

The latter doesn't really belong in the DT. Given they're writeable from the driver, it seems like that's what they are...

Good catch. Those should have been read-only. I wanted to be able to export these information to the userspace app. I'll fix the sysfs to make them read-only.

Quoted 1 line
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+- channel-reset-timeout-cycles: Channel reset timeout in cycles for this SOC.

I'm not sure what this means. Could you elaborate on this is?

After each reset command, HW starts a timer. This is the time HW waits before it declares reset failed.

Is that a reset command sent to the HIDMA by the OS, or a reset command from the HIDMA to something else?

What does it do when it declares a reset as failed?

How can the OS make use of this information? It has no idea of the clocks input to the HIDMA, so it has no idea how long a cycle is.

Is this programmed by the OS?

Is the particular duration in cycles a requirement of some other agent?

Thanks,
Mark.

author
#9 lore raw

Re: [PATCH V12 2/7] dma: hidma: Add Device Tree support

Quoted 16 lines · Mark Rutland
Quoted 16 lines
Quoted 11 lines

Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt line 26

Quoted 10 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +10 -0
+Main node required properties:
+- compatible: "qcom,hidma-mgmt-1.0";
+- reg: Address range for DMA device
+- dma-channels: Number of channels supported by this DMA controller.
+- max-write-burst-bytes: Maximum write burst in bytes. A memcpy requested is
+  fragmented to multiples of this amount.
+- max-read-burst-bytes: Maximum read burst in bytes. A memcpy request is
+  fragmented to multiples of this amount.
+- max-write-transactions: Maximum write transactions to perform in a burst
+- max-read-transactions: Maximum read transactions to perform in a burst
Quoted 1 line

Just to check, where do these max-* values come from?

These are HW bus parameters like the burst count and
size of each burst. These values change based on the SoC this IP is in use.

Quoted 1 line
Quoted 9 lines
Quoted 3 lines
Quoted 1 line

Are they some correctness requirement of the bus this is attached to?

You can starve other peripherals if you use incorrect values as the bus is shared with other peripherals. Yes, correctness is required.

Is that a property of the system known statically, or one determined by testing the system under particular workloads? It feels like the latter (though I appreciate that not starving other masters is certainly a correctness property regardless of how this is derived).

It is known statically and is determined through simulations according to the SoC design. It is later verified on chip. Once verified, these values never change. Values change from one SoC to another.

Quoted 3 lines

I'd have expected the bus this is plugged into to have appropriate QoS settings pre-configured so as to avoid starvation, though it sounds like that's not possible here?

There are some very safe values but they are not correct until validated on the chip.

Quoted 13 lines
Quoted 13 lines
Quoted 2 lines

Are they tuning values?

Correct value is necessary for functioning. I'd consider weight and priority as the only tuning parameters.

Quoted 3 lines

The latter doesn't really belong in the DT. Given they're writeable from the driver, it seems like that's what they are...

Good catch. Those should have been read-only. I wanted to be able to export these information to the userspace app. I'll fix the sysfs to make them read-only.

Quoted 1 line
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

+- channel-reset-timeout-cycles: Channel reset timeout in cycles for this SOC.

I'm not sure what this means. Could you elaborate on this is?

After each reset command, HW starts a timer. This is the time HW waits before it declares reset failed.

Is that a reset command sent to the HIDMA by the OS, or a reset command from the HIDMA to something else?

First one.

As I said on another email, The HIDMA channel driver resets the transfer and event channels before using them. The reset command is intended for the HIDMA HW itself.

Quoted 3 lines

What does it do when it declares a reset as failed?

The channel probe will fail with reset failed message.

Quoted 3 lines

How can the OS make use of this information? It has no idea of the clocks input to the HIDMA, so it has no idea how long a cycle is.

This is a HW parameter. The OS doesn't use timers or any other facility to time correctness.

The HIDMA channel driver issues a reset and then waits for confirmation while polling a status register. If no confirmation is received, then the HW is assumed broken or incorrectly configured. The HW channel is removed from the OS access.

Quoted 1 line

Is this programmed by the OS?

The HIDMA management driver programs this value to the HW. It is not consumed by the OS directly.

Quoted 2 lines

Is the particular duration in cycles a requirement of some other agent?

It is a requirement of the HW. Not the OS.

Quoted 4 lines

Thanks,
Mark.

Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
author
#10 lore raw

PATCH v12 3/7 dma: add Qualcomm Technologies HIDMA management driver

In reply to Sinan Kaya

The Qualcomm Technologies HIDMA device has been designed to support virtualization technology. The driver has been divided into two to follow the hardware design.

1. HIDMA Management driver
2. HIDMA Channel driver

Each HIDMA HW consists of multiple channels. These channels share some set of common parameters. These parameters are initialized by the management driver during power up. Same management driver is used for monitoring the execution of the channels. Management driver can change the performance behavior dynamically such as bandwidth allocation and prioritization.

The management driver is executed in hypervisor context and is the main management entity for all channels provided by the device.

---
 .../ABI/testing/sysfs-platform-hidma-mgmt          |  97 +++++++
 drivers/dma/qcom/Kconfig                           |  11 +
 drivers/dma/qcom/Makefile                          |   2 +
 drivers/dma/qcom/hidma_mgmt.c                      | 302 +++++++++++++++++++++
 drivers/dma/qcom/hidma_mgmt.h                      |  39 +++
 drivers/dma/qcom/hidma_mgmt_sys.c                  | 295 ++++++++++++++++++++
 6 files changed, 746 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-hidma-mgmt
 create mode 100644 drivers/dma/qcom/hidma_mgmt.c
 create mode 100644 drivers/dma/qcom/hidma_mgmt.h
 create mode 100644 drivers/dma/qcom/hidma_mgmt_sys.c
Documentation/ABI/testing/sysfs-platform-hidma-mgmt new file +97 -0
new file mode 100644
index 0000000..c2fb5d0
@@ -0,0 +1,97 @@
+What:		/sys/devices/platform/hidma-mgmt*/chanops/chan*/priority
+		/sys/devices/platform/QCOM8060:*/chanops/chan*/priority
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Contains either 0 or 1 and indicates if the DMA channel is a
+		low priority (0) or high priority (1) channel.
+
+What:		/sys/devices/platform/hidma-mgmt*/chanops/chan*/weight
+		/sys/devices/platform/QCOM8060:*/chanops/chan*/weight
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Contains 0..15 and indicates the weight of the channel among
+		equal priority channels during round robin scheduling.
+
+What:		/sys/devices/platform/hidma-mgmt*/chreset_timeout_cycles
+		/sys/devices/platform/QCOM8060:*/chreset_timeout_cycles
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Contains the platform specific cycle value to wait after a
+		reset command is issued. If the value is chosen too short,
+		then the HW will issue a reset failure interrupt. The value
+		is platform specific and should not be changed without
+		consultance.
+
+What:		/sys/devices/platform/hidma-mgmt*/dma_channels
+		/sys/devices/platform/QCOM8060:*/dma_channels
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Contains the number of dma channels supported by one instance
+		of HIDMA hardware. The value may change from chip to chip.
+
+What:		/sys/devices/platform/hidma-mgmt*/hw_version_major
+		/sys/devices/platform/QCOM8060:*/hw_version_major
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Version number major for the hardware.
+
+What:		/sys/devices/platform/hidma-mgmt*/hw_version_minor
+		/sys/devices/platform/QCOM8060:*/hw_version_minor
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Version number minor for the hardware.
+
+What:		/sys/devices/platform/hidma-mgmt*/max_rd_xactions
+		/sys/devices/platform/QCOM8060:*/max_rd_xactions
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Contains a value between 0 and 31. Maximum number of
+		read transactions that can be issued back to back.
+		Choosing a higher number gives better performance but
+		can also cause performance reduction to other peripherals
+		sharing the same bus.
+
+What:		/sys/devices/platform/hidma-mgmt*/max_read_request
+		/sys/devices/platform/QCOM8060:*/max_read_request
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Size of each read request. The value needs to be a power
+		of two and can be between 128 and 1024.
+
+What:		/sys/devices/platform/hidma-mgmt*/max_wr_xactions
+		/sys/devices/platform/QCOM8060:*/max_wr_xactions
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Contains a value between 0 and 31. Maximum number of
+		write transactions that can be issued back to back.
+		Choosing a higher number gives better performance but
+		can also cause performance reduction to other peripherals
+		sharing the same bus.
+
+
+What:		/sys/devices/platform/hidma-mgmt*/max_write_request
+		/sys/devices/platform/QCOM8060:*/max_write_request
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Size of each write request. The value needs to be a power
+		of two and can be between 128 and 1024.
drivers/dma/qcom/Kconfig +11 -0
index f17c272..ebe5b8c 100644
@@ -6,3 +6,14 @@ config QCOM_BAM_DMA
 	---help---
 	  Enable support for the QCOM BAM DMA controller.  This controller
 	  provides DMA capabilities for a variety of on-chip devices.
+
+config QCOM_HIDMA_MGMT
+	tristate "Qualcomm Technologies HIDMA Management support"
+	select DMA_ENGINE
+	help
+	  Enable support for the Qualcomm Technologies HIDMA Management.
+	  Each DMA device requires one management interface driver
+	  for basic initialization before QCOM_HIDMA channel driver can
+	  start managing the channels. In a virtualized environment,
+	  the guest OS would run QCOM_HIDMA channel driver and the
+	  hypervisor would run the QCOM_HIDMA_MGMT management driver.
drivers/dma/qcom/Makefile +2 -0
index f612ae3..bfea699 100644
@@ -1 +1,3 @@
 obj-$(CONFIG_QCOM_BAM_DMA) += bam_dma.o
+obj-$(CONFIG_QCOM_HIDMA_MGMT) += hdma_mgmt.o
+hdma_mgmt-objs	 := hidma_mgmt.o hidma_mgmt_sys.o
drivers/dma/qcom/hidma_mgmt.c new file +302 -0

302 lines not on this page · raw message

drivers/dma/qcom/hidma_mgmt.h new file +39 -0
new file mode 100644
index 0000000..f7daf33
@@ -0,0 +1,39 @@
+/*
+ * Qualcomm Technologies HIDMA Management common header
+ *
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+struct hidma_mgmt_dev {
+	u8 hw_version_major;
+	u8 hw_version_minor;
+
+	u32 max_wr_xactions;
+	u32 max_rd_xactions;
+	u32 max_write_request;
+	u32 max_read_request;
+	u32 dma_channels;
+	u32 chreset_timeout_cycles;
+	u32 hw_version;
+	u32 *priority;
+	u32 *weight;
+
+	/* Hardware device constants */
+	void __iomem *virtaddr;
+	resource_size_t addrsize;
+
+	struct kobject **chroots;
+	struct platform_device *pdev;
+};
+
+int hidma_mgmt_init_sys(struct hidma_mgmt_dev *dev);
+int hidma_mgmt_setup(struct hidma_mgmt_dev *mgmtdev);
drivers/dma/qcom/hidma_mgmt_sys.c new file +295 -0

295 lines not on this page · raw message

Signature · 2 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#11 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

Hi,

[adding KVM people, given this is meant for virtualization]

Quoted 7 lines · Sinan Kaya

The Qualcomm Technologies HIDMA device has been designed to support virtualization technology. The driver has been divided into two to follow the hardware design.

1. HIDMA Management driver
2. HIDMA Channel driver

Quoted 8 lines

Each HIDMA HW consists of multiple channels. These channels share some set of common parameters. These parameters are initialized by the management driver during power up. Same management driver is used for monitoring the execution of the channels. Management driver can change the performance behavior dynamically such as bandwidth allocation and prioritization.

The management driver is executed in hypervisor context and is the main management entity for all channels provided by the device.

You mention repeatedly that this is designed for virtualization, but looking at the series as it stands today I can't see how this operates from the host side.

This doesn't seem to tie into KVM or VFIO, and as far as I can tell there's no mechanism for associating channels with a particular virtual address space (i.e. no configuration of an external or internal IOMMU), nor pinning of guest pages to allow for DMA to occur safely.

Given that, I'm at a loss as to how this would be used in a hypervisor context. What am I missing?

Are there additional patches, or do you have some userspace that works with this in some limited configuration?

Thanks,
Mark.

Quoted 803 lines
---
 .../ABI/testing/sysfs-platform-hidma-mgmt          |  97 +++++++
 drivers/dma/qcom/Kconfig                           |  11 +
 drivers/dma/qcom/Makefile                          |   2 +
 drivers/dma/qcom/hidma_mgmt.c                      | 302 +++++++++++++++++++++
 drivers/dma/qcom/hidma_mgmt.h                      |  39 +++
 drivers/dma/qcom/hidma_mgmt_sys.c                  | 295 ++++++++++++++++++++
 6 files changed, 746 insertions(+)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-hidma-mgmt
 create mode 100644 drivers/dma/qcom/hidma_mgmt.c
 create mode 100644 drivers/dma/qcom/hidma_mgmt.h
 create mode 100644 drivers/dma/qcom/hidma_mgmt_sys.c
Documentation/ABI/testing/sysfs-platform-hidma-mgmt new file +97 -0
new file mode 100644
index 0000000..c2fb5d0
@@ -0,0 +1,97 @@
+What:		/sys/devices/platform/hidma-mgmt*/chanops/chan*/priority
+		/sys/devices/platform/QCOM8060:*/chanops/chan*/priority
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Contains either 0 or 1 and indicates if the DMA channel is a
+		low priority (0) or high priority (1) channel.
+
+What:		/sys/devices/platform/hidma-mgmt*/chanops/chan*/weight
+		/sys/devices/platform/QCOM8060:*/chanops/chan*/weight
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Contains 0..15 and indicates the weight of the channel among
+		equal priority channels during round robin scheduling.
+
+What:		/sys/devices/platform/hidma-mgmt*/chreset_timeout_cycles
+		/sys/devices/platform/QCOM8060:*/chreset_timeout_cycles
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Contains the platform specific cycle value to wait after a
+		reset command is issued. If the value is chosen too short,
+		then the HW will issue a reset failure interrupt. The value
+		is platform specific and should not be changed without
+		consultance.
+
+What:		/sys/devices/platform/hidma-mgmt*/dma_channels
+		/sys/devices/platform/QCOM8060:*/dma_channels
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Contains the number of dma channels supported by one instance
+		of HIDMA hardware. The value may change from chip to chip.
+
+What:		/sys/devices/platform/hidma-mgmt*/hw_version_major
+		/sys/devices/platform/QCOM8060:*/hw_version_major
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Version number major for the hardware.
+
+What:		/sys/devices/platform/hidma-mgmt*/hw_version_minor
+		/sys/devices/platform/QCOM8060:*/hw_version_minor
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Version number minor for the hardware.
+
+What:		/sys/devices/platform/hidma-mgmt*/max_rd_xactions
+		/sys/devices/platform/QCOM8060:*/max_rd_xactions
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Contains a value between 0 and 31. Maximum number of
+		read transactions that can be issued back to back.
+		Choosing a higher number gives better performance but
+		can also cause performance reduction to other peripherals
+		sharing the same bus.
+
+What:		/sys/devices/platform/hidma-mgmt*/max_read_request
+		/sys/devices/platform/QCOM8060:*/max_read_request
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Size of each read request. The value needs to be a power
+		of two and can be between 128 and 1024.
+
+What:		/sys/devices/platform/hidma-mgmt*/max_wr_xactions
+		/sys/devices/platform/QCOM8060:*/max_wr_xactions
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Contains a value between 0 and 31. Maximum number of
+		write transactions that can be issued back to back.
+		Choosing a higher number gives better performance but
+		can also cause performance reduction to other peripherals
+		sharing the same bus.
+
+
+What:		/sys/devices/platform/hidma-mgmt*/max_write_request
+		/sys/devices/platform/QCOM8060:*/max_write_request
+Date:		Nov 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Size of each write request. The value needs to be a power
+		of two and can be between 128 and 1024.
drivers/dma/qcom/Kconfig +11 -0
index f17c272..ebe5b8c 100644
@@ -6,3 +6,14 @@ config QCOM_BAM_DMA
 	---help---
 	  Enable support for the QCOM BAM DMA controller.  This controller
 	  provides DMA capabilities for a variety of on-chip devices.
+
+config QCOM_HIDMA_MGMT
+	tristate "Qualcomm Technologies HIDMA Management support"
+	select DMA_ENGINE
+	help
+	  Enable support for the Qualcomm Technologies HIDMA Management.
+	  Each DMA device requires one management interface driver
+	  for basic initialization before QCOM_HIDMA channel driver can
+	  start managing the channels. In a virtualized environment,
+	  the guest OS would run QCOM_HIDMA channel driver and the
+	  hypervisor would run the QCOM_HIDMA_MGMT management driver.
drivers/dma/qcom/Makefile +2 -0
index f612ae3..bfea699 100644
@@ -1 +1,3 @@
 obj-$(CONFIG_QCOM_BAM_DMA) += bam_dma.o
+obj-$(CONFIG_QCOM_HIDMA_MGMT) += hdma_mgmt.o
+hdma_mgmt-objs	 := hidma_mgmt.o hidma_mgmt_sys.o
drivers/dma/qcom/hidma_mgmt.c new file +302 -0
new file mode 100644
index 0000000..ef491b8
@@ -0,0 +1,302 @@
+/*
+ * Qualcomm Technologies HIDMA DMA engine Management interface
+ *
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/dmaengine.h>
+#include <linux/acpi.h>
+#include <linux/of.h>
+#include <linux/property.h>
+#include <linux/interrupt.h>
+#include <linux/platform_device.h>
+#include <linux/module.h>
+#include <linux/uaccess.h>
+#include <linux/slab.h>
+#include <linux/pm_runtime.h>
+#include <linux/bitops.h>
+
+#include "hidma_mgmt.h"
+
+#define HIDMA_QOS_N_OFFSET		0x300
+#define HIDMA_CFG_OFFSET		0x400
+#define HIDMA_MAX_BUS_REQ_LEN_OFFSET	0x41C
+#define HIDMA_MAX_XACTIONS_OFFSET	0x420
+#define HIDMA_HW_VERSION_OFFSET	0x424
+#define HIDMA_CHRESET_TIMEOUT_OFFSET	0x418
+
+#define HIDMA_MAX_WR_XACTIONS_MASK	GENMASK(4, 0)
+#define HIDMA_MAX_RD_XACTIONS_MASK	GENMASK(4, 0)
+#define HIDMA_WEIGHT_MASK		GENMASK(6, 0)
+#define HIDMA_MAX_BUS_REQ_LEN_MASK	GENMASK(15, 0)
+#define HIDMA_CHRESET_TIMEOUT_MASK	GENMASK(19, 0)
+
+#define HIDMA_MAX_WR_XACTIONS_BIT_POS	16
+#define HIDMA_MAX_BUS_WR_REQ_BIT_POS	16
+#define HIDMA_WRR_BIT_POS		8
+#define HIDMA_PRIORITY_BIT_POS		15
+
+#define HIDMA_AUTOSUSPEND_TIMEOUT	2000
+#define HIDMA_MAX_CHANNEL_WEIGHT	15
+
+int hidma_mgmt_setup(struct hidma_mgmt_dev *mgmtdev)
+{
+	unsigned int i;
+	u32 val;
+
+	if (!is_power_of_2(mgmtdev->max_write_request) ||
+	    (mgmtdev->max_write_request < 128) ||
+	    (mgmtdev->max_write_request > 1024)) {
+		dev_err(&mgmtdev->pdev->dev, "invalid write request %d\n",
+			mgmtdev->max_write_request);
+		return -EINVAL;
+	}
+
+	if (!is_power_of_2(mgmtdev->max_read_request) ||
+	    (mgmtdev->max_read_request < 128) ||
+	    (mgmtdev->max_read_request > 1024)) {
+		dev_err(&mgmtdev->pdev->dev, "invalid read request %d\n",
+			mgmtdev->max_read_request);
+		return -EINVAL;
+	}
+
+	if (mgmtdev->max_wr_xactions > HIDMA_MAX_WR_XACTIONS_MASK) {
+		dev_err(&mgmtdev->pdev->dev,
+			"max_wr_xactions cannot be bigger than %ld\n",
+			HIDMA_MAX_WR_XACTIONS_MASK);
+		return -EINVAL;
+	}
+
+	if (mgmtdev->max_rd_xactions > HIDMA_MAX_RD_XACTIONS_MASK) {
+		dev_err(&mgmtdev->pdev->dev,
+			"max_rd_xactions cannot be bigger than %ld\n",
+			HIDMA_MAX_RD_XACTIONS_MASK);
+		return -EINVAL;
+	}
+
+	for (i = 0; i < mgmtdev->dma_channels; i++) {
+		if (mgmtdev->priority[i] > 1) {
+			dev_err(&mgmtdev->pdev->dev,
+				"priority can be 0 or 1\n");
+			return -EINVAL;
+		}
+
+		if (mgmtdev->weight[i] > HIDMA_MAX_CHANNEL_WEIGHT) {
+			dev_err(&mgmtdev->pdev->dev,
+				"max value of weight can be %d.\n",
+				HIDMA_MAX_CHANNEL_WEIGHT);
+			return -EINVAL;
+		}
+
+		/* weight needs to be at least one */
+		if (mgmtdev->weight[i] == 0)
+			mgmtdev->weight[i] = 1;
+	}
+
+	pm_runtime_get_sync(&mgmtdev->pdev->dev);
+	val = readl(mgmtdev->virtaddr + HIDMA_MAX_BUS_REQ_LEN_OFFSET);
+	val &= ~(HIDMA_MAX_BUS_REQ_LEN_MASK << HIDMA_MAX_BUS_WR_REQ_BIT_POS);
+	val |= mgmtdev->max_write_request << HIDMA_MAX_BUS_WR_REQ_BIT_POS;
+	val &= ~HIDMA_MAX_BUS_REQ_LEN_MASK;
+	val |= mgmtdev->max_read_request;
+	writel(val, mgmtdev->virtaddr + HIDMA_MAX_BUS_REQ_LEN_OFFSET);
+
+	val = readl(mgmtdev->virtaddr + HIDMA_MAX_XACTIONS_OFFSET);
+	val &= ~(HIDMA_MAX_WR_XACTIONS_MASK << HIDMA_MAX_WR_XACTIONS_BIT_POS);
+	val |= mgmtdev->max_wr_xactions << HIDMA_MAX_WR_XACTIONS_BIT_POS;
+	val &= ~HIDMA_MAX_RD_XACTIONS_MASK;
+	val |= mgmtdev->max_rd_xactions;
+	writel(val, mgmtdev->virtaddr + HIDMA_MAX_XACTIONS_OFFSET);
+
+	mgmtdev->hw_version =
+	    readl(mgmtdev->virtaddr + HIDMA_HW_VERSION_OFFSET);
+	mgmtdev->hw_version_major = (mgmtdev->hw_version >> 28) & 0xF;
+	mgmtdev->hw_version_minor = (mgmtdev->hw_version >> 16) & 0xF;
+
+	for (i = 0; i < mgmtdev->dma_channels; i++) {
+		u32 weight = mgmtdev->weight[i];
+		u32 priority = mgmtdev->priority[i];
+
+		val = readl(mgmtdev->virtaddr + HIDMA_QOS_N_OFFSET + (4 * i));
+		val &= ~(1 << HIDMA_PRIORITY_BIT_POS);
+		val |= (priority & 0x1) << HIDMA_PRIORITY_BIT_POS;
+		val &= ~(HIDMA_WEIGHT_MASK << HIDMA_WRR_BIT_POS);
+		val |= (weight & HIDMA_WEIGHT_MASK) << HIDMA_WRR_BIT_POS;
+		writel(val, mgmtdev->virtaddr + HIDMA_QOS_N_OFFSET + (4 * i));
+	}
+
+	val = readl(mgmtdev->virtaddr + HIDMA_CHRESET_TIMEOUT_OFFSET);
+	val &= ~HIDMA_CHRESET_TIMEOUT_MASK;
+	val |= mgmtdev->chreset_timeout_cycles & HIDMA_CHRESET_TIMEOUT_MASK;
+	writel(val, mgmtdev->virtaddr + HIDMA_CHRESET_TIMEOUT_OFFSET);
+
+	pm_runtime_mark_last_busy(&mgmtdev->pdev->dev);
+	pm_runtime_put_autosuspend(&mgmtdev->pdev->dev);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(hidma_mgmt_setup);
+
+static int hidma_mgmt_probe(struct platform_device *pdev)
+{
+	struct hidma_mgmt_dev *mgmtdev;
+	struct resource *res;
+	void __iomem *virtaddr;
+	int irq;
+	int rc;
+	u32 val;
+
+	pm_runtime_set_autosuspend_delay(&pdev->dev, HIDMA_AUTOSUSPEND_TIMEOUT);
+	pm_runtime_use_autosuspend(&pdev->dev);
+	pm_runtime_set_active(&pdev->dev);
+	pm_runtime_enable(&pdev->dev);
+	pm_runtime_get_sync(&pdev->dev);
+
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	virtaddr = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(virtaddr)) {
+		rc = -ENOMEM;
+		goto out;
+	}
+
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0) {
+		dev_err(&pdev->dev, "irq resources not found\n");
+		rc = irq;
+		goto out;
+	}
+
+	mgmtdev = devm_kzalloc(&pdev->dev, sizeof(*mgmtdev), GFP_KERNEL);
+	if (!mgmtdev) {
+		rc = -ENOMEM;
+		goto out;
+	}
+
+	mgmtdev->pdev = pdev;
+	mgmtdev->addrsize = resource_size(res);
+	mgmtdev->virtaddr = virtaddr;
+
+	rc = device_property_read_u32(&pdev->dev, "dma-channels",
+				      &mgmtdev->dma_channels);
+	if (rc) {
+		dev_err(&pdev->dev, "number of channels missing\n");
+		goto out;
+	}
+
+	rc = device_property_read_u32(&pdev->dev,
+				      "channel-reset-timeout-cycles",
+				      &mgmtdev->chreset_timeout_cycles);
+	if (rc) {
+		dev_err(&pdev->dev, "channel reset timeout missing\n");
+		goto out;
+	}
+
+	rc = device_property_read_u32(&pdev->dev, "max-write-burst-bytes",
+				      &mgmtdev->max_write_request);
+	if (rc) {
+		dev_err(&pdev->dev, "max-write-burst-bytes missing\n");
+		goto out;
+	}
+
+	rc = device_property_read_u32(&pdev->dev, "max-read-burst-bytes",
+				      &mgmtdev->max_read_request);
+	if (rc) {
+		dev_err(&pdev->dev, "max-read-burst-bytes missing\n");
+		goto out;
+	}
+
+	rc = device_property_read_u32(&pdev->dev, "max-write-transactions",
+				      &mgmtdev->max_wr_xactions);
+	if (rc) {
+		dev_err(&pdev->dev, "max-write-transactions missing\n");
+		goto out;
+	}
+
+	rc = device_property_read_u32(&pdev->dev, "max-read-transactions",
+				      &mgmtdev->max_rd_xactions);
+	if (rc) {
+		dev_err(&pdev->dev, "max-read-transactions missing\n");
+		goto out;
+	}
+
+	mgmtdev->priority = devm_kcalloc(&pdev->dev,
+					 mgmtdev->dma_channels,
+					 sizeof(*mgmtdev->priority),
+					 GFP_KERNEL);
+	if (!mgmtdev->priority) {
+		rc = -ENOMEM;
+		goto out;
+	}
+
+	mgmtdev->weight = devm_kcalloc(&pdev->dev,
+				       mgmtdev->dma_channels,
+				       sizeof(*mgmtdev->weight), GFP_KERNEL);
+	if (!mgmtdev->weight) {
+		rc = -ENOMEM;
+		goto out;
+	}
+
+	rc = hidma_mgmt_setup(mgmtdev);
+	if (rc) {
+		dev_err(&pdev->dev, "setup failed\n");
+		goto out;
+	}
+
+	/* start the HW */
+	val = readl(mgmtdev->virtaddr + HIDMA_CFG_OFFSET);
+	val |= 1;
+	writel(val, mgmtdev->virtaddr + HIDMA_CFG_OFFSET);
+
+	rc = hidma_mgmt_init_sys(mgmtdev);
+	if (rc) {
+		dev_err(&pdev->dev, "sysfs setup failed\n");
+		goto out;
+	}
+
+	dev_info(&pdev->dev,
+		 "HW rev: %d.%d @ %pa with %d physical channels\n",
+		 mgmtdev->hw_version_major, mgmtdev->hw_version_minor,
+		 &res->start, mgmtdev->dma_channels);
+
+	platform_set_drvdata(pdev, mgmtdev);
+	pm_runtime_mark_last_busy(&pdev->dev);
+	pm_runtime_put_autosuspend(&pdev->dev);
+	return 0;
+out:
+	pm_runtime_put_sync_suspend(&pdev->dev);
+	pm_runtime_disable(&pdev->dev);
+	return rc;
+}
+
+#if IS_ENABLED(CONFIG_ACPI)
+static const struct acpi_device_id hidma_mgmt_acpi_ids[] = {
+	{"QCOM8060"},
+	{},
+};
+#endif
+
+static const struct of_device_id hidma_mgmt_match[] = {
+	{.compatible = "qcom,hidma-mgmt-1.0",},
+	{},
+};
+MODULE_DEVICE_TABLE(of, hidma_mgmt_match);
+
+static struct platform_driver hidma_mgmt_driver = {
+	.probe = hidma_mgmt_probe,
+	.driver = {
+		   .name = "hidma-mgmt",
+		   .of_match_table = hidma_mgmt_match,
+		   .acpi_match_table = ACPI_PTR(hidma_mgmt_acpi_ids),
+	},
+};
+
+module_platform_driver(hidma_mgmt_driver);
+MODULE_LICENSE("GPL v2");
drivers/dma/qcom/hidma_mgmt.h new file +39 -0
new file mode 100644
index 0000000..f7daf33
@@ -0,0 +1,39 @@
+/*
+ * Qualcomm Technologies HIDMA Management common header
+ *
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+struct hidma_mgmt_dev {
+	u8 hw_version_major;
+	u8 hw_version_minor;
+
+	u32 max_wr_xactions;
+	u32 max_rd_xactions;
+	u32 max_write_request;
+	u32 max_read_request;
+	u32 dma_channels;
+	u32 chreset_timeout_cycles;
+	u32 hw_version;
+	u32 *priority;
+	u32 *weight;
+
+	/* Hardware device constants */
+	void __iomem *virtaddr;
+	resource_size_t addrsize;
+
+	struct kobject **chroots;
+	struct platform_device *pdev;
+};
+
+int hidma_mgmt_init_sys(struct hidma_mgmt_dev *dev);
+int hidma_mgmt_setup(struct hidma_mgmt_dev *mgmtdev);
drivers/dma/qcom/hidma_mgmt_sys.c new file +295 -0
new file mode 100644
index 0000000..7f252fb
@@ -0,0 +1,295 @@
+/*
+ * Qualcomm Technologies HIDMA Management SYS interface
+ *
+ * Copyright (c) 2015, The Linux Foundation. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 and
+ * only version 2 as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/sysfs.h>
+#include <linux/platform_device.h>
+
+#include "hidma_mgmt.h"
+
+struct hidma_chan_attr {
+	struct hidma_mgmt_dev *mdev;
+	int index;
+	struct kobj_attribute attr;
+};
+
+struct hidma_mgmt_fileinfo {
+	char *name;
+	int mode;
+	int (*get)(struct hidma_mgmt_dev *mdev);
+	int (*set)(struct hidma_mgmt_dev *mdev, u64 val);
+};
+
+#define IMPLEMENT_GETSET(name)					\
+static int get_##name(struct hidma_mgmt_dev *mdev)		\
+{								\
+	return mdev->name;					\
+}								\
+static int set_##name(struct hidma_mgmt_dev *mdev, u64 val)	\
+{								\
+	u64 tmp;						\
+	int rc;							\
+								\
+	tmp = mdev->name;					\
+	mdev->name = val;					\
+	rc = hidma_mgmt_setup(mdev);				\
+	if (rc)							\
+		mdev->name = tmp;				\
+	return rc;						\
+}
+
+#define DECLARE_ATTRIBUTE(name, mode)				\
+	{#name, mode, get_##name, set_##name}
+
+IMPLEMENT_GETSET(hw_version_major)
+IMPLEMENT_GETSET(hw_version_minor)
+IMPLEMENT_GETSET(max_wr_xactions)
+IMPLEMENT_GETSET(max_rd_xactions)
+IMPLEMENT_GETSET(max_write_request)
+IMPLEMENT_GETSET(max_read_request)
+IMPLEMENT_GETSET(dma_channels)
+IMPLEMENT_GETSET(chreset_timeout_cycles)
+
+static int set_priority(struct hidma_mgmt_dev *mdev, unsigned int i, u64 val)
+{
+	u64 tmp;
+	int rc;
+
+	if (i >= mdev->dma_channels)
+		return -EINVAL;
+
+	tmp = mdev->priority[i];
+	mdev->priority[i] = val;
+	rc = hidma_mgmt_setup(mdev);
+	if (rc)
+		mdev->priority[i] = tmp;
+	return rc;
+}
+
+static int set_weight(struct hidma_mgmt_dev *mdev, unsigned int i, u64 val)
+{
+	u64 tmp;
+	int rc;
+
+	if (i >= mdev->dma_channels)
+		return -EINVAL;
+
+	tmp = mdev->weight[i];
+	mdev->weight[i] = val;
+	rc = hidma_mgmt_setup(mdev);
+	if (rc)
+		mdev->weight[i] = tmp;
+	return rc;
+}
+
+static struct hidma_mgmt_fileinfo hidma_mgmt_files[] = {
+	DECLARE_ATTRIBUTE(hw_version_major, S_IRUGO),
+	DECLARE_ATTRIBUTE(hw_version_minor, S_IRUGO),
+	DECLARE_ATTRIBUTE(dma_channels, S_IRUGO),
+	DECLARE_ATTRIBUTE(chreset_timeout_cycles, S_IRUGO),
+	DECLARE_ATTRIBUTE(max_wr_xactions, (S_IRUGO | S_IWUGO)),
+	DECLARE_ATTRIBUTE(max_rd_xactions, (S_IRUGO | S_IWUGO)),
+	DECLARE_ATTRIBUTE(max_write_request, (S_IRUGO | S_IWUGO)),
+	DECLARE_ATTRIBUTE(max_read_request, (S_IRUGO | S_IWUGO)),
+};
+
+static ssize_t show_values(struct device *dev, struct device_attribute *attr,
+			   char *buf)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct hidma_mgmt_dev *mdev = platform_get_drvdata(pdev);
+	unsigned int i;
+
+	buf[0] = 0;
+
+	for (i = 0; i < ARRAY_SIZE(hidma_mgmt_files); i++) {
+		if (strcmp(attr->attr.name, hidma_mgmt_files[i].name) == 0) {
+			sprintf(buf, "%d\n", hidma_mgmt_files[i].get(mdev));
+			break;
+		}
+	}
+	return strlen(buf);
+}
+
+static ssize_t set_values(struct device *dev, struct device_attribute *attr,
+			  const char *buf, size_t count)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct hidma_mgmt_dev *mdev = platform_get_drvdata(pdev);
+	unsigned long tmp;
+	unsigned int i;
+	int rc;
+
+	rc = kstrtoul(buf, 0, &tmp);
+	if (rc)
+		return rc;
+
+	for (i = 0; i < ARRAY_SIZE(hidma_mgmt_files); i++) {
+		if (strcmp(attr->attr.name, hidma_mgmt_files[i].name) == 0) {
+			rc = hidma_mgmt_files[i].set(mdev, tmp);
+			if (rc)
+				return rc;
+
+			break;
+		}
+	}
+	return count;
+}
+
+static ssize_t show_values_channel(struct kobject *kobj,
+				   struct kobj_attribute *attr, char *buf)
+{
+	struct hidma_chan_attr *chattr;
+	struct hidma_mgmt_dev *mdev;
+
+	buf[0] = 0;
+	chattr = container_of(attr, struct hidma_chan_attr, attr);
+	mdev = chattr->mdev;
+	if (strcmp(attr->attr.name, "priority") == 0)
+		sprintf(buf, "%d\n", mdev->priority[chattr->index]);
+	else if (strcmp(attr->attr.name, "weight") == 0)
+		sprintf(buf, "%d\n", mdev->weight[chattr->index]);
+
+	return strlen(buf);
+}
+
+static ssize_t set_values_channel(struct kobject *kobj,
+				  struct kobj_attribute *attr, const char *buf,
+				  size_t count)
+{
+	struct hidma_chan_attr *chattr;
+	struct hidma_mgmt_dev *mdev;
+	unsigned long tmp;
+	int rc;
+
+	chattr = container_of(attr, struct hidma_chan_attr, attr);
+	mdev = chattr->mdev;
+
+	rc = kstrtoul(buf, 0, &tmp);
+	if (rc)
+		return rc;
+
+	if (strcmp(attr->attr.name, "priority") == 0) {
+		rc = set_priority(mdev, chattr->index, tmp);
+		if (rc)
+			return rc;
+	} else if (strcmp(attr->attr.name, "weight") == 0) {
+		rc = set_weight(mdev, chattr->index, tmp);
+		if (rc)
+			return rc;
+	}
+	return count;
+}
+
+static int create_sysfs_entry(struct hidma_mgmt_dev *dev, char *name, int mode)
+{
+	struct device_attribute *attrs;
+	char *name_copy;
+
+	attrs = devm_kmalloc(&dev->pdev->dev,
+			     sizeof(struct device_attribute), GFP_KERNEL);
+	if (!attrs)
+		return -ENOMEM;
+
+	name_copy = devm_kstrdup(&dev->pdev->dev, name, GFP_KERNEL);
+	if (!name_copy)
+		return -ENOMEM;
+
+	attrs->attr.name = name_copy;
+	attrs->attr.mode = mode;
+	attrs->show = show_values;
+	attrs->store = set_values;
+	sysfs_attr_init(&attrs->attr);
+
+	return device_create_file(&dev->pdev->dev, attrs);
+}
+
+static int create_sysfs_entry_channel(struct hidma_mgmt_dev *mdev, char *name,
+				      int mode, int index,
+				      struct kobject *parent)
+{
+	struct hidma_chan_attr *chattr;
+	char *name_copy;
+
+	chattr = devm_kmalloc(&mdev->pdev->dev, sizeof(*chattr), GFP_KERNEL);
+	if (!chattr)
+		return -ENOMEM;
+
+	name_copy = devm_kstrdup(&mdev->pdev->dev, name, GFP_KERNEL);
+	if (!name_copy)
+		return -ENOMEM;
+
+	chattr->mdev = mdev;
+	chattr->index = index;
+	chattr->attr.attr.name = name_copy;
+	chattr->attr.attr.mode = mode;
+	chattr->attr.show = show_values_channel;
+	chattr->attr.store = set_values_channel;
+	sysfs_attr_init(&chattr->attr.attr);
+
+	return sysfs_create_file(parent, &chattr->attr.attr);
+}
+
+int hidma_mgmt_init_sys(struct hidma_mgmt_dev *mdev)
+{
+	unsigned int i;
+	int rc;
+	int required;
+	struct kobject *chanops;
+
+	required = sizeof(*mdev->chroots) * mdev->dma_channels;
+	mdev->chroots = devm_kmalloc(&mdev->pdev->dev, required, GFP_KERNEL);
+	if (!mdev->chroots)
+		return -ENOMEM;
+
+	chanops = kobject_create_and_add("chanops", &mdev->pdev->dev.kobj);
+	if (!chanops)
+		return -ENOMEM;
+
+	/* create each channel directory here */
+	for (i = 0; i < mdev->dma_channels; i++) {
+		char name[20];
+
+		snprintf(name, sizeof(name), "chan%d", i);
+		mdev->chroots[i] = kobject_create_and_add(name, chanops);
+		if (!mdev->chroots[i])
+			return -ENOMEM;
+	}
+
+	/* populate common parameters */
+	for (i = 0; i < ARRAY_SIZE(hidma_mgmt_files); i++) {
+		rc = create_sysfs_entry(mdev, hidma_mgmt_files[i].name,
+					hidma_mgmt_files[i].mode);
+		if (rc)
+			return rc;
+	}
+
+	/* populate parameters that are per channel */
+	for (i = 0; i < mdev->dma_channels; i++) {
+		rc = create_sysfs_entry_channel(mdev, "priority",
+						(S_IRUGO | S_IWUGO), i,
+						mdev->chroots[i]);
+		if (rc)
+			return rc;
+
+		rc = create_sysfs_entry_channel(mdev, "weight",
+						(S_IRUGO | S_IWUGO), i,
+						mdev->chroots[i]);
+		if (rc)
+			return rc;
+	}
+
+	return 0;
+}
+EXPORT_SYMBOL_GPL(hidma_mgmt_init_sys);
Signature · 2 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
author
#12 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

Hi Mark,

Quoted 21 lines · Mark Rutland

Hi,

[adding KVM people, given this is meant for virtualization]

Quoted 7 lines · Sinan Kaya

The Qualcomm Technologies HIDMA device has been designed to support virtualization technology. The driver has been divided into two to follow the hardware design.

1. HIDMA Management driver
2. HIDMA Channel driver

Quoted 8 lines

Each HIDMA HW consists of multiple channels. These channels share some set of common parameters. These parameters are initialized by the management driver during power up. Same management driver is used for monitoring the execution of the channels. Management driver can change the performance behavior dynamically such as bandwidth allocation and prioritization.

The management driver is executed in hypervisor context and is the main management entity for all channels provided by the device.

Quoted 8 lines

You mention repeatedly that this is designed for virtualization, but looking at the series as it stands today I can't see how this operates from the host side.

This doesn't seem to tie into KVM or VFIO, and as far as I can tell there's no mechanism for associating channels with a particular virtual address space (i.e. no configuration of an external or internal IOMMU), nor pinning of guest pages to allow for DMA to occur safely.

I'm using VFIO platform driver for this purpose. VFIO platform driver is capable of assigning any platform device to a guest machine with this driver.

You just unbind the HIDMA channel driver from the hypervisor and bind to vfio driver using the very same approach you'd use with PCIe.

Of course, this all assumes the presence of an IOMMU driver on the system. VFIO driver uses the IOMMU driver to create the mappings.

The mechanism used here is not different from VFIO PCI from user perspective.

Quoted 6 lines

Given that, I'm at a loss as to how this would be used in a hypervisor context. What am I missing?

Are there additional patches, or do you have some userspace that works with this in some limited configuration?

No, these are the only patches. We have one patch for the QEMU but from kernel perspective this is it.

I just rely on the platform VFIO driver to do the work.

Quoted 4 lines

Thanks,
Mark.

Sinan
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html

#13 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

Quoted 28 lines · Sinan Kaya

Hi Mark,

Quoted 25 lines · Mark Rutland

Hi,

[adding KVM people, given this is meant for virtualization]

Quoted 7 lines · Sinan Kaya

The Qualcomm Technologies HIDMA device has been designed to support virtualization technology. The driver has been divided into two to follow the hardware design.

1. HIDMA Management driver
2. HIDMA Channel driver

Quoted 8 lines

Each HIDMA HW consists of multiple channels. These channels share some set of common parameters. These parameters are initialized by the management driver during power up. Same management driver is used for monitoring the execution of the channels. Management driver can change the performance behavior dynamically such as bandwidth allocation and prioritization.

The management driver is executed in hypervisor context and is the main management entity for all channels provided by the device.

You mention repeatedly that this is designed for virtualization, but looking at the series as it stands today I can't see how this operates from the host side.

Quoted 7 lines
Quoted 4 lines

This doesn't seem to tie into KVM or VFIO, and as far as I can tell there's no mechanism for associating channels with a particular virtual address space (i.e. no configuration of an external or internal IOMMU), nor pinning of guest pages to allow for DMA to occur safely.

I'm using VFIO platform driver for this purpose. VFIO platform driver is capable of assigning any platform device to a guest machine with this driver.

Typically VFIO-platform also comes with a corresponding reset driver. You don't need one?

Quoted 5 lines

You just unbind the HIDMA channel driver from the hypervisor and bind to vfio driver using the very same approach you'd use with PCIe.

Of course, this all assumes the presence of an IOMMU driver on the system. VFIO driver uses the IOMMU driver to create the mappings.

No IOMMU was described in the DT binding. It sounds like you'd need an optional (not present in the guest) iommus property per-channel

Quoted 11 lines

The mechanism used here is not different from VFIO PCI from user perspective.

Quoted 6 lines

Given that, I'm at a loss as to how this would be used in a hypervisor context. What am I missing?

Are there additional patches, or do you have some userspace that works with this in some limited configuration?

No, these are the only patches. We have one patch for the QEMU but from kernel perspective this is it.

Do you have a link to that? Seeing it would help to ease my concerns.

Thanks,
Mark.

author
#14 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

Quoted 10 lines
Quoted 7 lines
Quoted 4 lines

This doesn't seem to tie into KVM or VFIO, and as far as I can tell there's no mechanism for associating channels with a particular virtual address space (i.e. no configuration of an external or internal IOMMU), nor pinning of guest pages to allow for DMA to occur safely.

I'm using VFIO platform driver for this purpose. VFIO platform driver is capable of assigning any platform device to a guest machine with this driver.

Typically VFIO-platform also comes with a corresponding reset driver. You don't need one?

The HIDMA channel driver resets the channel before using it. That's why, I never bothered with writing a reset driver on the hypervisor.

Quoted 9 lines
Quoted 6 lines

You just unbind the HIDMA channel driver from the hypervisor and bind to vfio driver using the very same approach you'd use with PCIe.

Of course, this all assumes the presence of an IOMMU driver on the system. VFIO driver uses the IOMMU driver to create the mappings.

No IOMMU was described in the DT binding. It sounds like you'd need an optional (not present in the guest) iommus property per-channel

You are right. I missed that part. I'll update the device-tree binding documentation.

Quoted 7 lines
Quoted 7 lines

The mechanism used here is not different from VFIO PCI from user perspective.

Quoted 4 lines

Given that, I'm at a loss as to how this would be used in a hypervisor context. What am I missing?

Quoted 7 lines
Quoted 5 lines
Quoted 2 lines

Are there additional patches, or do you have some userspace that works with this in some limited configuration?

No, these are the only patches. We have one patch for the QEMU but from kernel perspective this is it.

Do you have a link to that? Seeing it would help to ease my concerns.

The QEMU driver has not been posted yet. As far as I know, it just discovers the memory resources on the platform object and creates mappings for the guest machine only.

Shanker Donthineni and Vikram Sethi will post the QEMU patch later.

Quoted 4 lines

Thanks,
Mark.

Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#15 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

Quoted 39 lines · Sinan Kaya
Quoted 10 lines
Quoted 7 lines
Quoted 4 lines

This doesn't seem to tie into KVM or VFIO, and as far as I can tell there's no mechanism for associating channels with a particular virtual address space (i.e. no configuration of an external or internal IOMMU), nor pinning of guest pages to allow for DMA to occur safely.

I'm using VFIO platform driver for this purpose. VFIO platform driver is capable of assigning any platform device to a guest machine with this driver.

Typically VFIO-platform also comes with a corresponding reset driver. You don't need one?

The HIDMA channel driver resets the channel before using it. That's why, I never bothered with writing a reset driver on the hypervisor.

Quoted 9 lines
Quoted 6 lines

You just unbind the HIDMA channel driver from the hypervisor and bind to vfio driver using the very same approach you'd use with PCIe.

Of course, this all assumes the presence of an IOMMU driver on the system. VFIO driver uses the IOMMU driver to create the mappings.

No IOMMU was described in the DT binding. It sounds like you'd need an optional (not present in the guest) iommus property per-channel

You are right. I missed that part. I'll update the device-tree binding documentation.

Quoted 13 lines
Quoted 12 lines

The mechanism used here is not different from VFIO PCI from user perspective.

Quoted 6 lines

Given that, I'm at a loss as to how this would be used in a hypervisor context. What am I missing?

Are there additional patches, or do you have some userspace that works with this in some limited configuration?

No, these are the only patches. We have one patch for the QEMU but from kernel perspective this is it.

Quoted 6 lines
Quoted 1 line

Do you have a link to that? Seeing it would help to ease my concerns.

The QEMU driver has not been posted yet. As far as I know, it just discovers the memory resources on the platform object and creates mappings for the guest machine only.

Shanker Donthineni and Vikram Sethi will post the QEMU patch later.

Then may I suggest you both synchronize your submissions? I'd really like to hear from the QEMU maintainers that they are satisfied with that side of the story as well.

Thanks,

	M.
Signature · 5 lines
Jazz is not dead. It just smells funny...
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#16 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

Quoted 9 lines · Marc Zyngier
Quoted 6 lines
Quoted 6 lines

Do you have a link to that? Seeing it would help to ease my concerns.

The QEMU driver has not been posted yet. As far as I know, it just discovers the memory resources on the platform object and creates mappings for the guest machine only.

Shanker Donthineni and Vikram Sethi will post the QEMU patch later.

Then may I suggest you both synchronize your submissions? I'd really like to hear from the QEMU maintainers that they are satisfied with that side of the story as well.

The HIDMA QEMU driver is also based on VFIO platform driver in QEMU. It is not a new concept or new framework. All tried and tested solutions.

The driver below is already using this feature. HIDMA is no exception. I have verified functionality of HIDMA linux driver with HIDMA QEMU driver already.

https://lxr.missinglinkelectronics.com/qemu/hw/arm/sysbus-fdt.c#L67
https://lxr.missinglinkelectronics.com/qemu/hw/vfio/calxeda-xgmac.c#L18
https://lxr.missinglinkelectronics.com/qemu/include/hw/vfio/vfio-calxeda-xgmac.h

Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#17 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

Quoted 11 lines · Sinan Kaya
Quoted 9 lines · Marc Zyngier
Quoted 6 lines
Quoted 6 lines

Do you have a link to that? Seeing it would help to ease my concerns.

The QEMU driver has not been posted yet. As far as I know, it just discovers the memory resources on the platform object and creates mappings for the guest machine only.

Shanker Donthineni and Vikram Sethi will post the QEMU patch later.

Then may I suggest you both synchronize your submissions? I'd really like to hear from the QEMU maintainers that they are satisfied with that side of the story as well.

Quoted 5 lines

The HIDMA QEMU driver is also based on VFIO platform driver in QEMU. It is not a new concept or new framework. All tried and tested solutions.

The driver below is already using this feature. HIDMA is no exception. I have verified functionality of HIDMA linux driver with HIDMA QEMU driver already.

That you have tested what you propose is the minimum you can do.

Quoted 3 lines

https://lxr.missinglinkelectronics.com/qemu/hw/arm/sysbus-fdt.c#L67
https://lxr.missinglinkelectronics.com/qemu/hw/vfio/calxeda-xgmac.c#L18
https://lxr.missinglinkelectronics.com/qemu/include/hw/vfio/vfio-calxeda-xgmac.h

None of which warrants that what you're doing is the right thing. Since nobody has seen your QEMU code, I'm not going to take any bet.

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
author
#18 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

In reply to Mark Rutland
Quoted 2 lines · Mark Rutland

Typically VFIO-platform also comes with a corresponding reset driver. You don't need one?

Digging this further, I do need a HIDMA reset driver. The reset driver is useful if HIDMA operation is aborted in the middle and guest machine is shutdown.

I'm preparing a reset driver and I'll post it soon.

In the meantime, I have observed a lack of ACPI HID support in the platform reset interface vfio_platform_lookup_reset and vfio_platform_probe_common specifically.

The interface is querying objects with "compatible" string. Of course on a true ACPI system with proper named HIDs except PRP001, "compatible" attribute does not exist. I'm also preparing a patch for this too.

Since VFIO patches go through another branch and the reset driver also needs to go through vfio along with the ACPI object querying support, would you like this to be addressed independently with a different series or have it reviewed altogether here then figure out the merge path later?

Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#19 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

In reply to Mark Rutland
Quoted 18 lines · Mark Rutland

Hi,

[adding KVM people, given this is meant for virtualization]

Quoted 13 lines · Sinan Kaya

The Qualcomm Technologies HIDMA device has been designed to support virtualization technology. The driver has been divided into two to follow the hardware design.

1. HIDMA Management driver
2. HIDMA Channel driver

Each HIDMA HW consists of multiple channels. These channels share some set of common parameters. These parameters are initialized by the management driver during power up. Same management driver is used for monitoring the execution of the channels. Management driver can change the performance behavior dynamically such as bandwidth allocation and prioritization.

Quoted 6 lines
Quoted 2 lines

The management driver is executed in hypervisor context and is the main management entity for all channels provided by the device.

You mention repeatedly that this is designed for virtualization, but looking at the series as it stands today I can't see how this operates from the host side.

Nor the guest's, TBH. How do host and guest communicate, what is the infrastructure, how is it meant to be used? A lot of questions, and no answer whatsoever in this series.

Quoted 11 lines

This doesn't seem to tie into KVM or VFIO, and as far as I can tell there's no mechanism for associating channels with a particular virtual address space (i.e. no configuration of an external or internal IOMMU), nor pinning of guest pages to allow for DMA to occur safely.

Given that, I'm at a loss as to how this would be used in a hypervisor context. What am I missing?

Are there additional patches, or do you have some userspace that works with this in some limited configuration?

Well, this looks so far like a code dumping exercise. I'd very much appreciate a HIDMA101 crash course:

- How do host and guest communicate?
- How is the integration performed in the hypervisor?
- Does the HYP side requires any context switch (and how is that done)?
- What makes it safe?

Without any of this information (and pointer to the code to back it up), I'm very reluctant to take any of this.

Thanks,

	M.
Signature · 5 lines
Jazz is not dead. It just smells funny...
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#20 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

Quoted 22 lines · Marc Zyngier
Quoted 21 lines · Mark Rutland

Hi,

[adding KVM people, given this is meant for virtualization]

Quoted 15 lines · Sinan Kaya

The Qualcomm Technologies HIDMA device has been designed to support virtualization technology. The driver has been divided into two to follow the hardware design.

1. HIDMA Management driver
2. HIDMA Channel driver

Each HIDMA HW consists of multiple channels. These channels share some set of common parameters. These parameters are initialized by the management driver during power up. Same management driver is used for monitoring the execution of the channels. Management driver can change the performance behavior dynamically such as bandwidth allocation and prioritization.

The management driver is executed in hypervisor context and is the main management entity for all channels provided by the device.

Quoted 7 lines
Quoted 3 lines

You mention repeatedly that this is designed for virtualization, but looking at the series as it stands today I can't see how this operates from the host side.

Nor the guest's, TBH. How do host and guest communicate, what is the infrastructure, how is it meant to be used? A lot of questions, and no answer whatsoever in this series.

I always make an analogy of HIDMA channel driver to a PCI endpoint device driver (8139too for example) running on the guest machine.

Both HIDMA and PCI uses device pass-through approach.

I don't have an infrastructure for host and guest to communicate as I don't need to. A HIDMA channel is assigned to a guest machine after an unbind from the host machine.

Guest machine uses HIDMA channel driver to offload DMA operations. The guest machine owns the HW registers for the channel. It doesn't need to trap to host for register read/writes etc.

All guest machine pages used are assumed to be pinned similar to VFIO PCI. The reason is performance. The IOMMU takes care of the address translation for me.

Quoted 7 lines
Quoted 7 lines

This doesn't seem to tie into KVM or VFIO, and as far as I can tell there's no mechanism for associating channels with a particular virtual address space (i.e. no configuration of an external or internal IOMMU), nor pinning of guest pages to allow for DMA to occur safely.

Quoted 8 lines
Quoted 5 lines

Given that, I'm at a loss as to how this would be used in a hypervisor context. What am I missing?

Are there additional patches, or do you have some userspace that works with this in some limited configuration?

Well, this looks so far like a code dumping exercise. I'd very much appreciate a HIDMA101 crash course:

Sure, I'm ready to answer any questions. This is really a VFIO platform course. Not a HIDMA driver course. The approach is not different if you assign a platfom SATA (AHCI) or SDHC driver to a guest machine.

The summary is that:
- IOMMU takes care of the mappings via VFIO driver.
- Guest machine owns the HW. No hypervisor interaction.

Quoted 2 lines

- How do host and guest communicate?

They don't.

Quoted 1 line

- How is the integration performed in the hypervisor?

Hypervisor has a bunch of channel resources. For each guest machine, the channel gets unbound from the hypervisor. Channels get bind to each VFIO platform device and then control is given to the guest machine.

Once the guest machine is shutdown, VFIO driver still owns the channel device. It can assign the device to another guest machine.

Quoted 1 line

- Does the HYP side requires any context switch (and how is that done)?

No communication is needed.

Quoted 1 line

- What makes it safe?

No communication is needed.

Quoted 3 lines

Without any of this information (and pointer to the code to back it up), I'm very reluctant to take any of this.

Please let me know what exactly is not clear.

You don't write a virtualization driver for 8139too driver. The driver works whether it is running in the guest machine or the hypervisor.

The 8139too driver does not trap to the hypervisor for functionality when used in device pass-through mode.

No difference here.

Quoted 5 lines

Thanks,

	M.
Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#21 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

Quoted 58 lines · Sinan Kaya
Quoted 22 lines · Marc Zyngier
Quoted 21 lines · Mark Rutland

Hi,

[adding KVM people, given this is meant for virtualization]

Quoted 15 lines · Sinan Kaya

The Qualcomm Technologies HIDMA device has been designed to support virtualization technology. The driver has been divided into two to follow the hardware design.

1. HIDMA Management driver
2. HIDMA Channel driver

Each HIDMA HW consists of multiple channels. These channels share some set of common parameters. These parameters are initialized by the management driver during power up. Same management driver is used for monitoring the execution of the channels. Management driver can change the performance behavior dynamically such as bandwidth allocation and prioritization.

The management driver is executed in hypervisor context and is the main management entity for all channels provided by the device.

Quoted 7 lines
Quoted 3 lines

You mention repeatedly that this is designed for virtualization, but looking at the series as it stands today I can't see how this operates from the host side.

Nor the guest's, TBH. How do host and guest communicate, what is the infrastructure, how is it meant to be used? A lot of questions, and no answer whatsoever in this series.

I always make an analogy of HIDMA channel driver to a PCI endpoint device driver (8139too for example) running on the guest machine.

Both HIDMA and PCI uses device pass-through approach.

I don't have an infrastructure for host and guest to communicate as I don't need to. A HIDMA channel is assigned to a guest machine after an unbind from the host machine.

Guest machine uses HIDMA channel driver to offload DMA operations. The guest machine owns the HW registers for the channel. It doesn't need to trap to host for register read/writes etc.

All guest machine pages used are assumed to be pinned similar to VFIO PCI. The reason is performance. The IOMMU takes care of the address translation for me.

Quoted 13 lines
Quoted 12 lines

This doesn't seem to tie into KVM or VFIO, and as far as I can tell there's no mechanism for associating channels with a particular virtual address space (i.e. no configuration of an external or internal IOMMU), nor pinning of guest pages to allow for DMA to occur safely.

Given that, I'm at a loss as to how this would be used in a hypervisor context. What am I missing?

Are there additional patches, or do you have some userspace that works with this in some limited configuration?

Quoted 6 lines
Quoted 2 lines

Well, this looks so far like a code dumping exercise. I'd very much appreciate a HIDMA101 crash course:

Sure, I'm ready to answer any questions. This is really a VFIO platform course. Not a HIDMA driver course. The approach is not different if you assign a platfom SATA (AHCI) or SDHC driver to a guest machine.

I happen to have an idea of how VFIO works...

Quoted 4 lines

The summary is that:
- IOMMU takes care of the mappings via VFIO driver.
- Guest machine owns the HW. No hypervisor interaction.

Then it might be worth mentioning all of this

Quoted 9 lines
Quoted 3 lines

- How do host and guest communicate?

They don't.

Quoted 1 line

- How is the integration performed in the hypervisor?

Hypervisor has a bunch of channel resources. For each guest machine, the channel gets unbound from the hypervisor. Channels get bind to each VFIO platform device and then control is given to the guest machine.

And what does the hypervisor do with those in the meantime? Above, you say "Guest machine owns the HW". So what is that hypervisor code used for? Is that your reset driver?

You may want to drop the "hypervisor" designation, BTW, because this has no real connection to virtualisation.

Quoted 11 lines

Once the guest machine is shutdown, VFIO driver still owns the channel device. It can assign the device to another guest machine.

Quoted 1 line

- Does the HYP side requires any context switch (and how is that done)?

No communication is needed.

Quoted 1 line

- What makes it safe?

No communication is needed.

Quoted 1 line
Quoted 7 lines
Quoted 2 lines

Without any of this information (and pointer to the code to back it up), I'm very reluctant to take any of this.

Please let me know what exactly is not clear.

You don't write a virtualization driver for 8139too driver. The driver works whether it is running in the guest machine or the hypervisor.

Exactly. No hypervisor code needed whatsoever. So please get rid of this hypervisor nonsense! ;-)

Thanks,

	M.
Signature · 5 lines
Jazz is not dead. It just smells funny...
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
author
#22 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

Quoted 7 lines
Quoted 4 lines

Sure, I'm ready to answer any questions. This is really a VFIO platform course. Not a HIDMA driver course. The approach is not different if you assign a platfom SATA (AHCI) or SDHC driver to a guest machine.

I happen to have an idea of how VFIO works...

OK. Good to know that we are speaking the same language.

Quoted 7 lines
Quoted 4 lines

The summary is that:
- IOMMU takes care of the mappings via VFIO driver.
- Guest machine owns the HW. No hypervisor interaction.

Then it might be worth mentioning all of this

Sure thing. I'm trying to locate where the right place would be. I'll target commit message and source code for now.

Quoted 5 lines
Quoted 5 lines
Quoted 3 lines

- How do host and guest communicate?

They don't.

Quoted 7 lines
Quoted 4 lines
Quoted 1 line

- How is the integration performed in the hypervisor?

Hypervisor has a bunch of channel resources. For each guest machine, the channel gets unbound from the hypervisor. Channels get bind to each VFIO platform device and then control is given to the guest machine.

And what does the hypervisor do with those in the meantime? Above, you say "Guest machine owns the HW".

The guest machine owns the channel HW which runs independent of the management HW.

Quoted 2 lines

So what is that hypervisor code used
for? Is that your reset driver?

The HIDMA "management" driver which runs at the hypervisor owns the management HW. Management driver serves two purposes.

1. Common bus parameter configuration (could be called reset driver).
2. Fine tuning the HW resources.

Multiple HIDMA channels share common HW resources. The management driver is able to change the priority (high/low) and weight (round-robin priority) of each HIDMA channel on the flight.

The system administrator will use a userspace application to allocate HW resources to each channel via the management driver.

The management driver does some common configuration too for these parameters. The management interface also has to be enabled before any channel can be enabled.

- max-write-burst-bytes: Maximum write burst in bytes that HIDMA can occupy the bus for in a single transaction. A memcpy requested is fragmented to multiples of this amount. This parameter is used while writing into destination memory. Setting this value incorrectly can starve other peripherals in the system.
- max-read-burst-bytes: Maximum read burst in bytes that HIDMA can occupy the bus for in a single transaction. A memcpy request is fragmented to multiples of this amount. This parameter is used while reading the source memory. Setting this value incorrectly can starve other peripherals in the system.
- max-write-transactions: This value is how many times a write burst is applied back to back while writing to the destination before yielding the bus.
- max-read-transactions: This value is how many times a read burst is applied back to back while reading the source before a yielding the bus.
- channel-reset-timeout-cycles: Channel reset timeout in cycles for this SOC. Once a reset is applied to the HW, HW starts a timer for reset operation to confirm. If reset is not completed within this time, HW reports reset failure.

Quoted 4 lines

You may want to drop the "hypervisor" designation, BTW, because this has no real connection to virtualisation.

Would you use host/guest relationship?

Quoted 14 lines
Quoted 14 lines

Once the guest machine is shutdown, VFIO driver still owns the channel device. It can assign the device to another guest machine.

Quoted 1 line

- Does the HYP side requires any context switch (and how is that done)?

No communication is needed.

Quoted 1 line

- What makes it safe?

No communication is needed.

Quoted 3 lines

Without any of this information (and pointer to the code to back it up), I'm very reluctant to take any of this.

Quoted 8 lines
Quoted 4 lines

Please let me know what exactly is not clear.

You don't write a virtualization driver for 8139too driver. The driver works whether it is running in the guest machine or the hypervisor.

Exactly. No hypervisor code needed whatsoever. So please get rid of this hypervisor nonsense! ;-)

I need the management driver for administrative purposes and common initialization. I like the split SW design as it follows the HW design too.

Quoted 4 lines

Thanks,

	M.
Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
#23 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

Quoted 1 line · Sinan Kaya
Quoted 1 line
Quoted 1 line

[...]

Quoted 5 lines
Quoted 3 lines

You may want to drop the "hypervisor" designation, BTW, because this has no real connection to virtualisation.

Would you use host/guest relationship?

Not even that. This is a host/user relationship, as VFIO is in no way virtualisation specific. It just gives you a way to make a device accessible to userspace. KVM is just a specialised instance of a more generic problem.

Quoted 20 lines
Quoted 20 lines
Quoted 19 lines

Once the guest machine is shutdown, VFIO driver still owns the channel device. It can assign the device to another guest machine.

Quoted 1 line

- Does the HYP side requires any context switch (and how is that done)?

No communication is needed.

Quoted 1 line

- What makes it safe?

No communication is needed.

Quoted 3 lines

Without any of this information (and pointer to the code to back it up), I'm very reluctant to take any of this.

Please let me know what exactly is not clear.

You don't write a virtualization driver for 8139too driver. The driver works whether it is running in the guest machine or the hypervisor.

Quoted 6 lines
Quoted 3 lines

Exactly. No hypervisor code needed whatsoever. So please get rid of this hypervisor nonsense! ;-)

I need the management driver for administrative purposes and common initialization. I like the split SW design as it follows the HW design too.

I have no problem with the split design (whatever floats your boat), more with the terminology which I find very confusing. It would be a lot better if you stuck with management (host) and client (user), or some other general terminology.

Thanks,

	M.
Signature · 1 line
Jazz is not dead. It just smells funny...
#24 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

In reply to Marc Zyngier
Quoted 22 lines · Marc Zyngier
Quoted 21 lines · Mark Rutland

Hi,

[adding KVM people, given this is meant for virtualization]

Quoted 15 lines · Sinan Kaya

The Qualcomm Technologies HIDMA device has been designed to support virtualization technology. The driver has been divided into two to follow the hardware design.

1. HIDMA Management driver
2. HIDMA Channel driver

Each HIDMA HW consists of multiple channels. These channels share some set of common parameters. These parameters are initialized by the management driver during power up. Same management driver is used for monitoring the execution of the channels. Management driver can change the performance behavior dynamically such as bandwidth allocation and prioritization.

The management driver is executed in hypervisor context and is the main management entity for all channels provided by the device.

Quoted 7 lines
Quoted 3 lines

You mention repeatedly that this is designed for virtualization, but looking at the series as it stands today I can't see how this operates from the host side.

Nor the guest's, TBH. How do host and guest communicate, what is the infrastructure, how is it meant to be used? A lot of questions, and no answer whatsoever in this series.

I think the guest's PoV is fairly simple and understood. The DMA channel is pased in as with any passthrough of any other platform device.

No communication with the host is necessary -- an isolated channel is usable.

The larger concern is isolation, given the lack of IOMMU, or anything obvious w.r.t. pinning of pages.

Quoted 11 lines
Quoted 10 lines

This doesn't seem to tie into KVM or VFIO, and as far as I can tell there's no mechanism for associating channels with a particular virtual address space (i.e. no configuration of an external or internal IOMMU), nor pinning of guest pages to allow for DMA to occur safely.

Given that, I'm at a loss as to how this would be used in a hypervisor context. What am I missing?

Are there additional patches, or do you have some userspace that works with this in some limited configuration?

Quoted 6 lines

Well, this looks so far like a code dumping exercise. I'd very much appreciate a HIDMA101 crash course:

- How do host and guest communicate?
- How is the integration performed in the hypervisor?
- Does the HYP side requires any context switch (and how is that done)?

I don't believe this requires any context-switch -- it's the same as assigning any other platform device other than additional proeprties being controlled in the managament interface.

Quoted 1 line

- What makes it safe?

I'm concerned with how this is safe, and with the userspace interface. e.g. if the user wants to up the QoS for a VM, how to they find the right channel in sysfs to alter?

Quoted 2 lines

Without any of this information (and pointer to the code to back it up), I'm very reluctant to take any of this.

Likewise.

Thanks,
Mark.

author
#25 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

Quoted 31 lines · Mark Rutland
Quoted 22 lines · Marc Zyngier
Quoted 21 lines · Mark Rutland

Hi,

[adding KVM people, given this is meant for virtualization]

Quoted 15 lines · Sinan Kaya

The Qualcomm Technologies HIDMA device has been designed to support virtualization technology. The driver has been divided into two to follow the hardware design.

1. HIDMA Management driver
2. HIDMA Channel driver

Each HIDMA HW consists of multiple channels. These channels share some set of common parameters. These parameters are initialized by the management driver during power up. Same management driver is used for monitoring the execution of the channels. Management driver can change the performance behavior dynamically such as bandwidth allocation and prioritization.

The management driver is executed in hypervisor context and is the main management entity for all channels provided by the device.

Quoted 7 lines
Quoted 3 lines

You mention repeatedly that this is designed for virtualization, but looking at the series as it stands today I can't see how this operates from the host side.

Nor the guest's, TBH. How do host and guest communicate, what is the infrastructure, how is it meant to be used? A lot of questions, and no answer whatsoever in this series.

Quoted 6 lines

I think the guest's PoV is fairly simple and understood. The DMA channel is pased in as with any passthrough of any other platform device.

No communication with the host is necessary -- an isolated channel is usable.

Correct, I'm behind on emails. I'm following you.

Quoted 3 lines

The larger concern is isolation, given the lack of IOMMU, or anything obvious w.r.t. pinning of pages.

I assume the presence of an IOMMU if used in the guest machine. I wonder if I can place a check and make the driver fail if IOMMU driver is not present.

Any ideas?

Quoted 10 lines
Quoted 10 lines
Quoted 10 lines

This doesn't seem to tie into KVM or VFIO, and as far as I can tell there's no mechanism for associating channels with a particular virtual address space (i.e. no configuration of an external or internal IOMMU), nor pinning of guest pages to allow for DMA to occur safely.

Given that, I'm at a loss as to how this would be used in a hypervisor context. What am I missing?

Are there additional patches, or do you have some userspace that works with this in some limited configuration?

I forgot to mention that these are the only kernel patches. A userspace application is being built as we speak by another team.

The userspace application will use sysfs to communicate to the management driver. The management driver knows how to change runtime characteristics like priority and weight.

Quoted 11 lines
Quoted 7 lines

Well, this looks so far like a code dumping exercise. I'd very much appreciate a HIDMA101 crash course:

- How do host and guest communicate?
- How is the integration performed in the hypervisor?
- Does the HYP side requires any context switch (and how is that done)?

I don't believe this requires any context-switch -- it's the same as assigning any other platform device other than additional proeprties being controlled in the managament interface.

Agreed.

Quoted 6 lines
Quoted 2 lines

- What makes it safe?

I'm concerned with how this is safe, and with the userspace interface. e.g. if the user wants to up the QoS for a VM, how to they find the right channel in sysfs to alter?

The HW supports changing the QoS values on the flight. In order to locate the object, I'm exporting a

I tried to address your concern on v10 last series. Here is brief summary.

Each channel device has a sysfs entry named chid.
What: /sys/devices/platform/hidma-*/chid
+ /sys/devices/platform/QCOM8061:*/chid

Each management object has one priority and weight file per channel.
+What: /sys/devices/platform/hidma-mgmt*/chanops/chan*/priority
+ /sys/devices/platform/QCOM8060:*/chanops/chan*/priority

Suppose you want to change the priority of a channel you assigned to guess, the userspace application goes and reads the chid value of the channel.

Then goes to chanops/chan<chid>/ directory and can change priority and weight parameters here.

Here is how the directory looks like. QCOM8060:00 is a management object. QCOM8061:0x are the channel objects.

/sys/devices/platform/QCOM8060:00# ls
QCOM8061:00
QCOM8061:01
QCOM8061:02
QCOM8061:03
QCOM8061:04
QCOM8061:05
chanops
<other common attributes>

Quoted 9 lines
Quoted 3 lines

Without any of this information (and pointer to the code to back it up), I'm very reluctant to take any of this.

Likewise.

Thanks,
Mark.

Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
author
#26 lore raw

Re: [PATCH V12 3/7] dma: add Qualcomm Technologies HIDMA management driver

Mark,

Quoted 26 lines · Sinan Kaya
Quoted 3 lines

I'm concerned with how this is safe, and with the userspace interface.

Quoted 2 lines

e.g. if the user wants to up the QoS for a VM, how to they find the right channel in sysfs to alter?

The HW supports changing the QoS values on the flight. In order to locate the object, I'm exporting a

I tried to address your concern on v10 last series. Here is brief summary.

Each channel device has a sysfs entry named chid.
What: /sys/devices/platform/hidma-*/chid

(quoted diff) +1 -0
+		/sys/devices/platform/QCOM8061:*/chid

Each management object has one priority and weight file per channel.

Documentation/ABI/testing/sysfs-platform-hidma-mgmt new file +2 -0
+What:		/sys/devices/platform/hidma-mgmt*/chanops/chan*/priority
+		/sys/devices/platform/QCOM8060:*/chanops/chan*/priority

Suppose you want to change the priority of a channel you assigned to guess, the userspace application goes and reads the chid value of the channel.

Then goes to chanops/chan<chid>/ directory and can change priority and weight parameters here.

Here is how the directory looks like. QCOM8060:00 is a management object. QCOM8061:0x are the channel objects.

Quoted 13 lines

/sys/devices/platform/QCOM8060:00# ls
QCOM8061:00
QCOM8061:01
QCOM8061:02
QCOM8061:03
QCOM8061:04
QCOM8061:05
chanops
<other common attributes>

Did this answer your question?

I'm capturing all the questions and answers as FAQ into the cover letter as I keep repeating myself for every single reviewer.

Besides from the "lack of documentation", is there any code related change you'd like to discuss in the series.

Signature · 3 lines
Sinan Kaya
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
author
#27 lore raw

PATCH v12 4/7 dma: add Qualcomm Technologies HIDMA channel driver

In reply to Sinan Kaya

This patch adds support for hidma engine. The driver consists of two logical blocks. The DMA engine interface and the low-level interface. The hardware only supports memcpy/memset and this driver only support memcpy interface. HW and driver doesn't support slave interface.

---
 drivers/dma/qcom/Kconfig |  10 +
 drivers/dma/qcom/hidma.c | 744 +++++++++++++++++++++++++++++++++++++++++++++++
 drivers/dma/qcom/hidma.h | 160 ++++++++++
 3 files changed, 914 insertions(+)
 create mode 100644 drivers/dma/qcom/hidma.c
 create mode 100644 drivers/dma/qcom/hidma.h
drivers/dma/qcom/Kconfig +10 -0
index ebe5b8c..5588e1c 100644
@@ -17,3 +17,13 @@ config QCOM_HIDMA_MGMT
 	  start managing the channels. In a virtualized environment,
 	  the guest OS would run QCOM_HIDMA channel driver and the
 	  hypervisor would run the QCOM_HIDMA_MGMT management driver.
+
+config QCOM_HIDMA
+	tristate "Qualcomm Technologies HIDMA Channel support"
+	select DMA_ENGINE
+	help
+	  Enable support for the Qualcomm Technologies HIDMA controller.
+	  The HIDMA controller supports optimized buffer copies
+	  (user to kernel, kernel to kernel, etc.).  It only supports
+	  memcpy interface. The core is not intended for general
+	  purpose slave DMA.
drivers/dma/qcom/hidma.c new file +744 -0

744 lines not on this page · raw message

drivers/dma/qcom/hidma.h new file +160 -0

160 lines not on this page · raw message

Signature · 2 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
author
#28 lore raw

PATCH v12 5/7 dma: qcom_hidma: implement lower level hardware interface

In reply to Sinan Kaya

This patch implements the hardware hooks for the HIDMA channel driver.

The main functions of interest are:
- hidma_ll_init
- hidma_ll_request
- hidma_ll_queue_request
- hidma_ll_hw_start

OS layer calls the hidma_ll_init function during probe to set up the hardware. At this moment, the number of supported descriptors are also given. On each request, a descriptor is allocated from the free pool and filled in with the transfer parameters. Multiple requests can be queued into the hardware via the OS interface. When client is ready for requests to be executed, start method is called.

Completions are delivered via callbacks via tasklet.

---
 drivers/dma/qcom/Makefile   |   2 +
 drivers/dma/qcom/hidma.h    |   2 +-
 drivers/dma/qcom/hidma_ll.c | 927 ++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 930 insertions(+), 1 deletion(-)
 create mode 100644 drivers/dma/qcom/hidma_ll.c
drivers/dma/qcom/Makefile +2 -0
index bfea699..6bf9267 100644
@@ -1,3 +1,5 @@
 obj-$(CONFIG_QCOM_BAM_DMA) += bam_dma.o
 obj-$(CONFIG_QCOM_HIDMA_MGMT) += hdma_mgmt.o
 hdma_mgmt-objs	 := hidma_mgmt.o hidma_mgmt_sys.o
+obj-$(CONFIG_QCOM_HIDMA) +=  hdma.o
+hdma-objs        := hidma_ll.o hidma.o
drivers/dma/qcom/hidma.h +1 -1
index 231e306..1e09d7c 100644
@@ -37,7 +37,7 @@ struct hidma_tre {
 	atomic_t allocated;		/* if this channel is allocated	    */
 	bool queued;			/* flag whether this is pending     */
 	u16 status;			/* status			    */
-	u32 chidx;			/* index of the tre		    */
+	u32 idx;			/* index of the tre		    */
 	u32 dma_sig;			/* signature of the tre		    */
 	const char *dev_name;		/* name of the device		    */
 	void (*callback)(void *data);	/* requester callback		    */
drivers/dma/qcom/hidma_ll.c new file +927 -0

927 lines not on this page · raw message

Signature · 2 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
author
#29 lore raw

PATCH v12 6/7 dma: qcom_hidma: add debugfs hooks

In reply to Sinan Kaya

Add debugfs hooks for debugging the execution behavior of the DMA channel. The debugfs hooks get initialized by the probe function and uninitialized by the remove function.

A stats file is created in debugfs. The stats file will show the information about each HIDMA channel as well as each asynchronous job queued and completed at a given time.

---
 drivers/dma/qcom/Makefile    |   2 +-
 drivers/dma/qcom/hidma.c     |   3 +
 drivers/dma/qcom/hidma.h     |   2 +
 drivers/dma/qcom/hidma_dbg.c | 219 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 225 insertions(+), 1 deletion(-)
 create mode 100644 drivers/dma/qcom/hidma_dbg.c
drivers/dma/qcom/Makefile +1 -1
index 6bf9267..4bfc38b 100644
@@ -2,4 +2,4 @@ obj-$(CONFIG_QCOM_BAM_DMA) += bam_dma.o
 obj-$(CONFIG_QCOM_HIDMA_MGMT) += hdma_mgmt.o
 hdma_mgmt-objs	 := hidma_mgmt.o hidma_mgmt_sys.o
 obj-$(CONFIG_QCOM_HIDMA) +=  hdma.o
-hdma-objs        := hidma_ll.o hidma.o
+hdma-objs        := hidma_ll.o hidma.o hidma_dbg.o
drivers/dma/qcom/hidma.c +3 -0
index f8960f1..833db9e 100644
@@ -681,6 +681,7 @@ static int hidma_probe(struct platform_device *pdev)
 
 	dmadev->irq = chirq;
 	tasklet_init(&dmadev->task, hidma_issue_task, (unsigned long)dmadev);
+	hidma_debug_init(dmadev);
 	dev_info(&pdev->dev, "HI-DMA engine driver registration complete\n");
 	platform_set_drvdata(pdev, dmadev);
 	pm_runtime_mark_last_busy(dmadev->ddev.dev);
@@ -689,6 +690,7 @@ static int hidma_probe(struct platform_device *pdev)
 	return 0;
 
 uninit:
+	hidma_debug_uninit(dmadev);
 	hidma_ll_uninit(dmadev->lldev);
 dmafree:
 	if (dmadev)
@@ -706,6 +708,7 @@ static int hidma_remove(struct platform_device *pdev)
 	pm_runtime_get_sync(dmadev->ddev.dev);
 	dma_async_device_unregister(&dmadev->ddev);
 	devm_free_irq(dmadev->ddev.dev, dmadev->irq, dmadev->lldev);
+	hidma_debug_uninit(dmadev);
 	hidma_ll_uninit(dmadev->lldev);
 	hidma_free(dmadev);
 
drivers/dma/qcom/hidma.h +2 -0
index 1e09d7c..c6b3ae0 100644
@@ -157,4 +157,6 @@ int hidma_ll_uninit(struct hidma_lldev *llhndl);
 irqreturn_t hidma_ll_inthandler(int irq, void *arg);
 void hidma_cleanup_pending_tre(struct hidma_lldev *llhndl, u8 err_info,
 				u8 err_code);
+int hidma_debug_init(struct hidma_dev *dmadev);
+void hidma_debug_uninit(struct hidma_dev *dmadev);
 #endif
drivers/dma/qcom/hidma_dbg.c new file +219 -0

219 lines not on this page · raw message

Signature · 2 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project
author
#30 lore raw

PATCH v12 7/7 dma: qcom_hidma: add support for object hierarchy

In reply to Sinan Kaya

In order to create a relationship model between the channels and the management object, we are adding support for object hierarchy to the drivers. This patch simplifies the userspace application development. We will not have to traverse different firmware paths based on device tree or ACPI baed kernels.

No matter what flavor of kernel is used, objects will be represented as platform devices.

The new layout is as follows:

hidmam_10: hidma-mgmt at 0x5A000000 {
	compatible = "qcom,hidma-mgmt-1.0";
	...

	hidma_10: hidma at 0x5a010000 {
			compatible = "qcom,hidma-1.0";
			...
	}
}

The hidma_mgmt_init detects each instance of the hidma-mgmt-1.0 objects in device tree and calls into the channel driver to create platform devices for each child of the management object.

---
 Documentation/ABI/testing/sysfs-platform-hidma |   9 +++
 drivers/dma/qcom/hidma.c                       |  39 +++++++++-
 drivers/dma/qcom/hidma_mgmt.c                  | 104 ++++++++++++++++++++++++-
 3 files changed, 148 insertions(+), 4 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-hidma
Documentation/ABI/testing/sysfs-platform-hidma new file +9 -0
new file mode 100644
index 0000000..d364415
@@ -0,0 +1,9 @@
+What:		/sys/devices/platform/hidma-*/chid
+		/sys/devices/platform/QCOM8061:*/chid
+Date:		Dec 2015
+KernelVersion:	4.4
+Contact:	"Sinan Kaya <[email protected]>"
+Description:
+		Contains the ID of the channel within the HIDMA instance.
+		It is used to associate a given HIDMA channel with the
+		priority and weight calls in the management interface.
drivers/dma/qcom/hidma.c +38 -1
index 833db9e..ac20bdb 100644
@@ -549,6 +549,43 @@ static irqreturn_t hidma_chirq_handler(int chirq, void *arg)
 	return hidma_ll_inthandler(chirq, lldev);
 }
 
+static ssize_t hidma_show_values(struct device *dev,
+				 struct device_attribute *attr, char *buf)
+{
+	struct platform_device *pdev = to_platform_device(dev);
+	struct hidma_dev *mdev = platform_get_drvdata(pdev);
+
+	buf[0] = 0;
+
+	if (strcmp(attr->attr.name, "chid") == 0)
+		sprintf(buf, "%d\n", mdev->chidx);
+
+	return strlen(buf);
+}
+
+static int hidma_create_sysfs_entry(struct hidma_dev *dev, char *name,
+				    int mode)
+{
+	struct device_attribute *attrs;
+	char *name_copy;
+
+	attrs = devm_kmalloc(dev->ddev.dev, sizeof(struct device_attribute),
+			     GFP_KERNEL);
+	if (!attrs)
+		return -ENOMEM;
+
+	name_copy = devm_kstrdup(dev->ddev.dev, name, GFP_KERNEL);
+	if (!name_copy)
+		return -ENOMEM;
+
+	attrs->attr.name = name_copy;
+	attrs->attr.mode = mode;
+	attrs->show = hidma_show_values;
+	sysfs_attr_init(&attrs->attr);
+
+	return device_create_file(dev->ddev.dev, attrs);
+}
+
 static int hidma_probe(struct platform_device *pdev)
 {
 	struct hidma_dev *dmadev;
@@ -682,6 +719,7 @@ static int hidma_probe(struct platform_device *pdev)
 	dmadev->irq = chirq;
 	tasklet_init(&dmadev->task, hidma_issue_task, (unsigned long)dmadev);
 	hidma_debug_init(dmadev);
+	hidma_create_sysfs_entry(dmadev, "chid", S_IRUGO);
 	dev_info(&pdev->dev, "HI-DMA engine driver registration complete\n");
 	platform_set_drvdata(pdev, dmadev);
 	pm_runtime_mark_last_busy(dmadev->ddev.dev);
@@ -730,7 +768,6 @@ static const struct of_device_id hidma_match[] = {
 	{.compatible = "qcom,hidma-1.0",},
 	{},
 };
-
 MODULE_DEVICE_TABLE(of, hidma_match);
 
 static struct platform_driver hidma_driver = {
drivers/dma/qcom/hidma_mgmt.c +101 -3

119 lines not on this page · raw message

Signature · 2 lines
Qualcomm Technologies, Inc. on behalf of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project