Skip to contentSkip to conversation

dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe

PATCH Superseded Alexander Gordeev 2 participants 9 messages Oct 30, 2019 – Nov 3, 2019 dmaengine

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v4 cover dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe

This series is against v5.4-rc5

Patch 1. Introduces "avalon-dma" driver that conforms to the standard "dmaengine" model;

Patch 2. The existing "dmatest" is not meant for DMA_SLAVE type of transfers needed by "avalon-dma" driver. Instead, custom "avalon-test" was used to debug and stress "avalon-dma". In fact, the methology used for testing is pretty much generic:

- DMA to/from the remote device (memory) - oneshot or multiple times;
- continuously run cuncurrent threads DMAing to/from the remote device;
- using IOCTL to DMA data to/from user level;

Such functionality could be very useful for bringing up custom embedded devices, i.e sensors, displays etc.

With some effort "avalon-test" could even be merged into the existing "dmatest" or turned into a tool for testing any "dmaengine" compatible driver that does not need any custom hardware specifics to initiate DMA transfers.

I am not certain that "avalon-test" in its current form is the best way to proceed and thus marking patch 2 as RFC. It depends on "avalon-dma", but the two drivers are not needed to be accepted together.

Changes since v3 ("avalon-test" only):
- BUG_ONs, WARN_ONs, dev_dbgs removed goto labels renamed;
- kernel configuration options removed in favour of module parameters;
- fail paths reworked to avoid resource leaks uninitialized data crashes;
- invalid parameter checks reworked;

Changes since v2 ("avalon-dma" only):
- avalon_dma_register() return value bug fixed;
- device_prep_slave_sg() does not crash dmaengine_prep_slave_single();
- kernel configuration options removed in favour of module parameters;
- BUG_ONs, WARN_ONs, dev_dbgs removed goto labels renamed;
- polling loop in interrupt handler commented;
- cpu_relax() added to polling loop in interrupt handler;

Changes since v1:
- "avalon-dma" converted to "dmaengine" model;
- "avalon-drv" renamed to "avalon-test";

The Avalon-MM DMA Interface for PCIe is a design used in hard IPs for Intel Arria, Cyclone or Stratix FPGAs. It transfers data between on-chip memory and system memory.

Testing was done using a custom FPGA build with Arria 10 FPGA streaming data to target device RAM:

  +----------+    +----------+    +----------+        +----------+
  | NIOS CPU |<-->|   RAM    |<-->|  Avalon  |<-PCIe->| Host CPU |
  +----------+    +----------+    +----------+        +----------+

The data integrity was ensured by examining target device RAM contents
(a) from host CPU (indirectly - checking data DMAed to/from the system) and (b) from NIOS CPU that has direct access to the device RAM.

A companion tool using "avalon-test" IOCTL commands was used to DMA files:
https://github.com/a-gordeev/avalon-tool.git

Alexander Gordeev (2):
dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe
dmaengine: avalon-test: Intel Avalon-MM DMA Interface for PCIe test

 drivers/dma/Kconfig                     |   3 +
 drivers/dma/Makefile                    |   2 +
 drivers/dma/avalon-test/Kconfig         |  12 +
 drivers/dma/avalon-test/Makefile        |  14 +
 drivers/dma/avalon-test/avalon-dev.c    | 108 +++++
 drivers/dma/avalon-test/avalon-dev.h    |  33 ++
 drivers/dma/avalon-test/avalon-ioctl.c  | 100 +++++
 drivers/dma/avalon-test/avalon-ioctl.h  |  13 +
 drivers/dma/avalon-test/avalon-mmap.c   |  75 ++++
 drivers/dma/avalon-test/avalon-mmap.h   |  13 +
 drivers/dma/avalon-test/avalon-sg-buf.c | 131 ++++++
 drivers/dma/avalon-test/avalon-sg-buf.h |  27 ++
 drivers/dma/avalon-test/avalon-xfer.c   | 559 ++++++++++++++++++++++++
 drivers/dma/avalon-test/avalon-xfer.h   |  29 ++
 drivers/dma/avalon/Kconfig              |  15 +
 drivers/dma/avalon/Makefile             |  12 +
 drivers/dma/avalon/avalon-core.c        | 477 ++++++++++++++++++++
 drivers/dma/avalon/avalon-core.h        |  93 ++++
 drivers/dma/avalon/avalon-hw.c          | 187 ++++++++
 drivers/dma/avalon/avalon-hw.h          |  86 ++++
 drivers/dma/avalon/avalon-pci.c         | 145 ++++++
 include/uapi/linux/avalon-ioctl.h       |  32 ++
 22 files changed, 2166 insertions(+)
 create mode 100644 drivers/dma/avalon-test/Kconfig
 create mode 100644 drivers/dma/avalon-test/Makefile
 create mode 100644 drivers/dma/avalon-test/avalon-dev.c
 create mode 100644 drivers/dma/avalon-test/avalon-dev.h
 create mode 100644 drivers/dma/avalon-test/avalon-ioctl.c
 create mode 100644 drivers/dma/avalon-test/avalon-ioctl.h
 create mode 100644 drivers/dma/avalon-test/avalon-mmap.c
 create mode 100644 drivers/dma/avalon-test/avalon-mmap.h
 create mode 100644 drivers/dma/avalon-test/avalon-sg-buf.c
 create mode 100644 drivers/dma/avalon-test/avalon-sg-buf.h
 create mode 100644 drivers/dma/avalon-test/avalon-xfer.c
 create mode 100644 drivers/dma/avalon-test/avalon-xfer.h
 create mode 100644 drivers/dma/avalon/Kconfig
 create mode 100644 drivers/dma/avalon/Makefile
 create mode 100644 drivers/dma/avalon/avalon-core.c
 create mode 100644 drivers/dma/avalon/avalon-core.h
 create mode 100644 drivers/dma/avalon/avalon-hw.c
 create mode 100644 drivers/dma/avalon/avalon-hw.h
 create mode 100644 drivers/dma/avalon/avalon-pci.c
 create mode 100644 include/uapi/linux/avalon-ioctl.h
