Skip to contentSkip to conversation

dma: add Qualcomm Technologies HIDMA driver

PATCH Superseded Sinan Kaya 2 participants 15 messages Dec 11, 2015 – Jan 13, 2016

Subsystems (4)

v9 of 18 Superseded Latest is v18 →

lore
Share & tools
lore

Sinan Kaya

author
#0 lore raw

v9 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.

Changes from V8: (https://lkml.org/lkml/2015/12/3/19)
* none

Changes from V8: (https://lkml.org/lkml/2015/12/3/23)
* none

Changes from V8: (https://lkml.org/lkml/2015/12/3/20)
* Change the pause behavior. Only the running descriptor gets DMA_PAUSED return code. All others get DMA_IN_PROGRESS.

Changes from V8: (https://lkml.org/lkml/2015/12/3/22)
* none

Changes from V8: (https://lkml.org/lkml/2015/12/3/21)
* none

Sinan Kaya (5):
dma: qcom_bam_dma: move to qcom directory
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

 .../ABI/testing/sysfs-platform-hidma-mgmt          |  97 +++
 .../devicetree/bindings/dma/qcom_hidma.txt         |  18 +
 .../devicetree/bindings/dma/qcom_hidma_mgmt.txt    |  61 ++
 drivers/dma/Kconfig                                |  11 +-
 drivers/dma/Makefile                               |   2 +-
 drivers/dma/qcom/Kconfig                           |  29 +
 drivers/dma/qcom/Makefile                          |   4 +
 drivers/dma/{qcom_bam_dma.c => qcom/bam_dma.c}     |   4 +-
 drivers/dma/qcom/hidma.c                           | 743 +++++++++++++++++
 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                      | 318 +++++++
 drivers/dma/qcom/hidma_mgmt.h                      |  39 +
 drivers/dma/qcom/hidma_mgmt_sys.c                  | 292 +++++++
 15 files changed, 2914 insertions(+), 12 deletions(-)
 create mode 100644 Documentation/ABI/testing/sysfs-platform-hidma-mgmt
 create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma.txt
 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 v9 1/5 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 v9 2/5 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 +++++++
 .../devicetree/bindings/dma/qcom_hidma_mgmt.txt    |  61 ++++
 drivers/dma/qcom/Kconfig                           |  11 +
 drivers/dma/qcom/Makefile                          |   1 +
 drivers/dma/qcom/hidma_mgmt.c                      | 318 +++++++++++++++++++++
 drivers/dma/qcom/hidma_mgmt.h                      |  39 +++
 drivers/dma/qcom/hidma_mgmt_sys.c                  | 292 +++++++++++++++++++
 7 files changed, 819 insertions(+)
 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/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..4fc6876
@@ -0,0 +1,97 @@
+What:		/sys/devices/platform/hidma-mgmt*/chan*/priority
+		/sys/devices/platform/QCOM8060:*/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*/chan*/weight
+		/sys/devices/platform/QCOM8060:*/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.
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +61 -0

61 lines not on this page · raw message

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 +1 -0
index f612ae3..1a5a96d 100644
@@ -1 +1,2 @@
 obj-$(CONFIG_QCOM_BAM_DMA) += bam_dma.o
+obj-$(CONFIG_QCOM_HIDMA_MGMT) += hidma_mgmt.o hidma_mgmt_sys.o
drivers/dma/qcom/hidma_mgmt.c new file +318 -0

318 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 +292 -0

292 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
#12 lore raw

PATCH v9 3/5 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.

---
 .../devicetree/bindings/dma/qcom_hidma.txt         |  18 +
 drivers/dma/qcom/Kconfig                           |  10 +
 drivers/dma/qcom/hidma.c                           | 740 +++++++++++++++++++++
 drivers/dma/qcom/hidma.h                           | 160 +++++
 4 files changed, 928 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma.txt
 create mode 100644 drivers/dma/qcom/hidma.c
 create mode 100644 drivers/dma/qcom/hidma.h
Documentation/devicetree/bindings/dma/qcom_hidma.txt new file +18 -0
new file mode 100644
index 0000000..d18c8fc
@@ -0,0 +1,18 @@
+Qualcomm Technologies HIDMA Channel driver
+
+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
+- event-channel: The HW event channel completions will be delivered.
+Example:
+
+	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>;
+		event-channel = <4>;
+	};
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 +740 -0

740 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
#13 lore raw

PATCH v9 4/5 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.c    |   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 1a5a96d..d2c6bda 100644
@@ -1,2 +1,4 @@
 obj-$(CONFIG_QCOM_BAM_DMA) += bam_dma.o
 obj-$(CONFIG_QCOM_HIDMA_MGMT) += hidma_mgmt.o hidma_mgmt_sys.o
+obj-$(CONFIG_QCOM_HIDMA) +=  hdma.o
+hdma-objs        := hidma_ll.o hidma.o
drivers/dma/qcom/hidma.c +1 -1
index d2f7e32..be4ff8d 100644
@@ -442,7 +442,7 @@ static int hidma_terminate_channel(struct dma_chan *chan)
 		/* move myself to free_list */
 		list_move(&mdesc->node, &mchan->free);
 	}
-
+	rc = hidma_ll_resume(dmadev->lldev);
 out:
 	pm_runtime_mark_last_busy(dmadev->ddev.dev);
 	pm_runtime_put_autosuspend(dmadev->ddev.dev);
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
#14 lore raw

PATCH v9 5/5 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 d2c6bda..f702df1 100644
@@ -1,4 +1,4 @@
 obj-$(CONFIG_QCOM_BAM_DMA) += bam_dma.o
 obj-$(CONFIG_QCOM_HIDMA_MGMT) += 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 be4ff8d..23a0419 100644
@@ -677,6 +677,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);
@@ -685,6 +686,7 @@ static int hidma_probe(struct platform_device *pdev)
 	return 0;
 
 uninit:
+	hidma_debug_uninit(dmadev);
 	hidma_ll_uninit(dmadev->lldev);
 dmafree:
 	if (dmadev)
@@ -702,6 +704,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 363b82d..ad38431 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
#3 lore raw

Re: [PATCH V9 2/5] dma: add Qualcomm Technologies HIDMA management driver

In reply to Sinan Kaya

Hi,

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 8 lines

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 +++++++
 .../devicetree/bindings/dma/qcom_hidma_mgmt.txt    |  61 ++++

Please split the binding into a separate patch, per Documentation/devicetree/bindings/submitting-patches.txt.

Quoted 21 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +15 -0
new file mode 100644
index 0000000..b632635
@@ -0,0 +1,61 @@
+Qualcomm Technologies HIDMA Management interface
+
+The Qualcomm Technologies HIDMA device has been designed
+to support virtualization technology. The driver has been
+divided into two to follow the hardware design. The management
+driver is executed in hypervisor context and is the main
+management entity for all channels provided by the device.
+
+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.

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

Quoted 10 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +10 -0
+
+All channel devices get probed in the hypervisor
+context during power up. They show up as DMA engine
+DMA channels. Then, before starting the virtualization; each
+channel device is unbound from the hypervisor by VFIO
+and assign to the guest machine for control.
+
+This management driver will  be used by the system
+admin to monitor/reset the execution state of the DMA
+channels. This will be the management interface.

This is a mixture of hardware and software description (e.g. VFIO has nothing to do wit hteh hardware). We want to capture what is necessary to describe the hardware, not what the software stack above it will look like.

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

Quoted 3 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +3 -0
+Required properties:
+- compatible: "qcom,hidma-mgmt-1.0";
+- reg: Address range for DMA device

Does this cover just the management registers, or those for channels as well?

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

Quoted 1 line
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +1 -0
+- dma-channels: Number of channels supported by this DMA controller.

Surely this is discoverable, or can be derived from the set of channels described in the DT?

Quoted 5 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +5 -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

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

Quoted 10 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +10 -0
+- max-read-transactions: Maximum read transactions to perform in a burst
+- channel-reset-timeout-cycles: Channel reset timeout in cycles for this SOC.
+- channel-priority: Priority of the channel.
+  Each dma channel share the same HW bandwidth with other dma channels.
+  If two requests reach to the HW at the same time from a low priority and
+  high priority channel, high priority channel will claim the bus.
+  0=low priority, 1=high priority
+- channel-weight: Round robin weight of the channel
+  Since there are only two priority levels supported, scheduling among
+  the equal priority channels is done via weights.

Per the example, these last two seem to be arrays, which wasn't clear from the description.

Why can this information not be associated with the channel directly?

How does one choose the right priority and/or weight? These seem like runtime details given that channels are indned to be allocated by software.

There's no relationship to channels defined here. What happens if/when you have a system with multiple instances?

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

Quoted 12 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +12 -0
+
+Example:
+
+	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;

Please fix the syntax here (you're missing '<' and '>' for values.

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

Quoted 3 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +3 -0
+		channel-priority = <1 1 0 0 0 0>;
+		channel-weight = <1 13 10 3 4 5>;
+	};

I don't understand why you don't have a single binding for both the management interface and channels, e.g.

hidma {
	compatible - "qcom,hidma-1.0";

	/* OPTIONAL management interface registers */
	reg = < ... ... >;

	...

	channels {
		channel0 {
			compatible = "qcom,
			reg = < ... ... >;

			...
		};

		...
	};
};

That would be more in keeping with what we do for other componenents with hyp control elements (e.g. the GIC) and keeps everything associated.

Thanks,
Mark.

author
#4 lore raw

Re: [PATCH V9 2/5] dma: add Qualcomm Technologies HIDMA management driver

Hi Mark,

Quoted 19 lines · Mark Rutland

Hi,

Quoted 16 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 8 lines
Quoted 5 lines
---
 .../ABI/testing/sysfs-platform-hidma-mgmt          |  97 +++++++
 .../devicetree/bindings/dma/qcom_hidma_mgmt.txt    |  61 ++++

Please split the binding into a separate patch, per Documentation/devicetree/bindings/submitting-patches.txt.

Done. I'm new to this. Bare with me.

Quoted 29 lines
Quoted 29 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +22 -0
new file mode 100644
index 0000000..b632635
@@ -0,0 +1,61 @@
+Qualcomm Technologies HIDMA Management interface
+
+The Qualcomm Technologies HIDMA device has been designed
+to support virtualization technology. The driver has been
+divided into two to follow the hardware design. The management
+driver is executed in hypervisor context and is the main
+management entity for all channels provided by the device.
+
+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.
+
+All channel devices get probed in the hypervisor
+context during power up. They show up as DMA engine
+DMA channels. Then, before starting the virtualization; each
+channel device is unbound from the hypervisor by VFIO
+and assign to the guest machine for control.
+
Quoted 8 lines

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

Quoted 3 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +3 -0
+This management driver will  be used by the system
+admin to monitor/reset the execution state of the DMA
+channels. This will be the management interface.

This is a mixture of hardware and software description (e.g. VFIO has nothing to do wit hteh hardware). We want to capture what is necessary to describe the hardware, not what the software stack above it will look like.

Another reviewer requested guidance on how to set these parameters. That's why, I tried to provide as much data as possible.

Quoted 7 lines

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

Quoted 4 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +3 -0
+Required properties:
+- compatible: "qcom,hidma-mgmt-1.0";
+- reg: Address range for DMA device

Does this cover just the management registers, or those for channels as well?

just management.

Quoted 5 lines

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

Quoted 2 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +1 -0
+- dma-channels: Number of channels supported by this DMA controller.

Surely this is discoverable, or can be derived from the set of channels described in the DT?

No, this is a HW configuration. Each hardware instance supports certain number of channels based on the HW build. The number of active channels on the running operating system does not necessarily represent the maximum possible.

Quoted 17 lines
Quoted 6 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +5 -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

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

Quoted 10 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +10 -0
+- max-read-transactions: Maximum read transactions to perform in a burst
+- channel-reset-timeout-cycles: Channel reset timeout in cycles for this SOC.
+- channel-priority: Priority of the channel.
+  Each dma channel share the same HW bandwidth with other dma channels.
+  If two requests reach to the HW at the same time from a low priority and
+  high priority channel, high priority channel will claim the bus.
+  0=low priority, 1=high priority
+- channel-weight: Round robin weight of the channel
+  Since there are only two priority levels supported, scheduling among
+  the equal priority channels is done via weights.
Quoted 2 lines

Per the example, these last two seem to be arrays, which wasn't clear from the description.

OK, let me clarify this. New text:

+- channel-priority: an array of channel priorities.
+- channel-weight: an array of round robin channel weights
Quoted 3 lines

Why can this information not be associated with the channel directly?

Two reasons:
1. The channel doesn't have the capability to change the priority and weight. HW design. Management HW can do this only.
2. We are building SW to change the channel priority and weight at runtime from the hypervisor through sysfs. The system administrator of the server will reallocate resources based on the guest machine requirements.

Quoted 3 lines

How does one choose the right priority and/or weight? These seem like runtime details given that channels are indned to be allocated by software.

priority = 0..1
weight = 0...15 (adding max value to the documentation)

+ Valid values are 1..15.

Quoted 4 lines

There's no relationship to channels defined here. What happens if/when you have a system with multiple instances?

I do support multiple instances. I tested with 4 instances (6 channels each). This driver is only responsible for management which it can do through its own dedicated HW interface. It doesn't need access to the channel address space. There will be 4 HIDMA management instances in this case.

Quoted 6 lines
Quoted 6 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +6 -0
+
+Example:
+
+	hidma-mgmt at f9984000 = {
+		compatible = "qcom,hidma-mgmt-1.0";
+		reg = <0xf9984000 0x15000>;
Quoted 8 lines

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

Quoted 6 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +6 -0
+		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;

Please fix the syntax here (you're missing '<' and '>' for values.

Good catch

Quoted 28 lines

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

Quoted 4 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +3 -0
+		channel-priority = <1 1 0 0 0 0>;
+		channel-weight = <1 13 10 3 4 5>;
+	};

I don't understand why you don't have a single binding for both the management interface and channels, e.g.

hidma {
	compatible - "qcom,hidma-1.0";

	/* OPTIONAL management interface registers */
	reg = < ... ... >;

	...

	channels {
		channel0 {
			compatible = "qcom,
			reg = < ... ... >;

			...
		};

		...
	};
};
Quoted 3 lines

That would be more in keeping with what we do for other componenents with hyp control elements (e.g. the GIC) and keeps everything associated.

This was discussed before with the previous versions of the patch. This split and loose coupling design is on purpose.

The summary is that for static OS configurations where devices remain active for the rest of the OS execution; it makes perfect sense to create a device bus or child device object relationship.

The use case here is virtualization and object lifetime in the hypervisor is dynamic. Channel objects get unbound and bound dynamically for guest OS control. At any time, the hypervisor may not have any channel objects if the administrator decides to give all channels to the guest machines.

Only the hidma channel driver gets executed in the guest machine. There is no management driver and device entity in the guest. Therefore, child-parent relationship does not exist.

The object hierarchy is flat and the only object that exist is a channel object. The channel object can execute independent of the management interface and other channels in the hypervisor/ other guest machines.

Quoted 4 lines

Thanks,
Mark.

Thanks for the review.

Signature · 4 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
#5 lore raw

Re: [PATCH V9 2/5] dma: add Qualcomm Technologies HIDMA management driver

Quoted 37 lines
Quoted 28 lines
Quoted 28 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +22 -0
new file mode 100644
index 0000000..b632635
@@ -0,0 +1,61 @@
+Qualcomm Technologies HIDMA Management interface
+
+The Qualcomm Technologies HIDMA device has been designed
+to support virtualization technology. The driver has been
+divided into two to follow the hardware design. The management
+driver is executed in hypervisor context and is the main
+management entity for all channels provided by the device.
+
+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.
+
+All channel devices get probed in the hypervisor
+context during power up. They show up as DMA engine
+DMA channels. Then, before starting the virtualization; each
+channel device is unbound from the hypervisor by VFIO
+and assign to the guest machine for control.
+
Quoted 8 lines

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

Quoted 3 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +3 -0
+This management driver will  be used by the system
+admin to monitor/reset the execution state of the DMA
+channels. This will be the management interface.

This is a mixture of hardware and software description (e.g. VFIO has nothing to do wit hteh hardware). We want to capture what is necessary to describe the hardware, not what the software stack above it will look like.

Quoted 2 lines

Another reviewer requested guidance on how to set these parameters. That's why, I tried to provide as much data as possible.

It's perfectly fine to have some other document for the driver, but the binding doc should stick to HW description.

Quoted 12 lines
Quoted 6 lines

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

Quoted 3 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +3 -0
+Required properties:
+- compatible: "qcom,hidma-mgmt-1.0";
+- reg: Address range for DMA device

Does this cover just the management registers, or those for channels as well?

just management.

Quoted 3 lines
Quoted 2 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +1 -0
+- dma-channels: Number of channels supported by this DMA controller.
Quoted 7 lines
Quoted 2 lines

Surely this is discoverable, or can be derived from the set of channels described in the DT?

No, this is a HW configuration. Each hardware instance supports certain number of channels based on the HW build. The number of active channels on the running operating system does not necessarily represent the maximum possible.

I don't follow.

If you aren't using some channels, why do you need to know about them?

The driver seems to assume it can access registers for all (linearly indexed) channels up to the value it read from dt for dma-channels. That doesn't seem right if the driver is not dealing with all of those channels.

Quoted 24 lines
Quoted 16 lines
Quoted 5 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +5 -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

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

Quoted 10 lines
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +10 -0
+- max-read-transactions: Maximum read transactions to perform in a burst
+- channel-reset-timeout-cycles: Channel reset timeout in cycles for this SOC.
+- channel-priority: Priority of the channel.
+  Each dma channel share the same HW bandwidth with other dma channels.
+  If two requests reach to the HW at the same time from a low priority and
+  high priority channel, high priority channel will claim the bus.
+  0=low priority, 1=high priority
+- channel-weight: Round robin weight of the channel
+  Since there are only two priority levels supported, scheduling among
+  the equal priority channels is done via weights.
Quoted 2 lines

Per the example, these last two seem to be arrays, which wasn't clear from the description.

OK, let me clarify this. New text:

+- channel-priority: an array of channel priorities.
+- channel-weight: an array of round robin channel weights
Quoted 1 line
Quoted 5 lines
Quoted 2 lines

Why can this information not be associated with the channel directly?

Two reasons:
1. The channel doesn't have the capability to change the priority and weight. HW design. Management HW can do this only.

You can describe the channels directly to the hypervisor which talks to the management HW.

Quoted 4 lines

2. We are building SW to change the channel priority and weight at runtime from the hypervisor through sysfs. The system administrator of the server will reallocate resources based on the guest machine requirements.

Ok, so these properties are not necessary at all.

They can go, and you can default to a reasonable fair QoS configuration that the user can override at runtime depending on use-case.

Quoted 6 lines
Quoted 3 lines

How does one choose the right priority and/or weight? These seem like runtime details given that channels are indned to be allocated by software.

priority = 0..1
weight = 0...15 (adding max value to the documentation)

My point was more that the value you want depends on your use-case, which is _not_ a static hardware property, but rather a dynamic run-time property.

You stated this can be modified at run time. It should not be in the DT. Please drop it from the binding.

Quoted 7 lines

+ Valid values are 1..15.

Quoted 4 lines

There's no relationship to channels defined here. What happens if/when you have a system with multiple instances?

Quoted 5 lines

I do support multiple instances. I tested with 4 instances (6 channels each). This driver is only responsible for management which it can do through its own dedicated HW interface. It doesn't need access to the channel address space. There will be 4 HIDMA management instances in this case.

I don't follow.

How do you know which channels are associated with which management interface?

How can your sysfs interface work if that relationship is not described?

Quoted 23 lines
Quoted 23 lines

I don't understand why you don't have a single binding for both the management interface and channels, e.g.

hidma {
	compatible - "qcom,hidma-1.0";

	/* OPTIONAL management interface registers */
	reg = < ... ... >;

	...

	channels {
		channel0 {
			compatible = "qcom,
			reg = < ... ... >;

			...
		};

		...
	};
};
Quoted 6 lines
Quoted 3 lines

That would be more in keeping with what we do for other componenents with hyp control elements (e.g. the GIC) and keeps everything associated.

This was discussed before with the previous versions of the patch. This split and loose coupling design is on purpose.

I understand it was a deliberate choice. I am disagreeing with that choice.

Quoted 9 lines

The summary is that for static OS configurations where devices remain active for the rest of the OS execution; it makes perfect sense to create a device bus or child device object relationship.

The use case here is virtualization and object lifetime in the hypervisor is dynamic. Channel objects get unbound and bound dynamically for guest OS control. At any time, the hypervisor may not have any channel objects if the administrator decides to give all channels to the guest machines.

If the administrator tells the host to give a guest ownership of a channel, the host knows that it cannot use the channel itself, nor can it allocate the channel to another guest. Consider PCIe device passthrough; the host knows that there is a device on the PCIe bus, but also knows that a guest owns it. The same logic should apply here.

No guest should care which particular physical channels it's provided with.

Quoted 3 lines

Only the hidma channel driver gets executed in the guest machine. There is no management driver and device entity in the guest. Therefore, child-parent relationship does not exist.

The management driver needs to know details of the channels it's managing, even if it never accesses them directly. Otherwise how can you allocate a channel to a guest and manage it through the correct portion of the correct management interface?

I am not arguing for the management driver to run in the guest. For the GIC we have a single binding, yet never run the KVM driver in the guest. The same split of responsibility can apply to the hidma driver(s).

Thanks,
Mark.

author
#6 lore raw

Re: [PATCH V9 2/5] dma: add Qualcomm Technologies HIDMA management driver

Quoted 7 lines · Mark Rutland
Quoted 3 lines

Another reviewer requested guidance on how to set these parameters. That's why, I tried to provide as much data as possible.

It's perfectly fine to have some other document for the driver, but the binding doc should stick to HW description.

OK, I'll reword and put some more HW description.

Quoted 15 lines
Quoted 15 lines
Quoted 6 lines
Quoted 3 lines

+Required properties:

+- compatible: "qcom,hidma-mgmt-1.0";
+- reg: Address range for DMA device

Does this cover just the management registers, or those for channels as well?

just management.

Quoted 5 lines
Quoted 2 lines

+- dma-channels: Number of channels supported by this DMA controller.

Surely this is discoverable, or can be derived from the set of channels described in the DT?

Quoted 9 lines
Quoted 4 lines

No, this is a HW configuration. Each hardware instance supports certain number of channels based on the HW build. The number of active channels on the running operating system does not necessarily represent the maximum possible.

I don't follow.

If you aren't using some channels, why do you need to know about them?

I mean the hypervisor OS may not be using the channels. It could be the guest machines that are using it. I need the number of the channels not the memory addresses where each channel is.

Quoted 4 lines

The driver seems to assume it can access registers for all (linearly indexed) channels up to the value it read from dt for dma-channels. That doesn't seem right if the driver is not dealing with all of those channels.

I assume you are talking about this. Feel free to be specific if not this one.

	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));
	}

