Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp1254304rwb; Fri, 13 Jan 2023 09:44:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXuVzF17TpH8kSnEeytkpXcKOUmS7kZJ8qX/z++NggdefP0cUQ4mY4A4xEZddJ0o4aNA2leJ X-Received: by 2002:a17:903:124d:b0:192:fdd3:af5e with SMTP id u13-20020a170903124d00b00192fdd3af5emr41667958plh.48.1673631896573; Fri, 13 Jan 2023 09:44:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1673631896; cv=none; d=google.com; s=arc-20160816; b=Zv53mRSlC9M4KtslIu/E7JM3/gRUt81zY/dZzomlVp+nJQ1xikK5R0w3uFB46BKO5B m/33/zKxvXzFjKx5SQSC9SvnXk9jMh0dta4y9BSvhLJyGNaSTYg3BjpXeHIUj4kMefGC UWNl1+/RWrrlWlyM/Hx7TakyLNKp8goHL4ESQFDTh9HrIKGZnKpbLli4FpJogbbkwrJf YKZfBmozSs56bhunr5s0E/d3diHvvQZjNTvC2My3qFjYXpqp0EhpM6ZOHz9UOeXmCZd6 jvtYQxHqF/0CrUrrdp/Q+hEmTAevy33bfpov1Fa9J7YROV93mAgiuN3xLyK4+QqHJxpn BNUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9IAs5jR80/jb1e5odF+JbFjtXhnvVuaONmeUDKQO+u4=; b=HRu4LWHo96czKTJDoCgMC2aKYe4bzCrLOIIZf17ZsPKOpzttZv8/3MEQMdAo0HE/Uo HcIcbiM3l7AM4kEHE20dQDP24snq4/RcC0i0dHQjxsiWBTKvbEgyNe1YU3DR4mMgQpqG T5bXpo6EWdCxLw4uVkQUvoYtlq1Bj+woy9mX3hopre1Hf7MXnHdwqKqywR6rRjGLquS5 rjFtwCYKumWBAcUpnD4t938B002MkoVMtuhIW+zx+t/oTCicYTTAAIiqLcTY7FnQg+jc JgLgc1200zrZPaa5CMIoRuUYt9xOcCHiTktOnJosgL3WQlDfv0171HEb8XM8QfkvHFEG 5rtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=post header.b=Vt6oH94C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id t191-20020a6381c8000000b004b2889d675dsi16204277pgd.660.2023.01.13.09.44.50; Fri, 13 Jan 2023 09:44:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=post header.b=Vt6oH94C; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=baikalelectronics.ru Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229493AbjAMRY6 (ORCPT + 53 others); Fri, 13 Jan 2023 12:24:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33626 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbjAMRW7 (ORCPT ); Fri, 13 Jan 2023 12:22:59 -0500 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 5A518A1835; Fri, 13 Jan 2023 09:14:26 -0800 (PST) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id 7ECA5E0F20; Fri, 13 Jan 2023 20:14:22 +0300 (MSK) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= baikalelectronics.ru; h=cc:cc:content-transfer-encoding :content-type:content-type:date:from:from:in-reply-to:message-id :mime-version:references:reply-to:subject:subject:to:to; s=post; bh=9IAs5jR80/jb1e5odF+JbFjtXhnvVuaONmeUDKQO+u4=; b=Vt6oH94CQ9RA ZUWJhYGr6vpZT+7T5IpilMqvZY4ym6BMut7QXb1x84/Lq5IeT6VNXWUcsoUjCX0+ pT8MLzqGF8ULiGPLCu87diJifZVx/2YML6LGamC62yh9f3MyJn1qeAa0uGO1BffO f0BCmKWLRLojrJuXpsaP9AKAEAfp8V0= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id 655C1E0F13; Fri, 13 Jan 2023 20:14:22 +0300 (MSK) Received: from localhost (10.8.30.26) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Fri, 13 Jan 2023 20:14:22 +0300 From: Serge Semin To: Gustavo Pimentel , Vinod Koul , Rob Herring , Bjorn Helgaas , Lorenzo Pieralisi , Cai Huoqing , Robin Murphy , Jingoo Han , Frank Li , Manivannan Sadhasivam CC: Serge Semin , Serge Semin , Alexey Malahov , Pavel Parkhomenko , =?UTF-8?q?Krzysztof=20Wilczy=C5=84ski?= , caihuoqing , Yoshihiro Shimoda , , , , Gustavo Pimentel Subject: [PATCH v9 05/27] dmaengine: dw-edma: Don't permit non-inc interleaved xfers Date: Fri, 13 Jan 2023 20:13:47 +0300 Message-ID: <20230113171409.30470-6-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230113171409.30470-1-Sergey.Semin@baikalelectronics.ru> References: <20230113171409.30470-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.8.30.26] X-ClientProxiedBy: MAIL.baikal.int (192.168.51.25) To mail (192.168.51.25) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org DW eDMA controller always increments both source and destination addresses. Permitting DMA interleaved transfers with no src_inc/dst_inc flags set may lead to unexpected behaviour for the device users. Let's fix that by terminating the interleaved transfers if at least one of the dma_interleaved_template.{src_inc,dst_inc} flag is initialized with false value. Note in addition to that we need to increase the source and destination addresses accordingly after each iteration. Fixes: 85e7518f42c8 ("dmaengine: dw-edma: Add device_prep_interleave_dma() support") Signed-off-by: Serge Semin Reviewed-by: Manivannan Sadhasivam Tested-by: Manivannan Sadhasivam Acked-by: Vinod Koul --- drivers/dma/dw-edma/dw-edma-core.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c index 778d91d9fc1b..35588e14f79a 100644 --- a/drivers/dma/dw-edma/dw-edma-core.c +++ b/drivers/dma/dw-edma/dw-edma-core.c @@ -385,6 +385,8 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer) return NULL; if (xfer->xfer.il->numf > 0 && xfer->xfer.il->frame_size > 0) return NULL; + if (!xfer->xfer.il->src_inc || !xfer->xfer.il->dst_inc) + return NULL; } else { return NULL; } @@ -484,15 +486,13 @@ dw_edma_device_transfer(struct dw_edma_transfer *xfer) struct dma_interleaved_template *il = xfer->xfer.il; struct data_chunk *dc = &il->sgl[i]; - if (il->src_sgl) { - src_addr += burst->sz; + src_addr += burst->sz; + if (il->src_sgl) src_addr += dmaengine_get_src_icg(il, dc); - } - if (il->dst_sgl) { - dst_addr += burst->sz; + dst_addr += burst->sz; + if (il->dst_sgl) dst_addr += dmaengine_get_dst_icg(il, dc); - } } } -- 2.39.0