Signature · 1 line
2.23.0
#1 lore raw

PATCH v4 1/2 dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe

Support Avalon-MM DMA Interface for PCIe used in hard IPs for Intel Arria, Cyclone or Stratix FPGAs.

---
 drivers/dma/Kconfig              |   2 +
 drivers/dma/Makefile             |   1 +
 drivers/dma/avalon/Kconfig       |  15 +
 drivers/dma/avalon/Makefile      |  12 +
 drivers/dma/avalon/avalon-core.c | 477 +++++++++++++++++++++++++++++++
 drivers/dma/avalon/avalon-core.h |  93 ++++++
 drivers/dma/avalon/avalon-hw.c   | 187 ++++++++++++
 drivers/dma/avalon/avalon-hw.h   |  86 ++++++
 drivers/dma/avalon/avalon-pci.c  | 145 ++++++++++
 9 files changed, 1018 insertions(+)
 create mode 100644 drivers/dma/avalon/Kconfig
 create mode 100644 drivers/dma/avalon/Makefile
 create mode 100644 drivers/dma/avalon/avalon-core.c
 create mode 100644 drivers/dma/avalon/avalon-core.h
 create mode 100644 drivers/dma/avalon/avalon-hw.c
 create mode 100644 drivers/dma/avalon/avalon-hw.h
 create mode 100644 drivers/dma/avalon/avalon-pci.c
drivers/dma/Kconfig +2 -0
index 7af874b69ffb..f6f43480a4a4 100644
@@ -669,6 +669,8 @@ source "drivers/dma/sh/Kconfig"
 
 source "drivers/dma/ti/Kconfig"
 
+source "drivers/dma/avalon/Kconfig"
+
 # clients
 comment "DMA Clients"
 	depends on DMA_ENGINE
drivers/dma/Makefile +1 -0
index f5ce8665e944..fd7e11417b73 100644
@@ -75,6 +75,7 @@ obj-$(CONFIG_UNIPHIER_MDMAC) += uniphier-mdmac.o
 obj-$(CONFIG_XGENE_DMA) += xgene-dma.o
 obj-$(CONFIG_ZX_DMA) += zx_dma.o
 obj-$(CONFIG_ST_FDMA) += st_fdma.o
+obj-$(CONFIG_AVALON_DMA) += avalon/
 
 obj-y += mediatek/
 obj-y += qcom/
drivers/dma/avalon/Kconfig new file +15 -0
new file mode 100644
index 000000000000..b8cbb6fc04db
@@ -0,0 +1,15 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2019, The Linux Foundation. All rights reserved.
+# Author: Alexander Gordeev <[email protected]>
+#
+# Avalon DMA engine
+#
+config AVALON_DMA
+	tristate "Intel Avalon-MM DMA Interface for PCIe"
+	depends on PCI
+	select DMA_ENGINE
+	select DMA_VIRTUAL_CHANNELS
+	help
+	  This selects a driver for Avalon-MM DMA Interface for PCIe
+	  hard IP block used in Intel Arria, Cyclone or Stratix FPGAs.
drivers/dma/avalon/Makefile new file +12 -0
new file mode 100644
index 000000000000..483a31f0a289
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2019, The Linux Foundation. All rights reserved.
+# Author: Alexander Gordeev <[email protected]>
+#
+# Avalon DMA engine
+#
+obj-$(CONFIG_AVALON_DMA)	+= avalon-dma.o
+
+avalon-dma-objs			:= avalon-hw.o \
+				   avalon-core.o \
+				   avalon-pci.o
drivers/dma/avalon/avalon-core.c new file +477 -0

477 lines not on this page · raw message

drivers/dma/avalon/avalon-core.h new file +93 -0

93 lines not on this page · raw message

drivers/dma/avalon/avalon-hw.c new file +187 -0

187 lines not on this page · raw message

drivers/dma/avalon/avalon-hw.h new file +86 -0

86 lines not on this page · raw message

drivers/dma/avalon/avalon-pci.c new file +145 -0

145 lines not on this page · raw message

Signature · 1 line
2.23.0
#2 lore raw
Thank you for the patch! Perhaps something to improve:

Hi Alexander,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.4-rc5]
[cannot apply to next-20191031]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Alexander-Gordeev/dmaengine-avalon-Intel-Avalon-MM-DMA-Interface-for-PCIe/20191102-044059
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 0dbe6cb8f7e05bc9611602ef45980a6c57b245a3
config: mips-allmodconfig (attached as .config)
compiler: mips-linux-gcc (GCC) 7.4.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=mips

If you fix the issue, kindly add following tag

All warnings (new ones prefixed by >>):

drivers/dma/avalon/avalon-core.c: In function 'start_dma_xfer':

>> drivers/dma/avalon/avalon-core.c:115:32: warning: right shift count >= width of type [-Wshift-count-overflow]
     rc_src_hi = __table->dma_addr >> 32;
                                   ^~

