dma: add Qualcomm Technologies HIDMA driver
Subsystems (6)
v14 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 host context and is the main management entity for all channels provided by the device.
------------------------
What's new
------------------------
- Add back default number of descriptors.
- Fix compilation error in VFIO ACPI support.
- Merge the event-channel patch back to DTS and channel driver.
------------------------
Git repos
------------------------
QEMU Support
https://www.codeaurora.org/cgit/quic/qemu/qemu/log/?h=v2.5.0-sriov
------------------------
History of Changes
------------------------
dma: hidma: Add Device Tree Binding
Changes from V13: (https://lkml.org/lkml/2016/1/29/672)
* merged event-channel change.
dma: add Qualcomm Technologies HIDMA channel driver Changes from V13: (https://lkml.org/lkml/2016/1/29/685)
* add back default descriptor count
* merged event-channel change.
dma: qcom_hidma: add support for object hierarchy
Changes from V13: (https://lkml.org/lkml/2016/1/29/680)
* initialize platform info data structure.
* configure DMA by calling of_dma_configure. DMA mask was not set when
* IOMMU driver is not present for the children devices.
vfio, platform: add support for ACPI while detecting the reset driver Changes from V13: (https://lkml.org/lkml/2016/1/29/679)
* add forgotten pointer during merge
* clarify the driver loading rules in commit message
------------------------
FAQ
------------------------
- This doesn't seem to tie into KVM or VFIO, and as far as I can tell there's no mechanism for associating channels with a particular virtual address space (i.e. no configuration of an external or internal IOMMU), nor pinning of guest pages to allow for DMA to occur safely.
I'm using VFIO platform driver for this purpose. VFIO platform driver is capable of assigning any platform device to a guest machine with this driver.
- Are there additional patches, or do you have some userspace that works with this in some limited configuration?
No, these are the only patches. We have one patch for the QEMU but from kernel perspective this is it. I just rely on the platform VFIO driver to do the work.
- How do host and guest communicate, what is the infrastructure, how is HIDMA meant to be used?
They don't. Guest machine uses HIDMA channel driver to offload DMA operations in isolation. The guest machine owns the HW registers for the channel. It doesn't need to trap to host for register read/writes etc.
All guest machine pages used are assumed to be pinned similar to VFIO PCI. The reason is performance. The IOMMU takes care of the address translation for me.
- How do host and guest communicate?
They don't.
- How is the integration performed in the hypervisor?
Hypervisor has a bunch of channel resources. For each guest machine, the channel gets unbound from the hypervisor. Channels get bind to each VFIO platform device and then control is given to the guest machine.
Once the guest machine is shutdown, VFIO driver still owns the channel device. It can assign the device to another guest machine.
- Does the HYP side requires any context switch (and how is that done)?
No communication is needed.
- What makes it safe?
No communication is needed.
- Does the HYP side requires any context switch (and how is that done)?
I don't believe this requires any context-switch -- it's the same as assigning any other platform device other than additional proeprties being controlled in the managament interface.
- I'm concerned with how this is safe, and with the userspace interface. e.g. if the user wants to up the QoS for a VM, how to they find the right channel in sysfs to alter?
The HW supports changing the QoS values on the flight. In order to locate the object, I'm exporting a chid attribute in sysfs.
Each management object has one priority and weight file per channel that is indexed by the channel id read from the DMA object. /sys/devices/platform/hidma-mgmt*/chanops/chan*/priority /sys/devices/platform/QCOM8060:*/chanops/chan*/priority
- So what is that hypervisor code used for? Is that your reset driver?
The HIDMA "management" driver which runs at the hypervisor owns the management HW. Management driver serves two purposes.
1. Common bus parameter configuration (could be called reset driver).
2. Fine tuning the HW resources on the flight.
Sinan Kaya (9):
dma: qcom_bam_dma: move to qcom directory
dma: hidma: Add Device Tree binding
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
vfio, platform: add support for ACPI while detecting the reset driver vfio, platform: add QTI HIDMA reset driver
Documentation/ABI/testing/sysfs-platform-hidma | 9 +
.../ABI/testing/sysfs-platform-hidma-mgmt | 97 +++
.../devicetree/bindings/dma/qcom_hidma_mgmt.txt | 89 ++
drivers/dma/Kconfig | 11 +-
drivers/dma/Makefile | 2 +-
drivers/dma/qcom/Kconfig | 29 +
drivers/dma/qcom/Makefile | 5 +
drivers/dma/{qcom_bam_dma.c => qcom/bam_dma.c} | 4 +-
drivers/dma/qcom/hidma.c | 746 +++++++++++++++++
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 | 407 +++++++++
drivers/dma/qcom/hidma_mgmt.h | 39 +
drivers/dma/qcom/hidma_mgmt_sys.c | 295 +++++++
drivers/vfio/platform/reset/Kconfig | 9 +
drivers/vfio/platform/reset/Makefile | 2 +
.../vfio/platform/reset/vfio_platform_amdxgbe.c | 3 +-
.../platform/reset/vfio_platform_calxedaxgmac.c | 3 +-
.../vfio/platform/reset/vfio_platform_qcomhidma.c | 99 +++
drivers/vfio/platform/vfio_platform_common.c | 80 +-
drivers/vfio/platform/vfio_platform_private.h | 41 +-
22 files changed, 3235 insertions(+), 43 deletions(-)
create mode 100644 Documentation/ABI/testing/sysfs-platform-hidma
create mode 100644 Documentation/ABI/testing/sysfs-platform-hidma-mgmt
create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
create mode 100644 drivers/dma/qcom/Kconfig
create mode 100644 drivers/dma/qcom/Makefile
rename drivers/dma/{qcom_bam_dma.c => qcom/bam_dma.c} (99%)
create mode 100644 drivers/dma/qcom/hidma.c
create mode 100644 drivers/dma/qcom/hidma.h
create mode 100644 drivers/dma/qcom/hidma_dbg.c
create mode 100644 drivers/dma/qcom/hidma_ll.c
create mode 100644 drivers/dma/qcom/hidma_mgmt.c
create mode 100644 drivers/dma/qcom/hidma_mgmt.h
create mode 100644 drivers/dma/qcom/hidma_mgmt_sys.c
create mode 100644 drivers/vfio/platform/reset/vfio_platform_qcomhidma.cSignature · 1 line
1.8.2.1
PATCH v14 1/9 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
@@ -539,6 +530,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
@@ -67,4 +66,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 · 1 line
1.8.2.1
PATCH v14 2/9 dma: hidma: Add Device Tree binding
In reply to Sinan KayaAdd documentation for the Qualcomm Technologies HIDMA binding.
--- .../devicetree/bindings/dma/qcom_hidma_mgmt.txt | 89 ++++++++++++++++++++++ 1 file changed, 89 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +89 -0
@@ -0,0 +1,89 @@ +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 that HIDMA can + occupy the bus for in a single transaction. A memcpy requested is + fragmented to multiples of this amount. This parameter is used while + writing into destination memory. Setting this value incorrectly can + starve other peripherals in the system. +- max-read-burst-bytes: Maximum read burst in bytes that HIDMA can + occupy the bus for in a single transaction. A memcpy request is + fragmented to multiples of this amount. This parameter is used while + reading the source memory. Setting this value incorrectly can starve + other peripherals in the system. +- max-write-transactions: This value is how many times a write burst is + applied back to back while writing to the destination before yielding + the bus. +- max-read-transactions: This value is how many times a read burst is + applied back to back while reading the source before yielding the bus. +- channel-reset-timeout-cycles: Channel reset timeout in cycles for this SOC. + Once a reset is applied to the HW, HW starts a timer for reset operation + to confirm. If reset is not completed within this time, HW reports reset + failure. + +Sub-nodes: + +HIDMA has one or more DMA channels that are used to move data from one +memory location to another. + +When the OS is not in control of the management interface (i.e. it's a guest), +the channel nodes appear on their own, not under a management node. + +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 +- iommus: required a iommu node + +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>; + iommus = <&system_mmu>; + }; + }; + +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>; + iommus = <&system_mmu>; + };
Signature · 1 line
1.8.2.1
PATCH v14 3/9 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 host 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 + host 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 · 1 line
1.8.2.1
PATCH v14 4/9 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 | 706 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/dma/qcom/hidma.h | 160 +++++++++++ 3 files changed, 876 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 host 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 +706 -0
706 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 · 1 line
1.8.2.1
PATCH v14 5/9 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 · 1 line
1.8.2.1
PATCH v14 6/9 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
@@ -644,6 +644,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);
@@ -651,6 +652,7 @@ static int hidma_probe(struct platform_device *pdev)return 0 ; uninit: +hidma_debug_uninit (dmadev);hidma_ll_uninit (dmadev->lldev); dmafree:if (dmadev)
@@ -668,6 +670,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 · 1 line
1.8.2.1
PATCH v14 7/9 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 | 111 ++++++++++++++++++++++++- 3 files changed, 155 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
@@ -530,6 +530,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;
@@ -645,6 +682,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);
@@ -692,7 +730,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 +108 -3
126 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH v14 8/9 vfio, platform: add support for ACPI while detecting the reset driver
In reply to Sinan KayaThe code is using the compatible DT string to associate a reset driver with the actual device itself. The compatible string does not exist on ACPI based systems. HID is the unique identifier for a device driver instead. The change allows a driver to register with DT compatible string or ACPI HID and then match the object with one of these conditions.
Rules for loading the reset driver are as follow:
- ACPI HID needs match for ACPI systems
- DT compat needs to match for OF systems
--- .../vfio/platform/reset/vfio_platform_amdxgbe.c | 3 +- .../platform/reset/vfio_platform_calxedaxgmac.c | 3 +- drivers/vfio/platform/vfio_platform_common.c | 80 +++++++++++++++++++--- drivers/vfio/platform/vfio_platform_private.h | 41 ++++++----- 4 files changed, 96 insertions(+), 31 deletions(-)
drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +2 -1
@@ -119,7 +119,8 @@ int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)return 0 ; } -module_vfio_reset_handler ("amd,xgbe-seattle-v1a" , vfio_platform_amdxgbe_reset); +module_vfio_reset_handler ("amd,xgbe-seattle-v1a" ,NULL , + vfio_platform_amdxgbe_reset);MODULE_VERSION ("0.1" );MODULE_LICENSE ("GPL v2" );
drivers/vfio/platform/reset/vfio_platform_calxedaxgmac.c +2 -1
@@ -77,7 +77,8 @@ int vfio_platform_calxedaxgmac_reset(struct vfio_platform_device *vdev)return 0 ; } -module_vfio_reset_handler ("calxeda,hb-xgmac" , vfio_platform_calxedaxgmac_reset); +module_vfio_reset_handler ("calxeda,hb-xgmac" ,NULL , + vfio_platform_calxedaxgmac_reset);MODULE_VERSION (DRIVER_VERSION );MODULE_LICENSE ("GPL v2" );
drivers/vfio/platform/vfio_platform_common.c +69 -11
133 lines not on this page · raw message
drivers/vfio/platform/vfio_platform_private.h +23 -18
62 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH v14 9/9 vfio, platform: add QTI HIDMA reset driver
In reply to Sinan KayaIn situations where the userspace driver is stopped abnormally and the VFIO platform device is released, the assigned HW device currently is left running. As a consequence the HW device might continue issuing IRQs and performing DMA accesses.
This patch is implementing a reset driver for HIDMA platform driver. This gets called by the VFIO platform reset interface.
--- drivers/vfio/platform/reset/Kconfig | 9 ++ drivers/vfio/platform/reset/Makefile | 2 + .../vfio/platform/reset/vfio_platform_qcomhidma.c | 99 ++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 drivers/vfio/platform/reset/vfio_platform_qcomhidma.c
drivers/vfio/platform/reset/Kconfig +9 -0
@@ -13,3 +13,12 @@ config VFIO_PLATFORM_AMDXGBE_RESET Enables the VFIO platform driver to handle reset for AMD XGBE If you don't know what to do here, say N. + +config VFIO_PLATFORM_QCOMHIDMA_RESET + tristate "VFIO support for Qualcomm Technologies HIDMA reset" + depends on VFIO_PLATFORM + help + Enables the VFIO platform driver to handle reset for Qualcomm Technologies + HIDMA Channel. + + If you don't know what to do here, say N.
drivers/vfio/platform/reset/Makefile +2 -0
@@ -1,7 +1,9 @@ vfio-platform-calxedaxgmac-y := vfio_platform_calxedaxgmac.o vfio-platform-amdxgbe-y := vfio_platform_amdxgbe.o +vfio-platform-qcomhidma-y := vfio_platform_qcomhidma.o ccflags-y += -Idrivers/vfio/platform obj-$(CONFIG_VFIO_PLATFORM_CALXEDAXGMAC_RESET) += vfio-platform-calxedaxgmac.o +obj-$(CONFIG_VFIO_PLATFORM_QCOMHIDMA_RESET) += vfio-platform-qcomhidma.o obj-$(CONFIG_VFIO_PLATFORM_AMDXGBE_RESET) += vfio-platform-amdxgbe.o
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +99 -0
99 lines not on this page · raw message
Signature · 1 line
1.8.2.1
Hi Sinan,
Quoted 15 lines · Sinan Kaya
The Qualcomm Technologies HIDMA device has been designed to support virtualization technology. The driver has been divided into two to follow the hardware design.
1. HIDMA Management driver
2. HIDMA Channel driverEach 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.
Quoted 3 lines
The management driver is executed in host context and is the main management entity for all channels provided by the device.
I'm not at all familiar with this kind of hardware.
Once an entity (userspace or VM) has a HIDAM channel assigned via VFIO, how does it use it? Is it used in relation with another device to perform DMA on its behalf or is a HIDMA channel something that's useful on its own?
Thanks,
-Christoffer
Hi,
Quoted 18 lines · Christoffer Dall
Hi Sinan,
Quoted 15 lines · Sinan Kaya
The Qualcomm Technologies HIDMA device has been designed to support virtualization technology. The driver has been divided into two to follow the hardware design.
1. HIDMA Management driver
2. HIDMA Channel driverEach 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.
Quoted 6 lines
Quoted 3 lines
The management driver is executed in host context and is the main management entity for all channels provided by the device.
I'm not at all familiar with this kind of hardware.
Let me help.
Quoted 2 lines
Once an entity (userspace or VM) has a HIDAM channel assigned via VFIO, how does it use it?
HIDMA is a HW accelerator for memory operations like memcpy and memset. It fits into the DMA engine framework.
There are two classes of DMA HW. These are slave DMA and standalone DMA. Slave DMA is generally related to another piece of HW that needs DMA for moving data. Standalone DMA is intended for OS/CPU consumption not HW. These can be used to offload crypto operations (XOR) or other memory transactions (memcpy and memset) that are lengthy.
Once the HIDMA channel is assigned to the guest machine, guest operating system uses the DMA channel to offload memory operations as HIDMA only supports memcpy.
IOMMU HW provides the isolation from the rest of the host kernel or from other guest machines.
Quoted 3 lines
Is it used in relation with another device to
perform DMA on its behalf or is a HIDMA channel something that's useful on its own?
It is standalone only. The relationship you are referring to is known as slave DMA engine. HIDMA does not support slave DMA. HIDMA only supports memcpy and memset in HW and only memcpy in SW as the memset support has been removed from the kernel long time ago.
Quoted 4 lines
Thanks,
-Christoffer
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
Quoted 47 lines · Sinan Kaya
Hi,
Quoted 18 lines · Christoffer Dall
Hi Sinan,
Quoted 15 lines · Sinan Kaya
The Qualcomm Technologies HIDMA device has been designed to support virtualization technology. The driver has been divided into two to follow the hardware design.
1. HIDMA Management driver
2. HIDMA Channel driverEach 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.
Quoted 6 lines
Quoted 3 lines
The management driver is executed in host context and is the main management entity for all channels provided by the device.
I'm not at all familiar with this kind of hardware.
Let me help.
Quoted 2 lines
Once an entity (userspace or VM) has a HIDAM channel assigned via VFIO, how does it use it?
HIDMA is a HW accelerator for memory operations like memcpy and memset. It fits into the DMA engine framework.
There are two classes of DMA HW. These are slave DMA and standalone DMA. Slave DMA is generally related to another piece of HW that needs DMA for moving data. Standalone DMA is intended for OS/CPU consumption not HW. These can be used to offload crypto operations (XOR) or other memory transactions (memcpy and memset) that are lengthy.
Once the HIDMA channel is assigned to the guest machine, guest operating system uses the DMA channel to offload memory operations as HIDMA only supports memcpy.
IOMMU HW provides the isolation from the rest of the host kernel or from other guest machines.
Quoted 8 lines
Quoted 3 lines
Is it used in relation with another device to
perform DMA on its behalf or is a HIDMA channel something that's useful on its own?It is standalone only. The relationship you are referring to is known as slave DMA engine. HIDMA does not support slave DMA. HIDMA only supports memcpy and memset in HW and only memcpy in SW as the memset support has been removed from the kernel long time ago.
Thanks for the explanation.
-Christoffer
Hi Marc Zyngier, Mark Rutland;
I'm looking forward to hear your feedback on this series.
Quoted 179 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 driverEach 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 host context and is the main management entity for all channels provided by the device.
------------------------
What's new
------------------------
- Add back default number of descriptors.
- Fix compilation error in VFIO ACPI support.
- Merge the event-channel patch back to DTS and channel driver.------------------------
Git repos
------------------------
QEMU Support
https://www.codeaurora.org/cgit/quic/qemu/qemu/log/?h=v2.5.0-sriov------------------------
History of Changes
------------------------
dma: hidma: Add Device Tree Binding
Changes from V13: (https://lkml.org/lkml/2016/1/29/672)
* merged event-channel change.dma: add Qualcomm Technologies HIDMA channel driver Changes from V13: (https://lkml.org/lkml/2016/1/29/685)
* add back default descriptor count
* merged event-channel change.dma:
qcom_hidma: add support for object hierarchy
Changes from V13: (https://lkml.org/lkml/2016/1/29/680)
* initialize platform info data structure.
* configure DMA by callingof_dma_configure. DMA mask was not set when
* IOMMU driver is not present for the children devices.vfio, platform: add support for ACPI while detecting the reset driver Changes from V13: (https://lkml.org/lkml/2016/1/29/679)
* add forgotten pointer during merge
* clarify the driver loading rules in commit message------------------------
FAQ
------------------------
- This doesn't seem to tie into KVM or VFIO, and as far as I can tell there's no mechanism for associating channels with a particular virtual address space (i.e. no configuration of an external or internal IOMMU), nor pinning of guest pages to allow for DMA to occur safely.I'm using VFIO platform driver for this purpose. VFIO platform driver is capable of assigning any platform device to a guest machine with this driver.
- Are there additional patches, or do you have some userspace that works with this in some limited configuration?
No, these are the only patches. We have one patch for the QEMU but from kernel perspective this is it. I just rely on the platform VFIO driver to do the work.
- How do host and guest communicate, what is the infrastructure, how is HIDMA meant to be used?
They don't. Guest machine uses HIDMA channel driver to offload DMA operations in isolation. The guest machine owns the HW registers for the channel. It doesn't need to trap to host for register read/writes etc.
All guest machine pages used are assumed to be pinned similar to VFIO PCI. The reason is performance. The IOMMU takes care of the address translation for me.
- How do host and guest communicate?
They don't.- How is the integration performed in the hypervisor?
Hypervisor has a bunch of channel resources. For each guest machine, the channel gets unbound from the hypervisor. Channels get bind to each VFIO platform device and then control is given to the guest machine.
Once the guest machine is shutdown, VFIO driver still owns the channel device. It can assign the device to another guest machine.
- Does the HYP side requires any context switch (and how is that done)?
No communication is needed.
- What makes it safe?
No communication is needed.- Does the HYP side requires any context switch (and how is that done)?
I don't believe this requires any context-switch -- it's the same as assigning any other platform device other than additional proeprties being controlled in the managament interface.
- I'm concerned with how this is safe, and with the userspace interface. e.g. if the user wants to up the QoS for a VM, how to they find the right channel in sysfs to alter?
The HW supports changing the QoS values on the flight. In order to locate the object, I'm exporting a chid attribute in sysfs.
Each management object has one priority and weight file per channel that is indexed by the channel id read from the DMA object.
/sys/devices/platform/hidma-mgmt*/chanops/chan*/priority/sys/devices/platform/QCOM8060:*/chanops/chan*/priority- So what is that hypervisor code used for? Is that your reset driver?
The HIDMA "management" driver which runs at the hypervisor owns the management HW. Management driver serves two purposes.
1. Common bus parameter configuration (could be called reset driver).
2. Fine tuning the HW resources on the flight.Sinan Kaya (9):
dma:qcom_bam_dma: move to qcom directory
dma: hidma: Add Device Tree binding
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
vfio, platform: add support for ACPI while detecting the reset driver vfio, platform: add QTI HIDMA reset driverDocumentation/ABI/testing/sysfs-platform-hidma | 9 + .../ABI/testing/sysfs-platform-hidma-mgmt | 97 +++ .../devicetree/bindings/dma/qcom_hidma_mgmt.txt | 89 ++ drivers/dma/Kconfig | 11 +- drivers/dma/Makefile | 2 +- drivers/dma/qcom/Kconfig | 29 + drivers/dma/qcom/Makefile | 5 + drivers/dma/{qcom_bam_dma.c => qcom/bam_dma.c} | 4 +- drivers/dma/qcom/hidma.c | 746 +++++++++++++++++ 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 | 407 +++++++++ drivers/dma/qcom/hidma_mgmt.h | 39 + drivers/dma/qcom/hidma_mgmt_sys.c | 295 +++++++ drivers/vfio/platform/reset/Kconfig | 9 + drivers/vfio/platform/reset/Makefile | 2 + .../vfio/platform/reset/vfio_platform_amdxgbe.c | 3 +- .../platform/reset/vfio_platform_calxedaxgmac.c | 3 +- .../vfio/platform/reset/vfio_platform_qcomhidma.c | 99 +++ drivers/vfio/platform/vfio_platform_common.c | 80 +- drivers/vfio/platform/vfio_platform_private.h | 41 +- 22 files changed, 3235 insertions(+), 43 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-platform-hidma create mode 100644 Documentation/ABI/testing/sysfs-platform-hidma-mgmt create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt create mode 100644 drivers/dma/qcom/Kconfig create mode 100644 drivers/dma/qcom/Makefile rename drivers/dma/{qcom_bam_dma.c => qcom/bam_dma.c} (99%) create mode 100644 drivers/dma/qcom/hidma.c create mode 100644 drivers/dma/qcom/hidma.h create mode 100644 drivers/dma/qcom/hidma_dbg.c create mode 100644 drivers/dma/qcom/hidma_ll.c create mode 100644 drivers/dma/qcom/hidma_mgmt.c create mode 100644 drivers/dma/qcom/hidma_mgmt.h create mode 100644 drivers/dma/qcom/hidma_mgmt_sys.c create mode 100644 drivers/vfio/platform/reset/vfio_platform_qcomhidma.c
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
Re: [PATCH V14 8/9] vfio, platform: add support for ACPI while detecting the reset driver
In reply to Sinan KayaHi Alex,
Quoted 251 lines · Sinan Kaya
The code is using the compatible DT string to associate a reset driver with the actual device itself. The compatible string does not exist on ACPI based systems. HID is the unique identifier for a device driver instead. The change allows a driver to register with DT compatible string or ACPI HID and then match the object with one of these conditions.
Rules for loading the reset driver are as follow:
- ACPI HID needs match for ACPI systems
- DT compat needs to match for OF systemsSigned-off-by Sinan Kaya <[email protected]>--- .../vfio/platform/reset/vfio_platform_amdxgbe.c | 3 +- .../platform/reset/vfio_platform_calxedaxgmac.c | 3 +- drivers/vfio/platform/vfio_platform_common.c | 80 +++++++++++++++++++--- drivers/vfio/platform/vfio_platform_private.h | 41 ++++++----- 4 files changed, 96 insertions(+), 31 deletions(-)drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +2
-1@@ -119,7 +119,8 @@ int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)return 0 ; } -module_vfio_reset_handler ("amd,xgbe-seattle-v1a" , vfio_platform_amdxgbe_reset); +module_vfio_reset_handler ("amd,xgbe-seattle-v1a" ,NULL , + vfio_platform_amdxgbe_reset);MODULE_VERSION ("0.1" );MODULE_LICENSE ("GPL v2" );drivers/vfio/platform/reset/vfio_platform_calxedaxgmac.c +2
-1@@ -77,7 +77,8 @@ int vfio_platform_calxedaxgmac_reset(struct vfio_platform_device *vdev)return 0 ; } -module_vfio_reset_handler ("calxeda,hb-xgmac" , vfio_platform_calxedaxgmac_reset); +module_vfio_reset_handler ("calxeda,hb-xgmac" ,NULL , + vfio_platform_calxedaxgmac_reset);MODULE_VERSION (DRIVER_VERSION );MODULE_LICENSE ("GPL v2" );drivers/vfio/platform/vfio_platform_common.c +69
-11@@ -13,6 +13,7 @@*/ #include <linux/device.h> +#include <linux/acpi.h> #include <linux/iommu.h> #include <linux/module.h> #include <linux/mutex.h> @@ -31,14 +32,22 @@ static LIST_HEAD(reset_list);static DEFINE_MUTEX (driver_lock);static vfio_platform_reset_fn_t vfio_platform_lookup_reset (const char *compat, -struct module **module) +const char *acpihid,struct module **module) {struct vfio_platform_reset_node *iter;vfio_platform_reset_fn_t reset_fn =NULL ;mutex_lock (&driver_lock);list_for_each_entry (iter, &reset_list, link) { -if (!strcmp (iter->compat, compat) && +if (acpihid && iter->acpihid && + !strcmp (iter->acpihid, acpihid) && +try_module_get (iter->owner)) { + *module = iter->owner; + reset_fn = iter->reset; +break ; + } +if (compat && iter->compat && + !strcmp (iter->compat, compat) &&try_module_get (iter->owner)) { *module = iter->owner; reset_fn = iter->reset;@@ -51,11 +60,12 @@ static vfio_platform_reset_fn_t vfio_platform_lookup_reset(const char *compat,static void vfio_platform_get_reset (struct vfio_platform_device *vdev) { - vdev->reset =vfio_platform_lookup_reset (vdev->compat, - &vdev->reset_module); + vdev->reset =vfio_platform_lookup_reset (vdev->compat, vdev->acpihid, + &vdev->reset_module);if (!vdev->reset) {request_module ("vfio-reset:%s" , vdev->compat); vdev->reset =vfio_platform_lookup_reset (vdev->compat, + vdev->acpihid, &vdev->reset_module); } }@@ -541,6 +551,46 @@ static const struct vfio_device_ops vfio_platform_ops = { .mmap = vfio_platform_mmap, }; +#ifdef CONFIG_ACPI +int vfio_platform_probe_acpi (struct vfio_platform_device *vdev, +struct device *dev) +{ +struct acpi_device *adev =ACPI_COMPANION (dev); + +if (!adev) +return -EINVAL ; + + vdev->acpihid =acpi_device_hid (adev); +if (!vdev->acpihid) { +pr_err ("VFIO: cannot find ACPI HID for %s\n" , + vdev->name); +return -EINVAL ; + } +return 0 ; +} +#else +int vfio_platform_probe_acpi (struct vfio_platform_device *vdev, +struct device *dev) +{ +return -EINVAL ; +} +#endif + +int vfio_platform_probe_of (struct vfio_platform_device *vdev, +struct device *dev) +{ +int ret; + + ret =device_property_read_string (dev,"compatible" , + &vdev->compat); +if (ret) { +pr_err ("VFIO: cannot retrieve compat for %s\n" , + vdev->name); +return -EINVAL ; + } +return 0 ; +} +int vfio_platform_probe_common (struct vfio_platform_device *vdev,struct device *dev) {@@ -550,14 +600,14 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,if (!vdev)return -EINVAL ; - ret =device_property_read_string (dev,"compatible" , &vdev->compat); -if (ret) { -pr_err ("VFIO: cannot retrieve compat for %s\n" , vdev->name); -return -EINVAL ; - } + ret =vfio_platform_probe_acpi (vdev, dev); +if (ret) + ret =vfio_platform_probe_of (vdev, dev); - vdev->device = dev; +if (ret) +return ret; + vdev->device = dev; group =iommu_group_get (dev);if (!group) {pr_err ("VFIO: No IOMMU group for device %s\n" , vdev->name);@@ -602,13 +652,21 @@ void __vfio_platform_register_reset(struct vfio_platform_reset_node *node)EXPORT_SYMBOL_GPL (__vfio_platform_register_reset);void vfio_platform_unregister_reset (const char *compat, +const char *acpihid,vfio_platform_reset_fn_t fn) {struct vfio_platform_reset_node *iter, *temp;mutex_lock (&driver_lock);list_for_each_entry_safe (iter, temp, &reset_list, link) { -if (!strcmp (iter->compat, compat) && (iter->reset == fn)) { +if (acpihid && iter->acpihid && + !strcmp (iter->acpihid, acpihid) && (iter->reset == fn)) { +list_del (&iter->link); +break ; + } + +if (compat && iter->compat && + !strcmp (iter->compat, compat) && (iter->reset == fn)) {list_del (&iter->link);break ; }drivers/vfio/platform/vfio_platform_private.h +16
-18@@ -58,6 +58,7 @@ struct vfio_platform_device {struct mutex igate;struct module *parent_module;const char *compat; +const char *acpihid;struct module *reset_module;struct device *device;@@ -79,6 +80,7 @@ typedef int (*vfio_platform_reset_fn_t)(struct vfio_platform_device *vdev);struct vfio_platform_reset_node {struct list_head link;char *compat; +char *acpihid;struct module *owner;vfio_platform_reset_fn_t reset; };@@ -98,27 +100,30 @@ extern int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev,extern void __vfio_platform_register_reset (struct vfio_platform_reset_node *n);extern void vfio_platform_unregister_reset (const char *compat, +const char *acpihid,vfio_platform_reset_fn_t fn); -#define vfio_platform_register_reset (__compat, __reset) \ -static struct vfio_platform_reset_node __reset ## _node = { \ - .owner = THIS_MODULE, \ - .compat = __compat, \ - .reset = __reset, \ -}; \ + +#define vfio_platform_register_reset (__compat, __acpihid, __reset) \ +static struct vfio_platform_reset_node __reset ## _node = { \ + .owner = THIS_MODULE, \ + .compat = __compat, \ + .acpihid = __acpihid, \ + .reset = __reset, \ +}; \ __vfio_platform_register_reset(&__reset ## _node) -#define module_vfio_reset_handler (compat, reset) \ -MODULE_ALIAS("vfio-reset:" compat); \ -static int __init reset ## _module_init(void) \ -{ \ - vfio_platform_register_reset(compat, reset); \ - return 0; \ -}; \ -static void __exit reset ## _module_exit(void) \ -{ \ - vfio_platform_unregister_reset(compat, reset); \ -}; \ -module_init(reset ## _module_init); \ +#define module_vfio_reset_handler (compat, acpihid, reset) \ +MODULE_ALIAS("vfio-reset:" compat); \ +static int __init reset ## _module_init(void) \ +{ \ + vfio_platform_register_reset(compat, acpihid, reset); \
drivers/vfio/platform/vfio_platform_private.h extern int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev, · line 129
Quoted 10 lines
drivers/vfio/platform/vfio_platform_private.h +7
-0+return 0 ; \ +}; \ +static void __exit reset ## _module_exit(void) \ +{ \ +vfio_platform_unregister_reset (compat, acpihid, reset); \ +}; \ +module_init(reset ## _module_init); \ module_exit(reset ## _module_exit)#endif /* VFIO_PLATFORM_PRIVATE_H */
I believe these two reviews need to be reviewed by you as they are in the VFIO world. Would you please take a look?
[PATCH V14 8/9] vfio, platform: add support for ACPI while detecting the reset driver [PATCH V14 9/9] vfio, platform: add QTI HIDMA reset driver
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
Quoted 3 lines · Sinan Kaya
Hi Marc Zyngier, Mark Rutland;
I'm looking forward to hear your feedback on this series.
Would it be possible to get this patchset into 4.6? We're already at v14, and there have been no review comments since this patch was posted on the fourth (over three weeks ago).
Signature · 3 lines
Sent by an employee of the Qualcomm Innovation Center, Inc. The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, hosted by The Linux Foundation.
Re: [PATCH V14 8/9] vfio, platform: add support for ACPI while detecting the reset driver
In reply to Sinan KayaHi Sinan,
Quoted 102 lines · Sinan Kaya
The code is using the compatible DT string to associate a reset driver with the actual device itself. The compatible string does not exist on ACPI based systems. HID is the unique identifier for a device driver instead. The change allows a driver to register with DT compatible string or ACPI HID and then match the object with one of these conditions.
Rules for loading the reset driver are as follow:
- ACPI HID needs match for ACPI systems
- DT compat needs to match for OF systemsSigned-off-by Sinan Kaya <[email protected]>--- .../vfio/platform/reset/vfio_platform_amdxgbe.c | 3 +- .../platform/reset/vfio_platform_calxedaxgmac.c | 3 +- drivers/vfio/platform/vfio_platform_common.c | 80 +++++++++++++++++++--- drivers/vfio/platform/vfio_platform_private.h | 41 ++++++----- 4 files changed, 96 insertions(+), 31 deletions(-)drivers/vfio/platform/reset/vfio_platform_amdxgbe.c +2
-1@@ -119,7 +119,8 @@ int vfio_platform_amdxgbe_reset(struct vfio_platform_device *vdev)return 0 ; } -module_vfio_reset_handler ("amd,xgbe-seattle-v1a" , vfio_platform_amdxgbe_reset); +module_vfio_reset_handler ("amd,xgbe-seattle-v1a" ,NULL , + vfio_platform_amdxgbe_reset);MODULE_VERSION ("0.1" );MODULE_LICENSE ("GPL v2" );drivers/vfio/platform/reset/vfio_platform_calxedaxgmac.c +2
-1@@ -77,7 +77,8 @@ int vfio_platform_calxedaxgmac_reset(struct vfio_platform_device *vdev)return 0 ; } -module_vfio_reset_handler ("calxeda,hb-xgmac" , vfio_platform_calxedaxgmac_reset); +module_vfio_reset_handler ("calxeda,hb-xgmac" ,NULL , + vfio_platform_calxedaxgmac_reset);MODULE_VERSION (DRIVER_VERSION );MODULE_LICENSE ("GPL v2" );drivers/vfio/platform/vfio_platform_common.c +14
-4@@ -13,6 +13,7 @@*/ #include <linux/device.h> +#include <linux/acpi.h> #include <linux/iommu.h> #include <linux/module.h> #include <linux/mutex.h> @@ -31,14 +32,22 @@ static LIST_HEAD(reset_list);static DEFINE_MUTEX (driver_lock);static vfio_platform_reset_fn_t vfio_platform_lookup_reset (const char *compat, -struct module **module) +const char *acpihid,struct module **module) {struct vfio_platform_reset_node *iter;vfio_platform_reset_fn_t reset_fn =NULL ;mutex_lock (&driver_lock);list_for_each_entry (iter, &reset_list, link) { -if (!strcmp (iter->compat, compat) && +if (acpihid && iter->acpihid && + !strcmp (iter->acpihid, acpihid) && +try_module_get (iter->owner)) { + *module = iter->owner; + reset_fn = iter->reset; +break ; + } +if (compat && iter->compat && + !strcmp (iter->compat, compat) &&try_module_get (iter->owner)) { *module = iter->owner; reset_fn = iter->reset;@@ -51,11 +60,12 @@ static vfio_platform_reset_fn_t vfio_platform_lookup_reset(const char *compat,static void vfio_platform_get_reset (struct vfio_platform_device *vdev) { - vdev->reset =vfio_platform_lookup_reset (vdev->compat, - &vdev->reset_module); + vdev->reset =vfio_platform_lookup_reset (vdev->compat, vdev->acpihid, + &vdev->reset_module);if (!vdev->reset) {request_module ("vfio-reset:%s" , vdev->compat); vdev->reset =vfio_platform_lookup_reset (vdev->compat, + vdev->acpihid, &vdev->reset_module); } }@@ -541,6 +551,46 @@ static const struct vfio_device_ops vfio_platform_ops = { .mmap = vfio_platform_mmap,
drivers/vfio/platform/vfio_platform_common.c static const struct vfio_device_ops vfio_platform_ops = { · line 561
Quoted 10 lines
drivers/vfio/platform/vfio_platform_common.c +8
-0}; +#ifdef CONFIG_ACPI +int vfio_platform_probe_acpi (struct vfio_platform_device *vdev, +struct device *dev) +{ +struct acpi_device *adev =ACPI_COMPANION (dev); + +if (!adev) +return -EINVAL ;
-ENODEV seems to be commonly used in that case
drivers/vfio/platform/vfio_platform_common.c static const struct vfio_device_ops vfio_platform_ops = { · line 564
Quoted 3 lines
drivers/vfio/platform/vfio_platform_common.c +3
-0+ + vdev->acpihid =acpi_device_hid (adev); +if (!vdev->acpihid) {
can it return NULL? Seems to return dummy "device" or actual hid
drivers/vfio/platform/vfio_platform_common.c static const struct vfio_device_ops vfio_platform_ops = { · line 567
Quoted 3 lines
drivers/vfio/platform/vfio_platform_common.c +3
-0+pr_err ("VFIO: cannot find ACPI HID for %s\n" , + vdev->name); +return -EINVAL ;
-ENODEV too?
Quoted 12 lines
drivers/vfio/platform/vfio_platform_common.c +12
-0+ } +return 0 ; +} +#else +int vfio_platform_probe_acpi (struct vfio_platform_device *vdev, +struct device *dev) +{ +return -EINVAL ; +} +#endif + +int vfio_platform_probe_of(struct vfio_platform_device *vdev,
drivers/vfio/platform/vfio_platform_common.c static const struct vfio_device_ops vfio_platform_ops = { · line 589
Quoted 10 lines
drivers/vfio/platform/vfio_platform_common.c +10
-0+ struct device *dev) +{ +int ret; + + ret =device_property_read_string (dev,"compatible" , + &vdev->compat); +if (ret) { +pr_err ("VFIO: cannot retrieve compat for %s\n" , + vdev->name); +return -EINVAL ;
return ret instead.
Quoted 41 lines
drivers/vfio/platform/vfio_platform_common.c +12
-7+ } +return 0 ; +} +int vfio_platform_probe_common (struct vfio_platform_device *vdev,struct device *dev) {@@ -550,14 +600,14 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,if (!vdev)return -EINVAL ; - ret =device_property_read_string (dev,"compatible" , &vdev->compat); -if (ret) { -pr_err ("VFIO: cannot retrieve compat for %s\n" , vdev->name); -return -EINVAL ; - } + ret =vfio_platform_probe_acpi (vdev, dev); +if (ret) + ret =vfio_platform_probe_of (vdev, dev); - vdev->device = dev; +if (ret) +return ret; + vdev->device = dev; group =iommu_group_get (dev);if (!group) {pr_err ("VFIO: No IOMMU group for device %s\n" , vdev->name);@@ -602,13 +652,21 @@ void __vfio_platform_register_reset(struct vfio_platform_reset_node *node)EXPORT_SYMBOL_GPL (__vfio_platform_register_reset);void vfio_platform_unregister_reset (const char *compat, +const char *acpihid,vfio_platform_reset_fn_t fn) {struct vfio_platform_reset_node *iter, *temp;mutex_lock (&driver_lock);list_for_each_entry_safe (iter, temp, &reset_list, link) { -if (!strcmp (iter->compat, compat) && (iter->reset == fn)) { + if (acpihid && iter->acpihid &&
drivers/vfio/platform/vfio_platform_common.c void __vfio_platform_register_reset(struct vfio_platform_reset_node *node) · line 672
Quoted 10 lines
drivers/vfio/platform/vfio_platform_common.c +7
-0+ !strcmp(iter->acpihid, acpihid) && (iter->reset == fn)) { +list_del (&iter->link); +break ; + } + +if (compat && iter->compat && + !strcmp (iter->compat, compat) && (iter->reset == fn)) {list_del (&iter->link);break ; }
in vfio_platform_get_reset, if the 1st vfio_platform_lookup_reset call does not return anything then we currently call request_module("vfio-reset:%s", vdev->compat);
you need to handle the case where compat is not set but vdev->acpihid is, instead.
currently the module alias is constructed with the compat only MODULE_ALIAS("vfio-reset:" compat);
Looks you can define several ones ( for instance in drivers/block/xen-blkfront.c).
If I am not wrong this currently would not work with vfio-platform-qcomhidma compiled as a module.
Quoted 46 lines
drivers/vfio/platform/vfio_platform_private.h +11
-10@@ -58,6 +58,7 @@ struct vfio_platform_device {struct mutex igate;struct module *parent_module;const char *compat; +const char *acpihid;struct module *reset_module;struct device *device;@@ -79,6 +80,7 @@ typedef int (*vfio_platform_reset_fn_t)(struct vfio_platform_device *vdev);struct vfio_platform_reset_node {struct list_head link;char *compat; +char *acpihid;struct module *owner;vfio_platform_reset_fn_t reset; };@@ -98,27 +100,30 @@ extern int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev,extern void __vfio_platform_register_reset (struct vfio_platform_reset_node *n);extern void vfio_platform_unregister_reset (const char *compat, +const char *acpihid,vfio_platform_reset_fn_t fn); -#define vfio_platform_register_reset (__compat, __reset) \ -static struct vfio_platform_reset_node __reset ## _node = { \ - .owner = THIS_MODULE, \ - .compat = __compat, \ - .reset = __reset, \ -}; \ + +#define vfio_platform_register_reset (__compat, __acpihid, __reset) \ +static struct vfio_platform_reset_node __reset ## _node = { \ + .owner = THIS_MODULE, \ + .compat = __compat, \ + .acpihid = __acpihid, \ + .reset = __reset, \ +}; \ __vfio_platform_register_reset(&__reset ## _node) -#define module_vfio_reset_handler (compat, reset) \ -MODULE_ALIAS("vfio-reset:" compat); \ -static int __init reset ## _module_init(void) \ -{ \
drivers/vfio/platform/vfio_platform_private.h extern int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev, · line 116
Quoted 10 lines
drivers/vfio/platform/vfio_platform_private.h +2
-8-vfio_platform_register_reset (compat, reset); \ -return 0 ; \ -}; \ -static void __exit reset ## _module_exit(void) \ -{ \ -vfio_platform_unregister_reset (compat, reset); \ -}; \ -module_init(reset ## _module_init); \ +#define module_vfio_reset_handler (compat, acpihid, reset) \ +MODULE_ALIAS("vfio-reset:" compat); \
Here you need to handle alias for hid case I think
Best Regards
Eric
Quoted 14 lines
drivers/vfio/platform/vfio_platform_private.h +10
-0+static int __init reset ## _module_init(void) \ +{ \ +vfio_platform_register_reset (compat, acpihid, reset); \ +return 0 ; \ +}; \ +static void __exit reset ## _module_exit(void) \ +{ \ +vfio_platform_unregister_reset (compat, acpihid, reset); \ +}; \ +module_init(reset ## _module_init); \ module_exit(reset ## _module_exit)#endif /* VFIO_PLATFORM_PRIVATE_H */
Re: [PATCH V14 9/9] vfio, platform: add QTI HIDMA reset driver
In reply to Sinan KayaHi Sinan,
Quoted 71 lines · Sinan Kaya
In situations where the userspace driver is stopped abnormally and the VFIO platform device is released, the assigned HW device currently is left running. As a consequence the HW device might continue issuing IRQs and performing DMA accesses.
This patch is implementing a reset driver for HIDMA platform driver. This gets called by the VFIO platform reset interface.
Signed-off-by Sinan Kaya <[email protected]>--- drivers/vfio/platform/reset/Kconfig | 9 ++ drivers/vfio/platform/reset/Makefile | 2 + .../vfio/platform/reset/vfio_platform_qcomhidma.c | 99 ++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 drivers/vfio/platform/reset/vfio_platform_qcomhidma.cdrivers/vfio/platform/reset/Kconfig +9
-0@@ -13,3 +13,12 @@ config VFIO_PLATFORM_AMDXGBE_RESET Enables the VFIO platform driver to handle reset for AMD XGBE If you don't know what to do here, say N. + +config VFIO_PLATFORM_QCOMHIDMA_RESET + tristate "VFIO support for Qualcomm Technologies HIDMA reset" + depends on VFIO_PLATFORM + help + Enables the VFIO platform driver to handle reset for Qualcomm Technologies + HIDMA Channel. + + If you don't know what to do here, say N.drivers/vfio/platform/reset/Makefile +2
-0@@ -1,7 +1,9 @@ vfio-platform-calxedaxgmac-y := vfio_platform_calxedaxgmac.o vfio-platform-amdxgbe-y := vfio_platform_amdxgbe.o +vfio-platform-qcomhidma-y := vfio_platform_qcomhidma.o ccflags-y += -Idrivers/vfio/platform obj-$(CONFIG_VFIO_PLATFORM_CALXEDAXGMAC_RESET) += vfio-platform-calxedaxgmac.o +obj-$(CONFIG_VFIO_PLATFORM_QCOMHIDMA_RESET) += vfio-platform-qcomhidma.o obj-$(CONFIG_VFIO_PLATFORM_AMDXGBE_RESET) += vfio-platform-amdxgbe.odrivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +18
-0@@ -0,0 +1,99 @@ +/* +* Qualcomm Technologies HIDMA VFIO Reset Driver +* +* Copyright (c) 2016, The Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/init.h>
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c line 28
Quoted 10 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +10
-0+#include <linux/io.h> +#include <linux/device.h> +#include <linux/iopoll.h> + +#include "vfio_platform_private.h" + +#define TRCA_CTRLSTS_OFFSET 0x000 +#define EVCA_CTRLSTS_OFFSET 0x000 + +#define CH_CONTROL_MASK GENMASK(7, 0)
nit: alignment
Besides it looks ok to me
If it better suits you maybe you can separate the upstream of your management/channel driver from the VFIO reset driver upstream.
Best Regards
Eric
Quoted 72 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +71
-0+#define CH_STATE_MASK GENMASK(7, 0) +#define CH_STATE_BIT_POS 0x8 + +#define HIDMA_CH_STATE (val) \ + ((val >> CH_STATE_BIT_POS) & CH_STATE_MASK) + +#define EVCA_IRQ_EN_OFFSET 0x110 + +#define CH_RESET 9 +#define CH_DISABLED 0 + +int vfio_platform_qcomhidma_reset (struct vfio_platform_device *vdev) +{ +struct vfio_platform_region *trreg; +struct vfio_platform_region *evreg; +u32 val; +int ret; + +if (vdev->num_regions !=2 ) +return -ENODEV ; + + trreg = &vdev->regions[0 ]; +if (!trreg->ioaddr) { + trreg->ioaddr = +ioremap_nocache (trreg->addr, trreg->size); +if (!trreg->ioaddr) +return -ENOMEM ; + } + + evreg = &vdev->regions[1 ]; +if (!evreg->ioaddr) { + evreg->ioaddr = +ioremap_nocache (evreg->addr, evreg->size); +if (!evreg->ioaddr) +return -ENOMEM ; + } + +/* disable IRQ */ +writel (0 , evreg->ioaddr +EVCA_IRQ_EN_OFFSET ); + +/* reset both transfer and event channels */ + val =readl (trreg->ioaddr +TRCA_CTRLSTS_OFFSET ); + val &= ~(CH_CONTROL_MASK <<16 ); + val |=CH_RESET <<16 ; +writel (val, trreg->ioaddr +TRCA_CTRLSTS_OFFSET ); + + ret =readl_poll_timeout (trreg->ioaddr +TRCA_CTRLSTS_OFFSET , val, +HIDMA_CH_STATE (val) ==CH_DISABLED ,1000 , +10000 ); +if (ret) +return ret; + + val =readl (evreg->ioaddr +EVCA_CTRLSTS_OFFSET ); + val &= ~(CH_CONTROL_MASK <<16 ); + val |=CH_RESET <<16 ; +writel (val, evreg->ioaddr +EVCA_CTRLSTS_OFFSET ); + + ret =readl_poll_timeout (evreg->ioaddr +EVCA_CTRLSTS_OFFSET , val, +HIDMA_CH_STATE (val) ==CH_DISABLED ,1000 , +10000 ); +if (ret) +return ret; + +pr_info ("HIDMA channel reset\n" ); +return 0 ; +} +module_vfio_reset_handler ("qcom,hidma-1.0" ,"QCOM8061" , + vfio_platform_qcomhidma_reset); + +MODULE_LICENSE ("GPL v2" ); +MODULE_DESCRIPTION ("Reset support for Qualcomm Technologies HIDMA device" );
Re: [PATCH V14 9/9] vfio, platform: add QTI HIDMA reset driver
Quoted 85 lines · Eric Auger
Hi Sinan,
Quoted 71 lines · Sinan Kaya
In situations where the userspace driver is stopped abnormally and the VFIO platform device is released, the assigned HW device currently is left running. As a consequence the HW device might continue issuing IRQs and performing DMA accesses.
This patch is implementing a reset driver for HIDMA platform driver. This gets called by the VFIO platform reset interface.
Signed-off-by Sinan Kaya <[email protected]>--- drivers/vfio/platform/reset/Kconfig | 9 ++ drivers/vfio/platform/reset/Makefile | 2 + .../vfio/platform/reset/vfio_platform_qcomhidma.c | 99 ++++++++++++++++++++++ 3 files changed, 110 insertions(+) create mode 100644 drivers/vfio/platform/reset/vfio_platform_qcomhidma.cdrivers/vfio/platform/reset/Kconfig +9
-0@@ -13,3 +13,12 @@ config VFIO_PLATFORM_AMDXGBE_RESET Enables the VFIO platform driver to handle reset for AMD XGBE If you don't know what to do here, say N. + +config VFIO_PLATFORM_QCOMHIDMA_RESET + tristate "VFIO support for Qualcomm Technologies HIDMA reset" + depends on VFIO_PLATFORM + help + Enables the VFIO platform driver to handle reset for Qualcomm Technologies + HIDMA Channel. + + If you don't know what to do here, say N.drivers/vfio/platform/reset/Makefile +2
-0@@ -1,7 +1,9 @@ vfio-platform-calxedaxgmac-y := vfio_platform_calxedaxgmac.o vfio-platform-amdxgbe-y := vfio_platform_amdxgbe.o +vfio-platform-qcomhidma-y := vfio_platform_qcomhidma.o ccflags-y += -Idrivers/vfio/platform obj-$(CONFIG_VFIO_PLATFORM_CALXEDAXGMAC_RESET) += vfio-platform-calxedaxgmac.o +obj-$(CONFIG_VFIO_PLATFORM_QCOMHIDMA_RESET) += vfio-platform-qcomhidma.o obj-$(CONFIG_VFIO_PLATFORM_AMDXGBE_RESET) += vfio-platform-amdxgbe.odrivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +18
-0@@ -0,0 +1,99 @@ +/* +* Qualcomm Technologies HIDMA VFIO Reset Driver +* +* Copyright (c) 2016, The Linux Foundation. All rights reserved. +* +* This program is free software; you can redistribute it and/or modify +* it under the terms of the GNU General Public License version 2 and +* only version 2 as published by the Free Software Foundation. +* +* This program is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +* GNU General Public License for more details. +*/ + +#include <linux/module.h> +#include <linux/kernel.h> +#include <linux/init.h> drivers/vfio/platform/reset/vfio_platform_qcomhidma.c line 28
Quoted 10 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +10
-0+#include <linux/io.h> +#include <linux/device.h> +#include <linux/iopoll.h> + +#include "vfio_platform_private.h" + +#define TRCA_CTRLSTS_OFFSET 0x000 +#define EVCA_CTRLSTS_OFFSET 0x000 + +#define CH_CONTROL_MASK GENMASK(7, 0)nit: alignment
Quoted 5 lines
Besides it looks ok to me
Reviewed-by Eric Auger <[email protected]>If it better suits you maybe you can separate the upstream of your management/channel driver from the VFIO reset driver upstream.
Thanks, I wanted to keep things together. There were some review concerns to whether I'm doing the right thing when it comes to virtualization.
Patches 8 & 9 definitely needs to go in through another merge branch.
Quoted 78 lines
Best Regards
Eric
Quoted 72 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +71
-0+#define CH_STATE_MASK GENMASK(7, 0) +#define CH_STATE_BIT_POS 0x8 + +#define HIDMA_CH_STATE (val) \ + ((val >> CH_STATE_BIT_POS) & CH_STATE_MASK) + +#define EVCA_IRQ_EN_OFFSET 0x110 + +#define CH_RESET 9 +#define CH_DISABLED 0 + +int vfio_platform_qcomhidma_reset (struct vfio_platform_device *vdev) +{ +struct vfio_platform_region *trreg; +struct vfio_platform_region *evreg; +u32 val; +int ret; + +if (vdev->num_regions !=2 ) +return -ENODEV ; + + trreg = &vdev->regions[0 ]; +if (!trreg->ioaddr) { + trreg->ioaddr = +ioremap_nocache (trreg->addr, trreg->size); +if (!trreg->ioaddr) +return -ENOMEM ; + } + + evreg = &vdev->regions[1 ]; +if (!evreg->ioaddr) { + evreg->ioaddr = +ioremap_nocache (evreg->addr, evreg->size); +if (!evreg->ioaddr) +return -ENOMEM ; + } + +/* disable IRQ */ +writel (0 , evreg->ioaddr +EVCA_IRQ_EN_OFFSET ); + +/* reset both transfer and event channels */ + val =readl (trreg->ioaddr +TRCA_CTRLSTS_OFFSET ); + val &= ~(CH_CONTROL_MASK <<16 ); + val |=CH_RESET <<16 ; +writel (val, trreg->ioaddr +TRCA_CTRLSTS_OFFSET ); + + ret =readl_poll_timeout (trreg->ioaddr +TRCA_CTRLSTS_OFFSET , val, +HIDMA_CH_STATE (val) ==CH_DISABLED ,1000 , +10000 ); +if (ret) +return ret; + + val =readl (evreg->ioaddr +EVCA_CTRLSTS_OFFSET ); + val &= ~(CH_CONTROL_MASK <<16 ); + val |=CH_RESET <<16 ; +writel (val, evreg->ioaddr +EVCA_CTRLSTS_OFFSET ); + + ret =readl_poll_timeout (evreg->ioaddr +EVCA_CTRLSTS_OFFSET , val, +HIDMA_CH_STATE (val) ==CH_DISABLED ,1000 , +10000 ); +if (ret) +return ret; + +pr_info ("HIDMA channel reset\n" ); +return 0 ; +} +module_vfio_reset_handler ("qcom,hidma-1.0" ,"QCOM8061" , + vfio_platform_qcomhidma_reset); + +MODULE_LICENSE ("GPL v2" ); +MODULE_DESCRIPTION ("Reset support for Qualcomm Technologies HIDMA device" );
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
Re: [PATCH V14 8/9] vfio, platform: add support for ACPI while detecting the reset driver
In reply to Eric AugerQuoted 10 lines
drivers/vfio/platform/vfio_platform_common.c static const struct vfio_device_ops vfio_platform_ops = { · line 561
Quoted 9 lines
drivers/vfio/platform/vfio_platform_common.c +8
-0+#ifdef CONFIG_ACPI +int vfio_platform_probe_acpi (struct vfio_platform_device *vdev, +struct device *dev) +{ +struct acpi_device *adev =ACPI_COMPANION (dev); + +if (!adev) +return -EINVAL ;
-ENODEVseems to be commonly used in that case
ok
Quoted 8 lines
drivers/vfio/platform/vfio_platform_common.c static const struct vfio_device_ops vfio_platform_ops = { · line 564
Quoted 3 lines
drivers/vfio/platform/vfio_platform_common.c +3
-0+ + vdev->acpihid =acpi_device_hid (adev); +if (!vdev->acpihid) {can it return NULL? Seems to return dummy "device" or actual hid
drivers/vfio/platform/vfio_platform_common.c static const struct vfio_device_ops vfio_platform_ops = { · line 567
Quoted 3 lines
drivers/vfio/platform/vfio_platform_common.c +3
-0+pr_err ("VFIO: cannot find ACPI HID for %s\n" , + vdev->name); +return -EINVAL ;
-ENODEVtoo?
sure
Quoted 15 lines
Quoted 15 lines
drivers/vfio/platform/vfio_platform_common.c +15
-0+ } +return 0 ; +} +#else +int vfio_platform_probe_acpi (struct vfio_platform_device *vdev, +struct device *dev) +{ +return -EINVAL ; +} +#endif + +int vfio_platform_probe_of (struct vfio_platform_device *vdev, +struct device *dev) +{ +int ret;
Quoted 8 lines
drivers/vfio/platform/vfio_platform_common.c static const struct vfio_device_ops vfio_platform_ops = { · line 589
Quoted 7 lines
drivers/vfio/platform/vfio_platform_common.c +7
-0+ + ret =device_property_read_string (dev,"compatible" , + &vdev->compat); +if (ret) { +pr_err ("VFIO: cannot retrieve compat for %s\n" , + vdev->name); +return -EINVAL ;return ret instead.
ok
Quoted 59 lines
Quoted 41 lines
drivers/vfio/platform/vfio_platform_common.c +12
-7+ } +return 0 ; +} +int vfio_platform_probe_common (struct vfio_platform_device *vdev,struct device *dev) {@@ -550,14 +600,14 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,if (!vdev)return -EINVAL ; - ret =device_property_read_string (dev,"compatible" , &vdev->compat); -if (ret) { -pr_err ("VFIO: cannot retrieve compat for %s\n" , vdev->name); -return -EINVAL ; - } + ret =vfio_platform_probe_acpi (vdev, dev); +if (ret) + ret =vfio_platform_probe_of (vdev, dev); - vdev->device = dev; +if (ret) +return ret; + vdev->device = dev; group =iommu_group_get (dev);if (!group) {pr_err ("VFIO: No IOMMU group for device %s\n" , vdev->name);@@ -602,13 +652,21 @@ void __vfio_platform_register_reset(struct vfio_platform_reset_node *node)EXPORT_SYMBOL_GPL (__vfio_platform_register_reset);void vfio_platform_unregister_reset (const char *compat, +const char *acpihid,vfio_platform_reset_fn_t fn) {struct vfio_platform_reset_node *iter, *temp;mutex_lock (&driver_lock);list_for_each_entry_safe (iter, temp, &reset_list, link) { -if (!strcmp (iter->compat, compat) && (iter->reset == fn)) { + if (acpihid && iter->acpihid &&drivers/vfio/platform/vfio_platform_common.c void __vfio_platform_register_reset(struct vfio_platform_reset_node *node) · line 672
Quoted 10 lines
drivers/vfio/platform/vfio_platform_common.c +7
-0+ !strcmp(iter->acpihid, acpihid) && (iter->reset == fn)) { +list_del (&iter->link); +break ; + } + +if (compat && iter->compat && + !strcmp (iter->compat, compat) && (iter->reset == fn)) {list_del (&iter->link);break ; }in
vfio_platform_get_reset, if the 1stvfio_platform_lookup_resetcall does not return anything then we currently callrequest_module("vfio-reset:%s", vdev->compat);you need to handle the case where compat is not set but
vdev->acpihidis, instead.
Quoted 9 lines
currently the module alias is constructed with the compat only
MODULE_ALIAS("vfio-reset:" compat);Looks you can define several ones ( for instance in
drivers/block/xen-blkfront.c).If I am not wrong this currently would not work with vfio-platform-qcomhidma compiled as a module.
Good point. I happen to have both defined as the driver support both ACPI and device-tree. That's why, I have never seen the problem during testing.
Quoted 17 lines
Quoted 5 lines
drivers/vfio/platform/vfio_platform_private.h +0
-4-#define module_vfio_reset_handler (compat, reset) \ -MODULE_ALIAS("vfio-reset:" compat); \ -static int __init reset ## _module_init(void) \ -{ \drivers/vfio/platform/vfio_platform_private.h extern int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev, · line 116
Quoted 10 lines
drivers/vfio/platform/vfio_platform_private.h +2
-8-vfio_platform_register_reset (compat, reset); \ -return 0 ; \ -}; \ -static void __exit reset ## _module_exit(void) \ -{ \ -vfio_platform_unregister_reset (compat, reset); \ -}; \ -module_init(reset ## _module_init); \ +#define module_vfio_reset_handler (compat, acpihid, reset) \ +MODULE_ALIAS("vfio-reset:" compat); \Here you need to handle alias for hid case I think
I'll add this and test different combinations where compat and acpihid are null.
#define module_vfio_reset_handler(compat, acpihid, reset) \MODULE_ALIAS("vfio-reset:" compat); \MODULE_ALIAS("vfio-reset:" acpihid); \
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
Re: [PATCH V14 8/9] vfio, platform: add support for ACPI while detecting the reset driver
In reply to Eric AugerQuoted 4 lines · Eric Auger
Quoted 3 lines
-module_init(reset ##
_module_init); \drivers/vfio/platform/vfio_platform_private.h extern int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev, · line 116
Quoted 2 lines
drivers/vfio/platform/vfio_platform_private.h +2
-0+#define module_vfio_reset_handler (compat, acpihid, reset) \ +MODULE_ALIAS("vfio-reset:" compat); \Here you need to handle alias for hid case I think
I'm wondering what happens when Compat or ACPI string is NULL.
MODULE_ALIAS("vfio-reset:" NULL)
Would the kernel like it?
I'd rather create an alias only when the string is not NULL. Given this is a macro, I believe it won't work.
Can you think of any other way in the code to create the alias?
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
Quoted 6 lines · Timur Tabi
Quoted 3 lines · Sinan Kaya
Hi Marc Zyngier, Mark Rutland;
I'm looking forward to hear your feedback on this series.
Would it be possible to get this patchset into 4.6? We're already at v14, and there have been no review comments since this patch was posted on the fourth (over three weeks ago).
Vinod?
I have my DT ACK from Rob Herring as you initially asked. I responded to Mark Rutland and Marc Zyngier's comments by improving the cover letter and adding IOMMU binding.
I pinged both Mark and Marc twice with no response.
I don't know what else it takes besides waiting.
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
Quoted 10 lines · Sinan Kaya
Quoted 6 lines · Timur Tabi
Quoted 3 lines · Sinan Kaya
Hi Marc Zyngier, Mark Rutland;
I'm looking forward to hear your feedback on this series.
Would it be possible to get this patchset into 4.6? We're already at v14, and there have been no review comments since this patch was posted on the fourth (over three weeks ago).
Vinod?
Quoted 7 lines
I have my DT ACK from Rob Herring as you initially asked. I responded to Mark Rutland and Marc Zyngier's comments by improving the cover letter and adding IOMMU binding.
I pinged both Mark and Marc twice with no response.
I don't know what else it takes besides waiting.
I did check first couple of patches last week, things seemed fine to me. I will do details review in next couple of days and decide.
At least I will merge dmaengine patches for this cycle if all is good.
Signature · 1 line
~Vinod
Quoted 15 lines · Vinod Koul
Quoted 14 lines · Sinan Kaya
Quoted 6 lines · Timur Tabi
Quoted 3 lines · Sinan Kaya
Hi Marc Zyngier, Mark Rutland;
I'm looking forward to hear your feedback on this series.
Would it be possible to get this patchset into 4.6? We're already at v14, and there have been no review comments since this patch was posted on the fourth (over three weeks ago).
Vinod?
I have my DT ACK from Rob Herring as you initially asked. I responded to Mark Rutland and Marc Zyngier's comments by improving the cover letter and adding IOMMU binding.
Quoted 9 lines
Quoted 3 lines
I pinged both Mark and Marc twice with no response.
I don't know what else it takes besides waiting.
I did check first couple of patches last week, things seemed fine to me. I will do details review in next couple of days and decide.
At least I will merge dmaengine patches for this cycle if all is good.
Thanks, let me know if you have questions. The VFIO patches (8/9) need to be submitted separately anyhow. I have some follow up work on them too.
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
Re: [PATCH V14 8/9] vfio, platform: add support for ACPI while detecting the reset driver
In reply to Sinan KayaHi Sinan,
Quoted 8 lines · Sinan Kaya
Quoted 4 lines · Eric Auger
Quoted 3 lines
-module_init(reset ##
_module_init); \drivers/vfio/platform/vfio_platform_private.h extern int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev, · line 116
Quoted 2 lines
drivers/vfio/platform/vfio_platform_private.h +2
-0+#define module_vfio_reset_handler (compat, acpihid, reset) \ +MODULE_ALIAS("vfio-reset:" compat); \Here you need to handle alias for hid case I think
I'm wondering what happens when Compat or ACPI string is NULL.
Quoted 7 lines
MODULE_ALIAS("vfio-reset:" NULL)Would the kernel like it?
I'd rather create an alias only when the string is not NULL. Given this is a macro, I believe it won't work.
Indeed I think we should create an alias only for the supported case or 2 aliases if both are supported.
Quoted 3 lines
Can you think of any other way in the code to create the alias?
To be honest I did not find any elegant solution either. Personally I would move the MODULE_ALIAS for compat/acpihid outside of module_vfio_reset_handler macro, directly in the reset module. But maybe someone will propose a better solution?
Best Regards
Eric
Re: [PATCH V14 8/9] vfio, platform: add support for ACPI while detecting the reset driver
Quoted 21 lines · Eric Auger
Hi Sinan,
Quoted 8 lines · Sinan Kaya
Quoted 4 lines · Eric Auger
Quoted 3 lines
-module_init(reset ##
_module_init); \drivers/vfio/platform/vfio_platform_private.h extern int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev, · line 116
Quoted 2 lines
drivers/vfio/platform/vfio_platform_private.h +2
-0+#define module_vfio_reset_handler (compat, acpihid, reset) \ +MODULE_ALIAS("vfio-reset:" compat); \Here you need to handle alias for hid case I think
I'm wondering what happens when Compat or ACPI string is NULL.
Quoted 7 lines
MODULE_ALIAS("vfio-reset:" NULL)Would the kernel like it?
I'd rather create an alias only when the string is not NULL. Given this is a macro, I believe it won't work.
Indeed I think we should create an alias only for the supported case or 2 aliases if both are supported.
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
Can you think of any other way in the code to create the alias?
To be honest I did not find any elegant solution either. Personally I would move the
MODULE_ALIASfor compat/acpihid outside ofmodule_vfio_reset_handlermacro, directly in the reset module. But maybe someone will propose a better solution?
I briefly looked at this.
#define MODULE_ALIAS(_alias) MODULE_INFO(alias, _alias) #define MODULE_INFO(tag, info) __MODULE_INFO(tag, tag, info)
and it eventually becomes this
#define __MODULE_INFO(tag, name, info) \
static const char __UNIQUE_ID(name)[] \
__used __attribute__((section(".modinfo"), unused, aligned(1))) \
= __stringify(tag) "=" info
Since the info is on the right side of the equation, I'm allowed to add some conditionals.
#define module_vfio_reset_handler(compat, acpihid, reset) \MODULE_ALIAS("vfio-reset:" acpihid? acpihid: compat); \
This way, we'll create an alias with one of the provided strings.
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
Re: [PATCH V14 8/9] vfio, platform: add support for ACPI while detecting the reset driver
Hi Sinan,
Quoted 42 lines · Sinan Kaya
Quoted 21 lines · Eric Auger
Hi Sinan,
Quoted 8 lines · Sinan Kaya
Quoted 4 lines · Eric Auger
Quoted 3 lines
-module_init(reset ##
_module_init); \drivers/vfio/platform/vfio_platform_private.h extern int vfio_platform_set_irqs_ioctl(struct vfio_platform_device *vdev, · line 116
Quoted 2 lines
drivers/vfio/platform/vfio_platform_private.h +2
-0+#define module_vfio_reset_handler (compat, acpihid, reset) \ +MODULE_ALIAS("vfio-reset:" compat); \Here you need to handle alias for hid case I think
I'm wondering what happens when Compat or ACPI string is NULL.
Quoted 7 lines
MODULE_ALIAS("vfio-reset:" NULL)Would the kernel like it?
I'd rather create an alias only when the string is not NULL. Given this is a macro, I believe it won't work.
Indeed I think we should create an alias only for the supported case or 2 aliases if both are supported.
Quoted 1 line
Quoted 7 lines
Quoted 2 lines
Can you think of any other way in the code to create the alias?
To be honest I did not find any elegant solution either. Personally I would move the
MODULE_ALIASfor compat/acpihid outside ofmodule_vfio_reset_handlermacro, directly in the reset module. But maybe someone will propose a better solution?I briefly looked at this.
#define
MODULE_ALIAS(_alias)MODULE_INFO(alias, _alias)#defineMODULE_INFO(tag, info)__MODULE_INFO(tag, tag, info)and it eventually becomes this
#define
__MODULE_INFO(tag, name, info)\static const char __UNIQUE_ID(name)[] \ __used __attribute__((section(".modinfo"), unused, aligned(1))) \ = __stringify(tag) "=" info
Quoted 7 lines
Since the info is on the right side of the equation, I'm allowed to add some conditionals.
#define
module_vfio_reset_handler(compat, acpihid, reset)\MODULE_ALIAS("vfio-reset:" acpihid? acpihid: compat); \This way, we'll create an alias with one of the provided strings.
What if you want to use vfio platform driver for HiDMA in dt mode? the HiDma reset module advertises both acpihid and dt compat support but an alias module will be created only for acpihid. Then I think we will not be able to load the reset module in dt mode with existing code.
This could work however with some rework in vfio_platform_common.c. In vfio_platform_get_reset we should try to load the module using the acpihid if the module load using compat alias fails. In the look-up table we can find the acpihid corresponding to the dt compat.
Any thought?
Best Regards
Eric
Quoted 3 lines
Re: [PATCH V14 8/9] vfio, platform: add support for ACPI while detecting the reset driver
Quoted 9 lines · Eric Auger
Quoted 4 lines
#define
module_vfio_reset_handler(compat, acpihid, reset)\Quoted 3 lines
MODULE_ALIAS("vfio-reset:" acpihid? acpihid: compat); \This way, we'll create an alias with one of the provided strings.
What if you want to use vfio platform driver for HiDMA in dt mode? the HiDma reset module advertises both acpihid and dt compat support but an alias module will be created only for acpihid. Then I think we will not be able to load the reset module in dt mode with existing code.
Right, it won't work. Now that we know what MODULE_ALIAS does, there is no harm in doing this. I think we should do this.
#define module_vfio_reset_handler(compat, acpihid, reset) \
MODULE_ALIAS("vfio-reset:" compat); \
MODULE_ALIAS("vfio-reset:" acpihid); \If we prefer ACPI over DT, there is no guarantee that somebody can boot DT kernel with ACPI kernel compilation option enabled.
If one of these are null, then the module alias will be "vfio-reset:"
Of course to make things prettier, we could use "NOT SUPPORTED" as a string instead of NULL. then, the module alias will be vfio-reset: NOT SUPPORTED".
We could go one step further, and do.
#define module_vfio_reset_handler(compat, acpihid, reset) \MODULE_ALIAS("vfio-reset: dt: " compat); \MODULE_ALIAS("vfio-reset: acpi: " acpihid); \
and change the code below for this too.
Quoted 4 lines
This could work however with some rework in
vfio_platform_common.c. Invfio_platform_get_resetwe should try to load the module using the acpihid if the module load using compat alias fails. In the look-up table we can find the acpihid corresponding to the dt compat.
I was planning to submit this for the next review. Still, I don't want to assume that acpihid is the only working option. Somebody can boot DT kernel.
drivers/vfio/platform/vfio_platform_common.c +26 -8
@@ -58,16 +58,30 @@ static vfio_platform_reset_fn_t vfio_platform_lookup_reset(const char *compat,return reset_fn; } -static void vfio_platform_get_reset (struct vfio_platform_device *vdev) +static int vfio_platform_get_reset (struct vfio_platform_device *vdev) { +int rc; + vdev->reset =vfio_platform_lookup_reset (vdev->compat, vdev->acpihid, &vdev->reset_module); -if (!vdev->reset) { -request_module ("vfio-reset:%s" , vdev->compat); - vdev->reset =vfio_platform_lookup_reset (vdev->compat, - vdev->acpihid, - &vdev->reset_module); - } +if (vdev->reset) +return 0 ; + +if (vdev->acpihid) + rc =request_module ("vfio-reset:%s" , vdev->acpihid); + +if (rc && vdev->compat) + rc =request_module ("vfio-reset:%s" , vdev->compat); + +if (rc) +return rc; + + vdev->reset =vfio_platform_lookup_reset (vdev->compat, vdev->acpihid, + &vdev->reset_module); +if (vdev->reset) +return 0 ; + +return -ENODEV ; }static void vfio_platform_put_reset (struct vfio_platform_device *vdev)
@@ -620,7 +634,11 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,return ret; } -vfio_platform_get_reset (vdev); + ret =vfio_platform_get_reset (vdev); +if (ret) { +iommu_group_put (group); +return ret; + }mutex_init (&vdev->igate);
Let me know what you think.
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
Re: [PATCH V14 8/9] vfio, platform: add support for ACPI while detecting the reset driver
Hi Sinan,
Quoted 23 lines · Sinan Kaya
Quoted 9 lines · Eric Auger
Quoted 4 lines
#define
module_vfio_reset_handler(compat, acpihid, reset)\Quoted 3 lines
MODULE_ALIAS("vfio-reset:" acpihid? acpihid: compat); \This way, we'll create an alias with one of the provided strings.
What if you want to use vfio platform driver for HiDMA in dt mode? the HiDma reset module advertises both acpihid and dt compat support but an alias module will be created only for acpihid. Then I think we will not be able to load the reset module in dt mode with existing code.
Right, it won't work. Now that we know what
MODULE_ALIASdoes, there is no harm in doing this. I think we should do this.#define module_vfio_reset_handler(compat, acpihid, reset) \ MODULE_ALIAS("vfio-reset:" compat); \ MODULE_ALIAS("vfio-reset:" acpihid); \If we prefer ACPI over DT, there is no guarantee that somebody can boot DT kernel with ACPI kernel compilation option enabled.
If one of these are null, then the module alias will be "vfio-reset:"
Quoted 8 lines
Of course to make things prettier, we could use "NOT SUPPORTED" as a string instead of NULL. then, the module alias will be vfio-reset: NOT SUPPORTED".
We could go one step further, and do.
#define
module_vfio_reset_handler(compat, acpihid, reset)\MODULE_ALIAS("vfio-reset: dt: " compat); \MODULE_ALIAS("vfio-reset: acpi: " acpihid); \
My gut feeling is we must not create a dummy alias when the mode (dt/acpi) is not supported/tested. It fills the modinfo section with spurious data, aliases are visible to modinfo, ...
So I personally foresee 2 solutions,
1) we create a single alias using acpihid if supported or compat if not. Then even in dt mode we try to load this module through the acpihid alias. Looks weird but should work.
2) We simply move the module alias declaration out of this macro (to the reset module itself), define 2 aliases in case both dt and acpi are supported & tested.
My personal preference is 2 I think.
Best Regards
Eric
Quoted 71 lines
and change the code below for this too.
Quoted 4 lines
This could work however with some rework in
vfio_platform_common.c. Invfio_platform_get_resetwe should try to load the module using the acpihid if the module load using compat alias fails. In the look-up table we can find the acpihid corresponding to the dt compat.I was planning to submit this for the next review. Still, I don't want to assume that acpihid is the only working option. Somebody can boot DT kernel.
drivers/vfio/platform/vfio_platform_common.c +26
-8@@ -58,16 +58,30 @@ static vfio_platform_reset_fn_t vfio_platform_lookup_reset(const char *compat,return reset_fn; } -static void vfio_platform_get_reset (struct vfio_platform_device *vdev) +static int vfio_platform_get_reset (struct vfio_platform_device *vdev) { +int rc; + vdev->reset =vfio_platform_lookup_reset (vdev->compat, vdev->acpihid, &vdev->reset_module); -if (!vdev->reset) { -request_module ("vfio-reset:%s" , vdev->compat); - vdev->reset =vfio_platform_lookup_reset (vdev->compat, - vdev->acpihid, - &vdev->reset_module); - } +if (vdev->reset) +return 0 ; + +if (vdev->acpihid) + rc =request_module ("vfio-reset:%s" , vdev->acpihid); + +if (rc && vdev->compat) + rc =request_module ("vfio-reset:%s" , vdev->compat); + +if (rc) +return rc; + + vdev->reset =vfio_platform_lookup_reset (vdev->compat, vdev->acpihid, + &vdev->reset_module); +if (vdev->reset) +return 0 ; + +return -ENODEV ; }static void vfio_platform_put_reset (struct vfio_platform_device *vdev)@@ -620,7 +634,11 @@ int vfio_platform_probe_common(struct vfio_platform_device *vdev,return ret; } -vfio_platform_get_reset (vdev); + ret =vfio_platform_get_reset (vdev); +if (ret) { +iommu_group_put (group); +return ret; + }mutex_init (&vdev->igate);Let me know what you think.
Re: [PATCH V14 8/9] vfio, platform: add support for ACPI while detecting the reset driver
Quoted 15 lines · Eric Auger
Quoted 3 lines
#define
module_vfio_reset_handler(compat, acpihid, reset)\Quoted 2 lines
MODULE_ALIAS("vfio-reset: dt: " compat); \MODULE_ALIAS("vfio-reset: acpi: " acpihid); \My gut feeling is we must not create a dummy alias when the mode (dt/acpi) is not supported/tested. It fills the modinfo section with spurious data, aliases are visible to modinfo, ...
So I personally foresee 2 solutions,
1) we create a single alias using acpihid if supported or compat if not. Then even in dt mode we try to load this module through the acpihid alias. Looks weird but should work.
2) We simply move the module alias declaration out of this macro (to the reset module itself), define 2 aliases in case both dt and acpi are supported & tested.
Quoted 6 lines
My personal preference is 2 I think.
Best Regards
Eric
I agree with your assessment of #2. We are trying to be too smart. I'll post a patch with #2 solution.
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
Re: [PATCH V14 8/9] vfio, platform: add support for ACPI while detecting the reset driver
Hi,
Quoted 18 lines · Sinan Kaya
Quoted 17 lines · Eric Auger
Quoted 3 lines
#define
module_vfio_reset_handler(compat, acpihid, reset)\Quoted 2 lines
MODULE_ALIAS("vfio-reset: dt: " compat); \MODULE_ALIAS("vfio-reset: acpi: " acpihid); \My gut feeling is we must not create a dummy alias when the mode (dt/acpi) is not supported/tested. It fills the modinfo section with spurious data, aliases are visible to modinfo, ...
So I personally foresee 2 solutions,
1) we create a single alias using acpihid if supported or compat if not. Then even in dt mode we try to load this module through the acpihid alias. Looks weird but should work.
2) We simply move the module alias declaration out of this macro (to the reset module itself), define 2 aliases in case both dt and acpi are supported & tested.My personal preference is 2 I think.
Quoted 8 lines
Quoted 4 lines
Best Regards
Eric
I agree with your assessment of #2. We are trying to be too smart. I'll post a patch with #2 solution.
I split patch 8 and 9 from the series and posted a new set here.
http://www.spinics.net/lists/arm-kernel/msg489578.html
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
Re: [PATCH V14 5/9] dma: qcom_hidma: implement lower level hardware interface
In reply to Sinan KayaQuoted 24 lines · Sinan Kaya
drivers/dma/qcom/hidma_ll.c new file +24
-0+ +#define EVRE_SIZE 16/* each EVRE is 16 bytes */ + +#define TRCA_CTRLSTS_OFFSET 0x000 +#define TRCA_RING_LOW_OFFSET 0x008 +#define TRCA_RING_HIGH_OFFSET 0x00C +#define TRCA_RING_LEN_OFFSET 0x010 +#define TRCA_READ_PTR_OFFSET 0x018 +#define TRCA_WRITE_PTR_OFFSET 0x020 +#define TRCA_DOORBELL_OFFSET 0x400 + +#define EVCA_CTRLSTS_OFFSET 0x000 +#define EVCA_INTCTRL_OFFSET 0x004 +#define EVCA_RING_LOW_OFFSET 0x008 +#define EVCA_RING_HIGH_OFFSET 0x00C +#define EVCA_RING_LEN_OFFSET 0x010 +#define EVCA_READ_PTR_OFFSET 0x018 +#define EVCA_WRITE_PTR_OFFSET 0x020 +#define EVCA_DOORBELL_OFFSET 0x400 + +#define EVCA_IRQ_STAT_OFFSET 0x100 +#define EVCA_IRQ_CLR_OFFSET 0x108 +#define EVCA_IRQ_EN_OFFSET 0x110 +
drivers/dma/qcom/hidma_ll.c line 62
Quoted 10 lines
drivers/dma/qcom/hidma_ll.c new file +10
-0+#define EVRE_CFG_IDX 0 +#define EVRE_LEN_IDX 1 +#define EVRE_DEST_LOW_IDX 2 +#define EVRE_DEST_HI_IDX 3 + +#define EVRE_ERRINFO_BIT_POS 24 +#define EVRE_CODE_BIT_POS 28 + +#define EVRE_ERRINFO_MASK GENMASK(3, 0) +#define EVRE_CODE_MASK GENMASK(3, 0)
These are rest here are not namespace properly...
Quoted 18 lines
drivers/dma/qcom/hidma_ll.c new file +18
-0+static int hidma_ll_enable (struct hidma_lldev *lldev) +{ +u32 val; +int ret; + + val =readl (lldev->evca +EVCA_CTRLSTS_OFFSET ); + val &= ~(CH_CONTROL_MASK <<16 ); + val |=CH_ENABLE <<16 ; +writel (val, lldev->evca +EVCA_CTRLSTS_OFFSET ); + + ret =readl_poll_timeout (lldev->evca +EVCA_CTRLSTS_OFFSET , val, + (HIDMA_CH_STATE (val) ==CH_ENABLED ) || + (HIDMA_CH_STATE (val) ==CH_RUNNING ),1000 , +10000 ); +if (ret) { +dev_err (lldev->dev,"event channel did not get enabled\n" ); +return ret; + }
drivers/dma/qcom/hidma_ll.c line 542
Quoted 10 lines
drivers/dma/qcom/hidma_ll.c new file +10
-0+ + val =readl (lldev->trca +TRCA_CTRLSTS_OFFSET ); + val &= ~(CH_CONTROL_MASK <<16 ); + val |=CH_ENABLE <<16 ; +writel (val, lldev->trca +TRCA_CTRLSTS_OFFSET ); + + ret =readl_poll_timeout (lldev->trca +TRCA_CTRLSTS_OFFSET , val, + (HIDMA_CH_STATE (val) ==CH_ENABLED ) || + (HIDMA_CH_STATE (val) ==CH_RUNNING ),1000 , +10000 );
first arg for readl_poll_timeout is accessor fn to do read, which doesnt seem to be here... so what did i miss?
Quoted 9 lines
drivers/dma/qcom/hidma_ll.c new file +9
-0+void hidma_ll_queue_request (struct hidma_lldev *lldev,u32 tre_ch) +{ +struct hidma_tre *tre; +unsigned long flags; + + tre = &lldev->trepool[tre_ch]; + +/* copy the TRE into its location in the TRE ring */ +spin_lock_irqsave (&lldev->lock, flags);
drivers/dma/qcom/hidma_ll.c line 605
Quoted 10 lines
drivers/dma/qcom/hidma_ll.c new file +10
-0+ tre->tre_index = lldev->tre_write_offset /TRE_SIZE ; + lldev->pending_tre_list[tre->tre_index] = tre; +memcpy (lldev->tre_ring + lldev->tre_write_offset, &tre->tre_local[0 ], +TRE_SIZE ); + lldev->tx_status_list[tre->idx].err_code =0 ; + lldev->tx_status_list[tre->idx].err_info =0 ; + tre->queued =1 ; + lldev->pending_tre_count++; + lldev->tre_write_offset = (lldev->tre_write_offset +TRE_SIZE ) + % lldev->tre_ring_size;
These and above one should be right justfied per coding style
Signature · 1 line
~Vinod
Re: [PATCH V14 1/9] dma: qcom_bam_dma: move to qcom directory
In reply to Sinan KayaQuoted 1 line · Sinan Kaya
Creating a QCOM directory for all QCOM DMA source files.
Applied after fixing subsystem name
Signature · 1 line
~Vinod
Re: [PATCH V14 2/9] dma: hidma: Add Device Tree binding
In reply to Sinan KayaQuoted 1 line · Sinan Kaya
Add documentation for the Qualcomm Technologies HIDMA binding.
Applied after fixing subsystem name
Signature · 1 line
~Vinod
Re: [PATCH V14 3/9] dma: add Qualcomm Technologies HIDMA management driver
In reply to Sinan KayaQuoted 3 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.
Applied after fixing subsystem name
Signature · 1 line
~Vinod
Re: [PATCH V14 4/9] dma: add Qualcomm Technologies HIDMA channel driver
In reply to Sinan KayaQuoted 4 lines · 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.
Applied after fixing subsystem name
Signature · 1 line
~Vinod
Re: [PATCH V14 5/9] dma: qcom_hidma: implement lower level hardware interface
In reply to Vinod KoulQuoted 62 lines · Sinan Kaya
Quoted 25 lines
drivers/dma/qcom/hidma_ll.c new file +24
-0+ +#define EVRE_SIZE 16/* each EVRE is 16 bytes */ + +#define TRCA_CTRLSTS_OFFSET 0x000 +#define TRCA_RING_LOW_OFFSET 0x008 +#define TRCA_RING_HIGH_OFFSET 0x00C +#define TRCA_RING_LEN_OFFSET 0x010 +#define TRCA_READ_PTR_OFFSET 0x018 +#define TRCA_WRITE_PTR_OFFSET 0x020 +#define TRCA_DOORBELL_OFFSET 0x400 + +#define EVCA_CTRLSTS_OFFSET 0x000 +#define EVCA_INTCTRL_OFFSET 0x004 +#define EVCA_RING_LOW_OFFSET 0x008 +#define EVCA_RING_HIGH_OFFSET 0x00C +#define EVCA_RING_LEN_OFFSET 0x010 +#define EVCA_READ_PTR_OFFSET 0x018 +#define EVCA_WRITE_PTR_OFFSET 0x020 +#define EVCA_DOORBELL_OFFSET 0x400 + +#define EVCA_IRQ_STAT_OFFSET 0x100 +#define EVCA_IRQ_CLR_OFFSET 0x108 +#define EVCA_IRQ_EN_OFFSET 0x110 +drivers/dma/qcom/hidma_ll.c line 62
Quoted 10 lines
drivers/dma/qcom/hidma_ll.c new file +10
-0+#define EVRE_CFG_IDX 0 +#define EVRE_LEN_IDX 1 +#define EVRE_DEST_LOW_IDX 2 +#define EVRE_DEST_HI_IDX 3 + +#define EVRE_ERRINFO_BIT_POS 24 +#define EVRE_CODE_BIT_POS 28 + +#define EVRE_ERRINFO_MASK GENMASK(3, 0) +#define EVRE_CODE_MASK GENMASK(3, 0)These are rest here are not namespace properly...
Quoted 23 lines
drivers/dma/qcom/hidma_ll.c new file +23
-0+static int hidma_ll_enable (struct hidma_lldev *lldev) +{ +u32 val; +int ret; + + val =readl (lldev->evca +EVCA_CTRLSTS_OFFSET ); + val &= ~(CH_CONTROL_MASK <<16 ); + val |=CH_ENABLE <<16 ; +writel (val, lldev->evca +EVCA_CTRLSTS_OFFSET ); + + ret =readl_poll_timeout (lldev->evca +EVCA_CTRLSTS_OFFSET , val, + (HIDMA_CH_STATE (val) ==CH_ENABLED ) || + (HIDMA_CH_STATE (val) ==CH_RUNNING ),1000 , +10000 ); +if (ret) { +dev_err (lldev->dev,"event channel did not get enabled\n" ); +return ret; + } + + val =readl (lldev->trca +TRCA_CTRLSTS_OFFSET ); + val &= ~(CH_CONTROL_MASK <<16 ); + val |=CH_ENABLE <<16 ; +writel (val, lldev->trca +TRCA_CTRLSTS_OFFSET );
Quoted 9 lines
drivers/dma/qcom/hidma_ll.c line 542
Quoted 5 lines
drivers/dma/qcom/hidma_ll.c new file +5
-0+ + ret =readl_poll_timeout (lldev->trca +TRCA_CTRLSTS_OFFSET , val, + (HIDMA_CH_STATE (val) ==CH_ENABLED ) || + (HIDMA_CH_STATE (val) ==CH_RUNNING ),1000 , +10000 );first arg for
readl_poll_timeoutis accessor fn to do read, which doesnt seem to be here... so what did i miss?
First argument is the address to read.
#define readl_poll_timeout(addr, val, cond, delay_us, timeout_us) \
readx_poll_timeout(readl, addr, val, cond, delay_us, timeout_us)
Quoted 26 lines
Quoted 10 lines
drivers/dma/qcom/hidma_ll.c new file +9
-0+void hidma_ll_queue_request (struct hidma_lldev *lldev,u32 tre_ch) +{ +struct hidma_tre *tre; +unsigned long flags; + + tre = &lldev->trepool[tre_ch]; + +/* copy the TRE into its location in the TRE ring */ +spin_lock_irqsave (&lldev->lock, flags);drivers/dma/qcom/hidma_ll.c line 605
Quoted 10 lines
drivers/dma/qcom/hidma_ll.c new file +10
-0+ tre->tre_index = lldev->tre_write_offset /TRE_SIZE ; + lldev->pending_tre_list[tre->tre_index] = tre; +memcpy (lldev->tre_ring + lldev->tre_write_offset, &tre->tre_local[0 ], +TRE_SIZE ); + lldev->tx_status_list[tre->idx].err_code =0 ; + lldev->tx_status_list[tre->idx].err_info =0 ; + tre->queued =1 ; + lldev->pending_tre_count++; + lldev->tre_write_offset = (lldev->tre_write_offset +TRE_SIZE ) + % lldev->tre_ring_size;These and above one should be right justfied per coding style
--
~Vinod
Re: [PATCH V14 5/9] dma: qcom_hidma: implement lower level hardware interface
In reply to Vinod KoulQuoted 30 lines · Vinod Koul
Quoted 28 lines · Sinan Kaya
drivers/dma/qcom/hidma_ll.c new file +28
-0+ +#define EVRE_SIZE 16/* each EVRE is 16 bytes */ + +#define TRCA_CTRLSTS_OFFSET 0x000 +#define TRCA_RING_LOW_OFFSET 0x008 +#define TRCA_RING_HIGH_OFFSET 0x00C +#define TRCA_RING_LEN_OFFSET 0x010 +#define TRCA_READ_PTR_OFFSET 0x018 +#define TRCA_WRITE_PTR_OFFSET 0x020 +#define TRCA_DOORBELL_OFFSET 0x400 + +#define EVCA_CTRLSTS_OFFSET 0x000 +#define EVCA_INTCTRL_OFFSET 0x004 +#define EVCA_RING_LOW_OFFSET 0x008 +#define EVCA_RING_HIGH_OFFSET 0x00C +#define EVCA_RING_LEN_OFFSET 0x010 +#define EVCA_READ_PTR_OFFSET 0x018 +#define EVCA_WRITE_PTR_OFFSET 0x020 +#define EVCA_DOORBELL_OFFSET 0x400 + +#define EVCA_IRQ_STAT_OFFSET 0x100 +#define EVCA_IRQ_CLR_OFFSET 0x108 +#define EVCA_IRQ_EN_OFFSET 0x110 + +#define EVRE_CFG_IDX 0 +#define EVRE_LEN_IDX 1 +#define EVRE_DEST_LOW_IDX 2 +#define EVRE_DEST_HI_IDX 3
Quoted 8 lines
drivers/dma/qcom/hidma_ll.c line 62
Quoted 6 lines
drivers/dma/qcom/hidma_ll.c new file +6
-0+ +#define EVRE_ERRINFO_BIT_POS 24 +#define EVRE_CODE_BIT_POS 28 + +#define EVRE_ERRINFO_MASK GENMASK(3, 0) +#define EVRE_CODE_MASK GENMASK(3, 0)These are rest here are not namespace properly...
If I understood it right, you want me to prefix them with as HIDMA_xyz. Correct?
Quoted 43 lines
Quoted 19 lines
drivers/dma/qcom/hidma_ll.c new file +18
-0+static int hidma_ll_enable (struct hidma_lldev *lldev) +{ +u32 val; +int ret; + + val =readl (lldev->evca +EVCA_CTRLSTS_OFFSET ); + val &= ~(CH_CONTROL_MASK <<16 ); + val |=CH_ENABLE <<16 ; +writel (val, lldev->evca +EVCA_CTRLSTS_OFFSET ); + + ret =readl_poll_timeout (lldev->evca +EVCA_CTRLSTS_OFFSET , val, + (HIDMA_CH_STATE (val) ==CH_ENABLED ) || + (HIDMA_CH_STATE (val) ==CH_RUNNING ),1000 , +10000 ); +if (ret) { +dev_err (lldev->dev,"event channel did not get enabled\n" ); +return ret; + }drivers/dma/qcom/hidma_ll.c line 542
Quoted 10 lines
drivers/dma/qcom/hidma_ll.c new file +10
-0+ + val =readl (lldev->trca +TRCA_CTRLSTS_OFFSET ); + val &= ~(CH_CONTROL_MASK <<16 ); + val |=CH_ENABLE <<16 ; +writel (val, lldev->trca +TRCA_CTRLSTS_OFFSET ); + + ret =readl_poll_timeout (lldev->trca +TRCA_CTRLSTS_OFFSET , val, + (HIDMA_CH_STATE (val) ==CH_ENABLED ) || + (HIDMA_CH_STATE (val) ==CH_RUNNING ),1000 , +10000 );first arg for
readl_poll_timeoutis accessor fn to do read, which doesnt seem to be here... so what did i miss?Quoted 9 lines
drivers/dma/qcom/hidma_ll.c new file +9
-0+void hidma_ll_queue_request (struct hidma_lldev *lldev,u32 tre_ch) +{ +struct hidma_tre *tre; +unsigned long flags; + + tre = &lldev->trepool[tre_ch]; + +/* copy the TRE into its location in the TRE ring */ +spin_lock_irqsave (&lldev->lock, flags);
Quoted 8 lines
drivers/dma/qcom/hidma_ll.c line 603
Quoted 8 lines
drivers/dma/qcom/hidma_ll.c new file +8
-0+ tre->tre_index = lldev->tre_write_offset /TRE_SIZE ; + lldev->pending_tre_list[tre->tre_index] = tre; +memcpy (lldev->tre_ring + lldev->tre_write_offset, &tre->tre_local[0 ], +TRE_SIZE ); + lldev->tx_status_list[tre->idx].err_code =0 ; + lldev->tx_status_list[tre->idx].err_info =0 ; + tre->queued =1 ; + lldev->pending_tre_count++;
Is this the only one without alignment? I couldn't understand what you mean by above one?
Quoted 5 lines
drivers/dma/qcom/hidma_ll.c line 605
Quoted 2 lines
drivers/dma/qcom/hidma_ll.c new file +2
-0+ lldev->tre_write_offset = (lldev->tre_write_offset +TRE_SIZE ) + % lldev->tre_ring_size;These and above one should be right justfied per coding style
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
Re: [PATCH V14 5/9] dma: qcom_hidma: implement lower level hardware interface
Quoted 4 lines · Sinan Kaya
Quoted 1 line
These are rest here are not namespace properly...
If I understood it right, you want me to prefix them with as
HIDMA_xyz. Correct?
Yes..
Quoted 6 lines
Quoted 6 lines
drivers/dma/qcom/hidma_ll.c line 599
Quoted 6 lines
drivers/dma/qcom/hidma_ll.c new file +6
-0+/* copy the TRE into its location in the TRE ring */ +spin_lock_irqsave (&lldev->lock, flags); + tre->tre_index = lldev->tre_write_offset /TRE_SIZE ; + lldev->pending_tre_list[tre->tre_index] = tre; +memcpy (lldev->tre_ring + lldev->tre_write_offset, &tre->tre_local[0 ], +TRE_SIZE );
This one
Quoted 7 lines
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c line 603
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c new file +4
-0+ lldev->tx_status_list[tre->idx].err_code =0 ; + lldev->tx_status_list[tre->idx].err_info =0 ; + tre->queued =1 ; + lldev->pending_tre_count++;Is this the only one without alignment? I couldn't understand what you mean by above one?
quoting Coding Style:
Statements longer than 80 columns will be broken into sensible chunks, unless exceeding 80 columns significantly increases readability and does not hide information. Descendants are always substantially shorter than the parent and are placed substantially to the right.
Quoted 5 lines
Quoted 5 lines
drivers/dma/qcom/hidma_ll.c line 605
Quoted 3 lines
drivers/dma/qcom/hidma_ll.c new file +2
-0+ lldev->tre_write_offset = (lldev->tre_write_offset +TRE_SIZE ) + % lldev->tre_ring_size;These and above one should be right justfied per coding style
Signature · 1 line
~Vinod
Re: [PATCH V14 5/9] dma: qcom_hidma: implement lower level hardware interface
Quoted 11 lines · Vinod Koul
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
memcpy(lldev->tre_ring +
lldev->tre_write_offset, &tre->tre_local[0],Quoted 1 line
Quoted 1 line
drivers/dma/qcom/hidma_ll.c line 599
Quoted 1 line
drivers/dma/qcom/hidma_ll.c new file +1
-0+ TRE_SIZE);This one
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c line 603
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c new file +4
-0+ lldev->tx_status_list[tre->idx].err_code =0 ; + lldev->tx_status_list[tre->idx].err_info =0 ; + tre->queued =1 ; + lldev->pending_tre_count++;Is this the only one without alignment? I couldn't understand what you mean by above one?
Quoted 10 lines
quoting Coding Style:
Statements longer than 80 columns will be broken into sensible chunks, unless exceeding 80 columns significantly increases readability and does not hide information.
"Descendants are always substantially shorter than the parent and are placed substantially to the right."
Sorry for my poor English. I never got this rule.
Which one is a "substantially" right? Can you give me an example?
I need to understand how you'd write this to satisfy the above rule.
like this:
memcpy(lldev->tre_ring + lldev->tre_write_offset, &tre->tre_local[0],
TRE_SIZE);
or
memcpy(lldev->tre_ring + lldev->tre_write_offset,
&tre->tre_local[0], TRE_SIZE);
or
memcpy(lldev->tre_ring + lldev->tre_write_offset, &tre->tre_local[0],
TRE_SIZE);
or
memcpy(lldev->tre_ring + lldev->tre_write_offset,
&tre->tre_local[0], TRE_SIZE);
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
Re: [PATCH V14 5/9] dma: qcom_hidma: implement lower level hardware interface
Quoted 41 lines · Sinan Kaya
Quoted 11 lines · Vinod Koul
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
memcpy(lldev->tre_ring +
lldev->tre_write_offset, &tre->tre_local[0],Quoted 1 line
Quoted 1 line
drivers/dma/qcom/hidma_ll.c line 599
Quoted 1 line
drivers/dma/qcom/hidma_ll.c new file +1
-0+ TRE_SIZE);This one
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c line 603
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c new file +4
-0+ lldev->tx_status_list[tre->idx].err_code =0 ; + lldev->tx_status_list[tre->idx].err_info =0 ; + tre->queued =1 ; + lldev->pending_tre_count++;Is this the only one without alignment? I couldn't understand what you mean by above one?
Quoted 10 lines
quoting Coding Style:
Statements longer than 80 columns will be broken into sensible chunks, unless exceeding 80 columns significantly increases readability and does not hide information.
"Descendants are always substantially shorter than the parent and are placed substantially to the right."
Sorry for my poor English. I never got this rule.
Which one is a "substantially" right? Can you give me an example?
I need to understand how you'd write this to satisfy the above rule.
like this:
memcpy(lldev->tre_ring +
lldev->tre_write_offset, &tre->tre_local[0],TRE_SIZE);or
memcpy(lldev->tre_ring +
lldev->tre_write_offset,&tre->tre_local[0], TRE_SIZE);or
Quoted 9 lines
memcpy(lldev->tre_ring +
lldev->tre_write_offset, &tre->tre_local[0],TRE_SIZE);or
memcpy(lldev->tre_ring +
lldev->tre_write_offset,&tre->tre_local[0], TRE_SIZE);
so, I looked at other examples in drivers/dma/dw/core.c file...
I'm seeing two different patterns in the code. One pattern is to align the next line to the first character of the first line like I did based on the previous review comments.
mem_width = min_t(unsigned int,
data_width, dwc_fast_ffs(mem | len));The second example places an extra tab like this.
list_add_tail(&desc->desc_node, &first->tx_list);
Based on this example: this is how I'm changing the second one
+ lldev->tre_write_offset = (lldev->tre_write_offset + HIDMA_TRE_SIZE)
+ % lldev->tre_ring_size;
+
I'm still not sure what you want to do with this:
Is this what you want to do ?
memcpy(lldev->tre_ring + lldev->tre_write_offset, &tre->tre_local[0],
- HIDMA_TRE_SIZE);
+ HIDMA_TRE_SIZE);
I also got flagged before that HIDMA_TRE_SIZE does not start from the first character.
I have done the renaming. This is all left for me to post a follow up.
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
Re: [PATCH V14 5/9] dma: qcom_hidma: implement lower level hardware interface
Vinod,
Quoted 1 line · Sinan Kaya
I have done the renaming. This is all left for me to post a follow up.
I just posted v15 (forgot to put v15 on 4/4).
http://www.spinics.net/lists/arm-kernel/msg490282.html
I wanted to get v15 out before the end of the week with the macro renames. Let me know which lines need corrections.
There is also a single line change for the object hierarchy patch. The code was looking up DMA attributes (OF:dma-coherent) from the wrong place.
Thanks and have a good weekend,
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
Re: [PATCH V14 5/9] dma: qcom_hidma: implement lower level hardware interface
In reply to Sinan KayaQuoted 5 lines · Sinan Kaya
Quoted 4 lines · Sinan Kaya
Quoted 3 lines · Vinod Koul
Quoted 2 lines
Quoted 2 lines
Quoted 2 lines
memcpy(lldev->tre_ring +
lldev->tre_write_offset, &tre->tre_local[0],Quoted 1 line
Quoted 1 line
drivers/dma/qcom/hidma_ll.c line 599
Quoted 1 line
drivers/dma/qcom/hidma_ll.c new file +1
-0+ TRE_SIZE);This one
I would write this as:
memcpy(lldev->tre_ring + lldev->tre_write_offset,
&tre->tre_local[0], TRE_SIZE);
To make it look more readable
Quoted 21 lines
Quoted 21 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
drivers/dma/qcom/hidma_ll.c line 603
Quoted 5 lines
drivers/dma/qcom/hidma_ll.c new file +4
-0+ lldev->tx_status_list[tre->idx].err_code =0 ; + lldev->tx_status_list[tre->idx].err_info =0 ; + tre->queued =1 ; + lldev->pending_tre_count++;Is this the only one without alignment? I couldn't understand what you mean by above one?
Quoted 10 lines
quoting Coding Style:
Statements longer than 80 columns will be broken into sensible chunks, unless exceeding 80 columns significantly increases readability and does not hide information.
"Descendants are always substantially shorter than the parent and are placed substantially to the right."
Sorry for my poor English. I never got this rule.
Quoted 8 lines
Quoted 8 lines
Which one is a "substantially" right? Can you give me an example?
I need to understand how you'd write this to satisfy the above rule.
like this:
memcpy(lldev->tre_ring +
lldev->tre_write_offset, &tre->tre_local[0],TRE_SIZE);
No
Quoted 5 lines
Quoted 5 lines
or
memcpy(lldev->tre_ring +
lldev->tre_write_offset,&tre->tre_local[0], TRE_SIZE);
Better or above
Quoted 5 lines
Quoted 5 lines
or
memcpy(lldev->tre_ring +
lldev->tre_write_offset, &tre->tre_local[0],TRE_SIZE);
This doesnt look very readable IMHO, mostly try to use common sense and if it looks good and easy to read then you might have nailed it :)
Quoted 35 lines
Quoted 7 lines
or
memcpy(lldev->tre_ring +
lldev->tre_write_offset,&tre->tre_local[0], TRE_SIZE);so, I looked at other examples in
drivers/dma/dw/core.cfile...I'm seeing two different patterns in the code. One pattern is to align the next line to the first character of the first line like I did based on the previous review comments.
mem_width = min_t(unsigned int, data_width, dwc_fast_ffs(mem | len));The second example places an extra tab like this.
list_add_tail(&desc->desc_node, &first->tx_list);Based on this example: this is how I'm changing the second one
drivers/dma/qcom/hidma_ll.c new file +3
-0+ lldev->tre_write_offset = (lldev->tre_write_offset +HIDMA_TRE_SIZE ) + % lldev->tre_ring_size; +I'm still not sure what you want to do with this:
Is this what you want to do ?
memcpy(lldev->tre_ring + lldev->tre_write_offset, &tre->tre_local[0],(quoted diff) +1
-1- HIDMA_TRE_SIZE); + HIDMA_TRE_SIZE);
Quoted 4 lines
I also got flagged before that
HIDMA_TRE_SIZEdoes not start from the first character.I have done the renaming. This is all left for me to post a follow up.
OK
Signature · 1 line
~Vinod
Re: [PATCH V14 5/9] dma: qcom_hidma: implement lower level hardware interface
In reply to Sinan KayaQuoted 6 lines · Sinan Kaya
Vinod,
Quoted 1 line · Sinan Kaya
I have done the renaming. This is all left for me to post a follow up.
I just posted v15 (forgot to put v15 on 4/4).
Don't do that manually!
git formt-patch --subject-prefix is for that
Quoted 8 lines
http://www.spinics.net/lists/arm-kernel/msg490282.html
I wanted to get v15 out before the end of the week with the macro renames. Let me know which lines need corrections.
There is also a single line change for the object hierarchy patch. The code was looking up DMA attributes (OF:dma-coherent) from the wrong place.
Signature · 1 line
~Vinod
Re: [PATCH V14 5/9] dma: qcom_hidma: implement lower level hardware interface
Quoted 12 lines · Vinod Koul
Quoted 6 lines · Sinan Kaya
Vinod,
Quoted 1 line · Sinan Kaya
I have done the renaming. This is all left for me to post a follow up.
I just posted v15 (forgot to put v15 on 4/4).
Don't do that manually!
git formt-patch --subject-prefix is for that
Thanks for the hint. I was using the --annotate option and adding version numbers.
Quoted 9 lines
Quoted 8 lines
http://www.spinics.net/lists/arm-kernel/msg490282.html
I wanted to get v15 out before the end of the week with the macro renames. Let me know which lines need corrections.
There is also a single line change for the object hierarchy patch. The code was looking up DMA attributes (OF:dma-coherent) from the wrong place.
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
Re: [PATCH V14 5/9] dma: qcom_hidma: implement lower level hardware interface
In reply to Vinod KoulHi Vinod,
Quoted 6 lines · Vinod Koul
I would write this as:
memcpy(lldev->tre_ring +
lldev->tre_write_offset,&tre->tre_local[0], TRE_SIZE);To make it look more readable
Got it.
Quoted 30 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 22 lines
Quoted 11 lines
Quoted 11 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 9 lines
Quoted 6 lines
Quoted 6 lines
+ lldev->tx_status_list[tre->idx].err_code = 0;
+ lldev->tx_status_list[tre->idx].err_info = 0;
+ tre->queued = 1;
+ lldev->pending_tre_count++;Is this the only one without alignment? I couldn't understand what you mean by above one?
quoting Coding Style:
Quoted 8 lines
Quoted 8 lines
Statements longer than 80 columns will be broken into sensible chunks, unless exceeding 80 columns significantly increases readability and does not hide information.
"Descendants are always substantially shorter than the parent and are placed substantially to the right."
Sorry for my poor English. I never got this rule.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Which one is a "substantially" right? Can you give me an example?
I need to understand how you'd write this to satisfy the above rule.
like this:
memcpy(lldev->tre_ring +
lldev->tre_write_offset, &tre->tre_local[0],TRE_SIZE);
Quoted 9 lines
No
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines
or
memcpy(lldev->tre_ring +
lldev->tre_write_offset,&tre->tre_local[0], TRE_SIZE);Better or above
I'll do this to be consistent with the rest of the code.
Please let me know when you want to have the updated version. I don't want to post v16 while you are reviewing the rest of the code.
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