dma: add Qualcomm Technologies HIDMA driver
Subsystems (6)
v13 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
------------------------
- VFIO Reset driver
- More documentation in device-tree binding.
- Removed event-channel parameter
------------------------
Git repos
------------------------
QEMU Support
https://www.codeaurora.org/cgit/quic/qemu/qemu/log/?h=v2.5.0-sriov
------------------------
History of Changes
------------------------
Creating a QCOM directory for all QCOM DMA source files. Changes from V12: (https://lkml.org/lkml/2016/1/11/525)
* none
dma: hidma: Add Device Tree Binding
Changes from V12: (https://lkml.org/lkml/2016/1/11/522)
* s/driver/binding/
* s/hypervisor/host/
* add iommu node required.
* removed the flexibility to choose event channel. Will use HW defaults
* instead.
channel-index parameter is removed.
dma: add Qualcomm Technologies HIDMA management driver Changes from V12: (https://lkml.org/lkml/2016/1/11/518)
* s/hypervisor/host/
dma: add Qualcomm Technologies HIDMA channel driver Changes from V12: (https://lkml.org/lkml/2016/1/11/523)
* none
dma: qcom_hidma: implement lower level hardware interface Changes from V12: (https://lkml.org/lkml/2016/1/11/519)
* none
dma: qcom_hidma: add debugfs hooks
Changes from V12: (https://lkml.org/lkml/2016/1/11/521)
* none
dma: qcom_hidma: add support for object hierarchy Changes from V12: (https://lkml.org/lkml/2016/1/11/520)
* none
Sinan Kaya (10):
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
dma: qcom_hidma: read the channel id from HW
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 | 747 +++++++++++++++++
drivers/dma/qcom/hidma.h | 162 ++++
drivers/dma/qcom/hidma_dbg.c | 219 +++++
drivers/dma/qcom/hidma_ll.c | 927 +++++++++++++++++++++
drivers/dma/qcom/hidma_mgmt.c | 400 +++++++++
drivers/dma/qcom/hidma_mgmt.h | 39 +
drivers/dma/qcom/hidma_mgmt_sys.c | 295 +++++++
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, 3229 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 v13 1/10 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 v13 2/10 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 | 92 ++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt new file +92 -0
@@ -0,0 +1,92 @@ +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 +- channel-index: The HW event channel completions will be delivered. +- 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>; + channel-index = <4>; + }; + }; + +Guest OS configuration: + + hidma_24: dma-controller at 0x5c050000 { + compatible = "qcom,hidma-1.0"; + reg = <0 0x5c050000 0x0 0x1000>, + <0 0x5c0b0000 0x0 0x1000>; + interrupts = <0 389 0>; + desc-count = <10>; + channel-index = <4>; + iommus = <&system_mmu>; + };
Signature · 1 line
1.8.2.1
PATCH v13 3/10 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 v13 4/10 dma: add Qualcomm Technologies HIDMA channel driver
In reply to Sinan KayaThis patch adds support for hidma engine. The driver consists of two logical blocks. The DMA engine interface and the low-level interface. The hardware only supports memcpy/memset and this driver only support memcpy interface. HW and driver doesn't support slave interface.
--- drivers/dma/qcom/Kconfig | 10 + drivers/dma/qcom/hidma.c | 744 +++++++++++++++++++++++++++++++++++++++++++++++ drivers/dma/qcom/hidma.h | 160 ++++++++++ 3 files changed, 914 insertions(+) create mode 100644 drivers/dma/qcom/hidma.c create mode 100644 drivers/dma/qcom/hidma.h
drivers/dma/qcom/Kconfig +10 -0
@@ -17,3 +17,13 @@ config QCOM_HIDMA_MGMT start managing the channels. In a virtualized environment, the guest OS would run QCOM_HIDMA channel driver and the 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 +744 -0
744 lines not on this page · raw message
drivers/dma/qcom/hidma.h new file +160 -0
160 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH v13 5/10 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 v13 6/10 dma: qcom_hidma: add debugfs hooks
In reply to Sinan KayaAdd debugfs hooks for debugging the execution behavior of the DMA channel. The debugfs hooks get initialized by the probe function and uninitialized by the remove function.
A stats file is created in debugfs. The stats file will show the information about each HIDMA channel as well as each asynchronous job queued and completed at a given time.
--- drivers/dma/qcom/Makefile | 2 +- drivers/dma/qcom/hidma.c | 3 + drivers/dma/qcom/hidma.h | 2 + drivers/dma/qcom/hidma_dbg.c | 219 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 225 insertions(+), 1 deletion(-) create mode 100644 drivers/dma/qcom/hidma_dbg.c
drivers/dma/qcom/Makefile +1 -1
@@ -2,4 +2,4 @@ obj-$(CONFIG_QCOM_BAM_DMA) += bam_dma.o obj-$(CONFIG_QCOM_HIDMA_MGMT) += hdma_mgmt.o hdma_mgmt-objs := hidma_mgmt.o hidma_mgmt_sys.o obj-$(CONFIG_QCOM_HIDMA) += hdma.o -hdma-objs := hidma_ll.o hidma.o +hdma-objs := hidma_ll.o hidma.o hidma_dbg.o
drivers/dma/qcom/hidma.c +3 -0
@@ -681,6 +681,7 @@ static int hidma_probe(struct platform_device *pdev) dmadev->irq = chirq;tasklet_init (&dmadev->task, hidma_issue_task, (unsigned long )dmadev); +hidma_debug_init (dmadev);dev_info (&pdev->dev,"HI-DMA engine driver registration complete\n" );platform_set_drvdata (pdev, dmadev);pm_runtime_mark_last_busy (dmadev->ddev.dev);
@@ -689,6 +690,7 @@ static int hidma_probe(struct platform_device *pdev)return 0 ; uninit: +hidma_debug_uninit (dmadev);hidma_ll_uninit (dmadev->lldev); dmafree:if (dmadev)
@@ -706,6 +708,7 @@ static int hidma_remove(struct platform_device *pdev)pm_runtime_get_sync (dmadev->ddev.dev);dma_async_device_unregister (&dmadev->ddev);devm_free_irq (dmadev->ddev.dev, dmadev->irq, dmadev->lldev); +hidma_debug_uninit (dmadev);hidma_ll_uninit (dmadev->lldev);hidma_free (dmadev);
drivers/dma/qcom/hidma.h +2 -0
@@ -157,4 +157,6 @@ int hidma_ll_uninit(struct hidma_lldev *llhndl);irqreturn_t hidma_ll_inthandler (int irq,void *arg);void hidma_cleanup_pending_tre (struct hidma_lldev *llhndl,u8 err_info,u8 err_code); +int hidma_debug_init (struct hidma_dev *dmadev); +void hidma_debug_uninit (struct hidma_dev *dmadev);#endif
drivers/dma/qcom/hidma_dbg.c new file +219 -0
219 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH v13 7/10 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 | 104 ++++++++++++++++++++++++- 3 files changed, 148 insertions(+), 4 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-platform-hidma
Documentation/ABI/testing/sysfs-platform-hidma new file +9 -0
@@ -0,0 +1,9 @@ +What: /sys/devices/platform/hidma-*/chid + /sys/devices/platform/QCOM8061:*/chid +Date: Dec 2015 +KernelVersion: 4.4 +Contact: "Sinan Kaya <[email protected]>" +Description: + Contains the ID of the channel within the HIDMA instance. + It is used to associate a given HIDMA channel with the + priority and weight calls in the management interface.
drivers/dma/qcom/hidma.c +38 -1
@@ -549,6 +549,43 @@ static irqreturn_t hidma_chirq_handler(int chirq, void *arg)return hidma_ll_inthandler (chirq, lldev); } +static ssize_t hidma_show_values (struct device *dev, +struct device_attribute *attr,char *buf) +{ +struct platform_device *pdev =to_platform_device (dev); +struct hidma_dev *mdev =platform_get_drvdata (pdev); + + buf[0 ] =0 ; + +if (strcmp (attr->attr.name,"chid" ) ==0 ) +sprintf (buf,"%d\n" , mdev->chidx); + +return strlen (buf); +} + +static int hidma_create_sysfs_entry (struct hidma_dev *dev,char *name, +int mode) +{ +struct device_attribute *attrs; +char *name_copy; + + attrs =devm_kmalloc (dev->ddev.dev,sizeof (struct device_attribute ), +GFP_KERNEL ); +if (!attrs) +return -ENOMEM ; + + name_copy =devm_kstrdup (dev->ddev.dev, name,GFP_KERNEL ); +if (!name_copy) +return -ENOMEM ; + + attrs->attr.name = name_copy; + attrs->attr.mode = mode; + attrs->show = hidma_show_values; +sysfs_attr_init (&attrs->attr); + +return device_create_file (dev->ddev.dev, attrs); +} +static int hidma_probe (struct platform_device *pdev) {struct hidma_dev *dmadev;
@@ -682,6 +719,7 @@ static int hidma_probe(struct platform_device *pdev) dmadev->irq = chirq;tasklet_init (&dmadev->task, hidma_issue_task, (unsigned long )dmadev);hidma_debug_init (dmadev); +hidma_create_sysfs_entry (dmadev,"chid" ,S_IRUGO );dev_info (&pdev->dev,"HI-DMA engine driver registration complete\n" );platform_set_drvdata (pdev, dmadev);pm_runtime_mark_last_busy (dmadev->ddev.dev);
@@ -730,7 +768,6 @@ static const struct of_device_id hidma_match[] = { {.compatible = "qcom,hidma-1.0",}, {}, }; -MODULE_DEVICE_TABLE (of, hidma_match);static struct platform_driver hidma_driver = {
drivers/dma/qcom/hidma_mgmt.c +101 -3
119 lines not on this page · raw message
Signature · 1 line
1.8.2.1
PATCH v13 8/10 dma: qcom_hidma: read the channel id from HW
In reply to Sinan KayaRemoving the flexibility to choose the event channel as there is no real use case right now. We have been using the values in ACPI that match the HW defaults. OS is reading the event-channel from the HW register now.
--- .../devicetree/bindings/dma/qcom_hidma_mgmt.txt | 3 -- drivers/dma/qcom/hidma.c | 39 +--------------------- 2 files changed, 1 insertion(+), 41 deletions(-)
Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt +0 -3
@@ -51,7 +51,6 @@ Required properties: - reg: Addresses for the transfer and event channel - interrupts: Should contain the event interrupt - desc-count: Number of asynchronous requests this channel can handle -- channel-index: The HW event channel completions will be delivered. - iommus: required a iommu node Example:
@@ -75,7 +74,6 @@ Hypervisor OS configuration: interrupts = <0 389 0>; desc-count = <10>; iommus = <&system_mmu>; - channel-index = <4>; }; };
@@ -87,6 +85,5 @@ Guest OS configuration: <0 0x5c0b0000 0x0 0x1000>; interrupts = <0 389 0>; desc-count = <10>; - channel-index = <4>; iommus = <&system_mmu>; };
drivers/dma/qcom/hidma.c +1 -38
@@ -101,26 +101,6 @@ static unsigned int nr_desc_prm;module_param (nr_desc_prm, uint,0644 );MODULE_PARM_DESC (nr_desc_prm,"number of descriptors (default: 0)" ); -#define HIDMA_MAX_CHANNELS 64 -static int channel_idx[HIDMA_MAX_CHANNELS ] = { - [0 ... (HIDMA_MAX_CHANNELS -1 )] =-1 -}; - -/* -* Each DMA channel is associated with an event channel for interrupt -* delivery. The event channel index usually comes from the firmware through -* ACPI/DT. When a HIDMA channel is executed in the guest machine context (QEMU) -* the device tree gets auto-generated based on the memory and IRQ resources -* this driver uses on the host machine. Any device specific paraemeter such as -* channel-index gets ignored by the QEMU. -* We are using this command line parameter to pass the event channel index to -* the guest machine. -*/ -static unsigned int num_channel_idx; -module_param_array_named (channel_idx, channel_idx, int, &num_channel_idx, -0644 ); -MODULE_PARM_DESC (channel_idx,"channel index array for the notifications" ); -static atomic_t channel_ref_count;/* process completed descriptors */ static void hidma_process_completed (struct hidma_chan *mchan)
@@ -592,7 +572,6 @@ static int hidma_probe(struct platform_device *pdev)struct resource *trca_resource;struct resource *evca_resource;int chirq; -int current_channel_index =atomic_read (&channel_ref_count);void __iomem *evca;void __iomem *trca;int rc;
@@ -668,22 +647,7 @@ static int hidma_probe(struct platform_device *pdev) goto dmafree; } -if (current_channel_index >HIDMA_MAX_CHANNELS ) { - rc = -EINVAL ; - goto dmafree; - } - - dmadev->chidx =-1 ; -device_property_read_u32 (&pdev->dev,"channel-index" , &dmadev->chidx); - -/* kernel command line override for the guest machine */ -if (channel_idx[current_channel_index] !=-1 ) - dmadev->chidx = channel_idx[current_channel_index]; - -if (dmadev->chidx ==-1 ) { - rc = -EINVAL ; - goto dmafree; - } + dmadev->chidx =readl (dmadev->dev_trca +0x28 );/* Set DMA mask to 64 bits. */ rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ));
@@ -724,7 +688,6 @@ static int hidma_probe(struct platform_device *pdev)platform_set_drvdata (pdev, dmadev);pm_runtime_mark_last_busy (dmadev->ddev.dev);pm_runtime_put_autosuspend (dmadev->ddev.dev); -atomic_inc (&channel_ref_count);return 0 ; uninit:
Signature · 1 line
1.8.2.1
PATCH v13 9/10 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.
For ACPI systems, ACPI HID needs to match and compat in the registered reset
driver needs to match for ACPI reset driver loading to work.
For OF based systems, DT compatible string needs to match and compat in the registered reset driver needs to match for DT reset driver loading to work.
--- .../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 v13 10/10 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
kbuild test robot
build botRe: [PATCH V13 09/10] vfio, platform: add support for ACPI while detecting the reset driver
In reply to Sinan Kayareproduce: wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross # save the attached .config to linux build tree…
Hi Sinan,
[auto build test ERROR on vfio/next]
[also build test ERROR on v4.5-rc1 next-20160129]
[if your patch is applied to the wrong git tree, please drop us a note to help improving the system]
url: https://github.com/0day-ci/linux/commits/Sinan-Kaya/dma-add-Qualcomm-Technologies-HIDMA-driver/20160130-064551 base: https://github.com/awilliam/linux-vfio.git next config: arm64-allmodconfig (attached as .config)
reproduce:
wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
make.cross ARCH=arm64
All errors (new ones prefixed by >>):
drivers/vfio/platform/vfio_platform_common.c: In function 'vfio_platform_probe_acpi':
>> drivers/vfio/platform/vfio_platform_common.c:558:9: error: invalid initializer
struct acpi_device adev = ACPI_COMPANION(dev);
^
>> drivers/vfio/platform/vfio_platform_common.c:560:6: error: wrong type argument to unary exclamation mark
if (!adev)
^
>> drivers/vfio/platform/vfio_platform_common.c:563:18: error: incompatible type for argument 1 of 'acpi_device_hid'
vdev->acpihid = acpi_device_hid(adev);
^
In file included from include/linux/acpi.h:41:0,
from drivers/vfio/platform/vfio_platform_common.c:16:
include/acpi/acpi_bus.h:253:13: note: expected 'struct acpi_device *' but argument is of type 'struct acpi_device'
const char *acpi_device_hid(struct acpi_device *device);
^vim +558 drivers/vfio/platform/vfio_platform_common.c
552 };
553
554 #ifdef CONFIG_ACPI
555 int vfio_platform_probe_acpi(struct vfio_platform_device *vdev,
556 struct device *dev)
557 {
> 558 struct acpi_device adev = ACPI_COMPANION(dev); 559 > 560 if (!adev) 561 return -EINVAL; 562 > 563 vdev->acpihid = acpi_device_hid(adev);
564 if (!vdev->acpihid) {
565 pr_err("VFIO: cannot find ACPI HID for %s\n",
566 vdev->name);
---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation
Re: [PATCH V13 09/10] vfio, platform: add support for ACPI while detecting the reset driver
In reply to Sinan KayaHi Eric, Alex, Antonios;
Quoted 252 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.
For ACPI systems, ACPI HID needs to match and compat in the registered reset
driver needs to match for ACPI reset driver loading to work.For OF based systems, DT compatible string needs to match and compat in the registered reset driver needs to match for DT reset driver loading to work.
Signed-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 */
If we put aside the forgotten pointer in acpi_device assignment, (I had a merge conflict and I screwed it up at the last moment),
Can you review the following two patches?
https://lkml.org/lkml/2016/1/29/679
https://lkml.org/lkml/2016/1/29/677
These patches seem to be in your area. I was relying on the maintainer list to pull you into the review but for some reason your emails didn't show up.
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 V13 08/10] dma: qcom_hidma: read the channel id from HW
In reply to Sinan KayaQuoted 9 lines · Sinan Kaya
Removing the flexibility to choose the event channel as there is no real use case right now. We have been using the values in ACPI that match the HW defaults. OS is reading the event-channel from the HW register now.
Signed-off-by Sinan Kaya <[email protected]>--- .../devicetree/bindings/dma/qcom_hidma_mgmt.txt | 3 -- drivers/dma/qcom/hidma.c | 39 +--------------------- 2 files changed, 1 insertion(+), 41 deletions(-)
Re: [PATCH V13 08/10] dma: qcom_hidma: read the channel id from HW
In reply to Sinan KayaQuoted 3 lines · Sinan Kaya
Removing the flexibility to choose the event channel as there is no real use case right now. We have been using the values in ACPI that match the HW defaults. OS is reading the event-channel from the HW register now.
Fold this in to the patches adding the binding and the driver.
There is no reason to add this then remove it within the same series.
Mark.
Quoted 107 lines
Signed-off-by Sinan Kaya <[email protected]>--- .../devicetree/bindings/dma/qcom_hidma_mgmt.txt | 3 -- drivers/dma/qcom/hidma.c | 39 +--------------------- 2 files changed, 1 insertion(+), 41 deletions(-)Documentation/devicetree/bindings/dma/qcom_hidma_mgmt.txt +0
-3@@ -51,7 +51,6 @@ Required properties: - reg: Addresses for the transfer and event channel - interrupts: Should contain the event interrupt - desc-count: Number of asynchronous requests this channel can handle -- channel-index: The HW event channel completions will be delivered. - iommus: required a iommu node Example:@@ -75,7 +74,6 @@ Hypervisor OS configuration: interrupts = <0 389 0>; desc-count = <10>; iommus = <&system_mmu>; - channel-index = <4>; }; };@@ -87,6 +85,5 @@ Guest OS configuration: <0 0x5c0b0000 0x0 0x1000>; interrupts = <0 389 0>; desc-count = <10>; - channel-index = <4>; iommus = <&system_mmu>; };drivers/dma/qcom/hidma.c +1
-38@@ -101,26 +101,6 @@ static unsigned int nr_desc_prm;module_param (nr_desc_prm, uint,0644 );MODULE_PARM_DESC (nr_desc_prm,"number of descriptors (default: 0)" ); -#define HIDMA_MAX_CHANNELS 64 -static int channel_idx[HIDMA_MAX_CHANNELS ] = { - [0 ... (HIDMA_MAX_CHANNELS -1 )] =-1 -}; - -/* -* Each DMA channel is associated with an event channel for interrupt -* delivery. The event channel index usually comes from the firmware through -* ACPI/DT. When a HIDMA channel is executed in the guest machine context (QEMU) -* the device tree gets auto-generated based on the memory and IRQ resources -* this driver uses on the host machine. Any device specific paraemeter such as -* channel-index gets ignored by the QEMU. -* We are using this command line parameter to pass the event channel index to -* the guest machine. -*/ -static unsigned int num_channel_idx; -module_param_array_named (channel_idx, channel_idx, int, &num_channel_idx, -0644 ); -MODULE_PARM_DESC (channel_idx,"channel index array for the notifications" ); -static atomic_t channel_ref_count;/* process completed descriptors */ static void hidma_process_completed (struct hidma_chan *mchan)@@ -592,7 +572,6 @@ static int hidma_probe(struct platform_device *pdev)struct resource *trca_resource;struct resource *evca_resource;int chirq; -int current_channel_index =atomic_read (&channel_ref_count);void __iomem *evca;void __iomem *trca;int rc;@@ -668,22 +647,7 @@ static int hidma_probe(struct platform_device *pdev) goto dmafree; } -if (current_channel_index >HIDMA_MAX_CHANNELS ) { - rc = -EINVAL ; - goto dmafree; - } - - dmadev->chidx =-1 ; -device_property_read_u32 (&pdev->dev,"channel-index" , &dmadev->chidx); - -/* kernel command line override for the guest machine */ -if (channel_idx[current_channel_index] !=-1 ) - dmadev->chidx = channel_idx[current_channel_index]; - -if (dmadev->chidx ==-1 ) { - rc = -EINVAL ; - goto dmafree; - } + dmadev->chidx =readl (dmadev->dev_trca +0x28 );/* Set DMA mask to 64 bits. */ rc =dma_set_mask_and_coherent (&pdev->dev,DMA_BIT_MASK (64 ));@@ -724,7 +688,6 @@ static int hidma_probe(struct platform_device *pdev)platform_set_drvdata (pdev, dmadev);pm_runtime_mark_last_busy (dmadev->ddev.dev);pm_runtime_put_autosuspend (dmadev->ddev.dev); -atomic_inc (&channel_ref_count);return 0 ; uninit:Signature · 1 line
1.8.2.1
Re: [PATCH V13 10/10] vfio, platform: add QTI HIDMA reset driver
In reply to Sinan KayaHi Sinan,
Quoted 96 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 +43
-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> +#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) +#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;
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c line 53
Quoted 10 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +10
-0+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);
this is going to leak. See "vfio: platform: reset: calxedaxgmac: fix ioaddr leak".
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c line 61
Quoted 8 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +8
-0+if (!trreg.ioaddr) +return -ENOMEM ; + } + + evreg = vdev->regions[1 ]; +if (!evreg.ioaddr) { + evreg.ioaddr = +ioremap_nocache (evreg.addr, evreg.size);
same here
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c line 65
Quoted 4 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +4
-0+if (!evreg.ioaddr) +return -ENOMEM ; + } +
I understood the device is a kind of SR-IOV platform device. When the VF gets reset are there any interactions with the management driver? Is it handled by HW?
Best Regards
Eric
Quoted 35 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +34
-0+/* 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" ,NULL , + vfio_platform_qcomhidma_reset); + +MODULE_LICENSE ("GPL v2" ); +MODULE_DESCRIPTION ("Reset support for Qualcomm Technologies HIDMA device" );
Re: [PATCH V13 08/10] dma: qcom_hidma: read the channel id from HW
In reply to Mark RutlandQuoted 5 lines · Mark Rutland
Fold this in to the patches adding the binding and the driver.
There is no reason to add this then remove it within the same series.
Mark.
Will do. I was trying to keep changes to the minimum on the other patches to help the reviewers.
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 V13 10/10] vfio, platform: add QTI HIDMA reset driver
In reply to Eric AugerQuoted 9 lines · Eric Auger
Hi Sinan,
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c line 53
Quoted 5 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +5
-0+ + trreg = vdev->regions[0 ]; +if (!trreg.ioaddr) { + trreg.ioaddr = +ioremap_nocache (trreg.addr, trreg.size);this is going to leak. See "vfio: platform: reset: calxedaxgmac: fix ioaddr leak".
Thanks, I was following what other drivers were doing and got hit by the same problem :)
Quoted 9 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c line 61
Quoted 8 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +8
-0+if (!trreg.ioaddr) +return -ENOMEM ; + } + + evreg = vdev->regions[1 ]; +if (!evreg.ioaddr) { + evreg.ioaddr = +ioremap_nocache (evreg.addr, evreg.size);same here
I'll take care of it.
Quoted 7 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c line 65
Quoted 4 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +4
-0+if (!evreg.ioaddr) +return -ENOMEM ; + } +I understood the device is a kind of SR-IOV platform device. When the VF gets reset are there any interactions with the management driver? Is it handled by HW?
There is no communication between the management interface and the DMA channels. Management interface is just a runtime platform resource allocator.
"if you pay more, you get more DMA bandwidth. Otherwise, you get to share the channel with other users"
The DMA channels can be reset independent of other DMA channels or the management HW. This is a HW feature.
Quoted 40 lines
Best Regards
Eric
Quoted 35 lines
drivers/vfio/platform/reset/vfio_platform_qcomhidma.c new file +34
-0+/* 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" ,NULL , + 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 V13 09/10] vfio, platform: add support for ACPI while detecting the reset driver
In reply to Sinan KayaHi Sinan,
Quoted 9 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.
For ACPI systems, ACPI HID needs to match and compat in the registered reset
driver needs to match for ACPI reset driver loading to work.
Don't really get the sentence. For ACPI systems, a registered reset function is selected if its associated ACPI HID matches the device ACPI HID?
Quoted 3 lines
For OF based systems, DT compatible string needs to match and compat in the registered reset driver needs to match for DT reset driver loading to work.
same here
I added Baptiste who is vfio platform driver sub-system maintainer.
On my side I tested with of amd xgbe and I don't observe any regression.
Best Regards
Eric
Quoted 250 lines
Signed-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 +23
-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); \ + 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 V13 09/10] vfio, platform: add support for ACPI while detecting the reset driver
Quoted 5 lines · Eric Auger
Quoted 3 lines
For ACPI systems, ACPI HID needs to match and compat in the registered
Quoted 2 lines
reset
driver needs to match for ACPI reset driver loading to work.Don't really get the sentence. For ACPI systems, a registered reset function is selected if its associated ACPI HID matches the device ACPI HID?
Old commit message. I did an internal review before posting the patch. The first version of the patch was a hack. I simplified the code but forgot to update the commit message.
Now, the rule is simple.
- ACPI HID needs match for ACPI systems
- DT compat needs to match for OF systems
as expected. I'll rephrase for the next version.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
For OF based systems, DT compatible string needs to match and compat in the registered reset driver needs to match for DT reset driver loading to work.
same here
I added Baptiste who is vfio platform driver sub-system maintainer.
Thanks, we should ask Baptiste to get his email into the Maintainer file list.
Quoted 4 lines
On my side I tested with of amd xgbe and I don't observe any regression.
Best Regards
Can I add your tested by?
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 V13 09/10] vfio, platform: add support for ACPI while detecting the reset driver
Quoted 19 lines · Sinan Kaya
Quoted 5 lines · Eric Auger
Quoted 3 lines
For ACPI systems, ACPI HID needs to match and compat in the registered
Quoted 2 lines
reset
driver needs to match for ACPI reset driver loading to work.Don't really get the sentence. For ACPI systems, a registered reset function is selected if its associated ACPI HID matches the device ACPI HID?
Old commit message. I did an internal review before posting the patch. The first version of the patch was a hack. I simplified the code but forgot to update the commit message.
Now, the rule is simple.
- ACPI HID needs match for ACPI systems
- DT compat needs to match for OF systemsas expected. I'll rephrase for the next version.
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Quoted 2 lines
For OF based systems, DT compatible string needs to match and compat in the registered reset driver needs to match for DT reset driver loading to work.
same here
I added Baptiste who is vfio platform driver sub-system maintainer.
Thanks, we should ask Baptiste to get his email into the Maintainer file list.
I think it is:./scripts/get_maintainer.pl 0001-vfio-platform-add-support-for-ACPI-while-detecting-t.patch
Baptiste Reynal <[email protected]> (maintainer:VFIO PLATFORM DRIVER,commit_signer:1/5=20%)
Alex Williamson <[email protected]> (maintainer:VFIO DRIVER,commit_signer:2/3=67%,commit_signer:4/5=80%) ../..
Quoted 7 lines
Quoted 5 lines
On my side I tested with of amd xgbe and I don't observe any regression.
Best Regards
Can I add your tested by?
Well to make things clear I did not test the ACPI part. I just can tell this does not bring any regression on the of part. But I am not against if you don't find anybody else and you tested the ACPI part ;-)
Best Regards
Eric
Quoted 1 line
Re: [PATCH V13 09/10] vfio, platform: add support for ACPI while detecting the reset driver
Quoted 10 lines · Eric Auger
Quoted 1 line
hanks, we should ask Baptiste to get his email into the Maintainer file list.
I think it is:
./scripts/get_maintainer.pl0001-vfio-platform-add-support-for-ACPI-while-detecting-t.patchBaptiste Reynal <[email protected]> (maintainer:VFIO PLATFORM DRIVER,commit_signer:1/5=20%)
Alex Williamson <[email protected]> (maintainer:VFIO DRIVER,commit_signer:2/3=67%,commit_signer:4/5=80%) ../..
Strange, I'll reset my tree.
Quoted 11 lines
Quoted 7 lines
Quoted 7 lines
Quoted 5 lines
Quoted 5 lines
On my side I tested with of amd xgbe and I don't observe any regression.
Best Regards
Can I add your tested by?
Well to make things clear I did not test the ACPI part. I just can tell this does not bring any regression on the of part. But I am not against if you don't find anybody else and you tested the ACPI part ;-)
How about?
of-tested-by: ...
Shanker and I tested ACPI before pushing the patches to the list and we also posted the corresponding QEMU patches as well to the qemu-devel maillist.
http://patchwork.ozlabs.org/patch/575878/
I'll ask him to add his acpi-tested-by for the ACPI part.
Quoted 1 line
Best Regards
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 V13 09/10] vfio, platform: add support for ACPI while detecting the reset driver
Quoted 8 lines · Sinan Kaya
of-tested-by: ...
Shanker and I tested ACPI before pushing the patches to the list and we also posted the corresponding QEMU patches as well to the qemu-devel maillist.
http://patchwork.ozlabs.org/patch/575878/
I'll ask him to add his acpi-tested-by for the ACPI part.
I would rather not see a tested-by variant, and instead add comments to the line, like this:
That way, people can still grep for "^Tested-by:".
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 V13 09/10] vfio, platform: add support for ACPI while detecting the reset driver
Quoted 8 lines · Timur Tabi
Quoted 7 lines · Sinan Kaya
of-tested-by: ...
Shanker and I tested ACPI before pushing the patches to the list and we also posted the corresponding QEMU patches as well to the qemu-devel maillist.
Quoted 9 lines
Quoted 1 line
I'll ask him to add his acpi-tested-by for the ACPI part.
I would rather not see a tested-by variant, and instead add comments to the line, like this:
That way, people can still grep for "^Tested-by:".
will do.
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 V13 08/10] dma: qcom_hidma: read the channel id from HW
In reply to Mark RutlandHi Mark,
Quoted 9 lines · Mark Rutland
Quoted 3 lines
Removing the flexibility to choose the event channel as there is no real
Quoted 2 lines
use case right now. We have been using the values in ACPI that match the HW defaults. OS is reading the event-channel from the HW register now.
Fold this in to the patches adding the binding and the driver.
There is no reason to add this then remove it within the same series.
Mark.
Before I post the next rev, I'd like to see if I missed something in the series when it comes to your comments.
Can you please take a look and let me know?
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 V13 08/10] dma: qcom_hidma: read the channel id from HW
In reply to Rob HerringQuoted 5 lines · Rob Herring
Quoted 4 lines · Sinan Kaya
Removing the flexibility to choose the event channel as there is no real use case right now. We have been using the values in ACPI that match the HW defaults. OS is reading the event-channel from the HW register now.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Sinan Kaya <[email protected]>--- .../devicetree/bindings/dma/qcom_hidma_mgmt.txt | 3 -- drivers/dma/qcom/hidma.c | 39 +--------------------- 2 files changed, 1 insertion(+), 41 deletions(-)Acked-by Rob Herring <[email protected]>
Thanks Rob,
I'll merge this patch to the existing documentation and code on the next rev.
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 V13 08/10] dma: qcom_hidma: read the channel id from HW
In reply to Sinan KayaQuoted 10 lines · Sinan Kaya
Hi Mark,
Quoted 7 lines · Mark Rutland
Quoted 3 lines
Removing the flexibility to choose the event channel as there is no real
Quoted 2 lines
use case right now. We have been using the values in ACPI that match the HW defaults. OS is reading the event-channel from the HW register now.
Fold this in to the patches adding the binding and the driver.
There is no reason to add this then remove it within the same series.
Quoted 7 lines
Quoted 2 lines
Mark.
Before I post the next rev, I'd like to see if I missed something in the series when it comes to your comments.
Can you please take a look and let me know?
Sorry, but it's going to be far easier to review with useless code removed, so I will wait until the next posting where this patch is folded in.
Thanks,
Mark.
Re: [PATCH V13 09/10] vfio, platform: add support for ACPI while detecting the reset driver
In reply to Eric AugerHi Baptiste, Alex;
Quoted 6 lines · Eric Auger
Quoted 3 lines
Quoted 3 lines
I added Baptiste who is vfio platform driver sub-system maintainer.
Thanks, we should ask Baptiste to get his email into the Maintainer file list.
I think it is:
./scripts/get_maintainer.pl0001-vfio-platform-add-support-for-ACPI-while-detecting-t.patch
Any comments on these two reviews?
https://lkml.org/lkml/2016/1/29/679
https://lkml.org/lkml/2016/1/29/677
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 V13 08/10] dma: qcom_hidma: read the channel id from HW
In reply to Mark RutlandQuoted 7 lines · Mark Rutland
Quoted 1 line
Can you please take a look and let me know?
Sorry, but it's going to be far easier to review with useless code removed, so I will wait until the next posting where this patch is folded in.
Thanks,
Mark.
OK, I'll post the next rev by the end of this week.
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 V13 08/10] dma: qcom_hidma: read the channel id from HW
In reply to Mark RutlandHi Mark,
Quoted 3 lines · Mark Rutland
Sorry, but it's going to be far easier to review with useless code removed, so I will wait until the next posting where this patch is folded in.
V14 of the patch have been posted on the mail-list where this patch has been folder into the existing code.
https://lkml.org/lkml/2016/2/4/1086
I have also captured the information you previously asked into the cover letter as you asked.
I'm looking forward to hear your other comments.
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 V13 08/10] dma: qcom_hidma: read the channel id from HW
Quoted 9 lines · Sinan Kaya
Hi Mark,
Quoted 3 lines · Mark Rutland
Quoted 3 lines
Sorry, but it's going to be far easier to review with useless code removed, so I will wait until the next posting where this patch is folded in.
V14 of the patch have been posted on the mail-list where this patch has been folder into the existing code.
Quoted 7 lines
https://lkml.org/lkml/2016/2/4/1086
I have also captured the information you previously asked into the cover letter as you asked.
I'm looking forward to hear your other comments.
Sinan
ping
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