vim +115 drivers/dma/avalon/avalon-core.c

    71	
    72	static int start_dma_xfer(struct avalon_dma_hw *hw,
    73				  struct avalon_dma_desc *desc)
    74	{
    75		size_t ctrl_off;
    76		struct __dma_desc_table *__table;
    77		struct dma_desc_table *table;
    78		u32 rc_src_hi, rc_src_lo;
    79		u32 ep_dst_lo, ep_dst_hi;
    80		int last_id, *__last_id;
    81		int nr_descs;
    82	
    83		if (desc->direction == DMA_TO_DEVICE) {
    84			__table = &hw->dma_desc_table_rd;
    85	
    86			ctrl_off = AVALON_DMA_RD_CTRL_OFFSET;
    87	
    88			ep_dst_hi = rd_ep_dst_hi;
    89			ep_dst_lo = rd_ep_dst_lo;
    90	
    91			__last_id = &hw->h2d_last_id;
    92		} else if (desc->direction == DMA_FROM_DEVICE) {
    93			__table = &hw->dma_desc_table_wr;
    94	
    95			ctrl_off = AVALON_DMA_WR_CTRL_OFFSET;
    96	
    97			ep_dst_hi = wr_ep_dst_hi;
    98			ep_dst_lo = wr_ep_dst_lo;
    99	
   100			__last_id = &hw->d2h_last_id;
   101		} else {
   102			return -EINVAL;
   103		}
   104	
   105		table = __table->cpu_addr;
   106		memset(&table->flags, 0, sizeof(table->flags));
   107	
   108		nr_descs = setup_dma_descs(table->descs, desc);
   109		if (nr_descs < 0)
   110			return nr_descs;
   111	
   112		last_id = nr_descs - 1;
   113		*__last_id = last_id;
   114	
 > 115		rc_src_hi = __table->dma_addr >> 32;
   116		rc_src_lo = (u32)__table->dma_addr;
   117	
   118		start_xfer(hw->regs, ctrl_off,
   119			   rc_src_hi, rc_src_lo,
   120			   ep_dst_hi, ep_dst_lo,
   121			   last_id);

122
123 return 0;
124 }
125

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#3 lore raw
In reply to Alexander Gordeev
Thank you for the patch! Perhaps something to improve:

Hi Alexander,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[also build test WARNING on v5.4-rc5]
[cannot apply to next-20191031]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Alexander-Gordeev/dmaengine-avalon-Intel-Avalon-MM-DMA-Interface-for-PCIe/20191102-044059
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 0dbe6cb8f7e05bc9611602ef45980a6c57b245a3
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-6-g57f8611-dirty
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag

sparse warnings: (new ones prefixed by >>)

>> drivers/dma/avalon/avalon-hw.c:17:22: sparse: sparse: incorrect type in assignment (different base types) @@    expected unsigned int [usertype] src_lo @@    got restrunsigned int [usertype] src_lo @@
>> drivers/dma/avalon/avalon-hw.c:17:22: sparse:    expected unsigned int [usertype] src_lo
>> drivers/dma/avalon/avalon-hw.c:17:22: sparse:    got restricted __le32 [usertype]
>> drivers/dma/avalon/avalon-hw.c:18:22: sparse: sparse: incorrect type in assignment (different base types) @@    expected unsigned int [usertype] src_hi @@    got restrunsigned int [usertype] src_hi @@
>> drivers/dma/avalon/avalon-hw.c:18:22: sparse:    expected unsigned int [usertype] src_hi
   drivers/dma/avalon/avalon-hw.c:18:22: sparse:    got restricted __le32 [usertype]
>> drivers/dma/avalon/avalon-hw.c:19:22: sparse: sparse: incorrect type in assignment (different base types) @@    expected unsigned int [usertype] dst_lo @@    got restrunsigned int [usertype] dst_lo @@
>> drivers/dma/avalon/avalon-hw.c:19:22: sparse:    expected unsigned int [usertype] dst_lo
   drivers/dma/avalon/avalon-hw.c:19:22: sparse:    got restricted __le32 [usertype]
>> drivers/dma/avalon/avalon-hw.c:20:22: sparse: sparse: incorrect type in assignment (different base types) @@    expected unsigned int [usertype] dst_hi @@    got restrunsigned int [usertype] dst_hi @@
>> drivers/dma/avalon/avalon-hw.c:20:22: sparse:    expected unsigned int [usertype] dst_hi
   drivers/dma/avalon/avalon-hw.c:20:22: sparse:    got restricted __le32 [usertype]
>> drivers/dma/avalon/avalon-hw.c:21:27: sparse: sparse: incorrect type in assignment (different base types) @@    expected unsigned int [usertype] ctl_dma_len @@    got restrunsigned int [usertype] ctl_dma_len @@
>> drivers/dma/avalon/avalon-hw.c:21:27: sparse:    expected unsigned int [usertype] ctl_dma_len
   drivers/dma/avalon/avalon-hw.c:21:27: sparse:    got restricted __le32 [usertype]
>> drivers/dma/avalon/avalon-hw.c:22:27: sparse: sparse: incorrect type in assignment (different base types) @@    expected unsigned int @@    got restricted __le32unsigned int @@
>> drivers/dma/avalon/avalon-hw.c:22:27: sparse:    expected unsigned int

drivers/dma/avalon/avalon-hw.c:22:27: sparse: got restricted __le32 [usertype]
drivers/dma/avalon/avalon-hw.c:23:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int @@ got restricted __le32unsigned int @@
drivers/dma/avalon/avalon-hw.c:23:27: sparse: expected unsigned int
drivers/dma/avalon/avalon-hw.c:23:27: sparse: got restricted __le32 [usertype]
drivers/dma/avalon/avalon-hw.c:24:27: sparse: sparse: incorrect type in assignment (different base types) @@ expected unsigned int @@ got restricted __le32unsigned int @@
drivers/dma/avalon/avalon-hw.c:24:27: sparse: expected unsigned int
drivers/dma/avalon/avalon-hw.c:24:27: sparse: got restricted __le32 [usertype]
--

>> drivers/dma/avalon/avalon-core.c:346:27: sparse: sparse: mixing different enum types:
>> drivers/dma/avalon/avalon-core.c:346:27: sparse:    unsigned int enum dma_transfer_direction
>> drivers/dma/avalon/avalon-core.c:346:27: sparse:    unsigned int enum dma_data_direction

