dma: add Qualcomm Technologies HIDMA driver
v10 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 V9: (https://lkml.org/lkml/2015/12/11/584)
* none
Changes from V9: (https://lkml.org/lkml/2015/12/11/585)
* split device tree documentation from code
* correct syntax error in device tree documentation
* describe max value of the weight
* document that array and weight attributes are array
* add object hierarchy support
* move sysfs priority and weight files into chanops directory.
Changes from V9: (https://lkml.org/lkml/2015/12/11/588)
* add object hierarchy support
* rename event-channel to channel-index
* create a sysfs entry for channel-index
* add pm_runtime_get/sync around hidma_ll_isenabled
Changes from V9: (https://lkml.org/lkml/2015/12/11/586)
* rename TRE chidx to idx to not mix with the channel id.
Changes from V9: (https://lkml.org/lkml/2015/12/11/587)
* 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 | 4 +
drivers/dma/{qcom_bam_dma.c => qcom/bam_dma.c} | 4 +-
drivers/dma/qcom/hidma.c | 868 +++++++++++++++++++
drivers/dma/qcom/hidma.h | 163 ++++
drivers/dma/qcom/hidma_dbg.c | 219 +++++
drivers/dma/qcom/hidma_ll.c | 927 +++++++++++++++++++++
drivers/dma/qcom/hidma_mgmt.c | 317 +++++++
drivers/dma/qcom/hidma_mgmt.h | 39 +
drivers/dma/qcom/hidma_mgmt_sys.c | 295 +++++++
15 files changed, 3051 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.cSignature · 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
PATCH v10 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
@@ -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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v10 2/7 dma: hidma: Add Device Tree support
In reply to Sinan KayaAdd 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
@@ -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
Re: [PATCH V10 2/7] dma: hidma: Add Device Tree support
Quoted 7 lines · Sinan Kaya
Add documentation for the Qualcomm Technologies HIDMA driver.
Signed-off-by Sinan Kaya <[email protected]>--- .../devicetree/bindings/dma/qcom_hidma_mgmt.txt | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
Re: [PATCH V10 2/7] dma: hidma: Add Device Tree support
Quoted 11 lines · Sinan Kaya
Quoted 9 lines
Add documentation for the Qualcomm Technologies HIDMA driver.
Signed-off-by Sinan Kaya <[email protected]>--- .../devicetree/bindings/dma/qcom_hidma_mgmt.txt | 79 ++++++++++++++++++++++ 1 file changed, 79 insertions(+) create mode 100644
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
Quoted 3 lines
Acked-by Rob Herring <[email protected]>
Ty.
PATCH v10 3/7 dma: add Qualcomm Technologies HIDMA management driver
In reply to Sinan KayaThe 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
@@ -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
@@ -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
@@ -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
@@ -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
PATCH v10 4/7 dma: add Qualcomm Technologies HIDMA channel driver
In reply to Sinan KayaThis 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
@@ -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
PATCH v10 5/7 dma: qcom_hidma: implement lower level hardware interface
In reply to Sinan KayaThis 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
@@ -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
@@ -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
PATCH v10 6/7 dma: qcom_hidma: add debugfs hooks
In reply to Sinan KayaAdd 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
@@ -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
@@ -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
@@ -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
PATCH v10 7/7 dma: qcom_hidma: add support for object hierarchy
In reply to Sinan KayaIn 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 | 103 ++++++++++++++++++++++++- 3 files changed, 147 insertions(+), 4 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-platform-hidma
Documentation/ABI/testing/sysfs-platform-hidma new file +9 -0
@@ -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
@@ -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 +100 -3
118 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
kbuild test robot
build botRe: [PATCH V10 7/7] dma: qcom_hidma: add support for object hierarchy
reproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi Sinan,
[auto build test ERROR on v4.4-rc5]
[also build test ERROR on next-20151218]
url: https://github.com/0day-ci/linux/commits/Sinan-Kaya/dma-add-Qualcomm-Technologies-HIDMA-driver/20151218-010637 config: sparc-allyesconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc
All errors (new ones prefixed by >>):
drivers/built-in.o: In function `hidma_mgmt_of_populate_channels':
>> hidma_mgmt.c:(.init.text+0x5cc8): undefined reference to `of_irq_parse_one'
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 44406 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151219/cd75a00a/attachment-0001.obj>
kbuild test robot
build botRe: [PATCH V10 7/7] dma: qcom_hidma: add support for object hierarchy
In reply to Sinan Kayareproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi Sinan,
[auto build test ERROR on v4.4-rc5]
[also build test ERROR on next-20151218]
url: https://github.com/0day-ci/linux/commits/Sinan-Kaya/dma-add-Qualcomm-Technologies-HIDMA-driver/20151218-010637 config: sparc64-allmodconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=sparc64
All errors (new ones prefixed by >>):
>> ERROR: "of_irq_parse_one" [drivers/dma/qcom/hdma_mgmt.ko] undefined!
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
-------------- next part --------------
A non-text attachment was scrubbed...
Name: .config.gz
Type: application/octet-stream
Size: 44094 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20151219/34964eef/attachment-0001.obj>
Re: [PATCH V10 7/7] dma: qcom_hidma: add support for object hierarchy
Quoted 18 lines
Hi Sinan,
[auto build test ERROR on v4.4-rc5]
[also build test ERROR on next-20151218]url:
https://github.com/0day-ci/linux/commits/Sinan-Kaya/dma-add-Qualcomm-Technologies-HIDMA-driver/20151218-010637
config: sparc64-allmodconfig (attached as .config) reproduce:
wget
https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross
-O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree make.cross ARCH=sparc64All errors (new ones prefixed by >>):
Quoted 8 lines
Quoted 1 line
Quoted 1 line
ERROR: "
of_irq_parse_one" [drivers/dma/qcom/hdma_mgmt.ko] undefined!---
0-DAY kernel test infrastructure Open Source Technology
Center
https://lists.01.org/pipermail/kbuild-all Intel
Corporation
I am confused about this. The function call is made only if OF is defined. The function that is being called is defined with extern symbol and resides in drivers/of/irq.c. how does the sparc arch define OF yet exclude drivers/of/irq.c
Re: [PATCH V10 7/7] dma: qcom_hidma: add support for object hierarchy
In reply to Sinan KayaQuoted 40 lines · 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_initdetects 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.Signed-off-by Sinan Kaya <[email protected]>(quoted diff) +10
-1+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. -module_platform_driver(hidma_mgmt_driver); +#ifdef CONFIG_OF
Review
Quoted 10 lines
(quoted diff) +10
-0+static int object_counter; + +static int __init hidma_mgmt_of_populate_channels(struct device_node *np) +{ + struct platform_device *pdev_parent = of_find_device_by_node(np); + struct platform_device_info pdevinfo; + struct of_phandle_args out_irq; + struct device_node *child; + struct resource *res; + const __be32 *cell;
Always BE ?
drivers/dma/qcom/hidma_mgmt.c static struct platform_driver hidma_mgmt_driver = { · line 314
Quoted 2 lines
drivers/dma/qcom/hidma_mgmt.c +2
-0+int ret =0 , size, i, num; +u64 addr, addr_size;
resource_size_t
drivers/dma/qcom/hidma_mgmt.c static struct platform_driver hidma_mgmt_driver = { · line 325
Quoted 11 lines
drivers/dma/qcom/hidma_mgmt.c +11
-0+ +for_each_available_child_of_node (np, child) { +int iter =0 ; + + cell =of_get_property (child,"reg" , &size); +if (!cell) { + ret = -EINVAL ; + goto out; + } + + size /= (sizeof (*cell));
Redundant parens. I think it might be good to use common sense for operator precedence, here is a radical example of ignoring it. And this is not the first case.
Quoted 14 lines
drivers/dma/qcom/hidma_mgmt.c +14
-0+ num = size / + (of_n_addr_cells (child) +of_n_size_cells (child)) +1 ; + +/* allocate a resource array */ + res =kcalloc (num,sizeof (*res),GFP_KERNEL ); +if (!res) { + ret = -ENOMEM ; + goto out; + } + +/* read each reg value */ + i =0 ; +while (i < size) { + addr = of_read_number(&cell[i],
drivers/dma/qcom/hidma_mgmt.c static struct platform_driver hidma_mgmt_driver = { · line 349
Quoted 10 lines
drivers/dma/qcom/hidma_mgmt.c +10
-0+ of_n_addr_cells(child)); + i +=of_n_addr_cells (child); + + addr_size =of_read_number (&cell[i], +of_n_size_cells (child)); + i +=of_n_size_cells (child); + + res[iter].start = addr; + res[iter].end = res[iter].start + addr_size -1 ; + res[iter].flags =IORESOURCE_MEM ;
res->start = ?
?
res++;
drivers/dma/qcom/hidma_mgmt.c static struct platform_driver hidma_mgmt_driver = { · line 359
Quoted 10 lines
drivers/dma/qcom/hidma_mgmt.c +10
-0+ iter++; + } + + ret =of_irq_parse_one (child,0 , &out_irq); +if (ret) + goto out; + + res[iter].start =irq_create_of_mapping (&out_irq); + res[iter].name ="hidma event irq" ; + res[iter].flags =IORESOURCE_IRQ ;
Ditto.
Quoted 26 lines
drivers/dma/qcom/hidma_mgmt.c +23
-0+ + pdevinfo.fwnode = &child->fwnode; + pdevinfo.parent = pdev_parent ? &pdev_parent->dev :NULL ; + pdevinfo.name = child->name; + pdevinfo.id = object_counter++; + pdevinfo.res = res; + pdevinfo.num_res = num; + pdevinfo.data =NULL ; + pdevinfo.size_data =0 ; + pdevinfo.dma_mask =DMA_BIT_MASK (64 ); +platform_device_register_full (&pdevinfo); + +kfree (res); + res = NULL; + } +out: +kfree (res); + +return ret; +} +#endif + +static int __init hidma_mgmt_init (void )
drivers/dma/qcom/hidma_mgmt.c static struct platform_driver hidma_mgmt_driver = { · line 392
Quoted 10 lines
drivers/dma/qcom/hidma_mgmt.c +10
-0+{ +#ifdef CONFIG_OF +struct device_node *child; + +for (child =of_find_matching_node (NULL , hidma_mgmt_match); child; + child =of_find_matching_node (child, hidma_mgmt_match)) { +/* device tree based firmware here */ +hidma_mgmt_of_populate_channels (child); +of_node_put (child); + }
And why this is can't be done in probe of parent node driver?
Quoted 6 lines
drivers/dma/qcom/hidma_mgmt.c +6
-0+#endif +platform_driver_register (&hidma_mgmt_driver); + +return 0 ; +} +module_init (hidma_mgmt_init);
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH V10 7/7] dma: qcom_hidma: add support for object hierarchy
Quoted 10 lines · Andy Shevchenko
drivers/dma/qcom/hidma_mgmt.c static struct platform_driver hidma_mgmt_driver = { · line 312
Quoted 8 lines
drivers/dma/qcom/hidma_mgmt.c +8
-0+static int __init hidma_mgmt_of_populate_channels (struct device_node *np) +{ +struct platform_device *pdev_parent =of_find_device_by_node (np); +struct platform_device_info pdevinfo; +struct of_phandle_args out_irq; +struct device_node *child; +struct resource *res; +const __be32 *cell;Always BE ?
Unless things have changed, device tree properties are always in big-endian order, even on little-endian systems.
Signature · 3 lines
Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project.
Re: [PATCH V10 7/7] dma: qcom_hidma: add support for object hierarchy
In reply to Andy ShevchenkoQuoted 39 lines · Andy Shevchenko
Quoted 37 lines · 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@0x5A000000 { compatible = "qcom,hidma-mgmt-1.0"; ... hidma_10: hidma@0x5a010000 { compatible = "qcom,hidma-1.0"; ... } }The
hidma_mgmt_initdetects 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.Signed-off-by Sinan Kaya <[email protected]>Documentation/ABI/testing/sysfs-platform-hidma new file +9
-0+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.
Quoted 14 lines
drivers/dma/qcom/hidma_mgmt.c static struct platform_driver hidma_mgmt_driver = { · line 312
Quoted 12 lines
drivers/dma/qcom/hidma_mgmt.c +11
-1-module_platform_driver (hidma_mgmt_driver); +#ifdef CONFIG_OF +static int object_counter; + +static int __init hidma_mgmt_of_populate_channels (struct device_node *np) +{ +struct platform_device *pdev_parent =of_find_device_by_node (np); +struct platform_device_info pdevinfo; +struct of_phandle_args out_irq; +struct device_node *child; +struct resource *res; +const __be32 *cell;Always BE ?
Yes, as Timur indicated device tree is big endian all the time.
Quoted 5 lines
drivers/dma/qcom/hidma_mgmt.c static struct platform_driver hidma_mgmt_driver = { · line 314
Quoted 3 lines
drivers/dma/qcom/hidma_mgmt.c +2
-0+int ret =0 , size, i, num; +u64 addr, addr_size;
resource_size_t
These values are read from the device tree blob using of_read_number function. of_read_number returns a u64.
Quoted 16 lines
drivers/dma/qcom/hidma_mgmt.c static struct platform_driver hidma_mgmt_driver = { · line 325
Quoted 12 lines
drivers/dma/qcom/hidma_mgmt.c +11
-0+ +for_each_available_child_of_node (np, child) { +int iter =0 ; + + cell =of_get_property (child,"reg" , &size); +if (!cell) { + ret = -EINVAL ; + goto out; + } + + size /= (sizeof (*cell));Redundant parens. I think it might be good to use common sense for operator precedence, here is a radical example of ignoring it. And this is not the first case.
Removed. Note that I copied most of this function from another driver.
Quoted 21 lines
Quoted 21 lines
drivers/dma/qcom/hidma_mgmt.c +20
-0+ num = size / + (of_n_addr_cells (child) +of_n_size_cells (child)) +1 ; + +/* allocate a resource array */ + res =kcalloc (num,sizeof (*res),GFP_KERNEL ); +if (!res) { + ret = -ENOMEM ; + goto out; + } + +/* read each reg value */ + i =0 ; +while (i < size) { + addr =of_read_number (&cell[i], +of_n_addr_cells (child)); + i +=of_n_addr_cells (child); + + addr_size =of_read_number (&cell[i], +of_n_size_cells (child)); + i +=of_n_size_cells (child);
Quoted 8 lines
drivers/dma/qcom/hidma_mgmt.c static struct platform_driver hidma_mgmt_driver = { · line 349
Quoted 4 lines
drivers/dma/qcom/hidma_mgmt.c +4
-0+ + res[iter].start = addr; + res[iter].end = res[iter].start + addr_size -1 ; + res[iter].flags =IORESOURCE_MEM ;
res->start= …
…
res++;
ok
Quoted 13 lines
drivers/dma/qcom/hidma_mgmt.c static struct platform_driver hidma_mgmt_driver = { · line 359
Quoted 11 lines
drivers/dma/qcom/hidma_mgmt.c +10
-0+ iter++; + } + + ret =of_irq_parse_one (child,0 , &out_irq); +if (ret) + goto out; + + res[iter].start =irq_create_of_mapping (&out_irq); + res[iter].name ="hidma event irq" ; + res[iter].flags =IORESOURCE_IRQ ;Ditto.
ok
Quoted 31 lines
Quoted 31 lines
drivers/dma/qcom/hidma_mgmt.c +27
-0+ + pdevinfo.fwnode = &child->fwnode; + pdevinfo.parent = pdev_parent ? &pdev_parent->dev :NULL ; + pdevinfo.name = child->name; + pdevinfo.id = object_counter++; + pdevinfo.res = res; + pdevinfo.num_res = num; + pdevinfo.data =NULL ; + pdevinfo.size_data =0 ; + pdevinfo.dma_mask =DMA_BIT_MASK (64 ); +platform_device_register_full (&pdevinfo); + +kfree (res); + res = NULL; + } +out: +kfree (res); + +return ret; +} +#endif + +static int __init hidma_mgmt_init (void ) +{ +#ifdef CONFIG_OF +struct device_node *child; +
Quoted 8 lines
drivers/dma/qcom/hidma_mgmt.c static struct platform_driver hidma_mgmt_driver = { · line 392
Quoted 6 lines
drivers/dma/qcom/hidma_mgmt.c +6
-0+for (child =of_find_matching_node (NULL , hidma_mgmt_match); child; + child =of_find_matching_node (child, hidma_mgmt_match)) { +/* device tree based firmware here */ +hidma_mgmt_of_populate_channels (child); +of_node_put (child); + }And why this is can't be done in probe of parent node driver?
The populate function creates platform objects using platform_device_register_full function above. The hidma device driver later probes the object during object enumeration phase.
I tried moving platform_device_register_full into the probe context. The objects got generated but hidma device driver didn't probe the object. I suppose we are required to create the objects before the probing starts.
I copied this pattern from another driver.
Quoted 8 lines
Quoted 7 lines
drivers/dma/qcom/hidma_mgmt.c +6
-0+#endif +platform_driver_register (&hidma_mgmt_driver); + +return 0 ; +} +module_init (hidma_mgmt_init);
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