The management driver is configuring the priority and weight registers inside the management address space. It is not accessing the channel address space where data transfer descriptors are set up. There is one register for priority & weight of the each channel inside the management address space.

Quoted 10 lines
Quoted 7 lines
Quoted 4 lines

Why can this information not be associated with the channel directly?

Two reasons:
1. The channel doesn't have the capability to change the priority and weight. HW design. Management HW can do this only.

You can describe the channels directly to the hypervisor which talks to the management HW.

Not a use case, I don't want to allow guest machine to change their priority and weight. Guest machine runs the channel driver.

Quoted 10 lines
Quoted 5 lines

2. We are building SW to change the channel priority and weight at runtime from the hypervisor through sysfs. The system administrator of the server will reallocate resources based on the guest machine requirements.

Ok, so these properties are not necessary at all.

They can go, and you can default to a reasonable fair QoS configuration that the user can override at runtime depending on use-case.

Partially agreed, some values are "the fair QoS configuration defaults" per platform like maximum-read-request etc. The firmware writes the default values in their device tree/ ACPI table for HW description and the HIDMA driver will configure the defaults.

I'll remove the weight and priority though.

Quoted 8 lines
Quoted 7 lines
Quoted 4 lines

How does one choose the right priority and/or weight? These seem like runtime details given that channels are indned to be allocated by software.

