dmaengine: add Qualcomm Technologies HIDMA driver
Subsystems (4)
v17 cover dmaengine: 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
------------------------
- fix merge conflict introduced in v16
------------------------
Git repos
------------------------
QEMU Support
https://www.codeaurora.org/cgit/quic/qemu/qemu/log/?h=v2.5.0-sriov
------------------------
History of Changes
------------------------
dma: qcom_hidma: implement lower level hardware interface
Changes from V16:
(https://www.mail-archive.com/linux-kernel at vger.kernel.org/msg1119709.html)
* correct the merge conflict in IRQ handler by moving the while loop to the correct place
Sinan Kaya (3):
dmaengine: qcom_hidma: implement lower level hardware interface
dmaengine: qcom_hidma: add debugfs hooks
dmaengine: qcom_hidma: add support for object hierarchy
Documentation/ABI/testing/sysfs-platform-hidma | 9 + drivers/dma/qcom/Makefile | 2 + drivers/dma/qcom/hidma.c | 44 +- drivers/dma/qcom/hidma.h | 22 +- drivers/dma/qcom/hidma_dbg.c | 219 ++++++ drivers/dma/qcom/hidma_ll.c | 900 +++++++++++++++++++++++++ drivers/dma/qcom/hidma_mgmt.c | 113 +++- 7 files changed, 1293 insertions(+), 16 deletions(-) create mode 100644 Documentation/ABI/testing/sysfs-platform-hidma create mode 100644 drivers/dma/qcom/hidma_dbg.c create mode 100644 drivers/dma/qcom/hidma_ll.c
Signature · 1 line
1.8.2.1
PATCH v17 1/3 dmaengine: qcom_hidma: implement lower level hardware interface
This patch implements the hardware hooks for the HIDMA channel driver.
The main functions of interest are:
- hidma_ll_init
- hidma_ll_request
- hidma_ll_queue_request
- hidma_ll_hw_start
OS layer calls the hidma_ll_init function during probe to set up the hardware. At this moment, the number of supported descriptors are also given. On each request, a descriptor is allocated from the free pool and filled in with the transfer parameters. Multiple requests can be queued into the hardware via the OS interface. When client is ready for requests to be executed, start method is called.
Completions are delivered via callbacks via tasklet.
--- drivers/dma/qcom/Makefile | 2 + drivers/dma/qcom/hidma.h | 20 +- drivers/dma/qcom/hidma_ll.c | 900 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 912 insertions(+), 10 deletions(-) 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 +10 -10
@@ -1,7 +1,7 @@/* * Qualcomm Technologies HIDMA data structures * -* Copyright (c) 2014, The Linux Foundation. All rights reserved. +* Copyright (c) 2014-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
@@ -20,13 +20,13 @@#include <linux/interrupt.h> #include <linux/dmaengine.h> -#define TRE_SIZE 32/* each TRE is 32 bytes */ -#define TRE_CFG_IDX 0 -#define TRE_LEN_IDX 1 -#define TRE_SRC_LOW_IDX 2 -#define TRE_SRC_HI_IDX 3 -#define TRE_DEST_LOW_IDX 4 -#define TRE_DEST_HI_IDX 5 +#define HIDMA_TRE_SIZE 32/* each TRE is 32 bytes */ +#define HIDMA_TRE_CFG_IDX 0 +#define HIDMA_TRE_LEN_IDX 1 +#define HIDMA_TRE_SRC_LOW_IDX 2 +#define HIDMA_TRE_SRC_HI_IDX 3 +#define HIDMA_TRE_DEST_LOW_IDX 4 +#define HIDMA_TRE_DEST_HI_IDX 5struct hidma_tx_status {u8 err_info;/* error record in this transfer */
@@ -37,13 +37,13 @@ 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 */ void *data;/* Data associated with this channel*/ struct hidma_lldev *lldev;/* lldma device pointer */ -u32 tre_local[TRE_SIZE /sizeof (u32) +1 ];/* TRE local copy */ +u32 tre_local[HIDMA_TRE_SIZE /sizeof (u32) +1 ];/* TRE local copy */ u32 tre_index;/* the offset where this was written*/ u32 int_flags;/* interrupt flags */ };
drivers/dma/qcom/hidma_ll.c new file +900 -0
900 lines not on this page · raw message
Signature · 1 line
1.8.2.1
Re: [PATCH V17 1/3] dmaengine: qcom_hidma: implement lower level hardware interface
Quoted 3 lines · Sinan Kaya
+ * HIDMA is not aware of IOMMU presence since it follows the DMA API. All
+ * IOMMU latency will be built into the data movement time. By the time
+ * interrupt happens, IOMMU lookups + data movement has already taken place.
Do you mean dmaengine API or dma mapping API here? Where is you IOMMU located wrt to dma controller?
Quoted 19 lines
+ *
+ * While the first read in a typical PCI endpoint ISR flushes all outstanding
+ * requests traditionally to the destination, this concept does not apply
+ * here for this HW.
+ */drivers/dma/qcom/hidma_ll.c new file +14
-0+static void hidma_ll_int_handler_internal (struct hidma_lldev *lldev) +{ +u32 status; +u32 enable; +u32 cause; + +/* +* Fine tuned for this HW... +* +* This ISR has been designed for this particular hardware. Relaxed +* read and write accessors are used for performance reasons due to +* interrupt delivery guarantees. Do not copy this code blindly and +* expect that to work. +*/
drivers/dma/qcom/hidma_ll.c line 445
Quoted 10 lines
drivers/dma/qcom/hidma_ll.c new file +10
-0+ status =readl_relaxed (lldev->evca +HIDMA_EVCA_IRQ_STAT_REG ); + enable =readl_relaxed (lldev->evca +HIDMA_EVCA_IRQ_EN_REG ); + cause = status & enable; + +while (cause) { +if ((cause &BIT (HIDMA_IRQ_TR_CH_INVALID_TRE_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_TR_CH_TRE_RD_RSP_ER_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_EV_CH_WR_RESP_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_TR_CH_DATA_RD_ER_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_TR_CH_DATA_WR_ER_BIT_POS ))) {
Switch please
drivers/dma/qcom/hidma_ll.c line 458
Quoted 13 lines
drivers/dma/qcom/hidma_ll.c new file +13
-0+u8 err_code =HIDMA_EVRE_STATUS_ERROR ; +u8 err_info =0xFF ; + +/* Clear out pending interrupts */ +writel (cause, lldev->evca +HIDMA_EVCA_IRQ_CLR_REG ); + +dev_err (lldev->dev,"error 0x%x, resetting...\n" , + cause); + +hidma_cleanup_pending_tre (lldev, err_info, err_code); + +/* reset the channel for recovery */ +if (hidma_ll_setup (lldev)) {
should this be done in ISR?
drivers/dma/qcom/hidma_ll.c line 527
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c new file +4
-0+int hidma_ll_resume (struct hidma_lldev *lldev) +{ +return hidma_ll_enable (lldev); +}
why do we need this empty function, use hidma_ll_enable.
Quoted 5 lines
drivers/dma/qcom/hidma_ll.c new file +5
-0+bool hidma_ll_isenabled (struct hidma_lldev *lldev) +{ +u32 val; + + val =readl (lldev->trca +HIDMA_TRCA_CTRLSTS_REG );
drivers/dma/qcom/hidma_ll.c line 552
Quoted 10 lines
drivers/dma/qcom/hidma_ll.c new file +10
-0+ lldev->trch_state =HIDMA_CH_STATE (val); + val =readl (lldev->evca +HIDMA_EVCA_CTRLSTS_REG ); + lldev->evch_state =HIDMA_CH_STATE (val); + +/* both channels have to be enabled before calling this function */ +if (((lldev->trch_state ==HIDMA_CH_ENABLED ) || + (lldev->trch_state ==HIDMA_CH_RUNNING )) && + ((lldev->evch_state ==HIDMA_CH_ENABLED ) || + (lldev->evch_state ==HIDMA_CH_RUNNING ))) +return true;
hmmm this looks hard to read, why not do:
is_chan_enabled(state)
{
switch (state) {
case HIDMA_CH_ENABLED:
case HIDMA_CH_RUNNING:
return true;
default:
return false;
}and then :
if (is_chan_enabled(lldev->trch_state) && is_chan_enabled(lldev->evch_state))
drivers/dma/qcom/hidma_ll.c line 582
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c new file +4
-0+void hidma_ll_start (struct hidma_lldev *lldev) +{ +hidma_ll_hw_start (lldev); +}
Another dummy :(
Quoted 6 lines
+/*
+ * Note that even though we stop this channel
+ * if there is a pending transaction in flight
+ * it will complete and follow the callback.
+ * This request will prevent further requests
+ * to be made.
Why the odd formating?
Quoted 19 lines
drivers/dma/qcom/hidma_ll.c new file +19
-0+int hidma_ll_uninit (struct hidma_lldev *lldev) +{ +int rc =0 ; +u32 val; + +if (!lldev) +return -ENODEV ; + +if (lldev->initialized) { +u32 required_bytes; + + lldev->initialized =0 ; + + required_bytes =sizeof (struct hidma_tre ) * lldev->nr_tres; +tasklet_kill (&lldev->task); +memset (lldev->trepool,0 , required_bytes); + lldev->trepool =NULL ; + lldev->pending_tre_count =0 ; + lldev->tre_write_offset =0 ;
drivers/dma/qcom/hidma_ll.c line 869
Quoted 10 lines
drivers/dma/qcom/hidma_ll.c new file +10
-0+ + rc =hidma_ll_reset (lldev); + +/* +* Clear all pending interrupts again. +* Otherwise, we observe reset complete interrupts. +*/ + val =readl (lldev->evca +HIDMA_EVCA_IRQ_STAT_REG ); +writel (val, lldev->evca +HIDMA_EVCA_IRQ_CLR_REG ); +hidma_ll_enable_irq (lldev,0 );
uninit enables irq?
Signature · 1 line
~Vinod
Re: [PATCH V17 1/3] dmaengine: qcom_hidma: implement lower level hardware interface
Quoted 8 lines · Vinod Koul
Quoted 3 lines · Sinan Kaya
+ * HIDMA is not aware of IOMMU presence since it follows the DMA API. All
+ * IOMMU latency will be built into the data movement time. By the time
+ * interrupt happens, IOMMU lookups + data movement has already taken place.Do you mean dmaengine API or dma mapping API here? Where is you IOMMU located wrt to dma controller?
I mean DMA API in this context. The code works on dma_addr_t. That means the caller takes care of DMA mapping before coming to this code. This code is not involved in any of the DMA mapping calls or any other IOMMU related operations. All of this is abstracted from this code.
The IOMMU is right in front of this device. That's why, all IOMMU operations are inclusive into the data transfers.
Quoted 24 lines
Quoted 24 lines
+ *
+ * While the first read in a typical PCI endpoint ISR flushes all outstanding
+ * requests traditionally to the destination, this concept does not apply
+ * here for this HW.
+ */drivers/dma/qcom/hidma_ll.c new file +18
-0+static void hidma_ll_int_handler_internal (struct hidma_lldev *lldev) +{ +u32 status; +u32 enable; +u32 cause; + +/* +* Fine tuned for this HW... +* +* This ISR has been designed for this particular hardware. Relaxed +* read and write accessors are used for performance reasons due to +* interrupt delivery guarantees. Do not copy this code blindly and +* expect that to work. +*/ + status =readl_relaxed (lldev->evca +HIDMA_EVCA_IRQ_STAT_REG ); + enable =readl_relaxed (lldev->evca +HIDMA_EVCA_IRQ_EN_REG ); + cause = status & enable; +
Quoted 8 lines
drivers/dma/qcom/hidma_ll.c line 445
Quoted 6 lines
drivers/dma/qcom/hidma_ll.c new file +6
-0+while (cause) { +if ((cause &BIT (HIDMA_IRQ_TR_CH_INVALID_TRE_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_TR_CH_TRE_RD_RSP_ER_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_EV_CH_WR_RESP_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_TR_CH_DATA_RD_ER_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_TR_CH_DATA_WR_ER_BIT_POS ))) {Switch please
Cause is a combined status register. Let's say it contains 0x41. I need to check if bit 0 or bit 6 is set in this value for each case condition. The value is not 0x40 or 0x1.
I created macro like this instead.
+#define HIDMA_IS_ERR_INTERRUPT(cause) \
+ (cause & BIT(HIDMA_IRQ_TR_CH_INVALID_TRE_BIT_POS)) || \ + (cause & BIT(HIDMA_IRQ_TR_CH_TRE_RD_RSP_ER_BIT_POS)) || \ + (cause & BIT(HIDMA_IRQ_EV_CH_WR_RESP_BIT_POS)) || \ + (cause & BIT(HIDMA_IRQ_TR_CH_DATA_RD_ER_BIT_POS)) || \ + (cause & BIT(HIDMA_IRQ_TR_CH_DATA_WR_ER_BIT_POS))
and replaced the if statement as follows
if (HIDMA_IS_ERR_INTERRUPT(cause)) {
Quoted 16 lines
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c new file +3
-0+u8 err_code =HIDMA_EVRE_STATUS_ERROR ; +u8 err_info =0xFF ; +drivers/dma/qcom/hidma_ll.c line 458
Quoted 10 lines
drivers/dma/qcom/hidma_ll.c new file +10
-0+/* Clear out pending interrupts */ +writel (cause, lldev->evca +HIDMA_EVCA_IRQ_CLR_REG ); + +dev_err (lldev->dev,"error 0x%x, resetting...\n" , + cause); + +hidma_cleanup_pending_tre (lldev, err_info, err_code); + +/* reset the channel for recovery */ +if (hidma_ll_setup (lldev)) {should this be done in ISR?
I created a new tasklet called rst_task and posted the code there.
/*
+ * Abort all transactions and perform a reset.
+ */
+static void hidma_ll_abort(unsigned long arg)
+{
+ u8 err_code = HIDMA_EVRE_STATUS_ERROR;
+ u8 err_info = 0xFF;
+
+ dev_err(lldev->dev, "error 0x%x, resetting...\n",
+ cause);
+
+ hidma_cleanup_pending_tre(lldev, err_info, err_code);
+
+ /* reset the channel for recovery */
+ if (hidma_ll_setup(lldev)) {
+ dev_err(lldev->dev,
+ "channel reinitialize failed after error\n");
+ return;
+ }
+ hidma_ll_control_irq(lldev, ENABLE_IRQS);
+}
+ if (HIDMA_IS_ERR_INTERRUPT(cause)) {
/* Clear out pending interrupts */
writel(cause, lldev->evca + HIDMA_EVCA_IRQ_CLR_REG);- dev_err(lldev->dev, "error 0x%x, resetting...\n",
- cause);
-
- hidma_cleanup_pending_tre(lldev, err_info, err_code);
-
- /* reset the channel for recovery */
- if (hidma_ll_setup(lldev)) {
- dev_err(lldev->dev,
- "channel reinitialize failed after error\n");
- return;
- } - hidma_ll_enable_irq(lldev, ENABLE_IRQS); + tasklet_schedule(&lldev->rst_task);
Quoted 7 lines
drivers/dma/qcom/hidma_ll.c line 527
Quoted 5 lines
drivers/dma/qcom/hidma_ll.c new file +4
-0+int hidma_ll_resume (struct hidma_lldev *lldev) +{ +return hidma_ll_enable (lldev); +}why do we need this empty function, use
hidma_ll_enable.
hidma_ll_enable is a common function that gets called from multiple places. hidma_ll_resume and hidma_ll_pause is used by the OS interface for pausing and resuming the DMA channel.
Quoted 29 lines
Quoted 6 lines
drivers/dma/qcom/hidma_ll.c new file +5
-0+bool hidma_ll_isenabled (struct hidma_lldev *lldev) +{ +u32 val; + + val =readl (lldev->trca +HIDMA_TRCA_CTRLSTS_REG );drivers/dma/qcom/hidma_ll.c line 552
Quoted 10 lines
drivers/dma/qcom/hidma_ll.c new file +10
-0+ lldev->trch_state =HIDMA_CH_STATE (val); + val =readl (lldev->evca +HIDMA_EVCA_CTRLSTS_REG ); + lldev->evch_state =HIDMA_CH_STATE (val); + +/* both channels have to be enabled before calling this function */ +if (((lldev->trch_state ==HIDMA_CH_ENABLED ) || + (lldev->trch_state ==HIDMA_CH_RUNNING )) && + ((lldev->evch_state ==HIDMA_CH_ENABLED ) || + (lldev->evch_state ==HIDMA_CH_RUNNING ))) +return true;hmmm this looks hard to read, why not do:
is_chan_enabled(state){ switch (state) { case HIDMA_CH_ENABLED: case HIDMA_CH_RUNNING: return true; default: return false; }
Quoted 5 lines
and then :
if (is_chan_enabled(lldev->trch_state) && is_chan_enabled(lldev->evch_state))
Sure, makes sense.
Quoted 7 lines
drivers/dma/qcom/hidma_ll.c line 582
Quoted 5 lines
drivers/dma/qcom/hidma_ll.c new file +4
-0+void hidma_ll_start (struct hidma_lldev *lldev) +{ +hidma_ll_hw_start (lldev); +}Another dummy :(
renamed hidma_ll_hw_start to hidma_ll_start and removed this function.
Quoted 9 lines
Quoted 7 lines
+/*
+ * Note that even though we stop this channel
+ * if there is a pending transaction in flight
+ * it will complete and follow the callback.
+ * This request will prevent further requests
+ * to be made.Why the odd formating?
aligned to 75 characters.
Quoted 24 lines
Quoted 24 lines
drivers/dma/qcom/hidma_ll.c new file +23
-0+int hidma_ll_uninit (struct hidma_lldev *lldev) +{ +int rc =0 ; +u32 val; + +if (!lldev) +return -ENODEV ; + +if (lldev->initialized) { +u32 required_bytes; + + lldev->initialized =0 ; + + required_bytes =sizeof (struct hidma_tre ) * lldev->nr_tres; +tasklet_kill (&lldev->task); +memset (lldev->trepool,0 , required_bytes); + lldev->trepool =NULL ; + lldev->pending_tre_count =0 ; + lldev->tre_write_offset =0 ; + + rc =hidma_ll_reset (lldev); + +/*
Quoted 9 lines
drivers/dma/qcom/hidma_ll.c line 710
Quoted 6 lines
drivers/dma/qcom/hidma_ll.c new file +6
-0+* Clear all pending interrupts again. +* Otherwise, we observe reset complete interrupts. +*/ + val =readl (lldev->evca +HIDMA_EVCA_IRQ_STAT_REG ); +writel (val, lldev->evca +HIDMA_EVCA_IRQ_CLR_REG ); +hidma_ll_enable_irq (lldev,0 );uninit enables irq?
renamed to hidma_ll_control_irq. Second argument is the bits to enable. If 0, interrupts are disabled.
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 V17 1/3] dmaengine: qcom_hidma: implement lower level hardware interface
Quoted 18 lines · Sinan Kaya
Quoted 10 lines · Vinod Koul
drivers/dma/qcom/hidma_ll.c line 445
Quoted 6 lines · Sinan Kaya
drivers/dma/qcom/hidma_ll.c new file +6
-0+while (cause) { +if ((cause &BIT (HIDMA_IRQ_TR_CH_INVALID_TRE_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_TR_CH_TRE_RD_RSP_ER_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_EV_CH_WR_RESP_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_TR_CH_DATA_RD_ER_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_TR_CH_DATA_WR_ER_BIT_POS ))) {Switch please
Cause is a combined status register. Let's say it contains
0x41. I need to check if bit 0 or bit 6 is set in this value for each case condition. The value is not0x40or0x1.I created macro like this instead.
Review
Quoted 6 lines
(quoted diff) +6
-0+#define HIDMA_IS_ERR_INTERRUPT(cause) \ + (cause & BIT(HIDMA_IRQ_TR_CH_INVALID_TRE_BIT_POS)) || \ + (cause & BIT(HIDMA_IRQ_TR_CH_TRE_RD_RSP_ER_BIT_POS)) || \ + (cause & BIT(HIDMA_IRQ_EV_CH_WR_RESP_BIT_POS)) || \ + (cause & BIT(HIDMA_IRQ_TR_CH_DATA_RD_ER_BIT_POS)) || \ + (cause & BIT(HIDMA_IRQ_TR_CH_DATA_WR_ER_BIT_POS))
This looks overheaded.
#define HIDMA_XXX (BIT(a) | BIT (b) ... BIT(n))
Quoted 4 lines
and replaced the if statement as follows
if (
HIDMA_IS_ERR_INTERRUPT(cause)) {
if (cause & HIDMA_XXX) {
Signature · 2 lines
With Best Regards, Andy Shevchenko
Re: [PATCH V17 1/3] dmaengine: qcom_hidma: implement lower level hardware interface
Quoted 28 lines · Andy Shevchenko
Quoted 18 lines · Sinan Kaya
Quoted 10 lines · Vinod Koul
drivers/dma/qcom/hidma_ll.c line 445
Quoted 6 lines · Sinan Kaya
drivers/dma/qcom/hidma_ll.c new file +6
-0+while (cause) { +if ((cause &BIT (HIDMA_IRQ_TR_CH_INVALID_TRE_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_TR_CH_TRE_RD_RSP_ER_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_EV_CH_WR_RESP_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_TR_CH_DATA_RD_ER_BIT_POS )) || + (cause &BIT (HIDMA_IRQ_TR_CH_DATA_WR_ER_BIT_POS ))) {Switch please
Cause is a combined status register. Let's say it contains
0x41. I need to check if bit 0 or bit 6 is set in this value for each case condition. The value is not0x40or0x1.I created macro like this instead.
Review
Quoted 6 lines
(quoted diff) +6
-0+#define HIDMA_IS_ERR_INTERRUPT(cause) \ + (cause & BIT(HIDMA_IRQ_TR_CH_INVALID_TRE_BIT_POS)) || \ + (cause & BIT(HIDMA_IRQ_TR_CH_TRE_RD_RSP_ER_BIT_POS)) || \ + (cause & BIT(HIDMA_IRQ_EV_CH_WR_RESP_BIT_POS)) || \ + (cause & BIT(HIDMA_IRQ_TR_CH_DATA_RD_ER_BIT_POS)) || \ + (cause & BIT(HIDMA_IRQ_TR_CH_DATA_WR_ER_BIT_POS))This looks overheaded.
Quoted 9 lines
#define
HIDMA_XXX(BIT(a) | BIT (b) ... BIT(n))Quoted 4 lines
and replaced the if statement as follows
if (
HIDMA_IS_ERR_INTERRUPT(cause)) {if (cause &
HIDMA_XXX) {
This is even better.
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 V17 1/3] dmaengine: qcom_hidma: implement lower level hardware interface
In reply to Sinan KayaQuoted 8 lines · Sinan Kaya
Quoted 5 lines · Vinod Koul
drivers/dma/qcom/hidma_ll.c line 458
Quoted 3 lines
drivers/dma/qcom/hidma_ll.c new file +3
-0+ +/* reset the channel for recovery */ +if (hidma_ll_setup (lldev)) {should this be done in ISR?
I created a new tasklet called
rst_taskand posted the code there.
sounds better
drivers/dma/qcom/hidma_ll.c line 453
Quoted 11 lines
/*
+ * Abort all transactions and perform a reset.
+ */drivers/dma/qcom/hidma_ll.c new file +7
-0+static void hidma_ll_abort (unsigned long arg) +{ +u8 err_code =HIDMA_EVRE_STATUS_ERROR ; +u8 err_info =0xFF ; + +dev_err (lldev->dev,"error 0x%x, resetting...\n" , + cause);
right justify this and others as well please
Quoted 10 lines
Quoted 6 lines
drivers/dma/qcom/hidma_ll.c line 527
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c new file +4
-0+int hidma_ll_resume (struct hidma_lldev *lldev) +{ +return hidma_ll_enable (lldev); +}why do we need this empty function, use
hidma_ll_enable.
hidma_ll_enableis a common function that gets called from multiple places.hidma_ll_resumeandhidma_ll_pauseis used by the OS interface for pausing and resuming the DMA channel.
is there a reason why we can't have the code in resume and that being called internally as well as externally?
Quoted 10 lines
Quoted 8 lines
Quoted 6 lines
+/*
+ * Note that even though we stop this channel
+ * if there is a pending transaction in flight
+ * it will complete and follow the callback.
+ * This request will prevent further requests
+ * to be made.Why the odd formating?
aligned to 75 characters.
This seems to be 50 chars!
Signature · 1 line
~Vinod
Re: [PATCH V17 1/3] dmaengine: qcom_hidma: implement lower level hardware interface
Quoted 5 lines · Vinod Koul
Quoted 3 lines
+
Quoted 2 lines
drivers/dma/qcom/hidma_ll.c new file +2
-0+dev_err (lldev->dev,"error 0x%x, resetting...\n" , + cause);right justify this and others as well please
Can you please point me to other lines that need to be fixed please? It looks good to me though it doesn't to you. I want to make sure that I'm touching the right ones. You seem to prefer a tab following an open parenthesis in your code. Do you want me to add a tab for every single multi-line such that it comes this for instance?
ret = readl_poll_timeout(lldev->trca + HIDMA_TRCA_CTRLSTS_REG, val, HIDMA_CH_STATE(val) == HIDMA_CH_DISABLED, 1000, 10000);
instead of
ret = readl_poll_timeout(lldev->trca + HIDMA_TRCA_CTRLSTS_REG, val, HIDMA_CH_STATE(val) == HIDMA_CH_DISABLED, 1000, 10000);
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c line 527
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c new file +4
-0+int hidma_ll_resume (struct hidma_lldev *lldev) +{ +return hidma_ll_enable (lldev); +}why do we need this empty function, use
hidma_ll_enable.
Quoted 6 lines
Quoted 3 lines
Quoted 3 lines
hidma_ll_enableis a common function that gets called from multiple places.hidma_ll_resumeandhidma_ll_pauseis used by the OS interface for pausing and resuming the DMA channel.is there a reason why we can't have the code in resume and that being called internally as well as externally?
I'll have the pause code in OS layer call hidma_ll_enable and get rid of pause function here.
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 V17 1/3] dmaengine: qcom_hidma: implement lower level hardware interface
Quoted 34 lines · Sinan Kaya
Quoted 5 lines · Vinod Koul
Quoted 3 lines
+
Quoted 2 lines
drivers/dma/qcom/hidma_ll.c new file +2
-0+dev_err (lldev->dev,"error 0x%x, resetting...\n" , + cause);right justify this and others as well please
Can you please point me to other lines that need to be fixed please? It looks good to me though it doesn't to you. I want to make sure that I'm touching the right ones. You seem to prefer a tab following an open parenthesis in your code. Do you want me to add a tab for every single multi-line such that it comes this for instance?
ret = readl_poll_timeout(lldev->trca + HIDMA_TRCA_CTRLSTS_REG, val, HIDMA_CH_STATE(val) == HIDMA_CH_DISABLED, 1000, 10000);instead of
ret = readl_poll_timeout(lldev->trca + HIDMA_TRCA_CTRLSTS_REG, val, HIDMA_CH_STATE(val) == HIDMA_CH_DISABLED, 1000, 10000);Quoted 10 lines
Quoted 10 lines
Quoted 10 lines
Quoted 6 lines
Quoted 6 lines
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c line 527
Quoted 4 lines
drivers/dma/qcom/hidma_ll.c new file +4
-0+int hidma_ll_resume (struct hidma_lldev *lldev) +{ +return hidma_ll_enable (lldev); +}why do we need this empty function, use
hidma_ll_enable.
hidma_ll_enableis a common function that gets called from multiple places.hidma_ll_resumeandhidma_ll_pauseis used by the OS interface for pausing and resuming the DMA channel.
Quoted 7 lines
Quoted 3 lines
is there a reason why we can't have the code in resume and that being called internally as well as externally?
I'll have the pause code in OS layer call
hidma_ll_enableand get rid of pause function here.
I posted v18 along with all the style corrections and other things you asked me. Please let me know if there is anything outstanding.
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
PATCH v17 2/3 dmaengine: 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 | 5 +- drivers/dma/qcom/hidma.h | 2 + drivers/dma/qcom/hidma_dbg.c | 219 +++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 226 insertions(+), 2 deletions(-) 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 +4 -1
@@ -1,7 +1,7 @@/* * Qualcomm Technologies HIDMA DMA engine interface * -* Copyright (c) 2015, The Linux Foundation. All rights reserved. +* Copyright (c) 2015-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
@@ -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
Re: [PATCH V17 2/3] dmaengine: qcom_hidma: add debugfs hooks
drivers/dma/qcom/hidma_dbg.c line 99
Quoted 7 lines · Sinan Kaya
drivers/dma/qcom/hidma_dbg.c new file +7
-0+static int hidma_chan_stats (struct seq_file *s,void *unused) +{ +struct hidma_chan *mchan = s->private; +struct hidma_desc *mdesc; +struct hidma_dev *dmadev = mchan->dmadev; + +pm_runtime_get_sync (dmadev->ddev.dev);
debug shouldn't power up device, why do you want to do that
Signature · 1 line
~Vinod
Re: [PATCH V17 2/3] dmaengine: qcom_hidma: add debugfs hooks
Quoted 11 lines · Vinod Koul
drivers/dma/qcom/hidma_dbg.c line 99
Quoted 7 lines · Sinan Kaya
drivers/dma/qcom/hidma_dbg.c new file +7
-0+static int hidma_chan_stats (struct seq_file *s,void *unused) +{ +struct hidma_chan *mchan = s->private; +struct hidma_desc *mdesc; +struct hidma_dev *dmadev = mchan->dmadev; + +pm_runtime_get_sync (dmadev->ddev.dev);debug shouldn't power up device, why do you want to do that
Clocks are turned off while the hw is idle. I can?t reach hw registers without restoring power.
Re: [PATCH V17 2/3] dmaengine: qcom_hidma: add debugfs hooks
Quoted 14 lines · On Tue, Apr 26, 2016 at 08:08:16AM -0400, [email protected] wrote:
Quoted 11 lines · Vinod Koul
drivers/dma/qcom/hidma_dbg.c line 99
Quoted 7 lines · Sinan Kaya
drivers/dma/qcom/hidma_dbg.c new file +7
-0+static int hidma_chan_stats (struct seq_file *s,void *unused) +{ +struct hidma_chan *mchan = s->private; +struct hidma_desc *mdesc; +struct hidma_dev *dmadev = mchan->dmadev; + +pm_runtime_get_sync (dmadev->ddev.dev);debug shouldn't power up device, why do you want to do that
Quoted 2 lines
Clocks are turned off while the hw is idle. I can’t reach hw registers without restoring power.
Hmm, have you thought about using regmap?
Signature · 1 line
~Vinod
Re: [PATCH V17 2/3] dmaengine: qcom_hidma: add debugfs hooks
Quoted 15 lines · Vinod Koul
Quoted 14 lines · okaya at codeaurora.org
Quoted 11 lines · Vinod Koul
drivers/dma/qcom/hidma_dbg.c line 99
Quoted 7 lines · Sinan Kaya
drivers/dma/qcom/hidma_dbg.c new file +7
-0+static int hidma_chan_stats (struct seq_file *s,void *unused) +{ +struct hidma_chan *mchan = s->private; +struct hidma_desc *mdesc; +struct hidma_dev *dmadev = mchan->dmadev; + +pm_runtime_get_sync (dmadev->ddev.dev);debug shouldn't power up device, why do you want to do that
Quoted 5 lines
Quoted 2 lines
Clocks are turned off while the hw is idle. I can?t reach hw registers without restoring power.
Hmm, have you thought about using regmap?
To be honest, I didn't know what regmap is but I just read some code and looked at how it is used. Feel free to correct me if I got it wrong.
Regmap seems to be designed for *slow* speed peripherals to improve frequent accesses by the SW. It looks like it is used by MFD, SPI and I2C drivers.
It seems to cache the register contents and flush/invalidate them only when needed.
The MMIO version seems to be assuming the presence of device-tree like CLK API which doesn't exist on ACPI systems and is not portable.
My reaction is that it is a lot of code with no added functionality to what HIDMA driver is trying to achieve.
Given that the use case here is only for debug purposes; I think it is OK to keep this runtime call here. I don't want to add any overhead into the existing code just to support the debug use case.
None of my register read/writes are slow. This file will only be used to troubleshoot customer issues.
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 V17 2/3] dmaengine: qcom_hidma: add debugfs hooks
Quoted 38 lines · Sinan Kaya
Quoted 15 lines · Vinod Koul
Quoted 14 lines · On Tue, Apr 26, 2016 at 08:08:16AM -0400, [email protected] wrote:
Quoted 11 lines · Vinod Koul
drivers/dma/qcom/hidma_dbg.c line 99
Quoted 7 lines · Sinan Kaya
drivers/dma/qcom/hidma_dbg.c new file +7
-0+static int hidma_chan_stats (struct seq_file *s,void *unused) +{ +struct hidma_chan *mchan = s->private; +struct hidma_desc *mdesc; +struct hidma_dev *dmadev = mchan->dmadev; + +pm_runtime_get_sync (dmadev->ddev.dev);debug shouldn't power up device, why do you want to do that
Quoted 5 lines
Quoted 2 lines
Clocks are turned off while the hw is idle. I can’t reach hw registers without restoring power.
Hmm, have you thought about using regmap?
To be honest, I didn't know what regmap is but I just read some code and looked at how it is used. Feel free to correct me if I got it wrong.
Regmap seems to be designed for *slow* speed peripherals to improve frequent accesses by the SW. It looks like it is used by MFD, SPI and I2C drivers.
It seems to cache the register contents and flush/invalidate them only when needed.
The MMIO version seems to be assuming the presence of device-tree like CLK API which doesn't exist on ACPI systems and is not portable.
My reaction is that it is a lot of code with no added functionality to what HIDMA driver is trying to achieve.
Quoted 6 lines
Given that the use case here is only for debug purposes; I think it is OK to keep this runtime call here. I don't want to add any overhead into the existing code just to support the debug use case.
None of my register read/writes are slow. This file will only be used to troubleshoot customer issues.
$ is always faster than MMIO. This way you can give reg contents to users without waking up hw.
Also we at Intel use regmap on ACPI systems without CLK API
Signature · 1 line
~Vinod
Re: [PATCH V17 2/3] dmaengine: qcom_hidma: add debugfs hooks
Quoted 39 lines · Vinod Koul
Quoted 38 lines · Sinan Kaya
Quoted 15 lines · Vinod Koul
Quoted 14 lines · okaya at codeaurora.org
Quoted 11 lines · Vinod Koul
drivers/dma/qcom/hidma_dbg.c line 99
Quoted 7 lines · Sinan Kaya
drivers/dma/qcom/hidma_dbg.c new file +7
-0+static int hidma_chan_stats (struct seq_file *s,void *unused) +{ +struct hidma_chan *mchan = s->private; +struct hidma_desc *mdesc; +struct hidma_dev *dmadev = mchan->dmadev; + +pm_runtime_get_sync (dmadev->ddev.dev);debug shouldn't power up device, why do you want to do that
Quoted 5 lines
Quoted 2 lines
Clocks are turned off while the hw is idle. I can?t reach hw registers without restoring power.
Hmm, have you thought about using regmap?
To be honest, I didn't know what regmap is but I just read some code and looked at how it is used. Feel free to correct me if I got it wrong.
Regmap seems to be designed for *slow* speed peripherals to improve frequent accesses by the SW. It looks like it is used by MFD, SPI and I2C drivers.
It seems to cache the register contents and flush/invalidate them only when needed.
The MMIO version seems to be assuming the presence of device-tree like CLK API which doesn't exist on ACPI systems and is not portable.
My reaction is that it is a lot of code with no added functionality to what HIDMA driver is trying to achieve.
Quoted 6 lines
Quoted 6 lines
Given that the use case here is only for debug purposes; I think it is OK to keep this runtime call here. I don't want to add any overhead into the existing code just to support the debug use case.
None of my register read/writes are slow. This file will only be used to troubleshoot customer issues.
I'd recommend you actually run perf on a a few of your MMIO accesses. I believe the result will be eye opening. On the KVM side, we've trimmed our MMIO access as much as possible, using a memory-based cache (similar to regmap in concept). This has made some code paths about 40% faster.
Quoted 2 lines
$ is always faster than MMIO. This way you can give reg contents to users without waking up hw.
Indeed. MMIO access sucks rocks, even on a very fast box. Actually, the faster the box is, the slower MMIO feels (compared to memory).
Thanks,
M.
Signature · 1 line
Jazz is not dead. It just smells funny...
Re: [PATCH V17 2/3] dmaengine: qcom_hidma: add debugfs hooks
Quoted 66 lines · Marc Zyngier
Quoted 51 lines · Vinod Koul
Quoted 50 lines · Sinan Kaya
Quoted 16 lines · Vinod Koul
Quoted 14 lines · okaya at codeaurora.org
Quoted 11 lines · Vinod Koul
Review
Quoted 7 lines · Sinan Kaya
(quoted diff) +7
-0+static int hidma_chan_stats(struct seq_file *s, void *unused) +{ + struct hidma_chan *mchan = s->private; + struct hidma_desc *mdesc; + struct hidma_dev *dmadev = mchan->dmadev; + + pm_runtime_get_sync(dmadev->ddev.dev);debug shouldn't power up device, why do you want to do that
Quoted 5 lines
Quoted 2 lines
Clocks are turned off while the hw is idle. I can?t reach hw registers without restoring power.
Hmm, have you thought about using regmap?
To be honest, I didn't know what regmap is but I just read some code and looked at how it is used. Feel free to correct me if I got it wrong.
Regmap seems to be designed for *slow* speed peripherals to improve frequent
accesses by the SW. It looks like it is used by MFD, SPI and I2C drivers.It seems to cache the register contents and flush/invalidate them only when
needed.The MMIO version seems to be assuming the presence of device-tree like CLK
API which doesn't exist on ACPI systems and is not portable.My reaction is that it is a lot of code with no added functionality to what
HIDMA driver is trying to achieve.Given that the use case here is only for debug purposes; I think it is OK
to keep this runtime call here. I don't want to add any overhead into the
existing code just to support the debug use case.Quoted 3 lines
Quoted 3 lines
None of my register read/writes are slow. This file will only be used to
troubleshoot customer issues.I'd recommend you actually run perf on a a few of your MMIO accesses. I believe the result will be eye opening. On the KVM side, we've trimmed our MMIO access as much as possible, using a memory-based cache (similar
to regmap in concept). This has made some code paths about 40% faster.Quoted 3 lines
$ is always faster than MMIO. This way you can give reg contents to users without waking up hw.
Quoted 6 lines
Indeed. MMIO access sucks rocks, even on a very fast box. Actually, the faster the box is, the slower MMIO feels (compared to memory).
Thanks,
M.
Agreed. However, I need to understand how regmap really works under the covers and whether it is compatible with the hardware.
Re: [PATCH V17 2/3] dmaengine: qcom_hidma: add debugfs hooks
In reply to Vinod KoulQuoted 54 lines · Vinod Koul
Quoted 49 lines · Sinan Kaya
Quoted 15 lines · Vinod Koul
Quoted 14 lines · okaya at codeaurora.org
Quoted 11 lines · Vinod Koul
drivers/dma/qcom/hidma_dbg.c line 99
Quoted 7 lines · Sinan Kaya
drivers/dma/qcom/hidma_dbg.c new file +7
-0+static int hidma_chan_stats (struct seq_file *s,void *unused) +{ +struct hidma_chan *mchan = s->private; +struct hidma_desc *mdesc; +struct hidma_dev *dmadev = mchan->dmadev; + +pm_runtime_get_sync (dmadev->ddev.dev);debug shouldn't power up device, why do you want to do that
Quoted 5 lines
Quoted 2 lines
Clocks are turned off while the hw is idle. I can?t reach hw registers without restoring power.
Hmm, have you thought about using regmap?
To be honest, I didn't know what regmap is but I just read some code and looked at how it is used. Feel free to correct me if I got it wrong.
Regmap seems to be designed for *slow* speed peripherals to improve frequent
accesses by the SW. It looks like it is used by MFD, SPI and I2C drivers.It seems to cache the register contents and flush/invalidate them only when
needed.The MMIO version seems to be assuming the presence of device-tree like CLK
API which doesn't exist on ACPI systems and is not portable.My reaction is that it is a lot of code with no added functionality to what
HIDMA driver is trying to achieve.Given that the use case here is only for debug purposes; I think it is OK
to keep this runtime call here. I don't want to add any overhead into the
existing code just to support the debug use case.Quoted 3 lines
None of my register read/writes are slow. This file will only be used to
troubleshoot customer issues.
Quoted 5 lines
$ is always faster than MMIO. This way you can give reg contents to users without waking up hw.Also we at Intel use regmap on ACPI systems without CLK API
I can try and see the performance impact is. What happens to registers that hw updates like status registers. Those will be most interesting during debug. How does remap get updated for those? Is there a way to tell it not to cache certain registers
Re: [PATCH V17 2/3] dmaengine: qcom_hidma: add debugfs hooks
Quoted 47 lines · okaya at codeaurora.org
Quoted 46 lines · Vinod Koul
Quoted 44 lines · Sinan Kaya
Quoted 15 lines · Vinod Koul
Quoted 14 lines · okaya at codeaurora.org
Quoted 11 lines · Vinod Koul
Review
Quoted 7 lines · Sinan Kaya
(quoted diff) +7
-0+static int hidma_chan_stats(struct seq_file *s, void *unused) +{ + struct hidma_chan *mchan = s->private; + struct hidma_desc *mdesc; + struct hidma_dev *dmadev = mchan->dmadev; + + pm_runtime_get_sync(dmadev->ddev.dev);debug shouldn't power up device, why do you want to do that
Quoted 5 lines
Quoted 2 lines
Clocks are turned off while the hw is idle. I can?t reach hw registers without restoring power.
Hmm, have you thought about using regmap?
To be honest, I didn't know what regmap is but I just read some code and looked at how it is used. Feel free to correct me if I got it wrong.
Regmap seems to be designed for *slow* speed peripherals to improve frequent accesses by the SW. It looks like it is used by MFD, SPI and I2C drivers.
It seems to cache the register contents and flush/invalidate them only when needed.
The MMIO version seems to be assuming the presence of device-tree like CLK API which doesn't exist on ACPI systems and is not portable.
My reaction is that it is a lot of code with no added functionality to what HIDMA driver is trying to achieve.
Given that the use case here is only for debug purposes; I think it is OK to keep this runtime call here. I don't want to add any overhead into the existing code just to support the debug use case.
None of my register read/writes are slow. This file will only be used to troubleshoot customer issues.
Quoted 6 lines
Quoted 4 lines
$ is always faster than MMIO. This way you can give reg contents to users without waking up hw.Also we at Intel use regmap on ACPI systems without CLK API
I can try and see the performance impact is. What happens to registers that hw updates like status registers. Those will be most interesting during debug. How does remap get updated for those? Is there a way to tell it not to cache certain registers
My evaluation turned out negative. The regmap code is nice for bus like peripherals like I2C and SPI where everything is bitwise accessed. This is not the case in this code.
Regmap is a nice tool if used properly but it doesn't mean that it will work in every single case. It doesn't match with the goal of this driver.
As soon as I abstract register accesses, the regmap code writes all MMIO registers with the readl variant functions.
Barriers are really expensive on ARM. I paid very special attention in the code to decide when to use relaxed version vs. the readl version. I lose all of this optimization.
Since the clocks are restored only during the debug case, I don't see any problems here. It is not worth the effort to do redo the whole thing and introduce errors as I see a lot of tripping points like regmap_sync variants.
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 V17 2/3] dmaengine: qcom_hidma: add debugfs hooks
Quoted 29 lines · Sinan Kaya
Quoted 29 lines
Quoted 29 lines
Quoted 19 lines
Quoted 2 lines
Hmm, have you thought about using regmap?
To be honest, I didn't know what regmap is but I just read some code and looked at how it is used. Feel free to correct me if I got it wrong.
Regmap seems to be designed for *slow* speed peripherals to improve frequent accesses by the SW. It looks like it is used by MFD, SPI and I2C drivers.
It seems to cache the register contents and flush/invalidate them only when needed.
The MMIO version seems to be assuming the presence of device-tree like CLK API which doesn't exist on ACPI systems and is not portable.
My reaction is that it is a lot of code with no added functionality to what HIDMA driver is trying to achieve.
Quoted 6 lines
Given that the use case here is only for debug purposes; I think it is OK to keep this runtime call here. I don't want to add any overhead into the existing code just to support the debug use case.
None of my register read/writes are slow. This file will only be used to troubleshoot customer issues.
$ is always faster than MMIO. This way you can give reg contents to users without waking up hw.
Quoted 7 lines
Quoted 3 lines
Quoted 1 line
Also we at Intel use regmap on ACPI systems without CLK API
I can try and see the performance impact is. What happens to registers that hw updates like status registers. Those will be most interesting during debug. How does remap get updated for those? Is there a way to tell it not to cache certain registers
My evaluation turned out negative. The regmap code is nice for bus like peripherals like I2C and SPI where everything is bitwise accessed. This is not the case in this code.
I do not entirely agree with the statements here, it does give big benefit on our systems with MMIO. I am going to ask Mark to comment on this, he know better and understands ARM.
I am probably going to be okay with this not using regmap and it is debug but you should give that a try in future for better performance and ofcourse you can add to regmap to get a better model for your device
Quoted 13 lines
Regmap is a nice tool if used properly but it doesn't mean that it will work in every single case. It doesn't match with the goal of this driver.
As soon as I abstract register accesses, the regmap code writes all MMIO registers with the readl variant functions.
Barriers are really expensive on ARM. I paid very special attention in the code to decide when to use relaxed version vs. the readl version. I lose all of this optimization.
Since the clocks are restored only during the debug case, I don't see any problems here. It is not worth the effort to do redo the whole thing and introduce errors as I see a lot of tripping points like
regmap_syncvariants.
Signature · 1 line
~Vinod
Re: [PATCH V17 2/3] dmaengine: qcom_hidma: add debugfs hooks
Quoted 6 lines · Vinod Koul
Quoted 3 lines · Sinan Kaya
My evaluation turned out negative. The regmap code is nice for bus like peripherals like I2C and SPI where everything is bitwise accessed. This is not the case in this code.
Quoted 7 lines
I do not entirely agree with the statements here, it does give big benefit on our systems with MMIO. I am going to ask Mark to comment on this, he know better and understands ARM.
I am probably going to be okay with this not using regmap and it is debug but you should give that a try in future for better performance and ofcourse you can add to regmap to get a better model for your device
I've no idea what "this" is, sorry. All I've got here is an enormous backtrace with a bunch of the messages not even word wrapped.
Please be aware that I get CCed on so much irrelevant crap that copying me into the middle of a thread about some other subsystem is likely to get missed - almost always it's review of some patch I've got no interest in.
Quoted 3 lines
Quoted 3 lines
Barriers are really expensive on ARM. I paid very special attention in the code to decide when to use relaxed version vs. the readl version. I lose all of this optimization.
Drivers should not be using the relaxed accessors, they are there for
the generic code to build on not for drivers and they really need the
cache flush operations. Getting the cache flush operations right,
especially on ARM, isn't easy and needs detailed review.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 473 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20160502/15836f4d/attachment.sig>
PATCH v17 3/3 dmaengine: 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 based kernels.
No matter what flavor of kernel is used, objects will be represented as platform devices.
The new layout is as follows:
hidmam_10: hidma-mgmt@0x5A000000 {
compatible = "qcom,hidma-mgmt-1.0";
...
hidma_10: hidma@0x5a010000 {
compatible = "qcom,hidma-1.0";
...
}
}The hidma_mgmt_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 | 113 ++++++++++++++++++++++++- 3 files changed, 156 insertions(+), 5 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 +109 -4
134 lines not on this page · raw message
Signature · 1 line
1.8.2.1