vim +17 drivers/dma/avalon/avalon-hw.c

    13	
    14	static void setup_desc(struct dma_desc *desc, u32 desc_id,
    15			       u64 dest, u64 src, u32 size)
    16	{
  > 17		desc->src_lo = cpu_to_le32(src & 0xfffffffful);
  > 18		desc->src_hi = cpu_to_le32((src >> 32));
  > 19		desc->dst_lo = cpu_to_le32(dest & 0xfffffffful);
  > 20		desc->dst_hi = cpu_to_le32((dest >> 32));
  > 21		desc->ctl_dma_len = cpu_to_le32((size >> 2) | (desc_id << 18));
  > 22		desc->reserved[0] = cpu_to_le32(0x0);
    23		desc->reserved[1] = cpu_to_le32(0x0);
    24		desc->reserved[2] = cpu_to_le32(0x0);
    25	}
    26	

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#4 lore raw

RFC PATCH v4 2/2 dmaengine: avalon-test: Intel Avalon-MM DMA Interface for PCIe test

In reply to Alexander Gordeev

This is a sample implementation of a driver using "avalon-dma" to perform data transfers between target device memory and system memory:

    +----------+    +----------+            +----------+
    |   RAM    |<-->|  Avalon  |<---PCIe--->|   Host   |
    +----------+    +----------+            +----------+

The target device is expected to use only Avalon-MM DMA Interface for PCIe to initiate DMA transactions - without custom hardware specifics to make such transfers possible.

Unlike "dmatest" driver, the contents of DMAed data is not manipulated by "avalon-test" in any way. It is basically pass-through and the the data are fully dependent on the target device implementation. Thus, it is up to the users to analyze received or provide meaningful transmitted data.

---
 drivers/dma/Kconfig                     |   1 +
 drivers/dma/Makefile                    |   1 +
 drivers/dma/avalon-test/Kconfig         |  12 +
 drivers/dma/avalon-test/Makefile        |  14 +
 drivers/dma/avalon-test/avalon-dev.c    | 108 +++++
 drivers/dma/avalon-test/avalon-dev.h    |  33 ++
 drivers/dma/avalon-test/avalon-ioctl.c  | 100 +++++
 drivers/dma/avalon-test/avalon-ioctl.h  |  13 +
 drivers/dma/avalon-test/avalon-mmap.c   |  75 ++++
 drivers/dma/avalon-test/avalon-mmap.h   |  13 +
 drivers/dma/avalon-test/avalon-sg-buf.c | 131 ++++++
 drivers/dma/avalon-test/avalon-sg-buf.h |  27 ++
 drivers/dma/avalon-test/avalon-xfer.c   | 559 ++++++++++++++++++++++++
 drivers/dma/avalon-test/avalon-xfer.h   |  29 ++
 include/uapi/linux/avalon-ioctl.h       |  32 ++
 15 files changed, 1148 insertions(+)
 create mode 100644 drivers/dma/avalon-test/Kconfig
 create mode 100644 drivers/dma/avalon-test/Makefile
 create mode 100644 drivers/dma/avalon-test/avalon-dev.c
 create mode 100644 drivers/dma/avalon-test/avalon-dev.h
 create mode 100644 drivers/dma/avalon-test/avalon-ioctl.c
 create mode 100644 drivers/dma/avalon-test/avalon-ioctl.h
 create mode 100644 drivers/dma/avalon-test/avalon-mmap.c
 create mode 100644 drivers/dma/avalon-test/avalon-mmap.h
 create mode 100644 drivers/dma/avalon-test/avalon-sg-buf.c
 create mode 100644 drivers/dma/avalon-test/avalon-sg-buf.h
 create mode 100644 drivers/dma/avalon-test/avalon-xfer.c
 create mode 100644 drivers/dma/avalon-test/avalon-xfer.h
 create mode 100644 include/uapi/linux/avalon-ioctl.h
drivers/dma/Kconfig +1 -0
index f6f43480a4a4..4b3c6a6baf4c 100644
@@ -670,6 +670,7 @@ source "drivers/dma/sh/Kconfig"
 source "drivers/dma/ti/Kconfig"
 
 source "drivers/dma/avalon/Kconfig"
+source "drivers/dma/avalon-test/Kconfig"
 
 # clients
 comment "DMA Clients"
drivers/dma/Makefile +1 -0
index fd7e11417b73..eb3ee7f6cac6 100644
@@ -76,6 +76,7 @@ obj-$(CONFIG_XGENE_DMA) += xgene-dma.o
 obj-$(CONFIG_ZX_DMA) += zx_dma.o
 obj-$(CONFIG_ST_FDMA) += st_fdma.o
 obj-$(CONFIG_AVALON_DMA) += avalon/
+obj-$(CONFIG_AVALON_TEST) += avalon-test/
 
 obj-y += mediatek/
 obj-y += qcom/
drivers/dma/avalon-test/Kconfig new file +12 -0
new file mode 100644
index 000000000000..b4d22720ce23
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2019, The Linux Foundation. All rights reserved.
+# Author: Alexander Gordeev <[email protected]>
+#
+# Avalon DMA engine
+#
+config AVALON_TEST
+	select AVALON_DMA
+	tristate "Intel Avalon-MM DMA Interface for PCIe test driver"
+	help
+	  This selects a test driver for Avalon-MM DMA Interface for PCI
drivers/dma/avalon-test/Makefile new file +14 -0
new file mode 100644
index 000000000000..2387fc41c3ad
@@ -0,0 +1,14 @@
+# SPDX-License-Identifier: GPL-2.0
+#
+# Copyright (c) 2019, The Linux Foundation. All rights reserved.
+# Author: Alexander Gordeev <[email protected]>
+#
+# Avalon DMA driver
+#
+obj-$(CONFIG_AVALON_TEST)	+= avalon-test.o
+
+avalon-test-objs :=	avalon-dev.o \
+			avalon-ioctl.o \
+			avalon-mmap.o \
+			avalon-sg-buf.o \
+			avalon-xfer.o
drivers/dma/avalon-test/avalon-dev.c new file +108 -0

