Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2707650rwj; Mon, 19 Dec 2022 07:57:16 -0800 (PST) X-Google-Smtp-Source: AA0mqf43kyogdT7zBkAe4DvGO800oWP8vqbT7T5CeebI5SO0hiFnq+4bvvLjTScxYdBb0IpeA9cd X-Received: by 2002:a05:6a20:ce48:b0:a4:255b:f3b3 with SMTP id id8-20020a056a20ce4800b000a4255bf3b3mr50404101pzb.33.1671465435835; Mon, 19 Dec 2022 07:57:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671465435; cv=none; d=google.com; s=arc-20160816; b=B0bRMVyW4ztLV9AVtgM+tELWsiM1XdsKIzG1rIP+E3T1ycDuww9PrRraNS8FjIrn8v wvz/+2JMqhDgf1pSxiiWca1SNrahCTgqA6p7mR6j9JcAVKZ4d0hH6KdMlWGfdMZ82OZq Do6np7IkkoR0PbizWbsmp8GIy7K97mHOaeAtykaqjPg+b5VvRJNpQnBUHLFCijkwPxFe 9y9z62NFaAaTPmBO//35uWclkHBo5Lyc4Qpl+tdIlKxldftJUnkPrfYZaNm72QYqGYw8 +p1vWm+9cl3Ca2p53eliT+z1SmctzFK4/UgoG2Hd8iog6lg9RSpBXKqHgShlWBaSJ9jf 6Vcw== 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=gYdMxZn2yY/ZFty76XnTLyEMybFVqqclJyPRlZ3yZ5g=; b=xl72MKWo9Dye8ccjS+Su2u/o5ZnlPIsMPB6GMmiJYxaFDo7TOjUTbydBudWSwqd+7p gKLyzJPmexaGlfmg3nIQ+CGgnhm7RLwPCFpjVXqmFYPJkBlJiS5JickNxtBC+nmAOxeT I7HCtu2/UCnvsZ8xF06qJ+4/YnXtTZOydQyBaNA/iFsgRZQrRk23wYatYmOc5D7Z1ViY AlIhbVfISR1fCb8shDHTmzHDCRu3Udq8GYGvmBeseBZAf9Vbdt9fc9tsrkhr9VxYhNzn 8KVFRaDV0IRHTGdfP7Ba6uD4kWG+D8wOUNhKkmaKVNvi0APTZ7qrJN0aXHFcInVG9OdW iiKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baikalelectronics.ru header.s=post header.b=Jqk5NOUN; 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 r23-20020a63d917000000b00479433ac8aasi10660664pgg.260.2022.12.19.07.57.06; Mon, 19 Dec 2022 07:57:15 -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=Jqk5NOUN; 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 S232361AbiLSOsN (ORCPT + 71 others); Mon, 19 Dec 2022 09:48:13 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231896AbiLSOrT (ORCPT ); Mon, 19 Dec 2022 09:47:19 -0500 Received: from post.baikalelectronics.com (post.baikalelectronics.com [213.79.110.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 937F9DF05; Mon, 19 Dec 2022 06:47:07 -0800 (PST) Received: from post.baikalelectronics.com (localhost.localdomain [127.0.0.1]) by post.baikalelectronics.com (Proxmox) with ESMTP id CD802E0EB3; Mon, 19 Dec 2022 17:47:04 +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=gYdMxZn2yY/ZFty76XnTLyEMybFVqqclJyPRlZ3yZ5g=; b=Jqk5NOUNx0U5 IWJ1K++ZAzNILjmMMDqksqM74iWzdyy1vBhzU9RffphJZXG1gpaxOohrx4ZblFtH 7uKCorD1eqqzj+Rf/k5Wz/7LdXnu4qkD2haqd8kNnKXwYQvT4AfC3OOwzzz9yTay XL+afq4It805KEWer/3Pi4j2fmaP57I= Received: from mail.baikal.int (mail.baikal.int [192.168.51.25]) by post.baikalelectronics.com (Proxmox) with ESMTP id C2FAFE0E70; Mon, 19 Dec 2022 17:47:04 +0300 (MSK) Received: from localhost (10.8.30.14) by mail (192.168.51.25) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Mon, 19 Dec 2022 17:47:04 +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 v8 05/26] dmaengine: dw-edma: Don't permit non-inc interleaved xfers Date: Mon, 19 Dec 2022 17:46:36 +0300 Message-ID: <20221219144658.26620-6-Sergey.Semin@baikalelectronics.ru> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221219144658.26620-1-Sergey.Semin@baikalelectronics.ru> References: <20221219144658.26620-1-Sergey.Semin@baikalelectronics.ru> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.8.30.14] 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.38.1