Add NVIDIA Tegra GPC-DMA driver
v17 cover Add NVIDIA Tegra GPC-DMA driver
Add support for NVIDIA Tegra general purpose DMA driver for Tegra186 and Tegra194 platform.
v16 -> v17:
* Updates in terminate_all() and pause().
* Moved DMA busy check to configure_next_sg() from issue_pending()
* shortened variable names -
bytes_requested -> bytes_req; bytes_transferred -> bytes_xfer
* Correction in burst_size calculation
Akhil R (4):
dt-bindings: dmaengine: Add doc for tegra gpcdma
dmaengine: tegra: Add tegra gpcdma driver
arm64: defconfig: tegra: Enable GPCDMA
arm64: tegra: Add GPCDMA node for tegra186 and tegra194
.../bindings/dma/nvidia,tegra186-gpc-dma.yaml | 110 ++ arch/arm64/boot/dts/nvidia/tegra186.dtsi | 42 + arch/arm64/boot/dts/nvidia/tegra194.dtsi | 43 + arch/arm64/configs/defconfig | 1 + drivers/dma/Kconfig | 11 + drivers/dma/Makefile | 1 + drivers/dma/tegra186-gpc-dma.c | 1488 ++++++++++++++++++++ 7 files changed, 1696 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml create mode 100644 drivers/dma/tegra186-gpc-dma.c
Signature · 1 line
2.7.4
PATCH v17 1/4 dt-bindings: dmaengine: Add doc for tegra gpcdma
Add DT binding document for Nvidia Tegra GPCDMA controller.
--- .../bindings/dma/nvidia,tegra186-gpc-dma.yaml | 110 +++++++++++++++++++++ 1 file changed, 110 insertions(+) create mode 100644 Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml
Documentation/devicetree/bindings/dma/nvidia,tegra186-gpc-dma.yaml new file +110 -0
@@ -0,0 +1,110 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/dma/nvidia,tegra186-gpc-dma.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: NVIDIA Tegra GPC DMA Controller Device Tree Bindings + +description: | + The Tegra General Purpose Central (GPC) DMA controller is used for faster + data transfers between memory to memory, memory to device and device to + memory. + +maintainers: + - Jon Hunter <[email protected]> + - Rajesh Gumasta <[email protected]> + +allOf: + - $ref: "dma-controller.yaml#" + +properties: + compatible: + oneOf: + - const: nvidia,tegra186-gpcdma + - items: + - const: nvidia,tegra194-gpcdma + - const: nvidia,tegra186-gpcdma + + "#dma-cells": + const: 1 + + reg: + maxItems: 1 + + interrupts: + description: + Should contain all of the per-channel DMA interrupts in + ascending order with respect to the DMA channel index. + minItems: 1 + maxItems: 31 + + resets: + maxItems: 1 + + reset-names: + const: gpcdma + + iommus: + maxItems: 1 + + dma-coherent: true + +required: + - compatible + - reg + - interrupts + - resets + - reset-names + - "#dma-cells" + - iommus + +additionalProperties: false + +examples: + - | + #include <dt-bindings/interrupt-controller/arm-gic.h> + #include <dt-bindings/memory/tegra186-mc.h> + #include <dt-bindings/reset/tegra186-reset.h> + + dma-controller@2600000 { + compatible = "nvidia,tegra186-gpcdma"; + reg = <0x2600000 0x210000>; + resets = <&bpmp TEGRA186_RESET_GPCDMA>; + reset-names = "gpcdma"; + interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 81 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>; + #dma-cells = <1>; + iommus = <&smmu TEGRA186_SID_GPCDMA_0>; + dma-coherent; + }; +...
Signature · 1 line
2.7.4
PATCH v17 2/4 dmaengine: tegra: Add tegra gpcdma driver
In reply to Akhil RAdding GPC DMA controller driver for Tegra186 and Tegra194. The driver supports dma transfers between memory to memory, IO peripheral to memory and memory to IO peripheral.
--- drivers/dma/Kconfig | 11 + drivers/dma/Makefile | 1 + drivers/dma/tegra186-gpc-dma.c | 1488 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 1500 insertions(+) create mode 100644 drivers/dma/tegra186-gpc-dma.c
drivers/dma/Kconfig +11 -0
@@ -629,6 +629,17 @@ config TXX9_DMAC Support the TXx9 SoC internal DMA controller. This can be integrated in chips such as the Toshiba TX4927/38/39. +config TEGRA186_GPC_DMA + tristate "NVIDIA Tegra GPC DMA support" + depends on ARCH_TEGRA || COMPILE_TEST + select DMA_ENGINE + help + Support for the NVIDIA Tegra General Purpose Central DMA controller. + The DMA controller has multiple DMA channels which can be configured + for different peripherals like UART, SPI, etc which are on APB bus. + This DMA controller transfers data from memory to peripheral FIFO + or vice versa. It also supports memory to memory data transfer. + config TEGRA20_APB_DMA tristate "NVIDIA Tegra20 APB DMA support" depends on ARCH_TEGRA || COMPILE_TEST
drivers/dma/Makefile +1 -0
@@ -72,6 +72,7 @@ obj-$(CONFIG_STM32_MDMA) += stm32-mdma.o obj-$(CONFIG_SPRD_DMA) += sprd-dma.o obj-$(CONFIG_S3C24XX_DMAC) += s3c24xx-dma.o obj-$(CONFIG_TXX9_DMAC) += txx9dmac.o +obj-$(CONFIG_TEGRA186_GPC_DMA) += tegra186-gpc-dma.o obj-$(CONFIG_TEGRA20_APB_DMA) += tegra20-apb-dma.o obj-$(CONFIG_TEGRA210_ADMA) += tegra210-adma.o obj-$(CONFIG_TIMB_DMA) += timb_dma.o
drivers/dma/tegra186-gpc-dma.c new file +1488 -0
1,488 lines not on this page · raw message
Signature · 1 line
2.7.4
kernel test robot
build botRe: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
Thank you for the patch! Yet something to improve:
Hi Akhil,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on vkoul-dmaengine/next]
[also build test ERROR on robh/for-next arm64/for-next/core v5.17-rc1 next-20220128] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Akhil-R/Add-NVIDIA-Tegra-GPC-DMA-driver/20220130-004416 base: https://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine.git next config: sparc-randconfig-r014-20220130 (https://download.01.org/0day-ci/archive/20220130/202201300257.biRDxeFY-lkp(a)intel.com/config) compiler: sparc-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/6e1492836cbc56394256bd76f57ddb3d12cc65e6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Akhil-R/Add-NVIDIA-Tegra-GPC-DMA-driver/20220130-004416
git checkout 6e1492836cbc56394256bd76f57ddb3d12cc65e6
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross O=build_dir ARCH=sparc SHELL=/bin/bash drivers/dma/
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/dma/tegra186-gpc-dma.c:1186:81: warning: right shift count >= width of type [-Wshift-count-overflow]
1186 | FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR, (mem >> 32));
| ^~
include/linux/compiler_types.h:315:23: note: in definition of macro '__compiletime_assert'
315 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:335:9: note: in expansion of macro '_compiletime_assert'
335 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:17: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
| ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:17: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
| ^~~~~~~~~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:1186:33: note: in expansion of macro 'FIELD_PREP'
1186 | FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR, (mem >> 32));
| ^~~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:1186:81: warning: right shift count >= width of type [-Wshift-count-overflow]
1186 | FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR, (mem >> 32));
| ^~
include/linux/compiler_types.h:315:23: note: in definition of macro '__compiletime_assert'
315 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:335:9: note: in expansion of macro '_compiletime_assert'
335 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:17: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
| ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:17: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
| ^~~~~~~~~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:1186:33: note: in expansion of macro 'FIELD_PREP'
1186 | FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR, (mem >> 32));
| ^~~~~~~~~~
In file included from drivers/dma/tegra186-gpc-dma.c:8:
drivers/dma/tegra186-gpc-dma.c:1186:81: warning: right shift count >= width of type [-Wshift-count-overflow]
1186 | FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR, (mem >> 32));
| ^~
include/linux/bitfield.h:95:34: note: in definition of macro 'FIELD_PREP'
95 | ((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \
| ^~~~
In file included from <command-line>:
drivers/dma/tegra186-gpc-dma.c:1191:81: warning: right shift count >= width of type [-Wshift-count-overflow]
1191 | FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (mem >> 32));
| ^~
include/linux/compiler_types.h:315:23: note: in definition of macro '__compiletime_assert'
315 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:335:9: note: in expansion of macro '_compiletime_assert'
335 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:17: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
| ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:17: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
| ^~~~~~~~~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:1191:33: note: in expansion of macro 'FIELD_PREP'
1191 | FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (mem >> 32));
| ^~~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:1191:81: warning: right shift count >= width of type [-Wshift-count-overflow]
1191 | FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (mem >> 32));
| ^~
include/linux/compiler_types.h:315:23: note: in definition of macro '__compiletime_assert'
315 | if (!(condition)) \
| ^~~~~~~~~
include/linux/compiler_types.h:335:9: note: in expansion of macro '_compiletime_assert'
335 | _compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
| ^~~~~~~~~~~~~~~~~~~
include/linux/build_bug.h:39:37: note: in expansion of macro 'compiletime_assert'
39 | #define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
| ^~~~~~~~~~~~~~~~~~
include/linux/bitfield.h:49:17: note: in expansion of macro 'BUILD_BUG_ON_MSG'
49 | BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
| ^~~~~~~~~~~~~~~~
include/linux/bitfield.h:94:17: note: in expansion of macro '__BF_FIELD_CHECK'
94 | __BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
| ^~~~~~~~~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:1191:33: note: in expansion of macro 'FIELD_PREP'
1191 | FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (mem >> 32));
| ^~~~~~~~~~
In file included from drivers/dma/tegra186-gpc-dma.c:8:
drivers/dma/tegra186-gpc-dma.c:1191:81: warning: right shift count >= width of type [-Wshift-count-overflow]
1191 | FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (mem >> 32));
| ^~
include/linux/bitfield.h:95:34: note: in definition of macro 'FIELD_PREP'
95 | ((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \
| ^~~~
drivers/dma/tegra186-gpc-dma.c: In function 'tegra_dma_probe':
>> drivers/dma/tegra186-gpc-dma.c:1346:31: error: 'struct iommu_fwspec' has no member named 'ids'
1346 | stream_id = iommu_spec->ids[0] & 0xffff;
| ^~vim +1346 drivers/dma/tegra186-gpc-dma.c
1307
1308 static int tegra_dma_probe(struct platform_device *pdev)
1309 {
1310 const struct tegra_dma_chip_data *cdata = NULL;
1311 struct iommu_fwspec *iommu_spec;
1312 unsigned int stream_id, i;
1313 struct tegra_dma *tdma;
1314 struct resource *res;
1315 int ret;
1316
1317 cdata = of_device_get_match_data(&pdev->dev);
1318
1319 tdma = devm_kzalloc(&pdev->dev, sizeof(*tdma) + cdata->nr_channels *
1320 sizeof(struct tegra_dma_channel), GFP_KERNEL);
1321 if (!tdma)
1322 return -ENOMEM;
1323
1324 tdma->dev = &pdev->dev;
1325 tdma->chip_data = cdata;
1326 platform_set_drvdata(pdev, tdma);
1327
1328 tdma->base_addr = devm_platform_ioremap_resource(pdev, 0);
1329 if (IS_ERR(tdma->base_addr))
1330 return PTR_ERR(tdma->base_addr);
1331
1332 tdma->rst = devm_reset_control_get_exclusive(&pdev->dev, "gpcdma");
1333 if (IS_ERR(tdma->rst)) {
1334 return dev_err_probe(&pdev->dev, PTR_ERR(tdma->rst),
1335 "Missing controller reset\n");
1336 }
1337 reset_control_reset(tdma->rst);
1338
1339 tdma->dma_dev.dev = &pdev->dev;
1340
1341 iommu_spec = dev_iommu_fwspec_get(&pdev->dev);
1342 if (!iommu_spec) {
1343 dev_err(&pdev->dev, "Missing iommu stream-id\n");
1344 return -EINVAL;
1345 }
> 1346 stream_id = iommu_spec->ids[0] & 0xffff;
1347
1348 INIT_LIST_HEAD(&tdma->dma_dev.channels);
1349 for (i = 0; i < cdata->nr_channels; i++) {
1350 struct tegra_dma_channel *tdc = &tdma->channels[i];
1351
1352 tdc->chan_base_offset = TEGRA_GPCDMA_CHANNEL_BASE_ADD_OFFSET +
1353 i * cdata->channel_reg_size;
1354 res = platform_get_resource(pdev, IORESOURCE_IRQ, i);
1355 if (!res) {
1356 dev_err(&pdev->dev, "No irq resource for chan %d\n", i);
1357 return -EINVAL;
1358 }
1359 tdc->irq = res->start;
1360 snprintf(tdc->name, sizeof(tdc->name), "gpcdma.%d", i);
1361
1362 tdc->tdma = tdma;
1363 tdc->id = i;
1364 tdc->slave_id = -1;
1365
1366 vchan_init(&tdc->vc, &tdma->dma_dev);
1367 tdc->vc.desc_free = tegra_dma_desc_free;
1368
1369 /* program stream-id for this channel */
1370 tegra_dma_program_sid(tdc, i, stream_id);
1371 tdc->stream_id = stream_id;
1372 }
1373
1374 dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask);
1375 dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask);
1376 dma_cap_set(DMA_MEMCPY, tdma->dma_dev.cap_mask);
1377 dma_cap_set(DMA_MEMSET, tdma->dma_dev.cap_mask);
1378 dma_cap_set(DMA_CYCLIC, tdma->dma_dev.cap_mask);
1379
1380 /*
1381 * Only word aligned transfers are supported. Set the copy
1382 * alignment shift.
1383 */
1384 tdma->dma_dev.copy_align = 2;
1385 tdma->dma_dev.fill_align = 2;
1386 tdma->dma_dev.device_alloc_chan_resources =
1387 tegra_dma_alloc_chan_resources;
1388 tdma->dma_dev.device_free_chan_resources =
1389 tegra_dma_free_chan_resources;
1390 tdma->dma_dev.device_prep_slave_sg = tegra_dma_prep_slave_sg;
1391 tdma->dma_dev.device_prep_dma_memcpy = tegra_dma_prep_dma_memcpy;
1392 tdma->dma_dev.device_prep_dma_memset = tegra_dma_prep_dma_memset;
1393 tdma->dma_dev.device_prep_dma_cyclic = tegra_dma_prep_dma_cyclic;
1394 tdma->dma_dev.device_config = tegra_dma_slave_config;
1395 tdma->dma_dev.device_terminate_all = tegra_dma_terminate_all;
1396 tdma->dma_dev.device_tx_status = tegra_dma_tx_status;
1397 tdma->dma_dev.device_issue_pending = tegra_dma_issue_pending;
1398 tdma->dma_dev.device_pause = tegra_dma_device_pause;
1399 tdma->dma_dev.device_resume = tegra_dma_device_resume;
1400 tdma->dma_dev.device_synchronize = tegra_dma_chan_synchronize;
1401 tdma->dma_dev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
1402
1403 ret = dma_async_device_register(&tdma->dma_dev);
1404 if (ret < 0) {
1405 dev_err_probe(&pdev->dev, ret,
1406 "GPC DMA driver registration failed\n");
1407 return ret;
1408 }
1409
1410 ret = of_dma_controller_register(pdev->dev.of_node,
1411 tegra_dma_of_xlate, tdma);
1412 if (ret < 0) {
1413 dev_err_probe(&pdev->dev, ret,
1414 "GPC DMA OF registration failed\n");
1415
1416 dma_async_device_unregister(&tdma->dma_dev);
1417 return ret;
1418 }
1419
1420 dev_info(&pdev->dev, "GPC DMA driver register %d channels\n",
1421 cdata->nr_channels);
1422
1423 return 0;
1424 }
1425
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
kernel test robot
build botRe: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
In reply to Akhil RThank you for the patch! Perhaps something to improve:
Hi Akhil,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on vkoul-dmaengine/next]
[also build test WARNING on robh/for-next arm64/for-next/core v5.17-rc1 next-20220128] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Akhil-R/Add-NVIDIA-Tegra-GPC-DMA-driver/20220130-004416 base: https://git.kernel.org/pub/scm/linux/kernel/git/vkoul/dmaengine.git next config: hexagon-randconfig-r022-20220130 (https://download.01.org/0day-ci/archive/20220130/202201300351.7Qdca3M3-lkp(a)intel.com/config) compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project 33b45ee44b1f32ffdbc995e6fec806271b4b3ba4)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/6e1492836cbc56394256bd76f57ddb3d12cc65e6
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Akhil-R/Add-NVIDIA-Tegra-GPC-DMA-driver/20220130-004416
git checkout 6e1492836cbc56394256bd76f57ddb3d12cc65e6
# save the config file to linux build tree
mkdir build_dir
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross W=1 O=build_dir ARCH=hexagon SHELL=/bin/bash drivers/dma/
If you fix the issue, kindly add following tag as appropriate
All warnings (new ones prefixed by >>):
>> drivers/dma/tegra186-gpc-dma.c:885:53: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (dest >> 32));
^ ~~
include/linux/bitfield.h:94:33: note: expanded from macro 'FIELD_PREP'
__BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
^~~~
include/linux/bitfield.h:49:41: note: expanded from macro '__BF_FIELD_CHECK'
BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
^~~~
include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~
include/linux/compiler_types.h:335:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:323:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:315:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
>> drivers/dma/tegra186-gpc-dma.c:885:53: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (dest >> 32));
^ ~~
include/linux/bitfield.h:94:33: note: expanded from macro 'FIELD_PREP'
__BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
^~~~
include/linux/bitfield.h:50:39: note: expanded from macro '__BF_FIELD_CHECK'
~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \
^~~~
include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~
include/linux/compiler_types.h:335:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:323:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:315:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
>> drivers/dma/tegra186-gpc-dma.c:885:53: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (dest >> 32));
^ ~~
include/linux/bitfield.h:95:20: note: expanded from macro 'FIELD_PREP'
((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \
^~~~
drivers/dma/tegra186-gpc-dma.c:953:51: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR, (src >> 32));
^ ~~
include/linux/bitfield.h:94:33: note: expanded from macro 'FIELD_PREP'
__BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
^~~~
include/linux/bitfield.h:49:41: note: expanded from macro '__BF_FIELD_CHECK'
BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
^~~~
include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~
include/linux/compiler_types.h:335:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:323:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:315:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:953:51: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR, (src >> 32));
^ ~~
include/linux/bitfield.h:94:33: note: expanded from macro 'FIELD_PREP'
__BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
^~~~
include/linux/bitfield.h:50:39: note: expanded from macro '__BF_FIELD_CHECK'
~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \
^~~~
include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~
include/linux/compiler_types.h:335:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:323:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:315:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:953:51: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR, (src >> 32));
^ ~~
include/linux/bitfield.h:95:20: note: expanded from macro 'FIELD_PREP'
((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \
^~~~
drivers/dma/tegra186-gpc-dma.c:955:52: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (dest >> 32));
^ ~~
include/linux/bitfield.h:94:33: note: expanded from macro 'FIELD_PREP'
__BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
^~~~
include/linux/bitfield.h:49:41: note: expanded from macro '__BF_FIELD_CHECK'
BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
^~~~
include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~
include/linux/compiler_types.h:335:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:323:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:315:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:955:52: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (dest >> 32));
^ ~~
include/linux/bitfield.h:94:33: note: expanded from macro 'FIELD_PREP'
__BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
^~~~
include/linux/bitfield.h:50:39: note: expanded from macro '__BF_FIELD_CHECK'
~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \
^~~~
include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~
include/linux/compiler_types.h:335:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:323:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:315:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:955:52: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (dest >> 32));
^ ~~
include/linux/bitfield.h:95:20: note: expanded from macro 'FIELD_PREP'
((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \
--
^ ~~
include/linux/bitfield.h:95:20: note: expanded from macro 'FIELD_PREP'
((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \
^~~~
drivers/dma/tegra186-gpc-dma.c:1186:53: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR, (mem >> 32));
^ ~~
include/linux/bitfield.h:94:33: note: expanded from macro 'FIELD_PREP'
__BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
^~~~
include/linux/bitfield.h:49:41: note: expanded from macro '__BF_FIELD_CHECK'
BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
^~~~
include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~
include/linux/compiler_types.h:335:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:323:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:315:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:1186:53: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR, (mem >> 32));
^ ~~
include/linux/bitfield.h:94:33: note: expanded from macro 'FIELD_PREP'
__BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
^~~~
include/linux/bitfield.h:50:39: note: expanded from macro '__BF_FIELD_CHECK'
~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \
^~~~
include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~
include/linux/compiler_types.h:335:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:323:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:315:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:1186:53: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_SRC_PTR, (mem >> 32));
^ ~~
include/linux/bitfield.h:95:20: note: expanded from macro 'FIELD_PREP'
((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \
^~~~
drivers/dma/tegra186-gpc-dma.c:1191:53: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (mem >> 32));
^ ~~
include/linux/bitfield.h:94:33: note: expanded from macro 'FIELD_PREP'
__BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
^~~~
include/linux/bitfield.h:49:41: note: expanded from macro '__BF_FIELD_CHECK'
BUILD_BUG_ON_MSG(__builtin_constant_p(_val) ? \
^~~~
include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~
include/linux/compiler_types.h:335:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:323:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:315:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:1191:53: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (mem >> 32));
^ ~~
include/linux/bitfield.h:94:33: note: expanded from macro 'FIELD_PREP'
__BF_FIELD_CHECK(_mask, 0ULL, _val, "FIELD_PREP: "); \
^~~~
include/linux/bitfield.h:50:39: note: expanded from macro '__BF_FIELD_CHECK'
~((_mask) >> __bf_shf(_mask)) & (_val) : 0, \
^~~~
include/linux/build_bug.h:39:58: note: expanded from macro 'BUILD_BUG_ON_MSG'
#define BUILD_BUG_ON_MSG(cond, msg) compiletime_assert(!(cond), msg)
^~~~
include/linux/compiler_types.h:335:22: note: expanded from macro 'compiletime_assert'
_compiletime_assert(condition, msg, __compiletime_assert_, __COUNTER__)
^~~~~~~~~
include/linux/compiler_types.h:323:23: note: expanded from macro '_compiletime_assert'
__compiletime_assert(condition, msg, prefix, suffix)
^~~~~~~~~
include/linux/compiler_types.h:315:9: note: expanded from macro '__compiletime_assert'
if (!(condition)) \
^~~~~~~~~
drivers/dma/tegra186-gpc-dma.c:1191:53: warning: shift count >= width of type [-Wshift-count-overflow]
FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (mem >> 32));
^ ~~
include/linux/bitfield.h:95:20: note: expanded from macro 'FIELD_PREP'
((typeof(_mask))(_val) << __bf_shf(_mask)) & (_mask); \
^~~~
>> drivers/dma/tegra186-gpc-dma.c:1183:4: warning: variable 'sg_req' is uninitialized when used here [-Wuninitialized]
sg_req[i].ch_regs.src_ptr = mem;
^~~~~~
drivers/dma/tegra186-gpc-dma.c:1095:33: note: initialize the variable 'sg_req' to silence this warning
struct tegra_dma_sg_req *sg_req;
^
= NULL
>> drivers/dma/tegra186-gpc-dma.c:1469:21: warning: attribute declaration must precede definition [-Wignored-attributes]
static const struct __maybe_unused dev_pm_ops tegra_dma_dev_pm_ops = {
^
include/linux/compiler_attributes.h:286:56: note: expanded from macro '__maybe_unused'
#define __maybe_unused __attribute__((__unused__))
^
include/linux/pm.h:277:8: note: previous definition is here
struct dev_pm_ops {
^23 warnings generated.
vim +885 drivers/dma/tegra186-gpc-dma.c
830
831 static struct dma_async_tx_descriptor *
832 tegra_dma_prep_dma_memset(struct dma_chan *dc, dma_addr_t dest, int value,
833 size_t len, unsigned long flags)
834 {
835 struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
836 unsigned int max_dma_count = tdc->tdma->chip_data->max_dma_count;
837 struct tegra_dma_sg_req *sg_req;
838 struct tegra_dma_desc *dma_desc;
839 unsigned long csr, mc_seq;
840
841 if ((len & 3) || (dest & 3) || len > max_dma_count) {
842 dev_err(tdc2dev(tdc),
843 "DMA length/memory address is not supported\n");
844 return NULL;
845 }
846
847 /* Set dma mode to fixed pattern */
848 csr = TEGRA_GPCDMA_CSR_DMA_FIXED_PAT;
849 /* Enable once or continuous mode */
850 csr |= TEGRA_GPCDMA_CSR_ONCE;
851 /* Enable IRQ mask */
852 csr |= TEGRA_GPCDMA_CSR_IRQ_MASK;
853 /* Enable the dma interrupt */
854 if (flags & DMA_PREP_INTERRUPT)
855 csr |= TEGRA_GPCDMA_CSR_IE_EOC;
856 /* Configure default priority weight for the channel */
857 csr |= FIELD_PREP(TEGRA_GPCDMA_CSR_WEIGHT, 1);
858
859 mc_seq = tdc_read(tdc, TEGRA_GPCDMA_CHAN_MCSEQ);
860 /* retain stream-id and clean rest */
861 mc_seq &= TEGRA_GPCDMA_MCSEQ_STREAM_ID0_MASK;
862
863 /* Set the address wrapping */
864 mc_seq |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_WRAP0,
865 TEGRA_GPCDMA_MCSEQ_WRAP_NONE);
866 mc_seq |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_WRAP1,
867 TEGRA_GPCDMA_MCSEQ_WRAP_NONE);
868
869 /* Program outstanding MC requests */
870 mc_seq |= FIELD_PREP(TEGRA_GPCDMA_MCSEQ_REQ_COUNT, 1);
871 /* Set burst size */
872 mc_seq |= TEGRA_GPCDMA_MCSEQ_BURST_16;
873
874 dma_desc = kzalloc(struct_size(dma_desc, sg_req, 1), GFP_NOWAIT);
875 if (!dma_desc)
876 return NULL;
877
878 dma_desc->bytes_req = len;
879 dma_desc->sg_count = 1;
880 sg_req = dma_desc->sg_req;
881
882 sg_req[0].ch_regs.src_ptr = 0;
883 sg_req[0].ch_regs.dst_ptr = dest;
884 sg_req[0].ch_regs.high_addr_ptr =
> 885 FIELD_PREP(TEGRA_GPCDMA_HIGH_ADDR_DST_PTR, (dest >> 32));
886 sg_req[0].ch_regs.fixed_pattern = value;
887 /* Word count reg takes value as (N +1) words */
888 sg_req[0].ch_regs.wcount = ((len - 4) >> 2);
889 sg_req[0].ch_regs.csr = csr;
890 sg_req[0].ch_regs.mmio_seq = 0;
891 sg_req[0].ch_regs.mc_seq = mc_seq;
892 sg_req[0].len = len;
893
894 dma_desc->cyclic = false;
895 return vchan_tx_prep(&tdc->vc, &dma_desc->vd, flags);
896 }
897
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
In reply to Akhil R29.01.2022 19:40, Akhil R пишет:
drivers/dma/tegra186-gpc-dma.c line 396
Quoted 8 lines
drivers/dma/tegra186-gpc-dma.c new file +8
-0+static int tegra_dma_device_pause (struct dma_chan *dc) +{ +struct tegra_dma_channel *tdc =to_tegra_dma_chan (dc); +unsigned long wcount, flags; +int ret =0 ; + +if (!tdc->tdma->chip_data->hw_support_pause) +return 0 ;
It's wrong to return zero if pause unsupported, please see what dmaengine_pause() returns.
Quoted 4 lines
drivers/dma/tegra186-gpc-dma.c new file +4
-0+ +spin_lock_irqsave (&tdc->vc.lock, flags); +if (!tdc->dma_desc) + goto out;
drivers/dma/tegra186-gpc-dma.c line 410
Quoted 10 lines
drivers/dma/tegra186-gpc-dma.c new file +10
-0+ + ret =tegra_dma_pause (tdc); +if (ret) { +dev_err (tdc2dev (tdc),"DMA pause timed out\n" ); + goto out; + } + + wcount =tdc_read (tdc,TEGRA_GPCDMA_CHAN_XFER_COUNT ); + tdc->dma_desc->bytes_xfer += + tdc->dma_desc->bytes_req - (wcount *4 );
Why transfer is accumulated?
Why do you need to update xfer size at all on pause?
drivers/dma/tegra186-gpc-dma.c line 416
Quoted 6 lines
drivers/dma/tegra186-gpc-dma.c new file +6
-0+ +out: +spin_unlock_irqrestore (&tdc->vc.lock, flags); + +return ret; +}
Still nothing prevents interrupt handler to fire during the pause.
What you actually need to do is to disable/enable interrupt. This will prevent the interrupt racing and then pause/resume may look like this:
static int tegra_dma_device_resume(struct dma_chan *dc)
{
struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
u32 val;
if (!tdc->tdma->chip_data->hw_support_pause)
return -ENOSYS;
if (!tdc->dma_desc)
return 0;
val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE);
val &= ~TEGRA_GPCDMA_CHAN_CSRE_PAUSE;
tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val);
enable_irq(tdc->irq);
return 0;
}static int tegra_dma_device_pause(struct dma_chan *dc)
{
struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
u32 val;
int ret;
if (!tdc->tdma->chip_data->hw_support_pause)
return -ENOSYS;
disable_irq(tdc->irq);
if (!tdc->dma_desc)
return 0;
val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE);
val |= TEGRA_GPCDMA_CHAN_CSRE_PAUSE;
tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val);
/* Wait until busy bit is de-asserted */
ret = readl_relaxed_poll_timeout_atomic(
tdc->chan_base + TEGRA_GPCDMA_CHAN_STATUS,
val, !(val & TEGRA_GPCDMA_STATUS_BUSY),
TEGRA_GPCDMA_BURST_COMPLETE_TIME,
TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT);
if (ret) {
dev_err(tdc2dev(tdc), "DMA pause timed out: %d\n", ret);
tegra_dma_device_resume(dc);
}
return ret;
}Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
30.01.2022 13:05, Dmitry Osipenko пишет:
Quoted 16 lines
static int
tegra_dma_device_resume(struct dma_chan *dc){ struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); u32 val; if (!tdc->tdma->chip_data->hw_support_pause) return -ENOSYS; if (!tdc->dma_desc) return 0; val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE); val &= ~TEGRA_GPCDMA_CHAN_CSRE_PAUSE; tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val); enable_irq(tdc->irq);
Correction:
if (tdc->dma_desc) {
val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE);
val &= ~TEGRA_GPCDMA_CHAN_CSRE_PAUSE;
tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val);
}enable_irq(tdc->irq);
Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
30.01.2022 13:08, Dmitry Osipenko пишет:
Quoted 20 lines
30.01.2022 13:05, Dmitry Osipenko пишет:
Quoted 16 lines
static int
tegra_dma_device_resume(struct dma_chan *dc){ struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); u32 val; if (!tdc->tdma->chip_data->hw_support_pause) return -ENOSYS; if (!tdc->dma_desc) return 0; val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE); val &= ~TEGRA_GPCDMA_CHAN_CSRE_PAUSE; tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val); enable_irq(tdc->irq);Correction:
Quoted 7 lines
if (tdc->dma_desc) { val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE); val &= ~TEGRA_GPCDMA_CHAN_CSRE_PAUSE; tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val); }
enable_irq(tdc->irq);
And apparently, tegra_dma_terminate_all() also needs to take care of removing the PAUSE bit. Otherwise it won't be possible to unpause channel after the termination.
Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
30.01.2022 13:13, Dmitry Osipenko пишет:
Quoted 27 lines
30.01.2022 13:08, Dmitry Osipenko пишет:
Quoted 26 lines
30.01.2022 13:05, Dmitry Osipenko пишет:
Quoted 16 lines
static int
tegra_dma_device_resume(struct dma_chan *dc){ struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); u32 val; if (!tdc->tdma->chip_data->hw_support_pause) return -ENOSYS; if (!tdc->dma_desc) return 0; val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE); val &= ~TEGRA_GPCDMA_CHAN_CSRE_PAUSE; tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val); enable_irq(tdc->irq);Correction:
if (tdc->dma_desc) { val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE); val &= ~TEGRA_GPCDMA_CHAN_CSRE_PAUSE; tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val); }
Quoted 5 lines
Quoted 1 line
enable_irq(tdc->irq);And apparently,
tegra_dma_terminate_all()also needs to take care of removing the PAUSE bit. Otherwise it won't be possible to unpause channel after the termination.
Although, will be easier to just do this in the resume:
val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE);
if (val & TEGRA_GPCDMA_CHAN_CSRE_PAUSE) {
val &= ~TEGRA_GPCDMA_CHAN_CSRE_PAUSE;
tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val);
}Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
In reply to Dmitry Osipenko30.01.2022 13:05, Dmitry Osipenko пишет:
Quoted 4 lines
Still nothing prevents interrupt handler to fire during the pause.
What you actually need to do is to disable/enable interrupt. This will prevent the interrupt racing and then pause/resume may look like this:
Although, seems this won't work, unfortunately. I see now that device_pause() doesn't have might_sleep().
Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
30.01.2022 13:26, Dmitry Osipenko пишет:
Quoted 9 lines
30.01.2022 13:05, Dmitry Osipenko пишет:
Quoted 4 lines
Still nothing prevents interrupt handler to fire during the pause.
What you actually need to do is to disable/enable interrupt. This will prevent the interrupt racing and then pause/resume may look like this:
Although, seems this won't work, unfortunately. I see now that
device_pause()doesn't havemight_sleep().
Ah, I see now that the pause/unpause is actually a separate control and doesn't conflict with "start next transfer".
So you just need to set/unset the pause under lock. And don't touch tdc->dma_desc. That's it.
static int tegra_dma_device_pause(struct dma_chan *dc)
{
struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
unsigned long flags;
u32 val;
if (!tdc->tdma->chip_data->hw_support_pause)
return -ENOSYS;
spin_lock_irqsave(&tdc->vc.lock, flags);
val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE);
val |= TEGRA_GPCDMA_CHAN_CSRE_PAUSE;
tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val);
spin_unlock_irqrestore(&tdc->vc.lock, flags);
return 0;
}static int tegra_dma_device_resume(struct dma_chan *dc)
{
struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
unsigned long flags;
u32 val;
if (!tdc->tdma->chip_data->hw_support_pause)
return -ENOSYS;
spin_lock_irqsave(&tdc->vc.lock, flags);
val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE);
val &= ~TEGRA_GPCDMA_CHAN_CSRE_PAUSE;
tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val);
spin_unlock_irqrestore(&tdc->vc.lock, flags);
return 0;
}RE: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
Quoted 46 lines
30.01.2022 13:26, Dmitry Osipenko пишет:
Quoted 9 lines
30.01.2022 13:05, Dmitry Osipenko пишет:
Quoted 4 lines
Still nothing prevents interrupt handler to fire during the pause.
What you actually need to do is to disable/enable interrupt. This will prevent the interrupt racing and then pause/resume may look like this:
Although, seems this won't work, unfortunately. I see now that
device_pause()doesn't havemight_sleep().Ah, I see now that the pause/unpause is actually a separate control and doesn't conflict with "start next transfer".
So you just need to set/unset the pause under lock. And don't touch
tdc->dma_desc. That's it.static int tegra_dma_device_pause(struct dma_chan *dc) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); unsigned long flags; u32 val; if (!tdc->tdma->chip_data->hw_support_pause) return -ENOSYS; spin_lock_irqsave(&tdc->vc.lock, flags); val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE); val |= TEGRA_GPCDMA_CHAN_CSRE_PAUSE; tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val); spin_unlock_irqrestore(&tdc->vc.lock, flags); return 0; }static int tegra_dma_device_resume(struct dma_chan *dc) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); unsigned long flags; u32 val; if (!tdc->tdma->chip_data->hw_support_pause) return -ENOSYS; spin_lock_irqsave(&tdc->vc.lock, flags);
Quoted 8 lines
val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE);
val &= ~TEGRA_GPCDMA_CHAN_CSRE_PAUSE;
tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val);
spin_unlock_irqrestore(&tdc->vc.lock, flags);
return 0;
}The reason I separated out register writes was to conveniently call those in dma_start() and terminate_all(). Do you see any issue there? The recommended way of terminating a transfer in between is to pause it before disabling the channel.
dma_desc could be NULL while these functions are called. pause() or resume() is unneeded if there isn't any transfer going on. Moreover, if we are to calculate the xfer_size, the check would be mandatory.
Agree with the other comments.
Thanks,
Akhil
Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
30.01.2022 19:43, Akhil R пишет:
Quoted 52 lines
Quoted 52 lines
30.01.2022 13:26, Dmitry Osipenko пишет:
Quoted 9 lines
30.01.2022 13:05, Dmitry Osipenko пишет:
Quoted 4 lines
Still nothing prevents interrupt handler to fire during the pause.
What you actually need to do is to disable/enable interrupt. This will prevent the interrupt racing and then pause/resume may look like this:
Although, seems this won't work, unfortunately. I see now that
device_pause()doesn't havemight_sleep().Ah, I see now that the pause/unpause is actually a separate control and doesn't conflict with "start next transfer".
So you just need to set/unset the pause under lock. And don't touch
tdc->dma_desc. That's it.static int tegra_dma_device_pause(struct dma_chan *dc) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); unsigned long flags; u32 val; if (!tdc->tdma->chip_data->hw_support_pause) return -ENOSYS; spin_lock_irqsave(&tdc->vc.lock, flags); val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE); val |= TEGRA_GPCDMA_CHAN_CSRE_PAUSE; tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val); spin_unlock_irqrestore(&tdc->vc.lock, flags); return 0; }static int tegra_dma_device_resume(struct dma_chan *dc) { struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); unsigned long flags; u32 val; if (!tdc->tdma->chip_data->hw_support_pause) return -ENOSYS; spin_lock_irqsave(&tdc->vc.lock, flags); val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE); val &= ~TEGRA_GPCDMA_CHAN_CSRE_PAUSE; tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val); spin_unlock_irqrestore(&tdc->vc.lock, flags);
Quoted 7 lines
Quoted 2 lines
return 0; }The reason I separated out register writes was to conveniently call those in
dma_start()andterminate_all(). Do you see any issue there? The recommended way of terminating a transfer in between is to pause it before disabling the channel.
This is a sample code, feel free to adjust it as needed.
Quoted 3 lines
dma_desccould be NULL while these functions are called.pause()orresume()is unneeded if there isn't any transfer going on. Moreover, if we are to calculate thexfer_size, the check would be mandatory.
For now looks like it should be better to move the xfer_size updating to other places, like terminate_all() and tx_status().
I also see now that you have residue_granularity=DMA_RESIDUE_GRANULARITY_BURST, while tx_status() in fact uses segment granularity. This needs to be corrected.
You also must add locking to tx_status(), to protect tdc->dma_desc pointer updates.
RE: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
In reply to Dmitry OsipenkoQuoted 29 lines
29.01.2022 19:40, Akhil R пишет:
drivers/dma/tegra186-gpc-dma.c line 396
Quoted 7 lines
drivers/dma/tegra186-gpc-dma.c new file +7
-0+static int tegra_dma_device_pause (struct dma_chan *dc) { +struct tegra_dma_channel *tdc =to_tegra_dma_chan (dc); +unsigned long wcount, flags; +int ret =0 ; + +if (!tdc->tdma->chip_data->hw_support_pause) +return 0 ;It's wrong to return zero if pause unsupported, please see what
dmaengine_pause()returns.Quoted 4 lines
drivers/dma/tegra186-gpc-dma.c new file +4
-0+ +spin_lock_irqsave (&tdc->vc.lock, flags); +if (!tdc->dma_desc) + goto out;drivers/dma/tegra186-gpc-dma.c line 410
Quoted 10 lines
drivers/dma/tegra186-gpc-dma.c new file +10
-0+ + ret =tegra_dma_pause (tdc); +if (ret) { +dev_err (tdc2dev (tdc),"DMA pause timed out\n" ); + goto out; + } + + wcount =tdc_read (tdc,TEGRA_GPCDMA_CHAN_XFER_COUNT ); + tdc->dma_desc->bytes_xfer += + tdc->dma_desc->bytes_req - (wcount *4 );Why transfer is accumulated?
Quoted 1 line
Why do you need to update xfer size at all on pause?
I will verify the calculation. This looks correct only for single sg transaction.
Updating xfer_size is added to support drivers which pause the transaction and read the status before terminating.
Eg. https://elixir.bootlin.com/linux/latest/source/drivers/tty/serial/amba-pl011.c
Thanks,
Akhil
Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
30.01.2022 19:34, Akhil R пишет:
Quoted 29 lines
Quoted 29 lines
29.01.2022 19:40, Akhil R пишет:
drivers/dma/tegra186-gpc-dma.c line 396
Quoted 7 lines
drivers/dma/tegra186-gpc-dma.c new file +7
-0+static int tegra_dma_device_pause (struct dma_chan *dc) { +struct tegra_dma_channel *tdc =to_tegra_dma_chan (dc); +unsigned long wcount, flags; +int ret =0 ; + +if (!tdc->tdma->chip_data->hw_support_pause) +return 0 ;It's wrong to return zero if pause unsupported, please see what
dmaengine_pause()returns.Quoted 4 lines
drivers/dma/tegra186-gpc-dma.c new file +4
-0+ +spin_lock_irqsave (&tdc->vc.lock, flags); +if (!tdc->dma_desc) + goto out;drivers/dma/tegra186-gpc-dma.c line 410
Quoted 10 lines
drivers/dma/tegra186-gpc-dma.c new file +10
-0+ + ret =tegra_dma_pause (tdc); +if (ret) { +dev_err (tdc2dev (tdc),"DMA pause timed out\n" ); + goto out; + } + + wcount =tdc_read (tdc,TEGRA_GPCDMA_CHAN_XFER_COUNT ); + tdc->dma_desc->bytes_xfer += + tdc->dma_desc->bytes_req - (wcount *4 );Why transfer is accumulated?
Quoted 7 lines
Quoted 1 line
Why do you need to update xfer size at all on pause?
I will verify the calculation. This looks correct only for single sg transaction.
Updating
xfer_sizeis added to support drivers which pause the transaction and read the status before terminating.
Eg. https://elixir.bootlin.com/linux/latest/source/drivers/tty/serial/amba-pl011.c
Why you couldn't update the status in tegra_dma_terminate_all()?
RE: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
Quoted 32 lines
30.01.2022 19:34, Akhil R пишет:
Quoted 31 lines
Quoted 30 lines
29.01.2022 19:40, Akhil R пишет:
drivers/dma/tegra186-gpc-dma.c line 396
Quoted 7 lines
drivers/dma/tegra186-gpc-dma.c new file +7
-0+static int tegra_dma_device_pause (struct dma_chan *dc) { +struct tegra_dma_channel *tdc =to_tegra_dma_chan (dc); +unsigned long wcount, flags; +int ret =0 ; + +if (!tdc->tdma->chip_data->hw_support_pause) +return 0 ;It's wrong to return zero if pause unsupported, please see what
dmaengine_pause()returns.Quoted 4 lines
drivers/dma/tegra186-gpc-dma.c new file +4
-0+ +spin_lock_irqsave (&tdc->vc.lock, flags); +if (!tdc->dma_desc) + goto out;drivers/dma/tegra186-gpc-dma.c line 410
Quoted 10 lines
drivers/dma/tegra186-gpc-dma.c new file +10
-0+ + ret =tegra_dma_pause (tdc); +if (ret) { +dev_err (tdc2dev (tdc),"DMA pause timed out\n" ); + goto out; + } + + wcount =tdc_read (tdc,TEGRA_GPCDMA_CHAN_XFER_COUNT ); + tdc->dma_desc->bytes_xfer += + tdc->dma_desc->bytes_req - (wcount *4 );Why transfer is accumulated?
Why do you need to update xfer size at all on pause?
Quoted 7 lines
Quoted 5 lines
I will verify the calculation. This looks correct only for single sg transaction.
Updating
xfer_sizeis added to support drivers which pause the transaction and read the status before terminating. Eg.Why you couldn't update the status in
tegra_dma_terminate_all()?
Is it useful to update the status in terminate_all()? I assume the descriptor Is freed in vchan_dma_desc_free_list() or am I getting it wrong?
Thanks,
Akhil
Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
В Mon, 31 Jan 2022 04:25:14 +0000
Akhil R <[email protected]> пишет:
Quoted 35 lines
Quoted 35 lines
30.01.2022 19:34, Akhil R пишет:
Quoted 34 lines
Quoted 29 lines
29.01.2022 19:40, Akhil R пишет:
drivers/dma/tegra186-gpc-dma.c line 396
Quoted 7 lines
drivers/dma/tegra186-gpc-dma.c new file +7
-0+static int tegra_dma_device_pause (struct dma_chan *dc) { +struct tegra_dma_channel *tdc =to_tegra_dma_chan (dc); +unsigned long wcount, flags; +int ret =0 ; + +if (!tdc->tdma->chip_data->hw_support_pause) +return 0 ;It's wrong to return zero if pause unsupported, please see what
dmaengine_pause()returns.Quoted 4 lines
drivers/dma/tegra186-gpc-dma.c new file +4
-0+ +spin_lock_irqsave (&tdc->vc.lock, flags); +if (!tdc->dma_desc) + goto out;drivers/dma/tegra186-gpc-dma.c line 410
Quoted 10 lines
drivers/dma/tegra186-gpc-dma.c new file +10
-0+ + ret =tegra_dma_pause (tdc); +if (ret) { +dev_err (tdc2dev (tdc),"DMA pause timed out\n" ); + goto out; + } + + wcount =tdc_read (tdc,TEGRA_GPCDMA_CHAN_XFER_COUNT ); + tdc->dma_desc->bytes_xfer += + tdc->dma_desc->bytes_req - (wcount *4 );Why transfer is accumulated?
Quoted 1 line
Why do you need to update xfer size at all on pause?
I will verify the calculation. This looks correct only for single sg transaction.
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Updating
xfer_sizeis added to support drivers which pause the transaction and read the status before terminating. Eg.Why you couldn't update the status in
tegra_dma_terminate_all()?Is it useful to update the status in
terminate_all()? I assume the descriptor Is freed invchan_dma_desc_free_list()or am I getting it wrong?
Yes, it's not useful. Then you only need to fix the tx_status() and don't touch dma_desc on pause.
RE: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
Quoted 42 lines
В Mon, 31 Jan 2022 04:25:14 +0000
Akhil R <[email protected]> пишет:Quoted 39 lines
Quoted 39 lines
30.01.2022 19:34, Akhil R пишет:
Quoted 37 lines
Quoted 29 lines
29.01.2022 19:40, Akhil R пишет:
drivers/dma/tegra186-gpc-dma.c line 396
Quoted 7 lines
drivers/dma/tegra186-gpc-dma.c new file +7
-0+static int tegra_dma_device_pause (struct dma_chan *dc) { +struct tegra_dma_channel *tdc =to_tegra_dma_chan (dc); +unsigned long wcount, flags; +int ret =0 ; + +if (!tdc->tdma->chip_data->hw_support_pause) +return 0 ;It's wrong to return zero if pause unsupported, please see what
dmaengine_pause()returns.Quoted 4 lines
drivers/dma/tegra186-gpc-dma.c new file +4
-0+ +spin_lock_irqsave (&tdc->vc.lock, flags); +if (!tdc->dma_desc) + goto out;drivers/dma/tegra186-gpc-dma.c line 410
Quoted 10 lines
drivers/dma/tegra186-gpc-dma.c new file +10
-0+ + ret =tegra_dma_pause (tdc); +if (ret) { +dev_err (tdc2dev (tdc),"DMA pause timed out\n" ); + goto out; + } + + wcount =tdc_read (tdc,TEGRA_GPCDMA_CHAN_XFER_COUNT ); + tdc->dma_desc->bytes_xfer += + tdc->dma_desc->bytes_req - (wcount *4 );Why transfer is accumulated?
Quoted 1 line
Why do you need to update xfer size at all on pause?
I will verify the calculation. This looks correct only for single sg transaction.
Updating
xfer_sizeis added to support drivers which pause the transaction and read the status before terminating. Eg.
Quoted 7 lines
Quoted 4 lines
Quoted 1 line
Why you couldn't update the status in
tegra_dma_terminate_all()?Is it useful to update the status in
terminate_all()? I assume the descriptor Is freed invchan_dma_desc_free_list()or am I getting it wrong?Yes, it's not useful. Then you only need to fix the
tx_status()and don't touchdma_descon pause.
If the bytes_xfer is updated in tx_status(), I suppose DMA_RESIDUE_GRANULARITY_BURST can be kept as is, correct?
Thanks,
Akhil
Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
31.01.2022 12:09, Akhil R пишет:
Quoted 43 lines
Quoted 43 lines
В Mon, 31 Jan 2022 04:25:14 +0000
Akhil R <[email protected]> пишет:Quoted 40 lines
Quoted 40 lines
30.01.2022 19:34, Akhil R пишет:
Quoted 29 lines
Quoted 29 lines
29.01.2022 19:40, Akhil R пишет:
Review
Quoted 7 lines
(quoted diff) +7
-0+static int tegra_dma_device_pause(struct dma_chan *dc) { + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + unsigned long wcount, flags; + int ret = 0; + + if (!tdc->tdma->chip_data->hw_support_pause) + return 0;It's wrong to return zero if pause unsupported, please see what
dmaengine_pause()returns.Quoted 4 lines
(quoted diff) +4
-0+ + spin_lock_irqsave(&tdc->vc.lock, flags); + if (!tdc->dma_desc) + goto out;Review
Quoted 10 lines
(quoted diff) +10
-0+ + ret = tegra_dma_pause(tdc); + if (ret) { + dev_err(tdc2dev(tdc), "DMA pause timed out\n"); + goto out; + } + + wcount = tdc_read(tdc, TEGRA_GPCDMA_CHAN_XFER_COUNT); + tdc->dma_desc->bytes_xfer += + tdc->dma_desc->bytes_req - (wcount * 4);Why transfer is accumulated?
Quoted 8 lines
Quoted 1 line
Why do you need to update xfer size at all on pause?
I will verify the calculation. This looks correct only for single sg transaction.
Updating
xfer_sizeis added to support drivers which pause the transaction and read the status before terminating. Eg.Why you couldn't update the status in
tegra_dma_terminate_all()?
Quoted 8 lines
Quoted 6 lines
Quoted 3 lines
Is it useful to update the status in
terminate_all()? I assume the descriptor Is freed invchan_dma_desc_free_list()or am I getting it wrong?Yes, it's not useful. Then you only need to fix the
tx_status()and don't touchdma_descon pause.If the
bytes_xferis updated intx_status(), I supposeDMA_RESIDUE_GRANULARITY_BURSTcan be kept as is, correct?
You don't need to update bytes_xfer in tx_status(). Please see Tegra20 DMA driver for the example, which supports GRANULARITY_BURST properly.
RE: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
Quoted 48 lines
31.01.2022 12:09, Akhil R пишет:
Quoted 47 lines
Quoted 47 lines
В Mon, 31 Jan 2022 04:25:14 +0000
Akhil R <[email protected]> пишет:Quoted 43 lines
Quoted 32 lines
30.01.2022 19:34, Akhil R пишет:
Quoted 31 lines
Quoted 30 lines
29.01.2022 19:40, Akhil R пишет:
Review
Quoted 7 lines
(quoted diff) +7
-0+static int tegra_dma_device_pause(struct dma_chan *dc) { + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc); + unsigned long wcount, flags; + int ret = 0; + + if (!tdc->tdma->chip_data->hw_support_pause) + return 0;It's wrong to return zero if pause unsupported, please see what
dmaengine_pause()returns.Quoted 4 lines
(quoted diff) +4
-0+ + spin_lock_irqsave(&tdc->vc.lock, flags); + if (!tdc->dma_desc) + goto out;Review
Quoted 10 lines
(quoted diff) +10
-0+ + ret = tegra_dma_pause(tdc); + if (ret) { + dev_err(tdc2dev(tdc), "DMA pause timed out\n"); + goto out; + } + + wcount = tdc_read(tdc, TEGRA_GPCDMA_CHAN_XFER_COUNT); + tdc->dma_desc->bytes_xfer += + tdc->dma_desc->bytes_req - (wcount * 4);Why transfer is accumulated?
Why do you need to update xfer size at all on pause?
Quoted 8 lines
Quoted 6 lines
I will verify the calculation. This looks correct only for single sg transaction.
Updating
xfer_sizeis added to support drivers which pause the transaction and read the status before terminating. Eg.Why you couldn't update the status in
tegra_dma_terminate_all()?Is it useful to update the status in
terminate_all()? I assume the descriptor Is freed invchan_dma_desc_free_list()or am I getting it wrong?
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
Yes, it's not useful. Then you only need to fix the
tx_status()and don't touchdma_descon pause.If the
bytes_xferis updated intx_status(), I supposeDMA_RESIDUE_GRANULARITY_BURSTcan be kept as is, correct?You don't need to update
bytes_xferintx_status(). Please see Tegra20 DMA driver for the example, which supportsGRANULARITY_BURSTproperly.
Does the below method look good? bytes_xfer is updated on every ISR and in tx_status(), the wcount is read to calculate the intermittent value. If the transfer get complete in between, use wcount as 0 to add sg_req.len to bytes_xfer
static int tegra_dma_get_residual(struct tegra_dma_channel *tdc)
{
unsigned long wcount = 0, status;
unsigned int bytes_xfer, residual;
struct tegra_dma_desc *dma_desc = tdc->dma_desc;
struct tegra_dma_sg_req *sg_req = dma_desc->sg_req;
/*
* Do not read from CHAN_XFER_COUNT if EOC bit is set
* as the transfer would have already completed and
* the register could have updated for next transfer
* in case of cyclic transfers.
*/
status = tdc_read(tdc, TEGRA_GPCDMA_CHAN_STATUS);
if (!(status & TEGRA_GPCDMA_STATUS_ISE_EOC))
wcount = tdc_read(tdc, TEGRA_GPCDMA_CHAN_XFER_COUNT);
bytes_xfer = dma_desc->bytes_xfer +
sg_req[dma_desc->sg_idx - 1].len - (wcount * 4);
residual = dma_desc->bytes_req - (bytes_xfer % dma_desc->bytes_req);
return residual;
}static enum dma_status tegra_dma_tx_status( )
{
....
spin_lock_irqsave(&tdc->vc.lock, flags);
...
} else if (tdc->dma_desc && tdc->dma_desc->vd.tx.cookie == cookie) {
residual = tegra_dma_get_residual(tdc);
dma_set_residue(txstate, residual);
} else {
dev_err(tdc2dev(tdc), "cookie %d is not found\n", cookie);
}
spin_unlock_irqrestore(&tdc->vc.lock, flags);
return ret;
}Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
31.01.2022 18:38, Akhil R пишет:
Quoted 5 lines
Does the below method look good?
bytes_xferis updated on every ISR and intx_status(), the wcount is read to calculate the intermittent value. If the transfer get complete in between, use wcount as 0 to add sg_req.len tobytes_xferstatic int
tegra_dma_get_residual(struct tegra_dma_channel *tdc)
Quoted 15 lines
{
unsigned long wcount = 0, status;
unsigned int bytes_xfer, residual;
struct tegra_dma_desc *dma_desc = tdc->dma_desc;
struct tegra_dma_sg_req *sg_req = dma_desc->sg_req;
/*
* Do not read from CHAN_XFER_COUNT if EOC bit is set
* as the transfer would have already completed and
* the register could have updated for next transfer
* in case of cyclic transfers.
*/
status = tdc_read(tdc, TEGRA_GPCDMA_CHAN_STATUS);
if (!(status & TEGRA_GPCDMA_STATUS_ISE_EOC))
wcount = tdc_read(tdc, TEGRA_GPCDMA_CHAN_XFER_COUNT);You can't read WCOUNT after the STATUS without racing with the STATUS updates made by h/w. You should read the WCOUNT first and only then check the STATUS.
You should also check whether T20 tegra_dma_sg_bytes_xferred() workarounds apply to newer h/w. I see that the h/w base hasn't changed much since T20.
Otherwise looks okay.
RE: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
Quoted 23 lines
31.01.2022 18:38, Akhil R пишет:
Quoted 2 lines
Does the below method look good?
bytes_xferis updated on every ISR and intx_status(), the wcount is read to calculate the intermittent value. If thetransfer
Quoted 18 lines
get complete in between, use wcount as 0 to add sg_req.len to
bytes_xferstatic int
tegra_dma_get_residual(struct tegra_dma_channel *tdc){ unsigned long wcount = 0, status; unsigned int bytes_xfer, residual; struct tegra_dma_desc *dma_desc = tdc->dma_desc; struct tegra_dma_sg_req *sg_req = dma_desc->sg_req; /* * Do not read from CHAN_XFER_COUNT if EOC bit is set * as the transfer would have already completed and * the register could have updated for next transfer * in case of cyclic transfers. */ status = tdc_read(tdc, TEGRA_GPCDMA_CHAN_STATUS); if (!(status & TEGRA_GPCDMA_STATUS_ISE_EOC)) wcount = tdc_read(tdc, TEGRA_GPCDMA_CHAN_XFER_COUNT);
Quoted 7 lines
You can't read WCOUNT after the STATUS without racing with the STATUS updates made by h/w. You should read the WCOUNT first and only then check the STATUS.
You should also check whether T20
tegra_dma_sg_bytes_xferred()workarounds apply to newer h/w. I see that the h/w base hasn't changed much since T20.
The calculation in T20 driver is not applicable here. The register shows the actual number of words remaining to be transferred as far as I understand.
Thanks,
Akhil
Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
01.02.2022 15:05, Akhil R пишет:
Quoted 27 lines
Quoted 27 lines
31.01.2022 18:38, Akhil R пишет:
Quoted 2 lines
Does the below method look good?
bytes_xferis updated on every ISR and intx_status(), the wcount is read to calculate the intermittent value. If thetransfer
Quoted 18 lines
get complete in between, use wcount as 0 to add sg_req.len to
bytes_xferstatic int
tegra_dma_get_residual(struct tegra_dma_channel *tdc){ unsigned long wcount = 0, status; unsigned int bytes_xfer, residual; struct tegra_dma_desc *dma_desc = tdc->dma_desc; struct tegra_dma_sg_req *sg_req = dma_desc->sg_req; /* * Do not read from CHAN_XFER_COUNT if EOC bit is set * as the transfer would have already completed and * the register could have updated for next transfer * in case of cyclic transfers. */ status = tdc_read(tdc, TEGRA_GPCDMA_CHAN_STATUS); if (!(status & TEGRA_GPCDMA_STATUS_ISE_EOC)) wcount = tdc_read(tdc, TEGRA_GPCDMA_CHAN_XFER_COUNT);You can't read WCOUNT after the STATUS without racing with the STATUS updates made by h/w. You should read the WCOUNT first and only then check the STATUS.
Quoted 5 lines
Quoted 3 lines
You should also check whether T20
tegra_dma_sg_bytes_xferred()workarounds apply to newer h/w. I see that the h/w base hasn't changed much since T20.The calculation in T20 driver is not applicable here. The register shows the actual number of words remaining to be transferred as far as I understand.
If downstream kernel DMA driver doesn't have any special quirks, then likely that they are indeed unneeded.
Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
In reply to Akhil R29.01.2022 19:40, Akhil R пишет:
drivers/dma/tegra186-gpc-dma.c line 1229
Quoted 3 lines
drivers/dma/tegra186-gpc-dma.c new file +3
-0+static void tegra_dma_chan_synchronize (struct dma_chan *dc) +{ +struct tegra_dma_channel *tdc =to_tegra_dma_chan (dc);
synchronize_irq(tdc->irq);
Quoted 2 lines
drivers/dma/tegra186-gpc-dma.c new file +2
-0+vchan_synchronize (&tdc->vc); +}
Re: [PATCH v17 2/4] dmaengine: tegra: Add tegra gpcdma driver
In reply to Akhil R29.01.2022 19:40, Akhil R пишет:
drivers/dma/tegra186-gpc-dma.c line 1240
Quoted 7 lines
drivers/dma/tegra186-gpc-dma.c new file +7
-0+static void tegra_dma_free_chan_resources (struct dma_chan *dc) +{ +struct tegra_dma_channel *tdc =to_tegra_dma_chan (dc); + +dev_dbg (tdc2dev (tdc),"Freeing channel %d\n" , tdc->id); + +tegra_dma_terminate_all (dc);
synchronize_irq(tdc->irq);
Quoted 1 line
drivers/dma/tegra186-gpc-dma.c new file +1
-0+tasklet_kill (&tdc->vc.task);
PATCH v17 3/4 arm64: defconfig: tegra: Enable GPCDMA
In reply to Akhil REnable TEGRA_GPC_DMA in defconfig for Tegra186 and Tegra196 gpc dma controller driver
--- arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm64/configs/defconfig +1 -0
@@ -956,6 +956,7 @@ CONFIG_MV_XOR=y CONFIG_MV_XOR_V2=y CONFIG_OWL_DMA=y CONFIG_PL330_DMA=y +CONFIG_TEGRA186_GPC_DMA=m CONFIG_TEGRA20_APB_DMA=y CONFIG_TEGRA210_ADMA=m CONFIG_QCOM_BAM_DMA=y
Signature · 1 line
2.7.4
PATCH v17 4/4 arm64: tegra: Add GPCDMA node for tegra186 and tegra194
In reply to Akhil RAdd device tree node for GPCDMA controller on Tegra186 target and Tegra194 target.
--- arch/arm64/boot/dts/nvidia/tegra186.dtsi | 42 +++++++++++++++++++++++++++++++ arch/arm64/boot/dts/nvidia/tegra194.dtsi | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 85 insertions(+)
arch/arm64/boot/dts/nvidia/tegra186.dtsi +42 -0
@@ -73,6 +73,48 @@ snps,rxpbl = <8>; }; + dma-controller@2600000 { + compatible = "nvidia,tegra186-gpcdma"; + reg = <0x0 0x2600000 0x0 0x210000>; + resets = <&bpmp TEGRA186_RESET_GPCDMA>; + reset-names = "gpcdma"; + interrupts = <GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 77 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 78 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 79 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 80 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 81 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 82 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 83 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 84 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 86 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 87 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 88 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 89 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 90 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 91 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 92 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 93 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 94 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 95 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 96 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 97 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 98 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 99 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 100 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 101 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 102 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 103 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 104 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 105 IRQ_TYPE_LEVEL_HIGH>, + <GIC_SPI 106 IRQ_TYPE_LEVEL_HIGH>; + #dma-cells = <1>; + iommus = <&smmu TEGRA186_SID_GPCDMA_0>; + dma-coherent; + status = "okay"; + }; + aconnect@2900000 { compatible = "nvidia,tegra186-aconnect", "nvidia,tegra210-aconnect";
arch/arm64/boot/dts/nvidia/tegra194.dtsi +43 -0
49 lines not on this page · raw message
Signature · 1 line
2.7.4