108 lines not on this page · raw message

drivers/dma/avalon-test/avalon-dev.h new file +33 -0
new file mode 100644
index 000000000000..ad8f2f5717fa
@@ -0,0 +1,33 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ * Author: Alexander Gordeev <[email protected]>
+ *
+ * Avalon DMA driver
+ */
+#ifndef __AVALON_DEV_H__
+#define __AVALON_DEV_H__
+
+#include <linux/dmaengine.h>
+#include <linux/miscdevice.h>
+
+#define DEVICE_NAME		"avalon-dev"
+
+extern unsigned int mem_base;
+extern unsigned int mem_size;
+extern unsigned int dma_size;
+extern unsigned int dma_size_sg;
+extern unsigned int nr_dma_reps;
+extern unsigned int dmas_per_cpu;
+
+struct avalon_dev {
+	struct dma_chan *dma_chan;
+	struct miscdevice misc_dev;
+};
+
+static inline struct device *chan_to_dev(struct dma_chan *chan)
+{
+	return chan->device->dev;
+}
+
+#endif
drivers/dma/avalon-test/avalon-ioctl.c new file +100 -0

100 lines not on this page · raw message

drivers/dma/avalon-test/avalon-ioctl.h new file +13 -0
new file mode 100644
index 000000000000..a10ab0b5d67c
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ * Author: Alexander Gordeev <[email protected]>
+ *
+ * Avalon DMA driver
+ */
+#ifndef __AVALON_IOCTL_H__
+#define __AVALON_IOCTL_H__
+
+long avalon_dev_ioctl(struct file *file, unsigned int cmd, unsigned long arg);
+
+#endif
drivers/dma/avalon-test/avalon-mmap.c new file +75 -0

75 lines not on this page · raw message

drivers/dma/avalon-test/avalon-mmap.h new file +13 -0
new file mode 100644
index 000000000000..3d3878f236cf
@@ -0,0 +1,13 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ * Author: Alexander Gordeev <[email protected]>
+ *
+ * Avalon DMA driver
+ */
+#ifndef __AVALON_MMAP_H__
+#define __AVALON_MMAP_H__
+
+int avalon_dev_mmap(struct file *file, struct vm_area_struct *vma);
+
+#endif
drivers/dma/avalon-test/avalon-sg-buf.c new file +131 -0

131 lines not on this page · raw message

drivers/dma/avalon-test/avalon-sg-buf.h new file +27 -0
new file mode 100644
index 000000000000..a5cce1c18714
@@ -0,0 +1,27 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Author: Alexander Gordeev <[email protected]>
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ *
+ * Avalon DMA driver
+ */
+#ifndef __AVALON_SG_BUF_H__
+#define __AVALON_SG_BUF_H__
+
+struct dma_sg_buf {
+	struct device			*dev;
+	void				*vaddr;
+	struct page			**pages;
+	enum dma_data_direction		dma_dir;
+	struct sg_table			sgt;
+	size_t				size;
+	unsigned int			num_pages;
+};
+
+struct dma_sg_buf *dma_sg_buf_alloc(struct device *dev,
+				    unsigned long size,
+				    enum dma_data_direction dma_dir,
+				    gfp_t gfp_flags);
+void dma_sg_buf_free(struct dma_sg_buf *buf);
+
+#endif
drivers/dma/avalon-test/avalon-xfer.c new file +559 -0

559 lines not on this page · raw message

drivers/dma/avalon-test/avalon-xfer.h new file +29 -0
new file mode 100644
index 000000000000..3c1a096713d5
@@ -0,0 +1,29 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * Copyright (c) 2019, The Linux Foundation. All rights reserved.
+ * Author: Alexander Gordeev <[email protected]>
+ *
+ * Avalon DMA driver
+ */
+#ifndef __AVALON_XFER_H__
+#define __AVALON_XFER_H__
+
+#include <linux/dma-direction.h>
+
+#include "avalon-dev.h"
+
+int xfer_single(struct dma_chan *chan,
+		enum dma_data_direction direction,
+		void __user *user_buf, size_t user_len);
+int xfer_rw_single(struct dma_chan *chan,
+		   void __user *user_buf_rd, size_t user_len_rd,
+		   void __user *user_buf_wr, size_t user_len_wr);
+int xfer_sg(struct dma_chan *chan,
+	    enum dma_data_direction direction,
+	    void __user *user_buf, size_t user_len,
+	    bool is_smp);
+int xfer_rw_sg(struct dma_chan *chan,
+	       void __user *user_buf_rd, size_t user_len_rd,
+	       void __user *user_buf_wr, size_t user_len_wr);
+
+#endif
include/uapi/linux/avalon-ioctl.h new file +32 -0
new file mode 100644
index 000000000000..b929c2dd46ea
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
+/*
+ * Avalon DMA driver
+ *
+ * Author: Alexander Gordeev <[email protected]>
+ */
+#ifndef _UAPI_LINUX_AVALON_IOCTL_H__
+#define _UAPI_LINUX_AVALON_IOCTL_H__
+
+#define AVALON_DEVICE_NAME		"avalon-dev"
+
+struct avalon_dma_info {
+	size_t mem_addr;
+	size_t mem_size;
+	size_t dma_size;
+	size_t dma_size_sg;
+} __attribute((packed));
+
+#define AVALON_SIG 'V'
+
+#define IOCTL_AVALON_DMA_GET_INFO	_IOR(AVALON_SIG, 0, struct avalon_dma_info)
+#define IOCTL_AVALON_DMA_SET_INFO	_IOW(AVALON_SIG, 1, struct avalon_dma_info)
+#define IOCTL_AVALON_DMA_READ		_IOR(AVALON_SIG, 2, struct iovec)
+#define IOCTL_AVALON_DMA_WRITE		_IOW(AVALON_SIG, 3, struct iovec)
+#define IOCTL_AVALON_DMA_RDWR		_IOWR(AVALON_SIG, 4, struct iovec[2])
+#define IOCTL_AVALON_DMA_READ_SG	_IOR(AVALON_SIG, 5, struct iovec)
+#define IOCTL_AVALON_DMA_WRITE_SG	_IOW(AVALON_SIG, 6, struct iovec)
+#define IOCTL_AVALON_DMA_RDWR_SG	_IOWR(AVALON_SIG, 7, struct iovec[2])
+#define IOCTL_AVALON_DMA_READ_SG_SMP	_IOR(AVALON_SIG, 8, struct iovec)
+#define IOCTL_AVALON_DMA_WRITE_SG_SMP	_IOW(AVALON_SIG, 9, struct iovec)
+
+#endif
Signature · 1 line
2.23.0
#5 lore raw