priority = 0..1
weight = 0...15 (adding max value to the documentation)

Quoted 7 lines

My point was more that the value you want depends on your use-case, which is _not_ a static hardware property, but rather a dynamic run-time property.

You stated this can be modified at run time. It should not be in the DT. Please drop it from the binding.

I'll get rid of weight and priority only.

Quoted 13 lines
Quoted 7 lines

+ Valid values are 1..15.

Quoted 4 lines

There's no relationship to channels defined here. What happens if/when you have a system with multiple instances?

Quoted 5 lines

I do support multiple instances. I tested with 4 instances (6 channels each). This driver is only responsible for management which it can do through its own dedicated HW interface. It doesn't need access to the channel address space. There will be 4 HIDMA management instances in this case.

Quoted 4 lines

I don't follow.

How do you know which channels are associated with which management interface?

The association is the other way around. User need to know the management interface for a channel rather than the channel needing to know the management interface.

I'll think about it.

Quoted 2 lines

How can your sysfs interface work if that relationship is not described?

Here is the sysfs documentation. Each management object has one channel directory under it. I still don't need to access the channel object in order to change its weight and priority.

What: /sys/devices/platform/hidma-mgmt*/chan*/priority

                /sys/devices/platform/QCOM8060:*/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.

Quoted 28 lines
Quoted 28 lines
Quoted 27 lines

I don't understand why you don't have a single binding for both the management interface and channels, e.g.

hidma {
	compatible - "qcom,hidma-1.0";

	/* OPTIONAL management interface registers */
	reg = < ... ... >;

	...

	channels {
		channel0 {
			compatible = "qcom,
			reg = < ... ... >;

			...
		};

		...
	};
};

That would be more in keeping with what we do for other componenents with hyp control elements (e.g. the GIC) and keeps everything associated.

Quoted 6 lines
Quoted 2 lines

This was discussed before with the previous versions of the patch. This split and loose coupling design is on purpose.

I understand it was a deliberate choice. I am disagreeing with that choice.

In order to be able to use the same channel driver in the guest machine context with the hierarchy you want, I need to create this.

fake management object {
	fake values;
	channels {
		real DMA channel {
			...
		}
	}
}

This looks really ugly to me. I need to deal with a fake management driver and object that could be hypervisor specific.

Here is a fact:

QEMU is not capable of generating complex device-tree nodes for platform devices that are being virtualized. QEMU only generates a very simple device object with compatible ID and memory and interrupt resources. No parent, child relationship and no device-specific attributes. Here is an example:

device {
	compatible-id;
	reg;
	interrupt;
}

This is plain and simple. It works too. No need to create some fake device.

The other issue is the ACPI. I know device-tree has all kinds of nice gadgets for traversing the parent/child relationship and object pointers. I can't implement this if the solution does not scale to ACPI.

I'm still leaning towards keep it simple approach.

Quoted 10 lines
Quoted 9 lines

The summary is that for static OS configurations where devices remain active for the rest of the OS execution; it makes perfect sense to create a device bus or child device object relationship.

The use case here is virtualization and object lifetime in the hypervisor is dynamic. Channel objects get unbound and bound dynamically for guest OS control. At any time, the hypervisor may not have any channel objects if the administrator decides to give all channels to the guest machines.

Quoted 5 lines

If the administrator tells the host to give a guest ownership of a channel, the host knows that it cannot use the channel itself, nor can it allocate the channel to another guest. Consider PCIe device passthrough; the host knows that there is a device on the PCIe bus, but also knows that a guest owns it. The same logic should apply here.

Agreed, the HIDMA channel object gets associated to the VFIO driver while the guest is owning the HIDMA channel object.

Quoted 4 lines

No guest should care which particular physical channels it's provided with.

Quoted 8 lines
Quoted 3 lines

Only the hidma channel driver gets executed in the guest machine. There is no management driver and device entity in the guest. Therefore, child-parent relationship does not exist.

The management driver needs to know details of the channels it's managing, even if it never accesses them directly. Otherwise how can you allocate a channel to a guest and manage it through the correct portion of the correct management interface?

I'll add support for both. Both having a parent-child relationship while inside the hypervisor and flat hierarchy while running in the guest machine for QEMU.

I just created a child object of the management driver and channel driver got probed properly. So, it just a matter of device-tree documentation at this point.

It will be like this though.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
hidma {
	compatible - "qcom,hidma-1.0";

	/* OPTIONAL management interface registers */
	reg = < ... ... >;

	...

	channel0 {
		compatible = "qcom,
		reg = < ... ... >;
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
		...
	};

	...
};

This seems to have worked without requiring any work from me.

I need to associate sysfs next.

Quoted 8 lines

I am not arguing for the management driver to run in the guest. For the GIC we have a single binding, yet never run the KVM driver in the guest. The same split of responsibility can apply to the hidma driver(s).

Thanks,
Mark.

Signature · 4 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
#7 lore raw

Re: [PATCH V9 2/5] dma: add Qualcomm Technologies HIDMA management driver

Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 6 lines
Quoted 3 lines

+Required properties:

+- compatible: "qcom,hidma-mgmt-1.0";
+- reg: Address range for DMA device

Does this cover just the management registers, or those for channels as well?

just management.

Quoted 5 lines
Quoted 2 lines

+- dma-channels: Number of channels supported by this DMA controller.

Surely this is discoverable, or can be derived from the set of channels described in the DT?

No, this is a HW configuration. Each hardware instance supports certain number of channels based on the HW build. The number of active channels on the running operating system does not necessarily represent the maximum possible.

Quoted 8 lines
Quoted 4 lines

I don't follow.

If you aren't using some channels, why do you need to know about them?

I mean the hypervisor OS may not be using the channels. It could be the guest machines that are using it. I need the number of the channels not the memory addresses where each channel is.

I still don't follow. Knowing the number of channels alone is clearly insufficient.

The hypervisor is in charge of handing these out to guests. So it needs to know the set of of channels (i.e. the address of each channel, and which index the channel has in the control interface). Otherwise it cannot possibly allocate them to guests, and cannot possibly control those channels at runtime.

Given the hypervisor is in chage of allocating channels to guests, it knows which channels are in use, and can decide whether or not to use channels for its own purposes.

Quoted 20 lines
Quoted 4 lines

The driver seems to assume it can access registers for all (linearly indexed) channels up to the value it read from dt for dma-channels. That doesn't seem right if the driver is not dealing with all of those channels.

I assume you are talking about this. Feel free to be specific if not this one.

	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));
	}
Quoted 5 lines

The management driver is configuring the priority and weight registers inside the management address space. It is not accessing the channel address space where data transfer descriptors are set up. There is one register for priority & weight of the each channel inside the management address space.

My point was that this implies that the driver has no idea as to the relationship between these configuration registers and the actual channel address spaces. It has no idea which channel address spaces are being configured here. That does not seem right.

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Why can this information not be associated with the channel directly?

Two reasons:
1. The channel doesn't have the capability to change the priority and weight. HW design. Management HW can do this only.

You can describe the channels directly to the hypervisor which talks to the management HW.

Not a use case, I don't want to allow guest machine to change their priority and weight.

I didn't suggest that the guest would. Regardless, it seems these should be runtime configured anyway, at which point you need to know the relationship.

Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 3 lines

There's no relationship to channels defined here. What happens if/when you have a system with multiple instances?

I do support multiple instances. I tested with 4 instances (6 channels each). This driver is only responsible for management which it can do through its own dedicated HW interface. It doesn't need access to the channel address space. There will be 4 HIDMA management instances in this case.

I don't follow.

Quoted 8 lines
Quoted 2 lines

How do you know which channels are associated with which management interface?

The association is the other way around. User need to know the management interface for a channel rather than the channel needing to know the management interface.

I'll think about it.

Ok. I agree that's the way the user will look at it.

Quoted 6 lines
Quoted 1 line

How can your sysfs interface work if that relationship is not described?

Here is the sysfs documentation. Each management object has one channel directory under it. I still don't need to access the channel object in order to change its weight and priority.

Quoted 8 lines

What: /sys/devices/platform/hidma-mgmt*/chan*/priority

                /sys/devices/platform/QCOM8060:*/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 I was trying to ask is: given a write to a channel's priority file, how do you figure out which bits in which management interface to poke?

As far as I can see, the relationship between a channel and the management interface is not described in teh DT, so I cannot see how you figure this out.

Quoted 34 lines
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines

I don't understand why you don't have a single binding for both the management interface and channels, e.g.

hidma {
	compatible - "qcom,hidma-1.0";

	/* OPTIONAL management interface registers */
	reg = < ... ... >;

	...

	channels {
		channel0 {
			compatible = "qcom,
			reg = < ... ... >;

			...
		};

		...
	};
};

That would be more in keeping with what we do for other componenents with hyp control elements (e.g. the GIC) and keeps everything associated.

Quoted 6 lines
Quoted 2 lines

This was discussed before with the previous versions of the patch. This split and loose coupling design is on purpose.

I understand it was a deliberate choice. I am disagreeing with that choice.

Quoted 5 lines

In order to be able to use the same channel driver in the guest machine context with the hierarchy you want, I need to create this.

fake management object {
	fake values;

There'd be no fake values here, they'd just be ommitted entirely.

Quoted 9 lines
	channels {
		real DMA channel {
			...
		}
	}
}

This looks really ugly to me. I need to deal with a fake management driver and object that could be hypervisor specific.

You don't need a fake management driver. I don't understand what you mean w.r.t. being hypervisor specific.

Quoted 7 lines

Here is a fact:

QEMU is not capable of generating complex device-tree nodes for platform devices that are being virtualized. QEMU only generates a very simple device object with compatible ID and memory and interrupt resources. No parent, child relationship and no device-specific attributes. Here is an example:

So? The above _is_ simple, and trivial to generate.

I've not seen your patches for QEMU, so perhaps I'm missing something.

Regardless, QEMU is not the only thing that matters here. We shouldn't do something _only_ because it makes a patch to QEMU simpler.

Quoted 7 lines
device {
	compatible-id;
	reg;
	interrupt;
}
Quoted 5 lines

This is plain and simple. It works too. No need to create some fake device.

The other issue is the ACPI. I know device-tree has all kinds of nice gadgets for traversing the parent/child relationship and object pointers. I can't implement this if the solution does not scale to ACPI.

It sounds like ACPI is incapable of describing this device, then.

Quoted 7 lines
Quoted 7 lines

No guest should care which particular physical channels it's provided with.

Quoted 3 lines

Only the hidma channel driver gets executed in the guest machine. There is no management driver and device entity in the guest. Therefore, child-parent relationship does not exist.

Quoted 8 lines
Quoted 4 lines

The management driver needs to know details of the channels it's managing, even if it never accesses them directly. Otherwise how can you allocate a channel to a guest and manage it through the correct portion of the correct management interface?

I'll add support for both. Both having a parent-child relationship while inside the hypervisor and flat hierarchy while running in the guest machine for QEMU.

I'm happy with that.

Quoted 21 lines

I just created a child object of the management driver and channel driver got probed properly. So, it just a matter of device-tree documentation at this point.

It will be like this though.

Quoted 15 lines
Quoted 15 lines
Quoted 15 lines
hidma {
	compatible - "qcom,hidma-1.0";

	/* OPTIONAL management interface registers */
	reg = < ... ... >;

	...

	channel0 {
		compatible = "qcom,
		reg = < ... ... >;

		...
	};
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
	...
};

This seems to have worked without requiring any work from me.

I need to associate sysfs next.

Ok. I look forward to seeing those patches.

Thanks,
Mark.

author
#8 lore raw

Re: [PATCH V9 2/5] dma: add Qualcomm Technologies HIDMA management driver

Hi Mark,

Quoted 29 lines · Mark Rutland
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 6 lines
Quoted 3 lines

+Required properties:

+- compatible: "qcom,hidma-mgmt-1.0";
+- reg: Address range for DMA device

Does this cover just the management registers, or those for channels as well?

just management.

Quoted 5 lines
Quoted 2 lines

+- dma-channels: Number of channels supported by this DMA controller.

Surely this is discoverable, or can be derived from the set of channels described in the DT?

No, this is a HW configuration. Each hardware instance supports certain number of channels based on the HW build. The number of active channels on the running operating system does not necessarily represent the maximum possible.

Quoted 8 lines
Quoted 4 lines

I don't follow.

If you aren't using some channels, why do you need to know about them?

I mean the hypervisor OS may not be using the channels. It could be the guest machines that are using it. I need the number of the channels not the memory addresses where each channel is.

Quoted 8 lines

I still don't follow. Knowing the number of channels alone is clearly insufficient.

The hypervisor is in charge of handing these out to guests. So it needs to know the set of of channels (i.e. the address of each channel, and which index the channel has in the control interface). Otherwise it cannot possibly allocate them to guests, and cannot possibly control those channels at runtime.

For clarification, let me reiterate.

Hypervisor operating system certainly knows which channels and management interfaces there are in the system. However, the information feeds into the OS from two different drivers.

The HW ownership has been partitioned among two drivers as management driver and channel driver. Both of them serve the hypervisor but the management driver doesn't need to know about the channel addresses where the transfer descriptors are set up. Similarly, the channel driver doesn't need to know anything about the management interface where the priority and weight assignment is done.

Quoted 4 lines

Given the hypervisor is in chage of allocating channels to guests, it knows which channels are in use, and can decide whether or not to use channels for its own purposes.

Agreed

Quoted 27 lines
Quoted 21 lines
Quoted 5 lines

The driver seems to assume it can access registers for all (linearly indexed) channels up to the value it read from dt for dma-channels. That doesn't seem right if the driver is not dealing with all of those channels.

I assume you are talking about this. Feel free to be specific if not this one.

	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));
	}
Quoted 5 lines

The management driver is configuring the priority and weight registers inside the management address space. It is not accessing the channel address space where data transfer descriptors are set up. There is one register for priority & weight of the each channel inside the management address space.

Quoted 4 lines

My point was that this implies that the driver has no idea as to the relationship between these configuration registers and the actual channel address spaces. It has no idea which channel address spaces are being configured here. That does not seem right.

My intention was to use the ACPI _UID to associate the channel index. The _UID would tell me the index of the channel. I was encoding UID as follows in the ACPI table.

<deviceid><channelid>

this would tell me which HIDMA this channel belongs to as well as which channel it is.

Since this solution is very much ACPI specific and doesn't scale to device-tree, I'm thinking of adding a sysfs "index" file into each channel so that I don't need to search through the firmware_node in ACPI and of_node directory in device-tree mode.

I'm also thinking of creating symbolic links from the channel object into the management object.

Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
Quoted 12 lines
hidma {
	compatible - "qcom,hidma-1.0";

	/* OPTIONAL management interface registers */
	reg = < ... ... >;

	...

	channel0 {
		compatible = "qcom,
		reg = < ... ... >;
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
		...
	};

	...
};

This seems to have worked without requiring any work from me.

Here is something I don't understand why and I could get some help from DT experts.

When I have ACPI as follows

device(mgmt)

{
	device(channel0)
	{
	}
}

The channel0 driver gets automatically probed by the OS.

When I have device tree based structure as follows, hidma_00 doesn't get probed.

hidmam_00: hidma-mgmt at 0x58000000 {
		compatible = "qcom,hidma_mgmt-1.0";
		hidma_00: hidma at 0x58010000 {
			compatible = "qcom,hidma-1.0";

		}
}

If I put them seperately, it works

hidma_00: hidma at 0x58010000 {
	compatible = "qcom,hidma-1.0";
}
hidmam_00: hidma-mgmt at 0x58000000 {
	compatible = "qcom,hidma_mgmt-1.0";
}

Wondering If there is any mechanism in DT, I could have the same probing behavior as ACPI? I hate calling the of_find_matching_node functions and locate the child object. Then, create a platform device. This seems a lot of hand-crafting to me. I don't have any OF/ACPI specific code in my driver. I want to avoid it if there is a way.

Quoted 4 lines
Quoted 1 line

I need to associate sysfs next.

Ok. I look forward to seeing those patches.

OK. I'll post it as soon as I figure out DT/ACPI behavior differences.

Quoted 3 lines

Thanks,
Mark.

Signature · 4 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
#9 lore raw

Re: [PATCH V9 2/5] dma: add Qualcomm Technologies HIDMA management driver

In reply to Mark Rutland
Quoted 261 lines · Mark Rutland
Quoted 20 lines
Quoted 20 lines
Quoted 19 lines
Quoted 6 lines
Quoted 3 lines

+Required properties:

+- compatible: "qcom,hidma-mgmt-1.0";
+- reg: Address range for DMA device

Does this cover just the management registers, or those for channels as well?

just management.

Quoted 5 lines
Quoted 2 lines

+- dma-channels: Number of channels supported by this DMA controller.

Surely this is discoverable, or can be derived from the set of channels described in the DT?

No, this is a HW configuration. Each hardware instance supports certain number of channels based on the HW build. The number of active channels on the running operating system does not necessarily represent the maximum possible.

Quoted 8 lines
Quoted 4 lines

I don't follow.

If you aren't using some channels, why do you need to know about them?

I mean the hypervisor OS may not be using the channels. It could be the guest machines that are using it. I need the number of the channels not the memory addresses where each channel is.

I still don't follow. Knowing the number of channels alone is clearly insufficient.

The hypervisor is in charge of handing these out to guests. So it needs to know the set of of channels (i.e. the address of each channel, and which index the channel has in the control interface). Otherwise it cannot possibly allocate them to guests, and cannot possibly control those channels at runtime.

Given the hypervisor is in chage of allocating channels to guests, it knows which channels are in use, and can decide whether or not to use channels for its own purposes.

Quoted 20 lines
Quoted 4 lines

The driver seems to assume it can access registers for all (linearly indexed) channels up to the value it read from dt for dma-channels. That doesn't seem right if the driver is not dealing with all of those channels.

I assume you are talking about this. Feel free to be specific if not this one.

	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));
	}
Quoted 5 lines

The management driver is configuring the priority and weight registers inside the management address space. It is not accessing the channel address space where data transfer descriptors are set up. There is one register for priority & weight of the each channel inside the management address space.

My point was that this implies that the driver has no idea as to the relationship between these configuration registers and the actual channel address spaces. It has no idea which channel address spaces are being configured here. That does not seem right.

Quoted 11 lines
Quoted 8 lines
Quoted 5 lines
Quoted 2 lines

Why can this information not be associated with the channel directly?

Two reasons:
1. The channel doesn't have the capability to change the priority and weight. HW design. Management HW can do this only.

You can describe the channels directly to the hypervisor which talks to the management HW.

Not a use case, I don't want to allow guest machine to change their priority and weight.

I didn't suggest that the guest would. Regardless, it seems these should be runtime configured anyway, at which point you need to know the relationship.

Quoted 12 lines
Quoted 12 lines
Quoted 9 lines
Quoted 3 lines

There's no relationship to channels defined here. What happens if/when you have a system with multiple instances?

I do support multiple instances. I tested with 4 instances (6 channels each). This driver is only responsible for management which it can do through its own dedicated HW interface. It doesn't need access to the channel address space. There will be 4 HIDMA management instances in this case.

I don't follow.

Quoted 8 lines
Quoted 2 lines

How do you know which channels are associated with which management interface?

The association is the other way around. User need to know the management interface for a channel rather than the channel needing to know the management interface.

I'll think about it.

Ok. I agree that's the way the user will look at it.

Quoted 6 lines
Quoted 1 line

How can your sysfs interface work if that relationship is not described?

Here is the sysfs documentation. Each management object has one channel directory under it. I still don't need to access the channel object in order to change its weight and priority.

Quoted 8 lines

What: /sys/devices/platform/hidma-mgmt*/chan*/priority

                /sys/devices/platform/QCOM8060:*/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 I was trying to ask is: given a write to a channel's priority file, how do you figure out which bits in which management interface to poke?

As far as I can see, the relationship between a channel and the management interface is not described in teh DT, so I cannot see how you figure this out.

Quoted 34 lines
Quoted 27 lines
Quoted 27 lines
Quoted 26 lines

I don't understand why you don't have a single binding for both the management interface and channels, e.g.

hidma {
	compatible - "qcom,hidma-1.0";

	/* OPTIONAL management interface registers */
	reg = < ... ... >;

	...

	channels {
		channel0 {
			compatible = "qcom,
			reg = < ... ... >;

			...
		};

		...
	};
};

That would be more in keeping with what we do for other componenents with hyp control elements (e.g. the GIC) and keeps everything associated.

Quoted 6 lines
Quoted 2 lines

This was discussed before with the previous versions of the patch. This split and loose coupling design is on purpose.

I understand it was a deliberate choice. I am disagreeing with that choice.

Quoted 5 lines

In order to be able to use the same channel driver in the guest machine context with the hierarchy you want, I need to create this.

fake management object {
	fake values;

There'd be no fake values here, they'd just be ommitted entirely.

Quoted 9 lines
	channels {
		real DMA channel {
			...
		}
	}
}

This looks really ugly to me. I need to deal with a fake management driver and object that could be hypervisor specific.

You don't need a fake management driver. I don't understand what you mean w.r.t. being hypervisor specific.

Quoted 7 lines

Here is a fact:

QEMU is not capable of generating complex device-tree nodes for platform devices that are being virtualized. QEMU only generates a very simple device object with compatible ID and memory and interrupt resources. No parent, child relationship and no device-specific attributes. Here is an example:

So? The above _is_ simple, and trivial to generate.

I've not seen your patches for QEMU, so perhaps I'm missing something.

Regardless, QEMU is not the only thing that matters here. We shouldn't do something _only_ because it makes a patch to QEMU simpler.

Quoted 7 lines
device {
	compatible-id;
	reg;
	interrupt;
}
Quoted 5 lines

This is plain and simple. It works too. No need to create some fake device.

The other issue is the ACPI. I know device-tree has all kinds of nice gadgets for traversing the parent/child relationship and object pointers. I can't implement this if the solution does not scale to ACPI.

It sounds like ACPI is incapable of describing this device, then.

Quoted 7 lines
Quoted 7 lines

No guest should care which particular physical channels it's provided with.

Quoted 3 lines

Only the hidma channel driver gets executed in the guest machine. There is no management driver and device entity in the guest. Therefore, child-parent relationship does not exist.

Quoted 8 lines
Quoted 4 lines

The management driver needs to know details of the channels it's managing, even if it never accesses them directly. Otherwise how can you allocate a channel to a guest and manage it through the correct portion of the correct management interface?

I'll add support for both. Both having a parent-child relationship while inside the hypervisor and flat hierarchy while running in the guest machine for QEMU.

I'm happy with that.

Quoted 24 lines

I just created a child object of the management driver and channel driver got probed properly. So, it just a matter of device-tree documentation at this point.

It will be like this though.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
hidma {
	compatible - "qcom,hidma-1.0";

	/* OPTIONAL management interface registers */
	reg = < ... ... >;

	...

	channel0 {
		compatible = "qcom,
		reg = < ... ... >;

		...
	};

	...
};
Quoted 9 lines
Quoted 3 lines

This seems to have worked without requiring any work from me.

I need to associate sysfs next.

Ok. I look forward to seeing those patches.

Thanks,
Mark.

Mark,
The patch has been posted here. Please review.

https://lkml.org/lkml/2016/1/3/246

Sinan

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

Re: [PATCH V9 2/5] dma: add Qualcomm Technologies HIDMA management driver

Hi Mark, Rob, Frank, Grant and other DT experts;

Quoted 41 lines
Quoted 31 lines
Quoted 4 lines

I'll add support for both. Both having a parent-child relationship while inside the hypervisor and flat hierarchy while running in the guest machine for QEMU.

I'm happy with that.

Quoted 24 lines

I just created a child object of the management driver and channel driver got probed properly. So, it just a matter of device-tree documentation at this point.

It will be like this though.

Quoted 17 lines
Quoted 17 lines
Quoted 17 lines
hidma {
	compatible - "qcom,hidma-1.0";

	/* OPTIONAL management interface registers */
	reg = < ... ... >;

	...

	channel0 {
		compatible = "qcom,
		reg = < ... ... >;

		...
	};

	...
};
Quoted 9 lines
Quoted 3 lines

This seems to have worked without requiring any work from me.

I need to associate sysfs next.

Ok. I look forward to seeing those patches.

Thanks,
Mark.

Quoted 10 lines

Mark,
The patch has been posted here. Please review.

https://lkml.org/lkml/2016/1/3/246

Sinan

I have been trying to reach to device tree reviewers without any luck for the last two weeks. It must be the holidays.

I have restructured the code address concerns from Mark Rutland above. The dma-engine maintainer, Vinod Koul; is looking for an ACK from the DT community before the patches can be incorporated.

Could you please kindly review the series here from DT perspective and ACK it if you are OK?
https://lkml.org/lkml/2016/1/11/517

This document here
https://www.kernel.org/doc/linux/MAINTAINERS

tells me that Rob Herring, Frank Rowand and Grant Likely are the maintainers for device tree.

OPEN FIRMWARE AND FLATTENED DEVICE TREE
M: Rob Herring <[email protected]>
M: Frank Rowand <[email protected]>
M: Grant Likely <[email protected]>
L: devicetree at vger.kernel.org

That's why, I'm reaching out.

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
#11 lore raw

Re: [PATCH V9 2/5] dma: add Qualcomm Technologies HIDMA management driver

Quoted 3 lines · Sinan Kaya

Hi Mark, Rob, Frank, Grant and other DT experts;
I have been trying to reach to device tree reviewers without any luck for the last two weeks. It must be the holidays.

Indeed. Apologies for the delay.

Quoted 5 lines

I have restructured the code address concerns from Mark Rutland above. The dma-engine maintainer, Vinod Koul; is looking for an ACK from the DT community before the patches can be incorporated.

Could you please kindly review the series here from DT perspective and ACK it if you are OK?
https://lkml.org/lkml/2016/1/11/517

I will try to look at v12 shortly (i.e. in the next day or two).

Thanks,
Mark.