Re: [PATCH RFC v4 2/2] dmaengine: avalon-test: Intel Avalon-MM DMA Interface for PCIe test

[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please…

Hi Alexander,

[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on linus/master]
[also build test ERROR on v5.4-rc5]
[cannot apply to next-20191031]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Alexander-Gordeev/dmaengine-avalon-Intel-Avalon-MM-DMA-Interface-for-PCIe/20191102-044059
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 0dbe6cb8f7e05bc9611602ef45980a6c57b245a3
config: sparc64-allmodconfig (attached as .config)
compiler: sparc64-linux-gcc (GCC) 7.4.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=sparc64

If you fix the issue, kindly add following tag

All error/warnings (new ones prefixed by >>):

drivers/dma/avalon-test/avalon-sg-buf.c: In function 'dma_sg_buf_alloc':

>> drivers/dma/avalon-test/avalon-sg-buf.c:93:15: error: implicit declaration of function 'vm_map_ram'; did you mean 'vm_map_pages'? [-Werror=implicit-function-declaration]
     buf->vaddr = vm_map_ram(buf->pages, buf->num_pages, -1, PAGE_KERNEL);
                  ^~~~~~~~~~
                  vm_map_pages
>> drivers/dma/avalon-test/avalon-sg-buf.c:93:13: warning: assignment makes pointer from integer without a cast [-Wint-conversion]
     buf->vaddr = vm_map_ram(buf->pages, buf->num_pages, -1, PAGE_KERNEL);
                ^
   drivers/dma/avalon-test/avalon-sg-buf.c: In function 'dma_sg_buf_free':
>> drivers/dma/avalon-test/avalon-sg-buf.c:124:2: error: implicit declaration of function 'vm_unmap_ram'; did you mean 'vm_munmap'? [-Werror=implicit-function-declaration]
     vm_unmap_ram(buf->vaddr, buf->num_pages);
     ^~~~~~~~~~~~
     vm_munmap

cc1: some warnings being treated as errors

vim +93 drivers/dma/avalon-test/avalon-sg-buf.c

    51	
    52	struct dma_sg_buf *dma_sg_buf_alloc(struct device *dev,
    53					    unsigned long size,
    54					    enum dma_data_direction dma_dir,
    55					    gfp_t gfp_flags)
    56	{
    57		struct dma_sg_buf *buf;
    58		struct sg_table *sgt;
    59		int ret;
    60		int num_pages;
    61	
    62		buf = kzalloc(sizeof(*buf), GFP_KERNEL);
    63		if (!buf)
    64			return ERR_PTR(-ENOMEM);
    65	
    66		buf->dma_dir = dma_dir;
    67		buf->size = size;
    68		buf->num_pages = size >> PAGE_SHIFT;
    69	
    70		buf->pages = kvcalloc(buf->num_pages, sizeof(struct page *), GFP_KERNEL);
    71		if (!buf->pages)
    72			goto free_buf;
    73	
    74		ret = dma_sg_alloc_compacted(buf, gfp_flags);
    75		if (ret)
    76			goto free_arr;
    77	
    78		ret = sg_alloc_table_from_pages(&buf->sgt, buf->pages,
    79						buf->num_pages, 0, size,
    80						GFP_KERNEL);
    81		if (ret)
    82			goto free_pages;
    83	
    84		buf->dev = get_device(dev);
    85	
    86		sgt = &buf->sgt;
    87	
    88		sgt->nents = dma_map_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
    89					      buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
    90		if (!sgt->nents)
    91			goto free_sgt;
    92	
  > 93		buf->vaddr = vm_map_ram(buf->pages, buf->num_pages, -1, PAGE_KERNEL);
    94		if (!buf->vaddr)
    95			goto unmap_sg;
    96	
    97		return buf;
    98	
    99	unmap_sg:
   100		dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
   101				   buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
   102	free_sgt:
   103		put_device(buf->dev);
   104		sg_free_table(&buf->sgt);
   105	free_pages:
   106		num_pages = buf->num_pages;
   107		while (num_pages--)
   108			__free_page(buf->pages[num_pages]);
   109	free_arr:
   110		kvfree(buf->pages);
   111	free_buf:
   112		kfree(buf);
   113	
   114		return ERR_PTR(-ENOMEM);
   115	}
   116	
   117	void dma_sg_buf_free(struct dma_sg_buf *buf)
   118	{
   119		struct sg_table *sgt = &buf->sgt;
   120		int i = buf->num_pages;
   121	
   122		dma_unmap_sg_attrs(buf->dev, sgt->sgl, sgt->orig_nents,
   123				   buf->dma_dir, DMA_ATTR_SKIP_CPU_SYNC);
 > 124		vm_unmap_ram(buf->vaddr, buf->num_pages);

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#6 lore raw

Re: [PATCH RFC v4 2/2] dmaengine: avalon-test: Intel Avalon-MM DMA Interface for PCIe test

In reply to Alexander Gordeev
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please…

Hi Alexander,

[FYI, it's a private test report for your RFC patch.]
[auto build test ERROR on linus/master]
[also build test ERROR on v5.4-rc5]
[cannot apply to next-20191031]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Alexander-Gordeev/dmaengine-avalon-Intel-Avalon-MM-DMA-Interface-for-PCIe/20191102-044059
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 0dbe6cb8f7e05bc9611602ef45980a6c57b245a3
config: sh-allmodconfig (attached as .config)
compiler: sh4-linux-gcc (GCC) 7.4.0

reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
GCC_VERSION=7.4.0 make.cross ARCH=sh

If you fix the issue, kindly add following tag

All error/warnings (new ones prefixed by >>):

drivers/dma/avalon/avalon-pci.c: In function 'init_interrupts':

>> drivers/dma/avalon/avalon-pci.c:52:2: error: implicit declaration of function 'pci_disable_msi'; did you mean 'pci_disable_ats'? [-Werror=implicit-function-declaration]
     pci_disable_msi(pci_dev);
     ^~~~~~~~~~~~~~~
     pci_disable_ats
   drivers/dma/avalon/avalon-pci.c: In function 'avalon_pci_probe':
>> drivers/dma/avalon/avalon-pci.c:102:2: error: implicit declaration of function 'pci_iounmap'; did you mean 'pcim_iounmap'? [-Werror=implicit-function-declaration]
     pci_iounmap(pci_dev, regs);
     ^~~~~~~~~~~
     pcim_iounmap
   drivers/dma/avalon/avalon-pci.c: At top level:
>> drivers/dma/avalon/avalon-pci.c:140:1: warning: data definition has no type or storage class
    module_pci_driver(avalon_pci_driver);
    ^~~~~~~~~~~~~~~~~
>> drivers/dma/avalon/avalon-pci.c:140:1: error: type defaults to 'int' in declaration of 'module_pci_driver' [-Werror=implicit-int]
>> drivers/dma/avalon/avalon-pci.c:140:1: warning: parameter names (without types) in function declaration
   drivers/dma/avalon/avalon-pci.c:133:26: warning: 'avalon_pci_driver' defined but not used [-Wunused-variable]
    static struct pci_driver avalon_pci_driver = {
                             ^~~~~~~~~~~~~~~~~

cc1: some warnings being treated as errors

vim +52 drivers/dma/avalon/avalon-pci.c

eb0a1b5edfc55d Alexander Gordeev 2019-10-30   15  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   16  static unsigned int pci_bar = 0;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   17  module_param(pci_bar, uint, 0644);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   18  MODULE_PARM_DESC(pci_bar,
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   19  		 "PCI BAR number the controller is mapped to (default: 0)");
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   20  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   21  static unsigned int pci_msi_vector = 0;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   22  module_param(pci_msi_vector, uint, 0644);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   23  MODULE_PARM_DESC(pci_msi_vector,
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   24  		 "MSI vector number used for the controller (default: 0)");
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   25  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   26  static unsigned int pci_msi_count_order = 5;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   27  module_param(pci_msi_count_order, uint, 0644);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   28  MODULE_PARM_DESC(pci_msi_count_order,
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   29  		 "Number of MSI vectors (order) device uses (default: 5)");
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   30  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   31  static int init_interrupts(struct pci_dev *pci_dev)
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   32  {
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   33  	unsigned int nr_vecs = BIT(pci_msi_count_order);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   34  	int ret;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   35  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   36  	ret = pci_alloc_irq_vectors(pci_dev, nr_vecs, nr_vecs, PCI_IRQ_MSI);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   37  	if (ret < 0) {
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   38  		return ret;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   39  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   40  	} else if (ret != nr_vecs) {
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   41  		ret = -ENOSPC;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   42  		goto disable_msi;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   43  	}
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   44  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   45  	ret = pci_irq_vector(pci_dev, pci_msi_vector);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   46  	if (ret < 0)
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   47  		goto disable_msi;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   48  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   49  	return ret;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   50  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   51  disable_msi:
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  @52  	pci_disable_msi(pci_dev);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   53  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   54  	return ret;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   55  }
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   56  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   57  static void term_interrupts(struct pci_dev *pci_dev)
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   58  {
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   59  	pci_disable_msi(pci_dev);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   60  }
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   61  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   62  static int avalon_pci_probe(struct pci_dev *pci_dev,
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   63  			    const struct pci_device_id *id)
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   64  {
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   65  	void *adma;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   66  	void __iomem *regs;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   67  	int ret;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   68  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   69  	ret = pci_enable_device(pci_dev);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   70  	if (ret)
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   71  		return ret;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   72  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   73  	ret = pci_request_regions(pci_dev, DRIVER_NAME);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   74  	if (ret)
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   75  		goto disable_device;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   76  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   77  	regs = pci_ioremap_bar(pci_dev, pci_bar);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   78  	if (!regs) {
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   79  		ret = -ENOMEM;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   80  		goto release_regions;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   81  	}
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   82  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   83  	ret = init_interrupts(pci_dev);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   84  	if (ret < 0)
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   85  		goto unmap_bars;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   86  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   87  	adma = avalon_dma_register(&pci_dev->dev, regs, ret);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   88  	if (IS_ERR(adma)) {
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   89  		ret = PTR_ERR(adma);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   90  		goto terminate_interrupts;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   91  	}
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   92  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   93  	pci_set_master(pci_dev);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   94  	pci_set_drvdata(pci_dev, adma);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   95  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   96  	return 0;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   97  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   98  terminate_interrupts:
eb0a1b5edfc55d Alexander Gordeev 2019-10-30   99  	term_interrupts(pci_dev);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  100  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  101  unmap_bars:
eb0a1b5edfc55d Alexander Gordeev 2019-10-30 @102  	pci_iounmap(pci_dev, regs);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  103  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  104  release_regions:
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  105  	pci_release_regions(pci_dev);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  106  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  107  disable_device:
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  108  	pci_disable_device(pci_dev);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  109  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  110  	return ret;
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  111  }
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  112  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  113  static void avalon_pci_remove(struct pci_dev *pci_dev)
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  114  {
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  115  	void *adma = pci_get_drvdata(pci_dev);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  116  	void __iomem *regs = avalon_dma_mmio(adma);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  117  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  118  	pci_set_drvdata(pci_dev, NULL);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  119  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  120  	avalon_dma_unregister(adma);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  121  	term_interrupts(pci_dev);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  122  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  123  	pci_iounmap(pci_dev, regs);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  124  	pci_release_regions(pci_dev);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  125  	pci_disable_device(pci_dev);
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  126  }
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  127  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  128  static struct pci_device_id avalon_pci_ids[] = {
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  129  	{ PCI_DEVICE(PCI_VENDOR_ID_ALTERA, 0xe003) },
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  130  	{ 0 }
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  131  };
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  132  
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  133  static struct pci_driver avalon_pci_driver = {
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  134  	.name		= DRIVER_NAME,
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  135  	.id_table	= avalon_pci_ids,
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  136  	.probe		= avalon_pci_probe,
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  137  	.remove		= avalon_pci_remove,
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  138  };
eb0a1b5edfc55d Alexander Gordeev 2019-10-30  139  

eb0a1b5edfc55d Alexander Gordeev 2019-10-30 @140 module_pci_driver(avalon_pci_driver); eb0a1b5edfc55d Alexander Gordeev 2019-10-30 141

:::::: The code at line 52 was first introduced by commit
:::::: eb0a1b5edfc55dd6463793ae7b3ddde0f6a97063 dmaengine: avalon: Intel Avalon-MM DMA Interface for PCIe

:::::: TO: Alexander Gordeev <[email protected]> :::::: CC: 0day robot <[email protected]>

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#7 lore raw

[RFC PATCH] dmaengine: avalon-test: avalon_dev_fops can be static

In reply to Alexander Gordeev
Fixes: 9ea3a9a1478c ("dmaengine: avalon-test: Intel Avalon-MM DMA Interface for PCIe test")
Fixes 9ea3a9a1478c ("dmaengine: avalon-test: Intel Avalon-MM DMA Interface for PCIe test")
---
 avalon-dev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/dma/avalon-test/avalon-dev.c +1 -1
index 34d9507893790..937ac3663efd7 100644
@@ -39,7 +39,7 @@ unsigned int dmas_per_cpu = 8;
 module_param(dmas_per_cpu, uint, 0644);
 MODULE_PARM_DESC(dmas_per_cpu, "Device memory size (default: 8)");
 
-const struct file_operations avalon_dev_fops = {
+static const struct file_operations avalon_dev_fops = {
 	.llseek		= generic_file_llseek,
 	.unlocked_ioctl	= avalon_dev_ioctl,
 	.mmap		= avalon_dev_mmap,
#8 lore raw

Re: [PATCH RFC v4 2/2] dmaengine: avalon-test: Intel Avalon-MM DMA Interface for PCIe test

In reply to Alexander Gordeev
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please…

Hi Alexander,

[FYI, it's a private test report for your RFC patch.]
[auto build test WARNING on linus/master]
[also build test WARNING on v5.4-rc5]
[cannot apply to next-20191031]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system. BTW, we also suggest to use '--base' option to specify the base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url:    https://github.com/0day-ci/linux/commits/Alexander-Gordeev/dmaengine-avalon-Intel-Avalon-MM-DMA-Interface-for-PCIe/20191102-044059
base:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 0dbe6cb8f7e05bc9611602ef45980a6c57b245a3
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-6-g57f8611-dirty
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag

sparse warnings: (new ones prefixed by >>)

>> drivers/dma/avalon-test/avalon-dev.c:42:30: sparse: sparse: symbol 'avalon_dev_fops' was not declared. Should it be static?
--
>> drivers/dma/avalon-test/avalon-ioctl.c:23:34: sparse: sparse: duplicate [noderef]
>> drivers/dma/avalon-test/avalon-ioctl.c:23:34: sparse: sparse: multiple address space given: <asn:1> & <asn:1>
   drivers/dma/avalon-test/avalon-ioctl.c:23:57: sparse: sparse: multiple address space given: <asn:1> & <asn:1>
--
>> drivers/dma/avalon-test/avalon-xfer.c:52:35: sparse: sparse: mixing different enum types:
>> drivers/dma/avalon-test/avalon-xfer.c:52:35: sparse:    unsigned int enum dma_data_direction
>> drivers/dma/avalon-test/avalon-xfer.c:52:35: sparse:    unsigned int enum dma_transfer_direction

drivers/dma/avalon-test/avalon-xfer.c:92:65: sparse: sparse: mixing different enum types:
drivers/dma/avalon-test/avalon-xfer.c:92:65: sparse: unsigned int enum dma_data_direction
drivers/dma/avalon-test/avalon-xfer.c:92:65: sparse: unsigned int enum dma_transfer_direction
drivers/dma/avalon-test/avalon-xfer.c:117:56: sparse: sparse: mixing different enum types:
drivers/dma/avalon-test/avalon-xfer.c:117:56: sparse: unsigned int enum dma_data_direction
drivers/dma/avalon-test/avalon-xfer.c:117:56: sparse: unsigned int enum dma_transfer_direction

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation